@visulima/api-platform 1.2.12 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/bin/index.js +6 -8
- package/dist/{chunk-5B2CCUEK.js → chunk-3GKT5H3V.js} +2 -2
- package/dist/chunk-3GKT5H3V.js.map +1 -0
- package/dist/{chunk-OUWZ2PU5.js → chunk-4D6JZ4TL.js} +1 -1
- package/dist/chunk-AB7BFRZY.mjs +9 -0
- package/dist/chunk-AB7BFRZY.mjs.map +1 -0
- package/dist/chunk-ADVXXSKJ.js +24 -0
- package/dist/chunk-ADVXXSKJ.js.map +1 -0
- package/dist/chunk-EMJS7XMY.mjs +13 -0
- package/dist/chunk-EMJS7XMY.mjs.map +1 -0
- package/dist/chunk-HNWSVLC3.mjs +17 -0
- package/dist/chunk-HNWSVLC3.mjs.map +1 -0
- package/dist/{chunk-2BDDP26Z.mjs → chunk-IGJDNXIE.mjs} +2 -2
- package/dist/chunk-IGJDNXIE.mjs.map +1 -0
- package/dist/chunk-M5CDBLRM.js +25 -0
- package/dist/chunk-M5CDBLRM.js.map +1 -0
- package/dist/chunk-WYXGSYH5.js +13 -0
- package/dist/chunk-WYXGSYH5.js.map +1 -0
- package/dist/{chunk-YOXCJZNX.mjs → chunk-XIJ2ZQRX.mjs} +1 -1
- package/dist/framework/cli/commander/index.d.mts +5 -0
- package/dist/framework/cli/commander/index.js +3 -3
- package/dist/framework/cli/commander/index.js.map +1 -1
- package/dist/framework/cli/commander/index.mjs +3 -3
- package/dist/framework/cli/commander/index.mjs.map +1 -1
- package/dist/framework/cli/index.d.mts +11 -0
- package/dist/framework/cli/index.d.ts +4 -4
- package/dist/framework/cli/index.js +3 -3
- package/dist/framework/cli/index.mjs +2 -2
- package/dist/framework/next/index-browser.d.mts +5 -0
- package/dist/framework/next/index-browser.js +3 -3
- package/dist/framework/next/index-browser.mjs +2 -2
- package/dist/framework/next/index-server.d.mts +20 -0
- package/dist/framework/next/index-server.d.ts +5 -5
- package/dist/framework/next/index-server.js +11 -11
- package/dist/framework/next/index-server.js.map +1 -1
- package/dist/framework/next/index-server.mjs +7 -7
- package/dist/framework/next/index-server.mjs.map +1 -1
- package/dist/framework/next/routes/pages/redoc/index.d.mts +8 -0
- package/dist/framework/next/routes/pages/redoc/index.d.ts +3 -2
- package/dist/framework/next/routes/pages/redoc/index.js +4 -4
- package/dist/framework/next/routes/pages/redoc/index.js.map +1 -1
- package/dist/framework/next/routes/pages/redoc/index.mjs +4 -4
- package/dist/framework/next/routes/pages/redoc/index.mjs.map +1 -1
- package/dist/framework/next/routes/pages/swagger/index.d.mts +7 -0
- package/dist/framework/next/routes/pages/swagger/index.js +7 -7
- package/dist/framework/next/routes/pages/swagger/index.js.map +1 -1
- package/dist/framework/next/routes/pages/swagger/index.mjs +5 -5
- package/dist/framework/next/routes/pages/swagger/index.mjs.map +1 -1
- package/dist/index-browser.d.mts +2 -0
- package/dist/index-browser.d.ts +1 -1
- package/dist/index-browser.js +3 -3
- package/dist/index-browser.mjs +2 -2
- package/dist/index-server.d.mts +84 -0
- package/dist/index-server.d.ts +12 -14
- package/dist/index-server.js +87 -87
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +10 -10
- package/dist/index-server.mjs.map +1 -1
- package/dist/{swagger-handler-8947e0f1.d.ts → swagger-handler-47360cd1.d.ts} +4 -6
- package/package.json +66 -58
- package/dist/chunk-2BDDP26Z.mjs.map +0 -1
- package/dist/chunk-5B2CCUEK.js.map +0 -1
- package/dist/chunk-EP2A5R2C.js +0 -13
- package/dist/chunk-EP2A5R2C.js.map +0 -1
- package/dist/chunk-JC55W6OX.js +0 -25
- package/dist/chunk-JC55W6OX.js.map +0 -1
- package/dist/chunk-MAUWX6TE.mjs +0 -13
- package/dist/chunk-MAUWX6TE.mjs.map +0 -1
- package/dist/chunk-RK2WQGNS.js +0 -24
- package/dist/chunk-RK2WQGNS.js.map +0 -1
- package/dist/chunk-S2NV4N4L.mjs +0 -17
- package/dist/chunk-S2NV4N4L.mjs.map +0 -1
- package/dist/chunk-WJDS32PO.mjs +0 -9
- package/dist/chunk-WJDS32PO.mjs.map +0 -1
- package/dist/{chunk-OUWZ2PU5.js.map → chunk-4D6JZ4TL.js.map} +0 -0
- package/dist/{chunk-YOXCJZNX.mjs.map → chunk-XIJ2ZQRX.mjs.map} +0 -0
- package/dist/{index-browser-bd61921e.d.ts → index-browser-48644724.d.ts} +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/serializers/transformer/yaml.ts","../src/swagger/api/swagger-handler.ts","../src/swagger/extend-swagger-spec.ts","../src/utils.ts"],"names":["stringify","yamlTransformer","data","yaml_default","modelsToOpenApi","debug","merge","existsSync","readFileSync","path","xml","urlParse","toHeaderCase","string_","c","jsonMediaType","prepareStatusContent","methodSpec","status","mediaType","extendComponentSchemas","spec","schemaName","schema","extendResponseSchema","schemaIsArray","extendSwaggerWithMediaTypeSchema","responseSpec","allowedMediaTypes","pathKey","example","examples","mediaName","contentSpec","allowed","extendSwaggerWithMediaTypeExample","transformers","transformed","regex","transformer","extendComponentExamples","exampleName","prepareResponseExamples","transformedExamples","extendSwaggerWithMediaTypeExamples","examplesName","extendSwaggerSpec","value","pathSpec","swaggerCrudDebug","swaggerHandler","options","crud","specs","swaggerFilePath","request","response","swaggerPath","fileContents","crudSwagger","modelsOpenApi","error","swagger_handler_default"],"mappings":"AAAA,OAAS,aAAAA,MAAiB,OAI1B,IAAMC,EAA+BC,GAASF,EAAUE,EAAM,CAAE,OAAQ,CAAE,CAAC,EAEpEC,EAAQF,ECJf,OAAS,mBAAAG,MAAuB,iBAChC,OAAOC,MAAW,QAElB,OAAOC,MAAW,eAClB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,KAEzC,OAAOC,MAAU,OCPjB,OAAOC,MAAS,UAEhB,OAAS,aAAAV,MAAiB,OCF1B,OAAS,SAASW,MAAgB,MAsC3B,IAAMC,E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,GACnBA,EAAM,QAASN,GAAU,CACrB1B,EAAOf,EAAMe,EAAMyB,EAAkBC,EAAOnB,CAAiB,CAAC,CAClE,CAAC,EAGL,IAAI1B,EAEA,OAAOqD,EAAQ,QAAQ,QAAW,UAAY,WAAW,KAAKA,EAAQ,QAAQ,MAAM,GACpFC,EAAS,UAAU,eAAgBD,EAAQ,QAAQ,MAAM,EAEzDrD,EAAOC,EAAgBkB,CAAI,IAE3BmC,EAAS,UAAU,eAAgB,kBAAkB,EAErDtD,EAAO,KAAK,UAAUmB,EAAM,KAAM,CAAC,GAGvCmC,EAAS,WAAa,IACtBA,EAAS,IAAItD,CAAI,CACrB,CACJ,EAaO4D,GAAQZ","sourcesContent":["import { stringify } from \"yaml\";\n\nimport type { Serializer } from \"../types\";\n\nconst yamlTransformer: Serializer = (data) => stringify(data, { indent: 2 });\n\nexport default yamlTransformer;\n","import type { ModelsToOpenApiParameters, SwaggerModelsConfig } from \"@visulima/crud\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { modelsToOpenApi } from \"@visulima/crud\";\nimport debug from \"debug\";\n// eslint-disable-next-line no-restricted-imports\nimport merge from \"lodash.merge\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport path from \"node:path\";\nimport type { OpenAPIV3 } from \"openapi-types\";\n\nimport yamlTransformer from \"../../serializers/transformer/yaml\";\nimport extendSwaggerSpec from \"../extend-swagger-spec\";\n\nconst swaggerCrudDebug = debug(\"visulima:api-platform:swagger:crud:get-static-properties-swagger\");\n\nconst swaggerHandler = <M extends string, PrismaClient>(\n // eslint-disable-next-line no-use-before-define\n options: Partial<SwaggerHandlerOptions<M, PrismaClient>> = {},\n): ((request: IncomingMessage, response: ServerResponse) => Promise<void>) => {\n const {\n allowedMediaTypes = {\n \"application/json\": true,\n },\n crud,\n specs,\n swaggerFilePath,\n } = options;\n\n return async <Request extends IncomingMessage, Response extends ServerResponse>(request: Request, response: Response) => {\n const swaggerPath = path.join(process.cwd(), swaggerFilePath ?? \"swagger/swagger.json\");\n\n if (!existsSync(swaggerPath)) {\n throw new Error(`Swagger file not found at \"${swaggerPath}\".`);\n }\n\n const fileContents = readFileSync(swaggerPath, \"utf8\");\n\n let spec = extendSwaggerSpec(JSON.parse(fileContents) as OpenAPIV3.Document, allowedMediaTypes) as OpenAPIV3.Document;\n let crudSwagger: Partial<OpenAPIV3.Document> = {};\n\n if (crud !== undefined) {\n try {\n const modelsOpenApi = await modelsToOpenApi(crud);\n\n crudSwagger = {\n components: { examples: modelsOpenApi.examples, schemas: modelsOpenApi.schemas },\n paths: modelsOpenApi.paths,\n tags: modelsOpenApi.tags,\n };\n\n crudSwagger = extendSwaggerSpec(crudSwagger, allowedMediaTypes);\n\n swaggerCrudDebug(JSON.stringify(crudSwagger, null, 2));\n\n spec = merge(spec, crudSwagger);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(error);\n\n throw new Error(\"Please install @visulima/crud to use the crud swagger generator.\");\n }\n }\n\n if (Array.isArray(specs)) {\n specs.forEach((value) => {\n spec = merge(spec, extendSwaggerSpec(value, allowedMediaTypes));\n });\n }\n\n let data: Buffer | Uint8Array | string;\n\n if (typeof request.headers.accept === \"string\" && /yaml|yml/.test(request.headers.accept)) {\n response.setHeader(\"Content-Type\", request.headers.accept);\n\n data = yamlTransformer(spec);\n } else {\n response.setHeader(\"Content-Type\", \"application/json\");\n\n data = JSON.stringify(spec, null, 2);\n }\n\n response.statusCode = 200;\n response.end(data);\n };\n};\n\nexport interface SwaggerHandlerOptions<M extends string, PrismaClient> {\n allowedMediaTypes: Record<string, boolean>;\n crud: Exclude<ModelsToOpenApiParameters<M, PrismaClient>, \"swagger\"> & {\n swagger?: {\n models?: SwaggerModelsConfig<M>;\n };\n };\n specs?: Partial<OpenAPIV3.Document>[];\n swaggerFilePath: string;\n}\n\nexport default swaggerHandler;\n","import type { XmlElement } from \"jstoxml\";\nimport xml from \"jstoxml\";\nimport type { OpenAPIV3 } from \"openapi-types\";\nimport { stringify } from \"yaml\";\n\nimport { toHeaderCase } from \"../utils\";\n\ntype Transformers = { regex: RegExp; transformer: (data: any) => string }[];\n\nconst jsonMediaType = \"application/json\";\n\nconst prepareStatusContent = (methodSpec: OpenAPIV3.OperationObject, status: string, mediaType: string) => {\n if (((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content === undefined) {\n // eslint-disable-next-line no-param-reassign\n ((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content = {};\n }\n\n if (((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content?.[mediaType] === undefined) {\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n (((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] = {} as OpenAPIV3.MediaTypeObject;\n }\n};\n\nconst extendComponentSchemas = (spec: Partial<OpenAPIV3.Document>, schemaName: string, schema: OpenAPIV3.SchemaObject) => {\n if (typeof spec.components !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components = {};\n }\n\n if (typeof spec.components.schemas !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.schemas = {};\n }\n\n if (spec.components.schemas[schemaName] === undefined) {\n // eslint-disable-next-line no-param-reassign\n spec.components.schemas[schemaName] = schema;\n }\n};\n\nconst extendResponseSchema = (methodSpec: OpenAPIV3.OperationObject, status: string, mediaType: string, schemaName: string, schemaIsArray: boolean) => {\n prepareStatusContent(methodSpec, status, mediaType);\n\n if (((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content?.[mediaType]?.schema === undefined) {\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).schema =\n {} as OpenAPIV3.SchemaObject;\n }\n\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).schema =\n schemaIsArray\n ? {\n items: {\n $ref: `#/components/schemas/${schemaName}`,\n },\n type: \"array\",\n }\n : {\n $ref: `#/components/schemas/${schemaName}`,\n };\n};\n\nconst extendSwaggerWithMediaTypeSchema = (\n methodSpec: OpenAPIV3.OperationObject,\n responseSpec: OpenAPIV3.ResponseObject,\n allowedMediaTypes: Record<string, boolean> | undefined,\n pathKey: string,\n spec: Partial<OpenAPIV3.Document>,\n status: string,\n): {\n example?: any;\n examples?: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject>;\n} => {\n let example: any | undefined;\n let examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n Object.entries(responseSpec.content as object).forEach(([mediaName, contentSpec]) => {\n if (typeof contentSpec.schema === \"object\") {\n const { schema } = contentSpec;\n\n if (mediaName === jsonMediaType && contentSpec.examples !== undefined) {\n examples = contentSpec.examples;\n } else if (mediaName === jsonMediaType && contentSpec.example !== undefined) {\n example = contentSpec.example;\n }\n\n const schemaIsArray = (schema as OpenAPIV3.SchemaObject).type === \"array\";\n\n Object.entries(allowedMediaTypes ?? {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n let schemaName: string;\n\n if (schema?.$ref === undefined) {\n schemaName = `${toHeaderCase(pathKey.trim().replace(\"/\", \"\"))}${mediaType === \"application/ld+json\" ? \".jsonld\" : \"\"}`;\n\n extendComponentSchemas(spec as OpenAPIV3.Document, schemaName, schema as OpenAPIV3.SchemaObject);\n } else {\n schemaName = (schema as OpenAPIV3.ReferenceObject).$ref.replace(\"#/components/schemas/\", \"\");\n }\n\n extendResponseSchema(methodSpec, status, mediaType, schemaName, schemaIsArray);\n });\n }\n });\n\n return { example, examples };\n};\n\nconst extendSwaggerWithMediaTypeExample = (\n methodSpec: OpenAPIV3.OperationObject,\n responseSpec: OpenAPIV3.ResponseObject,\n status: string,\n allowedMediaTypes: Record<string, boolean> | undefined,\n transformers: Transformers,\n example: any,\n) => {\n Object.keys(responseSpec.content as object).forEach((mediaName) => {\n if (mediaName === jsonMediaType) {\n return;\n }\n\n Object.entries(allowedMediaTypes ?? {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n prepareStatusContent(methodSpec, status, mediaType);\n\n if (\n ((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content?.[mediaType]?.example === undefined\n ) {\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).example =\n {};\n }\n\n let transformed = false;\n\n transformers.forEach(({ regex, transformer }) => {\n if (!transformed && regex.test(mediaType)) {\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).example =\n transformer(example);\n\n transformed = true;\n }\n });\n\n if (!transformed) {\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).example =\n example;\n }\n });\n });\n};\n\nconst extendComponentExamples = (\n spec: Partial<OpenAPIV3.Document>,\n exampleName: string,\n examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject>,\n) => {\n if (typeof spec.components !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components = {};\n }\n\n if (typeof spec.components.examples !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.examples = {};\n }\n\n if (spec.components.examples[exampleName] === undefined && examples[exampleName] !== undefined) {\n // eslint-disable-next-line no-param-reassign\n spec.components.examples[exampleName] = examples[exampleName] as OpenAPIV3.ExampleObject;\n }\n};\n\nconst prepareResponseExamples = (\n spec: Partial<OpenAPIV3.Document>,\n methodSpec: OpenAPIV3.OperationObject,\n status: string,\n mediaType: string,\n transformers: Transformers,\n examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject>,\n // eslint-disable-next-line sonarjs/cognitive-complexity\n) => {\n prepareStatusContent(methodSpec, status, mediaType);\n\n if (((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content?.[mediaType]?.examples === undefined) {\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).examples =\n {};\n }\n\n const transformedExamples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> = {};\n\n Object.entries(examples).forEach(([exampleName, example]) => {\n let transformed = false;\n\n transformers.forEach(({ regex, transformer }) => {\n if (!transformed && regex.test(mediaType)) {\n let data: any = \"\";\n\n if (spec.components?.examples?.[exampleName]) {\n data = (spec.components.examples[exampleName] as OpenAPIV3.ExampleObject).value;\n } else if ((example as OpenAPIV3.ReferenceObject).$ref) {\n data = (\n spec.components?.examples?.[\n (example as OpenAPIV3.ReferenceObject).$ref.replace(\"#/components/examples/\", \"\")\n ] as OpenAPIV3.ExampleObject\n ).value;\n } else if (typeof (example as OpenAPIV3.ExampleObject).value === \"string\") {\n data = (example as OpenAPIV3.ExampleObject).value;\n }\n\n transformedExamples[exampleName] = {\n value: transformer(data),\n };\n\n transformed = true;\n }\n });\n\n if (!transformed) {\n transformedExamples[exampleName] =\n spec.components?.examples?.[exampleName] === undefined\n ? example\n : {\n $ref: `#/components/examples/${exampleName}`,\n };\n }\n });\n\n // prettier-ignore\n // eslint-disable-next-line no-param-reassign\n ((((methodSpec.responses as unknown as OpenAPIV3.ResponsesObject)[status] as OpenAPIV3.ResponseObject).content as Record<\n string,\n OpenAPIV3.MediaTypeObject\n >)[\n mediaType\n ] as OpenAPIV3.MediaTypeObject).examples =\n transformedExamples;\n};\n\nconst extendSwaggerWithMediaTypeExamples = (\n spec: Partial<OpenAPIV3.Document>,\n methodSpec: OpenAPIV3.OperationObject,\n status: string,\n responseSpec: OpenAPIV3.ResponseObject,\n allowedMediaTypes: Record<string, boolean> | undefined,\n pathKey: string,\n transformers: Transformers,\n examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject>,\n) => {\n const examplesName = `${toHeaderCase(pathKey.trim().replace(\"/\", \"\"))}`;\n\n Object.keys(responseSpec.content as object).forEach((mediaName) => {\n if (mediaName === jsonMediaType) {\n return;\n }\n\n Object.entries(allowedMediaTypes ?? {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n extendComponentExamples(spec, examplesName, examples);\n\n prepareResponseExamples(spec, methodSpec, status, mediaType, transformers, examples);\n });\n });\n};\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport default function extendSwaggerSpec(\n spec: Partial<OpenAPIV3.Document>,\n allowedMediaTypes?: Record<string, boolean>,\n transformers: Transformers = [\n {\n regex: /xml/,\n transformer: (value: XmlElement | XmlElement[] | undefined) =>\n xml.toXML(value, {\n header: true,\n indent: \" \",\n }),\n },\n {\n regex: /yaml|yml/,\n transformer: (value) => stringify(value, { indent: 2 }),\n },\n ],\n): Partial<OpenAPIV3.Document> {\n if (typeof spec === \"object\" && typeof spec.paths === \"object\") {\n Object.entries(spec.paths).forEach(([pathKey, pathSpec]) => {\n Object.values(pathSpec as OpenAPIV3.OperationObject & OpenAPIV3.PathsObject).forEach((methodSpec) => {\n if (typeof (methodSpec as OpenAPIV3.OperationObject).responses === \"object\") {\n Object.entries((methodSpec as OpenAPIV3.OperationObject).responses).forEach(([status, responseSpec]) => {\n if (typeof (responseSpec as OpenAPIV3.ResponseObject).content === \"object\") {\n const { example, examples } = extendSwaggerWithMediaTypeSchema(\n methodSpec as OpenAPIV3.OperationObject,\n responseSpec as OpenAPIV3.ResponseObject,\n allowedMediaTypes,\n pathKey,\n spec,\n status,\n );\n\n if (example !== undefined) {\n extendSwaggerWithMediaTypeExample(\n methodSpec as OpenAPIV3.OperationObject,\n responseSpec as OpenAPIV3.ResponseObject,\n status,\n allowedMediaTypes,\n transformers,\n example,\n );\n } else if (examples !== undefined) {\n extendSwaggerWithMediaTypeExamples(\n spec,\n methodSpec as OpenAPIV3.OperationObject,\n status,\n responseSpec as OpenAPIV3.ResponseObject,\n allowedMediaTypes,\n pathKey,\n transformers,\n examples,\n );\n }\n }\n });\n }\n });\n });\n }\n\n return spec;\n}\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { parse as urlParse } from \"node:url\";\n\ntype IncomingApiRequest<TApiRequest = IncomingMessage> = TApiRequest & {\n body?: any;\n query?: any;\n};\n\nexport const jsonResponse = (response: ServerResponse, status: number, data?: unknown): void => {\n response.statusCode = status;\n response.setHeader(\"Content-Type\", \"application/json\");\n response.end(data ? JSON.stringify(data) : \"\");\n};\n\nexport const parseBody = async (request: IncomingApiRequest): Promise<any> => {\n if (request.body) {\n return request.body;\n }\n\n const buffers = [];\n\n // eslint-disable-next-line no-restricted-syntax\n for await (const chunk of request) {\n buffers.push(chunk);\n }\n\n const data = Buffer.concat(buffers).toString();\n\n return data ? JSON.parse(data) : null;\n};\n\nexport const parseQuery = (request: IncomingApiRequest): unknown => {\n if (request.query) {\n return request.query;\n }\n\n return urlParse(request.url ?? \"\", true).query;\n};\n\nexport const toHeaderCase = (string_: string): string =>\n string_\n .toLowerCase()\n .replaceAll(/[^\\s\\w]/g, \" \") // Remove all non-word characters\n .trimEnd() // Remove trailing spaces\n .replaceAll(/\\s+|_/g, \"-\") // Replace multiple spaces or underline with a single hyphen\n .replaceAll(/\\b\\w/g, (c) => c.toUpperCase());\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4D6JZ4TL_js = require('./chunk-4D6JZ4TL.js');
|
|
4
|
+
var zodToTs = require('zod-to-ts');
|
|
5
|
+
var zod = require('zod');
|
|
6
|
+
|
|
7
|
+
var I={};chunk4D6JZ4TL_js.a(I,{dateIn:()=>K,dateOut:()=>w});var g="ZodDateIn",N=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?)?Z?$/,d=class d extends zod.ZodType{_parse(t){let{ctx:e,status:a}=this._processInputParams(t);if(e.parsedType!==zod.ZodParsedType.string)return zod.addIssueToContext(e,{code:zod.ZodIssueCode.invalid_type,expected:zod.ZodParsedType.string,received:e.parsedType}),zod.INVALID;N.test(e.data)||(zod.addIssueToContext(e,{code:zod.ZodIssueCode.invalid_string,validation:"regex"}),a.dirty());let c=new Date(e.data);return Number.isNaN(c.getTime())?(zod.addIssueToContext(e,{code:zod.ZodIssueCode.invalid_date}),zod.INVALID):{status:a.value,value:c}}};d.create=()=>new d({typeName:g});var r=d;var v="ZodDateOut",s=class s extends zod.ZodType{_parse(t){let{ctx:e,status:a}=this._processInputParams(t);return e.parsedType!==zod.ZodParsedType.date?(zod.addIssueToContext(e,{code:zod.ZodIssueCode.invalid_type,expected:zod.ZodParsedType.date,received:e.parsedType}),zod.INVALID):Number.isNaN(e.data.getTime())?(zod.addIssueToContext(e,{code:zod.ZodIssueCode.invalid_date}),zod.INVALID):{status:a.value,value:e.data.toISOString()}}};s.create=()=>new s({typeName:v});var o=s;var K=(...n)=>zodToTs.withGetType(r.create(...n),t=>t.factory.createKeywordTypeNode(t.SyntaxKind.StringKeyword)),w=(...n)=>zodToTs.withGetType(o.create(...n),t=>t.factory.createKeywordTypeNode(t.SyntaxKind.StringKeyword));
|
|
8
|
+
|
|
9
|
+
exports.a = K;
|
|
10
|
+
exports.b = w;
|
|
11
|
+
exports.c = I;
|
|
12
|
+
//# sourceMappingURL=out.js.map
|
|
13
|
+
//# sourceMappingURL=chunk-WYXGSYH5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/zod/index.ts","../src/zod/date-in-schema.ts","../src/zod/date-out-schema.ts"],"names":["zod_exports","__export","dateIn","dateOut","withGetType","INVALID","ZodIssueCode","ZodParsedType","ZodType","addIssueToContext","zodDateInKind","isoDateRegex","_ZodDateIn","input","ctx","status","date","ZodDateIn","zodDateOutKind","_ZodDateOut","ZodDateOut","parameters","ts"],"mappings":"wCAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,YAAAC,IAAA,OAAS,eAAAC,MAAmB,YCC5B,OAAS,WAAAC,EAAS,gBAAAC,EAAc,iBAAAC,EAAe,WAAAC,EAAS,qBAAAC,MAAyB,MAEjF,IAAMC,EAAgB,YAQTC,EAAe,uDAOfC,EAAN,MAAMA,UAAkBJ,CAAoC,CAOxD,OAAOK,EAA0C,CAEpD,GAAM,CAAE,IAAAC,EAAK,OAAAC,CAAO,EAAI,KAAK,oBAAoBF,CAAK,EACtD,GAAIC,EAAI,aAAeP,EAAc,OACjC,OAAAE,EAAkBK,EAAK,CACnB,KAAMR,EAAa,aACnB,SAAUC,EAAc,OACxB,SAAUO,EAAI,UAClB,CAAC,EACMT,EAGNM,EAAa,KAAKG,EAAI,IAAc,IACrCL,EAAkBK,EAAK,CACnB,KAAMR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ent":["import { withGetType } from \"zod-to-ts\";\n\nimport { ZodDateIn } from \"./date-in-schema\";\nimport { ZodDateOut } from \"./date-out-schema\";\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport const dateIn = (...parameters: Parameters<typeof ZodDateIn.create>) =>\n withGetType(ZodDateIn.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport const dateOut = (...parameters: Parameters<typeof ZodDateOut.create>) =>\n withGetType(ZodDateOut.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));\n","import type { ParseInput, ParseReturnType, ZodTypeDef } from \"zod\";\nimport { INVALID, ZodIssueCode, ZodParsedType, ZodType, addIssueToContext } from \"zod\";\n\nconst zodDateInKind = \"ZodDateIn\";\n\n// simple regex for ISO date, supports the following formats:\n// 2021-01-01T00:00:00.000Z\n// 2021-01-01T00:00:00Z\n// 2021-01-01T00:00:00\n// 2021-01-01\n// eslint-disable-next-line security/detect-unsafe-regex\nexport const isoDateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?)?Z?$/;\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport interface ZodDateInDef extends ZodTypeDef {\n typeName: typeof zodDateInKind;\n}\n\nexport class ZodDateIn extends ZodType<Date, ZodDateInDef, string> {\n public static create = (): ZodDateIn =>\n new ZodDateIn({\n typeName: zodDateInKind,\n });\n\n // eslint-disable-next-line no-underscore-dangle\n public _parse(input: ParseInput): ParseReturnType<Date> {\n // eslint-disable-next-line no-underscore-dangle\n const { ctx, status } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.string) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.string,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n\n if (!isoDateRegex.test(ctx.data as string)) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: \"regex\",\n });\n status.dirty();\n }\n\n const date = new Date(ctx.data as string);\n\n if (Number.isNaN(date.getTime())) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_date,\n });\n return INVALID;\n }\n\n return { status: status.value, value: date };\n }\n}\n","import type { ParseInput, ParseReturnType, ZodTypeDef } from \"zod\";\nimport { INVALID, ZodIssueCode, ZodParsedType, ZodType, addIssueToContext } from \"zod\";\n\nconst zodDateOutKind = \"ZodDateOut\";\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport interface ZodDateOutDef extends ZodTypeDef {\n typeName: typeof zodDateOutKind;\n}\n\nexport class ZodDateOut extends ZodType<string, ZodDateOutDef, Date> {\n public static create = (): ZodDateOut =>\n new ZodDateOut({\n typeName: zodDateOutKind,\n });\n\n // eslint-disable-next-line no-underscore-dangle\n public _parse(input: ParseInput): ParseReturnType<string> {\n // eslint-disable-next-line no-underscore-dangle\n const { ctx, status } = this._processInputParams(input);\n\n if (ctx.parsedType !== ZodParsedType.date) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n\n if (Number.isNaN(ctx.data.getTime())) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_date,\n });\n return INVALID;\n }\n\n return { status: status.value, value: (ctx.data as Date).toISOString() };\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../../chunk-
|
|
3
|
+
var chunkADVXXSKJ_js = require('../../../chunk-ADVXXSKJ.js');
|
|
4
|
+
require('../../../chunk-4D6JZ4TL.js');
|
|
5
5
|
var process = require('process');
|
|
6
6
|
|
|
7
|
-
var i=(o,t="list",r="List all available API routes; Supported frameworks are next, express, koa, hapi and fastify")=>{o.command(t).description(r).option("--framework <framework>","Framework to use, choose from next, express, koa, hapi and fastify").option("-p, --path [path]","...").option("--group [type]","Groups routes. Supported: path, tag").option("--include-path [path]","Includes only routes which contain a given path element. (comma-separated values)",[]).option("--exclude-path [path]","Excludes routes which contain a given path element. (comma-separated values)",[]).option("-v, --verbose","Verbose output.",!1).action(e=>{try{
|
|
7
|
+
var i=(o,t="list",r="List all available API routes; Supported frameworks are next, express, koa, hapi and fastify")=>{o.command(t).description(r).option("--framework <framework>","Framework to use, choose from next, express, koa, hapi and fastify").option("-p, --path [path]","...").option("--group [type]","Groups routes. Supported: path, tag").option("--include-path [path]","Includes only routes which contain a given path element. (comma-separated values)",[]).option("--exclude-path [path]","Excludes routes which contain a given path element. (comma-separated values)",[]).option("-v, --verbose","Verbose output.",!1).action(async e=>{try{await chunkADVXXSKJ_js.a(e.framework,e.path,{excludePaths:e.excludePaths,group:e.group,includePaths:e.includePath,verbose:e.verbose});}catch(n){console.log(),console.error(n),process.exit(1);}});},p=i;
|
|
8
8
|
|
|
9
9
|
exports.listCommand = p;
|
|
10
10
|
//# sourceMappingURL=out.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/framework/cli/commander/command/list-command.ts"],"names":["exit","listCommand","program","commandName","description","options","list_command_default","error"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/framework/cli/commander/command/list-command.ts"],"names":["exit","listCommand","program","commandName","description","options","list_command_default","error"],"mappings":"6EACA,OAAS,QAAAA,MAAY,UAIrB,IAAMC,EAAc,CAChBC,EACAC,EAAc,OACdC,EAAc,iGACP,CACPF,EACK,QAAQC,CAAW,EACnB,YAAYC,CAAW,EACvB,OAAO,0BAA2B,oEAAoE,EACtG,OAAO,oBAAqB,KAAK,EACjC,OAAO,iBAAkB,qCAAqC,EAC9D,OAAO,wBAAyB,oFAAqF,CAAC,CAAC,EACvH,OAAO,wBAAyB,+EAAgF,CAAC,CAAC,EAClH,OAAO,gBAAiB,kBAAmB,EAAK,EAChD,OAAO,MAAOC,GAAY,CACvB,GAAI,CACA,MAAMC,EAAQD,EAAQ,UAA8DA,EAAQ,KAAgB,CACxG,aAAcA,EAAQ,aACtB,MAAOA,EAAQ,MACf,aAAcA,EAAQ,YACtB,QAASA,EAAQ,OACrB,CAAC,CACL,OAASE,EAAY,CAEjB,QAAQ,IAAI,EAEZ,QAAQ,MAAMA,CAAK,EACnBP,EAAK,CAAC,CACV,CACJ,CAAC,CACT,EAEOM,EAAQL","sourcesContent":["import type { Command } from \"commander\";\nimport { exit } from \"node:process\";\n\nimport command from \"../../command/list/list-command\";\n\nconst listCommand = (\n program: Command,\n commandName = \"list\",\n description = \"List all available API routes; Supported frameworks are next, express, koa, hapi and fastify\",\n): void => {\n program\n .command(commandName)\n .description(description)\n .option(\"--framework <framework>\", \"Framework to use, choose from next, express, koa, hapi and fastify\")\n .option(\"-p, --path [path]\", \"...\")\n .option(\"--group [type]\", \"Groups routes. Supported: path, tag\")\n .option(\"--include-path [path]\", \"Includes only routes which contain a given path element. (comma-separated values)\", [])\n .option(\"--exclude-path [path]\", \"Excludes routes which contain a given path element. (comma-separated values)\", [])\n .option(\"-v, --verbose\", \"Verbose output.\", false)\n .action(async (options) => {\n try {\n await command(options.framework as \"express\" | \"fastify\" | \"hapi\" | \"koa\" | \"next\", options.path as string, {\n excludePaths: options.excludePaths as string[] | undefined,\n group: options.group as string | undefined,\n includePaths: options.includePath as string[] | undefined,\n verbose: options.verbose as boolean | undefined,\n });\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.log();\n // eslint-disable-next-line no-console\n console.error(error);\n exit(1);\n }\n });\n};\n\nexport default listCommand;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
1
|
+
import { a } from '../../../chunk-HNWSVLC3.mjs';
|
|
2
|
+
import '../../../chunk-XIJ2ZQRX.mjs';
|
|
3
3
|
import { exit } from 'process';
|
|
4
4
|
|
|
5
|
-
var i=(o,t="list",r="List all available API routes; Supported frameworks are next, express, koa, hapi and fastify")=>{o.command(t).description(r).option("--framework <framework>","Framework to use, choose from next, express, koa, hapi and fastify").option("-p, --path [path]","...").option("--group [type]","Groups routes. Supported: path, tag").option("--include-path [path]","Includes only routes which contain a given path element. (comma-separated values)",[]).option("--exclude-path [path]","Excludes routes which contain a given path element. (comma-separated values)",[]).option("-v, --verbose","Verbose output.",!1).action(e=>{try{a(e.framework,e.path,{
|
|
5
|
+
var i=(o,t="list",r="List all available API routes; Supported frameworks are next, express, koa, hapi and fastify")=>{o.command(t).description(r).option("--framework <framework>","Framework to use, choose from next, express, koa, hapi and fastify").option("-p, --path [path]","...").option("--group [type]","Groups routes. Supported: path, tag").option("--include-path [path]","Includes only routes which contain a given path element. (comma-separated values)",[]).option("--exclude-path [path]","Excludes routes which contain a given path element. (comma-separated values)",[]).option("-v, --verbose","Verbose output.",!1).action(async e=>{try{await a(e.framework,e.path,{excludePaths:e.excludePaths,group:e.group,includePaths:e.includePath,verbose:e.verbose});}catch(n){console.log(),console.error(n),exit(1);}});},p=i;
|
|
6
6
|
|
|
7
7
|
export { p as listCommand };
|
|
8
8
|
//# sourceMappingURL=out.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/framework/cli/commander/command/list-command.ts"],"names":["exit","listCommand","program","commandName","description","options","list_command_default","error"],"mappings":"+
|
|
1
|
+
{"version":3,"sources":["../../../../src/framework/cli/commander/command/list-command.ts"],"names":["exit","listCommand","program","commandName","description","options","list_command_default","error"],"mappings":"+EACA,OAAS,QAAAA,MAAY,UAIrB,IAAMC,EAAc,CAChBC,EACAC,EAAc,OACdC,EAAc,iGACP,CACPF,EACK,QAAQC,CAAW,EACnB,YAAYC,CAAW,EACvB,OAAO,0BAA2B,oEAAoE,EACtG,OAAO,oBAAqB,KAAK,EACjC,OAAO,iBAAkB,qCAAqC,EAC9D,OAAO,wBAAyB,oFAAqF,CAAC,CAAC,EACvH,OAAO,wBAAyB,+EAAgF,CAAC,CAAC,EAClH,OAAO,gBAAiB,kBAAmB,EAAK,EAChD,OAAO,MAAOC,GAAY,CACvB,GAAI,CACA,MAAMC,EAAQD,EAAQ,UAA8DA,EAAQ,KAAgB,CACxG,aAAcA,EAAQ,aACtB,MAAOA,EAAQ,MACf,aAAcA,EAAQ,YACtB,QAASA,EAAQ,OACrB,CAAC,CACL,OAASE,EAAY,CAEjB,QAAQ,IAAI,EAEZ,QAAQ,MAAMA,CAAK,EACnBP,EAAK,CAAC,CACV,CACJ,CAAC,CACT,EAEOM,EAAQL","sourcesContent":["import type { Command } from \"commander\";\nimport { exit } from \"node:process\";\n\nimport command from \"../../command/list/list-command\";\n\nconst listCommand = (\n program: Command,\n commandName = \"list\",\n description = \"List all available API routes; Supported frameworks are next, express, koa, hapi and fastify\",\n): void => {\n program\n .command(commandName)\n .description(description)\n .option(\"--framework <framework>\", \"Framework to use, choose from next, express, koa, hapi and fastify\")\n .option(\"-p, --path [path]\", \"...\")\n .option(\"--group [type]\", \"Groups routes. Supported: path, tag\")\n .option(\"--include-path [path]\", \"Includes only routes which contain a given path element. (comma-separated values)\", [])\n .option(\"--exclude-path [path]\", \"Excludes routes which contain a given path element. (comma-separated values)\", [])\n .option(\"-v, --verbose\", \"Verbose output.\", false)\n .action(async (options) => {\n try {\n await command(options.framework as \"express\" | \"fastify\" | \"hapi\" | \"koa\" | \"next\", options.path as string, {\n excludePaths: options.excludePaths as string[] | undefined,\n group: options.group as string | undefined,\n includePaths: options.includePath as string[] | undefined,\n verbose: options.verbose as boolean | undefined,\n });\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.log();\n // eslint-disable-next-line no-console\n console.error(error);\n exit(1);\n }\n });\n};\n\nexport default listCommand;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface RenderOptions {
|
|
2
|
+
excludePaths: string[];
|
|
3
|
+
group: string;
|
|
4
|
+
includePaths: string[];
|
|
5
|
+
methods: string[];
|
|
6
|
+
}
|
|
7
|
+
declare const listCommand: (framework: "express" | "fastify" | "hapi" | "koa" | "next" | undefined, path: string, options?: Partial<RenderOptions & {
|
|
8
|
+
verbose: boolean;
|
|
9
|
+
}>) => Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { listCommand };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
includePaths: string[];
|
|
1
|
+
interface RenderOptions {
|
|
3
2
|
excludePaths: string[];
|
|
4
|
-
methods: string[];
|
|
5
3
|
group: string;
|
|
6
|
-
|
|
4
|
+
includePaths: string[];
|
|
5
|
+
methods: string[];
|
|
6
|
+
}
|
|
7
7
|
declare const listCommand: (framework: "express" | "fastify" | "hapi" | "koa" | "next" | undefined, path: string, options?: Partial<RenderOptions & {
|
|
8
8
|
verbose: boolean;
|
|
9
9
|
}>) => Promise<void>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var chunkADVXXSKJ_js = require('../../chunk-ADVXXSKJ.js');
|
|
4
|
+
require('../../chunk-4D6JZ4TL.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, 'listCommand', {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkADVXXSKJ_js.a; }
|
|
11
11
|
});
|
|
12
12
|
//# sourceMappingURL=out.js.map
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var chunk3GKT5H3V_js = require('../../chunk-3GKT5H3V.js');
|
|
4
|
+
require('../../chunk-4D6JZ4TL.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, 'getSwaggerStaticProps', {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk3GKT5H3V_js.a; }
|
|
11
11
|
});
|
|
12
12
|
//# sourceMappingURL=out.js.map
|
|
13
13
|
//# sourceMappingURL=index-browser.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as getSwaggerStaticProps } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { a as getSwaggerStaticProps } from '../../chunk-IGJDNXIE.mjs';
|
|
2
|
+
import '../../chunk-XIJ2ZQRX.mjs';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=index-browser.mjs.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { getSwaggerStaticProps } from './index-browser.mjs';
|
|
2
|
+
import { S as SwaggerHandlerOptions } from '../../swagger-handler-47360cd1.js';
|
|
3
|
+
import { BaseDefinition } from '@visulima/jsdoc-open-api';
|
|
4
|
+
import { NextConfig } from 'next';
|
|
5
|
+
import '@visulima/crud';
|
|
6
|
+
import 'node:http';
|
|
7
|
+
import 'openapi-types';
|
|
8
|
+
|
|
9
|
+
declare const swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void;
|
|
10
|
+
|
|
11
|
+
declare const withOpenApi: ({ definition, output, sources, verbose, }: {
|
|
12
|
+
definition: Exclude<BaseDefinition, "openapi"> & {
|
|
13
|
+
openapi?: string;
|
|
14
|
+
};
|
|
15
|
+
output: string;
|
|
16
|
+
sources: string[];
|
|
17
|
+
verbose?: boolean | undefined;
|
|
18
|
+
}) => (nextConfig: NextConfig) => NextConfig;
|
|
19
|
+
|
|
20
|
+
export { swaggerApiRoute, withOpenApi };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export { getSwaggerStaticProps } from './index-browser.js';
|
|
2
|
+
import { S as SwaggerHandlerOptions } from '../../swagger-handler-47360cd1.js';
|
|
2
3
|
import { BaseDefinition } from '@visulima/jsdoc-open-api';
|
|
3
4
|
import { NextConfig } from 'next';
|
|
4
|
-
import { S as SwaggerHandlerOptions } from '../../swagger-handler-8947e0f1.js';
|
|
5
5
|
import '@visulima/crud';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
import 'openapi-types';
|
|
8
8
|
|
|
9
|
-
declare const
|
|
9
|
+
declare const swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void;
|
|
10
|
+
|
|
11
|
+
declare const withOpenApi: ({ definition, output, sources, verbose, }: {
|
|
10
12
|
definition: Exclude<BaseDefinition, "openapi"> & {
|
|
11
13
|
openapi?: string;
|
|
12
14
|
};
|
|
15
|
+
output: string;
|
|
13
16
|
sources: string[];
|
|
14
17
|
verbose?: boolean | undefined;
|
|
15
|
-
output: string;
|
|
16
18
|
}) => (nextConfig: NextConfig) => NextConfig;
|
|
17
19
|
|
|
18
|
-
declare const swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void;
|
|
19
|
-
|
|
20
20
|
export { swaggerApiRoute, withOpenApi };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../../chunk-
|
|
3
|
+
var chunkM5CDBLRM_js = require('../../chunk-M5CDBLRM.js');
|
|
4
|
+
var chunk3GKT5H3V_js = require('../../chunk-3GKT5H3V.js');
|
|
5
|
+
require('../../chunk-4D6JZ4TL.js');
|
|
6
6
|
var jsdocOpenApi = require('@visulima/jsdoc-open-api');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var d = require('fs');
|
|
8
|
+
var w = require('path');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var d__default = /*#__PURE__*/_interopDefault(d);
|
|
13
|
+
var w__default = /*#__PURE__*/_interopDefault(w);
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var f=(t={})=>chunkM5CDBLRM_js.c(t),m=f;var u=({definition:t,output:r="swagger/swagger.json",sources:s,verbose:p})=>o=>({...o,webpack:(e,i)=>{if(!i.isServer)return e;if(r.startsWith("/")&&(r=r.slice(1)),!r.endsWith(".json"))throw new Error("The output path must end with .json");return e={...e,plugins:[...e.plugins,new jsdocOpenApi.SwaggerCompilerPlugin(`${i.dir}/${r}`,s.map(g=>{let a=w__default.default.join(i.dir,g.replace("./",""));return d__default.default.lstatSync(a).isDirectory(),a}),{openapi:"3.0.0",...t},{verbose:p})]},typeof o.webpack=="function"?o.webpack(e,i):e}}),c=u;
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, 'getSwaggerStaticProps', {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunk3GKT5H3V_js.a; }
|
|
20
20
|
});
|
|
21
|
-
exports.swaggerApiRoute =
|
|
22
|
-
exports.withOpenApi =
|
|
21
|
+
exports.swaggerApiRoute = m;
|
|
22
|
+
exports.withOpenApi = c;
|
|
23
23
|
//# sourceMappingURL=out.js.map
|
|
24
24
|
//# sourceMappingURL=index-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/framework/next/
|
|
1
|
+
{"version":3,"sources":["../../../src/framework/next/routes/api/swagger.ts","../../../src/framework/next/webpack/with-open-api.ts"],"names":["swaggerApiRoute","options","swagger_handler_default","swagger_default","SwaggerCompilerPlugin","fs","path","withOpenApi","definition","output","sources","verbose","nextConfig","config","source","combinedPath","with_open_api_default"],"mappings":"wHAOA,IAAMA,EAAsH,CAACC,EAAU,CAAC,IACpIC,EAAeD,CAAO,EAGnBE,EAAQH,ECVf,OAAS,yBAAAI,MAA6B,2BAGtC,OAAOC,MAAQ,KACf,OAAOC,MAAU,OAGjB,IAAMC,EACF,CAAC,CACG,WAAAC,EACA,OAAAC,EAAS,uBACT,QAAAC,EACA,QAAAC,CACJ,IAMCC,IACI,CACG,GAAGA,EACH,QAAS,CAACC,EAAuBZ,IAAiB,CAC9C,GAAI,CAACA,EAAQ,SACT,OAAOY,EAQX,GALIJ,EAAO,WAAW,GAAG,IAErBA,EAASA,EAAO,MAAM,CAAC,GAGvB,CAACA,EAAO,SAAS,OAAO,EACxB,MAAM,IAAI,MAAM,qCAAqC,EA6BzD,OAzBAI,EAAS,CACL,GAAGA,EACH,QAAS,CAEL,GAAGA,EAAO,QACV,IAAIT,EACA,GAAGH,EAAQ,GAAG,IAAIQ,CAAM,GACxBC,EAAQ,IAAKI,GAAW,CACpB,IAAMC,EAAeT,EAAK,KAAKL,EAAQ,IAAea,EAAO,QAAQ,KAAM,EAAE,CAAC,EAG9E,OAAAT,EAAG,UAAUU,CAAY,EAAE,YAAY,EAEhCA,CACX,CAAC,EACD,CAEI,QAAS,QACT,GAAGP,CACP,EACA,CAAE,QAAAG,CAAQ,CACd,CACJ,CACJ,EAEI,OAAOC,EAAW,SAAY,WACvBA,EAAW,QAAQC,EAAQZ,CAAO,EAGtCY,CACX,CACJ,GAEDG,EAAQT","sourcesContent":["import type { SwaggerHandlerOptions } from \"../../../../swagger/api/swagger-handler\";\nimport swaggerHandler from \"../../../../swagger/api/swagger-handler\";\n\n/**\n * @deprecated Use `import { swaggerHandler } from \"@visulima/api-platform\"` instead.\n */\n\nconst swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void = (options = {}) =>\n swaggerHandler(options);\n\n// eslint-disable-next-line etc/no-deprecated\nexport default swaggerApiRoute;\n","import type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport type { NextConfig } from \"next\";\nimport type { NextJsWebpackConfig } from \"next/dist/server/config-shared\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi =\n ({\n definition,\n output = \"swagger/swagger.json\",\n sources,\n verbose,\n }: {\n definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string };\n output: string;\n sources: string[];\n verbose?: boolean;\n }) =>\n (nextConfig: NextConfig): NextConfig =>\n ({\n ...nextConfig,\n webpack: (config: Configuration, options: any) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-expect-error: ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = path.join(options.dir as string, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-expect-error: This property should be overwritten\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options) as NextJsWebpackConfig;\n }\n\n return config as NextJsWebpackConfig;\n },\n }) as NextConfig;\n\nexport default withOpenApi;\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { c as c$1 } from '../../chunk-
|
|
2
|
-
export { a as getSwaggerStaticProps } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
import { c as c$1 } from '../../chunk-EMJS7XMY.mjs';
|
|
2
|
+
export { a as getSwaggerStaticProps } from '../../chunk-IGJDNXIE.mjs';
|
|
3
|
+
import '../../chunk-XIJ2ZQRX.mjs';
|
|
4
4
|
import { SwaggerCompilerPlugin } from '@visulima/jsdoc-open-api';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import d from 'fs';
|
|
6
|
+
import w from 'path';
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var f=(t={})=>c$1(t),m=f;var u=({definition:t,output:r="swagger/swagger.json",sources:s,verbose:p})=>o=>({...o,webpack:(e,i)=>{if(!i.isServer)return e;if(r.startsWith("/")&&(r=r.slice(1)),!r.endsWith(".json"))throw new Error("The output path must end with .json");return e={...e,plugins:[...e.plugins,new SwaggerCompilerPlugin(`${i.dir}/${r}`,s.map(g=>{let a=w.join(i.dir,g.replace("./",""));return d.lstatSync(a).isDirectory(),a}),{openapi:"3.0.0",...t},{verbose:p})]},typeof o.webpack=="function"?o.webpack(e,i):e}}),c=u;
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { m as swaggerApiRoute, c as withOpenApi };
|
|
11
11
|
//# sourceMappingURL=out.js.map
|
|
12
12
|
//# sourceMappingURL=index-server.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/framework/next/
|
|
1
|
+
{"version":3,"sources":["../../../src/framework/next/routes/api/swagger.ts","../../../src/framework/next/webpack/with-open-api.ts"],"names":["swaggerApiRoute","options","swagger_handler_default","swagger_default","SwaggerCompilerPlugin","fs","path","withOpenApi","definition","output","sources","verbose","nextConfig","config","source","combinedPath","with_open_api_default"],"mappings":"2HAOA,IAAMA,EAAsH,CAACC,EAAU,CAAC,IACpIC,EAAeD,CAAO,EAGnBE,EAAQH,ECVf,OAAS,yBAAAI,MAA6B,2BAGtC,OAAOC,MAAQ,KACf,OAAOC,MAAU,OAGjB,IAAMC,EACF,CAAC,CACG,WAAAC,EACA,OAAAC,EAAS,uBACT,QAAAC,EACA,QAAAC,CACJ,IAMCC,IACI,CACG,GAAGA,EACH,QAAS,CAACC,EAAuBZ,IAAiB,CAC9C,GAAI,CAACA,EAAQ,SACT,OAAOY,EAQX,GALIJ,EAAO,WAAW,GAAG,IAErBA,EAASA,EAAO,MAAM,CAAC,GAGvB,CAACA,EAAO,SAAS,OAAO,EACxB,MAAM,IAAI,MAAM,qCAAqC,EA6BzD,OAzBAI,EAAS,CACL,GAAGA,EACH,QAAS,CAEL,GAAGA,EAAO,QACV,IAAIT,EACA,GAAGH,EAAQ,GAAG,IAAIQ,CAAM,GACxBC,EAAQ,IAAKI,GAAW,CACpB,IAAMC,EAAeT,EAAK,KAAKL,EAAQ,IAAea,EAAO,QAAQ,KAAM,EAAE,CAAC,EAG9E,OAAAT,EAAG,UAAUU,CAAY,EAAE,YAAY,EAEhCA,CACX,CAAC,EACD,CAEI,QAAS,QACT,GAAGP,CACP,EACA,CAAE,QAAAG,CAAQ,CACd,CACJ,CACJ,EAEI,OAAOC,EAAW,SAAY,WACvBA,EAAW,QAAQC,EAAQZ,CAAO,EAGtCY,CACX,CACJ,GAEDG,EAAQT","sourcesContent":["import type { SwaggerHandlerOptions } from \"../../../../swagger/api/swagger-handler\";\nimport swaggerHandler from \"../../../../swagger/api/swagger-handler\";\n\n/**\n * @deprecated Use `import { swaggerHandler } from \"@visulima/api-platform\"` instead.\n */\n\nconst swaggerApiRoute: <M extends string, PrismaClient>(options: Partial<SwaggerHandlerOptions<M, PrismaClient>>) => void = (options = {}) =>\n swaggerHandler(options);\n\n// eslint-disable-next-line etc/no-deprecated\nexport default swaggerApiRoute;\n","import type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport type { NextConfig } from \"next\";\nimport type { NextJsWebpackConfig } from \"next/dist/server/config-shared\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi =\n ({\n definition,\n output = \"swagger/swagger.json\",\n sources,\n verbose,\n }: {\n definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string };\n output: string;\n sources: string[];\n verbose?: boolean;\n }) =>\n (nextConfig: NextConfig): NextConfig =>\n ({\n ...nextConfig,\n webpack: (config: Configuration, options: any) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-expect-error: ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = path.join(options.dir as string, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-expect-error: This property should be overwritten\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options) as NextJsWebpackConfig;\n }\n\n return config as NextJsWebpackConfig;\n },\n }) as NextConfig;\n\nexport default withOpenApi;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NextPage, InferGetStaticPropsType } from 'next';
|
|
2
|
+
import { getSwaggerStaticProps as getStaticProps } from '../../../index-browser.mjs';
|
|
3
|
+
|
|
4
|
+
declare const RedocApiDocument: (name: string, swagger?: Exclude<{
|
|
5
|
+
specUrl?: string;
|
|
6
|
+
}, "spec">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>>;
|
|
7
|
+
|
|
8
|
+
export { RedocApiDocument as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NextPage, InferGetStaticPropsType } from 'next';
|
|
2
|
-
import { RedocStandaloneProps } from 'redoc';
|
|
3
2
|
import { getSwaggerStaticProps as getStaticProps } from '../../../index-browser.js';
|
|
4
3
|
|
|
5
|
-
declare const RedocApiDocument: (name: string, swagger?: Exclude<
|
|
4
|
+
declare const RedocApiDocument: (name: string, swagger?: Exclude<{
|
|
5
|
+
specUrl?: string;
|
|
6
|
+
}, "spec">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>>;
|
|
6
7
|
|
|
7
8
|
export { RedocApiDocument as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../../../../../chunk-
|
|
3
|
+
require('../../../../../chunk-4D6JZ4TL.js');
|
|
4
4
|
var a = require('next/head');
|
|
5
5
|
var redoc = require('redoc');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -9,12 +9,12 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
9
9
|
|
|
10
10
|
var a__default = /*#__PURE__*/_interopDefault(a);
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var s=(o,p={})=>({swaggerData:r})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(a__default.default,{children:[jsxRuntime.jsx("title",{children:o}),jsxRuntime.jsx("style",{children:`
|
|
13
13
|
body {
|
|
14
14
|
background: #fafafa !important;
|
|
15
15
|
}
|
|
16
|
-
`})]}),jsxRuntime.jsx(redoc.RedocStandalone,{...p,spec:r})]}),
|
|
16
|
+
`})]}),jsxRuntime.jsx(redoc.RedocStandalone,{...p,spec:r})]}),n=s;
|
|
17
17
|
|
|
18
|
-
module.exports =
|
|
18
|
+
module.exports = n;
|
|
19
19
|
//# sourceMappingURL=out.js.map
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["Head","RedocStandalone","Fragment","jsx","jsxs","RedocApiDocument","name","swagger","swaggerData","redoc_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["Head","RedocStandalone","Fragment","jsx","jsxs","RedocApiDocument","name","swagger","swaggerData","redoc_default"],"mappings":"yCAEA,OAAOA,MAAU,YAEjB,OAAS,mBAAAC,MAAuB,QAexB,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBAXR,IAAMC,EASF,CAACC,EAAMC,EAAU,CAAC,IAClB,CAAC,CAAE,YAAAC,CAAY,IACXJ,EAAAF,EAAA,CACI,UAAAE,EAACJ,EAAA,CACG,UAAAG,EAAC,SAAO,SAAAG,EAAK,EACbH,EAAC,SACI;AAAA;AAAA;AAAA;AAAA,EAKL,GACJ,EAEAA,EAACF,EAAA,CAAiB,GAAGM,EAAS,KAAMC,EAAa,GACrD,EAGDC,EAAQJ","sourcesContent":["import type { InferGetStaticPropsType, NextPage } from \"next\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { RedocStandalone } from \"redoc\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<\n {\n specUrl?: string;\n },\n \"spec\"\n >,\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default RedocApiDocument;\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import '../../../../../chunk-
|
|
1
|
+
import '../../../../../chunk-XIJ2ZQRX.mjs';
|
|
2
2
|
import a from 'next/head';
|
|
3
3
|
import { RedocStandalone } from 'redoc';
|
|
4
4
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var s=(o,p={})=>({swaggerData:r})=>jsxs(Fragment,{children:[jsxs(a,{children:[jsx("title",{children:o}),jsx("style",{children:`
|
|
7
7
|
body {
|
|
8
8
|
background: #fafafa !important;
|
|
9
9
|
}
|
|
10
|
-
`})]}),jsx(RedocStandalone,{...p,spec:r})]}),
|
|
10
|
+
`})]}),jsx(RedocStandalone,{...p,spec:r})]}),n=s;
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { n as default };
|
|
13
13
|
//# sourceMappingURL=out.js.map
|
|
14
14
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["Head","RedocStandalone","Fragment","jsx","jsxs","RedocApiDocument","name","swagger","swaggerData","redoc_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/framework/next/routes/pages/redoc/index.tsx"],"names":["Head","RedocStandalone","Fragment","jsx","jsxs","RedocApiDocument","name","swagger","swaggerData","redoc_default"],"mappings":"0CAEA,OAAOA,MAAU,YAEjB,OAAS,mBAAAC,MAAuB,QAexB,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBAXR,IAAMC,EASF,CAACC,EAAMC,EAAU,CAAC,IAClB,CAAC,CAAE,YAAAC,CAAY,IACXJ,EAAAF,EAAA,CACI,UAAAE,EAACJ,EAAA,CACG,UAAAG,EAAC,SAAO,SAAAG,EAAK,EACbH,EAAC,SACI;AAAA;AAAA;AAAA;AAAA,EAKL,GACJ,EAEAA,EAACF,EAAA,CAAiB,GAAGM,EAAS,KAAMC,EAAa,GACrD,EAGDC,EAAQJ","sourcesContent":["import type { InferGetStaticPropsType, NextPage } from \"next\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { RedocStandalone } from \"redoc\";\n\nimport type getStaticProps from \"../get-static-properties-swagger\";\n\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<\n {\n specUrl?: string;\n },\n \"spec\"\n >,\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> =\n (name, swagger = {}) =>\n ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n );\n\nexport default RedocApiDocument;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NextPage, InferGetStaticPropsType } from 'next';
|
|
2
|
+
import { SwaggerUIProps } from 'swagger-ui-react';
|
|
3
|
+
import { getSwaggerStaticProps as getStaticProps } from '../../../index-browser.mjs';
|
|
4
|
+
|
|
5
|
+
declare const SwaggerApiDocument: (name: string, swagger?: Exclude<SwaggerUIProps, "spec">) => NextPage<InferGetStaticPropsType<typeof getStaticProps>>;
|
|
6
|
+
|
|
7
|
+
export { SwaggerApiDocument as default };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../../../../../chunk-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
require('../../../../../chunk-4D6JZ4TL.js');
|
|
4
|
+
var p = require('next/dynamic');
|
|
5
|
+
var s = require('next/head');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var p__default = /*#__PURE__*/_interopDefault(p);
|
|
11
|
+
var s__default = /*#__PURE__*/_interopDefault(s);
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var g=p__default.default(async()=>await import('swagger-ui-react'),{ssr:!1}),i=(r,a={})=>({swaggerData:o})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(s__default.default,{children:[jsxRuntime.jsx("title",{children:r}),jsxRuntime.jsx("style",{children:`
|
|
14
14
|
body {
|
|
15
15
|
background: #fafafa !important;
|
|
16
16
|
}
|
|
17
|
-
`})]}),jsxRuntime.jsx(
|
|
17
|
+
`})]}),jsxRuntime.jsx(g,{...a,spec:o})]}),y=i;
|
|
18
18
|
|
|
19
19
|
module.exports = y;
|
|
20
20
|
//# sourceMappingURL=out.js.map
|