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

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 (448) hide show
  1. package/CHANGELOG.md +1831 -0
  2. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  3. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  4. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  5. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  7. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  9. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/node-file-system.cjs +90 -14
  11. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  12. package/dist/adapters/node-file-system/node-file-system.mjs +90 -14
  13. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +75 -0
  15. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +72 -0
  17. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
  19. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
  20. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
  21. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
  22. package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
  23. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  25. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +14 -15
  27. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  28. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +12 -13
  29. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  30. package/dist/adapters/redocly-loader/ref-access.cjs +31 -3
  31. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/ref-access.mjs +31 -3
  33. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/ref-holders.cjs +2 -2
  35. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/ref-holders.mjs +3 -3
  37. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  39. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  40. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  41. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  42. package/dist/adapters/redocly-loader/remote-fetch.cjs +35 -6
  43. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/remote-fetch.mjs +35 -6
  45. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/remote-node-limit.cjs +47 -0
  47. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  48. package/dist/adapters/redocly-loader/remote-node-limit.mjs +44 -0
  49. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  50. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  51. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  53. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/schema-source.cjs +11 -7
  55. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-source.mjs +12 -8
  57. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  58. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  59. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  61. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  62. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  63. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  64. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  65. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  66. package/dist/api/default-ports.cjs +14 -2
  67. package/dist/api/default-ports.cjs.map +1 -1
  68. package/dist/api/default-ports.mjs +14 -2
  69. package/dist/api/default-ports.mjs.map +1 -1
  70. package/dist/api/discriminator-enum-parent.cjs +2 -2
  71. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  72. package/dist/api/discriminator-enum-parent.mjs +3 -3
  73. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  74. package/dist/api/discriminator-other-owners.cjs +5 -3
  75. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  76. package/dist/api/discriminator-other-owners.mjs +5 -3
  77. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  78. package/dist/api/discriminator-patch.cjs +5 -1
  79. package/dist/api/discriminator-patch.cjs.map +1 -1
  80. package/dist/api/discriminator-patch.mjs +5 -1
  81. package/dist/api/discriminator-patch.mjs.map +1 -1
  82. package/dist/api/discriminator-scan.cjs +15 -8
  83. package/dist/api/discriminator-scan.cjs.map +1 -1
  84. package/dist/api/discriminator-scan.mjs +15 -8
  85. package/dist/api/discriminator-scan.mjs.map +1 -1
  86. package/dist/api/document-run.cjs +2 -2
  87. package/dist/api/document-run.cjs.map +1 -1
  88. package/dist/api/document-run.mjs +2 -2
  89. package/dist/api/document-run.mjs.map +1 -1
  90. package/dist/api/legacy-utils.cjs.map +1 -1
  91. package/dist/api/legacy-utils.mjs.map +1 -1
  92. package/dist/api/openapi-ts.cjs +8 -4
  93. package/dist/api/openapi-ts.cjs.map +1 -1
  94. package/dist/api/openapi-ts.mjs +8 -5
  95. package/dist/api/openapi-ts.mjs.map +1 -1
  96. package/dist/api/schema-callbacks.cjs +36 -12
  97. package/dist/api/schema-callbacks.cjs.map +1 -1
  98. package/dist/api/schema-callbacks.mjs +36 -12
  99. package/dist/api/schema-callbacks.mjs.map +1 -1
  100. package/dist/api/transform-context.cjs +7 -3
  101. package/dist/api/transform-context.cjs.map +1 -1
  102. package/dist/api/transform-context.mjs +7 -3
  103. package/dist/api/transform-context.mjs.map +1 -1
  104. package/dist/api/transform-schema.cjs +40 -10
  105. package/dist/api/transform-schema.cjs.map +1 -1
  106. package/dist/api/transform-schema.mjs +41 -11
  107. package/dist/api/transform-schema.mjs.map +1 -1
  108. package/dist/application/print/text-writer.cjs +10 -3
  109. package/dist/application/print/text-writer.cjs.map +1 -1
  110. package/dist/application/print/text-writer.mjs +10 -3
  111. package/dist/application/print/text-writer.mjs.map +1 -1
  112. package/dist/application/stack-overflow.cjs +2 -1
  113. package/dist/application/stack-overflow.cjs.map +1 -1
  114. package/dist/application/stack-overflow.mjs +2 -1
  115. package/dist/application/stack-overflow.mjs.map +1 -1
  116. package/dist/application/transform/document/components.cjs +1 -1
  117. package/dist/application/transform/document/components.cjs.map +1 -1
  118. package/dist/application/transform/document/components.mjs +2 -2
  119. package/dist/application/transform/document/components.mjs.map +1 -1
  120. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  121. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  122. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  123. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  124. package/dist/application/transform/document/defs-root.cjs +1 -1
  125. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  126. package/dist/application/transform/document/defs-root.mjs +2 -2
  127. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  128. package/dist/application/transform/document/document.cjs +4 -1
  129. package/dist/application/transform/document/document.cjs.map +1 -1
  130. package/dist/application/transform/document/document.mjs +3 -2
  131. package/dist/application/transform/document/document.mjs.map +1 -1
  132. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  133. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  134. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  135. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  136. package/dist/application/transform/document/global-type-references.cjs +1 -0
  137. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  138. package/dist/application/transform/document/global-type-references.mjs +1 -1
  139. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  140. package/dist/application/transform/document/media-type.cjs +2 -2
  141. package/dist/application/transform/document/media-type.cjs.map +1 -1
  142. package/dist/application/transform/document/media-type.mjs +3 -3
  143. package/dist/application/transform/document/media-type.mjs.map +1 -1
  144. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  145. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  146. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  147. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  148. package/dist/application/transform/document/operation.cjs +1 -1
  149. package/dist/application/transform/document/operation.cjs.map +1 -1
  150. package/dist/application/transform/document/operation.mjs +2 -2
  151. package/dist/application/transform/document/operation.mjs.map +1 -1
  152. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  153. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  154. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  155. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  156. package/dist/application/transform/document/parameter.cjs +12 -4
  157. package/dist/application/transform/document/parameter.cjs.map +1 -1
  158. package/dist/application/transform/document/parameter.mjs +13 -5
  159. package/dist/application/transform/document/parameter.mjs.map +1 -1
  160. package/dist/application/transform/document/parameters.cjs +6 -29
  161. package/dist/application/transform/document/parameters.cjs.map +1 -1
  162. package/dist/application/transform/document/parameters.mjs +6 -29
  163. package/dist/application/transform/document/parameters.mjs.map +1 -1
  164. package/dist/application/transform/document/path-item.cjs +11 -14
  165. package/dist/application/transform/document/path-item.cjs.map +1 -1
  166. package/dist/application/transform/document/path-item.mjs +12 -16
  167. package/dist/application/transform/document/path-item.mjs.map +1 -1
  168. package/dist/application/transform/document/paths-enum.cjs +1 -0
  169. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  170. package/dist/application/transform/document/paths-enum.mjs +1 -1
  171. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  172. package/dist/application/transform/document/paths.cjs +5 -1
  173. package/dist/application/transform/document/paths.cjs.map +1 -1
  174. package/dist/application/transform/document/paths.mjs +6 -2
  175. package/dist/application/transform/document/paths.mjs.map +1 -1
  176. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  177. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  178. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  179. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  180. package/dist/application/transform/document/request-body.cjs +1 -1
  181. package/dist/application/transform/document/request-body.cjs.map +1 -1
  182. package/dist/application/transform/document/request-body.mjs +2 -2
  183. package/dist/application/transform/document/request-body.mjs.map +1 -1
  184. package/dist/application/transform/document/response.cjs +2 -2
  185. package/dist/application/transform/document/response.cjs.map +1 -1
  186. package/dist/application/transform/document/response.mjs +3 -3
  187. package/dist/application/transform/document/response.mjs.map +1 -1
  188. package/dist/application/transform/document/responses.cjs +1 -1
  189. package/dist/application/transform/document/responses.cjs.map +1 -1
  190. package/dist/application/transform/document/responses.mjs +2 -2
  191. package/dist/application/transform/document/responses.mjs.map +1 -1
  192. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  193. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  194. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  195. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  196. package/dist/application/transform/document/type-resolution.cjs +3 -1
  197. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  198. package/dist/application/transform/document/type-resolution.mjs +3 -1
  199. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  200. package/dist/application/transform/document/webhooks.cjs +1 -1
  201. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  202. package/dist/application/transform/document/webhooks.mjs +2 -2
  203. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  204. package/dist/application/transform/footer/document-footer.cjs +10 -2
  205. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  206. package/dist/application/transform/footer/document-footer.mjs +10 -2
  207. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  208. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  209. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  210. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  211. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  212. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  213. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  214. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  215. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  216. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  217. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  218. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  219. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  220. package/dist/application/transform/helper-types.cjs +1 -1
  221. package/dist/application/transform/helper-types.cjs.map +1 -1
  222. package/dist/application/transform/helper-types.mjs +1 -1
  223. package/dist/application/transform/helper-types.mjs.map +1 -1
  224. package/dist/application/transform/numbered-names.cjs +9 -0
  225. package/dist/application/transform/numbered-names.cjs.map +1 -1
  226. package/dist/application/transform/numbered-names.mjs +9 -1
  227. package/dist/application/transform/numbered-names.mjs.map +1 -1
  228. package/dist/application/transform/ref-pointer/generated-location.cjs +1 -1
  229. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  230. package/dist/application/transform/ref-pointer/generated-location.mjs +2 -2
  231. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  232. package/dist/application/transform/ref-type.cjs +2 -1
  233. package/dist/application/transform/ref-type.cjs.map +1 -1
  234. package/dist/application/transform/ref-type.mjs +2 -1
  235. package/dist/application/transform/ref-type.mjs.map +1 -1
  236. package/dist/application/transform/schema/composition-type.cjs +1 -1
  237. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  238. package/dist/application/transform/schema/composition-type.mjs +2 -2
  239. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  240. package/dist/application/transform/schema/enum-rule.cjs +1 -1
  241. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  242. package/dist/application/transform/schema/enum-rule.mjs +2 -2
  243. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  244. package/dist/application/transform/schema/object-type.cjs +3 -3
  245. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  246. package/dist/application/transform/schema/object-type.mjs +4 -4
  247. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  248. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  249. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  250. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  251. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  252. package/dist/application/transform/schema/schema-transform.cjs +4 -2
  253. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  254. package/dist/application/transform/schema/schema-transform.mjs +4 -2
  255. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  256. package/dist/application/transform/schema-comment.cjs +5 -1
  257. package/dist/application/transform/schema-comment.cjs.map +1 -1
  258. package/dist/application/transform/schema-comment.mjs +5 -1
  259. package/dist/application/transform/schema-comment.mjs.map +1 -1
  260. package/dist/cli/api-settings.cjs +62 -6
  261. package/dist/cli/api-settings.cjs.map +1 -1
  262. package/dist/cli/api-settings.mjs +60 -7
  263. package/dist/cli/api-settings.mjs.map +1 -1
  264. package/dist/cli/api-writes.cjs +72 -0
  265. package/dist/cli/api-writes.cjs.map +1 -0
  266. package/dist/cli/api-writes.mjs +69 -0
  267. package/dist/cli/api-writes.mjs.map +1 -0
  268. package/dist/cli/cli-errors.cjs +12 -1
  269. package/dist/cli/cli-errors.cjs.map +1 -1
  270. package/dist/cli/cli-errors.mjs +12 -1
  271. package/dist/cli/cli-errors.mjs.map +1 -1
  272. package/dist/cli/cli-output.cjs +106 -1
  273. package/dist/cli/cli-output.cjs.map +1 -1
  274. package/dist/cli/cli-output.mjs +99 -2
  275. package/dist/cli/cli-output.mjs.map +1 -1
  276. package/dist/cli/main.cjs +5 -1
  277. package/dist/cli/main.cjs.map +1 -1
  278. package/dist/cli/main.mjs +6 -2
  279. package/dist/cli/main.mjs.map +1 -1
  280. package/dist/cli/redocly-apis.cjs +82 -36
  281. package/dist/cli/redocly-apis.cjs.map +1 -1
  282. package/dist/cli/redocly-apis.mjs +85 -39
  283. package/dist/cli/redocly-apis.mjs.map +1 -1
  284. package/dist/cli/run-cli.cjs +13 -7
  285. package/dist/cli/run-cli.cjs.map +1 -1
  286. package/dist/cli/run-cli.mjs +14 -8
  287. package/dist/cli/run-cli.mjs.map +1 -1
  288. package/dist/domain/append-all.cjs +10 -0
  289. package/dist/domain/append-all.cjs.map +1 -0
  290. package/dist/domain/append-all.mjs +8 -0
  291. package/dist/domain/append-all.mjs.map +1 -0
  292. package/dist/domain/cause-secrets.cjs +37 -0
  293. package/dist/domain/cause-secrets.cjs.map +1 -0
  294. package/dist/domain/cause-secrets.mjs +35 -0
  295. package/dist/domain/cause-secrets.mjs.map +1 -0
  296. package/dist/domain/errors.cjs +9 -3
  297. package/dist/domain/errors.cjs.map +1 -1
  298. package/dist/domain/errors.mjs +9 -3
  299. package/dist/domain/errors.mjs.map +1 -1
  300. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  301. package/dist/domain/ir/identifier-text.mjs +1 -1
  302. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  303. package/dist/domain/ir/ir-shape.cjs +187 -0
  304. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  305. package/dist/domain/ir/ir-shape.mjs +184 -0
  306. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  307. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  308. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  309. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  310. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  311. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  312. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  313. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  314. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  315. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  316. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  317. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  318. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  319. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  320. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  321. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  322. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  323. package/dist/domain/openapi/json-pointer.cjs +43 -1
  324. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  325. package/dist/domain/openapi/json-pointer.mjs +40 -2
  326. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  327. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  328. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  329. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  330. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  331. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  332. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  333. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  334. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  335. package/dist/domain/output-fixes.cjs +14 -0
  336. package/dist/domain/output-fixes.cjs.map +1 -1
  337. package/dist/domain/output-fixes.mjs +14 -0
  338. package/dist/domain/output-fixes.mjs.map +1 -1
  339. package/dist/domain/url-secrets.cjs +48 -0
  340. package/dist/domain/url-secrets.cjs.map +1 -0
  341. package/dist/domain/url-secrets.mjs +45 -0
  342. package/dist/domain/url-secrets.mjs.map +1 -0
  343. package/dist/index.d.cts +22 -4
  344. package/dist/index.d.mts +22 -4
  345. package/dist/index.d.ts +22 -4
  346. package/package.json +4 -5
  347. package/src/adapters/node-file-system/file-claims.ts +138 -0
  348. package/src/adapters/node-file-system/file-identity.ts +137 -0
  349. package/src/adapters/node-file-system/node-file-system.ts +145 -18
  350. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +95 -0
  351. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  352. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  353. package/src/adapters/redocly-loader/redocly-schema-loader.ts +18 -24
  354. package/src/adapters/redocly-loader/ref-access.ts +37 -3
  355. package/src/adapters/redocly-loader/ref-holders.ts +3 -3
  356. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  357. package/src/adapters/redocly-loader/remote-fetch.ts +74 -11
  358. package/src/adapters/redocly-loader/remote-node-limit.ts +62 -0
  359. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  360. package/src/adapters/redocly-loader/schema-source.ts +20 -8
  361. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  362. package/src/adapters/terminal-logger/terminal-logger.ts +10 -5
  363. package/src/api/default-ports.ts +33 -4
  364. package/src/api/discriminator-enum-parent.ts +3 -3
  365. package/src/api/discriminator-other-owners.ts +5 -3
  366. package/src/api/discriminator-patch.ts +5 -1
  367. package/src/api/discriminator-scan.ts +16 -8
  368. package/src/api/document-run.ts +4 -3
  369. package/src/api/legacy-utils.ts +5 -1
  370. package/src/api/openapi-ts.ts +20 -5
  371. package/src/api/run-context.ts +3 -0
  372. package/src/api/schema-callbacks.ts +60 -17
  373. package/src/api/transform-context.ts +7 -3
  374. package/src/api/transform-schema.ts +64 -12
  375. package/src/application/ports/file-system.ts +39 -0
  376. package/src/application/ports/schema-loader.ts +11 -1
  377. package/src/application/print/text-writer.ts +10 -3
  378. package/src/application/stack-overflow.ts +9 -5
  379. package/src/application/transform/document/components.ts +2 -2
  380. package/src/application/transform/document/declared-type-names.ts +36 -0
  381. package/src/application/transform/document/defs-root.ts +2 -2
  382. package/src/application/transform/document/document.ts +4 -3
  383. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  384. package/src/application/transform/document/global-type-references.ts +1 -1
  385. package/src/application/transform/document/media-type.ts +4 -3
  386. package/src/application/transform/document/operation-keys-written.ts +27 -0
  387. package/src/application/transform/document/operation.ts +2 -2
  388. package/src/application/transform/document/parameter-entries.ts +70 -0
  389. package/src/application/transform/document/parameter.ts +21 -9
  390. package/src/application/transform/document/parameters.ts +11 -56
  391. package/src/application/transform/document/path-item.ts +13 -31
  392. package/src/application/transform/document/paths-enum.ts +1 -1
  393. package/src/application/transform/document/paths.ts +6 -2
  394. package/src/application/transform/document/referenced-parameter.ts +146 -0
  395. package/src/application/transform/document/request-body.ts +2 -2
  396. package/src/application/transform/document/response.ts +3 -3
  397. package/src/application/transform/document/responses.ts +2 -2
  398. package/src/application/transform/document/root-type-aliases.ts +17 -38
  399. package/src/application/transform/document/type-resolution.ts +2 -1
  400. package/src/application/transform/document/webhooks.ts +2 -2
  401. package/src/application/transform/footer/document-footer.ts +18 -1
  402. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  403. package/src/application/transform/footer/operation-keys.ts +28 -0
  404. package/src/application/transform/footer/type-evaluation.ts +4 -4
  405. package/src/application/transform/helper-types.ts +6 -5
  406. package/src/application/transform/numbered-names.ts +15 -0
  407. package/src/application/transform/ref-pointer/generated-location.ts +2 -2
  408. package/src/application/transform/ref-type.ts +2 -1
  409. package/src/application/transform/schema/composition-type.ts +2 -2
  410. package/src/application/transform/schema/enum-rule.ts +6 -2
  411. package/src/application/transform/schema/object-type.ts +4 -4
  412. package/src/application/transform/schema/ref-siblings.ts +76 -0
  413. package/src/application/transform/schema/schema-context.ts +3 -0
  414. package/src/application/transform/schema/schema-transform.ts +4 -2
  415. package/src/application/transform/schema-comment.ts +5 -1
  416. package/src/application/transform/transform-context.ts +5 -0
  417. package/src/cli/api-settings.ts +82 -7
  418. package/src/cli/api-writes.ts +117 -0
  419. package/src/cli/cli-dependencies.ts +21 -4
  420. package/src/cli/cli-errors.ts +20 -1
  421. package/src/cli/cli-output.ts +186 -7
  422. package/src/cli/main.ts +6 -3
  423. package/src/cli/redocly-apis.ts +153 -48
  424. package/src/cli/run-cli.ts +37 -8
  425. package/src/domain/append-all.ts +10 -0
  426. package/src/domain/cause-secrets.ts +52 -0
  427. package/src/domain/errors.ts +14 -5
  428. package/src/domain/ir/identifier-text.ts +6 -5
  429. package/src/domain/ir/ir-shape.ts +299 -0
  430. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  431. package/src/domain/openapi/alias-expansion.ts +4 -1
  432. package/src/domain/openapi/discriminated-union.ts +6 -4
  433. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  434. package/src/domain/openapi/document-object.ts +2 -0
  435. package/src/domain/openapi/json-pointer.ts +96 -7
  436. package/src/domain/openapi/schema-dialect.ts +22 -0
  437. package/src/domain/openapi/unsupported-features.ts +2 -2
  438. package/src/domain/output-fixes.ts +21 -2
  439. package/src/domain/url-secrets.ts +72 -0
  440. package/src/types/generator-options.ts +1 -1
  441. package/dist/cli/main.d.cts +0 -2
  442. package/dist/cli/main.d.mts +0 -2
  443. package/dist/cli/main.d.ts +0 -2
  444. package/dist/domain/url-credentials.cjs +0 -10
  445. package/dist/domain/url-credentials.cjs.map +0 -1
  446. package/dist/domain/url-credentials.mjs +0 -8
  447. package/dist/domain/url-credentials.mjs.map +0 -1
  448. package/src/domain/url-credentials.ts +0 -18
@@ -1 +1 @@
1
- {"version":3,"file":"media-type.mjs","sources":["../../../../src/application/transform/document/media-type.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n type ContentMap,\n isMediaTypeComponentRef,\n type MediaTypeObject,\n} from \"../../../domain/openapi/media-type-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { documentMember } from \"./document-member.js\";\n\n/** The sibling of `content` that holds item types (ADR-020). */\nconst ITEM_CONTENT_KEY = \"itemContent\";\n\n/** A media type's schema, or `unknown` when it has none (OpenAPI 3.1 §4.8.14). */\nexport function mediaTypeType(\n mediaType: MediaTypeObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n return mediaType.schema ? transformSchema(mediaType.schema, location, context) : UNKNOWN_TYPE;\n}\n\n/** A `content` entry: a `$ref` is transformed like a schema `$ref`, the rest as a media type. */\nexport function contentEntryType(\n entry: ContentMap[string],\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n // `in` throws for a null entry, as in the original.\n return \"$ref\" in entry\n ? transformSchema(entry, location, context)\n : mediaTypeType(entry, location, context);\n}\n\n/** The `itemSchema` of a `content` entry and where it is, following a `$ref` to a component. */\nfunction itemSchemaAt(\n entry: ContentMap[string],\n path: string,\n context: SchemaContext,\n): { readonly schema: MediaTypeObject[\"itemSchema\"]; readonly path: string } {\n if (\"$ref\" in entry) {\n // Other `$ref`s in `content` keep their pre-3.2 output, so only media type components count.\n const resolved = isMediaTypeComponentRef(entry.$ref)\n ? (context.refs.resolve(entry.$ref) as MediaTypeObject | undefined)\n : undefined;\n return { schema: resolved?.itemSchema, path: createRef([entry.$ref, \"itemSchema\"]) };\n }\n return { schema: entry.itemSchema, path: createRef([path, \"itemSchema\"]) };\n}\n\n/**\n * `itemContent`: the type of one item of each media type with an `itemSchema` (OpenAPI 3.2), next\n * to `content`, which keeps the type of the complete body. Null when no media type has one.\n */\nexport function itemContentMember(\n content: ContentMap,\n location: SchemaLocation,\n context: SchemaContext,\n flags: { readonly isReadonly: boolean },\n): IrPropertySignature | null {\n const members = documentEntries(content, context.options).flatMap(([mediaType, entry]) => {\n const contentPath = createRef([location.path, \"content\", mediaType]);\n const item = itemSchemaAt(entry, contentPath, context);\n if (item.schema === undefined) {\n return [];\n }\n const type = transformSchema(item.schema, { ...location, path: item.path }, context);\n return [documentMember(mediaType, type, entry, { isReadonly: context.options.immutable })];\n });\n return members.length > 0\n ? irProperty(toPropertyName(ITEM_CONTENT_KEY), irObject(members), flags)\n : null;\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,aAAA;AAGlB,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,OAAO,UAAU,MAAA,GAAS,eAAA,CAAgB,UAAU,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAA,GAAI,YAAA;AACnF;AAGO,SAAS,gBAAA,CACd,KAAA,EACA,QAAA,EACA,OAAA,EACQ;AAER,EAAA,OAAO,MAAA,IAAU,KAAA,GACb,eAAA,CAAgB,KAAA,EAAO,QAAA,EAAU,OAAO,CAAA,GACxC,aAAA,CAAc,KAAA,EAAO,QAAA,EAAU,OAAO,CAAA;AAC5C;AAGA,SAAS,YAAA,CACP,KAAA,EACA,IAAA,EACA,OAAA,EAC2E;AAC3E,EAAA,IAAI,UAAU,KAAA,EAAO;AAEnB,IAAA,MAAM,QAAA,G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AA,CAAW,cAAA,CAAe,gBAAgB,CAAA,EAAG,QAAA,CAAS,OAAO,CAAA,EAAG,KAAK,CAAA,GACrE,IAAA;AACN;;"}
1
+ {"version":3,"file":"media-type.mjs","sources":["../../../../src/application/transform/document/media-type.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n type ContentMap,\n isMediaTypeComponentRef,\n type MediaTypeObject,\n} from \"../../../domain/openapi/media-type-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { documentMember } from \"./document-member.js\";\n\n/** The sibling of `content` that holds item types (ADR-020). */\nconst ITEM_CONTENT_KEY = \"itemContent\";\n\n/** A media type's schema, or `unknown` when it has none (OpenAPI 3.1 §4.8.14). */\nexport function mediaTypeType(\n mediaType: MediaTypeObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n return mediaType.schema ? transformSchema(mediaType.schema, location, context) : UNKNOWN_TYPE;\n}\n\n/** A `content` entry: a `$ref` is transformed like a schema `$ref`, the rest as a media type. */\nexport function contentEntryType(\n entry: ContentMap[string],\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n // `in` throws for a null entry, as in the original.\n return \"$ref\" in entry\n ? transformSchema(entry, location, context)\n : mediaTypeType(entry, location, context);\n}\n\n/** The `itemSchema` of a `content` entry and where it is, following a `$ref` to a component. */\nfunction itemSchemaAt(\n entry: ContentMap[string],\n path: string,\n context: SchemaContext,\n): { readonly schema: MediaTypeObject[\"itemSchema\"]; readonly path: string } {\n if (\"$ref\" in entry) {\n // Other `$ref`s in `content` keep their pre-3.2 output, so only media type components count.\n const resolved = isMediaTypeComponentRef(entry.$ref)\n ? (context.refs.resolve(entry.$ref) as MediaTypeObject | undefined)\n : undefined;\n // `createRef` reads the `$ref` itself as a pointer; only the constant segment is appended.\n return { schema: resolved?.itemSchema, path: createRef([entry.$ref, \"itemSchema\"]) };\n }\n return { schema: entry.itemSchema, path: appendPointer(path, [\"itemSchema\"]) };\n}\n\n/**\n * `itemContent`: the type of one item of each media type with an `itemSchema` (OpenAPI 3.2), next\n * to `content`, which keeps the type of the complete body. Null when no media type has one.\n */\nexport function itemContentMember(\n content: ContentMap,\n location: SchemaLocation,\n context: SchemaContext,\n flags: { readonly isReadonly: boolean },\n): IrPropertySignature | null {\n const members = documentEntries(content, context.options).flatMap(([mediaType, entry]) => {\n const contentPath = appendPointer(location.path, [\"content\", mediaType]);\n const item = itemSchemaAt(entry, contentPath, context);\n if (item.schema === undefined) {\n return [];\n }\n const type = transformSchema(item.schema, { ...location, path: item.path }, context);\n return [documentMember(mediaType, type, entry, { isReadonly: context.options.immutable })];\n });\n return members.length > 0\n ? irProperty(toPropertyName(ITEM_CONTENT_KEY), irObject(members), flags)\n : null;\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,aAAA;AAGlB,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,OAAO,UAAU,MAAA,GAAS,eAAA,CAAgB,UAAU,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAA,GAAI,YAAA;AACnF;AAGO,SAAS,gBAAA,CACd,KAAA,EACA,QAAA,EACA,OAAA,EACQ;AAER,EAAA,OAAO,MAAA,IAAU,KAAA,GACb,eAAA,CAAgB,KAAA,EAAO,QAAA,EAAU,OAAO,CAAA,GACxC,aAAA,CAAc,KAAA,EAAO,QAAA,EAAU,OAAO,CAAA;AAC5C;AAGA,SAAS,YAAA,CACP,KAAA,EACA,IAAA,EACA,OAAA,EAC2E;AAC3E,EAAA,IAAI,UAAU,KAAA,EAAO;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,MAAA,GAAS,CAAA,GACpB,UAAA,CAAW,cAAA,CAAe,gBAAgB,CAAA,EAAG,QAAA,CAAS,OAAO,CAAA,EAAG,KAAK,CAAA,GACrE,IAAA;AACN;;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ const appendAll = require('../../../domain/append-all.cjs');
4
+ const pathItem = require('./path-item.cjs');
5
+
6
+ function operationKeysWritten(document) {
7
+ const keys = /* @__PURE__ */ new Set();
8
+ const seen = /* @__PURE__ */ new WeakSet();
9
+ const pending = [document];
10
+ while (pending.length > 0) {
11
+ const value = pending.pop();
12
+ if (typeof value !== "object" || value === null || seen.has(value)) {
13
+ continue;
14
+ }
15
+ seen.add(value);
16
+ const { operationId } = value;
17
+ if (typeof operationId === "string") {
18
+ keys.add(pathItem.operationKeyOf(operationId));
19
+ }
20
+ appendAll.appendAll(pending, Object.values(value));
21
+ }
22
+ return keys;
23
+ }
24
+
25
+ exports.operationKeysWritten = operationKeysWritten;
26
+ //# sourceMappingURL=operation-keys-written.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-keys-written.cjs","sources":["../../../../src/application/transform/document/operation-keys-written.ts"],"sourcesContent":["import { appendAll } from \"../../../domain/append-all.js\";\nimport { operationKeyOf } from \"./path-item.js\";\n\n/**\n * Every `operations` key that an `operationId` in the document asks for, so that a repeated ID\n * never gets a number another operation has as its own ID (`OperationKeys`). Operations can sit\n * in `paths`, `webhooks`, `components.pathItems` and callbacks, so the whole document is read. A\n * Link Object's `operationId` is read too; an extra name only makes a number skip it.\n */\nexport function operationKeysWritten(document: object): Set<string> {\n const keys = new Set<string>();\n const seen = new WeakSet<object>();\n const pending: unknown[] = [document];\n while (pending.length > 0) {\n const value = pending.pop();\n if (typeof value !== \"object\" || value === null || seen.has(value)) {\n continue;\n }\n seen.add(value);\n const { operationId } = value as { operationId?: unknown };\n if (typeof operationId === \"string\") {\n keys.add(operationKeyOf(operationId));\n }\n appendAll(pending, Object.values(value));\n }\n return keys;\n}\n"],"names":["operationKeyOf","appendAll"],"mappings":";;;;;AASO,SAAS,qBAAqB,QAAA,EAA+B;AAClE,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,MAAM,IAAA,uBAAW,OAAA,EAAgB;AACjC,EAAA,MAAM,OAAA,GAAqB,CAAC,QAAQ,CAAA;AACpC,EAAA,OAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACzB,IAAA,MAAM,KAAA,GAAQ,QAAQ,GAAA,EAAI;AAC1B,IAAA,IAAI,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,IAAA,CAAK,GAAA,CAAI,KAAK,CAAA,EAAG;AAClE,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,IAAI,KAAK,CAAA;AACd,IAAA,MAAM,EAAE,aAAY,GAAI,KAAA;AACxB,IAAA,IAAI,OAAO,gBAAgB,QAAA,EAAU;AACnC,MAAA,IAAA,CAAK,GAAA,CAAIA,uBAAA,CAAe,WAAW,CAAC,CAAA;AAAA,IACtC;AACA,IAAAC,mBAAA,CAAU,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACzC;AACA,EAAA,OAAO,IAAA;AACT;;"}
@@ -0,0 +1,24 @@
1
+ import { appendAll } from '../../../domain/append-all.mjs';
2
+ import { operationKeyOf } from './path-item.mjs';
3
+
4
+ function operationKeysWritten(document) {
5
+ const keys = /* @__PURE__ */ new Set();
6
+ const seen = /* @__PURE__ */ new WeakSet();
7
+ const pending = [document];
8
+ while (pending.length > 0) {
9
+ const value = pending.pop();
10
+ if (typeof value !== "object" || value === null || seen.has(value)) {
11
+ continue;
12
+ }
13
+ seen.add(value);
14
+ const { operationId } = value;
15
+ if (typeof operationId === "string") {
16
+ keys.add(operationKeyOf(operationId));
17
+ }
18
+ appendAll(pending, Object.values(value));
19
+ }
20
+ return keys;
21
+ }
22
+
23
+ export { operationKeysWritten };
24
+ //# sourceMappingURL=operation-keys-written.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-keys-written.mjs","sources":["../../../../src/application/transform/document/operation-keys-written.ts"],"sourcesContent":["import { appendAll } from \"../../../domain/append-all.js\";\nimport { operationKeyOf } from \"./path-item.js\";\n\n/**\n * Every `operations` key that an `operationId` in the document asks for, so that a repeated ID\n * never gets a number another operation has as its own ID (`OperationKeys`). Operations can sit\n * in `paths`, `webhooks`, `components.pathItems` and callbacks, so the whole document is read. A\n * Link Object's `operationId` is read too; an extra name only makes a number skip it.\n */\nexport function operationKeysWritten(document: object): Set<string> {\n const keys = new Set<string>();\n const seen = new WeakSet<object>();\n const pending: unknown[] = [document];\n while (pending.length > 0) {\n const value = pending.pop();\n if (typeof value !== \"object\" || value === null || seen.has(value)) {\n continue;\n }\n seen.add(value);\n const { operationId } = value as { operationId?: unknown };\n if (typeof operationId === \"string\") {\n keys.add(operationKeyOf(operationId));\n }\n appendAll(pending, Object.values(value));\n }\n return keys;\n}\n"],"names":[],"mappings":";;;AASO,SAAS,qBAAqB,QAAA,EAA+B;AAClE,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,MAAM,IAAA,uBAAW,OAAA,EAAgB;AACjC,EAAA,MAAM,OAAA,GAAqB,CAAC,QAAQ,CAAA;AACpC,EAAA,OAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACzB,IAAA,MAAM,KAAA,GAAQ,QAAQ,GAAA,EAAI;AAC1B,IAAA,IAAI,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,IAAA,CAAK,GAAA,CAAI,KAAK,CAAA,EAAG;AAClE,MAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,IAAI,KAAK,CAAA;AACd,IAAA,MAAM,EAAE,aAAY,GAAI,KAAA;AACxB,IAAA,IAAI,OAAO,gBAAgB,QAAA,EAAU;AACnC,MAAA,IAAA,CAAK,GAAA,CAAI,cAAA,CAAe,WAAW,CAAC,CAAA;AAAA,IACtC;AACA,IAAA,SAAA,CAAU,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACzC;AACA,EAAA,OAAO,IAAA;AACT;;"}
@@ -21,7 +21,7 @@ function requestBodyMember(operation, location, context) {
21
21
  const isReference = "$ref" in body;
22
22
  const type = isReference ? refType.refType(body.$ref) : requestBody.requestBodyType(
23
23
  body,
24
- { ...location, path: jsonPointer.createRef([location.path, "requestBody"]) },
24
+ { ...location, path: jsonPointer.appendPointer(location.path, ["requestBody"]) },
25
25
  context
26
26
  );
27
27
  const resolved = isReference ? context.refs.resolve(body.$ref) : body;
@@ -1 +1 @@
1
- {"version":3,"file":"operation.cjs","sources":["../../../../src/application/transform/document/operation.ts"],"sourcesContent":["import { irKeyword, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertySignature } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type { RequestBodyObject } from \"../../../domain/openapi/request-body-object.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { parametersMember } from \"./parameters.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responsesType } from \"./responses.js\";\n\n/** `requestBody`, optional unless the resolved body is required; `requestBody?: never` if none. */\nfunction requestBodyMember(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const isReadonly = context.options.immutable;\n const body = operation.requestBody;\n if (!body) {\n return irProperty(toPropertyName(\"requestBody\"), irKeyword(\"never\"), {\n isOptional: true,\n isReadonly,\n });\n }\n const isReference = \"$ref\" in body;\n const type = isReference\n ? refType(body.$ref)\n : requestBodyType(\n body,\n { ...location, path: createRef([location.path, \"requestBody\"]) },\n context,\n );\n const resolved = isReference\n ? (context.refs.resolve(body.$ref) as RequestBodyObject | undefined)\n : body;\n return documentMember(\"requestBody\", type, body, {\n isReadonly,\n isOptional: !resolved?.required,\n });\n}\n\n/**\n * The members of an operation (OpenAPI 3.1 §4.8.10): `parameters`, `requestBody` and `responses`.\n * `location.path` is the operation's pointer.\n */\nexport function operationMembers(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature[] {\n // Built in document order: each part may add footer declarations (enums), in this order.\n const parameters = parametersMember(operation.parameters ?? [], location, context);\n const requestBody = requestBodyMember(operation, location, context);\n const responses = responsesType(operation.responses ?? {}, location, context);\n return [\n parameters,\n requestBody,\n irProperty(toPropertyName(\"responses\"), responses, { isReadonly: context.options.immutable }),\n ];\n}\n"],"names":["irProperty","toPropertyName","irKeyword","refType","requestBodyType","createRef","documentMember","parameters","parametersMember","responses","responsesType"],"mappings":";;;;;;;;;;;AAeA,SAAS,iBAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAA,GAAa,QAAQ,OAAA,CAAQ,SAAA;AACnC,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAOA,wBAAWC,2BAAA,CAAe,aAAa,CAAA,EAAGC,sBAAA,CAAU,OAAO,CAAA,EAAG;AAAA,MACnE,UAAA,EAAY,IAAA;AAAA,MACZ;AAAA,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,cAAc,MAAA,IAAU,IAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,WAAA,GACTC,eAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GACjBC,2BAAA;AAAA,IACE,IAAA;AAAA,IACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAMC,qBAAA,CAAU,CAAC,QAAA,CAAS,IAAA,EAAM,aAAa,CAAC,CAAA,EAAE;AAAA,IAC/D;AAAA,GACF;AACJ,EAAA,MAAM,WAAW,WAAA,GACZ,OAAA,CAAQ,KAAK,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GAC/B,IAAA;AACJ,EAAA,OAAOC,6BAAA,CAAe,aAAA,EAAe,IAAA,EAAM,IAAA,EAAM;AAAA,IAC/C,UAAA;AAAA,IACA,UAAA,EAAY,CAAC,QAAA,EAAU;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,gBAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACuB;AAEvB,EAAA,MAAMC,eAAaC,2BAAA,CAAiB,SAAA,CAAU,cAAc,EAAC,EAAG,UAAU,OAAO,CAAA;AACjF,EAAA,MAAM,WAAA,GAAc,iBAAA,CAAkB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAClE,EAAA,MAAMC,cAAYC,uBAAA,CAAc,SAAA,CAAU,aAAa,EAAC,EAAG,UAAU,OAAO,CAAA;AAC5E,EAAA,OAAO;AAAA,IACLH,YAAA;AAAA,IACA,WAAA;AAAA,IACAP,uBAAA,CAAWC,2BAAA,CAAe,WAAW,CAAA,EAAGQ,WAAA,EAAW,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW;AAAA,GAC9F;AACF;;"}
1
+ {"version":3,"file":"operation.cjs","sources":["../../../../src/application/transform/document/operation.ts"],"sourcesContent":["import { irKeyword, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertySignature } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type { RequestBodyObject } from \"../../../domain/openapi/request-body-object.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { parametersMember } from \"./parameters.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responsesType } from \"./responses.js\";\n\n/** `requestBody`, optional unless the resolved body is required; `requestBody?: never` if none. */\nfunction requestBodyMember(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const isReadonly = context.options.immutable;\n const body = operation.requestBody;\n if (!body) {\n return irProperty(toPropertyName(\"requestBody\"), irKeyword(\"never\"), {\n isOptional: true,\n isReadonly,\n });\n }\n const isReference = \"$ref\" in body;\n const type = isReference\n ? refType(body.$ref)\n : requestBodyType(\n body,\n { ...location, path: appendPointer(location.path, [\"requestBody\"]) },\n context,\n );\n const resolved = isReference\n ? (context.refs.resolve(body.$ref) as RequestBodyObject | undefined)\n : body;\n return documentMember(\"requestBody\", type, body, {\n isReadonly,\n isOptional: !resolved?.required,\n });\n}\n\n/**\n * The members of an operation (OpenAPI 3.1 §4.8.10): `parameters`, `requestBody` and `responses`.\n * `location.path` is the operation's pointer.\n */\nexport function operationMembers(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature[] {\n // Built in document order: each part may add footer declarations (enums), in this order.\n const parameters = parametersMember(operation.parameters ?? [], location, context);\n const requestBody = requestBodyMember(operation, location, context);\n const responses = responsesType(operation.responses ?? {}, location, context);\n return [\n parameters,\n requestBody,\n irProperty(toPropertyName(\"responses\"), responses, { isReadonly: context.options.immutable }),\n ];\n}\n"],"names":["irProperty","toPropertyName","irKeyword","refType","requestBodyType","appendPointer","documentMember","parameters","parametersMember","responses","responsesType"],"mappings":";;;;;;;;;;;AAeA,SAAS,iBAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAA,GAAa,QAAQ,OAAA,CAAQ,SAAA;AACnC,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAOA,wBAAWC,2BAAA,CAAe,aAAa,CAAA,EAAGC,sBAAA,CAAU,OAAO,CAAA,EAAG;AAAA,MACnE,UAAA,EAAY,IAAA;AAAA,MACZ;AAAA,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,cAAc,MAAA,IAAU,IAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,WAAA,GACTC,eAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GACjBC,2BAAA;AAAA,IACE,IAAA;AAAA,IACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAMC,yBAAA,CAAc,SAAS,IAAA,EAAM,CAAC,aAAa,CAAC,CAAA,EAAE;AAAA,IACnE;AAAA,GACF;AACJ,EAAA,MAAM,WAAW,WAAA,GACZ,OAAA,CAAQ,KAAK,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GAC/B,IAAA;AACJ,EAAA,OAAOC,6BAAA,CAAe,aAAA,EAAe,IAAA,EAAM,IAAA,EAAM;AAAA,IAC/C,UAAA;AAAA,IACA,UAAA,EAAY,CAAC,QAAA,EAAU;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,gBAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACuB;AAEvB,EAAA,MAAMC,eAAaC,2BAAA,CAAiB,SAAA,CAAU,cAAc,EAAC,EAAG,UAAU,OAAO,CAAA;AACjF,EAAA,MAAM,WAAA,GAAc,iBAAA,CAAkB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAClE,EAAA,MAAMC,cAAYC,uBAAA,CAAc,SAAA,CAAU,aAAa,EAAC,EAAG,UAAU,OAAO,CAAA;AAC5E,EAAA,OAAO;AAAA,IACLH,YAAA;AAAA,IACA,WAAA;AAAA,IACAP,uBAAA,CAAWC,2BAAA,CAAe,WAAW,CAAA,EAAGQ,WAAA,EAAW,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW;AAAA,GAC9F;AACF;;"}
@@ -1,6 +1,6 @@
1
1
  import { irProperty, irKeyword } from '../../../domain/ir/constructors.mjs';
2
2
  import { toPropertyName } from '../../../domain/ir/property-name.mjs';
3
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
3
+ import { appendPointer } from '../../../domain/openapi/json-pointer.mjs';
4
4
  import { refType } from '../ref-type.mjs';
5
5
  import { documentMember } from './document-member.mjs';
6
6
  import { parametersMember } from './parameters.mjs';
@@ -19,7 +19,7 @@ function requestBodyMember(operation, location, context) {
19
19
  const isReference = "$ref" in body;
20
20
  const type = isReference ? refType(body.$ref) : requestBodyType(
21
21
  body,
22
- { ...location, path: createRef([location.path, "requestBody"]) },
22
+ { ...location, path: appendPointer(location.path, ["requestBody"]) },
23
23
  context
24
24
  );
25
25
  const resolved = isReference ? context.refs.resolve(body.$ref) : body;
@@ -1 +1 @@
1
- {"version":3,"file":"operation.mjs","sources":["../../../../src/application/transform/document/operation.ts"],"sourcesContent":["import { irKeyword, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertySignature } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type { RequestBodyObject } from \"../../../domain/openapi/request-body-object.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { parametersMember } from \"./parameters.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responsesType } from \"./responses.js\";\n\n/** `requestBody`, optional unless the resolved body is required; `requestBody?: never` if none. */\nfunction requestBodyMember(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const isReadonly = context.options.immutable;\n const body = operation.requestBody;\n if (!body) {\n return irProperty(toPropertyName(\"requestBody\"), irKeyword(\"never\"), {\n isOptional: true,\n isReadonly,\n });\n }\n const isReference = \"$ref\" in body;\n const type = isReference\n ? refType(body.$ref)\n : requestBodyType(\n body,\n { ...location, path: createRef([location.path, \"requestBody\"]) },\n context,\n );\n const resolved = isReference\n ? (context.refs.resolve(body.$ref) as RequestBodyObject | undefined)\n : body;\n return documentMember(\"requestBody\", type, body, {\n isReadonly,\n isOptional: !resolved?.required,\n });\n}\n\n/**\n * The members of an operation (OpenAPI 3.1 §4.8.10): `parameters`, `requestBody` and `responses`.\n * `location.path` is the operation's pointer.\n */\nexport function operationMembers(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature[] {\n // Built in document order: each part may add footer declarations (enums), in this order.\n const parameters = parametersMember(operation.parameters ?? [], location, context);\n const requestBody = requestBodyMember(operation, location, context);\n const responses = responsesType(operation.responses ?? {}, location, context);\n return [\n parameters,\n requestBody,\n irProperty(toPropertyName(\"responses\"), responses, { isReadonly: context.options.immutable }),\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;AAeA,SAAS,iBAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAA,GAAa,QAAQ,OAAA,CAAQ,SAAA;AACnC,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,WAAW,cAAA,CAAe,aAAa,CAAA,EAAG,SAAA,CAAU,OAAO,CAAA,EAAG;AAAA,MACnE,UAAA,EAAY,IAAA;AAAA,MACZ;AAAA,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,cAAc,MAAA,IAAU,IAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,WAAA,GACT,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GACjB,eAAA;AAAA,IACE,IAAA;AAAA,IACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,SAAA,CAAU,CAAC,QAAA,CAAS,IAAA,EAAM,aAAa,CAAC,CAAA,EAAE;AAAA,IAC/D;AAAA,GACF;AACJ,EAAA,MAAM,WAAW,WAAA,GACZ,OAAA,CAAQ,KAAK,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GAC/B,IAAA;AACJ,EAAA,OAAO,cAAA,CAAe,aAAA,EAAe,IAAA,EAAM,IAAA,EAAM;AAAA,IAC/C,UAAA;AAAA,IACA,UAAA,EAAY,CAAC,QAAA,EAAU;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,gBAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACuB;AAEvB,EAAA,MAAM,aAAa,gBAAA,CAAiB,SAAA,CAAU,cAAc,EAAC,EAAG,UAAU,OAAO,CAAA;AACjF,EAAA,MAAM,WAAA,GAAc,iBAAA,CAAkB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAClE,EAAA,MAAM,YAAY,aAAA,CAAc,SAAA,CAAU,aAAa,EAAC,EAAG,UAAU,OAAO,CAAA;AAC5E,EAAA,OAAO;AAAA,IACL,UAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA,CAAW,cAAA,CAAe,WAAW,CAAA,EAAG,SAAA,EAAW,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW;AAAA,GAC9F;AACF;;"}
1
+ {"version":3,"file":"operation.mjs","sources":["../../../../src/application/transform/document/operation.ts"],"sourcesContent":["import { irKeyword, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertySignature } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type { RequestBodyObject } from \"../../../domain/openapi/request-body-object.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { parametersMember } from \"./parameters.js\";\nimport { requestBodyType } from \"./request-body.js\";\nimport { responsesType } from \"./responses.js\";\n\n/** `requestBody`, optional unless the resolved body is required; `requestBody?: never` if none. */\nfunction requestBodyMember(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const isReadonly = context.options.immutable;\n const body = operation.requestBody;\n if (!body) {\n return irProperty(toPropertyName(\"requestBody\"), irKeyword(\"never\"), {\n isOptional: true,\n isReadonly,\n });\n }\n const isReference = \"$ref\" in body;\n const type = isReference\n ? refType(body.$ref)\n : requestBodyType(\n body,\n { ...location, path: appendPointer(location.path, [\"requestBody\"]) },\n context,\n );\n const resolved = isReference\n ? (context.refs.resolve(body.$ref) as RequestBodyObject | undefined)\n : body;\n return documentMember(\"requestBody\", type, body, {\n isReadonly,\n isOptional: !resolved?.required,\n });\n}\n\n/**\n * The members of an operation (OpenAPI 3.1 §4.8.10): `parameters`, `requestBody` and `responses`.\n * `location.path` is the operation's pointer.\n */\nexport function operationMembers(\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature[] {\n // Built in document order: each part may add footer declarations (enums), in this order.\n const parameters = parametersMember(operation.parameters ?? [], location, context);\n const requestBody = requestBodyMember(operation, location, context);\n const responses = responsesType(operation.responses ?? {}, location, context);\n return [\n parameters,\n requestBody,\n irProperty(toPropertyName(\"responses\"), responses, { isReadonly: context.options.immutable }),\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;AAeA,SAAS,iBAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAA,GAAa,QAAQ,OAAA,CAAQ,SAAA;AACnC,EAAA,MAAM,OAAO,SAAA,CAAU,WAAA;AACvB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,WAAW,cAAA,CAAe,aAAa,CAAA,EAAG,SAAA,CAAU,OAAO,CAAA,EAAG;AAAA,MACnE,UAAA,EAAY,IAAA;AAAA,MACZ;AAAA,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,cAAc,MAAA,IAAU,IAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,WAAA,GACT,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GACjB,eAAA;AAAA,IACE,IAAA;AAAA,IACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,aAAA,CAAc,SAAS,IAAA,EAAM,CAAC,aAAa,CAAC,CAAA,EAAE;AAAA,IACnE;AAAA,GACF;AACJ,EAAA,MAAM,WAAW,WAAA,GACZ,OAAA,CAAQ,KAAK,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,GAC/B,IAAA;AACJ,EAAA,OAAO,cAAA,CAAe,aAAA,EAAe,IAAA,EAAM,IAAA,EAAM;AAAA,IAC/C,UAAA;AAAA,IACA,UAAA,EAAY,CAAC,QAAA,EAAU;AAAA,GACxB,CAAA;AACH;AAMO,SAAS,gBAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACuB;AAEvB,EAAA,MAAM,aAAa,gBAAA,CAAiB,SAAA,CAAU,cAAc,EAAC,EAAG,UAAU,OAAO,CAAA;AACjF,EAAA,MAAM,WAAA,GAAc,iBAAA,CAAkB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAClE,EAAA,MAAM,YAAY,aAAA,CAAc,SAAA,CAAU,aAAa,EAAC,EAAG,UAAU,OAAO,CAAA;AAC5E,EAAA,OAAO;AAAA,IACL,UAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA,CAAW,cAAA,CAAe,WAAW,CAAA,EAAG,SAAA,EAAW,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW;AAAA,GAC9F;AACF;;"}
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ function resolveParameter(parameter, refs) {
4
+ return "$ref" in parameter ? refs.resolve(parameter.$ref) : parameter;
5
+ }
6
+ function isDeprecatedParameter(parameter) {
7
+ const schema = parameter?.schema;
8
+ return Boolean(parameter?.deprecated || schema?.deprecated);
9
+ }
10
+ function parameterEntries(parameters, context) {
11
+ const entries = parameters.map((original) => ({
12
+ original,
13
+ resolved: resolveParameter(original, context.refs)
14
+ }));
15
+ if (context.options.alphabetize) {
16
+ entries.sort(
17
+ (left, right) => (left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? "")
18
+ );
19
+ }
20
+ return context.options.excludeDeprecated ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved)) : entries;
21
+ }
22
+ function mergedParameters(pathItem, operation, refs) {
23
+ const byKey = /* @__PURE__ */ new Map();
24
+ for (const parameter of [...pathItem.parameters ?? [], ...operation.parameters ?? []]) {
25
+ const resolved = resolveParameter(parameter, refs);
26
+ byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);
27
+ }
28
+ return [...byKey.values()];
29
+ }
30
+
31
+ exports.mergedParameters = mergedParameters;
32
+ exports.parameterEntries = parameterEntries;
33
+ exports.resolveParameter = resolveParameter;
34
+ //# sourceMappingURL=parameter-entries.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameter-entries.cjs","sources":["../../../../src/application/transform/document/parameter-entries.ts"],"sourcesContent":["import type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport type { PathItemObject } from \"../../../domain/openapi/path-item-object.js\";\nimport type { SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport type { RefResolver } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\n\n/** A parameter as written in the document, and the object its `$ref` points to. */\nexport interface ParameterEntry {\n readonly original: ParameterOrReference;\n readonly resolved: ParameterObject | undefined;\n}\n\n/** An entry whose `$ref` resolved, so its location and name are known. */\nexport type ResolvedEntry = ParameterEntry & { readonly resolved: ParameterObject };\n\n/** The parameter object itself, or the one its `$ref` points to. */\nexport function resolveParameter(\n parameter: ParameterOrReference,\n refs: RefResolver,\n): ParameterObject | undefined {\n return \"$ref\" in parameter\n ? (refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : parameter;\n}\n\nfunction isDeprecatedParameter(parameter: ParameterObject | undefined): boolean {\n const schema = parameter?.schema as SchemaObject | undefined;\n return Boolean(parameter?.deprecated || schema?.deprecated);\n}\n\n/** Resolved parameters, sorted for `--alphabetize`, without deprecated ones if excluded. */\nexport function parameterEntries(\n parameters: readonly ParameterOrReference[],\n context: TransformContext,\n): ParameterEntry[] {\n const entries = parameters.map((original) => ({\n original,\n resolved: resolveParameter(original, context.refs),\n }));\n if (context.options.alphabetize) {\n // Unlike map keys, the original sorts parameters with the default locale's `localeCompare`.\n entries.sort((left, right) =>\n (left.resolved?.name ?? \"\").localeCompare(right.resolved?.name ?? \"\"),\n );\n }\n return context.options.excludeDeprecated\n ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved))\n : entries;\n}\n\n/**\n * Path item parameters followed by the operation's, keyed by location and name, so an operation\n * parameter replaces the path item parameter it redefines (upstream issue #1798).\n */\nexport function mergedParameters(\n pathItem: PathItemObject,\n operation: OperationObject,\n refs: RefResolver,\n): ParameterOrReference[] {\n const byKey = new Map<string, ParameterOrReference>();\n for (const parameter of [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])]) {\n const resolved = resolveParameter(parameter, refs);\n byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);\n }\n return [...byKey.values()];\n}\n"],"names":[],"mappings":";;AAoBO,SAAS,gBAAA,CACd,WACA,IAAA,EAC6B;AAC7B,EAAA,OAAO,UAAU,SAAA,GACZ,IAAA,CAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GAC5B,SAAA;AACN;AAEA,SAAS,sBAAsB,SAAA,EAAiD;AAC9E,EAAA,MAAM,SAAS,SAAA,EAAW,MAAA;AAC1B,EAAA,OAAO,OAAA,CAAQ,SAAA,EAAW,UAAA,IAAc,MAAA,EAAQ,UAAU,CAAA;AAC5D;AAGO,SAAS,gBAAA,CACd,YACA,OAAA,EACkB;AAClB,EAAA,MAAM,OAAA,GAAU,UAAA,CAAW,GAAA,CAAI,CAAC,QAAA,MAAc;AAAA,IAC5C,QAAA;AAAA,IACA,QAAA,EAAU,gBAAA,CAAiB,QAAA,EAAU,OAAA,CAAQ,IAAI;AAAA,GACnD,CAAE,CAAA;AACF,EAAA,IAAI,OAAA,CAAQ,QAAQ,WAAA,EAAa;AAE/B,IAAA,OAAA,CAAQ,IAAA;AAAA,MAAK,CAAC,IAAA,EAAM,KAAA,KAAA,CACjB,IAAA,CAAK,QAAA,EAAU,IAAA,IAAQ,EAAA,EAAI,aAAA,CAAc,KAAA,CAAM,QAAA,EAAU,IAAA,IAAQ,EAAE;AAAA,KACtE;AAAA,EACF;AACA,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,iBAAA,GACnB,OAAA,CAAQ,MAAA,CAAO,CAAC,EAAE,QAAA,EAAS,KAAM,CAAC,qBAAA,CAAsB,QAAQ,CAAC,CAAA,GACjE,OAAA;AACN;AAMO,SAAS,gBAAA,CACd,QAAA,EACA,SAAA,EACA,IAAA,EACwB;AACxB,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAkC;AACpD,EAAA,KAAA,MAAW,SAAA,IAAa,CAAC,GAAI,QAAA,CAAS,UAAA,IAAc,EAAC,EAAI,GAAI,SAAA,CAAU,UAAA,IAAc,EAAG,CAAA,EAAG;AACzF,IAAA,MAAM,QAAA,GAAW,gBAAA,CAAiB,SAAA,EAAW,IAAI,CAAA;AACjD,IAAA,KAAA,CAAM,GAAA,CAAI,GAAG,QAAA,EAAU,EAAE,IAAI,QAAA,EAAU,IAAI,IAAI,SAAS,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,CAAC,GAAG,KAAA,CAAM,MAAA,EAAQ,CAAA;AAC3B;;;;"}
@@ -0,0 +1,30 @@
1
+ function resolveParameter(parameter, refs) {
2
+ return "$ref" in parameter ? refs.resolve(parameter.$ref) : parameter;
3
+ }
4
+ function isDeprecatedParameter(parameter) {
5
+ const schema = parameter?.schema;
6
+ return Boolean(parameter?.deprecated || schema?.deprecated);
7
+ }
8
+ function parameterEntries(parameters, context) {
9
+ const entries = parameters.map((original) => ({
10
+ original,
11
+ resolved: resolveParameter(original, context.refs)
12
+ }));
13
+ if (context.options.alphabetize) {
14
+ entries.sort(
15
+ (left, right) => (left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? "")
16
+ );
17
+ }
18
+ return context.options.excludeDeprecated ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved)) : entries;
19
+ }
20
+ function mergedParameters(pathItem, operation, refs) {
21
+ const byKey = /* @__PURE__ */ new Map();
22
+ for (const parameter of [...pathItem.parameters ?? [], ...operation.parameters ?? []]) {
23
+ const resolved = resolveParameter(parameter, refs);
24
+ byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);
25
+ }
26
+ return [...byKey.values()];
27
+ }
28
+
29
+ export { mergedParameters, parameterEntries, resolveParameter };
30
+ //# sourceMappingURL=parameter-entries.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameter-entries.mjs","sources":["../../../../src/application/transform/document/parameter-entries.ts"],"sourcesContent":["import type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport type { PathItemObject } from \"../../../domain/openapi/path-item-object.js\";\nimport type { SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport type { RefResolver } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\n\n/** A parameter as written in the document, and the object its `$ref` points to. */\nexport interface ParameterEntry {\n readonly original: ParameterOrReference;\n readonly resolved: ParameterObject | undefined;\n}\n\n/** An entry whose `$ref` resolved, so its location and name are known. */\nexport type ResolvedEntry = ParameterEntry & { readonly resolved: ParameterObject };\n\n/** The parameter object itself, or the one its `$ref` points to. */\nexport function resolveParameter(\n parameter: ParameterOrReference,\n refs: RefResolver,\n): ParameterObject | undefined {\n return \"$ref\" in parameter\n ? (refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : parameter;\n}\n\nfunction isDeprecatedParameter(parameter: ParameterObject | undefined): boolean {\n const schema = parameter?.schema as SchemaObject | undefined;\n return Boolean(parameter?.deprecated || schema?.deprecated);\n}\n\n/** Resolved parameters, sorted for `--alphabetize`, without deprecated ones if excluded. */\nexport function parameterEntries(\n parameters: readonly ParameterOrReference[],\n context: TransformContext,\n): ParameterEntry[] {\n const entries = parameters.map((original) => ({\n original,\n resolved: resolveParameter(original, context.refs),\n }));\n if (context.options.alphabetize) {\n // Unlike map keys, the original sorts parameters with the default locale's `localeCompare`.\n entries.sort((left, right) =>\n (left.resolved?.name ?? \"\").localeCompare(right.resolved?.name ?? \"\"),\n );\n }\n return context.options.excludeDeprecated\n ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved))\n : entries;\n}\n\n/**\n * Path item parameters followed by the operation's, keyed by location and name, so an operation\n * parameter replaces the path item parameter it redefines (upstream issue #1798).\n */\nexport function mergedParameters(\n pathItem: PathItemObject,\n operation: OperationObject,\n refs: RefResolver,\n): ParameterOrReference[] {\n const byKey = new Map<string, ParameterOrReference>();\n for (const parameter of [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])]) {\n const resolved = resolveParameter(parameter, refs);\n byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);\n }\n return [...byKey.values()];\n}\n"],"names":[],"mappings":"AAoBO,SAAS,gBAAA,CACd,WACA,IAAA,EAC6B;AAC7B,EAAA,OAAO,UAAU,SAAA,GACZ,IAAA,CAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GAC5B,SAAA;AACN;AAEA,SAAS,sBAAsB,SAAA,EAAiD;AAC9E,EAAA,MAAM,SAAS,SAAA,EAAW,MAAA;AAC1B,EAAA,OAAO,OAAA,CAAQ,SAAA,EAAW,UAAA,IAAc,MAAA,EAAQ,UAAU,CAAA;AAC5D;AAGO,SAAS,gBAAA,CACd,YACA,OAAA,EACkB;AAClB,EAAA,MAAM,OAAA,GAAU,UAAA,CAAW,GAAA,CAAI,CAAC,QAAA,MAAc;AAAA,IAC5C,QAAA;AAAA,IACA,QAAA,EAAU,gBAAA,CAAiB,QAAA,EAAU,OAAA,CAAQ,IAAI;AAAA,GACnD,CAAE,CAAA;AACF,EAAA,IAAI,OAAA,CAAQ,QAAQ,WAAA,EAAa;AAE/B,IAAA,OAAA,CAAQ,IAAA;AAAA,MAAK,CAAC,IAAA,EAAM,KAAA,KAAA,CACjB,IAAA,CAAK,QAAA,EAAU,IAAA,IAAQ,EAAA,EAAI,aAAA,CAAc,KAAA,CAAM,QAAA,EAAU,IAAA,IAAQ,EAAE;AAAA,KACtE;AAAA,EACF;AACA,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,iBAAA,GACnB,OAAA,CAAQ,MAAA,CAAO,CAAC,EAAE,QAAA,EAAS,KAAM,CAAC,qBAAA,CAAsB,QAAQ,CAAC,CAAA,GACjE,OAAA;AACN;AAMO,SAAS,gBAAA,CACd,QAAA,EACA,SAAA,EACA,IAAA,EACwB;AACxB,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAkC;AACpD,EAAA,KAAA,MAAW,SAAA,IAAa,CAAC,GAAI,QAAA,CAAS,UAAA,IAAc,EAAC,EAAI,GAAI,SAAA,CAAU,UAAA,IAAc,EAAG,CAAA,EAAG;AACzF,IAAA,MAAM,QAAA,GAAW,gBAAA,CAAiB,SAAA,EAAW,IAAI,CAAA;AACjD,IAAA,KAAA,CAAM,GAAA,CAAI,GAAG,QAAA,EAAU,EAAE,IAAI,QAAA,EAAU,IAAI,IAAI,SAAS,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,CAAC,GAAG,KAAA,CAAM,MAAA,EAAQ,CAAA;AAC3B;;"}
@@ -3,20 +3,28 @@
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const jsonPointer = require('../../../domain/openapi/json-pointer.cjs');
5
5
  const parameterObject = require('../../../domain/openapi/parameter-object.cjs');
6
+ const outputFixes = require('../../../domain/output-fixes.cjs');
6
7
  const schemaTransform = require('../schema/schema-transform.cjs');
7
8
  const mediaType = require('./media-type.cjs');
8
9
 
9
- function querystringType(parameter, location, context) {
10
+ function contentParameterType(parameter, location, context) {
10
11
  const [mediaType$1, entry] = Object.entries(parameter.content ?? {})[0] ?? [];
11
12
  if (mediaType$1 === void 0 || entry === void 0) {
12
13
  return constructors.irKeyword("string");
13
14
  }
14
- const path = jsonPointer.createRef([location.path, "content", mediaType$1]);
15
+ const path = jsonPointer.appendPointer(location.path, ["content", mediaType$1]);
15
16
  return mediaType.contentEntryType(entry, { ...location, path }, context);
16
17
  }
17
- function parameterType(parameter, location, context) {
18
+ function isTypedByContent(parameter, context) {
18
19
  if (parameter.in === parameterObject.QUERYSTRING_LOCATION) {
19
- return querystringType(parameter, location, context);
20
+ return true;
21
+ }
22
+ const hasContent = parameter.schema === void 0 && parameter.content !== void 0;
23
+ return hasContent && context.options.fixes.has(outputFixes.FIX.PARAMETER_CONTENT);
24
+ }
25
+ function parameterType(parameter, location, context) {
26
+ if (isTypedByContent(parameter, context)) {
27
+ return contentParameterType(parameter, location, context);
20
28
  }
21
29
  return parameter.schema ? schemaTransform.transformSchema(parameter.schema, location, context) : constructors.irKeyword("string");
22
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parameter.cjs","sources":["../../../../src/application/transform/document/parameter.ts"],"sourcesContent":["import { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n type ParameterObject,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { contentEntryType } from \"./media-type.js\";\n\n/**\n * An `in: querystring` parameter (OpenAPI 3.2): the whole query string, typed by the schema of its\n * one `content` media type (ADR-020). Without one it is `string`, the query string as text.\n */\nfunction querystringType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const [mediaType, entry] = Object.entries(parameter.content ?? {})[0] ?? [];\n if (mediaType === undefined || entry === undefined) {\n return irKeyword(\"string\");\n }\n const path = createRef([location.path, \"content\", mediaType]);\n return contentEntryType(entry, { ...location, path }, context);\n}\n\n/**\n * A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:\n * query, path, header and cookie values all arrive as text. `content` is read only for\n * `in: querystring`; other parameters with `content` keep their pre-3.2 type.\n */\nexport function parameterType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n if (parameter.in === QUERYSTRING_LOCATION) {\n return querystringType(parameter, location, context);\n }\n return parameter.schema\n ? transformSchema(parameter.schema, location, context)\n : irKeyword(\"string\");\n}\n"],"names":["mediaType","irKeyword","createRef","contentEntryType","QUERYSTRING_LOCATION","transformSchema"],"mappings":";;;;;;;;AAeA,SAAS,eAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,CAACA,WAAA,EAAW,KAAK,CAAA,GAAI,MAAA,CAAO,OAAA,CAAQ,SAAA,CAAU,OAAA,IAAW,EAAE,CAAA,CAAE,CAAC,KAAK,EAAC;AAC1E,EAAA,IAAIA,WAAA,KAAc,MAAA,IAAa,KAAA,KAAU,MAAA,EAAW;AAClD,IAAA,OAAOC,uBAAU,QAAQ,CAAA;AAAA,EAC3B;AACA,EAAA,MAAM,OAAOC,qBAAA,CAAU,CAAC,SAAS,IAAA,EAAM,SAAA,EAAWF,WAAS,CAAC,CAAA;AAC5D,EAAA,OAAOG,2BAAiB,KAAA,EAAO,EAAE,GAAG,QAAA,EAAU,IAAA,IAAQ,OAAO,CAAA;AAC/D;AAOO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,IAAI,SAAA,CAAU,OAAOC,oCAAA,EAAsB;AACzC,IAAA,OAAO,eAAA,CAAgB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAAA,EACrD;AACA,EAAA,OAAO,SAAA,CAAU,SACbC,+BAAA,CAAgB,SAAA,CAAU,QAAQ,QAAA,EAAU,OAAO,CAAA,GACnDJ,sBAAA,CAAU,QAAQ,CAAA;AACxB;;"}
1
+ {"version":3,"file":"parameter.cjs","sources":["../../../../src/application/transform/document/parameter.ts"],"sourcesContent":["import { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n type ParameterObject,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { contentEntryType } from \"./media-type.js\";\n\n/**\n * A parameter typed by the schema of its one `content` media type. An `in: querystring` parameter\n * (OpenAPI 3.2) is the whole query string (ADR-020); without a media type it is `string`, the\n * query string as text. With the `parameter-content` fix, any other parameter with `content`\n * (OpenAPI 3.0 and later, for a JSON value in a query parameter) is typed the same way.\n */\nfunction contentParameterType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const [mediaType, entry] = Object.entries(parameter.content ?? {})[0] ?? [];\n if (mediaType === undefined || entry === undefined) {\n return irKeyword(\"string\");\n }\n const path = appendPointer(location.path, [\"content\", mediaType]);\n return contentEntryType(entry, { ...location, path }, context);\n}\n\nfunction isTypedByContent(parameter: ParameterObject, context: SchemaContext): boolean {\n if (parameter.in === QUERYSTRING_LOCATION) {\n return true;\n }\n const hasContent = parameter.schema === undefined && parameter.content !== undefined;\n return hasContent && context.options.fixes.has(FIX.PARAMETER_CONTENT);\n}\n\n/**\n * A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:\n * query, path, header and cookie values all arrive as text. `content` is read for\n * `in: querystring`, and with the `parameter-content` fix for every parameter; without the fix\n * other parameters with `content` keep the original's `string`.\n */\nexport function parameterType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n if (isTypedByContent(parameter, context)) {\n return contentParameterType(parameter, location, context);\n }\n return parameter.schema\n ? transformSchema(parameter.schema, location, context)\n : irKeyword(\"string\");\n}\n"],"names":["mediaType","irKeyword","appendPointer","contentEntryType","QUERYSTRING_LOCATION","FIX","transformSchema"],"mappings":";;;;;;;;;AAkBA,SAAS,oBAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,CAACA,WAAA,EAAW,KAAK,CAAA,GAAI,MAAA,CAAO,OAAA,CAAQ,SAAA,CAAU,OAAA,IAAW,EAAE,CAAA,CAAE,CAAC,KAAK,EAAC;AAC1E,EAAA,IAAIA,WAAA,KAAc,MAAA,IAAa,KAAA,KAAU,MAAA,EAAW;AAClD,IAAA,OAAOC,uBAAU,QAAQ,CAAA;AAAA,EAC3B;AACA,EAAA,MAAM,OAAOC,yBAAA,CAAc,QAAA,CAAS,MAAM,CAAC,SAAA,EAAWF,WAAS,CAAC,CAAA;AAChE,EAAA,OAAOG,2BAAiB,KAAA,EAAO,EAAE,GAAG,QAAA,EAAU,IAAA,IAAQ,OAAO,CAAA;AAC/D;AAEA,SAAS,gBAAA,CAAiB,WAA4B,OAAA,EAAiC;AACrF,EAAA,IAAI,SAAA,CAAU,OAAOC,oCAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,UAAA,GAAa,SAAA,CAAU,MAAA,KAAW,MAAA,IAAa,UAAU,OAAA,KAAY,MAAA;AAC3E,EAAA,OAAO,cAAc,OAAA,CAAQ,OAAA,CAAQ,KAAA,CAAM,GAAA,CAAIC,gBAAI,iBAAiB,CAAA;AACtE;AAQO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,IAAI,gBAAA,CAAiB,SAAA,EAAW,OAAO,CAAA,EAAG;AACxC,IAAA,OAAO,oBAAA,CAAqB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,SAAA,CAAU,SACbC,+BAAA,CAAgB,SAAA,CAAU,QAAQ,QAAA,EAAU,OAAO,CAAA,GACnDL,sBAAA,CAAU,QAAQ,CAAA;AACxB;;"}
@@ -1,20 +1,28 @@
1
1
  import { irKeyword } from '../../../domain/ir/constructors.mjs';
2
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
2
+ import { appendPointer } from '../../../domain/openapi/json-pointer.mjs';
3
3
  import { QUERYSTRING_LOCATION } from '../../../domain/openapi/parameter-object.mjs';
4
+ import { FIX } from '../../../domain/output-fixes.mjs';
4
5
  import { transformSchema } from '../schema/schema-transform.mjs';
5
6
  import { contentEntryType } from './media-type.mjs';
6
7
 
7
- function querystringType(parameter, location, context) {
8
+ function contentParameterType(parameter, location, context) {
8
9
  const [mediaType, entry] = Object.entries(parameter.content ?? {})[0] ?? [];
9
10
  if (mediaType === void 0 || entry === void 0) {
10
11
  return irKeyword("string");
11
12
  }
12
- const path = createRef([location.path, "content", mediaType]);
13
+ const path = appendPointer(location.path, ["content", mediaType]);
13
14
  return contentEntryType(entry, { ...location, path }, context);
14
15
  }
15
- function parameterType(parameter, location, context) {
16
+ function isTypedByContent(parameter, context) {
16
17
  if (parameter.in === QUERYSTRING_LOCATION) {
17
- return querystringType(parameter, location, context);
18
+ return true;
19
+ }
20
+ const hasContent = parameter.schema === void 0 && parameter.content !== void 0;
21
+ return hasContent && context.options.fixes.has(FIX.PARAMETER_CONTENT);
22
+ }
23
+ function parameterType(parameter, location, context) {
24
+ if (isTypedByContent(parameter, context)) {
25
+ return contentParameterType(parameter, location, context);
18
26
  }
19
27
  return parameter.schema ? transformSchema(parameter.schema, location, context) : irKeyword("string");
20
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parameter.mjs","sources":["../../../../src/application/transform/document/parameter.ts"],"sourcesContent":["import { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n type ParameterObject,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { contentEntryType } from \"./media-type.js\";\n\n/**\n * An `in: querystring` parameter (OpenAPI 3.2): the whole query string, typed by the schema of its\n * one `content` media type (ADR-020). Without one it is `string`, the query string as text.\n */\nfunction querystringType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const [mediaType, entry] = Object.entries(parameter.content ?? {})[0] ?? [];\n if (mediaType === undefined || entry === undefined) {\n return irKeyword(\"string\");\n }\n const path = createRef([location.path, \"content\", mediaType]);\n return contentEntryType(entry, { ...location, path }, context);\n}\n\n/**\n * A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:\n * query, path, header and cookie values all arrive as text. `content` is read only for\n * `in: querystring`; other parameters with `content` keep their pre-3.2 type.\n */\nexport function parameterType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n if (parameter.in === QUERYSTRING_LOCATION) {\n return querystringType(parameter, location, context);\n }\n return parameter.schema\n ? transformSchema(parameter.schema, location, context)\n : irKeyword(\"string\");\n}\n"],"names":[],"mappings":";;;;;;AAeA,SAAS,eAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,CAAC,SAAA,EAAW,KAAK,CAAA,GAAI,MAAA,CAAO,OAAA,CAAQ,SAAA,CAAU,OAAA,IAAW,EAAE,CAAA,CAAE,CAAC,KAAK,EAAC;AAC1E,EAAA,IAAI,SAAA,KAAc,MAAA,IAAa,KAAA,KAAU,MAAA,EAAW;AAClD,IAAA,OAAO,UAAU,QAAQ,CAAA;AAAA,EAC3B;AACA,EAAA,MAAM,OAAO,SAAA,CAAU,CAAC,SAAS,IAAA,EAAM,SAAA,EAAW,SAAS,CAAC,CAAA;AAC5D,EAAA,OAAO,iBAAiB,KAAA,EAAO,EAAE,GAAG,QAAA,EAAU,IAAA,IAAQ,OAAO,CAAA;AAC/D;AAOO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,IAAI,SAAA,CAAU,OAAO,oBAAA,EAAsB;AACzC,IAAA,OAAO,eAAA,CAAgB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAAA,EACrD;AACA,EAAA,OAAO,SAAA,CAAU,SACb,eAAA,CAAgB,SAAA,CAAU,QAAQ,QAAA,EAAU,OAAO,CAAA,GACnD,SAAA,CAAU,QAAQ,CAAA;AACxB;;"}
1
+ {"version":3,"file":"parameter.mjs","sources":["../../../../src/application/transform/document/parameter.ts"],"sourcesContent":["import { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n type ParameterObject,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { transformSchema } from \"../schema/schema-transform.js\";\nimport { contentEntryType } from \"./media-type.js\";\n\n/**\n * A parameter typed by the schema of its one `content` media type. An `in: querystring` parameter\n * (OpenAPI 3.2) is the whole query string (ADR-020); without a media type it is `string`, the\n * query string as text. With the `parameter-content` fix, any other parameter with `content`\n * (OpenAPI 3.0 and later, for a JSON value in a query parameter) is typed the same way.\n */\nfunction contentParameterType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const [mediaType, entry] = Object.entries(parameter.content ?? {})[0] ?? [];\n if (mediaType === undefined || entry === undefined) {\n return irKeyword(\"string\");\n }\n const path = appendPointer(location.path, [\"content\", mediaType]);\n return contentEntryType(entry, { ...location, path }, context);\n}\n\nfunction isTypedByContent(parameter: ParameterObject, context: SchemaContext): boolean {\n if (parameter.in === QUERYSTRING_LOCATION) {\n return true;\n }\n const hasContent = parameter.schema === undefined && parameter.content !== undefined;\n return hasContent && context.options.fixes.has(FIX.PARAMETER_CONTENT);\n}\n\n/**\n * A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:\n * query, path, header and cookie values all arrive as text. `content` is read for\n * `in: querystring`, and with the `parameter-content` fix for every parameter; without the fix\n * other parameters with `content` keep the original's `string`.\n */\nexport function parameterType(\n parameter: ParameterObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n if (isTypedByContent(parameter, context)) {\n return contentParameterType(parameter, location, context);\n }\n return parameter.schema\n ? transformSchema(parameter.schema, location, context)\n : irKeyword(\"string\");\n}\n"],"names":[],"mappings":";;;;;;;AAkBA,SAAS,oBAAA,CACP,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,CAAC,SAAA,EAAW,KAAK,CAAA,GAAI,MAAA,CAAO,OAAA,CAAQ,SAAA,CAAU,OAAA,IAAW,EAAE,CAAA,CAAE,CAAC,KAAK,EAAC;AAC1E,EAAA,IAAI,SAAA,KAAc,MAAA,IAAa,KAAA,KAAU,MAAA,EAAW;AAClD,IAAA,OAAO,UAAU,QAAQ,CAAA;AAAA,EAC3B;AACA,EAAA,MAAM,OAAO,aAAA,CAAc,QAAA,CAAS,MAAM,CAAC,SAAA,EAAW,SAAS,CAAC,CAAA;AAChE,EAAA,OAAO,iBAAiB,KAAA,EAAO,EAAE,GAAG,QAAA,EAAU,IAAA,IAAQ,OAAO,CAAA;AAC/D;AAEA,SAAS,gBAAA,CAAiB,WAA4B,OAAA,EAAiC;AACrF,EAAA,IAAI,SAAA,CAAU,OAAO,oBAAA,EAAsB;AACzC,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,UAAA,GAAa,SAAA,CAAU,MAAA,KAAW,MAAA,IAAa,UAAU,OAAA,KAAY,MAAA;AAC3E,EAAA,OAAO,cAAc,OAAA,CAAQ,OAAA,CAAQ,KAAA,CAAM,GAAA,CAAI,IAAI,iBAAiB,CAAA;AACtE;AAQO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,IAAI,gBAAA,CAAiB,SAAA,EAAW,OAAO,CAAA,EAAG;AACxC,IAAA,OAAO,oBAAA,CAAqB,SAAA,EAAW,QAAA,EAAU,OAAO,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,SAAA,CAAU,SACb,eAAA,CAAgB,SAAA,CAAU,QAAQ,QAAA,EAAU,OAAO,CAAA,GACnD,SAAA,CAAU,QAAQ,CAAA;AACxB;;"}
@@ -5,15 +5,13 @@ const propertyName = require('../../../domain/ir/property-name.cjs');
5
5
  const jsonPointer = require('../../../domain/openapi/json-pointer.cjs');
6
6
  const parameterObject = require('../../../domain/openapi/parameter-object.cjs');
7
7
  const outputFixes = require('../../../domain/output-fixes.cjs');
8
- const refType = require('../ref-type.cjs');
9
8
  const schemaComment = require('../schema-comment.cjs');
10
9
  const explodedQuery = require('./exploded-query.cjs');
11
10
  const parameter = require('./parameter.cjs');
11
+ const parameterEntries = require('./parameter-entries.cjs');
12
+ const referencedParameter = require('./referenced-parameter.cjs');
12
13
 
13
14
  const PATH_TEMPLATE_RE = /\{([^{}]+)\}/g;
14
- function resolveParameter(parameter, context) {
15
- return "$ref" in parameter ? context.refs.resolve(parameter.$ref) : parameter;
16
- }
17
15
  function pathTemplateParameters(path) {
18
16
  return (path.match(PATH_TEMPLATE_RE) ?? []).map((match) => ({
19
17
  name: match.slice(1, -1),
@@ -29,7 +27,7 @@ function withPathTemplateParameters(parameters, location, context) {
29
27
  }
30
28
  for (const parameter of pathTemplateParameters(location.path)) {
31
29
  const isDefined = result.some((candidate) => {
32
- const resolved = resolveParameter(candidate, context);
30
+ const resolved = parameterEntries.resolveParameter(candidate, context.refs);
33
31
  return resolved?.in === "path" && resolved.name === parameter.name;
34
32
  });
35
33
  if (!isDefined) {
@@ -38,33 +36,12 @@ function withPathTemplateParameters(parameters, location, context) {
38
36
  }
39
37
  return result;
40
38
  }
41
- function isDeprecatedParameter(parameter) {
42
- const schema = parameter?.schema;
43
- return Boolean(parameter?.deprecated || schema?.deprecated);
44
- }
45
- function parameterEntries(parameters, context) {
46
- const entries = parameters.map((original) => ({
47
- original,
48
- resolved: resolveParameter(original, context)
49
- }));
50
- if (context.options.alphabetize) {
51
- entries.sort(
52
- (left, right) => (left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? "")
53
- );
54
- }
55
- return context.options.excludeDeprecated ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved)) : entries;
56
- }
57
39
  function parameterName(name) {
58
40
  return typeof name === "string" || typeof name === "number" ? propertyName.toPropertyName(name) : { kind: "string", value: String(name) };
59
41
  }
60
- function referencedParameterType(ref, resolved) {
61
- const isParameter = !resolved.$ref;
62
- const parameter = isParameter ? { in: resolved.in, name: resolved.name } : null;
63
- return refType.refType(ref, { parameter });
64
- }
65
42
  function entryType({ original, resolved }, location, context) {
66
- const path = jsonPointer.createRef([location.path, "parameters", resolved.in, resolved.name]);
67
- return "$ref" in original ? referencedParameterType(original.$ref, resolved) : parameter.parameterType(resolved, { ...location, path }, context);
43
+ const path = jsonPointer.appendPointer(location.path, ["parameters", resolved.in, resolved.name]);
44
+ return "$ref" in original ? referencedParameter.referencedParameterType(original.$ref, resolved, context) : parameter.parameterType(resolved, { ...location, path }, context);
68
45
  }
69
46
  function parameterMember(entry, location, context) {
70
47
  const { resolved } = entry;
@@ -129,7 +106,7 @@ function locationMember(parameterIn, entries, location, context) {
129
106
  });
130
107
  }
131
108
  function parametersMember(parameters, location, context) {
132
- const entries = parameterEntries(
109
+ const entries = parameterEntries.parameterEntries(
133
110
  withPathTemplateParameters(parameters, location, context),
134
111
  context
135
112
  );
@@ -1 +1 @@
1
- {"version":3,"file":"parameters.cjs","sources":["../../../../src/application/transform/document/parameters.ts"],"sourcesContent":["import {\n irIntersection,\n irKeyword,\n irObject,\n irProperty,\n irReference,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertyName, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n PARAMETER_LOCATIONS,\n type ParameterLocation,\n type ParameterObject,\n type ParameterOrReference,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport type { SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { isExplodedQueryObject } from \"./exploded-query.js\";\nimport { parameterType } from \"./parameter.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_TEMPLATE_RE = /\\{([^{}]+)\\}/g;\n\n/** A parameter as written in the document, and the object its `$ref` points to. */\ninterface ParameterEntry {\n readonly original: ParameterOrReference;\n readonly resolved: ParameterObject | undefined;\n}\n\n/** An entry whose `$ref` resolved, so its location and name are known. */\ntype ResolvedEntry = ParameterEntry & { readonly resolved: ParameterObject };\n\nfunction resolveParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : parameter;\n}\n\n/** Required string parameters for every `{name}` in a path template. */\nfunction pathTemplateParameters(path: string): ParameterObject[] {\n return (path.match(PATH_TEMPLATE_RE) ?? []).map((match) => ({\n name: match.slice(1, -1),\n in: \"path\",\n required: true,\n schema: { type: \"string\" },\n }));\n}\n\n/** `--generate-path-params`: add the path template parameters the list does not define. */\nfunction withPathTemplateParameters(\n parameters: readonly ParameterOrReference[],\n location: SchemaLocation,\n context: TransformContext,\n): ParameterOrReference[] {\n const result = [...parameters];\n if (!context.options.generatePathParams || !location.path) {\n return result;\n }\n for (const parameter of pathTemplateParameters(location.path)) {\n const isDefined = result.some((candidate) => {\n const resolved = resolveParameter(candidate, context);\n return resolved?.in === \"path\" && resolved.name === parameter.name;\n });\n if (!isDefined) {\n result.push(parameter);\n }\n }\n return result;\n}\n\nfunction isDeprecatedParameter(parameter: ParameterObject | undefined): boolean {\n const schema = parameter?.schema as SchemaObject | undefined;\n return Boolean(parameter?.deprecated || schema?.deprecated);\n}\n\n/** Resolved parameters, sorted for `--alphabetize`, without deprecated ones if excluded. */\nfunction parameterEntries(\n parameters: readonly ParameterOrReference[],\n context: TransformContext,\n): ParameterEntry[] {\n const entries = parameters.map((original) => ({\n original,\n resolved: resolveParameter(original, context),\n }));\n if (context.options.alphabetize) {\n // Unlike map keys, the original sorts parameters with the default locale's `localeCompare`.\n entries.sort((left, right) =>\n (left.resolved?.name ?? \"\").localeCompare(right.resolved?.name ?? \"\"),\n );\n }\n return context.options.excludeDeprecated\n ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved))\n : entries;\n}\n\n/** The original quotes a name that is not text (a missing name prints as `\"undefined\"`). */\nfunction parameterName(name: unknown): IrPropertyName {\n return typeof name === \"string\" || typeof name === \"number\"\n ? toPropertyName(name)\n : { kind: \"string\", value: String(name) };\n}\n\nfunction referencedParameterType(ref: string, resolved: ParameterObject): IrType {\n // A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.\n const isParameter = !(resolved as { $ref?: unknown }).$ref;\n const parameter = isParameter ? { in: resolved.in, name: resolved.name } : null;\n return refType(ref, { parameter });\n}\n\nfunction entryType(\n { original, resolved }: ResolvedEntry,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const path = createRef([location.path, \"parameters\", resolved.in, resolved.name]);\n return \"$ref\" in original\n ? referencedParameterType(original.$ref, resolved)\n : parameterType(resolved, { ...location, path }, context);\n}\n\nfunction parameterMember(\n entry: ResolvedEntry,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const { resolved } = entry;\n const property = irProperty(parameterName(resolved.name), entryType(entry, location, context), {\n isOptional: resolved.in !== \"path\" && !resolved.required,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, resolved);\n}\n\n/**\n * The `query` member typed by an `in: querystring` parameter (OpenAPI 3.2, ADR-020): the parameter\n * is the whole query string. Null when there is none, or when `in: query` parameters sit next to\n * it, which 3.2 does not allow; those keep their types, and a warning names the parameter.\n */\nfunction querystringMember(\n entries: readonly ParameterEntry[],\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const querystring = entries.find(\n (entry): entry is ResolvedEntry => entry.resolved?.in === QUERYSTRING_LOCATION,\n );\n if (!querystring || entries.some((entry) => entry.resolved?.in === \"query\")) {\n return null;\n }\n const property = irProperty(toPropertyName(\"query\"), entryType(querystring, location, context), {\n isOptional: !querystring.resolved.required,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, querystring.resolved);\n}\n\n/** With `exploded-query-objects`, whether the parameter's object keys are keys of `query`. */\nfunction isExplodedEntry(entry: ResolvedEntry, context: TransformContext): boolean {\n return (\n context.options.fixes.has(FIX.EXPLODED_QUERY_OBJECTS) &&\n isExplodedQueryObject(entry.resolved, context.refs)\n );\n}\n\n/**\n * An exploded object parameter's part of `query`: its object type. A parameter that may be left\n * out sends none of its keys then, so they are optional: `Partial<…>`.\n */\nfunction explodedPart(\n entry: ResolvedEntry,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const type = entryType(entry, location, context);\n return entry.resolved.required ? type : irReference(\"Partial\", [type]);\n}\n\n/** A location's parameters as members, and the object types of its exploded parameters. */\ninterface LocationParts {\n readonly members: readonly IrPropertySignature[];\n readonly exploded: readonly IrType[];\n readonly isOptional: boolean;\n}\n\n/** Each parameter in document order, so the declarations they add keep their order. */\nfunction locationParts(\n entries: readonly ResolvedEntry[],\n location: SchemaLocation,\n context: TransformContext,\n): LocationParts {\n const members: IrPropertySignature[] = [];\n const exploded: IrType[] = [];\n let isOptional = true;\n for (const entry of entries) {\n if (isExplodedEntry(entry, context)) {\n exploded.push(explodedPart(entry, location, context));\n isOptional &&= !entry.resolved.required;\n continue;\n }\n const member = parameterMember(entry, location, context);\n members.push(member);\n isOptional &&= member.isOptional;\n }\n return { members, exploded, isOptional };\n}\n\n/** The members' object, intersected with the exploded parameters' types; `never` for none. */\nfunction locationType({ members, exploded }: LocationParts): IrType {\n const types = [...(members.length > 0 ? [irObject(members)] : []), ...exploded];\n const [first] = types;\n if (first === undefined) {\n return irKeyword(\"never\");\n }\n return types.length === 1 ? first : irIntersection(types);\n}\n\n/** One location's parameters; optional when all of them are, and `never` when there are none. */\nfunction locationMember(\n parameterIn: ParameterLocation,\n entries: readonly ParameterEntry[],\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const located = entries.filter(\n (entry): entry is ResolvedEntry => entry.resolved?.in === parameterIn,\n );\n const parts = locationParts(located, location, context);\n return irProperty(toPropertyName(parameterIn), locationType(parts), {\n isOptional: parts.isOptional,\n isReadonly: context.options.immutable,\n });\n}\n\n/**\n * The `parameters` property of an operation or path item: one member per location, each an object\n * of that location's parameters. `location.path` is the path template for\n * `--generate-path-params`.\n */\nexport function parametersMember(\n parameters: readonly ParameterOrReference[],\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const entries = parameterEntries(\n withPathTemplateParameters(parameters, location, context),\n context,\n );\n const querystring = querystringMember(entries, location, context);\n const members = PARAMETER_LOCATIONS.map((parameterIn) =>\n parameterIn === \"query\" && querystring\n ? querystring\n : locationMember(parameterIn, entries, location, context),\n );\n return irProperty(toPropertyName(\"parameters\"), irObject(members), {\n isReadonly: context.options.immutable,\n });\n}\n"],"names":["toPropertyName","refType","createRef","parameterType","irProperty","withSchemaComment","QUERYSTRING_LOCATION","FIX","isExplodedQueryObject","irReference","irObject","irKey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d,UAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,OAAA,GAAU,gBAAA;AAAA,IACd,0BAAA,CAA2B,UAAA,EAAY,QAAA,EAAU,OAAO,CAAA;AAAA,IACxD;AAAA,GACF;AACA,EAAA,MAAM,WAAA,GAAc,iBAAA,CAAkB,OAAA,EAAS,QAAA,EAAU,OAAO,CAAA;AAChE,EAAA,MAAM,UAAUa,mCAAA,CAAoB,GAAA;AAAA,IAAI,CAAC,WAAA,KACvC,WAAA,KAAgB,OAAA,IAAW,WAAA,GACvB,cACA,cAAA,CAAe,WAAA,EAAa,OAAA,EAAS,QAAA,EAAU,OAAO;AAAA,GAC5D;AACA,EAAA,OAAOT,wBAAWJ,2BAAA,CAAe,YAAY,CAAA,EAAGU,qBAAA,CAAS,OAAO,CAAA,EAAG;AAAA,IACjE,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;;"}
1
+ {"version":3,"file":"parameters.cjs","sources":["../../../../src/application/transform/document/parameters.ts"],"sourcesContent":["import {\n irIntersection,\n irKeyword,\n irObject,\n irProperty,\n irReference,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrPropertyName, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n PARAMETER_LOCATIONS,\n type ParameterLocation,\n type ParameterObject,\n type ParameterOrReference,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport { withSchemaComment } from \"../schema-comment.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { isExplodedQueryObject } from \"./exploded-query.js\";\nimport { parameterType } from \"./parameter.js\";\nimport {\n type ParameterEntry,\n parameterEntries,\n type ResolvedEntry,\n resolveParameter,\n} from \"./parameter-entries.js\";\nimport { referencedParameterType } from \"./referenced-parameter.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_TEMPLATE_RE = /\\{([^{}]+)\\}/g;\n\n/** Required string parameters for every `{name}` in a path template. */\nfunction pathTemplateParameters(path: string): ParameterObject[] {\n return (path.match(PATH_TEMPLATE_RE) ?? []).map((match) => ({\n name: match.slice(1, -1),\n in: \"path\",\n required: true,\n schema: { type: \"string\" },\n }));\n}\n\n/** `--generate-path-params`: add the path template parameters the list does not define. */\nfunction withPathTemplateParameters(\n parameters: readonly ParameterOrReference[],\n location: SchemaLocation,\n context: TransformContext,\n): ParameterOrReference[] {\n const result = [...parameters];\n if (!context.options.generatePathParams || !location.path) {\n return result;\n }\n for (const parameter of pathTemplateParameters(location.path)) {\n const isDefined = result.some((candidate) => {\n const resolved = resolveParameter(candidate, context.refs);\n return resolved?.in === \"path\" && resolved.name === parameter.name;\n });\n if (!isDefined) {\n result.push(parameter);\n }\n }\n return result;\n}\n\n/** The original quotes a name that is not text (a missing name prints as `\"undefined\"`). */\nfunction parameterName(name: unknown): IrPropertyName {\n return typeof name === \"string\" || typeof name === \"number\"\n ? toPropertyName(name)\n : { kind: \"string\", value: String(name) };\n}\n\nfunction entryType(\n { original, resolved }: ResolvedEntry,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const path = appendPointer(location.path, [\"parameters\", resolved.in, resolved.name]);\n return \"$ref\" in original\n ? referencedParameterType(original.$ref, resolved, context)\n : parameterType(resolved, { ...location, path }, context);\n}\n\nfunction parameterMember(\n entry: ResolvedEntry,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const { resolved } = entry;\n const property = irProperty(parameterName(resolved.name), entryType(entry, location, context), {\n isOptional: resolved.in !== \"path\" && !resolved.required,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, resolved);\n}\n\n/**\n * The `query` member typed by an `in: querystring` parameter (OpenAPI 3.2, ADR-020): the parameter\n * is the whole query string. Null when there is none, or when `in: query` parameters sit next to\n * it, which 3.2 does not allow; those keep their types, and a warning names the parameter.\n */\nfunction querystringMember(\n entries: readonly ParameterEntry[],\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const querystring = entries.find(\n (entry): entry is ResolvedEntry => entry.resolved?.in === QUERYSTRING_LOCATION,\n );\n if (!querystring || entries.some((entry) => entry.resolved?.in === \"query\")) {\n return null;\n }\n const property = irProperty(toPropertyName(\"query\"), entryType(querystring, location, context), {\n isOptional: !querystring.resolved.required,\n isReadonly: context.options.immutable,\n });\n return withSchemaComment(property, querystring.resolved);\n}\n\n/** With `exploded-query-objects`, whether the parameter's object keys are keys of `query`. */\nfunction isExplodedEntry(entry: ResolvedEntry, context: TransformContext): boolean {\n return (\n context.options.fixes.has(FIX.EXPLODED_QUERY_OBJECTS) &&\n isExplodedQueryObject(entry.resolved, context.refs)\n );\n}\n\n/**\n * An exploded object parameter's part of `query`: its object type. A parameter that may be left\n * out sends none of its keys then, so they are optional: `Partial<…>`.\n */\nfunction explodedPart(\n entry: ResolvedEntry,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const type = entryType(entry, location, context);\n return entry.resolved.required ? type : irReference(\"Partial\", [type]);\n}\n\n/** A location's parameters as members, and the object types of its exploded parameters. */\ninterface LocationParts {\n readonly members: readonly IrPropertySignature[];\n readonly exploded: readonly IrType[];\n readonly isOptional: boolean;\n}\n\n/** Each parameter in document order, so the declarations they add keep their order. */\nfunction locationParts(\n entries: readonly ResolvedEntry[],\n location: SchemaLocation,\n context: TransformContext,\n): LocationParts {\n const members: IrPropertySignature[] = [];\n const exploded: IrType[] = [];\n let isOptional = true;\n for (const entry of entries) {\n if (isExplodedEntry(entry, context)) {\n exploded.push(explodedPart(entry, location, context));\n isOptional &&= !entry.resolved.required;\n continue;\n }\n const member = parameterMember(entry, location, context);\n members.push(member);\n isOptional &&= member.isOptional;\n }\n return { members, exploded, isOptional };\n}\n\n/** The members' object, intersected with the exploded parameters' types; `never` for none. */\nfunction locationType({ members, exploded }: LocationParts): IrType {\n const types = [...(members.length > 0 ? [irObject(members)] : []), ...exploded];\n const [first] = types;\n if (first === undefined) {\n return irKeyword(\"never\");\n }\n return types.length === 1 ? first : irIntersection(types);\n}\n\n/** One location's parameters; optional when all of them are, and `never` when there are none. */\nfunction locationMember(\n parameterIn: ParameterLocation,\n entries: readonly ParameterEntry[],\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const located = entries.filter(\n (entry): entry is ResolvedEntry => entry.resolved?.in === parameterIn,\n );\n const parts = locationParts(located, location, context);\n return irProperty(toPropertyName(parameterIn), locationType(parts), {\n isOptional: parts.isOptional,\n isReadonly: context.options.immutable,\n });\n}\n\n/**\n * The `parameters` property of an operation or path item: one member per location, each an object\n * of that location's parameters. `location.path` is the path template for\n * `--generate-path-params`.\n */\nexport function parametersMember(\n parameters: readonly ParameterOrReference[],\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const entries = parameterEntries(\n withPathTemplateParameters(parameters, location, context),\n context,\n );\n const querystring = querystringMember(entries, location, context);\n const members = PARAMETER_LOCATIONS.map((parameterIn) =>\n parameterIn === \"query\" && querystring\n ? querystring\n : locationMember(parameterIn, entries, location, context),\n );\n return irProperty(toPropertyName(\"parameters\"), irObject(members), {\n isReadonly: context.options.immutable,\n });\n}\n"],"names":["resolveParameter","toPropertyName","appendPointer","referencedParameterType","parameterType","irProperty","withSchemaComment","QUERYSTRING_LOCATION","FIX","isExplodedQueryObject","irReference","irObject","irKeyword","irIntersection","parameterEntries","PARAMETER_LOCATIONS"],"mappings":";;;;;;;;;;;;;AAgCA,MAAM,gBAAA,GAAmB,eAAA;AAGzB,SAAS,uBAAuB,IAAA,EAAiC;AAC/D,EAAA,OAAA,CAAQ,IAAA,CAAK,MAAM,gBAAgB,CAAA,IAAK,EAAC,EAAG,GAAA,CAAI,CAAC,KAAA,MAAW;AAAA,IAC1D,IAAA,EAAM,KAAA,CAAM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AAA,CAAoB,GAAA;AAAA,IAAI,CAAC,WAAA,KACvC,WAAA,KAAgB,OAAA,IAAW,WAAA,GACvB,cACA,cAAA,CAAe,WAAA,EAAa,OAAA,EAAS,QAAA,EAAU,OAAO;AAAA,GAC5D;AACA,EAAA,OAAOV,wBAAWJ,2BAAA,CAAe,YAAY,CAAA,EAAGU,qBAAA,CAAS,OAAO,CAAA,EAAG;AAAA,IACjE,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;;"}
@@ -1,17 +1,15 @@
1
1
  import { irProperty, irObject, irKeyword, irIntersection, irReference } from '../../../domain/ir/constructors.mjs';
2
2
  import { toPropertyName } from '../../../domain/ir/property-name.mjs';
3
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
3
+ import { appendPointer } from '../../../domain/openapi/json-pointer.mjs';
4
4
  import { PARAMETER_LOCATIONS, QUERYSTRING_LOCATION } from '../../../domain/openapi/parameter-object.mjs';
5
5
  import { FIX } from '../../../domain/output-fixes.mjs';
6
- import { refType } from '../ref-type.mjs';
7
6
  import { withSchemaComment } from '../schema-comment.mjs';
8
7
  import { isExplodedQueryObject } from './exploded-query.mjs';
9
8
  import { parameterType } from './parameter.mjs';
9
+ import { parameterEntries, resolveParameter } from './parameter-entries.mjs';
10
+ import { referencedParameterType } from './referenced-parameter.mjs';
10
11
 
11
12
  const PATH_TEMPLATE_RE = /\{([^{}]+)\}/g;
12
- function resolveParameter(parameter, context) {
13
- return "$ref" in parameter ? context.refs.resolve(parameter.$ref) : parameter;
14
- }
15
13
  function pathTemplateParameters(path) {
16
14
  return (path.match(PATH_TEMPLATE_RE) ?? []).map((match) => ({
17
15
  name: match.slice(1, -1),
@@ -27,7 +25,7 @@ function withPathTemplateParameters(parameters, location, context) {
27
25
  }
28
26
  for (const parameter of pathTemplateParameters(location.path)) {
29
27
  const isDefined = result.some((candidate) => {
30
- const resolved = resolveParameter(candidate, context);
28
+ const resolved = resolveParameter(candidate, context.refs);
31
29
  return resolved?.in === "path" && resolved.name === parameter.name;
32
30
  });
33
31
  if (!isDefined) {
@@ -36,33 +34,12 @@ function withPathTemplateParameters(parameters, location, context) {
36
34
  }
37
35
  return result;
38
36
  }
39
- function isDeprecatedParameter(parameter) {
40
- const schema = parameter?.schema;
41
- return Boolean(parameter?.deprecated || schema?.deprecated);
42
- }
43
- function parameterEntries(parameters, context) {
44
- const entries = parameters.map((original) => ({
45
- original,
46
- resolved: resolveParameter(original, context)
47
- }));
48
- if (context.options.alphabetize) {
49
- entries.sort(
50
- (left, right) => (left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? "")
51
- );
52
- }
53
- return context.options.excludeDeprecated ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved)) : entries;
54
- }
55
37
  function parameterName(name) {
56
38
  return typeof name === "string" || typeof name === "number" ? toPropertyName(name) : { kind: "string", value: String(name) };
57
39
  }
58
- function referencedParameterType(ref, resolved) {
59
- const isParameter = !resolved.$ref;
60
- const parameter = isParameter ? { in: resolved.in, name: resolved.name } : null;
61
- return refType(ref, { parameter });
62
- }
63
40
  function entryType({ original, resolved }, location, context) {
64
- const path = createRef([location.path, "parameters", resolved.in, resolved.name]);
65
- return "$ref" in original ? referencedParameterType(original.$ref, resolved) : parameterType(resolved, { ...location, path }, context);
41
+ const path = appendPointer(location.path, ["parameters", resolved.in, resolved.name]);
42
+ return "$ref" in original ? referencedParameterType(original.$ref, resolved, context) : parameterType(resolved, { ...location, path }, context);
66
43
  }
67
44
  function parameterMember(entry, location, context) {
68
45
  const { resolved } = entry;