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":"output-fixes.cjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default. The object names the fixes for this package's code; the public API is the `OutputFix`\n * union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).\n */\nexport const FIX = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\n/** The name of one opt-in output fix. */\nexport type OutputFix = (typeof FIX)[keyof typeof FIX];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(FIX);\n\n/** The name that turns on every fix of the installed version. */\nconst ALL_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `\"all\"`. */\nexport type OutputFixName = OutputFix | typeof ALL_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [FIX.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [FIX.NULLABLE_ENUMS]: [ENUM],\n [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" }],\n [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAQO,MAAM,GAAA,GAAM;AAAA;AAAA,EAEjB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,6BAAA,EAA+B,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,eAAA,EAAiB,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,sBAAA,EAAwB;AAC1B;AAKO,MAAM,YAAA,GAAqC,MA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A,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;;;;;"}
|
|
1
|
+
{"version":3,"file":"output-fixes.cjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default. The object names the fixes for this package's code; the public API is the `OutputFix`\n * union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).\n */\nexport const FIX = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** A parameter with `content` instead of `schema` is typed by the schema of its media type. */\n PARAMETER_CONTENT: \"parameter-content\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /**\n * OpenAPI 3.1 and 3.2: keywords next to a `$ref` (`required`, `properties`) apply too, so the\n * type is the reference intersected with them. OpenAPI 3.0 ignores them, as its spec says.\n */\n REF_SIBLINGS: \"ref-siblings\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\n/** The name of one opt-in output fix. */\nexport type OutputFix = (typeof FIX)[keyof typeof FIX];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(FIX);\n\n/** The name that turns on every fix of the installed version. */\nconst ALL_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `\"all\"`. */\nexport type OutputFixName = OutputFix | typeof ALL_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/**\n * The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value, and for a `fix`\n * option that is no list (`fix: \"all\"` from JavaScript), which must not be read letter by letter.\n */\nexport function outputFixNamesOf(values: unknown): readonly OutputFixName[] {\n if (!Array.isArray(values)) {\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message:\n 'The fix option must be a list of fix names, such as [\"all\"]. ' +\n `Got ${JSON.stringify(values)}.`,\n details: { unknown: [values], known: [...KNOWN_NAMES] },\n });\n }\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [FIX.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [FIX.NULLABLE_ENUMS]: [ENUM],\n [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" }],\n [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAQO,MAAM,GAAA,GAAM;AAAA;AAAA,EAEjB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,6BAAA,EAA+B,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,cAAA,EAAgB,gBAAA;AAA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C3B,CAAC,GAAA,CAAI,qBAAqB,GAAG,CAAC,EAAE,MAAA,EAAQ,mBAAA,EAAqB,IAAA,EAAM,wBAAA,EAA0B,CAAA;AAAA,EAC7F,CAAC,GAAA,CAAI,mBAAmB,GAAG,CAAC,YAAY,gBAAgB;AAC1D,CAAA;AAEA,SAAS,oBAAoB,WAAA,EAA2C;AACtE,EAAA,OAAO,CAAA,EAAG,WAAA,CAAY,MAAM,CAAA,EAAA,EAAK,YAAY,IAAI,CAAA,CAAA,CAAA;AACnD;AAMO,SAAS,qBAAA,CACd,OACA,UAAA,EACU;AACV,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAC3C,IAAA,MAAM,OAAA,GAAA,CAAW,YAAA,CAAa,IAAI,CAAA,IAAK,EAAC,EAAG,MAAA,CAAO,CAAC,EAAE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;;;;;"}
|
|
@@ -27,6 +27,8 @@ const FIX = {
|
|
|
27
27
|
EXPLODED_QUERY_OBJECTS: "exploded-query-objects",
|
|
28
28
|
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
29
29
|
NULLABLE_ENUMS: "nullable-enums",
|
|
30
|
+
/** A parameter with `content` instead of `schema` is typed by the schema of its media type. */
|
|
31
|
+
PARAMETER_CONTENT: "parameter-content",
|
|
30
32
|
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
31
33
|
PATH_PARAM_TYPE_NAMES: "path-param-type-names",
|
|
32
34
|
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
@@ -38,6 +40,11 @@ const FIX = {
|
|
|
38
40
|
* points at, also where the original type compiles through an index signature.
|
|
39
41
|
*/
|
|
40
42
|
REF_POINTERS: "ref-pointers",
|
|
43
|
+
/**
|
|
44
|
+
* OpenAPI 3.1 and 3.2: keywords next to a `$ref` (`required`, `properties`) apply too, so the
|
|
45
|
+
* type is the reference intersected with them. OpenAPI 3.0 ignores them, as its spec says.
|
|
46
|
+
*/
|
|
47
|
+
REF_SIBLINGS: "ref-siblings",
|
|
41
48
|
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
42
49
|
ROOT_TYPE_NUMBERING: "root-type-numbering",
|
|
43
50
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
@@ -50,6 +57,13 @@ function isOutputFixName(value) {
|
|
|
50
57
|
return typeof value === "string" && KNOWN_NAMES.has(value);
|
|
51
58
|
}
|
|
52
59
|
function outputFixNamesOf(values) {
|
|
60
|
+
if (!Array.isArray(values)) {
|
|
61
|
+
throw new OpenAPITypesafeError({
|
|
62
|
+
code: ERROR_CODES.OPTION_FIX_UNKNOWN,
|
|
63
|
+
message: `The fix option must be a list of fix names, such as ["all"]. Got ${JSON.stringify(values)}.`,
|
|
64
|
+
details: { unknown: [values], known: [...KNOWN_NAMES] }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
53
67
|
const unknown = values.filter((value) => !isOutputFixName(value));
|
|
54
68
|
if (unknown.length > 0) {
|
|
55
69
|
const names = unknown.map((value) => JSON.stringify(value)).join(", ");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-fixes.mjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default. The object names the fixes for this package's code; the public API is the `OutputFix`\n * union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).\n */\nexport const FIX = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\n/** The name of one opt-in output fix. */\nexport type OutputFix = (typeof FIX)[keyof typeof FIX];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(FIX);\n\n/** The name that turns on every fix of the installed version. */\nconst ALL_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `\"all\"`. */\nexport type OutputFixName = OutputFix | typeof ALL_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [FIX.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [FIX.NULLABLE_ENUMS]: [ENUM],\n [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" }],\n [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":[],"mappings":";;AAQO,MAAM,GAAA,GAAM;AAAA;AAAA,EAEjB,yBAAA,EAA2B,2BAAA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,CAAC,EAAE,MAAA,EAAQ,mBAAA,EAAqB,IAAA,EAAM,wBAAA,EAA0B,CAAA;AAAA,EAC7F,CAAC,GAAA,CAAI,mBAAmB,GAAG,CAAC,YAAY,gBAAgB;AAC1D,CAAA;AAEA,SAAS,oBAAoB,WAAA,EAA2C;AACtE,EAAA,OAAO,CAAA,EAAG,WAAA,CAAY,MAAM,CAAA,EAAA,EAAK,YAAY,IAAI,CAAA,CAAA,CAAA;AACnD;AAMO,SAAS,qBAAA,CACd,OACA,UAAA,EACU;AACV,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAC3C,IAAA,MAAM,OAAA,GAAA,CAAW,YAAA,CAAa,IAAI,CAAA,IAAK,EAAC,EAAG,MAAA,CAAO,CAAC,EAAE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;"}
|
|
1
|
+
{"version":3,"file":"output-fixes.mjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default. The object names the fixes for this package's code; the public API is the `OutputFix`\n * union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).\n */\nexport const FIX = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** A parameter with `content` instead of `schema` is typed by the schema of its media type. */\n PARAMETER_CONTENT: \"parameter-content\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /**\n * OpenAPI 3.1 and 3.2: keywords next to a `$ref` (`required`, `properties`) apply too, so the\n * type is the reference intersected with them. OpenAPI 3.0 ignores them, as its spec says.\n */\n REF_SIBLINGS: \"ref-siblings\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\n/** The name of one opt-in output fix. */\nexport type OutputFix = (typeof FIX)[keyof typeof FIX];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(FIX);\n\n/** The name that turns on every fix of the installed version. */\nconst ALL_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `\"all\"`. */\nexport type OutputFixName = OutputFix | typeof ALL_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/**\n * The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value, and for a `fix`\n * option that is no list (`fix: \"all\"` from JavaScript), which must not be read letter by letter.\n */\nexport function outputFixNamesOf(values: unknown): readonly OutputFixName[] {\n if (!Array.isArray(values)) {\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message:\n 'The fix option must be a list of fix names, such as [\"all\"]. ' +\n `Got ${JSON.stringify(values)}.`,\n details: { unknown: [values], known: [...KNOWN_NAMES] },\n });\n }\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [FIX.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [FIX.NULLABLE_ENUMS]: [ENUM],\n [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" }],\n [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":[],"mappings":";;AAQO,MAAM,GAAA,GAAM;AAAA;AAAA,EAEjB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,6BAAA,EAA+B,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,eAAA,EAAiB,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjB,YAAA,EAAc,cAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKd,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,sBAAA,EAAwB;AAC1B;AAKO,MAAM,YAAA,GAAqC,MAAA,CAAO,MAAA,CAAO,GAAG;AAGnE,MAAM,SAAA,GAAY,KAAA;AAKlB,MAAM,8BAAmC,IAAI,GAAA,CAAY,CAAC,GAAG,YAAA,EAAc,SAAS,CAAC,CAAA;AAErF,SAAS,gBAAgB,KAAA,EAAwC;AAC/D,EAAA,OA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AE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const URL_AFTER_SCHEME = /:\/\/[^\s"'<>]*[^\s"'<>.,:;!?)]/g;
|
|
4
|
+
const SCHEME_SEPARATOR = "://";
|
|
5
|
+
const AUTHORITY_END = /[/?#]/;
|
|
6
|
+
const QUERY_OR_FRAGMENT = /[?#]/;
|
|
7
|
+
const QUERY_START = "?";
|
|
8
|
+
const FRAGMENT_START = "#";
|
|
9
|
+
const USER_INFO_END = "@";
|
|
10
|
+
const HIDDEN = "***";
|
|
11
|
+
function withoutUserInfo(rest) {
|
|
12
|
+
const authorityEnd = rest.search(AUTHORITY_END);
|
|
13
|
+
const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
|
|
14
|
+
const userInfoEnd = authority.lastIndexOf(USER_INFO_END);
|
|
15
|
+
return userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;
|
|
16
|
+
}
|
|
17
|
+
function withoutQuery(rest) {
|
|
18
|
+
const fragmentStart = rest.indexOf(FRAGMENT_START);
|
|
19
|
+
const beforeFragment = fragmentStart === -1 ? rest : rest.slice(0, fragmentStart);
|
|
20
|
+
const queryStart = beforeFragment.indexOf(QUERY_START);
|
|
21
|
+
if (queryStart === -1) {
|
|
22
|
+
return rest;
|
|
23
|
+
}
|
|
24
|
+
const fragment = fragmentStart === -1 ? "" : rest.slice(fragmentStart);
|
|
25
|
+
return `${rest.slice(0, queryStart + 1)}${HIDDEN}${fragment}`;
|
|
26
|
+
}
|
|
27
|
+
function redactUrlSecrets(text) {
|
|
28
|
+
return text.replace(URL_AFTER_SCHEME, (url) => {
|
|
29
|
+
const rest = url.slice(SCHEME_SEPARATOR.length);
|
|
30
|
+
return `${SCHEME_SEPARATOR}${withoutQuery(withoutUserInfo(rest))}`;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function redactUnparsedUrl(text) {
|
|
34
|
+
const separator = text.indexOf(SCHEME_SEPARATOR);
|
|
35
|
+
if (separator === -1) {
|
|
36
|
+
return text;
|
|
37
|
+
}
|
|
38
|
+
const rest = text.slice(separator + SCHEME_SEPARATOR.length);
|
|
39
|
+
const queryOrFragment = rest.search(QUERY_OR_FRAGMENT);
|
|
40
|
+
const beforeQuery = queryOrFragment === -1 ? rest : rest.slice(0, queryOrFragment);
|
|
41
|
+
const userInfoEnd = beforeQuery.lastIndexOf(USER_INFO_END);
|
|
42
|
+
const shown = userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;
|
|
43
|
+
return `${text.slice(0, separator)}${SCHEME_SEPARATOR}${withoutQuery(shown)}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.redactUnparsedUrl = redactUnparsedUrl;
|
|
47
|
+
exports.redactUrlSecrets = redactUrlSecrets;
|
|
48
|
+
//# sourceMappingURL=url-secrets.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-secrets.cjs","sources":["../../src/domain/url-secrets.ts"],"sourcesContent":["/**\n * URLs can reach a message: the CLI input, a `$ref`, a redirect. Messages end up in CI job logs, so\n * the parts of a URL that carry secrets are hidden in every one (audit B2, F12): the user info\n * (`https://user:token@host/…`), which fetch refuses anyway, and the query, which holds API keys\n * and signatures (`?api_key=…`, `?X-Amz-Signature=…`). Which query parameters are secret cannot be\n * told by their names, so the whole query is hidden; the path and the fragment (a JSON pointer)\n * stay, so the message still names the document and the place in it.\n */\n\n/**\n * A URL in a message, from its `://` to the first space, quote or angle bracket: a serialized URL\n * percent-encodes these, and messages put them around a URL. A match takes the rest of the URL,\n * also a later `://` in it, so the scan never starts again inside a URL; it stays linear. It ends\n * before punctuation that closes a sentence or a parenthesis (`… x.yaml?key=1: 404`, `(… ?key=1)`),\n * which the message puts after the URL; a hidden query would hide it too.\n */\nconst URL_AFTER_SCHEME = /:\\/\\/[^\\s\"'<>]*[^\\s\"'<>.,:;!?)]/g;\n\nconst SCHEME_SEPARATOR = \"://\";\nconst AUTHORITY_END = /[/?#]/;\nconst QUERY_OR_FRAGMENT = /[?#]/;\nconst QUERY_START = \"?\";\nconst FRAGMENT_START = \"#\";\nconst USER_INFO_END = \"@\";\nconst HIDDEN = \"***\";\n\n/** The part after `://` with the user info of its authority hidden: `***@host`. */\nfunction withoutUserInfo(rest: string): string {\n const authorityEnd = rest.search(AUTHORITY_END);\n const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);\n const userInfoEnd = authority.lastIndexOf(USER_INFO_END);\n return userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;\n}\n\n/** The part after `://` with its query hidden: `/x.yaml?***#/a`. */\nfunction withoutQuery(rest: string): string {\n const fragmentStart = rest.indexOf(FRAGMENT_START);\n const beforeFragment = fragmentStart === -1 ? rest : rest.slice(0, fragmentStart);\n const queryStart = beforeFragment.indexOf(QUERY_START);\n if (queryStart === -1) {\n return rest;\n }\n const fragment = fragmentStart === -1 ? \"\" : rest.slice(fragmentStart);\n return `${rest.slice(0, queryStart + 1)}${HIDDEN}${fragment}`;\n}\n\n/** The text with the user info and the query of every URL in it replaced by `***`. */\nexport function redactUrlSecrets(text: string): string {\n return text.replace(URL_AFTER_SCHEME, (url) => {\n const rest = url.slice(SCHEME_SEPARATOR.length);\n return `${SCHEME_SEPARATOR}${withoutQuery(withoutUserInfo(rest))}`;\n });\n}\n\n/**\n * Text that starts like a URL but does not parse as one (`http://user:a/b@host/x`), with what may\n * be secret hidden. Without a parse there is no telling where the authority ends, so everything\n * from the `://` to the last `@` before the query counts as user info; the query is hidden as in\n * `redactUrlSecrets`.\n */\nexport function redactUnparsedUrl(text: string): string {\n const separator = text.indexOf(SCHEME_SEPARATOR);\n if (separator === -1) {\n return text;\n }\n const rest = text.slice(separator + SCHEME_SEPARATOR.length);\n const queryOrFragment = rest.search(QUERY_OR_FRAGMENT);\n const beforeQuery = queryOrFragment === -1 ? rest : rest.slice(0, queryOrFragment);\n const userInfoEnd = beforeQuery.lastIndexOf(USER_INFO_END);\n const shown = userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;\n return `${text.slice(0, separator)}${SCHEME_SEPARATOR}${withoutQuery(shown)}`;\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,gBAAA,GAAmB,kCAAA;AAEzB,MAAM,gBAAA,GAAmB,KAAA;AACzB,MAAM,aAAA,GAAgB,OAAA;AACtB,MAAM,iBAAA,GAAoB,MAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,cAAA,GAAiB,GAAA;AACvB,MAAM,aAAA,GAAgB,GAAA;AACtB,MAAM,MAAA,GAAS,KAAA;AAGf,SAAS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,CAAO,aAAa,CAAA;AAC9C,EAAA,MAAM,YAAY,YAAA,KAAiB,EAAA,GAAK,OAAO,IAAA,CAAK,KAAA,CAAM,GAAG,YAAY,CAAA;AACzE,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,WAAA,CAAY,aAAa,CAAA;AACvD,EAAA,OAAO,WAAA,KAAgB,KAAK,IAAA,GAAO,CAAA,EAAG,MAAM,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,WAAW,CAAC,CAAA,CAAA;AACxE;AAGA,SAAS,aAAa,IAAA,EAAsB;AAC1C,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,OAAA,CAAQ,cAAc,CAAA;AACjD,EAAA,MAA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Ac,WAAA,CAAY,WAAA,CAAY,aAAa,CAAA;AACzD,EAAA,MAAM,KAAA,GAAQ,WAAA,KAAgB,EAAA,GAAK,IAAA,GAAO,CAAA,EAAG,MAAM,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,WAAW,CAAC,CAAA,CAAA;AAC7E,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAC,CAAA,EAAG,gBAAgB,CAAA,EAAG,YAAA,CAAa,KAAK,CAAC,CAAA,CAAA;AAC7E;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const URL_AFTER_SCHEME = /:\/\/[^\s"'<>]*[^\s"'<>.,:;!?)]/g;
|
|
2
|
+
const SCHEME_SEPARATOR = "://";
|
|
3
|
+
const AUTHORITY_END = /[/?#]/;
|
|
4
|
+
const QUERY_OR_FRAGMENT = /[?#]/;
|
|
5
|
+
const QUERY_START = "?";
|
|
6
|
+
const FRAGMENT_START = "#";
|
|
7
|
+
const USER_INFO_END = "@";
|
|
8
|
+
const HIDDEN = "***";
|
|
9
|
+
function withoutUserInfo(rest) {
|
|
10
|
+
const authorityEnd = rest.search(AUTHORITY_END);
|
|
11
|
+
const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
|
|
12
|
+
const userInfoEnd = authority.lastIndexOf(USER_INFO_END);
|
|
13
|
+
return userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;
|
|
14
|
+
}
|
|
15
|
+
function withoutQuery(rest) {
|
|
16
|
+
const fragmentStart = rest.indexOf(FRAGMENT_START);
|
|
17
|
+
const beforeFragment = fragmentStart === -1 ? rest : rest.slice(0, fragmentStart);
|
|
18
|
+
const queryStart = beforeFragment.indexOf(QUERY_START);
|
|
19
|
+
if (queryStart === -1) {
|
|
20
|
+
return rest;
|
|
21
|
+
}
|
|
22
|
+
const fragment = fragmentStart === -1 ? "" : rest.slice(fragmentStart);
|
|
23
|
+
return `${rest.slice(0, queryStart + 1)}${HIDDEN}${fragment}`;
|
|
24
|
+
}
|
|
25
|
+
function redactUrlSecrets(text) {
|
|
26
|
+
return text.replace(URL_AFTER_SCHEME, (url) => {
|
|
27
|
+
const rest = url.slice(SCHEME_SEPARATOR.length);
|
|
28
|
+
return `${SCHEME_SEPARATOR}${withoutQuery(withoutUserInfo(rest))}`;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function redactUnparsedUrl(text) {
|
|
32
|
+
const separator = text.indexOf(SCHEME_SEPARATOR);
|
|
33
|
+
if (separator === -1) {
|
|
34
|
+
return text;
|
|
35
|
+
}
|
|
36
|
+
const rest = text.slice(separator + SCHEME_SEPARATOR.length);
|
|
37
|
+
const queryOrFragment = rest.search(QUERY_OR_FRAGMENT);
|
|
38
|
+
const beforeQuery = queryOrFragment === -1 ? rest : rest.slice(0, queryOrFragment);
|
|
39
|
+
const userInfoEnd = beforeQuery.lastIndexOf(USER_INFO_END);
|
|
40
|
+
const shown = userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;
|
|
41
|
+
return `${text.slice(0, separator)}${SCHEME_SEPARATOR}${withoutQuery(shown)}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { redactUnparsedUrl, redactUrlSecrets };
|
|
45
|
+
//# sourceMappingURL=url-secrets.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-secrets.mjs","sources":["../../src/domain/url-secrets.ts"],"sourcesContent":["/**\n * URLs can reach a message: the CLI input, a `$ref`, a redirect. Messages end up in CI job logs, so\n * the parts of a URL that carry secrets are hidden in every one (audit B2, F12): the user info\n * (`https://user:token@host/…`), which fetch refuses anyway, and the query, which holds API keys\n * and signatures (`?api_key=…`, `?X-Amz-Signature=…`). Which query parameters are secret cannot be\n * told by their names, so the whole query is hidden; the path and the fragment (a JSON pointer)\n * stay, so the message still names the document and the place in it.\n */\n\n/**\n * A URL in a message, from its `://` to the first space, quote or angle bracket: a serialized URL\n * percent-encodes these, and messages put them around a URL. A match takes the rest of the URL,\n * also a later `://` in it, so the scan never starts again inside a URL; it stays linear. It ends\n * before punctuation that closes a sentence or a parenthesis (`… x.yaml?key=1: 404`, `(… ?key=1)`),\n * which the message puts after the URL; a hidden query would hide it too.\n */\nconst URL_AFTER_SCHEME = /:\\/\\/[^\\s\"'<>]*[^\\s\"'<>.,:;!?)]/g;\n\nconst SCHEME_SEPARATOR = \"://\";\nconst AUTHORITY_END = /[/?#]/;\nconst QUERY_OR_FRAGMENT = /[?#]/;\nconst QUERY_START = \"?\";\nconst FRAGMENT_START = \"#\";\nconst USER_INFO_END = \"@\";\nconst HIDDEN = \"***\";\n\n/** The part after `://` with the user info of its authority hidden: `***@host`. */\nfunction withoutUserInfo(rest: string): string {\n const authorityEnd = rest.search(AUTHORITY_END);\n const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);\n const userInfoEnd = authority.lastIndexOf(USER_INFO_END);\n return userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;\n}\n\n/** The part after `://` with its query hidden: `/x.yaml?***#/a`. */\nfunction withoutQuery(rest: string): string {\n const fragmentStart = rest.indexOf(FRAGMENT_START);\n const beforeFragment = fragmentStart === -1 ? rest : rest.slice(0, fragmentStart);\n const queryStart = beforeFragment.indexOf(QUERY_START);\n if (queryStart === -1) {\n return rest;\n }\n const fragment = fragmentStart === -1 ? \"\" : rest.slice(fragmentStart);\n return `${rest.slice(0, queryStart + 1)}${HIDDEN}${fragment}`;\n}\n\n/** The text with the user info and the query of every URL in it replaced by `***`. */\nexport function redactUrlSecrets(text: string): string {\n return text.replace(URL_AFTER_SCHEME, (url) => {\n const rest = url.slice(SCHEME_SEPARATOR.length);\n return `${SCHEME_SEPARATOR}${withoutQuery(withoutUserInfo(rest))}`;\n });\n}\n\n/**\n * Text that starts like a URL but does not parse as one (`http://user:a/b@host/x`), with what may\n * be secret hidden. Without a parse there is no telling where the authority ends, so everything\n * from the `://` to the last `@` before the query counts as user info; the query is hidden as in\n * `redactUrlSecrets`.\n */\nexport function redactUnparsedUrl(text: string): string {\n const separator = text.indexOf(SCHEME_SEPARATOR);\n if (separator === -1) {\n return text;\n }\n const rest = text.slice(separator + SCHEME_SEPARATOR.length);\n const queryOrFragment = rest.search(QUERY_OR_FRAGMENT);\n const beforeQuery = queryOrFragment === -1 ? rest : rest.slice(0, queryOrFragment);\n const userInfoEnd = beforeQuery.lastIndexOf(USER_INFO_END);\n const shown = userInfoEnd === -1 ? rest : `${HIDDEN}${rest.slice(userInfoEnd)}`;\n return `${text.slice(0, separator)}${SCHEME_SEPARATOR}${withoutQuery(shown)}`;\n}\n"],"names":[],"mappings":"AAgBA,MAAM,gBAAA,GAAmB,kCAAA;AAEzB,MAAM,gBAAA,GAAmB,KAAA;AACzB,MAAM,aAAA,GAAgB,OAAA;AACtB,MAAM,iBAAA,GAAoB,MAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,cAAA,GAAiB,GAAA;AACvB,MAAM,aAAA,GAAgB,GAAA;AACtB,MAAM,MAAA,GAAS,KAAA;AAGf,SAAS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,CAAO,aAAa,CAAA;AAC9C,EAAA,MAAM,YAAY,YAAA,KAAiB,EAAA,GAAK,OAAO,IAAA,CAAK,KAAA,CAAM,GAAG,YAAY,CAAA;AACzE,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,WAAA,CAAY,aAAa,CAAA;AACvD,EAAA,OAAO,WAAA,KAAgB,KAAK,IAAA,GAAO,CAAA,EAAG,MAAM,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,WAAW,CAAC,CAAA,CAAA;AACxE;AAGA,SAAS,aAAa,IAAA,EAAsB;AAC1C,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,OAAA,CAAQ,cAAc,CAAA;AACjD,EAAA,MAAM,iBAAiB,aAA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,WAAA,CAAY,aAAa,CAAA;AACzD,EAAA,MAAM,KAAA,GAAQ,WAAA,KAAgB,EAAA,GAAK,IAAA,GAAO,CAAA,EAAG,MAAM,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,WAAW,CAAC,CAAA,CAAA;AAC7E,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAC,CAAA,EAAG,gBAAgB,CAAA,EAAG,YAAA,CAAa,KAAK,CAAC,CAAA,CAAA;AAC7E;;"}
|
package/dist/index.d.cts
CHANGED
|
@@ -280,6 +280,8 @@ declare const FIX: {
|
|
|
280
280
|
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
281
281
|
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
282
282
|
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
283
|
+
/** A parameter with `content` instead of `schema` is typed by the schema of its media type. */
|
|
284
|
+
readonly PARAMETER_CONTENT: "parameter-content";
|
|
283
285
|
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
284
286
|
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
285
287
|
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
@@ -291,6 +293,11 @@ declare const FIX: {
|
|
|
291
293
|
* points at, also where the original type compiles through an index signature.
|
|
292
294
|
*/
|
|
293
295
|
readonly REF_POINTERS: "ref-pointers";
|
|
296
|
+
/**
|
|
297
|
+
* OpenAPI 3.1 and 3.2: keywords next to a `$ref` (`required`, `properties`) apply too, so the
|
|
298
|
+
* type is the reference intersected with them. OpenAPI 3.0 ignores them, as its spec says.
|
|
299
|
+
*/
|
|
300
|
+
readonly REF_SIBLINGS: "ref-siblings";
|
|
294
301
|
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
295
302
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
296
303
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
@@ -1298,7 +1305,7 @@ interface OpenAPITSBaseOptions {
|
|
|
1298
1305
|
* still fail the run.
|
|
1299
1306
|
*/
|
|
1300
1307
|
lint?: boolean;
|
|
1301
|
-
/** (
|
|
1308
|
+
/** Hide warnings (default: false). Every line of the logger goes to stderr, never to stdout. */
|
|
1302
1309
|
silent?: boolean;
|
|
1303
1310
|
/** Accepted for compatibility with openapi-typescript; not read. */
|
|
1304
1311
|
version?: number;
|
|
@@ -1527,6 +1534,10 @@ declare const ERROR_CODES: {
|
|
|
1527
1534
|
readonly CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING";
|
|
1528
1535
|
readonly CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING";
|
|
1529
1536
|
readonly CLI_INPUT_MISSING: "CLI_INPUT_MISSING";
|
|
1537
|
+
readonly CLI_OUTPUT_IS_INPUT: "CLI_OUTPUT_IS_INPUT";
|
|
1538
|
+
readonly CLI_OUTPUT_DUPLICATE: "CLI_OUTPUT_DUPLICATE";
|
|
1539
|
+
readonly CLI_OUTPUT_INVALID: "CLI_OUTPUT_INVALID";
|
|
1540
|
+
readonly CLI_LOCATION_INVALID: "CLI_LOCATION_INVALID";
|
|
1530
1541
|
readonly OUTPUT_STALE: "OUTPUT_STALE";
|
|
1531
1542
|
readonly OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED";
|
|
1532
1543
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
@@ -1541,12 +1552,15 @@ interface OpenAPITypesafeErrorInit {
|
|
|
1541
1552
|
readonly code: ErrorCode;
|
|
1542
1553
|
readonly message: string;
|
|
1543
1554
|
readonly details?: ErrorDetails;
|
|
1544
|
-
/**
|
|
1555
|
+
/**
|
|
1556
|
+
* The lower-level error this one reports, if any (kept as the standard `cause`; a copy with URL
|
|
1557
|
+
* secrets hidden when its chain names one, see cause-secrets.ts).
|
|
1558
|
+
*/
|
|
1545
1559
|
readonly cause?: unknown;
|
|
1546
1560
|
}
|
|
1547
1561
|
/**
|
|
1548
1562
|
* The base of every expected failure; check `code`, not the class or the message. The message
|
|
1549
|
-
* never
|
|
1563
|
+
* and the `cause` chain never show the user info or the query of a URL (`url-secrets.ts`).
|
|
1550
1564
|
*/
|
|
1551
1565
|
declare class OpenAPITypesafeError extends Error {
|
|
1552
1566
|
readonly code: ErrorCode;
|
|
@@ -1773,7 +1787,11 @@ declare function createDiscriminatorProperty(discriminator: DiscriminatorObject,
|
|
|
1773
1787
|
path: string;
|
|
1774
1788
|
readonly?: boolean;
|
|
1775
1789
|
}): IrPropertySignature;
|
|
1776
|
-
/**
|
|
1790
|
+
/**
|
|
1791
|
+
* Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`
|
|
1792
|
+
* and contributes its decoded segments, so it throws URIError for a malformed percent escape; any
|
|
1793
|
+
* other part is one segment. To append raw document keys, escape each one instead.
|
|
1794
|
+
*/
|
|
1777
1795
|
declare function createRef(parts: (number | string | undefined | null)[]): string;
|
|
1778
1796
|
/**
|
|
1779
1797
|
* Print debug message (cribbed from the `debug` package, but without all the bells & whistles
|
package/dist/index.d.mts
CHANGED
|
@@ -280,6 +280,8 @@ declare const FIX: {
|
|
|
280
280
|
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
281
281
|
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
282
282
|
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
283
|
+
/** A parameter with `content` instead of `schema` is typed by the schema of its media type. */
|
|
284
|
+
readonly PARAMETER_CONTENT: "parameter-content";
|
|
283
285
|
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
284
286
|
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
285
287
|
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
@@ -291,6 +293,11 @@ declare const FIX: {
|
|
|
291
293
|
* points at, also where the original type compiles through an index signature.
|
|
292
294
|
*/
|
|
293
295
|
readonly REF_POINTERS: "ref-pointers";
|
|
296
|
+
/**
|
|
297
|
+
* OpenAPI 3.1 and 3.2: keywords next to a `$ref` (`required`, `properties`) apply too, so the
|
|
298
|
+
* type is the reference intersected with them. OpenAPI 3.0 ignores them, as its spec says.
|
|
299
|
+
*/
|
|
300
|
+
readonly REF_SIBLINGS: "ref-siblings";
|
|
294
301
|
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
295
302
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
296
303
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
@@ -1298,7 +1305,7 @@ interface OpenAPITSBaseOptions {
|
|
|
1298
1305
|
* still fail the run.
|
|
1299
1306
|
*/
|
|
1300
1307
|
lint?: boolean;
|
|
1301
|
-
/** (
|
|
1308
|
+
/** Hide warnings (default: false). Every line of the logger goes to stderr, never to stdout. */
|
|
1302
1309
|
silent?: boolean;
|
|
1303
1310
|
/** Accepted for compatibility with openapi-typescript; not read. */
|
|
1304
1311
|
version?: number;
|
|
@@ -1527,6 +1534,10 @@ declare const ERROR_CODES: {
|
|
|
1527
1534
|
readonly CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING";
|
|
1528
1535
|
readonly CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING";
|
|
1529
1536
|
readonly CLI_INPUT_MISSING: "CLI_INPUT_MISSING";
|
|
1537
|
+
readonly CLI_OUTPUT_IS_INPUT: "CLI_OUTPUT_IS_INPUT";
|
|
1538
|
+
readonly CLI_OUTPUT_DUPLICATE: "CLI_OUTPUT_DUPLICATE";
|
|
1539
|
+
readonly CLI_OUTPUT_INVALID: "CLI_OUTPUT_INVALID";
|
|
1540
|
+
readonly CLI_LOCATION_INVALID: "CLI_LOCATION_INVALID";
|
|
1530
1541
|
readonly OUTPUT_STALE: "OUTPUT_STALE";
|
|
1531
1542
|
readonly OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED";
|
|
1532
1543
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
@@ -1541,12 +1552,15 @@ interface OpenAPITypesafeErrorInit {
|
|
|
1541
1552
|
readonly code: ErrorCode;
|
|
1542
1553
|
readonly message: string;
|
|
1543
1554
|
readonly details?: ErrorDetails;
|
|
1544
|
-
/**
|
|
1555
|
+
/**
|
|
1556
|
+
* The lower-level error this one reports, if any (kept as the standard `cause`; a copy with URL
|
|
1557
|
+
* secrets hidden when its chain names one, see cause-secrets.ts).
|
|
1558
|
+
*/
|
|
1545
1559
|
readonly cause?: unknown;
|
|
1546
1560
|
}
|
|
1547
1561
|
/**
|
|
1548
1562
|
* The base of every expected failure; check `code`, not the class or the message. The message
|
|
1549
|
-
* never
|
|
1563
|
+
* and the `cause` chain never show the user info or the query of a URL (`url-secrets.ts`).
|
|
1550
1564
|
*/
|
|
1551
1565
|
declare class OpenAPITypesafeError extends Error {
|
|
1552
1566
|
readonly code: ErrorCode;
|
|
@@ -1773,7 +1787,11 @@ declare function createDiscriminatorProperty(discriminator: DiscriminatorObject,
|
|
|
1773
1787
|
path: string;
|
|
1774
1788
|
readonly?: boolean;
|
|
1775
1789
|
}): IrPropertySignature;
|
|
1776
|
-
/**
|
|
1790
|
+
/**
|
|
1791
|
+
* Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`
|
|
1792
|
+
* and contributes its decoded segments, so it throws URIError for a malformed percent escape; any
|
|
1793
|
+
* other part is one segment. To append raw document keys, escape each one instead.
|
|
1794
|
+
*/
|
|
1777
1795
|
declare function createRef(parts: (number | string | undefined | null)[]): string;
|
|
1778
1796
|
/**
|
|
1779
1797
|
* Print debug message (cribbed from the `debug` package, but without all the bells & whistles
|
package/dist/index.d.ts
CHANGED
|
@@ -280,6 +280,8 @@ declare const FIX: {
|
|
|
280
280
|
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
281
281
|
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
282
282
|
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
283
|
+
/** A parameter with `content` instead of `schema` is typed by the schema of its media type. */
|
|
284
|
+
readonly PARAMETER_CONTENT: "parameter-content";
|
|
283
285
|
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
284
286
|
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
285
287
|
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
@@ -291,6 +293,11 @@ declare const FIX: {
|
|
|
291
293
|
* points at, also where the original type compiles through an index signature.
|
|
292
294
|
*/
|
|
293
295
|
readonly REF_POINTERS: "ref-pointers";
|
|
296
|
+
/**
|
|
297
|
+
* OpenAPI 3.1 and 3.2: keywords next to a `$ref` (`required`, `properties`) apply too, so the
|
|
298
|
+
* type is the reference intersected with them. OpenAPI 3.0 ignores them, as its spec says.
|
|
299
|
+
*/
|
|
300
|
+
readonly REF_SIBLINGS: "ref-siblings";
|
|
294
301
|
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
295
302
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
296
303
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
@@ -1298,7 +1305,7 @@ interface OpenAPITSBaseOptions {
|
|
|
1298
1305
|
* still fail the run.
|
|
1299
1306
|
*/
|
|
1300
1307
|
lint?: boolean;
|
|
1301
|
-
/** (
|
|
1308
|
+
/** Hide warnings (default: false). Every line of the logger goes to stderr, never to stdout. */
|
|
1302
1309
|
silent?: boolean;
|
|
1303
1310
|
/** Accepted for compatibility with openapi-typescript; not read. */
|
|
1304
1311
|
version?: number;
|
|
@@ -1527,6 +1534,10 @@ declare const ERROR_CODES: {
|
|
|
1527
1534
|
readonly CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING";
|
|
1528
1535
|
readonly CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING";
|
|
1529
1536
|
readonly CLI_INPUT_MISSING: "CLI_INPUT_MISSING";
|
|
1537
|
+
readonly CLI_OUTPUT_IS_INPUT: "CLI_OUTPUT_IS_INPUT";
|
|
1538
|
+
readonly CLI_OUTPUT_DUPLICATE: "CLI_OUTPUT_DUPLICATE";
|
|
1539
|
+
readonly CLI_OUTPUT_INVALID: "CLI_OUTPUT_INVALID";
|
|
1540
|
+
readonly CLI_LOCATION_INVALID: "CLI_LOCATION_INVALID";
|
|
1530
1541
|
readonly OUTPUT_STALE: "OUTPUT_STALE";
|
|
1531
1542
|
readonly OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED";
|
|
1532
1543
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
@@ -1541,12 +1552,15 @@ interface OpenAPITypesafeErrorInit {
|
|
|
1541
1552
|
readonly code: ErrorCode;
|
|
1542
1553
|
readonly message: string;
|
|
1543
1554
|
readonly details?: ErrorDetails;
|
|
1544
|
-
/**
|
|
1555
|
+
/**
|
|
1556
|
+
* The lower-level error this one reports, if any (kept as the standard `cause`; a copy with URL
|
|
1557
|
+
* secrets hidden when its chain names one, see cause-secrets.ts).
|
|
1558
|
+
*/
|
|
1545
1559
|
readonly cause?: unknown;
|
|
1546
1560
|
}
|
|
1547
1561
|
/**
|
|
1548
1562
|
* The base of every expected failure; check `code`, not the class or the message. The message
|
|
1549
|
-
* never
|
|
1563
|
+
* and the `cause` chain never show the user info or the query of a URL (`url-secrets.ts`).
|
|
1550
1564
|
*/
|
|
1551
1565
|
declare class OpenAPITypesafeError extends Error {
|
|
1552
1566
|
readonly code: ErrorCode;
|
|
@@ -1773,7 +1787,11 @@ declare function createDiscriminatorProperty(discriminator: DiscriminatorObject,
|
|
|
1773
1787
|
path: string;
|
|
1774
1788
|
readonly?: boolean;
|
|
1775
1789
|
}): IrPropertySignature;
|
|
1776
|
-
/**
|
|
1790
|
+
/**
|
|
1791
|
+
* Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`
|
|
1792
|
+
* and contributes its decoded segments, so it throws URIError for a malformed percent escape; any
|
|
1793
|
+
* other part is one segment. To append raw document keys, escape each one instead.
|
|
1794
|
+
*/
|
|
1777
1795
|
declare function createRef(parts: (number | string | undefined | null)[]): string;
|
|
1778
1796
|
/**
|
|
1779
1797
|
* Print debug message (cribbed from the `debug` package, but without all the bells & whistles
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-typesafe",
|
|
3
3
|
"description": "Convert OpenAPI 3.0, 3.1 & 3.2 schemas to TypeScript",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Fedor Chishchin",
|
|
7
7
|
"url": "https://github.com/fedorello"
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"./*": "./*"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
|
+
"CHANGELOG.md",
|
|
38
39
|
"bin",
|
|
39
40
|
"dist",
|
|
40
41
|
"src"
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"@typescript/typescript6": "^6.0.0",
|
|
64
|
-
"typescript": ">=5.
|
|
65
|
+
"typescript": ">=5.4.0"
|
|
65
66
|
},
|
|
66
67
|
"peerDependenciesMeta": {
|
|
67
68
|
"@typescript/typescript6": {
|
|
@@ -106,11 +107,9 @@
|
|
|
106
107
|
"lint:ts": "tsc --noEmit && tsc -p tsconfig.strict.json",
|
|
107
108
|
"test": "pnpm run test:js && pnpm run test:examples && pnpm run test:exports",
|
|
108
109
|
"test:js": "vitest run",
|
|
109
|
-
"test:exports": "
|
|
110
|
+
"test:exports": "../../scripts/check-exports.sh",
|
|
110
111
|
"test:examples": "tsc -p tsconfig.examples.json --noEmit",
|
|
111
112
|
"update:examples": "pnpm run build && pnpm run download:schemas && vite-node ./scripts/update-examples.ts",
|
|
112
|
-
"prepublish": "pnpm run build",
|
|
113
|
-
"version": "pnpm run build",
|
|
114
113
|
"lint:deps": "depcruise src --config .dependency-cruiser.cjs",
|
|
115
114
|
"test:coverage": "vitest run --coverage",
|
|
116
115
|
"lint:sizes": "vite-node scripts/size-rules/check-sizes.ts src"
|