openapi-typesafe 1.0.0-rc.4 → 1.0.0-rc.6
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 +214 -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-document-names.cjs +50 -0
- package/dist/adapters/redocly-loader/query-document-names.cjs.map +1 -0
- package/dist/adapters/redocly-loader/query-document-names.mjs +48 -0
- package/dist/adapters/redocly-loader/query-document-names.mjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs +129 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs +126 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs +3 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-config-source.mjs +4 -1
- package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +39 -18
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +40 -19
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +25 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +26 -5
- 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 +20 -3
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +20 -4
- 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/cwd-option.cjs +58 -0
- package/dist/api/cwd-option.cjs.map +1 -0
- package/dist/api/cwd-option.mjs +52 -0
- package/dist/api/cwd-option.mjs.map +1 -0
- package/dist/api/default-ports.cjs +15 -7
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +14 -8
- package/dist/api/default-ports.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 -26
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +5 -21
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/legacy-utils.cjs +1 -1
- package/dist/api/legacy-utils.cjs.map +1 -1
- package/dist/api/legacy-utils.mjs +1 -1
- package/dist/api/legacy-utils.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/option-errors.cjs +24 -0
- package/dist/api/option-errors.cjs.map +1 -0
- package/dist/api/option-errors.mjs +21 -0
- package/dist/api/option-errors.mjs.map +1 -0
- package/dist/api/ref-limit-options.cjs +58 -0
- package/dist/api/ref-limit-options.cjs.map +1 -0
- package/dist/api/ref-limit-options.mjs +52 -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 +80 -0
- package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.mjs +77 -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 +63 -64
- package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.mjs +57 -53
- 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 +69 -14
- package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/original-index.mjs +71 -16
- 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 +57 -0
- package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs +49 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs +90 -22
- package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/typed-walk.mjs +87 -19
- 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 +10 -17
- package/dist/cli/api-settings.cjs.map +1 -1
- package/dist/cli/api-settings.mjs +10 -17
- package/dist/cli/api-settings.mjs.map +1 -1
- package/dist/cli/api-writes.cjs +7 -1
- package/dist/cli/api-writes.cjs.map +1 -1
- package/dist/cli/api-writes.mjs +7 -1
- package/dist/cli/api-writes.mjs.map +1 -1
- package/dist/cli/cli-arguments.cjs +32 -74
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +28 -70
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/cli-errors.cjs +18 -0
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +18 -1
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-flag-names.cjs +77 -0
- package/dist/cli/cli-flag-names.cjs.map +1 -0
- package/dist/cli/cli-flag-names.mjs +64 -0
- package/dist/cli/cli-flag-names.mjs.map +1 -0
- package/dist/cli/cli-output.cjs +13 -6
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +14 -7
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +11 -5
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +11 -5
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +33 -12
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +35 -14
- 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/cli/written-flags.cjs +83 -0
- package/dist/cli/written-flags.cjs.map +1 -0
- package/dist/cli/written-flags.mjs +77 -0
- package/dist/cli/written-flags.mjs.map +1 -0
- 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 +3 -0
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +3 -0
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/location-text.cjs +15 -0
- package/dist/domain/location-text.cjs.map +1 -0
- package/dist/domain/location-text.mjs +13 -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 +29 -18
- package/dist/index.d.mts +29 -18
- package/dist/index.d.ts +29 -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-document-names.ts +79 -0
- package/src/adapters/redocly-loader/query-named-components.ts +200 -0
- package/src/adapters/redocly-loader/redocly-config-source.ts +11 -1
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +63 -17
- package/src/adapters/redocly-loader/ref-access.ts +32 -5
- package/src/adapters/redocly-loader/ref-holders.ts +75 -14
- package/src/adapters/redocly-loader/remote-fetch.ts +37 -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/cwd-option.ts +76 -0
- package/src/api/default-ports.ts +33 -10
- package/src/api/document-refs.ts +29 -1
- package/src/api/document-run.ts +7 -32
- package/src/api/legacy-utils.ts +1 -1
- package/src/api/openapi-ts.ts +20 -4
- package/src/api/option-errors.ts +22 -0
- package/src/api/ref-limit-options.ts +69 -0
- package/src/api/transform-schema.ts +20 -5
- package/src/application/ports/file-system.ts +8 -0
- package/src/application/ports/redocly-config-source.ts +5 -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 +127 -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 +115 -83
- 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 +106 -20
- 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 +106 -0
- package/src/application/transform/ref-pointer/typed-walk.ts +143 -29
- 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/api-writes.ts +11 -3
- package/src/cli/cli-arguments.ts +57 -92
- package/src/cli/cli-dependencies.ts +7 -2
- package/src/cli/cli-errors.ts +23 -0
- package/src/cli/cli-flag-names.ts +99 -0
- package/src/cli/cli-output.ts +31 -16
- package/src/cli/main.ts +12 -5
- package/src/cli/redocly-apis.ts +56 -20
- package/src/cli/ref-limits.ts +21 -2
- package/src/cli/run-cli.ts +39 -7
- package/src/cli/written-flags.ts +131 -0
- package/src/domain/cause-secrets.ts +59 -25
- package/src/domain/errors.ts +3 -0
- package/src/domain/location-text.ts +27 -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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const constructors = require('../../../domain/ir/constructors.cjs');
|
|
4
|
+
const documentEntries = require('../document-entries.cjs');
|
|
5
|
+
const helperTypes = require('../helper-types.cjs');
|
|
6
|
+
const pathTemplateKey = require('./path-template-key.cjs');
|
|
7
|
+
const paths = require('./paths.cjs');
|
|
8
|
+
|
|
9
|
+
const PATHS_TYPE_NAME = "paths";
|
|
10
|
+
function templateIndexText(url, parts, takenUrls) {
|
|
11
|
+
const keys = pathTemplateKey.booleanExpandedKeys(parts).map(paths.pathKeyOf).filter((key) => paths.isUntakenKey(url, key, takenUrls));
|
|
12
|
+
const texts = keys.map(
|
|
13
|
+
(key) => key.kind === "literal" ? JSON.stringify(key.url) : pathTemplateKey.templateText(key.parts)
|
|
14
|
+
);
|
|
15
|
+
return texts.length === 0 ? void 0 : texts.join(" | ");
|
|
16
|
+
}
|
|
17
|
+
function unmatchedTemplateKeys(paths, context) {
|
|
18
|
+
const keys = /* @__PURE__ */ new Map();
|
|
19
|
+
if (!context.options.pathParamsAsTypes || typeof paths !== "object" || paths === null) {
|
|
20
|
+
return keys;
|
|
21
|
+
}
|
|
22
|
+
const takenUrls = new Set(Object.keys(paths));
|
|
23
|
+
for (const [url, pathItem] of documentEntries.documentEntries(paths, context.options)) {
|
|
24
|
+
if (!pathItem || typeof pathItem !== "object" || "$ref" in pathItem || !url.includes("{")) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const parts = pathTemplateKey.pathTemplateParts(url, pathItem, context);
|
|
28
|
+
const index = parts === null ? void 0 : templateIndexText(url, parts, takenUrls);
|
|
29
|
+
const isUnmatched = parts?.some(
|
|
30
|
+
(part) => part.kind === "placeholder" && part.type !== "string"
|
|
31
|
+
);
|
|
32
|
+
if (isUnmatched && index !== void 0) {
|
|
33
|
+
keys.set(url, index);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return keys;
|
|
37
|
+
}
|
|
38
|
+
function isNode(value) {
|
|
39
|
+
return typeof value === "object" && value !== null;
|
|
40
|
+
}
|
|
41
|
+
function isBarePathsReference(node) {
|
|
42
|
+
const reference = node;
|
|
43
|
+
return reference?.kind === "reference" && reference.name === PATHS_TYPE_NAME && reference.typeArguments?.length === 0;
|
|
44
|
+
}
|
|
45
|
+
function isPathsRoot(node) {
|
|
46
|
+
const reference = node;
|
|
47
|
+
const typeArguments = reference?.typeArguments;
|
|
48
|
+
const isDeepRoot = reference?.kind === "reference" && reference.name === helperTypes.HELPER_TYPES.flattenedDeepRequired.name && typeArguments?.length === 1 && isBarePathsReference(typeArguments[0]);
|
|
49
|
+
return isDeepRoot || isBarePathsReference(node);
|
|
50
|
+
}
|
|
51
|
+
function pathsIndexUrl(node) {
|
|
52
|
+
const index = node.index;
|
|
53
|
+
const isPathsIndex = node.kind === "indexedAccess" && isPathsRoot(node.object) && index?.kind === "stringLiteral";
|
|
54
|
+
return isPathsIndex ? index.value : void 0;
|
|
55
|
+
}
|
|
56
|
+
function rewrittenNode(value, keys) {
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
return value.map((item) => rewrittenNode(item, keys));
|
|
59
|
+
}
|
|
60
|
+
if (!isNode(value)) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
const template = keys.get(pathsIndexUrl(value) ?? "");
|
|
64
|
+
if (template !== void 0) {
|
|
65
|
+
return { ...value, index: constructors.irRaw(template) };
|
|
66
|
+
}
|
|
67
|
+
return Object.fromEntries(
|
|
68
|
+
Object.entries(value).map(([key, child]) => [
|
|
69
|
+
key,
|
|
70
|
+
key === "origin" ? child : rewrittenNode(child, keys)
|
|
71
|
+
])
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function withTemplatePathRefs(declarations, keys) {
|
|
75
|
+
return keys.size === 0 ? [...declarations] : rewrittenNode(declarations, keys);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
exports.unmatchedTemplateKeys = unmatchedTemplateKeys;
|
|
79
|
+
exports.withTemplatePathRefs = withTemplatePathRefs;
|
|
80
|
+
//# sourceMappingURL=path-template-refs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-template-refs.cjs","sources":["../../../../src/application/transform/document/path-template-refs.ts"],"sourcesContent":["import { irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { HELPER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport type { PathKeyPart } from \"./path-key-overlaps.js\";\nimport { booleanExpandedKeys, pathTemplateParts, templateText } from \"./path-template-key.js\";\nimport { isUntakenKey, pathKeyOf } from \"./paths.js\";\n\n/**\n * `--path-params-as-types` and `$ref`s into a templated path. Such a path is an index signature\n * of `paths` (`` [path: `/pets/${number}`] ``), so `paths[\"/pets/{id}\"]`, the type of a `$ref`\n * to it, names no key: `{id}` is no number (TS2339). The reference indexes `paths` by the\n * template instead, which reaches the signature; so does the type of an `--enum-values` array,\n * which indexes `FlattenedDeepRequired<paths>`. With only `${string}` placeholders the URL\n * itself matches the template and the output compiles, so it stays as it is.\n */\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/**\n * The index of a templated path: the union of the keys it is written with. A `${boolean}` key the\n * document's own path took (`/flags/true` next to `/flags/{enabled}`) is left out, so the index\n * names only this path's members. Undefined when every key was taken: the path has no member.\n */\nfunction templateIndexText(url: string, parts: readonly PathKeyPart[], takenUrls: Set<string>) {\n const keys = booleanExpandedKeys(parts)\n .map(pathKeyOf)\n .filter((key) => isUntakenKey(url, key, takenUrls));\n const texts = keys.map((key) =>\n key.kind === \"literal\" ? JSON.stringify(key.url) : templateText(key.parts),\n );\n return texts.length === 0 ? undefined : texts.join(\" | \");\n}\n\n/** The index of each templated path whose URL does not match its keys, by URL. */\nexport function unmatchedTemplateKeys(\n paths: PathsObject | null | undefined,\n context: TransformContext,\n): ReadonlyMap<string, string> {\n const keys = new Map<string, string>();\n // A document may hold any value as `paths`; one that is no object has no paths.\n if (!context.options.pathParamsAsTypes || typeof paths !== \"object\" || paths === null) {\n return keys;\n }\n // The same walk as `pathMembers`, so a URL is taken by the same path as there.\n const takenUrls = new Set(Object.keys(paths));\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\" || \"$ref\" in pathItem || !url.includes(\"{\")) {\n continue;\n }\n const parts = pathTemplateParts(url, pathItem, context);\n const index = parts === null ? undefined : templateIndexText(url, parts, takenUrls);\n const isUnmatched = parts?.some(\n (part) => part.kind === \"placeholder\" && part.type !== \"string\",\n );\n if (isUnmatched && index !== undefined) {\n keys.set(url, index);\n }\n }\n return keys;\n}\n\nfunction isNode(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isBarePathsReference(node: unknown): boolean {\n const reference = node as Readonly<Record<string, unknown>> | undefined;\n return (\n reference?.kind === \"reference\" &&\n reference.name === PATHS_TYPE_NAME &&\n (reference.typeArguments as readonly unknown[] | undefined)?.length === 0\n );\n}\n\n/**\n * The `paths` root as a `$ref` or an `--enum-values` array indexes it: `paths`, or\n * `FlattenedDeepRequired<paths>` (`rootType`), whose mapped keys are those of `paths`.\n */\nfunction isPathsRoot(node: unknown): boolean {\n const reference = node as Readonly<Record<string, unknown>> | undefined;\n const typeArguments = reference?.typeArguments as readonly unknown[] | undefined;\n const isDeepRoot =\n reference?.kind === \"reference\" &&\n reference.name === HELPER_TYPES.flattenedDeepRequired.name &&\n typeArguments?.length === 1 &&\n isBarePathsReference(typeArguments[0]);\n return isDeepRoot || isBarePathsReference(node);\n}\n\n/** `paths[\"<url>\"]`: an index of the `paths` root by a string literal. */\nfunction pathsIndexUrl(node: Readonly<Record<string, unknown>>): string | undefined {\n const index = node.index as Readonly<Record<string, unknown>> | undefined;\n const isPathsIndex =\n node.kind === \"indexedAccess\" && isPathsRoot(node.object) && index?.kind === \"stringLiteral\";\n return isPathsIndex ? (index.value as string) : undefined;\n}\n\nfunction rewrittenNode(value: unknown, keys: ReadonlyMap<string, string>): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => rewrittenNode(item, keys));\n }\n if (!isNode(value)) {\n return value;\n }\n const template = keys.get(pathsIndexUrl(value) ?? \"\");\n if (template !== undefined) {\n return { ...value, index: irRaw(template) };\n }\n // `origin` holds the compiler node a raw type was printed from; it is not IR.\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n key === \"origin\" ? child : rewrittenNode(child, keys),\n ]),\n );\n}\n\n/** The declarations with each `paths[\"<url>\"]` of an unmatched template indexed by it. */\nexport function withTemplatePathRefs<T extends IrDeclaration>(\n declarations: readonly T[],\n keys: ReadonlyMap<string, string>,\n): T[] {\n return keys.size === 0 ? [...declarations] : (rewrittenNode(declarations, keys) as T[]);\n}\n"],"names":["booleanExpandedKeys","pathKeyOf","isUntakenKey","templateText","documentEntries","pathTemplateParts","HELPER_TYPES","irRaw"],"mappings":";;;;;;;;AAmBA,MAAM,eAAA,GAAkB,OAAA;AAOxB,SAAS,iBAAA,CAAkB,GAAA,EAAa,KAAA,EAA+B,SAAA,EAAwB;AAC7F,EAAA,MAAM,IAAA,GAAOA,mCAAA,CAAoB,KAAK,CAAA,CACnC,IAAIC,eAAS,CAAA,CACb,MAAA,CAAO,CAAC,GAAA,KAAQC,kBAAA,CAAa,GAAA,EAAK,GAAA,EAAK,SAAS,CAAC,CAAA;AACpD,EAAA,MAAM,QAAQ,IAAA,CAAK,GAAA;AAAA,IAAI,CAAC,GAAA,KACtB,GAAA,CAAI,IAAA,KAAS,SAAA,GAAY,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,GAAIC,4B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AAI,aAAA,CAAc,KAAK,KAAK,EAAE,CAAA;AACpD,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,EAAE,GAAG,KAAA,EAAO,KAAA,EAAOC,kBAAA,CAAM,QAAQ,CAAA,EAAE;AAAA,EAC5C;AAEA,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,KAAK,CAAA,CAAE,IAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AAAA,MAC1C,GAAA;AAAA,MACA,GAAA,KAAQ,QAAA,GAAW,KAAA,GAAQ,aAAA,CAAc,OAAO,IAAI;AAAA,KACrD;AAAA,GACH;AACF;AAGO,SAAS,oBAAA,CACd,cACA,IAAA,EACK;AACL,EAAA,OAAO,IAAA,CAAK,SAAS,CAAA,GAAI,CAAC,GAAG,YAAY,CAAA,GAAK,aAAA,CAAc,YAAA,EAAc,IAAI,CAAA;AAChF;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { irRaw } from '../../../domain/ir/constructors.mjs';
|
|
2
|
+
import { documentEntries } from '../document-entries.mjs';
|
|
3
|
+
import { HELPER_TYPES } from '../helper-types.mjs';
|
|
4
|
+
import { pathTemplateParts, booleanExpandedKeys, templateText } from './path-template-key.mjs';
|
|
5
|
+
import { pathKeyOf, isUntakenKey } from './paths.mjs';
|
|
6
|
+
|
|
7
|
+
const PATHS_TYPE_NAME = "paths";
|
|
8
|
+
function templateIndexText(url, parts, takenUrls) {
|
|
9
|
+
const keys = booleanExpandedKeys(parts).map(pathKeyOf).filter((key) => isUntakenKey(url, key, takenUrls));
|
|
10
|
+
const texts = keys.map(
|
|
11
|
+
(key) => key.kind === "literal" ? JSON.stringify(key.url) : templateText(key.parts)
|
|
12
|
+
);
|
|
13
|
+
return texts.length === 0 ? void 0 : texts.join(" | ");
|
|
14
|
+
}
|
|
15
|
+
function unmatchedTemplateKeys(paths, context) {
|
|
16
|
+
const keys = /* @__PURE__ */ new Map();
|
|
17
|
+
if (!context.options.pathParamsAsTypes || typeof paths !== "object" || paths === null) {
|
|
18
|
+
return keys;
|
|
19
|
+
}
|
|
20
|
+
const takenUrls = new Set(Object.keys(paths));
|
|
21
|
+
for (const [url, pathItem] of documentEntries(paths, context.options)) {
|
|
22
|
+
if (!pathItem || typeof pathItem !== "object" || "$ref" in pathItem || !url.includes("{")) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const parts = pathTemplateParts(url, pathItem, context);
|
|
26
|
+
const index = parts === null ? void 0 : templateIndexText(url, parts, takenUrls);
|
|
27
|
+
const isUnmatched = parts?.some(
|
|
28
|
+
(part) => part.kind === "placeholder" && part.type !== "string"
|
|
29
|
+
);
|
|
30
|
+
if (isUnmatched && index !== void 0) {
|
|
31
|
+
keys.set(url, index);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return keys;
|
|
35
|
+
}
|
|
36
|
+
function isNode(value) {
|
|
37
|
+
return typeof value === "object" && value !== null;
|
|
38
|
+
}
|
|
39
|
+
function isBarePathsReference(node) {
|
|
40
|
+
const reference = node;
|
|
41
|
+
return reference?.kind === "reference" && reference.name === PATHS_TYPE_NAME && reference.typeArguments?.length === 0;
|
|
42
|
+
}
|
|
43
|
+
function isPathsRoot(node) {
|
|
44
|
+
const reference = node;
|
|
45
|
+
const typeArguments = reference?.typeArguments;
|
|
46
|
+
const isDeepRoot = reference?.kind === "reference" && reference.name === HELPER_TYPES.flattenedDeepRequired.name && typeArguments?.length === 1 && isBarePathsReference(typeArguments[0]);
|
|
47
|
+
return isDeepRoot || isBarePathsReference(node);
|
|
48
|
+
}
|
|
49
|
+
function pathsIndexUrl(node) {
|
|
50
|
+
const index = node.index;
|
|
51
|
+
const isPathsIndex = node.kind === "indexedAccess" && isPathsRoot(node.object) && index?.kind === "stringLiteral";
|
|
52
|
+
return isPathsIndex ? index.value : void 0;
|
|
53
|
+
}
|
|
54
|
+
function rewrittenNode(value, keys) {
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
return value.map((item) => rewrittenNode(item, keys));
|
|
57
|
+
}
|
|
58
|
+
if (!isNode(value)) {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
const template = keys.get(pathsIndexUrl(value) ?? "");
|
|
62
|
+
if (template !== void 0) {
|
|
63
|
+
return { ...value, index: irRaw(template) };
|
|
64
|
+
}
|
|
65
|
+
return Object.fromEntries(
|
|
66
|
+
Object.entries(value).map(([key, child]) => [
|
|
67
|
+
key,
|
|
68
|
+
key === "origin" ? child : rewrittenNode(child, keys)
|
|
69
|
+
])
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
function withTemplatePathRefs(declarations, keys) {
|
|
73
|
+
return keys.size === 0 ? [...declarations] : rewrittenNode(declarations, keys);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { unmatchedTemplateKeys, withTemplatePathRefs };
|
|
77
|
+
//# sourceMappingURL=path-template-refs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-template-refs.mjs","sources":["../../../../src/application/transform/document/path-template-refs.ts"],"sourcesContent":["import { irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { HELPER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport type { PathKeyPart } from \"./path-key-overlaps.js\";\nimport { booleanExpandedKeys, pathTemplateParts, templateText } from \"./path-template-key.js\";\nimport { isUntakenKey, pathKeyOf } from \"./paths.js\";\n\n/**\n * `--path-params-as-types` and `$ref`s into a templated path. Such a path is an index signature\n * of `paths` (`` [path: `/pets/${number}`] ``), so `paths[\"/pets/{id}\"]`, the type of a `$ref`\n * to it, names no key: `{id}` is no number (TS2339). The reference indexes `paths` by the\n * template instead, which reaches the signature; so does the type of an `--enum-values` array,\n * which indexes `FlattenedDeepRequired<paths>`. With only `${string}` placeholders the URL\n * itself matches the template and the output compiles, so it stays as it is.\n */\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/**\n * The index of a templated path: the union of the keys it is written with. A `${boolean}` key the\n * document's own path took (`/flags/true` next to `/flags/{enabled}`) is left out, so the index\n * names only this path's members. Undefined when every key was taken: the path has no member.\n */\nfunction templateIndexText(url: string, parts: readonly PathKeyPart[], takenUrls: Set<string>) {\n const keys = booleanExpandedKeys(parts)\n .map(pathKeyOf)\n .filter((key) => isUntakenKey(url, key, takenUrls));\n const texts = keys.map((key) =>\n key.kind === \"literal\" ? JSON.stringify(key.url) : templateText(key.parts),\n );\n return texts.length === 0 ? undefined : texts.join(\" | \");\n}\n\n/** The index of each templated path whose URL does not match its keys, by URL. */\nexport function unmatchedTemplateKeys(\n paths: PathsObject | null | undefined,\n context: TransformContext,\n): ReadonlyMap<string, string> {\n const keys = new Map<string, string>();\n // A document may hold any value as `paths`; one that is no object has no paths.\n if (!context.options.pathParamsAsTypes || typeof paths !== \"object\" || paths === null) {\n return keys;\n }\n // The same walk as `pathMembers`, so a URL is taken by the same path as there.\n const takenUrls = new Set(Object.keys(paths));\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\" || \"$ref\" in pathItem || !url.includes(\"{\")) {\n continue;\n }\n const parts = pathTemplateParts(url, pathItem, context);\n const index = parts === null ? undefined : templateIndexText(url, parts, takenUrls);\n const isUnmatched = parts?.some(\n (part) => part.kind === \"placeholder\" && part.type !== \"string\",\n );\n if (isUnmatched && index !== undefined) {\n keys.set(url, index);\n }\n }\n return keys;\n}\n\nfunction isNode(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isBarePathsReference(node: unknown): boolean {\n const reference = node as Readonly<Record<string, unknown>> | undefined;\n return (\n reference?.kind === \"reference\" &&\n reference.name === PATHS_TYPE_NAME &&\n (reference.typeArguments as readonly unknown[] | undefined)?.length === 0\n );\n}\n\n/**\n * The `paths` root as a `$ref` or an `--enum-values` array indexes it: `paths`, or\n * `FlattenedDeepRequired<paths>` (`rootType`), whose mapped keys are those of `paths`.\n */\nfunction isPathsRoot(node: unknown): boolean {\n const reference = node as Readonly<Record<string, unknown>> | undefined;\n const typeArguments = reference?.typeArguments as readonly unknown[] | undefined;\n const isDeepRoot =\n reference?.kind === \"reference\" &&\n reference.name === HELPER_TYPES.flattenedDeepRequired.name &&\n typeArguments?.length === 1 &&\n isBarePathsReference(typeArguments[0]);\n return isDeepRoot || isBarePathsReference(node);\n}\n\n/** `paths[\"<url>\"]`: an index of the `paths` root by a string literal. */\nfunction pathsIndexUrl(node: Readonly<Record<string, unknown>>): string | undefined {\n const index = node.index as Readonly<Record<string, unknown>> | undefined;\n const isPathsIndex =\n node.kind === \"indexedAccess\" && isPathsRoot(node.object) && index?.kind === \"stringLiteral\";\n return isPathsIndex ? (index.value as string) : undefined;\n}\n\nfunction rewrittenNode(value: unknown, keys: ReadonlyMap<string, string>): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => rewrittenNode(item, keys));\n }\n if (!isNode(value)) {\n return value;\n }\n const template = keys.get(pathsIndexUrl(value) ?? \"\");\n if (template !== undefined) {\n return { ...value, index: irRaw(template) };\n }\n // `origin` holds the compiler node a raw type was printed from; it is not IR.\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n key === \"origin\" ? child : rewrittenNode(child, keys),\n ]),\n );\n}\n\n/** The declarations with each `paths[\"<url>\"]` of an unmatched template indexed by it. */\nexport function withTemplatePathRefs<T extends IrDeclaration>(\n declarations: readonly T[],\n keys: ReadonlyMap<string, string>,\n): T[] {\n return keys.size === 0 ? [...declarations] : (rewrittenNode(declarations, keys) as T[]);\n}\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,eAAA,GAAkB,OAAA;AAOxB,SAAS,iBAAA,CAAkB,GAAA,EAAa,KAAA,EAA+B,SAAA,EAAw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AEA,SAAS,aAAA,CAAc,OAAgB,IAAA,EAA4C;AACjF,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,MAAM,GAAA,CAAI,CAAC,SAAS,aAAA,CAAc,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACtD;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,KAAK,CAAA,EAAG;AAClB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,WAAW,IAAA,CAAK,GAAA,CAAI,aAAA,CAAc,KAAK,KAAK,EAAE,CAAA;AACpD,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,EAAE,GAAG,KAAA,EAAO,KAAA,EAAO,KAAA,CAAM,QAAQ,CAAA,EAAE;AAAA,EAC5C;AAEA,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,KAAK,CAAA,CAAE,IAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AAAA,MAC1C,GAAA;AAAA,MACA,GAAA,KAAQ,QAAA,GAAW,KAAA,GAAQ,aAAA,CAAc,OAAO,IAAI;AAAA,KACrD;AAAA,GACH;AACF;AAGO,SAAS,oBAAA,CACd,cACA,IAAA,EACK;AACL,EAAA,OAAO,IAAA,CAAK,SAAS,CAAA,GAAI,CAAC,GAAG,YAAY,CAAA,GAAK,aAAA,CAAc,YAAA,EAAc,IAAI,CAAA;AAChF;;"}
|
|
@@ -33,9 +33,10 @@ function pathItemEntries(pathItem) {
|
|
|
33
33
|
return METHODS.has(key) ? [[key, value]] : [];
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
const INCLUDES_EVERY_OPERATION = () => true;
|
|
37
|
+
function pathOperations(paths, isIncluded) {
|
|
37
38
|
return Object.entries(paths).flatMap(
|
|
38
|
-
([url, pathItem]) => pathItemEntries(pathItem).map(([method, operation]) => {
|
|
39
|
+
([url, pathItem]) => pathItemEntries(pathItem).filter(([, operation]) => isIncluded(operation)).map(([method, operation]) => {
|
|
39
40
|
const operationId = operation.operationId || void 0;
|
|
40
41
|
return { url, method, operationId };
|
|
41
42
|
})
|
|
@@ -57,17 +58,17 @@ function uniqueNames(operations) {
|
|
|
57
58
|
});
|
|
58
59
|
return numberedNames.withNumberedRepeats(named, (name, count) => `${name}${count}`);
|
|
59
60
|
}
|
|
60
|
-
function apiPathsEnum(paths) {
|
|
61
|
-
const operations = pathOperations(paths);
|
|
61
|
+
function apiPathsEnum(paths, isIncluded = INCLUDES_EVERY_OPERATION) {
|
|
62
|
+
const operations = pathOperations(paths, isIncluded);
|
|
62
63
|
const names = uniqueNames(operations);
|
|
63
64
|
return {
|
|
64
65
|
values: operations.map((operation) => operation.url),
|
|
65
66
|
metadata: names.map((name) => ({ name, description: void 0 }))
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
|
-
function apiPathsEnumDeclaration(paths) {
|
|
69
|
+
function apiPathsEnumDeclaration(paths, isIncluded = INCLUDES_EVERY_OPERATION) {
|
|
69
70
|
const naming = new enumNaming.EnumNaming();
|
|
70
|
-
return enumNaming.enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);
|
|
71
|
+
return enumNaming.enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths, isIncluded), naming);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
exports.API_PATHS_NAME = API_PATHS_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths-enum.cjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nexport const API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\nfunction pathOperations(paths: PathsObject): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem).map(([method, operation]) => {\n
|
|
1
|
+
{"version":3,"file":"paths-enum.cjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nexport const API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\n/** Which operations get a member; the generator leaves out those `--exclude-deprecated` drops. */\nexport type OperationFilter = (operation: OperationEntry) => boolean;\n\nconst INCLUDES_EVERY_OPERATION: OperationFilter = () => true;\n\nfunction pathOperations(paths: PathsObject, isIncluded: OperationFilter): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem)\n .filter(([, operation]) => isIncluded(operation as OperationEntry))\n .map(([method, operation]) => {\n const operationId = (operation as OperationObject).operationId || undefined;\n return { url, method, operationId };\n }),\n );\n}\n\nfunction countOf(names: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const name of names) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n}\n\n/**\n * Names that are unique, so the enum compiles (upstream #2194). A URL key that collides names\n * its parameters; a name that still collides gets 2, 3… after its first use.\n */\nfunction uniqueNames(operations: readonly PathOperation[]): string[] {\n const keys = operations.map((op) => op.operationId ?? keyFromUrl(op.method, op.url));\n const counts = countOf(keys);\n const named = operations.map((op, index) => {\n const isCollidingUrlKey =\n op.operationId === undefined && (counts.get(keys[index] as string) ?? 0) > 1;\n return isCollidingUrlKey ? keyWithParameters(op.method, op.url) : (keys[index] as string);\n });\n return withNumberedRepeats(named, (name, count) => `${name}${count}`);\n}\n\n/**\n * One enum member per operation: the URL as the value, the operation ID (or a key built from the\n * method and URL) as the name. Paths are in document order; `--alphabetize` does not apply.\n */\nexport function apiPathsEnum(\n paths: PathsObject,\n isIncluded: OperationFilter = INCLUDES_EVERY_OPERATION,\n): ApiPathsEnum {\n const operations = pathOperations(paths, isIncluded);\n const names = uniqueNames(operations);\n return {\n values: operations.map((operation) => operation.url),\n metadata: names.map((name) => ({ name, description: undefined })),\n };\n}\n\n/**\n * The `ApiPaths` enum declaration. Its own naming state is equivalent to the run's: the name is a\n * valid identifier, and member names only reset the state, never read it.\n */\nexport function apiPathsEnumDeclaration(\n paths: PathsObject,\n isIncluded: OperationFilter = INCLUDES_EVERY_OPERATION,\n): IrEnumDeclaration {\n const naming = new EnumNaming();\n return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths, isIncluded), naming);\n}\n"],"names":["HTTP_METHODS","QUERY_METHOD","ADDITIONAL_OPERATIONS_KEY","withNumberedRepeats","EnumNaming","enumDeclaration"],"mappings":";;;;;;AAeA,MAAM,oBAAA,GAAuB,oBAAA;AAE7B,MAAM,mBAAA,GAAsB,wBAAA;AACrB,MAAM,cAAA,GAAiB;AAC9B,MAAM,0BAA+B,IAAI,GAAA,CAAoB,CAAC,GAAGA,2BAAA,EAAcC,2BAAY,CAAC,CAAA;AAS5F,SAAS,UAAA,CAAW,QAAgB,GAAA,EAAqB;AACvD,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,EAAG,GAAG,CAAA,CAAA,CACnB,MAAM,GAAG,CAAA,CACT,GAAA,CAAI,CAAC,IAAA,KA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34
|
-
|
|
34
|
+
const INCLUDES_EVERY_OPERATION = () => true;
|
|
35
|
+
function pathOperations(paths, isIncluded) {
|
|
35
36
|
return Object.entries(paths).flatMap(
|
|
36
|
-
([url, pathItem]) => pathItemEntries(pathItem).map(([method, operation]) => {
|
|
37
|
+
([url, pathItem]) => pathItemEntries(pathItem).filter(([, operation]) => isIncluded(operation)).map(([method, operation]) => {
|
|
37
38
|
const operationId = operation.operationId || void 0;
|
|
38
39
|
return { url, method, operationId };
|
|
39
40
|
})
|
|
@@ -55,17 +56,17 @@ function uniqueNames(operations) {
|
|
|
55
56
|
});
|
|
56
57
|
return withNumberedRepeats(named, (name, count) => `${name}${count}`);
|
|
57
58
|
}
|
|
58
|
-
function apiPathsEnum(paths) {
|
|
59
|
-
const operations = pathOperations(paths);
|
|
59
|
+
function apiPathsEnum(paths, isIncluded = INCLUDES_EVERY_OPERATION) {
|
|
60
|
+
const operations = pathOperations(paths, isIncluded);
|
|
60
61
|
const names = uniqueNames(operations);
|
|
61
62
|
return {
|
|
62
63
|
values: operations.map((operation) => operation.url),
|
|
63
64
|
metadata: names.map((name) => ({ name, description: void 0 }))
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
function apiPathsEnumDeclaration(paths) {
|
|
67
|
+
function apiPathsEnumDeclaration(paths, isIncluded = INCLUDES_EVERY_OPERATION) {
|
|
67
68
|
const naming = new EnumNaming();
|
|
68
|
-
return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);
|
|
69
|
+
return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths, isIncluded), naming);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
export { API_PATHS_NAME, apiPathsEnum, apiPathsEnumDeclaration };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths-enum.mjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nexport const API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\nfunction pathOperations(paths: PathsObject): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem).map(([method, operation]) => {\n
|
|
1
|
+
{"version":3,"file":"paths-enum.mjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nexport const API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\n/** Which operations get a member; the generator leaves out those `--exclude-deprecated` drops. */\nexport type OperationFilter = (operation: OperationEntry) => boolean;\n\nconst INCLUDES_EVERY_OPERATION: OperationFilter = () => true;\n\nfunction pathOperations(paths: PathsObject, isIncluded: OperationFilter): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem)\n .filter(([, operation]) => isIncluded(operation as OperationEntry))\n .map(([method, operation]) => {\n const operationId = (operation as OperationObject).operationId || undefined;\n return { url, method, operationId };\n }),\n );\n}\n\nfunction countOf(names: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const name of names) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n}\n\n/**\n * Names that are unique, so the enum compiles (upstream #2194). A URL key that collides names\n * its parameters; a name that still collides gets 2, 3… after its first use.\n */\nfunction uniqueNames(operations: readonly PathOperation[]): string[] {\n const keys = operations.map((op) => op.operationId ?? keyFromUrl(op.method, op.url));\n const counts = countOf(keys);\n const named = operations.map((op, index) => {\n const isCollidingUrlKey =\n op.operationId === undefined && (counts.get(keys[index] as string) ?? 0) > 1;\n return isCollidingUrlKey ? keyWithParameters(op.method, op.url) : (keys[index] as string);\n });\n return withNumberedRepeats(named, (name, count) => `${name}${count}`);\n}\n\n/**\n * One enum member per operation: the URL as the value, the operation ID (or a key built from the\n * method and URL) as the name. Paths are in document order; `--alphabetize` does not apply.\n */\nexport function apiPathsEnum(\n paths: PathsObject,\n isIncluded: OperationFilter = INCLUDES_EVERY_OPERATION,\n): ApiPathsEnum {\n const operations = pathOperations(paths, isIncluded);\n const names = uniqueNames(operations);\n return {\n values: operations.map((operation) => operation.url),\n metadata: names.map((name) => ({ name, description: undefined })),\n };\n}\n\n/**\n * The `ApiPaths` enum declaration. Its own naming state is equivalent to the run's: the name is a\n * valid identifier, and member names only reset the state, never read it.\n */\nexport function apiPathsEnumDeclaration(\n paths: PathsObject,\n isIncluded: OperationFilter = INCLUDES_EVERY_OPERATION,\n): IrEnumDeclaration {\n const naming = new EnumNaming();\n return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths, isIncluded), naming);\n}\n"],"names":[],"mappings":";;;;AAeA,MAAM,oBAAA,GAAuB,oBAAA;AAE7B,MAAM,mBAAA,GAAsB,wBAAA;AACrB,MAAM,cAAA,GAAiB;AAC9B,MAAM,0BAA+B,IAAI,GAAA,CAAoB,CAAC,GAAG,YAAA,EAAc,YAAY,CAAC,CAAA;AAS5F,SAAS,UAAA,CAAW,QAAgB,GAAA,EAAqB;AACvD,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,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|
const constructors = require('../../../domain/ir/constructors.cjs');
|
|
4
4
|
const propertyName = require('../../../domain/ir/property-name.cjs');
|
|
5
|
-
const rawTextEscapes = require('../../../domain/ir/raw-text-escapes.cjs');
|
|
6
5
|
const jsonPointer = require('../../../domain/openapi/json-pointer.cjs');
|
|
7
|
-
const pathItemObject = require('../../../domain/openapi/path-item-object.cjs');
|
|
8
|
-
const outputFixes = require('../../../domain/output-fixes.cjs');
|
|
9
6
|
const documentEntries = require('../document-entries.cjs');
|
|
10
7
|
const refType = require('../ref-type.cjs');
|
|
11
8
|
const declaredTypes = require('./declared-types.cjs');
|
|
12
9
|
const documentMember = require('./document-member.cjs');
|
|
13
10
|
const pathItem = require('./path-item.cjs');
|
|
14
11
|
const pathKeyOverlaps = require('./path-key-overlaps.cjs');
|
|
15
|
-
const
|
|
12
|
+
const pathTemplateKey = require('./path-template-key.cjs');
|
|
16
13
|
const typeAssignability = require('./type-assignability.cjs');
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
["integer", "number"],
|
|
22
|
-
["boolean", "boolean"]
|
|
23
|
-
]);
|
|
24
|
-
const STRING_PLACEHOLDER = "string";
|
|
25
|
-
function resolvedParameter(parameter, context) {
|
|
26
|
-
return "$ref" in parameter && parameter.$ref ? context.refs.resolve(parameter.$ref) : parameter;
|
|
15
|
+
function pathKeyOf(parts) {
|
|
16
|
+
const plainUrl = pathTemplateKey.plainUrlOf(parts);
|
|
17
|
+
return plainUrl === null ? { kind: "template", parts } : literalKey(plainUrl);
|
|
27
18
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function pathParameters(pathItem, context) {
|
|
37
|
-
const byName = /* @__PURE__ */ new Map();
|
|
38
|
-
addPathParameters(pathItem.parameters ?? [], byName, context);
|
|
39
|
-
for (const { operation: entry } of pathItemObject.pathItemOperations(pathItem)) {
|
|
40
|
-
const operation = entry.$ref ? context.refs.resolve(entry.$ref) : entry;
|
|
41
|
-
addPathParameters(operation?.parameters ?? [], byName, context);
|
|
19
|
+
function keyMember(url, parts, type, isReadonly) {
|
|
20
|
+
const key = pathKeyOf(parts);
|
|
21
|
+
if (key.kind === "literal") {
|
|
22
|
+
const member2 = constructors.irProperty(propertyName.toPropertyName(key.url), type, { isReadonly });
|
|
23
|
+
return { url, member: member2, key, type };
|
|
42
24
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
25
|
+
const member = {
|
|
26
|
+
kind: "indexSignature",
|
|
27
|
+
parameterName: "path",
|
|
28
|
+
parameterType: constructors.irRaw(pathTemplateKey.templateText(parts)),
|
|
29
|
+
type,
|
|
30
|
+
isReadonly,
|
|
31
|
+
comments: []
|
|
32
|
+
};
|
|
33
|
+
return { url, member, key, type };
|
|
51
34
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
return
|
|
35
|
+
function isUntakenKey(url, key, takenUrls) {
|
|
36
|
+
const isExpandedUrl = key.kind === "literal" && key.url !== url;
|
|
37
|
+
if (!isExpandedUrl) {
|
|
38
|
+
return true;
|
|
56
39
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };
|
|
61
|
-
});
|
|
62
|
-
return context.options.fixes.has(outputFixes.FIX.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : pathTemplateReplace.replacedTemplateParts(url, matches);
|
|
40
|
+
const isTaken = takenUrls.has(key.url);
|
|
41
|
+
takenUrls.add(key.url);
|
|
42
|
+
return !isTaken;
|
|
63
43
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
(part) => part.kind === "text" ? rawTextEscapes.escapeTemplateText(part.text) : pathTemplateReplace.placeholderText(part.type)
|
|
67
|
-
).join("");
|
|
68
|
-
return `\`${text}\``;
|
|
44
|
+
function withoutTakenUrls(url, members, takenUrls) {
|
|
45
|
+
return members.filter(({ key }) => isUntakenKey(url, key, takenUrls));
|
|
69
46
|
}
|
|
70
|
-
function
|
|
47
|
+
function pathItemMembers(url, pathItem$1, context) {
|
|
71
48
|
const isReadonly = context.options.immutable;
|
|
72
49
|
const type = pathItem.pathItemType(
|
|
73
50
|
pathItem$1,
|
|
74
51
|
{ path: jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, ["paths", url]) },
|
|
75
52
|
context
|
|
76
53
|
);
|
|
77
|
-
const parts = context.options.pathParamsAsTypes && url.includes("{") ? pathTemplateParts(url, pathItem$1, context) : null;
|
|
54
|
+
const parts = context.options.pathParamsAsTypes && url.includes("{") ? pathTemplateKey.pathTemplateParts(url, pathItem$1, context) : null;
|
|
78
55
|
if (parts === null) {
|
|
79
|
-
const
|
|
80
|
-
return { url, member
|
|
56
|
+
const member = constructors.irProperty(propertyName.toPropertyName(url), type, { isReadonly });
|
|
57
|
+
return [{ url, member, key: literalKey(url), type }];
|
|
81
58
|
}
|
|
82
|
-
|
|
83
|
-
kind: "indexSignature",
|
|
84
|
-
parameterName: "path",
|
|
85
|
-
parameterType: constructors.irRaw(templateText(parts)),
|
|
86
|
-
type,
|
|
87
|
-
isReadonly,
|
|
88
|
-
comments: []
|
|
89
|
-
};
|
|
90
|
-
return { url, member, key: { kind: "template", parts }, type };
|
|
59
|
+
return pathTemplateKey.booleanExpandedKeys(parts).map((key) => keyMember(url, key, type, isReadonly));
|
|
91
60
|
}
|
|
92
61
|
function literalKey(url) {
|
|
93
62
|
return { kind: "literal", url };
|
|
@@ -128,6 +97,7 @@ function pathsObjectType(paths, lookup = declaredTypes.NO_DECLARED_TYPES) {
|
|
|
128
97
|
}
|
|
129
98
|
function pathMembers(paths, context) {
|
|
130
99
|
const members = [];
|
|
100
|
+
const takenUrls = new Set(Object.keys(paths));
|
|
131
101
|
for (const [url, pathItem] of documentEntries.documentEntries(paths, context.options)) {
|
|
132
102
|
if (!pathItem || typeof pathItem !== "object") {
|
|
133
103
|
continue;
|
|
@@ -139,9 +109,9 @@ function pathMembers(paths, context) {
|
|
|
139
109
|
continue;
|
|
140
110
|
}
|
|
141
111
|
const startedAt = context.diagnostics.now();
|
|
142
|
-
const
|
|
143
|
-
members.push(
|
|
144
|
-
if (
|
|
112
|
+
const pathMembersOfUrl = pathItemMembers(url, pathItem, context);
|
|
113
|
+
members.push(...withoutTakenUrls(url, pathMembersOfUrl, takenUrls));
|
|
114
|
+
if (pathMembersOfUrl[0]?.key.kind === "literal" && pathMembersOfUrl[0].key.url === url) {
|
|
145
115
|
context.diagnostics.debug(`Transformed path "${url}"`, context.diagnostics.now() - startedAt);
|
|
146
116
|
}
|
|
147
117
|
}
|
|
@@ -151,6 +121,8 @@ function pathsType(paths, context) {
|
|
|
151
121
|
return pathsObjectType(pathMembers(paths, context));
|
|
152
122
|
}
|
|
153
123
|
|
|
124
|
+
exports.isUntakenKey = isUntakenKey;
|
|
125
|
+
exports.pathKeyOf = pathKeyOf;
|
|
154
126
|
exports.pathMembers = pathMembers;
|
|
155
127
|
exports.pathsObjectType = pathsObjectType;
|
|
156
128
|
exports.pathsType = pathsType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.cjs","sources":["../../../../src/application/transform/document/paths.ts"],"sourcesContent":["import { irIntersection, irObject, irProperty, irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n type PathsObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { type DeclaredTypeLookup, NO_DECLARED_TYPES } from \"./declared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport {\n type CoverRejection,\n coveringTemplateKeys,\n type PathKey,\n type PathKeyPart,\n type PathPlaceholder,\n} from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\nimport { assignabilityProof } from \"./type-assignability.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nfunction pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nfunction templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\n/** A path's member, its key and its path item type for the overlap check. */\nexport interface PathMember {\n readonly url: string;\n readonly member: IrMember;\n readonly key: PathKey;\n readonly type: IrType;\n}\n\nfunction pathItemMember(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathMember {\n const isReadonly = context.options.immutable;\n const type = pathItemType(\n pathItem,\n { path: appendPointer(ROOT_POINTER, [\"paths\", url]) },\n context,\n );\n const parts =\n context.options.pathParamsAsTypes && url.includes(\"{\")\n ? pathTemplateParts(url, pathItem, context)\n : null;\n if (parts === null) {\n const member = irProperty(toPropertyName(url), type, { isReadonly });\n return { url, member, key: literalKey(url), type };\n }\n const member: IrMember = {\n kind: \"indexSignature\",\n parameterName: \"path\",\n parameterType: irRaw(templateText(parts)),\n type,\n isReadonly,\n comments: [],\n };\n return { url, member, key: { kind: \"template\", parts }, type };\n}\n\nfunction literalKey(url: string): PathKey {\n return { kind: \"literal\", url };\n}\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/** The URL of `paths[\"/apps/{id}\"]`, or null for any other type. */\nfunction pathsIndexOf(type: IrType): string | null {\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const { object } = type;\n const isPaths =\n object.kind === \"reference\" &&\n object.name === PATHS_TYPE_NAME &&\n object.typeArguments.length === 0;\n return isPaths ? type.index.value : null;\n}\n\n/**\n * The lookup, and `paths[\"/apps/{id}\"]` as that path's item. The declarations cannot read it: a\n * templated path is no property of `paths`, and TypeScript finds it through the signature.\n */\nfunction withPathItems(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup,\n): DeclaredTypeLookup {\n const byUrl = new Map(paths.map((path) => [path.url, path.type]));\n return (type) => {\n const url = pathsIndexOf(type);\n return (url === null ? undefined : byUrl.get(url)) ?? lookup(type);\n };\n}\n\n/**\n * The rejection of a covered path item: only one proven not assignable to the signature's type\n * counts (ADR-028). A pair the proof cannot decide keeps the original output, which may well\n * compile (`Record<string, never>` fits `{ [key: string]: unknown }`).\n */\nfunction rejectionOf(paths: readonly PathMember[], lookup: DeclaredTypeLookup): CoverRejection {\n const relate = assignabilityProof(withPathItems(paths, lookup));\n return (coveringIndex, coveredIndex) => {\n const coveringPath = paths[coveringIndex];\n const coveredPath = paths[coveredIndex];\n return (\n coveringPath !== undefined &&\n coveredPath !== undefined &&\n relate(coveredPath.type, coveringPath.type) === \"rejected\"\n );\n };\n}\n\n/**\n * The members as one object type. When an index signature covers another key, TypeScript checks\n * the covered key's type against it. Where that check surely fails (TS2411, TS2413), each such\n * signature gets an object of its own in an intersection: an intersection does not check its parts\n * against each other, and every key has the type it had in the one object. Output that compiles\n * keeps the one object. The lookup reads the types that path items reference; without it, a\n * reference decides nothing.\n */\nexport function pathsObjectType(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup = NO_DECLARED_TYPES,\n): IrType {\n const keys = paths.map(({ key }) => key);\n const covering = coveringTemplateKeys(keys, rejectionOf(paths, lookup));\n if (covering.size === 0) {\n return irObject(paths.map(({ member }) => member));\n }\n const rest = paths.filter((_, index) => !covering.has(index)).map(({ member }) => member);\n const own = paths\n .filter((_, index) => covering.has(index))\n .map(({ member }) => irObject([member]));\n return irIntersection([irObject(rest), ...own]);\n}\n\n/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */\nexport function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {\n const members: PathMember[] = [];\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\") {\n continue;\n }\n if (\"$ref\" in pathItem) {\n const options = { isReadonly: context.options.immutable };\n const member = documentMember(url, refType(pathItem.$ref), pathItem, options);\n members.push({ url, member, key: literalKey(url), type: member.type });\n continue;\n }\n const startedAt = context.diagnostics.now();\n const path = pathItemMember(url, pathItem, context);\n members.push(path);\n // The original reports only paths written as properties.\n if (path.member.kind === \"property\") {\n context.diagnostics.debug(`Transformed path \"${url}\"`, context.diagnostics.now() - startedAt);\n }\n }\n return members;\n}\n\n/**\n * The `paths` interface body, with only the path items' own types for the overlap check. The\n * document transform checks the overlaps again once the referenced types are declared.\n */\nexport function pathsType(paths: PathsObject, context: TransformContext): IrType {\n return pathsObjectType(pathMembers(paths, context));\n}\n"],"names":["pathItemOperations","FIX","replacedTemplateParts","escapeTemplateText","placeholderText","pathItem","pathItemType","appendPointer","ROOT_POINTER","member","irProperty","toPropertyName","irRaw","assignabilityProof","NO_DECLARED_TYPES","coveringTemplateKeys","irObject","irIntersection","documentEntries","documentMember","refType"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,MAAM,iBAAA,GAAoB,aAAA;AAG1B,MAAM,YAAA,uBAA0D,GAAA,CAAI;AAAA,EAClE,CAAC,UAAU,QAAQ,CAAA;AAAA,EACnB,CAAC,WAAW,QAAQ,CAAA;AAAA,EACpB,CAAC,WAAW,SAAS;AACvB,CAAC,CAAA;AACD,MAAM,kBAAA,GAAsC,QAAA;AAE5C,SAAS,iBAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,OAAO,MAAA,IAAU,aAAa,SAAA,CAAU,IAAA,GACnC,QAAQ,IAAA,CAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACnC,SAAA;AACP;AAEA,SAAS,iBAAA,CACP,UAAA,EACA,MAAA,EACA,OAAA,EACM;AACN,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,MAAM,QAAA,GAAW,iBAAA,CAAkB,SAAA,EAAW,OAAO,CAAA;AACrD,IAAA,IAAI,QAAA,IAAY,QAAA,CAAS,EAAA,KAAO,MAAA,EAAQ;AACtC,MAAA,MAAA,CAAO,GAAA,CAAI,QAAA,CAAS,IAAA,EAAM,QAAQ,CAAA;AAAA,IACpC;AAAA,EACF;AACF;AAGA,SAAS,cAAA,CACP,UACA,OAAA,EAC8B;AAC9B,EAAA,MAAM,MAAA,uBAAa,GAAA,EAA6B;AAChD,EAAA,iBAAA,CAAkB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG,QAAQ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Y,GAAA,EAAI,GAAI,SAAS,CAAA;AAAA,IAC9F;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,SAAA,CAAU,OAAoB,OAAA,EAAmC;AAC/E,EAAA,OAAO,eAAA,CAAgB,WAAA,CAAY,KAAA,EAAO,OAAO,CAAC,CAAA;AACpD;;;;"}
|
|
1
|
+
{"version":3,"file":"paths.cjs","sources":["../../../../src/application/transform/document/paths.ts"],"sourcesContent":["import { irIntersection, irObject, irProperty, irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { PathItemObject, PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { type DeclaredTypeLookup, NO_DECLARED_TYPES } from \"./declared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport {\n type CoverRejection,\n coveringTemplateKeys,\n type PathKey,\n type PathKeyPart,\n} from \"./path-key-overlaps.js\";\nimport {\n booleanExpandedKeys,\n pathTemplateParts,\n plainUrlOf,\n templateText,\n} from \"./path-template-key.js\";\nimport { assignabilityProof } from \"./type-assignability.js\";\n\n/** A path's member, its key and its path item type for the overlap check. */\nexport interface PathMember {\n readonly url: string;\n readonly member: IrMember;\n readonly key: PathKey;\n readonly type: IrType;\n}\n\n/** The key of the parts: a plain URL, or a template with placeholders left. */\nexport function pathKeyOf(parts: readonly PathKeyPart[]): PathKey {\n const plainUrl = plainUrlOf(parts);\n return plainUrl === null ? { kind: \"template\", parts } : literalKey(plainUrl);\n}\n\n/** The member of one key of a path: a property for a plain URL, else an index signature. */\nfunction keyMember(url: string, parts: readonly PathKeyPart[], type: IrType, isReadonly: boolean) {\n const key = pathKeyOf(parts);\n if (key.kind === \"literal\") {\n const member = irProperty(toPropertyName(key.url), type, { isReadonly });\n return { url, member, key, type };\n }\n const member: IrMember = {\n kind: \"indexSignature\",\n parameterName: \"path\",\n parameterType: irRaw(templateText(parts)),\n type,\n isReadonly,\n comments: [],\n };\n return { url, member, key, type };\n}\n\n/**\n * Whether a key of the path at `url` is written. A URL that `${boolean}` keys give is not when it\n * is taken already: by a path of the document, which OpenAPI matches before a template (Paths\n * Object), or by the keys of an earlier path. A property written twice does not compile (TS2300).\n * `takenUrls` starts with the document's URLs and gets each expanded URL, in document order.\n */\nexport function isUntakenKey(url: string, key: PathKey, takenUrls: Set<string>): boolean {\n const isExpandedUrl = key.kind === \"literal\" && key.url !== url;\n if (!isExpandedUrl) {\n return true;\n }\n const isTaken = takenUrls.has(key.url);\n takenUrls.add(key.url);\n return !isTaken;\n}\n\nfunction withoutTakenUrls(url: string, members: readonly PathMember[], takenUrls: Set<string>) {\n return members.filter(({ key }) => isUntakenKey(url, key, takenUrls));\n}\n\n/** The members of a path: one, or one per key of its `${boolean}` placeholders. */\nfunction pathItemMembers(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathMember[] {\n const isReadonly = context.options.immutable;\n const type = pathItemType(\n pathItem,\n { path: appendPointer(ROOT_POINTER, [\"paths\", url]) },\n context,\n );\n const parts =\n context.options.pathParamsAsTypes && url.includes(\"{\")\n ? pathTemplateParts(url, pathItem, context)\n : null;\n if (parts === null) {\n const member = irProperty(toPropertyName(url), type, { isReadonly });\n return [{ url, member, key: literalKey(url), type }];\n }\n return booleanExpandedKeys(parts).map((key) => keyMember(url, key, type, isReadonly));\n}\n\nfunction literalKey(url: string): PathKey {\n return { kind: \"literal\", url };\n}\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/** The URL of `paths[\"/apps/{id}\"]`, or null for any other type. */\nfunction pathsIndexOf(type: IrType): string | null {\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const { object } = type;\n const isPaths =\n object.kind === \"reference\" &&\n object.name === PATHS_TYPE_NAME &&\n object.typeArguments.length === 0;\n return isPaths ? type.index.value : null;\n}\n\n/**\n * The lookup, and `paths[\"/apps/{id}\"]` as that path's item. The declarations cannot read it: a\n * templated path is no property of `paths`, and TypeScript finds it through the signature.\n */\nfunction withPathItems(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup,\n): DeclaredTypeLookup {\n const byUrl = new Map(paths.map((path) => [path.url, path.type]));\n return (type) => {\n const url = pathsIndexOf(type);\n return (url === null ? undefined : byUrl.get(url)) ?? lookup(type);\n };\n}\n\n/**\n * The rejection of a covered path item: only one proven not assignable to the signature's type\n * counts (ADR-028). A pair the proof cannot decide keeps the original output, which may well\n * compile (`Record<string, never>` fits `{ [key: string]: unknown }`).\n */\nfunction rejectionOf(paths: readonly PathMember[], lookup: DeclaredTypeLookup): CoverRejection {\n const relate = assignabilityProof(withPathItems(paths, lookup));\n return (coveringIndex, coveredIndex) => {\n const coveringPath = paths[coveringIndex];\n const coveredPath = paths[coveredIndex];\n return (\n coveringPath !== undefined &&\n coveredPath !== undefined &&\n relate(coveredPath.type, coveringPath.type) === \"rejected\"\n );\n };\n}\n\n/**\n * The members as one object type. When an index signature covers another key, TypeScript checks\n * the covered key's type against it. Where that check surely fails (TS2411, TS2413), each such\n * signature gets an object of its own in an intersection: an intersection does not check its parts\n * against each other, and every key has the type it had in the one object. Output that compiles\n * keeps the one object. The lookup reads the types that path items reference; without it, a\n * reference decides nothing.\n */\nexport function pathsObjectType(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup = NO_DECLARED_TYPES,\n): IrType {\n const keys = paths.map(({ key }) => key);\n const covering = coveringTemplateKeys(keys, rejectionOf(paths, lookup));\n if (covering.size === 0) {\n return irObject(paths.map(({ member }) => member));\n }\n const rest = paths.filter((_, index) => !covering.has(index)).map(({ member }) => member);\n const own = paths\n .filter((_, index) => covering.has(index))\n .map(({ member }) => irObject([member]));\n return irIntersection([irObject(rest), ...own]);\n}\n\n/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */\nexport function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {\n const members: PathMember[] = [];\n const takenUrls = new Set(Object.keys(paths));\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\") {\n continue;\n }\n if (\"$ref\" in pathItem) {\n const options = { isReadonly: context.options.immutable };\n const member = documentMember(url, refType(pathItem.$ref), pathItem, options);\n members.push({ url, member, key: literalKey(url), type: member.type });\n continue;\n }\n const startedAt = context.diagnostics.now();\n const pathMembersOfUrl = pathItemMembers(url, pathItem, context);\n members.push(...withoutTakenUrls(url, pathMembersOfUrl, takenUrls));\n // The original reports only paths written as properties.\n if (pathMembersOfUrl[0]?.key.kind === \"literal\" && pathMembersOfUrl[0].key.url === url) {\n context.diagnostics.debug(`Transformed path \"${url}\"`, context.diagnostics.now() - startedAt);\n }\n }\n return members;\n}\n\n/**\n * The `paths` interface body, with only the path items' own types for the overlap check. The\n * document transform checks the overlaps again once the referenced types are declared.\n */\nexport function pathsType(paths: PathsObject, context: TransformContext): IrType {\n return pathsObjectType(pathMembers(paths, context));\n}\n"],"names":["plainUrlOf","member","irProperty","toPropertyName","irRaw","templateText","pathItem","pathItemType","appendPointer","ROOT_POINTER","pathTemplateParts","booleanExpandedKeys","assignabilityProof","NO_DECLARED_TYPES","coveringTemplateKeys","irObject","irIntersection","documentEntries","documentMember","refType"],"mappings":";;;;;;;;;;;;;;AAkCO,SAAS,UAAU,KAAA,EAAwC;AAChE,EAAA,MAAM,QAAA,GAAWA,2BAAW,KAAK,CAAA;AACjC,EAAA,OAAO,QAAA,KAAa,OAAO,EAAE,IAAA,EAAM,YAAY,KAAA,EAAM,GAAI,WAAW,QAAQ,CAAA;AAC9E;AAGA,SAAS,SAAA,CAAU,GAAA,EAAa,KAAA,EAA+B,IAAA,EAAc,UAAA,EAAqB;AAChG,EAAA,MAAM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