{"version":3,"sources":["../../src/open-api/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { z } from \"zod\";\n\nexport const acceptsRequestBody = (method: string) => {\n\tif (method === \"GET\" || method === \"DELETE\") {\n\t\treturn false;\n\t}\n\treturn true;\n};\n\nexport const normalizePath = (path: string) => {\n\treturn `/${path.replace(/^\\/|\\/$/g, \"\")}`;\n};\n\nexport const getPathParameters = (path: string) => {\n\treturn Array.from(path.matchAll(/\\{(.+?)\\}/g)).map(([_, key]) => key!);\n};\n\nexport const preparePathForMatching = (path: string) => {\n\treturn path.replace(/\\{/g, \":\").replace(/\\}/g, \"\");\n};\n\nexport const getPathRegExp = (path: string) => {\n\tconst groupedExp = path.replace(/\\{(.+?)\\}/g, (_, key: string) => `(?<${key}>[^/]+)`);\n\treturn new RegExp(`^${groupedExp}$`, \"i\");\n};\n\nconst FORM_DATA_CONTENT_TYPE = \"application/x-www-form-urlencoded\";\nconst MULTI_PART_CONTENT_TYPE = \"multipart/form-data\";\nconst JSON_CONTENT_TYPE = \"application/json\";\nconst TEXT_PLAIN = \"text/plain\";\n\nexport type OpenApiContentType =\n\t| typeof FORM_DATA_CONTENT_TYPE\n\t| typeof JSON_CONTENT_TYPE\n\t| typeof MULTI_PART_CONTENT_TYPE\n\t| typeof TEXT_PLAIN\n\t| (string & {});\n\nexport const instanceofZodTypeObject = (type: z.ZodTypeAny): type is z.ZodObject<z.ZodRawShape> => {\n\treturn instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodObject);\n};\n\nexport const instanceofZodTypeKind = <Z extends z.ZodFirstPartyTypeKind>(\n\ttype: z.ZodTypeAny,\n\tzodTypeKind: Z\n): type is InstanceType<(typeof z)[Z]> => {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\treturn type?._def?.typeName === zodTypeKind;\n};\n\nexport const unwrapZodType = (type: z.ZodTypeAny, unwrapPreprocess: boolean): z.ZodTypeAny => {\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodOptional)) {\n\t\treturn unwrapZodType(type.unwrap(), unwrapPreprocess);\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodDefault)) {\n\t\treturn unwrapZodType(type.removeDefault(), unwrapPreprocess);\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodLazy)) {\n\t\treturn unwrapZodType(type._def.getter(), unwrapPreprocess);\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodEffects)) {\n\t\tif (type._def.effect.type === \"refinement\") {\n\t\t\treturn unwrapZodType(type._def.schema, unwrapPreprocess);\n\t\t}\n\t\tif (type._def.effect.type === \"transform\") {\n\t\t\treturn unwrapZodType(type._def.schema, unwrapPreprocess);\n\t\t}\n\t\tif (unwrapPreprocess && type._def.effect.type === \"preprocess\") {\n\t\t\treturn unwrapZodType(type._def.schema, unwrapPreprocess);\n\t\t}\n\t}\n\n\treturn type;\n};\n\nexport type ZodTypeLikeVoid = z.ZodVoid | z.ZodUndefined | z.ZodNever;\n\nexport const instanceofZodTypeLikeVoid = (type: z.ZodTypeAny): type is ZodTypeLikeVoid => {\n\treturn (\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodVoid) ||\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodUndefined) ||\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodNever)\n\t);\n};\n\ntype NativeEnumType = {\n\t[k: string]: string | number;\n\t[nu: number]: string;\n};\n\nexport type ZodTypeLikeString =\n\t| z.ZodString\n\t| z.ZodOptional<ZodTypeLikeString>\n\t| z.ZodDefault<ZodTypeLikeString>\n\t| z.ZodEffects<ZodTypeLikeString, unknown, unknown>\n\t| z.ZodUnion<[ZodTypeLikeString, ...ZodTypeLikeString[]]>\n\t| z.ZodIntersection<ZodTypeLikeString, ZodTypeLikeString>\n\t| z.ZodLazy<ZodTypeLikeString>\n\t| z.ZodLiteral<string>\n\t| z.ZodEnum<[string, ...string[]]>\n\t| z.ZodNativeEnum<NativeEnumType>;\n\nexport const instanceofZodTypeLikeString = (_type: z.ZodTypeAny): _type is ZodTypeLikeString => {\n\tconst type = unwrapZodType(_type, false);\n\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodEffects)) {\n\t\tif (type._def.effect.type === \"preprocess\") {\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodUnion)) {\n\t\treturn !type._def.options.some((option) => !instanceofZodTypeLikeString(option));\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodIntersection)) {\n\t\treturn instanceofZodTypeLikeString(type._def.left) && instanceofZodTypeLikeString(type._def.right);\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodLiteral)) {\n\t\treturn typeof type._def.value === \"string\";\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodEnum)) {\n\t\treturn true;\n\t}\n\tif (instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodNativeEnum)) {\n\t\treturn !Object.values(type._def.values).some((value) => typeof value === \"number\");\n\t}\n\treturn instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodString);\n};\n\nexport const zodSupportsCoerce = \"coerce\" in z;\n\nexport type ZodTypeCoercible = z.ZodNumber | z.ZodBoolean | z.ZodBigInt | z.ZodDate;\n\nexport const instanceofZodTypeCoercible = (_type: z.ZodTypeAny): _type is ZodTypeCoercible => {\n\tconst type = unwrapZodType(_type, false);\n\treturn (\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodNumber) ||\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodBoolean) ||\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodBigInt) ||\n\t\tinstanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodDate)\n\t);\n};\n\nexport const instanceofZodTypeOptional = (type: z.ZodTypeAny): type is z.ZodOptional<z.ZodTypeAny> => {\n\treturn instanceofZodTypeKind(type, z.ZodFirstPartyTypeKind.ZodOptional);\n};\n"],"mappings":";AACA,SAAS,SAAS;AAEX,IAAM,qBAAqB,CAAC,WAAmB;AACrD,MAAI,WAAW,SAAS,WAAW,UAAU;AAC5C,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEO,IAAM,gBAAgB,CAAC,SAAiB;AAC9C,SAAO,IAAI,KAAK,QAAQ,YAAY,EAAE,CAAC;AACxC;AAEO,IAAM,oBAAoB,CAAC,SAAiB;AAClD,SAAO,MAAM,KAAK,KAAK,SAAS,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,GAAG,MAAM,GAAI;AACtE;AAEO,IAAM,yBAAyB,CAAC,SAAiB;AACvD,SAAO,KAAK,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE;AAClD;AAEO,IAAM,gBAAgB,CAAC,SAAiB;AAC9C,QAAM,aAAa,KAAK,QAAQ,cAAc,CAAC,GAAG,QAAgB,MAAM,GAAG,SAAS;AACpF,SAAO,IAAI,OAAO,IAAI,UAAU,KAAK,GAAG;AACzC;AAcO,IAAM,0BAA0B,CAAC,SAA2D;AAClG,SAAO,sBAAsB,MAAM,EAAE,sBAAsB,SAAS;AACrE;AAEO,IAAM,wBAAwB,CACpC,MACA,gBACyC;AAEzC,SAAO,MAAM,MAAM,aAAa;AACjC;AAEO,IAAM,gBAAgB,CAAC,MAAoB,qBAA4C;AAC7F,MAAI,sBAAsB,MAAM,EAAE,sBAAsB,WAAW,GAAG;AACrE,WAAO,cAAc,KAAK,OAAO,GAAG,gBAAgB;AAAA,EACrD;AACA,MAAI,sBAAsB,MAAM,EAAE,sBAAsB,UAAU,GAAG;AACpE,WAAO,cAAc,KAAK,cAAc,GAAG,gBAAgB;AAAA,EAC5D;AACA,MAAI,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