openapi-typesafe 1.0.0-rc.1 → 1.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/README.md +12 -5
  2. package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
  3. package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
  4. package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
  5. package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
  6. package/dist/adapters/redocly-loader/configured-headers.cjs +32 -0
  7. package/dist/adapters/redocly-loader/configured-headers.cjs.map +1 -0
  8. package/dist/adapters/redocly-loader/configured-headers.mjs +30 -0
  9. package/dist/adapters/redocly-loader/configured-headers.mjs.map +1 -0
  10. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +19 -6
  11. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +18 -5
  13. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/ref-access.cjs +37 -4
  15. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  16. package/dist/adapters/redocly-loader/ref-access.mjs +37 -4
  17. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  18. package/dist/adapters/redocly-loader/ref-resolution-check.cjs +191 -0
  19. package/dist/adapters/redocly-loader/ref-resolution-check.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/ref-resolution-check.mjs +189 -0
  21. package/dist/adapters/redocly-loader/ref-resolution-check.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/ref-resolution-steps.cjs +73 -0
  23. package/dist/adapters/redocly-loader/ref-resolution-steps.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/ref-resolution-steps.mjs +60 -0
  25. package/dist/adapters/redocly-loader/ref-resolution-steps.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/remote-fetch.cjs +41 -14
  27. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  28. package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -14
  29. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  30. package/dist/adapters/redocly-loader/schema-load-errors.cjs +23 -5
  31. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/schema-load-errors.mjs +23 -5
  33. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/unsupported-keys.cjs +9 -1
  35. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/unsupported-keys.mjs +9 -1
  37. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  38. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  39. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  40. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  41. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  42. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +2 -1
  43. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
  44. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +2 -1
  45. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
  46. package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -1
  47. package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -1
  48. package/dist/api/default-ports.cjs +14 -0
  49. package/dist/api/default-ports.cjs.map +1 -1
  50. package/dist/api/default-ports.mjs +12 -1
  51. package/dist/api/default-ports.mjs.map +1 -1
  52. package/dist/api/discriminator-conflict-warnings.cjs +1 -1
  53. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
  54. package/dist/api/discriminator-conflict-warnings.mjs +2 -2
  55. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
  56. package/dist/api/discriminator-patch.cjs +8 -4
  57. package/dist/api/discriminator-patch.cjs.map +1 -1
  58. package/dist/api/discriminator-patch.mjs +9 -5
  59. package/dist/api/discriminator-patch.mjs.map +1 -1
  60. package/dist/api/discriminator-scan.cjs +2 -2
  61. package/dist/api/discriminator-scan.cjs.map +1 -1
  62. package/dist/api/discriminator-scan.mjs +3 -3
  63. package/dist/api/discriminator-scan.mjs.map +1 -1
  64. package/dist/api/document-refs.cjs +15 -12
  65. package/dist/api/document-refs.cjs.map +1 -1
  66. package/dist/api/document-refs.mjs +15 -12
  67. package/dist/api/document-refs.mjs.map +1 -1
  68. package/dist/api/document-run.cjs +6 -3
  69. package/dist/api/document-run.cjs.map +1 -1
  70. package/dist/api/document-run.mjs +6 -3
  71. package/dist/api/document-run.mjs.map +1 -1
  72. package/dist/api/footer-sink.cjs +25 -2
  73. package/dist/api/footer-sink.cjs.map +1 -1
  74. package/dist/api/footer-sink.mjs +25 -2
  75. package/dist/api/footer-sink.mjs.map +1 -1
  76. package/dist/api/legacy-callback-warning.cjs +7 -1
  77. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  78. package/dist/api/legacy-callback-warning.mjs +8 -2
  79. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  80. package/dist/api/legacy-ts-helpers.cjs.map +1 -1
  81. package/dist/api/legacy-ts-helpers.mjs.map +1 -1
  82. package/dist/api/legacy-utils.cjs.map +1 -1
  83. package/dist/api/legacy-utils.mjs.map +1 -1
  84. package/dist/api/openapi-ts.cjs +3 -2
  85. package/dist/api/openapi-ts.cjs.map +1 -1
  86. package/dist/api/openapi-ts.mjs +4 -3
  87. package/dist/api/openapi-ts.mjs.map +1 -1
  88. package/dist/api/string-to-ast.cjs +7 -9
  89. package/dist/api/string-to-ast.cjs.map +1 -1
  90. package/dist/api/string-to-ast.mjs +8 -9
  91. package/dist/api/string-to-ast.mjs.map +1 -1
  92. package/dist/api/transform-context.cjs +1 -1
  93. package/dist/api/transform-context.cjs.map +1 -1
  94. package/dist/api/transform-context.mjs +1 -1
  95. package/dist/api/transform-context.mjs.map +1 -1
  96. package/dist/api/transform-schema.cjs +2 -2
  97. package/dist/api/transform-schema.cjs.map +1 -1
  98. package/dist/api/transform-schema.mjs +3 -3
  99. package/dist/api/transform-schema.mjs.map +1 -1
  100. package/dist/application/print/type-printer.cjs +2 -1
  101. package/dist/application/print/type-printer.cjs.map +1 -1
  102. package/dist/application/print/type-printer.mjs +2 -1
  103. package/dist/application/print/type-printer.mjs.map +1 -1
  104. package/dist/application/transform/document/components.cjs +1 -1
  105. package/dist/application/transform/document/components.cjs.map +1 -1
  106. package/dist/application/transform/document/components.mjs +2 -2
  107. package/dist/application/transform/document/components.mjs.map +1 -1
  108. package/dist/application/transform/document/parameters.cjs +2 -2
  109. package/dist/application/transform/document/parameters.cjs.map +1 -1
  110. package/dist/application/transform/document/parameters.mjs +3 -3
  111. package/dist/application/transform/document/parameters.mjs.map +1 -1
  112. package/dist/application/transform/document/paths.cjs +2 -2
  113. package/dist/application/transform/document/paths.cjs.map +1 -1
  114. package/dist/application/transform/document/paths.mjs +3 -3
  115. package/dist/application/transform/document/paths.mjs.map +1 -1
  116. package/dist/application/transform/footer/evaluation.cjs +9 -0
  117. package/dist/application/transform/footer/evaluation.cjs.map +1 -1
  118. package/dist/application/transform/footer/evaluation.mjs +8 -1
  119. package/dist/application/transform/footer/evaluation.mjs.map +1 -1
  120. package/dist/application/transform/footer/type-evaluation.cjs +4 -112
  121. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  122. package/dist/application/transform/footer/type-evaluation.mjs +4 -112
  123. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  124. package/dist/application/transform/footer/type-indexing.cjs +107 -0
  125. package/dist/application/transform/footer/type-indexing.cjs.map +1 -0
  126. package/dist/application/transform/footer/type-indexing.mjs +105 -0
  127. package/dist/application/transform/footer/type-indexing.mjs.map +1 -0
  128. package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
  129. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  130. package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
  131. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  132. package/dist/application/transform/schema/access-flags.cjs +1 -1
  133. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  134. package/dist/application/transform/schema/access-flags.mjs +2 -2
  135. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  136. package/dist/application/transform/schema/array-type.cjs +2 -2
  137. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  138. package/dist/application/transform/schema/array-type.mjs +3 -3
  139. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  140. package/dist/application/transform/schema/composition-type.cjs +3 -3
  141. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  142. package/dist/application/transform/schema/composition-type.mjs +4 -4
  143. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  144. package/dist/application/transform/schema/enum-rule.cjs +3 -5
  145. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  146. package/dist/application/transform/schema/enum-rule.mjs +4 -6
  147. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  148. package/dist/application/transform/schema/presence-members.cjs +1 -1
  149. package/dist/application/transform/schema/presence-members.cjs.map +1 -1
  150. package/dist/application/transform/schema/presence-members.mjs +2 -2
  151. package/dist/application/transform/schema/presence-members.mjs.map +1 -1
  152. package/dist/application/transform/schema/required-variants.cjs +2 -2
  153. package/dist/application/transform/schema/required-variants.cjs.map +1 -1
  154. package/dist/application/transform/schema/required-variants.mjs +3 -3
  155. package/dist/application/transform/schema/required-variants.mjs.map +1 -1
  156. package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
  157. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  158. package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
  159. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  160. package/dist/application/transform/schema-comment.cjs +1 -1
  161. package/dist/application/transform/schema-comment.cjs.map +1 -1
  162. package/dist/application/transform/schema-comment.mjs +2 -2
  163. package/dist/application/transform/schema-comment.mjs.map +1 -1
  164. package/dist/cli/api-settings.cjs +78 -0
  165. package/dist/cli/api-settings.cjs.map +1 -0
  166. package/dist/cli/api-settings.mjs +73 -0
  167. package/dist/cli/api-settings.mjs.map +1 -0
  168. package/dist/cli/cli-arguments.cjs +1 -0
  169. package/dist/cli/cli-arguments.cjs.map +1 -1
  170. package/dist/cli/cli-arguments.mjs +1 -1
  171. package/dist/cli/cli-arguments.mjs.map +1 -1
  172. package/dist/cli/help-text.cjs +3 -3
  173. package/dist/cli/help-text.cjs.map +1 -1
  174. package/dist/cli/help-text.mjs +3 -3
  175. package/dist/cli/help-text.mjs.map +1 -1
  176. package/dist/cli/redocly-apis.cjs +8 -4
  177. package/dist/cli/redocly-apis.cjs.map +1 -1
  178. package/dist/cli/redocly-apis.mjs +7 -3
  179. package/dist/cli/redocly-apis.mjs.map +1 -1
  180. package/dist/cli/run-cli.cjs +5 -1
  181. package/dist/cli/run-cli.cjs.map +1 -1
  182. package/dist/cli/run-cli.mjs +5 -1
  183. package/dist/cli/run-cli.mjs.map +1 -1
  184. package/dist/domain/deprecations.cjs +11 -0
  185. package/dist/domain/deprecations.cjs.map +1 -0
  186. package/dist/domain/deprecations.mjs +9 -0
  187. package/dist/domain/deprecations.mjs.map +1 -0
  188. package/dist/domain/errors.cjs +4 -1
  189. package/dist/domain/errors.cjs.map +1 -1
  190. package/dist/domain/errors.mjs +4 -1
  191. package/dist/domain/errors.mjs.map +1 -1
  192. package/dist/domain/ir/constructors.cjs +2 -0
  193. package/dist/domain/ir/constructors.cjs.map +1 -1
  194. package/dist/domain/ir/constructors.mjs +2 -1
  195. package/dist/domain/ir/constructors.mjs.map +1 -1
  196. package/dist/domain/openapi/path-templates.cjs +1 -1
  197. package/dist/domain/openapi/path-templates.cjs.map +1 -1
  198. package/dist/domain/openapi/path-templates.mjs +1 -1
  199. package/dist/domain/openapi/path-templates.mjs.map +1 -1
  200. package/dist/domain/output-fixes.cjs +11 -14
  201. package/dist/domain/output-fixes.cjs.map +1 -1
  202. package/dist/domain/output-fixes.mjs +11 -13
  203. package/dist/domain/output-fixes.mjs.map +1 -1
  204. package/dist/domain/url-credentials.cjs +10 -0
  205. package/dist/domain/url-credentials.cjs.map +1 -0
  206. package/dist/domain/url-credentials.mjs +8 -0
  207. package/dist/domain/url-credentials.mjs.map +1 -0
  208. package/dist/domain/warnings.cjs +8 -1
  209. package/dist/domain/warnings.cjs.map +1 -1
  210. package/dist/domain/warnings.mjs +8 -1
  211. package/dist/domain/warnings.mjs.map +1 -1
  212. package/dist/index.cjs +4 -3
  213. package/dist/index.cjs.map +1 -1
  214. package/dist/index.d.cts +1185 -59
  215. package/dist/index.d.mts +1185 -59
  216. package/dist/index.d.ts +1185 -59
  217. package/dist/index.mjs +4 -2
  218. package/dist/index.mjs.map +1 -1
  219. package/dist/transform/path-item-object.cjs.map +1 -1
  220. package/dist/transform/path-item-object.mjs.map +1 -1
  221. package/package.json +5 -4
  222. package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
  223. package/src/adapters/redocly-loader/configured-headers.ts +65 -0
  224. package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -7
  225. package/src/adapters/redocly-loader/ref-access.ts +60 -5
  226. package/src/adapters/redocly-loader/ref-resolution-check.ts +257 -0
  227. package/src/adapters/redocly-loader/ref-resolution-steps.ts +113 -0
  228. package/src/adapters/redocly-loader/remote-fetch.ts +77 -21
  229. package/src/adapters/redocly-loader/schema-load-errors.ts +33 -11
  230. package/src/adapters/redocly-loader/unsupported-keys.ts +17 -2
  231. package/src/adapters/terminal-logger/terminal-logger.ts +9 -5
  232. package/src/adapters/type-ast-bridge/ir-to-typescript.ts +2 -1
  233. package/src/adapters/type-ast-bridge/print-typescript.ts +3 -1
  234. package/src/adapters/type-ast-bridge/typescript-types.ts +57 -5
  235. package/src/api/default-ports.ts +23 -0
  236. package/src/api/discriminator-conflict-warnings.ts +2 -2
  237. package/src/api/discriminator-patch.ts +11 -7
  238. package/src/api/discriminator-scan.ts +3 -3
  239. package/src/api/document-refs.ts +19 -15
  240. package/src/api/document-run.ts +14 -6
  241. package/src/api/footer-sink.ts +34 -2
  242. package/src/api/legacy-callback-warning.ts +16 -5
  243. package/src/api/legacy-ts-helpers.ts +7 -5
  244. package/src/api/legacy-utils.ts +1 -1
  245. package/src/api/openapi-ts.ts +8 -2
  246. package/src/api/run-context.ts +37 -0
  247. package/src/api/string-to-ast.ts +11 -15
  248. package/src/api/transform-context.ts +10 -8
  249. package/src/api/transform-schema.ts +9 -8
  250. package/src/application/ports/deprecation-reporter.ts +9 -0
  251. package/src/application/print/type-printer.ts +2 -1
  252. package/src/application/transform/document/components.ts +2 -2
  253. package/src/application/transform/document/parameters.ts +4 -3
  254. package/src/application/transform/document/paths.ts +4 -3
  255. package/src/application/transform/footer/evaluation.ts +10 -0
  256. package/src/application/transform/footer/type-evaluation.ts +6 -133
  257. package/src/application/transform/footer/type-indexing.ts +152 -0
  258. package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
  259. package/src/application/transform/schema/access-flags.ts +2 -2
  260. package/src/application/transform/schema/array-type.ts +3 -5
  261. package/src/application/transform/schema/composition-type.ts +4 -4
  262. package/src/application/transform/schema/enum-rule.ts +4 -6
  263. package/src/application/transform/schema/presence-members.ts +2 -2
  264. package/src/application/transform/schema/required-variants.ts +3 -3
  265. package/src/application/transform/schema/unevaluated-properties.ts +2 -2
  266. package/src/application/transform/schema-comment.ts +2 -2
  267. package/src/cli/api-settings.ts +109 -0
  268. package/src/cli/cli-arguments.ts +5 -2
  269. package/src/cli/help-text.ts +4 -4
  270. package/src/cli/redocly-apis.ts +13 -7
  271. package/src/cli/run-cli.ts +5 -1
  272. package/src/domain/deprecations.ts +15 -0
  273. package/src/domain/errors.ts +16 -4
  274. package/src/domain/ir/constructors.ts +3 -0
  275. package/src/domain/ir/nodes.ts +9 -6
  276. package/src/domain/openapi/path-templates.ts +2 -1
  277. package/src/domain/output-fixes.ts +16 -16
  278. package/src/domain/url-credentials.ts +18 -0
  279. package/src/domain/warnings.ts +7 -0
  280. package/src/index.ts +3 -6
  281. package/src/transform/path-item-object.ts +6 -2
  282. package/src/types/generator-options.ts +12 -32
  283. package/src/types/openapi-common.ts +1 -0
  284. package/src/types/openapi-request.ts +3 -0
  285. package/src/types/openapi-schema.ts +2 -0
  286. package/src/types/openapi-security.ts +1 -0
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const urlCredentials = require('./url-credentials.cjs');
4
+
3
5
  const ERROR_CODES = {
4
6
  SCHEMA_SOURCE_EMPTY: "SCHEMA_SOURCE_EMPTY",
5
7
  SCHEMA_SOURCE_INVALID: "SCHEMA_SOURCE_INVALID",
@@ -32,7 +34,8 @@ class OpenAPITypesafeError extends Error {
32
34
  code;
33
35
  details;
34
36
  constructor(init) {
35
- super(init.message, init.cause === void 0 ? void 0 : { cause: init.cause });
37
+ const message = urlCredentials.redactUrlCredentials(init.message);
38
+ super(message, init.cause === void 0 ? void 0 : { cause: init.cause });
36
39
  this.name = "OpenAPITypesafeError";
37
40
  this.code = init.code;
38
41
  this.details = init.details ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/** Every error code. The set is closed: a new code must be handled by the CLI exit-code table. */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_INVALID: \"CLI_CONFIG_INVALID\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n CLI_INPUT_MISSING: \"CLI_INPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/** Structured, JSON-serializable facts about a failure, for programs and logs. */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/** The base of every expected failure; check `code`, not the class or the message. */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":";;AAQO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,cAAA,EAAgB,gBAAA;AAAA,EAChB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,uBAAA,EAAyB,yBAAA;AAAA,EACzB,eAAA,EAAiB,iBAAA;AAAA,EACjB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,eAAA,EAAiB,iBAAA;AAAA,EACjB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,iBAAA,EAAmB,mBAAA;AAAA,EACnB,YAAA,EAAc,cAAA;AAAA,EACd,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB;AACvB;AAgBO,MAAM,6BAA6B,KAAA,CAAM;AAAA,EACrC,IAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAAgC;AAC1C,IAAA,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,IAAA,CAAK,KAAA,KAAU,MAAA,GAAY,SAAY,EAAE,KAAA,EAAO,IAAA,CAAK,KAAA,EAAO,CAAA;AAChF,IAAA,IAAA,CAAK,IAAA,GAAO,sBAAA;AACZ,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,EAClC;AACF;AAGO,SAAS,uBAAuB,KAAA,EAA+C;AACpF,EAAA,IAAI,iBAAiB,oBAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,OAAQ,KAAA,EAAqC,IAAA;AACnD,EAAA,OACE,KAAA,YAAiB,KAAA,IACjB,OAAO,IAAA,KAAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;;;"}
1
+ {"version":3,"file":"errors.cjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { redactUrlCredentials } from \"./url-credentials.js\";\n\n/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/**\n * Every error code. A minor release may add codes (ADR-034); each one needs a row in the CLI's\n * exit-code table, which the compiler checks.\n */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_INVALID: \"CLI_CONFIG_INVALID\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n CLI_INPUT_MISSING: \"CLI_INPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/**\n * Structured, JSON-serializable facts about a failure, for programs and logs. Only the keys that\n * docs/node.md (Errors) lists are stable (ADR-034, amendment of 2026-11-08).\n */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/**\n * The base of every expected failure; check `code`, not the class or the message. The message\n * never shows the user info of a URL (`url-credentials.ts`).\n */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n const message = redactUrlCredentials(init.message);\n super(message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":["redactUrlCredentials"],"mappings":";;;;AAaO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0B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,IAAI,iBAAiB,oBAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,OAAQ,KAAA,EAAqC,IAAA;AACnD,EAAA,OACE,KAAA,YAAiB,KAAA,IACjB,OAAO,IAAA,KAAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;;;"}
@@ -1,3 +1,5 @@
1
+ import { redactUrlCredentials } from './url-credentials.mjs';
2
+
1
3
  const ERROR_CODES = {
2
4
  SCHEMA_SOURCE_EMPTY: "SCHEMA_SOURCE_EMPTY",
3
5
  SCHEMA_SOURCE_INVALID: "SCHEMA_SOURCE_INVALID",
@@ -30,7 +32,8 @@ class OpenAPITypesafeError extends Error {
30
32
  code;
31
33
  details;
32
34
  constructor(init) {
33
- super(init.message, init.cause === void 0 ? void 0 : { cause: init.cause });
35
+ const message = redactUrlCredentials(init.message);
36
+ super(message, init.cause === void 0 ? void 0 : { cause: init.cause });
34
37
  this.name = "OpenAPITypesafeError";
35
38
  this.code = init.code;
36
39
  this.details = init.details ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/** Every error code. The set is closed: a new code must be handled by the CLI exit-code table. */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_INVALID: \"CLI_CONFIG_INVALID\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n CLI_INPUT_MISSING: \"CLI_INPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/** Structured, JSON-serializable facts about a failure, for programs and logs. */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/** The base of every expected failure; check `code`, not the class or the message. */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":"AAQO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,cAAA,EAAgB,gBAAA;AAAA,EAChB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,uBAAA,EAAyB,yBAAA;AAAA,EACzB,eAAA,EAAiB,iBAAA;AAAA,EACjB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,eAAA,EAAiB,iBAAA;AAAA,EACjB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,kBAAA,EAAoB,oBAAA;AAAA,EACpB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,iBAAA,EAAmB,mBAAA;AAAA,EACnB,YAAA,EAAc,cAAA;AAAA,EACd,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB;AACvB;AAgBO,MAAM,6BAA6B,KAAA,CAAM;AAAA,EACrC,IAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAAgC;AAC1C,IAAA,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,IAAA,CAAK,KAAA,KAAU,MAAA,GAAY,SAAY,EAAE,KAAA,EAAO,IAAA,CAAK,KAAA,EAAO,CAAA;AAChF,IAAA,IAAA,CAAK,IAAA,GAAO,sBAAA;AACZ,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,EAClC;AACF;AAGO,SAAS,uBAAuB,KAAA,EAA+C;AACpF,EAAA,IAAI,iBAAiB,oBAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,OAAQ,KAAA,EAAqC,IAAA;AACnD,EAAA,OACE,KAAA,YAAiB,KAAA,IACjB,OAAO,IAAA,KAAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;"}
1
+ {"version":3,"file":"errors.mjs","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { redactUrlCredentials } from \"./url-credentials.js\";\n\n/**\n * Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI\n * is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The\n * `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken\n * invariant) is a plain `Error`, not one of these.\n */\n\n/**\n * Every error code. A minor release may add codes (ADR-034); each one needs a row in the CLI's\n * exit-code table, which the compiler checks.\n */\nexport const ERROR_CODES = {\n SCHEMA_SOURCE_EMPTY: \"SCHEMA_SOURCE_EMPTY\",\n SCHEMA_SOURCE_INVALID: \"SCHEMA_SOURCE_INVALID\",\n SCHEMA_LOAD_FAILED: \"SCHEMA_LOAD_FAILED\",\n SCHEMA_PARSE_FAILED: \"SCHEMA_PARSE_FAILED\",\n SCHEMA_VERSION_UNSUPPORTED: \"SCHEMA_VERSION_UNSUPPORTED\",\n SCHEMA_INVALID: \"SCHEMA_INVALID\",\n SCHEMA_REF_INVALID: \"SCHEMA_REF_INVALID\",\n SCHEMA_REF_FORBIDDEN: \"SCHEMA_REF_FORBIDDEN\",\n SCHEMA_OBJECT_INVALID: \"SCHEMA_OBJECT_INVALID\",\n SCHEMA_PROPERTY_INVALID: \"SCHEMA_PROPERTY_INVALID\",\n SCHEMA_TOO_DEEP: \"SCHEMA_TOO_DEEP\",\n SCHEMA_KEY_UNSUPPORTED: \"SCHEMA_KEY_UNSUPPORTED\",\n ENUM_NAME_EMPTY: \"ENUM_NAME_EMPTY\",\n CALLBACK_RESULT_UNREADABLE: \"CALLBACK_RESULT_UNREADABLE\",\n OPTION_FIX_UNKNOWN: \"OPTION_FIX_UNKNOWN\",\n TYPESCRIPT_NOT_FOUND: \"TYPESCRIPT_NOT_FOUND\",\n CLI_FLAG_REMOVED: \"CLI_FLAG_REMOVED\",\n CLI_GLOB_UNSUPPORTED: \"CLI_GLOB_UNSUPPORTED\",\n CLI_CONFIG_NOT_FOUND: \"CLI_CONFIG_NOT_FOUND\",\n CLI_CONFIG_INVALID: \"CLI_CONFIG_INVALID\",\n CLI_CONFIG_OUTPUT_MISSING: \"CLI_CONFIG_OUTPUT_MISSING\",\n CLI_CHECK_OUTPUT_MISSING: \"CLI_CHECK_OUTPUT_MISSING\",\n CLI_INPUT_MISSING: \"CLI_INPUT_MISSING\",\n OUTPUT_STALE: \"OUTPUT_STALE\",\n OUTPUT_READ_FAILED: \"OUTPUT_READ_FAILED\",\n OUTPUT_WRITE_FAILED: \"OUTPUT_WRITE_FAILED\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\n/**\n * Structured, JSON-serializable facts about a failure, for programs and logs. Only the keys that\n * docs/node.md (Errors) lists are stable (ADR-034, amendment of 2026-11-08).\n */\nexport type ErrorDetails = Readonly<Record<string, unknown>>;\n\nexport interface OpenAPITypesafeErrorInit {\n readonly code: ErrorCode;\n readonly message: string;\n readonly details?: ErrorDetails;\n /** The lower-level error this one reports, if any (kept as the standard `cause`). */\n readonly cause?: unknown;\n}\n\n/**\n * The base of every expected failure; check `code`, not the class or the message. The message\n * never shows the user info of a URL (`url-credentials.ts`).\n */\nexport class OpenAPITypesafeError extends Error {\n readonly code: ErrorCode;\n readonly details: ErrorDetails;\n\n constructor(init: OpenAPITypesafeErrorInit) {\n const message = redactUrlCredentials(init.message);\n super(message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = \"OpenAPITypesafeError\";\n this.code = init.code;\n this.details = init.details ?? {};\n }\n}\n\n/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */\nexport function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError {\n if (value instanceof OpenAPITypesafeError) {\n return true;\n }\n const code = (value as { code?: unknown } | null)?.code;\n return (\n value instanceof Error &&\n typeof code === \"string\" &&\n Object.hasOwn(ERROR_CODES, code) &&\n typeof (value as { details?: unknown }).details === \"object\"\n );\n}\n"],"names":[],"mappings":";;AAaO,MAAM,WAAA,GAAc;AAAA,EACzB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,cAAA,EAAgB,gBAAA;AAAA,EAChB,kBAAA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AA,MAAM,OAAQ,KAAA,EAAqC,IAAA;AACnD,EAAA,OACE,KAAA,YAAiB,KAAA,IACjB,OAAO,IAAA,KAAS,QAAA,IAChB,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa,IAAI,CAAA,IAC/B,OAAQ,KAAA,CAAgC,OAAA,KAAY,QAAA;AAExD;;"}
@@ -3,6 +3,7 @@
3
3
  function irKeyword(keyword) {
4
4
  return { kind: "keyword", keyword };
5
5
  }
6
+ const DEFAULT_STRING_ENCODING = "json";
6
7
  function irString(value, encoding) {
7
8
  return { kind: "stringLiteral", value, encoding };
8
9
  }
@@ -72,6 +73,7 @@ function irRecord(key, value) {
72
73
  return irReference("Record", [key, value]);
73
74
  }
74
75
 
76
+ exports.DEFAULT_STRING_ENCODING = DEFAULT_STRING_ENCODING;
75
77
  exports.irArray = irArray;
76
78
  exports.irBoolean = irBoolean;
77
79
  exports.irIndexedAccess = irIndexedAccess;
@@ -1 +1 @@
1
- {"version":3,"file":"constructors.cjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest, isOptional: false };\n}\n\n/** `T?`: an element the tuple may end before. */\nexport function irOptionalTupleElement(type: IrType): IrTupleElement {\n return { type, isRest: false, isOptional: true };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAQ;AACpC;AAEO,SAAS,QAAA,CAAS,OAAe,QAAA,EAAiD;AACvF,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAO,QAAA,EAAS;AAClD;AAGO,SAAS,SAAS,KAAA,EAAoC;AAC3D,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,iDAAA,EAAoD,KAAK,CAAA,CAAE,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAM;AACxC;AAEO,SAAS,UAAU,KAAA,EAAsC;AAC9D,EAAA,OAAO,EAAE,IAAA,EAAM,gBAAA,EAAkB,KAAA,EAAM;AACzC;AAEO,SAAS,WAAA,CAAY,IAAA,EAAc,aAAA,GAAmC,EAAC,EAAoB;AAChG,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,aAAA,EAAc;AAClD;AAEO,SAAS,QAAQ,OAAA,EAA8B;AACpD,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,OAAA,EAAQ;AAClC;AAEO,SAAS,QAAQ,QAAA,EAAkD;AACxE,EAAA,OAAO,EAAE,IA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,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAY;AAAC,GACjC;AACF;AAGO,SAAS,sBAAA,CACd,aAAA,EACA,IAAA,EACA,UAAA,GAAa,KAAA,EACK;AAClB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,aAAA;AAAA,IACA,aAAA,EAAe,UAAU,QAAQ,CAAA;AAAA,IACjC,IAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAU;AAAC,GACb;AACF;AAGO,SAAS,QAAA,CAAS,KAAa,KAAA,EAAgC;AACpE,EAAA,OAAO,WAAA,CAAY,QAAA,EAAU,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constructors.cjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\n/** The encoding of a string literal that does not name one. */\nexport const DEFAULT_STRING_ENCODING: IrStringEncoding = \"json\";\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest, isOptional: false };\n}\n\n/** `T?`: an element the tuple may end before. */\nexport function irOptionalTupleElement(type: IrType): IrTupleElement {\n return { type, isRest: false, isOptional: true };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAQ;AACpC;AAGO,MAAM,uBAAA,GAA4C;AAElD,SAAS,QAAA,CAAS,OAAe,QAAA,EAAiD;AACvF,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAO,QAAA,EAAS;AAClD;AAGO,SAAS,SAAS,KAAA,EAAoC;AAC3D,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,iDAAA,EAAoD,KAAK,CAAA,CAAE,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAM;AACxC;AAEO,SAAS,UAAU,KAAA,EAAsC;AAC9D,EAAA,OAAO,EAAE,IAAA,EAAM,gBAAA,EAAkB,KAAA,EAAM;AACzC;AAEO,SAAS,WAAA,CAAY,IAAA,EAAc,aAAA,GAAmC,EAAC,EAAoB;AAChG,EAAA,OAAO,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,aAAA,EAAc;AAClD;AAEO,SAAS,QAAQ,OAAA,EAA8B;AACpD,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,OAAA,EAAQ;AAClC;AAEO,SAAS,QAAQ,QAAA,EAAkD;AACxE,EAAA,OAAO,EAAE,IA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,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAY;AAAC,GACjC;AACF;AAGO,SAAS,sBAAA,CACd,aAAA,EACA,IAAA,EACA,UAAA,GAAa,KAAA,EACK;AAClB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,aAAA;AAAA,IACA,aAAA,EAAe,UAAU,QAAQ,CAAA;AAAA,IACjC,IAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAU;AAAC,GACb;AACF;AAGO,SAAS,QAAA,CAAS,KAAa,KAAA,EAAgC;AACpE,EAAA,OAAO,WAAA,CAAY,QAAA,EAAU,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,7 @@
1
1
  function irKeyword(keyword) {
2
2
  return { kind: "keyword", keyword };
3
3
  }
4
+ const DEFAULT_STRING_ENCODING = "json";
4
5
  function irString(value, encoding) {
5
6
  return { kind: "stringLiteral", value, encoding };
6
7
  }
@@ -70,5 +71,5 @@ function irRecord(key, value) {
70
71
  return irReference("Record", [key, value]);
71
72
  }
72
73
 
73
- export { irArray, irBoolean, irIndexedAccess, irIntersection, irKeyword, irNumber, irObject, irOptionalTupleElement, irProperty, irRaw, irReadonly, irRecord, irReference, irString, irStringIndexSignature, irTuple, irTupleElement, irUnion };
74
+ export { DEFAULT_STRING_ENCODING, irArray, irBoolean, irIndexedAccess, irIntersection, irKeyword, irNumber, irObject, irOptionalTupleElement, irProperty, irRaw, irReadonly, irRecord, irReference, irString, irStringIndexSignature, irTuple, irTupleElement, irUnion };
74
75
  //# sourceMappingURL=constructors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constructors.mjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest, isOptional: false };\n}\n\n/** `T?`: an element the tuple may end before. */\nexport function irOptionalTupleElement(type: IrType): IrTupleElement {\n return { type, isRest: false, isOptional: true };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":"AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAQ;AACpC;AAEO,SAAS,QAAA,CAAS,OAAe,QAAA,EAAiD;AACvF,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAO,QAAA,EAAS;AAClD;AAGO,SAAS,SAAS,KAAA,EAAoC;AAC3D,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,iDAAA,EAAoD,KAAK,CAAA,CAAE,CAAA;AA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B;AACvD,EAAA,OAAO,EAAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAK;AAClC;AAMO,SAAS,KAAA,CAAM,MAAc,MAAA,EAA6B;AAC/D,EAAA,OAAO,MAAA,KAAW,MAAA,GAAY,EAAE,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK,GAAI,EAAE,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,MAAA,EAAO;AACpF;AASO,SAAS,UAAA,CACd,IAAA,EACA,IAAA,EACA,OAAA,GAA6B,EAAC,EACT;AACrB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,IAAA;AAAA,IACA,IAAA;AAAA,IACA,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAY;AAAC,GACjC;AACF;AAGO,SAAS,sBAAA,CACd,aAAA,EACA,IAAA,EACA,UAAA,GAAa,KAAA,EACK;AAClB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,aAAA;AAAA,IACA,aAAA,EAAe,UAAU,QAAQ,CAAA;AAAA,IACjC,IAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAU;AAAC,GACb;AACF;AAGO,SAAS,QAAA,CAAS,KAAa,KAAA,EAAgC;AACpE,EAAA,OAAO,WAAA,CAAY,QAAA,EAAU,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;;"}
1
+ {"version":3,"file":"constructors.mjs","sources":["../../../src/domain/ir/constructors.ts"],"sourcesContent":["import type {\n IrArrayType,\n IrBooleanLiteralType,\n IrComment,\n IrIndexedAccessType,\n IrIndexSignature,\n IrIntersectionType,\n IrKeyword,\n IrKeywordType,\n IrMember,\n IrNumberLiteralType,\n IrObjectType,\n IrPropertyName,\n IrPropertySignature,\n IrRawType,\n IrReadonlyType,\n IrReferenceType,\n IrStringEncoding,\n IrStringLiteralType,\n IrTupleElement,\n IrTupleType,\n IrType,\n IrUnionType,\n} from \"./nodes.js\";\n\n/**\n * Constructors of IR nodes. They build exactly the node asked for: no flattening, de-duplication or\n * sorting happens here (ENGINEERING_PLAN §4.2). Callers that need those call the functions in\n * `normalize.ts` explicitly, at the same places the original generator does.\n */\n\nexport function irKeyword(keyword: IrKeyword): IrKeywordType {\n return { kind: \"keyword\", keyword };\n}\n\n/** The encoding of a string literal that does not name one. */\nexport const DEFAULT_STRING_ENCODING: IrStringEncoding = \"json\";\n\nexport function irString(value: string, encoding: IrStringEncoding): IrStringLiteralType {\n return { kind: \"stringLiteral\", value, encoding };\n}\n\n/** Throws on NaN and infinities: they have no literal type. */\nexport function irNumber(value: number): IrNumberLiteralType {\n if (!Number.isFinite(value)) {\n throw new RangeError(`A number literal type needs a finite number, got ${value}`);\n }\n return { kind: \"numberLiteral\", value };\n}\n\nexport function irBoolean(value: boolean): IrBooleanLiteralType {\n return { kind: \"booleanLiteral\", value };\n}\n\nexport function irReference(name: string, typeArguments: readonly IrType[] = []): IrReferenceType {\n return { kind: \"reference\", name, typeArguments };\n}\n\nexport function irArray(element: IrType): IrArrayType {\n return { kind: \"array\", element };\n}\n\nexport function irTuple(elements: readonly IrTupleElement[]): IrTupleType {\n return { kind: \"tuple\", elements };\n}\n\nexport function irTupleElement(type: IrType, isRest = false): IrTupleElement {\n return { type, isRest, isOptional: false };\n}\n\n/** `T?`: an element the tuple may end before. */\nexport function irOptionalTupleElement(type: IrType): IrTupleElement {\n return { type, isRest: false, isOptional: true };\n}\n\nexport function irUnion(types: readonly IrType[]): IrUnionType {\n return { kind: \"union\", types };\n}\n\nexport function irIntersection(types: readonly IrType[]): IrIntersectionType {\n return { kind: \"intersection\", types };\n}\n\nexport function irObject(members: readonly IrMember[]): IrObjectType {\n return { kind: \"object\", members };\n}\n\nexport function irIndexedAccess(object: IrType, index: IrType): IrIndexedAccessType {\n return { kind: \"indexedAccess\", object, index };\n}\n\nexport function irReadonly(type: IrType): IrReadonlyType {\n return { kind: \"readonly\", type };\n}\n\n/**\n * Type text printed as is. The original builds some types from text (template literal path keys,\n * root type aliases); keeping them as text keeps their exact spelling.\n */\nexport function irRaw(text: string, origin?: unknown): IrRawType {\n return origin === undefined ? { kind: \"raw\", text } : { kind: \"raw\", text, origin };\n}\n\n/** Options of a property signature; omitted flags are false and there are no comments. */\nexport interface IrPropertyOptions {\n readonly isOptional?: boolean;\n readonly isReadonly?: boolean;\n readonly comments?: readonly IrComment[];\n}\n\nexport function irProperty(\n name: IrPropertyName,\n type: IrType,\n options: IrPropertyOptions = {},\n): IrPropertySignature {\n return {\n kind: \"property\",\n name,\n type,\n isOptional: options.isOptional ?? false,\n isReadonly: options.isReadonly ?? false,\n comments: options.comments ?? [],\n };\n}\n\n/** `[name: string]: type` (a `string` key, the only kind the generator writes). */\nexport function irStringIndexSignature(\n parameterName: string,\n type: IrType,\n isReadonly = false,\n): IrIndexSignature {\n return {\n kind: \"indexSignature\",\n parameterName,\n parameterType: irKeyword(\"string\"),\n type,\n isReadonly,\n comments: [],\n };\n}\n\n/** `Record<key, value>`. */\nexport function irRecord(key: IrType, value: IrType): IrReferenceType {\n return irReference(\"Record\", [key, value]);\n}\n"],"names":[],"mappings":"AA+BO,SAAS,UAAU,OAAA,EAAmC;AAC3D,EAAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,OAAA,EAAQ;AACpC;AAGO,MAAM,uBAAA,GAA4C;AAElD,SAAS,QAAA,CAAS,OAAe,QAAA,EAAiD;AACvF,EAAA,OAAO,EAAE,IAAA,EAAM,eAAA,EAAiB,KAAA,EAAO,QAAA,EAAS;AAClD;AAGO,SAAS,SAAS,KAAA,EAAoC;AAC3D,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,iDAAA,EAAoD,KAAK,CAAA,CAAE,CAAA;AAAA,EAClF;AACA,EAAA,O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AAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAK;AAClC;AAMO,SAAS,KAAA,CAAM,MAAc,MAAA,EAA6B;AAC/D,EAAA,OAAO,MAAA,KAAW,MAAA,GAAY,EAAE,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK,GAAI,EAAE,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,MAAA,EAAO;AACpF;AASO,SAAS,UAAA,CACd,IAAA,EACA,IAAA,EACA,OAAA,GAA6B,EAAC,EACT;AACrB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,IAAA;AAAA,IACA,IAAA;AAAA,IACA,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAY;AAAC,GACjC;AACF;AAGO,SAAS,sBAAA,CACd,aAAA,EACA,IAAA,EACA,UAAA,GAAa,KAAA,EACK;AAClB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,aAAA;AAAA,IACA,aAAA,EAAe,UAAU,QAAQ,CAAA;AAAA,IACjC,IAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAU;AAAC,GACb;AACF;AAGO,SAAS,QAAA,CAAS,KAAa,KAAA,EAAgC;AACpE,EAAA,OAAO,WAAA,CAAY,QAAA,EAAU,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AAC3C;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const PATH_PARAMETER_RE = /\{[^}]+\}/g;
3
+ const PATH_PARAMETER_RE = /\{[^{}]+\}/g;
4
4
  const PATH_PREFIX = "/";
5
5
  const UNNAMED_PARAMETER = "{}";
6
6
  function isObject(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"path-templates.cjs","sources":["../../../src/domain/openapi/path-templates.ts"],"sourcesContent":["/**\n * The Paths Object rule (OpenAPI 3.1 §4.8.8): \"Templated paths with the same hierarchy but\n * different templated names MUST NOT exist as they are identical.\" Such paths, `/a/{id}` and\n * `/a/{name}`, match the same URLs, so a client cannot tell which one a request is for.\n */\n\nconst PATH_PARAMETER_RE = /\\{[^}]+\\}/g;\nconst PATH_PREFIX = \"/\";\nconst UNNAMED_PARAMETER = \"{}\";\n\nfunction isObject(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The groups of paths that differ only in the names of their template parameters, each group in\n * document order, the groups in the order of their first path. Keys that are no path, such as an\n * `x-` extension, are left out.\n */\nexport function findIdenticalPathTemplates(document: unknown): string[][] {\n const paths = isObject(document) && isObject(document.paths) ? document.paths : {};\n const byHierarchy = new Map<string, string[]>();\n for (const url of Object.keys(paths)) {\n if (!url.startsWith(PATH_PREFIX) || !url.includes(\"{\")) {\n continue;\n }\n const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);\n byHierarchy.set(hierarchy, [...(byHierarchy.get(hierarchy) ?? []), url]);\n }\n return [...byHierarchy.values()].filter((urls) => urls.length > 1);\n}\n"],"names":[],"mappings":";;AAMA,MAAM,iBAAA,GAAoB,YAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,iBAAA,GAAoB,IAAA;AAE1B,SAAS,SAAS,KAAA,EAA4D;AAC5E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,2BAA2B,QAAA,EAA+B;AACxE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,QAAQ,CAAA,IAAK,QAAA,CAAS,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AACjF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAsB;AAC9C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,CAAC,IAAI,UAAA,CAAW,WAAW,KAAK,CAAC,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACtD,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,iBAAiB,CAAA;AAClE,IAAA,WAAA,CAAY,GAAA,CAAI,SAAA,EAAW,CAAC,GAAI,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA,IAAK,EAAC,EAAI,GAAG,CAAC,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,CAAC,GAAG,WAAA,CAAY,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACnE;;"}
1
+ {"version":3,"file":"path-templates.cjs","sources":["../../../src/domain/openapi/path-templates.ts"],"sourcesContent":["/**\n * The Paths Object rule (OpenAPI 3.1 §4.8.8): \"Templated paths with the same hierarchy but\n * different templated names MUST NOT exist as they are identical.\" Such paths, `/a/{id}` and\n * `/a/{name}`, match the same URLs, so a client cannot tell which one a request is for.\n */\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\nconst PATH_PREFIX = \"/\";\nconst UNNAMED_PARAMETER = \"{}\";\n\nfunction isObject(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The groups of paths that differ only in the names of their template parameters, each group in\n * document order, the groups in the order of their first path. Keys that are no path, such as an\n * `x-` extension, are left out.\n */\nexport function findIdenticalPathTemplates(document: unknown): string[][] {\n const paths = isObject(document) && isObject(document.paths) ? document.paths : {};\n const byHierarchy = new Map<string, string[]>();\n for (const url of Object.keys(paths)) {\n if (!url.startsWith(PATH_PREFIX) || !url.includes(\"{\")) {\n continue;\n }\n const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);\n byHierarchy.set(hierarchy, [...(byHierarchy.get(hierarchy) ?? []), url]);\n }\n return [...byHierarchy.values()].filter((urls) => urls.length > 1);\n}\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,aAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,iBAAA,GAAoB,IAAA;AAE1B,SAAS,SAAS,KAAA,EAA4D;AAC5E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,2BAA2B,QAAA,EAA+B;AACxE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,QAAQ,CAAA,IAAK,QAAA,CAAS,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AACjF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAsB;AAC9C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,CAAC,IAAI,UAAA,CAAW,WAAW,KAAK,CAAC,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACtD,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,iBAAiB,CAAA;AAClE,IAAA,WAAA,CAAY,GAAA,CAAI,SAAA,EAAW,CAAC,GAAI,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA,IAAK,EAAC,EAAI,GAAG,CAAC,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,CAAC,GAAG,WAAA,CAAY,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACnE;;"}
@@ -1,4 +1,4 @@
1
- const PATH_PARAMETER_RE = /\{[^}]+\}/g;
1
+ const PATH_PARAMETER_RE = /\{[^{}]+\}/g;
2
2
  const PATH_PREFIX = "/";
3
3
  const UNNAMED_PARAMETER = "{}";
4
4
  function isObject(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"path-templates.mjs","sources":["../../../src/domain/openapi/path-templates.ts"],"sourcesContent":["/**\n * The Paths Object rule (OpenAPI 3.1 §4.8.8): \"Templated paths with the same hierarchy but\n * different templated names MUST NOT exist as they are identical.\" Such paths, `/a/{id}` and\n * `/a/{name}`, match the same URLs, so a client cannot tell which one a request is for.\n */\n\nconst PATH_PARAMETER_RE = /\\{[^}]+\\}/g;\nconst PATH_PREFIX = \"/\";\nconst UNNAMED_PARAMETER = \"{}\";\n\nfunction isObject(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The groups of paths that differ only in the names of their template parameters, each group in\n * document order, the groups in the order of their first path. Keys that are no path, such as an\n * `x-` extension, are left out.\n */\nexport function findIdenticalPathTemplates(document: unknown): string[][] {\n const paths = isObject(document) && isObject(document.paths) ? document.paths : {};\n const byHierarchy = new Map<string, string[]>();\n for (const url of Object.keys(paths)) {\n if (!url.startsWith(PATH_PREFIX) || !url.includes(\"{\")) {\n continue;\n }\n const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);\n byHierarchy.set(hierarchy, [...(byHierarchy.get(hierarchy) ?? []), url]);\n }\n return [...byHierarchy.values()].filter((urls) => urls.length > 1);\n}\n"],"names":[],"mappings":"AAMA,MAAM,iBAAA,GAAoB,YAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,iBAAA,GAAoB,IAAA;AAE1B,SAAS,SAAS,KAAA,EAA4D;AAC5E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,2BAA2B,QAAA,EAA+B;AACxE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,QAAQ,CAAA,IAAK,QAAA,CAAS,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AACjF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAsB;AAC9C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,CAAC,IAAI,UAAA,CAAW,WAAW,KAAK,CAAC,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACtD,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,iBAAiB,CAAA;AAClE,IAAA,WAAA,CAAY,GAAA,CAAI,SAAA,EAAW,CAAC,GAAI,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA,IAAK,EAAC,EAAI,GAAG,CAAC,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,CAAC,GAAG,WAAA,CAAY,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACnE;;"}
1
+ {"version":3,"file":"path-templates.mjs","sources":["../../../src/domain/openapi/path-templates.ts"],"sourcesContent":["/**\n * The Paths Object rule (OpenAPI 3.1 §4.8.8): \"Templated paths with the same hierarchy but\n * different templated names MUST NOT exist as they are identical.\" Such paths, `/a/{id}` and\n * `/a/{name}`, match the same URLs, so a client cannot tell which one a request is for.\n */\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\nconst PATH_PREFIX = \"/\";\nconst UNNAMED_PARAMETER = \"{}\";\n\nfunction isObject(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The groups of paths that differ only in the names of their template parameters, each group in\n * document order, the groups in the order of their first path. Keys that are no path, such as an\n * `x-` extension, are left out.\n */\nexport function findIdenticalPathTemplates(document: unknown): string[][] {\n const paths = isObject(document) && isObject(document.paths) ? document.paths : {};\n const byHierarchy = new Map<string, string[]>();\n for (const url of Object.keys(paths)) {\n if (!url.startsWith(PATH_PREFIX) || !url.includes(\"{\")) {\n continue;\n }\n const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);\n byHierarchy.set(hierarchy, [...(byHierarchy.get(hierarchy) ?? []), url]);\n }\n return [...byHierarchy.values()].filter((urls) => urls.length > 1);\n}\n"],"names":[],"mappings":"AAOA,MAAM,iBAAA,GAAoB,aAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,iBAAA,GAAoB,IAAA;AAE1B,SAAS,SAAS,KAAA,EAA4D;AAC5E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,2BAA2B,QAAA,EAA+B;AACxE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,QAAQ,CAAA,IAAK,QAAA,CAAS,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AACjF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAsB;AAC9C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,CAAC,IAAI,UAAA,CAAW,WAAW,KAAK,CAAC,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACtD,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,iBAAiB,CAAA;AAClE,IAAA,WAAA,CAAY,GAAA,CAAI,SAAA,EAAW,CAAC,GAAI,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA,IAAK,EAAC,EAAI,GAAG,CAAC,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,CAAC,GAAG,WAAA,CAAY,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACnE;;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  const errors = require('./errors.cjs');
4
4
 
5
- const OutputFix = {
5
+ const FIX = {
6
6
  /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
7
7
  ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union",
8
8
  /** An `allOf` member with only `required` makes those properties of the others required. */
@@ -45,9 +45,9 @@ const OutputFix = {
45
45
  /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
46
46
  UNEVALUATED_PROPERTIES: "unevaluated-properties"
47
47
  };
48
- const OUTPUT_FIXES = Object.values(OutputFix);
49
- const ALL_OUTPUT_FIXES = "all";
50
- const KNOWN_NAMES = /* @__PURE__ */ new Set([...OUTPUT_FIXES, ALL_OUTPUT_FIXES]);
48
+ const OUTPUT_FIXES = Object.values(FIX);
49
+ const ALL_FIXES = "all";
50
+ const KNOWN_NAMES = /* @__PURE__ */ new Set([...OUTPUT_FIXES, ALL_FIXES]);
51
51
  function isOutputFixName(value) {
52
52
  return typeof value === "string" && KNOWN_NAMES.has(value);
53
53
  }
@@ -65,7 +65,7 @@ function outputFixNamesOf(values) {
65
65
  return values;
66
66
  }
67
67
  function resolveOutputFixes(names) {
68
- return new Set(names.flatMap((name) => name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name]));
68
+ return new Set(names.flatMap((name) => name === ALL_FIXES ? OUTPUT_FIXES : [name]));
69
69
  }
70
70
  const ROOT_TYPES = { option: "rootTypes", flag: "--root-types" };
71
71
  const ENUM = { option: "enum", flag: "--enum" };
@@ -74,13 +74,11 @@ const NO_SCHEMA_PREFIX = {
74
74
  flag: "--root-types-no-schema-prefix"
75
75
  };
76
76
  const REQUIREMENTS = {
77
- [OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: "arrayLength", flag: "--array-length" }],
78
- [OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: "dedupeEnums", flag: "--dedupe-enums" }],
79
- [OutputFix.NULLABLE_ENUMS]: [ENUM],
80
- [OutputFix.PATH_PARAM_TYPE_NAMES]: [
81
- { option: "pathParamsAsTypes", flag: "--path-params-as-types" }
82
- ],
83
- [OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX]
77
+ [FIX.ARRAY_LENGTH_TUPLES]: [{ option: "arrayLength", flag: "--array-length" }],
78
+ [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: "dedupeEnums", flag: "--dedupe-enums" }],
79
+ [FIX.NULLABLE_ENUMS]: [ENUM],
80
+ [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: "pathParamsAsTypes", flag: "--path-params-as-types" }],
81
+ [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX]
84
82
  };
85
83
  function describeRequirement(requirement) {
86
84
  return `${requirement.option} (${requirement.flag})`;
@@ -92,9 +90,8 @@ function ineffectiveFixNotices(names, isOptionOn) {
92
90
  });
93
91
  }
94
92
 
95
- exports.ALL_OUTPUT_FIXES = ALL_OUTPUT_FIXES;
93
+ exports.FIX = FIX;
96
94
  exports.OUTPUT_FIXES = OUTPUT_FIXES;
97
- exports.OutputFix = OutputFix;
98
95
  exports.ineffectiveFixNotices = ineffectiveFixNotices;
99
96
  exports.outputFixNamesOf = outputFixNamesOf;
100
97
  exports.resolveOutputFixes = resolveOutputFixes;
@@ -1 +1 @@
1
- {"version":3,"file":"output-fixes.cjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default.\n */\nexport const OutputFix = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\nexport type OutputFix = (typeof OutputFix)[keyof typeof OutputFix];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(OutputFix);\n\n/** The name that turns on every fix of the installed version. */\nexport const ALL_OUTPUT_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `all`. */\nexport type OutputFixName = OutputFix | typeof ALL_OUTPUT_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_OUTPUT_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [OutputFix.NULLABLE_ENUMS]: [ENUM],\n [OutputFix.PATH_PARAM_TYPE_NAMES]: [\n { option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" },\n ],\n [OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAOO,MAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EA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,EAAQ,mBAAA,EAAqB,IAAA,EAAM,wBAAA;AAAyB,GAChE;AAAA,EACA,CAAC,SAAA,CAAU,mBAAmB,GAAG,CAAC,YAAY,gBAAgB;AAChE,CAAA;AAEA,SAAS,oBAAoB,WAAA,EAA2C;AACtE,EAAA,OAAO,CAAA,EAAG,WAAA,CAAY,MAAM,CAAA,EAAA,EAAK,YAAY,IAAI,CAAA,CAAA,CAAA;AACnD;AAMO,SAAS,qBAAA,CACd,OACA,UAAA,EACU;AACV,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAC3C,IAAA,MAAM,OAAA,GAAA,CAAW,YAAA,CAAa,IAAI,CAAA,IAAK,EAAC,EAAG,MAAA,CAAO,CAAC,EAAE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;;;;;;"}
1
+ {"version":3,"file":"output-fixes.cjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default. The object names the fixes for this package's code; the public API is the `OutputFix`\n * union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).\n */\nexport const FIX = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\n/** The name of one opt-in output fix. */\nexport type OutputFix = (typeof FIX)[keyof typeof FIX];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(FIX);\n\n/** The name that turns on every fix of the installed version. */\nconst ALL_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `\"all\"`. */\nexport type OutputFixName = OutputFix | typeof ALL_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [FIX.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [FIX.NULLABLE_ENUMS]: [ENUM],\n [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" }],\n [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAQO,MAAM,GAAA,GAAM;AAAA;AAAA,EAEjB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB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,EAAA,OAAO,CAAA,EAAG,WAAA,CAAY,MAAM,CAAA,EAAA,EAAK,YAAY,IAAI,CAAA,CAAA,CAAA;AACnD;AAMO,SAAS,qBAAA,CACd,OACA,UAAA,EACU;AACV,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAC3C,IAAA,MAAM,OAAA,GAAA,CAAW,YAAA,CAAa,IAAI,CAAA,IAAK,EAAC,EAAG,MAAA,CAAO,CAAC,EAAE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { OpenAPITypesafeError, ERROR_CODES } from './errors.mjs';
2
2
 
3
- const OutputFix = {
3
+ const FIX = {
4
4
  /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
5
5
  ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union",
6
6
  /** An `allOf` member with only `required` makes those properties of the others required. */
@@ -43,9 +43,9 @@ const OutputFix = {
43
43
  /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
44
44
  UNEVALUATED_PROPERTIES: "unevaluated-properties"
45
45
  };
46
- const OUTPUT_FIXES = Object.values(OutputFix);
47
- const ALL_OUTPUT_FIXES = "all";
48
- const KNOWN_NAMES = /* @__PURE__ */ new Set([...OUTPUT_FIXES, ALL_OUTPUT_FIXES]);
46
+ const OUTPUT_FIXES = Object.values(FIX);
47
+ const ALL_FIXES = "all";
48
+ const KNOWN_NAMES = /* @__PURE__ */ new Set([...OUTPUT_FIXES, ALL_FIXES]);
49
49
  function isOutputFixName(value) {
50
50
  return typeof value === "string" && KNOWN_NAMES.has(value);
51
51
  }
@@ -63,7 +63,7 @@ function outputFixNamesOf(values) {
63
63
  return values;
64
64
  }
65
65
  function resolveOutputFixes(names) {
66
- return new Set(names.flatMap((name) => name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name]));
66
+ return new Set(names.flatMap((name) => name === ALL_FIXES ? OUTPUT_FIXES : [name]));
67
67
  }
68
68
  const ROOT_TYPES = { option: "rootTypes", flag: "--root-types" };
69
69
  const ENUM = { option: "enum", flag: "--enum" };
@@ -72,13 +72,11 @@ const NO_SCHEMA_PREFIX = {
72
72
  flag: "--root-types-no-schema-prefix"
73
73
  };
74
74
  const REQUIREMENTS = {
75
- [OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: "arrayLength", flag: "--array-length" }],
76
- [OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: "dedupeEnums", flag: "--dedupe-enums" }],
77
- [OutputFix.NULLABLE_ENUMS]: [ENUM],
78
- [OutputFix.PATH_PARAM_TYPE_NAMES]: [
79
- { option: "pathParamsAsTypes", flag: "--path-params-as-types" }
80
- ],
81
- [OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX]
75
+ [FIX.ARRAY_LENGTH_TUPLES]: [{ option: "arrayLength", flag: "--array-length" }],
76
+ [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: "dedupeEnums", flag: "--dedupe-enums" }],
77
+ [FIX.NULLABLE_ENUMS]: [ENUM],
78
+ [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: "pathParamsAsTypes", flag: "--path-params-as-types" }],
79
+ [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX]
82
80
  };
83
81
  function describeRequirement(requirement) {
84
82
  return `${requirement.option} (${requirement.flag})`;
@@ -90,5 +88,5 @@ function ineffectiveFixNotices(names, isOptionOn) {
90
88
  });
91
89
  }
92
90
 
93
- export { ALL_OUTPUT_FIXES, OUTPUT_FIXES, OutputFix, ineffectiveFixNotices, outputFixNamesOf, resolveOutputFixes };
91
+ export { FIX, OUTPUT_FIXES, ineffectiveFixNotices, outputFixNamesOf, resolveOutputFixes };
94
92
  //# sourceMappingURL=output-fixes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"output-fixes.mjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default.\n */\nexport const OutputFix = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\nexport type OutputFix = (typeof OutputFix)[keyof typeof OutputFix];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(OutputFix);\n\n/** The name that turns on every fix of the installed version. */\nexport const ALL_OUTPUT_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `all`. */\nexport type OutputFixName = OutputFix | typeof ALL_OUTPUT_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_OUTPUT_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [OutputFix.NULLABLE_ENUMS]: [ENUM],\n [OutputFix.PATH_PARAM_TYPE_NAMES]: [\n { option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" },\n ],\n [OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":[],"mappings":";;AAOO,MAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,6BAAA,EAA+B,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,eAAA,EAAiB,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,sBAAA,EAAwB;AAC1B;AAIO,MAAM,YAAA,GAAqC,MAAA,CAAO,MAAA,CAAO,SAAS;AAGlE,MAAM,gBAAA,GAAmB;AAKhC,MAAM,8BAAmC,IAAI,GAAA,CAAY,CAAC,GAAG,YAAA,EAAc,gBAAgB,CAAC,CAA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mjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default. The object names the fixes for this package's code; the public API is the `OutputFix`\n * union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).\n */\nexport const FIX = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\n/** The name of one opt-in output fix. */\nexport type OutputFix = (typeof FIX)[keyof typeof FIX];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(FIX);\n\n/** The name that turns on every fix of the installed version. */\nconst ALL_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `\"all\"`. */\nexport type OutputFixName = OutputFix | typeof ALL_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [FIX.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [FIX.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [FIX.NULLABLE_ENUMS]: [ENUM],\n [FIX.PATH_PARAM_TYPE_NAMES]: [{ option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" }],\n [FIX.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":[],"mappings":";;AAQO,MAAM,GAAA,GAAM;AAAA;AAAA,EAEjB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,6BAAA,EAA+B,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,eAAA,EAAiB,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,sBAAA,EAAwB;AAC1B;AAKO,MAAM,YAAA,GAAqC,MAAA,CAAO,MAAA,CAAO,GAAG;AAGnE,MAAM,SAAA,GAAY,KAAA;AAKlB,MAAM,8BAAmC,IAAI,GAAA,CAAY,CAAC,GAAG,YAAA,EAAc,SAAS,CAAC,CAAA;AAErF,SAAS,gBAAgB,KAAA,EAAwC;AAC/D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,WAAA,CAAY,IAAI,KAAK,CAAA;AAC3D;AAGO,SAAS,iBAAiB,MAAA,EAAsD;AACrF,EAAA,MAAM,OAAA,GAAU,OAAO,MAAA,CAA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AC,IAAA,EAAM,EAAE,MAAA,EAAQ,aAAA,EAAe,IAAA,EAAM,gBAAA,EAAkB,CAAA;AAAA,EACjF,CAAC,GAAA,CAAI,cAAc,GAAG,CAAC,IAAI,CAAA;AAAA,EAC3B,CAAC,GAAA,CAAI,qBAAqB,GAAG,CAAC,EAAE,MAAA,EAAQ,mBAAA,EAAqB,IAAA,EAAM,wBAAA,EAA0B,CAAA;AAAA,EAC7F,CAAC,GAAA,CAAI,mBAAmB,GAAG,CAAC,YAAY,gBAAgB;AAC1D,CAAA;AAEA,SAAS,oBAAoB,WAAA,EAA2C;AACtE,EAAA,OAAO,CAAA,EAAG,WAAA,CAAY,MAAM,CAAA,EAAA,EAAK,YAAY,IAAI,CAAA,CAAA,CAAA;AACnD;AAMO,SAAS,qBAAA,CACd,OACA,UAAA,EACU;AACV,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAC3C,IAAA,MAAM,OAAA,GAAA,CAAW,YAAA,CAAa,IAAI,CAAA,IAAK,EAAC,EAAG,MAAA,CAAO,CAAC,EAAE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const URL_USER_INFO = /:\/\/[^\s/?#@]*@/g;
4
+ const REDACTED_USER_INFO = "://***@";
5
+ function redactUrlCredentials(text) {
6
+ return text.replace(URL_USER_INFO, () => REDACTED_USER_INFO);
7
+ }
8
+
9
+ exports.redactUrlCredentials = redactUrlCredentials;
10
+ //# sourceMappingURL=url-credentials.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-credentials.cjs","sources":["../../src/domain/url-credentials.ts"],"sourcesContent":["/**\n * URLs with user info (`https://user:token@host/…`) can reach a message: the CLI input, a `$ref`,\n * a redirect. Messages end up in CI job logs, so the user info is hidden in every one (audit B2,\n * F12). Fetch refuses such URLs anyway, so a message never needs the credentials.\n */\n\n/**\n * The user info after a scheme: everything up to an `@` that comes before the end of the\n * authority. The class stops at `/`, so a scan never runs past the next `://`; it stays linear.\n */\nconst URL_USER_INFO = /:\\/\\/[^\\s/?#@]*@/g;\n\nconst REDACTED_USER_INFO = \"://***@\";\n\n/** The text with the user info of every URL in it replaced by `***`. */\nexport function redactUrlCredentials(text: string): string {\n return text.replace(URL_USER_INFO, () => REDACTED_USER_INFO);\n}\n"],"names":[],"mappings":";;AAUA,MAAM,aAAA,GAAgB,mBAAA;AAEtB,MAAM,kBAAA,GAAqB,SAAA;AAGpB,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,aAAA,EAAe,MAAM,kBAAkB,CAAA;AAC7D;;"}
@@ -0,0 +1,8 @@
1
+ const URL_USER_INFO = /:\/\/[^\s/?#@]*@/g;
2
+ const REDACTED_USER_INFO = "://***@";
3
+ function redactUrlCredentials(text) {
4
+ return text.replace(URL_USER_INFO, () => REDACTED_USER_INFO);
5
+ }
6
+
7
+ export { redactUrlCredentials };
8
+ //# sourceMappingURL=url-credentials.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-credentials.mjs","sources":["../../src/domain/url-credentials.ts"],"sourcesContent":["/**\n * URLs with user info (`https://user:token@host/…`) can reach a message: the CLI input, a `$ref`,\n * a redirect. Messages end up in CI job logs, so the user info is hidden in every one (audit B2,\n * F12). Fetch refuses such URLs anyway, so a message never needs the credentials.\n */\n\n/**\n * The user info after a scheme: everything up to an `@` that comes before the end of the\n * authority. The class stops at `/`, so a scan never runs past the next `://`; it stays linear.\n */\nconst URL_USER_INFO = /:\\/\\/[^\\s/?#@]*@/g;\n\nconst REDACTED_USER_INFO = \"://***@\";\n\n/** The text with the user info of every URL in it replaced by `***`. */\nexport function redactUrlCredentials(text: string): string {\n return text.replace(URL_USER_INFO, () => REDACTED_USER_INFO);\n}\n"],"names":[],"mappings":"AAUA,MAAM,aAAA,GAAgB,mBAAA;AAEtB,MAAM,kBAAA,GAAqB,SAAA;AAGpB,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,aAAA,EAAe,MAAM,kBAAkB,CAAA;AAC7D;;"}
@@ -1,10 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  const WARNING_CODES = {
4
+ CLI_INPUT_IGNORED: "CLI_INPUT_IGNORED",
5
+ CONFIG_SETTING_UNKNOWN: "CONFIG_SETTING_UNKNOWN",
6
+ DISCRIMINATOR_MAPPING_INVALID: "DISCRIMINATOR_MAPPING_INVALID",
4
7
  DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED",
5
8
  ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED",
9
+ FIX_NEEDS_OPTION: "FIX_NEEDS_OPTION",
10
+ LINT_PROBLEM: "LINT_PROBLEM",
6
11
  PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL",
7
- QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY"
12
+ QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY",
13
+ REF_CIRCULAR: "REF_CIRCULAR",
14
+ REF_NOT_FOUND: "REF_NOT_FOUND"
8
15
  };
9
16
  function warningText(message, code) {
10
17
  return `${message} (${code})`;
@@ -1 +1 @@
1
- {"version":3,"file":"warnings.cjs","sources":["../../src/domain/warnings.ts"],"sourcesContent":["/**\n * Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.\n * Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors\n * (`message (CODE)`), so a script or a person can search for it.\n */\n\n/** Every warning code. */\nexport const WARNING_CODES = {\n DISCRIMINATOR_VALUE_NOT_ALLOWED: \"DISCRIMINATOR_VALUE_NOT_ALLOWED\",\n ENUM_VALUES_EXCLUDED: \"ENUM_VALUES_EXCLUDED\",\n PATH_TEMPLATES_IDENTICAL: \"PATH_TEMPLATES_IDENTICAL\",\n QUERYSTRING_NEXT_TO_QUERY: \"QUERYSTRING_NEXT_TO_QUERY\",\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/** The warning line for people, with its code at the end. */\nexport function warningText(message: string, code: WarningCode): string {\n return `${message} (${code})`;\n}\n"],"names":[],"mappings":";;AAOO,MAAM,aAAA,GAAgB;AAAA,EAC3B,+BAAA,EAAiC,iCAAA;AAAA,EACjC,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B;AAC7B;AAKO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAC5B;;;"}
1
+ {"version":3,"file":"warnings.cjs","sources":["../../src/domain/warnings.ts"],"sourcesContent":["/**\n * Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.\n * Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors\n * (`message (CODE)`), so a script or a person can search for it.\n */\n\n/** Every warning code. */\nexport const WARNING_CODES = {\n CLI_INPUT_IGNORED: \"CLI_INPUT_IGNORED\",\n CONFIG_SETTING_UNKNOWN: \"CONFIG_SETTING_UNKNOWN\",\n DISCRIMINATOR_MAPPING_INVALID: \"DISCRIMINATOR_MAPPING_INVALID\",\n DISCRIMINATOR_VALUE_NOT_ALLOWED: \"DISCRIMINATOR_VALUE_NOT_ALLOWED\",\n ENUM_VALUES_EXCLUDED: \"ENUM_VALUES_EXCLUDED\",\n FIX_NEEDS_OPTION: \"FIX_NEEDS_OPTION\",\n LINT_PROBLEM: \"LINT_PROBLEM\",\n PATH_TEMPLATES_IDENTICAL: \"PATH_TEMPLATES_IDENTICAL\",\n QUERYSTRING_NEXT_TO_QUERY: \"QUERYSTRING_NEXT_TO_QUERY\",\n REF_CIRCULAR: \"REF_CIRCULAR\",\n REF_NOT_FOUND: \"REF_NOT_FOUND\",\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/** The warning line for people, with its code at the end. */\nexport function warningText(message: string, code: WarningCode): string {\n return `${message} (${code})`;\n}\n"],"names":[],"mappings":";;AAOO,MAAM,aAAA,GAAgB;AAAA,EAC3B,iBAAA,EAAmB,mBAAA;AAAA,EACnB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,6BAAA,EAA+B,+BAAA;AAAA,EAC/B,+BAAA,EAAiC,iCAAA;AAAA,EACjC,oBAAA,EAAsB,sBAAA;AAAA,EACtB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,YAAA,EAAc,cAAA;AAAA,EACd,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,YAAA,EAAc,cAAA;AAAA,EACd,aAAA,EAAe;AACjB;AAKO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAC5B;;;"}
@@ -1,8 +1,15 @@
1
1
  const WARNING_CODES = {
2
+ CLI_INPUT_IGNORED: "CLI_INPUT_IGNORED",
3
+ CONFIG_SETTING_UNKNOWN: "CONFIG_SETTING_UNKNOWN",
4
+ DISCRIMINATOR_MAPPING_INVALID: "DISCRIMINATOR_MAPPING_INVALID",
2
5
  DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED",
3
6
  ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED",
7
+ FIX_NEEDS_OPTION: "FIX_NEEDS_OPTION",
8
+ LINT_PROBLEM: "LINT_PROBLEM",
4
9
  PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL",
5
- QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY"
10
+ QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY",
11
+ REF_CIRCULAR: "REF_CIRCULAR",
12
+ REF_NOT_FOUND: "REF_NOT_FOUND"
6
13
  };
7
14
  function warningText(message, code) {
8
15
  return `${message} (${code})`;
@@ -1 +1 @@
1
- {"version":3,"file":"warnings.mjs","sources":["../../src/domain/warnings.ts"],"sourcesContent":["/**\n * Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.\n * Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors\n * (`message (CODE)`), so a script or a person can search for it.\n */\n\n/** Every warning code. */\nexport const WARNING_CODES = {\n DISCRIMINATOR_VALUE_NOT_ALLOWED: \"DISCRIMINATOR_VALUE_NOT_ALLOWED\",\n ENUM_VALUES_EXCLUDED: \"ENUM_VALUES_EXCLUDED\",\n PATH_TEMPLATES_IDENTICAL: \"PATH_TEMPLATES_IDENTICAL\",\n QUERYSTRING_NEXT_TO_QUERY: \"QUERYSTRING_NEXT_TO_QUERY\",\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/** The warning line for people, with its code at the end. */\nexport function warningText(message: string, code: WarningCode): string {\n return `${message} (${code})`;\n}\n"],"names":[],"mappings":"AAOO,MAAM,aAAA,GAAgB;AAAA,EAC3B,+BAAA,EAAiC,iCAAA;AAAA,EACjC,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B;AAC7B;AAKO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAC5B;;"}
1
+ {"version":3,"file":"warnings.mjs","sources":["../../src/domain/warnings.ts"],"sourcesContent":["/**\n * Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.\n * Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors\n * (`message (CODE)`), so a script or a person can search for it.\n */\n\n/** Every warning code. */\nexport const WARNING_CODES = {\n CLI_INPUT_IGNORED: \"CLI_INPUT_IGNORED\",\n CONFIG_SETTING_UNKNOWN: \"CONFIG_SETTING_UNKNOWN\",\n DISCRIMINATOR_MAPPING_INVALID: \"DISCRIMINATOR_MAPPING_INVALID\",\n DISCRIMINATOR_VALUE_NOT_ALLOWED: \"DISCRIMINATOR_VALUE_NOT_ALLOWED\",\n ENUM_VALUES_EXCLUDED: \"ENUM_VALUES_EXCLUDED\",\n FIX_NEEDS_OPTION: \"FIX_NEEDS_OPTION\",\n LINT_PROBLEM: \"LINT_PROBLEM\",\n PATH_TEMPLATES_IDENTICAL: \"PATH_TEMPLATES_IDENTICAL\",\n QUERYSTRING_NEXT_TO_QUERY: \"QUERYSTRING_NEXT_TO_QUERY\",\n REF_CIRCULAR: \"REF_CIRCULAR\",\n REF_NOT_FOUND: \"REF_NOT_FOUND\",\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/** The warning line for people, with its code at the end. */\nexport function warningText(message: string, code: WarningCode): string {\n return `${message} (${code})`;\n}\n"],"names":[],"mappings":"AAOO,MAAM,aAAA,GAAgB;AAAA,EAC3B,iBAAA,EAAmB,mBAAA;AAAA,EACnB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,6BAAA,EAA+B,+BAAA;AAAA,EAC/B,+BAAA,EAAiC,iCAAA;AAAA,EACjC,oBAAA,EAAsB,sBAAA;AAAA,EACtB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,YAAA,EAAc,cAAA;AAAA,EACd,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,YAAA,EAAc,cAAA;AAAA,EACd,aAAA,EAAe;AACjB;AAKO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAC5B;;"}
package/dist/index.cjs CHANGED
@@ -11,8 +11,10 @@ const legacyUtils = require('./api/legacy-utils.cjs');
11
11
  const stringToAst = require('./api/string-to-ast.cjs');
12
12
  const transformSchema = require('./api/transform-schema.cjs');
13
13
  const typeHelpers = require('./api/type-helpers.cjs');
14
+ const deprecations = require('./domain/deprecations.cjs');
14
15
  const errors = require('./domain/errors.cjs');
15
16
  const outputFixes = require('./domain/output-fixes.cjs');
17
+ const warnings = require('./domain/warnings.cjs');
16
18
  const componentsObject = require('./transform/components-object.cjs');
17
19
  const headerObject = require('./transform/header-object.cjs');
18
20
  const mediaTypeObject = require('./transform/media-type-object.cjs');
@@ -56,7 +58,6 @@ exports.getEntries = legacyUtils.getEntries;
56
58
  exports.resolveRef = legacyUtils.resolveRef;
57
59
  exports.walk = legacyUtils.walk;
58
60
  exports.warn = legacyUtils.warn;
59
- exports.STRING_TO_AST_DEPRECATION_CODE = stringToAst.STRING_TO_AST_DEPRECATION_CODE;
60
61
  exports.stringToAST = stringToAst.stringToAST;
61
62
  exports.transformSchema = transformSchema.default;
62
63
  exports.BOOLEAN = typeHelpers.BOOLEAN;
@@ -76,12 +77,12 @@ exports.tsOmit = typeHelpers.tsOmit;
76
77
  exports.tsRecord = typeHelpers.tsRecord;
77
78
  exports.tsUnion = typeHelpers.tsUnion;
78
79
  exports.tsWithRequired = typeHelpers.tsWithRequired;
80
+ exports.DEPRECATION_CODES = deprecations.DEPRECATION_CODES;
79
81
  exports.ERROR_CODES = errors.ERROR_CODES;
80
82
  exports.OpenAPITypesafeError = errors.OpenAPITypesafeError;
81
83
  exports.isOpenAPITypesafeError = errors.isOpenAPITypesafeError;
82
- exports.ALL_OUTPUT_FIXES = outputFixes.ALL_OUTPUT_FIXES;
83
84
  exports.OUTPUT_FIXES = outputFixes.OUTPUT_FIXES;
84
- exports.OutputFix = outputFixes.OutputFix;
85
+ exports.WARNING_CODES = warnings.WARNING_CODES;
85
86
  exports.transformComponentsObject = componentsObject.default;
86
87
  exports.transformHeaderObject = headerObject;
87
88
  exports.transformMediaTypeObject = mediaTypeObject;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}