openapi-typesafe 1.0.0-rc.3 → 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-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 +14 -2
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +14 -2
- package/dist/api/default-ports.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 +5 -1
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +5 -1
- package/dist/api/discriminator-patch.mjs.map +1 -1
- package/dist/api/discriminator-scan.cjs +15 -8
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +15 -8
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-run.cjs +2 -2
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +2 -2
- package/dist/api/document-run.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 +8 -4
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +8 -5
- 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/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 +40 -10
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +41 -11
- 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 +1 -1
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +2 -2
- 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 +6 -29
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +6 -29
- 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 +5 -1
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +6 -2
- 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-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/composition-type.cjs +1 -1
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +2 -2
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +1 -1
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +2 -2
- 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/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/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-comment.cjs +5 -1
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +5 -1
- 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/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 +14 -0
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +14 -0
- 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/index.d.cts +22 -4
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/package.json +4 -5
- 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 +33 -4
- package/src/api/discriminator-enum-parent.ts +3 -3
- package/src/api/discriminator-other-owners.ts +5 -3
- package/src/api/discriminator-patch.ts +5 -1
- package/src/api/discriminator-scan.ts +16 -8
- package/src/api/document-run.ts +4 -3
- package/src/api/legacy-utils.ts +5 -1
- package/src/api/openapi-ts.ts +20 -5
- package/src/api/run-context.ts +3 -0
- package/src/api/schema-callbacks.ts +60 -17
- package/src/api/transform-context.ts +7 -3
- package/src/api/transform-schema.ts +64 -12
- 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 +2 -2
- 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 +11 -56
- 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 +6 -2
- 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-type.ts +2 -1
- package/src/application/transform/schema/composition-type.ts +2 -2
- package/src/application/transform/schema/enum-rule.ts +6 -2
- package/src/application/transform/schema/object-type.ts +4 -4
- package/src/application/transform/schema/ref-siblings.ts +76 -0
- 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-comment.ts +5 -1
- 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/errors.ts +14 -5
- 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 +21 -2
- package/src/domain/url-secrets.ts +72 -0
- 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":"terminal-logger.cjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"terminal-logger.cjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport { redactUrlSecrets } from \"../../domain/url-secrets.js\";\n\n/**\n * The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `\n * errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No\n * line shows the user info of a URL.\n */\n\n/** Where the lines go: `console` in production, a recording sink in tests. */\nexport interface TerminalSink {\n debug(line: string): void;\n warn(line: string): void;\n error(line: string): void;\n}\n\nexport interface TerminalLoggerOptions {\n /**\n * Drop warnings and error lines; debug lines, which `DEBUG` asks for, are still written. The\n * error lines are the problems of a document that fails to load, which the thrown error lists.\n */\n readonly silent: boolean;\n /** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */\n readonly debugFilter: string | undefined;\n readonly useColors: boolean;\n readonly sink: TerminalSink;\n}\n\ntype Colors = ReturnType<typeof colors.create>;\n\nconst MILLISECONDS_PER_SECOND = 1000;\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** A duration as the original prints it: one decimal, in ms, s or m. */\nexport function formatDuration(milliseconds: number): string {\n if (milliseconds < MILLISECONDS_PER_SECOND) {\n return `${Math.round(10 * milliseconds) / 10}ms`;\n }\n if (milliseconds < MILLISECONDS_PER_MINUTE) {\n return `${Math.round(milliseconds / 100) / 10}s`;\n }\n return `${Math.round(milliseconds / 6000) / 10}m`;\n}\n\nfunction groupColor(palette: Colors, group: DebugGroup | undefined): (text: string) => string {\n const byGroup: Readonly<Partial<Record<DebugGroup, (text: string) => string>>> = {\n redoc: palette.cyanBright,\n lint: palette.yellowBright,\n bundle: palette.magentaBright,\n ts: palette.blueBright,\n };\n return (group && byGroup[group]) || palette.whiteBright;\n}\n\n/** Whether `DEBUG` asks for this group (the original check, case-insensitive for the group). */\nexport function isDebugEnabled(filter: string | undefined, group: DebugGroup | undefined): boolean {\n if (!filter) {\n return false;\n }\n return (\n !group ||\n filter === \"*\" ||\n filter === \"openapi-ts:*\" ||\n filter.toLocaleLowerCase() === `openapi-ts:${group.toLocaleLowerCase()}`\n );\n}\n\nclass TerminalLogger implements Logger {\n readonly #options: TerminalLoggerOptions;\n readonly #palette: Colors;\n\n constructor(options: TerminalLoggerOptions) {\n this.#options = options;\n this.#palette = colors.create();\n this.#palette.enabled = options.useColors;\n }\n\n debug(message: string, group?: DebugGroup, durationMs?: number): void {\n if (!isDebugEnabled(this.#options.debugFilter, group)) {\n return;\n }\n const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? \"info\"}`);\n // The original wrote no space without a duration (`openapi-ts:lintIgnored …`).\n const time =\n durationMs === undefined ? \" \" : this.#palette.green(` ${formatDuration(durationMs)} `);\n const text = redactUrlSecrets(message);\n this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);\n }\n\n warn(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.warn(this.#palette.yellow(` ⚠ ${redactUrlSecrets(message)}`));\n }\n }\n\n error(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.error(this.#palette.red(` ✘ ${redactUrlSecrets(message)}`));\n }\n }\n}\n\n/** A Logger that writes to a terminal sink. */\nexport function createTerminalLogger(options: TerminalLoggerOptions): Logger {\n return new TerminalLogger(options);\n}\n"],"names":["colors","redactUrlSecrets"],"mappings":";;;;;;;;;AA+BA,MAAM,uBAAA,GAA0B,GAAA;AAChC,MAAM,uBAAA,GAA0B,GAAA;AAGzB,SAAS,eAAe,YAAA,EAA8B;AAC3D,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,EAAA,GAAK,YAAY,IAAI,EAAE,CAAA,EAAA,CAAA;AAAA,EAC9C;AACA,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAG,IAAI,EAAE,CAAA,CAAA,CAAA;AAAA,EAC/C;AACA,EAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAI,IAAI,EAAE,CAAA,CAAA,CAAA;AAChD;AAEA,SAAS,UAAA,CAAW,SAAiB,KAAA,EAAyD;AAC5F,EAAA,MAAM,OAAA,GAA2E;AAAA,IAC/E,OAAO,OAAA,CAAQ,UAAA;AAAA,IACf,MAAM,OAAA,CAAQ,YAAA;AAAA,IACd,QAAQ,OAAA,CAAQ,aAAA;AAAA,IAChB,IAAI,OAAA,CAAQ;AAAA,GACd;AACA,EAAA,OAAQ,KAAA,IAAS,OAAA,CAAQ,KAAK,CAAA,IAAM,OAAA,CAAQ,WAAA;AAC9C;AAGO,SAAS,cAAA,CAAe,QAA4B,KAAA,EAAwC;AACjG,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OACE,CAAC,KAAA,IACD,MAAA,KAAW,GAAA,IACX,MAAA,KAAW,cAAA,IACX,MAAA,CAAO,iBAAA,EAAkB,KAAM,CAAA,WAAA,EAAc,KAAA,CAAM,iBAAA,EAAmB,CAAA,CAAA;AAE1E;AA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,CAAC,CAAA;AAAA,IAClF;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,EAAuB;AAC3B,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,MAAA,EAAQ;AACzB,MAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAA,SAAA,EAAOA,2BAAA,CAAiB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IAChF;AAAA,EACF;AACF;AAGO,SAAS,qBAAqB,OAAA,EAAwC;AAC3E,EAAA,OAAO,IAAI,eAAe,OAAO,CAAA;AACnC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import colors from 'ansi-colors';
|
|
2
|
-
import {
|
|
2
|
+
import { redactUrlSecrets } from '../../domain/url-secrets.mjs';
|
|
3
3
|
|
|
4
4
|
const MILLISECONDS_PER_SECOND = 1e3;
|
|
5
5
|
const MILLISECONDS_PER_MINUTE = 6e4;
|
|
@@ -41,16 +41,18 @@ class TerminalLogger {
|
|
|
41
41
|
}
|
|
42
42
|
const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? "info"}`);
|
|
43
43
|
const time = durationMs === void 0 ? " " : this.#palette.green(` ${formatDuration(durationMs)} `);
|
|
44
|
-
const text =
|
|
44
|
+
const text = redactUrlSecrets(message);
|
|
45
45
|
this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);
|
|
46
46
|
}
|
|
47
47
|
warn(message) {
|
|
48
48
|
if (!this.#options.silent) {
|
|
49
|
-
this.#options.sink.warn(this.#palette.yellow(` \u26A0 ${
|
|
49
|
+
this.#options.sink.warn(this.#palette.yellow(` \u26A0 ${redactUrlSecrets(message)}`));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
error(message) {
|
|
53
|
-
this.#options.
|
|
53
|
+
if (!this.#options.silent) {
|
|
54
|
+
this.#options.sink.error(this.#palette.red(` \u2718 ${redactUrlSecrets(message)}`));
|
|
55
|
+
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
function createTerminalLogger(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-logger.mjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"terminal-logger.mjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport { redactUrlSecrets } from \"../../domain/url-secrets.js\";\n\n/**\n * The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `\n * errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No\n * line shows the user info of a URL.\n */\n\n/** Where the lines go: `console` in production, a recording sink in tests. */\nexport interface TerminalSink {\n debug(line: string): void;\n warn(line: string): void;\n error(line: string): void;\n}\n\nexport interface TerminalLoggerOptions {\n /**\n * Drop warnings and error lines; debug lines, which `DEBUG` asks for, are still written. The\n * error lines are the problems of a document that fails to load, which the thrown error lists.\n */\n readonly silent: boolean;\n /** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */\n readonly debugFilter: string | undefined;\n readonly useColors: boolean;\n readonly sink: TerminalSink;\n}\n\ntype Colors = ReturnType<typeof colors.create>;\n\nconst MILLISECONDS_PER_SECOND = 1000;\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** A duration as the original prints it: one decimal, in ms, s or m. */\nexport function formatDuration(milliseconds: number): string {\n if (milliseconds < MILLISECONDS_PER_SECOND) {\n return `${Math.round(10 * milliseconds) / 10}ms`;\n }\n if (milliseconds < MILLISECONDS_PER_MINUTE) {\n return `${Math.round(milliseconds / 100) / 10}s`;\n }\n return `${Math.round(milliseconds / 6000) / 10}m`;\n}\n\nfunction groupColor(palette: Colors, group: DebugGroup | undefined): (text: string) => string {\n const byGroup: Readonly<Partial<Record<DebugGroup, (text: string) => string>>> = {\n redoc: palette.cyanBright,\n lint: palette.yellowBright,\n bundle: palette.magentaBright,\n ts: palette.blueBright,\n };\n return (group && byGroup[group]) || palette.whiteBright;\n}\n\n/** Whether `DEBUG` asks for this group (the original check, case-insensitive for the group). */\nexport function isDebugEnabled(filter: string | undefined, group: DebugGroup | undefined): boolean {\n if (!filter) {\n return false;\n }\n return (\n !group ||\n filter === \"*\" ||\n filter === \"openapi-ts:*\" ||\n filter.toLocaleLowerCase() === `openapi-ts:${group.toLocaleLowerCase()}`\n );\n}\n\nclass TerminalLogger implements Logger {\n readonly #options: TerminalLoggerOptions;\n readonly #palette: Colors;\n\n constructor(options: TerminalLoggerOptions) {\n this.#options = options;\n this.#palette = colors.create();\n this.#palette.enabled = options.useColors;\n }\n\n debug(message: string, group?: DebugGroup, durationMs?: number): void {\n if (!isDebugEnabled(this.#options.debugFilter, group)) {\n return;\n }\n const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? \"info\"}`);\n // The original wrote no space without a duration (`openapi-ts:lintIgnored …`).\n const time =\n durationMs === undefined ? \" \" : this.#palette.green(` ${formatDuration(durationMs)} `);\n const text = redactUrlSecrets(message);\n this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);\n }\n\n warn(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.warn(this.#palette.yellow(` ⚠ ${redactUrlSecrets(message)}`));\n }\n }\n\n error(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.error(this.#palette.red(` ✘ ${redactUrlSecrets(message)}`));\n }\n }\n}\n\n/** A Logger that writes to a terminal sink. */\nexport function createTerminalLogger(options: TerminalLoggerOptions): Logger {\n return new TerminalLogger(options);\n}\n"],"names":[],"mappings":";;;AA+BA,MAAM,uBAAA,GAA0B,GAAA;AAChC,MAAM,uBAAA,GAA0B,GAAA;AAGzB,SAAS,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,CAAS,GAAA,CAAI,CAAA,SAAA,EAAO,gBAAA,CAAiB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IAChF;AAAA,EACF;AACF;AAGO,SAAS,qBAAqB,OAAA,EAAwC;AAC3E,EAAA,OAAO,IAAI,eAAe,OAAO,CAAA;AACnC;;"}
|
|
@@ -14,21 +14,33 @@ function terminalSupportsColor() {
|
|
|
14
14
|
const stdout = supportsColor__default.stdout;
|
|
15
15
|
return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;
|
|
16
16
|
}
|
|
17
|
+
const STDERR_SINK = {
|
|
18
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
19
|
+
debug: (line) => console.error(line),
|
|
20
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
21
|
+
warn: (line) => console.warn(line),
|
|
22
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
23
|
+
error: (line) => console.error(line)
|
|
24
|
+
};
|
|
17
25
|
function defaultLogger(silent) {
|
|
18
26
|
return terminalLogger.createTerminalLogger({
|
|
19
27
|
silent,
|
|
20
28
|
debugFilter: process.env.DEBUG,
|
|
21
29
|
useColors: terminalSupportsColor(),
|
|
22
|
-
sink:
|
|
30
|
+
sink: STDERR_SINK
|
|
23
31
|
});
|
|
24
32
|
}
|
|
25
33
|
function defaultDeprecationReporter() {
|
|
26
34
|
return nodeDeprecations.createNodeDeprecationReporter();
|
|
27
35
|
}
|
|
28
36
|
const REMOTE_REF_TIMEOUT_MS = 6e4;
|
|
37
|
+
const MEBIBYTE = 1024 * 1024;
|
|
29
38
|
const DEFAULT_REMOTE_DOCUMENT_LIMITS = {
|
|
30
39
|
maxDocuments: 1e4,
|
|
31
|
-
maxParallelFetches: 16
|
|
40
|
+
maxParallelFetches: 16,
|
|
41
|
+
maxDocumentBytes: 128 * MEBIBYTE,
|
|
42
|
+
maxTotalBytes: 256 * MEBIBYTE,
|
|
43
|
+
maxNodes: 8e6
|
|
32
44
|
};
|
|
33
45
|
function processCwd() {
|
|
34
46
|
return process.cwd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-ports.cjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport { createNodeDeprecationReporter } from \"../adapters/node-deprecations/node-deprecations.js\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"default-ports.cjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport { createNodeDeprecationReporter } from \"../adapters/node-deprecations/node-deprecations.js\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport {\n createTerminalLogger,\n type TerminalSink,\n} from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DeprecationReporter } from \"../application/ports/deprecation-reporter.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\n\n/**\n * The default adapters of the Node API (ENGINEERING_PLAN 4.5): this module and the CLI's\n * composition root are where the process environment is read.\n */\n\n/** Colors when the terminal supports them, as the original decided. */\nexport function terminalSupportsColor(): boolean {\n const stdout = supportsColor.stdout;\n return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;\n}\n\n/**\n * Every line of the logger goes to stderr: the CLI writes the types to stdout, and `console.debug`\n * writes there too, so debug lines would end up inside the generated file.\n */\nconst STDERR_SINK: TerminalSink = {\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n debug: (line) => console.error(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n warn: (line) => console.warn(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n error: (line) => console.error(line),\n};\n\n/** The terminal logger with `DEBUG` from the environment, writing to stderr. */\nexport function defaultLogger(silent: boolean): Logger {\n return createTerminalLogger({\n silent,\n debugFilter: process.env.DEBUG,\n useColors: terminalSupportsColor(),\n sink: STDERR_SINK,\n });\n}\n\n/** Deprecations as Node.js `DeprecationWarning`s, each code once per process. */\nexport function defaultDeprecationReporter(): DeprecationReporter {\n return createNodeDeprecationReporter();\n}\n\n/**\n * How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB\n * Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would\n * wait five minutes for a server that never answers (ENGINEERING_PLAN 8.5).\n */\nexport const REMOTE_REF_TIMEOUT_MS = 60_000;\n\nconst MEBIBYTE = 1024 * 1024;\n\n/**\n * Bounds on the remote documents of one schema (ADR-033). Large split documents have a few thousand\n * files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a\n * multi-file document fast without exhausting local ports.\n *\n * The size limits count decoded bytes and parsed nodes (threat model T2, ADR-033 decision 6).\n * The largest document of the 1,820-entry compatibility corpus is Microsoft Graph beta: 71 MiB,\n * 2.65 million nodes (keys and values), 1.6 GB peak memory when loaded from a URL. A remote body\n * took about 7 bytes of memory per byte of text and 110 per node in our measurements, so 128 MiB\n * per document (1.8 times Graph beta), 256 MiB per schema (a split document may be twice as\n * large) and 8 million nodes per schema (3 times Graph beta) let crafted documents finish within\n * a heap of 2 GB; with the default heap of 4 GB they peak at about 1.2 to 2.3 GB.\n */\nexport const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {\n maxDocuments: 10_000,\n maxParallelFetches: 16,\n maxDocumentBytes: 128 * MEBIBYTE,\n maxTotalBytes: 256 * MEBIBYTE,\n maxNodes: 8_000_000,\n};\n\n/** The working directory of the process: the default `cwd` of an inline source. */\nexport function processCwd(): string {\n return process.cwd();\n}\n\n/** A monotonic clock in milliseconds, for debug durations. */\nexport function monotonicNow(): number {\n return performance.now();\n}\n\n/** The default Redocly config: minimal rules, and duplicate operation IDs are an error. */\nexport function defaultRedoclyConfig(): Promise<RedoclyConfig> {\n const rules = { \"operation-operationId-unique\": { severity: \"error\" as const } };\n return createConfig({ rules }, { extends: [\"minimal\"] });\n}\n"],"names":["supportsColor","createTerminalLogger","createNodeDeprecationReporter","performance","createConfig"],"mappings":";;;;;;;;;;;;AAkBO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,SAASA,sBAAA,CAAc,MAAA;AAC7B,EAAA,OAAO,QAAQ,MAAM,CAAA,IAAK,MAAA,KAAW,KAAA,IAAS,OAAO,QAAA,KAAa,KAAA;AACpE;AAMA,MAAM,WAAA,GAA4B;AAAA;AAAA,EAEhC,KAAA,EAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,MAAM,IAAI,CAAA;AAAA;AAAA,EAEnC,IAAA,EAAM,CAAC,IAAA,KAAS,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA;AAAA,EAEjC,KAAA,EAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,MAAM,IAAI;AACrC,CAAA;AAGO,SAAS,cAAc,MAAA,EAAyB;AACrD,EAAA,OAAOC,mCAAA,CAAqB;AAAA,IAC1B,MAAA;AAAA,IACA,WAAA,EAAa,QAAQ,GAAA,CAAI,KAAA;AAAA,IACzB,WAAW,qBAAA,EAAsB;AAAA,IACjC,IAAA,EAAM;AAAA,GACP,CAAA;AACH;AAGO,SAAS,0BAAA,GAAkD;AAChE,EAAA,OAAOC,8CAAA,EAA8B;AACvC;AAOO,MAAM,qBAAA,GAAwB;AAErC,MAAM,WAAW,IAAA,GAAO,IAAA;AAejB,MAAM,8BAAA,GAAuD;AAAA,EAClE,YAAA,EAAc,GAAA;AAAA,EACd,kBAAA,EAAoB,EAAA;AAAA,EACpB,kBAAkB,GAAA,GAAM,QAAA;AAAA,EACxB,eAAe,GAAA,GAAM,QAAA;AAAA,EACrB,QAAA,EAAU;AACZ;AAGO,SAAS,UAAA,GAAqB;AACnC,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB;AAGO,SAAS,YAAA,GAAuB;AACrC,EAAA,OAAOC,4BAAY,GAAA,EAAI;AACzB;AAGO,SAAS,oBAAA,GAA+C;AAC7D,EAAA,MAAM,QAAQ,EAAE,8BAAA,EAAgC,EAAE,QAAA,EAAU,SAAiB,EAAE;AAC/E,EAAA,OAAOC,wBAAA,CAAa,EAAE,KAAA,EAAM,EAAG,EAAE,OAAA,EAAS,CAAC,SAAS,CAAA,EAAG,CAAA;AACzD;;;;;;;;;"}
|
|
@@ -8,21 +8,33 @@ function terminalSupportsColor() {
|
|
|
8
8
|
const stdout = supportsColor.stdout;
|
|
9
9
|
return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;
|
|
10
10
|
}
|
|
11
|
+
const STDERR_SINK = {
|
|
12
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
13
|
+
debug: (line) => console.error(line),
|
|
14
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
15
|
+
warn: (line) => console.warn(line),
|
|
16
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
17
|
+
error: (line) => console.error(line)
|
|
18
|
+
};
|
|
11
19
|
function defaultLogger(silent) {
|
|
12
20
|
return createTerminalLogger({
|
|
13
21
|
silent,
|
|
14
22
|
debugFilter: process.env.DEBUG,
|
|
15
23
|
useColors: terminalSupportsColor(),
|
|
16
|
-
sink:
|
|
24
|
+
sink: STDERR_SINK
|
|
17
25
|
});
|
|
18
26
|
}
|
|
19
27
|
function defaultDeprecationReporter() {
|
|
20
28
|
return createNodeDeprecationReporter();
|
|
21
29
|
}
|
|
22
30
|
const REMOTE_REF_TIMEOUT_MS = 6e4;
|
|
31
|
+
const MEBIBYTE = 1024 * 1024;
|
|
23
32
|
const DEFAULT_REMOTE_DOCUMENT_LIMITS = {
|
|
24
33
|
maxDocuments: 1e4,
|
|
25
|
-
maxParallelFetches: 16
|
|
34
|
+
maxParallelFetches: 16,
|
|
35
|
+
maxDocumentBytes: 128 * MEBIBYTE,
|
|
36
|
+
maxTotalBytes: 256 * MEBIBYTE,
|
|
37
|
+
maxNodes: 8e6
|
|
26
38
|
};
|
|
27
39
|
function processCwd() {
|
|
28
40
|
return process.cwd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-ports.mjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport { createNodeDeprecationReporter } from \"../adapters/node-deprecations/node-deprecations.js\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"default-ports.mjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport { createNodeDeprecationReporter } from \"../adapters/node-deprecations/node-deprecations.js\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport {\n createTerminalLogger,\n type TerminalSink,\n} from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DeprecationReporter } from \"../application/ports/deprecation-reporter.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\n\n/**\n * The default adapters of the Node API (ENGINEERING_PLAN 4.5): this module and the CLI's\n * composition root are where the process environment is read.\n */\n\n/** Colors when the terminal supports them, as the original decided. */\nexport function terminalSupportsColor(): boolean {\n const stdout = supportsColor.stdout;\n return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;\n}\n\n/**\n * Every line of the logger goes to stderr: the CLI writes the types to stdout, and `console.debug`\n * writes there too, so debug lines would end up inside the generated file.\n */\nconst STDERR_SINK: TerminalSink = {\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n debug: (line) => console.error(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n warn: (line) => console.warn(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n error: (line) => console.error(line),\n};\n\n/** The terminal logger with `DEBUG` from the environment, writing to stderr. */\nexport function defaultLogger(silent: boolean): Logger {\n return createTerminalLogger({\n silent,\n debugFilter: process.env.DEBUG,\n useColors: terminalSupportsColor(),\n sink: STDERR_SINK,\n });\n}\n\n/** Deprecations as Node.js `DeprecationWarning`s, each code once per process. */\nexport function defaultDeprecationReporter(): DeprecationReporter {\n return createNodeDeprecationReporter();\n}\n\n/**\n * How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB\n * Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would\n * wait five minutes for a server that never answers (ENGINEERING_PLAN 8.5).\n */\nexport const REMOTE_REF_TIMEOUT_MS = 60_000;\n\nconst MEBIBYTE = 1024 * 1024;\n\n/**\n * Bounds on the remote documents of one schema (ADR-033). Large split documents have a few thousand\n * files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a\n * multi-file document fast without exhausting local ports.\n *\n * The size limits count decoded bytes and parsed nodes (threat model T2, ADR-033 decision 6).\n * The largest document of the 1,820-entry compatibility corpus is Microsoft Graph beta: 71 MiB,\n * 2.65 million nodes (keys and values), 1.6 GB peak memory when loaded from a URL. A remote body\n * took about 7 bytes of memory per byte of text and 110 per node in our measurements, so 128 MiB\n * per document (1.8 times Graph beta), 256 MiB per schema (a split document may be twice as\n * large) and 8 million nodes per schema (3 times Graph beta) let crafted documents finish within\n * a heap of 2 GB; with the default heap of 4 GB they peak at about 1.2 to 2.3 GB.\n */\nexport const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {\n maxDocuments: 10_000,\n maxParallelFetches: 16,\n maxDocumentBytes: 128 * MEBIBYTE,\n maxTotalBytes: 256 * MEBIBYTE,\n maxNodes: 8_000_000,\n};\n\n/** The working directory of the process: the default `cwd` of an inline source. */\nexport function processCwd(): string {\n return process.cwd();\n}\n\n/** A monotonic clock in milliseconds, for debug durations. */\nexport function monotonicNow(): number {\n return performance.now();\n}\n\n/** The default Redocly config: minimal rules, and duplicate operation IDs are an error. */\nexport function defaultRedoclyConfig(): Promise<RedoclyConfig> {\n const rules = { \"operation-operationId-unique\": { severity: \"error\" as const } };\n return createConfig({ rules }, { extends: [\"minimal\"] });\n}\n"],"names":[],"mappings":";;;;;;AAkBO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,SAAS,aAAA,CAAc,MAAA;AAC7B,EAAA,OAAO,QAAQ,MAAM,CAAA,IAAK,MAAA,KAAW,KAAA,IAAS,OAAO,QAAA,KAAa,KAAA;AACpE;AAMA,MAAM,WAAA,GAA4B;AAAA;AAAA,EAEhC,KAAA,EAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,MAAM,IAAI,CAAA;AAAA;AAAA,EAEnC,IAAA,EAAM,CAAC,IAAA,KAAS,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA;AAAA,EAEjC,KAAA,EAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,MAAM,IAAI;AACrC,CAAA;AAGO,SAAS,cAAc,MAAA,EAAyB;AACrD,EAAA,OAAO,oBAAA,CAAqB;AAAA,IAC1B,MAAA;AAAA,IACA,WAAA,EAAa,QAAQ,GAAA,CAAI,KAAA;AAAA,IACzB,WAAW,qBAAA,EAAsB;AAAA,IACjC,IAAA,EAAM;AAAA,GACP,CAAA;AACH;AAGO,SAAS,0BAAA,GAAkD;AAChE,EAAA,OAAO,6BAAA,EAA8B;AACvC;AAOO,MAAM,qBAAA,GAAwB;AAErC,MAAM,WAAW,IAAA,GAAO,IAAA;AAejB,MAAM,8BAAA,GAAuD;AAAA,EAClE,YAAA,EAAc,GAAA;AAAA,EACd,kBAAA,EAAoB,EAAA;AAAA,EACpB,kBAAkB,GAAA,GAAM,QAAA;AAAA,EACxB,eAAe,GAAA,GAAM,QAAA;AAAA,EACrB,QAAA,EAAU;AACZ;AAGO,SAAS,UAAA,GAAqB;AACnC,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB;AAGO,SAAS,YAAA,GAAuB;AACrC,EAAA,OAAO,YAAY,GAAA,EAAI;AACzB;AAGO,SAAS,oBAAA,GAA+C;AAC7D,EAAA,MAAM,QAAQ,EAAE,8BAAA,EAAgC,EAAE,QAAA,EAAU,SAAiB,EAAE;AAC/E,EAAA,OAAO,YAAA,CAAa,EAAE,KAAA,EAAM,EAAG,EAAE,OAAA,EAAS,CAAC,SAAS,CAAA,EAAG,CAAA;AACzD;;"}
|
|
@@ -7,14 +7,14 @@ const ROOT_SEGMENTS = 3;
|
|
|
7
7
|
function typedAt(ref) {
|
|
8
8
|
const segments = jsonPointer.parseRefPointer(ref);
|
|
9
9
|
const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);
|
|
10
|
-
return jsonPointer.
|
|
10
|
+
return jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);
|
|
11
11
|
}
|
|
12
12
|
function isSchemaObject(value) {
|
|
13
13
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
14
|
}
|
|
15
15
|
function ownProperty(item, ref, name) {
|
|
16
16
|
const property = ("properties" in item ? item.properties : void 0)?.[name];
|
|
17
|
-
return property === void 0 ? void 0 : { property, path: jsonPointer.
|
|
17
|
+
return property === void 0 ? void 0 : { property, path: jsonPointer.appendPointer(ref, [name]) };
|
|
18
18
|
}
|
|
19
19
|
function declaredProperty(ref, name, resolve, visited) {
|
|
20
20
|
const schema = resolve(ref);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator-enum-parent.cjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"discriminator-enum-parent.cjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import { appendPointer, parseRefPointer, ROOT_POINTER } from \"../domain/openapi/json-pointer.js\";\nimport type { SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\n\n/**\n * The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member\n * (`petType: \"Cat\"`) is declared as an enum of its own (`CatPetType`), which is not assignable to\n * the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be\n * typed with its members (`PetType.Cat`).\n */\n\n/** The parent's enum schema and the location it is typed at, which gives the enum its name. */\nexport interface EnumParent {\n readonly schema: SchemaObject;\n readonly path: string;\n}\n\ntype ResolveSchemaRef = (ref: string) => unknown;\n\n/** A declared property schema and the location the transformer types it at. */\ninterface DeclaredProperty {\n readonly property: unknown;\n readonly path: string;\n}\n\nconst PROPERTIES_KEYWORD = \"properties\";\n/** `components`, `schemas` and the schema name: the segments before the schema's own keywords. */\nconst ROOT_SEGMENTS = 3;\n\n/** The location a `$ref` is typed at: object properties are nested without `properties`. */\nfunction typedAt(ref: string): string {\n const segments = parseRefPointer(ref);\n const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);\n return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);\n}\n\nfunction isSchemaObject(value: unknown): value is SchemaObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The property `name` of a schema object typed at `ref`. */\nfunction ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {\n const property = (\"properties\" in item ? item.properties : undefined)?.[name];\n return property === undefined ? undefined : { property, path: appendPointer(ref, [name]) };\n}\n\n/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */\nfunction declaredProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n visited: Set<string>,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n if (visited.has(ref) || !isSchemaObject(schema)) {\n return undefined;\n }\n visited.add(ref);\n // An inline `allOf` item is typed at its parent's location, so both share the path.\n for (const item of [schema, ...(schema.allOf ?? [])]) {\n if (!isSchemaObject(item)) {\n continue;\n }\n const found =\n \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : ownProperty(item, ref, name);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * A discriminator and the `$ref` of the schema that declares its property; `ref` is the member\n * whose value the discriminator gives, where there is one.\n */\nexport type DiscriminatorOwner = Pick<EnumPatch, \"discriminator\" | \"discriminatorRef\"> &\n Partial<Pick<EnumPatch, \"ref\">>;\n\n/**\n * The property `name` that the member at `ref` inherits through its `allOf` `$ref`s. Its own\n * keywords and inline items are left out: the scan writes the added value there.\n */\nfunction inheritedProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n const visited = new Set([ref]);\n for (const item of isSchemaObject(schema) ? (schema.allOf ?? []) : []) {\n const found =\n isSchemaObject(item) && \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : undefined;\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * The enum of the property that the discriminator owner declares, if it is one. An owner that\n * declares no such property (a `oneOf` with a mapping) leaves the member's type to the property\n * the member inherits, so that property's enum is the one.\n */\nexport function enumParentOf(\n patch: DiscriminatorOwner,\n resolve: ResolveSchemaRef,\n): EnumParent | undefined {\n const name = patch.discriminator.propertyName;\n const declared =\n declaredProperty(patch.discriminatorRef, name, resolve, new Set()) ??\n (patch.ref === undefined ? undefined : inheritedProperty(patch.ref, name, resolve));\n if (declared === undefined || !isSchemaObject(declared.property)) {\n return undefined;\n }\n const ref = (declared.property as { readonly $ref?: unknown }).$ref;\n const parent =\n typeof ref === \"string\"\n ? { schema: resolve(ref), path: typedAt(ref) }\n : { schema: declared.property, path: declared.path };\n return isSchemaObject(parent.schema) && Array.isArray(parent.schema.enum)\n ? { schema: parent.schema, path: parent.path }\n : undefined;\n}\n"],"names":["parseRefPointer","appendPointer","ROOT_POINTER"],"mappings":";;;;AAyBA,MA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;AACnF,EAAA,IAAI,aAAa,MAAA,IAAa,CAAC,cAAA,CAAe,QAAA,CAAS,QAAQ,CAAA,EAAG;AAChE,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAO,SAAS,QAAA,CAAyC,IAAA;AAC/D,EAAA,MAAM,MAAA,GACJ,OAAO,GAAA,KAAQ,QAAA,GACX,EAAE,MAAA,EAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG,IAAA,EAAM,QAAQ,GAAG,CAAA,KACzC,EAAE,MAAA,EAAQ,SAAS,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AACvD,EAAA,OAAO,eAAe,MAAA,CAAO,MAAM,CAAA,IAAK,KAAA,CAAM,QAAQ,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,GACpE,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,IAAA,EAAM,MAAA,CAAO,MAAK,GAC3C,MAAA;AACN;;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { parseRefPointer,
|
|
1
|
+
import { parseRefPointer, appendPointer, ROOT_POINTER } from '../domain/openapi/json-pointer.mjs';
|
|
2
2
|
|
|
3
3
|
const PROPERTIES_KEYWORD = "properties";
|
|
4
4
|
const ROOT_SEGMENTS = 3;
|
|
5
5
|
function typedAt(ref) {
|
|
6
6
|
const segments = parseRefPointer(ref);
|
|
7
7
|
const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);
|
|
8
|
-
return
|
|
8
|
+
return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);
|
|
9
9
|
}
|
|
10
10
|
function isSchemaObject(value) {
|
|
11
11
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
12
|
}
|
|
13
13
|
function ownProperty(item, ref, name) {
|
|
14
14
|
const property = ("properties" in item ? item.properties : void 0)?.[name];
|
|
15
|
-
return property === void 0 ? void 0 : { property, path:
|
|
15
|
+
return property === void 0 ? void 0 : { property, path: appendPointer(ref, [name]) };
|
|
16
16
|
}
|
|
17
17
|
function declaredProperty(ref, name, resolve, visited) {
|
|
18
18
|
const schema = resolve(ref);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator-enum-parent.mjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"discriminator-enum-parent.mjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import { appendPointer, parseRefPointer, ROOT_POINTER } from \"../domain/openapi/json-pointer.js\";\nimport type { SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\n\n/**\n * The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member\n * (`petType: \"Cat\"`) is declared as an enum of its own (`CatPetType`), which is not assignable to\n * the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be\n * typed with its members (`PetType.Cat`).\n */\n\n/** The parent's enum schema and the location it is typed at, which gives the enum its name. */\nexport interface EnumParent {\n readonly schema: SchemaObject;\n readonly path: string;\n}\n\ntype ResolveSchemaRef = (ref: string) => unknown;\n\n/** A declared property schema and the location the transformer types it at. */\ninterface DeclaredProperty {\n readonly property: unknown;\n readonly path: string;\n}\n\nconst PROPERTIES_KEYWORD = \"properties\";\n/** `components`, `schemas` and the schema name: the segments before the schema's own keywords. */\nconst ROOT_SEGMENTS = 3;\n\n/** The location a `$ref` is typed at: object properties are nested without `properties`. */\nfunction typedAt(ref: string): string {\n const segments = parseRefPointer(ref);\n const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);\n return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);\n}\n\nfunction isSchemaObject(value: unknown): value is SchemaObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The property `name` of a schema object typed at `ref`. */\nfunction ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {\n const property = (\"properties\" in item ? item.properties : undefined)?.[name];\n return property === undefined ? undefined : { property, path: appendPointer(ref, [name]) };\n}\n\n/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */\nfunction declaredProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n visited: Set<string>,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n if (visited.has(ref) || !isSchemaObject(schema)) {\n return undefined;\n }\n visited.add(ref);\n // An inline `allOf` item is typed at its parent's location, so both share the path.\n for (const item of [schema, ...(schema.allOf ?? [])]) {\n if (!isSchemaObject(item)) {\n continue;\n }\n const found =\n \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : ownProperty(item, ref, name);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * A discriminator and the `$ref` of the schema that declares its property; `ref` is the member\n * whose value the discriminator gives, where there is one.\n */\nexport type DiscriminatorOwner = Pick<EnumPatch, \"discriminator\" | \"discriminatorRef\"> &\n Partial<Pick<EnumPatch, \"ref\">>;\n\n/**\n * The property `name` that the member at `ref` inherits through its `allOf` `$ref`s. Its own\n * keywords and inline items are left out: the scan writes the added value there.\n */\nfunction inheritedProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n const visited = new Set([ref]);\n for (const item of isSchemaObject(schema) ? (schema.allOf ?? []) : []) {\n const found =\n isSchemaObject(item) && \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : undefined;\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * The enum of the property that the discriminator owner declares, if it is one. An owner that\n * declares no such property (a `oneOf` with a mapping) leaves the member's type to the property\n * the member inherits, so that property's enum is the one.\n */\nexport function enumParentOf(\n patch: DiscriminatorOwner,\n resolve: ResolveSchemaRef,\n): EnumParent | undefined {\n const name = patch.discriminator.propertyName;\n const declared =\n declaredProperty(patch.discriminatorRef, name, resolve, new Set()) ??\n (patch.ref === undefined ? undefined : inheritedProperty(patch.ref, name, resolve));\n if (declared === undefined || !isSchemaObject(declared.property)) {\n return undefined;\n }\n const ref = (declared.property as { readonly $ref?: unknown }).$ref;\n const parent =\n typeof ref === \"string\"\n ? { schema: resolve(ref), path: typedAt(ref) }\n : { schema: declared.property, path: declared.path };\n return isSchemaObject(parent.schema) && Array.isArray(parent.schema.enum)\n ? { schema: parent.schema, path: parent.path }\n : undefined;\n}\n"],"names":[],"mappings":";;AAyBA,MAAM,kBAAA,GAAqB,YAAA;AAE3B,MAAM,aAAA,GAAgB,CAAA;AAGtB,SAAS,QAAQ,GAAA,EAAqB;AACpC,EAAA,MAAM,QAAA,GAAW,gBAAgB,GAAG,CAAA;AACpC,EAAA,MAAM,MAAA,GAAS,SAAS,KAAA,CAAM,aAAa,EAAE,MAAA,CAAO,CAAC,OAAA,KAAY,OAAA,KAAY,kBAAkB,CAAA;AAC/F,EAAA,OAAO,aAAA,CAAc,YAAA,EAAc,CAAC,GAAG,QAAA,CAAS,KAAA,CAAM,CAAA,EAAG,aAAa,CAAA,EAAG,GAAG,MAAM,CAAC,CAAA;AACrF;AAEA,SAAS,eAAe,KAAA,EAAuC;AAC7D,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAGA,SAAS,WAAA,CAAY,IAAA,EAAoB,GAAA,EAAa,IAAA,EAA4C;AAChG,EAAA,MAAM,YAAY,YAAA,IAAgB,IAAA,GAAO,IAAA,CAAK,UAAA,GAAa,UAAa,IAAI,CAAA;AAC5E,EAAA,OAAO,QAAA,KAAa,MAAA,GAAY,MAAA,GAAY,EAAE,QAAA,EAAU,IAAA,EAAM,aAAA,CAAc,GAAA,EAAK,CAAC,IAAI,CAAC,CAAA,EAAE;AAC3F;AAGA,SAAS,gBAAA,CACP,GAAA,EACA,IAAA,EACA,OAAA,EACA,OA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AACA,EAAA,OAAO,MAAA;AACT;AAOO,SAAS,YAAA,CACd,OACA,OAAA,EACwB;AACxB,EAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc,YAAA;AACjC,EAAA,MAAM,WACJ,gBAAA,CAAiB,KAAA,CAAM,kBAAkB,IAAA,EAAM,OAAA,sBAAa,GAAA,EAAK,CAAA,KAChE,KAAA,CAAM,QAAQ,MAAA,GAAY,MAAA,GAAY,kBAAkB,KAAA,CAAM,GAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AACnF,EAAA,IAAI,aAAa,MAAA,IAAa,CAAC,cAAA,CAAe,QAAA,CAAS,QAAQ,CAAA,EAAG;AAChE,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAO,SAAS,QAAA,CAAyC,IAAA;AAC/D,EAAA,MAAM,MAAA,GACJ,OAAO,GAAA,KAAQ,QAAA,GACX,EAAE,MAAA,EAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG,IAAA,EAAM,QAAQ,GAAG,CAAA,KACzC,EAAE,MAAA,EAAQ,SAAS,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AACvD,EAAA,OAAO,eAAe,MAAA,CAAO,MAAM,CAAA,IAAK,KAAA,CAAM,QAAQ,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,GACpE,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,IAAA,EAAM,MAAA,CAAO,MAAK,GAC3C,MAAA;AACN;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const appendAll = require('../domain/append-all.cjs');
|
|
4
|
+
const jsonPointer = require('../domain/openapi/json-pointer.cjs');
|
|
3
5
|
const discriminatorPatch = require('./discriminator-patch.cjs');
|
|
4
6
|
const documentRefs = require('./document-refs.cjs');
|
|
5
7
|
|
|
@@ -8,7 +10,7 @@ function allOfRefs(state, ref) {
|
|
|
8
10
|
const schema = documentRefs.resolveDocumentRef(state.schema, ref, { silent, logger });
|
|
9
11
|
const items = schema?.allOf ?? [];
|
|
10
12
|
return items.flatMap(
|
|
11
|
-
(item) => "$ref" in item && typeof item.$ref === "string" ? [item.$ref] : []
|
|
13
|
+
(item) => "$ref" in item && typeof item.$ref === "string" ? [jsonPointer.canonicalRef(item.$ref)] : []
|
|
12
14
|
);
|
|
13
15
|
}
|
|
14
16
|
function otherOwners(state, parentRef) {
|
|
@@ -26,7 +28,7 @@ function otherOwners(state, parentRef) {
|
|
|
26
28
|
if (discriminator && name !== void 0 && name !== own && !found.has(name)) {
|
|
27
29
|
found.set(name, { discriminator, ownerRef: ref });
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
appendAll.appendAll(queue, allOfRefs(state, ref));
|
|
30
32
|
}
|
|
31
33
|
return [...found.values()];
|
|
32
34
|
}
|
|
@@ -44,7 +46,7 @@ function inheritOtherOwners(state, parentRef, ref) {
|
|
|
44
46
|
continue;
|
|
45
47
|
}
|
|
46
48
|
recordOtherProperty(state, ref, discriminator.propertyName);
|
|
47
|
-
const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => target === ref).map(([value]) => value);
|
|
49
|
+
const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => jsonPointer.canonicalRef(target) === ref).map(([value]) => value);
|
|
48
50
|
const name = ref.slice(ref.lastIndexOf("/") + 1);
|
|
49
51
|
const patch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };
|
|
50
52
|
if (mapped.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator-other-owners.cjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [item.$ref] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n queue
|
|
1
|
+
{"version":3,"file":"discriminator-other-owners.cjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import { appendAll } from \"../domain/append-all.js\";\nimport { canonicalRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [canonicalRef(item.$ref)] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n appendAll(queue, allOfRefs(state, ref));\n }\n return [...found.values()];\n}\n\n/**\n * The child redefines this property, so its `allOf` items omit it: a parent may have a value of\n * its own, as `Content` has when `Element`'s mapping names it.\n */\nfunction recordOtherProperty(state: ScanState, ref: string, propertyName: string): void {\n const names = state.otherProperties[ref] ?? [];\n if (!names.includes(propertyName)) {\n names.push(propertyName);\n }\n state.otherProperties[ref] = names;\n}\n\n/**\n * The child at `ref` of the schema at `parentRef` gets a value of each other property: a mapped\n * one at once, else its schema name after both passes, where no mapping gives one. The schema's\n * own discriminator property is still added, so these patches do not mark it handled.\n */\nexport function inheritOtherOwners(state: ScanState, parentRef: string, ref: string): void {\n const childProperty = state.objects[ref]?.propertyName;\n for (const { discriminator, ownerRef } of otherOwners(state, parentRef)) {\n if (discriminator.propertyName === childProperty) {\n continue;\n }\n recordOtherProperty(state, ref, discriminator.propertyName);\n const mapped = Object.entries(discriminator.mapping ?? {})\n .filter(([, target]) => canonicalRef(target) === ref)\n .map(([value]) => value);\n const name = ref.slice(ref.lastIndexOf(\"/\") + 1);\n const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };\n if (mapped.length > 0) {\n patchDiscriminatorEnum(state, patch);\n } else {\n state.otherInferredPatches.push({ ...patch, values: [name] });\n }\n }\n}\n\n/** The deferred schema-name values of other properties; see `inheritOtherOwners`. */\nexport function applyOtherInferredPatches(state: ScanState, mapped: ReadonlySet<string>): void {\n for (const patch of state.otherInferredPatches) {\n if (!mapped.has(enumKey(patch))) {\n patchDiscriminatorEnum(state, patch);\n }\n }\n}\n"],"names":["resolveDocumentRef","canonicalRef","appendAll","patchDiscriminatorEnum","enumKey"],"mappings":";;;;;;;AAqBA,SAAS,SAAA,CAAU,OAAkB,GAAA,EAAuB;AAC1D,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,KAAA;AAC3B,EAAA,MAAM,MAAA,GAASA,gCAAiC,KAAA,CAAM,MAAA,EAAQ,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AACrF,EAAA,MAAM,KAAA,GAAS,MAAA,EAAQ,KAAA,IAAS,EAAC;AACjC,EAAA,OAAO,KAAA,CAAM,OAAA;AAAA,IAAQ,CAAC,IAAA,KACpB,MAAA,IAAU,IAAA,IAAQ,OAAO,IAAA,CAAK,IAAA,KAAS,QAAA,GAAW,CAACC,wBAAA,CAAa,IAAA,CAAK,IAAI,CAAC,IAAI;AAAC,GACjF;AACF;AAMA,SAAS,WAAA,CAAY,OAAkB,SAAA,EAAiC;AACtE,EAAA,MAAM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AAA,IAAS,MAAM,oBAAA,EAAsB;AAC9C,IAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAIC,0BAAA,CAAQ,KAAK,CAAC,CAAA,EAAG;AAC/B,MAAAD,yCAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC;AAAA,EACF;AACF;;;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { appendAll } from '../domain/append-all.mjs';
|
|
2
|
+
import { canonicalRef } from '../domain/openapi/json-pointer.mjs';
|
|
1
3
|
import { enumKey, patchDiscriminatorEnum } from './discriminator-patch.mjs';
|
|
2
4
|
import { resolveDocumentRef } from './document-refs.mjs';
|
|
3
5
|
|
|
@@ -6,7 +8,7 @@ function allOfRefs(state, ref) {
|
|
|
6
8
|
const schema = resolveDocumentRef(state.schema, ref, { silent, logger });
|
|
7
9
|
const items = schema?.allOf ?? [];
|
|
8
10
|
return items.flatMap(
|
|
9
|
-
(item) => "$ref" in item && typeof item.$ref === "string" ? [item.$ref] : []
|
|
11
|
+
(item) => "$ref" in item && typeof item.$ref === "string" ? [canonicalRef(item.$ref)] : []
|
|
10
12
|
);
|
|
11
13
|
}
|
|
12
14
|
function otherOwners(state, parentRef) {
|
|
@@ -24,7 +26,7 @@ function otherOwners(state, parentRef) {
|
|
|
24
26
|
if (discriminator && name !== void 0 && name !== own && !found.has(name)) {
|
|
25
27
|
found.set(name, { discriminator, ownerRef: ref });
|
|
26
28
|
}
|
|
27
|
-
queue
|
|
29
|
+
appendAll(queue, allOfRefs(state, ref));
|
|
28
30
|
}
|
|
29
31
|
return [...found.values()];
|
|
30
32
|
}
|
|
@@ -42,7 +44,7 @@ function inheritOtherOwners(state, parentRef, ref) {
|
|
|
42
44
|
continue;
|
|
43
45
|
}
|
|
44
46
|
recordOtherProperty(state, ref, discriminator.propertyName);
|
|
45
|
-
const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => target === ref).map(([value]) => value);
|
|
47
|
+
const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => canonicalRef(target) === ref).map(([value]) => value);
|
|
46
48
|
const name = ref.slice(ref.lastIndexOf("/") + 1);
|
|
47
49
|
const patch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };
|
|
48
50
|
if (mapped.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator-other-owners.mjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [item.$ref] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n queue
|
|
1
|
+
{"version":3,"file":"discriminator-other-owners.mjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import { appendAll } from \"../domain/append-all.js\";\nimport { canonicalRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [canonicalRef(item.$ref)] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n appendAll(queue, allOfRefs(state, ref));\n }\n return [...found.values()];\n}\n\n/**\n * The child redefines this property, so its `allOf` items omit it: a parent may have a value of\n * its own, as `Content` has when `Element`'s mapping names it.\n */\nfunction recordOtherProperty(state: ScanState, ref: string, propertyName: string): void {\n const names = state.otherProperties[ref] ?? [];\n if (!names.includes(propertyName)) {\n names.push(propertyName);\n }\n state.otherProperties[ref] = names;\n}\n\n/**\n * The child at `ref` of the schema at `parentRef` gets a value of each other property: a mapped\n * one at once, else its schema name after both passes, where no mapping gives one. The schema's\n * own discriminator property is still added, so these patches do not mark it handled.\n */\nexport function inheritOtherOwners(state: ScanState, parentRef: string, ref: string): void {\n const childProperty = state.objects[ref]?.propertyName;\n for (const { discriminator, ownerRef } of otherOwners(state, parentRef)) {\n if (discriminator.propertyName === childProperty) {\n continue;\n }\n recordOtherProperty(state, ref, discriminator.propertyName);\n const mapped = Object.entries(discriminator.mapping ?? {})\n .filter(([, target]) => canonicalRef(target) === ref)\n .map(([value]) => value);\n const name = ref.slice(ref.lastIndexOf(\"/\") + 1);\n const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };\n if (mapped.length > 0) {\n patchDiscriminatorEnum(state, patch);\n } else {\n state.otherInferredPatches.push({ ...patch, values: [name] });\n }\n }\n}\n\n/** The deferred schema-name values of other properties; see `inheritOtherOwners`. */\nexport function applyOtherInferredPatches(state: ScanState, mapped: ReadonlySet<string>): void {\n for (const patch of state.otherInferredPatches) {\n if (!mapped.has(enumKey(patch))) {\n patchDiscriminatorEnum(state, patch);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAqBA,SAAS,SAAA,CAAU,OAAkB,GAAA,EAAuB;AAC1D,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,KAAA;AAC3B,EAAA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AAM,QAAmB,EAAE,GAAA,EAAK,QAAQ,MAAA,EAAQ,aAAA,EAAe,kBAAkB,QAAA,EAAS;AAC1F,IAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,MAAA,sBAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC,CAAA,MAAO;AACL,MAAA,KAAA,CAAM,oBAAA,CAAqB,KAAK,EAAE,GAAG,OAAO,MAAA,EAAQ,CAAC,IAAI,CAAA,EAAG,CAAA;AAAA,IAC9D;AAAA,EACF;AACF;AAGO,SAAS,yBAAA,CAA0B,OAAkB,MAAA,EAAmC;AAC7F,EAAA,KAAA,MAAW,KAAA,IAAS,MAAM,oBAAA,EAAsB;AAC9C,IAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,KAAK,CAAC,CAAA,EAAG;AAC/B,MAAA,sBAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC;AAAA,EACF;AACF;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const appendAll = require('../domain/append-all.cjs');
|
|
3
4
|
const outputFixes = require('../domain/output-fixes.cjs');
|
|
4
5
|
const warnings = require('../domain/warnings.cjs');
|
|
5
6
|
const discriminatorEnum = require('./discriminator-enum.cjs');
|
|
@@ -48,7 +49,10 @@ function mergeIntoPatchedEnum(state, key, values) {
|
|
|
48
49
|
return false;
|
|
49
50
|
}
|
|
50
51
|
const merged = patched.enum;
|
|
51
|
-
|
|
52
|
+
appendAll.appendAll(
|
|
53
|
+
merged,
|
|
54
|
+
values.filter((value) => !merged.includes(value))
|
|
55
|
+
);
|
|
52
56
|
return true;
|
|
53
57
|
}
|
|
54
58
|
function patchDiscriminatorEnum(state, patch) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator-patch.cjs","sources":["../../src/api/discriminator-patch.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport { FIX, type OutputFix } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport type { DiscriminatorObject, OpenAPI3, SchemaObject } from \"../types.js\";\nimport { addEnumProperty, declaresValues, type EnumPatch } from \"./discriminator-enum.js\";\nimport {\n type DiscriminatorOwner,\n type EnumParent,\n enumParentOf,\n} from \"./discriminator-enum-parent.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The state of the discriminator pre-pass and the in-place patch of a mapped schema: the enum\n * property that the generated union narrows by. Two discriminators of one property may patch one\n * schema; how they combine is the `discriminator-values` fix (ADR-021, roadmap R12).\n */\n\n/** How to scan: the warnings, and the output fixes of the run (ADR-021). */\nexport interface DiscriminatorScanOptions {\n readonly silent: boolean;\n readonly logger: Logger;\n readonly fixes: ReadonlySet<OutputFix>;\n}\n\n/** What the two passes share: the document they patch and what they found so far. */\nexport interface ScanState extends DiscriminatorScanOptions {\n readonly schema: OpenAPI3;\n readonly objects: Record<string, DiscriminatorObject>;\n /** The schemas that define a discriminator themselves (pass 1), not by inheritance. */\n readonly owners: Set<string>;\n readonly refsHandled: string[];\n /** With the fix: the enum added to each schema, by schema and property, so values merge. */\n readonly patchedEnums: Map<string, SchemaObject>;\n /** With the fix: schema-name values, applied after both passes where no mapping names one. */\n readonly inferredPatches: EnumPatch[];\n /** With the fix: schema-name values of other properties (`inheritOtherOwners`). */\n readonly otherInferredPatches: EnumPatch[];\n /** With the fix: the other properties each schema got a value of (`inheritOtherOwners`). */\n readonly otherProperties: Record<string, string[]>;\n /** With `discriminator-values`: the enum keys that a schema declares itself. */\n readonly declaredKeys: Set<string>;\n /** With `discriminator-values`: the owner's enum of each added enum, by that enum. */\n readonly enumParents: Map<object, EnumParent>;\n}\n\n/** Whether `discriminator-values` is on: values of two discriminators merge into one enum. */\nexport function mergesValues(state: ScanState): boolean {\n return state.fixes.has(FIX.DISCRIMINATOR_VALUES);\n}\n\nfunction patchedSchema(state: ScanState, patch: EnumPatch): SchemaObject | undefined {\n const { silent, logger } = state;\n return resolveDocumentRef<SchemaObject>(state.schema, patch.ref, { silent, logger });\n}\n\n/**\n * With `discriminator-values`: the schema at `patch.ref` requires the property with\n * exactly these values already, so a patch would only repeat it (#2124).\n */\nfunction isDeclared(state: ScanState, patch: EnumPatch): boolean {\n return (\n state.fixes.has(FIX.DISCRIMINATOR_VALUES) && declaresValues(patchedSchema(state, patch), patch)\n );\n}\n\n/**\n * With `discriminator-values`: the enum of the owner's property, for `key`: an enum the scan\n * added, or a discriminator object that a schema inherited.\n */\nexport function recordEnumParent(state: ScanState, owner: DiscriminatorOwner, key: object): void {\n if (!state.fixes.has(FIX.DISCRIMINATOR_VALUES)) {\n return;\n }\n const { silent, logger } = state;\n const parent = enumParentOf(owner, (ref) =>\n resolveDocumentRef(state.schema, ref, { silent, logger }),\n );\n if (parent !== undefined) {\n state.enumParents.set(key, parent);\n }\n}\n\n/** The enum the schema at `patch.ref` gets, or null (with a warning) for another kind of schema. */\nfunction addDiscriminatorEnum(state: ScanState, patch: EnumPatch): SchemaObject | null {\n const added = addEnumProperty(patchedSchema(state, patch), patch);\n if (added === null) {\n warnInvalidMapping(patch, state.logger);\n } else {\n recordEnumParent(state, patch, added);\n }\n return added;\n}\n\n/** One schema and discriminator property; two discriminators of one property share an enum. */\nexport function enumKey(patch: EnumPatch): string {\n return `${patch.ref}\\n${patch.discriminator.propertyName}`;\n}\n\n/** With the fix, a second discriminator of the same property adds its values to the first enum. */\nfunction mergeIntoPatchedEnum(state: ScanState, key: string, values: readonly string[]): boolean {\n const patched = state.patchedEnums.get(key);\n if (patched === undefined) {\n return false;\n }\n const merged = patched.enum as unknown[];\n merged
|
|
1
|
+
{"version":3,"file":"discriminator-patch.cjs","sources":["../../src/api/discriminator-patch.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport { appendAll } from \"../domain/append-all.js\";\nimport { FIX, type OutputFix } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport type { DiscriminatorObject, OpenAPI3, SchemaObject } from \"../types.js\";\nimport { addEnumProperty, declaresValues, type EnumPatch } from \"./discriminator-enum.js\";\nimport {\n type DiscriminatorOwner,\n type EnumParent,\n enumParentOf,\n} from \"./discriminator-enum-parent.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The state of the discriminator pre-pass and the in-place patch of a mapped schema: the enum\n * property that the generated union narrows by. Two discriminators of one property may patch one\n * schema; how they combine is the `discriminator-values` fix (ADR-021, roadmap R12).\n */\n\n/** How to scan: the warnings, and the output fixes of the run (ADR-021). */\nexport interface DiscriminatorScanOptions {\n readonly silent: boolean;\n readonly logger: Logger;\n readonly fixes: ReadonlySet<OutputFix>;\n}\n\n/** What the two passes share: the document they patch and what they found so far. */\nexport interface ScanState extends DiscriminatorScanOptions {\n readonly schema: OpenAPI3;\n readonly objects: Record<string, DiscriminatorObject>;\n /** The schemas that define a discriminator themselves (pass 1), not by inheritance. */\n readonly owners: Set<string>;\n readonly refsHandled: string[];\n /** With the fix: the enum added to each schema, by schema and property, so values merge. */\n readonly patchedEnums: Map<string, SchemaObject>;\n /** With the fix: schema-name values, applied after both passes where no mapping names one. */\n readonly inferredPatches: EnumPatch[];\n /** With the fix: schema-name values of other properties (`inheritOtherOwners`). */\n readonly otherInferredPatches: EnumPatch[];\n /** With the fix: the other properties each schema got a value of (`inheritOtherOwners`). */\n readonly otherProperties: Record<string, string[]>;\n /** With `discriminator-values`: the enum keys that a schema declares itself. */\n readonly declaredKeys: Set<string>;\n /** With `discriminator-values`: the owner's enum of each added enum, by that enum. */\n readonly enumParents: Map<object, EnumParent>;\n}\n\n/** Whether `discriminator-values` is on: values of two discriminators merge into one enum. */\nexport function mergesValues(state: ScanState): boolean {\n return state.fixes.has(FIX.DISCRIMINATOR_VALUES);\n}\n\nfunction patchedSchema(state: ScanState, patch: EnumPatch): SchemaObject | undefined {\n const { silent, logger } = state;\n return resolveDocumentRef<SchemaObject>(state.schema, patch.ref, { silent, logger });\n}\n\n/**\n * With `discriminator-values`: the schema at `patch.ref` requires the property with\n * exactly these values already, so a patch would only repeat it (#2124).\n */\nfunction isDeclared(state: ScanState, patch: EnumPatch): boolean {\n return (\n state.fixes.has(FIX.DISCRIMINATOR_VALUES) && declaresValues(patchedSchema(state, patch), patch)\n );\n}\n\n/**\n * With `discriminator-values`: the enum of the owner's property, for `key`: an enum the scan\n * added, or a discriminator object that a schema inherited.\n */\nexport function recordEnumParent(state: ScanState, owner: DiscriminatorOwner, key: object): void {\n if (!state.fixes.has(FIX.DISCRIMINATOR_VALUES)) {\n return;\n }\n const { silent, logger } = state;\n const parent = enumParentOf(owner, (ref) =>\n resolveDocumentRef(state.schema, ref, { silent, logger }),\n );\n if (parent !== undefined) {\n state.enumParents.set(key, parent);\n }\n}\n\n/** The enum the schema at `patch.ref` gets, or null (with a warning) for another kind of schema. */\nfunction addDiscriminatorEnum(state: ScanState, patch: EnumPatch): SchemaObject | null {\n const added = addEnumProperty(patchedSchema(state, patch), patch);\n if (added === null) {\n warnInvalidMapping(patch, state.logger);\n } else {\n recordEnumParent(state, patch, added);\n }\n return added;\n}\n\n/** One schema and discriminator property; two discriminators of one property share an enum. */\nexport function enumKey(patch: EnumPatch): string {\n return `${patch.ref}\\n${patch.discriminator.propertyName}`;\n}\n\n/** With the fix, a second discriminator of the same property adds its values to the first enum. */\nfunction mergeIntoPatchedEnum(state: ScanState, key: string, values: readonly string[]): boolean {\n const patched = state.patchedEnums.get(key);\n if (patched === undefined) {\n return false;\n }\n const merged = patched.enum as unknown[];\n appendAll(\n merged,\n values.filter((value) => !merged.includes(value)),\n );\n return true;\n}\n\n/**\n * Add or replace the discriminator enum in the schema at `patch.ref`. Returns false, with a\n * warning, when that schema is neither an `allOf` nor an object schema. Without the fix every\n * patch adds a property, so two discriminators with different values intersect to `never`.\n */\nexport function patchDiscriminatorEnum(state: ScanState, patch: EnumPatch): boolean {\n if (isDeclared(state, patch)) {\n state.declaredKeys.add(enumKey(patch));\n return true;\n }\n if (!mergesValues(state)) {\n return addDiscriminatorEnum(state, patch) !== null;\n }\n const key = enumKey(patch);\n if (mergeIntoPatchedEnum(state, key, patch.values)) {\n return true;\n }\n const added = addDiscriminatorEnum(state, patch);\n if (added !== null) {\n state.patchedEnums.set(key, added);\n }\n return added !== null;\n}\n\nexport function markHandled(state: ScanState, ref: string): void {\n if (!state.refsHandled.includes(ref)) {\n state.refsHandled.push(ref);\n }\n}\n\nfunction warnInvalidMapping(patch: EnumPatch, logger: Logger): void {\n const mapped = `${patch.ref} => ${patch.values.join(\", \")}`;\n logger.warn(\n warningText(\n \"Discriminator mapping has an invalid schema \" +\n \"(neither an object schema nor an allOf array): \" +\n `${mapped} (Discriminator: ${patch.discriminatorRef})`,\n WARNING_CODES.DISCRIMINATOR_MAPPING_INVALID,\n ),\n );\n}\n"],"names":["FIX","resolveDocumentRef","declaresValues","enumParentOf","addEnumProperty","appendAll","warningText","WARNING_CODES"],"mappings":";;;;;;;;;AAgDO,SAAS,aAAa,KAAA,EAA2B;AACtD,EAAA,OAAO,KAAA,CAAM,KAAA,CAAM,GAAA,CAAIA,eAAA,CAAI,oBAAoB,CAAA;AACjD;AAEA,SAAS,aAAA,CAAc,OAAkB,KAAA,EAA4C;AACnF,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,KAAA;AAC3B,EAAA,OAAOC,+BAAA,CAAiC,MAAM,MAAA,EAAQ,KAAA,CAAM,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AACrF;AAMA,SAAS,UAAA,CAAW,OAAkB,KAAA,EAA2B;AAC/D,EAAA,OACE,KAAA,CAAM,KAAA,CAAM,GAAA,CAAID,eAAA,CAAI,oBAAoB,CAAA,IAAKE,gCAAA,CAAe,aAAA,CAAc,KAAA,EAAO,KAAK,CAAA,EAAG,KAAK,CAAA;AAElG;AAMO,SAAS,gBAAA,CAAiB,KAAA,EAAkB,KAAA,EAA2B,GAAA,EAAmB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AAA,CAAK,IAAI,CAAC,CAAA,CAAA;AACzD,EAAA,MAAA,CAAO,IAAA;AAAA,IACLC,oBAAA;AAAA,MACE,CAAA,2FAAA,EAEK,MAAM,CAAA,iBAAA,EAAoB,KAAA,CAAM,gBAAgB,CAAA,CAAA,CAAA;AAAA,MACrDC,sBAAA,CAAc;AAAA;AAChB,GACF;AACF;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appendAll } from '../domain/append-all.mjs';
|
|
1
2
|
import { FIX } from '../domain/output-fixes.mjs';
|
|
2
3
|
import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
|
|
3
4
|
import { declaresValues, addEnumProperty } from './discriminator-enum.mjs';
|
|
@@ -46,7 +47,10 @@ function mergeIntoPatchedEnum(state, key, values) {
|
|
|
46
47
|
return false;
|
|
47
48
|
}
|
|
48
49
|
const merged = patched.enum;
|
|
49
|
-
|
|
50
|
+
appendAll(
|
|
51
|
+
merged,
|
|
52
|
+
values.filter((value) => !merged.includes(value))
|
|
53
|
+
);
|
|
50
54
|
return true;
|
|
51
55
|
}
|
|
52
56
|
function patchDiscriminatorEnum(state, patch) {
|