openapi-typesafe 0.0.0 → 1.0.0-rc.0
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/LICENSE +22 -0
- package/README.md +71 -1
- package/bin/cli.js +4 -0
- package/dist/adapters/node-file-system/node-file-system.cjs +46 -0
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -0
- package/dist/adapters/node-file-system/node-file-system.mjs +40 -0
- package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -0
- package/dist/adapters/redocly-loader/alias-limit.cjs +16 -0
- package/dist/adapters/redocly-loader/alias-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/alias-limit.mjs +14 -0
- package/dist/adapters/redocly-loader/alias-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/allowed-hosts.cjs +42 -0
- package/dist/adapters/redocly-loader/allowed-hosts.cjs.map +1 -0
- package/dist/adapters/redocly-loader/allowed-hosts.mjs +40 -0
- package/dist/adapters/redocly-loader/allowed-hosts.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +53 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +51 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -0
- package/dist/adapters/redocly-loader/malformed-refs.cjs +41 -0
- package/dist/adapters/redocly-loader/malformed-refs.cjs.map +1 -0
- package/dist/adapters/redocly-loader/malformed-refs.mjs +38 -0
- package/dist/adapters/redocly-loader/malformed-refs.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs +42 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-config-source.mjs +35 -0
- package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +169 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +167 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-access.cjs +107 -0
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-access.mjs +99 -0
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-holders.cjs +31 -0
- package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-holders.mjs +29 -0
- package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +60 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.mjs +56 -0
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +87 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +77 -0
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-source.cjs +104 -0
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-source.mjs +98 -0
- package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -0
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +62 -0
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -0
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +58 -0
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -0
- package/dist/adapters/terminal-logger/terminal-logger.cjs +67 -0
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -0
- package/dist/adapters/terminal-logger/terminal-logger.mjs +59 -0
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.cjs +21 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.mjs +17 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.cjs +75 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.mjs +71 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +145 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +139 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/lazy-node.cjs +23 -0
- package/dist/adapters/type-ast-bridge/lazy-node.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/lazy-node.mjs +21 -0
- package/dist/adapters/type-ast-bridge/lazy-node.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/load-typescript.cjs +57 -0
- package/dist/adapters/type-ast-bridge/load-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/load-typescript.mjs +51 -0
- package/dist/adapters/type-ast-bridge/load-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/print-typescript.cjs +21 -0
- package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/print-typescript.mjs +19 -0
- package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.cjs +33 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.mjs +29 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs +204 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs +201 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs.map +1 -0
- package/dist/api/ast-to-string.cjs +39 -0
- package/dist/api/ast-to-string.cjs.map +1 -0
- package/dist/api/ast-to-string.mjs +37 -0
- package/dist/api/ast-to-string.mjs.map +1 -0
- package/dist/api/comment-header.cjs +11 -0
- package/dist/api/comment-header.cjs.map +1 -0
- package/dist/api/comment-header.mjs +9 -0
- package/dist/api/comment-header.mjs.map +1 -0
- package/dist/api/default-ports.cjs +38 -0
- package/dist/api/default-ports.cjs.map +1 -0
- package/dist/api/default-ports.mjs +28 -0
- package/dist/api/default-ports.mjs.map +1 -0
- package/dist/api/discriminator-enum.cjs +44 -0
- package/dist/api/discriminator-enum.cjs.map +1 -0
- package/dist/api/discriminator-enum.mjs +42 -0
- package/dist/api/discriminator-enum.mjs.map +1 -0
- package/dist/api/discriminator-scan.cjs +168 -0
- package/dist/api/discriminator-scan.cjs.map +1 -0
- package/dist/api/discriminator-scan.mjs +165 -0
- package/dist/api/discriminator-scan.mjs.map +1 -0
- package/dist/api/document-declarations.cjs +28 -0
- package/dist/api/document-declarations.cjs.map +1 -0
- package/dist/api/document-declarations.mjs +26 -0
- package/dist/api/document-declarations.mjs.map +1 -0
- package/dist/api/document-refs.cjs +53 -0
- package/dist/api/document-refs.cjs.map +1 -0
- package/dist/api/document-refs.mjs +50 -0
- package/dist/api/document-refs.mjs.map +1 -0
- package/dist/api/document-run.cjs +107 -0
- package/dist/api/document-run.cjs.map +1 -0
- package/dist/api/document-run.mjs +101 -0
- package/dist/api/document-run.mjs.map +1 -0
- package/dist/api/footer-entry.cjs +18 -0
- package/dist/api/footer-entry.cjs.map +1 -0
- package/dist/api/footer-entry.mjs +15 -0
- package/dist/api/footer-entry.mjs.map +1 -0
- package/dist/api/footer-sink.cjs +53 -0
- package/dist/api/footer-sink.cjs.map +1 -0
- package/dist/api/footer-sink.mjs +51 -0
- package/dist/api/footer-sink.mjs.map +1 -0
- package/dist/api/legacy-callback-warning.cjs +25 -0
- package/dist/api/legacy-callback-warning.cjs.map +1 -0
- package/dist/api/legacy-callback-warning.mjs +22 -0
- package/dist/api/legacy-callback-warning.mjs.map +1 -0
- package/dist/api/legacy-ts-helpers.cjs +203 -0
- package/dist/api/legacy-ts-helpers.cjs.map +1 -0
- package/dist/api/legacy-ts-helpers.mjs +187 -0
- package/dist/api/legacy-ts-helpers.mjs.map +1 -0
- package/dist/api/legacy-utils.cjs +65 -0
- package/dist/api/legacy-utils.cjs.map +1 -0
- package/dist/api/legacy-utils.mjs +50 -0
- package/dist/api/legacy-utils.mjs.map +1 -0
- package/dist/api/openapi-ts.cjs +40 -0
- package/dist/api/openapi-ts.cjs.map +1 -0
- package/dist/api/openapi-ts.mjs +34 -0
- package/dist/api/openapi-ts.mjs.map +1 -0
- package/dist/api/schema-callbacks.cjs +140 -0
- package/dist/api/schema-callbacks.cjs.map +1 -0
- package/dist/api/schema-callbacks.mjs +136 -0
- package/dist/api/schema-callbacks.mjs.map +1 -0
- package/dist/api/string-to-ast.cjs +21 -0
- package/dist/api/string-to-ast.cjs.map +1 -0
- package/dist/api/string-to-ast.mjs +18 -0
- package/dist/api/string-to-ast.mjs.map +1 -0
- package/dist/api/transform-context.cjs +82 -0
- package/dist/api/transform-context.cjs.map +1 -0
- package/dist/api/transform-context.mjs +65 -0
- package/dist/api/transform-context.mjs.map +1 -0
- package/dist/api/transform-schema.cjs +31 -0
- package/dist/api/transform-schema.cjs.map +1 -0
- package/dist/api/transform-schema.mjs +26 -0
- package/dist/api/transform-schema.mjs.map +1 -0
- package/dist/api/type-helpers.cjs +85 -0
- package/dist/api/type-helpers.cjs.map +1 -0
- package/dist/api/type-helpers.mjs +66 -0
- package/dist/api/type-helpers.mjs.map +1 -0
- package/dist/api/unsupported-feature-warnings.cjs +17 -0
- package/dist/api/unsupported-feature-warnings.cjs.map +1 -0
- package/dist/api/unsupported-feature-warnings.mjs +15 -0
- package/dist/api/unsupported-feature-warnings.mjs.map +1 -0
- package/dist/application/print/comment-writer.cjs +95 -0
- package/dist/application/print/comment-writer.cjs.map +1 -0
- package/dist/application/print/comment-writer.mjs +93 -0
- package/dist/application/print/comment-writer.mjs.map +1 -0
- package/dist/application/print/declaration-printer.cjs +83 -0
- package/dist/application/print/declaration-printer.cjs.map +1 -0
- package/dist/application/print/declaration-printer.mjs +81 -0
- package/dist/application/print/declaration-printer.mjs.map +1 -0
- package/dist/application/print/literal-text.cjs +52 -0
- package/dist/application/print/literal-text.cjs.map +1 -0
- package/dist/application/print/literal-text.mjs +48 -0
- package/dist/application/print/literal-text.mjs.map +1 -0
- package/dist/application/print/print-nodes.cjs +38 -0
- package/dist/application/print/print-nodes.cjs.map +1 -0
- package/dist/application/print/print-nodes.mjs +36 -0
- package/dist/application/print/print-nodes.mjs.map +1 -0
- package/dist/application/print/print-options.cjs +6 -0
- package/dist/application/print/print-options.cjs.map +1 -0
- package/dist/application/print/print-options.mjs +4 -0
- package/dist/application/print/print-options.mjs.map +1 -0
- package/dist/application/print/text-writer.cjs +63 -0
- package/dist/application/print/text-writer.cjs.map +1 -0
- package/dist/application/print/text-writer.mjs +60 -0
- package/dist/application/print/text-writer.mjs.map +1 -0
- package/dist/application/print/type-printer.cjs +214 -0
- package/dist/application/print/type-printer.cjs.map +1 -0
- package/dist/application/print/type-printer.mjs +210 -0
- package/dist/application/print/type-printer.mjs.map +1 -0
- package/dist/application/stack-overflow.cjs +36 -0
- package/dist/application/stack-overflow.cjs.map +1 -0
- package/dist/application/stack-overflow.mjs +31 -0
- package/dist/application/stack-overflow.mjs.map +1 -0
- package/dist/application/transform/document/components.cjs +104 -0
- package/dist/application/transform/document/components.cjs.map +1 -0
- package/dist/application/transform/document/components.mjs +102 -0
- package/dist/application/transform/document/components.mjs.map +1 -0
- package/dist/application/transform/document/defs-root.cjs +18 -0
- package/dist/application/transform/document/defs-root.cjs.map +1 -0
- package/dist/application/transform/document/defs-root.mjs +16 -0
- package/dist/application/transform/document/defs-root.mjs.map +1 -0
- package/dist/application/transform/document/document-member.cjs +13 -0
- package/dist/application/transform/document/document-member.cjs.map +1 -0
- package/dist/application/transform/document/document-member.mjs +11 -0
- package/dist/application/transform/document/document-member.mjs.map +1 -0
- package/dist/application/transform/document/document.cjs +86 -0
- package/dist/application/transform/document/document.cjs.map +1 -0
- package/dist/application/transform/document/document.mjs +83 -0
- package/dist/application/transform/document/document.mjs.map +1 -0
- package/dist/application/transform/document/header.cjs +27 -0
- package/dist/application/transform/document/header.cjs.map +1 -0
- package/dist/application/transform/document/header.mjs +25 -0
- package/dist/application/transform/document/header.mjs.map +1 -0
- package/dist/application/transform/document/kept-deprecated.cjs +96 -0
- package/dist/application/transform/document/kept-deprecated.cjs.map +1 -0
- package/dist/application/transform/document/kept-deprecated.mjs +94 -0
- package/dist/application/transform/document/kept-deprecated.mjs.map +1 -0
- package/dist/application/transform/document/media-type.cjs +42 -0
- package/dist/application/transform/document/media-type.cjs.map +1 -0
- package/dist/application/transform/document/media-type.mjs +38 -0
- package/dist/application/transform/document/media-type.mjs.map +1 -0
- package/dist/application/transform/document/operation.cjs +45 -0
- package/dist/application/transform/document/operation.cjs.map +1 -0
- package/dist/application/transform/document/operation.mjs +43 -0
- package/dist/application/transform/document/operation.mjs.map +1 -0
- package/dist/application/transform/document/parameter.cjs +25 -0
- package/dist/application/transform/document/parameter.cjs.map +1 -0
- package/dist/application/transform/document/parameter.mjs +23 -0
- package/dist/application/transform/document/parameter.mjs.map +1 -0
- package/dist/application/transform/document/parameters.cjs +114 -0
- package/dist/application/transform/document/parameters.cjs.map +1 -0
- package/dist/application/transform/document/parameters.mjs +112 -0
- package/dist/application/transform/document/parameters.mjs.map +1 -0
- package/dist/application/transform/document/path-item-conflicts.cjs +51 -0
- package/dist/application/transform/document/path-item-conflicts.cjs.map +1 -0
- package/dist/application/transform/document/path-item-conflicts.mjs +49 -0
- package/dist/application/transform/document/path-item-conflicts.mjs.map +1 -0
- package/dist/application/transform/document/path-item.cjs +82 -0
- package/dist/application/transform/document/path-item.cjs.map +1 -0
- package/dist/application/transform/document/path-item.mjs +80 -0
- package/dist/application/transform/document/path-item.mjs.map +1 -0
- package/dist/application/transform/document/path-key-overlaps.cjs +57 -0
- package/dist/application/transform/document/path-key-overlaps.cjs.map +1 -0
- package/dist/application/transform/document/path-key-overlaps.mjs +55 -0
- package/dist/application/transform/document/path-key-overlaps.mjs.map +1 -0
- package/dist/application/transform/document/paths-enum.cjs +75 -0
- package/dist/application/transform/document/paths-enum.cjs.map +1 -0
- package/dist/application/transform/document/paths-enum.mjs +72 -0
- package/dist/application/transform/document/paths-enum.mjs.map +1 -0
- package/dist/application/transform/document/paths.cjs +127 -0
- package/dist/application/transform/document/paths.cjs.map +1 -0
- package/dist/application/transform/document/paths.mjs +125 -0
- package/dist/application/transform/document/paths.mjs.map +1 -0
- package/dist/application/transform/document/request-body.cjs +36 -0
- package/dist/application/transform/document/request-body.cjs.map +1 -0
- package/dist/application/transform/document/request-body.mjs +34 -0
- package/dist/application/transform/document/request-body.mjs.map +1 -0
- package/dist/application/transform/document/response.cjs +59 -0
- package/dist/application/transform/document/response.cjs.map +1 -0
- package/dist/application/transform/document/response.mjs +57 -0
- package/dist/application/transform/document/response.mjs.map +1 -0
- package/dist/application/transform/document/responses.cjs +23 -0
- package/dist/application/transform/document/responses.cjs.map +1 -0
- package/dist/application/transform/document/responses.mjs +21 -0
- package/dist/application/transform/document/responses.mjs.map +1 -0
- package/dist/application/transform/document/root-type-aliases.cjs +69 -0
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -0
- package/dist/application/transform/document/root-type-aliases.mjs +65 -0
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -0
- package/dist/application/transform/document/webhooks.cjs +19 -0
- package/dist/application/transform/document/webhooks.cjs.map +1 -0
- package/dist/application/transform/document/webhooks.mjs +17 -0
- package/dist/application/transform/document/webhooks.mjs.map +1 -0
- package/dist/application/transform/document-entries.cjs +17 -0
- package/dist/application/transform/document-entries.cjs.map +1 -0
- package/dist/application/transform/document-entries.mjs +14 -0
- package/dist/application/transform/document-entries.mjs.map +1 -0
- package/dist/application/transform/footer/document-footer.cjs +88 -0
- package/dist/application/transform/footer/document-footer.cjs.map +1 -0
- package/dist/application/transform/footer/document-footer.mjs +86 -0
- package/dist/application/transform/footer/document-footer.mjs.map +1 -0
- package/dist/application/transform/footer/enum-naming.cjs +121 -0
- package/dist/application/transform/footer/enum-naming.cjs.map +1 -0
- package/dist/application/transform/footer/enum-naming.mjs +115 -0
- package/dist/application/transform/footer/enum-naming.mjs.map +1 -0
- package/dist/application/transform/helper-types.cjs +68 -0
- package/dist/application/transform/helper-types.cjs.map +1 -0
- package/dist/application/transform/helper-types.mjs +65 -0
- package/dist/application/transform/helper-types.mjs.map +1 -0
- package/dist/application/transform/literal-type.cjs +36 -0
- package/dist/application/transform/literal-type.cjs.map +1 -0
- package/dist/application/transform/literal-type.mjs +34 -0
- package/dist/application/transform/literal-type.mjs.map +1 -0
- package/dist/application/transform/numbered-names.cjs +18 -0
- package/dist/application/transform/numbered-names.cjs.map +1 -0
- package/dist/application/transform/numbered-names.mjs +16 -0
- package/dist/application/transform/numbered-names.mjs.map +1 -0
- package/dist/application/transform/ref-type.cjs +57 -0
- package/dist/application/transform/ref-type.cjs.map +1 -0
- package/dist/application/transform/ref-type.mjs +54 -0
- package/dist/application/transform/ref-type.mjs.map +1 -0
- package/dist/application/transform/schema/array-type.cjs +105 -0
- package/dist/application/transform/schema/array-type.cjs.map +1 -0
- package/dist/application/transform/schema/array-type.mjs +103 -0
- package/dist/application/transform/schema/array-type.mjs.map +1 -0
- package/dist/application/transform/schema/composition-type.cjs +107 -0
- package/dist/application/transform/schema/composition-type.cjs.map +1 -0
- package/dist/application/transform/schema/composition-type.mjs +105 -0
- package/dist/application/transform/schema/composition-type.mjs.map +1 -0
- package/dist/application/transform/schema/core-type.cjs +84 -0
- package/dist/application/transform/schema/core-type.cjs.map +1 -0
- package/dist/application/transform/schema/core-type.mjs +82 -0
- package/dist/application/transform/schema/core-type.mjs.map +1 -0
- package/dist/application/transform/schema/discriminator-property.cjs +21 -0
- package/dist/application/transform/schema/discriminator-property.cjs.map +1 -0
- package/dist/application/transform/schema/discriminator-property.mjs +19 -0
- package/dist/application/transform/schema/discriminator-property.mjs.map +1 -0
- package/dist/application/transform/schema/enum-rule.cjs +107 -0
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -0
- package/dist/application/transform/schema/enum-rule.mjs +105 -0
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +173 -0
- package/dist/application/transform/schema/object-type.cjs.map +1 -0
- package/dist/application/transform/schema/object-type.mjs +170 -0
- package/dist/application/transform/schema/object-type.mjs.map +1 -0
- package/dist/application/transform/schema/presence-members.cjs +59 -0
- package/dist/application/transform/schema/presence-members.cjs.map +1 -0
- package/dist/application/transform/schema/presence-members.mjs +57 -0
- package/dist/application/transform/schema/presence-members.mjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.cjs +72 -0
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.mjs +68 -0
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -0
- package/dist/application/transform/schema/unevaluated-properties.cjs +61 -0
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -0
- package/dist/application/transform/schema/unevaluated-properties.mjs +59 -0
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -0
- package/dist/application/transform/schema-comment.cjs +84 -0
- package/dist/application/transform/schema-comment.cjs.map +1 -0
- package/dist/application/transform/schema-comment.mjs +81 -0
- package/dist/application/transform/schema-comment.mjs.map +1 -0
- package/dist/application/transform/shared-types.cjs +8 -0
- package/dist/application/transform/shared-types.cjs.map +1 -0
- package/dist/application/transform/shared-types.mjs +6 -0
- package/dist/application/transform/shared-types.mjs.map +1 -0
- package/dist/application/transform/type-combinators.cjs +49 -0
- package/dist/application/transform/type-combinators.cjs.map +1 -0
- package/dist/application/transform/type-combinators.mjs +42 -0
- package/dist/application/transform/type-combinators.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +137 -0
- package/dist/cli/cli-arguments.cjs.map +1 -0
- package/dist/cli/cli-arguments.mjs +129 -0
- package/dist/cli/cli-arguments.mjs.map +1 -0
- package/dist/cli/cli-errors.cjs +80 -0
- package/dist/cli/cli-errors.cjs.map +1 -0
- package/dist/cli/cli-errors.mjs +76 -0
- package/dist/cli/cli-errors.mjs.map +1 -0
- package/dist/cli/cli-output.cjs +37 -0
- package/dist/cli/cli-output.cjs.map +1 -0
- package/dist/cli/cli-output.mjs +30 -0
- package/dist/cli/cli-output.mjs.map +1 -0
- package/dist/cli/docs-links.cjs +6 -0
- package/dist/cli/docs-links.cjs.map +1 -0
- package/dist/cli/docs-links.mjs +4 -0
- package/dist/cli/docs-links.mjs.map +1 -0
- package/dist/cli/fix-option.cjs +19 -0
- package/dist/cli/fix-option.cjs.map +1 -0
- package/dist/cli/fix-option.mjs +16 -0
- package/dist/cli/fix-option.mjs.map +1 -0
- package/dist/cli/help-text.cjs +44 -0
- package/dist/cli/help-text.cjs.map +1 -0
- package/dist/cli/help-text.mjs +42 -0
- package/dist/cli/help-text.mjs.map +1 -0
- package/dist/cli/main.cjs +62 -0
- package/dist/cli/main.cjs.map +1 -0
- package/dist/cli/main.d.cts +2 -0
- package/dist/cli/main.d.mts +2 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.mjs +54 -0
- package/dist/cli/main.mjs.map +1 -0
- package/dist/cli/redocly-apis.cjs +65 -0
- package/dist/cli/redocly-apis.cjs.map +1 -0
- package/dist/cli/redocly-apis.mjs +62 -0
- package/dist/cli/redocly-apis.mjs.map +1 -0
- package/dist/cli/ref-limits.cjs +14 -0
- package/dist/cli/ref-limits.cjs.map +1 -0
- package/dist/cli/ref-limits.mjs +12 -0
- package/dist/cli/ref-limits.mjs.map +1 -0
- package/dist/cli/run-cli.cjs +100 -0
- package/dist/cli/run-cli.cjs.map +1 -0
- package/dist/cli/run-cli.mjs +98 -0
- package/dist/cli/run-cli.mjs.map +1 -0
- package/dist/domain/assert-never.cjs +8 -0
- package/dist/domain/assert-never.cjs.map +1 -0
- package/dist/domain/assert-never.mjs +6 -0
- package/dist/domain/assert-never.mjs.map +1 -0
- package/dist/domain/errors.cjs +50 -0
- package/dist/domain/errors.cjs.map +1 -0
- package/dist/domain/errors.mjs +46 -0
- package/dist/domain/errors.mjs.map +1 -0
- package/dist/domain/ir/constructors.cjs +89 -0
- package/dist/domain/ir/constructors.cjs.map +1 -0
- package/dist/domain/ir/constructors.mjs +71 -0
- package/dist/domain/ir/constructors.mjs.map +1 -0
- package/dist/domain/ir/identifier-text.cjs +29 -0
- package/dist/domain/ir/identifier-text.cjs.map +1 -0
- package/dist/domain/ir/identifier-text.mjs +25 -0
- package/dist/domain/ir/identifier-text.mjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs +109 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.mjs +106 -0
- package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -0
- package/dist/domain/ir/normalize.cjs +32 -0
- package/dist/domain/ir/normalize.cjs.map +1 -0
- package/dist/domain/ir/normalize.mjs +29 -0
- package/dist/domain/ir/normalize.mjs.map +1 -0
- package/dist/domain/ir/property-name.cjs +19 -0
- package/dist/domain/ir/property-name.cjs.map +1 -0
- package/dist/domain/ir/property-name.mjs +16 -0
- package/dist/domain/ir/property-name.mjs.map +1 -0
- package/dist/domain/ir/raw-text-escapes.cjs +25 -0
- package/dist/domain/ir/raw-text-escapes.cjs.map +1 -0
- package/dist/domain/ir/raw-text-escapes.mjs +22 -0
- package/dist/domain/ir/raw-text-escapes.mjs.map +1 -0
- package/dist/domain/openapi/alias-expansion.cjs +50 -0
- package/dist/domain/openapi/alias-expansion.cjs.map +1 -0
- package/dist/domain/openapi/alias-expansion.mjs +45 -0
- package/dist/domain/openapi/alias-expansion.mjs.map +1 -0
- package/dist/domain/openapi/binary-content.cjs +48 -0
- package/dist/domain/openapi/binary-content.cjs.map +1 -0
- package/dist/domain/openapi/binary-content.mjs +45 -0
- package/dist/domain/openapi/binary-content.mjs.map +1 -0
- package/dist/domain/openapi/components-object.cjs +29 -0
- package/dist/domain/openapi/components-object.cjs.map +1 -0
- package/dist/domain/openapi/components-object.mjs +24 -0
- package/dist/domain/openapi/components-object.mjs.map +1 -0
- package/dist/domain/openapi/json-pointer.cjs +31 -0
- package/dist/domain/openapi/json-pointer.cjs.map +1 -0
- package/dist/domain/openapi/json-pointer.mjs +27 -0
- package/dist/domain/openapi/json-pointer.mjs.map +1 -0
- package/dist/domain/openapi/media-type-object.cjs +14 -0
- package/dist/domain/openapi/media-type-object.cjs.map +1 -0
- package/dist/domain/openapi/media-type-object.mjs +11 -0
- package/dist/domain/openapi/media-type-object.mjs.map +1 -0
- package/dist/domain/openapi/parameter-object.cjs +13 -0
- package/dist/domain/openapi/parameter-object.cjs.map +1 -0
- package/dist/domain/openapi/parameter-object.mjs +10 -0
- package/dist/domain/openapi/parameter-object.mjs.map +1 -0
- package/dist/domain/openapi/path-item-object.cjs +35 -0
- package/dist/domain/openapi/path-item-object.cjs.map +1 -0
- package/dist/domain/openapi/path-item-object.mjs +30 -0
- package/dist/domain/openapi/path-item-object.mjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.cjs +87 -0
- package/dist/domain/openapi/unsupported-features.cjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.mjs +84 -0
- package/dist/domain/openapi/unsupported-features.mjs.map +1 -0
- package/dist/domain/output-fixes.cjs +66 -0
- package/dist/domain/output-fixes.cjs.map +1 -0
- package/dist/domain/output-fixes.mjs +59 -0
- package/dist/domain/output-fixes.mjs.map +1 -0
- package/dist/index.cjs +98 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +812 -0
- package/dist/index.d.mts +812 -0
- package/dist/index.d.ts +812 -0
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/dist/transform/components-object.cjs +14 -0
- package/dist/transform/components-object.cjs.map +1 -0
- package/dist/transform/components-object.mjs +10 -0
- package/dist/transform/components-object.mjs.map +1 -0
- package/dist/transform/header-object.cjs +12 -0
- package/dist/transform/header-object.cjs.map +1 -0
- package/dist/transform/header-object.mjs +10 -0
- package/dist/transform/header-object.mjs.map +1 -0
- package/dist/transform/media-type-object.cjs +12 -0
- package/dist/transform/media-type-object.cjs.map +1 -0
- package/dist/transform/media-type-object.mjs +10 -0
- package/dist/transform/media-type-object.mjs.map +1 -0
- package/dist/transform/operation-object.cjs +26 -0
- package/dist/transform/operation-object.cjs.map +1 -0
- package/dist/transform/operation-object.mjs +21 -0
- package/dist/transform/operation-object.mjs.map +1 -0
- package/dist/transform/parameter-object.cjs +12 -0
- package/dist/transform/parameter-object.cjs.map +1 -0
- package/dist/transform/parameter-object.mjs +10 -0
- package/dist/transform/parameter-object.mjs.map +1 -0
- package/dist/transform/path-item-object.cjs +12 -0
- package/dist/transform/path-item-object.cjs.map +1 -0
- package/dist/transform/path-item-object.mjs +10 -0
- package/dist/transform/path-item-object.mjs.map +1 -0
- package/dist/transform/paths-object.cjs +11 -0
- package/dist/transform/paths-object.cjs.map +1 -0
- package/dist/transform/paths-object.mjs +9 -0
- package/dist/transform/paths-object.mjs.map +1 -0
- package/dist/transform/request-body-object.cjs +12 -0
- package/dist/transform/request-body-object.cjs.map +1 -0
- package/dist/transform/request-body-object.mjs +10 -0
- package/dist/transform/request-body-object.mjs.map +1 -0
- package/dist/transform/response-object.cjs +12 -0
- package/dist/transform/response-object.cjs.map +1 -0
- package/dist/transform/response-object.mjs +10 -0
- package/dist/transform/response-object.mjs.map +1 -0
- package/dist/transform/responses-object.cjs +12 -0
- package/dist/transform/responses-object.cjs.map +1 -0
- package/dist/transform/responses-object.mjs +10 -0
- package/dist/transform/responses-object.mjs.map +1 -0
- package/dist/transform/schema-object.cjs +21 -0
- package/dist/transform/schema-object.cjs.map +1 -0
- package/dist/transform/schema-object.mjs +16 -0
- package/dist/transform/schema-object.mjs.map +1 -0
- package/package.json +115 -4
- package/src/adapters/node-file-system/node-file-system.ts +44 -0
- package/src/adapters/redocly-loader/alias-limit.ts +20 -0
- package/src/adapters/redocly-loader/allowed-hosts.ts +62 -0
- package/src/adapters/redocly-loader/bundled-ref-repair.ts +65 -0
- package/src/adapters/redocly-loader/malformed-refs.ts +61 -0
- package/src/adapters/redocly-loader/redocly-config-source.ts +43 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +246 -0
- package/src/adapters/redocly-loader/ref-access.ts +146 -0
- package/src/adapters/redocly-loader/ref-holders.ts +43 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +104 -0
- package/src/adapters/redocly-loader/schema-load-errors.ts +124 -0
- package/src/adapters/redocly-loader/schema-source.ts +151 -0
- package/src/adapters/redocly-loader/unsupported-keys.ts +102 -0
- package/src/adapters/terminal-logger/terminal-logger.ts +98 -0
- package/src/adapters/type-ast-bridge/footer-nodes.ts +38 -0
- package/src/adapters/type-ast-bridge/ir-declarations-to-typescript.ts +100 -0
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +220 -0
- package/src/adapters/type-ast-bridge/lazy-node.ts +24 -0
- package/src/adapters/type-ast-bridge/load-typescript.ts +84 -0
- package/src/adapters/type-ast-bridge/print-typescript.ts +33 -0
- package/src/adapters/type-ast-bridge/typescript-raw-text.ts +49 -0
- package/src/adapters/type-ast-bridge/typescript-to-ir.ts +280 -0
- package/src/adapters/type-ast-bridge/typescript-types.ts +8 -0
- package/src/api/ast-to-string.ts +59 -0
- package/src/api/comment-header.ts +7 -0
- package/src/api/default-ports.ts +44 -0
- package/src/api/discriminator-enum.ts +76 -0
- package/src/api/discriminator-scan.ts +272 -0
- package/src/api/document-declarations.ts +41 -0
- package/src/api/document-refs.ts +71 -0
- package/src/api/document-run.ts +159 -0
- package/src/api/footer-entry.ts +23 -0
- package/src/api/footer-sink.ts +67 -0
- package/src/api/legacy-callback-warning.ts +29 -0
- package/src/api/legacy-ts-helpers.ts +311 -0
- package/src/api/legacy-utils.ts +118 -0
- package/src/api/openapi-ts.ts +62 -0
- package/src/api/schema-callbacks.ts +211 -0
- package/src/api/string-to-ast.ts +27 -0
- package/src/api/transform-context.ts +87 -0
- package/src/api/transform-schema.ts +39 -0
- package/src/api/type-helpers.ts +130 -0
- package/src/api/unsupported-feature-warnings.ts +26 -0
- package/src/application/ports/file-system.ts +12 -0
- package/src/application/ports/logger.ts +16 -0
- package/src/application/ports/redocly-config-source.ts +16 -0
- package/src/application/ports/schema-loader.ts +32 -0
- package/src/application/print/comment-writer.ts +91 -0
- package/src/application/print/declaration-printer.ts +100 -0
- package/src/application/print/literal-text.ts +62 -0
- package/src/application/print/print-nodes.ts +62 -0
- package/src/application/print/print-options.ts +11 -0
- package/src/application/print/text-writer.ts +83 -0
- package/src/application/print/type-printer.ts +281 -0
- package/src/application/stack-overflow.ts +54 -0
- package/src/application/transform/document/components.ts +189 -0
- package/src/application/transform/document/defs-root.ts +25 -0
- package/src/application/transform/document/document-member.ts +20 -0
- package/src/application/transform/document/document.ts +157 -0
- package/src/application/transform/document/header.ts +34 -0
- package/src/application/transform/document/kept-deprecated.ts +135 -0
- package/src/application/transform/document/media-type.ts +78 -0
- package/src/application/transform/document/operation.ts +64 -0
- package/src/application/transform/document/parameter.ts +45 -0
- package/src/application/transform/document/parameters.ts +200 -0
- package/src/application/transform/document/path-item-conflicts.ts +79 -0
- package/src/application/transform/document/path-item.ts +168 -0
- package/src/application/transform/document/path-key-overlaps.ts +112 -0
- package/src/application/transform/document/paths-enum.ts +127 -0
- package/src/application/transform/document/paths.ts +211 -0
- package/src/application/transform/document/request-body.ts +50 -0
- package/src/application/transform/document/response.ts +109 -0
- package/src/application/transform/document/responses.ts +29 -0
- package/src/application/transform/document/root-type-aliases.ts +106 -0
- package/src/application/transform/document/webhooks.ts +22 -0
- package/src/application/transform/document-entries.ts +28 -0
- package/src/application/transform/footer/document-footer.ts +127 -0
- package/src/application/transform/footer/enum-naming.ts +181 -0
- package/src/application/transform/helper-types.ts +92 -0
- package/src/application/transform/literal-type.ts +54 -0
- package/src/application/transform/numbered-names.ts +20 -0
- package/src/application/transform/ref-type.ts +97 -0
- package/src/application/transform/schema/array-type.ts +152 -0
- package/src/application/transform/schema/composition-type.ts +183 -0
- package/src/application/transform/schema/core-type.ts +115 -0
- package/src/application/transform/schema/discriminator-property.ts +28 -0
- package/src/application/transform/schema/enum-rule.ts +157 -0
- package/src/application/transform/schema/object-type.ts +271 -0
- package/src/application/transform/schema/presence-members.ts +96 -0
- package/src/application/transform/schema/schema-context.ts +110 -0
- package/src/application/transform/schema/schema-rule.ts +29 -0
- package/src/application/transform/schema/schema-transform.ts +99 -0
- package/src/application/transform/schema/unevaluated-properties.ts +105 -0
- package/src/application/transform/schema-comment.ts +116 -0
- package/src/application/transform/shared-types.ts +9 -0
- package/src/application/transform/transform-context.ts +51 -0
- package/src/application/transform/type-combinators.ts +57 -0
- package/src/cli/cli-arguments.ts +198 -0
- package/src/cli/cli-dependencies.ts +42 -0
- package/src/cli/cli-errors.ts +125 -0
- package/src/cli/cli-output.ts +53 -0
- package/src/cli/docs-links.ts +6 -0
- package/src/cli/fix-option.ts +29 -0
- package/src/cli/help-text.ts +52 -0
- package/src/cli/main.ts +67 -0
- package/src/cli/redocly-apis.ts +91 -0
- package/src/cli/ref-limits.ts +16 -0
- package/src/cli/run-cli.ts +114 -0
- package/src/domain/assert-never.ts +8 -0
- package/src/domain/errors.ts +74 -0
- package/src/domain/ir/constructors.ts +137 -0
- package/src/domain/ir/identifier-text.ts +49 -0
- package/src/domain/ir/newer-identifier-ranges.ts +109 -0
- package/src/domain/ir/nodes.ts +224 -0
- package/src/domain/ir/normalize.ts +51 -0
- package/src/domain/ir/property-name.ts +28 -0
- package/src/domain/ir/raw-text-escapes.ts +37 -0
- package/src/domain/openapi/alias-expansion.ts +72 -0
- package/src/domain/openapi/binary-content.ts +74 -0
- package/src/domain/openapi/components-object.ts +52 -0
- package/src/domain/openapi/document-object.ts +12 -0
- package/src/domain/openapi/header-object.ts +9 -0
- package/src/domain/openapi/json-pointer.ts +46 -0
- package/src/domain/openapi/media-type-object.ts +26 -0
- package/src/domain/openapi/operation-object.ts +13 -0
- package/src/domain/openapi/parameter-object.ts +30 -0
- package/src/domain/openapi/path-item-object.ts +70 -0
- package/src/domain/openapi/request-body-object.ts +7 -0
- package/src/domain/openapi/response-object.ts +14 -0
- package/src/domain/openapi/schema-object.ts +59 -0
- package/src/domain/openapi/unsupported-features.ts +139 -0
- package/src/domain/output-fixes.ts +95 -0
- package/src/index.ts +67 -0
- package/src/transform/components-object.ts +25 -0
- package/src/transform/header-object.ts +19 -0
- package/src/transform/media-type-object.ts +19 -0
- package/src/transform/operation-object.ts +36 -0
- package/src/transform/parameter-object.ts +19 -0
- package/src/transform/parameters-array.ts +19 -0
- package/src/transform/path-item-object.ts +22 -0
- package/src/transform/paths-enum.ts +8 -0
- package/src/transform/paths-object.ts +15 -0
- package/src/transform/request-body-object.ts +19 -0
- package/src/transform/response-object.ts +19 -0
- package/src/transform/responses-object.ts +19 -0
- package/src/transform/schema-object.ts +36 -0
- package/src/transform/webhooks-object.ts +15 -0
- package/src/types/generator-options.ts +267 -0
- package/src/types/openapi-common.ts +100 -0
- package/src/types/openapi-document.ts +196 -0
- package/src/types/openapi-path-item.ts +130 -0
- package/src/types/openapi-request.ts +209 -0
- package/src/types/openapi-response.ts +81 -0
- package/src/types/openapi-schema.ts +169 -0
- package/src/types/openapi-security.ts +116 -0
- package/src/types.ts +12 -0
|
@@ -0,0 +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 { SchemaLocation } 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 },\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":";;;;;;AAoBA,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,IAC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AW,CAAC,GAAA,KAAQ,IAAI,cAAA,CAAe,WAAA,CAAY,SAAS,GAAG;AAAA,KACjE;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;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const document = require('../application/transform/document/document.cjs');
|
|
6
|
+
const rootTypeAliases = require('../application/transform/document/root-type-aliases.cjs');
|
|
7
|
+
const documentDeclarations = require('./document-declarations.cjs');
|
|
8
|
+
const footerEntry = require('./footer-entry.cjs');
|
|
9
|
+
const transformContext = require('./transform-context.cjs');
|
|
10
|
+
|
|
11
|
+
const OPERATIONS_NAME = "operations";
|
|
12
|
+
function isOperations(entry) {
|
|
13
|
+
const name = footerEntry.isIrDeclaration(entry) ? entry.name : entry.name?.escapedText;
|
|
14
|
+
return name === OPERATIONS_NAME;
|
|
15
|
+
}
|
|
16
|
+
function transformDocument(schema, ctx) {
|
|
17
|
+
const document$1 = schema;
|
|
18
|
+
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));
|
|
22
|
+
const closing = document.documentClosing(document$1, context, footer.some(isOperations));
|
|
23
|
+
return { body, footer, closing };
|
|
24
|
+
}
|
|
25
|
+
function transformSchema(schema, ctx) {
|
|
26
|
+
return documentDeclarations.documentDeclarations(transformDocument(schema, ctx));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.default = transformSchema;
|
|
30
|
+
exports.transformDocument = transformDocument;
|
|
31
|
+
//# sourceMappingURL=transform-schema.cjs.map
|
|
@@ -0,0 +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 { renameAliasesTakenByFooter } from \"../application/transform/document/root-type-aliases.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.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/** @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 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);\n const footer: FooterEntry[] = [...ctx.injectFooter];\n const body = renameAliasesTakenByFooter(rawBody, footer.filter(isIrDeclaration));\n const closing = documentClosing(document, context, footer.some(isOperations));\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","createTransformContext","documentBody","renameAliasesTakenByFooter","documentClosing","documentDeclarations"],"mappings":";;;;;;;;;;AAUA,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;AAGO,SAAS,iBAAA,CAAkB,QAAkB,GAAA,EAAyC;AAC3F,EAAA,MAAMC,UAAA,GAAW,MAAA;AACjB,EAAA,MAAM,OAAA,GAAUC,wCAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAUC,qBAAA,CAAaF,UAAA,EAAU,OAAO,CAAA;AAC9C,EAAA,MAAM,MAAA,GAAwB,CAAC,GAAG,GAAA,CAAI,YAAY,CAAA;AAClD,EAAA,MAAM,OAAOG,0CAAA,CAA2B,OAAA,EAAS,MAAA,CAAO,MAAA,CAAOJ,2BAAe,CAAC,CAAA;AAC/E,EAAA,MAAM,UAAUK,wBAAA,CAAgBJ,UAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAOK,yCAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { documentBody, documentClosing } from '../application/transform/document/document.mjs';
|
|
2
|
+
import { renameAliasesTakenByFooter } from '../application/transform/document/root-type-aliases.mjs';
|
|
3
|
+
import { documentDeclarations } from './document-declarations.mjs';
|
|
4
|
+
import { isIrDeclaration } from './footer-entry.mjs';
|
|
5
|
+
import { createTransformContext } from './transform-context.mjs';
|
|
6
|
+
|
|
7
|
+
const OPERATIONS_NAME = "operations";
|
|
8
|
+
function isOperations(entry) {
|
|
9
|
+
const name = isIrDeclaration(entry) ? entry.name : entry.name?.escapedText;
|
|
10
|
+
return name === OPERATIONS_NAME;
|
|
11
|
+
}
|
|
12
|
+
function transformDocument(schema, ctx) {
|
|
13
|
+
const document = schema;
|
|
14
|
+
const context = createTransformContext(ctx);
|
|
15
|
+
const rawBody = documentBody(document, context);
|
|
16
|
+
const footer = [...ctx.injectFooter];
|
|
17
|
+
const body = renameAliasesTakenByFooter(rawBody, footer.filter(isIrDeclaration));
|
|
18
|
+
const closing = documentClosing(document, context, footer.some(isOperations));
|
|
19
|
+
return { body, footer, closing };
|
|
20
|
+
}
|
|
21
|
+
function transformSchema(schema, ctx) {
|
|
22
|
+
return documentDeclarations(transformDocument(schema, ctx));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { transformSchema as default, transformDocument };
|
|
26
|
+
//# sourceMappingURL=transform-schema.mjs.map
|
|
@@ -0,0 +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 { renameAliasesTakenByFooter } from \"../application/transform/document/root-type-aliases.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.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/** @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 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);\n const footer: FooterEntry[] = [...ctx.injectFooter];\n const body = renameAliasesTakenByFooter(rawBody, footer.filter(isIrDeclaration));\n const closing = documentClosing(document, context, footer.some(isOperations));\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":";;;;;;AAUA,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;AAGO,SAAS,iBAAA,CAAkB,QAAkB,GAAA,EAAyC;AAC3F,EAAA,MAAM,QAAA,GAAW,MAAA;AACjB,EAAA,MAAM,OAAA,GAAU,uBAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAC9C,EAAA,MAAM,MAAA,GAAwB,CAAC,GAAG,GAAA,CAAI,YAAY,CAAA;AAClD,EAAA,MAAM,OAAO,0BAAA,CAA2B,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,eAAe,CAAC,CAAA;AAC/E,EAAA,MAAM,UAAU,eAAA,CAAgB,QAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const loadTypescript = require('../adapters/type-ast-bridge/load-typescript.cjs');
|
|
4
|
+
const typescriptToIr = require('../adapters/type-ast-bridge/typescript-to-ir.cjs');
|
|
5
|
+
const helperTypes = require('../application/transform/helper-types.cjs');
|
|
6
|
+
const literalType = require('../application/transform/literal-type.cjs');
|
|
7
|
+
const refType = require('../application/transform/ref-type.cjs');
|
|
8
|
+
const sharedTypes = require('../application/transform/shared-types.cjs');
|
|
9
|
+
const typeCombinators = require('../application/transform/type-combinators.cjs');
|
|
10
|
+
const constructors = require('../domain/ir/constructors.cjs');
|
|
11
|
+
const footerEntry = require('./footer-entry.cjs');
|
|
12
|
+
|
|
13
|
+
const BOOLEAN = Object.freeze(constructors.irKeyword("boolean"));
|
|
14
|
+
const FALSE = Object.freeze(constructors.irBoolean(false));
|
|
15
|
+
const NEVER = Object.freeze(constructors.irKeyword("never"));
|
|
16
|
+
const NULL = Object.freeze(constructors.irKeyword("null"));
|
|
17
|
+
const NUMBER = Object.freeze(constructors.irKeyword("number"));
|
|
18
|
+
const STRING = Object.freeze(constructors.irKeyword("string"));
|
|
19
|
+
const TRUE = Object.freeze(constructors.irBoolean(true));
|
|
20
|
+
const UNDEFINED = Object.freeze(constructors.irKeyword("undefined"));
|
|
21
|
+
const UNKNOWN = sharedTypes.UNKNOWN_TYPE;
|
|
22
|
+
function isIrType(type) {
|
|
23
|
+
return typeof type.kind === "string";
|
|
24
|
+
}
|
|
25
|
+
function toIrType(type) {
|
|
26
|
+
return isIrType(type) ? type : typescriptToIr.fromTypeNode(loadTypescript.loadTypeScript(), type);
|
|
27
|
+
}
|
|
28
|
+
function tsUnion(types) {
|
|
29
|
+
return typeCombinators.unionOf(types.map(toIrType));
|
|
30
|
+
}
|
|
31
|
+
function tsIntersection(types) {
|
|
32
|
+
return typeCombinators.intersectionOf(types.map(toIrType));
|
|
33
|
+
}
|
|
34
|
+
function tsNullable(types) {
|
|
35
|
+
return typeCombinators.nullableOf(types.map(toIrType));
|
|
36
|
+
}
|
|
37
|
+
function tsOmit(type, keys) {
|
|
38
|
+
return typeCombinators.omitKeys(toIrType(type), keys);
|
|
39
|
+
}
|
|
40
|
+
function tsRecord(key, value) {
|
|
41
|
+
return constructors.irRecord(toIrType(key), toIrType(value));
|
|
42
|
+
}
|
|
43
|
+
function tsLiteral(value) {
|
|
44
|
+
return literalType.literalType(value);
|
|
45
|
+
}
|
|
46
|
+
function tsWithRequired(type, keys, injectFooter) {
|
|
47
|
+
if (keys.length === 0) {
|
|
48
|
+
return toIrType(type);
|
|
49
|
+
}
|
|
50
|
+
const { name, text } = helperTypes.HELPER_TYPES.withRequired;
|
|
51
|
+
if (!injectFooter.some((entry) => footerEntry.declaresTypeAlias(entry, name))) {
|
|
52
|
+
injectFooter.push({ kind: "rawDeclaration", name, text });
|
|
53
|
+
}
|
|
54
|
+
return typeCombinators.withRequiredKeys(toIrType(type), keys);
|
|
55
|
+
}
|
|
56
|
+
function isParameterObject(value) {
|
|
57
|
+
return Boolean(value && !("$ref" in value && value.$ref) && value.in);
|
|
58
|
+
}
|
|
59
|
+
function oapiRef(path, resolved, options = {}) {
|
|
60
|
+
return refType.refType(path, {
|
|
61
|
+
isDeep: options.deep ?? false,
|
|
62
|
+
extractProperties: options.extractProperties ?? [],
|
|
63
|
+
parameter: isParameterObject(resolved) ? { in: resolved.in, name: resolved.name } : null
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
exports.BOOLEAN = BOOLEAN;
|
|
68
|
+
exports.FALSE = FALSE;
|
|
69
|
+
exports.NEVER = NEVER;
|
|
70
|
+
exports.NULL = NULL;
|
|
71
|
+
exports.NUMBER = NUMBER;
|
|
72
|
+
exports.STRING = STRING;
|
|
73
|
+
exports.TRUE = TRUE;
|
|
74
|
+
exports.UNDEFINED = UNDEFINED;
|
|
75
|
+
exports.UNKNOWN = UNKNOWN;
|
|
76
|
+
exports.oapiRef = oapiRef;
|
|
77
|
+
exports.toIrType = toIrType;
|
|
78
|
+
exports.tsIntersection = tsIntersection;
|
|
79
|
+
exports.tsLiteral = tsLiteral;
|
|
80
|
+
exports.tsNullable = tsNullable;
|
|
81
|
+
exports.tsOmit = tsOmit;
|
|
82
|
+
exports.tsRecord = tsRecord;
|
|
83
|
+
exports.tsUnion = tsUnion;
|
|
84
|
+
exports.tsWithRequired = tsWithRequired;
|
|
85
|
+
//# sourceMappingURL=type-helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-helpers.cjs","sources":["../../src/api/type-helpers.ts"],"sourcesContent":["import { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { fromTypeNode } from \"../adapters/type-ast-bridge/typescript-to-ir.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { literalType } from \"../application/transform/literal-type.js\";\nimport { refType } from \"../application/transform/ref-type.js\";\nimport { UNKNOWN_TYPE } from \"../application/transform/shared-types.js\";\nimport {\n intersectionOf,\n nullableOf,\n omitKeys,\n unionOf,\n withRequiredKeys,\n} from \"../application/transform/type-combinators.js\";\nimport { irBoolean, irKeyword, irRecord } from \"../domain/ir/constructors.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport type { ParameterObject, ReferenceObject } from \"../types.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\n\n/**\n * The public type helpers (ENGINEERING_PLAN 6.2, ADR-004 decision 2). Same names and call\n * signatures as the original helpers; they return IR types. A `ts.TypeNode` argument (from user\n * code built with `ts.factory`) is read into IR by the bridge.\n */\n\n/** A helper argument: an IR type, or a TypeScript type node from user code. */\nexport type TypeInput = IrType | ts.TypeNode;\n\nexport const BOOLEAN: IrType = Object.freeze(irKeyword(\"boolean\"));\nexport const FALSE: IrType = Object.freeze(irBoolean(false));\nexport const NEVER: IrType = Object.freeze(irKeyword(\"never\"));\nexport const NULL: IrType = Object.freeze(irKeyword(\"null\"));\nexport const NUMBER: IrType = Object.freeze(irKeyword(\"number\"));\nexport const STRING: IrType = Object.freeze(irKeyword(\"string\"));\nexport const TRUE: IrType = Object.freeze(irBoolean(true));\nexport const UNDEFINED: IrType = Object.freeze(irKeyword(\"undefined\"));\n/** The shared `unknown` type; the transformers compare with it by identity, as the original did. */\nexport const UNKNOWN: IrType = UNKNOWN_TYPE;\n\n/** IR nodes have a string `kind`; TypeScript nodes have a numeric `SyntaxKind`. */\nfunction isIrType(type: TypeInput): type is IrType {\n return typeof type.kind === \"string\";\n}\n\n/** @internal Read a helper argument into IR. */\nexport function toIrType(type: TypeInput): IrType {\n return isIrType(type) ? type : fromTypeNode(loadTypeScript(), type);\n}\n\n/** `A | B`: `never` for no types, the type itself for one; repeated primitives are removed. */\nexport function tsUnion(types: readonly TypeInput[]): IrType {\n return unionOf(types.map(toIrType));\n}\n\n/** `A & B`, with the same rules as `tsUnion`. */\nexport function tsIntersection(types: readonly TypeInput[]): IrType {\n return intersectionOf(types.map(toIrType));\n}\n\n/** `A | null`, without removing repeated types. */\nexport function tsNullable(types: readonly TypeInput[]): IrType {\n return nullableOf(types.map(toIrType));\n}\n\n/** `Omit<T, \"a\" | \"b\">`. */\nexport function tsOmit(type: TypeInput, keys: readonly string[]): IrType {\n return omitKeys(toIrType(type), keys);\n}\n\n/** `Record<K, V>`. */\nexport function tsRecord(key: TypeInput, value: TypeInput): IrType {\n return irRecord(toIrType(key), toIrType(value));\n}\n\n/**\n * The literal type of a JSON value: strings, numbers, booleans and `null` as literals, arrays as\n * tuples (an empty one as `never[]`), objects as object types; anything else is `unknown`.\n */\nexport function tsLiteral(value: unknown): IrType {\n return literalType(value);\n}\n\n/**\n * `WithRequired<T, \"a\" | \"b\">`, or the type itself for no keys. Adds the `WithRequired` helper\n * type to the footer once.\n */\nexport function tsWithRequired(\n type: TypeInput,\n keys: readonly string[],\n injectFooter: FooterEntry[],\n): IrType {\n if (keys.length === 0) {\n return toIrType(type);\n }\n const { name, text } = HELPER_TYPES.withRequired;\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name, text });\n }\n return withRequiredKeys(toIrType(type), keys);\n}\n\nexport interface OapiRefOptions {\n /** Whether to wrap with FlattenedDeepRequired<> (default: false) */\n deep?: boolean;\n /** Array of property names to wrap with Extract<> when accessing */\n extractProperties?: string[];\n}\n\nfunction isParameterObject(\n value: ParameterObject | ReferenceObject | undefined,\n): value is ParameterObject {\n return Boolean(value && !(\"$ref\" in value && value.$ref) && (value as ParameterObject).in);\n}\n\n/**\n * The generated type a JSON Pointer refers to, as an indexed access: `#/components/schemas/Foo`\n * → `components[\"schemas\"][\"Foo\"]`. Object `properties` are skipped, and a referenced parameter\n * is indexed by its location (`resolved`).\n */\nexport function oapiRef(\n path: string,\n resolved?: ParameterObject | ReferenceObject,\n options: OapiRefOptions = {},\n): IrType {\n return refType(path, {\n isDeep: options.deep ?? false,\n extractProperties: options.extractProperties ?? [],\n parameter: isParameterObject(resolved) ? { in: resolved.in, name: resolved.name } : null,\n });\n}\n"],"names":["irKeyword","irBoolean","UNKNOWN_TYPE","fromTypeNode","loadTypeScript","unionOf","intersectionOf","nullableOf","omitKeys","irRecord","literalType","HELPER_TYPES","declaresTypeAlias","withRequiredKeys","refType"],"mappings":";;;;;;;;;;;;AA4BO,MAAM,OAAA,GAAkB,MAAA,CAAO,MAAA,CAAOA,sBAAA,CAAU,SAAS,CAAC;AAC1D,MAAM,KAA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I;AAAA,GACrF,CAAA;AACH;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { loadTypeScript } from '../adapters/type-ast-bridge/load-typescript.mjs';
|
|
2
|
+
import { fromTypeNode } from '../adapters/type-ast-bridge/typescript-to-ir.mjs';
|
|
3
|
+
import { HELPER_TYPES } from '../application/transform/helper-types.mjs';
|
|
4
|
+
import { literalType } from '../application/transform/literal-type.mjs';
|
|
5
|
+
import { refType } from '../application/transform/ref-type.mjs';
|
|
6
|
+
import { UNKNOWN_TYPE } from '../application/transform/shared-types.mjs';
|
|
7
|
+
import { intersectionOf, nullableOf, omitKeys, unionOf, withRequiredKeys } from '../application/transform/type-combinators.mjs';
|
|
8
|
+
import { irKeyword, irBoolean, irRecord } from '../domain/ir/constructors.mjs';
|
|
9
|
+
import { declaresTypeAlias } from './footer-entry.mjs';
|
|
10
|
+
|
|
11
|
+
const BOOLEAN = Object.freeze(irKeyword("boolean"));
|
|
12
|
+
const FALSE = Object.freeze(irBoolean(false));
|
|
13
|
+
const NEVER = Object.freeze(irKeyword("never"));
|
|
14
|
+
const NULL = Object.freeze(irKeyword("null"));
|
|
15
|
+
const NUMBER = Object.freeze(irKeyword("number"));
|
|
16
|
+
const STRING = Object.freeze(irKeyword("string"));
|
|
17
|
+
const TRUE = Object.freeze(irBoolean(true));
|
|
18
|
+
const UNDEFINED = Object.freeze(irKeyword("undefined"));
|
|
19
|
+
const UNKNOWN = UNKNOWN_TYPE;
|
|
20
|
+
function isIrType(type) {
|
|
21
|
+
return typeof type.kind === "string";
|
|
22
|
+
}
|
|
23
|
+
function toIrType(type) {
|
|
24
|
+
return isIrType(type) ? type : fromTypeNode(loadTypeScript(), type);
|
|
25
|
+
}
|
|
26
|
+
function tsUnion(types) {
|
|
27
|
+
return unionOf(types.map(toIrType));
|
|
28
|
+
}
|
|
29
|
+
function tsIntersection(types) {
|
|
30
|
+
return intersectionOf(types.map(toIrType));
|
|
31
|
+
}
|
|
32
|
+
function tsNullable(types) {
|
|
33
|
+
return nullableOf(types.map(toIrType));
|
|
34
|
+
}
|
|
35
|
+
function tsOmit(type, keys) {
|
|
36
|
+
return omitKeys(toIrType(type), keys);
|
|
37
|
+
}
|
|
38
|
+
function tsRecord(key, value) {
|
|
39
|
+
return irRecord(toIrType(key), toIrType(value));
|
|
40
|
+
}
|
|
41
|
+
function tsLiteral(value) {
|
|
42
|
+
return literalType(value);
|
|
43
|
+
}
|
|
44
|
+
function tsWithRequired(type, keys, injectFooter) {
|
|
45
|
+
if (keys.length === 0) {
|
|
46
|
+
return toIrType(type);
|
|
47
|
+
}
|
|
48
|
+
const { name, text } = HELPER_TYPES.withRequired;
|
|
49
|
+
if (!injectFooter.some((entry) => declaresTypeAlias(entry, name))) {
|
|
50
|
+
injectFooter.push({ kind: "rawDeclaration", name, text });
|
|
51
|
+
}
|
|
52
|
+
return withRequiredKeys(toIrType(type), keys);
|
|
53
|
+
}
|
|
54
|
+
function isParameterObject(value) {
|
|
55
|
+
return Boolean(value && !("$ref" in value && value.$ref) && value.in);
|
|
56
|
+
}
|
|
57
|
+
function oapiRef(path, resolved, options = {}) {
|
|
58
|
+
return refType(path, {
|
|
59
|
+
isDeep: options.deep ?? false,
|
|
60
|
+
extractProperties: options.extractProperties ?? [],
|
|
61
|
+
parameter: isParameterObject(resolved) ? { in: resolved.in, name: resolved.name } : null
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { BOOLEAN, FALSE, NEVER, NULL, NUMBER, STRING, TRUE, UNDEFINED, UNKNOWN, oapiRef, toIrType, tsIntersection, tsLiteral, tsNullable, tsOmit, tsRecord, tsUnion, tsWithRequired };
|
|
66
|
+
//# sourceMappingURL=type-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-helpers.mjs","sources":["../../src/api/type-helpers.ts"],"sourcesContent":["import { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { fromTypeNode } from \"../adapters/type-ast-bridge/typescript-to-ir.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { literalType } from \"../application/transform/literal-type.js\";\nimport { refType } from \"../application/transform/ref-type.js\";\nimport { UNKNOWN_TYPE } from \"../application/transform/shared-types.js\";\nimport {\n intersectionOf,\n nullableOf,\n omitKeys,\n unionOf,\n withRequiredKeys,\n} from \"../application/transform/type-combinators.js\";\nimport { irBoolean, irKeyword, irRecord } from \"../domain/ir/constructors.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport type { ParameterObject, ReferenceObject } from \"../types.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\n\n/**\n * The public type helpers (ENGINEERING_PLAN 6.2, ADR-004 decision 2). Same names and call\n * signatures as the original helpers; they return IR types. A `ts.TypeNode` argument (from user\n * code built with `ts.factory`) is read into IR by the bridge.\n */\n\n/** A helper argument: an IR type, or a TypeScript type node from user code. */\nexport type TypeInput = IrType | ts.TypeNode;\n\nexport const BOOLEAN: IrType = Object.freeze(irKeyword(\"boolean\"));\nexport const FALSE: IrType = Object.freeze(irBoolean(false));\nexport const NEVER: IrType = Object.freeze(irKeyword(\"never\"));\nexport const NULL: IrType = Object.freeze(irKeyword(\"null\"));\nexport const NUMBER: IrType = Object.freeze(irKeyword(\"number\"));\nexport const STRING: IrType = Object.freeze(irKeyword(\"string\"));\nexport const TRUE: IrType = Object.freeze(irBoolean(true));\nexport const UNDEFINED: IrType = Object.freeze(irKeyword(\"undefined\"));\n/** The shared `unknown` type; the transformers compare with it by identity, as the original did. */\nexport const UNKNOWN: IrType = UNKNOWN_TYPE;\n\n/** IR nodes have a string `kind`; TypeScript nodes have a numeric `SyntaxKind`. */\nfunction isIrType(type: TypeInput): type is IrType {\n return typeof type.kind === \"string\";\n}\n\n/** @internal Read a helper argument into IR. */\nexport function toIrType(type: TypeInput): IrType {\n return isIrType(type) ? type : fromTypeNode(loadTypeScript(), type);\n}\n\n/** `A | B`: `never` for no types, the type itself for one; repeated primitives are removed. */\nexport function tsUnion(types: readonly TypeInput[]): IrType {\n return unionOf(types.map(toIrType));\n}\n\n/** `A & B`, with the same rules as `tsUnion`. */\nexport function tsIntersection(types: readonly TypeInput[]): IrType {\n return intersectionOf(types.map(toIrType));\n}\n\n/** `A | null`, without removing repeated types. */\nexport function tsNullable(types: readonly TypeInput[]): IrType {\n return nullableOf(types.map(toIrType));\n}\n\n/** `Omit<T, \"a\" | \"b\">`. */\nexport function tsOmit(type: TypeInput, keys: readonly string[]): IrType {\n return omitKeys(toIrType(type), keys);\n}\n\n/** `Record<K, V>`. */\nexport function tsRecord(key: TypeInput, value: TypeInput): IrType {\n return irRecord(toIrType(key), toIrType(value));\n}\n\n/**\n * The literal type of a JSON value: strings, numbers, booleans and `null` as literals, arrays as\n * tuples (an empty one as `never[]`), objects as object types; anything else is `unknown`.\n */\nexport function tsLiteral(value: unknown): IrType {\n return literalType(value);\n}\n\n/**\n * `WithRequired<T, \"a\" | \"b\">`, or the type itself for no keys. Adds the `WithRequired` helper\n * type to the footer once.\n */\nexport function tsWithRequired(\n type: TypeInput,\n keys: readonly string[],\n injectFooter: FooterEntry[],\n): IrType {\n if (keys.length === 0) {\n return toIrType(type);\n }\n const { name, text } = HELPER_TYPES.withRequired;\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name, text });\n }\n return withRequiredKeys(toIrType(type), keys);\n}\n\nexport interface OapiRefOptions {\n /** Whether to wrap with FlattenedDeepRequired<> (default: false) */\n deep?: boolean;\n /** Array of property names to wrap with Extract<> when accessing */\n extractProperties?: string[];\n}\n\nfunction isParameterObject(\n value: ParameterObject | ReferenceObject | undefined,\n): value is ParameterObject {\n return Boolean(value && !(\"$ref\" in value && value.$ref) && (value as ParameterObject).in);\n}\n\n/**\n * The generated type a JSON Pointer refers to, as an indexed access: `#/components/schemas/Foo`\n * → `components[\"schemas\"][\"Foo\"]`. Object `properties` are skipped, and a referenced parameter\n * is indexed by its location (`resolved`).\n */\nexport function oapiRef(\n path: string,\n resolved?: ParameterObject | ReferenceObject,\n options: OapiRefOptions = {},\n): IrType {\n return refType(path, {\n isDeep: options.deep ?? false,\n extractProperties: options.extractProperties ?? [],\n parameter: isParameterObject(resolved) ? { in: resolved.in, name: resolved.name } : null,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BO,MAAM,OAAA,GAAkB,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,SAAS,CAAC;AAC1D,MAAM,KAAA,GAAgB,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,KAAK,CAAC;AACpD,MAAM,KAAA,GAAgB,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,OAAO,CAAC;AACtD,MAAM,IAAA,GAAe,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,MAAM,CAAC;AACpD,MAAM,MAAA,GAAiB,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAC;AACxD,MAAM,MAAA,GAAiB,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAC;AACxD,MAAM,IAAA,GAAe,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,IAAI,CAAC;AAClD,MAAM,SAAA,GAAoB,MAAA,CAAO,MAAA,CAAO,SAAA,CAAU,WAAW,CAAC;AAE9D,MAAM,OAAA,GAAkB;AAG/B,SAAS,SAAS,IAAA,EAAiC;AACjD,EAAA,OAAO,OAAO,KAAK,IAAA,KAAS,QAAA;AAC9B;AAGO,SAAS,SAAS,IAAA,EAAyB;AAChD,EAAA,OAAO,SAAS,IAAI,CAAA,GAAI,OAAO,YAAA,CAAa,cAAA,IAAkB,IAAI,CAAA;AACpE;AAGO,SAAS,QAAQ,KAAA,EAAqC;AAC3D,EAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,GAAA,CAAI,QAAQ,CAAC,CAAA;AACpC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CACd,IAAA,EACA,QAAA,EACA,OAAA,GAA0B,EAAC,EACnB;AACR,EAAA,OAAO,QAAQ,IAAA,EAAM;AAAA,IACnB,MAAA,EAAQ,QAAQ,IAAA,IAAQ,KAAA;AAAA,IACxB,iBAAA,EAAmB,OAAA,CAAQ,iBAAA,IAAqB,EAAC;AAAA,IACjD,SAAA,EAAW,iBAAA,CAAkB,QAAQ,CAAA,GAAI,EAAE,EAAA,EAAI,QAAA,CAAS,EAAA,EAAI,IAAA,EAAM,QAAA,CAAS,IAAA,EAAK,GAAI;AAAA,GACrF,CAAA;AACH;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const unsupportedFeatures = require('../domain/openapi/unsupported-features.cjs');
|
|
4
|
+
|
|
5
|
+
const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
|
|
6
|
+
const SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;
|
|
7
|
+
const REASONS = {
|
|
8
|
+
[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
|
+
function warnUnsupportedFeatures(document, logger) {
|
|
11
|
+
for (const { feature, pointer } of unsupportedFeatures.findUnsupportedFeatures(document)) {
|
|
12
|
+
logger.warn(`${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.warnUnsupportedFeatures = warnUnsupportedFeatures;
|
|
17
|
+
//# sourceMappingURL=unsupported-feature-warnings.cjs.map
|
|
@@ -0,0 +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 logger.warn(`${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`);\n }\n}\n"],"names":["UnsupportedFeature","findUnsupportedFeatures"],"mappings":";;;;AAMA,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;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,MAAA,CAAO,IAAA,CAAK,GAAG,OAAO,CAAA,CAAA,EAAI,QAAQ,OAAO,CAAC,CAAA,MAAA,EAAS,gBAAgB,CAAA,CAAE,CAAA;AAAA,EACvE;AACF;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { findUnsupportedFeatures, UnsupportedFeature } from '../domain/openapi/unsupported-features.mjs';
|
|
2
|
+
|
|
3
|
+
const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
|
|
4
|
+
const SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;
|
|
5
|
+
const REASONS = {
|
|
6
|
+
[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
|
+
function warnUnsupportedFeatures(document, logger) {
|
|
9
|
+
for (const { feature, pointer } of findUnsupportedFeatures(document)) {
|
|
10
|
+
logger.warn(`${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { warnUnsupportedFeatures };
|
|
15
|
+
//# sourceMappingURL=unsupported-feature-warnings.mjs.map
|
|
@@ -0,0 +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 logger.warn(`${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`);\n }\n}\n"],"names":[],"mappings":";;AAMA,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;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,MAAA,CAAO,IAAA,CAAK,GAAG,OAAO,CAAA,CAAA,EAAI,QAAQ,OAAO,CAAC,CAAA,MAAA,EAAS,gBAAgB,CAAA,CAAE,CAAA;AAAA,EACvE;AACF;;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assertNever = require('../../domain/assert-never.cjs');
|
|
4
|
+
const textWriter = require('./text-writer.cjs');
|
|
5
|
+
|
|
6
|
+
const LINE_FEED = 10;
|
|
7
|
+
const CARRIAGE_RETURN = 13;
|
|
8
|
+
const SINGLE_LINE_WHITESPACE = /* @__PURE__ */ new Set([
|
|
9
|
+
32,
|
|
10
|
+
9,
|
|
11
|
+
11,
|
|
12
|
+
12,
|
|
13
|
+
160,
|
|
14
|
+
133,
|
|
15
|
+
5760,
|
|
16
|
+
8192,
|
|
17
|
+
8193,
|
|
18
|
+
8194,
|
|
19
|
+
8195,
|
|
20
|
+
8196,
|
|
21
|
+
8197,
|
|
22
|
+
8198,
|
|
23
|
+
8199,
|
|
24
|
+
8200,
|
|
25
|
+
8201,
|
|
26
|
+
8202,
|
|
27
|
+
8203,
|
|
28
|
+
8239,
|
|
29
|
+
8287,
|
|
30
|
+
12288,
|
|
31
|
+
65279
|
|
32
|
+
]);
|
|
33
|
+
const TAB = 9;
|
|
34
|
+
function computeLineStarts(text) {
|
|
35
|
+
const starts = [0];
|
|
36
|
+
for (let position = 0; position < text.length; position++) {
|
|
37
|
+
const code = text.charCodeAt(position);
|
|
38
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(position + 1) === LINE_FEED) {
|
|
39
|
+
position++;
|
|
40
|
+
}
|
|
41
|
+
if (textWriter.isLineBreak(code)) {
|
|
42
|
+
starts.push(position + 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return starts;
|
|
46
|
+
}
|
|
47
|
+
function measureIndent(text, start, end, tabSize) {
|
|
48
|
+
let width = 0;
|
|
49
|
+
for (let position = start; position < end && SINGLE_LINE_WHITESPACE.has(text.charCodeAt(position)); position++) {
|
|
50
|
+
width += text.charCodeAt(position) === TAB ? tabSize - width % tabSize : 1;
|
|
51
|
+
}
|
|
52
|
+
return width;
|
|
53
|
+
}
|
|
54
|
+
function writeTrimmedLine(writer, text, start, end) {
|
|
55
|
+
const lineEnd = Math.min(text.length, end - 1);
|
|
56
|
+
const line = text.substring(start, lineEnd).trim();
|
|
57
|
+
if (line.length === 0) {
|
|
58
|
+
writer.rawWrite(writer.options.newLine);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
writer.write(line);
|
|
62
|
+
if (lineEnd !== text.length) {
|
|
63
|
+
writer.writeLine();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function writeBlockComment(writer, body) {
|
|
67
|
+
const text = `/*${body}*/`;
|
|
68
|
+
const lineStarts = computeLineStarts(text);
|
|
69
|
+
const { indentSize } = writer.options;
|
|
70
|
+
lineStarts.forEach((start, line) => {
|
|
71
|
+
const end = line + 1 === lineStarts.length ? text.length + 1 : lineStarts[line + 1];
|
|
72
|
+
if (line > 0) {
|
|
73
|
+
const spaces = writer.indent * indentSize + measureIndent(text, start, end, indentSize);
|
|
74
|
+
writer.rawWrite(" ".repeat(spaces));
|
|
75
|
+
}
|
|
76
|
+
writeTrimmedLine(writer, text, start, end);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function writeLeadingComment(writer, comment) {
|
|
80
|
+
switch (comment.kind) {
|
|
81
|
+
case "block":
|
|
82
|
+
writeBlockComment(writer, comment.text);
|
|
83
|
+
break;
|
|
84
|
+
case "line":
|
|
85
|
+
writer.writeLine();
|
|
86
|
+
writer.write(`//${comment.text}`);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
assertNever.assertNever(comment);
|
|
90
|
+
}
|
|
91
|
+
writer.writeLine();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.writeLeadingComment = writeLeadingComment;
|
|
95
|
+
//# sourceMappingURL=comment-writer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment-writer.cjs","sources":["../../../src/application/print/comment-writer.ts"],"sourcesContent":["import { assertNever } from \"../../domain/assert-never.js\";\nimport type { IrComment } from \"../../domain/ir/nodes.js\";\nimport { isLineBreak, type TextWriter } from \"./text-writer.js\";\n\nconst LINE_FEED = 0x0a;\nconst CARRIAGE_RETURN = 0x0d;\n\n/** Single-line white space as the TypeScript scanner defines it (`isWhiteSpaceSingleLine`). */\nconst SINGLE_LINE_WHITESPACE = new Set([\n 0x20, 0x09, 0x0b, 0x0c, 0xa0, 0x85, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005,\n 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x200b, 0x202f, 0x205f, 0x3000, 0xfeff,\n]);\nconst TAB = 0x09;\n\n/** Start offsets of every line, splitting at CR LF, CR, LF, U+2028 and U+2029 like TypeScript. */\nfunction computeLineStarts(text: string): number[] {\n const starts = [0];\n for (let position = 0; position < text.length; position++) {\n const code = text.charCodeAt(position);\n if (code === CARRIAGE_RETURN && text.charCodeAt(position + 1) === LINE_FEED) {\n position++;\n }\n if (isLineBreak(code)) {\n starts.push(position + 1);\n }\n }\n return starts;\n}\n\n/** Leading white space width of `text[start, end)`, counting a tab up to the next tab stop. */\nfunction measureIndent(text: string, start: number, end: number, tabSize: number): number {\n let width = 0;\n for (\n let position = start;\n position < end && SINGLE_LINE_WHITESPACE.has(text.charCodeAt(position));\n position++\n ) {\n width += text.charCodeAt(position) === TAB ? tabSize - (width % tabSize) : 1;\n }\n return width;\n}\n\n/** Write the line `text[start, end)` trimmed; a blank line becomes a bare line break. */\nfunction writeTrimmedLine(writer: TextWriter, text: string, start: number, end: number): void {\n const lineEnd = Math.min(text.length, end - 1);\n const line = text.substring(start, lineEnd).trim();\n if (line.length === 0) {\n writer.rawWrite(writer.options.newLine);\n return;\n }\n writer.write(line);\n if (lineEnd !== text.length) {\n writer.writeLine();\n }\n}\n\n/**\n * Write a `/*...*\\/` comment the way the TypeScript printer writes a synthesized one: every line\n * after the first is re-indented to the current level plus the line's own leading white space, and\n * every line is trimmed. (TypeScript only does this for comments whose second character is `*`,\n * which is always true for a synthesized block comment, so there is no other branch.)\n */\nfunction writeBlockComment(writer: TextWriter, body: string): void {\n const text = `/*${body}*/`;\n const lineStarts = computeLineStarts(text);\n const { indentSize } = writer.options;\n lineStarts.forEach((start, line) => {\n const end = line + 1 === lineStarts.length ? text.length + 1 : (lineStarts[line + 1] as number);\n if (line > 0) {\n const spaces = writer.indent * indentSize + measureIndent(text, start, end, indentSize);\n writer.rawWrite(\" \".repeat(spaces));\n }\n writeTrimmedLine(writer, text, start, end);\n });\n}\n\n/** Write a comment on its own line before the node it belongs to. */\nexport function writeLeadingComment(writer: TextWriter, comment: IrComment): void {\n switch (comment.kind) {\n case \"block\":\n writeBlockComment(writer, comment.text);\n break;\n case \"line\":\n writer.writeLine();\n writer.write(`//${comment.text}`);\n break;\n default:\n assertNever(comment);\n }\n writer.writeLine();\n}\n"],"names":["isLineBreak","assertNever"],"mappings":";;;;;AAIA,MAAM,SAAA,GAAY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,CAAC,CAAA;AACnF,IAAA,IAAI,OAAO,CAAA,EAAG;AACZ,MAAA,MAAM,MAAA,GAAS,OAAO,MAAA,GAAS,UAAA,GAAa,cAAc,IAAA,EAAM,KAAA,EAAO,KAAK,UAAU,CAAA;AACtF,MAAA,MAAA,CAAO,QAAA,CAAS,GAAA,CAAI,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,IACpC;AACA,IAAA,gBAAA,CAAiB,MAAA,EAAQ,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAAA,EAC3C,CAAC,CAAA;AACH;AAGO,SAAS,mBAAA,CAAoB,QAAoB,OAAA,EAA0B;AAChF,EAAA,QAAQ,QAAQ,IAAA;AAAM,IACpB,KAAK,OAAA;AACH,MAAA,iBAAA,CAAkB,MAAA,EAAQ,QAAQ,IAAI,CAAA;AACtC,MAAA;AAAA,IACF,KAAK,MAAA;AACH,MAAA,MAAA,CAAO,SAAA,EAAU;AACjB,MAAA,MAAA,CAAO,KAAA,CAAM,CAAA,EAAA,EAAK,OAAA,CAAQ,IAAI,CAAA,CAAE,CAAA;AAChC,MAAA;AAAA,IACF;AACE,MAAAC,uBAAA,CAAY,OAAO,CAAA;AAAA;AAEvB,EAAA,MAAA,CAAO,SAAA,EAAU;AACnB;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { assertNever } from '../../domain/assert-never.mjs';
|
|
2
|
+
import { isLineBreak } from './text-writer.mjs';
|
|
3
|
+
|
|
4
|
+
const LINE_FEED = 10;
|
|
5
|
+
const CARRIAGE_RETURN = 13;
|
|
6
|
+
const SINGLE_LINE_WHITESPACE = /* @__PURE__ */ new Set([
|
|
7
|
+
32,
|
|
8
|
+
9,
|
|
9
|
+
11,
|
|
10
|
+
12,
|
|
11
|
+
160,
|
|
12
|
+
133,
|
|
13
|
+
5760,
|
|
14
|
+
8192,
|
|
15
|
+
8193,
|
|
16
|
+
8194,
|
|
17
|
+
8195,
|
|
18
|
+
8196,
|
|
19
|
+
8197,
|
|
20
|
+
8198,
|
|
21
|
+
8199,
|
|
22
|
+
8200,
|
|
23
|
+
8201,
|
|
24
|
+
8202,
|
|
25
|
+
8203,
|
|
26
|
+
8239,
|
|
27
|
+
8287,
|
|
28
|
+
12288,
|
|
29
|
+
65279
|
|
30
|
+
]);
|
|
31
|
+
const TAB = 9;
|
|
32
|
+
function computeLineStarts(text) {
|
|
33
|
+
const starts = [0];
|
|
34
|
+
for (let position = 0; position < text.length; position++) {
|
|
35
|
+
const code = text.charCodeAt(position);
|
|
36
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(position + 1) === LINE_FEED) {
|
|
37
|
+
position++;
|
|
38
|
+
}
|
|
39
|
+
if (isLineBreak(code)) {
|
|
40
|
+
starts.push(position + 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return starts;
|
|
44
|
+
}
|
|
45
|
+
function measureIndent(text, start, end, tabSize) {
|
|
46
|
+
let width = 0;
|
|
47
|
+
for (let position = start; position < end && SINGLE_LINE_WHITESPACE.has(text.charCodeAt(position)); position++) {
|
|
48
|
+
width += text.charCodeAt(position) === TAB ? tabSize - width % tabSize : 1;
|
|
49
|
+
}
|
|
50
|
+
return width;
|
|
51
|
+
}
|
|
52
|
+
function writeTrimmedLine(writer, text, start, end) {
|
|
53
|
+
const lineEnd = Math.min(text.length, end - 1);
|
|
54
|
+
const line = text.substring(start, lineEnd).trim();
|
|
55
|
+
if (line.length === 0) {
|
|
56
|
+
writer.rawWrite(writer.options.newLine);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
writer.write(line);
|
|
60
|
+
if (lineEnd !== text.length) {
|
|
61
|
+
writer.writeLine();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeBlockComment(writer, body) {
|
|
65
|
+
const text = `/*${body}*/`;
|
|
66
|
+
const lineStarts = computeLineStarts(text);
|
|
67
|
+
const { indentSize } = writer.options;
|
|
68
|
+
lineStarts.forEach((start, line) => {
|
|
69
|
+
const end = line + 1 === lineStarts.length ? text.length + 1 : lineStarts[line + 1];
|
|
70
|
+
if (line > 0) {
|
|
71
|
+
const spaces = writer.indent * indentSize + measureIndent(text, start, end, indentSize);
|
|
72
|
+
writer.rawWrite(" ".repeat(spaces));
|
|
73
|
+
}
|
|
74
|
+
writeTrimmedLine(writer, text, start, end);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function writeLeadingComment(writer, comment) {
|
|
78
|
+
switch (comment.kind) {
|
|
79
|
+
case "block":
|
|
80
|
+
writeBlockComment(writer, comment.text);
|
|
81
|
+
break;
|
|
82
|
+
case "line":
|
|
83
|
+
writer.writeLine();
|
|
84
|
+
writer.write(`//${comment.text}`);
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
assertNever(comment);
|
|
88
|
+
}
|
|
89
|
+
writer.writeLine();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { writeLeadingComment };
|
|
93
|
+
//# sourceMappingURL=comment-writer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment-writer.mjs","sources":["../../../src/application/print/comment-writer.ts"],"sourcesContent":["import { assertNever } from \"../../domain/assert-never.js\";\nimport type { IrComment } from \"../../domain/ir/nodes.js\";\nimport { isLineBreak, type TextWriter } from \"./text-writer.js\";\n\nconst LINE_FEED = 0x0a;\nconst CARRIAGE_RETURN = 0x0d;\n\n/** Single-line white space as the TypeScript scanner defines it (`isWhiteSpaceSingleLine`). */\nconst SINGLE_LINE_WHITESPACE = new Set([\n 0x20, 0x09, 0x0b, 0x0c, 0xa0, 0x85, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005,\n 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x200b, 0x202f, 0x205f, 0x3000, 0xfeff,\n]);\nconst TAB = 0x09;\n\n/** Start offsets of every line, splitting at CR LF, CR, LF, U+2028 and U+2029 like TypeScript. */\nfunction computeLineStarts(text: string): number[] {\n const starts = [0];\n for (let position = 0; position < text.length; position++) {\n const code = text.charCodeAt(position);\n if (code === CARRIAGE_RETURN && text.charCodeAt(position + 1) === LINE_FEED) {\n position++;\n }\n if (isLineBreak(code)) {\n starts.push(position + 1);\n }\n }\n return starts;\n}\n\n/** Leading white space width of `text[start, end)`, counting a tab up to the next tab stop. */\nfunction measureIndent(text: string, start: number, end: number, tabSize: number): number {\n let width = 0;\n for (\n let position = start;\n position < end && SINGLE_LINE_WHITESPACE.has(text.charCodeAt(position));\n position++\n ) {\n width += text.charCodeAt(position) === TAB ? tabSize - (width % tabSize) : 1;\n }\n return width;\n}\n\n/** Write the line `text[start, end)` trimmed; a blank line becomes a bare line break. */\nfunction writeTrimmedLine(writer: TextWriter, text: string, start: number, end: number): void {\n const lineEnd = Math.min(text.length, end - 1);\n const line = text.substring(start, lineEnd).trim();\n if (line.length === 0) {\n writer.rawWrite(writer.options.newLine);\n return;\n }\n writer.write(line);\n if (lineEnd !== text.length) {\n writer.writeLine();\n }\n}\n\n/**\n * Write a `/*...*\\/` comment the way the TypeScript printer writes a synthesized one: every line\n * after the first is re-indented to the current level plus the line's own leading white space, and\n * every line is trimmed. (TypeScript only does this for comments whose second character is `*`,\n * which is always true for a synthesized block comment, so there is no other branch.)\n */\nfunction writeBlockComment(writer: TextWriter, body: string): void {\n const text = `/*${body}*/`;\n const lineStarts = computeLineStarts(text);\n const { indentSize } = writer.options;\n lineStarts.forEach((start, line) => {\n const end = line + 1 === lineStarts.length ? text.length + 1 : (lineStarts[line + 1] as number);\n if (line > 0) {\n const spaces = writer.indent * indentSize + measureIndent(text, start, end, indentSize);\n writer.rawWrite(\" \".repeat(spaces));\n }\n writeTrimmedLine(writer, text, start, end);\n });\n}\n\n/** Write a comment on its own line before the node it belongs to. */\nexport function writeLeadingComment(writer: TextWriter, comment: IrComment): void {\n switch (comment.kind) {\n case \"block\":\n writeBlockComment(writer, comment.text);\n break;\n case \"line\":\n writer.writeLine();\n writer.write(`//${comment.text}`);\n break;\n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AA,CAAW,MAAA,GAAS,KAAK,MAAA,GAAS,CAAA,GAAK,UAAA,CAAW,IAAA,GAAO,CAAC,CAAA;AACnF,IAAA,IAAI,OAAO,CAAA,EAAG;AACZ,MAAA,MAAM,MAAA,GAAS,OAAO,MAAA,GAAS,UAAA,GAAa,cAAc,IAAA,EAAM,KAAA,EAAO,KAAK,UAAU,CAAA;AACtF,MAAA,MAAA,CAAO,QAAA,CAAS,GAAA,CAAI,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,IACpC;AACA,IAAA,gBAAA,CAAiB,MAAA,EAAQ,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAAA,EAC3C,CAAC,CAAA;AACH;AAGO,SAAS,mBAAA,CAAoB,QAAoB,OAAA,EAA0B;AAChF,EAAA,QAAQ,QAAQ,IAAA;AAAM,IACpB,KAAK,OAAA;AACH,MAAA,iBAAA,CAAkB,MAAA,EAAQ,QAAQ,IAAI,CAAA;AACtC,MAAA;AAAA,IACF,KAAK,MAAA;AACH,MAAA,MAAA,CAAO,SAAA,EAAU;AACjB,MAAA,MAAA,CAAO,KAAA,CAAM,CAAA,EAAA,EAAK,OAAA,CAAQ,IAAI,CAAA,CAAE,CAAA;AAChC,MAAA;AAAA,IACF;AACE,MAAA,WAAA,CAAY,OAAO,CAAA;AAAA;AAEvB,EAAA,MAAA,CAAO,SAAA,EAAU;AACnB;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assertNever = require('../../domain/assert-never.cjs');
|
|
4
|
+
const commentWriter = require('./comment-writer.cjs');
|
|
5
|
+
const literalText = require('./literal-text.cjs');
|
|
6
|
+
const typePrinter = require('./type-printer.cjs');
|
|
7
|
+
|
|
8
|
+
function printValue(value) {
|
|
9
|
+
return typeof value === "number" ? literalText.printNumberLiteral(value) : literalText.printEscapedString(value);
|
|
10
|
+
}
|
|
11
|
+
function writeHead(writer, declaration) {
|
|
12
|
+
for (const comment of declaration.comments) {
|
|
13
|
+
commentWriter.writeLeadingComment(writer, comment);
|
|
14
|
+
}
|
|
15
|
+
if (declaration.isExported) {
|
|
16
|
+
writer.write("export ");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function writeInterface(writer, declaration) {
|
|
20
|
+
writeHead(writer, declaration);
|
|
21
|
+
writer.write(`interface ${declaration.name} {`);
|
|
22
|
+
typePrinter.writeMultiLineList(
|
|
23
|
+
writer,
|
|
24
|
+
declaration.members,
|
|
25
|
+
{ delimiter: "", isLineBreakWhenEmpty: true },
|
|
26
|
+
(member) => typePrinter.writeMember(writer, member)
|
|
27
|
+
);
|
|
28
|
+
writer.write("}");
|
|
29
|
+
}
|
|
30
|
+
function writeTypeAlias(writer, declaration) {
|
|
31
|
+
writeHead(writer, declaration);
|
|
32
|
+
writer.write(`type ${declaration.name} = `);
|
|
33
|
+
typePrinter.writeType(writer, declaration.type);
|
|
34
|
+
writer.write(";");
|
|
35
|
+
}
|
|
36
|
+
function writeEnumMember(writer, member) {
|
|
37
|
+
for (const comment of member.comments) {
|
|
38
|
+
commentWriter.writeLeadingComment(writer, comment);
|
|
39
|
+
}
|
|
40
|
+
writer.write(`${member.name} = ${printValue(member.value)}`);
|
|
41
|
+
}
|
|
42
|
+
function writeEnum(writer, declaration) {
|
|
43
|
+
writeHead(writer, declaration);
|
|
44
|
+
writer.write(`enum ${declaration.name} {`);
|
|
45
|
+
typePrinter.writeMultiLineList(
|
|
46
|
+
writer,
|
|
47
|
+
declaration.members,
|
|
48
|
+
{ delimiter: ",", isLineBreakWhenEmpty: true },
|
|
49
|
+
(member) => writeEnumMember(writer, member)
|
|
50
|
+
);
|
|
51
|
+
writer.write("}");
|
|
52
|
+
}
|
|
53
|
+
function writeConstArray(writer, declaration) {
|
|
54
|
+
writeHead(writer, declaration);
|
|
55
|
+
writer.write(`const ${declaration.name}: `);
|
|
56
|
+
typePrinter.writeType(writer, declaration.type);
|
|
57
|
+
writer.write(` = [${declaration.values.map(printValue).join(", ")}];`);
|
|
58
|
+
}
|
|
59
|
+
function writeDeclaration(writer, declaration) {
|
|
60
|
+
writer.writeLine();
|
|
61
|
+
switch (declaration.kind) {
|
|
62
|
+
case "interface":
|
|
63
|
+
writeInterface(writer, declaration);
|
|
64
|
+
break;
|
|
65
|
+
case "typeAlias":
|
|
66
|
+
writeTypeAlias(writer, declaration);
|
|
67
|
+
break;
|
|
68
|
+
case "enum":
|
|
69
|
+
writeEnum(writer, declaration);
|
|
70
|
+
break;
|
|
71
|
+
case "constArray":
|
|
72
|
+
writeConstArray(writer, declaration);
|
|
73
|
+
break;
|
|
74
|
+
case "rawDeclaration":
|
|
75
|
+
writer.write(declaration.text);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
assertNever.assertNever(declaration);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.writeDeclaration = writeDeclaration;
|
|
83
|
+
//# sourceMappingURL=declaration-printer.cjs.map
|