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
package/src/cli/redocly-apis.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import { kebabCase } from "scule";
|
|
2
1
|
import type { RedoclyConfig } from "../application/ports/redocly-config-source.js";
|
|
3
|
-
import type { OutputFixName } from "../domain/output-fixes.js";
|
|
4
2
|
import type { GeneratorOptions } from "../types.js";
|
|
5
3
|
import {
|
|
6
4
|
type ApiSettings,
|
|
5
|
+
apiFixNames,
|
|
6
|
+
apiFlags,
|
|
7
|
+
apiOutputOf,
|
|
7
8
|
apiRefLimitOptions,
|
|
8
|
-
FIX_SETTING,
|
|
9
9
|
OUTPUT_SETTING,
|
|
10
10
|
unknownSettingWarnings,
|
|
11
11
|
} from "./api-settings.js";
|
|
12
|
-
import {
|
|
12
|
+
import { type GeneratedApi, writeGeneratedApis } from "./api-writes.js";
|
|
13
13
|
import { cliError } from "./cli-errors.js";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type CliRun,
|
|
16
|
+
ensureOutputIsNotSchema,
|
|
17
|
+
ensureOutputIsOwn,
|
|
18
|
+
filesReadBy,
|
|
19
|
+
type NamedFile,
|
|
20
|
+
outputFileOf,
|
|
21
|
+
parseLocationUrl,
|
|
22
|
+
redoclyConfigFiles,
|
|
23
|
+
resolveLocationUrl,
|
|
24
|
+
} from "./cli-output.js";
|
|
15
25
|
import { MULTIPLE_SCHEMAS_DOCS_URL } from "./docs-links.js";
|
|
16
|
-
import {
|
|
26
|
+
import { fixOption } from "./fix-option.js";
|
|
17
27
|
import { refLimitOptions } from "./ref-limits.js";
|
|
18
28
|
|
|
19
29
|
/** The `apis` of a Redocly config: each API is generated into its `x-openapi-ts.output`. */
|
|
@@ -21,16 +31,17 @@ import { refLimitOptions } from "./ref-limits.js";
|
|
|
21
31
|
/** The key of an API's openapi-typesafe settings in `redocly.yaml`. */
|
|
22
32
|
const REDOCLY_CONFIG_KEY = "x-openapi-ts";
|
|
23
33
|
|
|
34
|
+
/** An API of the config as written: `root` and the settings are not checked yet. */
|
|
24
35
|
interface RedoclyApi {
|
|
25
36
|
readonly name: string;
|
|
26
|
-
readonly root:
|
|
27
|
-
readonly settings:
|
|
37
|
+
readonly root: unknown;
|
|
38
|
+
readonly settings: unknown;
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
function redoclyApisOf(redocly: RedoclyConfig): RedoclyApi[] {
|
|
31
42
|
return Object.entries(redocly.apis ?? {}).map(([name, api]) => {
|
|
32
|
-
const
|
|
33
|
-
return { name, root:
|
|
43
|
+
const fields = api as Readonly<Record<string, unknown>>;
|
|
44
|
+
return { name, root: fields.root, settings: fields[REDOCLY_CONFIG_KEY] };
|
|
34
45
|
});
|
|
35
46
|
}
|
|
36
47
|
|
|
@@ -38,64 +49,158 @@ export function hasRedoclyApis(redocly: RedoclyConfig): boolean {
|
|
|
38
49
|
return Object.keys(redocly.apis ?? {}).length > 0;
|
|
39
50
|
}
|
|
40
51
|
|
|
41
|
-
/**
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
for (const name of GENERATOR_FLAGS) {
|
|
45
|
-
const value = typeof settings[name] === "boolean" ? settings[name] : settings[kebabCase(name)];
|
|
46
|
-
if (typeof value === "boolean") {
|
|
47
|
-
flags[name] = value;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return flags;
|
|
52
|
+
/** Paths in the config are relative to the config file; without a file, to the working dir. */
|
|
53
|
+
function configRootOf(redocly: RedoclyConfig, cwd: URL): URL {
|
|
54
|
+
return redocly.configFile ? resolveLocationUrl(redocly.configFile, cwd) : cwd;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
/** An API whose root and settings are usable, and the directory its paths are relative to. */
|
|
58
|
+
interface ApiTarget {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly root: string;
|
|
61
|
+
readonly settings: ApiSettings;
|
|
62
|
+
readonly configRoot: URL;
|
|
56
63
|
}
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return redocly.configFile ? resolveLocationUrl(redocly.configFile, cwd) : cwd;
|
|
65
|
+
function isSettingsMap(value: unknown): value is ApiSettings {
|
|
66
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The API with its settings. Fails with `CLI_CONFIG_OUTPUT_MISSING` when they name no output, and
|
|
71
|
+
* with `CLI_CONFIG_INVALID` when they are no map or `root` is no path or URL; only this API then
|
|
72
|
+
* fails, the others are still generated.
|
|
73
|
+
*/
|
|
74
|
+
function apiTarget(api: RedoclyApi, configRoot: URL): ApiTarget {
|
|
75
|
+
const { name, root, settings } = api;
|
|
76
|
+
if (settings !== undefined && !isSettingsMap(settings)) {
|
|
77
|
+
throw cliError("CLI_CONFIG_INVALID", `API ${name}: \`${REDOCLY_CONFIG_KEY}\` must be a map`);
|
|
78
|
+
}
|
|
79
|
+
if (!settings?.[OUTPUT_SETTING]) {
|
|
65
80
|
throw cliError(
|
|
66
81
|
"CLI_CONFIG_OUTPUT_MISSING",
|
|
67
|
-
`API ${
|
|
82
|
+
`API ${name} is missing an \`${REDOCLY_CONFIG_KEY}.output\` key. ` +
|
|
68
83
|
`See ${MULTIPLE_SCHEMAS_DOCS_URL}`,
|
|
69
84
|
);
|
|
70
85
|
}
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
if (typeof root !== "string" || root === "") {
|
|
87
|
+
throw cliError(
|
|
88
|
+
"CLI_CONFIG_INVALID",
|
|
89
|
+
`API ${name}: \`root\` in redocly.yaml must be the path or URL of its schema`,
|
|
90
|
+
);
|
|
73
91
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
return { name, root, settings, configRoot };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The generator options of one API: its own settings win over the CLI's flags. */
|
|
96
|
+
function apiOptions(run: CliRun, redocly: RedoclyConfig, target: ApiTarget): GeneratorOptions {
|
|
97
|
+
const { name, settings, configRoot } = target;
|
|
98
|
+
return {
|
|
77
99
|
...run.args.generatorFlags,
|
|
78
|
-
...apiFlags(
|
|
100
|
+
...apiFlags(name, settings),
|
|
79
101
|
...refLimitOptions(run.args, run.deps.cwd),
|
|
80
|
-
...apiRefLimitOptions(
|
|
81
|
-
...fixOption(apiFixNames(
|
|
102
|
+
...apiRefLimitOptions(name, settings, configRoot),
|
|
103
|
+
...fixOption(apiFixNames(name, settings) ?? run.args.fix),
|
|
82
104
|
redocly,
|
|
83
105
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The schemas and outputs of every API of the config, keyed by API name for the outputs. */
|
|
109
|
+
interface ConfigFiles {
|
|
110
|
+
readonly schemas: readonly NamedFile[];
|
|
111
|
+
readonly outputs: ReadonlyMap<string, URL>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The outputs of the other APIs, as `ensureOutputIsOwn` names them. */
|
|
115
|
+
function otherOutputs(files: ConfigFiles, apiName: string): NamedFile[] {
|
|
116
|
+
return [...files.outputs]
|
|
117
|
+
.filter(([name]) => name !== apiName)
|
|
118
|
+
.map(([name, location]) => ({ name: `API ${name}`, location }));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Generate the types of one API. Its output must not be a file the run reads before any API is
|
|
123
|
+
* loaded (the root of any API, the Redocly config) nor another API's output.
|
|
124
|
+
*/
|
|
125
|
+
async function generateApi(
|
|
126
|
+
run: CliRun,
|
|
127
|
+
redocly: RedoclyConfig,
|
|
128
|
+
target: ApiTarget,
|
|
129
|
+
files: ConfigFiles,
|
|
130
|
+
): Promise<GeneratedApi> {
|
|
131
|
+
for (const warning of unknownSettingWarnings(target.name, target.settings)) {
|
|
132
|
+
run.deps.logger.warn(warning);
|
|
133
|
+
}
|
|
134
|
+
const output = apiOutputOf(target.name, target.settings);
|
|
135
|
+
const outputFile = outputFileOf(run, { source: target.name, output }, target.configRoot);
|
|
136
|
+
ensureOutputIsNotSchema(run, outputFile, files.schemas);
|
|
137
|
+
ensureOutputIsOwn(run, outputFile, otherOutputs(files, target.name));
|
|
138
|
+
const source = resolveLocationUrl(target.root, target.configRoot);
|
|
139
|
+
const types = await run.deps.generate(source, apiOptions(run, redocly, target));
|
|
140
|
+
return { name: target.name, outputFile, types };
|
|
90
141
|
}
|
|
91
142
|
|
|
92
143
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
144
|
+
* The schema and the output of every API, and the config file itself. A location that is no
|
|
145
|
+
* text or no valid URL is left out: it is no file that an output could be, and its own API fails
|
|
146
|
+
* on it, not every API.
|
|
147
|
+
*/
|
|
148
|
+
function configFilesOf(run: CliRun, redocly: RedoclyConfig, apis: readonly RedoclyApi[]) {
|
|
149
|
+
const configRoot = configRootOf(redocly, run.deps.cwd);
|
|
150
|
+
const roots = apis.flatMap(({ name, root }) => {
|
|
151
|
+
const location = typeof root === "string" ? parseLocationUrl(root, configRoot) : undefined;
|
|
152
|
+
return location ? [{ name: `schema ${root} of API ${name}`, location }] : [];
|
|
153
|
+
});
|
|
154
|
+
const outputs = new Map<string, URL>();
|
|
155
|
+
for (const api of apis) {
|
|
156
|
+
const output = isSettingsMap(api.settings) ? api.settings[OUTPUT_SETTING] : undefined;
|
|
157
|
+
const location = typeof output === "string" ? parseLocationUrl(output, configRoot) : undefined;
|
|
158
|
+
if (location) {
|
|
159
|
+
outputs.set(api.name, location);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const schemas = [...roots, ...redoclyConfigFiles(run, redocly)];
|
|
163
|
+
return { configRoot, files: { schemas, outputs } satisfies ConfigFiles };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** What `task` gives for each item, run one after another: the next starts when one settles. */
|
|
167
|
+
async function settledInTurn<T, R>(
|
|
168
|
+
items: readonly T[],
|
|
169
|
+
task: (item: T) => Promise<R>,
|
|
170
|
+
): Promise<PromiseSettledResult<R>[]> {
|
|
171
|
+
const results: PromiseSettledResult<R>[] = [];
|
|
172
|
+
for (const item of items) {
|
|
173
|
+
try {
|
|
174
|
+
results.push({ status: "fulfilled", value: await task(item) });
|
|
175
|
+
} catch (reason) {
|
|
176
|
+
results.push({ status: "rejected", reason });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return results;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Generate every API of the config, one after another in the order of the config, then write
|
|
184
|
+
* them. One at a time, so a run takes the memory of its largest API, not the sum of all of them,
|
|
185
|
+
* and the work of one API cannot hold up the fetches of another until their timeout ends them.
|
|
186
|
+
* Nothing is written until every API is read and every output is claimed, so no output can
|
|
187
|
+
* replace a file that another API still reads; an output that is a file any API read (a `$ref`'d
|
|
188
|
+
* schema) fails with `CLI_OUTPUT_IS_INPUT`. Every API is generated or checked even when another
|
|
189
|
+
* fails, so `--check` reports a stale output wherever it is; the failures are returned in the
|
|
190
|
+
* order of the config.
|
|
96
191
|
*/
|
|
97
192
|
export async function generateRedoclyApis(run: CliRun, redocly: RedoclyConfig): Promise<unknown[]> {
|
|
98
193
|
const apis = redoclyApisOf(redocly);
|
|
99
|
-
const
|
|
100
|
-
|
|
194
|
+
const { configRoot, files } = configFilesOf(run, redocly, apis);
|
|
195
|
+
const results = await settledInTurn(apis, (api) =>
|
|
196
|
+
generateApi(run, redocly, apiTarget(api, configRoot), files),
|
|
197
|
+
);
|
|
198
|
+
const generated = results.flatMap((result) =>
|
|
199
|
+
result.status === "fulfilled" ? [result.value] : [],
|
|
200
|
+
);
|
|
201
|
+
const readFiles = generated.flatMap(({ name, types }) => filesReadBy(run, types, `API ${name}`));
|
|
202
|
+
const writeFailures = writeGeneratedApis(run, generated, readFiles);
|
|
203
|
+
return results.flatMap((result) =>
|
|
204
|
+
result.status === "rejected" ? [result.reason] : (writeFailures.get(result.value.name) ?? []),
|
|
205
|
+
);
|
|
101
206
|
}
|
package/src/cli/run-cli.ts
CHANGED
|
@@ -5,7 +5,16 @@ import type { SchemaSource } from "../types.js";
|
|
|
5
5
|
import { ineffectiveFlagNotices, parseCliArguments } from "./cli-arguments.js";
|
|
6
6
|
import type { CliDependencies } from "./cli-dependencies.js";
|
|
7
7
|
import { cliError, describeCliFailure, EXIT_CODES, type ExitCode } from "./cli-errors.js";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
type CliRun,
|
|
10
|
+
ensureOutputIsNotSchema,
|
|
11
|
+
filesReadBy,
|
|
12
|
+
type OutputFile,
|
|
13
|
+
outputFileOf,
|
|
14
|
+
redoclyConfigFiles,
|
|
15
|
+
resolveLocationUrl,
|
|
16
|
+
writeOutput,
|
|
17
|
+
} from "./cli-output.js";
|
|
9
18
|
import { MULTIPLE_SCHEMAS_DOCS_URL } from "./docs-links.js";
|
|
10
19
|
import { fixOption } from "./fix-option.js";
|
|
11
20
|
import { HELP_TEXT } from "./help-text.js";
|
|
@@ -43,7 +52,10 @@ function schemaSource(run: CliRun): SchemaSource {
|
|
|
43
52
|
return run.deps.stdin();
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* One schema from a path, a URL or stdin; without `--output`, the types go to stdout. Warnings and
|
|
57
|
+
* errors go to stderr either way, so they never mix with the types (upstream dropped warnings).
|
|
58
|
+
*/
|
|
47
59
|
async function generateSingleSchema(run: CliRun, redocly: RedoclyConfig): Promise<void> {
|
|
48
60
|
const { input, output } = run.args;
|
|
49
61
|
if (input?.includes("*")) {
|
|
@@ -61,20 +73,37 @@ async function generateSingleSchema(run: CliRun, redocly: RedoclyConfig): Promis
|
|
|
61
73
|
);
|
|
62
74
|
}
|
|
63
75
|
const source = schemaSource(run);
|
|
76
|
+
const outputFile = output ? singleOutputFile(run, output, source, redocly) : undefined;
|
|
64
77
|
const options = {
|
|
65
78
|
...run.args.generatorFlags,
|
|
66
79
|
...refLimitOptions(run.args, run.deps.cwd),
|
|
67
80
|
...fixOption(run.args.fix),
|
|
68
81
|
redocly,
|
|
69
|
-
silent: !output,
|
|
70
82
|
};
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
73
|
-
run.deps.writeStdout(contents);
|
|
83
|
+
const types = await run.deps.generate(source, options);
|
|
84
|
+
if (!outputFile) {
|
|
85
|
+
run.deps.writeStdout(types.contents);
|
|
74
86
|
return;
|
|
75
87
|
}
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
writeOutput(run, outputFile, types, filesReadBy(run, types, outputFile.source));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The `--output` file; it must not be the schema file nor the Redocly config, which writing it
|
|
93
|
+
* would replace.
|
|
94
|
+
*/
|
|
95
|
+
function singleOutputFile(
|
|
96
|
+
run: CliRun,
|
|
97
|
+
output: string,
|
|
98
|
+
source: SchemaSource,
|
|
99
|
+
redocly: RedoclyConfig,
|
|
100
|
+
): OutputFile {
|
|
101
|
+
const { input } = run.args;
|
|
102
|
+
const outputFile = outputFileOf(run, { source: input ?? "stdin", output }, run.deps.cwd);
|
|
103
|
+
const schemas =
|
|
104
|
+
input && source instanceof URL ? [{ name: `schema ${input}`, location: source }] : [];
|
|
105
|
+
ensureOutputIsNotSchema(run, outputFile, [...schemas, ...redoclyConfigFiles(run, redocly)]);
|
|
106
|
+
return outputFile;
|
|
78
107
|
}
|
|
79
108
|
|
|
80
109
|
async function generate(run: CliRun): Promise<unknown[]> {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append every item of `items` to `target`. `target.push(...items)` passes each item as an
|
|
3
|
+
* argument, and engines limit the arguments of a call (V8 throws a RangeError from about 125,000),
|
|
4
|
+
* so a list as long as a document allows (an `enum`, an `anyOf`, `examples`) must not be spread.
|
|
5
|
+
*/
|
|
6
|
+
export function appendAll<T>(target: T[], items: Iterable<T>): void {
|
|
7
|
+
for (const item of items) {
|
|
8
|
+
target.push(item);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { redactUrlSecrets } from "./url-secrets.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `cause` of a typed error is shown wherever the error is: `console.error(error)` and
|
|
5
|
+
* `util.inspect` print the whole chain, and error trackers send it. A lower-level error names the
|
|
6
|
+
* URL it failed on (fetch refuses `https://user:token@host/…` and quotes it), so the chain must
|
|
7
|
+
* hide the same secrets as the message (url-secrets.ts).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** A string with its URL secrets hidden; any other value as it is. */
|
|
11
|
+
function redactedValue(value: unknown): unknown {
|
|
12
|
+
return typeof value === "string" ? redactUrlSecrets(value) : value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A copy of `error` of the same class, its own properties (`message`, `stack`, `code`, `input`, a
|
|
17
|
+
* nested `cause`) with URL secrets hidden, or `error` itself when none of them holds one. Each
|
|
18
|
+
* property is read through its getter (V8 keeps `stack` behind one) and copied as a value.
|
|
19
|
+
*/
|
|
20
|
+
function redactedError(error: Error, seen: ReadonlySet<Error>): Error {
|
|
21
|
+
const inner = new Set([...seen, error]);
|
|
22
|
+
// A real error with the class of `error`, so `util.inspect` and `util.types.isNativeError`
|
|
23
|
+
// treat it as one.
|
|
24
|
+
const copy = Object.setPrototypeOf(new Error(), Object.getPrototypeOf(error)) as Error;
|
|
25
|
+
let isChanged = false;
|
|
26
|
+
for (const key of Reflect.ownKeys(error)) {
|
|
27
|
+
const value: unknown = Reflect.get(error, key);
|
|
28
|
+
const shown = key === "cause" ? redactedCauseIn(value, inner) : redactedValue(value);
|
|
29
|
+
isChanged ||= shown !== value;
|
|
30
|
+
const enumerable = Object.getOwnPropertyDescriptor(error, key)?.enumerable === true;
|
|
31
|
+
Object.defineProperty(copy, key, {
|
|
32
|
+
value: shown,
|
|
33
|
+
enumerable,
|
|
34
|
+
writable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return isChanged ? copy : error;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function redactedCauseIn(cause: unknown, seen: ReadonlySet<Error>): unknown {
|
|
42
|
+
if (!(cause instanceof Error)) {
|
|
43
|
+
return redactedValue(cause);
|
|
44
|
+
}
|
|
45
|
+
// A chain that loops back is cut where it does, so the copy is finite.
|
|
46
|
+
return seen.has(cause) ? undefined : redactedError(cause, seen);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The cause of a typed error with the URL secrets of its whole chain hidden. */
|
|
50
|
+
export function redactCauseSecrets(cause: unknown): unknown {
|
|
51
|
+
return redactedCauseIn(cause, new Set());
|
|
52
|
+
}
|
package/src/domain/errors.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { redactCauseSecrets } from "./cause-secrets.js";
|
|
2
|
+
import { redactUrlSecrets } from "./url-secrets.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI
|
|
@@ -35,6 +36,10 @@ export const ERROR_CODES = {
|
|
|
35
36
|
CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING",
|
|
36
37
|
CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING",
|
|
37
38
|
CLI_INPUT_MISSING: "CLI_INPUT_MISSING",
|
|
39
|
+
CLI_OUTPUT_IS_INPUT: "CLI_OUTPUT_IS_INPUT",
|
|
40
|
+
CLI_OUTPUT_DUPLICATE: "CLI_OUTPUT_DUPLICATE",
|
|
41
|
+
CLI_OUTPUT_INVALID: "CLI_OUTPUT_INVALID",
|
|
42
|
+
CLI_LOCATION_INVALID: "CLI_LOCATION_INVALID",
|
|
38
43
|
OUTPUT_STALE: "OUTPUT_STALE",
|
|
39
44
|
OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED",
|
|
40
45
|
OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED",
|
|
@@ -52,21 +57,25 @@ export interface OpenAPITypesafeErrorInit {
|
|
|
52
57
|
readonly code: ErrorCode;
|
|
53
58
|
readonly message: string;
|
|
54
59
|
readonly details?: ErrorDetails;
|
|
55
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* The lower-level error this one reports, if any (kept as the standard `cause`; a copy with URL
|
|
62
|
+
* secrets hidden when its chain names one, see cause-secrets.ts).
|
|
63
|
+
*/
|
|
56
64
|
readonly cause?: unknown;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
68
|
* The base of every expected failure; check `code`, not the class or the message. The message
|
|
61
|
-
* never
|
|
69
|
+
* and the `cause` chain never show the user info or the query of a URL (`url-secrets.ts`).
|
|
62
70
|
*/
|
|
63
71
|
export class OpenAPITypesafeError extends Error {
|
|
64
72
|
readonly code: ErrorCode;
|
|
65
73
|
readonly details: ErrorDetails;
|
|
66
74
|
|
|
67
75
|
constructor(init: OpenAPITypesafeErrorInit) {
|
|
68
|
-
const message =
|
|
69
|
-
|
|
76
|
+
const message = redactUrlSecrets(init.message);
|
|
77
|
+
const cause = redactCauseSecrets(init.cause);
|
|
78
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
70
79
|
this.name = "OpenAPITypesafeError";
|
|
71
80
|
this.code = init.code;
|
|
72
81
|
this.details = init.details ?? {};
|
|
@@ -2,11 +2,12 @@ import { NEWER_IDENTIFIER_PART, NEWER_IDENTIFIER_START } from "./newer-identifie
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Identifier rules of ECMAScript (Unicode `ID_Start` / `ID_Continue`, plus `$`, `_`, ZWNJ and
|
|
5
|
-
* ZWJ), for names built from document text, without the characters that
|
|
6
|
-
* does not know
|
|
7
|
-
* so a name such as `Name` (Unicode 17) passed here and failed to
|
|
8
|
-
* character" (ADR-019)
|
|
9
|
-
* supported Node.js
|
|
5
|
+
* ZWJ), for names built from document text, without the characters that the scanner of the lowest
|
|
6
|
+
* supported TypeScript (5.4) does not know. Node.js follows a newer Unicode version than
|
|
7
|
+
* TypeScript's identifier tables, so a name such as `Name` (Unicode 17) passed here and failed to
|
|
8
|
+
* parse with "Invalid character" (ADR-019); TypeScript 5.4 also rejects ZWJ and characters that
|
|
9
|
+
* TypeScript 6 accepts. Removing these also gives the same names on every supported Node.js
|
|
10
|
+
* version.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
const IDENTIFIER_START_RE = new RegExp(
|