openapi-typesafe 1.0.0-rc.4 → 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 +141 -0
- package/dist/adapters/node-file-system/node-file-system.cjs +7 -0
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
- package/dist/adapters/node-file-system/node-file-system.mjs +7 -0
- 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 +5 -32
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -1
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +6 -33
- package/dist/adapters/redocly-loader/bundled-mapping-copies.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/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 +26 -14
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +26 -14
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +16 -3
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +16 -3
- 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 +52 -11
- package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.cjs +5 -3
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +5 -3
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-node-limit.cjs +17 -3
- package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-node-limit.mjs +17 -3
- package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.cjs +7 -2
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.mjs +8 -3
- package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +7 -3
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +7 -3
- package/dist/adapters/terminal-logger/terminal-logger.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 +4 -10
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +4 -10
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +1 -2
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +2 -3
- 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/transform-schema.cjs +12 -5
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +12 -5
- package/dist/api/transform-schema.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/document.cjs +3 -1
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +3 -1
- package/dist/application/transform/document/document.mjs.map +1 -1
- 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/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/parameter.cjs +1 -1
- package/dist/application/transform/document/parameter.cjs.map +1 -1
- package/dist/application/transform/document/parameter.mjs +1 -1
- package/dist/application/transform/document/parameter.mjs.map +1 -1
- package/dist/application/transform/document/parameters.cjs +23 -5
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +23 -5
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-item.cjs +4 -3
- package/dist/application/transform/document/path-item.cjs.map +1 -1
- package/dist/application/transform/document/path-item.mjs +4 -4
- 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 +7 -6
- package/dist/application/transform/document/paths-enum.cjs.map +1 -1
- package/dist/application/transform/document/paths-enum.mjs +7 -6
- package/dist/application/transform/document/paths-enum.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +38 -66
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +36 -66
- package/dist/application/transform/document/paths.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 +9 -2
- package/dist/application/transform/document/webhooks.mjs.map +1 -1
- package/dist/application/transform/footer/document-footer.cjs +6 -3
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +6 -3
- package/dist/application/transform/footer/document-footer.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/ref-pointer/generated-location.cjs +4 -4
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.mjs +1 -1
- 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/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.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 +15 -5
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +15 -5
- package/dist/application/transform/schema/object-type.mjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.cjs +2 -1
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +2 -1
- 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/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 +7 -15
- package/dist/cli/api-settings.cjs.map +1 -1
- package/dist/cli/api-settings.mjs +8 -16
- package/dist/cli/api-settings.mjs.map +1 -1
- 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 +17 -0
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +17 -1
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +6 -4
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +7 -5
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +10 -4
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +10 -4
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +20 -9
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +22 -11
- 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 +24 -7
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +25 -8
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/cause-secrets.cjs +31 -16
- package/dist/domain/cause-secrets.cjs.map +1 -1
- package/dist/domain/cause-secrets.mjs +31 -16
- package/dist/domain/cause-secrets.mjs.map +1 -1
- package/dist/domain/errors.cjs +2 -0
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +2 -0
- package/dist/domain/errors.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/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/output-fixes.cjs +8 -2
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +8 -2
- 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/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 +26 -18
- package/dist/index.d.mts +26 -18
- package/dist/index.d.ts +26 -18
- package/package.json +1 -1
- package/src/adapters/node-file-system/node-file-system.ts +14 -1
- package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
- package/src/adapters/redocly-loader/bundled-mapping-copies.ts +7 -42
- package/src/adapters/redocly-loader/component-schemas.ts +19 -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 +46 -14
- package/src/adapters/redocly-loader/ref-access.ts +16 -3
- package/src/adapters/redocly-loader/ref-holders.ts +75 -14
- package/src/adapters/redocly-loader/remote-fetch.ts +11 -2
- package/src/adapters/redocly-loader/remote-node-limit.ts +44 -4
- package/src/adapters/redocly-loader/schema-source.ts +15 -3
- package/src/adapters/terminal-logger/terminal-logger.ts +10 -4
- package/src/api/document-refs.ts +29 -1
- package/src/api/document-run.ts +6 -16
- package/src/api/openapi-ts.ts +6 -3
- package/src/api/ref-limit-options.ts +76 -0
- package/src/api/transform-schema.ts +20 -5
- package/src/application/ports/file-system.ts +8 -0
- package/src/application/transform/declared-value-types.ts +42 -0
- package/src/application/transform/document/document.ts +4 -2
- package/src/application/transform/document/exploded-query-values.ts +88 -0
- package/src/application/transform/document/header.ts +25 -5
- package/src/application/transform/document/parameter.ts +4 -4
- package/src/application/transform/document/parameters.ts +45 -10
- package/src/application/transform/document/path-item.ts +3 -3
- 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 +23 -9
- package/src/application/transform/document/paths.ts +53 -123
- package/src/application/transform/document/webhooks.ts +18 -5
- package/src/application/transform/footer/document-footer.ts +18 -8
- package/src/application/transform/helper-types.ts +4 -4
- package/src/application/transform/ref-pointer/generated-location.ts +1 -1
- 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/schema/access-flags.ts +5 -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 +18 -8
- package/src/application/transform/schema/schema-transform.ts +2 -1
- package/src/application/transform/schema/unevaluated-properties.ts +4 -44
- package/src/cli/api-logger.ts +17 -0
- package/src/cli/api-settings.ts +12 -20
- package/src/cli/cli-arguments.ts +90 -14
- package/src/cli/cli-dependencies.ts +7 -2
- package/src/cli/cli-errors.ts +22 -0
- package/src/cli/cli-output.ts +11 -10
- package/src/cli/main.ts +10 -4
- package/src/cli/redocly-apis.ts +37 -17
- package/src/cli/ref-limits.ts +21 -2
- package/src/cli/run-cli.ts +39 -7
- package/src/domain/cause-secrets.ts +59 -25
- package/src/domain/errors.ts +2 -0
- package/src/domain/location-text.ts +12 -0
- package/src/domain/openapi/document-places.ts +78 -0
- package/src/domain/output-fixes.ts +9 -2
- package/src/domain/terminal-text.ts +44 -0
- package/src/domain/warnings.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,147 @@
|
|
|
2
2
|
|
|
3
3
|
This package is a fork of `openapi-typescript`. The entries above `7.13.0` are releases of openapi-typesafe; `7.13.0` and the entries below it are the upstream history up to the fork point (upstream commit `d46a319a`), with `openapi-typescript` versions.
|
|
4
4
|
|
|
5
|
+
## 1.0.0-rc.5
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - With several APIs in `redocly.yaml`, an error while an API is loaded or generated starts with
|
|
10
|
+
`API <name>:`, as its config errors do, so it tells which API failed. The code and the exit code
|
|
11
|
+
stay the same. Every warning, problem and debug line of an API's generation (a `$ref` it cannot
|
|
12
|
+
resolve, a lint problem) starts with `API <name>:` too. A notice that a root-types flag has no
|
|
13
|
+
effect follows the CLI flags together with each API's settings and names the API, and an invalid
|
|
14
|
+
`--local-ref-root` fails the run once instead of once for each API.
|
|
15
|
+
|
|
16
|
+
- [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - Types piped to a reader that stops early (`openapi-typesafe api.yaml | head`) no longer crash the
|
|
17
|
+
CLI with `EPIPE` and exit code `1`; the rest is dropped and the exit code stays `0`.
|
|
18
|
+
|
|
19
|
+
- [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - CLI flags are read by their names:
|
|
20
|
+
- A removed flag fails with `CLI_FLAG_REMOVED` written with a value too (`--redoc=redocly.yaml`),
|
|
21
|
+
in camelCase (`--immutableTypes`) and with `--no-` (`--no-immutable-types`).
|
|
22
|
+
- The boolean alias `-t` (`--export-type`) takes `=true` and `=false` as the flag does; another
|
|
23
|
+
value fails with `CLI_FLAG_INVALID`.
|
|
24
|
+
- A boolean flag takes no value, or `=true` or `=false`. Another value (`--enum=1`,
|
|
25
|
+
`--no-enum=true`) fails with `CLI_FLAG_INVALID` (exit code `2`) instead of turning the flag off.
|
|
26
|
+
- A flag given more than once takes the last value; `--output` and `--redocly` no longer fail with
|
|
27
|
+
a list.
|
|
28
|
+
- The notice that a root-types flag has no effect without `--root-types` follows the parsed flags:
|
|
29
|
+
`--rootTypes` and `--root-types=true` count, `--root-types=false` does not.
|
|
30
|
+
|
|
31
|
+
- [#76](https://github.com/openapi-typesafe/openapi-typesafe/pull/76) [`e464bc3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e464bc3c9dcb243a4259307d6b667bde134d8468) Thanks [@fedorello](https://github.com/fedorello)! - A schema argument is a glob pattern, which fails with `CLI_GLOB_UNSUPPORTED`, only when it is a
|
|
32
|
+
path with a `*` that names no file. A URL with a `*` in its query (`…/openapi?fields=*`) and an
|
|
33
|
+
existing file whose name has a `*` are read as any other schema.
|
|
34
|
+
|
|
35
|
+
- [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - `--output` together with the APIs of `redocly.yaml` warns with `CLI_OUTPUT_IGNORED`: each API is
|
|
36
|
+
written to its `x-openapi-ts.output`, and the `--output` path was ignored without a word.
|
|
37
|
+
|
|
38
|
+
- [#76](https://github.com/openapi-typesafe/openapi-typesafe/pull/76) [`e464bc3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e464bc3c9dcb243a4259307d6b667bde134d8468) Thanks [@fedorello](https://github.com/fedorello)! - The line for a written file and the notices about flags show a line break or an escape sequence in
|
|
39
|
+
a file name, a flag or an API name as an escape (`\n`, `\u001b`), as warnings and errors already
|
|
40
|
+
do, so a name cannot start a forged line in a CI log.
|
|
41
|
+
|
|
42
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `const: null` is typed `null`; it was `unknown`, as if the schema had no `const`.
|
|
43
|
+
|
|
44
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--enum --dedupe-enums` no longer merges enums with other values. Their key joined the member
|
|
45
|
+
names and descriptions as text, and a member name stood in for its value, so `Flag` (`1`, `0`)
|
|
46
|
+
became the `Status` enum (`"A"`, `"I"`) when both named their members `Active` and `Inactive`, and
|
|
47
|
+
`["1", "2"]` and `[1, 2]`, or `["a", "b"]` and `["a:,b"]`, shared one enum. The key also paired
|
|
48
|
+
the values in sorted order with the names in document order, so `[desc, asc]` and `[asc, desc]`,
|
|
49
|
+
both named `[Desc, Asc]`, shared one enum and one of them typed `asc` as `Desc = "desc"`. Enums
|
|
50
|
+
with the same values and member names are still merged.
|
|
51
|
+
|
|
52
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - The new fix `default-input-locations` finds parameters and request bodies by the document's
|
|
53
|
+
structure for `--default-non-nullable` (on by default). Without it, as in openapi-typescript, a
|
|
54
|
+
defaulted property stays optional wherever its location holds the word `parameters` or
|
|
55
|
+
`requestBody`, such as a response of `/system-parameters` or a property named `hyperparameters`.
|
|
56
|
+
It changes nothing with `--default-non-nullable=false`, so naming it then prints the warning
|
|
57
|
+
`FIX_NEEDS_OPTION`, as other fixes that need a flag do (`--fix all` does not).
|
|
58
|
+
|
|
59
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - With `--exclude-deprecated`, a `$ref` to a property it leaves out
|
|
60
|
+
(`#/components/schemas/A/properties/old`) is typed as that property's schema, instead of naming a
|
|
61
|
+
key the type no longer has. The same holds for a `$ref` into a deprecated operation or response
|
|
62
|
+
header, and a `$ref` through another `$ref` (`Wrap/properties/o/properties/v`, where `o` is a
|
|
63
|
+
`$ref`) no longer warns `REF_NOT_FOUND`. With `--make-paths-enum`, `ApiPaths` lists only the
|
|
64
|
+
operations that `paths` keeps.
|
|
65
|
+
|
|
66
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--fix exploded-query-objects`: an exploded object with `additionalProperties` next to other query
|
|
67
|
+
parameters no longer makes the whole `query` type unusable. Its index signature also takes the
|
|
68
|
+
value types of the other query keys (`{ page?: number } & Partial<{ [key: string]: string | number
|
|
69
|
+
| undefined }>`), since TypeScript checks it against `page` too. A `$ref` to such an object is
|
|
70
|
+
written out in place when other query keys are next to it.
|
|
71
|
+
|
|
72
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - An index signature from `additionalProperties` or `patternProperties` also takes the types of the
|
|
73
|
+
properties next to it that it does not admit (`{ total: number } & { [key: string]: string |
|
|
74
|
+
number }`). TypeScript checks the signature against the declared keys too, so the old type took no
|
|
75
|
+
value with those properties.
|
|
76
|
+
|
|
77
|
+
- [#76](https://github.com/openapi-typesafe/openapi-typesafe/pull/76) [`e464bc3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e464bc3c9dcb243a4259307d6b667bde134d8468) Thanks [@fedorello](https://github.com/fedorello)! - A YAML parse error of a string source or a stream (stdin in the CLI) names it `the schema string`
|
|
78
|
+
or `the schema stream`. It named `<cwd>/inline-source`, a file that does not exist.
|
|
79
|
+
|
|
80
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - A discriminator `mapping` value that names a schema (`cat: Cat`), as OpenAPI allows, is read as
|
|
81
|
+
`#/components/schemas/Cat`, also in a document a `$ref` loads, where it names that document's
|
|
82
|
+
schemas. It failed with "Can't resolve $ref"; any other value is still a URI reference. A `mapping`
|
|
83
|
+
inside `example`, `examples`, `default`, `const`, `enum` or an `x-` value is data and stays as
|
|
84
|
+
written. A problem in a document other than the root now names that document: its path, or its URL
|
|
85
|
+
without the query.
|
|
86
|
+
|
|
87
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - The `parameter-content` fix is now `parameter-header-content` and types a response header with
|
|
88
|
+
`content` by the schema of its media type too (`"X-Rate": { limit: number }`), not as a map of
|
|
89
|
+
media types. Configs that name `parameter-content` fail with `OPTION_FIX_UNKNOWN` until renamed.
|
|
90
|
+
|
|
91
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--path-params-as-types` with only `boolean` path parameters in a path compiles:
|
|
92
|
+
``[path: `/flags/${boolean}`]`` is no valid index signature (TS1337), so such a path is written as
|
|
93
|
+
the keys `"/flags/true"` and `"/flags/false"`, with the same path item type (2ⁿ keys for n boolean
|
|
94
|
+
parameters). A key that the document already has as a path is left out. Next to another parameter
|
|
95
|
+
(`` `/a/${number}/${boolean}` ``) the signature is valid and stays as it was.
|
|
96
|
+
|
|
97
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--path-params-as-types`: a `$ref` into a path with a `number` or `boolean` path parameter
|
|
98
|
+
compiles. It was typed as `paths["/pets/{id}"]`, which names no key of
|
|
99
|
+
``[path: `/pets/${number}`]`` (TS2339); it is now ``paths[`/pets/${number}`]``. A boolean path
|
|
100
|
+
is indexed by the keys it is written with (`paths["/flags/true" | "/flags/false"]`), without the
|
|
101
|
+
one a path of the document takes, so the `$ref` no longer gets that path's type too. With only
|
|
102
|
+
string parameters the URL matches the template, so that output stays as it was.
|
|
103
|
+
|
|
104
|
+
- [#75](https://github.com/openapi-typesafe/openapi-typesafe/pull/75) [`a74608e`](https://github.com/openapi-typesafe/openapi-typesafe/commit/a74608ec36b0a938594e0d0fac10c9fb222c1742) Thanks [@fedorello](https://github.com/fedorello)! - `Readable` and `Writable` find the `$Read` and `$Write` properties of an object with an index
|
|
105
|
+
signature (`additionalProperties`). The keys were read through the index signature, so no
|
|
106
|
+
property was marked: a request body required the `readOnly` `id`, and a response kept the
|
|
107
|
+
`writeOnly` password. The helper types that `--read-write-markers` writes are fixed the same way.
|
|
108
|
+
|
|
109
|
+
- [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - The `$ref` limits are checked before anything loads:
|
|
110
|
+
- In the Node API, a `remoteRefHosts` that is no list of strings, or a `localRefRoot` that is no
|
|
111
|
+
path or `file:` URL, fails with `OPTION_INVALID` and `details.option`. It failed later as an error
|
|
112
|
+
of the document, such as `hosts.map is not a function`.
|
|
113
|
+
- `--local-ref-root https://…` fails with `CLI_FLAG_INVALID` (exit code `2`) instead of exit code
|
|
114
|
+
`3`, and a `local-ref-root` URL of another protocol in `redocly.yaml` with `CLI_CONFIG_INVALID`.
|
|
115
|
+
- In the Node API, a `localRefRoot` string with a scheme is a URL, as for `--local-ref-root`:
|
|
116
|
+
`"file:///specs/"` is that directory, not a path below `cwd`, and `"https://…"` fails with
|
|
117
|
+
`OPTION_INVALID`.
|
|
118
|
+
|
|
119
|
+
- [#75](https://github.com/openapi-typesafe/openapi-typesafe/pull/75) [`a74608e`](https://github.com/openapi-typesafe/openapi-typesafe/commit/a74608ec36b0a938594e0d0fac10c9fb222c1742) Thanks [@fedorello](https://github.com/fedorello)! - More `$ref`s into a schema compile and get the type they point at:
|
|
120
|
+
- A `$ref` into the `content` of a header or parameter follows the generated type: the media type
|
|
121
|
+
member of a header (`components["headers"]["H"]["text/plain"]`), or with the
|
|
122
|
+
`parameter-header-content` fix the media type's type itself. A parameter typed `string` and
|
|
123
|
+
`content` next to a `schema` are typed in place. Before, `["content"]["text/plain"]["schema"]`
|
|
124
|
+
did not compile (TS2339).
|
|
125
|
+
- With `--read-write-markers`, a `$ref` through an optional property gets `NonNullable` as
|
|
126
|
+
without the flag; one through a `$Read` or `$Write` property is typed in place.
|
|
127
|
+
- A `$ref` through a property with a `default` that the output makes optional (in a request body,
|
|
128
|
+
or under a property named `hyperparameters`) gets `NonNullable`: the property is read as
|
|
129
|
+
optional or required by where it is, not where the `$ref` is.
|
|
130
|
+
|
|
131
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--fix ref-siblings` also reads the keywords next to the `$ref` of an object property
|
|
132
|
+
(`owner: { $ref: Base, required: [id] }` is `WithRequired<Base, "id">`); it read them only for
|
|
133
|
+
components, array items, bodies and parameters.
|
|
134
|
+
|
|
135
|
+
- [#66](https://github.com/openapi-typesafe/openapi-typesafe/pull/66) [`15344bf`](https://github.com/openapi-typesafe/openapi-typesafe/commit/15344bfb803ff9872a6d3f79b8279fbbbbfd14ea) Thanks [@fedorello](https://github.com/fedorello)! - A remote `$ref` to a document served as `text/plain` loads when its URL has a query after the
|
|
136
|
+
extension (`pet.yaml?token=…`), no extension at all (`/schemas/pet`) or a dot that names no text
|
|
137
|
+
format (`/schemas/v1.0`, `/schemas/pet.v2`); before, it was kept as text and failed with
|
|
138
|
+
`Expected SchemaObject, received string`. A URL whose extension or type names a text format
|
|
139
|
+
(`.md`, `.markdown`, `.txt`, `.html`, `.htm`, `text/markdown`, `text/html`) stays text, as a
|
|
140
|
+
Markdown `description` does.
|
|
141
|
+
|
|
142
|
+
- [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - A webhook that is a `$ref` (often to `components/pathItems`) is typed as the path item it points
|
|
143
|
+
at, as a `$ref` in `paths` is: `petAdded: components["pathItems"]["PetEvent"]`. Every method of
|
|
144
|
+
such a webhook was `never`.
|
|
145
|
+
|
|
5
146
|
## 1.0.0-rc.4
|
|
6
147
|
|
|
7
148
|
### Minor Changes
|
|
@@ -100,6 +100,13 @@ class NodeFileSystem {
|
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
isFile(file) {
|
|
104
|
+
try {
|
|
105
|
+
return fs__default.statSync(file).isFile();
|
|
106
|
+
} catch {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
103
110
|
isSameFile(left, right) {
|
|
104
111
|
const leftPath = node_url.fileURLToPath(left);
|
|
105
112
|
const rightPath = node_url.fileURLToPath(right);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-file-system.cjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem
|
|
1
|
+
{"version":3,"file":"node-file-system.cjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem\n implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileCheck, FileClaims\n{\n readText(file: URL): string {\n try {\n return fs.readFileSync(file, \"utf8\");\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, \"read\", file, cause);\n }\n }\n\n writeText(file: URL, contents: string): void {\n try {\n writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n }\n\n claimFile(file: URL): ClaimedFile {\n const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));\n return {\n identity: claim.identity,\n release: () => typedWrite(file, () => claim.release()),\n };\n }\n\n isDirectory(file: URL): boolean {\n try {\n return fs.statSync(file).isDirectory();\n } catch {\n // Missing or unreadable: not a directory; the write that follows reports a failure.\n return false;\n }\n }\n\n isFile(file: URL): boolean {\n try {\n return fs.statSync(file).isFile();\n } catch {\n // Missing or unreadable: no file; the read that follows reports a failure.\n return false;\n }\n }\n\n isSameFile(left: URL, right: URL): boolean {\n const leftPath = fileURLToPath(left);\n const rightPath = fileURLToPath(right);\n if (leftPath === rightPath) {\n return true;\n }\n const leftStatus = statusOf(leftPath);\n const rightStatus = statusOf(rightPath);\n if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {\n return true;\n }\n return (\n fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)\n );\n }\n}\n\n/** File access for the CLI. */\nexport function createNodeFileSystem(): FileReader &\n FileWriter &\n FileIdentity &\n DirectoryCheck &\n FileCheck &\n FileClaims {\n return new NodeFileSystem();\n}\n"],"names":["fs","fileURLToPath","OpenAPITypesafeError","ERROR_CODES","writeFileAt","claimFileAt","isSameFileNumber","fileIdentityKey"],"mappings":";;;;;;;;;;;;AAsBA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAC9D;AAOA,SAAS,SA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
}
|
|
96
96
|
}
|
|
97
|
+
isFile(file) {
|
|
98
|
+
try {
|
|
99
|
+
return fs.statSync(file).isFile();
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
97
104
|
isSameFile(left, right) {
|
|
98
105
|
const leftPath = fileURLToPath(left);
|
|
99
106
|
const rightPath = fileURLToPath(right);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-file-system.mjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem
|
|
1
|
+
{"version":3,"file":"node-file-system.mjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem\n implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileCheck, FileClaims\n{\n readText(file: URL): string {\n try {\n return fs.readFileSync(file, \"utf8\");\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, \"read\", file, cause);\n }\n }\n\n writeText(file: URL, contents: string): void {\n try {\n writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n }\n\n claimFile(file: URL): ClaimedFile {\n const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));\n return {\n identity: claim.identity,\n release: () => typedWrite(file, () => claim.release()),\n };\n }\n\n isDirectory(file: URL): boolean {\n try {\n return fs.statSync(file).isDirectory();\n } catch {\n // Missing or unreadable: not a directory; the write that follows reports a failure.\n return false;\n }\n }\n\n isFile(file: URL): boolean {\n try {\n return fs.statSync(file).isFile();\n } catch {\n // Missing or unreadable: no file; the read that follows reports a failure.\n return false;\n }\n }\n\n isSameFile(left: URL, right: URL): boolean {\n const leftPath = fileURLToPath(left);\n const rightPath = fileURLToPath(right);\n if (leftPath === rightPath) {\n return true;\n }\n const leftStatus = statusOf(leftPath);\n const rightStatus = statusOf(rightPath);\n if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {\n return true;\n }\n return (\n fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)\n );\n }\n}\n\n/** File access for the CLI. */\nexport function createNodeFileSystem(): FileReader &\n FileWriter &\n FileIdentity &\n DirectoryCheck &\n FileCheck &\n FileClaims {\n return new NodeFileSystem();\n}\n"],"names":[],"mappings":";;;;;;AAsBA,SAAS,aAAa,K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AAe;AAC5B;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const BROKEN_PIPE = "EPIPE";
|
|
4
|
+
function isBrokenPipe(error) {
|
|
5
|
+
return error.code === BROKEN_PIPE;
|
|
6
|
+
}
|
|
7
|
+
function createPipeSafeWriter(stream) {
|
|
8
|
+
stream.on("error", (error) => {
|
|
9
|
+
if (!isBrokenPipe(error)) {
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return (text) => {
|
|
14
|
+
stream.write(text);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.createPipeSafeWriter = createPipeSafeWriter;
|
|
19
|
+
//# sourceMappingURL=pipe-safe-writer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-safe-writer.cjs","sources":["../../../src/adapters/pipe-safe-writer/pipe-safe-writer.ts"],"sourcesContent":["import type { Writable } from \"node:stream\";\n\n/**\n * A writer for the CLI's stdout that stops when the reader closes the pipe (`| head`): the write\n * fails with `EPIPE`, which Node raises as an unhandled `error` event and a crash with exit code\n * 1. The reader has all it wanted, so the rest is dropped and the run ends as it would have.\n * Every other write error is thrown again, as before.\n */\n\nconst BROKEN_PIPE = \"EPIPE\";\n\nfunction isBrokenPipe(error: Error): boolean {\n return (error as NodeJS.ErrnoException).code === BROKEN_PIPE;\n}\n\n/**\n * The text writer of the stream. After `EPIPE` the stream is destroyed, so later writes are\n * dropped by the stream itself and raise no second error.\n */\nexport function createPipeSafeWriter(stream: Writable): (text: string) => void {\n stream.on(\"error\", (error: Error) => {\n if (!isBrokenPipe(error)) {\n throw error;\n }\n });\n return (text) => {\n stream.write(text);\n };\n}\n"],"names":[],"mappings":";;AASA,MAAM,WAAA,GAAc,OAAA;AAEpB,SAAS,aAAa,KAAA,EAAuB;AAC3C,EAAA,OAAQ,MAAgC,IAAA,KAAS,WAAA;AACnD;AAMO,SAAS,qBAAqB,MAAA,EAA0C;AAC7E,EAAA,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,CAAC,KAAA,KAAiB;AACnC,IAAA,IAAI,CAAC,YAAA,CAAa,KAAK,CAAA,EAAG;AACxB,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,CAAC,IAAA,KAAS;AACf,IAAA,MAAA,CAAO,MAAM,IAAI,CAAA;AAAA,EACnB,CAAA;AACF;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const BROKEN_PIPE = "EPIPE";
|
|
2
|
+
function isBrokenPipe(error) {
|
|
3
|
+
return error.code === BROKEN_PIPE;
|
|
4
|
+
}
|
|
5
|
+
function createPipeSafeWriter(stream) {
|
|
6
|
+
stream.on("error", (error) => {
|
|
7
|
+
if (!isBrokenPipe(error)) {
|
|
8
|
+
throw error;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return (text) => {
|
|
12
|
+
stream.write(text);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { createPipeSafeWriter };
|
|
17
|
+
//# sourceMappingURL=pipe-safe-writer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-safe-writer.mjs","sources":["../../../src/adapters/pipe-safe-writer/pipe-safe-writer.ts"],"sourcesContent":["import type { Writable } from \"node:stream\";\n\n/**\n * A writer for the CLI's stdout that stops when the reader closes the pipe (`| head`): the write\n * fails with `EPIPE`, which Node raises as an unhandled `error` event and a crash with exit code\n * 1. The reader has all it wanted, so the rest is dropped and the run ends as it would have.\n * Every other write error is thrown again, as before.\n */\n\nconst BROKEN_PIPE = \"EPIPE\";\n\nfunction isBrokenPipe(error: Error): boolean {\n return (error as NodeJS.ErrnoException).code === BROKEN_PIPE;\n}\n\n/**\n * The text writer of the stream. After `EPIPE` the stream is destroyed, so later writes are\n * dropped by the stream itself and raise no second error.\n */\nexport function createPipeSafeWriter(stream: Writable): (text: string) => void {\n stream.on(\"error\", (error: Error) => {\n if (!isBrokenPipe(error)) {\n throw error;\n }\n });\n return (text) => {\n stream.write(text);\n };\n}\n"],"names":[],"mappings":"AASA,MAAM,WAAA,GAAc,OAAA;AAEpB,SAAS,aAAa,KAAA,EAAuB;AAC3C,EAAA,OAAQ,MAAgC,IAAA,KAAS,WAAA;AACnD;AAMO,SAAS,qBAAqB,MAAA,EAA0C;AAC7E,EAAA,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,CAAC,KAAA,KAAiB;AACnC,IAAA,IAAI,CAAC,YAAA,CAAa,KAAK,CAAA,EAAG;AACxB,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,CAAC,IAAA,KAAS;AACf,IAAA,MAAA,CAAO,MAAM,IAAI,CAAA;AAAA,EACnB,CAAA;AACF;;"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const jsonPointer = require('../../domain/openapi/json-pointer.cjs');
|
|
4
|
+
const componentSchemas = require('./component-schemas.cjs');
|
|
4
5
|
const refHolders = require('./ref-holders.cjs');
|
|
5
6
|
|
|
6
|
-
const SCHEMAS_POINTER = jsonPointer.childPointer(jsonPointer.childPointer(jsonPointer.ROOT_POINTER, "components"), "schemas");
|
|
7
|
-
function isContainer(value) {
|
|
8
|
-
return typeof value === "object" && value !== null;
|
|
9
|
-
}
|
|
10
|
-
function schemasOf(document) {
|
|
11
|
-
const components = isContainer(document) ? document.components : void 0;
|
|
12
|
-
const schemas = isContainer(components) ? components.schemas : void 0;
|
|
13
|
-
return isContainer(schemas) ? schemas : void 0;
|
|
14
|
-
}
|
|
15
7
|
function schemaKeysOf(document) {
|
|
16
|
-
return new Set(Object.keys(
|
|
8
|
+
return new Set(Object.keys(componentSchemas.componentSchemasOf(document) ?? {}));
|
|
17
9
|
}
|
|
18
10
|
function copiesIn(schemas, keysBefore) {
|
|
19
11
|
const originals = /* @__PURE__ */ new Map();
|
|
@@ -26,38 +18,19 @@ function copiesIn(schemas, keysBefore) {
|
|
|
26
18
|
for (const [key, value] of Object.entries(schemas)) {
|
|
27
19
|
const original = keysBefore.has(key) ? void 0 : originals.get(value);
|
|
28
20
|
if (original !== void 0) {
|
|
29
|
-
copies.set(`${SCHEMAS_POINTER}/${key}`, jsonPointer.childPointer(SCHEMAS_POINTER, original));
|
|
21
|
+
copies.set(`${componentSchemas.SCHEMAS_POINTER}/${key}`, jsonPointer.childPointer(componentSchemas.SCHEMAS_POINTER, original));
|
|
30
22
|
delete schemas[key];
|
|
31
23
|
}
|
|
32
24
|
}
|
|
33
25
|
return copies;
|
|
34
26
|
}
|
|
35
|
-
function mappingsOf(document) {
|
|
36
|
-
const mappings = [];
|
|
37
|
-
const visited = /* @__PURE__ */ new WeakSet();
|
|
38
|
-
const pending = [document];
|
|
39
|
-
for (let next = pending.pop(); next !== void 0; next = pending.pop()) {
|
|
40
|
-
if (!isContainer(next) || visited.has(next)) {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
visited.add(next);
|
|
44
|
-
const mapping = isContainer(next.discriminator) ? next.discriminator.mapping : void 0;
|
|
45
|
-
if (isContainer(mapping)) {
|
|
46
|
-
mappings.push(mapping);
|
|
47
|
-
}
|
|
48
|
-
for (const child of Object.values(next)) {
|
|
49
|
-
pending.push(child);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return mappings;
|
|
53
|
-
}
|
|
54
27
|
function removeBundledMappingCopies(bundled, keysBefore) {
|
|
55
|
-
const schemas =
|
|
28
|
+
const schemas = componentSchemas.componentSchemasOf(bundled);
|
|
56
29
|
const copies = schemas === void 0 ? /* @__PURE__ */ new Map() : copiesIn(schemas, keysBefore);
|
|
57
30
|
if (copies.size === 0) {
|
|
58
31
|
return;
|
|
59
32
|
}
|
|
60
|
-
for (const mapping of
|
|
33
|
+
for (const mapping of refHolders.findMappings(bundled)) {
|
|
61
34
|
for (const [name, value] of Object.entries(mapping)) {
|
|
62
35
|
const original = typeof value === "string" ? copies.get(value) : void 0;
|
|
63
36
|
if (original !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundled-mapping-copies.cjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer
|
|
1
|
+
{"version":3,"file":"bundled-mapping-copies.cjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer } from \"../../domain/openapi/json-pointer.js\";\nimport { type ComponentSchemas, componentSchemasOf, SCHEMAS_POINTER } from \"./component-schemas.js\";\nimport { findMappings, findRefHolders } from \"./ref-holders.js\";\n\n/**\n * Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it\n * stores the target schema under the raw last segment of the pointer. For a local schema whose\n * key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing\n * key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and\n * `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it\n * copies, so a key the bundle added whose value is the value of a key the document had is removed,\n * and the mapping values and `$ref`s that name it point at the original.\n */\n\n/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */\nexport function schemaKeysOf(document: unknown): ReadonlySet<string> {\n return new Set(Object.keys(componentSchemasOf(document) ?? {}));\n}\n\n/** Each key the bundle added as a copy, with the pointer of the schema it copies. */\nfunction copiesIn(schemas: ComponentSchemas, keysBefore: ReadonlySet<string>): Map<string, string> {\n const originals = new Map<unknown, string>();\n for (const key of keysBefore) {\n if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {\n originals.set(schemas[key], key);\n }\n }\n const copies = new Map<string, string>();\n for (const [key, value] of Object.entries(schemas)) {\n const original = keysBefore.has(key) ? undefined : originals.get(value);\n if (original !== undefined) {\n copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));\n delete schemas[key];\n }\n }\n return copies;\n}\n\n/** Remove the bundle's copies of the document's own schemas, in place. */\nexport function removeBundledMappingCopies(\n bundled: unknown,\n keysBefore: ReadonlySet<string>,\n): void {\n const schemas = componentSchemasOf(bundled);\n const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);\n if (copies.size === 0) {\n return;\n }\n for (const mapping of findMappings(bundled)) {\n for (const [name, value] of Object.entries(mapping)) {\n const original = typeof value === \"string\" ? copies.get(value) : undefined;\n if (original !== undefined) {\n mapping[name] = original;\n }\n }\n }\n for (const { node } of findRefHolders(bundled)) {\n node.$ref = copies.get(node.$ref) ?? node.$ref;\n }\n}\n"],"names":["componentSchemasOf","SCHEMAS_POINTER","childPointer","findMappings","findRefHolders"],"mappings":";;;;;;AAeO,SAAS,aAAa,QAAA,EAAwC;AACnE,EAAA,OAAO,IAAI,IAAI,MAAA,CAAO,IAAA,CAAKA,oCAAmB,QAAQ,CAAA,IAAK,EAAE,CAAC,CAAA;AAChE;AAGA,SAAS,QAAA,CAAS,SAA2B,UAAA,EAAsD;AACjG,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAqB;AAC3C,EAAA,KAAA,MAAW,OAAO,UAAA,EAAY;AAC5B,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,GAAG,CAAA,IAAK,CAAC,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAC,CAAA,EAAG;AAC/D,MAAA,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA,EAAG,GAAG,CAAA;AAAA,IACjC;AAAA,EACF;AACA,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAoB;AACvC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,IAAA,MAAM,QAAA,GAAW,WAAW,GAAA,CAAI,GAAG,IAAI,MAAA,GAAY,SAAA,CAAU,IA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.mjs';
|
|
2
|
+
import { componentSchemasOf, SCHEMAS_POINTER } from './component-schemas.mjs';
|
|
3
|
+
import { findMappings, findRefHolders } from './ref-holders.mjs';
|
|
3
4
|
|
|
4
|
-
const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, "components"), "schemas");
|
|
5
|
-
function isContainer(value) {
|
|
6
|
-
return typeof value === "object" && value !== null;
|
|
7
|
-
}
|
|
8
|
-
function schemasOf(document) {
|
|
9
|
-
const components = isContainer(document) ? document.components : void 0;
|
|
10
|
-
const schemas = isContainer(components) ? components.schemas : void 0;
|
|
11
|
-
return isContainer(schemas) ? schemas : void 0;
|
|
12
|
-
}
|
|
13
5
|
function schemaKeysOf(document) {
|
|
14
|
-
return new Set(Object.keys(
|
|
6
|
+
return new Set(Object.keys(componentSchemasOf(document) ?? {}));
|
|
15
7
|
}
|
|
16
8
|
function copiesIn(schemas, keysBefore) {
|
|
17
9
|
const originals = /* @__PURE__ */ new Map();
|
|
@@ -30,32 +22,13 @@ function copiesIn(schemas, keysBefore) {
|
|
|
30
22
|
}
|
|
31
23
|
return copies;
|
|
32
24
|
}
|
|
33
|
-
function mappingsOf(document) {
|
|
34
|
-
const mappings = [];
|
|
35
|
-
const visited = /* @__PURE__ */ new WeakSet();
|
|
36
|
-
const pending = [document];
|
|
37
|
-
for (let next = pending.pop(); next !== void 0; next = pending.pop()) {
|
|
38
|
-
if (!isContainer(next) || visited.has(next)) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
visited.add(next);
|
|
42
|
-
const mapping = isContainer(next.discriminator) ? next.discriminator.mapping : void 0;
|
|
43
|
-
if (isContainer(mapping)) {
|
|
44
|
-
mappings.push(mapping);
|
|
45
|
-
}
|
|
46
|
-
for (const child of Object.values(next)) {
|
|
47
|
-
pending.push(child);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return mappings;
|
|
51
|
-
}
|
|
52
25
|
function removeBundledMappingCopies(bundled, keysBefore) {
|
|
53
|
-
const schemas =
|
|
26
|
+
const schemas = componentSchemasOf(bundled);
|
|
54
27
|
const copies = schemas === void 0 ? /* @__PURE__ */ new Map() : copiesIn(schemas, keysBefore);
|
|
55
28
|
if (copies.size === 0) {
|
|
56
29
|
return;
|
|
57
30
|
}
|
|
58
|
-
for (const mapping of
|
|
31
|
+
for (const mapping of findMappings(bundled)) {
|
|
59
32
|
for (const [name, value] of Object.entries(mapping)) {
|
|
60
33
|
const original = typeof value === "string" ? copies.get(value) : void 0;
|
|
61
34
|
if (original !== void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundled-mapping-copies.mjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer
|
|
1
|
+
{"version":3,"file":"bundled-mapping-copies.mjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer } from \"../../domain/openapi/json-pointer.js\";\nimport { type ComponentSchemas, componentSchemasOf, SCHEMAS_POINTER } from \"./component-schemas.js\";\nimport { findMappings, findRefHolders } from \"./ref-holders.js\";\n\n/**\n * Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it\n * stores the target schema under the raw last segment of the pointer. For a local schema whose\n * key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing\n * key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and\n * `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it\n * copies, so a key the bundle added whose value is the value of a key the document had is removed,\n * and the mapping values and `$ref`s that name it point at the original.\n */\n\n/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */\nexport function schemaKeysOf(document: unknown): ReadonlySet<string> {\n return new Set(Object.keys(componentSchemasOf(document) ?? {}));\n}\n\n/** Each key the bundle added as a copy, with the pointer of the schema it copies. */\nfunction copiesIn(schemas: ComponentSchemas, keysBefore: ReadonlySet<string>): Map<string, string> {\n const originals = new Map<unknown, string>();\n for (const key of keysBefore) {\n if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {\n originals.set(schemas[key], key);\n }\n }\n const copies = new Map<string, string>();\n for (const [key, value] of Object.entries(schemas)) {\n const original = keysBefore.has(key) ? undefined : originals.get(value);\n if (original !== undefined) {\n copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));\n delete schemas[key];\n }\n }\n return copies;\n}\n\n/** Remove the bundle's copies of the document's own schemas, in place. */\nexport function removeBundledMappingCopies(\n bundled: unknown,\n keysBefore: ReadonlySet<string>,\n): void {\n const schemas = componentSchemasOf(bundled);\n const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);\n if (copies.size === 0) {\n return;\n }\n for (const mapping of findMappings(bundled)) {\n for (const [name, value] of Object.entries(mapping)) {\n const original = typeof value === \"string\" ? copies.get(value) : undefined;\n if (original !== undefined) {\n mapping[name] = original;\n }\n }\n }\n for (const { node } of findRefHolders(bundled)) {\n node.$ref = copies.get(node.$ref) ?? node.$ref;\n }\n}\n"],"names":[],"mappings":";;;;AAeO,SAAS,aAAa,QAAA,EAAwC;AACnE,EAAA,OAAO,IAAI,IAAI,MAAA,CAAO,IAAA,CAAK,mBAAmB,QAAQ,CAAA,IAAK,EAAE,CAAC,CAAA;AAChE;AAGA,SAAS,QAAA,CAAS,SAA2B,UAAA,EAAsD;AACjG,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAqB;AAC3C,EAAA,KAAA,MAAW,OAAO,UAAA,EAAY;AAC5B,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,GAAG,CAAA,IAAK,CAAC,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAC,CAAA,EAAG;AAC/D,MAAA,SAAA,CAAU,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA,EAAG,GAAG,CAAA;AAAA,IACjC;AAAA,EACF;AACA,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAoB;AACvC,EAAA,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K,IAAI,KAAK,IAAA,CAAK,IAAA;AAAA,EAC5C;AACF;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsonPointer = require('../../domain/openapi/json-pointer.cjs');
|
|
4
|
+
|
|
5
|
+
const SCHEMAS_POINTER = jsonPointer.childPointer(jsonPointer.childPointer(jsonPointer.ROOT_POINTER, "components"), "schemas");
|
|
6
|
+
function isContainer(value) {
|
|
7
|
+
return typeof value === "object" && value !== null;
|
|
8
|
+
}
|
|
9
|
+
function componentSchemasOf(document) {
|
|
10
|
+
const components = isContainer(document) ? document.components : void 0;
|
|
11
|
+
const schemas = isContainer(components) ? components.schemas : void 0;
|
|
12
|
+
return isContainer(schemas) ? schemas : void 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.SCHEMAS_POINTER = SCHEMAS_POINTER;
|
|
16
|
+
exports.componentSchemasOf = componentSchemasOf;
|
|
17
|
+
//# sourceMappingURL=component-schemas.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-schemas.cjs","sources":["../../../src/adapters/redocly-loader/component-schemas.ts"],"sourcesContent":["import { childPointer, ROOT_POINTER } from \"../../domain/openapi/json-pointer.js\";\n\n/** `components.schemas` of a parsed document, which the loader repairs in place. */\n\nexport type ComponentSchemas = Record<string, unknown>;\n\n/** `#/components/schemas`. */\nexport const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, \"components\"), \"schemas\");\n\nfunction isContainer(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n/** The `components.schemas` object of a document, when it has one. */\nexport function componentSchemasOf(document: unknown): ComponentSchemas | undefined {\n const components = isContainer(document) ? document.components : undefined;\n const schemas = isContainer(components) ? components.schemas : undefined;\n return isContainer(schemas) ? schemas : undefined;\n}\n"],"names":["childPointer","ROOT_POINTER"],"mappings":";;;;AAOO,MAAM,kBAAkBA,wBAAA,CAAaA,wBAAA,CAAaC,wBAAA,EAAc,YAAY,GAAG,SAAS;AAE/F,SAAS,YAAY,KAAA,EAAkD;AACrE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAGO,SAAS,mBAAmB,QAAA,EAAiD;AAClF,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,QAAQ,CAAA,GAAI,SAAS,UAAA,GAAa,MAAA;AACjE,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,UAAU,CAAA,GAAI,WAAW,OAAA,GAAU,MAAA;AAC/D,EAAA,OAAO,WAAA,CAAY,OAAO,CAAA,GAAI,OAAA,GAAU,MAAA;AAC1C;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { childPointer, ROOT_POINTER } from '../../domain/openapi/json-pointer.mjs';
|
|
2
|
+
|
|
3
|
+
const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, "components"), "schemas");
|
|
4
|
+
function isContainer(value) {
|
|
5
|
+
return typeof value === "object" && value !== null;
|
|
6
|
+
}
|
|
7
|
+
function componentSchemasOf(document) {
|
|
8
|
+
const components = isContainer(document) ? document.components : void 0;
|
|
9
|
+
const schemas = isContainer(components) ? components.schemas : void 0;
|
|
10
|
+
return isContainer(schemas) ? schemas : void 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { SCHEMAS_POINTER, componentSchemasOf };
|
|
14
|
+
//# sourceMappingURL=component-schemas.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-schemas.mjs","sources":["../../../src/adapters/redocly-loader/component-schemas.ts"],"sourcesContent":["import { childPointer, ROOT_POINTER } from \"../../domain/openapi/json-pointer.js\";\n\n/** `components.schemas` of a parsed document, which the loader repairs in place. */\n\nexport type ComponentSchemas = Record<string, unknown>;\n\n/** `#/components/schemas`. */\nexport const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, \"components\"), \"schemas\");\n\nfunction isContainer(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n/** The `components.schemas` object of a document, when it has one. */\nexport function componentSchemasOf(document: unknown): ComponentSchemas | undefined {\n const components = isContainer(document) ? document.components : undefined;\n const schemas = isContainer(components) ? components.schemas : undefined;\n return isContainer(schemas) ? schemas : undefined;\n}\n"],"names":[],"mappings":";;AAOO,MAAM,kBAAkB,YAAA,CAAa,YAAA,CAAa,YAAA,EAAc,YAAY,GAAG,SAAS;AAE/F,SAAS,YAAY,KAAA,EAAkD;AACrE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAGO,SAAS,mBAAmB,QAAA,EAAiD;AAClF,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,QAAQ,CAAA,GAAI,SAAS,UAAA,GAAa,MAAA;AACjE,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,UAAU,CAAA,GAAI,WAAW,OAAA,GAAU,MAAA;AAC/D,EAAA,OAAO,WAAA,CAAY,OAAO,CAAA,GAAI,OAAA,GAAU,MAAA;AAC1C;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsonPointer = require('../../domain/openapi/json-pointer.cjs');
|
|
4
|
+
const componentSchemas = require('./component-schemas.cjs');
|
|
5
|
+
const refHolders = require('./ref-holders.cjs');
|
|
6
|
+
|
|
7
|
+
function pointMappingNamesAtSchemas(document) {
|
|
8
|
+
const schemas = componentSchemas.componentSchemasOf(document);
|
|
9
|
+
if (schemas === void 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
for (const mapping of refHolders.findMappings(document)) {
|
|
13
|
+
for (const [name, value] of Object.entries(mapping)) {
|
|
14
|
+
if (typeof value === "string" && Object.hasOwn(schemas, value)) {
|
|
15
|
+
mapping[name] = jsonPointer.childPointer(componentSchemas.SCHEMAS_POINTER, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.pointMappingNamesAtSchemas = pointMappingNamesAtSchemas;
|
|
22
|
+
//# sourceMappingURL=mapping-schema-names.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping-schema-names.cjs","sources":["../../../src/adapters/redocly-loader/mapping-schema-names.ts"],"sourcesContent":["import { childPointer } from \"../../domain/openapi/json-pointer.js\";\nimport { componentSchemasOf, SCHEMAS_POINTER } from \"./component-schemas.js\";\nimport { findMappings } from \"./ref-holders.js\";\n\n/**\n * A discriminator `mapping` value may be a schema name (`cat: Cat`) or a URI reference. Redocly\n * reads every value as a `$ref`, so a name failed with \"Can't resolve $ref\". OpenAPI 3.1.1\n * (§4.8.25) leaves a value that is both to the implementation and recommends the schema name; a\n * relative URI is then written `./Cat`. So a value that is a key of the document's\n * `components.schemas` becomes the pointer to that schema, in place, before the `$ref`s are\n * resolved. Any other value stays a URI reference.\n */\nexport function pointMappingNamesAtSchemas(document: unknown): void {\n const schemas = componentSchemasOf(document);\n if (schemas === undefined) {\n return;\n }\n for (const mapping of findMappings(document)) {\n for (const [name, value] of Object.entries(mapping)) {\n if (typeof value === \"string\" && Object.hasOwn(schemas, value)) {\n mapping[name] = childPointer(SCHEMAS_POINTER, value);\n }\n }\n }\n}\n"],"names":["componentSchemasOf","findMappings","childPointer","SCHEMAS_POINTER"],"mappings":";;;;;;AAYO,SAAS,2BAA2B,QAAA,EAAyB;AAClE,EAAA,MAAM,OAAA,GAAUA,oCAAmB,QAAQ,CAAA;AAC3C,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA;AAAA,EACF;AACA,EAAA,KAAA,MAAW,OAAA,IAAWC,uBAAA,CAAa,QAAQ,CAAA,EAAG;AAC5C,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACnD,MAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,MAAA,CAAO,OAAA,EAAS,KAAK,CAAA,EAAG;AAC9D,QAAA,OAAA,CAAQ,IAAI,CAAA,GAAIC,wBAAA,CAAaC,gCAAA,EAAiB,KAAK,CAAA;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { childPointer } from '../../domain/openapi/json-pointer.mjs';
|
|
2
|
+
import { componentSchemasOf, SCHEMAS_POINTER } from './component-schemas.mjs';
|
|
3
|
+
import { findMappings } from './ref-holders.mjs';
|
|
4
|
+
|
|
5
|
+
function pointMappingNamesAtSchemas(document) {
|
|
6
|
+
const schemas = componentSchemasOf(document);
|
|
7
|
+
if (schemas === void 0) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
for (const mapping of findMappings(document)) {
|
|
11
|
+
for (const [name, value] of Object.entries(mapping)) {
|
|
12
|
+
if (typeof value === "string" && Object.hasOwn(schemas, value)) {
|
|
13
|
+
mapping[name] = childPointer(SCHEMAS_POINTER, value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { pointMappingNamesAtSchemas };
|
|
20
|
+
//# sourceMappingURL=mapping-schema-names.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping-schema-names.mjs","sources":["../../../src/adapters/redocly-loader/mapping-schema-names.ts"],"sourcesContent":["import { childPointer } from \"../../domain/openapi/json-pointer.js\";\nimport { componentSchemasOf, SCHEMAS_POINTER } from \"./component-schemas.js\";\nimport { findMappings } from \"./ref-holders.js\";\n\n/**\n * A discriminator `mapping` value may be a schema name (`cat: Cat`) or a URI reference. Redocly\n * reads every value as a `$ref`, so a name failed with \"Can't resolve $ref\". OpenAPI 3.1.1\n * (§4.8.25) leaves a value that is both to the implementation and recommends the schema name; a\n * relative URI is then written `./Cat`. So a value that is a key of the document's\n * `components.schemas` becomes the pointer to that schema, in place, before the `$ref`s are\n * resolved. Any other value stays a URI reference.\n */\nexport function pointMappingNamesAtSchemas(document: unknown): void {\n const schemas = componentSchemasOf(document);\n if (schemas === undefined) {\n return;\n }\n for (const mapping of findMappings(document)) {\n for (const [name, value] of Object.entries(mapping)) {\n if (typeof value === \"string\" && Object.hasOwn(schemas, value)) {\n mapping[name] = childPointer(SCHEMAS_POINTER, value);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;AAYO,SAAS,2BAA2B,QAAA,EAAyB;AAClE,EAAA,MAAM,OAAA,GAAU,mBAAmB,QAAQ,CAAA;AAC3C,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA;AAAA,EACF;AACA,EAAA,KAAA,MAAW,OAAA,IAAW,YAAA,CAAa,QAAQ,CAAA,EAAG;AAC5C,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACnD,MAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,MAAA,CAAO,OAAA,EAAS,KAAK,CAAA,EAAG;AAC9D,QAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,YAAA,CAAa,eAAA,EAAiB,KAAK,CAAA;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACF;;"}
|