openapi-typesafe 1.0.0-rc.2 → 1.0.0-rc.4
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 +1831 -0
- package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
- package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
- package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
- package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
- package/dist/adapters/node-file-system/file-claims.cjs +105 -0
- package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
- package/dist/adapters/node-file-system/file-claims.mjs +95 -0
- package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
- package/dist/adapters/node-file-system/file-identity.cjs +82 -0
- package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
- package/dist/adapters/node-file-system/file-identity.mjs +74 -0
- package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
- package/dist/adapters/node-file-system/node-file-system.cjs +90 -14
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
- package/dist/adapters/node-file-system/node-file-system.mjs +90 -14
- package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +75 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +72 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
- package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
- package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
- package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
- package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +14 -15
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +12 -13
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +31 -3
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +31 -3
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.cjs +2 -2
- package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.mjs +3 -3
- package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
- package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
- package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +35 -6
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +35 -6
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-node-limit.cjs +47 -0
- package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs +44 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.cjs +11 -7
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.mjs +12 -8
- package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
- package/dist/api/default-ports.cjs +19 -2
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +19 -3
- package/dist/api/default-ports.mjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.mjs +2 -2
- package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
- package/dist/api/discriminator-enum-parent.cjs +2 -2
- package/dist/api/discriminator-enum-parent.cjs.map +1 -1
- package/dist/api/discriminator-enum-parent.mjs +3 -3
- package/dist/api/discriminator-enum-parent.mjs.map +1 -1
- package/dist/api/discriminator-other-owners.cjs +5 -3
- package/dist/api/discriminator-other-owners.cjs.map +1 -1
- package/dist/api/discriminator-other-owners.mjs +5 -3
- package/dist/api/discriminator-other-owners.mjs.map +1 -1
- package/dist/api/discriminator-patch.cjs +8 -4
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +9 -5
- package/dist/api/discriminator-patch.mjs.map +1 -1
- package/dist/api/discriminator-scan.cjs +17 -10
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +18 -11
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-run.cjs +4 -3
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +4 -3
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/legacy-callback-warning.cjs +7 -4
- package/dist/api/legacy-callback-warning.cjs.map +1 -1
- package/dist/api/legacy-callback-warning.mjs +8 -5
- package/dist/api/legacy-callback-warning.mjs.map +1 -1
- package/dist/api/legacy-utils.cjs.map +1 -1
- package/dist/api/legacy-utils.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +9 -5
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +10 -7
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/schema-callbacks.cjs +36 -12
- package/dist/api/schema-callbacks.cjs.map +1 -1
- package/dist/api/schema-callbacks.mjs +36 -12
- package/dist/api/schema-callbacks.mjs.map +1 -1
- package/dist/api/string-to-ast.cjs +7 -9
- package/dist/api/string-to-ast.cjs.map +1 -1
- package/dist/api/string-to-ast.mjs +8 -9
- package/dist/api/string-to-ast.mjs.map +1 -1
- package/dist/api/transform-context.cjs +7 -3
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +7 -3
- package/dist/api/transform-context.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +42 -12
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +44 -14
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/application/print/text-writer.cjs +10 -3
- package/dist/application/print/text-writer.cjs.map +1 -1
- package/dist/application/print/text-writer.mjs +10 -3
- package/dist/application/print/text-writer.mjs.map +1 -1
- package/dist/application/stack-overflow.cjs +2 -1
- package/dist/application/stack-overflow.cjs.map +1 -1
- package/dist/application/stack-overflow.mjs +2 -1
- package/dist/application/stack-overflow.mjs.map +1 -1
- package/dist/application/transform/document/components.cjs +2 -2
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +4 -4
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/declared-type-names.cjs +23 -0
- package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
- package/dist/application/transform/document/declared-type-names.mjs +20 -0
- package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
- package/dist/application/transform/document/defs-root.cjs +1 -1
- package/dist/application/transform/document/defs-root.cjs.map +1 -1
- package/dist/application/transform/document/defs-root.mjs +2 -2
- package/dist/application/transform/document/defs-root.mjs.map +1 -1
- package/dist/application/transform/document/document.cjs +4 -1
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +3 -2
- package/dist/application/transform/document/document.mjs.map +1 -1
- package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
- package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
- package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
- package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
- package/dist/application/transform/document/global-type-references.cjs +1 -0
- package/dist/application/transform/document/global-type-references.cjs.map +1 -1
- package/dist/application/transform/document/global-type-references.mjs +1 -1
- package/dist/application/transform/document/global-type-references.mjs.map +1 -1
- package/dist/application/transform/document/media-type.cjs +2 -2
- package/dist/application/transform/document/media-type.cjs.map +1 -1
- package/dist/application/transform/document/media-type.mjs +3 -3
- package/dist/application/transform/document/media-type.mjs.map +1 -1
- package/dist/application/transform/document/operation-keys-written.cjs +26 -0
- package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
- package/dist/application/transform/document/operation-keys-written.mjs +24 -0
- package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
- package/dist/application/transform/document/operation.cjs +1 -1
- package/dist/application/transform/document/operation.cjs.map +1 -1
- package/dist/application/transform/document/operation.mjs +2 -2
- package/dist/application/transform/document/operation.mjs.map +1 -1
- package/dist/application/transform/document/parameter-entries.cjs +34 -0
- package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
- package/dist/application/transform/document/parameter-entries.mjs +30 -0
- package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
- package/dist/application/transform/document/parameter.cjs +12 -4
- package/dist/application/transform/document/parameter.cjs.map +1 -1
- package/dist/application/transform/document/parameter.mjs +13 -5
- package/dist/application/transform/document/parameter.mjs.map +1 -1
- package/dist/application/transform/document/parameters.cjs +7 -30
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +8 -31
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-item.cjs +11 -14
- package/dist/application/transform/document/path-item.cjs.map +1 -1
- package/dist/application/transform/document/path-item.mjs +12 -16
- package/dist/application/transform/document/path-item.mjs.map +1 -1
- package/dist/application/transform/document/paths-enum.cjs +1 -0
- package/dist/application/transform/document/paths-enum.cjs.map +1 -1
- package/dist/application/transform/document/paths-enum.mjs +1 -1
- package/dist/application/transform/document/paths-enum.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +6 -2
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +8 -4
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/document/referenced-parameter.cjs +80 -0
- package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
- package/dist/application/transform/document/referenced-parameter.mjs +78 -0
- package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
- package/dist/application/transform/document/request-body.cjs +1 -1
- package/dist/application/transform/document/request-body.cjs.map +1 -1
- package/dist/application/transform/document/request-body.mjs +2 -2
- package/dist/application/transform/document/request-body.mjs.map +1 -1
- package/dist/application/transform/document/response.cjs +2 -2
- package/dist/application/transform/document/response.cjs.map +1 -1
- package/dist/application/transform/document/response.mjs +3 -3
- package/dist/application/transform/document/response.mjs.map +1 -1
- package/dist/application/transform/document/responses.cjs +1 -1
- package/dist/application/transform/document/responses.cjs.map +1 -1
- package/dist/application/transform/document/responses.mjs +2 -2
- package/dist/application/transform/document/responses.mjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.cjs +8 -23
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.mjs +8 -24
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
- package/dist/application/transform/document/type-resolution.cjs +3 -1
- package/dist/application/transform/document/type-resolution.cjs.map +1 -1
- package/dist/application/transform/document/type-resolution.mjs +3 -1
- package/dist/application/transform/document/type-resolution.mjs.map +1 -1
- package/dist/application/transform/document/webhooks.cjs +1 -1
- package/dist/application/transform/document/webhooks.cjs.map +1 -1
- package/dist/application/transform/document/webhooks.mjs +2 -2
- package/dist/application/transform/document/webhooks.mjs.map +1 -1
- package/dist/application/transform/footer/document-footer.cjs +10 -2
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +10 -2
- package/dist/application/transform/footer/document-footer.mjs.map +1 -1
- package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
- package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
- package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
- package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
- package/dist/application/transform/footer/operation-keys.cjs +23 -0
- package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
- package/dist/application/transform/footer/operation-keys.mjs +21 -0
- package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.cjs +4 -4
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.mjs +4 -4
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
- package/dist/application/transform/helper-types.cjs +1 -1
- package/dist/application/transform/helper-types.cjs.map +1 -1
- package/dist/application/transform/helper-types.mjs +1 -1
- package/dist/application/transform/helper-types.mjs.map +1 -1
- package/dist/application/transform/numbered-names.cjs +9 -0
- package/dist/application/transform/numbered-names.cjs.map +1 -1
- package/dist/application/transform/numbered-names.mjs +9 -1
- package/dist/application/transform/numbered-names.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.cjs +1 -1
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.mjs +2 -2
- package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
- package/dist/application/transform/ref-type.cjs +2 -1
- package/dist/application/transform/ref-type.cjs.map +1 -1
- package/dist/application/transform/ref-type.mjs +2 -1
- package/dist/application/transform/ref-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs +1 -1
- package/dist/application/transform/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.mjs +2 -2
- package/dist/application/transform/schema/access-flags.mjs.map +1 -1
- package/dist/application/transform/schema/array-type.cjs +2 -2
- package/dist/application/transform/schema/array-type.cjs.map +1 -1
- package/dist/application/transform/schema/array-type.mjs +3 -3
- package/dist/application/transform/schema/array-type.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +4 -4
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +6 -6
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +4 -6
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +6 -8
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/object-type.cjs +3 -3
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +4 -4
- package/dist/application/transform/schema/object-type.mjs.map +1 -1
- package/dist/application/transform/schema/presence-members.cjs +1 -1
- package/dist/application/transform/schema/presence-members.cjs.map +1 -1
- package/dist/application/transform/schema/presence-members.mjs +2 -2
- package/dist/application/transform/schema/presence-members.mjs.map +1 -1
- package/dist/application/transform/schema/ref-siblings.cjs +47 -0
- package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
- package/dist/application/transform/schema/ref-siblings.mjs +45 -0
- package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
- package/dist/application/transform/schema/required-variants.cjs +2 -2
- package/dist/application/transform/schema/required-variants.cjs.map +1 -1
- package/dist/application/transform/schema/required-variants.mjs +3 -3
- package/dist/application/transform/schema/required-variants.mjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.cjs +4 -2
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +4 -2
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +6 -2
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +7 -3
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/cli/api-settings.cjs +62 -6
- package/dist/cli/api-settings.cjs.map +1 -1
- package/dist/cli/api-settings.mjs +60 -7
- package/dist/cli/api-settings.mjs.map +1 -1
- package/dist/cli/api-writes.cjs +72 -0
- package/dist/cli/api-writes.cjs.map +1 -0
- package/dist/cli/api-writes.mjs +69 -0
- package/dist/cli/api-writes.mjs.map +1 -0
- package/dist/cli/cli-errors.cjs +12 -1
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +12 -1
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +106 -1
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +99 -2
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +5 -1
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +6 -2
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +82 -36
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +85 -39
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +13 -7
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +14 -8
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/append-all.cjs +10 -0
- package/dist/domain/append-all.cjs.map +1 -0
- package/dist/domain/append-all.mjs +8 -0
- package/dist/domain/append-all.mjs.map +1 -0
- package/dist/domain/cause-secrets.cjs +37 -0
- package/dist/domain/cause-secrets.cjs.map +1 -0
- package/dist/domain/cause-secrets.mjs +35 -0
- package/dist/domain/cause-secrets.mjs.map +1 -0
- package/dist/domain/deprecations.cjs +11 -0
- package/dist/domain/deprecations.cjs.map +1 -0
- package/dist/domain/deprecations.mjs +9 -0
- package/dist/domain/deprecations.mjs.map +1 -0
- package/dist/domain/errors.cjs +9 -3
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +9 -3
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/identifier-text.cjs.map +1 -1
- package/dist/domain/ir/identifier-text.mjs +1 -1
- package/dist/domain/ir/identifier-text.mjs.map +1 -1
- package/dist/domain/ir/ir-shape.cjs +187 -0
- package/dist/domain/ir/ir-shape.cjs.map +1 -0
- package/dist/domain/ir/ir-shape.mjs +184 -0
- package/dist/domain/ir/ir-shape.mjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
- package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
- package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
- package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
- package/dist/domain/openapi/alias-expansion.cjs +3 -1
- package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
- package/dist/domain/openapi/alias-expansion.mjs +3 -1
- package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
- package/dist/domain/openapi/discriminated-union.cjs +3 -3
- package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
- package/dist/domain/openapi/discriminated-union.mjs +4 -4
- package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
- package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
- package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
- package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
- package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
- package/dist/domain/openapi/json-pointer.cjs +43 -1
- package/dist/domain/openapi/json-pointer.cjs.map +1 -1
- package/dist/domain/openapi/json-pointer.mjs +40 -2
- package/dist/domain/openapi/json-pointer.mjs.map +1 -1
- package/dist/domain/openapi/schema-dialect.cjs +15 -0
- package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
- package/dist/domain/openapi/schema-dialect.mjs +12 -0
- package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.cjs +1 -1
- package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
- package/dist/domain/openapi/unsupported-features.mjs +2 -2
- package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
- package/dist/domain/output-fixes.cjs +25 -14
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +25 -13
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/url-secrets.cjs +48 -0
- package/dist/domain/url-secrets.cjs.map +1 -0
- package/dist/domain/url-secrets.mjs +45 -0
- package/dist/domain/url-secrets.mjs.map +1 -0
- package/dist/domain/warnings.cjs +0 -1
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +0 -1
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -20
- package/dist/index.d.mts +57 -20
- package/dist/index.d.ts +57 -20
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -6
- package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
- package/src/adapters/node-file-system/file-claims.ts +138 -0
- package/src/adapters/node-file-system/file-identity.ts +137 -0
- package/src/adapters/node-file-system/node-file-system.ts +145 -18
- package/src/adapters/redocly-loader/bundled-mapping-copies.ts +95 -0
- package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
- package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +18 -24
- package/src/adapters/redocly-loader/ref-access.ts +37 -3
- package/src/adapters/redocly-loader/ref-holders.ts +3 -3
- package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +74 -11
- package/src/adapters/redocly-loader/remote-node-limit.ts +62 -0
- package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
- package/src/adapters/redocly-loader/schema-source.ts +20 -8
- package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
- package/src/adapters/terminal-logger/terminal-logger.ts +10 -5
- package/src/api/default-ports.ts +40 -4
- package/src/api/discriminator-conflict-warnings.ts +2 -2
- package/src/api/discriminator-enum-parent.ts +3 -3
- package/src/api/discriminator-other-owners.ts +5 -3
- package/src/api/discriminator-patch.ts +9 -6
- package/src/api/discriminator-scan.ts +19 -11
- package/src/api/document-run.ts +9 -3
- package/src/api/legacy-callback-warning.ts +13 -6
- package/src/api/legacy-utils.ts +5 -1
- package/src/api/openapi-ts.ts +26 -7
- package/src/api/run-context.ts +6 -0
- package/src/api/schema-callbacks.ts +60 -17
- package/src/api/string-to-ast.ts +11 -15
- package/src/api/transform-context.ts +7 -3
- package/src/api/transform-schema.ts +67 -15
- package/src/application/ports/deprecation-reporter.ts +9 -0
- package/src/application/ports/file-system.ts +39 -0
- package/src/application/ports/schema-loader.ts +11 -1
- package/src/application/print/text-writer.ts +10 -3
- package/src/application/stack-overflow.ts +9 -5
- package/src/application/transform/document/components.ts +4 -4
- package/src/application/transform/document/declared-type-names.ts +36 -0
- package/src/application/transform/document/defs-root.ts +2 -2
- package/src/application/transform/document/document.ts +4 -3
- package/src/application/transform/document/enum-names-given-back.ts +91 -0
- package/src/application/transform/document/global-type-references.ts +1 -1
- package/src/application/transform/document/media-type.ts +4 -3
- package/src/application/transform/document/operation-keys-written.ts +27 -0
- package/src/application/transform/document/operation.ts +2 -2
- package/src/application/transform/document/parameter-entries.ts +70 -0
- package/src/application/transform/document/parameter.ts +21 -9
- package/src/application/transform/document/parameters.ts +13 -58
- package/src/application/transform/document/path-item.ts +13 -31
- package/src/application/transform/document/paths-enum.ts +1 -1
- package/src/application/transform/document/paths.ts +8 -4
- package/src/application/transform/document/referenced-parameter.ts +146 -0
- package/src/application/transform/document/request-body.ts +2 -2
- package/src/application/transform/document/response.ts +3 -3
- package/src/application/transform/document/responses.ts +2 -2
- package/src/application/transform/document/root-type-aliases.ts +17 -38
- package/src/application/transform/document/type-resolution.ts +2 -1
- package/src/application/transform/document/webhooks.ts +2 -2
- package/src/application/transform/footer/document-footer.ts +18 -1
- package/src/application/transform/footer/enum-name-claims.ts +62 -0
- package/src/application/transform/footer/operation-keys.ts +28 -0
- package/src/application/transform/footer/type-evaluation.ts +4 -4
- package/src/application/transform/helper-types.ts +6 -5
- package/src/application/transform/numbered-names.ts +15 -0
- package/src/application/transform/ref-pointer/generated-location.ts +2 -2
- package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
- package/src/application/transform/ref-type.ts +2 -1
- package/src/application/transform/schema/access-flags.ts +2 -2
- package/src/application/transform/schema/array-type.ts +3 -5
- package/src/application/transform/schema/composition-type.ts +6 -6
- package/src/application/transform/schema/enum-rule.ts +10 -8
- package/src/application/transform/schema/object-type.ts +4 -4
- package/src/application/transform/schema/presence-members.ts +2 -2
- package/src/application/transform/schema/ref-siblings.ts +76 -0
- package/src/application/transform/schema/required-variants.ts +3 -3
- package/src/application/transform/schema/schema-context.ts +3 -0
- package/src/application/transform/schema/schema-transform.ts +4 -2
- package/src/application/transform/schema/unevaluated-properties.ts +2 -2
- package/src/application/transform/schema-comment.ts +7 -3
- package/src/application/transform/transform-context.ts +5 -0
- package/src/cli/api-settings.ts +82 -7
- package/src/cli/api-writes.ts +117 -0
- package/src/cli/cli-dependencies.ts +21 -4
- package/src/cli/cli-errors.ts +20 -1
- package/src/cli/cli-output.ts +186 -7
- package/src/cli/main.ts +6 -3
- package/src/cli/redocly-apis.ts +153 -48
- package/src/cli/run-cli.ts +37 -8
- package/src/domain/append-all.ts +10 -0
- package/src/domain/cause-secrets.ts +52 -0
- package/src/domain/deprecations.ts +15 -0
- package/src/domain/errors.ts +22 -7
- package/src/domain/ir/identifier-text.ts +6 -5
- package/src/domain/ir/ir-shape.ts +299 -0
- package/src/domain/ir/newer-identifier-ranges.ts +183 -30
- package/src/domain/openapi/alias-expansion.ts +4 -1
- package/src/domain/openapi/discriminated-union.ts +6 -4
- package/src/domain/openapi/discriminator-conflicts.ts +21 -7
- package/src/domain/openapi/document-object.ts +2 -0
- package/src/domain/openapi/json-pointer.ts +96 -7
- package/src/domain/openapi/schema-dialect.ts +22 -0
- package/src/domain/openapi/unsupported-features.ts +2 -2
- package/src/domain/output-fixes.ts +37 -18
- package/src/domain/url-secrets.ts +72 -0
- package/src/domain/warnings.ts +0 -1
- package/src/index.ts +2 -6
- package/src/types/generator-options.ts +1 -1
- package/dist/cli/main.d.cts +0 -2
- package/dist/cli/main.d.mts +0 -2
- package/dist/cli/main.d.ts +0 -2
- package/dist/domain/url-credentials.cjs +0 -10
- package/dist/domain/url-credentials.cjs.map +0 -1
- package/dist/domain/url-credentials.mjs +0 -8
- package/dist/domain/url-credentials.mjs.map +0 -1
- package/src/domain/url-credentials.ts +0 -18
|
@@ -9,10 +9,10 @@ import type {
|
|
|
9
9
|
} from "../application/transform/schema/schema-context.js";
|
|
10
10
|
import { ERROR_CODES, OpenAPITypesafeError } from "../domain/errors.js";
|
|
11
11
|
import { irRaw } from "../domain/ir/constructors.js";
|
|
12
|
+
import { isPrintableIrProperty, isPrintableIrType } from "../domain/ir/ir-shape.js";
|
|
12
13
|
import type { IrPropertySignature, IrType } from "../domain/ir/nodes.js";
|
|
13
14
|
import type {
|
|
14
15
|
GlobalContext,
|
|
15
|
-
IrCallbackType,
|
|
16
16
|
IrPostTransform,
|
|
17
17
|
IrTransform,
|
|
18
18
|
IrTransformProperty,
|
|
@@ -29,13 +29,15 @@ import { toIrType } from "./type-helpers.js";
|
|
|
29
29
|
* their results are read by the bridge.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
+
/** What a legacy `transformProperty` result fails to be. */
|
|
33
|
+
const LEGACY_PROPERTY_PROBLEM = "a property with syntax the generator cannot read";
|
|
34
|
+
|
|
35
|
+
/** A `transformProperty` result the generator cannot print as a property. */
|
|
32
36
|
export class UnreadablePropertyError extends OpenAPITypesafeError {
|
|
33
|
-
constructor(path: string | undefined) {
|
|
37
|
+
constructor(path: string | undefined, problem = LEGACY_PROPERTY_PROBLEM) {
|
|
34
38
|
super({
|
|
35
39
|
code: ERROR_CODES.CALLBACK_RESULT_UNREADABLE,
|
|
36
|
-
message:
|
|
37
|
-
`transformProperty at ${path} returned a property ` +
|
|
38
|
-
"with syntax the generator cannot read",
|
|
40
|
+
message: `transformProperty at ${path} returned ${problem}`,
|
|
39
41
|
details: { callback: "transformProperty", path },
|
|
40
42
|
});
|
|
41
43
|
this.name = "UnreadablePropertyError";
|
|
@@ -44,16 +46,26 @@ export class UnreadablePropertyError extends OpenAPITypesafeError {
|
|
|
44
46
|
|
|
45
47
|
/** A `transform` or `postTransform` result that is neither IR nor a TypeScript node. */
|
|
46
48
|
export class UnreadableTypeError extends OpenAPITypesafeError {
|
|
47
|
-
constructor(
|
|
49
|
+
constructor(
|
|
50
|
+
callback: "transform" | "postTransform",
|
|
51
|
+
path: string | undefined,
|
|
52
|
+
expected = "a TypeScript node",
|
|
53
|
+
) {
|
|
48
54
|
super({
|
|
49
55
|
code: ERROR_CODES.CALLBACK_RESULT_UNREADABLE,
|
|
50
|
-
message: `${callback} at ${path} returned a value that is not
|
|
56
|
+
message: `${callback} at ${path} returned a value that is not ${expected}`,
|
|
51
57
|
details: { callback, path },
|
|
52
58
|
});
|
|
53
59
|
this.name = "UnreadableTypeError";
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
/** What an IR type result must be (docs/node.md, IR callbacks). */
|
|
64
|
+
const IR_TYPE_EXPECTED = "an IR type or non-empty type text";
|
|
65
|
+
|
|
66
|
+
/** What an IR property result must be. */
|
|
67
|
+
const IR_PROPERTY_PROBLEM = "a value that is not an IR property the generator can print";
|
|
68
|
+
|
|
57
69
|
function nodeOptions(ctx: GlobalContext, location: SchemaLocation): TransformNodeOptions {
|
|
58
70
|
return { ...location, ctx } as TransformNodeOptions;
|
|
59
71
|
}
|
|
@@ -63,24 +75,50 @@ export function schemaCallbacks(ctx: GlobalContext): SchemaCallbacks {
|
|
|
63
75
|
return ctx.irCallbacks ? irSchemaCallbacks(ctx) : legacySchemaCallbacks(ctx);
|
|
64
76
|
}
|
|
65
77
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
/**
|
|
79
|
+
* An IR callback type; text is a raw type, printed as written. Any other value, and IR the
|
|
80
|
+
* printer cannot write as TypeScript, fails with `CALLBACK_RESULT_UNREADABLE` (`ir-shape.ts`).
|
|
81
|
+
*/
|
|
82
|
+
function fromCallbackType(
|
|
83
|
+
callback: "transform" | "postTransform",
|
|
84
|
+
type: unknown,
|
|
85
|
+
location: SchemaLocation,
|
|
86
|
+
): IrType {
|
|
87
|
+
const candidate = typeof type === "string" ? irRaw(type) : type;
|
|
88
|
+
if (!isPrintableIrType(candidate)) {
|
|
89
|
+
throw new UnreadableTypeError(callback, location.path, IR_TYPE_EXPECTED);
|
|
90
|
+
}
|
|
91
|
+
return candidate;
|
|
69
92
|
}
|
|
70
93
|
|
|
71
|
-
function irCustomType(result:
|
|
94
|
+
function irCustomType(result: unknown, location: SchemaLocation): CustomType | null {
|
|
72
95
|
if (result === undefined || result === null) {
|
|
73
96
|
return null;
|
|
74
97
|
}
|
|
75
98
|
if (typeof result === "object" && "schema" in result) {
|
|
76
|
-
|
|
99
|
+
const { schema, questionToken } = result as { schema: unknown; questionToken?: unknown };
|
|
100
|
+
return {
|
|
101
|
+
type: fromCallbackType("transform", schema, location),
|
|
102
|
+
isOptional: Boolean(questionToken),
|
|
103
|
+
};
|
|
77
104
|
}
|
|
78
|
-
return { type: fromCallbackType(result), isOptional: false };
|
|
105
|
+
return { type: fromCallbackType("transform", result, location), isOptional: false };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function irProperty(result: unknown, location: SchemaLocation): IrPropertySignature | null {
|
|
109
|
+
if (result === undefined || result === null) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (!isPrintableIrProperty(result)) {
|
|
113
|
+
throw new UnreadablePropertyError(location.path, IR_PROPERTY_PROBLEM);
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
79
116
|
}
|
|
80
117
|
|
|
81
118
|
/**
|
|
82
119
|
* The context fields hold either callback form; `irCallbacks` says which one, so the casts below
|
|
83
|
-
* only name the form the user declared with `OpenAPITSIrOptions`.
|
|
120
|
+
* only name the form the user declared with `OpenAPITSIrOptions`. The results are checked, since
|
|
121
|
+
* JavaScript callers can return any value.
|
|
84
122
|
*/
|
|
85
123
|
function irSchemaCallbacks(ctx: GlobalContext): SchemaCallbacks {
|
|
86
124
|
const transform = ctx.transform as IrTransform | undefined;
|
|
@@ -89,14 +127,19 @@ function irSchemaCallbacks(ctx: GlobalContext): SchemaCallbacks {
|
|
|
89
127
|
return {
|
|
90
128
|
transform: (schema, location) =>
|
|
91
129
|
transform
|
|
92
|
-
? irCustomType(transform(schema as SchemaObject, nodeOptions(ctx, location)))
|
|
130
|
+
? irCustomType(transform(schema as SchemaObject, nodeOptions(ctx, location)), location)
|
|
93
131
|
: null,
|
|
94
132
|
postTransform(type, location) {
|
|
95
133
|
const result = postTransform?.(type, nodeOptions(ctx, location));
|
|
96
|
-
return result === undefined ? null : fromCallbackType(result);
|
|
134
|
+
return result === undefined ? null : fromCallbackType("postTransform", result, location);
|
|
97
135
|
},
|
|
98
136
|
transformProperty: (property, schema, location) =>
|
|
99
|
-
transformProperty
|
|
137
|
+
transformProperty
|
|
138
|
+
? irProperty(
|
|
139
|
+
transformProperty(property, schema as SchemaObject, nodeOptions(ctx, location)),
|
|
140
|
+
location,
|
|
141
|
+
)
|
|
142
|
+
: null,
|
|
100
143
|
};
|
|
101
144
|
}
|
|
102
145
|
|
package/src/api/string-to-ast.ts
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { deprecate } from "node:util";
|
|
2
1
|
import { parseStatements } from "../adapters/type-ast-bridge/ir-declarations-to-typescript.js";
|
|
3
2
|
import { loadTypeScript } from "../adapters/type-ast-bridge/load-typescript.js";
|
|
3
|
+
import { DEPRECATION_CODES } from "../domain/deprecations.js";
|
|
4
|
+
import { defaultDeprecationReporter } from "./default-ports.js";
|
|
4
5
|
import { IR_CALLBACKS_GUIDE_URL } from "./legacy-callback-warning.js";
|
|
5
6
|
|
|
6
7
|
const STRING_TO_AST_DEPRECATION =
|
|
7
8
|
"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR " +
|
|
8
9
|
`callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;
|
|
9
10
|
|
|
10
|
-
/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */
|
|
11
|
-
export const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
12
|
-
|
|
13
|
-
function parseSource(source: string): unknown[] {
|
|
14
|
-
return [...parseStatements(loadTypeScript(), source)];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
11
|
/**
|
|
18
12
|
* Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so
|
|
19
|
-
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node
|
|
20
|
-
* on the first call only.
|
|
13
|
+
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js
|
|
14
|
+
* `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.
|
|
21
15
|
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.
|
|
22
16
|
*/
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
17
|
+
export function stringToAST(source: string): unknown[] {
|
|
18
|
+
defaultDeprecationReporter().report(
|
|
19
|
+
DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,
|
|
20
|
+
STRING_TO_AST_DEPRECATION,
|
|
21
|
+
);
|
|
22
|
+
return [...parseStatements(loadTypeScript(), source)];
|
|
23
|
+
}
|
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
TransformDiagnostics,
|
|
12
12
|
TransformOptions,
|
|
13
13
|
} from "../application/transform/transform-context.js";
|
|
14
|
+
import { canonicalRef } from "../domain/openapi/json-pointer.js";
|
|
15
|
+
import { SCHEMA_DIALECTS } from "../domain/openapi/schema-dialect.js";
|
|
14
16
|
import type { TransformNodeOptions } from "../types.js";
|
|
15
17
|
import { defaultLogger, monotonicNow } from "./default-ports.js";
|
|
16
18
|
import { ContextFooterSink } from "./footer-sink.js";
|
|
@@ -40,6 +42,7 @@ function transformOptions(ctx: RunContext): TransformOptions {
|
|
|
40
42
|
immutable: ctx.immutable,
|
|
41
43
|
propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,
|
|
42
44
|
readWriteMarkers: ctx.readWriteMarkers,
|
|
45
|
+
schemaDialect: ctx.schemaDialect ?? SCHEMA_DIALECTS.OPENAPI_3_0,
|
|
43
46
|
generatePathParams: ctx.generatePathParams,
|
|
44
47
|
pathParamsAsTypes: ctx.pathParamsAsTypes,
|
|
45
48
|
rootTypes: ctx.rootTypes,
|
|
@@ -76,9 +79,10 @@ export function createTransformContext(ctx: RunContext): TransformContext {
|
|
|
76
79
|
options: transformOptions(ctx),
|
|
77
80
|
refs: { resolve: (ref) => ctx.resolve(ref) },
|
|
78
81
|
discriminators: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
// The scan keys pointers canonically; a caller may pass a `$ref` as the document writes it.
|
|
83
|
+
objectAt: (ref) => ctx.discriminators.objects[canonicalRef(ref)],
|
|
84
|
+
isHandled: (ref) => ctx.discriminators.refsHandled.includes(canonicalRef(ref)),
|
|
85
|
+
otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[canonicalRef(ref)] ?? [],
|
|
82
86
|
enumParentOf: (schema) =>
|
|
83
87
|
ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,
|
|
84
88
|
},
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import type { ts } from "../adapters/type-ast-bridge/typescript-types.js";
|
|
2
2
|
import { documentBody, documentClosing } from "../application/transform/document/document.js";
|
|
3
|
+
import {
|
|
4
|
+
NAMES_THE_OUTPUT_MAY_NEED,
|
|
5
|
+
namesTheOutputNeeds,
|
|
6
|
+
withEnumsRenamed,
|
|
7
|
+
} from "../application/transform/document/enum-names-given-back.js";
|
|
8
|
+
import { operationKeysWritten } from "../application/transform/document/operation-keys-written.js";
|
|
3
9
|
import { renameTakenAliases } from "../application/transform/document/root-type-aliases.js";
|
|
4
|
-
import { RunFooter } from "../application/transform/footer/document-footer.js";
|
|
10
|
+
import { RunFooter, type RunFooterNames } from "../application/transform/footer/document-footer.js";
|
|
11
|
+
import { EnumNameClaims } from "../application/transform/footer/enum-name-claims.js";
|
|
5
12
|
import { checkedEnumValues } from "../application/transform/footer/enum-values-check.js";
|
|
13
|
+
import { OperationKeys } from "../application/transform/footer/operation-keys.js";
|
|
6
14
|
import {
|
|
15
|
+
FIRST_SCHEMA_NAMES,
|
|
7
16
|
SharedEnumNameRecorder,
|
|
8
17
|
type SharedEnumNames,
|
|
9
18
|
} from "../application/transform/footer/shared-enum-names.js";
|
|
10
19
|
import type { IrDeclaration } from "../domain/ir/nodes.js";
|
|
11
20
|
import type { DocumentObject } from "../domain/openapi/document-object.js";
|
|
12
|
-
import {
|
|
21
|
+
import { schemaDialectOf } from "../domain/openapi/schema-dialect.js";
|
|
22
|
+
import { FIX } from "../domain/output-fixes.js";
|
|
13
23
|
import type { GlobalContext, OpenAPI3 } from "../types.js";
|
|
14
24
|
import { FirstSchemaNameRecorder } from "./discriminator-enum-names.js";
|
|
15
25
|
import { documentDeclarations, type TransformedDocument } from "./document-declarations.js";
|
|
@@ -65,20 +75,52 @@ function sharedEnumNamesOf(
|
|
|
65
75
|
|
|
66
76
|
/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */
|
|
67
77
|
function enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {
|
|
68
|
-
if (ctx.fix?.includes(
|
|
78
|
+
if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {
|
|
69
79
|
return new SharedEnumNameRecorder();
|
|
70
80
|
}
|
|
71
|
-
return ctx.fix?.includes(
|
|
81
|
+
return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
|
|
72
82
|
}
|
|
73
83
|
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
/**
|
|
85
|
+
* The run's footer: with a naming fix, `--enum` and `--dedupe-enums` it names shared enums. A
|
|
86
|
+
* footer that a call before created on the context is kept.
|
|
87
|
+
*/
|
|
88
|
+
function withRunFooter(document: DocumentObject, ctx: RunContext, names: RunFooterNames): void {
|
|
89
|
+
if (ctx.runFooter !== undefined) {
|
|
78
90
|
return;
|
|
79
91
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
92
|
+
const recorder = enumNameRecorderOf(ctx);
|
|
93
|
+
const shared =
|
|
94
|
+
recorder === null || !ctx.enum || !ctx.dedupeEnums
|
|
95
|
+
? null
|
|
96
|
+
: sharedEnumNamesOf(document, ctx, recorder);
|
|
97
|
+
const sink = new ContextFooterSink(ctx.injectFooter);
|
|
98
|
+
ctx.runFooter =
|
|
99
|
+
shared === null
|
|
100
|
+
? new RunFooter(sink, ctx.dedupeEnums, FIRST_SCHEMA_NAMES, names)
|
|
101
|
+
: new RunFooter(sink, true, shared, names);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The document with the enums renamed that gave way to a name the output turned out not to need
|
|
106
|
+
* (`EnumNameClaims`): they get that name back, as before.
|
|
107
|
+
*/
|
|
108
|
+
function withEnumNamesGivenBack(
|
|
109
|
+
parts: TransformedDocument,
|
|
110
|
+
names: RunFooterNames,
|
|
111
|
+
): TransformedDocument {
|
|
112
|
+
const footer = parts.footer.filter(isIrDeclaration);
|
|
113
|
+
const renames = names.enums.givenBack(namesTheOutputNeeds({ ...parts, footer }));
|
|
114
|
+
if (renames.size === 0) {
|
|
115
|
+
return parts;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
body: withEnumsRenamed(parts.body, renames),
|
|
119
|
+
footer: parts.footer.map((entry) =>
|
|
120
|
+
isIrDeclaration(entry) ? (withEnumsRenamed([entry], renames)[0] ?? entry) : entry,
|
|
121
|
+
),
|
|
122
|
+
closing: withEnumsRenamed(parts.closing, renames),
|
|
123
|
+
};
|
|
82
124
|
}
|
|
83
125
|
|
|
84
126
|
/**
|
|
@@ -105,14 +147,24 @@ function enumValuesChecked(
|
|
|
105
147
|
/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */
|
|
106
148
|
export function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {
|
|
107
149
|
const document = schema as DocumentObject;
|
|
108
|
-
|
|
150
|
+
ctx.schemaDialect = schemaDialectOf(document.openapi);
|
|
151
|
+
const names: RunFooterNames = {
|
|
152
|
+
enums: new EnumNameClaims(NAMES_THE_OUTPUT_MAY_NEED),
|
|
153
|
+
operations: new OperationKeys(operationKeysWritten(document)),
|
|
154
|
+
};
|
|
155
|
+
withRunFooter(document, ctx, names);
|
|
109
156
|
const context = createTransformContext(ctx);
|
|
110
157
|
// documentBody registers the enums in the footer, so the footer is read after it.
|
|
111
158
|
const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
159
|
+
const rawFooter = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);
|
|
160
|
+
const rawClosing = documentClosing(document, context, rawFooter.some(isOperations));
|
|
161
|
+
const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };
|
|
162
|
+
const { body, footer, closing } = withEnumNamesGivenBack(parts, names);
|
|
163
|
+
return {
|
|
164
|
+
body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing),
|
|
165
|
+
footer,
|
|
166
|
+
closing,
|
|
167
|
+
};
|
|
116
168
|
}
|
|
117
169
|
|
|
118
170
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DeprecationCode } from "../../domain/deprecations.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where the generator reports the use of something 2.0 removes (ENGINEERING_PLAN 4.5). The
|
|
5
|
+
* adapter decides how often a code is shown; the Node.js one shows each code once per process.
|
|
6
|
+
*/
|
|
7
|
+
export interface DeprecationReporter {
|
|
8
|
+
report(code: DeprecationCode, message: string): void;
|
|
9
|
+
}
|
|
@@ -10,3 +10,42 @@ export interface FileReader {
|
|
|
10
10
|
export interface FileWriter {
|
|
11
11
|
writeText(file: URL, contents: string): void;
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether two `file:` locations name one file: also through a symbolic link, a hard link, or
|
|
16
|
+
* another letter case on a case-insensitive file system, and also when the file does not exist
|
|
17
|
+
* yet. The CLI asks before it writes, so that an output path never replaces a file the run reads
|
|
18
|
+
* (`CLI_OUTPUT_IS_INPUT`) nor another API's output (`CLI_OUTPUT_DUPLICATE`).
|
|
19
|
+
*/
|
|
20
|
+
export interface FileIdentity {
|
|
21
|
+
isSameFile(left: URL, right: URL): boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether a `file:` location is an existing directory. An output there is no file the CLI can
|
|
26
|
+
* write, so it fails with `CLI_OUTPUT_INVALID` before anything is generated.
|
|
27
|
+
*/
|
|
28
|
+
export interface DirectoryCheck {
|
|
29
|
+
isDirectory(file: URL): boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An output file that exists before its content is written: the claim created it, empty, when it
|
|
34
|
+
* was missing, so the file system has given it its own identity.
|
|
35
|
+
*/
|
|
36
|
+
export interface ClaimedFile {
|
|
37
|
+
/** The file system's identity of the file: equal for two paths that name one file. */
|
|
38
|
+
readonly identity: string;
|
|
39
|
+
/** Remove what the claim created (the file and its new directories); existing ones stay. */
|
|
40
|
+
release(): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Claim output files before writing to them. Names cannot prove that two missing files are two:
|
|
45
|
+
* the file system may ignore Unicode normalization, fold `ß` to `SS`, ignore letter case where
|
|
46
|
+
* nothing can be probed, or follow a link to a directory that does not exist yet. Once each file
|
|
47
|
+
* exists, its identity is the file system's own. Fails with `OUTPUT_WRITE_FAILED`.
|
|
48
|
+
*/
|
|
49
|
+
export interface FileClaims {
|
|
50
|
+
claimFile(file: URL): ClaimedFile;
|
|
51
|
+
}
|
|
@@ -20,6 +20,16 @@ export interface SchemaLoadRequest {
|
|
|
20
20
|
readonly refAccess: RefAccess;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/** A bundled document, and the local files read to build it. */
|
|
24
|
+
export interface LoadedSchema {
|
|
25
|
+
readonly document: OpenAPI3;
|
|
26
|
+
/**
|
|
27
|
+
* The root, when it is a local file, and every local file a `$ref` loaded. The CLI keeps its
|
|
28
|
+
* output from replacing any of them (`CLI_OUTPUT_IS_INPUT`).
|
|
29
|
+
*/
|
|
30
|
+
readonly localFiles: readonly URL[];
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
/**
|
|
24
34
|
* Read, validate and bundle an OpenAPI 3 document into one document (ENGINEERING_PLAN 4.5).
|
|
25
35
|
* Fails with a typed error (ADR-011): `SCHEMA_SOURCE_*`, `SCHEMA_LOAD_FAILED`,
|
|
@@ -28,5 +38,5 @@ export interface SchemaLoadRequest {
|
|
|
28
38
|
* `SCHEMA_TOO_DEEP` or `SCHEMA_KEY_UNSUPPORTED`.
|
|
29
39
|
*/
|
|
30
40
|
export interface SchemaLoader {
|
|
31
|
-
load(request: SchemaLoadRequest): Promise<
|
|
41
|
+
load(request: SchemaLoadRequest): Promise<LoadedSchema>;
|
|
32
42
|
}
|
|
@@ -22,7 +22,12 @@ export function isLineBreak(code: number): boolean {
|
|
|
22
22
|
*/
|
|
23
23
|
export class TextWriter {
|
|
24
24
|
readonly #options: PrintOptions;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The written parts, joined once at the end. A string built with `+=` is kept by V8 as a tree
|
|
27
|
+
* of its parts, several times the size of the text, for as long as the text is kept (until the
|
|
28
|
+
* CLI writes it); `join` gives one flat string.
|
|
29
|
+
*/
|
|
30
|
+
#parts: string[] = [];
|
|
26
31
|
#indent = 0;
|
|
27
32
|
#isAtLineStart = true;
|
|
28
33
|
|
|
@@ -39,7 +44,9 @@ export class TextWriter {
|
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
get text(): string {
|
|
42
|
-
|
|
47
|
+
const text = this.#parts.join("");
|
|
48
|
+
this.#parts = [text];
|
|
49
|
+
return text;
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
increaseIndent(): void {
|
|
@@ -61,7 +68,7 @@ export class TextWriter {
|
|
|
61
68
|
|
|
62
69
|
/** Write text exactly as given. */
|
|
63
70
|
rawWrite(text: string): void {
|
|
64
|
-
this.#
|
|
71
|
+
this.#parts.push(text);
|
|
65
72
|
this.#updateLineStart(text);
|
|
66
73
|
}
|
|
67
74
|
|
|
@@ -4,9 +4,11 @@ import { ERROR_CODES, OpenAPITypesafeError } from "../domain/errors.js";
|
|
|
4
4
|
* Deeply nested schemas (ENGINEERING_PLAN 8.5). Loading, bundling, transforming and printing walk
|
|
5
5
|
* schemas recursively, and Redocly follows each `$ref` inside the walk. On the default Node.js
|
|
6
6
|
* stack, about 550 levels of inline schemas or a chain of about 900 `$ref`s (each schema refers to
|
|
7
|
-
* the next) run out of call stack.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* the next) run out of call stack. Redocly's walk also passes the keys of an object to one call as
|
|
8
|
+
* arguments, so a single object with more than about 100,000 keys runs out of it while loading.
|
|
9
|
+
* Real documents stay far below: every YAML or JSON file goes through the YAML parser, which stops
|
|
10
|
+
* at 100 levels, and the whole corpus passes. The overflow is reported as a typed error instead of
|
|
11
|
+
* a `RangeError` with a stack trace.
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
/** The step that ran out of call stack; named in the message and the details. */
|
|
@@ -20,13 +22,15 @@ export function isStackOverflowError(error: unknown): boolean {
|
|
|
20
22
|
return error instanceof RangeError && STACK_OVERFLOW_MESSAGE.test(error.message);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
/** The typed error for a document nested too deeply for the call stack. */
|
|
25
|
+
/** The typed error for a document nested too deeply, or too wide, for the call stack. */
|
|
24
26
|
export function schemaTooDeepError(step: DeepSchemaStep, cause: unknown): OpenAPITypesafeError {
|
|
27
|
+
const wide = step === "load" ? ", and so does an object with more than about 100,000 keys" : "";
|
|
25
28
|
return new OpenAPITypesafeError({
|
|
26
29
|
code: ERROR_CODES.SCHEMA_TOO_DEEP,
|
|
27
30
|
message:
|
|
28
31
|
`The schema is nested too deeply to ${step}: the call stack ran out. Both inline ` +
|
|
29
|
-
|
|
32
|
+
`schemas and chains of $ref (each schema referring to the next) count${wide}; shorten ` +
|
|
33
|
+
"the deepest.",
|
|
30
34
|
details: { step },
|
|
31
35
|
cause,
|
|
32
36
|
});
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
isEnumSchema,
|
|
19
19
|
singularizeComponentKind,
|
|
20
20
|
} from "../../../domain/openapi/components-object.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
|
|
22
|
+
import { FIX } from "../../../domain/output-fixes.js";
|
|
23
23
|
import { type DeprecatedEntryFilter, documentEntries } from "../document-entries.js";
|
|
24
24
|
import type { SchemaLocation } from "../schema/schema-context.js";
|
|
25
25
|
import { transformSchema } from "../schema/schema-transform.js";
|
|
@@ -62,7 +62,7 @@ function componentMember(
|
|
|
62
62
|
item: unknown,
|
|
63
63
|
context: TransformContext,
|
|
64
64
|
): IrPropertySignature {
|
|
65
|
-
const location = { path:
|
|
65
|
+
const location = { path: appendPointer(ROOT_POINTER, ["components", kind, name]), schema: item };
|
|
66
66
|
const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);
|
|
67
67
|
const custom = context.callbacks.transform(item, location);
|
|
68
68
|
const property = irProperty(toPropertyName(name), custom?.type ?? type, {
|
|
@@ -174,7 +174,7 @@ export function componentsType(
|
|
|
174
174
|
// A plain object, as in the original: its key order (integer-like names first) is the
|
|
175
175
|
// output order.
|
|
176
176
|
const aliases: Record<string, IrTypeAliasDeclaration> = {};
|
|
177
|
-
const displaced = context.options.fixes.has(
|
|
177
|
+
const displaced = context.options.fixes.has(FIX.ROOT_TYPE_NUMBERING) ? [] : null;
|
|
178
178
|
const isKept = (item: unknown) => kept.has(item as object);
|
|
179
179
|
const request = { components, isKept, aliases, displaced };
|
|
180
180
|
const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IrDeclaration } from "../../../domain/ir/nodes.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The type names that declarations of the output take. Two declarations of one type name do not
|
|
5
|
+
* compile (TS2300, TS2567), or merge into one type without an error (two enums, two interfaces).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A declaration at the start of a line of raw text: the helper types, the `--read-write-markers`
|
|
10
|
+
* types, `inject` text and footer nodes from user code. A `const` lives in the value namespace.
|
|
11
|
+
*/
|
|
12
|
+
const RAW_TYPE_DECLARATION_RE =
|
|
13
|
+
/^(?:export\s+)?(?:declare\s+)?(?:type|interface|enum|const\s+enum|class)\s+([A-Za-z_$][\w$]*)/gm;
|
|
14
|
+
|
|
15
|
+
/** The type names that raw declaration text declares. */
|
|
16
|
+
export function typeNamesInText(text: string): string[] {
|
|
17
|
+
return [...text.matchAll(RAW_TYPE_DECLARATION_RE)].map((match) => match[1] ?? "");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function typeNamesOf(declaration: IrDeclaration): readonly string[] {
|
|
21
|
+
switch (declaration.kind) {
|
|
22
|
+
case "rawDeclaration":
|
|
23
|
+
return declaration.name === undefined
|
|
24
|
+
? typeNamesInText(declaration.text)
|
|
25
|
+
: [declaration.name];
|
|
26
|
+
case "constArray":
|
|
27
|
+
return [];
|
|
28
|
+
default:
|
|
29
|
+
return [declaration.name];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Every type name the declarations take; `--enum-values` arrays are values, so they take none. */
|
|
34
|
+
export function typeNamesDeclaredBy(declarations: readonly IrDeclaration[]): Set<string> {
|
|
35
|
+
return new Set(declarations.flatMap(typeNamesOf));
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { irObject, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrObjectType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
-
import {
|
|
4
|
+
import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
|
|
5
5
|
import type { Schema } from "../../../domain/openapi/schema-object.js";
|
|
6
6
|
import { transformSchema } from "../schema/schema-transform.js";
|
|
7
7
|
import type { TransformContext } from "../transform-context.js";
|
|
@@ -17,7 +17,7 @@ export function defsRootType(
|
|
|
17
17
|
context: TransformContext,
|
|
18
18
|
): IrObjectType {
|
|
19
19
|
const members = Object.entries(defs).map(([name, schema]) => {
|
|
20
|
-
const location = { path:
|
|
20
|
+
const location = { path: appendPointer(ROOT_POINTER, ["$defs", name]), schema };
|
|
21
21
|
const type = transformSchema(schema, location, context);
|
|
22
22
|
return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });
|
|
23
23
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appendAll } from "../../../domain/append-all.js";
|
|
1
2
|
import { irKeyword, irObject, irRecord } from "../../../domain/ir/constructors.js";
|
|
2
3
|
import type {
|
|
3
4
|
IrDeclaration,
|
|
@@ -20,10 +21,10 @@ import { apiPathsEnumDeclaration } from "./paths-enum.js";
|
|
|
20
21
|
import { webhooksType } from "./webhooks.js";
|
|
21
22
|
|
|
22
23
|
/** The root types, in output order. */
|
|
23
|
-
const ROOT_KEYS = Object.freeze(["paths", "webhooks", "components", "$defs"] as const);
|
|
24
|
+
export const ROOT_KEYS = Object.freeze(["paths", "webhooks", "components", "$defs"] as const);
|
|
24
25
|
type RootKey = (typeof ROOT_KEYS)[number];
|
|
25
26
|
|
|
26
|
-
const OPERATIONS_NAME = "operations";
|
|
27
|
+
export const OPERATIONS_NAME = "operations";
|
|
27
28
|
/** The type of a root without members: `Record<string, never>`. */
|
|
28
29
|
const EMPTY_ROOT_TYPE = irRecord(irKeyword("string"), irKeyword("never"));
|
|
29
30
|
|
|
@@ -191,7 +192,7 @@ export function documentBody(
|
|
|
191
192
|
if (inject !== "") {
|
|
192
193
|
declarations.push({ kind: "rawDeclaration", text: inject });
|
|
193
194
|
}
|
|
194
|
-
declarations
|
|
195
|
+
appendAll(declarations, rootsDeclarations(document, context, footer));
|
|
195
196
|
return declarations;
|
|
196
197
|
}
|
|
197
198
|
|