openapi-typesafe 1.0.0-rc.1 → 1.0.0-rc.3
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/README.md +12 -5
- package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
- package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
- package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
- package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
- package/dist/adapters/redocly-loader/configured-headers.cjs +32 -0
- package/dist/adapters/redocly-loader/configured-headers.cjs.map +1 -0
- package/dist/adapters/redocly-loader/configured-headers.mjs +30 -0
- package/dist/adapters/redocly-loader/configured-headers.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +19 -6
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +18 -5
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +37 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +37 -4
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-resolution-check.cjs +191 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.mjs +189 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.cjs +73 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.mjs +60 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +41 -14
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -14
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +23 -5
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +23 -5
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +9 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +9 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +2 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +2 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -1
- package/dist/api/default-ports.cjs +14 -0
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +12 -1
- package/dist/api/default-ports.mjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.mjs +2 -2
- package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
- package/dist/api/discriminator-patch.cjs +8 -4
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +9 -5
- package/dist/api/discriminator-patch.mjs.map +1 -1
- package/dist/api/discriminator-scan.cjs +2 -2
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +3 -3
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-refs.cjs +15 -12
- package/dist/api/document-refs.cjs.map +1 -1
- package/dist/api/document-refs.mjs +15 -12
- package/dist/api/document-refs.mjs.map +1 -1
- package/dist/api/document-run.cjs +6 -3
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +6 -3
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/footer-sink.cjs +25 -2
- package/dist/api/footer-sink.cjs.map +1 -1
- package/dist/api/footer-sink.mjs +25 -2
- package/dist/api/footer-sink.mjs.map +1 -1
- package/dist/api/legacy-callback-warning.cjs +7 -1
- package/dist/api/legacy-callback-warning.cjs.map +1 -1
- package/dist/api/legacy-callback-warning.mjs +8 -2
- package/dist/api/legacy-callback-warning.mjs.map +1 -1
- package/dist/api/legacy-ts-helpers.cjs.map +1 -1
- package/dist/api/legacy-ts-helpers.mjs.map +1 -1
- package/dist/api/legacy-utils.cjs.map +1 -1
- package/dist/api/legacy-utils.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +3 -2
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +4 -3
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/string-to-ast.cjs +7 -9
- package/dist/api/string-to-ast.cjs.map +1 -1
- package/dist/api/string-to-ast.mjs +8 -9
- package/dist/api/string-to-ast.mjs.map +1 -1
- package/dist/api/transform-context.cjs +1 -1
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +1 -1
- package/dist/api/transform-context.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +2 -2
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +3 -3
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/application/print/type-printer.cjs +2 -1
- package/dist/application/print/type-printer.cjs.map +1 -1
- package/dist/application/print/type-printer.mjs +2 -1
- package/dist/application/print/type-printer.mjs.map +1 -1
- package/dist/application/transform/document/components.cjs +1 -1
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +2 -2
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/parameters.cjs +2 -2
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +3 -3
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +2 -2
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +3 -3
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/footer/evaluation.cjs +9 -0
- package/dist/application/transform/footer/evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/evaluation.mjs +8 -1
- package/dist/application/transform/footer/evaluation.mjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.cjs +4 -112
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.mjs +4 -112
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
- package/dist/application/transform/footer/type-indexing.cjs +107 -0
- package/dist/application/transform/footer/type-indexing.cjs.map +1 -0
- package/dist/application/transform/footer/type-indexing.mjs +105 -0
- package/dist/application/transform/footer/type-indexing.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs +1 -1
- package/dist/application/transform/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.mjs +2 -2
- package/dist/application/transform/schema/access-flags.mjs.map +1 -1
- package/dist/application/transform/schema/array-type.cjs +2 -2
- package/dist/application/transform/schema/array-type.cjs.map +1 -1
- package/dist/application/transform/schema/array-type.mjs +3 -3
- package/dist/application/transform/schema/array-type.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +3 -3
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +4 -4
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +3 -5
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +4 -6
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/presence-members.cjs +1 -1
- package/dist/application/transform/schema/presence-members.cjs.map +1 -1
- package/dist/application/transform/schema/presence-members.mjs +2 -2
- package/dist/application/transform/schema/presence-members.mjs.map +1 -1
- package/dist/application/transform/schema/required-variants.cjs +2 -2
- package/dist/application/transform/schema/required-variants.cjs.map +1 -1
- package/dist/application/transform/schema/required-variants.mjs +3 -3
- package/dist/application/transform/schema/required-variants.mjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +1 -1
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +2 -2
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/cli/api-settings.cjs +78 -0
- package/dist/cli/api-settings.cjs.map +1 -0
- package/dist/cli/api-settings.mjs +73 -0
- package/dist/cli/api-settings.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +1 -0
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +1 -1
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/help-text.cjs +3 -3
- package/dist/cli/help-text.cjs.map +1 -1
- package/dist/cli/help-text.mjs +3 -3
- package/dist/cli/help-text.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +8 -4
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +7 -3
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +5 -1
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +5 -1
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/deprecations.cjs +11 -0
- package/dist/domain/deprecations.cjs.map +1 -0
- package/dist/domain/deprecations.mjs +9 -0
- package/dist/domain/deprecations.mjs.map +1 -0
- package/dist/domain/errors.cjs +4 -1
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +4 -1
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/constructors.cjs +2 -0
- package/dist/domain/ir/constructors.cjs.map +1 -1
- package/dist/domain/ir/constructors.mjs +2 -1
- package/dist/domain/ir/constructors.mjs.map +1 -1
- package/dist/domain/openapi/path-templates.cjs +1 -1
- package/dist/domain/openapi/path-templates.cjs.map +1 -1
- package/dist/domain/openapi/path-templates.mjs +1 -1
- package/dist/domain/openapi/path-templates.mjs.map +1 -1
- package/dist/domain/output-fixes.cjs +11 -14
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +11 -13
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/url-credentials.cjs +10 -0
- package/dist/domain/url-credentials.cjs.map +1 -0
- package/dist/domain/url-credentials.mjs +8 -0
- package/dist/domain/url-credentials.mjs.map +1 -0
- package/dist/domain/warnings.cjs +8 -1
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +8 -1
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1185 -59
- package/dist/index.d.mts +1185 -59
- package/dist/index.d.ts +1185 -59
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/transform/path-item-object.cjs.map +1 -1
- package/dist/transform/path-item-object.mjs.map +1 -1
- package/package.json +5 -4
- package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
- package/src/adapters/redocly-loader/configured-headers.ts +65 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -7
- package/src/adapters/redocly-loader/ref-access.ts +60 -5
- package/src/adapters/redocly-loader/ref-resolution-check.ts +257 -0
- package/src/adapters/redocly-loader/ref-resolution-steps.ts +113 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +77 -21
- package/src/adapters/redocly-loader/schema-load-errors.ts +33 -11
- package/src/adapters/redocly-loader/unsupported-keys.ts +17 -2
- package/src/adapters/terminal-logger/terminal-logger.ts +9 -5
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +2 -1
- package/src/adapters/type-ast-bridge/print-typescript.ts +3 -1
- package/src/adapters/type-ast-bridge/typescript-types.ts +57 -5
- package/src/api/default-ports.ts +23 -0
- package/src/api/discriminator-conflict-warnings.ts +2 -2
- package/src/api/discriminator-patch.ts +11 -7
- package/src/api/discriminator-scan.ts +3 -3
- package/src/api/document-refs.ts +19 -15
- package/src/api/document-run.ts +14 -6
- package/src/api/footer-sink.ts +34 -2
- package/src/api/legacy-callback-warning.ts +16 -5
- package/src/api/legacy-ts-helpers.ts +7 -5
- package/src/api/legacy-utils.ts +1 -1
- package/src/api/openapi-ts.ts +8 -2
- package/src/api/run-context.ts +37 -0
- package/src/api/string-to-ast.ts +11 -15
- package/src/api/transform-context.ts +10 -8
- package/src/api/transform-schema.ts +9 -8
- package/src/application/ports/deprecation-reporter.ts +9 -0
- package/src/application/print/type-printer.ts +2 -1
- package/src/application/transform/document/components.ts +2 -2
- package/src/application/transform/document/parameters.ts +4 -3
- package/src/application/transform/document/paths.ts +4 -3
- package/src/application/transform/footer/evaluation.ts +10 -0
- package/src/application/transform/footer/type-evaluation.ts +6 -133
- package/src/application/transform/footer/type-indexing.ts +152 -0
- package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
- package/src/application/transform/schema/access-flags.ts +2 -2
- package/src/application/transform/schema/array-type.ts +3 -5
- package/src/application/transform/schema/composition-type.ts +4 -4
- package/src/application/transform/schema/enum-rule.ts +4 -6
- package/src/application/transform/schema/presence-members.ts +2 -2
- package/src/application/transform/schema/required-variants.ts +3 -3
- package/src/application/transform/schema/unevaluated-properties.ts +2 -2
- package/src/application/transform/schema-comment.ts +2 -2
- package/src/cli/api-settings.ts +109 -0
- package/src/cli/cli-arguments.ts +5 -2
- package/src/cli/help-text.ts +4 -4
- package/src/cli/redocly-apis.ts +13 -7
- package/src/cli/run-cli.ts +5 -1
- package/src/domain/deprecations.ts +15 -0
- package/src/domain/errors.ts +16 -4
- package/src/domain/ir/constructors.ts +3 -0
- package/src/domain/ir/nodes.ts +9 -6
- package/src/domain/openapi/path-templates.ts +2 -1
- package/src/domain/output-fixes.ts +16 -16
- package/src/domain/url-credentials.ts +18 -0
- package/src/domain/warnings.ts +7 -0
- package/src/index.ts +3 -6
- package/src/transform/path-item-object.ts +6 -2
- package/src/types/generator-options.ts +12 -32
- package/src/types/openapi-common.ts +1 -0
- package/src/types/openapi-request.ts +3 -0
- package/src/types/openapi-schema.ts +2 -0
- package/src/types/openapi-security.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-run.cjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport { sourceEmptyError } from \"../adapters/redocly-loader/schema-load-errors.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport type { RefAccess, SchemaLoader } from \"../application/ports/schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport {\n ineffectiveFixNotices,\n type OutputFix,\n outputFixNamesOf,\n resolveOutputFixes,\n} from \"../domain/output-fixes.js\";\nimport type { GeneratorOptions, GlobalContext, OpenAPI3, SchemaSource } from \"../types.js\";\nimport { warnDiscriminatorValueConflicts } from \"./discriminator-conflict-warnings.js\";\nimport { findDiscriminators } from \"./discriminator-scan.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\nimport { warnIdenticalPathTemplates } from \"./path-template-warnings.js\";\nimport { warnUnsupportedFeatures } from \"./unsupported-feature-warnings.js\";\n\n/** The ports of one generator run, wired by the Node API or the CLI (ENGINEERING_PLAN 4.5). */\nexport interface GeneratorPorts {\n readonly loader: SchemaLoader;\n readonly logger: Logger;\n /** The Redocly config the loader uses; the run's context exposes it as `ctx.redoc`. */\n readonly redoc: RedoclyConfig;\n /** A monotonic time in milliseconds, for debug durations. */\n readonly now: () => number;\n}\n\n/** A validated, bundled document and the context of one generator run. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly ctx: GlobalContext;\n}\n\n/** The context fields that are user flags, with the original defaults. */\ntype ContextFlags = Omit<\n GlobalContext,\n | \"discriminators\"\n | \"injectFooter\"\n | \"redoc\"\n | \"resolve\"\n | \"runFooter\"\n | \"legacyCallbackWarnings\"\n | \"logger\"\n | \"fix\"\n>;\n\n/**\n * The directory that relative `$ref`s of an inline source resolve against, as a URL that ends in\n * a slash. A path is resolved and encoded (`#`, `%`, spaces); a URL without the slash gets one.\n */\nfunction sourceCwd(options: GeneratorOptions): URL {\n const { cwd } = options;\n if (cwd instanceof URL) {\n return cwd.pathname.endsWith(\"/\") ? cwd : new URL(`${cwd.pathname}/`, cwd);\n }\n const directory = path.resolve(cwd === undefined ? process.cwd() : cwd.toString());\n return pathToFileURL(path.join(directory, path.sep));\n}\n\n/** The `$ref` limits of the options; a relative local root resolves against the cwd. */\nfunction refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n const localRoot =\n typeof localRefRoot === \"string\"\n ? pathToFileURL(path.resolve(fileURLToPath(cwd), localRefRoot))\n : localRefRoot;\n return {\n ...(localRoot === undefined ? {} : { localRoot }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteRefHosts }),\n };\n}\n\nfunction callbackOptions(options: GeneratorOptions) {\n return {\n irCallbacks: options.irCallbacks === true,\n postTransform: typeof options.postTransform === \"function\" ? options.postTransform : undefined,\n transform: typeof options.transform === \"function\" ? options.transform : undefined,\n transformProperty:\n typeof options.transformProperty === \"function\" ? options.transformProperty : undefined,\n };\n}\n\nfunction contextFlags(options: GeneratorOptions): ContextFlags {\n return {\n additionalProperties: options.additionalProperties ?? false,\n alphabetize: options.alphabetize ?? false,\n arrayLength: options.arrayLength ?? false,\n binaryAsBlob: options.binaryAsBlob ?? false,\n defaultNonNullable: options.defaultNonNullable ?? true,\n emptyObjectsUnknown: options.emptyObjectsUnknown ?? false,\n enum: options.enum ?? false,\n enumValues: options.enumValues ?? false,\n conditionalEnums: options.conditionalEnums ?? false,\n dedupeEnums: options.dedupeEnums ?? false,\n excludeDeprecated: options.excludeDeprecated ?? false,\n exportType: options.exportType ?? false,\n immutable: options.immutable ?? false,\n rootTypes: options.rootTypes ?? false,\n rootTypesNoSchemaPrefix: options.rootTypesNoSchemaPrefix ?? false,\n rootTypesKeepCasing: options.rootTypesKeepCasing ?? false,\n pathParamsAsTypes: options.pathParamsAsTypes ?? false,\n propertiesRequiredByDefault: options.propertiesRequiredByDefault ?? false,\n silent: options.silent ?? false,\n ...(options.inject === undefined ? {} : { inject: options.inject }),\n makePathsEnum: options.makePathsEnum ?? false,\n generatePathParams: options.generatePathParams ?? false,\n readWriteMarkers: options.readWriteMarkers ?? false,\n ...callbackOptions(options),\n };\n}\n\n/**\n * The fixes of the options, `all` expanded; fails with `OPTION_FIX_UNKNOWN` for another name.\n * A fix named without the option it needs is reported, since it changes nothing.\n */\nfunction outputFixesOf(options: GeneratorOptions, logger: Logger): readonly OutputFix[] {\n const names = outputFixNamesOf(options.fix ?? []);\n for (const notice of ineffectiveFixNotices(names, (option) => options[option] === true)) {\n logger.warn(notice);\n }\n return [...resolveOutputFixes(names)];\n}\n\n/** The warnings about the loaded document itself, before it is transformed. */\nfunction warnAboutDocument(schema: OpenAPI3, fix: readonly OutputFix[], logger: Logger): void {\n withStackOverflowReported(\"transform\", () => warnUnsupportedFeatures(schema, logger));\n withStackOverflowReported(\"transform\", () =>\n warnDiscriminatorValueConflicts(schema, fix, logger),\n );\n warnIdenticalPathTemplates(schema, logger);\n}\n\n/**\n * Load the source through the ports, then build the run's context from the options. The fix names\n * are checked first, so a typo fails before the document is read.\n */\nexport async function createDocumentRun(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<DocumentRun> {\n if (!source) {\n throw sourceEmptyError(\"Empty schema. Please specify a URL, file path, or Redocly Config\");\n }\n const { logger } = ports;\n const fix = outputFixesOf(options, logger);\n const silent = options.silent ?? false;\n const cwd = sourceCwd(options);\n const schema = await ports.loader.load({\n source,\n cwd,\n shouldLint: options.lint ?? true,\n refAccess: refAccessOf(options, cwd),\n });\n warnAboutDocument(schema, fix, logger);\n const ctx: GlobalContext = {\n ...contextFlags(options),\n fix,\n // The scan walks every schema before the transform does, so on a larger stack, where loading\n // passed, it is the first step to run out.\n discriminators: withStackOverflowReported(\"transform\", () =>\n findDiscriminators(schema, {\n silent,\n logger,\n fixes: new Set(fix),\n }),\n ),\n injectFooter: [],\n redoc: ports.redoc,\n resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),\n logger,\n };\n return { schema, ctx };\n}\n"],"names":["path","pathToFileURL","fileURLToPath","outputFixNamesOf","ineffectiveFixNotices","resolveOutputFixes","withStackOverflowReported","warnUnsupportedFeatures","warnDiscriminatorValueConflicts","warnIdenticalPathTemplates","sourceEmptyError","findDiscriminators","resolveDocumentRef"],"mappings":";;;;;;;;;;;;;;;;;AAqDA,SAAS,UAAU,OAAA,EAAgC;AACjD,EAAA,MAAM,EAAE,KAAI,GAAI,OAAA;AAChB,EAAA,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AA,MAAM,MAAA,GAAS,MAAM,KAAA,CAAM,MAAA,CAAO,IAAA,CAAK;AAAA,IACrC,MAAA;AAAA,IACA,GAAA;AAAA,IACA,UAAA,EAAY,QAAQ,IAAA,IAAQ,IAAA;AAAA,IAC5B,SAAA,EAAW,WAAA,CAAY,OAAA,EAAS,GAAG;AAAA,GACpC,CAAA;AACD,EAAA,iBAAA,CAAkB,MAAA,EAAQ,KAAK,MAAM,CAAA;AACrC,EAAA,MAAM,GAAA,GAAqB;AAAA,IACzB,GAAG,aAAa,OAAO,CAAA;AAAA,IACvB,GAAA;AAAA;AAAA;AAAA,IAGA,cAAA,EAAgBJ,uCAAA;AAAA,MAA0B,WAAA;AAAA,MAAa,MACrDK,qCAAmB,MAAA,EAAQ;AAAA,QACzB,MAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,IAAI,GAAA,CAAI,GAAG;AAAA,OACnB;AAAA,KACH;AAAA,IACA,cAAc,EAAC;AAAA,IACf,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,OAAA,EAAS,CAAC,IAAA,KAASC,+BAAA,CAAmB,QAAQ,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACtE;AAAA,GACF;AACA,EAAA,OAAO,EAAE,QAAQ,GAAA,EAAI;AACvB;;"}
|
|
1
|
+
{"version":3,"file":"document-run.cjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport { sourceEmptyError } from \"../adapters/redocly-loader/schema-load-errors.js\";\nimport type { DeprecationReporter } from \"../application/ports/deprecation-reporter.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport type { RefAccess, SchemaLoader } from \"../application/ports/schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport {\n ineffectiveFixNotices,\n type OutputFix,\n outputFixNamesOf,\n resolveOutputFixes,\n} from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport type { GeneratorOptions, OpenAPI3, SchemaSource } from \"../types.js\";\nimport { processCwd } from \"./default-ports.js\";\nimport { warnDiscriminatorValueConflicts } from \"./discriminator-conflict-warnings.js\";\nimport { findDiscriminators } from \"./discriminator-scan.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\nimport { warnIdenticalPathTemplates } from \"./path-template-warnings.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { warnUnsupportedFeatures } from \"./unsupported-feature-warnings.js\";\n\n/** The ports of one generator run, wired by the Node API or the CLI (ENGINEERING_PLAN 4.5). */\nexport interface GeneratorPorts {\n readonly loader: SchemaLoader;\n readonly logger: Logger;\n /** Where the run reports the deprecated callback forms (ADR-004). */\n readonly deprecations: DeprecationReporter;\n /** The Redocly config the loader uses; the run's context exposes it as `ctx.redoc`. */\n readonly redoc: RedoclyConfig;\n /** A monotonic time in milliseconds, for debug durations. */\n readonly now: () => number;\n}\n\n/** A validated, bundled document and the context of one generator run. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly ctx: RunContext;\n}\n\n/** The context fields that are user flags, with the original defaults. */\ntype ContextFlags = Omit<\n RunContext,\n | \"discriminators\"\n | \"injectFooter\"\n | \"redoc\"\n | \"resolve\"\n | \"runFooter\"\n | \"legacyCallbackWarnings\"\n | \"logger\"\n | \"deprecations\"\n | \"fix\"\n>;\n\n/**\n * The directory that relative `$ref`s of an inline source resolve against, as a URL that ends in\n * a slash. A path is resolved and encoded (`#`, `%`, spaces); a URL without the slash gets one.\n */\nfunction sourceCwd(options: GeneratorOptions): URL {\n const { cwd } = options;\n if (cwd instanceof URL) {\n return cwd.pathname.endsWith(\"/\") ? cwd : new URL(`${cwd.pathname}/`, cwd);\n }\n const directory = path.resolve(cwd === undefined ? processCwd() : cwd.toString());\n return pathToFileURL(path.join(directory, path.sep));\n}\n\n/** The `$ref` limits of the options; a relative local root resolves against the cwd. */\nfunction refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n const localRoot =\n typeof localRefRoot === \"string\"\n ? pathToFileURL(path.resolve(fileURLToPath(cwd), localRefRoot))\n : localRefRoot;\n return {\n ...(localRoot === undefined ? {} : { localRoot }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteRefHosts }),\n };\n}\n\nfunction callbackOptions(options: GeneratorOptions) {\n return {\n irCallbacks: options.irCallbacks === true,\n postTransform: typeof options.postTransform === \"function\" ? options.postTransform : undefined,\n transform: typeof options.transform === \"function\" ? options.transform : undefined,\n transformProperty:\n typeof options.transformProperty === \"function\" ? options.transformProperty : undefined,\n };\n}\n\nfunction contextFlags(options: GeneratorOptions): ContextFlags {\n return {\n additionalProperties: options.additionalProperties ?? false,\n alphabetize: options.alphabetize ?? false,\n arrayLength: options.arrayLength ?? false,\n binaryAsBlob: options.binaryAsBlob ?? false,\n defaultNonNullable: options.defaultNonNullable ?? true,\n emptyObjectsUnknown: options.emptyObjectsUnknown ?? false,\n enum: options.enum ?? false,\n enumValues: options.enumValues ?? false,\n conditionalEnums: options.conditionalEnums ?? false,\n dedupeEnums: options.dedupeEnums ?? false,\n excludeDeprecated: options.excludeDeprecated ?? false,\n exportType: options.exportType ?? false,\n immutable: options.immutable ?? false,\n rootTypes: options.rootTypes ?? false,\n rootTypesNoSchemaPrefix: options.rootTypesNoSchemaPrefix ?? false,\n rootTypesKeepCasing: options.rootTypesKeepCasing ?? false,\n pathParamsAsTypes: options.pathParamsAsTypes ?? false,\n propertiesRequiredByDefault: options.propertiesRequiredByDefault ?? false,\n silent: options.silent ?? false,\n ...(options.inject === undefined ? {} : { inject: options.inject }),\n makePathsEnum: options.makePathsEnum ?? false,\n generatePathParams: options.generatePathParams ?? false,\n readWriteMarkers: options.readWriteMarkers ?? false,\n ...callbackOptions(options),\n };\n}\n\n/**\n * The fixes of the options, `all` expanded; fails with `OPTION_FIX_UNKNOWN` for another name.\n * A fix named without the option it needs is reported, since it changes nothing.\n */\nfunction outputFixesOf(options: GeneratorOptions, logger: Logger): readonly OutputFix[] {\n const names = outputFixNamesOf(options.fix ?? []);\n for (const notice of ineffectiveFixNotices(names, (option) => options[option] === true)) {\n logger.warn(warningText(notice, WARNING_CODES.FIX_NEEDS_OPTION));\n }\n return [...resolveOutputFixes(names)];\n}\n\n/** The warnings about the loaded document itself, before it is transformed. */\nfunction warnAboutDocument(schema: OpenAPI3, fix: readonly OutputFix[], logger: Logger): void {\n withStackOverflowReported(\"transform\", () => warnUnsupportedFeatures(schema, logger));\n withStackOverflowReported(\"transform\", () =>\n warnDiscriminatorValueConflicts(schema, fix, logger),\n );\n warnIdenticalPathTemplates(schema, logger);\n}\n\n/**\n * Load the source through the ports, then build the run's context from the options. The fix names\n * are checked first, so a typo fails before the document is read.\n */\nexport async function createDocumentRun(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<DocumentRun> {\n if (!source) {\n throw sourceEmptyError(\"Empty schema. Please specify a URL, file path, or Redocly Config\");\n }\n const { logger } = ports;\n const fix = outputFixesOf(options, logger);\n const silent = options.silent ?? false;\n const cwd = sourceCwd(options);\n const schema = await ports.loader.load({\n source,\n cwd,\n shouldLint: options.lint ?? true,\n refAccess: refAccessOf(options, cwd),\n });\n warnAboutDocument(schema, fix, logger);\n const ctx: RunContext = {\n ...contextFlags(options),\n fix,\n // The scan walks every schema before the transform does, so on a larger stack, where loading\n // passed, it is the first step to run out.\n discriminators: withStackOverflowReported(\"transform\", () =>\n findDiscriminators(schema, {\n silent,\n logger,\n fixes: new Set(fix),\n }),\n ),\n injectFooter: [],\n redoc: ports.redoc,\n resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),\n logger,\n deprecations: ports.deprecations,\n };\n return { schema, ctx };\n}\n"],"names":["path","processCwd","pathToFileURL","fileURLToPath","outputFixNamesOf","ineffectiveFixNotices","warningText","WARNING_CODES","resolveOutputFixes","withStackOverflowReported","warnUnsupportedFeatures","warnDiscriminatorValueConflicts","warnIdenticalPathTemplates","sourceEmptyError","findDiscriminators","resolveDocumentRef"],"mappings":";;;;;;;;;;;;;;;;;;;AA4DA,SAAS,UAAU,OAAA,EAAgC;AACjD,EAAA,MAAM,EAAE,KAAI,GAAI,OAAA;AAChB,EAAA,IAAI,eAAe,GAAA,EAAK;AACtB,IAAA,OAAO,GAAA,CAAI,QAAA,CAAS,QAAA,CAAS,GAAG,CAAA,GAAI,GAAA,GAAM,IAAI,GAAA,CAAI,CAAA,EAAG,GAAA,CAAI,QAAQ,CAAA,CAAA,CAAA,EAAK,GAAG,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,SAAA,GAAYA,cAAK,OAAA,CAAQ,GAAA,KAAQ,SAAYC,uBAAA,EAAW,GAAI,GAAA,CAAI,QAAA,EAAU,CAAA;AAChF,EAAA,OAAOC,uBAAcF,aAAA,CAAK,IAAA,CAAK,SAAA,EAAWA,aAAA,CAAK,GAAG,CAAC,CAAA;AACrD;AAGA,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AACnE,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,MAAM,SAAA,GACJ,OAAO,YAAA,KAAiB,QAAA,GACpBE,sBAAA,CAAcF,aAAA,CAAK,OAAA,CAAQG,sBAAA,CAAc,GAAG,CAAA,EAAG,YAAY,CAAC,CAAA,GAC5D,YAAA;AACN,EAAA,OAAO;AAAA,IACL,GAAI,SAAA,KAAc,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAU;AAAA,IAC/C,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,aAAa,cAAA;AAAe,GACxE;AACF;AAEA,SAAS,gBAAgB,OAAA,EAA2B;AAClD,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,QAAQ,WAAA,KAAgB,IAAA;AAAA,IACrC,eAAe,OAAO,OAAA,CAAQ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
|
4
4
|
import { withStackOverflowReported } from '../application/stack-overflow.mjs';
|
|
5
5
|
import { outputFixNamesOf, ineffectiveFixNotices, resolveOutputFixes } from '../domain/output-fixes.mjs';
|
|
6
|
+
import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
|
|
7
|
+
import { processCwd } from './default-ports.mjs';
|
|
6
8
|
import { warnDiscriminatorValueConflicts } from './discriminator-conflict-warnings.mjs';
|
|
7
9
|
import { findDiscriminators } from './discriminator-scan.mjs';
|
|
8
10
|
import { resolveDocumentRef } from './document-refs.mjs';
|
|
@@ -14,7 +16,7 @@ function sourceCwd(options) {
|
|
|
14
16
|
if (cwd instanceof URL) {
|
|
15
17
|
return cwd.pathname.endsWith("/") ? cwd : new URL(`${cwd.pathname}/`, cwd);
|
|
16
18
|
}
|
|
17
|
-
const directory = path.resolve(cwd === void 0 ?
|
|
19
|
+
const directory = path.resolve(cwd === void 0 ? processCwd() : cwd.toString());
|
|
18
20
|
return pathToFileURL(path.join(directory, path.sep));
|
|
19
21
|
}
|
|
20
22
|
function refAccessOf(options, cwd) {
|
|
@@ -64,7 +66,7 @@ function contextFlags(options) {
|
|
|
64
66
|
function outputFixesOf(options, logger) {
|
|
65
67
|
const names = outputFixNamesOf(options.fix ?? []);
|
|
66
68
|
for (const notice of ineffectiveFixNotices(names, (option) => options[option] === true)) {
|
|
67
|
-
logger.warn(notice);
|
|
69
|
+
logger.warn(warningText(notice, WARNING_CODES.FIX_NEEDS_OPTION));
|
|
68
70
|
}
|
|
69
71
|
return [...resolveOutputFixes(names)];
|
|
70
72
|
}
|
|
@@ -107,7 +109,8 @@ async function createDocumentRun(source, options, ports) {
|
|
|
107
109
|
injectFooter: [],
|
|
108
110
|
redoc: ports.redoc,
|
|
109
111
|
resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),
|
|
110
|
-
logger
|
|
112
|
+
logger,
|
|
113
|
+
deprecations: ports.deprecations
|
|
111
114
|
};
|
|
112
115
|
return { schema, ctx };
|
|
113
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-run.mjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport { sourceEmptyError } from \"../adapters/redocly-loader/schema-load-errors.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport type { RefAccess, SchemaLoader } from \"../application/ports/schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport {\n ineffectiveFixNotices,\n type OutputFix,\n outputFixNamesOf,\n resolveOutputFixes,\n} from \"../domain/output-fixes.js\";\nimport type { GeneratorOptions, GlobalContext, OpenAPI3, SchemaSource } from \"../types.js\";\nimport { warnDiscriminatorValueConflicts } from \"./discriminator-conflict-warnings.js\";\nimport { findDiscriminators } from \"./discriminator-scan.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\nimport { warnIdenticalPathTemplates } from \"./path-template-warnings.js\";\nimport { warnUnsupportedFeatures } from \"./unsupported-feature-warnings.js\";\n\n/** The ports of one generator run, wired by the Node API or the CLI (ENGINEERING_PLAN 4.5). */\nexport interface GeneratorPorts {\n readonly loader: SchemaLoader;\n readonly logger: Logger;\n /** The Redocly config the loader uses; the run's context exposes it as `ctx.redoc`. */\n readonly redoc: RedoclyConfig;\n /** A monotonic time in milliseconds, for debug durations. */\n readonly now: () => number;\n}\n\n/** A validated, bundled document and the context of one generator run. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly ctx: GlobalContext;\n}\n\n/** The context fields that are user flags, with the original defaults. */\ntype ContextFlags = Omit<\n GlobalContext,\n | \"discriminators\"\n | \"injectFooter\"\n | \"redoc\"\n | \"resolve\"\n | \"runFooter\"\n | \"legacyCallbackWarnings\"\n | \"logger\"\n | \"fix\"\n>;\n\n/**\n * The directory that relative `$ref`s of an inline source resolve against, as a URL that ends in\n * a slash. A path is resolved and encoded (`#`, `%`, spaces); a URL without the slash gets one.\n */\nfunction sourceCwd(options: GeneratorOptions): URL {\n const { cwd } = options;\n if (cwd instanceof URL) {\n return cwd.pathname.endsWith(\"/\") ? cwd : new URL(`${cwd.pathname}/`, cwd);\n }\n const directory = path.resolve(cwd === undefined ? process.cwd() : cwd.toString());\n return pathToFileURL(path.join(directory, path.sep));\n}\n\n/** The `$ref` limits of the options; a relative local root resolves against the cwd. */\nfunction refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n const localRoot =\n typeof localRefRoot === \"string\"\n ? pathToFileURL(path.resolve(fileURLToPath(cwd), localRefRoot))\n : localRefRoot;\n return {\n ...(localRoot === undefined ? {} : { localRoot }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteRefHosts }),\n };\n}\n\nfunction callbackOptions(options: GeneratorOptions) {\n return {\n irCallbacks: options.irCallbacks === true,\n postTransform: typeof options.postTransform === \"function\" ? options.postTransform : undefined,\n transform: typeof options.transform === \"function\" ? options.transform : undefined,\n transformProperty:\n typeof options.transformProperty === \"function\" ? options.transformProperty : undefined,\n };\n}\n\nfunction contextFlags(options: GeneratorOptions): ContextFlags {\n return {\n additionalProperties: options.additionalProperties ?? false,\n alphabetize: options.alphabetize ?? false,\n arrayLength: options.arrayLength ?? false,\n binaryAsBlob: options.binaryAsBlob ?? false,\n defaultNonNullable: options.defaultNonNullable ?? true,\n emptyObjectsUnknown: options.emptyObjectsUnknown ?? false,\n enum: options.enum ?? false,\n enumValues: options.enumValues ?? false,\n conditionalEnums: options.conditionalEnums ?? false,\n dedupeEnums: options.dedupeEnums ?? false,\n excludeDeprecated: options.excludeDeprecated ?? false,\n exportType: options.exportType ?? false,\n immutable: options.immutable ?? false,\n rootTypes: options.rootTypes ?? false,\n rootTypesNoSchemaPrefix: options.rootTypesNoSchemaPrefix ?? false,\n rootTypesKeepCasing: options.rootTypesKeepCasing ?? false,\n pathParamsAsTypes: options.pathParamsAsTypes ?? false,\n propertiesRequiredByDefault: options.propertiesRequiredByDefault ?? false,\n silent: options.silent ?? false,\n ...(options.inject === undefined ? {} : { inject: options.inject }),\n makePathsEnum: options.makePathsEnum ?? false,\n generatePathParams: options.generatePathParams ?? false,\n readWriteMarkers: options.readWriteMarkers ?? false,\n ...callbackOptions(options),\n };\n}\n\n/**\n * The fixes of the options, `all` expanded; fails with `OPTION_FIX_UNKNOWN` for another name.\n * A fix named without the option it needs is reported, since it changes nothing.\n */\nfunction outputFixesOf(options: GeneratorOptions, logger: Logger): readonly OutputFix[] {\n const names = outputFixNamesOf(options.fix ?? []);\n for (const notice of ineffectiveFixNotices(names, (option) => options[option] === true)) {\n logger.warn(notice);\n }\n return [...resolveOutputFixes(names)];\n}\n\n/** The warnings about the loaded document itself, before it is transformed. */\nfunction warnAboutDocument(schema: OpenAPI3, fix: readonly OutputFix[], logger: Logger): void {\n withStackOverflowReported(\"transform\", () => warnUnsupportedFeatures(schema, logger));\n withStackOverflowReported(\"transform\", () =>\n warnDiscriminatorValueConflicts(schema, fix, logger),\n );\n warnIdenticalPathTemplates(schema, logger);\n}\n\n/**\n * Load the source through the ports, then build the run's context from the options. The fix names\n * are checked first, so a typo fails before the document is read.\n */\nexport async function createDocumentRun(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<DocumentRun> {\n if (!source) {\n throw sourceEmptyError(\"Empty schema. Please specify a URL, file path, or Redocly Config\");\n }\n const { logger } = ports;\n const fix = outputFixesOf(options, logger);\n const silent = options.silent ?? false;\n const cwd = sourceCwd(options);\n const schema = await ports.loader.load({\n source,\n cwd,\n shouldLint: options.lint ?? true,\n refAccess: refAccessOf(options, cwd),\n });\n warnAboutDocument(schema, fix, logger);\n const ctx: GlobalContext = {\n ...contextFlags(options),\n fix,\n // The scan walks every schema before the transform does, so on a larger stack, where loading\n // passed, it is the first step to run out.\n discriminators: withStackOverflowReported(\"transform\", () =>\n findDiscriminators(schema, {\n silent,\n logger,\n fixes: new Set(fix),\n }),\n ),\n injectFooter: [],\n redoc: ports.redoc,\n resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),\n logger,\n };\n return { schema, ctx };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqDA,SAAS,UAAU,OAAA,EAAgC;AACjD,EAAA,MAAM,EAAE,KAAI,GAAI,OAAA;AAChB,EAAA,IAAI,eAAe,GAAA,EAAK;AACtB,IAAA,OAAO,GAAA,CAAI,QAAA,CAAS,QAAA,CAAS,GAAG,CAAA,GAAI,GAAA,GAAM,IAAI,GAAA,CAAI,CAAA,EAAG,GAAA,CAAI,QAAQ,CAAA,CAAA,CAAA,EAAK,GAAG,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,GAAA,KAAQ,MAAA,GAAY,QAAQ,GAAA,EAAI,GAAI,GAAA,CAAI,QAAA,EAAU,CAAA;AACjF,EAAA,OAAO,cAAc,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,IAAA,CAAK,GAAG,CAAC,CAAA;AACrD;AAGA,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AACnE,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,MAAM,SAAA,GACJ,OAAO,YAAA,KAAiB,QAAA,GACpB,aAAA,CAAc,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,GAAG,CAAA,EAAG,YAAY,CAAC,CAAA,GAC5D,YAAA;AACN,EAAA,OAAO;AAAA,IACL,GAAI,SAAA,KAAc,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAU;AAAA,IAC/C,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,aAAa,cAAA;AAAe,GACxE;AACF;AAEA,SAAS,gBAAgB,OAAA,EAA2B;AAClD,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,QAAQ,WAAA,KAAgB,IAAA;AAAA,IACrC,eAA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AA,MAAM,EAAE,QAAO,GAAI,KAAA;AACnB,EAAA,MAAM,GAAA,GAAM,aAAA,CAAc,OAAA,EAAS,MAAM,CAAA;AACzC,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,KAAA;AACjC,EAAA,MAAM,GAAA,GAAM,UAAU,OAAO,CAAA;AAC7B,EAAA,MAAM,MAAA,GAAS,MAAM,KAAA,CAAM,MAAA,CAAO,IAAA,CAAK;AAAA,IACrC,MAAA;AAAA,IACA,GAAA;AAAA,IACA,UAAA,EAAY,QAAQ,IAAA,IAAQ,IAAA;AAAA,IAC5B,SAAA,EAAW,WAAA,CAAY,OAAA,EAAS,GAAG;AAAA,GACpC,CAAA;AACD,EAAA,iBAAA,CAAkB,MAAA,EAAQ,KAAK,MAAM,CAAA;AACrC,EAAA,MAAM,GAAA,GAAqB;AAAA,IACzB,GAAG,aAAa,OAAO,CAAA;AAAA,IACvB,GAAA;AAAA;AAAA;AAAA,IAGA,cAAA,EAAgB,yBAAA;AAAA,MAA0B,WAAA;AAAA,MAAa,MACrD,mBAAmB,MAAA,EAAQ;AAAA,QACzB,MAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,IAAI,GAAA,CAAI,GAAG;AAAA,OACnB;AAAA,KACH;AAAA,IACA,cAAc,EAAC;AAAA,IACf,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,OAAA,EAAS,CAAC,IAAA,KAAS,kBAAA,CAAmB,QAAQ,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACtE;AAAA,GACF;AACA,EAAA,OAAO,EAAE,QAAQ,GAAA,EAAI;AACvB;;"}
|
|
1
|
+
{"version":3,"file":"document-run.mjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport { sourceEmptyError } from \"../adapters/redocly-loader/schema-load-errors.js\";\nimport type { DeprecationReporter } from \"../application/ports/deprecation-reporter.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport type { RefAccess, SchemaLoader } from \"../application/ports/schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport {\n ineffectiveFixNotices,\n type OutputFix,\n outputFixNamesOf,\n resolveOutputFixes,\n} from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport type { GeneratorOptions, OpenAPI3, SchemaSource } from \"../types.js\";\nimport { processCwd } from \"./default-ports.js\";\nimport { warnDiscriminatorValueConflicts } from \"./discriminator-conflict-warnings.js\";\nimport { findDiscriminators } from \"./discriminator-scan.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\nimport { warnIdenticalPathTemplates } from \"./path-template-warnings.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { warnUnsupportedFeatures } from \"./unsupported-feature-warnings.js\";\n\n/** The ports of one generator run, wired by the Node API or the CLI (ENGINEERING_PLAN 4.5). */\nexport interface GeneratorPorts {\n readonly loader: SchemaLoader;\n readonly logger: Logger;\n /** Where the run reports the deprecated callback forms (ADR-004). */\n readonly deprecations: DeprecationReporter;\n /** The Redocly config the loader uses; the run's context exposes it as `ctx.redoc`. */\n readonly redoc: RedoclyConfig;\n /** A monotonic time in milliseconds, for debug durations. */\n readonly now: () => number;\n}\n\n/** A validated, bundled document and the context of one generator run. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly ctx: RunContext;\n}\n\n/** The context fields that are user flags, with the original defaults. */\ntype ContextFlags = Omit<\n RunContext,\n | \"discriminators\"\n | \"injectFooter\"\n | \"redoc\"\n | \"resolve\"\n | \"runFooter\"\n | \"legacyCallbackWarnings\"\n | \"logger\"\n | \"deprecations\"\n | \"fix\"\n>;\n\n/**\n * The directory that relative `$ref`s of an inline source resolve against, as a URL that ends in\n * a slash. A path is resolved and encoded (`#`, `%`, spaces); a URL without the slash gets one.\n */\nfunction sourceCwd(options: GeneratorOptions): URL {\n const { cwd } = options;\n if (cwd instanceof URL) {\n return cwd.pathname.endsWith(\"/\") ? cwd : new URL(`${cwd.pathname}/`, cwd);\n }\n const directory = path.resolve(cwd === undefined ? processCwd() : cwd.toString());\n return pathToFileURL(path.join(directory, path.sep));\n}\n\n/** The `$ref` limits of the options; a relative local root resolves against the cwd. */\nfunction refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n const localRoot =\n typeof localRefRoot === \"string\"\n ? pathToFileURL(path.resolve(fileURLToPath(cwd), localRefRoot))\n : localRefRoot;\n return {\n ...(localRoot === undefined ? {} : { localRoot }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteRefHosts }),\n };\n}\n\nfunction callbackOptions(options: GeneratorOptions) {\n return {\n irCallbacks: options.irCallbacks === true,\n postTransform: typeof options.postTransform === \"function\" ? options.postTransform : undefined,\n transform: typeof options.transform === \"function\" ? options.transform : undefined,\n transformProperty:\n typeof options.transformProperty === \"function\" ? options.transformProperty : undefined,\n };\n}\n\nfunction contextFlags(options: GeneratorOptions): ContextFlags {\n return {\n additionalProperties: options.additionalProperties ?? false,\n alphabetize: options.alphabetize ?? false,\n arrayLength: options.arrayLength ?? false,\n binaryAsBlob: options.binaryAsBlob ?? false,\n defaultNonNullable: options.defaultNonNullable ?? true,\n emptyObjectsUnknown: options.emptyObjectsUnknown ?? false,\n enum: options.enum ?? false,\n enumValues: options.enumValues ?? false,\n conditionalEnums: options.conditionalEnums ?? false,\n dedupeEnums: options.dedupeEnums ?? false,\n excludeDeprecated: options.excludeDeprecated ?? false,\n exportType: options.exportType ?? false,\n immutable: options.immutable ?? false,\n rootTypes: options.rootTypes ?? false,\n rootTypesNoSchemaPrefix: options.rootTypesNoSchemaPrefix ?? false,\n rootTypesKeepCasing: options.rootTypesKeepCasing ?? false,\n pathParamsAsTypes: options.pathParamsAsTypes ?? false,\n propertiesRequiredByDefault: options.propertiesRequiredByDefault ?? false,\n silent: options.silent ?? false,\n ...(options.inject === undefined ? {} : { inject: options.inject }),\n makePathsEnum: options.makePathsEnum ?? false,\n generatePathParams: options.generatePathParams ?? false,\n readWriteMarkers: options.readWriteMarkers ?? false,\n ...callbackOptions(options),\n };\n}\n\n/**\n * The fixes of the options, `all` expanded; fails with `OPTION_FIX_UNKNOWN` for another name.\n * A fix named without the option it needs is reported, since it changes nothing.\n */\nfunction outputFixesOf(options: GeneratorOptions, logger: Logger): readonly OutputFix[] {\n const names = outputFixNamesOf(options.fix ?? []);\n for (const notice of ineffectiveFixNotices(names, (option) => options[option] === true)) {\n logger.warn(warningText(notice, WARNING_CODES.FIX_NEEDS_OPTION));\n }\n return [...resolveOutputFixes(names)];\n}\n\n/** The warnings about the loaded document itself, before it is transformed. */\nfunction warnAboutDocument(schema: OpenAPI3, fix: readonly OutputFix[], logger: Logger): void {\n withStackOverflowReported(\"transform\", () => warnUnsupportedFeatures(schema, logger));\n withStackOverflowReported(\"transform\", () =>\n warnDiscriminatorValueConflicts(schema, fix, logger),\n );\n warnIdenticalPathTemplates(schema, logger);\n}\n\n/**\n * Load the source through the ports, then build the run's context from the options. The fix names\n * are checked first, so a typo fails before the document is read.\n */\nexport async function createDocumentRun(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<DocumentRun> {\n if (!source) {\n throw sourceEmptyError(\"Empty schema. Please specify a URL, file path, or Redocly Config\");\n }\n const { logger } = ports;\n const fix = outputFixesOf(options, logger);\n const silent = options.silent ?? false;\n const cwd = sourceCwd(options);\n const schema = await ports.loader.load({\n source,\n cwd,\n shouldLint: options.lint ?? true,\n refAccess: refAccessOf(options, cwd),\n });\n warnAboutDocument(schema, fix, logger);\n const ctx: RunContext = {\n ...contextFlags(options),\n fix,\n // The scan walks every schema before the transform does, so on a larger stack, where loading\n // passed, it is the first step to run out.\n discriminators: withStackOverflowReported(\"transform\", () =>\n findDiscriminators(schema, {\n silent,\n logger,\n fixes: new Set(fix),\n }),\n ),\n injectFooter: [],\n redoc: ports.redoc,\n resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),\n logger,\n deprecations: ports.deprecations,\n };\n return { schema, ctx };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA4DA,SAAS,UAAU,OAAA,EAAgC;AACjD,EAAA,MAAM,EAAE,KAAI,GAAI,OAAA;AAChB,EAAA,IAAI,eAAe,GAAA,EAAK;AACtB,IAAA,OAAO,GAAA,CAAI,QAAA,CAAS,QAAA,CAAS,GAAG,CAAA,GAAI,GAAA,GAAM,IAAI,GAAA,CAAI,CAAA,EAAG,GAAA,CAAI,QAAQ,CAAA,CAAA,CAAA,EAAK,GAAG,CAAA;AAAA,EAC3E;AACA,EAAA,MAAM,SAAA,GAAY,KAAK,OAAA,CAAQ,GAAA,KAAQ,SAAY,UAAA,EAAW,GAAI,GAAA,CAAI,QAAA,EAAU,CAAA;AAChF,EAAA,OAAO,cAAc,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,IAAA,CAAK,GAAG,CAAC,CAAA;AACrD;AAGA,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AACnE,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,MAAM,SAAA,GACJ,OAAO,YAAA,KAAiB,QAAA,GACpB,aAAA,CAAc,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,GAAG,CAAA,EAAG,YAAY,CAAC,CAAA,GAC5D,YAAA;AACN,EAAA,OAAO;AAAA,IACL,GAAI,SAAA,KAAc,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAU;AAAA,IAC/C,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,aAAa,cAAA;AAAe,GACxE;AACF;AAEA,SAAS,gBAAgB,OAAA,EAA2B;AAClD,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,QAAQ,WAAA,KAAgB,IAAA;AAAA,IACrC,eAAe,OAAO,O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|
class ContextFooterSink {
|
|
9
9
|
footer;
|
|
10
|
+
/**
|
|
11
|
+
* The IR `operations` entry this sink wrote last, with its members array that only this sink
|
|
12
|
+
* holds. Adding to it in place keeps a run linear: copying the members on every operation was
|
|
13
|
+
* quadratic (about 0.4 s on Microsoft Graph beta).
|
|
14
|
+
*/
|
|
15
|
+
owned = null;
|
|
10
16
|
constructor(footer) {
|
|
11
17
|
this.footer = footer;
|
|
12
18
|
}
|
|
@@ -22,6 +28,11 @@ class ContextFooterSink {
|
|
|
22
28
|
* the member in place, as in the original.
|
|
23
29
|
*/
|
|
24
30
|
addOperation(build) {
|
|
31
|
+
const owned = this.currentOwnedOperations();
|
|
32
|
+
if (owned !== null) {
|
|
33
|
+
owned.members.push(build());
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
25
36
|
const existing = this.findOperations();
|
|
26
37
|
if (existing !== null && !footerEntry.isIrDeclaration(existing.entry)) {
|
|
27
38
|
const ts = loadTypescript.loadTypeScript();
|
|
@@ -32,9 +43,21 @@ class ContextFooterSink {
|
|
|
32
43
|
return;
|
|
33
44
|
}
|
|
34
45
|
const index = existing?.index ?? this.footer.push(emptyOperations()) - 1;
|
|
35
|
-
|
|
46
|
+
this.takeOwnership(index).members.push(build());
|
|
47
|
+
}
|
|
48
|
+
/** The owned entry, unless user code replaced or moved it in the footer since. */
|
|
49
|
+
currentOwnedOperations() {
|
|
50
|
+
const owned = this.owned;
|
|
51
|
+
return owned !== null && this.footer[owned.index] === owned.entry ? owned : null;
|
|
52
|
+
}
|
|
53
|
+
/** Replace the IR entry at `index` with a copy whose members array only this sink holds. */
|
|
54
|
+
takeOwnership(index) {
|
|
36
55
|
const operations = this.footer[index];
|
|
37
|
-
|
|
56
|
+
const members = [...operations.members];
|
|
57
|
+
const entry = { ...operations, members };
|
|
58
|
+
this.footer[index] = entry;
|
|
59
|
+
this.owned = { entry, members, index };
|
|
60
|
+
return this.owned;
|
|
38
61
|
}
|
|
39
62
|
/** The first `operations` interface: the generator's (IR) or a user's (TypeScript). */
|
|
40
63
|
findOperations() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer-sink.cjs","sources":["../../src/api/footer-sink.ts"],"sourcesContent":["import { appendMember, asInterfaceNamed } from \"../adapters/type-ast-bridge/footer-nodes.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { FooterSink } from \"../application/transform/footer/document-footer.js\";\nimport type {\n IrDeclaration,\n IrInterfaceDeclaration,\n IrPropertySignature,\n} from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/**\n * The footer of a run is its `ctx.injectFooter` list. The generator adds IR declarations; user\n * code may add IR declarations or TypeScript nodes (ENGINEERING_PLAN 6.2).\n */\nexport class ContextFooterSink implements FooterSink {\n private readonly footer: FooterEntry[];\n\n constructor(footer: FooterEntry[]) {\n this.footer = footer;\n }\n\n hasTypeAlias(name: string): boolean {\n return this.footer.some((entry) => declaresTypeAlias(entry, name));\n }\n\n add(declaration: IrDeclaration): void {\n this.footer.push(declaration);\n }\n\n /**\n * Add a member to the `operations` interface, declared first (exported) when missing, so it\n * comes before any declaration `build` adds. A user's TypeScript `operations` interface gets\n * the member in place, as in the original.\n */\n addOperation(build: () => IrPropertySignature): void {\n const existing = this.findOperations();\n if (existing !== null && !isIrDeclaration(existing.entry)) {\n const ts = loadTypeScript();\n const node = asInterfaceNamed(ts, existing.entry, OPERATIONS_NAME);\n if (node) {\n appendMember(ts, node, build());\n }\n return;\n }\n const index = existing?.index ?? this.footer.push(emptyOperations()) - 1;\n const
|
|
1
|
+
{"version":3,"file":"footer-sink.cjs","sources":["../../src/api/footer-sink.ts"],"sourcesContent":["import { appendMember, asInterfaceNamed } from \"../adapters/type-ast-bridge/footer-nodes.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { FooterSink } from \"../application/transform/footer/document-footer.js\";\nimport type {\n IrDeclaration,\n IrInterfaceDeclaration,\n IrMember,\n IrPropertySignature,\n} from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/**\n * The footer of a run is its `ctx.injectFooter` list. The generator adds IR declarations; user\n * code may add IR declarations or TypeScript nodes (ENGINEERING_PLAN 6.2).\n */\nexport class ContextFooterSink implements FooterSink {\n private readonly footer: FooterEntry[];\n /**\n * The IR `operations` entry this sink wrote last, with its members array that only this sink\n * holds. Adding to it in place keeps a run linear: copying the members on every operation was\n * quadratic (about 0.4 s on Microsoft Graph beta).\n */\n private owned: OwnedOperations | null = null;\n\n constructor(footer: FooterEntry[]) {\n this.footer = footer;\n }\n\n hasTypeAlias(name: string): boolean {\n return this.footer.some((entry) => declaresTypeAlias(entry, name));\n }\n\n add(declaration: IrDeclaration): void {\n this.footer.push(declaration);\n }\n\n /**\n * Add a member to the `operations` interface, declared first (exported) when missing, so it\n * comes before any declaration `build` adds. A user's TypeScript `operations` interface gets\n * the member in place, as in the original.\n */\n addOperation(build: () => IrPropertySignature): void {\n const owned = this.currentOwnedOperations();\n if (owned !== null) {\n owned.members.push(build());\n return;\n }\n const existing = this.findOperations();\n if (existing !== null && !isIrDeclaration(existing.entry)) {\n const ts = loadTypeScript();\n const node = asInterfaceNamed(ts, existing.entry, OPERATIONS_NAME);\n if (node) {\n appendMember(ts, node, build());\n }\n return;\n }\n const index = existing?.index ?? this.footer.push(emptyOperations()) - 1;\n this.takeOwnership(index).members.push(build());\n }\n\n /** The owned entry, unless user code replaced or moved it in the footer since. */\n private currentOwnedOperations(): OwnedOperations | null {\n const owned = this.owned;\n return owned !== null && this.footer[owned.index] === owned.entry ? owned : null;\n }\n\n /** Replace the IR entry at `index` with a copy whose members array only this sink holds. */\n private takeOwnership(index: number): OwnedOperations {\n const operations = this.footer[index] as IrInterfaceDeclaration;\n const members: IrMember[] = [...operations.members];\n const entry: IrInterfaceDeclaration = { ...operations, members };\n this.footer[index] = entry;\n this.owned = { entry, members, index };\n return this.owned;\n }\n\n /** The first `operations` interface: the generator's (IR) or a user's (TypeScript). */\n private findOperations(): { entry: FooterEntry; index: number } | null {\n const index = this.footer.findIndex((entry) =>\n isIrDeclaration(entry)\n ? entry.kind === \"interface\" && entry.name === OPERATIONS_NAME\n : asInterfaceNamed(loadTypeScript(), entry, OPERATIONS_NAME) !== null,\n );\n const entry = this.footer[index];\n return entry === undefined ? null : { entry, index };\n }\n}\n\ninterface OwnedOperations {\n readonly entry: IrInterfaceDeclaration;\n readonly members: IrMember[];\n readonly index: number;\n}\n\nfunction emptyOperations(): IrInterfaceDeclaration {\n return { kind: \"interface\", name: OPERATIONS_NAME, isExported: true, members: [], comments: [] };\n}\n"],"names":["declaresTypeAlias","isIrDeclaration","loadTypeScript","asInterfaceNamed","appendMember","entry"],"mappings":";;;;;;AAWA,MAAM,eAAA,GAAkB,YAAA;AAMjB,MAAM,iBAAA,CAAwC;AAAA,EAClC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,KAAA,GAAgC,IAAA;AAAA,EAExC,YAAY,MAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,aAAa,IAAA,EAAuB;AAClC,IAAA,OAAO,IAAA,CAAK,OAAO,IAAA,CAAK,CAAC,UAAUA,6BAAA,CAAkB,KAAA,EAAO,IAAI,CAAC,CAAA;AAAA,EACnE;AAAA,EAEA,IAAI,WAAA,EAAkC;AACpC,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,WAAW,CAAA;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,KAAA,EAAwC;AACnD,IAAA,MAAM,KAAA,GAAQ,KAAK,sBAAA,EAAuB;AAC1C,IAAA,IAAI,UAAU,IAAA,EAAM;AAClB,MAAA,KAAA,C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EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAM;AACrC,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA;AAAA,EAGQ,cAAA,GAA+D;AACrE,IAAA,MAAM,KAAA,GAAQ,KAAK,MAAA,CAAO,SAAA;AAAA,MAAU,CAACC,MAAAA,KACnCJ,2BAAA,CAAgBI,MAAK,CAAA,GACjBA,OAAM,IAAA,KAAS,WAAA,IAAeA,MAAAA,CAAM,IAAA,KAAS,kBAC7CF,4BAAA,CAAiBD,6BAAA,EAAe,EAAGG,MAAAA,EAAO,eAAe,CAAA,KAAM;AAAA,KACrE;AACA,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA;AAC/B,IAAA,OAAO,KAAA,KAAU,MAAA,GAAY,IAAA,GAAO,EAAE,OAAO,KAAA,EAAM;AAAA,EACrD;AACF;AAQA,SAAS,eAAA,GAA0C;AACjD,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,eAAA,EAAiB,UAAA,EAAY,IAAA,EAAM,OAAA,EAAS,EAAC,EAAG,QAAA,EAAU,EAAC,EAAE;AACjG;;"}
|
package/dist/api/footer-sink.mjs
CHANGED
|
@@ -5,6 +5,12 @@ import { declaresTypeAlias, isIrDeclaration } from './footer-entry.mjs';
|
|
|
5
5
|
const OPERATIONS_NAME = "operations";
|
|
6
6
|
class ContextFooterSink {
|
|
7
7
|
footer;
|
|
8
|
+
/**
|
|
9
|
+
* The IR `operations` entry this sink wrote last, with its members array that only this sink
|
|
10
|
+
* holds. Adding to it in place keeps a run linear: copying the members on every operation was
|
|
11
|
+
* quadratic (about 0.4 s on Microsoft Graph beta).
|
|
12
|
+
*/
|
|
13
|
+
owned = null;
|
|
8
14
|
constructor(footer) {
|
|
9
15
|
this.footer = footer;
|
|
10
16
|
}
|
|
@@ -20,6 +26,11 @@ class ContextFooterSink {
|
|
|
20
26
|
* the member in place, as in the original.
|
|
21
27
|
*/
|
|
22
28
|
addOperation(build) {
|
|
29
|
+
const owned = this.currentOwnedOperations();
|
|
30
|
+
if (owned !== null) {
|
|
31
|
+
owned.members.push(build());
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
23
34
|
const existing = this.findOperations();
|
|
24
35
|
if (existing !== null && !isIrDeclaration(existing.entry)) {
|
|
25
36
|
const ts = loadTypeScript();
|
|
@@ -30,9 +41,21 @@ class ContextFooterSink {
|
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
32
43
|
const index = existing?.index ?? this.footer.push(emptyOperations()) - 1;
|
|
33
|
-
|
|
44
|
+
this.takeOwnership(index).members.push(build());
|
|
45
|
+
}
|
|
46
|
+
/** The owned entry, unless user code replaced or moved it in the footer since. */
|
|
47
|
+
currentOwnedOperations() {
|
|
48
|
+
const owned = this.owned;
|
|
49
|
+
return owned !== null && this.footer[owned.index] === owned.entry ? owned : null;
|
|
50
|
+
}
|
|
51
|
+
/** Replace the IR entry at `index` with a copy whose members array only this sink holds. */
|
|
52
|
+
takeOwnership(index) {
|
|
34
53
|
const operations = this.footer[index];
|
|
35
|
-
|
|
54
|
+
const members = [...operations.members];
|
|
55
|
+
const entry = { ...operations, members };
|
|
56
|
+
this.footer[index] = entry;
|
|
57
|
+
this.owned = { entry, members, index };
|
|
58
|
+
return this.owned;
|
|
36
59
|
}
|
|
37
60
|
/** The first `operations` interface: the generator's (IR) or a user's (TypeScript). */
|
|
38
61
|
findOperations() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer-sink.mjs","sources":["../../src/api/footer-sink.ts"],"sourcesContent":["import { appendMember, asInterfaceNamed } from \"../adapters/type-ast-bridge/footer-nodes.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { FooterSink } from \"../application/transform/footer/document-footer.js\";\nimport type {\n IrDeclaration,\n IrInterfaceDeclaration,\n IrPropertySignature,\n} from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/**\n * The footer of a run is its `ctx.injectFooter` list. The generator adds IR declarations; user\n * code may add IR declarations or TypeScript nodes (ENGINEERING_PLAN 6.2).\n */\nexport class ContextFooterSink implements FooterSink {\n private readonly footer: FooterEntry[];\n\n constructor(footer: FooterEntry[]) {\n this.footer = footer;\n }\n\n hasTypeAlias(name: string): boolean {\n return this.footer.some((entry) => declaresTypeAlias(entry, name));\n }\n\n add(declaration: IrDeclaration): void {\n this.footer.push(declaration);\n }\n\n /**\n * Add a member to the `operations` interface, declared first (exported) when missing, so it\n * comes before any declaration `build` adds. A user's TypeScript `operations` interface gets\n * the member in place, as in the original.\n */\n addOperation(build: () => IrPropertySignature): void {\n const existing = this.findOperations();\n if (existing !== null && !isIrDeclaration(existing.entry)) {\n const ts = loadTypeScript();\n const node = asInterfaceNamed(ts, existing.entry, OPERATIONS_NAME);\n if (node) {\n appendMember(ts, node, build());\n }\n return;\n }\n const index = existing?.index ?? this.footer.push(emptyOperations()) - 1;\n const
|
|
1
|
+
{"version":3,"file":"footer-sink.mjs","sources":["../../src/api/footer-sink.ts"],"sourcesContent":["import { appendMember, asInterfaceNamed } from \"../adapters/type-ast-bridge/footer-nodes.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { FooterSink } from \"../application/transform/footer/document-footer.js\";\nimport type {\n IrDeclaration,\n IrInterfaceDeclaration,\n IrMember,\n IrPropertySignature,\n} from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/**\n * The footer of a run is its `ctx.injectFooter` list. The generator adds IR declarations; user\n * code may add IR declarations or TypeScript nodes (ENGINEERING_PLAN 6.2).\n */\nexport class ContextFooterSink implements FooterSink {\n private readonly footer: FooterEntry[];\n /**\n * The IR `operations` entry this sink wrote last, with its members array that only this sink\n * holds. Adding to it in place keeps a run linear: copying the members on every operation was\n * quadratic (about 0.4 s on Microsoft Graph beta).\n */\n private owned: OwnedOperations | null = null;\n\n constructor(footer: FooterEntry[]) {\n this.footer = footer;\n }\n\n hasTypeAlias(name: string): boolean {\n return this.footer.some((entry) => declaresTypeAlias(entry, name));\n }\n\n add(declaration: IrDeclaration): void {\n this.footer.push(declaration);\n }\n\n /**\n * Add a member to the `operations` interface, declared first (exported) when missing, so it\n * comes before any declaration `build` adds. A user's TypeScript `operations` interface gets\n * the member in place, as in the original.\n */\n addOperation(build: () => IrPropertySignature): void {\n const owned = this.currentOwnedOperations();\n if (owned !== null) {\n owned.members.push(build());\n return;\n }\n const existing = this.findOperations();\n if (existing !== null && !isIrDeclaration(existing.entry)) {\n const ts = loadTypeScript();\n const node = asInterfaceNamed(ts, existing.entry, OPERATIONS_NAME);\n if (node) {\n appendMember(ts, node, build());\n }\n return;\n }\n const index = existing?.index ?? this.footer.push(emptyOperations()) - 1;\n this.takeOwnership(index).members.push(build());\n }\n\n /** The owned entry, unless user code replaced or moved it in the footer since. */\n private currentOwnedOperations(): OwnedOperations | null {\n const owned = this.owned;\n return owned !== null && this.footer[owned.index] === owned.entry ? owned : null;\n }\n\n /** Replace the IR entry at `index` with a copy whose members array only this sink holds. */\n private takeOwnership(index: number): OwnedOperations {\n const operations = this.footer[index] as IrInterfaceDeclaration;\n const members: IrMember[] = [...operations.members];\n const entry: IrInterfaceDeclaration = { ...operations, members };\n this.footer[index] = entry;\n this.owned = { entry, members, index };\n return this.owned;\n }\n\n /** The first `operations` interface: the generator's (IR) or a user's (TypeScript). */\n private findOperations(): { entry: FooterEntry; index: number } | null {\n const index = this.footer.findIndex((entry) =>\n isIrDeclaration(entry)\n ? entry.kind === \"interface\" && entry.name === OPERATIONS_NAME\n : asInterfaceNamed(loadTypeScript(), entry, OPERATIONS_NAME) !== null,\n );\n const entry = this.footer[index];\n return entry === undefined ? null : { entry, index };\n }\n}\n\ninterface OwnedOperations {\n readonly entry: IrInterfaceDeclaration;\n readonly members: IrMember[];\n readonly index: number;\n}\n\nfunction emptyOperations(): IrInterfaceDeclaration {\n return { kind: \"interface\", name: OPERATIONS_NAME, isExported: true, members: [], comments: [] };\n}\n"],"names":["entry"],"mappings":";;;;AAWA,MAAM,eAAA,GAAkB,YAAA;AAMjB,MAAM,iBAAA,CAAwC;AAAA,EAClC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,KAAA,GAAgC,IAAA;AAAA,EAExC,YAAY,MAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,aAAa,IAAA,EAAuB;AAClC,IAAA,OAAO,IAAA,CAAK,OAAO,IAAA,CAAK,CAAC,UAAU,iBAAA,CAAkB,KAAA,EAAO,IAAI,CAAC,CAAA;AAAA,EACnE;AAAA,EAEA,IAAI,WAAA,EAAkC;AACpC,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,WAAW,CAAA;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,KAAA,EAAwC;AACnD,IAAA,MAAM,KAAA,GAAQ,KAAK,sBAAA,EAAuB;AAC1C,IAAA,IAAI,UAAU,IAAA,EAAM;AAClB,MAAA,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,KAAA,EAAO,CAAA;AAC1B,MAAA;AAAA,IACF;AACA,IAAA,MAAM,QAAA,GAAW,KAAK,cAAA,EAAe;AACrC,IAAA,IAAI,aAAa,IAAA,IAAQ,CAAC,eAAA,CAAgB,QAAA,CAAS,KAAK,CAAA,EAAG;AACzD,MAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,MAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,EAAA,EAAI,QAAA,CAAS,OAAO,eAAe,CAAA;AACjE,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,YAAA,CAAa,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,CAAA;AAA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O,KAAK,CAAA;AAC/B,IAAA,OAAO,KAAA,KAAU,MAAA,GAAY,IAAA,GAAO,EAAE,OAAO,KAAA,EAAM;AAAA,EACrD;AACF;AAQA,SAAS,eAAA,GAA0C;AACjD,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,eAAA,EAAiB,UAAA,EAAY,IAAA,EAAM,OAAA,EAAS,EAAC,EAAG,QAAA,EAAU,EAAC,EAAE;AACjG;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const deprecations = require('../domain/deprecations.cjs');
|
|
3
4
|
const defaultPorts = require('./default-ports.cjs');
|
|
4
5
|
|
|
5
6
|
const IR_CALLBACKS_GUIDE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks";
|
|
@@ -8,6 +9,11 @@ const USES = {
|
|
|
8
9
|
postTransform: "`postTransform` receives TypeScript nodes",
|
|
9
10
|
transformProperty: "`transformProperty` receives TypeScript nodes"
|
|
10
11
|
};
|
|
12
|
+
const CODES = {
|
|
13
|
+
transform: deprecations.DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM,
|
|
14
|
+
postTransform: deprecations.DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM,
|
|
15
|
+
transformProperty: deprecations.DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY
|
|
16
|
+
};
|
|
11
17
|
function message(name) {
|
|
12
18
|
return `${USES[name]}. This form works in 1.x through the TypeScript bridge and is removed in 2.0. Use irCallbacks: true and return IR or type text instead: ${IR_CALLBACKS_GUIDE_URL}`;
|
|
13
19
|
}
|
|
@@ -17,7 +23,7 @@ function warnLegacyCallback(ctx, name) {
|
|
|
17
23
|
return;
|
|
18
24
|
}
|
|
19
25
|
ctx.legacyCallbackWarnings.add(name);
|
|
20
|
-
(ctx.
|
|
26
|
+
(ctx.deprecations ?? defaultPorts.defaultDeprecationReporter()).report(CODES[name], message(name));
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
exports.IR_CALLBACKS_GUIDE_URL = IR_CALLBACKS_GUIDE_URL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-callback-warning.cjs","sources":["../../src/api/legacy-callback-warning.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"legacy-callback-warning.cjs","sources":["../../src/api/legacy-callback-warning.ts"],"sourcesContent":["import { DEPRECATION_CODES, type DeprecationCode } from \"../domain/deprecations.js\";\nimport type { LegacyCallbackName } from \"../types.js\";\nimport { defaultDeprecationReporter } from \"./default-ports.js\";\nimport type { RunContext } from \"./run-context.js\";\n\n/** Where the IR callbacks are documented; the warning points users there. */\nexport const IR_CALLBACKS_GUIDE_URL =\n \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks\";\n\nconst USES: Readonly<Record<LegacyCallbackName, string>> = {\n transform: \"`transform` returned a TypeScript node\",\n postTransform: \"`postTransform` receives TypeScript nodes\",\n transformProperty: \"`transformProperty` receives TypeScript nodes\",\n};\n\nconst CODES: Readonly<Record<LegacyCallbackName, DeprecationCode>> = {\n transform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM,\n postTransform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM,\n transformProperty: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY,\n};\n\nfunction message(name: LegacyCallbackName): string {\n return (\n `${USES[name]}. This form works in 1.x through the TypeScript bridge and is removed in 2.0. ` +\n `Use irCallbacks: true and return IR or type text instead: ${IR_CALLBACKS_GUIDE_URL}`\n );\n}\n\n/**\n * Report a deprecated callback form once per run and callback, as a deprecation (not through the\n * logger, so `silent` does not hide it). The Node.js reporter shows each code once per process.\n */\nexport function warnLegacyCallback(ctx: RunContext, name: LegacyCallbackName): void {\n ctx.legacyCallbackWarnings ??= new Set();\n if (ctx.legacyCallbackWarnings.has(name)) {\n return;\n }\n ctx.legacyCallbackWarnings.add(name);\n (ctx.deprecations ?? defaultDeprecationReporter()).report(CODES[name], message(name));\n}\n"],"names":["DEPRECATION_CODES","defaultDeprecationReporter"],"mappings":";;;;;AAMO,MAAM,sBAAA,GACX;AAEF,MAAM,IAAA,GAAqD;AAAA,EACzD,SAAA,EAAW,wCAAA;AAAA,EACX,aAAA,EAAe,2CAAA;AAAA,EACf,iBAAA,EAAmB;AACrB,CAAA;AAEA,MAAM,KAAA,GAA+D;AAAA,EACnE,WAAWA,8BAAA,CAAkB,iCAAA;AAAA,EAC7B,eAAeA,8BAAA,CAAkB,sCAAA;AAAA,EACjC,mBAAmBA,8BAAA,CAAkB;AACvC,CAAA;AAEA,SAAS,QAAQ,IAAA,EAAkC;AACjD,EAAA,OACE,CAAA,EAAG,IAAA,CAAK,IAAI,CAAC,2IACgD,sBAAsB,CAAA,CAAA;AAEvF;AAMO,SAAS,kBAAA,CAAmB,KAAiB,IAAA,EAAgC;AAClF,EAAA,GAAA,CAAI,sBAAA,yBAA+B,GAAA,EAAI;AACvC,EAAA,IAAI,GAAA,CAAI,sBAAA,CAAuB,GAAA,CAAI,IAAI,CAAA,EAAG;AACxC,IAAA;AAAA,EACF;AACA,EAAA,GAAA,CAAI,sBAAA,CAAuB,IAAI,IAAI,CAAA;AACnC,EAAA,CAAC,GAAA,CAAI,YAAA,IAAgBC,uCAAA,EAA2B,EAAG,MAAA,CAAO,MAAM,IAAI,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAC,CAAA;AACtF;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEPRECATION_CODES } from '../domain/deprecations.mjs';
|
|
2
|
+
import { defaultDeprecationReporter } from './default-ports.mjs';
|
|
2
3
|
|
|
3
4
|
const IR_CALLBACKS_GUIDE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks";
|
|
4
5
|
const USES = {
|
|
@@ -6,6 +7,11 @@ const USES = {
|
|
|
6
7
|
postTransform: "`postTransform` receives TypeScript nodes",
|
|
7
8
|
transformProperty: "`transformProperty` receives TypeScript nodes"
|
|
8
9
|
};
|
|
10
|
+
const CODES = {
|
|
11
|
+
transform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM,
|
|
12
|
+
postTransform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM,
|
|
13
|
+
transformProperty: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY
|
|
14
|
+
};
|
|
9
15
|
function message(name) {
|
|
10
16
|
return `${USES[name]}. This form works in 1.x through the TypeScript bridge and is removed in 2.0. Use irCallbacks: true and return IR or type text instead: ${IR_CALLBACKS_GUIDE_URL}`;
|
|
11
17
|
}
|
|
@@ -15,7 +21,7 @@ function warnLegacyCallback(ctx, name) {
|
|
|
15
21
|
return;
|
|
16
22
|
}
|
|
17
23
|
ctx.legacyCallbackWarnings.add(name);
|
|
18
|
-
(ctx.
|
|
24
|
+
(ctx.deprecations ?? defaultDeprecationReporter()).report(CODES[name], message(name));
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export { IR_CALLBACKS_GUIDE_URL, warnLegacyCallback };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-callback-warning.mjs","sources":["../../src/api/legacy-callback-warning.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"legacy-callback-warning.mjs","sources":["../../src/api/legacy-callback-warning.ts"],"sourcesContent":["import { DEPRECATION_CODES, type DeprecationCode } from \"../domain/deprecations.js\";\nimport type { LegacyCallbackName } from \"../types.js\";\nimport { defaultDeprecationReporter } from \"./default-ports.js\";\nimport type { RunContext } from \"./run-context.js\";\n\n/** Where the IR callbacks are documented; the warning points users there. */\nexport const IR_CALLBACKS_GUIDE_URL =\n \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks\";\n\nconst USES: Readonly<Record<LegacyCallbackName, string>> = {\n transform: \"`transform` returned a TypeScript node\",\n postTransform: \"`postTransform` receives TypeScript nodes\",\n transformProperty: \"`transformProperty` receives TypeScript nodes\",\n};\n\nconst CODES: Readonly<Record<LegacyCallbackName, DeprecationCode>> = {\n transform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM,\n postTransform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM,\n transformProperty: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY,\n};\n\nfunction message(name: LegacyCallbackName): string {\n return (\n `${USES[name]}. This form works in 1.x through the TypeScript bridge and is removed in 2.0. ` +\n `Use irCallbacks: true and return IR or type text instead: ${IR_CALLBACKS_GUIDE_URL}`\n );\n}\n\n/**\n * Report a deprecated callback form once per run and callback, as a deprecation (not through the\n * logger, so `silent` does not hide it). The Node.js reporter shows each code once per process.\n */\nexport function warnLegacyCallback(ctx: RunContext, name: LegacyCallbackName): void {\n ctx.legacyCallbackWarnings ??= new Set();\n if (ctx.legacyCallbackWarnings.has(name)) {\n return;\n }\n ctx.legacyCallbackWarnings.add(name);\n (ctx.deprecations ?? defaultDeprecationReporter()).report(CODES[name], message(name));\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,sBAAA,GACX;AAEF,MAAM,IAAA,GAAqD;AAAA,EACzD,SAAA,EAAW,wCAAA;AAAA,EACX,aAAA,EAAe,2CAAA;AAAA,EACf,iBAAA,EAAmB;AACrB,CAAA;AAEA,MAAM,KAAA,GAA+D;AAAA,EACnE,WAAW,iBAAA,CAAkB,iCAAA;AAAA,EAC7B,eAAe,iBAAA,CAAkB,sCAAA;AAAA,EACjC,mBAAmB,iBAAA,CAAkB;AACvC,CAAA;AAEA,SAAS,QAAQ,IAAA,EAAkC;AACjD,EAAA,OACE,CAAA,EAAG,IAAA,CAAK,IAAI,CAAC,2IACgD,sBAAsB,CAAA,CAAA;AAEvF;AAMO,SAAS,kBAAA,CAAmB,KAAiB,IAAA,EAAgC;AAClF,EAAA,GAAA,CAAI,sBAAA,yBAA+B,GAAA,EAAI;AACvC,EAAA,IAAI,GAAA,CAAI,sBAAA,CAAuB,GAAA,CAAI,IAAI,CAAA,EAAG;AACxC,IAAA;AAAA,EACF;AACA,EAAA,GAAA,CAAI,sBAAA,CAAuB,IAAI,IAAI,CAAA;AACnC,EAAA,CAAC,GAAA,CAAI,YAAA,IAAgB,0BAAA,EAA2B,EAAG,MAAA,CAAO,MAAM,IAAI,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAC,CAAA;AACtF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-ts-helpers.cjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache = new Map<string, ts.EnumDeclaration>();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n) {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n) {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n) {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(index: string | number) {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":["lazyNode","loadTypeScript","schemaComment","toTypeNode","declaresTypeAlias","HELPER_TYPES","toValueExpression","quotedMemberName","enumMemberDescription"],"mappings":";;;;;;;;;;AAoBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,kCAAA,GAAqC;AAC3C,MAAM,qBAAA,GAAgD;AAAA,EAC3D,GAAA,EAAK;AAAA;AAEP;AAMO,MAAM,cAAA,GAAmCA,kBAAS,MAAM;AAC7D,EAAA,MAAM,KAAKC,6BAAA,EAAe;AAC1B,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,WAAA,CAAY,EAAA,CAAG,WAAW,aAAa,CAAA;AAC3D,CAAC;AAqBM,SAAS,eAAA,CACd,cACA,IAAA,EACM;AACN,EAAA,MAAM,KAAKA,6BAAA,EAA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AAA,CAAG,OAAA,CAAQ,gBAAA,CAAiB,KAAK,CAAA,GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAcI,yBAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"legacy-ts-helpers.cjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache: Map<string, ts.EnumDeclaration> = new Map();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n): ts.EnumDeclaration {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n): ts.VariableStatement {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n): ts.EnumMember {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(\n index: string | number,\n): ts.Identifier | ts.NumericLiteral | ts.StringLiteral {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":["lazyNode","loadTypeScript","schemaComment","toTypeNode","declaresTypeAlias","HELPER_TYPES","toValueExpression","quotedMemberName","enumMemberDescription"],"mappings":";;;;;;;;;;AAoBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,kCAAA,GAAqC;AAC3C,MAAM,qBAAA,GAAgD;AAAA,EAC3D,GAAA,EAAK;AAAA;AAEP;AAMO,MAAM,cAAA,GAAmCA,kBAAS,MAAM;AAC7D,EAAA,MAAM,KAAKC,6BAAA,EAAe;AAC1B,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,WAAA,CAAY,EAAA,CAAG,WAAW,aAAa,CAAA;AAC3D,CAAC;AAqBM,SA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,KAAU,QAAA,IAAY,oBAAA,CAAqB,IAAA,CAAK,KAAK,CAAA,GAC/D,EAAA,CAAG,OAAA,CAAQ,gBAAA,CAAiB,KAAK,CAAA,GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAcI,yBAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-ts-helpers.mjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache = new Map<string, ts.EnumDeclaration>();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n) {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n) {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n) {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(index: string | number) {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":[],"mappings":";;;;;;;;AAoBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,kCAAA,GAAqC;AAC3C,MAAM,qBAAA,GAAgD;AAAA,EAC3D,GAAA,EAAK;AAAA;AAEP;AAMO,MAAM,cAAA,GAAmC,SAAS,MAAM;AAC7D,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,WAAA,CAAY,EAAA,CAAG,WAAW,aAAa,CAAA;AAC3D,CAAC;AAqBM,SAAS,eAAA,CACd,cACA,IAAA,EACM;AACN,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,MAA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GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAc,aAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;"}
|
|
1
|
+
{"version":3,"file":"legacy-ts-helpers.mjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache: Map<string, ts.EnumDeclaration> = new Map();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n): ts.EnumDeclaration {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n): ts.VariableStatement {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n): ts.EnumMember {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(\n index: string | number,\n): ts.Identifier | ts.NumericLiteral | ts.StringLiteral {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":[],"mappings":";;;;;;;;AAoBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,kCAAA,GAAqC;AAC3C,MAAM,qBAAA,GAAgD;AAAA,EAC3D,GAAA,EAAK;AAAA;AAEP;AAMO,MAAM,cAAA,GAAmC,SAAS,MAAM;AAC7D,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,WAAA,CAAY,EAAA,CAAG,WAAW,aAAa,CAAA;AAC3D,CAAC;AAqBM,SAAS,eAAA,CACd,cACA,IAAA,EACM;AACN,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,MAAM,OAAA,GAAU,cAAc,YAAY,CAAA;AAC1C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,EAAA,CA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