openapi-typesafe 1.0.0-rc.3 → 1.0.0-rc.5
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 +1972 -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 +97 -14
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
- package/dist/adapters/node-file-system/node-file-system.mjs +97 -14
- package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +48 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +45 -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/component-schemas.cjs +17 -0
- package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
- package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
- package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
- 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/mapping-schema-names.cjs +22 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs +137 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs +134 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +40 -29
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +38 -27
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +45 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +45 -4
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
- package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.mjs +53 -12
- 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 +40 -9
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -9
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-node-limit.cjs +61 -0
- package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs +58 -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 +18 -9
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.mjs +20 -11
- 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 +10 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +10 -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-refs.cjs +16 -1
- package/dist/api/document-refs.cjs.map +1 -1
- package/dist/api/document-refs.mjs +16 -1
- package/dist/api/document-refs.mjs.map +1 -1
- package/dist/api/document-run.cjs +6 -12
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +6 -12
- 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 +9 -6
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +10 -8
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/ref-limit-options.cjs +63 -0
- package/dist/api/ref-limit-options.cjs.map +1 -0
- package/dist/api/ref-limit-options.mjs +57 -0
- package/dist/api/ref-limit-options.mjs.map +1 -0
- 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 +47 -10
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +48 -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/declared-value-types.cjs +36 -0
- package/dist/application/transform/declared-value-types.cjs.map +1 -0
- package/dist/application/transform/declared-value-types.mjs +34 -0
- package/dist/application/transform/declared-value-types.mjs.map +1 -0
- 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 +7 -2
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +6 -3
- 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/exploded-query-values.cjs +63 -0
- package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
- package/dist/application/transform/document/exploded-query-values.mjs +59 -0
- package/dist/application/transform/document/exploded-query-values.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/header.cjs +11 -3
- package/dist/application/transform/document/header.cjs.map +1 -1
- package/dist/application/transform/document/header.mjs +10 -2
- package/dist/application/transform/document/header.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 +29 -34
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +29 -34
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-item.cjs +15 -17
- package/dist/application/transform/document/path-item.cjs.map +1 -1
- package/dist/application/transform/document/path-item.mjs +15 -19
- package/dist/application/transform/document/path-item.mjs.map +1 -1
- package/dist/application/transform/document/path-template-key.cjs +84 -0
- package/dist/application/transform/document/path-template-key.cjs.map +1 -0
- package/dist/application/transform/document/path-template-key.mjs +79 -0
- package/dist/application/transform/document/path-template-key.mjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.cjs +70 -0
- package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.mjs +67 -0
- package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
- package/dist/application/transform/document/paths-enum.cjs +8 -6
- package/dist/application/transform/document/paths-enum.cjs.map +1 -1
- package/dist/application/transform/document/paths-enum.mjs +8 -7
- package/dist/application/transform/document/paths-enum.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +43 -67
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +42 -68
- 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 +10 -3
- package/dist/application/transform/document/webhooks.cjs.map +1 -1
- package/dist/application/transform/document/webhooks.mjs +10 -3
- package/dist/application/transform/document/webhooks.mjs.map +1 -1
- package/dist/application/transform/footer/document-footer.cjs +16 -5
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +16 -5
- 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 +3 -3
- package/dist/application/transform/helper-types.cjs.map +1 -1
- package/dist/application/transform/helper-types.mjs +3 -3
- 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 +5 -5
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.mjs +3 -3
- package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.cjs +47 -66
- package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.mjs +36 -50
- package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
- package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
- package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
- package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.cjs +68 -13
- package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/original-index.mjs +70 -15
- package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
- package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
- package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/property-shape.cjs +52 -0
- package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs +45 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs +79 -21
- package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/typed-walk.mjs +76 -18
- package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
- package/dist/application/transform/ref-type.cjs +2 -1
- package/dist/application/transform/ref-type.cjs.map +1 -1
- package/dist/application/transform/ref-type.mjs +2 -1
- package/dist/application/transform/ref-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.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/index-signature-type.cjs +21 -0
- package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
- package/dist/application/transform/schema/index-signature-type.mjs +19 -0
- package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
- package/dist/application/transform/schema/input-location.cjs +23 -0
- package/dist/application/transform/schema/input-location.cjs.map +1 -0
- package/dist/application/transform/schema/input-location.mjs +21 -0
- package/dist/application/transform/schema/input-location.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +18 -8
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +19 -9
- 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 +6 -3
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +6 -3
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
- package/dist/application/transform/schema/unevaluated-properties.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-logger.cjs +13 -0
- package/dist/cli/api-logger.cjs.map +1 -0
- package/dist/cli/api-logger.mjs +11 -0
- package/dist/cli/api-logger.mjs.map +1 -0
- package/dist/cli/api-settings.cjs +57 -9
- package/dist/cli/api-settings.cjs.map +1 -1
- package/dist/cli/api-settings.mjs +56 -11
- 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-arguments.cjs +51 -11
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +51 -11
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/cli-errors.cjs +29 -1
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +29 -2
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +111 -4
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +104 -5
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +13 -3
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +14 -4
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +94 -37
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +99 -42
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/ref-limits.cjs +15 -1
- package/dist/cli/ref-limits.cjs.map +1 -1
- package/dist/cli/ref-limits.mjs +15 -2
- package/dist/cli/ref-limits.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +37 -14
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +39 -16
- 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 +52 -0
- package/dist/domain/cause-secrets.cjs.map +1 -0
- package/dist/domain/cause-secrets.mjs +50 -0
- package/dist/domain/cause-secrets.mjs.map +1 -0
- package/dist/domain/errors.cjs +11 -3
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +11 -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/location-text.cjs +9 -0
- package/dist/domain/location-text.cjs.map +1 -0
- package/dist/domain/location-text.mjs +7 -0
- package/dist/domain/location-text.mjs.map +1 -0
- 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/document-places.cjs +55 -0
- package/dist/domain/openapi/document-places.cjs.map +1 -0
- package/dist/domain/openapi/document-places.mjs +53 -0
- package/dist/domain/openapi/document-places.mjs.map +1 -0
- 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 +20 -0
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +20 -0
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/terminal-text.cjs +31 -0
- package/dist/domain/terminal-text.cjs.map +1 -0
- package/dist/domain/terminal-text.mjs +29 -0
- package/dist/domain/terminal-text.mjs.map +1 -0
- package/dist/domain/url-secrets.cjs +48 -0
- package/dist/domain/url-secrets.cjs.map +1 -0
- package/dist/domain/url-secrets.mjs +45 -0
- package/dist/domain/url-secrets.mjs.map +1 -0
- package/dist/domain/warnings.cjs +1 -0
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +1 -0
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.d.cts +46 -20
- package/dist/index.d.mts +46 -20
- package/dist/index.d.ts +46 -20
- 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 +158 -18
- package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
- package/src/adapters/redocly-loader/bundled-mapping-copies.ts +60 -0
- package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
- package/src/adapters/redocly-loader/component-schemas.ts +19 -0
- package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
- package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
- package/src/adapters/redocly-loader/query-named-components.ts +201 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +64 -38
- package/src/adapters/redocly-loader/ref-access.ts +51 -4
- package/src/adapters/redocly-loader/ref-holders.ts +76 -15
- package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +85 -13
- package/src/adapters/redocly-loader/remote-node-limit.ts +102 -0
- package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
- package/src/adapters/redocly-loader/schema-source.ts +35 -11
- package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
- package/src/adapters/terminal-logger/terminal-logger.ts +17 -6
- 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-refs.ts +29 -1
- package/src/api/document-run.ts +10 -19
- package/src/api/legacy-utils.ts +5 -1
- package/src/api/openapi-ts.ts +26 -8
- package/src/api/ref-limit-options.ts +76 -0
- 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 +79 -12
- package/src/application/ports/file-system.ts +47 -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/declared-value-types.ts +42 -0
- 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 +8 -5
- package/src/application/transform/document/enum-names-given-back.ts +91 -0
- package/src/application/transform/document/exploded-query-values.ts +88 -0
- package/src/application/transform/document/global-type-references.ts +1 -1
- package/src/application/transform/document/header.ts +25 -5
- 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 +56 -66
- package/src/application/transform/document/path-item.ts +16 -34
- package/src/application/transform/document/path-template-key.ts +152 -0
- package/src/application/transform/document/path-template-refs.ts +106 -0
- package/src/application/transform/document/paths-enum.ts +24 -10
- package/src/application/transform/document/paths.ts +59 -125
- 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 +19 -6
- package/src/application/transform/footer/document-footer.ts +36 -9
- 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 +8 -7
- package/src/application/transform/numbered-names.ts +15 -0
- package/src/application/transform/ref-pointer/generated-location.ts +3 -3
- package/src/application/transform/ref-pointer/generated-shape.ts +67 -78
- package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
- package/src/application/transform/ref-pointer/located-node.ts +38 -0
- package/src/application/transform/ref-pointer/original-index.ts +100 -17
- package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
- package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
- package/src/application/transform/ref-pointer/property-shape.ts +97 -0
- package/src/application/transform/ref-pointer/typed-walk.ts +117 -25
- package/src/application/transform/ref-type.ts +2 -1
- package/src/application/transform/schema/access-flags.ts +5 -2
- 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/index-signature-type.ts +31 -0
- package/src/application/transform/schema/input-location.ts +35 -0
- package/src/application/transform/schema/object-type.ts +22 -12
- 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 +6 -3
- package/src/application/transform/schema/unevaluated-properties.ts +4 -44
- package/src/application/transform/schema-comment.ts +5 -1
- package/src/application/transform/transform-context.ts +5 -0
- package/src/cli/api-logger.ts +17 -0
- package/src/cli/api-settings.ts +80 -13
- package/src/cli/api-writes.ts +117 -0
- package/src/cli/cli-arguments.ts +90 -14
- package/src/cli/cli-dependencies.ts +26 -4
- package/src/cli/cli-errors.ts +42 -1
- package/src/cli/cli-output.ts +195 -15
- package/src/cli/main.ts +14 -5
- package/src/cli/redocly-apis.ts +177 -52
- package/src/cli/ref-limits.ts +21 -2
- package/src/cli/run-cli.ts +76 -15
- package/src/domain/append-all.ts +10 -0
- package/src/domain/cause-secrets.ts +86 -0
- package/src/domain/errors.ts +16 -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/location-text.ts +12 -0
- 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/document-places.ts +78 -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 +28 -2
- package/src/domain/terminal-text.ts +44 -0
- package/src/domain/url-secrets.ts +72 -0
- package/src/domain/warnings.ts +1 -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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The identity of a file path, also of one that does not exist yet (an output before the first
|
|
5
|
+
* run). Two paths are one file when their keys are equal: the real path of the nearest existing
|
|
6
|
+
* ancestor (links resolved, letter case as stored on disk) followed by the segments that do not
|
|
7
|
+
* exist yet, compared in the letter case rules of the file system that will hold them. Equal keys
|
|
8
|
+
* prove one file; different keys do not prove two (Unicode normalization, full case folding):
|
|
9
|
+
* the CLI claims every output before writing to decide those (ADR-043, decision 1).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** A device and a file number: one file, also through a hard link. */
|
|
13
|
+
export interface FileNumber {
|
|
14
|
+
readonly device: bigint;
|
|
15
|
+
readonly file: bigint;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The file-system queries the identity needs; Node's `fs` in production, a fake in tests. */
|
|
19
|
+
export interface PathQueries {
|
|
20
|
+
/** The file number of a path, following links; undefined when it cannot be read. */
|
|
21
|
+
status(filePath: string): FileNumber | undefined;
|
|
22
|
+
/** The path with every link resolved, in the letter case stored on disk. */
|
|
23
|
+
realPath(filePath: string): string;
|
|
24
|
+
/** The names in a directory; empty when it cannot be listed. */
|
|
25
|
+
entries(directory: string): readonly string[];
|
|
26
|
+
/** The target of a symbolic link as written in it; undefined for a path that is no link. */
|
|
27
|
+
linkTarget(filePath: string): string | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The most links followed for one path. Linux follows at most 40 (MAXSYMLINKS) and macOS 32
|
|
32
|
+
* before it fails with ELOOP; a longer chain is a loop, and the path is taken as missing.
|
|
33
|
+
*/
|
|
34
|
+
const MAX_LINK_HOPS = 40;
|
|
35
|
+
|
|
36
|
+
/** Whether two file numbers name one file. */
|
|
37
|
+
export function isSameFileNumber(left: FileNumber, right: FileNumber): boolean {
|
|
38
|
+
// Some file systems (FAT, some network shares) report no file number: 0 then proves nothing.
|
|
39
|
+
return left.file !== 0n && left.file === right.file && left.device === right.device;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function hasLetters(text: string): boolean {
|
|
43
|
+
return text.toLowerCase() !== text.toUpperCase();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function flipCase(text: string): string {
|
|
47
|
+
return [...text]
|
|
48
|
+
.map((character) => {
|
|
49
|
+
const upper = character.toUpperCase();
|
|
50
|
+
return character === upper ? character.toLowerCase() : upper;
|
|
51
|
+
})
|
|
52
|
+
.join("");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Whether a directory entry is also found under its name in the other letter case. */
|
|
56
|
+
function isFoundInOtherCase(entryPath: string, queries: PathQueries): boolean | undefined {
|
|
57
|
+
const status = queries.status(entryPath);
|
|
58
|
+
if (!status) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const flipped = path.join(path.dirname(entryPath), flipCase(path.basename(entryPath)));
|
|
62
|
+
const flippedStatus = queries.status(flipped);
|
|
63
|
+
return flippedStatus !== undefined && isSameFileNumber(status, flippedStatus);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether new names in `directory` ignore letter case. It is asked of the file system, not
|
|
68
|
+
* assumed from the OS: macOS and Windows volumes can be case-sensitive, and Linux mounts can
|
|
69
|
+
* ignore case. An entry of the directory is looked up in the other case; without one with
|
|
70
|
+
* letters, the directory itself is. With nothing to look up, names are taken as case-sensitive.
|
|
71
|
+
*/
|
|
72
|
+
function ignoresCase(directory: string, queries: PathQueries): boolean {
|
|
73
|
+
const candidates = [
|
|
74
|
+
...queries
|
|
75
|
+
.entries(directory)
|
|
76
|
+
.filter(hasLetters)
|
|
77
|
+
.map((name) => path.join(directory, name)),
|
|
78
|
+
...(hasLetters(path.basename(directory)) ? [directory] : []),
|
|
79
|
+
];
|
|
80
|
+
for (const candidate of candidates) {
|
|
81
|
+
const answer = isFoundInOtherCase(candidate, queries);
|
|
82
|
+
if (answer !== undefined) {
|
|
83
|
+
return answer;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The nearest ancestor of `filePath` that exists (or the path itself), and the rest below it. A
|
|
91
|
+
* link to a missing file or directory is followed to its target, which a write would create: so
|
|
92
|
+
* `link/x.ts` with `link -> missing` is `missing/x.ts`. A relative target is read from the real
|
|
93
|
+
* directory of the link, as the system does: with `a -> real/sub` and
|
|
94
|
+
* `real/sub/link -> ../missing`, `a/link` is `real/missing`, not `missing`.
|
|
95
|
+
*/
|
|
96
|
+
function nearestExisting(filePath: string, queries: PathQueries): [string, string[]] {
|
|
97
|
+
const missing: string[] = [];
|
|
98
|
+
let current = path.resolve(filePath);
|
|
99
|
+
let hops = 0;
|
|
100
|
+
while (queries.status(current) === undefined) {
|
|
101
|
+
const target = hops < MAX_LINK_HOPS ? queries.linkTarget(current) : undefined;
|
|
102
|
+
if (target !== undefined) {
|
|
103
|
+
current = path.resolve(queries.realPath(path.dirname(current)), target);
|
|
104
|
+
hops += 1;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const parent = path.dirname(current);
|
|
108
|
+
if (parent === current) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
missing.unshift(path.basename(current));
|
|
112
|
+
current = parent;
|
|
113
|
+
}
|
|
114
|
+
return [current, missing];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The path that a write to `filePath` creates, with links followed also where their target is
|
|
119
|
+
* missing: `link/x.ts` with `link -> missing` is the real path of `missing/x.ts`. `mkdir` does not
|
|
120
|
+
* follow a link to a missing directory on Linux and Windows, so the directories are created here.
|
|
121
|
+
*/
|
|
122
|
+
export function creationPath(filePath: string, queries: PathQueries): string {
|
|
123
|
+
const [existing, missing] = nearestExisting(filePath, queries);
|
|
124
|
+
return path.join(queries.realPath(existing), ...missing);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The key of a path: equal keys are one file, whether or not it exists yet. */
|
|
128
|
+
export function fileIdentityKey(filePath: string, queries: PathQueries): string {
|
|
129
|
+
const [existing, missing] = nearestExisting(filePath, queries);
|
|
130
|
+
const realExisting = queries.realPath(existing);
|
|
131
|
+
if (missing.length === 0) {
|
|
132
|
+
return realExisting;
|
|
133
|
+
}
|
|
134
|
+
const isCaseIgnored = ignoresCase(realExisting, queries);
|
|
135
|
+
const rest = isCaseIgnored ? missing.map((segment) => segment.toLowerCase()) : missing;
|
|
136
|
+
return path.join(realExisting, ...rest);
|
|
137
|
+
}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
ClaimedFile,
|
|
5
|
+
DirectoryCheck,
|
|
6
|
+
FileCheck,
|
|
7
|
+
FileClaims,
|
|
8
|
+
FileIdentity,
|
|
9
|
+
FileReader,
|
|
10
|
+
FileWriter,
|
|
11
|
+
} from "../../application/ports/file-system.js";
|
|
12
|
+
import { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from "../../domain/errors.js";
|
|
13
|
+
import { claimFileAt, writeFileAt } from "./file-claims.js";
|
|
14
|
+
import {
|
|
15
|
+
type FileNumber,
|
|
16
|
+
fileIdentityKey,
|
|
17
|
+
isSameFileNumber,
|
|
18
|
+
type PathQueries,
|
|
19
|
+
} from "./file-identity.js";
|
|
5
20
|
|
|
6
21
|
/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */
|
|
7
22
|
|
|
@@ -9,36 +24,161 @@ function causeMessage(cause: unknown): string {
|
|
|
9
24
|
return cause instanceof Error ? cause.message : String(cause);
|
|
10
25
|
}
|
|
11
26
|
|
|
12
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The file number of a path, or undefined when it cannot be read. A missing output is the common
|
|
29
|
+
* case; any other failure (no access, a file used as a directory) is reported by the read or write
|
|
30
|
+
* that follows, so the identity check does not report it a second time.
|
|
31
|
+
*/
|
|
32
|
+
function statusOf(filePath: string): FileNumber | undefined {
|
|
33
|
+
try {
|
|
34
|
+
const status = fs.statSync(filePath, { bigint: true });
|
|
35
|
+
return { device: status.dev, file: status.ino };
|
|
36
|
+
} catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The native `realpath` resolves symbolic links and returns the letter case stored on disk, which
|
|
43
|
+
* the JavaScript one does not do on a case-insensitive file system. A path that vanished since its
|
|
44
|
+
* status was read keeps its own spelling.
|
|
45
|
+
*/
|
|
46
|
+
function realPathOf(filePath: string): string {
|
|
47
|
+
try {
|
|
48
|
+
return fs.realpathSync.native(filePath);
|
|
49
|
+
} catch {
|
|
50
|
+
return filePath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** A directory that cannot be listed has no entry to tell its letter case rules by. */
|
|
55
|
+
function entriesOf(directory: string): readonly string[] {
|
|
56
|
+
try {
|
|
57
|
+
return fs.readdirSync(directory);
|
|
58
|
+
} catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The target of a symbolic link, as written in it; undefined for a path that is no link or cannot
|
|
65
|
+
* be read. The key then treats the path as missing, and the claim at write time decides.
|
|
66
|
+
*/
|
|
67
|
+
function linkTargetOf(filePath: string): string | undefined {
|
|
68
|
+
try {
|
|
69
|
+
return fs.readlinkSync(filePath);
|
|
70
|
+
} catch {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const NODE_PATH_QUERIES: PathQueries = {
|
|
76
|
+
status: statusOf,
|
|
77
|
+
realPath: realPathOf,
|
|
78
|
+
entries: entriesOf,
|
|
79
|
+
linkTarget: linkTargetOf,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */
|
|
83
|
+
function localPathOf(file: URL): string | undefined {
|
|
84
|
+
try {
|
|
85
|
+
return fileURLToPath(file);
|
|
86
|
+
} catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A failed read or write as a typed error. The location is named by its path, or by the URL when
|
|
93
|
+
* it names no local file: computing the path must not throw a second, untyped error here.
|
|
94
|
+
*/
|
|
95
|
+
function fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {
|
|
96
|
+
const name = localPathOf(file) ?? file.href;
|
|
97
|
+
return new OpenAPITypesafeError({
|
|
98
|
+
code,
|
|
99
|
+
message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,
|
|
100
|
+
details: { file: name },
|
|
101
|
+
cause,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */
|
|
106
|
+
function typedWrite<T>(file: URL, step: () => T): T {
|
|
107
|
+
try {
|
|
108
|
+
return step();
|
|
109
|
+
} catch (cause) {
|
|
110
|
+
throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, "write", file, cause);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class NodeFileSystem
|
|
115
|
+
implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileCheck, FileClaims
|
|
116
|
+
{
|
|
13
117
|
readText(file: URL): string {
|
|
14
118
|
try {
|
|
15
119
|
return fs.readFileSync(file, "utf8");
|
|
16
120
|
} catch (cause) {
|
|
17
|
-
throw
|
|
18
|
-
code: ERROR_CODES.OUTPUT_READ_FAILED,
|
|
19
|
-
message: `Cannot read ${fileURLToPath(file)}: ${causeMessage(cause)}`,
|
|
20
|
-
details: { file: fileURLToPath(file) },
|
|
21
|
-
cause,
|
|
22
|
-
});
|
|
121
|
+
throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, "read", file, cause);
|
|
23
122
|
}
|
|
24
123
|
}
|
|
25
124
|
|
|
26
125
|
writeText(file: URL, contents: string): void {
|
|
27
126
|
try {
|
|
28
|
-
|
|
29
|
-
fs.writeFileSync(file, contents, "utf8");
|
|
127
|
+
writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);
|
|
30
128
|
} catch (cause) {
|
|
31
|
-
throw
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
129
|
+
throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, "write", file, cause);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
claimFile(file: URL): ClaimedFile {
|
|
134
|
+
const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));
|
|
135
|
+
return {
|
|
136
|
+
identity: claim.identity,
|
|
137
|
+
release: () => typedWrite(file, () => claim.release()),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
isDirectory(file: URL): boolean {
|
|
142
|
+
try {
|
|
143
|
+
return fs.statSync(file).isDirectory();
|
|
144
|
+
} catch {
|
|
145
|
+
// Missing or unreadable: not a directory; the write that follows reports a failure.
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
isFile(file: URL): boolean {
|
|
151
|
+
try {
|
|
152
|
+
return fs.statSync(file).isFile();
|
|
153
|
+
} catch {
|
|
154
|
+
// Missing or unreadable: no file; the read that follows reports a failure.
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
isSameFile(left: URL, right: URL): boolean {
|
|
160
|
+
const leftPath = fileURLToPath(left);
|
|
161
|
+
const rightPath = fileURLToPath(right);
|
|
162
|
+
if (leftPath === rightPath) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
const leftStatus = statusOf(leftPath);
|
|
166
|
+
const rightStatus = statusOf(rightPath);
|
|
167
|
+
if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {
|
|
168
|
+
return true;
|
|
37
169
|
}
|
|
170
|
+
return (
|
|
171
|
+
fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)
|
|
172
|
+
);
|
|
38
173
|
}
|
|
39
174
|
}
|
|
40
175
|
|
|
41
176
|
/** File access for the CLI. */
|
|
42
|
-
export function createNodeFileSystem(): FileReader &
|
|
177
|
+
export function createNodeFileSystem(): FileReader &
|
|
178
|
+
FileWriter &
|
|
179
|
+
FileIdentity &
|
|
180
|
+
DirectoryCheck &
|
|
181
|
+
FileCheck &
|
|
182
|
+
FileClaims {
|
|
43
183
|
return new NodeFileSystem();
|
|
44
184
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Writable } from "node:stream";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A writer for the CLI's stdout that stops when the reader closes the pipe (`| head`): the write
|
|
5
|
+
* fails with `EPIPE`, which Node raises as an unhandled `error` event and a crash with exit code
|
|
6
|
+
* 1. The reader has all it wanted, so the rest is dropped and the run ends as it would have.
|
|
7
|
+
* Every other write error is thrown again, as before.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const BROKEN_PIPE = "EPIPE";
|
|
11
|
+
|
|
12
|
+
function isBrokenPipe(error: Error): boolean {
|
|
13
|
+
return (error as NodeJS.ErrnoException).code === BROKEN_PIPE;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The text writer of the stream. After `EPIPE` the stream is destroyed, so later writes are
|
|
18
|
+
* dropped by the stream itself and raise no second error.
|
|
19
|
+
*/
|
|
20
|
+
export function createPipeSafeWriter(stream: Writable): (text: string) => void {
|
|
21
|
+
stream.on("error", (error: Error) => {
|
|
22
|
+
if (!isBrokenPipe(error)) {
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return (text) => {
|
|
27
|
+
stream.write(text);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { childPointer } from "../../domain/openapi/json-pointer.js";
|
|
2
|
+
import { type ComponentSchemas, componentSchemasOf, SCHEMAS_POINTER } from "./component-schemas.js";
|
|
3
|
+
import { findMappings, findRefHolders } from "./ref-holders.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it
|
|
7
|
+
* stores the target schema under the raw last segment of the pointer. For a local schema whose
|
|
8
|
+
* key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing
|
|
9
|
+
* key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and
|
|
10
|
+
* `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it
|
|
11
|
+
* copies, so a key the bundle added whose value is the value of a key the document had is removed,
|
|
12
|
+
* and the mapping values and `$ref`s that name it point at the original.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */
|
|
16
|
+
export function schemaKeysOf(document: unknown): ReadonlySet<string> {
|
|
17
|
+
return new Set(Object.keys(componentSchemasOf(document) ?? {}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Each key the bundle added as a copy, with the pointer of the schema it copies. */
|
|
21
|
+
function copiesIn(schemas: ComponentSchemas, keysBefore: ReadonlySet<string>): Map<string, string> {
|
|
22
|
+
const originals = new Map<unknown, string>();
|
|
23
|
+
for (const key of keysBefore) {
|
|
24
|
+
if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {
|
|
25
|
+
originals.set(schemas[key], key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const copies = new Map<string, string>();
|
|
29
|
+
for (const [key, value] of Object.entries(schemas)) {
|
|
30
|
+
const original = keysBefore.has(key) ? undefined : originals.get(value);
|
|
31
|
+
if (original !== undefined) {
|
|
32
|
+
copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));
|
|
33
|
+
delete schemas[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return copies;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Remove the bundle's copies of the document's own schemas, in place. */
|
|
40
|
+
export function removeBundledMappingCopies(
|
|
41
|
+
bundled: unknown,
|
|
42
|
+
keysBefore: ReadonlySet<string>,
|
|
43
|
+
): void {
|
|
44
|
+
const schemas = componentSchemasOf(bundled);
|
|
45
|
+
const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);
|
|
46
|
+
if (copies.size === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
for (const mapping of findMappings(bundled)) {
|
|
50
|
+
for (const [name, value] of Object.entries(mapping)) {
|
|
51
|
+
const original = typeof value === "string" ? copies.get(value) : undefined;
|
|
52
|
+
if (original !== undefined) {
|
|
53
|
+
mapping[name] = original;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const { node } of findRefHolders(bundled)) {
|
|
58
|
+
node.$ref = copies.get(node.$ref) ?? node.$ref;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { childPointer, parseRefPointer, ROOT_POINTER } from "../../domain/openapi/json-pointer.js";
|
|
2
2
|
import { findRefHolders } from "./ref-holders.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -48,7 +48,7 @@ function repairedRef(document: unknown, ref: string): string | null {
|
|
|
48
48
|
if (!resolves(document, raw)) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return raw.reduce((pointer, key) => childPointer(pointer, key), ROOT_POINTER);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/** Repair the local `$ref`s of a bundled document in place, as Redocly's bundle edits it. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { childPointer, ROOT_POINTER } from "../../domain/openapi/json-pointer.js";
|
|
2
|
+
|
|
3
|
+
/** `components.schemas` of a parsed document, which the loader repairs in place. */
|
|
4
|
+
|
|
5
|
+
export type ComponentSchemas = Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
/** `#/components/schemas`. */
|
|
8
|
+
export const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, "components"), "schemas");
|
|
9
|
+
|
|
10
|
+
function isContainer(value: unknown): value is Record<string, unknown> {
|
|
11
|
+
return typeof value === "object" && value !== null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The `components.schemas` object of a document, when it has one. */
|
|
15
|
+
export function componentSchemasOf(document: unknown): ComponentSchemas | undefined {
|
|
16
|
+
const components = isContainer(document) ? document.components : undefined;
|
|
17
|
+
const schemas = isContainer(components) ? components.schemas : undefined;
|
|
18
|
+
return isContainer(schemas) ? schemas : undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import type { BaseResolver, Document } from "@redocly/openapi-core";
|
|
4
|
+
import type { LoadedDocument } from "./unsupported-keys.js";
|
|
5
|
+
|
|
6
|
+
/** The documents one load read, from the Redocly resolver's cache. */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The root document and every other document the resolver loaded, as far as they parsed. A root
|
|
10
|
+
* read from a file or URL is in the resolver cache too, and is listed once. A `$ref` that failed
|
|
11
|
+
* to load leaves a rejected entry in the cache, also when bundling did not need it (an example's
|
|
12
|
+
* `$ref`): that entry is no document, and must not fail the listing.
|
|
13
|
+
*/
|
|
14
|
+
export async function loadedDocuments(
|
|
15
|
+
root: Document,
|
|
16
|
+
resolver: BaseResolver,
|
|
17
|
+
): Promise<LoadedDocument[]> {
|
|
18
|
+
const settled = await Promise.allSettled(resolver.cache.values());
|
|
19
|
+
const cached = settled.flatMap((entry) => (entry.status === "fulfilled" ? [entry.value] : []));
|
|
20
|
+
const bySource = new Map<string, unknown>([[root.source.absoluteRef, root.parsed]]);
|
|
21
|
+
for (const document of cached) {
|
|
22
|
+
if ("parsed" in document && !bySource.has(document.source.absoluteRef)) {
|
|
23
|
+
bySource.set(document.source.absoluteRef, document.parsed);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return [...bySource].map(([source, parsed]) => ({ source, parsed }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The local files the load read: the root, when it is a file, and every `$ref`'d file. Redocly
|
|
31
|
+
* names a local document by its absolute path and a remote one by its URL. An inline root (a
|
|
32
|
+
* string, object, buffer or stream) has a made-up path in the working directory, so it is left
|
|
33
|
+
* out unless it was read from a file.
|
|
34
|
+
*/
|
|
35
|
+
export async function localFilesRead(
|
|
36
|
+
root: Document,
|
|
37
|
+
resolver: BaseResolver,
|
|
38
|
+
isRootAFile: boolean,
|
|
39
|
+
): Promise<URL[]> {
|
|
40
|
+
const documents = await loadedDocuments(root, resolver);
|
|
41
|
+
return documents
|
|
42
|
+
.map(({ source }) => source)
|
|
43
|
+
.filter((source) => path.isAbsolute(source))
|
|
44
|
+
.filter((source) => isRootAFile || source !== root.source.absoluteRef)
|
|
45
|
+
.map((source) => pathToFileURL(source));
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { childPointer } from "../../domain/openapi/json-pointer.js";
|
|
2
|
+
import { componentSchemasOf, SCHEMAS_POINTER } from "./component-schemas.js";
|
|
3
|
+
import { findMappings } from "./ref-holders.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A discriminator `mapping` value may be a schema name (`cat: Cat`) or a URI reference. Redocly
|
|
7
|
+
* reads every value as a `$ref`, so a name failed with "Can't resolve $ref". OpenAPI 3.1.1
|
|
8
|
+
* (§4.8.25) leaves a value that is both to the implementation and recommends the schema name; a
|
|
9
|
+
* relative URI is then written `./Cat`. So a value that is a key of the document's
|
|
10
|
+
* `components.schemas` becomes the pointer to that schema, in place, before the `$ref`s are
|
|
11
|
+
* resolved. Any other value stays a URI reference.
|
|
12
|
+
*/
|
|
13
|
+
export function pointMappingNamesAtSchemas(document: unknown): void {
|
|
14
|
+
const schemas = componentSchemasOf(document);
|
|
15
|
+
if (schemas === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
for (const mapping of findMappings(document)) {
|
|
19
|
+
for (const [name, value] of Object.entries(mapping)) {
|
|
20
|
+
if (typeof value === "string" && Object.hasOwn(schemas, value)) {
|
|
21
|
+
mapping[name] = childPointer(SCHEMAS_POINTER, value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|