openapi-typesafe 1.0.0-rc.5 → 1.0.0-rc.6

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 (148) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/adapters/redocly-loader/query-document-names.cjs +50 -0
  3. package/dist/adapters/redocly-loader/query-document-names.cjs.map +1 -0
  4. package/dist/adapters/redocly-loader/query-document-names.mjs +48 -0
  5. package/dist/adapters/redocly-loader/query-document-names.mjs.map +1 -0
  6. package/dist/adapters/redocly-loader/query-named-components.cjs +29 -37
  7. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -1
  8. package/dist/adapters/redocly-loader/query-named-components.mjs +29 -37
  9. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -1
  10. package/dist/adapters/redocly-loader/redocly-config-source.cjs +3 -0
  11. package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/redocly-config-source.mjs +4 -1
  13. package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +16 -7
  15. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  16. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +17 -8
  17. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  18. package/dist/adapters/redocly-loader/ref-access.cjs +9 -1
  19. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  20. package/dist/adapters/redocly-loader/ref-access.mjs +10 -2
  21. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  22. package/dist/adapters/redocly-loader/remote-fetch.cjs +16 -1
  23. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  24. package/dist/adapters/redocly-loader/remote-fetch.mjs +16 -2
  25. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  26. package/dist/api/cwd-option.cjs +58 -0
  27. package/dist/api/cwd-option.cjs.map +1 -0
  28. package/dist/api/cwd-option.mjs +52 -0
  29. package/dist/api/cwd-option.mjs.map +1 -0
  30. package/dist/api/default-ports.cjs +15 -7
  31. package/dist/api/default-ports.cjs.map +1 -1
  32. package/dist/api/default-ports.mjs +14 -8
  33. package/dist/api/default-ports.mjs.map +1 -1
  34. package/dist/api/document-run.cjs +2 -16
  35. package/dist/api/document-run.cjs.map +1 -1
  36. package/dist/api/document-run.mjs +2 -12
  37. package/dist/api/document-run.mjs.map +1 -1
  38. package/dist/api/legacy-utils.cjs +1 -1
  39. package/dist/api/legacy-utils.cjs.map +1 -1
  40. package/dist/api/legacy-utils.mjs +1 -1
  41. package/dist/api/legacy-utils.mjs.map +1 -1
  42. package/dist/api/openapi-ts.cjs.map +1 -1
  43. package/dist/api/openapi-ts.mjs.map +1 -1
  44. package/dist/api/option-errors.cjs +24 -0
  45. package/dist/api/option-errors.cjs.map +1 -0
  46. package/dist/api/option-errors.mjs +21 -0
  47. package/dist/api/option-errors.mjs.map +1 -0
  48. package/dist/api/ref-limit-options.cjs +19 -24
  49. package/dist/api/ref-limit-options.cjs.map +1 -1
  50. package/dist/api/ref-limit-options.mjs +15 -20
  51. package/dist/api/ref-limit-options.mjs.map +1 -1
  52. package/dist/application/transform/document/path-template-refs.cjs +12 -2
  53. package/dist/application/transform/document/path-template-refs.cjs.map +1 -1
  54. package/dist/application/transform/document/path-template-refs.mjs +12 -2
  55. package/dist/application/transform/document/path-template-refs.mjs.map +1 -1
  56. package/dist/application/transform/ref-pointer/generated-shape.cjs +28 -10
  57. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  58. package/dist/application/transform/ref-pointer/generated-shape.mjs +29 -11
  59. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  60. package/dist/application/transform/ref-pointer/original-index.cjs +1 -1
  61. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  62. package/dist/application/transform/ref-pointer/original-index.mjs +1 -1
  63. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  64. package/dist/application/transform/ref-pointer/property-shape.cjs +5 -0
  65. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -1
  66. package/dist/application/transform/ref-pointer/property-shape.mjs +5 -1
  67. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -1
  68. package/dist/application/transform/ref-pointer/typed-walk.cjs +11 -1
  69. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  70. package/dist/application/transform/ref-pointer/typed-walk.mjs +12 -2
  71. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  72. package/dist/cli/api-settings.cjs +3 -2
  73. package/dist/cli/api-settings.cjs.map +1 -1
  74. package/dist/cli/api-settings.mjs +2 -1
  75. package/dist/cli/api-settings.mjs.map +1 -1
  76. package/dist/cli/api-writes.cjs +7 -1
  77. package/dist/cli/api-writes.cjs.map +1 -1
  78. package/dist/cli/api-writes.mjs +7 -1
  79. package/dist/cli/api-writes.mjs.map +1 -1
  80. package/dist/cli/cli-arguments.cjs +25 -107
  81. package/dist/cli/cli-arguments.cjs.map +1 -1
  82. package/dist/cli/cli-arguments.mjs +18 -100
  83. package/dist/cli/cli-arguments.mjs.map +1 -1
  84. package/dist/cli/cli-errors.cjs +1 -0
  85. package/dist/cli/cli-errors.cjs.map +1 -1
  86. package/dist/cli/cli-errors.mjs +1 -0
  87. package/dist/cli/cli-errors.mjs.map +1 -1
  88. package/dist/cli/cli-flag-names.cjs +77 -0
  89. package/dist/cli/cli-flag-names.cjs.map +1 -0
  90. package/dist/cli/cli-flag-names.mjs +64 -0
  91. package/dist/cli/cli-flag-names.mjs.map +1 -0
  92. package/dist/cli/cli-output.cjs +7 -2
  93. package/dist/cli/cli-output.cjs.map +1 -1
  94. package/dist/cli/cli-output.mjs +7 -2
  95. package/dist/cli/cli-output.mjs.map +1 -1
  96. package/dist/cli/main.cjs +1 -1
  97. package/dist/cli/main.cjs.map +1 -1
  98. package/dist/cli/main.mjs +1 -1
  99. package/dist/cli/main.mjs.map +1 -1
  100. package/dist/cli/redocly-apis.cjs +14 -4
  101. package/dist/cli/redocly-apis.cjs.map +1 -1
  102. package/dist/cli/redocly-apis.mjs +14 -4
  103. package/dist/cli/redocly-apis.mjs.map +1 -1
  104. package/dist/cli/written-flags.cjs +83 -0
  105. package/dist/cli/written-flags.cjs.map +1 -0
  106. package/dist/cli/written-flags.mjs +77 -0
  107. package/dist/cli/written-flags.mjs.map +1 -0
  108. package/dist/domain/errors.cjs +1 -0
  109. package/dist/domain/errors.cjs.map +1 -1
  110. package/dist/domain/errors.mjs +1 -0
  111. package/dist/domain/errors.mjs.map +1 -1
  112. package/dist/domain/location-text.cjs +7 -1
  113. package/dist/domain/location-text.cjs.map +1 -1
  114. package/dist/domain/location-text.mjs +7 -1
  115. package/dist/domain/location-text.mjs.map +1 -1
  116. package/dist/index.d.cts +3 -0
  117. package/dist/index.d.mts +3 -0
  118. package/dist/index.d.ts +3 -0
  119. package/package.json +1 -1
  120. package/src/adapters/redocly-loader/query-document-names.ts +79 -0
  121. package/src/adapters/redocly-loader/query-named-components.ts +48 -49
  122. package/src/adapters/redocly-loader/redocly-config-source.ts +11 -1
  123. package/src/adapters/redocly-loader/redocly-schema-loader.ts +20 -6
  124. package/src/adapters/redocly-loader/ref-access.ts +16 -2
  125. package/src/adapters/redocly-loader/remote-fetch.ts +26 -0
  126. package/src/api/cwd-option.ts +76 -0
  127. package/src/api/default-ports.ts +33 -10
  128. package/src/api/document-run.ts +2 -17
  129. package/src/api/legacy-utils.ts +1 -1
  130. package/src/api/openapi-ts.ts +14 -1
  131. package/src/api/option-errors.ts +22 -0
  132. package/src/api/ref-limit-options.ts +17 -24
  133. package/src/application/ports/redocly-config-source.ts +5 -0
  134. package/src/application/transform/document/path-template-refs.ts +28 -7
  135. package/src/application/transform/ref-pointer/generated-shape.ts +57 -14
  136. package/src/application/transform/ref-pointer/original-index.ts +6 -3
  137. package/src/application/transform/ref-pointer/property-shape.ts +9 -0
  138. package/src/application/transform/ref-pointer/typed-walk.ts +26 -4
  139. package/src/cli/api-writes.ts +11 -3
  140. package/src/cli/cli-arguments.ts +42 -153
  141. package/src/cli/cli-errors.ts +1 -0
  142. package/src/cli/cli-flag-names.ts +99 -0
  143. package/src/cli/cli-output.ts +20 -6
  144. package/src/cli/main.ts +2 -1
  145. package/src/cli/redocly-apis.ts +21 -5
  146. package/src/cli/written-flags.ts +131 -0
  147. package/src/domain/errors.ts +1 -0
  148. package/src/domain/location-text.ts +17 -2
@@ -1 +1 @@
1
- {"version":3,"file":"document-run.cjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import path from \"node:path\";\nimport { 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 { 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 { refAccessOf } from \"./ref-limit-options.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, the local files it was read from, and the run's context. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly localFiles: readonly URL[];\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\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 // The options with their defaults: `defaultNonNullable` is on unless set to false.\n const flags = contextFlags(options);\n for (const notice of ineffectiveFixNotices(names, (option) => flags[option])) {\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 { document: schema, localFiles } = 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, localFiles, ctx };\n}\n"],"names":["path","processCwd","pathToFileURL","outputFixNamesOf","ineffectiveFixNotices","warningText","WARNING_CODES","resolveOutputFixes","withStackOverflowReported","warnUnsupportedFeatures","warnDiscriminatorValueConflicts","warnIdenticalPathTemplates","sourceEmptyError","refAccessOf","findDiscriminators","resolveDocumentRef"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8DA,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;AAEA,SAAS,gBAAgB,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,GACtB;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,GAAA,EAAI;AACnC;;"}
1
+ {"version":3,"file":"document-run.cjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import 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 { 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 { sourceCwdOf } from \"./cwd-option.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 { refAccessOf } from \"./ref-limit-options.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, the local files it was read from, and the run's context. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly localFiles: readonly URL[];\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\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 // The options with their defaults: `defaultNonNullable` is on unless set to false.\n const flags = contextFlags(options);\n for (const notice of ineffectiveFixNotices(names, (option) => flags[option])) {\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 = sourceCwdOf(options);\n const { document: schema, localFiles } = 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, localFiles, ctx };\n}\n"],"names":["outputFixNamesOf","ineffectiveFixNotices","warningText","WARNING_CODES","resolveOutputFixes","withStackOverflowReported","warnUnsupportedFeatures","warnDiscriminatorValueConflicts","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CAAmB,QAAQ,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACtE,MAAA;AAAA,IACA,cAAc,KAAA,CAAM;AAAA,GACtB;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,GAAA,EAAI;AACnC;;"}
@@ -1,10 +1,8 @@
1
- import path from 'node:path';
2
- import { pathToFileURL } from 'node:url';
3
1
  import { sourceEmptyError } from '../adapters/redocly-loader/schema-load-errors.mjs';
4
2
  import { withStackOverflowReported } from '../application/stack-overflow.mjs';
5
3
  import { outputFixNamesOf, ineffectiveFixNotices, resolveOutputFixes } from '../domain/output-fixes.mjs';
6
4
  import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
7
- import { processCwd } from './default-ports.mjs';
5
+ import { sourceCwdOf } from './cwd-option.mjs';
8
6
  import { warnDiscriminatorValueConflicts } from './discriminator-conflict-warnings.mjs';
9
7
  import { findDiscriminators } from './discriminator-scan.mjs';
10
8
  import { resolveDocumentRef } from './document-refs.mjs';
@@ -12,14 +10,6 @@ import { warnIdenticalPathTemplates } from './path-template-warnings.mjs';
12
10
  import { refAccessOf } from './ref-limit-options.mjs';
13
11
  import { warnUnsupportedFeatures } from './unsupported-feature-warnings.mjs';
14
12
 
15
- function sourceCwd(options) {
16
- const { cwd } = options;
17
- if (cwd instanceof URL) {
18
- return cwd.pathname.endsWith("/") ? cwd : new URL(`${cwd.pathname}/`, cwd);
19
- }
20
- const directory = path.resolve(cwd === void 0 ? processCwd() : cwd.toString());
21
- return pathToFileURL(path.join(directory, path.sep));
22
- }
23
13
  function callbackOptions(options) {
24
14
  return {
25
15
  irCallbacks: options.irCallbacks === true,
@@ -79,7 +69,7 @@ async function createDocumentRun(source, options, ports) {
79
69
  const { logger } = ports;
80
70
  const fix = outputFixesOf(options, logger);
81
71
  const silent = options.silent ?? false;
82
- const cwd = sourceCwd(options);
72
+ const cwd = sourceCwdOf(options);
83
73
  const { document: schema, localFiles } = await ports.loader.load({
84
74
  source,
85
75
  cwd,
@@ -1 +1 @@
1
- {"version":3,"file":"document-run.mjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import path from \"node:path\";\nimport { 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 { 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 { refAccessOf } from \"./ref-limit-options.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, the local files it was read from, and the run's context. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly localFiles: readonly URL[];\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\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 // The options with their defaults: `defaultNonNullable` is on unless set to false.\n const flags = contextFlags(options);\n for (const notice of ineffectiveFixNotices(names, (option) => flags[option])) {\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 { document: schema, localFiles } = 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, localFiles, ctx };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8DA,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;AAEA,SAAS,gBAAgB,OAAA,EAA2B;AAClD,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,QAAQ,WAAA,KAAgB,IAAA;AAAA,IACrC,eAAe,OAAO,OAAA,CAAQ,aAAA,KAAkB,UAAA,GAAa,QAAQ,aAAA,GAAgB,MAAA;AAAA,IACrF,WAAW,OAAO,OAAA,CAAQ,SAAA,KAAc,UAAA,GAAa,QAAQ,SAAA,GAAY,MAAA;AAAA,IACzE,mBACE,OAAO,OAAA,CAAQ,iBAAA,KAAsB,UAAA,GAAa,QAAQ,iBAAA,GAAoB;AAAA,GAClF;AACF;AAEA,SAAS,aAAa,OAAA,EAAyC;AAC7D,EAAA,OAAO;AAAA,IACL,oBAAA,EAAsB,QAAQ,oBAAA,IAAwB,KAAA;AAAA,IACtD,WAAA,EAAa,QAAQ,WAA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AAA;AAAA,IACA,GAAA;AAAA,IACA,UAAA,EAAY,QAAQ,IAAA,IAAQ,IAAA;AAAA,IAC5B,SAAA,EAAW,WAAA,CAAY,OAAA,EAAS,GAAG;AAAA,GACpC,CAAA;AACD,EAAA,iBAAA,CAAkB,MAAA,EAAQ,KAAK,MAAM,CAAA;AACrC,EAAA,MAAM,GAAA,GAAkB;AAAA,IACtB,GAAG,aAAa,OAAO,CAAA;AAAA,IACvB,GAAA;AAAA;AAAA;AAAA,IAGA,cAAA,EAAgB,yBAAA;AAAA,MAA0B,WAAA;AAAA,MAAa,MACrD,mBAAmB,MAAA,EAAQ;AAAA,QACzB,MAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,IAAI,GAAA,CAAI,GAAG;AAAA,OACnB;AAAA,KACH;AAAA,IACA,cAAc,EAAC;AAAA,IACf,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,OAAA,EAAS,CAAC,IAAA,KAAS,kBAAA,CAAmB,QAAQ,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACtE,MAAA;AAAA,IACA,cAAc,KAAA,CAAM;AAAA,GACtB;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,GAAA,EAAI;AACnC;;"}
1
+ {"version":3,"file":"document-run.mjs","sources":["../../src/api/document-run.ts"],"sourcesContent":["import 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 { 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 { sourceCwdOf } from \"./cwd-option.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 { refAccessOf } from \"./ref-limit-options.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, the local files it was read from, and the run's context. */\nexport interface DocumentRun {\n readonly schema: OpenAPI3;\n readonly localFiles: readonly URL[];\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\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 // The options with their defaults: `defaultNonNullable` is on unless set to false.\n const flags = contextFlags(options);\n for (const notice of ineffectiveFixNotices(names, (option) => flags[option])) {\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 = sourceCwdOf(options);\n const { document: schema, localFiles } = 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, localFiles, ctx };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAwDA,SAAS,gBAAgB,OAAA,EAA2B;AAClD,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,QAAQ,WAAA,KAAgB,IAAA;AAAA,IACrC,eAAe,OAAO,OAAA,CAAQ,aAAA,KAAkB,UAAA,GAAa,QAAQ,aAAA,GAAgB,MAAA;AAAA,IACrF,WAAW,OAAO,OAAA,CAAQ,SAAA,KAAc,UAAA,GAAa,QAAQ,SAAA,GAAY,MAAA;AAAA,IACzE,mBACE,OAAO,OAAA,CAAQ,iBAAA,KAAsB,UAAA,GAAa,QAAQ,iBAAA,GAAoB;AAAA,GAClF;AACF;AAEA,SAAS,aAAa,OAAA,EAAyC;AAC7D,EAAA,OAAO;AAAA,IACL,oBAAA,EAAsB,QAAQ,oBAAA,IAAwB,KAAA;AAAA,IACtD,WAAA,EAAa,QAAQ,WAAA,IAAe,KAAA;AAAA,IACpC,WAAA,EAAa,QAAQ,WAAA,IAAe,KAAA;AAAA,IACpC,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,IAC5B,SAAA,EAAW,WAAA,CAAY,OAAA,EAAS,GAAG;AAAA,GACpC,CAAA;AACD,EAAA,iBAAA,CAAkB,MAAA,EAAQ,KAAK,MAAM,CAAA;AACrC,EAAA,MAAM,GAAA,GAAkB;AAAA,IACtB,GAAG,aAAa,OAAO,CAAA;AAAA,IACvB,GAAA;AAAA;AAAA;AAAA,IAGA,cAAA,EAAgB,yBAAA;AAAA,MAA0B,WAAA;AAAA,MAAa,MACrD,mBAAmB,MAAA,EAAQ;AAAA,QACzB,MAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,IAAI,GAAA,CAAI,GAAG;AAAA,OACnB;AAAA,KACH;AAAA,IACA,cAAc,EAAC;AAAA,IACf,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,OAAA,EAAS,CAAC,IAAA,KAAS,kBAAA,CAAmB,QAAQ,IAAA,EAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACtE,MAAA;AAAA,IACA,cAAc,KAAA,CAAM;AAAA,GACtB;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAA,EAAY,GAAA,EAAI;AACnC;;"}
@@ -11,7 +11,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  const colors__default = /*#__PURE__*/_interopDefaultCompat(colors);
13
13
 
14
- if (!defaultPorts.terminalSupportsColor()) {
14
+ if (!defaultPorts.terminalSupportsColor("stdout")) {
15
15
  colors__default.enabled = false;
16
16
  }
17
17
  const c = colors__default;
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-utils.cjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor()) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["terminalSupportsColor","colors","discriminatorProperty","createDomainRef","defaultLogger","formatDuration","resolveDocumentRef","walkDocument"],"mappings":";;;;;;;;;;;;;AAiBA,IAAI,CAACA,oCAAsB,EAAG;AAC5B,EAAAC,eAAA,CAAO,OAAA,GAAU,KAAA;AACnB;AAMO,MAAM,CAAA,GAAIA;AAMV,SAAS,4BACd,aAAA,EACA,EAAE,IAAA,EAAM,QAAA,GAAW,OAAM,EACJ;AACrB,EAAA,OAAOC,2CAAA,CAAsB,aAAA,EAAe,IAAA,EAAM,QAAQ,CAAA;AAC5D;AAOO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOC,sBAAgB,KAAK,CAAA;AAC9B;AAMO,SAAS,KAAA,CAA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A,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAAH,0BAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;;;;;;;;;;"}
1
+ {"version":3,"file":"legacy-utils.cjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor(\"stdout\")) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["terminalSupportsColor","colors","discriminatorProperty","createDomainRef","defaultLog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A,KAAM,EAAE,CAAA,IAAK,OAAO,CAAA,KAAM,QAAA,IAAY,YAAA,IAAgB,CAAA,IAAK,CAAA,CAAE,UAAA;AAAA,KACpE;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAQO,SAAS,UAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,EACe;AACf,EAAA,OAAOC,+BAAA,CAAsB,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAA;AACpD;AAMO,SAAS,IAAA,CACd,GAAA,EACA,EAAA,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAAC,yBAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAAH,0BAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ import { createRef as createRef$1 } from '../domain/openapi/json-pointer.mjs';
5
5
  import { terminalSupportsColor, defaultLogger } from './default-ports.mjs';
6
6
  import { resolveDocumentRef, walkDocument } from './document-refs.mjs';
7
7
 
8
- if (!terminalSupportsColor()) {
8
+ if (!terminalSupportsColor("stdout")) {
9
9
  colors.enabled = false;
10
10
  }
11
11
  const c = colors;
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-utils.mjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor()) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["createDomainRef"],"mappings":";;;;;;;AAiBA,IAAI,CAAC,uBAAsB,EAAG;AAC5B,EAAA,MAAA,CAAO,OAAA,GAAU,KAAA;AACnB;AAMO,MAAM,CAAA,GAAI;AAMV,SAAS,4BACd,aAAA,EACA,EAAE,IAAA,EAAM,QAAA,GAAW,OAAM,EACJ;AACrB,EAAA,OAAO,qBAAA,CAAsB,aAAA,EAAe,IAAA,EAAM,QAAQ,CAAA;AAC5D;AAOO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOA,YAAgB,KAAK,CAAA;AAC9B;AAMO,SAAS,KAAA,CAAM,GAAA,EAAa,KAAA,EAAgB,IAAA,EAAe;AAEhE,EAAA,aAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAA,EAAK,OAAiC,IAAI,CAAA;AACvE;AAMO,SAAS,MAAM,GAAA,EAAa;AACjC,EAAA,aAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA;AAChC;AAGO,SAAS,WAAW,CAAA,EAAW;AACpC,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,GAAW,cAAA,CAAe,CAAC,CAAA,GAAI,CAAA;AACrD;AAGO,SAAS,UAAA,CACd,KACA,OAAA,EAIA;AACA,EAAA,IAAI,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA;AAChC,EAAA,IAAI,SAAS,WAAA,EAAa;AACxB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAC,CAAA,EAAG,CAAC,CAAC,CAAA,KAAM,CAAA,CAAE,aAAA,CAAc,GAAG,OAAA,EAAS,EAAE,OAAA,EAAS,IAAA,EAAM,CAAC,CAAA;AAAA,EAC3E;AACA,EAAA,IAAI,SAAS,iBAAA,EAAmB;AAC9B,IAAA,OAAA,GAAU,OAAA,CAAQ,MAAA;AAAA,MAChB,CAAC,GAAG,CAAC,CAAA,KAAM,EAAE,CAAA,IAAK,OAAO,CAAA,KAAM,QAAA,IAAY,YAAA,IAAgB,CAAA,IAAK,CAAA,CAAE,UAAA;AAAA,KACpE;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAQO,SAAS,UAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAsB,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAA;AACpD;AAMO,SAAS,IAAA,CACd,GAAA,EACA,EAAA,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAA,YAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAA,aAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;"}
1
+ {"version":3,"file":"legacy-utils.mjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor(\"stdout\")) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["createDomainRef"],"mappings":";;;;;;;AAiBA,IAAI,CAAC,qBAAA,CAAsB,QAAQ,CAAA,EAAG;AACpC,EAAA,MAAA,CAAO,OAAA,GAAU,KAAA;AACnB;AAMO,MAAM,CAAA,GAAI;AAMV,SAAS,4BACd,aAAA,EACA,EAAE,IAAA,EAAM,QAAA,GAAW,OAAM,EACJ;AACrB,EAAA,OAAO,qBAAA,CAAsB,aAAA,EAAe,IAAA,EAAM,QA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,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAA,YAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAA,aAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;"}
@@ -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 type { Logger } from \"../application/ports/logger.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/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = 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 { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.\n */\nexport async function defaultGeneratorPorts(\n options: GeneratorOptions,\n logger: Logger = defaultLogger(options.silent ?? false),\n): Promise<GeneratorPorts> {\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":";;;;;;;;;;AA4BA,eAAsB,gBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,QAAQ,UAAA,EAAY,GAAA,KAAQ,MAAMA,6BAAA,CAAkB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAClF,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,eAAeC,uCAAA,CAA0B,WAAA,EAAa,MAAMC,uBAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC9F,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,EAAE,cAAc,UAAA,EAAW;AACpC;AAGA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,OAAA,CAAQ,MAAM,gBAAA,CAAiB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA,EAAG,YAAA;AAC1D;AAMA,eAAsB,sBACpB,OAAA,EACA,MAAA,GAAiBC,2BAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA,EAC7B;AACzB,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
+ {"version":3,"file":"openapi-ts.cjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, OpenAPITSOptions, 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/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = 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 { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.\n */\nexport async function defaultGeneratorPorts(\n options: GeneratorOptions,\n logger: Logger = defaultLogger(options.silent ?? false),\n): Promise<GeneratorPorts> {\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 function openapiTS(\n source: SchemaSource,\n options?: OpenAPITSOptions,\n): Promise<IrDeclaration[]>;\n// The options without `irCallbacks` get their own signature: TypeScript does not pick a member of\n// `GeneratorOptions | undefined` (an optional parameter) by a key that the object leaves out, so\n// inline callbacks had implicit `any` parameters (TS7006). `irCallbacks: true` picks the member\n// here. This signature is last, so `Parameters<typeof openapiTS>` reads it.\n/** Convert an OpenAPI schema to IR declarations, with either form of the options. */\nexport default function openapiTS(\n source: SchemaSource,\n options?: GeneratorOptions,\n): Promise<IrDeclaration[]>;\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":";;;;;;;;;;AA4BA,eAAsB,gBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,QAAQ,UAAA,EAAY,GAAA,KAAQ,MAAMA,6BAAA,CAAkB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAClF,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,eAAeC,uCAAA,CAA0B,WAAA,EAAa,MAAMC,uBAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC9F,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,EAAE,cAAc,UAAA,EAAW;AACpC;AAGA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,OAAA,CAAQ,MAAM,gBAAA,CAAiB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA,EAAG,YAAA;AAC1D;AAMA,eAAsB,sBACpB,OAAA,EACA,MAAA,GAAiBC,2BAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA,EAC7B;AACzB,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;AAuBA,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 +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 type { Logger } from \"../application/ports/logger.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/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = 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 { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.\n */\nexport async function defaultGeneratorPorts(\n options: GeneratorOptions,\n logger: Logger = defaultLogger(options.silent ?? false),\n): Promise<GeneratorPorts> {\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":";;;;;;AA4BA,eAAsB,gBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,QAAQ,UAAA,EAAY,GAAA,KAAQ,MAAM,iBAAA,CAAkB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAClF,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,eAAe,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC9F,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,EAAE,cAAc,UAAA,EAAW;AACpC;AAGA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,OAAA,CAAQ,MAAM,gBAAA,CAAiB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA,EAAG,YAAA;AAC1D;AAMA,eAAsB,sBACpB,OAAA,EACA,MAAA,GAAiB,cAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA,EAC7B;AACzB,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
+ {"version":3,"file":"openapi-ts.mjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, OpenAPITSOptions, 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/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = 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 { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.\n */\nexport async function defaultGeneratorPorts(\n options: GeneratorOptions,\n logger: Logger = defaultLogger(options.silent ?? false),\n): Promise<GeneratorPorts> {\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 function openapiTS(\n source: SchemaSource,\n options?: OpenAPITSOptions,\n): Promise<IrDeclaration[]>;\n// The options without `irCallbacks` get their own signature: TypeScript does not pick a member of\n// `GeneratorOptions | undefined` (an optional parameter) by a key that the object leaves out, so\n// inline callbacks had implicit `any` parameters (TS7006). `irCallbacks: true` picks the member\n// here. This signature is last, so `Parameters<typeof openapiTS>` reads it.\n/** Convert an OpenAPI schema to IR declarations, with either form of the options. */\nexport default function openapiTS(\n source: SchemaSource,\n options?: GeneratorOptions,\n): Promise<IrDeclaration[]>;\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":";;;;;;AA4BA,eAAsB,gBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,QAAQ,UAAA,EAAY,GAAA,KAAQ,MAAM,iBAAA,CAAkB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAClF,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,eAAe,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC9F,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,EAAE,cAAc,UAAA,EAAW;AACpC;AAGA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,OAAA,CAAQ,MAAM,gBAAA,CAAiB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA,EAAG,YAAA;AAC1D;AAMA,eAAsB,sBACpB,OAAA,EACA,MAAA,GAAiB,cAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA,EAC7B;AACzB,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;AAuBA,eAA8B,SAAA,CAC5B,MAAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const errors = require('../domain/errors.cjs');
4
+
5
+ function kindOf(value) {
6
+ if (value instanceof URL) {
7
+ return `a ${value.protocol} URL`;
8
+ }
9
+ if (Array.isArray(value)) {
10
+ return "a list";
11
+ }
12
+ return value === null ? "null" : `a ${typeof value}`;
13
+ }
14
+ function optionInvalid(option, expected, got) {
15
+ return new errors.OpenAPITypesafeError({
16
+ code: errors.ERROR_CODES.OPTION_INVALID,
17
+ message: `The ${option} option must be ${expected}; got ${got}.`,
18
+ details: { option }
19
+ });
20
+ }
21
+
22
+ exports.kindOf = kindOf;
23
+ exports.optionInvalid = optionInvalid;
24
+ //# sourceMappingURL=option-errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-errors.cjs","sources":["../../src/api/option-errors.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/** The `OPTION_INVALID` errors of the Node API's options, checked before anything loads. */\n\n/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */\nexport function kindOf(value: unknown): string {\n if (value instanceof URL) {\n return `a ${value.protocol} URL`;\n }\n if (Array.isArray(value)) {\n return \"a list\";\n }\n return value === null ? \"null\" : `a ${typeof value}`;\n}\n\nexport function optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {\n return new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_INVALID,\n message: `The ${option} option must be ${expected}; got ${got}.`,\n details: { option },\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAKO,SAAS,OAAO,KAAA,EAAwB;AAC7C,EAAA,IAAI,iBAAiB,GAAA,EAAK;AACxB,IAAA,OAAO,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA,IAAA,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,KAAU,IAAA,GAAO,MAAA,GAAS,CAAA,EAAA,EAAK,OAAO,KAAK,CAAA,CAAA;AACpD;AAEO,SAAS,aAAA,CAAc,MAAA,EAAgB,QAAA,EAAkB,GAAA,EAAmC;AACjG,EAAA,OAAO,IAAIA,2BAAA,CAAqB;AAAA,IAC9B,MAAMC,kBAAA,CAAY,cAAA;AAAA,IAClB,SAAS,CAAA,IAAA,EAAO,MAAM,CAAA,gBAAA,EAAmB,QAAQ,SAAS,GAAG,CAAA,CAAA,CAAA;AAAA,IAC7D,OAAA,EAAS,EAAE,MAAA;AAAO,GACnB,CAAA;AACH;;;"}
@@ -0,0 +1,21 @@
1
+ import { OpenAPITypesafeError, ERROR_CODES } from '../domain/errors.mjs';
2
+
3
+ function kindOf(value) {
4
+ if (value instanceof URL) {
5
+ return `a ${value.protocol} URL`;
6
+ }
7
+ if (Array.isArray(value)) {
8
+ return "a list";
9
+ }
10
+ return value === null ? "null" : `a ${typeof value}`;
11
+ }
12
+ function optionInvalid(option, expected, got) {
13
+ return new OpenAPITypesafeError({
14
+ code: ERROR_CODES.OPTION_INVALID,
15
+ message: `The ${option} option must be ${expected}; got ${got}.`,
16
+ details: { option }
17
+ });
18
+ }
19
+
20
+ export { kindOf, optionInvalid };
21
+ //# sourceMappingURL=option-errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-errors.mjs","sources":["../../src/api/option-errors.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/** The `OPTION_INVALID` errors of the Node API's options, checked before anything loads. */\n\n/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */\nexport function kindOf(value: unknown): string {\n if (value instanceof URL) {\n return `a ${value.protocol} URL`;\n }\n if (Array.isArray(value)) {\n return \"a list\";\n }\n return value === null ? \"null\" : `a ${typeof value}`;\n}\n\nexport function optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {\n return new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_INVALID,\n message: `The ${option} option must be ${expected}; got ${got}.`,\n details: { option },\n });\n}\n"],"names":[],"mappings":";;AAKO,SAAS,OAAO,KAAA,EAAwB;AAC7C,EAAA,IAAI,iBAAiB,GAAA,EAAK;AACxB,IAAA,OAAO,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA,IAAA,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,KAAU,IAAA,GAAO,MAAA,GAAS,CAAA,EAAA,EAAK,OAAO,KAAK,CAAA,CAAA;AACpD;AAEO,SAAS,aAAA,CAAc,MAAA,EAAgB,QAAA,EAAkB,GAAA,EAAmC;AACjG,EAAA,OAAO,IAAI,oBAAA,CAAqB;AAAA,IAC9B,MAAM,WAAA,CAAY,cAAA;AAAA,IAClB,SAAS,CAAA,IAAA,EAAO,MAAM,CAAA,gBAAA,EAAmB,QAAQ,SAAS,GAAG,CAAA,CAAA,CAAA;AAAA,IAC7D,OAAA,EAAS,EAAE,MAAA;AAAO,GACnB,CAAA;AACH;;"}
@@ -2,52 +2,47 @@
2
2
 
3
3
  const path = require('node:path');
4
4
  const node_url = require('node:url');
5
- const errors = require('../domain/errors.cjs');
6
5
  const locationText = require('../domain/location-text.cjs');
6
+ const optionErrors = require('./option-errors.cjs');
7
7
 
8
8
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
9
 
10
10
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
11
11
 
12
12
  const FILE_PROTOCOL = "file:";
13
- function kindOf(value) {
14
- if (value instanceof URL) {
15
- return `a ${value.protocol} URL`;
16
- }
17
- if (Array.isArray(value)) {
18
- return "a list";
19
- }
20
- return value === null ? "null" : `a ${typeof value}`;
21
- }
22
- function optionInvalid(option, expected, got) {
23
- return new errors.OpenAPITypesafeError({
24
- code: errors.ERROR_CODES.OPTION_INVALID,
25
- message: `The ${option} option must be ${expected}; got ${got}.`,
26
- details: { option }
27
- });
28
- }
29
13
  const LOCAL_ROOT_EXPECTED = "a directory path or a file: URL";
14
+ const RELATIVE_ROOT_EXPECTED = "an absolute path or a file: URL when cwd is no file: URL";
30
15
  function localRootUrlOf(value, cwd) {
31
- if (!locationText.hasUrlScheme(value)) {
32
- return node_url.pathToFileURL(path__default.resolve(node_url.fileURLToPath(cwd), value));
16
+ if (locationText.hasUrlScheme(value)) {
17
+ return URL.parse(value, cwd.href) ?? void 0;
18
+ }
19
+ if (path__default.isAbsolute(value)) {
20
+ return node_url.pathToFileURL(value);
21
+ }
22
+ if (cwd.protocol !== FILE_PROTOCOL) {
23
+ throw optionErrors.optionInvalid(
24
+ "localRefRoot",
25
+ RELATIVE_ROOT_EXPECTED,
26
+ `a relative path, and cwd is ${optionErrors.kindOf(cwd)}`
27
+ );
33
28
  }
34
- return URL.parse(value, cwd.href) ?? void 0;
29
+ return node_url.pathToFileURL(path__default.resolve(node_url.fileURLToPath(cwd), value));
35
30
  }
36
31
  function localRootOf(value, cwd) {
37
32
  const root = typeof value === "string" ? localRootUrlOf(value, cwd) : value;
38
33
  if (root instanceof URL && root.protocol === FILE_PROTOCOL) {
39
34
  return root;
40
35
  }
41
- const got = root === void 0 ? "a string that is no valid URL" : kindOf(root);
42
- throw optionInvalid("localRefRoot", LOCAL_ROOT_EXPECTED, got);
36
+ const got = root === void 0 ? "a string that is no valid URL" : optionErrors.kindOf(root);
37
+ throw optionErrors.optionInvalid("localRefRoot", LOCAL_ROOT_EXPECTED, got);
43
38
  }
44
39
  function remoteHostsOf(value) {
45
40
  if (!Array.isArray(value)) {
46
- throw optionInvalid("remoteRefHosts", "a list of hosts", kindOf(value));
41
+ throw optionErrors.optionInvalid("remoteRefHosts", "a list of hosts", optionErrors.kindOf(value));
47
42
  }
48
43
  const other = value.find((entry) => typeof entry !== "string");
49
44
  if (other !== void 0) {
50
- throw optionInvalid("remoteRefHosts", "a list of hosts", `a list with ${kindOf(other)}`);
45
+ throw optionErrors.optionInvalid("remoteRefHosts", "a list of hosts", `a list with ${optionErrors.kindOf(other)}`);
51
46
  }
52
47
  return value;
53
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ref-limit-options.cjs","sources":["../../src/api/ref-limit-options.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { RefAccess } from \"../application/ports/schema-loader.js\";\nimport { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\nimport { hasUrlScheme } from \"../domain/location-text.js\";\nimport type { GeneratorOptions } from \"../types.js\";\n\n/**\n * The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.\n * A value of another type from JavaScript (`remoteRefHosts: \"a.com\"`, `localRefRoot: new\n * URL(\"https://…\")`) used to fail later as an error of the document.\n */\n\nconst FILE_PROTOCOL = \"file:\";\n\n/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */\nfunction kindOf(value: unknown): string {\n if (value instanceof URL) {\n return `a ${value.protocol} URL`;\n }\n if (Array.isArray(value)) {\n return \"a list\";\n }\n return value === null ? \"null\" : `a ${typeof value}`;\n}\n\nfunction optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {\n return new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_INVALID,\n message: `The ${option} option must be ${expected}; got ${got}.`,\n details: { option },\n });\n}\n\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\n\n/**\n * A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),\n * else a path that resolves against the cwd. Undefined when it does not parse as a URL.\n */\nfunction localRootUrlOf(value: string, cwd: URL): URL | undefined {\n if (!hasUrlScheme(value)) {\n return pathToFileURL(path.resolve(fileURLToPath(cwd), value));\n }\n return URL.parse(value, cwd.href) ?? undefined;\n}\n\n/** The local root as a `file:` URL; the option is set, so it is not undefined. */\nfunction localRootOf(value: unknown, cwd: URL): URL {\n const root = typeof value === \"string\" ? localRootUrlOf(value, cwd) : value;\n if (root instanceof URL && root.protocol === FILE_PROTOCOL) {\n return root;\n }\n const got = root === undefined ? \"a string that is no valid URL\" : kindOf(root);\n throw optionInvalid(\"localRefRoot\", LOCAL_ROOT_EXPECTED, got);\n}\n\nfunction remoteHostsOf(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", kindOf(value));\n }\n const other = value.find((entry) => typeof entry !== \"string\");\n if (other !== undefined) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", `a list with ${kindOf(other)}`);\n }\n return value;\n}\n\n/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */\nexport function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n return {\n ...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),\n };\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES","hasUrlScheme","pathToFileURL","path","fileURLToPath"],"mappings":";;;;;;;;;;;AAaA,MAAM,aAAA,GAAgB,OAAA;AAGtB,SAAS,OAAO,KAAA,EAAwB;AACtC,EAAA,IAAI,iBAAiB,GAAA,EAAK;AACxB,IAAA,OAAO,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA,IAAA,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,KAAU,IAAA,GA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AA,MAAM,aAAA,CAAc,gBAAA,EAAkB,iBAAA,EAAmB,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,KAAA,KAAU,OAAO,UAAU,QAAQ,CAAA;AAC7D,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAM,cAAc,gBAAA,EAAkB,iBAAA,EAAmB,eAAe,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AAC1E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,WAAA,CAAY,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAClF,GAAI,mBAAmB,MAAA,GAAY,KAAK,EAAE,WAAA,EAAa,aAAA,CAAc,cAAc,CAAA;AAAE,GACvF;AACF;;"}
1
+ {"version":3,"file":"ref-limit-options.cjs","sources":["../../src/api/ref-limit-options.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { RefAccess } from \"../application/ports/schema-loader.js\";\nimport { hasUrlScheme } from \"../domain/location-text.js\";\nimport type { GeneratorOptions } from \"../types.js\";\nimport { kindOf, optionInvalid } from \"./option-errors.js\";\n\n/**\n * The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.\n * A value of another type from JavaScript (`remoteRefHosts: \"a.com\"`, `localRefRoot: new\n * URL(\"https://…\")`) used to fail later as an error of the document.\n */\n\nconst FILE_PROTOCOL = \"file:\";\n\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\nconst RELATIVE_ROOT_EXPECTED = \"an absolute path or a file: URL when cwd is no file: URL\";\n\n/**\n * A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),\n * else a path that resolves against the cwd. Undefined when it does not parse as a URL. A\n * relative path needs a local cwd: with an `http:` cwd it names no local directory.\n */\nfunction localRootUrlOf(value: string, cwd: URL): URL | undefined {\n if (hasUrlScheme(value)) {\n return URL.parse(value, cwd.href) ?? undefined;\n }\n if (path.isAbsolute(value)) {\n return pathToFileURL(value);\n }\n if (cwd.protocol !== FILE_PROTOCOL) {\n throw optionInvalid(\n \"localRefRoot\",\n RELATIVE_ROOT_EXPECTED,\n `a relative path, and cwd is ${kindOf(cwd)}`,\n );\n }\n return pathToFileURL(path.resolve(fileURLToPath(cwd), value));\n}\n\n/** The local root as a `file:` URL; the option is set, so it is not undefined. */\nfunction localRootOf(value: unknown, cwd: URL): URL {\n const root = typeof value === \"string\" ? localRootUrlOf(value, cwd) : value;\n if (root instanceof URL && root.protocol === FILE_PROTOCOL) {\n return root;\n }\n const got = root === undefined ? \"a string that is no valid URL\" : kindOf(root);\n throw optionInvalid(\"localRefRoot\", LOCAL_ROOT_EXPECTED, got);\n}\n\nfunction remoteHostsOf(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", kindOf(value));\n }\n const other = value.find((entry) => typeof entry !== \"string\");\n if (other !== undefined) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", `a list with ${kindOf(other)}`);\n }\n return value;\n}\n\n/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */\nexport function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n return {\n ...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),\n };\n}\n"],"names":["hasUrlScheme","path","pathToFileURL","optionInvalid","kindOf","fileURLToPath"],"mappings":";;;;;;;;;;;AAaA,MAA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AA,MAAMA,0BAAA,CAAc,gBAAA,EAAkB,iBAAA,EAAmBC,mBAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,KAAA,KAAU,OAAO,UAAU,QAAQ,CAAA;AAC7D,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAMD,2BAAc,gBAAA,EAAkB,iBAAA,EAAmB,eAAeC,mBAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AAC1E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,WAAA,CAAY,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAClF,GAAI,mBAAmB,MAAA,GAAY,KAAK,EAAE,WAAA,EAAa,aAAA,CAAc,cAAc,CAAA;AAAE,GACvF;AACF;;"}
@@ -1,31 +1,26 @@
1
1
  import path from 'node:path';
2
2
  import { pathToFileURL, fileURLToPath } from 'node:url';
3
- import { OpenAPITypesafeError, ERROR_CODES } from '../domain/errors.mjs';
4
3
  import { hasUrlScheme } from '../domain/location-text.mjs';
4
+ import { optionInvalid, kindOf } from './option-errors.mjs';
5
5
 
6
6
  const FILE_PROTOCOL = "file:";
7
- function kindOf(value) {
8
- if (value instanceof URL) {
9
- return `a ${value.protocol} URL`;
10
- }
11
- if (Array.isArray(value)) {
12
- return "a list";
13
- }
14
- return value === null ? "null" : `a ${typeof value}`;
15
- }
16
- function optionInvalid(option, expected, got) {
17
- return new OpenAPITypesafeError({
18
- code: ERROR_CODES.OPTION_INVALID,
19
- message: `The ${option} option must be ${expected}; got ${got}.`,
20
- details: { option }
21
- });
22
- }
23
7
  const LOCAL_ROOT_EXPECTED = "a directory path or a file: URL";
8
+ const RELATIVE_ROOT_EXPECTED = "an absolute path or a file: URL when cwd is no file: URL";
24
9
  function localRootUrlOf(value, cwd) {
25
- if (!hasUrlScheme(value)) {
26
- return pathToFileURL(path.resolve(fileURLToPath(cwd), value));
10
+ if (hasUrlScheme(value)) {
11
+ return URL.parse(value, cwd.href) ?? void 0;
12
+ }
13
+ if (path.isAbsolute(value)) {
14
+ return pathToFileURL(value);
15
+ }
16
+ if (cwd.protocol !== FILE_PROTOCOL) {
17
+ throw optionInvalid(
18
+ "localRefRoot",
19
+ RELATIVE_ROOT_EXPECTED,
20
+ `a relative path, and cwd is ${kindOf(cwd)}`
21
+ );
27
22
  }
28
- return URL.parse(value, cwd.href) ?? void 0;
23
+ return pathToFileURL(path.resolve(fileURLToPath(cwd), value));
29
24
  }
30
25
  function localRootOf(value, cwd) {
31
26
  const root = typeof value === "string" ? localRootUrlOf(value, cwd) : value;
@@ -1 +1 @@
1
- {"version":3,"file":"ref-limit-options.mjs","sources":["../../src/api/ref-limit-options.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { RefAccess } from \"../application/ports/schema-loader.js\";\nimport { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\nimport { hasUrlScheme } from \"../domain/location-text.js\";\nimport type { GeneratorOptions } from \"../types.js\";\n\n/**\n * The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.\n * A value of another type from JavaScript (`remoteRefHosts: \"a.com\"`, `localRefRoot: new\n * URL(\"https://…\")`) used to fail later as an error of the document.\n */\n\nconst FILE_PROTOCOL = \"file:\";\n\n/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */\nfunction kindOf(value: unknown): string {\n if (value instanceof URL) {\n return `a ${value.protocol} URL`;\n }\n if (Array.isArray(value)) {\n return \"a list\";\n }\n return value === null ? \"null\" : `a ${typeof value}`;\n}\n\nfunction optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {\n return new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_INVALID,\n message: `The ${option} option must be ${expected}; got ${got}.`,\n details: { option },\n });\n}\n\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\n\n/**\n * A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),\n * else a path that resolves against the cwd. Undefined when it does not parse as a URL.\n */\nfunction localRootUrlOf(value: string, cwd: URL): URL | undefined {\n if (!hasUrlScheme(value)) {\n return pathToFileURL(path.resolve(fileURLToPath(cwd), value));\n }\n return URL.parse(value, cwd.href) ?? undefined;\n}\n\n/** The local root as a `file:` URL; the option is set, so it is not undefined. */\nfunction localRootOf(value: unknown, cwd: URL): URL {\n const root = typeof value === \"string\" ? localRootUrlOf(value, cwd) : value;\n if (root instanceof URL && root.protocol === FILE_PROTOCOL) {\n return root;\n }\n const got = root === undefined ? \"a string that is no valid URL\" : kindOf(root);\n throw optionInvalid(\"localRefRoot\", LOCAL_ROOT_EXPECTED, got);\n}\n\nfunction remoteHostsOf(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", kindOf(value));\n }\n const other = value.find((entry) => typeof entry !== \"string\");\n if (other !== undefined) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", `a list with ${kindOf(other)}`);\n }\n return value;\n}\n\n/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */\nexport function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n return {\n ...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),\n };\n}\n"],"names":[],"mappings":";;;;;AAaA,MAAM,aAAA,GAAgB,OAAA;AAGtB,SAAS,OAAO,KAAA,EAAwB;AACtC,EAAA,IAAI,iBAAiB,GAAA,EAA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C,OAAO,IAAI,CAAA;AAC9E,EAAA,MAAM,aAAA,CAAc,cAAA,EAAgB,mBAAA,EAAqB,GAAG,CAAA;AAC9D;AAEA,SAAS,cAAc,KAAA,EAAmC;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACzB,IAAA,MAAM,aAAA,CAAc,gBAAA,EAAkB,iBAAA,EAAmB,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,KAAA,KAAU,OAAO,UAAU,QAAQ,CAAA;AAC7D,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAM,cAAc,gBAAA,EAAkB,iBAAA,EAAmB,eAAe,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AAC1E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,WAAA,CAAY,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAClF,GAAI,mBAAmB,MAAA,GAAY,KAAK,EAAE,WAAA,EAAa,aAAA,CAAc,cAAc,CAAA;AAAE,GACvF;AACF;;"}
1
+ {"version":3,"file":"ref-limit-options.mjs","sources":["../../src/api/ref-limit-options.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { RefAccess } from \"../application/ports/schema-loader.js\";\nimport { hasUrlScheme } from \"../domain/location-text.js\";\nimport type { GeneratorOptions } from \"../types.js\";\nimport { kindOf, optionInvalid } from \"./option-errors.js\";\n\n/**\n * The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.\n * A value of another type from JavaScript (`remoteRefHosts: \"a.com\"`, `localRefRoot: new\n * URL(\"https://…\")`) used to fail later as an error of the document.\n */\n\nconst FILE_PROTOCOL = \"file:\";\n\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\nconst RELATIVE_ROOT_EXPECTED = \"an absolute path or a file: URL when cwd is no file: URL\";\n\n/**\n * A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),\n * else a path that resolves against the cwd. Undefined when it does not parse as a URL. A\n * relative path needs a local cwd: with an `http:` cwd it names no local directory.\n */\nfunction localRootUrlOf(value: string, cwd: URL): URL | undefined {\n if (hasUrlScheme(value)) {\n return URL.parse(value, cwd.href) ?? undefined;\n }\n if (path.isAbsolute(value)) {\n return pathToFileURL(value);\n }\n if (cwd.protocol !== FILE_PROTOCOL) {\n throw optionInvalid(\n \"localRefRoot\",\n RELATIVE_ROOT_EXPECTED,\n `a relative path, and cwd is ${kindOf(cwd)}`,\n );\n }\n return pathToFileURL(path.resolve(fileURLToPath(cwd), value));\n}\n\n/** The local root as a `file:` URL; the option is set, so it is not undefined. */\nfunction localRootOf(value: unknown, cwd: URL): URL {\n const root = typeof value === \"string\" ? localRootUrlOf(value, cwd) : value;\n if (root instanceof URL && root.protocol === FILE_PROTOCOL) {\n return root;\n }\n const got = root === undefined ? \"a string that is no valid URL\" : kindOf(root);\n throw optionInvalid(\"localRefRoot\", LOCAL_ROOT_EXPECTED, got);\n}\n\nfunction remoteHostsOf(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", kindOf(value));\n }\n const other = value.find((entry) => typeof entry !== \"string\");\n if (other !== undefined) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", `a list with ${kindOf(other)}`);\n }\n return value;\n}\n\n/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */\nexport function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n return {\n ...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),\n };\n}\n"],"names":[],"mappings":";;;;;AAaA,MAAM,aAAA,GAAgB,OAAA;AAEtB,MAAM,mBAAA,GAAsB,iCAAA;AAC5B,MAAM,sBAAA,GAAyB,0DAAA;AAO/B,SAAS,cAAA,CAAe,OAAe,GAAA,EAA2B;AAChE,EAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG;AACvB,IAAA,OAAO,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO,GAAA,CAAI,IAAI,CAAA,IAAK,MAAA;AAAA,EACvC;AACA,EAAA,IAAI,IAAA,CAAK,UAAA,CAAW,KAAK,CAAA,EAAG;AAC1B,IAAA,OAAO,cAAc,KAAK,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,GAAA,CAAI,aAAa,aAAA,EAAe;AAClC,IAAA,MAAM,aAAA;AAAA,MACJ,cAAA;AAAA,MACA,sBAAA;AAAA,MACA,CAAA,4BAAA,EAA+B,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,KAC5C;AAAA,EACF;AACA,EAAA,OAAO,cAAc,IAAA,CAAK,OAAA,CAAQ,cAAc,GAAG,CAAA,EAAG,KAAK,CAAC,CAAA;AAC9D;AAGA,SAAS,WAAA,CAAY,OAAgB,GAAA,EAAe;AAClD,EAAA,MAAM,OAAO,OAAO,KAAA,KAAU,WAAW,cAAA,CAAe,KAAA,EAAO,GAAG,CAAA,GAAI,KAAA;AACtE,EAAA,IAAI,IAAA,YAAgB,GAAA,IAAO,IAAA,CAAK,QAAA,KAAa,aAAA,EAAe;AAC1D,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAM,IAAA,KAAS,MAAA,GAAY,+BAAA,GAAkC,OAAO,IAAI,CAAA;AAC9E,EAAA,MAAM,aAAA,CAAc,cAAA,EAAgB,mBAAA,EAAqB,GAAG,CAAA;AAC9D;AAEA,SAAS,cAAc,KAAA,EAAmC;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACzB,IAAA,MAAM,aAAA,CAAc,gBAAA,EAAkB,iBAAA,EAAmB,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,KAAA,KAAU,OAAO,UAAU,QAAQ,CAAA;AAC7D,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAM,cAAc,gBAAA,EAAkB,iBAAA,EAAmB,eAAe,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AAC1E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,WAAA,CAAY,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAClF,GAAI,mBAAmB,MAAA,GAAY,KAAK,EAAE,WAAA,EAAa,aAAA,CAAc,cAAc,CAAA;AAAE,GACvF;AACF;;"}
@@ -2,6 +2,7 @@
2
2
 
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const documentEntries = require('../document-entries.cjs');
5
+ const helperTypes = require('../helper-types.cjs');
5
6
  const pathTemplateKey = require('./path-template-key.cjs');
6
7
  const paths = require('./paths.cjs');
7
8
 
@@ -37,10 +38,19 @@ function unmatchedTemplateKeys(paths, context) {
37
38
  function isNode(value) {
38
39
  return typeof value === "object" && value !== null;
39
40
  }
41
+ function isBarePathsReference(node) {
42
+ const reference = node;
43
+ return reference?.kind === "reference" && reference.name === PATHS_TYPE_NAME && reference.typeArguments?.length === 0;
44
+ }
45
+ function isPathsRoot(node) {
46
+ const reference = node;
47
+ const typeArguments = reference?.typeArguments;
48
+ const isDeepRoot = reference?.kind === "reference" && reference.name === helperTypes.HELPER_TYPES.flattenedDeepRequired.name && typeArguments?.length === 1 && isBarePathsReference(typeArguments[0]);
49
+ return isDeepRoot || isBarePathsReference(node);
50
+ }
40
51
  function pathsIndexUrl(node) {
41
- const object = node.object;
42
52
  const index = node.index;
43
- const isPathsIndex = node.kind === "indexedAccess" && object?.kind === "reference" && object.name === PATHS_TYPE_NAME && object.typeArguments?.length === 0 && index?.kind === "stringLiteral";
53
+ const isPathsIndex = node.kind === "indexedAccess" && isPathsRoot(node.object) && index?.kind === "stringLiteral";
44
54
  return isPathsIndex ? index.value : void 0;
45
55
  }
46
56
  function rewrittenNode(value, keys) {