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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const pathTemplates = require('../domain/openapi/path-templates.cjs');
|
|
4
|
+
const warnings = require('../domain/warnings.cjs');
|
|
5
|
+
|
|
6
|
+
const DOCS_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/cli.md#pathparamsastypes";
|
|
7
|
+
const SPEC_RULE = "OpenAPI does not allow this (Paths Object): templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical";
|
|
8
|
+
function quotedList(urls) {
|
|
9
|
+
const quoted = urls.map((url) => `"${url}"`);
|
|
10
|
+
const last = quoted.pop();
|
|
11
|
+
return quoted.length === 0 ? last ?? "" : `${quoted.join(", ")} and ${last}`;
|
|
12
|
+
}
|
|
13
|
+
function warnIdenticalPathTemplates(document, logger) {
|
|
14
|
+
for (const urls of pathTemplates.findIdenticalPathTemplates(document)) {
|
|
15
|
+
const message = `Paths ${quotedList(urls)} differ only in their parameter names. ${SPEC_RULE}`;
|
|
16
|
+
logger.warn(warnings.warningText(`${message}. See ${DOCS_URL}`, warnings.WARNING_CODES.PATH_TEMPLATES_IDENTICAL));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.warnIdenticalPathTemplates = warnIdenticalPathTemplates;
|
|
21
|
+
//# sourceMappingURL=path-template-warnings.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-template-warnings.cjs","sources":["../../src/api/path-template-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport { findIdenticalPathTemplates } from \"../domain/openapi/path-templates.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_URL =\n \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/cli.md#pathparamsastypes\";\nconst SPEC_RULE =\n \"OpenAPI does not allow this (Paths Object): templated paths with the same hierarchy but \" +\n \"different templated names MUST NOT exist as they are identical\";\n\n/** `\"/a\"`, `\"/a\" and \"/b\"`, `\"/a\", \"/b\" and \"/c\"`. */\nfunction quotedList(urls: readonly string[]): string {\n const quoted = urls.map((url) => `\"${url}\"`);\n const last = quoted.pop();\n return quoted.length === 0 ? (last ?? \"\") : `${quoted.join(\", \")} and ${last}`;\n}\n\n/**\n * Warn once per group of paths that differ only in parameter names, which the spec forbids: a URL\n * cannot tell them apart, and `--path-params-as-types` gives them the same key type.\n */\nexport function warnIdenticalPathTemplates(document: unknown, logger: Logger): void {\n for (const urls of findIdenticalPathTemplates(document)) {\n const message = `Paths ${quotedList(urls)} differ only in their parameter names. ${SPEC_RULE}`;\n logger.warn(warningText(`${message}. See ${DOCS_URL}`, WARNING_CODES.PATH_TEMPLATES_IDENTICAL));\n }\n}\n"],"names":["findIdenticalPathTemplates","warningText","WARNING_CODES"],"mappings":";;;;;AAIA,MAAM,QAAA,GACJ,8FAAA;AACF,MAAM,SAAA,GACJ,wJAAA;AAIF,SAAS,WAAW,IAAA,EAAiC;AACnD,EAAA,MAAM,SAAS,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,KAAQ,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,CAAG,CAAA;AAC3C,EAAA,MAAM,IAAA,GAAO,OAAO,GAAA,EAAI;AACxB,EAAA,OAAO,MAAA,CAAO,MAAA,KAAW,CAAA,GAAK,IAAA,IAAQ,EAAA,GAAM,CAAA,EAAG,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,CAAA;AAC9E;AAMO,SAAS,0BAAA,CAA2B,UAAmB,MAAA,EAAsB;AAClF,EAAA,KAAA,MAAW,IAAA,IAAQA,wCAAA,CAA2B,QAAQ,CAAA,EAAG;AACvD,IAAA,MAAM,UAAU,CAAA,MAAA,EAAS,UAAA,CAAW,IAAI,CAAC,0CAA0C,SAAS,CAAA,CAAA;AAC5F,IAAA,MAAA,CAAO,IAAA,CAAKC,qBAAY,CAAA,EAAG,OAAO,SAAS,QAAQ,CAAA,CAAA,EAAIC,sBAAA,CAAc,wBAAwB,CAAC,CAAA;AAAA,EAChG;AACF;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findIdenticalPathTemplates } from '../domain/openapi/path-templates.mjs';
|
|
2
|
+
import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
|
|
3
|
+
|
|
4
|
+
const DOCS_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/cli.md#pathparamsastypes";
|
|
5
|
+
const SPEC_RULE = "OpenAPI does not allow this (Paths Object): templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical";
|
|
6
|
+
function quotedList(urls) {
|
|
7
|
+
const quoted = urls.map((url) => `"${url}"`);
|
|
8
|
+
const last = quoted.pop();
|
|
9
|
+
return quoted.length === 0 ? last ?? "" : `${quoted.join(", ")} and ${last}`;
|
|
10
|
+
}
|
|
11
|
+
function warnIdenticalPathTemplates(document, logger) {
|
|
12
|
+
for (const urls of findIdenticalPathTemplates(document)) {
|
|
13
|
+
const message = `Paths ${quotedList(urls)} differ only in their parameter names. ${SPEC_RULE}`;
|
|
14
|
+
logger.warn(warningText(`${message}. See ${DOCS_URL}`, WARNING_CODES.PATH_TEMPLATES_IDENTICAL));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { warnIdenticalPathTemplates };
|
|
19
|
+
//# sourceMappingURL=path-template-warnings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-template-warnings.mjs","sources":["../../src/api/path-template-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport { findIdenticalPathTemplates } from \"../domain/openapi/path-templates.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_URL =\n \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/cli.md#pathparamsastypes\";\nconst SPEC_RULE =\n \"OpenAPI does not allow this (Paths Object): templated paths with the same hierarchy but \" +\n \"different templated names MUST NOT exist as they are identical\";\n\n/** `\"/a\"`, `\"/a\" and \"/b\"`, `\"/a\", \"/b\" and \"/c\"`. */\nfunction quotedList(urls: readonly string[]): string {\n const quoted = urls.map((url) => `\"${url}\"`);\n const last = quoted.pop();\n return quoted.length === 0 ? (last ?? \"\") : `${quoted.join(\", \")} and ${last}`;\n}\n\n/**\n * Warn once per group of paths that differ only in parameter names, which the spec forbids: a URL\n * cannot tell them apart, and `--path-params-as-types` gives them the same key type.\n */\nexport function warnIdenticalPathTemplates(document: unknown, logger: Logger): void {\n for (const urls of findIdenticalPathTemplates(document)) {\n const message = `Paths ${quotedList(urls)} differ only in their parameter names. ${SPEC_RULE}`;\n logger.warn(warningText(`${message}. See ${DOCS_URL}`, WARNING_CODES.PATH_TEMPLATES_IDENTICAL));\n }\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,QAAA,GACJ,8FAAA;AACF,MAAM,SAAA,GACJ,wJAAA;AAIF,SAAS,WAAW,IAAA,EAAiC;AACnD,EAAA,MAAM,SAAS,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,KAAQ,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,CAAG,CAAA;AAC3C,EAAA,MAAM,IAAA,GAAO,OAAO,GAAA,EAAI;AACxB,EAAA,OAAO,MAAA,CAAO,MAAA,KAAW,CAAA,GAAK,IAAA,IAAQ,EAAA,GAAM,CAAA,EAAG,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,CAAA;AAC9E;AAMO,SAAS,0BAAA,CAA2B,UAAmB,MAAA,EAAsB;AAClF,EAAA,KAAA,MAAW,IAAA,IAAQ,0BAAA,CAA2B,QAAQ,CAAA,EAAG;AACvD,IAAA,MAAM,UAAU,CAAA,MAAA,EAAS,UAAA,CAAW,IAAI,CAAC,0CAA0C,SAAS,CAAA,CAAA;AAC5F,IAAA,MAAA,CAAO,IAAA,CAAK,YAAY,CAAA,EAAG,OAAO,SAAS,QAAQ,CAAA,CAAA,EAAI,aAAA,CAAc,wBAAwB,CAAC,CAAA;AAAA,EAChG;AACF;;"}
|
|
@@ -65,7 +65,9 @@ function createTransformContext(ctx) {
|
|
|
65
65
|
refs: { resolve: (ref) => ctx.resolve(ref) },
|
|
66
66
|
discriminators: {
|
|
67
67
|
objectAt: (ref) => ctx.discriminators.objects[ref],
|
|
68
|
-
isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref)
|
|
68
|
+
isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),
|
|
69
|
+
otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],
|
|
70
|
+
enumParentOf: (schema) => ctx.discriminators.enumParents?.get(schema)
|
|
69
71
|
},
|
|
70
72
|
footer: runFooter(ctx),
|
|
71
73
|
callbacks: schemaCallbacks.schemaCallbacks(ctx),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-context.cjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"transform-context.cjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {\n DiscriminatorEnumParent,\n SchemaLocation,\n} from \"../application/transform/schema/schema-context.js\";\nimport type {\n DocumentFooter,\n NameCasing,\n TransformContext,\n TransformDiagnostics,\n TransformOptions,\n} from \"../application/transform/transform-context.js\";\nimport type { GlobalContext, TransformNodeOptions } from \"../types.js\";\nimport { defaultLogger, monotonicNow } from \"./default-ports.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport { schemaCallbacks } from \"./schema-callbacks.js\";\n\n/**\n * Builds the ported transformers' context from the original `GlobalContext`: options, refs,\n * discriminators, the run footer and the user callbacks (see `schema-callbacks.ts`).\n */\n\nfunction transformOptions(ctx: GlobalContext): TransformOptions {\n return {\n additionalProperties: ctx.additionalProperties,\n alphabetize: ctx.alphabetize,\n arrayLength: ctx.arrayLength,\n binaryAsBlob: ctx.binaryAsBlob,\n conditionalEnums: ctx.conditionalEnums,\n dedupeEnums: ctx.dedupeEnums,\n defaultNonNullable: ctx.defaultNonNullable,\n emptyObjectsUnknown: ctx.emptyObjectsUnknown,\n enum: ctx.enum,\n enumValues: ctx.enumValues,\n excludeDeprecated: ctx.excludeDeprecated,\n fixes: new Set(ctx.fix ?? []),\n immutable: ctx.immutable,\n propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,\n readWriteMarkers: ctx.readWriteMarkers,\n generatePathParams: ctx.generatePathParams,\n pathParamsAsTypes: ctx.pathParamsAsTypes,\n rootTypes: ctx.rootTypes,\n rootTypesNoSchemaPrefix: ctx.rootTypesNoSchemaPrefix,\n rootTypesKeepCasing: ctx.rootTypesKeepCasing,\n exportType: ctx.exportType,\n inject: ctx.inject,\n makePathsEnum: ctx.makePathsEnum,\n };\n}\n\n/** One footer per run: it holds the enum registry, so it lives on the run's context. */\nfunction runFooter(ctx: GlobalContext): DocumentFooter {\n ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);\n return ctx.runFooter;\n}\n\nconst CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) };\n\n/**\n * A monotonic clock and the run's logger (the default one for a user's own context), \"ts\" group.\n */\nfunction diagnostics(ctx: GlobalContext): TransformDiagnostics {\n const logger = ctx.logger ?? defaultLogger(ctx.silent);\n return {\n now: monotonicNow,\n debug: (message, durationMs) => logger.debug(message, \"ts\", durationMs),\n };\n}\n\n/** The ported transformers' context for one call from a legacy transformer. */\nexport function createTransformContext(ctx: GlobalContext): TransformContext {\n return {\n options: transformOptions(ctx),\n refs: { resolve: (ref) => ctx.resolve(ref) },\n discriminators: {\n objectAt: (ref) => ctx.discriminators.objects[ref],\n isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),\n otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],\n enumParentOf: (schema) =>\n ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,\n },\n footer: runFooter(ctx),\n callbacks: schemaCallbacks(ctx),\n diagnostics: diagnostics(ctx),\n casing: CASING,\n };\n}\n\n/** The transformer's location for the original options object. */\nexport function schemaLocation(options: TransformNodeOptions): SchemaLocation {\n return { path: options.path, schema: options.schema };\n}\n"],"names":["RunFooter","ContextFooterSink","changeCase","defaultLogger","monotonicNow","schemaCallbacks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,iBAAiB,GAAA,EAAsC;AAC9D,EAAA,OAAO;AAAA,IACL,sBAAsB,GAAA,CAAI,oBAAA;AAAA,IAC1B,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,cAAc,GAAA,CAAI,YAAA;AAAA,IAClB,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,oBAAoB,GAAA,CAAI,kBAAA;AAAA,IACxB,qBAAqB,GAAA,CAAI,mBAAA;AAAA,IACzB,MAAM,GAAA,CAAI,IAAA;AAAA,IACV,YAAY,GAAA,CAAI,UAAA;AAAA,IAChB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,IACvB,OAAO,IAAI,GAAA,CAAI,GAAA,CAAI,GAAA,IAAO,EAAE,CAAA;AAAA,IAC5B,WAAW,GAAA,CAAI,SAAA;AAAA,IACf,6BAA6B,GAAA,CAAI,2BAAA;AAAA,IACjC,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,oBAAoB,GAAA,CAAI,kBA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,GAAG,CAAA;AAAA,MAC/D,iBAAA,EAAmB,CAAC,GAAA,KAAQ,GAAA,CAAI,eAAe,eAAA,GAAkB,GAAG,KAAK,EAAC;AAAA,MAC1E,cAAc,CAAC,MAAA,KACb,IAAI,cAAA,CAAe,WAAA,EAAa,IAAI,MAAM;AAAA,KAC9C;AAAA,IACA,MAAA,EAAQ,UAAU,GAAG,CAAA;AAAA,IACrB,SAAA,EAAWC,gCAAgB,GAAG,CAAA;AAAA,IAC9B,WAAA,EAAa,YAAY,GAAG,CAAA;AAAA,IAC5B,MAAA,EAAQ;AAAA,GACV;AACF;AAGO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,MAAA,EAAQ,QAAQ,MAAA,EAAO;AACtD;;;"}
|
|
@@ -49,7 +49,9 @@ function createTransformContext(ctx) {
|
|
|
49
49
|
refs: { resolve: (ref) => ctx.resolve(ref) },
|
|
50
50
|
discriminators: {
|
|
51
51
|
objectAt: (ref) => ctx.discriminators.objects[ref],
|
|
52
|
-
isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref)
|
|
52
|
+
isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),
|
|
53
|
+
otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],
|
|
54
|
+
enumParentOf: (schema) => ctx.discriminators.enumParents?.get(schema)
|
|
53
55
|
},
|
|
54
56
|
footer: runFooter(ctx),
|
|
55
57
|
callbacks: schemaCallbacks(ctx),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-context.mjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"transform-context.mjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {\n DiscriminatorEnumParent,\n SchemaLocation,\n} from \"../application/transform/schema/schema-context.js\";\nimport type {\n DocumentFooter,\n NameCasing,\n TransformContext,\n TransformDiagnostics,\n TransformOptions,\n} from \"../application/transform/transform-context.js\";\nimport type { GlobalContext, TransformNodeOptions } from \"../types.js\";\nimport { defaultLogger, monotonicNow } from \"./default-ports.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport { schemaCallbacks } from \"./schema-callbacks.js\";\n\n/**\n * Builds the ported transformers' context from the original `GlobalContext`: options, refs,\n * discriminators, the run footer and the user callbacks (see `schema-callbacks.ts`).\n */\n\nfunction transformOptions(ctx: GlobalContext): TransformOptions {\n return {\n additionalProperties: ctx.additionalProperties,\n alphabetize: ctx.alphabetize,\n arrayLength: ctx.arrayLength,\n binaryAsBlob: ctx.binaryAsBlob,\n conditionalEnums: ctx.conditionalEnums,\n dedupeEnums: ctx.dedupeEnums,\n defaultNonNullable: ctx.defaultNonNullable,\n emptyObjectsUnknown: ctx.emptyObjectsUnknown,\n enum: ctx.enum,\n enumValues: ctx.enumValues,\n excludeDeprecated: ctx.excludeDeprecated,\n fixes: new Set(ctx.fix ?? []),\n immutable: ctx.immutable,\n propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,\n readWriteMarkers: ctx.readWriteMarkers,\n generatePathParams: ctx.generatePathParams,\n pathParamsAsTypes: ctx.pathParamsAsTypes,\n rootTypes: ctx.rootTypes,\n rootTypesNoSchemaPrefix: ctx.rootTypesNoSchemaPrefix,\n rootTypesKeepCasing: ctx.rootTypesKeepCasing,\n exportType: ctx.exportType,\n inject: ctx.inject,\n makePathsEnum: ctx.makePathsEnum,\n };\n}\n\n/** One footer per run: it holds the enum registry, so it lives on the run's context. */\nfunction runFooter(ctx: GlobalContext): DocumentFooter {\n ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);\n return ctx.runFooter;\n}\n\nconst CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) };\n\n/**\n * A monotonic clock and the run's logger (the default one for a user's own context), \"ts\" group.\n */\nfunction diagnostics(ctx: GlobalContext): TransformDiagnostics {\n const logger = ctx.logger ?? defaultLogger(ctx.silent);\n return {\n now: monotonicNow,\n debug: (message, durationMs) => logger.debug(message, \"ts\", durationMs),\n };\n}\n\n/** The ported transformers' context for one call from a legacy transformer. */\nexport function createTransformContext(ctx: GlobalContext): TransformContext {\n return {\n options: transformOptions(ctx),\n refs: { resolve: (ref) => ctx.resolve(ref) },\n discriminators: {\n objectAt: (ref) => ctx.discriminators.objects[ref],\n isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),\n otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],\n enumParentOf: (schema) =>\n ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,\n },\n footer: runFooter(ctx),\n callbacks: schemaCallbacks(ctx),\n diagnostics: diagnostics(ctx),\n casing: CASING,\n };\n}\n\n/** The transformer's location for the original options object. */\nexport function schemaLocation(options: TransformNodeOptions): SchemaLocation {\n return { path: options.path, schema: options.schema };\n}\n"],"names":[],"mappings":";;;;;;AAuBA,SAAS,iBAAiB,GAAA,EAAsC;AAC9D,EAAA,OAAO;AAAA,IACL,sBAAsB,GAAA,CAAI,oBAAA;AAAA,IAC1B,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,cAAc,GAAA,CAAI,YAAA;AAAA,IAClB,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,oBAAoB,GAAA,CAAI,kBAAA;AAAA,IACxB,qBAAqB,GAAA,CAAI,mBAAA;AAAA,IACzB,MAAM,GAAA,CAAI,IAAA;AAAA,IACV,YAAY,GAAA,CAAI,UAAA;AAAA,IAChB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,IACvB,OAAO,IAAI,GAAA,CAAI,GAAA,CAAI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C,cAAA,EAAgB;AAAA,MACd,UAAU,CAAC,GAAA,KAAQ,GAAA,CAAI,cAAA,CAAe,QAAQ,GAAG,CAAA;AAAA,MACjD,WAAW,CAAC,GAAA,KAAQ,IAAI,cAAA,CAAe,WAAA,CAAY,SAAS,GAAG,CAAA;AAAA,MAC/D,iBAAA,EAAmB,CAAC,GAAA,KAAQ,GAAA,CAAI,eAAe,eAAA,GAAkB,GAAG,KAAK,EAAC;AAAA,MAC1E,cAAc,CAAC,MAAA,KACb,IAAI,cAAA,CAAe,WAAA,EAAa,IAAI,MAAM;AAAA,KAC9C;AAAA,IACA,MAAA,EAAQ,UAAU,GAAG,CAAA;AAAA,IACrB,SAAA,EAAW,gBAAgB,GAAG,CAAA;AAAA,IAC9B,WAAA,EAAa,YAAY,GAAG,CAAA;AAAA,IAC5B,MAAA,EAAQ;AAAA,GACV;AACF;AAGO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,MAAA,EAAQ,QAAQ,MAAA,EAAO;AACtD;;"}
|
|
@@ -4,8 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const document = require('../application/transform/document/document.cjs');
|
|
6
6
|
const rootTypeAliases = require('../application/transform/document/root-type-aliases.cjs');
|
|
7
|
+
const documentFooter = require('../application/transform/footer/document-footer.cjs');
|
|
8
|
+
const enumValuesCheck = require('../application/transform/footer/enum-values-check.cjs');
|
|
9
|
+
const sharedEnumNames = require('../application/transform/footer/shared-enum-names.cjs');
|
|
10
|
+
const outputFixes = require('../domain/output-fixes.cjs');
|
|
11
|
+
const discriminatorEnumNames = require('./discriminator-enum-names.cjs');
|
|
7
12
|
const documentDeclarations = require('./document-declarations.cjs');
|
|
13
|
+
const enumValuesWarnings = require('./enum-values-warnings.cjs');
|
|
8
14
|
const footerEntry = require('./footer-entry.cjs');
|
|
15
|
+
const footerSink = require('./footer-sink.cjs');
|
|
9
16
|
const transformContext = require('./transform-context.cjs');
|
|
10
17
|
|
|
11
18
|
const OPERATIONS_NAME = "operations";
|
|
@@ -13,13 +20,55 @@ function isOperations(entry) {
|
|
|
13
20
|
const name = footerEntry.isIrDeclaration(entry) ? entry.name : entry.name?.escapedText;
|
|
14
21
|
return name === OPERATIONS_NAME;
|
|
15
22
|
}
|
|
23
|
+
const dropMessage = () => void 0;
|
|
24
|
+
const DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };
|
|
25
|
+
function sharedEnumNamesOf(document$1, ctx, recorder) {
|
|
26
|
+
const injectFooter = [];
|
|
27
|
+
const scratch = {
|
|
28
|
+
...ctx,
|
|
29
|
+
injectFooter,
|
|
30
|
+
runFooter: new documentFooter.RunFooter(new footerSink.ContextFooterSink(injectFooter), true, recorder),
|
|
31
|
+
logger: DROPPED_MESSAGES,
|
|
32
|
+
legacyCallbackWarnings: /* @__PURE__ */ new Set()
|
|
33
|
+
};
|
|
34
|
+
const scratchContext = transformContext.createTransformContext(scratch);
|
|
35
|
+
document.documentBody(document$1, scratchContext, () => injectFooter.filter(footerEntry.isIrDeclaration));
|
|
36
|
+
return recorder.chosenNames();
|
|
37
|
+
}
|
|
38
|
+
function enumNameRecorderOf(ctx) {
|
|
39
|
+
if (ctx.fix?.includes(outputFixes.OutputFix.DEDUPE_ENUM_NAMES)) {
|
|
40
|
+
return new sharedEnumNames.SharedEnumNameRecorder();
|
|
41
|
+
}
|
|
42
|
+
return ctx.fix?.includes(outputFixes.OutputFix.DISCRIMINATOR_VALUES) ? new discriminatorEnumNames.FirstSchemaNameRecorder() : null;
|
|
43
|
+
}
|
|
44
|
+
function withSharedEnumNames(document, ctx) {
|
|
45
|
+
const recorder = ctx.runFooter === void 0 ? enumNameRecorderOf(ctx) : null;
|
|
46
|
+
if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const names = sharedEnumNamesOf(document, ctx, recorder);
|
|
50
|
+
ctx.runFooter = new documentFooter.RunFooter(new footerSink.ContextFooterSink(ctx.injectFooter), true, names);
|
|
51
|
+
}
|
|
52
|
+
function enumValuesChecked(body, footer, ctx) {
|
|
53
|
+
if (!ctx.enumValues) {
|
|
54
|
+
return footer;
|
|
55
|
+
}
|
|
56
|
+
const checked = enumValuesCheck.checkedEnumValues(footer, body, footerEntry.isIrDeclaration);
|
|
57
|
+
for (const retype of checked.retyped) {
|
|
58
|
+
if (retype.kind === "excluded") {
|
|
59
|
+
ctx.logger?.warn(enumValuesWarnings.excludedValuesWarning(retype.name, retype.excluded));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return checked.footer;
|
|
63
|
+
}
|
|
16
64
|
function transformDocument(schema, ctx) {
|
|
17
65
|
const document$1 = schema;
|
|
66
|
+
withSharedEnumNames(document$1, ctx);
|
|
18
67
|
const context = transformContext.createTransformContext(ctx);
|
|
19
|
-
const rawBody = document.documentBody(document$1, context);
|
|
20
|
-
const footer = [...ctx.injectFooter];
|
|
21
|
-
const body = rootTypeAliases.renameAliasesTakenByFooter(rawBody, footer.filter(footerEntry.isIrDeclaration));
|
|
68
|
+
const rawBody = document.documentBody(document$1, context, () => ctx.injectFooter.filter(footerEntry.isIrDeclaration));
|
|
69
|
+
const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);
|
|
22
70
|
const closing = document.documentClosing(document$1, context, footer.some(isOperations));
|
|
71
|
+
const body = rootTypeAliases.renameTakenAliases(rawBody, footer.filter(footerEntry.isIrDeclaration), closing);
|
|
23
72
|
return { body, footer, closing };
|
|
24
73
|
}
|
|
25
74
|
function transformSchema(schema, ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-schema.cjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"transform-schema.cjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { OutputFix } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: GlobalContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: GlobalContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: GlobalContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: GlobalContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: GlobalContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":["isIrDeclaration","document","RunFooter","ContextFooterSink","createTransformContext","documentBody","OutputFix","SharedEnumNameRecorder","FirstSchemaNameRecorder","checkedEnumValues","excludedValuesWarning","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAyB;AAAA,IAC7B,GAAG,GAAA;AAAA,IACH,YAAA;AAAA,IACA,SAAA,EAAW,IAAIC,wBAAA,CA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transform/document/document.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { renameTakenAliases } from '../application/transform/document/root-type-aliases.mjs';
|
|
3
|
+
import { RunFooter } from '../application/transform/footer/document-footer.mjs';
|
|
4
|
+
import { checkedEnumValues } from '../application/transform/footer/enum-values-check.mjs';
|
|
5
|
+
import { SharedEnumNameRecorder } from '../application/transform/footer/shared-enum-names.mjs';
|
|
6
|
+
import { OutputFix } from '../domain/output-fixes.mjs';
|
|
7
|
+
import { FirstSchemaNameRecorder } from './discriminator-enum-names.mjs';
|
|
3
8
|
import { documentDeclarations } from './document-declarations.mjs';
|
|
9
|
+
import { excludedValuesWarning } from './enum-values-warnings.mjs';
|
|
4
10
|
import { isIrDeclaration } from './footer-entry.mjs';
|
|
11
|
+
import { ContextFooterSink } from './footer-sink.mjs';
|
|
5
12
|
import { createTransformContext } from './transform-context.mjs';
|
|
6
13
|
|
|
7
14
|
const OPERATIONS_NAME = "operations";
|
|
@@ -9,13 +16,55 @@ function isOperations(entry) {
|
|
|
9
16
|
const name = isIrDeclaration(entry) ? entry.name : entry.name?.escapedText;
|
|
10
17
|
return name === OPERATIONS_NAME;
|
|
11
18
|
}
|
|
19
|
+
const dropMessage = () => void 0;
|
|
20
|
+
const DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };
|
|
21
|
+
function sharedEnumNamesOf(document, ctx, recorder) {
|
|
22
|
+
const injectFooter = [];
|
|
23
|
+
const scratch = {
|
|
24
|
+
...ctx,
|
|
25
|
+
injectFooter,
|
|
26
|
+
runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),
|
|
27
|
+
logger: DROPPED_MESSAGES,
|
|
28
|
+
legacyCallbackWarnings: /* @__PURE__ */ new Set()
|
|
29
|
+
};
|
|
30
|
+
const scratchContext = createTransformContext(scratch);
|
|
31
|
+
documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));
|
|
32
|
+
return recorder.chosenNames();
|
|
33
|
+
}
|
|
34
|
+
function enumNameRecorderOf(ctx) {
|
|
35
|
+
if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {
|
|
36
|
+
return new SharedEnumNameRecorder();
|
|
37
|
+
}
|
|
38
|
+
return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
|
|
39
|
+
}
|
|
40
|
+
function withSharedEnumNames(document, ctx) {
|
|
41
|
+
const recorder = ctx.runFooter === void 0 ? enumNameRecorderOf(ctx) : null;
|
|
42
|
+
if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const names = sharedEnumNamesOf(document, ctx, recorder);
|
|
46
|
+
ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);
|
|
47
|
+
}
|
|
48
|
+
function enumValuesChecked(body, footer, ctx) {
|
|
49
|
+
if (!ctx.enumValues) {
|
|
50
|
+
return footer;
|
|
51
|
+
}
|
|
52
|
+
const checked = checkedEnumValues(footer, body, isIrDeclaration);
|
|
53
|
+
for (const retype of checked.retyped) {
|
|
54
|
+
if (retype.kind === "excluded") {
|
|
55
|
+
ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return checked.footer;
|
|
59
|
+
}
|
|
12
60
|
function transformDocument(schema, ctx) {
|
|
13
61
|
const document = schema;
|
|
62
|
+
withSharedEnumNames(document, ctx);
|
|
14
63
|
const context = createTransformContext(ctx);
|
|
15
|
-
const rawBody = documentBody(document, context);
|
|
16
|
-
const footer = [...ctx.injectFooter];
|
|
17
|
-
const body = renameAliasesTakenByFooter(rawBody, footer.filter(isIrDeclaration));
|
|
64
|
+
const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));
|
|
65
|
+
const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);
|
|
18
66
|
const closing = documentClosing(document, context, footer.some(isOperations));
|
|
67
|
+
const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);
|
|
19
68
|
return { body, footer, closing };
|
|
20
69
|
}
|
|
21
70
|
function transformSchema(schema, ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-schema.mjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"transform-schema.mjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { OutputFix } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: GlobalContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: GlobalContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: GlobalContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: GlobalContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: GlobalContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAO,eAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACP,QAAA,EAC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AqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const unsupportedFeatures = require('../domain/openapi/unsupported-features.cjs');
|
|
4
|
+
const warnings = require('../domain/warnings.cjs');
|
|
4
5
|
|
|
5
6
|
const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
|
|
6
7
|
const SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;
|
|
7
8
|
const REASONS = {
|
|
8
9
|
[unsupportedFeatures.UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: 'is an "in: querystring" parameter next to "in: query" parameters, which OpenAPI 3.2 does not allow; the query parameters keep their types and this parameter is not in the generated types'
|
|
9
10
|
};
|
|
11
|
+
const CODES = {
|
|
12
|
+
[unsupportedFeatures.UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: warnings.WARNING_CODES.QUERYSTRING_NEXT_TO_QUERY
|
|
13
|
+
};
|
|
10
14
|
function warnUnsupportedFeatures(document, logger) {
|
|
11
15
|
for (const { feature, pointer } of unsupportedFeatures.findUnsupportedFeatures(document)) {
|
|
12
|
-
|
|
16
|
+
const message = `${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`;
|
|
17
|
+
logger.warn(warnings.warningText(message, CODES[feature]));
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-feature-warnings.cjs","sources":["../../src/api/unsupported-feature-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n findUnsupportedFeatures,\n UnsupportedFeature,\n} from \"../domain/openapi/unsupported-features.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;\n\n/** Why each feature is not in the generated types. */\nconst REASONS: Readonly<Record<UnsupportedFeature, string>> = {\n [UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]:\n 'is an \"in: querystring\" parameter next to \"in: query\" parameters, which OpenAPI 3.2 does ' +\n \"not allow; the query parameters keep their types and this parameter is not in the \" +\n \"generated types\",\n};\n\n/**\n * Warn once per use of an OpenAPI 3.2 feature that the generated types leave out, so a missing\n * parameter is never silent (CODING_PRINCIPLES §8.7).\n */\nexport function warnUnsupportedFeatures(document: unknown, logger: Logger): void {\n for (const { feature, pointer } of findUnsupportedFeatures(document)) {\n
|
|
1
|
+
{"version":3,"file":"unsupported-feature-warnings.cjs","sources":["../../src/api/unsupported-feature-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n findUnsupportedFeatures,\n UnsupportedFeature,\n} from \"../domain/openapi/unsupported-features.js\";\nimport { WARNING_CODES, type WarningCode, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;\n\n/** Why each feature is not in the generated types. */\nconst REASONS: Readonly<Record<UnsupportedFeature, string>> = {\n [UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]:\n 'is an \"in: querystring\" parameter next to \"in: query\" parameters, which OpenAPI 3.2 does ' +\n \"not allow; the query parameters keep their types and this parameter is not in the \" +\n \"generated types\",\n};\n\n/** The warning code of each feature. */\nconst CODES: Readonly<Record<UnsupportedFeature, WarningCode>> = {\n [UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: WARNING_CODES.QUERYSTRING_NEXT_TO_QUERY,\n};\n\n/**\n * Warn once per use of an OpenAPI 3.2 feature that the generated types leave out, so a missing\n * parameter is never silent (CODING_PRINCIPLES §8.7).\n */\nexport function warnUnsupportedFeatures(document: unknown, logger: Logger): void {\n for (const { feature, pointer } of findUnsupportedFeatures(document)) {\n const message = `${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`;\n logger.warn(warningText(message, CODES[feature]));\n }\n}\n"],"names":["UnsupportedFeature","WARNING_CODES","findUnsupportedFeatures","warningText"],"mappings":";;;;;AAOA,MAAM,aAAA,GAAgB,qEAAA;AACtB,MAAM,gBAAA,GAAmB,GAAG,aAAa,CAAA,oCAAA,CAAA;AAGzC,MAAM,OAAA,GAAwD;AAAA,EAC5D,CAACA,sCAAA,CAAmB,yBAAyB,GAC3C;AAGJ,CAAA;AAGA,MAAM,KAAA,GAA2D;AAAA,EAC/D,CAACA,sCAAA,CAAmB,yBAAyB,GAAGC,sBAAA,CAAc;AAChE,CAAA;AAMO,SAAS,uBAAA,CAAwB,UAAmB,MAAA,EAAsB;AAC/E,EAAA,KAAA,MAAW,EAAE,OAAA,EAAS,OAAA,EAAQ,IAAKC,2CAAA,CAAwB,QAAQ,CAAA,EAAG;AACpE,IAAA,MAAM,OAAA,GAAU,GAAG,OAAO,CAAA,CAAA,EAAI,QAAQ,OAAO,CAAC,SAAS,gBAAgB,CAAA,CAAA;AACvE,IAAA,MAAA,CAAO,KAAKC,oBAAA,CAAY,OAAA,EAAS,KAAA,CAAM,OAAO,CAAC,CAAC,CAAA;AAAA,EAClD;AACF;;"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { findUnsupportedFeatures, UnsupportedFeature } from '../domain/openapi/unsupported-features.mjs';
|
|
2
|
+
import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
|
|
2
3
|
|
|
3
4
|
const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
|
|
4
5
|
const SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;
|
|
5
6
|
const REASONS = {
|
|
6
7
|
[UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: 'is an "in: querystring" parameter next to "in: query" parameters, which OpenAPI 3.2 does not allow; the query parameters keep their types and this parameter is not in the generated types'
|
|
7
8
|
};
|
|
9
|
+
const CODES = {
|
|
10
|
+
[UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: WARNING_CODES.QUERYSTRING_NEXT_TO_QUERY
|
|
11
|
+
};
|
|
8
12
|
function warnUnsupportedFeatures(document, logger) {
|
|
9
13
|
for (const { feature, pointer } of findUnsupportedFeatures(document)) {
|
|
10
|
-
|
|
14
|
+
const message = `${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`;
|
|
15
|
+
logger.warn(warningText(message, CODES[feature]));
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-feature-warnings.mjs","sources":["../../src/api/unsupported-feature-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n findUnsupportedFeatures,\n UnsupportedFeature,\n} from \"../domain/openapi/unsupported-features.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;\n\n/** Why each feature is not in the generated types. */\nconst REASONS: Readonly<Record<UnsupportedFeature, string>> = {\n [UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]:\n 'is an \"in: querystring\" parameter next to \"in: query\" parameters, which OpenAPI 3.2 does ' +\n \"not allow; the query parameters keep their types and this parameter is not in the \" +\n \"generated types\",\n};\n\n/**\n * Warn once per use of an OpenAPI 3.2 feature that the generated types leave out, so a missing\n * parameter is never silent (CODING_PRINCIPLES §8.7).\n */\nexport function warnUnsupportedFeatures(document: unknown, logger: Logger): void {\n for (const { feature, pointer } of findUnsupportedFeatures(document)) {\n
|
|
1
|
+
{"version":3,"file":"unsupported-feature-warnings.mjs","sources":["../../src/api/unsupported-feature-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n findUnsupportedFeatures,\n UnsupportedFeature,\n} from \"../domain/openapi/unsupported-features.js\";\nimport { WARNING_CODES, type WarningCode, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;\n\n/** Why each feature is not in the generated types. */\nconst REASONS: Readonly<Record<UnsupportedFeature, string>> = {\n [UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]:\n 'is an \"in: querystring\" parameter next to \"in: query\" parameters, which OpenAPI 3.2 does ' +\n \"not allow; the query parameters keep their types and this parameter is not in the \" +\n \"generated types\",\n};\n\n/** The warning code of each feature. */\nconst CODES: Readonly<Record<UnsupportedFeature, WarningCode>> = {\n [UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: WARNING_CODES.QUERYSTRING_NEXT_TO_QUERY,\n};\n\n/**\n * Warn once per use of an OpenAPI 3.2 feature that the generated types leave out, so a missing\n * parameter is never silent (CODING_PRINCIPLES §8.7).\n */\nexport function warnUnsupportedFeatures(document: unknown, logger: Logger): void {\n for (const { feature, pointer } of findUnsupportedFeatures(document)) {\n const message = `${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`;\n logger.warn(warningText(message, CODES[feature]));\n }\n}\n"],"names":[],"mappings":";;;AAOA,MAAM,aAAA,GAAgB,qEAAA;AACtB,MAAM,gBAAA,GAAmB,GAAG,aAAa,CAAA,oCAAA,CAAA;AAGzC,MAAM,OAAA,GAAwD;AAAA,EAC5D,CAAC,kBAAA,CAAmB,yBAAyB,GAC3C;AAGJ,CAAA;AAGA,MAAM,KAAA,GAA2D;AAAA,EAC/D,CAAC,kBAAA,CAAmB,yBAAyB,GAAG,aAAA,CAAc;AAChE,CAAA;AAMO,SAAS,uBAAA,CAAwB,UAAmB,MAAA,EAAsB;AAC/E,EAAA,KAAA,MAAW,EAAE,OAAA,EAAS,OAAA,EAAQ,IAAK,uBAAA,CAAwB,QAAQ,CAAA,EAAG;AACpE,IAAA,MAAM,OAAA,GAAU,GAAG,OAAO,CAAA,CAAA,EAAI,QAAQ,OAAO,CAAC,SAAS,gBAAgB,CAAA,CAAA;AACvE,IAAA,MAAA,CAAO,KAAK,WAAA,CAAY,OAAA,EAAS,KAAA,CAAM,OAAO,CAAC,CAAC,CAAA;AAAA,EAClD;AACF;;"}
|
|
@@ -85,6 +85,11 @@ function writeTupleElement(writer, element) {
|
|
|
85
85
|
if (element.isRest) {
|
|
86
86
|
writer.write("...");
|
|
87
87
|
}
|
|
88
|
+
if (element.isOptional) {
|
|
89
|
+
writeTypeIn(writer, element.type, needsParensAsPostfixOperand);
|
|
90
|
+
writer.write("?");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
88
93
|
writeType(writer, element.type);
|
|
89
94
|
}
|
|
90
95
|
function writeObjectType(writer, members) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-printer.cjs","sources":["../../../src/application/print/type-printer.ts"],"sourcesContent":["import { assertNever } from \"../../domain/assert-never.js\";\nimport type {\n IrIndexedAccessType,\n IrMember,\n IrPropertyName,\n IrRawType,\n IrTupleElement,\n IrType,\n} from \"../../domain/ir/nodes.js\";\nimport { writeLeadingComment } from \"./comment-writer.js\";\nimport { printEscapedString, printNumberLiteral, printStringLiteral } from \"./literal-text.js\";\nimport type { TextWriter } from \"./text-writer.js\";\n\n/**\n * Parenthesization contexts. Each predicate says when a child type needs parentheses; together they\n * reproduce the TypeScript factory's parenthesizer rules for the node kinds of the IR, so output\n * matches the original even when unions are nested (`A | (B | C)`).\n */\nconst isUnionOrIntersection = (type: IrType): boolean =>\n type.kind === \"union\" || type.kind === \"intersection\";\n/** Union and intersection members (`parenthesizeConstituentTypeOf{Union,Intersection}Type`). */\nconst needsParensAsConstituent = isUnionOrIntersection;\n/** Array element and indexed-access object (`parenthesizeNonArrayTypeOfPostfixType`). */\nconst needsParensAsPostfixOperand = (type: IrType): boolean =>\n type.kind === \"readonly\" || isUnionOrIntersection(type);\n/** Operand of `readonly` (`parenthesizeOperandOfReadonlyTypeOperator`). */\nconst needsParensAsReadonlyOperand = needsParensAsPostfixOperand;\n\nfunction writeTypeIn(\n writer: TextWriter,\n type: IrType,\n needsParens: (type: IrType) => boolean,\n): void {\n if (!needsParens(type)) {\n writeType(writer, type);\n return;\n }\n writer.write(\"(\");\n writeType(writer, type);\n writer.write(\")\");\n}\n\n/** Write a single-line list: `separator` between items, nothing for an empty list. */\nfunction writeInlineList<T>(\n writer: TextWriter,\n items: readonly T[],\n separator: string,\n writeItem: (item: T) => void,\n) {\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(separator);\n }\n writeItem(item);\n });\n}\n\n/**\n * Write a multi-line list the way the TypeScript printer does: a line break after the opening\n * token, one item per indented line, `delimiter` after every item but the last, and a line break\n * before the closing token. An empty list prints the line break only when `isLineBreakWhenEmpty`\n * (interfaces, enums and tuples do; object type literals print `{}`).\n */\nexport function writeMultiLineList<T>(\n writer: TextWriter,\n items: readonly T[],\n format: { readonly delimiter: string; readonly isLineBreakWhenEmpty: boolean },\n writeItem: (item: T) => void,\n): void {\n if (items.length === 0) {\n if (format.isLineBreakWhenEmpty) {\n writer.writeLine();\n }\n return;\n }\n writer.writeLine();\n writer.increaseIndent();\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(format.delimiter);\n writer.writeLine();\n }\n writeItem(item);\n });\n writer.decreaseIndent();\n writer.writeLine();\n}\n\nfunction writePropertyName(writer: TextWriter, name: IrPropertyName): void {\n switch (name.kind) {\n case \"identifier\":\n case \"number\":\n writer.write(name.text);\n break;\n case \"string\":\n writer.write(printEscapedString(name.value));\n break;\n default:\n assertNever(name);\n }\n}\n\n/**\n * `[name: type]`. TypeScript prints index signature parameters as an indented list, so a multi-line\n * parameter type (an object or tuple) is indented one level deeper than the member.\n */\nfunction writeIndexSignatureParameter(writer: TextWriter, name: string, type: IrType): void {\n writer.write(`[${name}: `);\n writer.increaseIndent();\n writeType(writer, type);\n writer.decreaseIndent();\n writer.write(\"]\");\n}\n\n/** Write one member of an interface or object type, with its comment and trailing semicolon. */\nexport function writeMember(writer: TextWriter, member: IrMember): void {\n for (const comment of member.comments) {\n writeLeadingComment(writer, comment);\n }\n if (member.isReadonly) {\n writer.write(\"readonly \");\n }\n if (member.kind === \"property\") {\n writePropertyName(writer, member.name);\n writer.write(member.isOptional ? \"?: \" : \": \");\n } else {\n writeIndexSignatureParameter(writer, member.parameterName, member.parameterType);\n writer.write(\": \");\n }\n writeType(writer, member.type);\n writer.write(\";\");\n}\n\nfunction writeTupleElement(writer: TextWriter, element: IrTupleElement): void {\n if (element.isRest) {\n writer.write(\"...\");\n }\n writeType(writer, element.type);\n}\n\nfunction writeObjectType(writer: TextWriter, members: readonly IrMember[]): void {\n writer.write(\"{\");\n writeMultiLineList(writer, members, { delimiter: \"\", isLineBreakWhenEmpty: false }, (member) =>\n writeMember(writer, member),\n );\n writer.write(\"}\");\n}\n\nfunction writeTupleType(writer: TextWriter, elements: readonly IrTupleElement[]): void {\n writer.write(\"[\");\n writeMultiLineList(writer, elements, { delimiter: \",\", isLineBreakWhenEmpty: true }, (element) =>\n writeTupleElement(writer, element),\n );\n writer.write(\"]\");\n}\n\nfunction writeReferenceType(\n writer: TextWriter,\n name: string,\n typeArguments: readonly IrType[],\n): void {\n writer.write(name);\n if (typeArguments.length > 0) {\n writer.write(\"<\");\n writeInlineList(writer, typeArguments, \", \", (argument) => writeType(writer, argument));\n writer.write(\">\");\n }\n}\n\nfunction writeIndexedAccessType(writer: TextWriter, type: IrIndexedAccessType): void {\n writeTypeIn(writer, type.object, needsParensAsPostfixOperand);\n writer.write(\"[\");\n writeType(writer, type.index);\n writer.write(\"]\");\n}\n\nfunction writeConstituents(writer: TextWriter, types: readonly IrType[], separator: string): void {\n writeInlineList(writer, types, separator, (member) =>\n writeTypeIn(writer, member, needsParensAsConstituent),\n );\n}\n\ntype IrLeafType = Extract<\n IrType,\n { kind: \"keyword\" | \"stringLiteral\" | \"numberLiteral\" | \"booleanLiteral\" }\n>;\n\nfunction printLeafType(type: IrLeafType): string {\n switch (type.kind) {\n case \"keyword\":\n return type.keyword;\n case \"stringLiteral\":\n return printStringLiteral(type.value, type.encoding);\n case \"numberLiteral\":\n return printNumberLiteral(type.value);\n case \"booleanLiteral\":\n return String(type.value);\n default:\n return assertNever(type);\n }\n}\n\n/**\n * Raw text is printed as if it started at column 0, so its continuation lines get the current\n * indentation, as the TypeScript printer indents a nested node.\n */\nfunction writeRawType(writer: TextWriter, text: string): void {\n text.split(\"\\n\").forEach((line, index) => {\n if (index > 0) {\n writer.rawWrite(writer.options.newLine);\n }\n writer.write(line);\n });\n}\n\nfunction writeArrayType(writer: TextWriter, element: IrType): void {\n writeTypeIn(writer, element, needsParensAsPostfixOperand);\n writer.write(\"[]\");\n}\n\nfunction writeReadonlyType(writer: TextWriter, operand: IrType): void {\n writer.write(\"readonly \");\n writeTypeIn(writer, operand, needsParensAsReadonlyOperand);\n}\n\ntype IrOperatorType = Extract<IrType, { kind: \"array\" | \"indexedAccess\" | \"readonly\" }>;\n\n/** Types built with a type operator: `T[]`, `T[K]` and `readonly T`. */\nfunction writeOperatorType(writer: TextWriter, type: IrOperatorType): void {\n if (type.kind === \"array\") {\n writeArrayType(writer, type.element);\n } else if (type.kind === \"indexedAccess\") {\n writeIndexedAccessType(writer, type);\n } else {\n writeReadonlyType(writer, type.type);\n }\n}\n\nconst CONSTITUENT_SEPARATORS = { union: \" | \", intersection: \" & \" } as const;\n\n/** A raw type may span lines and is re-indented; any other leaf prints on one line. */\nfunction writeLeafType(writer: TextWriter, type: IrLeafType | IrRawType): void {\n if (type.kind === \"raw\") {\n writeRawType(writer, type.text);\n } else {\n writer.write(printLeafType(type));\n }\n}\n\n/** Write a type at the writer's current position. */\nexport function writeType(writer: TextWriter, type: IrType): void {\n switch (type.kind) {\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"raw\":\n writeLeafType(writer, type);\n break;\n case \"reference\":\n writeReferenceType(writer, type.name, type.typeArguments);\n break;\n case \"array\":\n case \"indexedAccess\":\n case \"readonly\":\n writeOperatorType(writer, type);\n break;\n case \"union\":\n case \"intersection\":\n writeConstituents(writer, type.types, CONSTITUENT_SEPARATORS[type.kind]);\n break;\n case \"object\":\n writeObjectType(writer, type.members);\n break;\n case \"tuple\":\n writeTupleType(writer, type.elements);\n break;\n default:\n assertNever(type);\n }\n}\n"],"names":["printEscapedString","assertNever","writeLeadingComment","printStringLiteral","printNumberLiteral"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB,CAAC,IAAA,KAC7B,KAAK,IAAA,KAAS,OAAA,IAAW,KAAK,IAAA,KAAS,cAAA;AAEzC,MAAM,wBAAA,GAA2B,qBAAA;AAEjC,MAAM,8BAA8B,CAAC,IAAA,KACnC,KAAK,IAAA,KAAS,UAAA,IAAc,sBAAsB,IAAI,CAAA;AAExD,MAAM,4BAAA,GAA+B,2BAAA;AAErC,SAAS,WAAA,CACP,MAAA,EACA,IAAA,EACA,WAAA,EACM;AACN,EAAA,IAAI,CAAC,WAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,SAAA,CAAU,QAAQ,IAAI,CAAA;AACtB,IAAA;AAAA,EACF;AACA,EAAA,MAAA,CAAO,MAAM,GAAG,CAAA;AAChB,EAAA,SAAA,CAAU,QAAQ,IAAI,CAAA;AACtB,EAAA,MAAA,CAAO,MAAM,GAAG,CAAA;AAClB;AAGA,SAAS,eAAA,CACP,MAAA,EACA,KAAA,EACA,SAAA,EACA,SAAA,EACA;AACA,EAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,IAAA,EAAM,KAAA,KAAU;AAC7B,IAAA,IAAI,QAAQ,CAAA,EAAG;AACb,MAAA,MAAA,CAAO,MAAM,SAAS,CAAA;AAAA,IACxB;AACA,IAAA,SAAA,CAAU,IAAI,CAAA;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AuB,IAAA,CAAK,IAAI,CAAC,CAAA;AACvE,MAAA;AAAA,IACF,KAAK,QAAA;AACH,MAAA,eAAA,CAAgB,MAAA,EAAQ,KAAK,OAAO,CAAA;AACpC,MAAA;AAAA,IACF,KAAK,OAAA;AACH,MAAA,cAAA,CAAe,MAAA,EAAQ,KAAK,QAAQ,CAAA;AACpC,MAAA;AAAA,IACF;AACE,MAAAA,uBAAA,CAAY,IAAI,CAAA;AAAA;AAEtB;;;;"}
|
|
1
|
+
{"version":3,"file":"type-printer.cjs","sources":["../../../src/application/print/type-printer.ts"],"sourcesContent":["import { assertNever } from \"../../domain/assert-never.js\";\nimport type {\n IrIndexedAccessType,\n IrMember,\n IrPropertyName,\n IrRawType,\n IrTupleElement,\n IrType,\n} from \"../../domain/ir/nodes.js\";\nimport { writeLeadingComment } from \"./comment-writer.js\";\nimport { printEscapedString, printNumberLiteral, printStringLiteral } from \"./literal-text.js\";\nimport type { TextWriter } from \"./text-writer.js\";\n\n/**\n * Parenthesization contexts. Each predicate says when a child type needs parentheses; together they\n * reproduce the TypeScript factory's parenthesizer rules for the node kinds of the IR, so output\n * matches the original even when unions are nested (`A | (B | C)`).\n */\nconst isUnionOrIntersection = (type: IrType): boolean =>\n type.kind === \"union\" || type.kind === \"intersection\";\n/** Union and intersection members (`parenthesizeConstituentTypeOf{Union,Intersection}Type`). */\nconst needsParensAsConstituent = isUnionOrIntersection;\n/** Array element and indexed-access object (`parenthesizeNonArrayTypeOfPostfixType`). */\nconst needsParensAsPostfixOperand = (type: IrType): boolean =>\n type.kind === \"readonly\" || isUnionOrIntersection(type);\n/** Operand of `readonly` (`parenthesizeOperandOfReadonlyTypeOperator`). */\nconst needsParensAsReadonlyOperand = needsParensAsPostfixOperand;\n\nfunction writeTypeIn(\n writer: TextWriter,\n type: IrType,\n needsParens: (type: IrType) => boolean,\n): void {\n if (!needsParens(type)) {\n writeType(writer, type);\n return;\n }\n writer.write(\"(\");\n writeType(writer, type);\n writer.write(\")\");\n}\n\n/** Write a single-line list: `separator` between items, nothing for an empty list. */\nfunction writeInlineList<T>(\n writer: TextWriter,\n items: readonly T[],\n separator: string,\n writeItem: (item: T) => void,\n) {\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(separator);\n }\n writeItem(item);\n });\n}\n\n/**\n * Write a multi-line list the way the TypeScript printer does: a line break after the opening\n * token, one item per indented line, `delimiter` after every item but the last, and a line break\n * before the closing token. An empty list prints the line break only when `isLineBreakWhenEmpty`\n * (interfaces, enums and tuples do; object type literals print `{}`).\n */\nexport function writeMultiLineList<T>(\n writer: TextWriter,\n items: readonly T[],\n format: { readonly delimiter: string; readonly isLineBreakWhenEmpty: boolean },\n writeItem: (item: T) => void,\n): void {\n if (items.length === 0) {\n if (format.isLineBreakWhenEmpty) {\n writer.writeLine();\n }\n return;\n }\n writer.writeLine();\n writer.increaseIndent();\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(format.delimiter);\n writer.writeLine();\n }\n writeItem(item);\n });\n writer.decreaseIndent();\n writer.writeLine();\n}\n\nfunction writePropertyName(writer: TextWriter, name: IrPropertyName): void {\n switch (name.kind) {\n case \"identifier\":\n case \"number\":\n writer.write(name.text);\n break;\n case \"string\":\n writer.write(printEscapedString(name.value));\n break;\n default:\n assertNever(name);\n }\n}\n\n/**\n * `[name: type]`. TypeScript prints index signature parameters as an indented list, so a multi-line\n * parameter type (an object or tuple) is indented one level deeper than the member.\n */\nfunction writeIndexSignatureParameter(writer: TextWriter, name: string, type: IrType): void {\n writer.write(`[${name}: `);\n writer.increaseIndent();\n writeType(writer, type);\n writer.decreaseIndent();\n writer.write(\"]\");\n}\n\n/** Write one member of an interface or object type, with its comment and trailing semicolon. */\nexport function writeMember(writer: TextWriter, member: IrMember): void {\n for (const comment of member.comments) {\n writeLeadingComment(writer, comment);\n }\n if (member.isReadonly) {\n writer.write(\"readonly \");\n }\n if (member.kind === \"property\") {\n writePropertyName(writer, member.name);\n writer.write(member.isOptional ? \"?: \" : \": \");\n } else {\n writeIndexSignatureParameter(writer, member.parameterName, member.parameterType);\n writer.write(\": \");\n }\n writeType(writer, member.type);\n writer.write(\";\");\n}\n\nfunction writeTupleElement(writer: TextWriter, element: IrTupleElement): void {\n if (element.isRest) {\n writer.write(\"...\");\n }\n if (element.isOptional) {\n // TypeScript parenthesizes an optional element as a postfix operand (`(A | B)?`).\n writeTypeIn(writer, element.type, needsParensAsPostfixOperand);\n writer.write(\"?\");\n return;\n }\n writeType(writer, element.type);\n}\n\nfunction writeObjectType(writer: TextWriter, members: readonly IrMember[]): void {\n writer.write(\"{\");\n writeMultiLineList(writer, members, { delimiter: \"\", isLineBreakWhenEmpty: false }, (member) =>\n writeMember(writer, member),\n );\n writer.write(\"}\");\n}\n\nfunction writeTupleType(writer: TextWriter, elements: readonly IrTupleElement[]): void {\n writer.write(\"[\");\n writeMultiLineList(writer, elements, { delimiter: \",\", isLineBreakWhenEmpty: true }, (element) =>\n writeTupleElement(writer, element),\n );\n writer.write(\"]\");\n}\n\nfunction writeReferenceType(\n writer: TextWriter,\n name: string,\n typeArguments: readonly IrType[],\n): void {\n writer.write(name);\n if (typeArguments.length > 0) {\n writer.write(\"<\");\n writeInlineList(writer, typeArguments, \", \", (argument) => writeType(writer, argument));\n writer.write(\">\");\n }\n}\n\nfunction writeIndexedAccessType(writer: TextWriter, type: IrIndexedAccessType): void {\n writeTypeIn(writer, type.object, needsParensAsPostfixOperand);\n writer.write(\"[\");\n writeType(writer, type.index);\n writer.write(\"]\");\n}\n\nfunction writeConstituents(writer: TextWriter, types: readonly IrType[], separator: string): void {\n writeInlineList(writer, types, separator, (member) =>\n writeTypeIn(writer, member, needsParensAsConstituent),\n );\n}\n\ntype IrLeafType = Extract<\n IrType,\n { kind: \"keyword\" | \"stringLiteral\" | \"numberLiteral\" | \"booleanLiteral\" }\n>;\n\nfunction printLeafType(type: IrLeafType): string {\n switch (type.kind) {\n case \"keyword\":\n return type.keyword;\n case \"stringLiteral\":\n return printStringLiteral(type.value, type.encoding);\n case \"numberLiteral\":\n return printNumberLiteral(type.value);\n case \"booleanLiteral\":\n return String(type.value);\n default:\n return assertNever(type);\n }\n}\n\n/**\n * Raw text is printed as if it started at column 0, so its continuation lines get the current\n * indentation, as the TypeScript printer indents a nested node.\n */\nfunction writeRawType(writer: TextWriter, text: string): void {\n text.split(\"\\n\").forEach((line, index) => {\n if (index > 0) {\n writer.rawWrite(writer.options.newLine);\n }\n writer.write(line);\n });\n}\n\nfunction writeArrayType(writer: TextWriter, element: IrType): void {\n writeTypeIn(writer, element, needsParensAsPostfixOperand);\n writer.write(\"[]\");\n}\n\nfunction writeReadonlyType(writer: TextWriter, operand: IrType): void {\n writer.write(\"readonly \");\n writeTypeIn(writer, operand, needsParensAsReadonlyOperand);\n}\n\ntype IrOperatorType = Extract<IrType, { kind: \"array\" | \"indexedAccess\" | \"readonly\" }>;\n\n/** Types built with a type operator: `T[]`, `T[K]` and `readonly T`. */\nfunction writeOperatorType(writer: TextWriter, type: IrOperatorType): void {\n if (type.kind === \"array\") {\n writeArrayType(writer, type.element);\n } else if (type.kind === \"indexedAccess\") {\n writeIndexedAccessType(writer, type);\n } else {\n writeReadonlyType(writer, type.type);\n }\n}\n\nconst CONSTITUENT_SEPARATORS = { union: \" | \", intersection: \" & \" } as const;\n\n/** A raw type may span lines and is re-indented; any other leaf prints on one line. */\nfunction writeLeafType(writer: TextWriter, type: IrLeafType | IrRawType): void {\n if (type.kind === \"raw\") {\n writeRawType(writer, type.text);\n } else {\n writer.write(printLeafType(type));\n }\n}\n\n/** Write a type at the writer's current position. */\nexport function writeType(writer: TextWriter, type: IrType): void {\n switch (type.kind) {\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"raw\":\n writeLeafType(writer, type);\n break;\n case \"reference\":\n writeReferenceType(writer, type.name, type.typeArguments);\n break;\n case \"array\":\n case \"indexedAccess\":\n case \"readonly\":\n writeOperatorType(writer, type);\n break;\n case \"union\":\n case \"intersection\":\n writeConstituents(writer, type.types, CONSTITUENT_SEPARATORS[type.kind]);\n break;\n case \"object\":\n writeObjectType(writer, type.members);\n break;\n case \"tuple\":\n writeTupleType(writer, type.elements);\n break;\n default:\n assertNever(type);\n }\n}\n"],"names":["printEscapedString","assertNever","writeLeadingComment","printStringLiteral","printNumberLiteral"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB,CAAC,IAAA,KAC7B,KAAK,IAAA,KAAS,OAAA,IAAW,KAAK,IAAA,KAAS,cAAA;AAEzC,MAAM,wBAAA,GAA2B,qBAAA;AAEjC,MAAM,8BAA8B,CAAC,IAAA,KACnC,KAAK,IAAA,KAAS,UAAA,IAAc,sBAAsB,IAAI,CAAA;AAExD,MAAM,4BAAA,GAA+B,2BAAA;AAErC,SAAS,WAAA,CACP,MAAA,EACA,IAAA,EACA,WAAA,EACM;AACN,EAAA,IAAI,CAAC,WAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,SAAA,CAAU,QAAQ,IAAI,CAAA;AACtB,IAAA;AAAA,EACF;AACA,EAAA,MAAA,CAAO,MAAM,GAAG,CAAA;AAChB,EAAA,SAAA,CAAU,QAAQ,IAAI,CAAA;AACtB,EAAA,MAAA,CAAO,MAAM,GAAG,CAAA;AAClB;AAGA,SAAS,eAAA,CACP,MAAA,EACA,KAAA,EACA,SAAA,EACA,SAAA,EACA;AACA,EAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,IAAA,EAAM,KAAA,KAAU;AAC7B,IAAA,IAAI,QAAQ,CAAA,EAAG;AACb,MAAA,MAAA,CAAO,MAAM,SAAS,CAAA;AAAA,IACxB;AACA,IAAA,SAAA,CAAU,IAAI,CAAA;AAAA,EAChB,CAAC,CAAA;AACH;AAQO,SAAS,kBAAA,CACd,MAAA,EACA,KAAA,EACA,MAAA,EACA,SAAA,EACM;AACN,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACtB,IAAA,IAAI,OAAO,oBAAA,EAAsB;AAC/B,MAAA,MAAA,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I,CAAC,CAAA;AACvE,MAAA;AAAA,IACF,KAAK,QAAA;AACH,MAAA,eAAA,CAAgB,MAAA,EAAQ,KAAK,OAAO,CAAA;AACpC,MAAA;AAAA,IACF,KAAK,OAAA;AACH,MAAA,cAAA,CAAe,MAAA,EAAQ,KAAK,QAAQ,CAAA;AACpC,MAAA;AAAA,IACF;AACE,MAAAA,uBAAA,CAAY,IAAI,CAAA;AAAA;AAEtB;;;;"}
|
|
@@ -83,6 +83,11 @@ function writeTupleElement(writer, element) {
|
|
|
83
83
|
if (element.isRest) {
|
|
84
84
|
writer.write("...");
|
|
85
85
|
}
|
|
86
|
+
if (element.isOptional) {
|
|
87
|
+
writeTypeIn(writer, element.type, needsParensAsPostfixOperand);
|
|
88
|
+
writer.write("?");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
86
91
|
writeType(writer, element.type);
|
|
87
92
|
}
|
|
88
93
|
function writeObjectType(writer, members) {
|