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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-writer.cjs","sources":["../../../src/application/print/text-writer.ts"],"sourcesContent":["import type { PrintOptions } from \"./print-options.js\";\n\nconst LINE_FEED = 0x0a;\nconst CARRIAGE_RETURN = 0x0d;\nconst LINE_SEPARATOR = 0x2028;\nconst PARAGRAPH_SEPARATOR = 0x2029;\n\n/** Line breaks as the TypeScript scanner defines them (`isLineBreak`). */\nexport function isLineBreak(code: number): boolean {\n return (\n code === LINE_FEED ||\n code === CARRIAGE_RETURN ||\n code === LINE_SEPARATOR ||\n code === PARAGRAPH_SEPARATOR\n );\n}\n\n/**\n * Output buffer with indentation, modeled on the TypeScript printer's text writer: `write` indents\n * text that starts a line, `rawWrite` never does, and `writeLine` does nothing at the start of a\n * line. Matching these rules is what makes comment re-indentation byte-identical to the original.\n */\nexport class TextWriter {\n readonly #options: PrintOptions;\n #
|
|
1
|
+
{"version":3,"file":"text-writer.cjs","sources":["../../../src/application/print/text-writer.ts"],"sourcesContent":["import type { PrintOptions } from \"./print-options.js\";\n\nconst LINE_FEED = 0x0a;\nconst CARRIAGE_RETURN = 0x0d;\nconst LINE_SEPARATOR = 0x2028;\nconst PARAGRAPH_SEPARATOR = 0x2029;\n\n/** Line breaks as the TypeScript scanner defines them (`isLineBreak`). */\nexport function isLineBreak(code: number): boolean {\n return (\n code === LINE_FEED ||\n code === CARRIAGE_RETURN ||\n code === LINE_SEPARATOR ||\n code === PARAGRAPH_SEPARATOR\n );\n}\n\n/**\n * Output buffer with indentation, modeled on the TypeScript printer's text writer: `write` indents\n * text that starts a line, `rawWrite` never does, and `writeLine` does nothing at the start of a\n * line. Matching these rules is what makes comment re-indentation byte-identical to the original.\n */\nexport class TextWriter {\n readonly #options: PrintOptions;\n /**\n * The written parts, joined once at the end. A string built with `+=` is kept by V8 as a tree\n * of its parts, several times the size of the text, for as long as the text is kept (until the\n * CLI writes it); `join` gives one flat string.\n */\n #parts: string[] = [];\n #indent = 0;\n #isAtLineStart = true;\n\n constructor(options: PrintOptions) {\n this.#options = options;\n }\n\n get indent(): number {\n return this.#indent;\n }\n\n get options(): PrintOptions {\n return this.#options;\n }\n\n get text(): string {\n const text = this.#parts.join(\"\");\n this.#parts = [text];\n return text;\n }\n\n increaseIndent(): void {\n this.#indent++;\n }\n\n decreaseIndent(): void {\n this.#indent--;\n }\n\n /** Write text, indenting it first when it starts a line. */\n write(text: string): void {\n if (text.length === 0) {\n return;\n }\n const prefix = this.#isAtLineStart ? this.indentString(this.#indent) : \"\";\n this.rawWrite(prefix + text);\n }\n\n /** Write text exactly as given. */\n rawWrite(text: string): void {\n this.#parts.push(text);\n this.#updateLineStart(text);\n }\n\n /** End the current line; does nothing when nothing has been written on it yet. */\n writeLine(): void {\n if (!this.#isAtLineStart) {\n this.rawWrite(this.#options.newLine);\n }\n }\n\n indentString(level: number): string {\n return \" \".repeat(level * this.#options.indentSize);\n }\n\n // Like TypeScript: any write leaves the writer mid-line unless the text ends with a line break.\n #updateLineStart(text: string): void {\n this.#isAtLineStart = text.length > 0 && isLineBreak(text.charCodeAt(text.length - 1));\n }\n}\n"],"names":[],"mappings":";;AAEA,MAAM,SAAA,GAAY,EAAA;AAClB,MAAM,eAAA,GAAkB,EAAA;AACxB,MAAM,cAAA,GAAiB,IAAA;AACvB,MAAM,mBAAA,GAAsB,IAAA;AAGrB,SAAS,YAAY,IAAA,EAAuB;AACjD,EAAA,OACE,SAAS,SAAA,IACT,IAAA,KAAS,eAAA,IACT,IAAA,KAAS,kBACT,IAAA,KAAS,mBAAA;AAEb;AAOO,MAAM,UAAA,CAAW;AAAA,EACb,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,SAAmB,EAAC;AAAA,EACpB,OAAA,GAAU,CAAA;AAAA,EACV,cAAA,GAAiB,IAAA;AAAA,EAEjB,YAAY,OAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EAClB;AAAA,EAEA,IAAI,MAAA,GAAiB;AACnB,IAAA,OA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IAAA,CAAK,cAAA,GAAiB,IAAA,CAAK,MAAA,GAAS,CAAA,IAAK,WAAA,CAAY,KAAK,UAAA,CAAW,IAAA,CAAK,MAAA,GAAS,CAAC,CAAC,CAAA;AAAA,EACvF;AACF;;;"}
|
|
@@ -7,7 +7,12 @@ function isLineBreak(code) {
|
|
|
7
7
|
}
|
|
8
8
|
class TextWriter {
|
|
9
9
|
#options;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The written parts, joined once at the end. A string built with `+=` is kept by V8 as a tree
|
|
12
|
+
* of its parts, several times the size of the text, for as long as the text is kept (until the
|
|
13
|
+
* CLI writes it); `join` gives one flat string.
|
|
14
|
+
*/
|
|
15
|
+
#parts = [];
|
|
11
16
|
#indent = 0;
|
|
12
17
|
#isAtLineStart = true;
|
|
13
18
|
constructor(options) {
|
|
@@ -20,7 +25,9 @@ class TextWriter {
|
|
|
20
25
|
return this.#options;
|
|
21
26
|
}
|
|
22
27
|
get text() {
|
|
23
|
-
|
|
28
|
+
const text = this.#parts.join("");
|
|
29
|
+
this.#parts = [text];
|
|
30
|
+
return text;
|
|
24
31
|
}
|
|
25
32
|
increaseIndent() {
|
|
26
33
|
this.#indent++;
|
|
@@ -38,7 +45,7 @@ class TextWriter {
|
|
|
38
45
|
}
|
|
39
46
|
/** Write text exactly as given. */
|
|
40
47
|
rawWrite(text) {
|
|
41
|
-
this.#
|
|
48
|
+
this.#parts.push(text);
|
|
42
49
|
this.#updateLineStart(text);
|
|
43
50
|
}
|
|
44
51
|
/** End the current line; does nothing when nothing has been written on it yet. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-writer.mjs","sources":["../../../src/application/print/text-writer.ts"],"sourcesContent":["import type { PrintOptions } from \"./print-options.js\";\n\nconst LINE_FEED = 0x0a;\nconst CARRIAGE_RETURN = 0x0d;\nconst LINE_SEPARATOR = 0x2028;\nconst PARAGRAPH_SEPARATOR = 0x2029;\n\n/** Line breaks as the TypeScript scanner defines them (`isLineBreak`). */\nexport function isLineBreak(code: number): boolean {\n return (\n code === LINE_FEED ||\n code === CARRIAGE_RETURN ||\n code === LINE_SEPARATOR ||\n code === PARAGRAPH_SEPARATOR\n );\n}\n\n/**\n * Output buffer with indentation, modeled on the TypeScript printer's text writer: `write` indents\n * text that starts a line, `rawWrite` never does, and `writeLine` does nothing at the start of a\n * line. Matching these rules is what makes comment re-indentation byte-identical to the original.\n */\nexport class TextWriter {\n readonly #options: PrintOptions;\n #
|
|
1
|
+
{"version":3,"file":"text-writer.mjs","sources":["../../../src/application/print/text-writer.ts"],"sourcesContent":["import type { PrintOptions } from \"./print-options.js\";\n\nconst LINE_FEED = 0x0a;\nconst CARRIAGE_RETURN = 0x0d;\nconst LINE_SEPARATOR = 0x2028;\nconst PARAGRAPH_SEPARATOR = 0x2029;\n\n/** Line breaks as the TypeScript scanner defines them (`isLineBreak`). */\nexport function isLineBreak(code: number): boolean {\n return (\n code === LINE_FEED ||\n code === CARRIAGE_RETURN ||\n code === LINE_SEPARATOR ||\n code === PARAGRAPH_SEPARATOR\n );\n}\n\n/**\n * Output buffer with indentation, modeled on the TypeScript printer's text writer: `write` indents\n * text that starts a line, `rawWrite` never does, and `writeLine` does nothing at the start of a\n * line. Matching these rules is what makes comment re-indentation byte-identical to the original.\n */\nexport class TextWriter {\n readonly #options: PrintOptions;\n /**\n * The written parts, joined once at the end. A string built with `+=` is kept by V8 as a tree\n * of its parts, several times the size of the text, for as long as the text is kept (until the\n * CLI writes it); `join` gives one flat string.\n */\n #parts: string[] = [];\n #indent = 0;\n #isAtLineStart = true;\n\n constructor(options: PrintOptions) {\n this.#options = options;\n }\n\n get indent(): number {\n return this.#indent;\n }\n\n get options(): PrintOptions {\n return this.#options;\n }\n\n get text(): string {\n const text = this.#parts.join(\"\");\n this.#parts = [text];\n return text;\n }\n\n increaseIndent(): void {\n this.#indent++;\n }\n\n decreaseIndent(): void {\n this.#indent--;\n }\n\n /** Write text, indenting it first when it starts a line. */\n write(text: string): void {\n if (text.length === 0) {\n return;\n }\n const prefix = this.#isAtLineStart ? this.indentString(this.#indent) : \"\";\n this.rawWrite(prefix + text);\n }\n\n /** Write text exactly as given. */\n rawWrite(text: string): void {\n this.#parts.push(text);\n this.#updateLineStart(text);\n }\n\n /** End the current line; does nothing when nothing has been written on it yet. */\n writeLine(): void {\n if (!this.#isAtLineStart) {\n this.rawWrite(this.#options.newLine);\n }\n }\n\n indentString(level: number): string {\n return \" \".repeat(level * this.#options.indentSize);\n }\n\n // Like TypeScript: any write leaves the writer mid-line unless the text ends with a line break.\n #updateLineStart(text: string): void {\n this.#isAtLineStart = text.length > 0 && isLineBreak(text.charCodeAt(text.length - 1));\n }\n}\n"],"names":[],"mappings":"AAEA,MAAM,SAAA,GAAY,EAAA;AAClB,MAAM,eAAA,GAAkB,EAAA;AACxB,MAAM,cAAA,GAAiB,IAAA;AACvB,MAAM,mBAAA,GAAsB,IAAA;AAGrB,SAAS,YAAY,IAAA,EAAuB;AACjD,EAAA,OACE,SAAS,SAAA,IACT,IAAA,KAAS,eAAA,IACT,IAAA,KAAS,kBACT,IAAA,KAAS,mBAAA;AAEb;AAOO,MAAM,UAAA,CAAW;AAAA,EACb,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,SAAmB,EAAC;AAAA,EACpB,OAAA,GAAU,CAAA;AAAA,EACV,cAAA,GAAiB,IAAA;AAAA,EAEjB,YAAY,OAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EAClB;AAAA,EAEA,IAAI,MAAA,GAAiB;AACnB,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA,EAEA,IAAI,OAAA,GAAwB;AAC1B,IAAA,OAAO,IAAA,CAAK,QAAA;AAAA,EACd;AAAA,EAEA,IAAI,IAAA,GAAe;AACjB,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,EAAE,CAAA;AAChC,IAAA,IAAA,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MESSAGE.test(error.message);
|
|
8
8
|
}
|
|
9
9
|
function schemaTooDeepError(step, cause) {
|
|
10
|
+
const wide = step === "load" ? ", and so does an object with more than about 100,000 keys" : "";
|
|
10
11
|
return new errors.OpenAPITypesafeError({
|
|
11
12
|
code: errors.ERROR_CODES.SCHEMA_TOO_DEEP,
|
|
12
|
-
message: `The schema is nested too deeply to ${step}: the call stack ran out. Both inline schemas and chains of $ref (each schema referring to the next) count; shorten the deepest.`,
|
|
13
|
+
message: `The schema is nested too deeply to ${step}: the call stack ran out. Both inline schemas and chains of $ref (each schema referring to the next) count${wide}; shorten the deepest.`,
|
|
13
14
|
details: { step },
|
|
14
15
|
cause
|
|
15
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-overflow.cjs","sources":["../../src/application/stack-overflow.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/**\n * Deeply nested schemas (ENGINEERING_PLAN 8.5). Loading, bundling, transforming and printing walk\n * schemas recursively, and Redocly follows each `$ref` inside the walk. On the default Node.js\n * stack, about 550 levels of inline schemas or a chain of about 900 `$ref`s (each schema refers to\n * the next) run out of call stack. Real documents stay far below: every YAML or JSON file goes
|
|
1
|
+
{"version":3,"file":"stack-overflow.cjs","sources":["../../src/application/stack-overflow.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/**\n * Deeply nested schemas (ENGINEERING_PLAN 8.5). Loading, bundling, transforming and printing walk\n * schemas recursively, and Redocly follows each `$ref` inside the walk. On the default Node.js\n * stack, about 550 levels of inline schemas or a chain of about 900 `$ref`s (each schema refers to\n * the next) run out of call stack. Redocly's walk also passes the keys of an object to one call as\n * arguments, so a single object with more than about 100,000 keys runs out of it while loading.\n * Real documents stay far below: every YAML or JSON file goes through the YAML parser, which stops\n * at 100 levels, and the whole corpus passes. The overflow is reported as a typed error instead of\n * a `RangeError` with a stack trace.\n */\n\n/** The step that ran out of call stack; named in the message and the details. */\nexport type DeepSchemaStep = \"load\" | \"transform\" | \"print\";\n\n/** V8 and JavaScriptCore (Node.js, Deno, Bun) throw a `RangeError` with this message. */\nconst STACK_OVERFLOW_MESSAGE = /maximum call stack size exceeded/i;\n\n/** Whether a thrown value is a call stack overflow. */\nexport function isStackOverflowError(error: unknown): boolean {\n return error instanceof RangeError && STACK_OVERFLOW_MESSAGE.test(error.message);\n}\n\n/** The typed error for a document nested too deeply, or too wide, for the call stack. */\nexport function schemaTooDeepError(step: DeepSchemaStep, cause: unknown): OpenAPITypesafeError {\n const wide = step === \"load\" ? \", and so does an object with more than about 100,000 keys\" : \"\";\n return new OpenAPITypesafeError({\n code: ERROR_CODES.SCHEMA_TOO_DEEP,\n message:\n `The schema is nested too deeply to ${step}: the call stack ran out. Both inline ` +\n `schemas and chains of $ref (each schema referring to the next) count${wide}; shorten ` +\n \"the deepest.\",\n details: { step },\n cause,\n });\n}\n\n/** Run a step and report a stack overflow in it as SCHEMA_TOO_DEEP; other errors pass through. */\nexport function withStackOverflowReported<T>(step: DeepSchemaStep, run: () => T): T {\n try {\n return run();\n } catch (error) {\n throw isStackOverflowError(error) ? schemaTooDeepError(step, error) : error;\n }\n}\n\n/** The asynchronous form of `withStackOverflowReported`. */\nexport async function withStackOverflowReportedAsync<T>(\n step: DeepSchemaStep,\n run: () => Promise<T>,\n): Promise<T> {\n try {\n return await run();\n } catch (error) {\n throw isStackOverflowError(error) ? schemaTooDeepError(step, error) : error;\n }\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAiBA,MAAM,sBAAA,GAAyB,mCAAA;AAGxB,SAAS,qBAAqB,KAAA,EAAyB;AAC5D,EAAA,OAAO,KAAA,YAAiB,UAAA,IAAc,sBAAA,CAAuB,IAAA,CAAK,MAAM,OAAO,CAAA;AACjF;AAGO,SAAS,kBAAA,CAAmB,MAAsB,KAAA,EAAsC;AAC7F,EAAA,MAAM,IAAA,GAAO,IAAA,KAAS,MAAA,GAAS,2DAAA,GAA8D,EAAA;AAC7F,EAAA,OAAO,IAAIA,2BAAA,CAAqB;AAAA,IAC9B,MAAMC,kBAAA,CAAY,eAAA;AAAA,IAClB,OAAA,EACE,CAAA,mCAAA,EAAsC,IAAI,CAAA,0GAAA,EAC6B,IAAI,CAAA,sBAAA,CAAA;AAAA,IAE7E,OAAA,EAAS,EAAE,IAAA,EAAK;AAAA,IAChB;AAAA,GACD,CAAA;AACH;AAGO,SAAS,yBAAA,CAA6B,MAAsB,GAAA,EAAiB;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,GAAA,EAAI;AAAA,EACb,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,qBAAqB,KAAK,CAAA,GAAI,kBAAA,CAAmB,IAAA,EAAM,KAAK,CAAA,GAAI,KAAA;AAAA,EACxE;AACF;AAGA,eAAsB,8BAAA,CACpB,MACA,GAAA,EACY;AACZ,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,GAAA,EAAI;AAAA,EACnB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,qBAAqB,KAAK,CAAA,GAAI,kBAAA,CAAmB,IAAA,EAAM,KAAK,CAAA,GAAI,KAAA;AAAA,EACxE;AACF;;;;;"}
|
|
@@ -5,9 +5,10 @@ function isStackOverflowError(error) {
|
|
|
5
5
|
return error instanceof RangeError && STACK_OVERFLOW_MESSAGE.test(error.message);
|
|
6
6
|
}
|
|
7
7
|
function schemaTooDeepError(step, cause) {
|
|
8
|
+
const wide = step === "load" ? ", and so does an object with more than about 100,000 keys" : "";
|
|
8
9
|
return new OpenAPITypesafeError({
|
|
9
10
|
code: ERROR_CODES.SCHEMA_TOO_DEEP,
|
|
10
|
-
message: `The schema is nested too deeply to ${step}: the call stack ran out. Both inline schemas and chains of $ref (each schema referring to the next) count; shorten the deepest.`,
|
|
11
|
+
message: `The schema is nested too deeply to ${step}: the call stack ran out. Both inline schemas and chains of $ref (each schema referring to the next) count${wide}; shorten the deepest.`,
|
|
11
12
|
details: { step },
|
|
12
13
|
cause
|
|
13
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-overflow.mjs","sources":["../../src/application/stack-overflow.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/**\n * Deeply nested schemas (ENGINEERING_PLAN 8.5). Loading, bundling, transforming and printing walk\n * schemas recursively, and Redocly follows each `$ref` inside the walk. On the default Node.js\n * stack, about 550 levels of inline schemas or a chain of about 900 `$ref`s (each schema refers to\n * the next) run out of call stack. Real documents stay far below: every YAML or JSON file goes
|
|
1
|
+
{"version":3,"file":"stack-overflow.mjs","sources":["../../src/application/stack-overflow.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/**\n * Deeply nested schemas (ENGINEERING_PLAN 8.5). Loading, bundling, transforming and printing walk\n * schemas recursively, and Redocly follows each `$ref` inside the walk. On the default Node.js\n * stack, about 550 levels of inline schemas or a chain of about 900 `$ref`s (each schema refers to\n * the next) run out of call stack. Redocly's walk also passes the keys of an object to one call as\n * arguments, so a single object with more than about 100,000 keys runs out of it while loading.\n * Real documents stay far below: every YAML or JSON file goes through the YAML parser, which stops\n * at 100 levels, and the whole corpus passes. The overflow is reported as a typed error instead of\n * a `RangeError` with a stack trace.\n */\n\n/** The step that ran out of call stack; named in the message and the details. */\nexport type DeepSchemaStep = \"load\" | \"transform\" | \"print\";\n\n/** V8 and JavaScriptCore (Node.js, Deno, Bun) throw a `RangeError` with this message. */\nconst STACK_OVERFLOW_MESSAGE = /maximum call stack size exceeded/i;\n\n/** Whether a thrown value is a call stack overflow. */\nexport function isStackOverflowError(error: unknown): boolean {\n return error instanceof RangeError && STACK_OVERFLOW_MESSAGE.test(error.message);\n}\n\n/** The typed error for a document nested too deeply, or too wide, for the call stack. */\nexport function schemaTooDeepError(step: DeepSchemaStep, cause: unknown): OpenAPITypesafeError {\n const wide = step === \"load\" ? \", and so does an object with more than about 100,000 keys\" : \"\";\n return new OpenAPITypesafeError({\n code: ERROR_CODES.SCHEMA_TOO_DEEP,\n message:\n `The schema is nested too deeply to ${step}: the call stack ran out. Both inline ` +\n `schemas and chains of $ref (each schema referring to the next) count${wide}; shorten ` +\n \"the deepest.\",\n details: { step },\n cause,\n });\n}\n\n/** Run a step and report a stack overflow in it as SCHEMA_TOO_DEEP; other errors pass through. */\nexport function withStackOverflowReported<T>(step: DeepSchemaStep, run: () => T): T {\n try {\n return run();\n } catch (error) {\n throw isStackOverflowError(error) ? schemaTooDeepError(step, error) : error;\n }\n}\n\n/** The asynchronous form of `withStackOverflowReported`. */\nexport async function withStackOverflowReportedAsync<T>(\n step: DeepSchemaStep,\n run: () => Promise<T>,\n): Promise<T> {\n try {\n return await run();\n } catch (error) {\n throw isStackOverflowError(error) ? schemaTooDeepError(step, error) : error;\n }\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,sBAAA,GAAyB,mCAAA;AAGxB,SAAS,qBAAqB,KAAA,EAAyB;AAC5D,EAAA,OAAO,KAAA,YAAiB,UAAA,IAAc,sBAAA,CAAuB,IAAA,CAAK,MAAM,OAAO,CAAA;AACjF;AAGO,SAAS,kBAAA,CAAmB,MAAsB,KAAA,EAAsC;AAC7F,EAAA,MAAM,IAAA,GAAO,IAAA,KAAS,MAAA,GAAS,2DAAA,GAA8D,EAAA;AAC7F,EAAA,OAAO,IAAI,oBAAA,CAAqB;AAAA,IAC9B,MAAM,WAAA,CAAY,eAAA;AAAA,IAClB,OAAA,EACE,CAAA,mCAAA,EAAsC,IAAI,CAAA,0GAAA,EAC6B,IAAI,CAAA,sBAAA,CAAA;AAAA,IAE7E,OAAA,EAAS,EAAE,IAAA,EAAK;AAAA,IAChB;AAAA,GACD,CAAA;AACH;AAGO,SAAS,yBAAA,CAA6B,MAAsB,GAAA,EAAiB;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,GAAA,EAAI;AAAA,EACb,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,qBAAqB,KAAK,CAAA,GAAI,kBAAA,CAAmB,IAAA,EAAM,KAAK,CAAA,GAAI,KAAA;AAAA,EACxE;AACF;AAGA,eAAsB,8BAAA,CACpB,MACA,GAAA,EACY;AACZ,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,GAAA,EAAI;AAAA,EACnB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,qBAAqB,KAAK,CAAA,GAAI,kBAAA,CAAmB,IAAA,EAAM,KAAK,CAAA,GAAI,KAAA;AAAA,EACxE;AACF;;"}
|
|
@@ -27,7 +27,7 @@ const COMPONENT_TRANSFORMS = {
|
|
|
27
27
|
mediaTypes: mediaType.contentEntryType
|
|
28
28
|
};
|
|
29
29
|
function componentMember(kind, name, item, context) {
|
|
30
|
-
const location = { path: jsonPointer.
|
|
30
|
+
const location = { path: jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, ["components", kind, name]), schema: item };
|
|
31
31
|
const type = COMPONENT_TRANSFORMS[kind](item, location, context);
|
|
32
32
|
const custom = context.callbacks.transform(item, location);
|
|
33
33
|
const property = constructors.irProperty(propertyName.toPropertyName(name), custom?.type ?? type, {
|
|
@@ -86,7 +86,7 @@ function kindMember(kind, request, context) {
|
|
|
86
86
|
}
|
|
87
87
|
function componentsType(components, context, kept = /* @__PURE__ */ new Set()) {
|
|
88
88
|
const aliases = {};
|
|
89
|
-
const displaced = context.options.fixes.has(outputFixes.
|
|
89
|
+
const displaced = context.options.fixes.has(outputFixes.FIX.ROOT_TYPE_NUMBERING) ? [] : null;
|
|
90
90
|
const isKept = (item) => kept.has(item);
|
|
91
91
|
const request = { components, isKept, aliases, displaced };
|
|
92
92
|
const declaredKinds = componentsObject.DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.cjs","sources":["../../../../src/application/transform/document/components.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport {\n hasIdentifierStart,\n isReservedTypeName,\n withIdentifierParts,\n} from \"../../../domain/ir/identifier-text.js\";\nimport type {\n IrPropertySignature,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {\n COMPONENT_KINDS,\n type ComponentKind,\n type ComponentsObject,\n DECLARED_COMPONENT_KINDS,\n isEnumSchema,\n singularizeComponentKind,\n} from \"../../../domain/openapi/components-object.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport { OutputFix } from \"../../../domain/output-fixes.js\";\nimport { type DeprecatedEntryFilter, documentEntries } from \"../document-entries.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType } from \"./media-type.js\";\nimport { parameterType } from \"./parameter.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responseType } from \"./response.js\";\nimport { rootTypeAlias } from \"./root-type-aliases.js\";\n\ntype ComponentTransform = (\n item: never,\n location: SchemaLocation,\n context: TransformContext,\n) => IrType;\n\nconst COMPONENT_TRANSFORMS: Readonly<Record<ComponentKind, ComponentTransform>> = {\n schemas: transformSchema,\n responses: responseType,\n parameters: parameterType,\n requestBodies: requestBodyType,\n headers: headerType,\n pathItems: pathItemType,\n mediaTypes: contentEntryType,\n};\n\n/** The `components` type and the `--root-types` aliases. */\nexport interface ComponentsResult {\n readonly type: IrType;\n readonly rootTypes: readonly IrTypeAliasDeclaration[];\n}\n\n/** One component; the `transform` callback may replace its type, as for nested schemas. */\nfunction componentMember(\n kind: ComponentKind,\n name: string,\n item: unknown,\n context: TransformContext,\n): IrPropertySignature {\n const location = { path: createRef([\"components\", kind, name]), schema: item };\n const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);\n const custom = context.callbacks.transform(item, location);\n const property = irProperty(toPropertyName(name), custom?.type ?? type, {\n isOptional: custom?.isOptional ?? false,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, item, schemaCommentOptionsOf(context.options.fixes));\n}\n\n/**\n * The root alias name: `SchemaPet`, `ResponseNotFound`, … A taken name gets `_2`, `_3`, … The\n * original checks for conflicts before it removes the schema prefix, and so does this; for a clash\n * of exported names see `addRootAlias`.\n *\n * The original could build a name that is no identifier, so the generated file did not parse\n * (research/legacy-bugs.md, item 16): a kept casing keeps spaces and symbols, which become `_`;\n * and a name without the prefix can start with a digit, so it keeps the prefix (`Schema1`). A\n * kept casing without the prefix can also give a reserved name (`void`, `class`), which keeps the\n * prefix too (`Schemavoid`).\n */\nfunction rootTypeName(\n kind: ComponentKind,\n name: string,\n aliases: Readonly<Record<string, IrTypeAliasDeclaration>>,\n context: TransformContext,\n): string {\n const { options, casing } = context;\n const prefix = casing.pascalCase(singularizeComponentKind(kind));\n const isSchema = kind === \"schemas\";\n const base = withIdentifierParts(\n options.rootTypesKeepCasing && isSchema ? name : casing.pascalCase(name),\n );\n const exportedName = (alias: string): string => {\n const unprefixed = alias.replace(prefix, \"\");\n const isUnprefixed = options.rootTypesNoSchemaPrefix && isSchema;\n const isTypeName = hasIdentifierStart(unprefixed) && !isReservedTypeName(unprefixed);\n return isUnprefixed && isTypeName ? unprefixed : alias;\n };\n let alias = `${prefix}${base}`;\n for (let counter = 2; aliases[alias] !== undefined; counter++) {\n alias = `${prefix}${base}_${counter}`;\n }\n return exportedName(alias);\n}\n\n/**\n * Add a root alias. When its exported name is taken (two schemas of one PascalCase name without\n * the prefix), the later schema takes the name, as in the original. Without the\n * `root-type-numbering` fix the earlier one then has no alias: that output is valid, so a number\n * for it would change it (backlog 30). With the fix the earlier alias is kept aside and follows\n * the others under the same name; `renameTakenAliases` numbers it once every name is known.\n */\nfunction addRootAlias(request: ComponentsRequest, alias: IrTypeAliasDeclaration): void {\n const { aliases, displaced } = request;\n const previous = aliases[alias.name];\n if (previous !== undefined && displaced !== null) {\n displaced.push(previous);\n }\n aliases[alias.name] = alias;\n}\n\n/** `--root-types` skips enum schemas under `--enum`: the enum itself is exported. */\nfunction hasRootType(kind: ComponentKind, item: unknown, context: TransformContext): boolean {\n const { options } = context;\n return options.rootTypes && !(options.enum && kind === \"schemas\" && isEnumSchema(item));\n}\n\n/** The components of one run, and the deprecated ones that kept output still references. */\ninterface ComponentsRequest {\n readonly components: ComponentsObject;\n readonly isKept: DeprecatedEntryFilter;\n readonly aliases: Record<string, IrTypeAliasDeclaration>;\n /** With the `root-type-numbering` fix: the aliases a later schema took the name of, in order. */\n readonly displaced: IrTypeAliasDeclaration[] | null;\n}\n\nfunction kindMember(\n kind: ComponentKind,\n request: ComponentsRequest,\n context: TransformContext,\n): IrPropertySignature {\n const { components, isKept, aliases } = request;\n const startedAt = context.diagnostics.now();\n const items: IrPropertySignature[] = [];\n for (const [name, item] of documentEntries(components[kind] ?? {}, context.options, isKept)) {\n items.push(componentMember(kind, name, item, context));\n if (hasRootType(kind, item, context)) {\n addRootAlias(request, rootTypeAlias(rootTypeName(kind, name, aliases, context), kind, name));\n }\n }\n const type = items.length > 0 ? irObject(items) : irKeyword(\"never\");\n context.diagnostics.debug(\n `Transformed components → ${kind}`,\n context.diagnostics.now() - startedAt,\n );\n return irProperty(toPropertyName(kind), type);\n}\n\n/**\n * The `components` interface body (OpenAPI 3.1 §4.8.7), one member per component kind. With\n * `--exclude-deprecated`, `kept` holds the deprecated components that kept output references\n * (`keptDeprecatedComponents`); they stay, so no reference names a missing key.\n */\nexport function componentsType(\n components: ComponentsObject,\n context: TransformContext,\n kept: ReadonlySet<object> = new Set(),\n): ComponentsResult {\n // A plain object, as in the original: its key order (integer-like names first) is the\n // output order.\n const aliases: Record<string, IrTypeAliasDeclaration> = {};\n const displaced = context.options.fixes.has(OutputFix.ROOT_TYPE_NUMBERING) ? [] : null;\n const isKept = (item: unknown) => kept.has(item as object);\n const request = { components, isKept, aliases, displaced };\n const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);\n const members = [...COMPONENT_KINDS, ...declaredKinds].map((kind) =>\n kindMember(kind, request, context),\n );\n const rootTypes = Object.values(aliases);\n return {\n type: irObject(members),\n rootTypes: [...rootTypes, ...(displaced ?? [])],\n };\n}\n"],"names":["transformSchema","responseType","parameterType","requestBodyType","headerType","pathItemType","contentEntryType","createRef","irProperty","toPropertyName","withSchemaComment","schemaCommentOptionsOf","singularizeComponentKind","withIdentifierParts","alias","hasIdentifierStart","isReservedTypeName","isEnumSchema","documentEntries","rootTypeAlias","irObject","irKeyword","OutputFix","DECLARED_COMPONENT_KINDS","COMPONENT_KINDS"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCA,MAAM,oBAAA,GAA4E;AAAA,EAChF,OAAA,EAASA,+BAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC,uBAAA;AAAA,EACZ,aAAA,EAAeC,2BAAA;AAAA,EACf,OAAA,EAASC,iBAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC;AACd,CAAA;AASA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAMC,qBAAA,CAAU,CAAC,YAAA,EAAc,IAAA,EAAM,IAAI,CAAC,CAAA,EAAG,MAAA,EAAQ,IAAA,EAAK;AAC7E,EAAA,MAAM,OAAO,oBAAA,CAAqB,IAAI,CAAA,CAAE,IAAA,EAAe,UAAU,OAAO,CAAA;AACxE,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,SAAA,CAAU,SAAA,CAAU,MAAM,QAAQ,CAAA;AACzD,EAAA,MAAM,WAAWC,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,MAAA,EAAQ,QAAQ,IAA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AMJ,sBAAS,OAAO,CAAA;AAAA,IACtB,WAAW,CAAC,GAAG,WAAW,GAAI,SAAA,IAAa,EAAG;AAAA,GAChD;AACF;;"}
|
|
1
|
+
{"version":3,"file":"components.cjs","sources":["../../../../src/application/transform/document/components.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport {\n hasIdentifierStart,\n isReservedTypeName,\n withIdentifierParts,\n} from \"../../../domain/ir/identifier-text.js\";\nimport type {\n IrPropertySignature,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {\n COMPONENT_KINDS,\n type ComponentKind,\n type ComponentsObject,\n DECLARED_COMPONENT_KINDS,\n isEnumSchema,\n singularizeComponentKind,\n} from \"../../../domain/openapi/components-object.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { type DeprecatedEntryFilter, documentEntries } from \"../document-entries.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType } from \"./media-type.js\";\nimport { parameterType } from \"./parameter.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responseType } from \"./response.js\";\nimport { rootTypeAlias } from \"./root-type-aliases.js\";\n\ntype ComponentTransform = (\n item: never,\n location: SchemaLocation,\n context: TransformContext,\n) => IrType;\n\nconst COMPONENT_TRANSFORMS: Readonly<Record<ComponentKind, ComponentTransform>> = {\n schemas: transformSchema,\n responses: responseType,\n parameters: parameterType,\n requestBodies: requestBodyType,\n headers: headerType,\n pathItems: pathItemType,\n mediaTypes: contentEntryType,\n};\n\n/** The `components` type and the `--root-types` aliases. */\nexport interface ComponentsResult {\n readonly type: IrType;\n readonly rootTypes: readonly IrTypeAliasDeclaration[];\n}\n\n/** One component; the `transform` callback may replace its type, as for nested schemas. */\nfunction componentMember(\n kind: ComponentKind,\n name: string,\n item: unknown,\n context: TransformContext,\n): IrPropertySignature {\n const location = { path: appendPointer(ROOT_POINTER, [\"components\", kind, name]), schema: item };\n const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);\n const custom = context.callbacks.transform(item, location);\n const property = irProperty(toPropertyName(name), custom?.type ?? type, {\n isOptional: custom?.isOptional ?? false,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, item, schemaCommentOptionsOf(context.options.fixes));\n}\n\n/**\n * The root alias name: `SchemaPet`, `ResponseNotFound`, … A taken name gets `_2`, `_3`, … The\n * original checks for conflicts before it removes the schema prefix, and so does this; for a clash\n * of exported names see `addRootAlias`.\n *\n * The original could build a name that is no identifier, so the generated file did not parse\n * (research/legacy-bugs.md, item 16): a kept casing keeps spaces and symbols, which become `_`;\n * and a name without the prefix can start with a digit, so it keeps the prefix (`Schema1`). A\n * kept casing without the prefix can also give a reserved name (`void`, `class`), which keeps the\n * prefix too (`Schemavoid`).\n */\nfunction rootTypeName(\n kind: ComponentKind,\n name: string,\n aliases: Readonly<Record<string, IrTypeAliasDeclaration>>,\n context: TransformContext,\n): string {\n const { options, casing } = context;\n const prefix = casing.pascalCase(singularizeComponentKind(kind));\n const isSchema = kind === \"schemas\";\n const base = withIdentifierParts(\n options.rootTypesKeepCasing && isSchema ? name : casing.pascalCase(name),\n );\n const exportedName = (alias: string): string => {\n const unprefixed = alias.replace(prefix, \"\");\n const isUnprefixed = options.rootTypesNoSchemaPrefix && isSchema;\n const isTypeName = hasIdentifierStart(unprefixed) && !isReservedTypeName(unprefixed);\n return isUnprefixed && isTypeName ? unprefixed : alias;\n };\n let alias = `${prefix}${base}`;\n for (let counter = 2; aliases[alias] !== undefined; counter++) {\n alias = `${prefix}${base}_${counter}`;\n }\n return exportedName(alias);\n}\n\n/**\n * Add a root alias. When its exported name is taken (two schemas of one PascalCase name without\n * the prefix), the later schema takes the name, as in the original. Without the\n * `root-type-numbering` fix the earlier one then has no alias: that output is valid, so a number\n * for it would change it (backlog 30). With the fix the earlier alias is kept aside and follows\n * the others under the same name; `renameTakenAliases` numbers it once every name is known.\n */\nfunction addRootAlias(request: ComponentsRequest, alias: IrTypeAliasDeclaration): void {\n const { aliases, displaced } = request;\n const previous = aliases[alias.name];\n if (previous !== undefined && displaced !== null) {\n displaced.push(previous);\n }\n aliases[alias.name] = alias;\n}\n\n/** `--root-types` skips enum schemas under `--enum`: the enum itself is exported. */\nfunction hasRootType(kind: ComponentKind, item: unknown, context: TransformContext): boolean {\n const { options } = context;\n return options.rootTypes && !(options.enum && kind === \"schemas\" && isEnumSchema(item));\n}\n\n/** The components of one run, and the deprecated ones that kept output still references. */\ninterface ComponentsRequest {\n readonly components: ComponentsObject;\n readonly isKept: DeprecatedEntryFilter;\n readonly aliases: Record<string, IrTypeAliasDeclaration>;\n /** With the `root-type-numbering` fix: the aliases a later schema took the name of, in order. */\n readonly displaced: IrTypeAliasDeclaration[] | null;\n}\n\nfunction kindMember(\n kind: ComponentKind,\n request: ComponentsRequest,\n context: TransformContext,\n): IrPropertySignature {\n const { components, isKept, aliases } = request;\n const startedAt = context.diagnostics.now();\n const items: IrPropertySignature[] = [];\n for (const [name, item] of documentEntries(components[kind] ?? {}, context.options, isKept)) {\n items.push(componentMember(kind, name, item, context));\n if (hasRootType(kind, item, context)) {\n addRootAlias(request, rootTypeAlias(rootTypeName(kind, name, aliases, context), kind, name));\n }\n }\n const type = items.length > 0 ? irObject(items) : irKeyword(\"never\");\n context.diagnostics.debug(\n `Transformed components → ${kind}`,\n context.diagnostics.now() - startedAt,\n );\n return irProperty(toPropertyName(kind), type);\n}\n\n/**\n * The `components` interface body (OpenAPI 3.1 §4.8.7), one member per component kind. With\n * `--exclude-deprecated`, `kept` holds the deprecated components that kept output references\n * (`keptDeprecatedComponents`); they stay, so no reference names a missing key.\n */\nexport function componentsType(\n components: ComponentsObject,\n context: TransformContext,\n kept: ReadonlySet<object> = new Set(),\n): ComponentsResult {\n // A plain object, as in the original: its key order (integer-like names first) is the\n // output order.\n const aliases: Record<string, IrTypeAliasDeclaration> = {};\n const displaced = context.options.fixes.has(FIX.ROOT_TYPE_NUMBERING) ? [] : null;\n const isKept = (item: unknown) => kept.has(item as object);\n const request = { components, isKept, aliases, displaced };\n const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);\n const members = [...COMPONENT_KINDS, ...declaredKinds].map((kind) =>\n kindMember(kind, request, context),\n );\n const rootTypes = Object.values(aliases);\n return {\n type: irObject(members),\n rootTypes: [...rootTypes, ...(displaced ?? [])],\n };\n}\n"],"names":["transformSchema","responseType","parameterType","requestBodyType","headerType","pathItemType","contentEntryType","appendPointer","ROOT_POINTER","irProperty","toPropertyName","withSchemaComment","schemaCommentOptionsOf","singularizeComponentKind","withIdentifierParts","alias","hasIdentifierStart","isReservedTypeName","isEnumSchema","documentEntries","rootTypeAlias","irObject","irKeyword","FIX","DECLARED_COMPONENT_KINDS","COMPONENT_KINDS"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCA,MAAM,oBAAA,GAA4E;AAAA,EAChF,OAAA,EAASA,+BAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC,uBAAA;AAAA,EACZ,aAAA,EAAeC,2BAAA;AAAA,EACf,OAAA,EAASC,iBAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC;AACd,CAAA;AASA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAMC,yBAAA,CAAcC,wBAAA,EAAc,CAAC,YAAA,EAAc,IAAA,EAAM,IAAI,CAAC,CAAA,EAAG,MAAA,EAAQ,IAAA,E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AS,CAAA;AAC9F,EAAA,MAAM,UAAU,CAAC,GAAGC,gCAAA,EAAiB,GAAG,aAAa,CAAA,CAAE,GAAA;AAAA,IAAI,CAAC,IAAA,KAC1D,UAAA,CAAW,IAAA,EAAM,SAAS,OAAO;AAAA,GACnC;AACA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA;AACvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAMJ,sBAAS,OAAO,CAAA;AAAA,IACtB,WAAW,CAAC,GAAG,WAAW,GAAI,SAAA,IAAa,EAAG;AAAA,GAChD;AACF;;"}
|
|
@@ -2,8 +2,8 @@ import { irObject, irProperty, irKeyword } from '../../../domain/ir/constructors
|
|
|
2
2
|
import { withIdentifierParts, hasIdentifierStart, isReservedTypeName } from '../../../domain/ir/identifier-text.mjs';
|
|
3
3
|
import { toPropertyName } from '../../../domain/ir/property-name.mjs';
|
|
4
4
|
import { DECLARED_COMPONENT_KINDS, COMPONENT_KINDS, isEnumSchema, singularizeComponentKind } from '../../../domain/openapi/components-object.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { appendPointer, ROOT_POINTER } from '../../../domain/openapi/json-pointer.mjs';
|
|
6
|
+
import { FIX } from '../../../domain/output-fixes.mjs';
|
|
7
7
|
import { documentEntries } from '../document-entries.mjs';
|
|
8
8
|
import { transformSchema } from '../schema/schema-transform.mjs';
|
|
9
9
|
import { withSchemaComment, schemaCommentOptionsOf } from '../schema-comment.mjs';
|
|
@@ -25,7 +25,7 @@ const COMPONENT_TRANSFORMS = {
|
|
|
25
25
|
mediaTypes: contentEntryType
|
|
26
26
|
};
|
|
27
27
|
function componentMember(kind, name, item, context) {
|
|
28
|
-
const location = { path:
|
|
28
|
+
const location = { path: appendPointer(ROOT_POINTER, ["components", kind, name]), schema: item };
|
|
29
29
|
const type = COMPONENT_TRANSFORMS[kind](item, location, context);
|
|
30
30
|
const custom = context.callbacks.transform(item, location);
|
|
31
31
|
const property = irProperty(toPropertyName(name), custom?.type ?? type, {
|
|
@@ -84,7 +84,7 @@ function kindMember(kind, request, context) {
|
|
|
84
84
|
}
|
|
85
85
|
function componentsType(components, context, kept = /* @__PURE__ */ new Set()) {
|
|
86
86
|
const aliases = {};
|
|
87
|
-
const displaced = context.options.fixes.has(
|
|
87
|
+
const displaced = context.options.fixes.has(FIX.ROOT_TYPE_NUMBERING) ? [] : null;
|
|
88
88
|
const isKept = (item) => kept.has(item);
|
|
89
89
|
const request = { components, isKept, aliases, displaced };
|
|
90
90
|
const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.mjs","sources":["../../../../src/application/transform/document/components.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport {\n hasIdentifierStart,\n isReservedTypeName,\n withIdentifierParts,\n} from \"../../../domain/ir/identifier-text.js\";\nimport type {\n IrPropertySignature,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {\n COMPONENT_KINDS,\n type ComponentKind,\n type ComponentsObject,\n DECLARED_COMPONENT_KINDS,\n isEnumSchema,\n singularizeComponentKind,\n} from \"../../../domain/openapi/components-object.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport { OutputFix } from \"../../../domain/output-fixes.js\";\nimport { type DeprecatedEntryFilter, documentEntries } from \"../document-entries.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType } from \"./media-type.js\";\nimport { parameterType } from \"./parameter.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responseType } from \"./response.js\";\nimport { rootTypeAlias } from \"./root-type-aliases.js\";\n\ntype ComponentTransform = (\n item: never,\n location: SchemaLocation,\n context: TransformContext,\n) => IrType;\n\nconst COMPONENT_TRANSFORMS: Readonly<Record<ComponentKind, ComponentTransform>> = {\n schemas: transformSchema,\n responses: responseType,\n parameters: parameterType,\n requestBodies: requestBodyType,\n headers: headerType,\n pathItems: pathItemType,\n mediaTypes: contentEntryType,\n};\n\n/** The `components` type and the `--root-types` aliases. */\nexport interface ComponentsResult {\n readonly type: IrType;\n readonly rootTypes: readonly IrTypeAliasDeclaration[];\n}\n\n/** One component; the `transform` callback may replace its type, as for nested schemas. */\nfunction componentMember(\n kind: ComponentKind,\n name: string,\n item: unknown,\n context: TransformContext,\n): IrPropertySignature {\n const location = { path: createRef([\"components\", kind, name]), schema: item };\n const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);\n const custom = context.callbacks.transform(item, location);\n const property = irProperty(toPropertyName(name), custom?.type ?? type, {\n isOptional: custom?.isOptional ?? false,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, item, schemaCommentOptionsOf(context.options.fixes));\n}\n\n/**\n * The root alias name: `SchemaPet`, `ResponseNotFound`, … A taken name gets `_2`, `_3`, … The\n * original checks for conflicts before it removes the schema prefix, and so does this; for a clash\n * of exported names see `addRootAlias`.\n *\n * The original could build a name that is no identifier, so the generated file did not parse\n * (research/legacy-bugs.md, item 16): a kept casing keeps spaces and symbols, which become `_`;\n * and a name without the prefix can start with a digit, so it keeps the prefix (`Schema1`). A\n * kept casing without the prefix can also give a reserved name (`void`, `class`), which keeps the\n * prefix too (`Schemavoid`).\n */\nfunction rootTypeName(\n kind: ComponentKind,\n name: string,\n aliases: Readonly<Record<string, IrTypeAliasDeclaration>>,\n context: TransformContext,\n): string {\n const { options, casing } = context;\n const prefix = casing.pascalCase(singularizeComponentKind(kind));\n const isSchema = kind === \"schemas\";\n const base = withIdentifierParts(\n options.rootTypesKeepCasing && isSchema ? name : casing.pascalCase(name),\n );\n const exportedName = (alias: string): string => {\n const unprefixed = alias.replace(prefix, \"\");\n const isUnprefixed = options.rootTypesNoSchemaPrefix && isSchema;\n const isTypeName = hasIdentifierStart(unprefixed) && !isReservedTypeName(unprefixed);\n return isUnprefixed && isTypeName ? unprefixed : alias;\n };\n let alias = `${prefix}${base}`;\n for (let counter = 2; aliases[alias] !== undefined; counter++) {\n alias = `${prefix}${base}_${counter}`;\n }\n return exportedName(alias);\n}\n\n/**\n * Add a root alias. When its exported name is taken (two schemas of one PascalCase name without\n * the prefix), the later schema takes the name, as in the original. Without the\n * `root-type-numbering` fix the earlier one then has no alias: that output is valid, so a number\n * for it would change it (backlog 30). With the fix the earlier alias is kept aside and follows\n * the others under the same name; `renameTakenAliases` numbers it once every name is known.\n */\nfunction addRootAlias(request: ComponentsRequest, alias: IrTypeAliasDeclaration): void {\n const { aliases, displaced } = request;\n const previous = aliases[alias.name];\n if (previous !== undefined && displaced !== null) {\n displaced.push(previous);\n }\n aliases[alias.name] = alias;\n}\n\n/** `--root-types` skips enum schemas under `--enum`: the enum itself is exported. */\nfunction hasRootType(kind: ComponentKind, item: unknown, context: TransformContext): boolean {\n const { options } = context;\n return options.rootTypes && !(options.enum && kind === \"schemas\" && isEnumSchema(item));\n}\n\n/** The components of one run, and the deprecated ones that kept output still references. */\ninterface ComponentsRequest {\n readonly components: ComponentsObject;\n readonly isKept: DeprecatedEntryFilter;\n readonly aliases: Record<string, IrTypeAliasDeclaration>;\n /** With the `root-type-numbering` fix: the aliases a later schema took the name of, in order. */\n readonly displaced: IrTypeAliasDeclaration[] | null;\n}\n\nfunction kindMember(\n kind: ComponentKind,\n request: ComponentsRequest,\n context: TransformContext,\n): IrPropertySignature {\n const { components, isKept, aliases } = request;\n const startedAt = context.diagnostics.now();\n const items: IrPropertySignature[] = [];\n for (const [name, item] of documentEntries(components[kind] ?? {}, context.options, isKept)) {\n items.push(componentMember(kind, name, item, context));\n if (hasRootType(kind, item, context)) {\n addRootAlias(request, rootTypeAlias(rootTypeName(kind, name, aliases, context), kind, name));\n }\n }\n const type = items.length > 0 ? irObject(items) : irKeyword(\"never\");\n context.diagnostics.debug(\n `Transformed components → ${kind}`,\n context.diagnostics.now() - startedAt,\n );\n return irProperty(toPropertyName(kind), type);\n}\n\n/**\n * The `components` interface body (OpenAPI 3.1 §4.8.7), one member per component kind. With\n * `--exclude-deprecated`, `kept` holds the deprecated components that kept output references\n * (`keptDeprecatedComponents`); they stay, so no reference names a missing key.\n */\nexport function componentsType(\n components: ComponentsObject,\n context: TransformContext,\n kept: ReadonlySet<object> = new Set(),\n): ComponentsResult {\n // A plain object, as in the original: its key order (integer-like names first) is the\n // output order.\n const aliases: Record<string, IrTypeAliasDeclaration> = {};\n const displaced = context.options.fixes.has(OutputFix.ROOT_TYPE_NUMBERING) ? [] : null;\n const isKept = (item: unknown) => kept.has(item as object);\n const request = { components, isKept, aliases, displaced };\n const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);\n const members = [...COMPONENT_KINDS, ...declaredKinds].map((kind) =>\n kindMember(kind, request, context),\n );\n const rootTypes = Object.values(aliases);\n return {\n type: irObject(members),\n rootTypes: [...rootTypes, ...(displaced ?? [])],\n };\n}\n"],"names":["alias"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAM,oBAAA,GAA4E;AAAA,EAChF,OAAA,EAAS,eAAA;AAAA,EACT,SAAA,EAAW,YAAA;AAAA,EACX,UAAA,EAAY,aAAA;AAAA,EACZ,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,UAAA;AAAA,EACT,SAAA,EAAW,YAAA;AAAA,EACX,UAAA,EAAY;AACd,CAAA;AASA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAM,SAAA,CAAU,CAAC,YAAA,EAAc,IAAA,EAAM,IAAI,CAAC,CAAA,EAAG,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AAC9F,EAAA,MAAM,UAAU,CAAC,GAAG,eAAA,EAAiB,GAAG,aAAa,CAAA,CAAE,GAAA;AAAA,IAAI,CAAC,IAAA,KAC1D,UAAA,CAAW,IAAA,EAAM,SAAS,OAAO;AAAA,GACnC;AACA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA;AACvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,SAAS,OAAO,CAAA;AAAA,IACtB,WAAW,CAAC,GAAG,WAAW,GAAI,SAAA,IAAa,EAAG;AAAA,GAChD;AACF;;"}
|
|
1
|
+
{"version":3,"file":"components.mjs","sources":["../../../../src/application/transform/document/components.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport {\n hasIdentifierStart,\n isReservedTypeName,\n withIdentifierParts,\n} from \"../../../domain/ir/identifier-text.js\";\nimport type {\n IrPropertySignature,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {\n COMPONENT_KINDS,\n type ComponentKind,\n type ComponentsObject,\n DECLARED_COMPONENT_KINDS,\n isEnumSchema,\n singularizeComponentKind,\n} from \"../../../domain/openapi/components-object.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { type DeprecatedEntryFilter, documentEntries } from \"../document-entries.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType } from \"./media-type.js\";\nimport { parameterType } from \"./parameter.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responseType } from \"./response.js\";\nimport { rootTypeAlias } from \"./root-type-aliases.js\";\n\ntype ComponentTransform = (\n item: never,\n location: SchemaLocation,\n context: TransformContext,\n) => IrType;\n\nconst COMPONENT_TRANSFORMS: Readonly<Record<ComponentKind, ComponentTransform>> = {\n schemas: transformSchema,\n responses: responseType,\n parameters: parameterType,\n requestBodies: requestBodyType,\n headers: headerType,\n pathItems: pathItemType,\n mediaTypes: contentEntryType,\n};\n\n/** The `components` type and the `--root-types` aliases. */\nexport interface ComponentsResult {\n readonly type: IrType;\n readonly rootTypes: readonly IrTypeAliasDeclaration[];\n}\n\n/** One component; the `transform` callback may replace its type, as for nested schemas. */\nfunction componentMember(\n kind: ComponentKind,\n name: string,\n item: unknown,\n context: TransformContext,\n): IrPropertySignature {\n const location = { path: appendPointer(ROOT_POINTER, [\"components\", kind, name]), schema: item };\n const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);\n const custom = context.callbacks.transform(item, location);\n const property = irProperty(toPropertyName(name), custom?.type ?? type, {\n isOptional: custom?.isOptional ?? false,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, item, schemaCommentOptionsOf(context.options.fixes));\n}\n\n/**\n * The root alias name: `SchemaPet`, `ResponseNotFound`, … A taken name gets `_2`, `_3`, … The\n * original checks for conflicts before it removes the schema prefix, and so does this; for a clash\n * of exported names see `addRootAlias`.\n *\n * The original could build a name that is no identifier, so the generated file did not parse\n * (research/legacy-bugs.md, item 16): a kept casing keeps spaces and symbols, which become `_`;\n * and a name without the prefix can start with a digit, so it keeps the prefix (`Schema1`). A\n * kept casing without the prefix can also give a reserved name (`void`, `class`), which keeps the\n * prefix too (`Schemavoid`).\n */\nfunction rootTypeName(\n kind: ComponentKind,\n name: string,\n aliases: Readonly<Record<string, IrTypeAliasDeclaration>>,\n context: TransformContext,\n): string {\n const { options, casing } = context;\n const prefix = casing.pascalCase(singularizeComponentKind(kind));\n const isSchema = kind === \"schemas\";\n const base = withIdentifierParts(\n options.rootTypesKeepCasing && isSchema ? name : casing.pascalCase(name),\n );\n const exportedName = (alias: string): string => {\n const unprefixed = alias.replace(prefix, \"\");\n const isUnprefixed = options.rootTypesNoSchemaPrefix && isSchema;\n const isTypeName = hasIdentifierStart(unprefixed) && !isReservedTypeName(unprefixed);\n return isUnprefixed && isTypeName ? unprefixed : alias;\n };\n let alias = `${prefix}${base}`;\n for (let counter = 2; aliases[alias] !== undefined; counter++) {\n alias = `${prefix}${base}_${counter}`;\n }\n return exportedName(alias);\n}\n\n/**\n * Add a root alias. When its exported name is taken (two schemas of one PascalCase name without\n * the prefix), the later schema takes the name, as in the original. Without the\n * `root-type-numbering` fix the earlier one then has no alias: that output is valid, so a number\n * for it would change it (backlog 30). With the fix the earlier alias is kept aside and follows\n * the others under the same name; `renameTakenAliases` numbers it once every name is known.\n */\nfunction addRootAlias(request: ComponentsRequest, alias: IrTypeAliasDeclaration): void {\n const { aliases, displaced } = request;\n const previous = aliases[alias.name];\n if (previous !== undefined && displaced !== null) {\n displaced.push(previous);\n }\n aliases[alias.name] = alias;\n}\n\n/** `--root-types` skips enum schemas under `--enum`: the enum itself is exported. */\nfunction hasRootType(kind: ComponentKind, item: unknown, context: TransformContext): boolean {\n const { options } = context;\n return options.rootTypes && !(options.enum && kind === \"schemas\" && isEnumSchema(item));\n}\n\n/** The components of one run, and the deprecated ones that kept output still references. */\ninterface ComponentsRequest {\n readonly components: ComponentsObject;\n readonly isKept: DeprecatedEntryFilter;\n readonly aliases: Record<string, IrTypeAliasDeclaration>;\n /** With the `root-type-numbering` fix: the aliases a later schema took the name of, in order. */\n readonly displaced: IrTypeAliasDeclaration[] | null;\n}\n\nfunction kindMember(\n kind: ComponentKind,\n request: ComponentsRequest,\n context: TransformContext,\n): IrPropertySignature {\n const { components, isKept, aliases } = request;\n const startedAt = context.diagnostics.now();\n const items: IrPropertySignature[] = [];\n for (const [name, item] of documentEntries(components[kind] ?? {}, context.options, isKept)) {\n items.push(componentMember(kind, name, item, context));\n if (hasRootType(kind, item, context)) {\n addRootAlias(request, rootTypeAlias(rootTypeName(kind, name, aliases, context), kind, name));\n }\n }\n const type = items.length > 0 ? irObject(items) : irKeyword(\"never\");\n context.diagnostics.debug(\n `Transformed components → ${kind}`,\n context.diagnostics.now() - startedAt,\n );\n return irProperty(toPropertyName(kind), type);\n}\n\n/**\n * The `components` interface body (OpenAPI 3.1 §4.8.7), one member per component kind. With\n * `--exclude-deprecated`, `kept` holds the deprecated components that kept output references\n * (`keptDeprecatedComponents`); they stay, so no reference names a missing key.\n */\nexport function componentsType(\n components: ComponentsObject,\n context: TransformContext,\n kept: ReadonlySet<object> = new Set(),\n): ComponentsResult {\n // A plain object, as in the original: its key order (integer-like names first) is the\n // output order.\n const aliases: Record<string, IrTypeAliasDeclaration> = {};\n const displaced = context.options.fixes.has(FIX.ROOT_TYPE_NUMBERING) ? [] : null;\n const isKept = (item: unknown) => kept.has(item as object);\n const request = { components, isKept, aliases, displaced };\n const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);\n const members = [...COMPONENT_KINDS, ...declaredKinds].map((kind) =>\n kindMember(kind, request, context),\n );\n const rootTypes = Object.values(aliases);\n return {\n type: irObject(members),\n rootTypes: [...rootTypes, ...(displaced ?? [])],\n };\n}\n"],"names":["alias"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAM,oBAAA,GAA4E;AAAA,EAChF,OAAA,EAAS,eAAA;AAAA,EACT,SAAA,EAAW,YAAA;AAAA,EACX,UAAA,EAAY,aAAA;AAAA,EACZ,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS,UAAA;AAAA,EACT,SAAA,EAAW,YAAA;AAAA,EACX,UAAA,EAAY;AACd,CAAA;AASA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAM,aAAA,CAAc,YAAA,EAAc,CAAC,YAAA,EAAc,IAAA,EAAM,IAAI,CAAC,CAAA,EAAG,MAAA,EAAQ,I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MAAM,UAAU,CAAC,GAAG,eAAA,EAAiB,GAAG,aAAa,CAAA,CAAE,GAAA;AAAA,IAAI,CAAC,IAAA,KAC1D,UAAA,CAAW,IAAA,EAAM,SAAS,OAAO;AAAA,GACnC;AACA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA;AACvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,SAAS,OAAO,CAAA;AAAA,IACtB,WAAW,CAAC,GAAG,WAAW,GAAI,SAAA,IAAa,EAAG;AAAA,GAChD;AACF;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const RAW_TYPE_DECLARATION_RE = /^(?:export\s+)?(?:declare\s+)?(?:type|interface|enum|const\s+enum|class)\s+([A-Za-z_$][\w$]*)/gm;
|
|
4
|
+
function typeNamesInText(text) {
|
|
5
|
+
return [...text.matchAll(RAW_TYPE_DECLARATION_RE)].map((match) => match[1] ?? "");
|
|
6
|
+
}
|
|
7
|
+
function typeNamesOf(declaration) {
|
|
8
|
+
switch (declaration.kind) {
|
|
9
|
+
case "rawDeclaration":
|
|
10
|
+
return declaration.name === void 0 ? typeNamesInText(declaration.text) : [declaration.name];
|
|
11
|
+
case "constArray":
|
|
12
|
+
return [];
|
|
13
|
+
default:
|
|
14
|
+
return [declaration.name];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function typeNamesDeclaredBy(declarations) {
|
|
18
|
+
return new Set(declarations.flatMap(typeNamesOf));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.typeNamesDeclaredBy = typeNamesDeclaredBy;
|
|
22
|
+
exports.typeNamesInText = typeNamesInText;
|
|
23
|
+
//# sourceMappingURL=declared-type-names.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declared-type-names.cjs","sources":["../../../../src/application/transform/document/declared-type-names.ts"],"sourcesContent":["import type { IrDeclaration } from \"../../../domain/ir/nodes.js\";\n\n/**\n * The type names that declarations of the output take. Two declarations of one type name do not\n * compile (TS2300, TS2567), or merge into one type without an error (two enums, two interfaces).\n */\n\n/**\n * A declaration at the start of a line of raw text: the helper types, the `--read-write-markers`\n * types, `inject` text and footer nodes from user code. A `const` lives in the value namespace.\n */\nconst RAW_TYPE_DECLARATION_RE =\n /^(?:export\\s+)?(?:declare\\s+)?(?:type|interface|enum|const\\s+enum|class)\\s+([A-Za-z_$][\\w$]*)/gm;\n\n/** The type names that raw declaration text declares. */\nexport function typeNamesInText(text: string): string[] {\n return [...text.matchAll(RAW_TYPE_DECLARATION_RE)].map((match) => match[1] ?? \"\");\n}\n\nfunction typeNamesOf(declaration: IrDeclaration): readonly string[] {\n switch (declaration.kind) {\n case \"rawDeclaration\":\n return declaration.name === undefined\n ? typeNamesInText(declaration.text)\n : [declaration.name];\n case \"constArray\":\n return [];\n default:\n return [declaration.name];\n }\n}\n\n/** Every type name the declarations take; `--enum-values` arrays are values, so they take none. */\nexport function typeNamesDeclaredBy(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(declarations.flatMap(typeNamesOf));\n}\n"],"names":[],"mappings":";;AAWA,MAAM,uBAAA,GACJ,iGAAA;AAGK,SAAS,gBAAgB,IAAA,EAAwB;AACtD,EAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAA,CAAS,uBAAuB,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,KAAA,KAAU,KAAA,CAAM,CAAC,KAAK,EAAE,CAAA;AAClF;AAEA,SAAS,YAAY,WAAA,EAA+C;AAClE,EAAA,QAAQ,YAAY,IAAA;AAAM,IACxB,KAAK,gBAAA;AACH,MAAA,OAAO,WAAA,CAAY,SAAS,MAAA,GACxB,eAAA,CAAgB,YAAY,IAAI,CAAA,GAChC,CAAC,WAAA,CAAY,IAAI,CAAA;AAAA,IACvB,KAAK,YAAA;AACH,MAAA,OAAO,EAAC;AAAA,IACV;AACE,MAAA,OAAO,CAAC,YAAY,IAAI,CAAA;AAAA;AAE9B;AAGO,SAAS,oBAAoB,YAAA,EAAqD;AACvF,EAAA,OAAO,IAAI,GAAA,CAAI,YAAA,CAAa,OAAA,CAAQ,WAAW,CAAC,CAAA;AAClD;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const RAW_TYPE_DECLARATION_RE = /^(?:export\s+)?(?:declare\s+)?(?:type|interface|enum|const\s+enum|class)\s+([A-Za-z_$][\w$]*)/gm;
|
|
2
|
+
function typeNamesInText(text) {
|
|
3
|
+
return [...text.matchAll(RAW_TYPE_DECLARATION_RE)].map((match) => match[1] ?? "");
|
|
4
|
+
}
|
|
5
|
+
function typeNamesOf(declaration) {
|
|
6
|
+
switch (declaration.kind) {
|
|
7
|
+
case "rawDeclaration":
|
|
8
|
+
return declaration.name === void 0 ? typeNamesInText(declaration.text) : [declaration.name];
|
|
9
|
+
case "constArray":
|
|
10
|
+
return [];
|
|
11
|
+
default:
|
|
12
|
+
return [declaration.name];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function typeNamesDeclaredBy(declarations) {
|
|
16
|
+
return new Set(declarations.flatMap(typeNamesOf));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { typeNamesDeclaredBy, typeNamesInText };
|
|
20
|
+
//# sourceMappingURL=declared-type-names.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declared-type-names.mjs","sources":["../../../../src/application/transform/document/declared-type-names.ts"],"sourcesContent":["import type { IrDeclaration } from \"../../../domain/ir/nodes.js\";\n\n/**\n * The type names that declarations of the output take. Two declarations of one type name do not\n * compile (TS2300, TS2567), or merge into one type without an error (two enums, two interfaces).\n */\n\n/**\n * A declaration at the start of a line of raw text: the helper types, the `--read-write-markers`\n * types, `inject` text and footer nodes from user code. A `const` lives in the value namespace.\n */\nconst RAW_TYPE_DECLARATION_RE =\n /^(?:export\\s+)?(?:declare\\s+)?(?:type|interface|enum|const\\s+enum|class)\\s+([A-Za-z_$][\\w$]*)/gm;\n\n/** The type names that raw declaration text declares. */\nexport function typeNamesInText(text: string): string[] {\n return [...text.matchAll(RAW_TYPE_DECLARATION_RE)].map((match) => match[1] ?? \"\");\n}\n\nfunction typeNamesOf(declaration: IrDeclaration): readonly string[] {\n switch (declaration.kind) {\n case \"rawDeclaration\":\n return declaration.name === undefined\n ? typeNamesInText(declaration.text)\n : [declaration.name];\n case \"constArray\":\n return [];\n default:\n return [declaration.name];\n }\n}\n\n/** Every type name the declarations take; `--enum-values` arrays are values, so they take none. */\nexport function typeNamesDeclaredBy(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(declarations.flatMap(typeNamesOf));\n}\n"],"names":[],"mappings":"AAWA,MAAM,uBAAA,GACJ,iGAAA;AAGK,SAAS,gBAAgB,IAAA,EAAwB;AACtD,EAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAA,CAAS,uBAAuB,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,KAAA,KAAU,KAAA,CAAM,CAAC,KAAK,EAAE,CAAA;AAClF;AAEA,SAAS,YAAY,WAAA,EAA+C;AAClE,EAAA,QAAQ,YAAY,IAAA;AAAM,IACxB,KAAK,gBAAA;AACH,MAAA,OAAO,WAAA,CAAY,SAAS,MAAA,GACxB,eAAA,CAAgB,YAAY,IAAI,CAAA,GAChC,CAAC,WAAA,CAAY,IAAI,CAAA;AAAA,IACvB,KAAK,YAAA;AACH,MAAA,OAAO,EAAC;AAAA,IACV;AACE,MAAA,OAAO,CAAC,YAAY,IAAI,CAAA;AAAA;AAE9B;AAGO,SAAS,oBAAoB,YAAA,EAAqD;AACvF,EAAA,OAAO,IAAI,GAAA,CAAI,YAAA,CAAa,OAAA,CAAQ,WAAW,CAAC,CAAA;AAClD;;"}
|
|
@@ -7,7 +7,7 @@ const schemaTransform = require('../schema/schema-transform.cjs');
|
|
|
7
7
|
|
|
8
8
|
function defsRootType(defs, context) {
|
|
9
9
|
const members = Object.entries(defs).map(([name, schema]) => {
|
|
10
|
-
const location = { path: jsonPointer.
|
|
10
|
+
const location = { path: jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, ["$defs", name]), schema };
|
|
11
11
|
const type = schemaTransform.transformSchema(schema, location, context);
|
|
12
12
|
return constructors.irProperty(propertyName.toPropertyName(name), type, { isReadonly: context.options.immutable });
|
|
13
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs-root.cjs","sources":["../../../../src/application/transform/document/defs-root.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrObjectType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"defs-root.cjs","sources":["../../../../src/application/transform/document/defs-root.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrObjectType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { Schema } from \"../../../domain/openapi/schema-object.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport type { TransformContext } from \"../transform-context.js\";\n\n/**\n * The root `$defs` type: one required member per named subschema, so `#/$defs/<name>` refs\n * (`$defs[\"<name>\"]`) resolve. The original transformed the whole `$defs` map as one schema,\n * which gave `Record<string, never>` and made every such ref `never` (research/legacy-bugs.md,\n * item 18).\n */\nexport function defsRootType(\n defs: Readonly<Record<string, Schema>>,\n context: TransformContext,\n): IrObjectType {\n const members = Object.entries(defs).map(([name, schema]) => {\n const location = { path: appendPointer(ROOT_POINTER, [\"$defs\", name]), schema };\n const type = transformSchema(schema, location, context);\n return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });\n });\n return irObject(members);\n}\n"],"names":["appendPointer","ROOT_POINTER","transformSchema","irProperty","toPropertyName","irObject"],"mappings":";;;;;;;AAcO,SAAS,YAAA,CACd,MACA,OAAA,EACc;AACd,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,IAAA,EAAM,MAAM,CAAA,KAAM;AAC3D,IAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAMA,yBAAA,CAAcC,wBAAA,EAAc,CAAC,OAAA,EAAS,IAAI,CAAC,CAAA,EAAG,MAAA,EAAO;AAC9E,IAAA,MAAM,IAAA,GAAOC,+BAAA,CAAgB,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAA;AACtD,IAAA,OAAOC,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACzF,CAAC,CAAA;AACD,EAAA,OAAOC,sBAAS,OAAO,CAAA;AACzB;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { irProperty, irObject } from '../../../domain/ir/constructors.mjs';
|
|
2
2
|
import { toPropertyName } from '../../../domain/ir/property-name.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { appendPointer, ROOT_POINTER } from '../../../domain/openapi/json-pointer.mjs';
|
|
4
4
|
import { transformSchema } from '../schema/schema-transform.mjs';
|
|
5
5
|
|
|
6
6
|
function defsRootType(defs, context) {
|
|
7
7
|
const members = Object.entries(defs).map(([name, schema]) => {
|
|
8
|
-
const location = { path:
|
|
8
|
+
const location = { path: appendPointer(ROOT_POINTER, ["$defs", name]), schema };
|
|
9
9
|
const type = transformSchema(schema, location, context);
|
|
10
10
|
return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs-root.mjs","sources":["../../../../src/application/transform/document/defs-root.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrObjectType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"defs-root.mjs","sources":["../../../../src/application/transform/document/defs-root.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrObjectType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { Schema } from \"../../../domain/openapi/schema-object.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport type { TransformContext } from \"../transform-context.js\";\n\n/**\n * The root `$defs` type: one required member per named subschema, so `#/$defs/<name>` refs\n * (`$defs[\"<name>\"]`) resolve. The original transformed the whole `$defs` map as one schema,\n * which gave `Record<string, never>` and made every such ref `never` (research/legacy-bugs.md,\n * item 18).\n */\nexport function defsRootType(\n defs: Readonly<Record<string, Schema>>,\n context: TransformContext,\n): IrObjectType {\n const members = Object.entries(defs).map(([name, schema]) => {\n const location = { path: appendPointer(ROOT_POINTER, [\"$defs\", name]), schema };\n const type = transformSchema(schema, location, context);\n return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });\n });\n return irObject(members);\n}\n"],"names":[],"mappings":";;;;;AAcO,SAAS,YAAA,CACd,MACA,OAAA,EACc;AACd,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,IAAA,EAAM,MAAM,CAAA,KAAM;AAC3D,IAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAM,aAAA,CAAc,YAAA,EAAc,CAAC,OAAA,EAAS,IAAI,CAAC,CAAA,EAAG,MAAA,EAAO;AAC9E,IAAA,MAAM,IAAA,GAAO,eAAA,CAAgB,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAA;AACtD,IAAA,OAAO,UAAA,CAAW,cAAA,CAAe,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACzF,CAAC,CAAA;AACD,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const appendAll = require('../../../domain/append-all.cjs');
|
|
3
4
|
const constructors = require('../../../domain/ir/constructors.cjs');
|
|
4
5
|
const helperTypes = require('../helper-types.cjs');
|
|
5
6
|
const components = require('./components.cjs');
|
|
@@ -90,7 +91,7 @@ function documentBody(document, context, footer = NO_FOOTER) {
|
|
|
90
91
|
if (inject !== "") {
|
|
91
92
|
declarations.push({ kind: "rawDeclaration", text: inject });
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
appendAll.appendAll(declarations, rootsDeclarations(document, context, footer));
|
|
94
95
|
return declarations;
|
|
95
96
|
}
|
|
96
97
|
function documentClosing(document, context, hasOperations) {
|
|
@@ -104,6 +105,8 @@ function documentClosing(document, context, hasOperations) {
|
|
|
104
105
|
return declarations;
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
exports.OPERATIONS_NAME = OPERATIONS_NAME;
|
|
109
|
+
exports.ROOT_KEYS = ROOT_KEYS;
|
|
107
110
|
exports.documentBody = documentBody;
|
|
108
111
|
exports.documentClosing = documentClosing;
|
|
109
112
|
//# sourceMappingURL=document.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.cjs","sources":["../../../../src/application/transform/document/document.ts"],"sourcesContent":["import { irKeyword, irObject, irRecord } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrIntersectionType,\n IrObjectType,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport type { ComponentsObject } from \"../../../domain/openapi/components-object.js\";\nimport type { DocumentObject } from \"../../../domain/openapi/document-object.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { READ_WRITE_MARKER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext, TransformOptions } from \"../transform-context.js\";\nimport { componentsType } from \"./components.js\";\nimport { type DeclaredTypeLookup, declaredTypeLookup } from \"./declared-types.js\";\nimport { defsRootType } from \"./defs-root.js\";\nimport { keptDeprecatedComponents } from \"./kept-deprecated.js\";\nimport { pathMembers, pathsObjectType } from \"./paths.js\";\nimport { apiPathsEnumDeclaration } from \"./paths-enum.js\";\nimport { webhooksType } from \"./webhooks.js\";\n\n/** The root types, in output order. */\nconst ROOT_KEYS = Object.freeze([\"paths\", \"webhooks\", \"components\", \"$defs\"] as const);\ntype RootKey = (typeof ROOT_KEYS)[number];\n\nconst OPERATIONS_NAME = \"operations\";\n/** The type of a root without members: `Record<string, never>`. */\nconst EMPTY_ROOT_TYPE = irRecord(irKeyword(\"string\"), irKeyword(\"never\"));\n\n/** A root's type and the declarations that follow it (the `--root-types` aliases). */\ninterface RootResult {\n readonly type: IrType;\n readonly aliases: readonly IrTypeAliasDeclaration[];\n /**\n * The root's final type, for a root that reads the types the whole file declares (`paths`, whose\n * overlap check follows references). `type` then only tells whether the root has members.\n */\n readonly withDeclaredTypes?: (lookup: DeclaredTypeLookup) => IrType;\n}\n\ntype RootTransform = (\n node: object,\n context: TransformContext,\n document: DocumentObject,\n) => RootResult;\n\n/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */\nfunction keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {\n return context.options.excludeDeprecated\n ? keptDeprecatedComponents(document, context.refs)\n : new Set();\n}\n\nconst ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {\n paths: (node, context) => {\n const members = pathMembers(node as PathsObject, context);\n return {\n type: irObject(members.map(({ member }) => member)),\n aliases: [],\n withDeclaredTypes: (lookup) => pathsObjectType(members, lookup),\n };\n },\n webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),\n components: (node, context, document) => {\n const kept = keptDeprecated(document, context);\n const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);\n return { type, aliases: rootTypes };\n },\n $defs: (node, context) => ({\n type: defsRootType(node as NonNullable<DocumentObject[\"$defs\"]>, context),\n aliases: [],\n }),\n};\n\nfunction emptyAlias(name: string): IrTypeAliasDeclaration {\n return { kind: \"typeAlias\", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };\n}\n\n/** A root type that declares something: an object with members, or an intersection of them. */\ntype RootBodyType = IrObjectType | IrIntersectionType;\n\nfunction isRootBody(type: IrType): type is RootBodyType {\n return (type.kind === \"object\" && type.members.length > 0) || type.kind === \"intersection\";\n}\n\n/**\n * A root with members: an interface, or a type alias with `--export-type`. An intersection (the\n * `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.\n */\nfunction rootDeclaration(\n name: RootKey,\n type: RootBodyType,\n options: TransformOptions,\n): IrDeclaration {\n return options.exportType || type.kind === \"intersection\"\n ? { kind: \"typeAlias\", name, isExported: true, type, comments: [] }\n : { kind: \"interface\", name, isExported: true, members: type.members, comments: [] };\n}\n\n/**\n * The declarations of one root: its type, then its aliases. `finish` gives the root's declaration\n * again from the types the whole file declares, for a root with `withDeclaredTypes`.\n */\ninterface RootDeclarations {\n readonly declarations: readonly IrDeclaration[];\n readonly finish?: (lookup: DeclaredTypeLookup) => IrDeclaration;\n}\n\n/**\n * The declarations of one root. A root that is missing, or whose type has no members, is\n * `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having\n * members: a callback type the IR keeps as raw text does not (ADR-004).\n */\nfunction rootDeclarations(\n root: RootKey,\n document: DocumentObject,\n context: TransformContext,\n): RootDeclarations {\n const node: unknown = document[root];\n if (!node || typeof node !== \"object\") {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root)] };\n }\n const startedAt = context.diagnostics.now();\n const { type, aliases, withDeclaredTypes } = ROOT_TRANSFORMS[root](node, context, document);\n if (!isRootBody(type)) {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root), ...aliases] };\n }\n const declaration = rootDeclaration(root, type, context.options);\n context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);\n const finish =\n withDeclaredTypes &&\n ((lookup: DeclaredTypeLookup) => {\n const finished = withDeclaredTypes(lookup);\n return isRootBody(finished) ? rootDeclaration(root, finished, context.options) : declaration;\n });\n return { declarations: [declaration, ...aliases], ...(finish ? { finish } : {}) };\n}\n\n/**\n * Every root's declarations in output order. A root with `finish` gets its declaration from the\n * types of the other roots and of the footer (the `operations` interface), which exist only once\n * every root is transformed.\n */\nfunction rootsDeclarations(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[],\n): IrDeclaration[] {\n const roots = ROOT_KEYS.map((root) => rootDeclarations(root, document, context));\n const transformed = roots.flatMap(({ declarations }) => declarations);\n if (roots.every(({ finish }) => finish === undefined)) {\n return transformed;\n }\n const lookup = declaredTypeLookup([...transformed, ...footer()]);\n return roots.flatMap(({ declarations, finish }) => {\n const [declaration, ...aliases] = declarations;\n return finish === undefined || declaration === undefined\n ? declarations\n : [finish(lookup), ...aliases];\n });\n}\n\n/**\n * The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The\n * original reprinted it with the TypeScript printer; text without code printed nothing then.\n */\nfunction withoutBlankLinesAround(text: string): string {\n return text.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\n/** No footer declarations: the roots' references to `operations` stay unresolved. */\nconst NO_FOOTER = (): readonly IrDeclaration[] => [];\n\n/**\n * The document's declarations before the footer: helper types, injected code, then one root type\n * per root key with the aliases that follow it. `footer` reads the footer's declarations once the\n * roots are transformed.\n */\nexport function documentBody(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[] = NO_FOOTER,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (context.options.readWriteMarkers) {\n declarations.push({ kind: \"rawDeclaration\", text: READ_WRITE_MARKER_TYPES });\n }\n const inject = withoutBlankLinesAround(context.options.inject ?? \"\");\n if (inject !== \"\") {\n declarations.push({ kind: \"rawDeclaration\", text: inject });\n }\n declarations.push(...rootsDeclarations(document, context, footer));\n return declarations;\n}\n\n/**\n * The declarations after the footer: an empty `operations` type when the footer has no\n * operations, and the `--make-paths-enum` enum.\n */\nexport function documentClosing(\n document: DocumentObject,\n context: TransformContext,\n hasOperations: boolean,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (!hasOperations) {\n declarations.push(emptyAlias(OPERATIONS_NAME));\n }\n if (context.options.makePathsEnum && document.paths) {\n declarations.push(apiPathsEnumDeclaration(document.paths));\n }\n return declarations;\n}\n"],"names":["irRecord","irKeyword","keptDeprecatedComponents","pathMembers","irObject","pathsObjectType","webhooksType","componentsType","defsRootType","declaredTypeLookup","READ_WRITE_MARKER_TYPES","apiPathsEnumDeclaration"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,SAAA,GAAY,OAAO,MAAA,CAAO,CAAC,SAAS,UAAA,EAAY,YAAA,EAAc,OAAO,CAAU,CAAA;AAGrF,MAAM,eAAA,GAAkB,YAAA;AAExB,MAAM,kBAAkBA,qBAAA,CAASC,sBAAA,CAAU,QAAQ,CAAA,EAAGA,sBAAA,CAAU,OAAO,CAAC,CAAA;AAoBxE,SAAS,cAAA,CAAe,UAA0B,OAAA,EAAgD;AAChG,EAAA,OAAO,OAAA,CAAQ,QAAQ,iBAAA,GACnBC,yCAAA,CAAyB,UAAU,OAAA,CAAQ,IAAI,CAAA,mBAC/C,IAAI,GAAA,EAAI;AACd;AAEA,MAAM,eAAA,GAA4D;AAAA,EAChE,KAAA,EAAO,CAAC,IAAA,EAAM,OAAA,KAAY;AACxB,IAAA,MAAM,OAAA,GAAUC,iBAAA,CAAY,IAAA,EAAqB,OAAO,CAAA;AACxD,IAAA,OAAO;AAAA,MACL,IAAA,EAAMC,sBAAS,OAAA,CAAQ,GAAA,CAAI,CAAC,EAAE,MAAA,EAAO,KAAM,MAAM,CAA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,mBAAA,EAAqB,EAAE,EAAE,OAAA,EAAQ;AACvD;AAGA,MAAM,SAAA,GAAY,MAAgC,EAAC;AAO5C,SAAS,YAAA,CACd,QAAA,EACA,OAAA,EACA,MAAA,GAAyC,SAAA,EACxB;AACjB,EAAA,MAAM,eAAgC,EAAC;AACvC,EAAA,IAAI,OAAA,CAAQ,QAAQ,gBAAA,EAAkB;AACpC,IAAA,YAAA,CAAa,KAAK,EAAE,IAAA,EAAM,gBAAA,EAAkB,IAAA,EAAMC,qCAAyB,CAAA;AAAA,EAC7E;AACA,EAAA,MAAM,MAAA,GAAS,uBAAA,CAAwB,OAAA,CAAQ,OAAA,CAAQ,UAAU,EAAE,CAAA;AACnE,EAAA,IAAI,WAAW,EAAA,EAAI;AACjB,IAAA,YAAA,CAAa,KAAK,EAAE,IAAA,EAAM,gBAAA,EAAkB,IAAA,EAAM,QAAQ,CAAA;AAAA,EAC5D;AACA,EAAA,YAAA,CAAa,KAAK,GAAG,iBAAA,CAAkB,QAAA,EAAU,OAAA,EAAS,MAAM,CAAC,CAAA;AACjE,EAAA,OAAO,YAAA;AACT;AAMO,SAAS,eAAA,CACd,QAAA,EACA,OAAA,EACA,aAAA,EACiB;AACjB,EAAA,MAAM,eAAgC,EAAC;AACvC,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,YAAA,CAAa,IAAA,CAAK,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,aAAA,IAAiB,QAAA,CAAS,KAAA,EAAO;AACnD,IAAA,YAAA,CAAa,IAAA,CAAKC,iCAAA,CAAwB,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,YAAA;AACT;;;"}
|
|
1
|
+
{"version":3,"file":"document.cjs","sources":["../../../../src/application/transform/document/document.ts"],"sourcesContent":["import { appendAll } from \"../../../domain/append-all.js\";\nimport { irKeyword, irObject, irRecord } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrIntersectionType,\n IrObjectType,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport type { ComponentsObject } from \"../../../domain/openapi/components-object.js\";\nimport type { DocumentObject } from \"../../../domain/openapi/document-object.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { READ_WRITE_MARKER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext, TransformOptions } from \"../transform-context.js\";\nimport { componentsType } from \"./components.js\";\nimport { type DeclaredTypeLookup, declaredTypeLookup } from \"./declared-types.js\";\nimport { defsRootType } from \"./defs-root.js\";\nimport { keptDeprecatedComponents } from \"./kept-deprecated.js\";\nimport { pathMembers, pathsObjectType } from \"./paths.js\";\nimport { apiPathsEnumDeclaration } from \"./paths-enum.js\";\nimport { webhooksType } from \"./webhooks.js\";\n\n/** The root types, in output order. */\nexport const ROOT_KEYS = Object.freeze([\"paths\", \"webhooks\", \"components\", \"$defs\"] as const);\ntype RootKey = (typeof ROOT_KEYS)[number];\n\nexport const OPERATIONS_NAME = \"operations\";\n/** The type of a root without members: `Record<string, never>`. */\nconst EMPTY_ROOT_TYPE = irRecord(irKeyword(\"string\"), irKeyword(\"never\"));\n\n/** A root's type and the declarations that follow it (the `--root-types` aliases). */\ninterface RootResult {\n readonly type: IrType;\n readonly aliases: readonly IrTypeAliasDeclaration[];\n /**\n * The root's final type, for a root that reads the types the whole file declares (`paths`, whose\n * overlap check follows references). `type` then only tells whether the root has members.\n */\n readonly withDeclaredTypes?: (lookup: DeclaredTypeLookup) => IrType;\n}\n\ntype RootTransform = (\n node: object,\n context: TransformContext,\n document: DocumentObject,\n) => RootResult;\n\n/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */\nfunction keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {\n return context.options.excludeDeprecated\n ? keptDeprecatedComponents(document, context.refs)\n : new Set();\n}\n\nconst ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {\n paths: (node, context) => {\n const members = pathMembers(node as PathsObject, context);\n return {\n type: irObject(members.map(({ member }) => member)),\n aliases: [],\n withDeclaredTypes: (lookup) => pathsObjectType(members, lookup),\n };\n },\n webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),\n components: (node, context, document) => {\n const kept = keptDeprecated(document, context);\n const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);\n return { type, aliases: rootTypes };\n },\n $defs: (node, context) => ({\n type: defsRootType(node as NonNullable<DocumentObject[\"$defs\"]>, context),\n aliases: [],\n }),\n};\n\nfunction emptyAlias(name: string): IrTypeAliasDeclaration {\n return { kind: \"typeAlias\", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };\n}\n\n/** A root type that declares something: an object with members, or an intersection of them. */\ntype RootBodyType = IrObjectType | IrIntersectionType;\n\nfunction isRootBody(type: IrType): type is RootBodyType {\n return (type.kind === \"object\" && type.members.length > 0) || type.kind === \"intersection\";\n}\n\n/**\n * A root with members: an interface, or a type alias with `--export-type`. An intersection (the\n * `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.\n */\nfunction rootDeclaration(\n name: RootKey,\n type: RootBodyType,\n options: TransformOptions,\n): IrDeclaration {\n return options.exportType || type.kind === \"intersection\"\n ? { kind: \"typeAlias\", name, isExported: true, type, comments: [] }\n : { kind: \"interface\", name, isExported: true, members: type.members, comments: [] };\n}\n\n/**\n * The declarations of one root: its type, then its aliases. `finish` gives the root's declaration\n * again from the types the whole file declares, for a root with `withDeclaredTypes`.\n */\ninterface RootDeclarations {\n readonly declarations: readonly IrDeclaration[];\n readonly finish?: (lookup: DeclaredTypeLookup) => IrDeclaration;\n}\n\n/**\n * The declarations of one root. A root that is missing, or whose type has no members, is\n * `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having\n * members: a callback type the IR keeps as raw text does not (ADR-004).\n */\nfunction rootDeclarations(\n root: RootKey,\n document: DocumentObject,\n context: TransformContext,\n): RootDeclarations {\n const node: unknown = document[root];\n if (!node || typeof node !== \"object\") {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root)] };\n }\n const startedAt = context.diagnostics.now();\n const { type, aliases, withDeclaredTypes } = ROOT_TRANSFORMS[root](node, context, document);\n if (!isRootBody(type)) {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root), ...aliases] };\n }\n const declaration = rootDeclaration(root, type, context.options);\n context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);\n const finish =\n withDeclaredTypes &&\n ((lookup: DeclaredTypeLookup) => {\n const finished = withDeclaredTypes(lookup);\n return isRootBody(finished) ? rootDeclaration(root, finished, context.options) : declaration;\n });\n return { declarations: [declaration, ...aliases], ...(finish ? { finish } : {}) };\n}\n\n/**\n * Every root's declarations in output order. A root with `finish` gets its declaration from the\n * types of the other roots and of the footer (the `operations` interface), which exist only once\n * every root is transformed.\n */\nfunction rootsDeclarations(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[],\n): IrDeclaration[] {\n const roots = ROOT_KEYS.map((root) => rootDeclarations(root, document, context));\n const transformed = roots.flatMap(({ declarations }) => declarations);\n if (roots.every(({ finish }) => finish === undefined)) {\n return transformed;\n }\n const lookup = declaredTypeLookup([...transformed, ...footer()]);\n return roots.flatMap(({ declarations, finish }) => {\n const [declaration, ...aliases] = declarations;\n return finish === undefined || declaration === undefined\n ? declarations\n : [finish(lookup), ...aliases];\n });\n}\n\n/**\n * The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The\n * original reprinted it with the TypeScript printer; text without code printed nothing then.\n */\nfunction withoutBlankLinesAround(text: string): string {\n return text.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\n/** No footer declarations: the roots' references to `operations` stay unresolved. */\nconst NO_FOOTER = (): readonly IrDeclaration[] => [];\n\n/**\n * The document's declarations before the footer: helper types, injected code, then one root type\n * per root key with the aliases that follow it. `footer` reads the footer's declarations once the\n * roots are transformed.\n */\nexport function documentBody(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[] = NO_FOOTER,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (context.options.readWriteMarkers) {\n declarations.push({ kind: \"rawDeclaration\", text: READ_WRITE_MARKER_TYPES });\n }\n const inject = withoutBlankLinesAround(context.options.inject ?? \"\");\n if (inject !== \"\") {\n declarations.push({ kind: \"rawDeclaration\", text: inject });\n }\n appendAll(declarations, rootsDeclarations(document, context, footer));\n return declarations;\n}\n\n/**\n * The declarations after the footer: an empty `operations` type when the footer has no\n * operations, and the `--make-paths-enum` enum.\n */\nexport function documentClosing(\n document: DocumentObject,\n context: TransformContext,\n hasOperations: boolean,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (!hasOperations) {\n declarations.push(emptyAlias(OPERATIONS_NAME));\n }\n if (context.options.makePathsEnum && document.paths) {\n declarations.push(apiPathsEnumDeclaration(document.paths));\n }\n return declarations;\n}\n"],"names":["irRecord","irKeyword","keptDeprecatedComponents","pathMembers","irObject","pathsObjectType","webhooksType","componentsType","defsRootType","declaredTypeLookup","READ_WRITE_MARKER_TYPES","appendAll","apiPathsEnumDeclaration"],"mappings":";;;;;;;;;;;;;AAuBO,MAAM,SAAA,GAAY,OAAO,MAAA,CAAO,CAAC,SAAS,UAAA,EAAY,YAAA,EAAc,OAAO,CAAU;AAGrF,MAAM,eAAA,GAAkB;AAE/B,MAAM,kBAAkBA,qBAAA,CAASC,sBAAA,CAAU,QAAQ,CAAA,EAAGA,sBAAA,CAAU,OAAO,CAAC,CAAA;AAoBxE,SAAS,cAAA,CAAe,UAA0B,OAAA,EAAgD;AAChG,EAAA,OAAO,OAAA,CAAQ,QAAQ,iBAAA,GACnBC,yCAAA,CAAyB,UAAU,OAAA,CAAQ,IAAI,CAAA,mBAC/C,IAAI,GAAA,EAAI;AACd;AAEA,MAAM,eAAA,GAA4D;AAAA,E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AA,CAAKC,iCAAA,CAAwB,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,YAAA;AACT;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appendAll } from '../../../domain/append-all.mjs';
|
|
1
2
|
import { irRecord, irObject, irKeyword } from '../../../domain/ir/constructors.mjs';
|
|
2
3
|
import { READ_WRITE_MARKER_TYPES } from '../helper-types.mjs';
|
|
3
4
|
import { componentsType } from './components.mjs';
|
|
@@ -88,7 +89,7 @@ function documentBody(document, context, footer = NO_FOOTER) {
|
|
|
88
89
|
if (inject !== "") {
|
|
89
90
|
declarations.push({ kind: "rawDeclaration", text: inject });
|
|
90
91
|
}
|
|
91
|
-
declarations
|
|
92
|
+
appendAll(declarations, rootsDeclarations(document, context, footer));
|
|
92
93
|
return declarations;
|
|
93
94
|
}
|
|
94
95
|
function documentClosing(document, context, hasOperations) {
|
|
@@ -102,5 +103,5 @@ function documentClosing(document, context, hasOperations) {
|
|
|
102
103
|
return declarations;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
export { documentBody, documentClosing };
|
|
106
|
+
export { OPERATIONS_NAME, ROOT_KEYS, documentBody, documentClosing };
|
|
106
107
|
//# sourceMappingURL=document.mjs.map
|