openapi-typesafe 1.0.0-rc.0 → 1.0.0-rc.1
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/dist/adapters/redocly-loader/redocly-config-source.cjs +21 -2
- package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-config-source.mjs +22 -3
- package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +15 -5
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +15 -5
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +3 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +3 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs +15 -9
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs +15 -9
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs +25 -0
- package/dist/api/discriminator-conflict-warnings.cjs.map +1 -0
- package/dist/api/discriminator-conflict-warnings.mjs +23 -0
- package/dist/api/discriminator-conflict-warnings.mjs.map +1 -0
- package/dist/api/discriminator-enum-names.cjs +19 -0
- package/dist/api/discriminator-enum-names.cjs.map +1 -0
- package/dist/api/discriminator-enum-names.mjs +17 -0
- package/dist/api/discriminator-enum-names.mjs.map +1 -0
- package/dist/api/discriminator-enum-parent.cjs +59 -0
- package/dist/api/discriminator-enum-parent.cjs.map +1 -0
- package/dist/api/discriminator-enum-parent.mjs +57 -0
- package/dist/api/discriminator-enum-parent.mjs.map +1 -0
- package/dist/api/discriminator-enum.cjs +25 -0
- package/dist/api/discriminator-enum.cjs.map +1 -1
- package/dist/api/discriminator-enum.mjs +25 -1
- package/dist/api/discriminator-enum.mjs.map +1 -1
- package/dist/api/discriminator-other-owners.cjs +67 -0
- package/dist/api/discriminator-other-owners.cjs.map +1 -0
- package/dist/api/discriminator-other-owners.mjs +64 -0
- package/dist/api/discriminator-other-owners.mjs.map +1 -0
- package/dist/api/discriminator-patch.cjs +88 -0
- package/dist/api/discriminator-patch.cjs.map +1 -0
- package/dist/api/discriminator-patch.mjs +82 -0
- package/dist/api/discriminator-patch.mjs.map +1 -0
- package/dist/api/discriminator-scan.cjs +50 -65
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +44 -59
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-run.cjs +18 -3
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +19 -4
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/enum-values-warnings.cjs +16 -0
- package/dist/api/enum-values-warnings.cjs.map +1 -0
- package/dist/api/enum-values-warnings.mjs +14 -0
- package/dist/api/enum-values-warnings.mjs.map +1 -0
- package/dist/api/path-template-warnings.cjs +21 -0
- package/dist/api/path-template-warnings.cjs.map +1 -0
- package/dist/api/path-template-warnings.mjs +19 -0
- package/dist/api/path-template-warnings.mjs.map +1 -0
- package/dist/api/transform-context.cjs +3 -1
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +3 -1
- package/dist/api/transform-context.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +52 -3
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +53 -4
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/api/unsupported-feature-warnings.cjs +6 -1
- package/dist/api/unsupported-feature-warnings.cjs.map +1 -1
- package/dist/api/unsupported-feature-warnings.mjs +6 -1
- package/dist/api/unsupported-feature-warnings.mjs.map +1 -1
- package/dist/application/print/type-printer.cjs +5 -0
- package/dist/application/print/type-printer.cjs.map +1 -1
- package/dist/application/print/type-printer.mjs +5 -0
- package/dist/application/print/type-printer.mjs.map +1 -1
- package/dist/application/transform/document/assignability.cjs +144 -0
- package/dist/application/transform/document/assignability.cjs.map +1 -0
- package/dist/application/transform/document/assignability.mjs +138 -0
- package/dist/application/transform/document/assignability.mjs.map +1 -0
- package/dist/application/transform/document/components.cjs +2 -2
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +4 -4
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/declared-types.cjs +66 -0
- package/dist/application/transform/document/declared-types.cjs.map +1 -0
- package/dist/application/transform/document/declared-types.mjs +63 -0
- package/dist/application/transform/document/declared-types.mjs.map +1 -0
- package/dist/application/transform/document/document.cjs +32 -9
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +34 -11
- package/dist/application/transform/document/document.mjs.map +1 -1
- package/dist/application/transform/document/exploded-query.cjs +46 -0
- package/dist/application/transform/document/exploded-query.cjs.map +1 -0
- package/dist/application/transform/document/exploded-query.mjs +43 -0
- package/dist/application/transform/document/exploded-query.mjs.map +1 -0
- package/dist/application/transform/document/global-type-references.cjs +63 -0
- package/dist/application/transform/document/global-type-references.cjs.map +1 -0
- package/dist/application/transform/document/global-type-references.mjs +61 -0
- package/dist/application/transform/document/global-type-references.mjs.map +1 -0
- package/dist/application/transform/document/list-assignability.cjs +54 -0
- package/dist/application/transform/document/list-assignability.cjs.map +1 -0
- package/dist/application/transform/document/list-assignability.mjs +52 -0
- package/dist/application/transform/document/list-assignability.mjs.map +1 -0
- package/dist/application/transform/document/parameters.cjs +40 -8
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +41 -9
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-key-overlaps.cjs +83 -33
- package/dist/application/transform/document/path-key-overlaps.cjs.map +1 -1
- package/dist/application/transform/document/path-key-overlaps.mjs +83 -33
- package/dist/application/transform/document/path-key-overlaps.mjs.map +1 -1
- package/dist/application/transform/document/path-template-replace.cjs +48 -0
- package/dist/application/transform/document/path-template-replace.cjs.map +1 -0
- package/dist/application/transform/document/path-template-replace.mjs +45 -0
- package/dist/application/transform/document/path-template-replace.mjs.map +1 -0
- package/dist/application/transform/document/paths.cjs +54 -28
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +53 -29
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.cjs +15 -14
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.mjs +15 -13
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
- package/dist/application/transform/document/template-key-match.cjs +128 -0
- package/dist/application/transform/document/template-key-match.cjs.map +1 -0
- package/dist/application/transform/document/template-key-match.mjs +125 -0
- package/dist/application/transform/document/template-key-match.mjs.map +1 -0
- package/dist/application/transform/document/type-assignability.cjs +192 -0
- package/dist/application/transform/document/type-assignability.cjs.map +1 -0
- package/dist/application/transform/document/type-assignability.mjs +190 -0
- package/dist/application/transform/document/type-assignability.mjs.map +1 -0
- package/dist/application/transform/document/type-key.cjs +70 -0
- package/dist/application/transform/document/type-key.cjs.map +1 -0
- package/dist/application/transform/document/type-key.mjs +68 -0
- package/dist/application/transform/document/type-key.mjs.map +1 -0
- package/dist/application/transform/document/type-resolution.cjs +131 -0
- package/dist/application/transform/document/type-resolution.cjs.map +1 -0
- package/dist/application/transform/document/type-resolution.mjs +125 -0
- package/dist/application/transform/document/type-resolution.mjs.map +1 -0
- package/dist/application/transform/footer/document-footer.cjs +66 -4
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +67 -5
- package/dist/application/transform/footer/document-footer.mjs.map +1 -1
- package/dist/application/transform/footer/enum-naming.cjs +17 -0
- package/dist/application/transform/footer/enum-naming.cjs.map +1 -1
- package/dist/application/transform/footer/enum-naming.mjs +17 -1
- package/dist/application/transform/footer/enum-naming.mjs.map +1 -1
- package/dist/application/transform/footer/enum-values-check.cjs +129 -0
- package/dist/application/transform/footer/enum-values-check.cjs.map +1 -0
- package/dist/application/transform/footer/enum-values-check.mjs +127 -0
- package/dist/application/transform/footer/enum-values-check.mjs.map +1 -0
- package/dist/application/transform/footer/evaluation.cjs +33 -0
- package/dist/application/transform/footer/evaluation.cjs.map +1 -0
- package/dist/application/transform/footer/evaluation.mjs +26 -0
- package/dist/application/transform/footer/evaluation.mjs.map +1 -0
- package/dist/application/transform/footer/shared-enum-names.cjs +60 -0
- package/dist/application/transform/footer/shared-enum-names.cjs.map +1 -0
- package/dist/application/transform/footer/shared-enum-names.mjs +57 -0
- package/dist/application/transform/footer/shared-enum-names.mjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.cjs +246 -0
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.mjs +244 -0
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -0
- package/dist/application/transform/footer/type-rules.cjs +172 -0
- package/dist/application/transform/footer/type-rules.cjs.map +1 -0
- package/dist/application/transform/footer/type-rules.mjs +166 -0
- package/dist/application/transform/footer/type-rules.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-location.cjs +138 -0
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-location.mjs +136 -0
- package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-shape.cjs +171 -0
- package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-shape.mjs +162 -0
- package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/inline-cycles.cjs +44 -0
- package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/inline-cycles.mjs +42 -0
- package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.cjs +62 -0
- package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.mjs +60 -0
- package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-type.cjs +60 -0
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-type.mjs +57 -0
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-walk.cjs +66 -0
- package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-walk.mjs +56 -0
- package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs +124 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.mjs +122 -0
- package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -0
- package/dist/application/transform/ref-type.cjs +7 -2
- package/dist/application/transform/ref-type.cjs.map +1 -1
- package/dist/application/transform/ref-type.mjs +3 -2
- package/dist/application/transform/ref-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs +38 -0
- package/dist/application/transform/schema/access-flags.cjs.map +1 -0
- package/dist/application/transform/schema/access-flags.mjs +36 -0
- package/dist/application/transform/schema/access-flags.mjs.map +1 -0
- package/dist/application/transform/schema/array-type.cjs +32 -1
- package/dist/application/transform/schema/array-type.cjs.map +1 -1
- package/dist/application/transform/schema/array-type.mjs +33 -2
- package/dist/application/transform/schema/array-type.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +50 -15
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +50 -15
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/core-type.cjs +3 -1
- package/dist/application/transform/schema/core-type.cjs.map +1 -1
- package/dist/application/transform/schema/core-type.mjs +3 -1
- package/dist/application/transform/schema/core-type.mjs.map +1 -1
- package/dist/application/transform/schema/discriminated-union.cjs +30 -0
- package/dist/application/transform/schema/discriminated-union.cjs.map +1 -0
- package/dist/application/transform/schema/discriminated-union.mjs +27 -0
- package/dist/application/transform/schema/discriminated-union.mjs.map +1 -0
- package/dist/application/transform/schema/discriminator-property.cjs +3 -2
- package/dist/application/transform/schema/discriminator-property.cjs.map +1 -1
- package/dist/application/transform/schema/discriminator-property.mjs +3 -2
- package/dist/application/transform/schema/discriminator-property.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +66 -10
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +67 -12
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/inherited-discriminator.cjs +29 -0
- package/dist/application/transform/schema/inherited-discriminator.cjs.map +1 -0
- package/dist/application/transform/schema/inherited-discriminator.mjs +26 -0
- package/dist/application/transform/schema/inherited-discriminator.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +38 -25
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +39 -27
- package/dist/application/transform/schema/object-type.mjs.map +1 -1
- package/dist/application/transform/schema/required-variants.cjs +45 -0
- package/dist/application/transform/schema/required-variants.cjs.map +1 -0
- package/dist/application/transform/schema/required-variants.mjs +42 -0
- package/dist/application/transform/schema/required-variants.mjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.cjs +2 -2
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +2 -2
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +51 -5
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +50 -6
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/application/transform/type-combinators.mjs +1 -1
- package/dist/cli/cli-arguments.cjs +11 -3
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +11 -3
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/cli-errors.cjs +3 -2
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +3 -2
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +8 -3
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +9 -4
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +5 -0
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +5 -0
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +7 -3
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +8 -4
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/ref-limits.cjs +1 -1
- package/dist/cli/ref-limits.cjs.map +1 -1
- package/dist/cli/ref-limits.mjs +2 -2
- package/dist/cli/ref-limits.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +15 -2
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +16 -3
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/errors.cjs +2 -0
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +2 -0
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/constructors.cjs +5 -1
- package/dist/domain/ir/constructors.cjs.map +1 -1
- package/dist/domain/ir/constructors.mjs +5 -2
- package/dist/domain/ir/constructors.mjs.map +1 -1
- package/dist/domain/openapi/admitted-values.cjs +75 -0
- package/dist/domain/openapi/admitted-values.cjs.map +1 -0
- package/dist/domain/openapi/admitted-values.mjs +72 -0
- package/dist/domain/openapi/admitted-values.mjs.map +1 -0
- package/dist/domain/openapi/discriminated-union.cjs +68 -0
- package/dist/domain/openapi/discriminated-union.cjs.map +1 -0
- package/dist/domain/openapi/discriminated-union.mjs +62 -0
- package/dist/domain/openapi/discriminated-union.mjs.map +1 -0
- package/dist/domain/openapi/discriminator-conflicts.cjs +143 -0
- package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -0
- package/dist/domain/openapi/discriminator-conflicts.mjs +141 -0
- package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -0
- package/dist/domain/openapi/parameter-object.cjs.map +1 -1
- package/dist/domain/openapi/parameter-object.mjs.map +1 -1
- package/dist/domain/openapi/path-templates.cjs +23 -0
- package/dist/domain/openapi/path-templates.cjs.map +1 -0
- package/dist/domain/openapi/path-templates.mjs +21 -0
- package/dist/domain/openapi/path-templates.mjs.map +1 -0
- package/dist/domain/output-fixes.cjs +36 -1
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +36 -1
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/warnings.cjs +15 -0
- package/dist/domain/warnings.cjs.map +1 -0
- package/dist/domain/warnings.mjs +12 -0
- package/dist/domain/warnings.mjs.map +1 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/transform/components-object.cjs +2 -1
- package/dist/transform/components-object.cjs.map +1 -1
- package/dist/transform/components-object.mjs +2 -1
- package/dist/transform/components-object.mjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/redocly-loader/redocly-config-source.ts +41 -6
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -6
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +3 -0
- package/src/adapters/type-ast-bridge/typescript-to-ir.ts +26 -12
- package/src/api/discriminator-conflict-warnings.ts +43 -0
- package/src/api/discriminator-enum-names.ts +26 -0
- package/src/api/discriminator-enum-parent.ts +129 -0
- package/src/api/discriminator-enum.ts +39 -0
- package/src/api/discriminator-other-owners.ts +97 -0
- package/src/api/discriminator-patch.ts +147 -0
- package/src/api/discriminator-scan.ts +78 -90
- package/src/api/document-run.ts +24 -6
- package/src/api/enum-values-warnings.ts +21 -0
- package/src/api/path-template-warnings.ts +27 -0
- package/src/api/transform-context.ts +7 -1
- package/src/api/transform-schema.ts +88 -4
- package/src/api/unsupported-feature-warnings.ts +8 -1
- package/src/application/ports/redocly-config-source.ts +5 -1
- package/src/application/print/type-printer.ts +6 -0
- package/src/application/transform/document/assignability.ts +203 -0
- package/src/application/transform/document/components.ts +6 -6
- package/src/application/transform/document/declared-types.ts +93 -0
- package/src/application/transform/document/document.ts +71 -13
- package/src/application/transform/document/exploded-query.ts +91 -0
- package/src/application/transform/document/global-type-references.ts +78 -0
- package/src/application/transform/document/list-assignability.ts +87 -0
- package/src/application/transform/document/parameters.ts +76 -11
- package/src/application/transform/document/path-key-overlaps.ts +148 -59
- package/src/application/transform/document/path-template-replace.ts +90 -0
- package/src/application/transform/document/paths.ts +99 -37
- package/src/application/transform/document/root-type-aliases.ts +29 -28
- package/src/application/transform/document/template-key-match.ts +183 -0
- package/src/application/transform/document/type-assignability.ts +268 -0
- package/src/application/transform/document/type-key.ts +80 -0
- package/src/application/transform/document/type-resolution.ts +163 -0
- package/src/application/transform/footer/document-footer.ts +91 -6
- package/src/application/transform/footer/enum-naming.ts +29 -0
- package/src/application/transform/footer/enum-values-check.ts +171 -0
- package/src/application/transform/footer/evaluation.ts +47 -0
- package/src/application/transform/footer/shared-enum-names.ts +86 -0
- package/src/application/transform/footer/type-evaluation.ts +294 -0
- package/src/application/transform/footer/type-rules.ts +269 -0
- package/src/application/transform/ref-pointer/generated-location.ts +211 -0
- package/src/application/transform/ref-pointer/generated-shape.ts +275 -0
- package/src/application/transform/ref-pointer/inline-cycles.ts +56 -0
- package/src/application/transform/ref-pointer/original-index.ts +95 -0
- package/src/application/transform/ref-pointer/pointer-type.ts +92 -0
- package/src/application/transform/ref-pointer/pointer-walk.ts +96 -0
- package/src/application/transform/ref-pointer/typed-walk.ts +192 -0
- package/src/application/transform/ref-type.ts +11 -6
- package/src/application/transform/schema/access-flags.ts +63 -0
- package/src/application/transform/schema/array-type.ts +66 -5
- package/src/application/transform/schema/composition-type.ts +96 -24
- package/src/application/transform/schema/core-type.ts +8 -4
- package/src/application/transform/schema/discriminated-union.ts +58 -0
- package/src/application/transform/schema/discriminator-property.ts +8 -3
- package/src/application/transform/schema/enum-rule.ts +136 -13
- package/src/application/transform/schema/inherited-discriminator.ts +54 -0
- package/src/application/transform/schema/object-type.ts +51 -33
- package/src/application/transform/schema/required-variants.ts +88 -0
- package/src/application/transform/schema/schema-context.ts +26 -0
- package/src/application/transform/schema/schema-transform.ts +2 -2
- package/src/application/transform/schema-comment.ts +84 -4
- package/src/cli/cli-arguments.ts +13 -3
- package/src/cli/cli-dependencies.ts +5 -0
- package/src/cli/cli-errors.ts +4 -2
- package/src/cli/cli-output.ts +18 -4
- package/src/cli/main.ts +6 -0
- package/src/cli/redocly-apis.ts +8 -4
- package/src/cli/ref-limits.ts +2 -2
- package/src/cli/run-cli.ts +20 -3
- package/src/domain/errors.ts +2 -0
- package/src/domain/ir/constructors.ts +6 -1
- package/src/domain/ir/nodes.ts +2 -1
- package/src/domain/openapi/admitted-values.ts +113 -0
- package/src/domain/openapi/discriminated-union.ts +109 -0
- package/src/domain/openapi/discriminator-conflicts.ts +251 -0
- package/src/domain/openapi/parameter-object.ts +4 -0
- package/src/domain/openapi/path-templates.ts +31 -0
- package/src/domain/openapi/schema-object.ts +2 -0
- package/src/domain/output-fixes.ts +43 -2
- package/src/domain/warnings.ts +20 -0
- package/src/transform/components-object.ts +3 -1
- package/src/types/generator-options.ts +11 -0
- package/dist/application/transform/document/path-item-conflicts.cjs +0 -51
- package/dist/application/transform/document/path-item-conflicts.cjs.map +0 -1
- package/dist/application/transform/document/path-item-conflicts.mjs +0 -49
- package/dist/application/transform/document/path-item-conflicts.mjs.map +0 -1
- package/src/application/transform/document/path-item-conflicts.ts +0 -79
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { kebabCase } from 'scule';
|
|
2
2
|
import { GENERATOR_FLAGS } from './cli-arguments.mjs';
|
|
3
3
|
import { cliError } from './cli-errors.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveLocationUrl, emitOutput } from './cli-output.mjs';
|
|
5
5
|
import { MULTIPLE_SCHEMAS_DOCS_URL } from './docs-links.mjs';
|
|
6
6
|
import { fixOption, fixNamesOf } from './fix-option.mjs';
|
|
7
7
|
import { refLimitOptions } from './ref-limits.mjs';
|
|
@@ -31,7 +31,7 @@ function apiFixNames(settings) {
|
|
|
31
31
|
return fixNamesOf(settings[FIX_SETTING]);
|
|
32
32
|
}
|
|
33
33
|
function configRootOf(redocly, cwd) {
|
|
34
|
-
return redocly.configFile ?
|
|
34
|
+
return redocly.configFile ? resolveLocationUrl(redocly.configFile, cwd) : cwd;
|
|
35
35
|
}
|
|
36
36
|
async function generateApi(run, redocly, api) {
|
|
37
37
|
if (!api.settings?.output) {
|
|
@@ -49,8 +49,12 @@ async function generateApi(run, redocly, api) {
|
|
|
49
49
|
...fixOption(apiFixNames(api.settings) ?? run.args.fix),
|
|
50
50
|
redocly
|
|
51
51
|
};
|
|
52
|
-
const contents = await run.deps.generate(
|
|
53
|
-
emitOutput(
|
|
52
|
+
const contents = await run.deps.generate(resolveLocationUrl(api.root, configRoot), options);
|
|
53
|
+
emitOutput(
|
|
54
|
+
run,
|
|
55
|
+
{ source: api.name, output, file: resolveLocationUrl(output, configRoot) },
|
|
56
|
+
contents
|
|
57
|
+
);
|
|
54
58
|
}
|
|
55
59
|
async function generateRedoclyApis(run, redocly) {
|
|
56
60
|
const apis = redoclyApisOf(redocly);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redocly-apis.mjs","sources":["../../src/cli/redocly-apis.ts"],"sourcesContent":["import { kebabCase } from \"scule\";\nimport type { RedoclyConfig } from \"../application/ports/redocly-config-source.js\";\nimport type { OutputFixName } from \"../domain/output-fixes.js\";\nimport type { GeneratorOptions } from \"../types.js\";\nimport { GENERATOR_FLAGS, type GeneratorFlags } from \"./cli-arguments.js\";\nimport { cliError } from \"./cli-errors.js\";\nimport { type CliRun, emitOutput,
|
|
1
|
+
{"version":3,"file":"redocly-apis.mjs","sources":["../../src/cli/redocly-apis.ts"],"sourcesContent":["import { kebabCase } from \"scule\";\nimport type { RedoclyConfig } from \"../application/ports/redocly-config-source.js\";\nimport type { OutputFixName } from \"../domain/output-fixes.js\";\nimport type { GeneratorOptions } from \"../types.js\";\nimport { GENERATOR_FLAGS, type GeneratorFlags } from \"./cli-arguments.js\";\nimport { cliError } from \"./cli-errors.js\";\nimport { type CliRun, emitOutput, resolveLocationUrl } from \"./cli-output.js\";\nimport { MULTIPLE_SCHEMAS_DOCS_URL } from \"./docs-links.js\";\nimport { fixNamesOf, fixOption } from \"./fix-option.js\";\nimport { refLimitOptions } from \"./ref-limits.js\";\n\n/** The `apis` of a Redocly config: each API is generated into its `x-openapi-ts.output`. */\n\n/** The key of an API's openapi-typesafe settings in `redocly.yaml`. */\nconst REDOCLY_CONFIG_KEY = \"x-openapi-ts\";\n\n/** The setting of an API that lists its output fixes. */\nconst FIX_SETTING = \"fix\";\n\ntype ApiSettings = Readonly<Record<string, unknown>>;\n\ninterface RedoclyApi {\n readonly name: string;\n readonly root: string;\n readonly settings: ApiSettings | undefined;\n}\n\nfunction redoclyApisOf(redocly: RedoclyConfig): RedoclyApi[] {\n return Object.entries(redocly.apis ?? {}).map(([name, api]) => {\n const settings = (api as Record<string, unknown>)[REDOCLY_CONFIG_KEY];\n return { name, root: api.root, settings: settings as ApiSettings | undefined };\n });\n}\n\nexport function hasRedoclyApis(redocly: RedoclyConfig): boolean {\n return Object.keys(redocly.apis ?? {}).length > 0;\n}\n\n/** The boolean flags an API sets, in camelCase or kebab-case; they win over the CLI's flags. */\nfunction apiFlags(settings: ApiSettings): GeneratorFlags {\n const flags: Partial<Record<(typeof GENERATOR_FLAGS)[number], boolean>> = {};\n for (const name of GENERATOR_FLAGS) {\n const value = typeof settings[name] === \"boolean\" ? settings[name] : settings[kebabCase(name)];\n if (typeof value === \"boolean\") {\n flags[name] = value;\n }\n }\n return flags;\n}\n\n/** The API's `fix` names; they replace the CLI's `--fix`, as its boolean settings win (ADR-021). */\nfunction apiFixNames(settings: ApiSettings): readonly OutputFixName[] | undefined {\n return fixNamesOf(settings[FIX_SETTING]);\n}\n\n/** Paths in the config are relative to the config file; without a file, to the working dir. */\nfunction configRootOf(redocly: RedoclyConfig, cwd: URL): URL {\n return redocly.configFile ? resolveLocationUrl(redocly.configFile, cwd) : cwd;\n}\n\nasync function generateApi(run: CliRun, redocly: RedoclyConfig, api: RedoclyApi): Promise<void> {\n if (!api.settings?.output) {\n throw cliError(\n \"CLI_CONFIG_OUTPUT_MISSING\",\n `API ${api.name} is missing an \\`${REDOCLY_CONFIG_KEY}.output\\` key. ` +\n `See ${MULTIPLE_SCHEMAS_DOCS_URL}`,\n );\n }\n const output = String(api.settings.output);\n const configRoot = configRootOf(redocly, run.deps.cwd);\n const options: GeneratorOptions = {\n ...run.args.generatorFlags,\n ...apiFlags(api.settings),\n ...refLimitOptions(run.args, run.deps.cwd),\n ...fixOption(apiFixNames(api.settings) ?? run.args.fix),\n redocly,\n };\n const contents = await run.deps.generate(resolveLocationUrl(api.root, configRoot), options);\n emitOutput(\n run,\n { source: api.name, output, file: resolveLocationUrl(output, configRoot) },\n contents,\n );\n}\n\n/**\n * Generate every API of the config, concurrently. Every API is generated or checked even when\n * another fails, so `--check` reports a stale output wherever it is; the failures are returned\n * in the order of the config.\n */\nexport async function generateRedoclyApis(run: CliRun, redocly: RedoclyConfig): Promise<unknown[]> {\n const apis = redoclyApisOf(redocly);\n const results = await Promise.allSettled(apis.map((api) => generateApi(run, redocly, api)));\n return results.flatMap((result) => (result.status === \"rejected\" ? [result.reason] : []));\n}\n"],"names":[],"mappings":";;;;;;;;AAcA,MAAM,kBAAA,GAAqB,cAAA;AAG3B,MAAM,WAAA,GAAc,KAAA;AAUpB,SAAS,cAAc,OAAA,EAAsC;AAC3D,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,IAAQ,EAAE,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,GAAG,CAAA,KAAM;AAC7D,IAAA,MAAM,QAAA,GAAY,IAAgC,kBAAkB,CAAA;AACpE,IAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAM,GAAA,CAAI,MAAM,QAAA,EAA8C;AAAA,EAC/E,CAAC,CAAA;AACH;AAEO,SAAS,eAAe,OAAA,EAAiC;AAC9D,EAAA,OAAO,OAAO,IAAA,CAAK,OAAA,CAAQ,QAAQ,EAAE,EAAE,MAAA,GAAS,CAAA;AAClD;AAGA,SAAS,SAAS,QAAA,EAAuC;AACvD,EAAA,MAAM,QAAoE,EAAC;AAC3E,EAAA,KAAA,MAAW,QAAQ,eAAA,EAAiB;AAClC,IAAA,MAAM,KAAA,GAAQ,OAAO,QAAA,CAAS,IAAI,CAAA,KAAM,SAAA,GAAY,QAAA,CAAS,IAAI,CAAA,GAAI,QAAA,CAAS,SAAA,CAAU,IAAI,CAAC,CAAA;AAC7F,IAAA,IAAI,OAAO,UAAU,SAAA,EAAW;AAC9B,MAAA,KAAA,CAAM,IAAI,CAAA,GAAI,KAAA;AAAA,IAChB;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAGA,SAAS,YAAY,QAAA,EAA6D;AAChF,EAAA,OAAO,UAAA,CAAW,QAAA,CAAS,WAAW,CAAC,CAAA;AACzC;AAGA,SAAS,YAAA,CAAa,SAAwB,GAAA,EAAe;AAC3D,EAAA,OAAO,QAAQ,UAAA,GAAa,kBAAA,C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AO,CAAA;AAClC,EAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,UAAA,CAAW,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,KAAQ,WAAA,CAAY,GAAA,EAAK,OAAA,EAAS,GAAG,CAAC,CAAC,CAAA;AAC1F,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,CAAC,MAAA,KAAY,MAAA,CAAO,MAAA,KAAW,UAAA,GAAa,CAAC,MAAA,CAAO,MAAM,CAAA,GAAI,EAAG,CAAA;AAC1F;;"}
|
package/dist/cli/ref-limits.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const cliOutput = require('./cli-output.cjs');
|
|
|
5
5
|
function refLimitOptions(args, cwd) {
|
|
6
6
|
const { localRefRoot, remoteRefHosts } = args.refLimits;
|
|
7
7
|
return {
|
|
8
|
-
...localRefRoot === void 0 ? {} : { localRefRoot: cliOutput.
|
|
8
|
+
...localRefRoot === void 0 ? {} : { localRefRoot: cliOutput.resolveLocationUrl(localRefRoot, cwd) },
|
|
9
9
|
...remoteRefHosts === void 0 ? {} : { remoteRefHosts }
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-limits.cjs","sources":["../../src/cli/ref-limits.ts"],"sourcesContent":["import type { GeneratorOptions } from \"../types.js\";\nimport type { CliArguments } from \"./cli-arguments.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"ref-limits.cjs","sources":["../../src/cli/ref-limits.ts"],"sourcesContent":["import type { GeneratorOptions } from \"../types.js\";\nimport type { CliArguments } from \"./cli-arguments.js\";\nimport { resolveLocationUrl } from \"./cli-output.js\";\n\n/** The `$ref` limits of the CLI flags as generator options (threat model R1, R2, ADR-017). */\n\nexport type RefLimitOptions = Pick<GeneratorOptions, \"localRefRoot\" | \"remoteRefHosts\">;\n\n/** `--local-ref-root` resolves against the working directory, like every other CLI path. */\nexport function refLimitOptions(args: CliArguments, cwd: URL): RefLimitOptions {\n const { localRefRoot, remoteRefHosts } = args.refLimits;\n return {\n ...(localRefRoot === undefined ? {} : { localRefRoot: resolveLocationUrl(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteRefHosts }),\n };\n}\n"],"names":["resolveLocationUrl"],"mappings":";;;;AASO,SAAS,eAAA,CAAgB,MAAoB,GAAA,EAA2B;AAC7E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,IAAA,CAAK,SAAA;AAC9C,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,YAAA,EAAcA,4BAAA,CAAmB,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAC5F,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,cAAA;AAAe,GAC3D;AACF;;"}
|
package/dist/cli/ref-limits.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveLocationUrl } from './cli-output.mjs';
|
|
2
2
|
|
|
3
3
|
function refLimitOptions(args, cwd) {
|
|
4
4
|
const { localRefRoot, remoteRefHosts } = args.refLimits;
|
|
5
5
|
return {
|
|
6
|
-
...localRefRoot === void 0 ? {} : { localRefRoot:
|
|
6
|
+
...localRefRoot === void 0 ? {} : { localRefRoot: resolveLocationUrl(localRefRoot, cwd) },
|
|
7
7
|
...remoteRefHosts === void 0 ? {} : { remoteRefHosts }
|
|
8
8
|
};
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-limits.mjs","sources":["../../src/cli/ref-limits.ts"],"sourcesContent":["import type { GeneratorOptions } from \"../types.js\";\nimport type { CliArguments } from \"./cli-arguments.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"ref-limits.mjs","sources":["../../src/cli/ref-limits.ts"],"sourcesContent":["import type { GeneratorOptions } from \"../types.js\";\nimport type { CliArguments } from \"./cli-arguments.js\";\nimport { resolveLocationUrl } from \"./cli-output.js\";\n\n/** The `$ref` limits of the CLI flags as generator options (threat model R1, R2, ADR-017). */\n\nexport type RefLimitOptions = Pick<GeneratorOptions, \"localRefRoot\" | \"remoteRefHosts\">;\n\n/** `--local-ref-root` resolves against the working directory, like every other CLI path. */\nexport function refLimitOptions(args: CliArguments, cwd: URL): RefLimitOptions {\n const { localRefRoot, remoteRefHosts } = args.refLimits;\n return {\n ...(localRefRoot === undefined ? {} : { localRefRoot: resolveLocationUrl(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteRefHosts }),\n };\n}\n"],"names":[],"mappings":";;AASO,SAAS,eAAA,CAAgB,MAAoB,GAAA,EAA2B;AAC7E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,IAAA,CAAK,SAAA;AAC9C,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,YAAA,EAAc,kBAAA,CAAmB,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAC5F,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,cAAA;AAAe,GAC3D;AACF;;"}
|
package/dist/cli/run-cli.cjs
CHANGED
|
@@ -18,6 +18,19 @@ async function loadRedoclyConfig(run) {
|
|
|
18
18
|
}
|
|
19
19
|
return configPath ? redoclyConfigs.load(configPath) : redoclyConfigs.createDefault();
|
|
20
20
|
}
|
|
21
|
+
function schemaSource(run) {
|
|
22
|
+
const { input } = run.args;
|
|
23
|
+
if (input) {
|
|
24
|
+
return cliOutput.resolveLocationUrl(input, run.deps.cwd);
|
|
25
|
+
}
|
|
26
|
+
if (run.deps.isStdinTerminal()) {
|
|
27
|
+
throw cliErrors.cliError(
|
|
28
|
+
"CLI_INPUT_MISSING",
|
|
29
|
+
"No schema given: pass a schema path or URL, pipe a schema into stdin, or define `apis` in redocly.yaml. See --help."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return run.deps.stdin();
|
|
33
|
+
}
|
|
21
34
|
async function generateSingleSchema(run, redocly) {
|
|
22
35
|
const { input, output } = run.args;
|
|
23
36
|
if (input?.includes("*")) {
|
|
@@ -32,7 +45,7 @@ async function generateSingleSchema(run, redocly) {
|
|
|
32
45
|
"--check needs the generated file to compare with: add --output <file>."
|
|
33
46
|
);
|
|
34
47
|
}
|
|
35
|
-
const source =
|
|
48
|
+
const source = schemaSource(run);
|
|
36
49
|
const options = {
|
|
37
50
|
...run.args.generatorFlags,
|
|
38
51
|
...refLimits.refLimitOptions(run.args, run.deps.cwd),
|
|
@@ -45,7 +58,7 @@ async function generateSingleSchema(run, redocly) {
|
|
|
45
58
|
run.deps.writeStdout(contents);
|
|
46
59
|
return;
|
|
47
60
|
}
|
|
48
|
-
const file = cliOutput.
|
|
61
|
+
const file = cliOutput.resolveLocationUrl(output, run.deps.cwd);
|
|
49
62
|
cliOutput.emitOutput(run, { source: input ?? "stdin", output, file }, contents);
|
|
50
63
|
}
|
|
51
64
|
async function generate(run) {
|
package/dist/cli/run-cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cli.cjs","sources":["../../src/cli/run-cli.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport type { RedoclyConfig } from \"../application/ports/redocly-config-source.js\";\nimport { ineffectiveFlagNotices, parseCliArguments } from \"./cli-arguments.js\";\nimport type { CliDependencies } from \"./cli-dependencies.js\";\nimport { cliError, describeCliFailure, EXIT_CODES, type ExitCode } from \"./cli-errors.js\";\nimport { type CliRun, emitOutput,
|
|
1
|
+
{"version":3,"file":"run-cli.cjs","sources":["../../src/cli/run-cli.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport type { RedoclyConfig } from \"../application/ports/redocly-config-source.js\";\nimport type { SchemaSource } from \"../types.js\";\nimport { ineffectiveFlagNotices, parseCliArguments } from \"./cli-arguments.js\";\nimport type { CliDependencies } from \"./cli-dependencies.js\";\nimport { cliError, describeCliFailure, EXIT_CODES, type ExitCode } from \"./cli-errors.js\";\nimport { type CliRun, emitOutput, resolveLocationUrl } from \"./cli-output.js\";\nimport { MULTIPLE_SCHEMAS_DOCS_URL } from \"./docs-links.js\";\nimport { fixOption } from \"./fix-option.js\";\nimport { HELP_TEXT } from \"./help-text.js\";\nimport { generateRedoclyApis, hasRedoclyApis } from \"./redocly-apis.js\";\nimport { refLimitOptions } from \"./ref-limits.js\";\n\n/**\n * The CLI's use case: parse the arguments, then generate the APIs of the Redocly config, one\n * schema file or URL, or stdin. It has no process access of its own; `main.ts` wires it (ADR-012).\n */\n\nasync function loadRedoclyConfig(run: CliRun): Promise<RedoclyConfig> {\n const { redoclyConfigs } = run.deps;\n const explicitPath = run.args.redocly;\n const configPath = redoclyConfigs.find(explicitPath);\n if (explicitPath && !configPath) {\n throw cliError(\"CLI_CONFIG_NOT_FOUND\", `Redocly config not found at: ${explicitPath}`);\n }\n return configPath ? redoclyConfigs.load(configPath) : redoclyConfigs.createDefault();\n}\n\n/** The schema's URL, or stdin when no path or URL is given and something is piped in. */\nfunction schemaSource(run: CliRun): SchemaSource {\n const { input } = run.args;\n if (input) {\n return resolveLocationUrl(input, run.deps.cwd);\n }\n if (run.deps.isStdinTerminal()) {\n throw cliError(\n \"CLI_INPUT_MISSING\",\n \"No schema given: pass a schema path or URL, pipe a schema into stdin, or define `apis` \" +\n \"in redocly.yaml. See --help.\",\n );\n }\n return run.deps.stdin();\n}\n\n/** One schema from a path, a URL or stdin; without `--output`, the types go to stdout only. */\nasync function generateSingleSchema(run: CliRun, redocly: RedoclyConfig): Promise<void> {\n const { input, output } = run.args;\n if (input?.includes(\"*\")) {\n throw cliError(\n \"CLI_GLOB_UNSUPPORTED\",\n \"Globbing has been deprecated in favor of redocly.yaml’s `apis` keys. \" +\n `See ${MULTIPLE_SCHEMAS_DOCS_URL}`,\n );\n }\n if (run.args.isCheck && !output) {\n // Without a file there is nothing to compare: the original printed the types and passed.\n throw cliError(\n \"CLI_CHECK_OUTPUT_MISSING\",\n \"--check needs the generated file to compare with: add --output <file>.\",\n );\n }\n const source = schemaSource(run);\n const options = {\n ...run.args.generatorFlags,\n ...refLimitOptions(run.args, run.deps.cwd),\n ...fixOption(run.args.fix),\n redocly,\n silent: !output,\n };\n const contents = await run.deps.generate(source, options);\n if (!output) {\n run.deps.writeStdout(contents);\n return;\n }\n const file = resolveLocationUrl(output, run.deps.cwd);\n emitOutput(run, { source: input ?? \"stdin\", output, file }, contents);\n}\n\nasync function generate(run: CliRun): Promise<unknown[]> {\n const redocly = await loadRedoclyConfig(run);\n if (!hasRedoclyApis(redocly)) {\n await generateSingleSchema(run, redocly);\n return [];\n }\n if (run.args.input) {\n run.deps.logger.warn(\n \"APIs are specified both in Redocly Config and CLI argument. Only using Redocly config.\",\n );\n }\n return generateRedoclyApis(run, redocly);\n}\n\n/** Run the command; the failures it returns did not stop the other outputs. */\nasync function runCommand(argv: readonly string[], deps: CliDependencies): Promise<unknown[]> {\n const startedAt = deps.now();\n for (const notice of ineffectiveFlagNotices(argv)) {\n deps.console.notice(notice);\n }\n const args = parseCliArguments(argv);\n for (const flag of args.unknownFlags) {\n deps.console.notice(`Unknown flag ${flag} is ignored (see --help)`);\n }\n if (args.isHelp || args.isVersion) {\n deps.console.info(args.isHelp ? HELP_TEXT : `v${deps.version}`);\n return [];\n }\n if (args.output) {\n deps.console.info(`✨ ${deps.style.bold(`openapi-typesafe ${deps.version}`)}`);\n }\n return generate({ deps, args, startedAt });\n}\n\n/** Print one line per failure; the exit code is the first failure's (ADR-011). */\nfunction reportFailures(failures: readonly unknown[], logger: Logger): ExitCode {\n const reports = failures.map(describeCliFailure);\n for (const report of reports) {\n logger.error(report.message);\n }\n return reports[0]?.exitCode ?? EXIT_CODES.SUCCESS;\n}\n\n/** Run the CLI with the arguments after `node cli.js`, and return the process exit code. */\nexport async function runCli(argv: readonly string[], deps: CliDependencies): Promise<ExitCode> {\n let failures: unknown[];\n try {\n failures = await runCommand(argv, deps);\n } catch (thrown) {\n failures = [thrown];\n }\n return reportFailures(failures, deps.logger);\n}\n"],"names":["cliError","resolveLocationUrl","MULTIPLE_SCHEMAS_DOCS_URL","refLimitOptions","fixOption","emitOutput","hasRedoclyApis","generateRedoclyApis","ineffectiveFlagNotices","parseCliArguments","HELP_TEXT","describeCliFailure","EXIT_CODES"],"mappings":";;;;;;;;;;;AAkBA,eAAe,kBAAkB,GAAA,EAAqC;AACpE,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,GAAA,CAAI,IAAA;AAC/B,EAAA,MAAM,YAAA,GAAe,IAAI,IAAA,CAAK,OAAA;AAC9B,EAAA,MAAM,UAAA,GAAa,cAAA,CAAe,IAAA,CAAK,YAAY,CAAA;AACnD,EAAA,IAAI,YAAA,IAAgB,CAAC,UAAA,EAAY;AAC/B,IAAA,MAAMA,kBAAA,CAAS,sBAAA,EAAwB,CAAA,6BAAA,EAAgC,YAAY,CAAA,CAAE,CAAA;AAAA,EACvF;AACA,EAAA,OAAO,aAAa,cAAA,CAAe,IAAA,CAAK,UAAU,CAAA,GAAI,eAAe,aAAA,EAAc;AACrF;AAGA,SAAS,aAAa,GAAA,EAA2B;AAC/C,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,GAAA,CAAI,IAAA;AACtB,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAOC,4BAAA,CAAmB,KAAA,EAAO,GAAA,CAAI,IAAA,CAAK,GAAG,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,GAAA,CAAI,IAAA,CAAK,eAAA,EAAgB,EAAG;AAC9B,IAAA,MAAMD,kBAAA;AAAA,MACJ,mBAAA;AAAA,MACA;AAAA,KAEF;AAAA,EACF;AACA,EAAA,OAAO,GAAA,CAAI,KAAK,KAAA,EAAM;AACxB;AAGA,eAAe,oBAAA,CAAqB,KAAa,OAAA,EAAuC;AACtF,EAAA,MAAM,EAAE,KAAA,EAAO,MAAA,EAAO,GAAI,GAAA,CAAI,IAAA;AAC9B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,cAAA,CAAe,UAA8B,MAAA,EAA0B;AAC9E,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,GAAA,CAAIC,4BAAkB,CAAA;AAC/C,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,MAAA,CAAO,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA,EAC7B;AACA,EAAA,OAAO,OAAA,CAAQ,CAAC,CAAA,EAAG,QAAA,IAAYC,oBAAA,CAAW,OAAA;AAC5C;AAGA,eAAsB,MAAA,CAAO,MAAyB,IAAA,EAA0C;AAC9F,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI;AACF,IAAA,QAAA,GAAW,MAAM,UAAA,CAAW,IAAA,EAAM,IAAI,CAAA;AAAA,EACxC,SAAS,MAAA,EAAQ;AACf,IAAA,QAAA,GAAW,CAAC,MAAM,CAAA;AAAA,EACpB;AACA,EAAA,OAAO,cAAA,CAAe,QAAA,EAAU,IAAA,CAAK,MAAM,CAAA;AAC7C;;"}
|
package/dist/cli/run-cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ineffectiveFlagNotices, parseCliArguments } from './cli-arguments.mjs';
|
|
2
2
|
import { describeCliFailure, EXIT_CODES, cliError } from './cli-errors.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveLocationUrl, emitOutput } from './cli-output.mjs';
|
|
4
4
|
import { MULTIPLE_SCHEMAS_DOCS_URL } from './docs-links.mjs';
|
|
5
5
|
import { fixOption } from './fix-option.mjs';
|
|
6
6
|
import { HELP_TEXT } from './help-text.mjs';
|
|
@@ -16,6 +16,19 @@ async function loadRedoclyConfig(run) {
|
|
|
16
16
|
}
|
|
17
17
|
return configPath ? redoclyConfigs.load(configPath) : redoclyConfigs.createDefault();
|
|
18
18
|
}
|
|
19
|
+
function schemaSource(run) {
|
|
20
|
+
const { input } = run.args;
|
|
21
|
+
if (input) {
|
|
22
|
+
return resolveLocationUrl(input, run.deps.cwd);
|
|
23
|
+
}
|
|
24
|
+
if (run.deps.isStdinTerminal()) {
|
|
25
|
+
throw cliError(
|
|
26
|
+
"CLI_INPUT_MISSING",
|
|
27
|
+
"No schema given: pass a schema path or URL, pipe a schema into stdin, or define `apis` in redocly.yaml. See --help."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return run.deps.stdin();
|
|
31
|
+
}
|
|
19
32
|
async function generateSingleSchema(run, redocly) {
|
|
20
33
|
const { input, output } = run.args;
|
|
21
34
|
if (input?.includes("*")) {
|
|
@@ -30,7 +43,7 @@ async function generateSingleSchema(run, redocly) {
|
|
|
30
43
|
"--check needs the generated file to compare with: add --output <file>."
|
|
31
44
|
);
|
|
32
45
|
}
|
|
33
|
-
const source =
|
|
46
|
+
const source = schemaSource(run);
|
|
34
47
|
const options = {
|
|
35
48
|
...run.args.generatorFlags,
|
|
36
49
|
...refLimitOptions(run.args, run.deps.cwd),
|
|
@@ -43,7 +56,7 @@ async function generateSingleSchema(run, redocly) {
|
|
|
43
56
|
run.deps.writeStdout(contents);
|
|
44
57
|
return;
|
|
45
58
|
}
|
|
46
|
-
const file =
|
|
59
|
+
const file = resolveLocationUrl(output, run.deps.cwd);
|
|
47
60
|
emitOutput(run, { source: input ?? "stdin", output, file }, contents);
|
|
48
61
|
}
|
|
49
62
|
async function generate(run) {
|
package/dist/cli/run-cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cli.mjs","sources":["../../src/cli/run-cli.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport type { RedoclyConfig } from \"../application/ports/redocly-config-source.js\";\nimport { ineffectiveFlagNotices, parseCliArguments } from \"./cli-arguments.js\";\nimport type { CliDependencies } from \"./cli-dependencies.js\";\nimport { cliError, describeCliFailure, EXIT_CODES, type ExitCode } from \"./cli-errors.js\";\nimport { type CliRun, emitOutput,
|
|
1
|
+
{"version":3,"file":"run-cli.mjs","sources":["../../src/cli/run-cli.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport type { RedoclyConfig } from \"../application/ports/redocly-config-source.js\";\nimport type { SchemaSource } from \"../types.js\";\nimport { ineffectiveFlagNotices, parseCliArguments } from \"./cli-arguments.js\";\nimport type { CliDependencies } from \"./cli-dependencies.js\";\nimport { cliError, describeCliFailure, EXIT_CODES, type ExitCode } from \"./cli-errors.js\";\nimport { type CliRun, emitOutput, resolveLocationUrl } from \"./cli-output.js\";\nimport { MULTIPLE_SCHEMAS_DOCS_URL } from \"./docs-links.js\";\nimport { fixOption } from \"./fix-option.js\";\nimport { HELP_TEXT } from \"./help-text.js\";\nimport { generateRedoclyApis, hasRedoclyApis } from \"./redocly-apis.js\";\nimport { refLimitOptions } from \"./ref-limits.js\";\n\n/**\n * The CLI's use case: parse the arguments, then generate the APIs of the Redocly config, one\n * schema file or URL, or stdin. It has no process access of its own; `main.ts` wires it (ADR-012).\n */\n\nasync function loadRedoclyConfig(run: CliRun): Promise<RedoclyConfig> {\n const { redoclyConfigs } = run.deps;\n const explicitPath = run.args.redocly;\n const configPath = redoclyConfigs.find(explicitPath);\n if (explicitPath && !configPath) {\n throw cliError(\"CLI_CONFIG_NOT_FOUND\", `Redocly config not found at: ${explicitPath}`);\n }\n return configPath ? redoclyConfigs.load(configPath) : redoclyConfigs.createDefault();\n}\n\n/** The schema's URL, or stdin when no path or URL is given and something is piped in. */\nfunction schemaSource(run: CliRun): SchemaSource {\n const { input } = run.args;\n if (input) {\n return resolveLocationUrl(input, run.deps.cwd);\n }\n if (run.deps.isStdinTerminal()) {\n throw cliError(\n \"CLI_INPUT_MISSING\",\n \"No schema given: pass a schema path or URL, pipe a schema into stdin, or define `apis` \" +\n \"in redocly.yaml. See --help.\",\n );\n }\n return run.deps.stdin();\n}\n\n/** One schema from a path, a URL or stdin; without `--output`, the types go to stdout only. */\nasync function generateSingleSchema(run: CliRun, redocly: RedoclyConfig): Promise<void> {\n const { input, output } = run.args;\n if (input?.includes(\"*\")) {\n throw cliError(\n \"CLI_GLOB_UNSUPPORTED\",\n \"Globbing has been deprecated in favor of redocly.yaml’s `apis` keys. \" +\n `See ${MULTIPLE_SCHEMAS_DOCS_URL}`,\n );\n }\n if (run.args.isCheck && !output) {\n // Without a file there is nothing to compare: the original printed the types and passed.\n throw cliError(\n \"CLI_CHECK_OUTPUT_MISSING\",\n \"--check needs the generated file to compare with: add --output <file>.\",\n );\n }\n const source = schemaSource(run);\n const options = {\n ...run.args.generatorFlags,\n ...refLimitOptions(run.args, run.deps.cwd),\n ...fixOption(run.args.fix),\n redocly,\n silent: !output,\n };\n const contents = await run.deps.generate(source, options);\n if (!output) {\n run.deps.writeStdout(contents);\n return;\n }\n const file = resolveLocationUrl(output, run.deps.cwd);\n emitOutput(run, { source: input ?? \"stdin\", output, file }, contents);\n}\n\nasync function generate(run: CliRun): Promise<unknown[]> {\n const redocly = await loadRedoclyConfig(run);\n if (!hasRedoclyApis(redocly)) {\n await generateSingleSchema(run, redocly);\n return [];\n }\n if (run.args.input) {\n run.deps.logger.warn(\n \"APIs are specified both in Redocly Config and CLI argument. Only using Redocly config.\",\n );\n }\n return generateRedoclyApis(run, redocly);\n}\n\n/** Run the command; the failures it returns did not stop the other outputs. */\nasync function runCommand(argv: readonly string[], deps: CliDependencies): Promise<unknown[]> {\n const startedAt = deps.now();\n for (const notice of ineffectiveFlagNotices(argv)) {\n deps.console.notice(notice);\n }\n const args = parseCliArguments(argv);\n for (const flag of args.unknownFlags) {\n deps.console.notice(`Unknown flag ${flag} is ignored (see --help)`);\n }\n if (args.isHelp || args.isVersion) {\n deps.console.info(args.isHelp ? HELP_TEXT : `v${deps.version}`);\n return [];\n }\n if (args.output) {\n deps.console.info(`✨ ${deps.style.bold(`openapi-typesafe ${deps.version}`)}`);\n }\n return generate({ deps, args, startedAt });\n}\n\n/** Print one line per failure; the exit code is the first failure's (ADR-011). */\nfunction reportFailures(failures: readonly unknown[], logger: Logger): ExitCode {\n const reports = failures.map(describeCliFailure);\n for (const report of reports) {\n logger.error(report.message);\n }\n return reports[0]?.exitCode ?? EXIT_CODES.SUCCESS;\n}\n\n/** Run the CLI with the arguments after `node cli.js`, and return the process exit code. */\nexport async function runCli(argv: readonly string[], deps: CliDependencies): Promise<ExitCode> {\n let failures: unknown[];\n try {\n failures = await runCommand(argv, deps);\n } catch (thrown) {\n failures = [thrown];\n }\n return reportFailures(failures, deps.logger);\n}\n"],"names":[],"mappings":";;;;;;;;;AAkBA,eAAe,kBAAkB,GAAA,EAAqC;AACpE,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,GAAA,CAAI,IAAA;AAC/B,EAAA,MAAM,YAAA,GAAe,IAAI,IAAA,CAAK,OAAA;AAC9B,EAAA,MAAM,UAAA,GAAa,cAAA,CAAe,IAAA,CAAK,YAAY,CAAA;AACnD,EAAA,IAAI,YAAA,IAAgB,CAAC,UAAA,EAAY;AAC/B,IAAA,MAAM,QAAA,CAAS,sBAAA,EAAwB,CAAA,6BAAA,EAAgC,YAAY,CAAA,CAAE,CAAA;AAAA,EACvF;AACA,EAAA,OAAO,aAAa,cAAA,CAAe,IAAA,CAAK,UAAU,CAAA,GAAI,eAAe,aAAA,EAAc;AACrF;AAGA,SAAS,aAAa,GAAA,EAA2B;AAC/C,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,GAAA,CAAI,IAAA;AACtB,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAO,kBAAA,CAAmB,KAAA,EAAO,GAAA,CAAI,IAAA,CAAK,GAAG,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,GAAA,CAAI,IAAA,CAAK,eAAA,EAAgB,EAAG;AAC9B,IAAA,MAAM,QAAA;AAAA,MACJ,mBAAA;AAAA,MACA;AAAA,KAEF;AAAA,EACF;AACA,EAAA,OAAO,GAAA,CAAI,KAAK,KAAA,EAAM;AACxB;AAGA,eAAe,oBAAA,CAAqB,KAAa,OAAA,EAAuC;AACtF,EAAA,MAAM,EAAE,KAAA,EAAO,MAAA,EAAO,GAA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,SAAS,cAAA,CAAe,UAA8B,MAAA,EAA0B;AAC9E,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,GAAA,CAAI,kBAAkB,CAAA;AAC/C,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,MAAA,CAAO,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA,EAC7B;AACA,EAAA,OAAO,OAAA,CAAQ,CAAC,CAAA,EAAG,QAAA,IAAY,UAAA,CAAW,OAAA;AAC5C;AAGA,eAAsB,MAAA,CAAO,MAAyB,IAAA,EAA0C;AAC9F,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI;AACF,IAAA,QAAA,GAAW,MAAM,UAAA,CAAW,IAAA,EAAM,IAAI,CAAA;AAAA,EACxC,SAAS,MAAA,EAAQ;AACf,IAAA,QAAA,GAAW,CAAC,MAAM,CAAA;AAAA,EACpB;AACA,EAAA,OAAO,cAAA,CAAe,QAAA,EAAU,IAAA,CAAK,MAAM,CAAA;AAC7C;;"}
|
package/dist/domain/errors.cjs
CHANGED
|
@@ -20,8 +20,10 @@ const ERROR_CODES = {
|
|
|
20
20
|
CLI_FLAG_REMOVED: "CLI_FLAG_REMOVED",
|
|
21
21
|
CLI_GLOB_UNSUPPORTED: "CLI_GLOB_UNSUPPORTED",
|
|
22
22
|
CLI_CONFIG_NOT_FOUND: "CLI_CONFIG_NOT_FOUND",
|
|
23
|
+
CLI_CONFIG_INVALID: "CLI_CONFIG_INVALID",
|
|
23
24
|
CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING",
|
|
24
25
|
CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING",
|
|
26
|
+
CLI_INPUT_MISSING: "CLI_INPUT_MISSING",
|
|
25
27
|
OUTPUT_STALE: "OUTPUT_STALE",
|
|
26
28
|
OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED",
|
|
27
29
|
OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/** Every error code. The set is closed: a new code must be handled by the CLI exit-code table. */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/** Structured, JSON-serializable facts about a failure, for programs and logs. */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/** The base of every expected failure; check `code`, not the class or the message. */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":";;AAQO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,cAAA,EAAg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AAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;;;"}
|
|
1
|
+
{"version":3,"file":"errors.cjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/** Every error code. The set is closed: a new code must be handled by the CLI exit-code table. */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_INVALID: \"CLI_CONFIG_INVALID\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n CLI_INPUT_MISSING: \"CLI_INPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/** Structured, JSON-serializable facts about a failure, for programs and logs. */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/** The base of every expected failure; check `code`, not the class or the message. */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":";;AAQO,MAAM,WAAA,GAAc;AAAA,EACzB,m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AK,OAAA,IAAW,EAAC;AAAA,EAClC;AACF;AAGO,SAAS,uBAAuB,KAAA,EAA+C;AACpF,EAAA,IAAI,iBAAiB,oBAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,OAAQ,KAAA,EAAqC,IAAA;AACnD,EAAA,OACE,KAAA,YAAiB,KAAA,IACjB,OAAO,IAAA,KAAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;;;"}
|
package/dist/domain/errors.mjs
CHANGED
|
@@ -18,8 +18,10 @@ const ERROR_CODES = {
|
|
|
18
18
|
CLI_FLAG_REMOVED: "CLI_FLAG_REMOVED",
|
|
19
19
|
CLI_GLOB_UNSUPPORTED: "CLI_GLOB_UNSUPPORTED",
|
|
20
20
|
CLI_CONFIG_NOT_FOUND: "CLI_CONFIG_NOT_FOUND",
|
|
21
|
+
CLI_CONFIG_INVALID: "CLI_CONFIG_INVALID",
|
|
21
22
|
CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING",
|
|
22
23
|
CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING",
|
|
24
|
+
CLI_INPUT_MISSING: "CLI_INPUT_MISSING",
|
|
23
25
|
OUTPUT_STALE: "OUTPUT_STALE",
|
|
24
26
|
OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED",
|
|
25
27
|
OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/** Every error code. The set is closed: a new code must be handled by the CLI exit-code table. */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/** Structured, JSON-serializable facts about a failure, for programs and logs. */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/** The base of every expected failure; check `code`, not the class or the message. */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":"AAQO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,cAAA,EAAgB,gBAAA;AAAA,EAChB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,uBAAA,EAAyB,yBAAA;AAAA,EACzB,eAAA,EAAiB,iBAAA;AAAA,EACjB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,eAAA,EAAiB,iBAAA;AAAA,EACjB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,YAAA,EAAc,cAAA;AAAA,EACd,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB;AACvB;AAgBO,MAAM,6BAA6B,KAAA,CAAM;AAAA,EACrC,IAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAAgC;AAC1C,IAAA,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,IAAA,CAAK,KAAA,KAAU,MAAA,GAAY,SAAY,EAAE,KAAA,EAAO,IAAA,CAAK,KAAA,EAAO,CAAA;AAChF,IAAA,IAAA,CAAK,IAAA,GAAO,sBAAA;AACZ,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,EAClC;AACF;AAGO,SAAS,uBAAuB,KAAA,EAA+C;AACpF,EAAA,IAAI,iBAAiB,oBAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,OAAQ,KAAA,EAAqC,IAAA;AACnD,EAAA,OACE,KAAA,YAAiB,KAAA,IACjB,OAAO,IAAA,KAAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;"}
|
|
1
|
+
{"version":3,"file":"errors.mjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/** Every error code. The set is closed: a new code must be handled by the CLI exit-code table. */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_INVALID: \"CLI_CONFIG_INVALID\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n CLI_INPUT_MISSING: \"CLI_INPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/** Structured, JSON-serializable facts about a failure, for programs and logs. */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/** The base of every expected failure; check `code`, not the class or the message. */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":"AAQO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,cAAA,EAAgB,gBAAA;AAAA,EAChB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;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,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;"}
|
|
@@ -25,7 +25,10 @@ function irTuple(elements) {
|
|
|
25
25
|
return { kind: "tuple", elements };
|
|
26
26
|
}
|
|
27
27
|
function irTupleElement(type, isRest = false) {
|
|
28
|
-
return { type, isRest };
|
|
28
|
+
return { type, isRest, isOptional: false };
|
|
29
|
+
}
|
|
30
|
+
function irOptionalTupleElement(type) {
|
|
31
|
+
return { type, isRest: false, isOptional: true };
|
|
29
32
|
}
|
|
30
33
|
function irUnion(types) {
|
|
31
34
|
return { kind: "union", types };
|
|
@@ -76,6 +79,7 @@ exports.irIntersection = irIntersection;
|
|
|
76
79
|
exports.irKeyword = irKeyword;
|
|
77
80
|
exports.irNumber = irNumber;
|
|
78
81
|
exports.irObject = irObject;
|
|
82
|
+
exports.irOptionalTupleElement = irOptionalTupleElement;
|
|
79
83
|
exports.irProperty = irProperty;
|
|
80
84
|
exports.irRaw = irRaw;
|
|
81
85
|
exports.irReadonly = irReadonly;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.cjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAQ;AACpC;AAEO,SAAS,QAAA,CAAS,OAAe,QAAA,EAAiD;AACvF,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAO,QAAA,EAAS;AAClD;AAGO,SAAS,SAAS,KAAA,EAAoC;AAC3D,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,iDAAA,EAAoD,KAAK,CAAA,CAAE,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAM;AACxC;AAEO,SAAS,UAAU,KAAA,EAAsC;AAC9D,EAAA,OAAO,EAAE,IAAA,EAAM,gBAAA,EAAkB,KAAA,EAAM;AACzC;AAEO,SAAS,WAAA,CAAY,IAAA,EAAc,aAAA,GAAmC,EAAC,EAAoB;AAChG,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,aAAA,EAAc;AAClD;AAEO,SAAS,QAAQ,OAAA,EAA8B;AACpD,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,OAAA,EAAQ;AAClC;AAEO,SAAS,QAAQ,QAAA,EAAkD;AACxE,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,QAAA,EAAS;AACnC;AAEO,SAAS,cAAA,CAAe,IAAA,EAAc,MAAA,GAAS,KAAA,EAAuB;AAC3E,EAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constructors.cjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest, isOptional: false };\n}\n\n/** `T?`: an element the tuple may end before. */\nexport function irOptionalTupleElement(type: IrType): IrTupleElement {\n return { type, isRest: false, isOptional: true };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EA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CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -23,7 +23,10 @@ function irTuple(elements) {
|
|
|
23
23
|
return { kind: "tuple", elements };
|
|
24
24
|
}
|
|
25
25
|
function irTupleElement(type, isRest = false) {
|
|
26
|
-
return { type, isRest };
|
|
26
|
+
return { type, isRest, isOptional: false };
|
|
27
|
+
}
|
|
28
|
+
function irOptionalTupleElement(type) {
|
|
29
|
+
return { type, isRest: false, isOptional: true };
|
|
27
30
|
}
|
|
28
31
|
function irUnion(types) {
|
|
29
32
|
return { kind: "union", types };
|
|
@@ -67,5 +70,5 @@ function irRecord(key, value) {
|
|
|
67
70
|
return irReference("Record", [key, value]);
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
export { irArray, irBoolean, irIndexedAccess, irIntersection, irKeyword, irNumber, irObject, irProperty, irRaw, irReadonly, irRecord, irReference, irString, irStringIndexSignature, irTuple, irTupleElement, irUnion };
|
|
73
|
+
export { irArray, irBoolean, irIndexedAccess, irIntersection, irKeyword, irNumber, irObject, irOptionalTupleElement, irProperty, irRaw, irReadonly, irRecord, irReference, irString, irStringIndexSignature, irTuple, irTupleElement, irUnion };
|
|
71
74
|
//# sourceMappingURL=constructors.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructors.mjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":"AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAQ;AACpC;AAEO,SAAS,QAAA,CAAS,OAAe,QAAA,EAAiD;AACvF,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAO,QAAA,EAAS;AAClD;AAGO,SAAS,SAAS,KAAA,EAAoC;AAC3D,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,iDAAA,EAAoD,KAAK,CAAA,CAAE,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAM;AACxC;AAEO,SAAS,UAAU,KAAA,EAAsC;AAC9D,EAAA,OAAO,EAAE,IAAA,EAAM,gBAAA,EAAkB,KAAA,EAAM;AACzC;AAEO,SAAS,WAAA,CAAY,IAAA,EAAc,aAAA,GAAmC,EAAC,EAAoB;AAChG,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,aAAA,EAAc;AAClD;AAEO,SAAS,QAAQ,OAAA,EAA8B;AACpD,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,OAAA,EAAQ;AAClC;AAEO,SAAS,QAAQ,QAAA,EAAkD;AACxE,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,QAAA,EAAS;AACnC;AAEO,SAAS,cAAA,CAAe,IAAA,EAAc,MAAA,GAAS,KAAA,EAAuB;AAC3E,EAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constructors.mjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest, isOptional: false };\n}\n\n/** `T?`: an element the tuple may end before. */\nexport function irOptionalTupleElement(type: IrType): IrTupleElement {\n return { type, isRest: false, isOptional: true };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n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C,GACb;AACF;AAGO,SAAS,QAAA,CAAS,KAAa,KAAA,EAAgC;AACpE,EAAA,OAAO,WAAA,CAAY,QAAA,EAAU,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsonPointer = require('./json-pointer.cjs');
|
|
4
|
+
|
|
5
|
+
const MAX_DEPTH = 16;
|
|
6
|
+
const LOCAL_REF_PREFIX = "#/";
|
|
7
|
+
function isObject(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function resolveLocalRef(document, ref) {
|
|
11
|
+
if (!ref.startsWith(LOCAL_REF_PREFIX)) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
let node = document;
|
|
15
|
+
for (const segment of jsonPointer.parseRefPointer(ref)) {
|
|
16
|
+
node = isObject(node) || Array.isArray(node) ? node[segment] : void 0;
|
|
17
|
+
}
|
|
18
|
+
return node;
|
|
19
|
+
}
|
|
20
|
+
function intersect(left, right) {
|
|
21
|
+
if (left === null || right === null) {
|
|
22
|
+
return left ?? right;
|
|
23
|
+
}
|
|
24
|
+
return new Set([...left].filter((value) => right.has(value)));
|
|
25
|
+
}
|
|
26
|
+
function unite(sets) {
|
|
27
|
+
return sets.some((set) => set === null) ? null : new Set(sets.flatMap((set) => [...set ?? []]));
|
|
28
|
+
}
|
|
29
|
+
function isAdmittedValue(value) {
|
|
30
|
+
return value === null || ["string", "number", "boolean"].includes(typeof value);
|
|
31
|
+
}
|
|
32
|
+
function follow(node, walk) {
|
|
33
|
+
if (!isObject(node) || typeof node.$ref !== "string") {
|
|
34
|
+
return node;
|
|
35
|
+
}
|
|
36
|
+
return walk.skipped.has(node.$ref) ? void 0 : resolveLocalRef(walk.document, node.$ref);
|
|
37
|
+
}
|
|
38
|
+
function members(node, keyword) {
|
|
39
|
+
const list = node[keyword];
|
|
40
|
+
return Array.isArray(list) ? list : [];
|
|
41
|
+
}
|
|
42
|
+
function ownValues(node) {
|
|
43
|
+
const listed = Array.isArray(node.enum) ? node.enum.filter(isAdmittedValue) : null;
|
|
44
|
+
const constant = "const" in node && isAdmittedValue(node.const) ? /* @__PURE__ */ new Set([node.const]) : null;
|
|
45
|
+
return intersect(listed === null ? null : new Set(listed), constant);
|
|
46
|
+
}
|
|
47
|
+
function schemaValues(schema, walk) {
|
|
48
|
+
const node = follow(schema, walk);
|
|
49
|
+
if (!isObject(node) || walk.depth > MAX_DEPTH) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const next = { ...walk, depth: walk.depth + 1 };
|
|
53
|
+
const parts = members(node, "allOf").map((part) => schemaValues(part, next));
|
|
54
|
+
const variants = [...members(node, "anyOf"), ...members(node, "oneOf")];
|
|
55
|
+
const union = variants.length === 0 ? null : unite(variants.map((v) => schemaValues(v, next)));
|
|
56
|
+
return [...parts, union].reduce(intersect, ownValues(node));
|
|
57
|
+
}
|
|
58
|
+
function propertyValues(schema, key, walk) {
|
|
59
|
+
const node = follow(schema, walk);
|
|
60
|
+
if (!isObject(node) || walk.depth > MAX_DEPTH) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const next = { ...walk, depth: walk.depth + 1 };
|
|
64
|
+
const properties = isObject(node.properties) ? node.properties : {};
|
|
65
|
+
const own = Object.hasOwn(properties, key) ? schemaValues(properties[key], next) : null;
|
|
66
|
+
const parts = members(node, "allOf").map((part) => propertyValues(part, key, next));
|
|
67
|
+
return parts.reduce(intersect, own);
|
|
68
|
+
}
|
|
69
|
+
function admittedPropertyValues(schema, key, document, skipped = /* @__PURE__ */ new Set()) {
|
|
70
|
+
return propertyValues(schema, key, { document, depth: 0, skipped });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.admittedPropertyValues = admittedPropertyValues;
|
|
74
|
+
exports.resolveLocalRef = resolveLocalRef;
|
|
75
|
+
//# sourceMappingURL=admitted-values.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admitted-values.cjs","sources":["../../../src/domain/openapi/admitted-values.ts"],"sourcesContent":["import { parseRefPointer } from \"./json-pointer.js\";\n\n/**\n * The values a schema admits when it admits only finitely many (`enum`, `const`, and `allOf` /\n * `anyOf` / `oneOf` of those), read from the document. Null means \"any value\" as far as this\n * reading goes: a schema of any other shape, or a `$ref` it cannot follow, is never assumed to\n * exclude a value.\n */\n\nexport type AdmittedValue = string | number | boolean | null;\n/** A finite set of values, or null for every value. */\nexport type AdmittedValues = ReadonlySet<AdmittedValue> | null;\n\ntype JsonObject = Readonly<Record<string, unknown>>;\n\n/** How deep `$ref`s and compositions are followed; deeper schemas admit every value. */\nconst MAX_DEPTH = 16;\nconst LOCAL_REF_PREFIX = \"#/\";\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The node at a local `$ref` (`#/...`) of the document, or undefined. */\nexport function resolveLocalRef(document: unknown, ref: string): unknown {\n if (!ref.startsWith(LOCAL_REF_PREFIX)) {\n return undefined;\n }\n let node: unknown = document;\n for (const segment of parseRefPointer(ref)) {\n node = isObject(node) || Array.isArray(node) ? (node as JsonObject)[segment] : undefined;\n }\n return node;\n}\n\nfunction intersect(left: AdmittedValues, right: AdmittedValues): AdmittedValues {\n if (left === null || right === null) {\n return left ?? right;\n }\n return new Set([...left].filter((value) => right.has(value)));\n}\n\nfunction unite(sets: readonly AdmittedValues[]): AdmittedValues {\n return sets.some((set) => set === null) ? null : new Set(sets.flatMap((set) => [...(set ?? [])]));\n}\n\nfunction isAdmittedValue(value: unknown): value is AdmittedValue {\n return value === null || [\"string\", \"number\", \"boolean\"].includes(typeof value);\n}\n\ninterface Walk {\n readonly document: unknown;\n readonly depth: number;\n /** `$ref`s whose targets are left out: they add nothing to the generated type here. */\n readonly skipped: ReadonlySet<string>;\n}\n\nfunction follow(node: unknown, walk: Walk): unknown {\n if (!isObject(node) || typeof node.$ref !== \"string\") {\n return node;\n }\n return walk.skipped.has(node.$ref) ? undefined : resolveLocalRef(walk.document, node.$ref);\n}\n\nfunction members(node: JsonObject, keyword: string): readonly unknown[] {\n const list = node[keyword];\n return Array.isArray(list) ? list : [];\n}\n\n/** `enum` and `const` of the schema itself, before its compositions. */\nfunction ownValues(node: JsonObject): AdmittedValues {\n const listed = Array.isArray(node.enum) ? node.enum.filter(isAdmittedValue) : null;\n const constant = \"const\" in node && isAdmittedValue(node.const) ? new Set([node.const]) : null;\n return intersect(listed === null ? null : new Set(listed), constant);\n}\n\nfunction schemaValues(schema: unknown, walk: Walk): AdmittedValues {\n const node = follow(schema, walk);\n if (!isObject(node) || walk.depth > MAX_DEPTH) {\n return null;\n }\n const next = { ...walk, depth: walk.depth + 1 };\n const parts = members(node, \"allOf\").map((part) => schemaValues(part, next));\n const variants = [...members(node, \"anyOf\"), ...members(node, \"oneOf\")];\n const union = variants.length === 0 ? null : unite(variants.map((v) => schemaValues(v, next)));\n return [...parts, union].reduce<AdmittedValues>(intersect, ownValues(node));\n}\n\nfunction propertyValues(schema: unknown, key: string, walk: Walk): AdmittedValues {\n const node = follow(schema, walk);\n if (!isObject(node) || walk.depth > MAX_DEPTH) {\n return null;\n }\n const next = { ...walk, depth: walk.depth + 1 };\n const properties = isObject(node.properties) ? node.properties : {};\n const own = Object.hasOwn(properties, key) ? schemaValues(properties[key], next) : null;\n const parts = members(node, \"allOf\").map((part) => propertyValues(part, key, next));\n return parts.reduce<AdmittedValues>(intersect, own);\n}\n\n/**\n * The values property `key` of an object schema admits: the intersection over the schema's own\n * `properties` and its `allOf` parts (followed through `$ref`s, except `skipped` ones); null for\n * every value.\n */\nexport function admittedPropertyValues(\n schema: unknown,\n key: string,\n document: unknown,\n skipped: ReadonlySet<string> = new Set(),\n): AdmittedValues {\n return propertyValues(schema, key, { document, depth: 0, skipped });\n}\n"],"names":["parseRefPointer"],"mappings":";;;;AAgBA,MAAM,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