openapi-typesafe 1.0.0-rc.2 → 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.
Files changed (139) hide show
  1. package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
  2. package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
  3. package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
  4. package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
  5. package/dist/api/default-ports.cjs +5 -0
  6. package/dist/api/default-ports.cjs.map +1 -1
  7. package/dist/api/default-ports.mjs +5 -1
  8. package/dist/api/default-ports.mjs.map +1 -1
  9. package/dist/api/discriminator-conflict-warnings.cjs +1 -1
  10. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
  11. package/dist/api/discriminator-conflict-warnings.mjs +2 -2
  12. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
  13. package/dist/api/discriminator-patch.cjs +3 -3
  14. package/dist/api/discriminator-patch.cjs.map +1 -1
  15. package/dist/api/discriminator-patch.mjs +4 -4
  16. package/dist/api/discriminator-patch.mjs.map +1 -1
  17. package/dist/api/discriminator-scan.cjs +2 -2
  18. package/dist/api/discriminator-scan.cjs.map +1 -1
  19. package/dist/api/discriminator-scan.mjs +3 -3
  20. package/dist/api/discriminator-scan.mjs.map +1 -1
  21. package/dist/api/document-run.cjs +2 -1
  22. package/dist/api/document-run.cjs.map +1 -1
  23. package/dist/api/document-run.mjs +2 -1
  24. package/dist/api/document-run.mjs.map +1 -1
  25. package/dist/api/legacy-callback-warning.cjs +7 -4
  26. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  27. package/dist/api/legacy-callback-warning.mjs +8 -5
  28. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  29. package/dist/api/openapi-ts.cjs +1 -1
  30. package/dist/api/openapi-ts.cjs.map +1 -1
  31. package/dist/api/openapi-ts.mjs +2 -2
  32. package/dist/api/openapi-ts.mjs.map +1 -1
  33. package/dist/api/string-to-ast.cjs +7 -9
  34. package/dist/api/string-to-ast.cjs.map +1 -1
  35. package/dist/api/string-to-ast.mjs +8 -9
  36. package/dist/api/string-to-ast.mjs.map +1 -1
  37. package/dist/api/transform-schema.cjs +2 -2
  38. package/dist/api/transform-schema.cjs.map +1 -1
  39. package/dist/api/transform-schema.mjs +3 -3
  40. package/dist/api/transform-schema.mjs.map +1 -1
  41. package/dist/application/transform/document/components.cjs +1 -1
  42. package/dist/application/transform/document/components.cjs.map +1 -1
  43. package/dist/application/transform/document/components.mjs +2 -2
  44. package/dist/application/transform/document/components.mjs.map +1 -1
  45. package/dist/application/transform/document/parameters.cjs +1 -1
  46. package/dist/application/transform/document/parameters.cjs.map +1 -1
  47. package/dist/application/transform/document/parameters.mjs +2 -2
  48. package/dist/application/transform/document/parameters.mjs.map +1 -1
  49. package/dist/application/transform/document/paths.cjs +1 -1
  50. package/dist/application/transform/document/paths.cjs.map +1 -1
  51. package/dist/application/transform/document/paths.mjs +2 -2
  52. package/dist/application/transform/document/paths.mjs.map +1 -1
  53. package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
  54. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  55. package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
  56. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  57. package/dist/application/transform/schema/access-flags.cjs +1 -1
  58. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  59. package/dist/application/transform/schema/access-flags.mjs +2 -2
  60. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  61. package/dist/application/transform/schema/array-type.cjs +2 -2
  62. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  63. package/dist/application/transform/schema/array-type.mjs +3 -3
  64. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  65. package/dist/application/transform/schema/composition-type.cjs +3 -3
  66. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  67. package/dist/application/transform/schema/composition-type.mjs +4 -4
  68. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  69. package/dist/application/transform/schema/enum-rule.cjs +3 -5
  70. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  71. package/dist/application/transform/schema/enum-rule.mjs +4 -6
  72. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  73. package/dist/application/transform/schema/presence-members.cjs +1 -1
  74. package/dist/application/transform/schema/presence-members.cjs.map +1 -1
  75. package/dist/application/transform/schema/presence-members.mjs +2 -2
  76. package/dist/application/transform/schema/presence-members.mjs.map +1 -1
  77. package/dist/application/transform/schema/required-variants.cjs +2 -2
  78. package/dist/application/transform/schema/required-variants.cjs.map +1 -1
  79. package/dist/application/transform/schema/required-variants.mjs +3 -3
  80. package/dist/application/transform/schema/required-variants.mjs.map +1 -1
  81. package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
  82. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  83. package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
  84. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  85. package/dist/application/transform/schema-comment.cjs +1 -1
  86. package/dist/application/transform/schema-comment.cjs.map +1 -1
  87. package/dist/application/transform/schema-comment.mjs +2 -2
  88. package/dist/application/transform/schema-comment.mjs.map +1 -1
  89. package/dist/domain/deprecations.cjs +11 -0
  90. package/dist/domain/deprecations.cjs.map +1 -0
  91. package/dist/domain/deprecations.mjs +9 -0
  92. package/dist/domain/deprecations.mjs.map +1 -0
  93. package/dist/domain/errors.cjs.map +1 -1
  94. package/dist/domain/errors.mjs.map +1 -1
  95. package/dist/domain/output-fixes.cjs +11 -14
  96. package/dist/domain/output-fixes.cjs.map +1 -1
  97. package/dist/domain/output-fixes.mjs +11 -13
  98. package/dist/domain/output-fixes.mjs.map +1 -1
  99. package/dist/domain/warnings.cjs +0 -1
  100. package/dist/domain/warnings.cjs.map +1 -1
  101. package/dist/domain/warnings.mjs +0 -1
  102. package/dist/domain/warnings.mjs.map +1 -1
  103. package/dist/index.cjs +2 -3
  104. package/dist/index.cjs.map +1 -1
  105. package/dist/index.d.cts +35 -16
  106. package/dist/index.d.mts +35 -16
  107. package/dist/index.d.ts +35 -16
  108. package/dist/index.mjs +3 -2
  109. package/dist/index.mjs.map +1 -1
  110. package/package.json +2 -2
  111. package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
  112. package/src/api/default-ports.ts +7 -0
  113. package/src/api/discriminator-conflict-warnings.ts +2 -2
  114. package/src/api/discriminator-patch.ts +4 -5
  115. package/src/api/discriminator-scan.ts +3 -3
  116. package/src/api/document-run.ts +5 -0
  117. package/src/api/legacy-callback-warning.ts +13 -6
  118. package/src/api/openapi-ts.ts +6 -2
  119. package/src/api/run-context.ts +3 -0
  120. package/src/api/string-to-ast.ts +11 -15
  121. package/src/api/transform-schema.ts +3 -3
  122. package/src/application/ports/deprecation-reporter.ts +9 -0
  123. package/src/application/transform/document/components.ts +2 -2
  124. package/src/application/transform/document/parameters.ts +2 -2
  125. package/src/application/transform/document/paths.ts +2 -2
  126. package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
  127. package/src/application/transform/schema/access-flags.ts +2 -2
  128. package/src/application/transform/schema/array-type.ts +3 -5
  129. package/src/application/transform/schema/composition-type.ts +4 -4
  130. package/src/application/transform/schema/enum-rule.ts +4 -6
  131. package/src/application/transform/schema/presence-members.ts +2 -2
  132. package/src/application/transform/schema/required-variants.ts +3 -3
  133. package/src/application/transform/schema/unevaluated-properties.ts +2 -2
  134. package/src/application/transform/schema-comment.ts +2 -2
  135. package/src/domain/deprecations.ts +15 -0
  136. package/src/domain/errors.ts +8 -2
  137. package/src/domain/output-fixes.ts +16 -16
  138. package/src/domain/warnings.ts +0 -1
  139. package/src/index.ts +2 -6
@@ -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 { 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 /** 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 | \"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 };\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":";;;;;;;;;;;;;;;;;;;AAwDA,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,c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;;"}
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,CA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AAA,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,MAAA;AAAA,IACA,cAAc,KAAA,CAAM;AAAA,GACtB;AACA,EAAA,OAAO,EAAE,QAAQ,GAAA,EAAI;AACvB;;"}
@@ -109,7 +109,8 @@ async function createDocumentRun(source, options, ports) {
109
109
  injectFooter: [],
110
110
  redoc: ports.redoc,
111
111
  resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),
112
- logger
112
+ logger,
113
+ deprecations: ports.deprecations
113
114
  };
114
115
  return { schema, ctx };
115
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 { 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 /** 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 | \"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 };\n return { schema, ctx };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwDA,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;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;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,I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AA;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,MAAA;AAAA,IACA,cAAc,KAAA,CAAM;AAAA,GACtB;AACA,EAAA,OAAO,EAAE,QAAQ,GAAA,EAAI;AACvB;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const warnings = require('../domain/warnings.cjs');
3
+ const deprecations = require('../domain/deprecations.cjs');
4
4
  const defaultPorts = require('./default-ports.cjs');
5
5
 
6
6
  const IR_CALLBACKS_GUIDE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks";
@@ -9,6 +9,11 @@ const USES = {
9
9
  postTransform: "`postTransform` receives TypeScript nodes",
10
10
  transformProperty: "`transformProperty` receives TypeScript nodes"
11
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
+ };
12
17
  function message(name) {
13
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}`;
14
19
  }
@@ -18,9 +23,7 @@ function warnLegacyCallback(ctx, name) {
18
23
  return;
19
24
  }
20
25
  ctx.legacyCallbackWarnings.add(name);
21
- (ctx.logger ?? defaultPorts.defaultLogger(ctx.silent)).warn(
22
- warnings.warningText(message(name), warnings.WARNING_CODES.LEGACY_CALLBACK_DEPRECATED)
23
- );
26
+ (ctx.deprecations ?? defaultPorts.defaultDeprecationReporter()).report(CODES[name], message(name));
24
27
  }
25
28
 
26
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 { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport type { LegacyCallbackName } from \"../types.js\";\nimport { defaultLogger } 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\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/** Warn once per run and callback; `silent` runs record the use but print nothing. */\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.logger ?? defaultLogger(ctx.silent)).warn(\n warningText(message(name), WARNING_CODES.LEGACY_CALLBACK_DEPRECATED),\n );\n}\n"],"names":["defaultLogger","warningText","WARNING_CODES"],"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,SAAS,QAAQ,IAAA,EAAkC;AACjD,EAAA,OACE,CAAA,EAAG,IAAA,CAAK,IAAI,CAAC,2IACgD,sBAAsB,CAAA,CAAA;AAEvF;AAGO,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,MAAA,IAAUA,0BAAA,CAAc,GAAA,CAAI,MAAM,CAAA,EAAG,IAAA;AAAA,IACxCC,oBAAA,CAAY,OAAA,CAAQ,IAAI,CAAA,EAAGC,uBAAc,0BAA0B;AAAA,GACrE;AACF;;;"}
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,5 +1,5 @@
1
- import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
2
- import { defaultLogger } from './default-ports.mjs';
1
+ import { DEPRECATION_CODES } from '../domain/deprecations.mjs';
2
+ import { defaultDeprecationReporter } from './default-ports.mjs';
3
3
 
4
4
  const IR_CALLBACKS_GUIDE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks";
5
5
  const USES = {
@@ -7,6 +7,11 @@ const USES = {
7
7
  postTransform: "`postTransform` receives TypeScript nodes",
8
8
  transformProperty: "`transformProperty` receives TypeScript nodes"
9
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
+ };
10
15
  function message(name) {
11
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}`;
12
17
  }
@@ -16,9 +21,7 @@ function warnLegacyCallback(ctx, name) {
16
21
  return;
17
22
  }
18
23
  ctx.legacyCallbackWarnings.add(name);
19
- (ctx.logger ?? defaultLogger(ctx.silent)).warn(
20
- warningText(message(name), WARNING_CODES.LEGACY_CALLBACK_DEPRECATED)
21
- );
24
+ (ctx.deprecations ?? defaultDeprecationReporter()).report(CODES[name], message(name));
22
25
  }
23
26
 
24
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 { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport type { LegacyCallbackName } from \"../types.js\";\nimport { defaultLogger } 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\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/** Warn once per run and callback; `silent` runs record the use but print nothing. */\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.logger ?? defaultLogger(ctx.silent)).warn(\n warningText(message(name), WARNING_CODES.LEGACY_CALLBACK_DEPRECATED),\n );\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,SAAS,QAAQ,IAAA,EAAkC;AACjD,EAAA,OACE,CAAA,EAAG,IAAA,CAAK,IAAI,CAAC,2IACgD,sBAAsB,CAAA,CAAA;AAEvF;AAGO,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,MAAA,IAAU,aAAA,CAAc,GAAA,CAAI,MAAM,CAAA,EAAG,IAAA;AAAA,IACxC,WAAA,CAAY,OAAA,CAAQ,IAAI,CAAA,EAAG,cAAc,0BAA0B;AAAA,GACrE;AACF;;"}
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;;"}
@@ -29,7 +29,7 @@ async function defaultGeneratorPorts(options) {
29
29
  remoteRefTimeoutMs: defaultPorts.REMOTE_REF_TIMEOUT_MS,
30
30
  remoteDocumentLimits: defaultPorts.DEFAULT_REMOTE_DOCUMENT_LIMITS
31
31
  });
32
- return { loader, logger, redoc, now: defaultPorts.monotonicNow };
32
+ return { loader, logger, deprecations: defaultPorts.defaultDeprecationReporter(), redoc, now: defaultPorts.monotonicNow };
33
33
  }
34
34
  async function openapiTS(source, options = {}) {
35
35
  return generateDeclarations(source, options, await defaultGeneratorPorts(options));
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-ts.cjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return result;\n}\n\n/** The default ports: the terminal logger, the given or default Redocly config, Redocly loading. */\nexport async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {\n const logger = defaultLogger(options.silent ?? false);\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":["createDocumentRun","withStackOverflowReported","transformSchema","defaultLogger","defaultRedoclyConfig","createRedoclySchemaLoader","monotonicNow","REMOTE_REF_TIMEOUT_MS","DEFAULT_REMOTE_DOCUMENT_LIMITS"],"mappings":";;;;;;;;;;AAoBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAMA,6BAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAASC,uCAAA,CAA0B,WAAA,EAAa,MAAMC,uBAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAGA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAASC,0BAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAMC,iCAAA,EAAqB;AAC7D,EAAA,MAAM,SAASC,6CAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAKC,yBAAA;AAAA,IACL,kBAAA,EAAoBC,kCAAA;AAAA,IACpB,oBAAA,EAAsBC;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,KAAKF,yBAAA,EAAa;AACpD;AAUA,eAA8B,SAAA,CAC5B,MAAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;;;"}
1
+ {"version":3,"file":"openapi-ts.cjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultDeprecationReporter,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return result;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading.\n */\nexport async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {\n const logger = defaultLogger(options.silent ?? false);\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":["createDocumentRun","withStackOverflowReported","transformSchema","defaultLogger","defaultRedoclyConfig","createRedoclySchemaLoader","monotonicNow","REMOTE_REF_TIMEOUT_MS","DEFAULT_REMOTE_DOCUMENT_LIMITS","defaultDeprecationReporter"],"mappings":";;;;;;;;;;AAqBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAMA,6BAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAASC,uCAAA,CAA0B,WAAA,EAAa,MAAMC,uBAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAMA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAASC,0BAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAMC,iCAAA,EAAqB;AAC7D,EAAA,MAAM,SAASC,6CAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAKC,yBAAA;AAAA,IACL,kBAAA,EAAoBC,kCAAA;AAAA,IACpB,oBAAA,EAAsBC;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,QAAQ,MAAA,EAAQ,YAAA,EAAcC,yCAA2B,EAAG,KAAA,EAAO,KAAKH,yBAAA,EAAa;AAChG;AAUA,eAA8B,SAAA,CAC5B,MAAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { createRedoclySchemaLoader } from '../adapters/redocly-loader/redocly-schema-loader.mjs';
2
2
  import { withStackOverflowReported } from '../application/stack-overflow.mjs';
3
- import { defaultLogger, defaultRedoclyConfig, monotonicNow, DEFAULT_REMOTE_DOCUMENT_LIMITS, REMOTE_REF_TIMEOUT_MS } from './default-ports.mjs';
3
+ import { defaultLogger, defaultRedoclyConfig, monotonicNow, defaultDeprecationReporter, DEFAULT_REMOTE_DOCUMENT_LIMITS, REMOTE_REF_TIMEOUT_MS } from './default-ports.mjs';
4
4
  import { createDocumentRun } from './document-run.mjs';
5
5
  import transformSchema from './transform-schema.mjs';
6
6
 
@@ -25,7 +25,7 @@ async function defaultGeneratorPorts(options) {
25
25
  remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,
26
26
  remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS
27
27
  });
28
- return { loader, logger, redoc, now: monotonicNow };
28
+ return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };
29
29
  }
30
30
  async function openapiTS(source, options = {}) {
31
31
  return generateDeclarations(source, options, await defaultGeneratorPorts(options));
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-ts.mjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return result;\n}\n\n/** The default ports: the terminal logger, the given or default Redocly config, Redocly loading. */\nexport async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {\n const logger = defaultLogger(options.silent ?? false);\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":[],"mappings":";;;;;;AAoBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAM,iBAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAAS,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAGA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAM,oBAAA,EAAqB;AAC7D,EAAA,MAAM,SAAS,yBAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAK,YAAA;AAAA,IACL,kBAAA,EAAoB,qBAAA;AAAA,IACpB,oBAAA,EAAsB;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,KAAK,YAAA,EAAa;AACpD;AAUA,eAA8B,SAAA,CAC5B,MAAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;"}
1
+ {"version":3,"file":"openapi-ts.mjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultDeprecationReporter,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return result;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading.\n */\nexport async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {\n const logger = defaultLogger(options.silent ?? false);\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":[],"mappings":";;;;;;AAqBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAM,iBAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAAS,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAMA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAM,oBAAA,EAAqB;AAC7D,EAAA,MAAM,SAAS,yBAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAK,YAAA;AAAA,IACL,kBAAA,EAAoB,qBAAA;AAAA,IACpB,oBAAA,EAAsB;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,QAAQ,MAAA,EAAQ,YAAA,EAAc,4BAA2B,EAAG,KAAA,EAAO,KAAK,YAAA,EAAa;AAChG;AAUA,eAA8B,SAAA,CAC5B,MAAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;"}
@@ -1,21 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const node_util = require('node:util');
4
3
  const irDeclarationsToTypescript = require('../adapters/type-ast-bridge/ir-declarations-to-typescript.cjs');
5
4
  const loadTypescript = require('../adapters/type-ast-bridge/load-typescript.cjs');
5
+ const deprecations = require('../domain/deprecations.cjs');
6
+ const defaultPorts = require('./default-ports.cjs');
6
7
  const legacyCallbackWarning = require('./legacy-callback-warning.cjs');
7
8
 
8
9
  const STRING_TO_AST_DEPRECATION = `stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR callback (irCallbacks: true) instead: ${legacyCallbackWarning.IR_CALLBACKS_GUIDE_URL}`;
9
- const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
10
- function parseSource(source) {
10
+ function stringToAST(source) {
11
+ defaultPorts.defaultDeprecationReporter().report(
12
+ deprecations.DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,
13
+ STRING_TO_AST_DEPRECATION
14
+ );
11
15
  return [...irDeclarationsToTypescript.parseStatements(loadTypescript.loadTypeScript(), source)];
12
16
  }
13
- const stringToAST = node_util.deprecate(
14
- parseSource,
15
- STRING_TO_AST_DEPRECATION,
16
- STRING_TO_AST_DEPRECATION_CODE
17
- );
18
17
 
19
- exports.STRING_TO_AST_DEPRECATION_CODE = STRING_TO_AST_DEPRECATION_CODE;
20
18
  exports.stringToAST = stringToAST;
21
19
  //# sourceMappingURL=string-to-ast.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-to-ast.cjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { deprecate } from \"node:util\";\nimport { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */\nexport const STRING_TO_AST_DEPRECATION_CODE = \"OPENAPI_TYPESAFE_DEP_STRING_TO_AST\";\n\nfunction parseSource(source: string): unknown[] {\n return [...parseStatements(loadTypeScript(), source)];\n}\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node's `util.deprecate` warns\n * on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport const stringToAST: (source: string) => unknown[] = deprecate(\n parseSource,\n STRING_TO_AST_DEPRECATION,\n STRING_TO_AST_DEPRECATION_CODE,\n);\n"],"names":["IR_CALLBACKS_GUIDE_URL","parseStatements","loadTypeScript","deprecate"],"mappings":";;;;;;;AAKA,MAAM,yBAAA,GACJ,gIACyCA,4CAAsB,CAAA,CAAA;AAG1D,MAAM,8BAAA,GAAiC;AAE9C,SAAS,YAAY,MAAA,EAA2B;AAC9C,EAAA,OAAO,CAAC,GAAGC,0CAAA,CAAgBC,6BAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;AAQO,MAAM,WAAA,GAA6CC,mBAAA;AAAA,EACxD,WAAA;AAAA,EACA,yBAAA;AAAA,EACA;AACF;;;"}
1
+ {"version":3,"file":"string-to-ast.cjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { DEPRECATION_CODES } from \"../domain/deprecations.js\";\nimport { defaultDeprecationReporter } from \"./default-ports.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js\n * `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport function stringToAST(source: string): unknown[] {\n defaultDeprecationReporter().report(\n DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,\n STRING_TO_AST_DEPRECATION,\n );\n return [...parseStatements(loadTypeScript(), source)];\n}\n"],"names":["IR_CALLBACKS_GUIDE_URL","defaultDeprecationReporter","DEPRECATION_CODES","parseStatements","loadTypeScript"],"mappings":";;;;;;;;AAMA,MAAM,yBAAA,GACJ,gIACyCA,4CAAsB,CAAA,CAAA;AAQ1D,SAAS,YAAY,MAAA,EAA2B;AACrD,EAAAC,uCAAA,EAA2B,CAAE,MAAA;AAAA,IAC3BC,8BAAA,CAAkB,kCAAA;AAAA,IAClB;AAAA,GACF;AACA,EAAA,OAAO,CAAC,GAAGC,0CAAA,CAAgBC,6BAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;;"}
@@ -1,18 +1,17 @@
1
- import { deprecate } from 'node:util';
2
1
  import { parseStatements } from '../adapters/type-ast-bridge/ir-declarations-to-typescript.mjs';
3
2
  import { loadTypeScript } from '../adapters/type-ast-bridge/load-typescript.mjs';
3
+ import { DEPRECATION_CODES } from '../domain/deprecations.mjs';
4
+ import { defaultDeprecationReporter } from './default-ports.mjs';
4
5
  import { IR_CALLBACKS_GUIDE_URL } from './legacy-callback-warning.mjs';
5
6
 
6
7
  const STRING_TO_AST_DEPRECATION = `stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;
7
- const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
8
- function parseSource(source) {
8
+ function stringToAST(source) {
9
+ defaultDeprecationReporter().report(
10
+ DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,
11
+ STRING_TO_AST_DEPRECATION
12
+ );
9
13
  return [...parseStatements(loadTypeScript(), source)];
10
14
  }
11
- const stringToAST = deprecate(
12
- parseSource,
13
- STRING_TO_AST_DEPRECATION,
14
- STRING_TO_AST_DEPRECATION_CODE
15
- );
16
15
 
17
- export { STRING_TO_AST_DEPRECATION_CODE, stringToAST };
16
+ export { stringToAST };
18
17
  //# sourceMappingURL=string-to-ast.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-to-ast.mjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { deprecate } from \"node:util\";\nimport { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */\nexport const STRING_TO_AST_DEPRECATION_CODE = \"OPENAPI_TYPESAFE_DEP_STRING_TO_AST\";\n\nfunction parseSource(source: string): unknown[] {\n return [...parseStatements(loadTypeScript(), source)];\n}\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node's `util.deprecate` warns\n * on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport const stringToAST: (source: string) => unknown[] = deprecate(\n parseSource,\n STRING_TO_AST_DEPRECATION,\n STRING_TO_AST_DEPRECATION_CODE,\n);\n"],"names":[],"mappings":";;;;;AAKA,MAAM,yBAAA,GACJ,gIACyC,sBAAsB,CAAA,CAAA;AAG1D,MAAM,8BAAA,GAAiC;AAE9C,SAAS,YAAY,MAAA,EAA2B;AAC9C,EAAA,OAAO,CAAC,GAAG,eAAA,CAAgB,cAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;AAQO,MAAM,WAAA,GAA6C,SAAA;AAAA,EACxD,WAAA;AAAA,EACA,yBAAA;AAAA,EACA;AACF;;"}
1
+ {"version":3,"file":"string-to-ast.mjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { DEPRECATION_CODES } from \"../domain/deprecations.js\";\nimport { defaultDeprecationReporter } from \"./default-ports.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js\n * `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport function stringToAST(source: string): unknown[] {\n defaultDeprecationReporter().report(\n DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,\n STRING_TO_AST_DEPRECATION,\n );\n return [...parseStatements(loadTypeScript(), source)];\n}\n"],"names":[],"mappings":";;;;;;AAMA,MAAM,yBAAA,GACJ,gIACyC,sBAAsB,CAAA,CAAA;AAQ1D,SAAS,YAAY,MAAA,EAA2B;AACrD,EAAA,0BAAA,EAA2B,CAAE,MAAA;AAAA,IAC3B,iBAAA,CAAkB,kCAAA;AAAA,IAClB;AAAA,GACF;AACA,EAAA,OAAO,CAAC,GAAG,eAAA,CAAgB,cAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;;"}
@@ -36,10 +36,10 @@ function sharedEnumNamesOf(document$1, ctx, recorder) {
36
36
  return recorder.chosenNames();
37
37
  }
38
38
  function enumNameRecorderOf(ctx) {
39
- if (ctx.fix?.includes(outputFixes.OutputFix.DEDUPE_ENUM_NAMES)) {
39
+ if (ctx.fix?.includes(outputFixes.FIX.DEDUPE_ENUM_NAMES)) {
40
40
  return new sharedEnumNames.SharedEnumNameRecorder();
41
41
  }
42
- return ctx.fix?.includes(outputFixes.OutputFix.DISCRIMINATOR_VALUES) ? new discriminatorEnumNames.FirstSchemaNameRecorder() : null;
42
+ return ctx.fix?.includes(outputFixes.FIX.DISCRIMINATOR_VALUES) ? new discriminatorEnumNames.FirstSchemaNameRecorder() : null;
43
43
  }
44
44
  function withSharedEnumNames(document, ctx) {
45
45
  const recorder = ctx.runFooter === void 0 ? enumNameRecorderOf(ctx) : null;
@@ -1 +1 @@
1
- {"version":3,"file":"transform-schema.cjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { OutputFix } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":["isIrDeclaration","document","RunFooter","ContextFooterSink","createTransformContext","documentBody","OutputFix","SharedEnumNameRecorder","FirstSchemaNameRecorder","checkedEnumValues","excludedValuesWarning","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,O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,GAAG,CAAC,CAAA;AAC5D;;;"}
1
+ {"version":3,"file":"transform-schema.cjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { FIX } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":["isIrDeclaration","document","RunFooter","ContextFooterSink","createTransformContext","documentBody","FIX","SharedEnumNameRecorder","FirstSchemaNameRecorder","checkedEnumValues","excludedValuesWarning","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAsB;AAAA,IAC1B,GAAG,GAAA;AAAA,I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 @@ import { renameTakenAliases } from '../application/transform/document/root-type-
3
3
  import { RunFooter } from '../application/transform/footer/document-footer.mjs';
4
4
  import { checkedEnumValues } from '../application/transform/footer/enum-values-check.mjs';
5
5
  import { SharedEnumNameRecorder } from '../application/transform/footer/shared-enum-names.mjs';
6
- import { OutputFix } from '../domain/output-fixes.mjs';
6
+ import { FIX } from '../domain/output-fixes.mjs';
7
7
  import { FirstSchemaNameRecorder } from './discriminator-enum-names.mjs';
8
8
  import { documentDeclarations } from './document-declarations.mjs';
9
9
  import { excludedValuesWarning } from './enum-values-warnings.mjs';
@@ -32,10 +32,10 @@ function sharedEnumNamesOf(document, ctx, recorder) {
32
32
  return recorder.chosenNames();
33
33
  }
34
34
  function enumNameRecorderOf(ctx) {
35
- if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {
35
+ if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {
36
36
  return new SharedEnumNameRecorder();
37
37
  }
38
- return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
38
+ return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
39
39
  }
40
40
  function withSharedEnumNames(document, ctx) {
41
41
  const recorder = ctx.runFooter === void 0 ? enumNameRecorderOf(ctx) : null;
@@ -1 +1 @@
1
- {"version":3,"file":"transform-schema.mjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { OutputFix } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAO,eAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACP,QAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAsB;AAAA,IAC1B,GAAG,GAAA;AAAA,IACH,YAAA;AAAA,IACA,SAAA,EAAW,IAAI,SAAA,CAAU,IAAI,kBAAkB,YAAY,CAAA,EAAG,MAAM,QAAQ,CAAA;AAAA,IAC5E,MAAA,EAAQ,gBAAA;AAAA,IACR,sBAAA,sBAA4B,GAAA;AAAI,GAClC;AACA,EAAA,MAAM,cAAA,GAAiB,uBAAuB,OAAO,CAAA;AACrD,EAAA,YAAA,CAAa,UAAU,cAAA,EAAgB,MAAM,YAAA,CAAa,MAAA,CAAO,eAAe,CAAC,CAAA;AACjF,EAAA,OAAO,SAAS,WAAA,EAAY;AAC9B;AAGA,SAAS,mBAAmB,GAAA,EAA6C;AACvE,EAAA,IAAI,GAAA,CAAI,GAAA,EAAK,QAAA,CAAS,SAAA,CAAU,iBAAiB,CAAA,EAAG;AAClD,IAAA,OAAO,IAAI,sBAAA,EAAuB;AAAA,EACpC;AACA,EAAA,OAAO,GA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E1C,EAAA,MAAM,OAAA,GAAU,aAAa,QAAA,EAAU,OAAA,EAAS,MAAM,GAAA,CAAI,YAAA,CAAa,MAAA,CAAO,eAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,MAAA,GAAS,kBAAkB,OAAA,EAAS,CAAC,GAAG,GAAA,CAAI,YAAY,GAAG,GAAG,CAAA;AACpE,EAAA,MAAM,UAAU,eAAA,CAAgB,QAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,MAAM,OAAO,kBAAA,CAAmB,OAAA,EAAS,OAAO,MAAA,CAAO,eAAe,GAAG,OAAO,CAAA;AAChF,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
1
+ {"version":3,"file":"transform-schema.mjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { FIX } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqBA,MAAM,eAAA,GAAkB,YAAA;AAGx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AM,UAAU,eAAA,CAAgB,QAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,MAAM,OAAO,kBAAA,CAAmB,OAAA,EAAS,OAAO,MAAA,CAAO,eAAe,GAAG,OAAO,CAAA;AAChF,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
@@ -86,7 +86,7 @@ function kindMember(kind, request, context) {
86
86
  }
87
87
  function componentsType(components, context, kept = /* @__PURE__ */ new Set()) {
88
88
  const aliases = {};
89
- const displaced = context.options.fixes.has(outputFixes.OutputFix.ROOT_TYPE_NUMBERING) ? [] : null;
89
+ const displaced = context.options.fixes.has(outputFixes.FIX.ROOT_TYPE_NUMBERING) ? [] : null;
90
90
  const isKept = (item) => kept.has(item);
91
91
  const request = { components, isKept, aliases, displaced };
92
92
  const declaredKinds = componentsObject.DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"components.cjs","sources":["../../../../src/application/transform/document/components.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport {\n hasIdentifierStart,\n isReservedTypeName,\n withIdentifierParts,\n} from \"../../../domain/ir/identifier-text.js\";\nimport type {\n IrPropertySignature,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {\n COMPONENT_KINDS,\n type ComponentKind,\n type ComponentsObject,\n DECLARED_COMPONENT_KINDS,\n isEnumSchema,\n singularizeComponentKind,\n} from \"../../../domain/openapi/components-object.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport { OutputFix } from \"../../../domain/output-fixes.js\";\nimport { type DeprecatedEntryFilter, documentEntries } from \"../document-entries.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType } from \"./media-type.js\";\nimport { parameterType } from \"./parameter.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responseType } from \"./response.js\";\nimport { rootTypeAlias } from \"./root-type-aliases.js\";\n\ntype ComponentTransform = (\n item: never,\n location: SchemaLocation,\n context: TransformContext,\n) => IrType;\n\nconst COMPONENT_TRANSFORMS: Readonly<Record<ComponentKind, ComponentTransform>> = {\n schemas: transformSchema,\n responses: responseType,\n parameters: parameterType,\n requestBodies: requestBodyType,\n headers: headerType,\n pathItems: pathItemType,\n mediaTypes: contentEntryType,\n};\n\n/** The `components` type and the `--root-types` aliases. */\nexport interface ComponentsResult {\n readonly type: IrType;\n readonly rootTypes: readonly IrTypeAliasDeclaration[];\n}\n\n/** One component; the `transform` callback may replace its type, as for nested schemas. */\nfunction componentMember(\n kind: ComponentKind,\n name: string,\n item: unknown,\n context: TransformContext,\n): IrPropertySignature {\n const location = { path: createRef([\"components\", kind, name]), schema: item };\n const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);\n const custom = context.callbacks.transform(item, location);\n const property = irProperty(toPropertyName(name), custom?.type ?? type, {\n isOptional: custom?.isOptional ?? false,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, item, schemaCommentOptionsOf(context.options.fixes));\n}\n\n/**\n * The root alias name: `SchemaPet`, `ResponseNotFound`, … A taken name gets `_2`, `_3`, … The\n * original checks for conflicts before it removes the schema prefix, and so does this; for a clash\n * of exported names see `addRootAlias`.\n *\n * The original could build a name that is no identifier, so the generated file did not parse\n * (research/legacy-bugs.md, item 16): a kept casing keeps spaces and symbols, which become `_`;\n * and a name without the prefix can start with a digit, so it keeps the prefix (`Schema1`). A\n * kept casing without the prefix can also give a reserved name (`void`, `class`), which keeps the\n * prefix too (`Schemavoid`).\n */\nfunction rootTypeName(\n kind: ComponentKind,\n name: string,\n aliases: Readonly<Record<string, IrTypeAliasDeclaration>>,\n context: TransformContext,\n): string {\n const { options, casing } = context;\n const prefix = casing.pascalCase(singularizeComponentKind(kind));\n const isSchema = kind === \"schemas\";\n const base = withIdentifierParts(\n options.rootTypesKeepCasing && isSchema ? name : casing.pascalCase(name),\n );\n const exportedName = (alias: string): string => {\n const unprefixed = alias.replace(prefix, \"\");\n const isUnprefixed = options.rootTypesNoSchemaPrefix && isSchema;\n const isTypeName = hasIdentifierStart(unprefixed) && !isReservedTypeName(unprefixed);\n return isUnprefixed && isTypeName ? unprefixed : alias;\n };\n let alias = `${prefix}${base}`;\n for (let counter = 2; aliases[alias] !== undefined; counter++) {\n alias = `${prefix}${base}_${counter}`;\n }\n return exportedName(alias);\n}\n\n/**\n * Add a root alias. When its exported name is taken (two schemas of one PascalCase name without\n * the prefix), the later schema takes the name, as in the original. Without the\n * `root-type-numbering` fix the earlier one then has no alias: that output is valid, so a number\n * for it would change it (backlog 30). With the fix the earlier alias is kept aside and follows\n * the others under the same name; `renameTakenAliases` numbers it once every name is known.\n */\nfunction addRootAlias(request: ComponentsRequest, alias: IrTypeAliasDeclaration): void {\n const { aliases, displaced } = request;\n const previous = aliases[alias.name];\n if (previous !== undefined && displaced !== null) {\n displaced.push(previous);\n }\n aliases[alias.name] = alias;\n}\n\n/** `--root-types` skips enum schemas under `--enum`: the enum itself is exported. */\nfunction hasRootType(kind: ComponentKind, item: unknown, context: TransformContext): boolean {\n const { options } = context;\n return options.rootTypes && !(options.enum && kind === \"schemas\" && isEnumSchema(item));\n}\n\n/** The components of one run, and the deprecated ones that kept output still references. */\ninterface ComponentsRequest {\n readonly components: ComponentsObject;\n readonly isKept: DeprecatedEntryFilter;\n readonly aliases: Record<string, IrTypeAliasDeclaration>;\n /** With the `root-type-numbering` fix: the aliases a later schema took the name of, in order. */\n readonly displaced: IrTypeAliasDeclaration[] | null;\n}\n\nfunction kindMember(\n kind: ComponentKind,\n request: ComponentsRequest,\n context: TransformContext,\n): IrPropertySignature {\n const { components, isKept, aliases } = request;\n const startedAt = context.diagnostics.now();\n const items: IrPropertySignature[] = [];\n for (const [name, item] of documentEntries(components[kind] ?? {}, context.options, isKept)) {\n items.push(componentMember(kind, name, item, context));\n if (hasRootType(kind, item, context)) {\n addRootAlias(request, rootTypeAlias(rootTypeName(kind, name, aliases, context), kind, name));\n }\n }\n const type = items.length > 0 ? irObject(items) : irKeyword(\"never\");\n context.diagnostics.debug(\n `Transformed components → ${kind}`,\n context.diagnostics.now() - startedAt,\n );\n return irProperty(toPropertyName(kind), type);\n}\n\n/**\n * The `components` interface body (OpenAPI 3.1 §4.8.7), one member per component kind. With\n * `--exclude-deprecated`, `kept` holds the deprecated components that kept output references\n * (`keptDeprecatedComponents`); they stay, so no reference names a missing key.\n */\nexport function componentsType(\n components: ComponentsObject,\n context: TransformContext,\n kept: ReadonlySet<object> = new Set(),\n): ComponentsResult {\n // A plain object, as in the original: its key order (integer-like names first) is the\n // output order.\n const aliases: Record<string, IrTypeAliasDeclaration> = {};\n const displaced = context.options.fixes.has(OutputFix.ROOT_TYPE_NUMBERING) ? [] : null;\n const isKept = (item: unknown) => kept.has(item as object);\n const request = { components, isKept, aliases, displaced };\n const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);\n const members = [...COMPONENT_KINDS, ...declaredKinds].map((kind) =>\n kindMember(kind, request, context),\n );\n const rootTypes = Object.values(aliases);\n return {\n type: irObject(members),\n rootTypes: [...rootTypes, ...(displaced ?? [])],\n };\n}\n"],"names":["transformSchema","responseType","parameterType","requestBodyType","headerType","pathItemType","contentEntryType","createRef","irProperty","toPropertyName","withSchemaComment","schemaCommentOptionsOf","singularizeComponentKind","withIdentifierParts","alias","hasIdentifierStart","isReservedTypeName","isEnumSchema","documentEntries","rootTypeAlias","irObject","irKeyword","OutputFix","DECLARED_COMPONENT_KINDS","COMPONENT_KINDS"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCA,MAAM,oBAAA,GAA4E;AAAA,EAChF,OAAA,EAASA,+BAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC,uBAAA;AAAA,EACZ,aAAA,EAAeC,2BAAA;AAAA,EACf,OAAA,EAASC,iBAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC;AACd,CAAA;AASA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAMC,qBAAA,CAAU,CAAC,YAAA,EAAc,IAAA,EAAM,IAAI,CAAC,CAAA,EAAG,MAAA,EAAQ,IAAA,EAAK;AAC7E,EAAA,MAAM,OAAO,oBAAA,CAAqB,IAAI,CAAA,CAAE,IAAA,EAAe,UAAU,OAAO,CAAA;AACxE,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,SAAA,CAAU,SAAA,CAAU,MAAM,QAAQ,CAAA;AACzD,EAAA,MAAM,WAAWC,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,MAAA,EAAQ,QAAQ,IAAA,EAAM;AAAA,IACtE,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACD,EAAA,OAAOC,gCAAkB,QAAA,EAAU,IAAA,EAAMC,qCAAuB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAC,CAAA;AACxF;AAaA,SAAS,YAAA,CACP,IAAA,EACA,IAAA,EACA,OAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAO,GAAI,OAAA;AAC5B,EA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GAAA,EAAI,GAAI;AAAA,GAC9B;AACA,EAAA,OAAOb,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,IAAI,CAAA;AAC9C;AAOO,SAAS,eACd,UAAA,EACA,OAAA,EACA,IAAA,mBAA4B,IAAI,KAAI,EAClB;AAGlB,EAAA,MAAM,UAAkD,EAAC;AACzD,EAAA,MAAM,SAAA,GAAY,QAAQ,OAAA,CAAQ,KAAA,CAAM,IAAIa,qBAAA,CAAU,mBAAmB,CAAA,GAAI,EAAC,GAAI,IAAA;AAClF,EAAA,MAAM,MAAA,GAAS,CAAC,IAAA,KAAkB,IAAA,CAAK,IAAI,IAAc,CAAA;AACzD,EAAA,MAAM,OAAA,GAAU,EAAE,UAAA,EAAY,MAAA,EAAQ,SAAS,SAAA,EAAU;AACzD,EAAA,MAAM,aAAA,GAAgBC,0CAAyB,MAAA,CAAO,CAAC,SAAS,UAAA,CAAW,IAAI,MAAM,MAAS,CAAA;AAC9F,EAAA,MAAM,UAAU,CAAC,GAAGC,gCAAA,EAAiB,GAAG,aAAa,CAAA,CAAE,GAAA;AAAA,IAAI,CAAC,IAAA,KAC1D,UAAA,CAAW,IAAA,EAAM,SAAS,OAAO;AAAA,GACnC;AACA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA;AACvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAMJ,sBAAS,OAAO,CAAA;AAAA,IACtB,WAAW,CAAC,GAAG,WAAW,GAAI,SAAA,IAAa,EAAG;AAAA,GAChD;AACF;;"}
1
+ {"version":3,"file":"components.cjs","sources":["../../../../src/application/transform/document/components.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport {\n hasIdentifierStart,\n isReservedTypeName,\n withIdentifierParts,\n} from \"../../../domain/ir/identifier-text.js\";\nimport type {\n IrPropertySignature,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport {\n COMPONENT_KINDS,\n type ComponentKind,\n type ComponentsObject,\n DECLARED_COMPONENT_KINDS,\n isEnumSchema,\n singularizeComponentKind,\n} from \"../../../domain/openapi/components-object.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { type DeprecatedEntryFilter, documentEntries } from \"../document-entries.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType } from \"./media-type.js\";\nimport { parameterType } from \"./parameter.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responseType } from \"./response.js\";\nimport { rootTypeAlias } from \"./root-type-aliases.js\";\n\ntype ComponentTransform = (\n item: never,\n location: SchemaLocation,\n context: TransformContext,\n) => IrType;\n\nconst COMPONENT_TRANSFORMS: Readonly<Record<ComponentKind, ComponentTransform>> = {\n schemas: transformSchema,\n responses: responseType,\n parameters: parameterType,\n requestBodies: requestBodyType,\n headers: headerType,\n pathItems: pathItemType,\n mediaTypes: contentEntryType,\n};\n\n/** The `components` type and the `--root-types` aliases. */\nexport interface ComponentsResult {\n readonly type: IrType;\n readonly rootTypes: readonly IrTypeAliasDeclaration[];\n}\n\n/** One component; the `transform` callback may replace its type, as for nested schemas. */\nfunction componentMember(\n kind: ComponentKind,\n name: string,\n item: unknown,\n context: TransformContext,\n): IrPropertySignature {\n const location = { path: createRef([\"components\", kind, name]), schema: item };\n const type = COMPONENT_TRANSFORMS[kind](item as never, location, context);\n const custom = context.callbacks.transform(item, location);\n const property = irProperty(toPropertyName(name), custom?.type ?? type, {\n isOptional: custom?.isOptional ?? false,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, item, schemaCommentOptionsOf(context.options.fixes));\n}\n\n/**\n * The root alias name: `SchemaPet`, `ResponseNotFound`, … A taken name gets `_2`, `_3`, … The\n * original checks for conflicts before it removes the schema prefix, and so does this; for a clash\n * of exported names see `addRootAlias`.\n *\n * The original could build a name that is no identifier, so the generated file did not parse\n * (research/legacy-bugs.md, item 16): a kept casing keeps spaces and symbols, which become `_`;\n * and a name without the prefix can start with a digit, so it keeps the prefix (`Schema1`). A\n * kept casing without the prefix can also give a reserved name (`void`, `class`), which keeps the\n * prefix too (`Schemavoid`).\n */\nfunction rootTypeName(\n kind: ComponentKind,\n name: string,\n aliases: Readonly<Record<string, IrTypeAliasDeclaration>>,\n context: TransformContext,\n): string {\n const { options, casing } = context;\n const prefix = casing.pascalCase(singularizeComponentKind(kind));\n const isSchema = kind === \"schemas\";\n const base = withIdentifierParts(\n options.rootTypesKeepCasing && isSchema ? name : casing.pascalCase(name),\n );\n const exportedName = (alias: string): string => {\n const unprefixed = alias.replace(prefix, \"\");\n const isUnprefixed = options.rootTypesNoSchemaPrefix && isSchema;\n const isTypeName = hasIdentifierStart(unprefixed) && !isReservedTypeName(unprefixed);\n return isUnprefixed && isTypeName ? unprefixed : alias;\n };\n let alias = `${prefix}${base}`;\n for (let counter = 2; aliases[alias] !== undefined; counter++) {\n alias = `${prefix}${base}_${counter}`;\n }\n return exportedName(alias);\n}\n\n/**\n * Add a root alias. When its exported name is taken (two schemas of one PascalCase name without\n * the prefix), the later schema takes the name, as in the original. Without the\n * `root-type-numbering` fix the earlier one then has no alias: that output is valid, so a number\n * for it would change it (backlog 30). With the fix the earlier alias is kept aside and follows\n * the others under the same name; `renameTakenAliases` numbers it once every name is known.\n */\nfunction addRootAlias(request: ComponentsRequest, alias: IrTypeAliasDeclaration): void {\n const { aliases, displaced } = request;\n const previous = aliases[alias.name];\n if (previous !== undefined && displaced !== null) {\n displaced.push(previous);\n }\n aliases[alias.name] = alias;\n}\n\n/** `--root-types` skips enum schemas under `--enum`: the enum itself is exported. */\nfunction hasRootType(kind: ComponentKind, item: unknown, context: TransformContext): boolean {\n const { options } = context;\n return options.rootTypes && !(options.enum && kind === \"schemas\" && isEnumSchema(item));\n}\n\n/** The components of one run, and the deprecated ones that kept output still references. */\ninterface ComponentsRequest {\n readonly components: ComponentsObject;\n readonly isKept: DeprecatedEntryFilter;\n readonly aliases: Record<string, IrTypeAliasDeclaration>;\n /** With the `root-type-numbering` fix: the aliases a later schema took the name of, in order. */\n readonly displaced: IrTypeAliasDeclaration[] | null;\n}\n\nfunction kindMember(\n kind: ComponentKind,\n request: ComponentsRequest,\n context: TransformContext,\n): IrPropertySignature {\n const { components, isKept, aliases } = request;\n const startedAt = context.diagnostics.now();\n const items: IrPropertySignature[] = [];\n for (const [name, item] of documentEntries(components[kind] ?? {}, context.options, isKept)) {\n items.push(componentMember(kind, name, item, context));\n if (hasRootType(kind, item, context)) {\n addRootAlias(request, rootTypeAlias(rootTypeName(kind, name, aliases, context), kind, name));\n }\n }\n const type = items.length > 0 ? irObject(items) : irKeyword(\"never\");\n context.diagnostics.debug(\n `Transformed components → ${kind}`,\n context.diagnostics.now() - startedAt,\n );\n return irProperty(toPropertyName(kind), type);\n}\n\n/**\n * The `components` interface body (OpenAPI 3.1 §4.8.7), one member per component kind. With\n * `--exclude-deprecated`, `kept` holds the deprecated components that kept output references\n * (`keptDeprecatedComponents`); they stay, so no reference names a missing key.\n */\nexport function componentsType(\n components: ComponentsObject,\n context: TransformContext,\n kept: ReadonlySet<object> = new Set(),\n): ComponentsResult {\n // A plain object, as in the original: its key order (integer-like names first) is the\n // output order.\n const aliases: Record<string, IrTypeAliasDeclaration> = {};\n const displaced = context.options.fixes.has(FIX.ROOT_TYPE_NUMBERING) ? [] : null;\n const isKept = (item: unknown) => kept.has(item as object);\n const request = { components, isKept, aliases, displaced };\n const declaredKinds = DECLARED_COMPONENT_KINDS.filter((kind) => components[kind] !== undefined);\n const members = [...COMPONENT_KINDS, ...declaredKinds].map((kind) =>\n kindMember(kind, request, context),\n );\n const rootTypes = Object.values(aliases);\n return {\n type: irObject(members),\n rootTypes: [...rootTypes, ...(displaced ?? [])],\n };\n}\n"],"names":["transformSchema","responseType","parameterType","requestBodyType","headerType","pathItemType","contentEntryType","createRef","irProperty","toPropertyName","withSchemaComment","schemaCommentOptionsOf","singularizeComponentKind","withIdentifierParts","alias","hasIdentifierStart","isReservedTypeName","isEnumSchema","documentEntries","rootTypeAlias","irObject","irKeyword","FIX","DECLARED_COMPONENT_KINDS","COMPONENT_KINDS"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCA,MAAM,oBAAA,GAA4E;AAAA,EAChF,OAAA,EAASA,+BAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC,uBAAA;AAAA,EACZ,aAAA,EAAeC,2BAAA;AAAA,EACf,OAAA,EAASC,iBAAA;AAAA,EACT,SAAA,EAAWC,qBAAA;AAAA,EACX,UAAA,EAAYC;AACd,CAAA;AASA,SAAS,eAAA,CACP,IAAA,EACA,IAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAMC,qBAAA,CAAU,CAAC,YAAA,EAAc,IAAA,EAAM,IAAI,CAAC,CAAA,EAAG,MAAA,EAAQ,IAAA,EAAK;AAC7E,EAAA,MAAM,OAAO,oBAAA,CAAqB,IAAI,CAAA,CAAE,IAAA,EAAe,UAAU,OAAO,CAAA;AACxE,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,SAAA,CAAU,SAAA,CAAU,MAAM,QAAQ,CAAA;AACzD,EAAA,MAAM,WAAWC,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,MAAA,EAAQ,QAAQ,IAAA,EAAM;AAAA,IACtE,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACD,EAAA,OAAOC,gCAAkB,QAAA,EAAU,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