@redocly/client-generator 0.3.8 → 0.4.0
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/README.md +32 -54
- package/eject-assets/AGENTS.md +137 -0
- package/eject-assets/generators/cli/docs.ts +224 -0
- package/eject-assets/generators/cli/engine-source.ts +21 -0
- package/eject-assets/generators/cli/index.ts +90 -0
- package/eject-assets/generators/cli/render.ts +348 -0
- package/eject-assets/generators/go/client.ts +57 -0
- package/eject-assets/generators/go/descriptor.ts +41 -0
- package/eject-assets/generators/go/index.ts +336 -0
- package/eject-assets/generators/go/models.ts +179 -0
- package/eject-assets/generators/go/naming.ts +49 -0
- package/eject-assets/generators/go/operations.ts +296 -0
- package/eject-assets/generators/go/pagination.ts +194 -0
- package/eject-assets/generators/go/types.ts +60 -0
- package/eject-assets/generators/mock/faker.ts +214 -0
- package/eject-assets/generators/mock/index.ts +35 -0
- package/eject-assets/generators/mock/render.ts +282 -0
- package/eject-assets/generators/mock/sample.ts +316 -0
- package/eject-assets/generators/mock/values.ts +63 -0
- package/eject-assets/generators/php/client.ts +63 -0
- package/eject-assets/generators/php/descriptor.ts +58 -0
- package/eject-assets/generators/php/index.ts +237 -0
- package/eject-assets/generators/php/models.ts +275 -0
- package/eject-assets/generators/php/naming.ts +51 -0
- package/eject-assets/generators/php/operations.ts +232 -0
- package/eject-assets/generators/php/pagination.ts +133 -0
- package/eject-assets/generators/php/types.ts +148 -0
- package/eject-assets/generators/python/client.ts +123 -0
- package/eject-assets/generators/python/descriptor.ts +52 -0
- package/eject-assets/generators/python/index.ts +251 -0
- package/eject-assets/generators/python/models.ts +242 -0
- package/eject-assets/generators/python/naming.ts +46 -0
- package/eject-assets/generators/python/operations.ts +147 -0
- package/eject-assets/generators/python/pagination.ts +128 -0
- package/eject-assets/generators/python/types.ts +54 -0
- package/eject-assets/generators/swr/index.ts +37 -0
- package/eject-assets/generators/swr/render.ts +78 -0
- package/eject-assets/generators/tanstack-query/index.ts +48 -0
- package/eject-assets/generators/tanstack-query/render.ts +346 -0
- package/eject-assets/generators/transformers/index.ts +46 -0
- package/eject-assets/generators/transformers/render.ts +506 -0
- package/eject-assets/generators/typescript/banner.ts +35 -0
- package/eject-assets/generators/typescript/client.ts +254 -0
- package/eject-assets/generators/typescript/descriptor.ts +137 -0
- package/eject-assets/generators/typescript/index.ts +101 -0
- package/eject-assets/generators/typescript/inline-runtime.ts +135 -0
- package/eject-assets/generators/typescript/operation-signature.ts +62 -0
- package/eject-assets/generators/typescript/operation-types.ts +17 -0
- package/eject-assets/generators/typescript/operations.ts +524 -0
- package/eject-assets/generators/typescript/response-headers.ts +74 -0
- package/eject-assets/generators/typescript/type-guards.ts +159 -0
- package/eject-assets/generators/typescript/types.ts +172 -0
- package/eject-assets/generators/zod/index.ts +32 -0
- package/eject-assets/generators/zod/schemas.ts +456 -0
- package/eject-assets/skills/cli-generator/SKILL.md +121 -0
- package/eject-assets/skills/client-generators/SKILL.md +142 -0
- package/eject-assets/skills/go-generator/SKILL.md +96 -0
- package/eject-assets/skills/mock-generator/SKILL.md +50 -0
- package/eject-assets/skills/php-generator/SKILL.md +112 -0
- package/eject-assets/skills/python-generator/SKILL.md +110 -0
- package/eject-assets/skills/swr-generator/SKILL.md +50 -0
- package/eject-assets/skills/tanstack-query-generator/SKILL.md +55 -0
- package/eject-assets/skills/transformers-generator/SKILL.md +47 -0
- package/eject-assets/skills/typescript-generator/SKILL.md +95 -0
- package/eject-assets/skills/zod-generator/SKILL.md +54 -0
- package/lib/authoring/index.d.ts +11 -0
- package/lib/authoring/index.d.ts.map +1 -0
- package/lib/authoring/index.js +42 -0
- package/lib/authoring/index.js.map +1 -0
- package/lib/authoring/naming.d.ts +34 -0
- package/lib/authoring/naming.d.ts.map +1 -0
- package/lib/authoring/naming.js +104 -0
- package/lib/authoring/naming.js.map +1 -0
- package/lib/authoring/operation.d.ts +47 -0
- package/lib/authoring/operation.d.ts.map +1 -0
- package/lib/authoring/operation.js +86 -0
- package/lib/authoring/operation.js.map +1 -0
- package/lib/authoring/options.d.ts +9 -0
- package/lib/authoring/options.d.ts.map +1 -0
- package/lib/authoring/options.js +5 -0
- package/lib/authoring/options.js.map +1 -0
- package/lib/authoring/pagination.d.ts +19 -0
- package/lib/authoring/pagination.d.ts.map +1 -0
- package/lib/authoring/pagination.js +45 -0
- package/lib/authoring/pagination.js.map +1 -0
- package/lib/authoring/printer.d.ts +16 -0
- package/lib/authoring/printer.d.ts.map +1 -0
- package/lib/authoring/printer.js +36 -0
- package/lib/authoring/printer.js.map +1 -0
- package/lib/authoring/reference-page.d.ts +31 -0
- package/lib/authoring/reference-page.d.ts.map +1 -0
- package/lib/authoring/reference-page.js +160 -0
- package/lib/authoring/reference-page.js.map +1 -0
- package/lib/authoring/schema.d.ts +51 -0
- package/lib/authoring/schema.d.ts.map +1 -0
- package/lib/authoring/schema.js +190 -0
- package/lib/authoring/schema.js.map +1 -0
- package/lib/cli-contract.d.ts +126 -0
- package/lib/cli-contract.d.ts.map +1 -0
- package/lib/cli-contract.js +25 -0
- package/lib/cli-contract.js.map +1 -0
- package/lib/{emitters/wrapper-support.d.ts → contracts/typescript.d.ts} +13 -24
- package/lib/contracts/typescript.d.ts.map +1 -0
- package/lib/contracts/typescript.js +87 -0
- package/lib/contracts/typescript.js.map +1 -0
- package/lib/generate.d.ts +10 -10
- package/lib/generate.d.ts.map +1 -1
- package/lib/generate.js +25 -106
- package/lib/generate.js.map +1 -1
- package/lib/generators/cli/docs.d.ts +19 -0
- package/lib/generators/cli/docs.d.ts.map +1 -0
- package/lib/generators/cli/docs.js +187 -0
- package/lib/generators/cli/docs.js.map +1 -0
- package/lib/generators/cli/engine-source.d.ts +5 -0
- package/lib/generators/cli/engine-source.d.ts.map +1 -0
- package/lib/generators/cli/engine-source.js +12 -0
- package/lib/generators/cli/engine-source.js.map +1 -0
- package/lib/generators/cli/index.d.ts +18 -0
- package/lib/generators/cli/index.d.ts.map +1 -0
- package/lib/generators/cli/index.js +67 -0
- package/lib/generators/cli/index.js.map +1 -0
- package/lib/generators/cli/render.d.ts +39 -0
- package/lib/generators/cli/render.d.ts.map +1 -0
- package/lib/generators/cli/render.js +281 -0
- package/lib/generators/cli/render.js.map +1 -0
- package/lib/generators/cli/runtime/cli.d.ts +42 -0
- package/lib/generators/cli/runtime/cli.d.ts.map +1 -0
- package/lib/generators/cli/runtime/cli.js +582 -0
- package/lib/generators/cli/runtime/cli.js.map +1 -0
- package/lib/generators/compatibility.d.ts +10 -0
- package/lib/generators/compatibility.d.ts.map +1 -0
- package/lib/generators/compatibility.js +45 -0
- package/lib/generators/compatibility.js.map +1 -0
- package/lib/generators/go/client.d.ts +5 -0
- package/lib/generators/go/client.d.ts.map +1 -0
- package/lib/generators/go/client.js +34 -0
- package/lib/generators/go/client.js.map +1 -0
- package/lib/generators/go/descriptor.d.ts +6 -0
- package/lib/generators/go/descriptor.d.ts.map +1 -0
- package/lib/generators/go/descriptor.js +26 -0
- package/lib/generators/go/descriptor.js.map +1 -0
- package/lib/generators/go/index.d.ts +14 -0
- package/lib/generators/go/index.d.ts.map +1 -0
- package/lib/generators/go/index.js +240 -0
- package/lib/generators/go/index.js.map +1 -0
- package/lib/generators/go/models.d.ts +4 -0
- package/lib/generators/go/models.d.ts.map +1 -0
- package/lib/generators/go/models.js +125 -0
- package/lib/generators/go/models.js.map +1 -0
- package/lib/generators/go/naming.d.ts +15 -0
- package/lib/generators/go/naming.d.ts.map +1 -0
- package/lib/generators/go/naming.js +36 -0
- package/lib/generators/go/naming.js.map +1 -0
- package/lib/generators/go/operations.d.ts +16 -0
- package/lib/generators/go/operations.d.ts.map +1 -0
- package/lib/generators/go/operations.js +200 -0
- package/lib/generators/go/operations.js.map +1 -0
- package/lib/generators/go/pagination.d.ts +5 -0
- package/lib/generators/go/pagination.d.ts.map +1 -0
- package/lib/generators/go/pagination.js +93 -0
- package/lib/generators/go/pagination.js.map +1 -0
- package/lib/generators/go/types.d.ts +4 -0
- package/lib/generators/go/types.d.ts.map +1 -0
- package/lib/generators/go/types.js +48 -0
- package/lib/generators/go/types.js.map +1 -0
- package/lib/generators/index.d.ts +2 -3
- package/lib/generators/index.d.ts.map +1 -1
- package/lib/generators/index.js +31 -53
- package/lib/generators/index.js.map +1 -1
- package/lib/generators/meta.d.ts +13 -0
- package/lib/generators/meta.d.ts.map +1 -0
- package/lib/generators/meta.js +157 -0
- package/lib/generators/meta.js.map +1 -0
- package/lib/{emitters → generators/mock}/faker.d.ts +4 -5
- package/lib/generators/mock/faker.d.ts.map +1 -0
- package/lib/generators/mock/faker.js +180 -0
- package/lib/generators/mock/faker.js.map +1 -0
- package/lib/generators/{mock.d.ts → mock/index.d.ts} +2 -2
- package/lib/generators/mock/index.d.ts.map +1 -0
- package/lib/generators/{mock.js → mock/index.js} +8 -8
- package/lib/generators/mock/index.js.map +1 -0
- package/lib/{emitters/mock.d.ts → generators/mock/render.d.ts} +2 -3
- package/lib/generators/mock/render.d.ts.map +1 -0
- package/lib/generators/mock/render.js +228 -0
- package/lib/generators/mock/render.js.map +1 -0
- package/lib/{emitters → generators/mock}/sample.d.ts +1 -2
- package/lib/generators/mock/sample.d.ts.map +1 -0
- package/lib/generators/mock/sample.js.map +1 -0
- package/lib/generators/mock/values.d.ts +33 -0
- package/lib/generators/mock/values.d.ts.map +1 -0
- package/lib/generators/mock/values.js +46 -0
- package/lib/generators/mock/values.js.map +1 -0
- package/lib/generators/options.d.ts +7 -0
- package/lib/generators/options.d.ts.map +1 -0
- package/lib/generators/options.js +74 -0
- package/lib/generators/options.js.map +1 -0
- package/lib/generators/php/client.d.ts +5 -0
- package/lib/generators/php/client.d.ts.map +1 -0
- package/lib/generators/php/client.js +38 -0
- package/lib/generators/php/client.js.map +1 -0
- package/lib/generators/php/descriptor.d.ts +7 -0
- package/lib/generators/php/descriptor.d.ts.map +1 -0
- package/lib/generators/php/descriptor.js +42 -0
- package/lib/generators/php/descriptor.js.map +1 -0
- package/lib/generators/php/index.d.ts +14 -0
- package/lib/generators/php/index.d.ts.map +1 -0
- package/lib/generators/php/index.js +166 -0
- package/lib/generators/php/index.js.map +1 -0
- package/lib/generators/php/models.d.ts +8 -0
- package/lib/generators/php/models.d.ts.map +1 -0
- package/lib/generators/php/models.js +200 -0
- package/lib/generators/php/models.js.map +1 -0
- package/lib/generators/php/naming.d.ts +16 -0
- package/lib/generators/php/naming.d.ts.map +1 -0
- package/lib/generators/php/naming.js +31 -0
- package/lib/generators/php/naming.js.map +1 -0
- package/lib/generators/php/operations.d.ts +21 -0
- package/lib/generators/php/operations.d.ts.map +1 -0
- package/lib/generators/php/operations.js +156 -0
- package/lib/generators/php/operations.js.map +1 -0
- package/lib/generators/php/pagination.d.ts +5 -0
- package/lib/generators/php/pagination.d.ts.map +1 -0
- package/lib/generators/php/pagination.js +68 -0
- package/lib/generators/php/pagination.js.map +1 -0
- package/lib/generators/php/types.d.ts +27 -0
- package/lib/generators/php/types.d.ts.map +1 -0
- package/lib/generators/php/types.js +128 -0
- package/lib/generators/php/types.js.map +1 -0
- package/lib/generators/python/client.d.ts +6 -0
- package/lib/generators/python/client.d.ts.map +1 -0
- package/lib/generators/python/client.js +80 -0
- package/lib/generators/python/client.js.map +1 -0
- package/lib/generators/python/descriptor.d.ts +9 -0
- package/lib/generators/python/descriptor.d.ts.map +1 -0
- package/lib/generators/python/descriptor.js +38 -0
- package/lib/generators/python/descriptor.js.map +1 -0
- package/lib/generators/python/index.d.ts +15 -0
- package/lib/generators/python/index.d.ts.map +1 -0
- package/lib/generators/python/index.js +197 -0
- package/lib/generators/python/index.js.map +1 -0
- package/lib/generators/python/models.d.ts +31 -0
- package/lib/generators/python/models.d.ts.map +1 -0
- package/lib/generators/python/models.js +203 -0
- package/lib/generators/python/models.js.map +1 -0
- package/lib/generators/python/naming.d.ts +22 -0
- package/lib/generators/python/naming.d.ts.map +1 -0
- package/lib/generators/python/naming.js +28 -0
- package/lib/generators/python/naming.js.map +1 -0
- package/lib/generators/python/operations.d.ts +4 -0
- package/lib/generators/python/operations.d.ts.map +1 -0
- package/lib/generators/python/operations.js +108 -0
- package/lib/generators/python/operations.js.map +1 -0
- package/lib/generators/python/pagination.d.ts +5 -0
- package/lib/generators/python/pagination.d.ts.map +1 -0
- package/lib/generators/python/pagination.js +95 -0
- package/lib/generators/python/pagination.js.map +1 -0
- package/lib/generators/python/types.d.ts +4 -0
- package/lib/generators/python/types.d.ts.map +1 -0
- package/lib/generators/python/types.js +45 -0
- package/lib/generators/python/types.js.map +1 -0
- package/lib/generators/resolve.d.ts.map +1 -1
- package/lib/generators/resolve.js +92 -13
- package/lib/generators/resolve.js.map +1 -1
- package/lib/generators/{swr.d.ts → swr/index.d.ts} +3 -3
- package/lib/generators/swr/index.d.ts.map +1 -0
- package/lib/generators/{swr.js → swr/index.js} +7 -10
- package/lib/generators/swr/index.js.map +1 -0
- package/lib/{emitters/swr.d.ts → generators/swr/render.d.ts} +2 -4
- package/lib/generators/swr/render.d.ts.map +1 -0
- package/lib/generators/swr/render.js +57 -0
- package/lib/generators/swr/render.js.map +1 -0
- package/lib/generators/{tanstack-query.d.ts → tanstack-query/index.d.ts} +3 -3
- package/lib/generators/tanstack-query/index.d.ts.map +1 -0
- package/lib/generators/{tanstack-query.js → tanstack-query/index.js} +11 -10
- package/lib/generators/tanstack-query/index.js.map +1 -0
- package/lib/{emitters/tanstack-query.d.ts → generators/tanstack-query/render.d.ts} +6 -5
- package/lib/generators/tanstack-query/render.d.ts.map +1 -0
- package/lib/{emitters/tanstack-query.js → generators/tanstack-query/render.js} +33 -21
- package/lib/generators/tanstack-query/render.js.map +1 -0
- package/lib/generators/{transformers.d.ts → transformers/index.d.ts} +2 -2
- package/lib/generators/transformers/index.d.ts.map +1 -0
- package/lib/generators/{transformers.js → transformers/index.js} +11 -8
- package/lib/generators/transformers/index.js.map +1 -0
- package/lib/{emitters/transformers.d.ts → generators/transformers/render.d.ts} +2 -2
- package/lib/generators/transformers/render.d.ts.map +1 -0
- package/lib/{emitters/transformers.js → generators/transformers/render.js} +125 -165
- package/lib/generators/transformers/render.js.map +1 -0
- package/lib/generators/types.d.ts +190 -12
- package/lib/generators/types.d.ts.map +1 -1
- package/lib/generators/typescript/banner.d.ts +12 -0
- package/lib/generators/typescript/banner.d.ts.map +1 -0
- package/lib/{emitters/emit-options.js → generators/typescript/banner.js} +2 -3
- package/lib/generators/typescript/banner.js.map +1 -0
- package/lib/generators/typescript/client.d.ts +25 -0
- package/lib/generators/typescript/client.d.ts.map +1 -0
- package/lib/generators/typescript/client.js +207 -0
- package/lib/generators/typescript/client.js.map +1 -0
- package/lib/generators/typescript/descriptor.d.ts +11 -0
- package/lib/generators/typescript/descriptor.d.ts.map +1 -0
- package/lib/generators/typescript/descriptor.js +97 -0
- package/lib/generators/typescript/descriptor.js.map +1 -0
- package/lib/generators/typescript/index.d.ts +20 -0
- package/lib/generators/typescript/index.d.ts.map +1 -0
- package/lib/generators/typescript/index.js +80 -0
- package/lib/generators/typescript/index.js.map +1 -0
- package/lib/generators/typescript/inline-runtime.d.ts +21 -0
- package/lib/generators/typescript/inline-runtime.d.ts.map +1 -0
- package/lib/generators/typescript/inline-runtime.js +114 -0
- package/lib/generators/typescript/inline-runtime.js.map +1 -0
- package/lib/generators/typescript/operation-signature.d.ts +23 -0
- package/lib/generators/typescript/operation-signature.d.ts.map +1 -0
- package/lib/generators/typescript/operation-signature.js +41 -0
- package/lib/generators/typescript/operation-signature.js.map +1 -0
- package/lib/generators/typescript/operation-types.d.ts +9 -0
- package/lib/generators/typescript/operation-types.d.ts.map +1 -0
- package/lib/generators/typescript/operation-types.js +11 -0
- package/lib/generators/typescript/operation-types.js.map +1 -0
- package/lib/generators/typescript/operations.d.ts +60 -0
- package/lib/generators/typescript/operations.d.ts.map +1 -0
- package/lib/generators/typescript/operations.js +386 -0
- package/lib/generators/typescript/operations.js.map +1 -0
- package/lib/generators/typescript/response-headers.d.ts +12 -0
- package/lib/generators/typescript/response-headers.d.ts.map +1 -0
- package/lib/generators/typescript/response-headers.js +40 -0
- package/lib/generators/typescript/response-headers.js.map +1 -0
- package/lib/generators/typescript/runtime/auth.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/auth.js.map +1 -0
- package/lib/{runtime → generators/typescript/runtime}/create-client.d.ts +7 -2
- package/lib/generators/typescript/runtime/create-client.d.ts.map +1 -0
- package/lib/{runtime → generators/typescript/runtime}/create-client.js +84 -30
- package/lib/generators/typescript/runtime/create-client.js.map +1 -0
- package/lib/generators/typescript/runtime/errors.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/errors.js.map +1 -0
- package/lib/generators/typescript/runtime/index.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/index.js.map +1 -0
- package/lib/generators/typescript/runtime/multipart.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/multipart.js.map +1 -0
- package/lib/{runtime → generators/typescript/runtime}/paginate.d.ts +2 -2
- package/lib/generators/typescript/runtime/paginate.d.ts.map +1 -0
- package/lib/{runtime → generators/typescript/runtime}/paginate.js +12 -12
- package/lib/generators/typescript/runtime/paginate.js.map +1 -0
- package/lib/generators/typescript/runtime/parse.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/parse.js.map +1 -0
- package/lib/generators/typescript/runtime/retry.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/retry.js.map +1 -0
- package/lib/generators/typescript/runtime/send.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/send.js.map +1 -0
- package/lib/generators/typescript/runtime/setup.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/setup.js.map +1 -0
- package/lib/generators/typescript/runtime/sse.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/sse.js.map +1 -0
- package/lib/{runtime → generators/typescript/runtime}/types.d.ts +17 -95
- package/lib/generators/typescript/runtime/types.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/types.js.map +1 -0
- package/lib/generators/typescript/runtime/url.d.ts.map +1 -0
- package/lib/generators/typescript/runtime/url.js.map +1 -0
- package/lib/generators/typescript/type-guards.d.ts +4 -0
- package/lib/generators/typescript/type-guards.d.ts.map +1 -0
- package/lib/{emitters → generators/typescript}/type-guards.js +18 -52
- package/lib/generators/typescript/type-guards.js.map +1 -0
- package/lib/generators/typescript/types.d.ts +8 -0
- package/lib/generators/typescript/types.d.ts.map +1 -0
- package/lib/generators/typescript/types.js +132 -0
- package/lib/generators/typescript/types.js.map +1 -0
- package/lib/generators/{zod.d.ts → zod/index.d.ts} +2 -2
- package/lib/generators/zod/index.d.ts.map +1 -0
- package/lib/generators/{zod.js → zod/index.js} +5 -7
- package/lib/generators/zod/index.js.map +1 -0
- package/lib/{emitters/zod.d.ts → generators/zod/schemas.d.ts} +4 -5
- package/lib/generators/zod/schemas.d.ts.map +1 -0
- package/lib/{emitters/zod.js → generators/zod/schemas.js} +118 -154
- package/lib/generators/zod/schemas.js.map +1 -0
- package/lib/index.d.ts +8 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +18 -11
- package/lib/index.js.map +1 -1
- package/lib/intermediate-representation/build.d.ts +8 -1
- package/lib/intermediate-representation/build.d.ts.map +1 -1
- package/lib/intermediate-representation/build.js +59 -4
- package/lib/intermediate-representation/build.js.map +1 -1
- package/lib/intermediate-representation/model.d.ts +26 -1
- package/lib/intermediate-representation/model.d.ts.map +1 -1
- package/lib/intermediate-representation/model.js.map +1 -1
- package/lib/intermediate-representation/sanitize-identifiers.d.ts +1 -10
- package/lib/intermediate-representation/sanitize-identifiers.d.ts.map +1 -1
- package/lib/intermediate-representation/sanitize-identifiers.js +37 -38
- package/lib/intermediate-representation/sanitize-identifiers.js.map +1 -1
- package/lib/{emitters/pagination.d.ts → pagination.d.ts} +39 -15
- package/lib/pagination.d.ts.map +1 -0
- package/lib/{emitters/pagination.js → pagination.js} +13 -52
- package/lib/pagination.js.map +1 -0
- package/lib/pipeline.d.ts +17 -0
- package/lib/pipeline.d.ts.map +1 -0
- package/lib/pipeline.js +244 -0
- package/lib/pipeline.js.map +1 -0
- package/lib/plugin.d.ts +4 -4
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +12 -9
- package/lib/plugin.js.map +1 -1
- package/lib/printers/go.d.ts +33 -0
- package/lib/printers/go.d.ts.map +1 -0
- package/lib/printers/go.js +209 -0
- package/lib/printers/go.js.map +1 -0
- package/lib/printers/index.d.ts +5 -0
- package/lib/printers/index.d.ts.map +1 -0
- package/lib/printers/index.js +9 -0
- package/lib/printers/index.js.map +1 -0
- package/lib/printers/php.d.ts +21 -0
- package/lib/printers/php.d.ts.map +1 -0
- package/lib/printers/php.js +68 -0
- package/lib/printers/php.js.map +1 -0
- package/lib/printers/python.d.ts +31 -0
- package/lib/printers/python.d.ts.map +1 -0
- package/lib/printers/python.js +101 -0
- package/lib/printers/python.js.map +1 -0
- package/lib/printers/typescript.d.ts +82 -0
- package/lib/printers/typescript.d.ts.map +1 -0
- package/lib/printers/typescript.js +268 -0
- package/lib/printers/typescript.js.map +1 -0
- package/lib/reserved-names.d.ts +8 -0
- package/lib/reserved-names.d.ts.map +1 -0
- package/lib/{emitters/reserved-names.js → reserved-names.js} +16 -27
- package/lib/reserved-names.js.map +1 -0
- package/lib/runtime-contract.d.ts +62 -2
- package/lib/runtime-contract.d.ts.map +1 -1
- package/lib/runtime-contract.js +3 -3
- package/lib/runtime-contract.js.map +1 -1
- package/lib/runtime-sources/go.d.ts +2 -0
- package/lib/runtime-sources/go.d.ts.map +1 -0
- package/lib/runtime-sources/go.js +3 -0
- package/lib/runtime-sources/go.js.map +1 -0
- package/lib/runtime-sources/php.d.ts +2 -0
- package/lib/runtime-sources/php.d.ts.map +1 -0
- package/lib/runtime-sources/php.js +3 -0
- package/lib/runtime-sources/php.js.map +1 -0
- package/lib/runtime-sources/python.d.ts +12 -0
- package/lib/runtime-sources/python.d.ts.map +1 -0
- package/lib/runtime-sources/python.js +12 -0
- package/lib/runtime-sources/python.js.map +1 -0
- package/lib/runtime-sources/typescript.d.ts +36 -0
- package/lib/runtime-sources/typescript.d.ts.map +1 -0
- package/lib/runtime-sources/typescript.js +152 -0
- package/lib/runtime-sources/typescript.js.map +1 -0
- package/lib/runtime-sources.d.ts +5 -0
- package/lib/runtime-sources.d.ts.map +1 -0
- package/lib/runtime-sources.js +10 -0
- package/lib/runtime-sources.js.map +1 -0
- package/lib/setup-bake.d.ts.map +1 -0
- package/lib/{emitters/setup-bake.js → setup-bake.js} +11 -2
- package/lib/setup-bake.js.map +1 -0
- package/lib/types.d.ts +38 -8
- package/lib/types.d.ts.map +1 -1
- package/package.json +40 -4
- package/lib/emitters/auth.d.ts +0 -14
- package/lib/emitters/auth.d.ts.map +0 -1
- package/lib/emitters/auth.js +0 -30
- package/lib/emitters/auth.js.map +0 -1
- package/lib/emitters/client-assembly.d.ts +0 -15
- package/lib/emitters/client-assembly.d.ts.map +0 -1
- package/lib/emitters/client-assembly.js +0 -358
- package/lib/emitters/client-assembly.js.map +0 -1
- package/lib/emitters/descriptor.d.ts +0 -22
- package/lib/emitters/descriptor.d.ts.map +0 -1
- package/lib/emitters/descriptor.js +0 -199
- package/lib/emitters/descriptor.js.map +0 -1
- package/lib/emitters/emit-options.d.ts +0 -67
- package/lib/emitters/emit-options.d.ts.map +0 -1
- package/lib/emitters/emit-options.js.map +0 -1
- package/lib/emitters/faker.d.ts.map +0 -1
- package/lib/emitters/faker.js +0 -221
- package/lib/emitters/faker.js.map +0 -1
- package/lib/emitters/identifier.d.ts +0 -34
- package/lib/emitters/identifier.d.ts.map +0 -1
- package/lib/emitters/identifier.js +0 -104
- package/lib/emitters/identifier.js.map +0 -1
- package/lib/emitters/inline-runtime.d.ts +0 -11
- package/lib/emitters/inline-runtime.d.ts.map +0 -1
- package/lib/emitters/inline-runtime.js +0 -99
- package/lib/emitters/inline-runtime.js.map +0 -1
- package/lib/emitters/jsdoc.d.ts +0 -9
- package/lib/emitters/jsdoc.d.ts.map +0 -1
- package/lib/emitters/jsdoc.js +0 -83
- package/lib/emitters/jsdoc.js.map +0 -1
- package/lib/emitters/mock.d.ts.map +0 -1
- package/lib/emitters/mock.js +0 -265
- package/lib/emitters/mock.js.map +0 -1
- package/lib/emitters/operation-aliases.d.ts +0 -27
- package/lib/emitters/operation-aliases.d.ts.map +0 -1
- package/lib/emitters/operation-aliases.js +0 -150
- package/lib/emitters/operation-aliases.js.map +0 -1
- package/lib/emitters/operation-signature.d.ts +0 -24
- package/lib/emitters/operation-signature.d.ts.map +0 -1
- package/lib/emitters/operation-signature.js +0 -42
- package/lib/emitters/operation-signature.js.map +0 -1
- package/lib/emitters/operation-types.d.ts +0 -32
- package/lib/emitters/operation-types.d.ts.map +0 -1
- package/lib/emitters/operation-types.js +0 -117
- package/lib/emitters/operation-types.js.map +0 -1
- package/lib/emitters/operations.d.ts +0 -41
- package/lib/emitters/operations.d.ts.map +0 -1
- package/lib/emitters/operations.js +0 -35
- package/lib/emitters/operations.js.map +0 -1
- package/lib/emitters/pagination.d.ts.map +0 -1
- package/lib/emitters/pagination.js.map +0 -1
- package/lib/emitters/reserved-names.d.ts +0 -5
- package/lib/emitters/reserved-names.d.ts.map +0 -1
- package/lib/emitters/reserved-names.js.map +0 -1
- package/lib/emitters/response-headers.d.ts +0 -14
- package/lib/emitters/response-headers.d.ts.map +0 -1
- package/lib/emitters/response-headers.js +0 -91
- package/lib/emitters/response-headers.js.map +0 -1
- package/lib/emitters/runtime-sources.d.ts +0 -16
- package/lib/emitters/runtime-sources.d.ts.map +0 -1
- package/lib/emitters/runtime-sources.js +0 -16
- package/lib/emitters/runtime-sources.js.map +0 -1
- package/lib/emitters/sample.d.ts.map +0 -1
- package/lib/emitters/sample.js.map +0 -1
- package/lib/emitters/setup-bake.d.ts.map +0 -1
- package/lib/emitters/setup-bake.js.map +0 -1
- package/lib/emitters/sse.d.ts +0 -10
- package/lib/emitters/sse.d.ts.map +0 -1
- package/lib/emitters/sse.js +0 -46
- package/lib/emitters/sse.js.map +0 -1
- package/lib/emitters/support.d.ts +0 -18
- package/lib/emitters/support.d.ts.map +0 -1
- package/lib/emitters/support.js +0 -37
- package/lib/emitters/support.js.map +0 -1
- package/lib/emitters/swr.d.ts.map +0 -1
- package/lib/emitters/swr.js +0 -88
- package/lib/emitters/swr.js.map +0 -1
- package/lib/emitters/tanstack-query.d.ts.map +0 -1
- package/lib/emitters/tanstack-query.js.map +0 -1
- package/lib/emitters/transformers.d.ts.map +0 -1
- package/lib/emitters/transformers.js.map +0 -1
- package/lib/emitters/ts.d.ts +0 -42
- package/lib/emitters/ts.d.ts.map +0 -1
- package/lib/emitters/ts.js +0 -116
- package/lib/emitters/ts.js.map +0 -1
- package/lib/emitters/type-guards.d.ts +0 -21
- package/lib/emitters/type-guards.d.ts.map +0 -1
- package/lib/emitters/type-guards.js.map +0 -1
- package/lib/emitters/types.d.ts +0 -15
- package/lib/emitters/types.d.ts.map +0 -1
- package/lib/emitters/types.js +0 -125
- package/lib/emitters/types.js.map +0 -1
- package/lib/emitters/wrapper-support.d.ts.map +0 -1
- package/lib/emitters/wrapper-support.js +0 -127
- package/lib/emitters/wrapper-support.js.map +0 -1
- package/lib/emitters/zod.d.ts.map +0 -1
- package/lib/emitters/zod.js.map +0 -1
- package/lib/generators/anchor.d.ts +0 -9
- package/lib/generators/anchor.d.ts.map +0 -1
- package/lib/generators/anchor.js +0 -10
- package/lib/generators/anchor.js.map +0 -1
- package/lib/generators/mock.d.ts.map +0 -1
- package/lib/generators/mock.js.map +0 -1
- package/lib/generators/sdk.d.ts +0 -12
- package/lib/generators/sdk.d.ts.map +0 -1
- package/lib/generators/sdk.js +0 -26
- package/lib/generators/sdk.js.map +0 -1
- package/lib/generators/swr.d.ts.map +0 -1
- package/lib/generators/swr.js.map +0 -1
- package/lib/generators/tanstack-query.d.ts.map +0 -1
- package/lib/generators/tanstack-query.js.map +0 -1
- package/lib/generators/transformers.d.ts.map +0 -1
- package/lib/generators/transformers.js.map +0 -1
- package/lib/generators/zod.d.ts.map +0 -1
- package/lib/generators/zod.js.map +0 -1
- package/lib/runtime/auth.d.ts.map +0 -1
- package/lib/runtime/auth.js.map +0 -1
- package/lib/runtime/create-client.d.ts.map +0 -1
- package/lib/runtime/create-client.js.map +0 -1
- package/lib/runtime/errors.d.ts.map +0 -1
- package/lib/runtime/errors.js.map +0 -1
- package/lib/runtime/index.d.ts.map +0 -1
- package/lib/runtime/index.js.map +0 -1
- package/lib/runtime/multipart.d.ts.map +0 -1
- package/lib/runtime/multipart.js.map +0 -1
- package/lib/runtime/paginate.d.ts.map +0 -1
- package/lib/runtime/paginate.js.map +0 -1
- package/lib/runtime/parse.d.ts.map +0 -1
- package/lib/runtime/parse.js.map +0 -1
- package/lib/runtime/retry.d.ts.map +0 -1
- package/lib/runtime/retry.js.map +0 -1
- package/lib/runtime/send.d.ts.map +0 -1
- package/lib/runtime/send.js.map +0 -1
- package/lib/runtime/setup.d.ts.map +0 -1
- package/lib/runtime/setup.js.map +0 -1
- package/lib/runtime/sse.d.ts.map +0 -1
- package/lib/runtime/sse.js.map +0 -1
- package/lib/runtime/types.d.ts.map +0 -1
- package/lib/runtime/types.js.map +0 -1
- package/lib/runtime/url.d.ts.map +0 -1
- package/lib/runtime/url.js.map +0 -1
- /package/lib/{emitters → generators/mock}/sample.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/auth.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/auth.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/errors.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/errors.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/index.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/index.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/multipart.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/multipart.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/parse.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/parse.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/retry.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/retry.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/send.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/send.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/setup.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/setup.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/sse.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/sse.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/types.js +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/url.d.ts +0 -0
- /package/lib/{runtime → generators/typescript/runtime}/url.js +0 -0
- /package/lib/{emitters/setup-bake.d.ts → setup-bake.d.ts} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Package-mode descriptor emission: the identifier plan for a generated module that
|
|
2
|
+
// shares scope with the `@redocly/client-generator` wiring, plus the `OPERATIONS`
|
|
3
|
+
// descriptor map (`satisfies Record<string, OperationDescriptor>` — the semver skew
|
|
4
|
+
// guard against the runtime contract in src/runtime/types.ts). Text templates.
|
|
5
|
+
import { allOperations, securityRequirements, WIRING_NAMES, } from '@redocly/client-generator';
|
|
6
|
+
import { codeLiteral, uniqueIdent } from '@redocly/client-generator/printers/typescript';
|
|
7
|
+
import { isTypedMultipart } from "./operation-types.js";
|
|
8
|
+
import { flatInputShape, responseText } from "./operations.js";
|
|
9
|
+
import { responseHeaderSpecs } from "./response-headers.js";
|
|
10
|
+
import { tsJsdoc } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Operation-name → emitted-identifier plan. The full reserved set (wiring + imported
|
|
13
|
+
* bindings, computed from the model FIRST) is seeded before any operation
|
|
14
|
+
* is sanitized, so collisions rename the operation (`configure` → `configure_2`)
|
|
15
|
+
* deterministically regardless of document order.
|
|
16
|
+
*/
|
|
17
|
+
export function packageIdents(model) {
|
|
18
|
+
const used = new Set(WIRING_NAMES);
|
|
19
|
+
const idents = new Map();
|
|
20
|
+
for (const op of allOperations(model.services))
|
|
21
|
+
idents.set(op.name, uniqueIdent(op.name, used));
|
|
22
|
+
return idents;
|
|
23
|
+
}
|
|
24
|
+
/** One operation's OperationDescriptor as plain data (only non-default fields present). */
|
|
25
|
+
function descriptorValue(op, schemes, dateType, pagination, schemas = [], argsStyle = 'grouped') {
|
|
26
|
+
const params = [...op.pathParams, ...op.queryParams, ...op.headerParams, ...op.cookieParams].map((p) => ({
|
|
27
|
+
name: p.name,
|
|
28
|
+
in: p.in,
|
|
29
|
+
...(p.style !== undefined ? { style: p.style } : {}),
|
|
30
|
+
...(p.explode !== undefined ? { explode: p.explode } : {}),
|
|
31
|
+
...(p.allowReserved !== undefined ? { allowReserved: p.allowReserved } : {}),
|
|
32
|
+
}));
|
|
33
|
+
const security = securityRequirements(op, { securitySchemes: schemes });
|
|
34
|
+
const sse = op.sse !== undefined;
|
|
35
|
+
const responseKind = sse ? 'sse' : responseText(op.successResponses, dateType).kind;
|
|
36
|
+
const responseHeaders = responseHeaderSpecs(op.successResponseHeaders, schemas);
|
|
37
|
+
return {
|
|
38
|
+
// The spec's operationId, NOT the (possibly renamed) map key: `id` drives middleware
|
|
39
|
+
// targeting (`ctx.operation.id`) and must match inline mode's `operationMetaExpr`.
|
|
40
|
+
// The wire/middleware identity stays the SPEC operationId even when the emitted
|
|
41
|
+
// function name was renamed away from a collision (`configure` → `configure_2`).
|
|
42
|
+
id: op.specName ?? op.name,
|
|
43
|
+
method: op.method.toUpperCase(),
|
|
44
|
+
path: op.path,
|
|
45
|
+
...(op.tags.length > 0 ? { tags: op.tags } : {}),
|
|
46
|
+
...(params.length > 0 ? { params } : {}),
|
|
47
|
+
...(op.requestBody
|
|
48
|
+
? {
|
|
49
|
+
body: {
|
|
50
|
+
contentType: op.requestBody.contentType,
|
|
51
|
+
...(isTypedMultipart(op.requestBody) ? { multipart: true } : {}),
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
: {}),
|
|
55
|
+
...(responseKind !== 'json' ? { responseKind } : {}),
|
|
56
|
+
...(op.sse === undefined ? {} : { sseDataKind: op.sse.dataKind }),
|
|
57
|
+
...(security.length > 0 ? { security } : {}),
|
|
58
|
+
...(responseHeaders === undefined ? {} : { responseHeaders }),
|
|
59
|
+
// The resolved spec is already normalized with stable key order (see pagination.ts).
|
|
60
|
+
...(pagination?.has(op.name) ? { pagination: pagination.get(op.name).spec } : {}),
|
|
61
|
+
// A merged call cannot carry one name for two layers, so an operation whose names
|
|
62
|
+
// collide keeps the namespaced shape — its `<Op>Variables` says so, and the runtime
|
|
63
|
+
// has to agree or the typed call would be rejected.
|
|
64
|
+
...(argsStyle === 'flat' && 'collisions' in flatInputShape(op, schemas)
|
|
65
|
+
? { argsStyle: 'grouped' }
|
|
66
|
+
: {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** `export const OPERATIONS = {…} as const satisfies …` + the derived unions. */
|
|
70
|
+
export function renderDescriptors(model, idents, dateType, pagination, argsStyle = 'grouped') {
|
|
71
|
+
const ops = allOperations(model.services);
|
|
72
|
+
if (ops.length === 0)
|
|
73
|
+
return '';
|
|
74
|
+
const entryLines = ops.map((op, index) => {
|
|
75
|
+
const value = codeLiteral(descriptorValue(op, model.securitySchemes, dateType, pagination, model.schemas, argsStyle));
|
|
76
|
+
return ` ${idents.get(op.name)}: ${value}${index === ops.length - 1 ? '' : ','}`;
|
|
77
|
+
});
|
|
78
|
+
const blocks = [
|
|
79
|
+
[
|
|
80
|
+
...tsJsdoc('The wire-shape descriptor for every operation, keyed by operationId — the data the\n' +
|
|
81
|
+
'runtime routes requests by. Also minification-safe static metadata (method, path,\n' +
|
|
82
|
+
'tags) for cache keys, tracing span names, and request logging.', undefined, ''),
|
|
83
|
+
'export const OPERATIONS = {',
|
|
84
|
+
...entryLines,
|
|
85
|
+
'} as const satisfies Record<string, OperationDescriptor>;',
|
|
86
|
+
].join('\n'),
|
|
87
|
+
'export type OperationId = (typeof OPERATIONS)[keyof typeof OPERATIONS]["id"];',
|
|
88
|
+
'export type OperationPath = (typeof OPERATIONS)[keyof typeof OPERATIONS]["path"];',
|
|
89
|
+
];
|
|
90
|
+
if (ops.some((op) => op.tags.length > 0)) {
|
|
91
|
+
blocks.push('export type OperationTag = Extract<(typeof OPERATIONS)[keyof typeof OPERATIONS], {\n' +
|
|
92
|
+
' tags: readonly string[];\n' +
|
|
93
|
+
'}>["tags"][number];');
|
|
94
|
+
}
|
|
95
|
+
return blocks.join('\n\n');
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../../src/generators/typescript/descriptor.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,kFAAkF;AAClF,oFAAoF;AACpF,+EAA+E;AAE/E,OAAO,EACL,aAAa,EAOb,oBAAoB,EAEpB,YAAY,GACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAe;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAS,YAAY,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,EAAE,IAAI,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAChG,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2FAA2F;AAC3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AgE,EAClE,SAAS,EACT,EAAE,CACH;YACD,6BAA6B;YAC7B,GAAG,UAAU;YACb,2DAA2D;SAC5D,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,+EAA+E;QAC/E,mFAAmF;KACpF,CAAC;IACF,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,IAAI,CACT,sFAAsF;YACpF,gCAAgC;YAChC,qBAAqB,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CodeSample, type Generator, type OperationModel, type SampleContext } from '@redocly/client-generator';
|
|
2
|
+
/**
|
|
3
|
+
* The default generator: the full typed client (model types + runtime + endpoints).
|
|
4
|
+
* Other generators (zod, framework hooks) emit *additional* files alongside.
|
|
5
|
+
*
|
|
6
|
+
* `single` mode writes the whole client to the `--output` path. `split` mode derives
|
|
7
|
+
* two sibling files from that anchor — `<stem>.schemas.ts` (model types, enums,
|
|
8
|
+
* const-objects, type guards; skipped when the document declares no schemas) and
|
|
9
|
+
* `<stem>.ts` (everything else, which `export *`s the schemas module).
|
|
10
|
+
*/
|
|
11
|
+
export declare const typescriptGenerator: Generator;
|
|
12
|
+
/**
|
|
13
|
+
* The client's own reference page, written when `client.docs` is on. Its snippets come from
|
|
14
|
+
* `typescriptSample` below, so the page shows the calling convention this run generated —
|
|
15
|
+
* `argsStyle` included.
|
|
16
|
+
*/
|
|
17
|
+
export declare const typescriptDocs: Generator;
|
|
18
|
+
/** One idiomatic TS call per operation, for `x-codeSamples` and the SDK reference pages. */
|
|
19
|
+
export declare function typescriptSample(op: OperationModel, ctx: SampleContext): CodeSample;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/typescript/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EAEnB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAMnC;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAkBjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAgB5B,CAAC;AAEF,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,UAAU,CAuBnF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { renderReferencePage, } from '@redocly/client-generator';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { emitClientSingleFile, emitClientSplit, emitRuntimeFiles } from "./client.js";
|
|
4
|
+
import { packageIdents } from "./descriptor.js";
|
|
5
|
+
/**
|
|
6
|
+
* The default generator: the full typed client (model types + runtime + endpoints).
|
|
7
|
+
* Other generators (zod, framework hooks) emit *additional* files alongside.
|
|
8
|
+
*
|
|
9
|
+
* `single` mode writes the whole client to the `--output` path. `split` mode derives
|
|
10
|
+
* two sibling files from that anchor — `<stem>.schemas.ts` (model types, enums,
|
|
11
|
+
* const-objects, type guards; skipped when the document declares no schemas) and
|
|
12
|
+
* `<stem>.ts` (everything else, which `export *`s the schemas module).
|
|
13
|
+
*/
|
|
14
|
+
export const typescriptGenerator = ({ model, output, outputMode, emit }) => {
|
|
15
|
+
// `runtime: 'module'` adds the per-needs runtime files beside the client.
|
|
16
|
+
const runtime = emitRuntimeFiles(model, emit).map(({ name, content }) => ({
|
|
17
|
+
path: join(output.dir, 'runtime', name),
|
|
18
|
+
content,
|
|
19
|
+
}));
|
|
20
|
+
if (outputMode === 'split') {
|
|
21
|
+
const { dir, stem } = output;
|
|
22
|
+
const { entry, schemas } = emitClientSplit(model, emit, stem);
|
|
23
|
+
return [
|
|
24
|
+
...(schemas === undefined
|
|
25
|
+
? []
|
|
26
|
+
: [{ path: join(dir, `${stem}.schemas.ts`), content: schemas }]),
|
|
27
|
+
{ path: output.path, content: entry },
|
|
28
|
+
...runtime,
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
return [{ path: output.path, content: emitClientSingleFile(model, emit) }, ...runtime];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The client's own reference page, written when `client.docs` is on. Its snippets come from
|
|
35
|
+
* `typescriptSample` below, so the page shows the calling convention this run generated —
|
|
36
|
+
* `argsStyle` included.
|
|
37
|
+
*/
|
|
38
|
+
export const typescriptDocs = ({ model, output, emit, pagination }) => [
|
|
39
|
+
{
|
|
40
|
+
path: output.path.replace(/\.[^.\\/]+$/, '.typescript.md'),
|
|
41
|
+
content: renderReferencePage(model, {
|
|
42
|
+
title: `${model.title} TypeScript client reference`,
|
|
43
|
+
frontmatter: emit.docsFrontmatter === true,
|
|
44
|
+
language: {
|
|
45
|
+
name: 'typescript',
|
|
46
|
+
label: 'TypeScript',
|
|
47
|
+
fence: 'typescript',
|
|
48
|
+
requires: 'The client has no dependencies.',
|
|
49
|
+
},
|
|
50
|
+
sample: (op) => typescriptSample(op, { model, emit, outputPath: output.path }),
|
|
51
|
+
paginated: new Set(pagination?.keys() ?? []),
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
/** One idiomatic TS call per operation, for `x-codeSamples` and the SDK reference pages. */
|
|
56
|
+
export function typescriptSample(op, ctx) {
|
|
57
|
+
const ident = packageIdents(ctx.model).get(op.name) ?? op.name;
|
|
58
|
+
// The module this run writes, with the run's import extension — `./client` would be
|
|
59
|
+
// both the wrong name for most stems and extensionless under ESM resolution.
|
|
60
|
+
const stem = ctx.outputPath.replace(/^.*[\\/]/, '').replace(/\.[^.]+$/, '');
|
|
61
|
+
const specifier = `./${stem}.${ctx.emit.importExt ?? 'js'}`;
|
|
62
|
+
const requiredQuery = op.queryParams.filter((param) => param.required);
|
|
63
|
+
const merged = ctx.emit.argsStyle === 'flat';
|
|
64
|
+
const path = op.pathParams.map((param) => `${param.name}: '<${param.name}>'`);
|
|
65
|
+
const query = requiredQuery.map((param) => `${param.name}: /* … */`);
|
|
66
|
+
const parts = merged
|
|
67
|
+
? [...path, ...query, ...(op.requestBody ? ['/* body properties */'] : [])]
|
|
68
|
+
: [
|
|
69
|
+
...(path.length > 0 ? [`path: { ${path.join(', ')} }`] : []),
|
|
70
|
+
...(query.length > 0 ? [`query: { ${query.join(', ')} }`] : []),
|
|
71
|
+
...(op.requestBody ? ['body: { /* … */ }'] : []),
|
|
72
|
+
];
|
|
73
|
+
const args = parts.length > 0 ? [`{ ${parts.join(', ')} }`] : [];
|
|
74
|
+
return {
|
|
75
|
+
lang: 'typescript',
|
|
76
|
+
label: 'TypeScript SDK',
|
|
77
|
+
source: `import { ${ident} } from '${specifier}';\n\nconst result = await ${ident}(${args.join(', ')});\n`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generators/typescript/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE;IACpF,0EAA0E;IAC1E,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CA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+
auth: boolean;
|
|
5
|
+
sse: boolean;
|
|
6
|
+
setup: boolean;
|
|
7
|
+
paginate: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** The embedded runtime source block: stripped modules in dependency order + the factory. */
|
|
10
|
+
export declare function assembleInlineRuntime(needs: InlineRuntimeNeeds): string;
|
|
11
|
+
/**
|
|
12
|
+
* The runtime as real files (`runtime: 'module'`): the same per-needs modules, RAW —
|
|
13
|
+
* imports intact, exactly as authored — plus `factory.ts`, the per-needs `createClient`
|
|
14
|
+
* wiring as a module importing what it references from its siblings. `importExt`
|
|
15
|
+
* rewrites the intra-runtime specifiers for consumers that resolve them literally.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runtimeModuleFiles(needs: InlineRuntimeNeeds, importExt?: 'js' | 'ts'): Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
content: string;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=inline-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-runtime.d.ts","sourceRoot":"","sources":["../../../src/generators/typescript/inline-runtime.ts"],"names":[],"mappings":"AAaA,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAsBF,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAMvE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,kBAAkB,EACzB,SAAS,GAAE,IAAI,GAAG,IAAW,GAC5B,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAU1C"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Assembles the embedded runtime block for inline-mode clients: the real
|
|
2
|
+
// `src/runtime/` sources — stripped of module syntax at PREPARE time (see
|
|
3
|
+
// scripts/generate-runtime-sources.mjs, which owns the kept-export surface) — in
|
|
4
|
+
// import-graph order, followed by a local `createClient` factory wiring only the
|
|
5
|
+
// capabilities this API needs. Pure string concatenation: no `typescript` at
|
|
6
|
+
// generate time.
|
|
7
|
+
import { RUNTIME_SOURCES, RUNTIME_SOURCES_STRIPPED, } from '@redocly/client-generator/runtime-sources';
|
|
8
|
+
const HEADER = "// ─── Embedded runtime (@redocly/client-generator, assembled per this API's needs) ───";
|
|
9
|
+
/** The per-needs module set, in import-graph topological order (both modes share it). */
|
|
10
|
+
function runtimeModules(needs) {
|
|
11
|
+
// The optional capability modules slot in where the runtime barrel would import
|
|
12
|
+
// them (core never imports them statically).
|
|
13
|
+
const modules = ['types.ts', 'errors.ts', 'url.ts', 'parse.ts', 'retry.ts'];
|
|
14
|
+
if (needs.multipart)
|
|
15
|
+
modules.push('multipart.ts');
|
|
16
|
+
if (needs.auth)
|
|
17
|
+
modules.push('auth.ts');
|
|
18
|
+
if (needs.setup)
|
|
19
|
+
modules.push('setup.ts');
|
|
20
|
+
// paginate.ts has only type imports (types.ts + create-client.ts's OperationArgs),
|
|
21
|
+
// so it can sit anywhere; keep it with the other capability modules, before send.ts.
|
|
22
|
+
if (needs.paginate)
|
|
23
|
+
modules.push('paginate.ts');
|
|
24
|
+
modules.push('send.ts');
|
|
25
|
+
if (needs.sse)
|
|
26
|
+
modules.push('sse.ts');
|
|
27
|
+
modules.push('create-client.ts');
|
|
28
|
+
return modules;
|
|
29
|
+
}
|
|
30
|
+
/** The embedded runtime source block: stripped modules in dependency order + the factory. */
|
|
31
|
+
export function assembleInlineRuntime(needs) {
|
|
32
|
+
return [
|
|
33
|
+
HEADER,
|
|
34
|
+
...runtimeModules(needs).map((name) => RUNTIME_SOURCES_STRIPPED[name]),
|
|
35
|
+
clientFactory(needs),
|
|
36
|
+
].join('\n\n');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The runtime as real files (`runtime: 'module'`): the same per-needs modules, RAW —
|
|
40
|
+
* imports intact, exactly as authored — plus `factory.ts`, the per-needs `createClient`
|
|
41
|
+
* wiring as a module importing what it references from its siblings. `importExt`
|
|
42
|
+
* rewrites the intra-runtime specifiers for consumers that resolve them literally.
|
|
43
|
+
*/
|
|
44
|
+
export function runtimeModuleFiles(needs, importExt = 'js') {
|
|
45
|
+
const files = [
|
|
46
|
+
...runtimeModules(needs).map((name) => ({ name, content: RUNTIME_SOURCES[name] })),
|
|
47
|
+
{ name: 'factory.ts', content: moduleFactory(needs) },
|
|
48
|
+
];
|
|
49
|
+
if (importExt === 'js')
|
|
50
|
+
return files;
|
|
51
|
+
return files.map(({ name, content }) => ({
|
|
52
|
+
name,
|
|
53
|
+
content: content.replace(/(from '\.\/[a-z-]+)\.js'/g, "$1.ts'"),
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
/** `factory.ts`: the sibling-module equivalent of the inline factory block. */
|
|
57
|
+
function moduleFactory(needs) {
|
|
58
|
+
const imports = [
|
|
59
|
+
"import { createClientCore } from './create-client.js';",
|
|
60
|
+
...(needs.multipart ? ["import { toFormData } from './multipart.js';"] : []),
|
|
61
|
+
...(needs.auth ? ["import { resolveAuth } from './auth.js';"] : []),
|
|
62
|
+
...(needs.paginate
|
|
63
|
+
? ["import { items, itemsByLink, pages, pagesByLink } from './paginate.js';"]
|
|
64
|
+
: []),
|
|
65
|
+
...(needs.sse ? ["import { sse } from './sse.js';"] : []),
|
|
66
|
+
`import type {
|
|
67
|
+
Client,
|
|
68
|
+
ClientConfig,
|
|
69
|
+
OperationContext,
|
|
70
|
+
OperationDescriptor,
|
|
71
|
+
OpsShape,
|
|
72
|
+
} from './types.js';`,
|
|
73
|
+
];
|
|
74
|
+
// The client entry re-exports this module, so the factory carries the same public
|
|
75
|
+
// surface the inline embed leaves in module scope (the kept-export set).
|
|
76
|
+
const reexports = [
|
|
77
|
+
"export { ApiError, TimeoutError } from './errors.js';",
|
|
78
|
+
"export { defaultRetryOn } from './retry.js';",
|
|
79
|
+
...(needs.setup ? ["export { mergeSetup } from './setup.js';"] : []),
|
|
80
|
+
"export type * from './types.js';",
|
|
81
|
+
];
|
|
82
|
+
return [imports.join('\n'), clientFactory(needs), reexports.join('\n')].join('\n\n');
|
|
83
|
+
}
|
|
84
|
+
// The embedded equivalent of the package barrel's `createClient`: `createClientCore`
|
|
85
|
+
// with only the included capabilities wired. EXPORTED — the design spec promises the
|
|
86
|
+
// generated module re-exports `createClient`/`OPERATIONS`/`Ops` so apps can build
|
|
87
|
+
// additional per-tenant instances over the same descriptors.
|
|
88
|
+
function clientFactory(needs) {
|
|
89
|
+
const caps = [
|
|
90
|
+
...(needs.multipart ? ['serializeMultipart: toFormData'] : []),
|
|
91
|
+
...(needs.auth ? ['resolveAuth'] : []),
|
|
92
|
+
...(needs.sse ? ['sse'] : []),
|
|
93
|
+
...(needs.paginate ? ['paginate: { pages, items, pagesByLink, itemsByLink }'] : []),
|
|
94
|
+
];
|
|
95
|
+
const wired = caps.length > 0 ? `{ ${caps.join(', ')} }` : '{}';
|
|
96
|
+
return `/**
|
|
97
|
+
* The client factory: \`createClientCore\` wired with the capabilities this API needs.
|
|
98
|
+
* Exported so apps can build additional instances (per-tenant, per-environment) over
|
|
99
|
+
* the same \`OPERATIONS\`/\`Ops\`. The trailing string params carry the wiring's literal
|
|
100
|
+
* unions (\`OperationId\`/\`OperationPath\`/\`OperationTag\`) into \`ctx.operation\`.
|
|
101
|
+
*/
|
|
102
|
+
export function createClient<
|
|
103
|
+
Ops extends OpsShape,
|
|
104
|
+
Id extends string = string,
|
|
105
|
+
Path extends string = string,
|
|
106
|
+
Tag extends string = string,
|
|
107
|
+
>(
|
|
108
|
+
operations: Record<string, OperationDescriptor>,
|
|
109
|
+
config?: ClientConfig<OperationContext<Id, Path, Tag>>
|
|
110
|
+
): Client<Ops, OperationContext<Id, Path, Tag>> {
|
|
111
|
+
return createClientCore<Ops, Id, Path, Tag>(operations, config, ${wired});
|
|
112
|
+
}`;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=inline-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-runtime.js","sourceRoot":"","sources":["../../../src/generators/typescript/inline-runtime.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,0EAA0E;AAC1E,iFAAiF;AACjF,iFAAiF;AACjF,6EAA6E;AAC7E,iBAAiB;AAEjB,OAAO,EACL,eAAe,EACf,wBAAwB,GAEzB,MAAM,2CAA2C,CAAC;AAWnD,MAAM,MAAM,GACV,yFAAyF,CAAC;AAE5F,yFAAyF;AACzF,SAAS,cAAc,CAAC,KAAyB;IAC/C,gFAAgF;IAChF,6CAA6C;IAC7C,MAAM,OAAO,GAAwB,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACjG,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1C,mFAAmF;IACnF,qFAAqF;IACrF,IAAI,KAAK,CAAC,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,IAAI,KAAK,CAAC,GAAG;QAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,qBAAqB,CAAC,K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AAC;IAChE,OAAO;;;;;;;;;;;;;;;oEAe2D,KAAK;EACvE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OperationModel, ParamModel } from '@redocly/client-generator';
|
|
2
|
+
export type OperationSignature = {
|
|
3
|
+
/** Slot presence — which input layers the operation has. */
|
|
4
|
+
hasQuery: boolean;
|
|
5
|
+
hasBody: boolean;
|
|
6
|
+
hasHeaders: boolean;
|
|
7
|
+
hasCookies: boolean;
|
|
8
|
+
/** Any input at all — i.e. a `<Op>Variables` type exists for the operation. */
|
|
9
|
+
hasInputs: boolean;
|
|
10
|
+
/** Whether the input argument is required (else it defaults to `= {}`). */
|
|
11
|
+
varsRequired: boolean;
|
|
12
|
+
/** The `<Op>Variables` type-alias name. */
|
|
13
|
+
variablesTypeName: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Path parameters in URL-template order — the order a reader sees them in the path, and the
|
|
17
|
+
* order the old positional signature used. A parameter declared but absent from the template
|
|
18
|
+
* is dropped: it has nowhere to go in the URL, so asking for a value would mislead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function templatePathParams(op: OperationModel): ParamModel[];
|
|
21
|
+
/** Compute the calling-convention description for `op`. Pure; no AST. */
|
|
22
|
+
export declare function operationSignature(op: OperationModel): OperationSignature;
|
|
23
|
+
//# sourceMappingURL=operation-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-signature.d.ts","sourceRoot":"","sources":["../../../src/generators/typescript/operation-signature.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,YAAY,EAAE,OAAO,CAAC;IACtB,2CAA2C;IAC3C,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,UAAU,EAAE,CAQnE;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,kBAAkB,CAoBzE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The shared calling-convention description for an operation. The sdk (which emits each
|
|
2
|
+
// operation's input type) and the wrapper generators (which forward it) read slot presence
|
|
3
|
+
// and `<Op>Variables` naming from this one source, so a call and its type cannot drift.
|
|
4
|
+
import { pascalCase } from '@redocly/client-generator/printers/typescript';
|
|
5
|
+
/**
|
|
6
|
+
* Path parameters in URL-template order — the order a reader sees them in the path, and the
|
|
7
|
+
* order the old positional signature used. A parameter declared but absent from the template
|
|
8
|
+
* is dropped: it has nowhere to go in the URL, so asking for a value would mislead.
|
|
9
|
+
*/
|
|
10
|
+
export function templatePathParams(op) {
|
|
11
|
+
const byName = new Map(op.pathParams.map((param) => [param.name, param]));
|
|
12
|
+
const ordered = [];
|
|
13
|
+
for (const match of op.path.matchAll(/\{([^{}]+)\}/g)) {
|
|
14
|
+
const param = byName.get(match[1]);
|
|
15
|
+
if (param !== undefined)
|
|
16
|
+
ordered.push(param);
|
|
17
|
+
}
|
|
18
|
+
return ordered;
|
|
19
|
+
}
|
|
20
|
+
/** Compute the calling-convention description for `op`. Pure; no AST. */
|
|
21
|
+
export function operationSignature(op) {
|
|
22
|
+
const pathParams = templatePathParams(op);
|
|
23
|
+
const hasQuery = op.queryParams.length > 0;
|
|
24
|
+
const hasBody = Boolean(op.requestBody);
|
|
25
|
+
const hasHeaders = op.headerParams.length > 0;
|
|
26
|
+
const hasCookies = op.cookieParams.length > 0;
|
|
27
|
+
return {
|
|
28
|
+
hasQuery,
|
|
29
|
+
hasBody,
|
|
30
|
+
hasHeaders,
|
|
31
|
+
hasCookies,
|
|
32
|
+
hasInputs: pathParams.length > 0 || hasQuery || hasBody || hasHeaders || hasCookies,
|
|
33
|
+
varsRequired: pathParams.length > 0 ||
|
|
34
|
+
op.queryParams.some((p) => p.required) ||
|
|
35
|
+
(op.requestBody?.required ?? false) ||
|
|
36
|
+
op.headerParams.some((p) => p.required) ||
|
|
37
|
+
op.cookieParams.some((p) => p.required),
|
|
38
|
+
variablesTypeName: `${pascalCase(op.name)}Variables`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=operation-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-signature.js","sourceRoot":"","sources":["../../../src/generators/typescript/operation-signature.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,2FAA2F;AAC3F,wFAAwF;AAGxF,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAgB3E;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAkB;IACnD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC,CAAC,CAAC;IACnF,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACtD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,EAAkB;IACnD,MAAM,UAAU,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,OAAO;QACL,QAAQ;QACR,OAAO;QACP,UAAU;QACV,UAAU;QACV,SAAS,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,IAAI,OAAO,IAAI,UAAU,IAAI,UAAU;QACnF,YAAY,EACV,UAAU,CAAC,MAAM,GAAG,CAAC;YACrB,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;YACtC,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,IAAI,KAAK,CAAC;YACnC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;YACvC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzC,iBAAiB,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RequestBodyModel } from '@redocly/client-generator';
|
|
2
|
+
/**
|
|
3
|
+
* A multipart body whose schema is a concrete object — the case worth typing. Such a body
|
|
4
|
+
* is emitted as its object shape (binary fields → `Blob`); the runtime serializes it to
|
|
5
|
+
* `FormData` (`runtime/multipart.ts`) after the onRequest chain. Multipart bodies with a
|
|
6
|
+
* non-object schema can't be typed field-by-field, so they keep the raw `FormData` escape hatch.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isTypedMultipart(rb: RequestBodyModel): boolean;
|
|
9
|
+
//# sourceMappingURL=operation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../../../src/generators/typescript/operation-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Shared operation-shape predicates.
|
|
2
|
+
/**
|
|
3
|
+
* A multipart body whose schema is a concrete object — the case worth typing. Such a body
|
|
4
|
+
* is emitted as its object shape (binary fields → `Blob`); the runtime serializes it to
|
|
5
|
+
* `FormData` (`runtime/multipart.ts`) after the onRequest chain. Multipart bodies with a
|
|
6
|
+
* non-object schema can't be typed field-by-field, so they keep the raw `FormData` escape hatch.
|
|
7
|
+
*/
|
|
8
|
+
export function isTypedMultipart(rb) {
|
|
9
|
+
return rb.contentType === 'multipart/form-data' && rb.schema.kind === 'object';
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=operation-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-types.js","sourceRoot":"","sources":["../../../src/generators/typescript/operation-types.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAIrC;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAoB;IACnD,OAAO,EAAE,CAAC,WAAW,KAAK,qBAAqB,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type ApiModel, type ArgsStyle, type DateType, type ErrorMode, type ModelPagination, type NamedSchemaModel, type OperationModel, type ParamModel, type RequestBodyModel, type ResponseBodyModel } from '@redocly/client-generator';
|
|
2
|
+
/**
|
|
3
|
+
* The emit configuration every operation shares. Bundling it into one value keeps
|
|
4
|
+
* it out of the positional parameter lists of the operation emitters (which would
|
|
5
|
+
* otherwise thread the same arguments through every layer, inviting transposition
|
|
6
|
+
* bugs). Per-call structural data (response type, ordered path params, …) stays an
|
|
7
|
+
* explicit argument; only this cross-cutting config travels as `ctx`.
|
|
8
|
+
*/
|
|
9
|
+
export type EmitContext = {
|
|
10
|
+
argsStyle: ArgsStyle;
|
|
11
|
+
errorMode: ErrorMode;
|
|
12
|
+
dateType: DateType;
|
|
13
|
+
/** Names of every exported schema, used for `<Op>*` alias collision suppression. */
|
|
14
|
+
schemaNames: Set<string>;
|
|
15
|
+
/** Named schemas — used to resolve `$ref` / `allOf` wrappers on response-header types. */
|
|
16
|
+
schemas?: readonly NamedSchemaModel[];
|
|
17
|
+
/** Resolved auto-pagination per operation name (absent ⇒ nothing paginates). */
|
|
18
|
+
pagination?: ModelPagination;
|
|
19
|
+
};
|
|
20
|
+
/** The request-body TS type: special wrapper types per content-type, else the schema. */
|
|
21
|
+
export declare function bodyTypeText(rb: RequestBodyModel, dateType: DateType, indent?: string): string;
|
|
22
|
+
/** The `{ … }` type literal for a params object (query or headers), with per-prop JSDoc. */
|
|
23
|
+
export declare function paramsTypeText(params: ParamModel[], dateType: DateType, indent?: string): string;
|
|
24
|
+
/** The success-response type + kind (JSON preferred; binary/text fall back; deduped union). */
|
|
25
|
+
export declare function responseText(responses: ResponseBodyModel[], dateType: DateType, indent?: string): {
|
|
26
|
+
type: string;
|
|
27
|
+
kind: 'json' | 'blob' | 'text' | 'void';
|
|
28
|
+
};
|
|
29
|
+
/** The deduped error-response body types, or `[]` when none. */
|
|
30
|
+
export declare function errorTypeTexts(responses: ResponseBodyModel[], dateType: DateType, indent?: string): string[];
|
|
31
|
+
/**
|
|
32
|
+
* How a flat-style call spells one operation's inputs. Every parameter sits at one level,
|
|
33
|
+
* and a REQUIRED object body contributes its own properties — an optional body cannot
|
|
34
|
+
* (omitting it and omitting its required properties would look the same), and neither can
|
|
35
|
+
* an array, scalar, or binary body, so those keep the `body` key.
|
|
36
|
+
*
|
|
37
|
+
* When one name appears in two layers (a path and a query parameter of the same name, which
|
|
38
|
+
* OpenAPI permits) a merged call cannot say which is which, so that operation keeps the
|
|
39
|
+
* namespaced shape. The caller reports it once.
|
|
40
|
+
*/
|
|
41
|
+
export declare function flatInputShape(op: OperationModel, schemas: readonly NamedSchemaModel[] | undefined): {
|
|
42
|
+
mergeBody: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
collisions: string[];
|
|
45
|
+
};
|
|
46
|
+
/** The `<Op>Variables` object type literal (see operation-aliases.ts for the contract). */
|
|
47
|
+
export declare function variablesTypeText(op: OperationModel, name: string, ctx: EmitContext, indent?: string): string;
|
|
48
|
+
/** `export type Ops = { <ident>: { args; result; item?; page?; kind? } }` — what `createClient<Ops>` consumes. */
|
|
49
|
+
export declare function renderOpsType(model: ApiModel, idents: Map<string, string>, ctx: EmitContext): string;
|
|
50
|
+
/** One operation's `<Op>*` aliases (Result/Error/Path/Query/Body/Headers/Cookies/Variables), collision-suppressed. */
|
|
51
|
+
export declare function renderAliases(op: OperationModel, ctx: EmitContext): string;
|
|
52
|
+
/**
|
|
53
|
+
* Schema names the ENTRY file's own types reference — the split layout's type-only
|
|
54
|
+
* import list. Derived from the IR (the exact sources the alias/Ops renderers type):
|
|
55
|
+
* every ref reachable from operation inputs, success responses, error responses
|
|
56
|
+
* (result mode only — throw mode never renders them), and pagination item schemas.
|
|
57
|
+
* Named schema BODIES are not expanded: a ref renders as its bare name.
|
|
58
|
+
*/
|
|
59
|
+
export declare function collectEntrySchemaRefs(model: ApiModel, ctx: EmitContext): string[];
|
|
60
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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