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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/dist/adapters/node-file-system/node-file-system.cjs +7 -0
  3. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  4. package/dist/adapters/node-file-system/node-file-system.mjs +7 -0
  5. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  6. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
  7. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
  8. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
  9. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
  10. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +5 -32
  11. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +6 -33
  13. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
  15. package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
  17. package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
  19. package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
  21. package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/query-document-names.cjs +50 -0
  23. package/dist/adapters/redocly-loader/query-document-names.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/query-document-names.mjs +48 -0
  25. package/dist/adapters/redocly-loader/query-document-names.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/query-named-components.cjs +129 -0
  27. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/query-named-components.mjs +126 -0
  29. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/redocly-config-source.cjs +3 -0
  31. package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/redocly-config-source.mjs +4 -1
  33. package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +39 -18
  35. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +40 -19
  37. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/ref-access.cjs +25 -4
  39. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/ref-access.mjs +26 -5
  41. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
  43. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/ref-holders.mjs +52 -11
  45. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/remote-fetch.cjs +20 -3
  47. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/remote-fetch.mjs +20 -4
  49. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/remote-node-limit.cjs +17 -3
  51. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/remote-node-limit.mjs +17 -3
  53. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/schema-source.cjs +7 -2
  55. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-source.mjs +8 -3
  57. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  58. package/dist/adapters/terminal-logger/terminal-logger.cjs +7 -3
  59. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  60. package/dist/adapters/terminal-logger/terminal-logger.mjs +7 -3
  61. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  62. package/dist/api/cwd-option.cjs +58 -0
  63. package/dist/api/cwd-option.cjs.map +1 -0
  64. package/dist/api/cwd-option.mjs +52 -0
  65. package/dist/api/cwd-option.mjs.map +1 -0
  66. package/dist/api/default-ports.cjs +15 -7
  67. package/dist/api/default-ports.cjs.map +1 -1
  68. package/dist/api/default-ports.mjs +14 -8
  69. package/dist/api/default-ports.mjs.map +1 -1
  70. package/dist/api/document-refs.cjs +16 -1
  71. package/dist/api/document-refs.cjs.map +1 -1
  72. package/dist/api/document-refs.mjs +16 -1
  73. package/dist/api/document-refs.mjs.map +1 -1
  74. package/dist/api/document-run.cjs +6 -26
  75. package/dist/api/document-run.cjs.map +1 -1
  76. package/dist/api/document-run.mjs +5 -21
  77. package/dist/api/document-run.mjs.map +1 -1
  78. package/dist/api/legacy-utils.cjs +1 -1
  79. package/dist/api/legacy-utils.cjs.map +1 -1
  80. package/dist/api/legacy-utils.mjs +1 -1
  81. package/dist/api/legacy-utils.mjs.map +1 -1
  82. package/dist/api/openapi-ts.cjs +1 -2
  83. package/dist/api/openapi-ts.cjs.map +1 -1
  84. package/dist/api/openapi-ts.mjs +2 -3
  85. package/dist/api/openapi-ts.mjs.map +1 -1
  86. package/dist/api/option-errors.cjs +24 -0
  87. package/dist/api/option-errors.cjs.map +1 -0
  88. package/dist/api/option-errors.mjs +21 -0
  89. package/dist/api/option-errors.mjs.map +1 -0
  90. package/dist/api/ref-limit-options.cjs +58 -0
  91. package/dist/api/ref-limit-options.cjs.map +1 -0
  92. package/dist/api/ref-limit-options.mjs +52 -0
  93. package/dist/api/ref-limit-options.mjs.map +1 -0
  94. package/dist/api/transform-schema.cjs +12 -5
  95. package/dist/api/transform-schema.cjs.map +1 -1
  96. package/dist/api/transform-schema.mjs +12 -5
  97. package/dist/api/transform-schema.mjs.map +1 -1
  98. package/dist/application/transform/declared-value-types.cjs +36 -0
  99. package/dist/application/transform/declared-value-types.cjs.map +1 -0
  100. package/dist/application/transform/declared-value-types.mjs +34 -0
  101. package/dist/application/transform/declared-value-types.mjs.map +1 -0
  102. package/dist/application/transform/document/document.cjs +3 -1
  103. package/dist/application/transform/document/document.cjs.map +1 -1
  104. package/dist/application/transform/document/document.mjs +3 -1
  105. package/dist/application/transform/document/document.mjs.map +1 -1
  106. package/dist/application/transform/document/exploded-query-values.cjs +63 -0
  107. package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
  108. package/dist/application/transform/document/exploded-query-values.mjs +59 -0
  109. package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
  110. package/dist/application/transform/document/header.cjs +11 -3
  111. package/dist/application/transform/document/header.cjs.map +1 -1
  112. package/dist/application/transform/document/header.mjs +10 -2
  113. package/dist/application/transform/document/header.mjs.map +1 -1
  114. package/dist/application/transform/document/parameter.cjs +1 -1
  115. package/dist/application/transform/document/parameter.cjs.map +1 -1
  116. package/dist/application/transform/document/parameter.mjs +1 -1
  117. package/dist/application/transform/document/parameter.mjs.map +1 -1
  118. package/dist/application/transform/document/parameters.cjs +23 -5
  119. package/dist/application/transform/document/parameters.cjs.map +1 -1
  120. package/dist/application/transform/document/parameters.mjs +23 -5
  121. package/dist/application/transform/document/parameters.mjs.map +1 -1
  122. package/dist/application/transform/document/path-item.cjs +4 -3
  123. package/dist/application/transform/document/path-item.cjs.map +1 -1
  124. package/dist/application/transform/document/path-item.mjs +4 -4
  125. package/dist/application/transform/document/path-item.mjs.map +1 -1
  126. package/dist/application/transform/document/path-template-key.cjs +84 -0
  127. package/dist/application/transform/document/path-template-key.cjs.map +1 -0
  128. package/dist/application/transform/document/path-template-key.mjs +79 -0
  129. package/dist/application/transform/document/path-template-key.mjs.map +1 -0
  130. package/dist/application/transform/document/path-template-refs.cjs +80 -0
  131. package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
  132. package/dist/application/transform/document/path-template-refs.mjs +77 -0
  133. package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
  134. package/dist/application/transform/document/paths-enum.cjs +7 -6
  135. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  136. package/dist/application/transform/document/paths-enum.mjs +7 -6
  137. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  138. package/dist/application/transform/document/paths.cjs +38 -66
  139. package/dist/application/transform/document/paths.cjs.map +1 -1
  140. package/dist/application/transform/document/paths.mjs +36 -66
  141. package/dist/application/transform/document/paths.mjs.map +1 -1
  142. package/dist/application/transform/document/webhooks.cjs +10 -3
  143. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  144. package/dist/application/transform/document/webhooks.mjs +9 -2
  145. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  146. package/dist/application/transform/footer/document-footer.cjs +6 -3
  147. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  148. package/dist/application/transform/footer/document-footer.mjs +6 -3
  149. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  150. package/dist/application/transform/helper-types.cjs +3 -3
  151. package/dist/application/transform/helper-types.cjs.map +1 -1
  152. package/dist/application/transform/helper-types.mjs +3 -3
  153. package/dist/application/transform/helper-types.mjs.map +1 -1
  154. package/dist/application/transform/ref-pointer/generated-location.cjs +4 -4
  155. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  156. package/dist/application/transform/ref-pointer/generated-location.mjs +1 -1
  157. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  158. package/dist/application/transform/ref-pointer/generated-shape.cjs +63 -64
  159. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  160. package/dist/application/transform/ref-pointer/generated-shape.mjs +57 -53
  161. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  162. package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
  163. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
  164. package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
  165. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
  166. package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
  167. package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
  168. package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
  169. package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
  170. package/dist/application/transform/ref-pointer/original-index.cjs +69 -14
  171. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  172. package/dist/application/transform/ref-pointer/original-index.mjs +71 -16
  173. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  174. package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
  175. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  176. package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
  177. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  178. package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
  179. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
  180. package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
  181. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
  182. package/dist/application/transform/ref-pointer/property-shape.cjs +57 -0
  183. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
  184. package/dist/application/transform/ref-pointer/property-shape.mjs +49 -0
  185. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
  186. package/dist/application/transform/ref-pointer/typed-walk.cjs +90 -22
  187. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  188. package/dist/application/transform/ref-pointer/typed-walk.mjs +87 -19
  189. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  190. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  191. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  192. package/dist/application/transform/schema/index-signature-type.cjs +21 -0
  193. package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
  194. package/dist/application/transform/schema/index-signature-type.mjs +19 -0
  195. package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
  196. package/dist/application/transform/schema/input-location.cjs +23 -0
  197. package/dist/application/transform/schema/input-location.cjs.map +1 -0
  198. package/dist/application/transform/schema/input-location.mjs +21 -0
  199. package/dist/application/transform/schema/input-location.mjs.map +1 -0
  200. package/dist/application/transform/schema/object-type.cjs +15 -5
  201. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  202. package/dist/application/transform/schema/object-type.mjs +15 -5
  203. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  204. package/dist/application/transform/schema/schema-transform.cjs +2 -1
  205. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  206. package/dist/application/transform/schema/schema-transform.mjs +2 -1
  207. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  208. package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
  209. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  210. package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
  211. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  212. package/dist/cli/api-logger.cjs +13 -0
  213. package/dist/cli/api-logger.cjs.map +1 -0
  214. package/dist/cli/api-logger.mjs +11 -0
  215. package/dist/cli/api-logger.mjs.map +1 -0
  216. package/dist/cli/api-settings.cjs +10 -17
  217. package/dist/cli/api-settings.cjs.map +1 -1
  218. package/dist/cli/api-settings.mjs +10 -17
  219. package/dist/cli/api-settings.mjs.map +1 -1
  220. package/dist/cli/api-writes.cjs +7 -1
  221. package/dist/cli/api-writes.cjs.map +1 -1
  222. package/dist/cli/api-writes.mjs +7 -1
  223. package/dist/cli/api-writes.mjs.map +1 -1
  224. package/dist/cli/cli-arguments.cjs +32 -74
  225. package/dist/cli/cli-arguments.cjs.map +1 -1
  226. package/dist/cli/cli-arguments.mjs +28 -70
  227. package/dist/cli/cli-arguments.mjs.map +1 -1
  228. package/dist/cli/cli-errors.cjs +18 -0
  229. package/dist/cli/cli-errors.cjs.map +1 -1
  230. package/dist/cli/cli-errors.mjs +18 -1
  231. package/dist/cli/cli-errors.mjs.map +1 -1
  232. package/dist/cli/cli-flag-names.cjs +77 -0
  233. package/dist/cli/cli-flag-names.cjs.map +1 -0
  234. package/dist/cli/cli-flag-names.mjs +64 -0
  235. package/dist/cli/cli-flag-names.mjs.map +1 -0
  236. package/dist/cli/cli-output.cjs +13 -6
  237. package/dist/cli/cli-output.cjs.map +1 -1
  238. package/dist/cli/cli-output.mjs +14 -7
  239. package/dist/cli/cli-output.mjs.map +1 -1
  240. package/dist/cli/main.cjs +11 -5
  241. package/dist/cli/main.cjs.map +1 -1
  242. package/dist/cli/main.mjs +11 -5
  243. package/dist/cli/main.mjs.map +1 -1
  244. package/dist/cli/redocly-apis.cjs +33 -12
  245. package/dist/cli/redocly-apis.cjs.map +1 -1
  246. package/dist/cli/redocly-apis.mjs +35 -14
  247. package/dist/cli/redocly-apis.mjs.map +1 -1
  248. package/dist/cli/ref-limits.cjs +15 -1
  249. package/dist/cli/ref-limits.cjs.map +1 -1
  250. package/dist/cli/ref-limits.mjs +15 -2
  251. package/dist/cli/ref-limits.mjs.map +1 -1
  252. package/dist/cli/run-cli.cjs +24 -7
  253. package/dist/cli/run-cli.cjs.map +1 -1
  254. package/dist/cli/run-cli.mjs +25 -8
  255. package/dist/cli/run-cli.mjs.map +1 -1
  256. package/dist/cli/written-flags.cjs +83 -0
  257. package/dist/cli/written-flags.cjs.map +1 -0
  258. package/dist/cli/written-flags.mjs +77 -0
  259. package/dist/cli/written-flags.mjs.map +1 -0
  260. package/dist/domain/cause-secrets.cjs +31 -16
  261. package/dist/domain/cause-secrets.cjs.map +1 -1
  262. package/dist/domain/cause-secrets.mjs +31 -16
  263. package/dist/domain/cause-secrets.mjs.map +1 -1
  264. package/dist/domain/errors.cjs +3 -0
  265. package/dist/domain/errors.cjs.map +1 -1
  266. package/dist/domain/errors.mjs +3 -0
  267. package/dist/domain/errors.mjs.map +1 -1
  268. package/dist/domain/location-text.cjs +15 -0
  269. package/dist/domain/location-text.cjs.map +1 -0
  270. package/dist/domain/location-text.mjs +13 -0
  271. package/dist/domain/location-text.mjs.map +1 -0
  272. package/dist/domain/openapi/document-places.cjs +55 -0
  273. package/dist/domain/openapi/document-places.cjs.map +1 -0
  274. package/dist/domain/openapi/document-places.mjs +53 -0
  275. package/dist/domain/openapi/document-places.mjs.map +1 -0
  276. package/dist/domain/output-fixes.cjs +8 -2
  277. package/dist/domain/output-fixes.cjs.map +1 -1
  278. package/dist/domain/output-fixes.mjs +8 -2
  279. package/dist/domain/output-fixes.mjs.map +1 -1
  280. package/dist/domain/terminal-text.cjs +31 -0
  281. package/dist/domain/terminal-text.cjs.map +1 -0
  282. package/dist/domain/terminal-text.mjs +29 -0
  283. package/dist/domain/terminal-text.mjs.map +1 -0
  284. package/dist/domain/warnings.cjs +1 -0
  285. package/dist/domain/warnings.cjs.map +1 -1
  286. package/dist/domain/warnings.mjs +1 -0
  287. package/dist/domain/warnings.mjs.map +1 -1
  288. package/dist/index.d.cts +29 -18
  289. package/dist/index.d.mts +29 -18
  290. package/dist/index.d.ts +29 -18
  291. package/package.json +1 -1
  292. package/src/adapters/node-file-system/node-file-system.ts +14 -1
  293. package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
  294. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +7 -42
  295. package/src/adapters/redocly-loader/component-schemas.ts +19 -0
  296. package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
  297. package/src/adapters/redocly-loader/query-document-names.ts +79 -0
  298. package/src/adapters/redocly-loader/query-named-components.ts +200 -0
  299. package/src/adapters/redocly-loader/redocly-config-source.ts +11 -1
  300. package/src/adapters/redocly-loader/redocly-schema-loader.ts +63 -17
  301. package/src/adapters/redocly-loader/ref-access.ts +32 -5
  302. package/src/adapters/redocly-loader/ref-holders.ts +75 -14
  303. package/src/adapters/redocly-loader/remote-fetch.ts +37 -2
  304. package/src/adapters/redocly-loader/remote-node-limit.ts +44 -4
  305. package/src/adapters/redocly-loader/schema-source.ts +15 -3
  306. package/src/adapters/terminal-logger/terminal-logger.ts +10 -4
  307. package/src/api/cwd-option.ts +76 -0
  308. package/src/api/default-ports.ts +33 -10
  309. package/src/api/document-refs.ts +29 -1
  310. package/src/api/document-run.ts +7 -32
  311. package/src/api/legacy-utils.ts +1 -1
  312. package/src/api/openapi-ts.ts +20 -4
  313. package/src/api/option-errors.ts +22 -0
  314. package/src/api/ref-limit-options.ts +69 -0
  315. package/src/api/transform-schema.ts +20 -5
  316. package/src/application/ports/file-system.ts +8 -0
  317. package/src/application/ports/redocly-config-source.ts +5 -0
  318. package/src/application/transform/declared-value-types.ts +42 -0
  319. package/src/application/transform/document/document.ts +4 -2
  320. package/src/application/transform/document/exploded-query-values.ts +88 -0
  321. package/src/application/transform/document/header.ts +25 -5
  322. package/src/application/transform/document/parameter.ts +4 -4
  323. package/src/application/transform/document/parameters.ts +45 -10
  324. package/src/application/transform/document/path-item.ts +3 -3
  325. package/src/application/transform/document/path-template-key.ts +152 -0
  326. package/src/application/transform/document/path-template-refs.ts +127 -0
  327. package/src/application/transform/document/paths-enum.ts +23 -9
  328. package/src/application/transform/document/paths.ts +53 -123
  329. package/src/application/transform/document/webhooks.ts +18 -5
  330. package/src/application/transform/footer/document-footer.ts +18 -8
  331. package/src/application/transform/helper-types.ts +4 -4
  332. package/src/application/transform/ref-pointer/generated-location.ts +1 -1
  333. package/src/application/transform/ref-pointer/generated-shape.ts +115 -83
  334. package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
  335. package/src/application/transform/ref-pointer/located-node.ts +38 -0
  336. package/src/application/transform/ref-pointer/original-index.ts +106 -20
  337. package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
  338. package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
  339. package/src/application/transform/ref-pointer/property-shape.ts +106 -0
  340. package/src/application/transform/ref-pointer/typed-walk.ts +143 -29
  341. package/src/application/transform/schema/access-flags.ts +5 -2
  342. package/src/application/transform/schema/index-signature-type.ts +31 -0
  343. package/src/application/transform/schema/input-location.ts +35 -0
  344. package/src/application/transform/schema/object-type.ts +18 -8
  345. package/src/application/transform/schema/schema-transform.ts +2 -1
  346. package/src/application/transform/schema/unevaluated-properties.ts +4 -44
  347. package/src/cli/api-logger.ts +17 -0
  348. package/src/cli/api-settings.ts +12 -20
  349. package/src/cli/api-writes.ts +11 -3
  350. package/src/cli/cli-arguments.ts +57 -92
  351. package/src/cli/cli-dependencies.ts +7 -2
  352. package/src/cli/cli-errors.ts +23 -0
  353. package/src/cli/cli-flag-names.ts +99 -0
  354. package/src/cli/cli-output.ts +31 -16
  355. package/src/cli/main.ts +12 -5
  356. package/src/cli/redocly-apis.ts +56 -20
  357. package/src/cli/ref-limits.ts +21 -2
  358. package/src/cli/run-cli.ts +39 -7
  359. package/src/cli/written-flags.ts +131 -0
  360. package/src/domain/cause-secrets.ts +59 -25
  361. package/src/domain/errors.ts +3 -0
  362. package/src/domain/location-text.ts +27 -0
  363. package/src/domain/openapi/document-places.ts +78 -0
  364. package/src/domain/output-fixes.ts +9 -2
  365. package/src/domain/terminal-text.ts +44 -0
  366. package/src/domain/warnings.ts +1 -0
@@ -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 { 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,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,IACvB,EAAA,EAAI,MAAA;AAAA,IACJ,QAAA,EAAU,IAAA;AAAA,IACV,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA;AAAS,GAC3B,CAAE,CAAA;AACJ;AAGA,SAAS,0BAAA,CACP,UAAA,EACA,QAAA,EACA,OAAA,EACwB;AACxB,EAAA,MAAM,MAAA,GAAS,CAAC,GAAG,UAAU,CAAA;AAC7B,EAAA,IAAI,CAAC,OAAA,CAAQ,OAAA,CAAQ,kBAAA,IAAsB,CAAC,SAAS,IAAA,EAAM;AACzD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,KAAA,MAAW,SAAA,IAAa,sBAAA,CAAuB,QAAA,CAAS,IAAI,CAAA,EAAG;AAC7D,IAAA,MAAM,SAAA,GAAY,MAAA,CAAO,IAAA,CAAK,CAAC,SAAA,KAAc;AAC3C,MAAA,MAAM,QAAA,GAAWA,iCAAA,CAAiB,SAAA,EAAW,OAAA,CAAQ,IAAI,CAAA;AACzD,MAAA,OAAO,QAAA,EAAU,EAAA,KAAO,MAAA,IAAU,QAAA,CAAS,SAAS,SAAA,CAAU,IAAA;AAAA,IAChE,CAAC,CAAA;AACD,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,MAAA,CAAO,KAA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,CAAA,EAAG;AAAA,IAClE,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;AAOO,SAAS,gBAAA,CACd,UAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,OAAA,GAAUa,iCAAA;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,UAAUC,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,OAAOV,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 { declaredValueTypes } from \"../declared-value-types.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 { declaredObjectType, hasIndexSignature, withIndexValues } from \"./exploded-query-values.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/** An exploded object parameter with its type, typed in document order. */\ninterface ExplodedEntry {\n readonly entry: ResolvedEntry;\n readonly type: IrType;\n}\n\n/**\n * The object type of an exploded parameter, written out when it is a reference to a type with an\n * index signature and `query` has other keys, which that signature must then admit. Without\n * other keys the reference is kept.\n */\nfunction explodedObjectType(\n { entry, type }: ExplodedEntry,\n hasOtherKeys: boolean,\n context: TransformContext,\n): IrType {\n if (!hasOtherKeys) {\n return type;\n }\n const declared = declaredObjectType(entry, context);\n return declared !== null && hasIndexSignature(declared) ? declared : type;\n}\n\n/**\n * The exploded object parameters' parts of `query`: their object types, each index signature\n * widened by the value types of the other keys (see `exploded-query-values.ts`). A parameter that\n * may be left out sends none of its keys then, so they are optional: `Partial<…>`.\n */\nfunction explodedParts(\n exploded: readonly ExplodedEntry[],\n members: readonly IrPropertySignature[],\n context: TransformContext,\n): IrType[] {\n const hasOtherKeys = members.length > 0 || exploded.length > 1;\n const types = exploded.map((part) => explodedObjectType(part, hasOtherKeys, context));\n const others = (index: number) => [\n ...(members.length > 0 ? [irObject(members)] : []),\n ...types.filter((_type, other) => other !== index),\n ];\n return types.map((type, index) => {\n const values = others(index).flatMap((other) => declaredValueTypes(other, context.footer));\n const widened = withIndexValues(type, values);\n return exploded[index]?.entry.resolved.required ? widened : irReference(\"Partial\", [widened]);\n });\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: ExplodedEntry[] = [];\n let isOptional = true;\n for (const entry of entries) {\n if (isExplodedEntry(entry, context)) {\n exploded.push({ entry, type: entryType(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: explodedParts(exploded, members, context), 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","declaredObjectType","hasIndexSignature","irObject","declaredValueTypes","withIndexValues","irReference","irKeyword","irIntersection","parameterEntries","PARAMETER_LOCATIONS"],"mappings":";;;;;;;;;;;;;;;AAkCA,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,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,IACvB,EAAA,EAAI,MAAA;AAAA,IACJ,QAAA,EAAU,IAAA;AAAA,IACV,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA;AAAS,GAC3B,CAAE,CAAA;AACJ;AAGA,SAAS,0BAAA,CACP,UAAA,EACA,QAAA,EACA,OAAA,EACwB;AACxB,EAAA,MAAM,MAAA,GAAS,CAAC,GAAG,UAAU,CAAA;AAC7B,EAAA,IAAI,CAAC,OA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AAQC,4BAAe,KAAK,CAAA;AAC1D;AAGA,SAAS,cAAA,CACP,WAAA,EACA,OAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAU,OAAA,CAAQ,MAAA;AAAA,IACtB,CAAC,KAAA,KAAkC,KAAA,CAAM,QAAA,EAAU,EAAA,KAAO;AAAA,GAC5D;AACA,EAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,OAAA,EAAS,QAAA,EAAU,OAAO,CAAA;AACtD,EAAA,OAAOZ,wBAAWJ,2BAAA,CAAe,WAAW,CAAA,EAAG,YAAA,CAAa,KAAK,CAAA,EAAG;AAAA,IAClE,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;AAOO,SAAS,gBAAA,CACd,UAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,OAAA,GAAUiB,iCAAA;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,UAAUC,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,OAAOd,wBAAWJ,2BAAA,CAAe,YAAY,CAAA,EAAGW,qBAAA,CAAS,OAAO,CAAA,EAAG;AAAA,IACjE,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;;"}
@@ -3,8 +3,10 @@ import { toPropertyName } from '../../../domain/ir/property-name.mjs';
3
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 { declaredValueTypes } from '../declared-value-types.mjs';
6
7
  import { withSchemaComment } from '../schema-comment.mjs';
7
8
  import { isExplodedQueryObject } from './exploded-query.mjs';
9
+ import { withIndexValues, declaredObjectType, hasIndexSignature } from './exploded-query-values.mjs';
8
10
  import { parameterType } from './parameter.mjs';
9
11
  import { parameterEntries, resolveParameter } from './parameter-entries.mjs';
10
12
  import { referencedParameterType } from './referenced-parameter.mjs';
@@ -65,9 +67,25 @@ function querystringMember(entries, location, context) {
65
67
  function isExplodedEntry(entry, context) {
66
68
  return context.options.fixes.has(FIX.EXPLODED_QUERY_OBJECTS) && isExplodedQueryObject(entry.resolved, context.refs);
67
69
  }
68
- function explodedPart(entry, location, context) {
69
- const type = entryType(entry, location, context);
70
- return entry.resolved.required ? type : irReference("Partial", [type]);
70
+ function explodedObjectType({ entry, type }, hasOtherKeys, context) {
71
+ if (!hasOtherKeys) {
72
+ return type;
73
+ }
74
+ const declared = declaredObjectType(entry, context);
75
+ return declared !== null && hasIndexSignature(declared) ? declared : type;
76
+ }
77
+ function explodedParts(exploded, members, context) {
78
+ const hasOtherKeys = members.length > 0 || exploded.length > 1;
79
+ const types = exploded.map((part) => explodedObjectType(part, hasOtherKeys, context));
80
+ const others = (index) => [
81
+ ...members.length > 0 ? [irObject(members)] : [],
82
+ ...types.filter((_type, other) => other !== index)
83
+ ];
84
+ return types.map((type, index) => {
85
+ const values = others(index).flatMap((other) => declaredValueTypes(other, context.footer));
86
+ const widened = withIndexValues(type, values);
87
+ return exploded[index]?.entry.resolved.required ? widened : irReference("Partial", [widened]);
88
+ });
71
89
  }
72
90
  function locationParts(entries, location, context) {
73
91
  const members = [];
@@ -75,7 +93,7 @@ function locationParts(entries, location, context) {
75
93
  let isOptional = true;
76
94
  for (const entry of entries) {
77
95
  if (isExplodedEntry(entry, context)) {
78
- exploded.push(explodedPart(entry, location, context));
96
+ exploded.push({ entry, type: entryType(entry, location, context) });
79
97
  isOptional &&= !entry.resolved.required;
80
98
  continue;
81
99
  }
@@ -83,7 +101,7 @@ function locationParts(entries, location, context) {
83
101
  members.push(member);
84
102
  isOptional &&= member.isOptional;
85
103
  }
86
- return { members, exploded, isOptional };
104
+ return { members, exploded: explodedParts(exploded, members, context), isOptional };
87
105
  }
88
106
  function locationType({ members, exploded }) {
89
107
  const types = [...members.length > 0 ? [irObject(members)] : [], ...exploded];
@@ -1 +1 @@
1
- {"version":3,"file":"parameters.mjs","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":[],"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,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,IACvB,EAAA,EAAI,MAAA;AAAA,IACJ,QAAA,EAAU,IAAA;AAAA,IACV,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA;AAAS,GAC3B,CAAE,CAAA;AACJ;AAGA,SAAS,0BAAA,CACP,UAAA,EACA,QAAA,EACA,OAAA,EACwB;AACxB,EAAA,MAAM,MAAA,GAAS,CAAC,GAAG,UAAU,CAAA;AAC7B,EAAA,IAAI,CAAC,OAAA,CAAQ,OAAA,CAAQ,kBAAA,IAAsB,CAAC,SAAS,IAAA,EAAM;AACzD,IAAA,OAAO,MAAA;AAA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AI,KAAA,GAAQ,eAAe,KAAK,CAAA;AAC1D;AAGA,SAAS,cAAA,CACP,WAAA,EACA,OAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAU,OAAA,CAAQ,MAAA;AAAA,IACtB,CAAC,KAAA,KAAkC,KAAA,CAAM,QAAA,EAAU,EAAA,KAAO;AAAA,GAC5D;AACA,EAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,OAAA,EAAS,QAAA,EAAU,OAAO,CAAA;AACtD,EAAA,OAAO,WAAW,cAAA,CAAe,WAAW,CAAA,EAAG,YAAA,CAAa,KAAK,CAAA,EAAG;AAAA,IAClE,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;AAOO,SAAS,gBAAA,CACd,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,UAAU,mBAAA,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,OAAO,WAAW,cAAA,CAAe,YAAY,CAAA,EAAG,QAAA,CAAS,OAAO,CAAA,EAAG;AAAA,IACjE,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACH;;"}
1
+ {"version":3,"file":"parameters.mjs","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 { declaredValueTypes } from \"../declared-value-types.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 { declaredObjectType, hasIndexSignature, withIndexValues } from \"./exploded-query-values.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/** An exploded object parameter with its type, typed in document order. */\ninterface ExplodedEntry {\n readonly entry: ResolvedEntry;\n readonly type: IrType;\n}\n\n/**\n * The object type of an exploded parameter, written out when it is a reference to a type with an\n * index signature and `query` has other keys, which that signature must then admit. Without\n * other keys the reference is kept.\n */\nfunction explodedObjectType(\n { entry, type }: ExplodedEntry,\n hasOtherKeys: boolean,\n context: TransformContext,\n): IrType {\n if (!hasOtherKeys) {\n return type;\n }\n const declared = declaredObjectType(entry, context);\n return declared !== null && hasIndexSignature(declared) ? declared : type;\n}\n\n/**\n * The exploded object parameters' parts of `query`: their object types, each index signature\n * widened by the value types of the other keys (see `exploded-query-values.ts`). A parameter that\n * may be left out sends none of its keys then, so they are optional: `Partial<…>`.\n */\nfunction explodedParts(\n exploded: readonly ExplodedEntry[],\n members: readonly IrPropertySignature[],\n context: TransformContext,\n): IrType[] {\n const hasOtherKeys = members.length > 0 || exploded.length > 1;\n const types = exploded.map((part) => explodedObjectType(part, hasOtherKeys, context));\n const others = (index: number) => [\n ...(members.length > 0 ? [irObject(members)] : []),\n ...types.filter((_type, other) => other !== index),\n ];\n return types.map((type, index) => {\n const values = others(index).flatMap((other) => declaredValueTypes(other, context.footer));\n const widened = withIndexValues(type, values);\n return exploded[index]?.entry.resolved.required ? widened : irReference(\"Partial\", [widened]);\n });\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: ExplodedEntry[] = [];\n let isOptional = true;\n for (const entry of entries) {\n if (isExplodedEntry(entry, context)) {\n exploded.push({ entry, type: entryType(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: explodedParts(exploded, members, context), 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":[],"mappings":";;;;;;;;;;;;;AAkCA,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,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,IACvB,EAAA,EAAI,MAAA;AAAA,IACJ,QAAA,EAAU,IAAA;AAAA,IACV,MAAA,EAAQ,EAAE,I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ACH;;"}
@@ -15,7 +15,7 @@ const HASH_RE = /#/g;
15
15
  function operationKeyOf(operationId) {
16
16
  return operationId.replace(HASH_RE, "/");
17
17
  }
18
- function isIncluded(operation, context) {
18
+ function isIncludedOperation(operation, context) {
19
19
  if (!operation) {
20
20
  return false;
21
21
  }
@@ -41,7 +41,7 @@ function operationMember({ name, operation, path }, pathItem, location, context)
41
41
  }
42
42
  function methodMember(method, pathItem, location, context) {
43
43
  const operation = pathItem[method];
44
- if (!isIncluded(operation, context)) {
44
+ if (!isIncludedOperation(operation, context)) {
45
45
  const isReadonly = context.options.immutable;
46
46
  return constructors.irProperty(propertyName.toPropertyName(method), constructors.irKeyword("never"), { isOptional: true, isReadonly });
47
47
  }
@@ -50,7 +50,7 @@ function methodMember(method, pathItem, location, context) {
50
50
  }
51
51
  function additionalOperationsMember(pathItem, location, context) {
52
52
  const entries = documentEntries.documentEntries(pathItem.additionalOperations ?? {}, context.options);
53
- const members = entries.filter(([, operation]) => isIncluded(operation, context)).map(([method, operation]) => {
53
+ const members = entries.filter(([, operation]) => isIncludedOperation(operation, context)).map(([method, operation]) => {
54
54
  const path = jsonPointer.appendPointer(location.path, [pathItemObject.ADDITIONAL_OPERATIONS_KEY, method]);
55
55
  return operationMember({ name: method, operation, path }, pathItem, location, context);
56
56
  });
@@ -74,6 +74,7 @@ function pathItemType(pathItem, location, context) {
74
74
  return constructors.irObject(members);
75
75
  }
76
76
 
77
+ exports.isIncludedOperation = isIncludedOperation;
77
78
  exports.operationKeyOf = operationKeyOf;
78
79
  exports.pathItemType = pathItemType;
79
80
  //# sourceMappingURL=path-item.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-item.cjs","sources":["../../../../src/application/transform/document/path-item.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.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 { operationMembers } from \"./operation.js\";\nimport { mergedParameters } from \"./parameter-entries.js\";\nimport { parametersMember } from \"./parameters.js\";\n\n/** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */\nconst HASH_RE = /#/g;\n\n/** The `operations` key an `operationId` asks for, before a repeated one gets a number. */\nexport function operationKeyOf(operationId: string): string {\n return operationId.replace(HASH_RE, \"/\");\n}\n\n/** Whether the method has an operation, not removed by `--exclude-deprecated`. */\nfunction isIncluded(\n operation: OperationEntry | undefined,\n context: TransformContext,\n): operation is OperationEntry {\n if (!operation) {\n return false;\n }\n const resolved =\n \"$ref\" in operation\n ? (context.refs.resolve(operation.$ref) as OperationObject | undefined)\n : operation;\n return !(context.options.excludeDeprecated && resolved?.deprecated);\n}\n\n/**\n * An operation with an `operationId` goes into the `operations` interface and is referenced from\n * the path item; others are written inline.\n */\nfunction operationType(\n pathItem: PathItemObject,\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };\n if (!operation.operationId) {\n return irObject(operationMembers(merged, location, context));\n }\n const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));\n context.footer.addOperation(() =>\n irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {\n isReadonly: context.options.immutable,\n }),\n );\n return refType(appendPointer(ROOT_POINTER, [\"operations\", operationId]));\n}\n\n/** An included operation, the member name it gets and its location below the path item. */\ninterface DeclaredOperation {\n readonly name: string;\n readonly operation: OperationEntry;\n readonly path: string;\n}\n\nfunction operationMember(\n { name, operation, path }: DeclaredOperation,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const type =\n \"$ref\" in operation\n ? refType(operation.$ref)\n : operationType(pathItem, operation, { ...location, path }, context);\n return documentMember(name, type, operation, { isReadonly: context.options.immutable });\n}\n\n/** A method member: the operation, or `?: never` when there is none or it is excluded. */\nfunction methodMember(\n method: PathItemMethod,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const operation = pathItem[method];\n if (!isIncluded(operation, context)) {\n const isReadonly = context.options.immutable;\n return irProperty(toPropertyName(method), irKeyword(\"never\"), { isOptional: true, isReadonly });\n }\n const path = appendPointer(location.path, [method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n}\n\n/**\n * `additionalOperations` (OpenAPI 3.2): the included operations keyed by their exact method name,\n * or null when the path item has none left.\n */\nfunction additionalOperationsMember(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);\n const members = entries\n .filter(([, operation]) => isIncluded(operation, context))\n .map(([method, operation]) => {\n const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n });\n return members.length > 0\n ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {\n isReadonly: context.options.immutable,\n })\n : null;\n}\n\n/**\n * A path item (OpenAPI 3.2 §4.8.9): its `parameters`, one member per HTTP method, then `query` and\n * `additionalOperations` when the path item declares them (ADR-020).\n */\nexport function pathItemType(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const parametersLocation = { ...location, path: appendPointer(location.path, [\"parameters\"]) };\n const members: IrMember[] = [\n parametersMember(pathItem.parameters ?? [], parametersLocation, context),\n ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),\n ];\n if (pathItem[QUERY_METHOD] !== undefined) {\n members.push(methodMember(QUERY_METHOD, pathItem, location, context));\n }\n const additionalOperations = additionalOperationsMember(pathItem, location, context);\n if (additionalOperations) {\n members.push(additionalOperations);\n }\n return irObject(members);\n}\n"],"names":["operation","mergedParameters","irObject","operationMembers","irProperty","toPropertyName","refType","appendPointer","ROOT_POINTER","documentMember","irKeyword","documentEntries","ADDITIONAL_OPERATIONS_KEY","parametersMember","HTTP_METHODS","QUERY_METHOD"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,OAAA,GAAU,IAAA;AAGT,SAAS,eAAe,WAAA,EAA6B;AAC1D,EAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,GAAG,CAAA;AACzC;AAGA,SAAS,UAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,QAAA,GACJ,UAAU,SAAA,GACL,OAAA,CAAQ,KAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACpC,SAAA;AACN,EAAA,OAAO,EAAE,OAAA,CAAQ,OAAA,CAAQ,iBAAA,IAAqB,QAAA,EAAU,UAAA,CAAA;AAC1D;AAMA,SAAS,aAAA,CACP,QAAA,EACAA,WAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,MAAA,GAAS,EAAE,GAAGA,WAAA,EAAW,UAAA,EAAYC,kCAAiB,QAAA,EAAUD,WAAA,EAAW,OAAA,CAAQ,IAAI,CAAA,EAAE;AAC/F,EAAA,IAAI,CAACA,YAAU,WAAA,EAAa;AAC1B,IAAA,OAAOE,qBAAA,CAASC,0BAAA,CAAiB,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,EAC7D;AACA,EAAA,MAAM,cA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BAAiB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG,oBAAoB,OAAO,CAAA;AAAA,IACvE,GAAGC,2BAAA,CAAa,GAAA,CAAI,CAAC,MAAA,KAAW,aAAa,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC;AAAA,GACnF;AACA,EAAA,IAAI,QAAA,CAASC,2BAAY,CAAA,KAAM,MAAA,EAAW;AACxC,IAAA,OAAA,CAAQ,KAAK,YAAA,CAAaA,2BAAA,EAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,oBAAA,GAAuB,0BAAA,CAA2B,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AACnF,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAA,CAAQ,KAAK,oBAAoB,CAAA;AAAA,EACnC;AACA,EAAA,OAAOb,sBAAS,OAAO,CAAA;AACzB;;;"}
1
+ {"version":3,"file":"path-item.cjs","sources":["../../../../src/application/transform/document/path-item.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.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 { operationMembers } from \"./operation.js\";\nimport { mergedParameters } from \"./parameter-entries.js\";\nimport { parametersMember } from \"./parameters.js\";\n\n/** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */\nconst HASH_RE = /#/g;\n\n/** The `operations` key an `operationId` asks for, before a repeated one gets a number. */\nexport function operationKeyOf(operationId: string): string {\n return operationId.replace(HASH_RE, \"/\");\n}\n\n/** Whether the method has an operation, not removed by `--exclude-deprecated`. */\nexport function isIncludedOperation(\n operation: OperationEntry | undefined,\n context: TransformContext,\n): operation is OperationEntry {\n if (!operation) {\n return false;\n }\n const resolved =\n \"$ref\" in operation\n ? (context.refs.resolve(operation.$ref) as OperationObject | undefined)\n : operation;\n return !(context.options.excludeDeprecated && resolved?.deprecated);\n}\n\n/**\n * An operation with an `operationId` goes into the `operations` interface and is referenced from\n * the path item; others are written inline.\n */\nfunction operationType(\n pathItem: PathItemObject,\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };\n if (!operation.operationId) {\n return irObject(operationMembers(merged, location, context));\n }\n const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));\n context.footer.addOperation(() =>\n irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {\n isReadonly: context.options.immutable,\n }),\n );\n return refType(appendPointer(ROOT_POINTER, [\"operations\", operationId]));\n}\n\n/** An included operation, the member name it gets and its location below the path item. */\ninterface DeclaredOperation {\n readonly name: string;\n readonly operation: OperationEntry;\n readonly path: string;\n}\n\nfunction operationMember(\n { name, operation, path }: DeclaredOperation,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const type =\n \"$ref\" in operation\n ? refType(operation.$ref)\n : operationType(pathItem, operation, { ...location, path }, context);\n return documentMember(name, type, operation, { isReadonly: context.options.immutable });\n}\n\n/** A method member: the operation, or `?: never` when there is none or it is excluded. */\nfunction methodMember(\n method: PathItemMethod,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const operation = pathItem[method];\n if (!isIncludedOperation(operation, context)) {\n const isReadonly = context.options.immutable;\n return irProperty(toPropertyName(method), irKeyword(\"never\"), { isOptional: true, isReadonly });\n }\n const path = appendPointer(location.path, [method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n}\n\n/**\n * `additionalOperations` (OpenAPI 3.2): the included operations keyed by their exact method name,\n * or null when the path item has none left.\n */\nfunction additionalOperationsMember(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);\n const members = entries\n .filter(([, operation]) => isIncludedOperation(operation, context))\n .map(([method, operation]) => {\n const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n });\n return members.length > 0\n ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {\n isReadonly: context.options.immutable,\n })\n : null;\n}\n\n/**\n * A path item (OpenAPI 3.2 §4.8.9): its `parameters`, one member per HTTP method, then `query` and\n * `additionalOperations` when the path item declares them (ADR-020).\n */\nexport function pathItemType(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const parametersLocation = { ...location, path: appendPointer(location.path, [\"parameters\"]) };\n const members: IrMember[] = [\n parametersMember(pathItem.parameters ?? [], parametersLocation, context),\n ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),\n ];\n if (pathItem[QUERY_METHOD] !== undefined) {\n members.push(methodMember(QUERY_METHOD, pathItem, location, context));\n }\n const additionalOperations = additionalOperationsMember(pathItem, location, context);\n if (additionalOperations) {\n members.push(additionalOperations);\n }\n return irObject(members);\n}\n"],"names":["operation","mergedParameters","irObject","operationMembers","irProperty","toPropertyName","refType","appendPointer","ROOT_POINTER","documentMember","irKeyword","documentEntries","ADDITIONAL_OPERATIONS_KEY","parametersMember","HTTP_METHODS","QUERY_METHOD"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,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QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AACnF,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAA,CAAQ,KAAK,oBAAoB,CAAA;AAAA,EACnC;AACA,EAAA,OAAOb,sBAAS,OAAO,CAAA;AACzB;;;;"}
@@ -13,7 +13,7 @@ const HASH_RE = /#/g;
13
13
  function operationKeyOf(operationId) {
14
14
  return operationId.replace(HASH_RE, "/");
15
15
  }
16
- function isIncluded(operation, context) {
16
+ function isIncludedOperation(operation, context) {
17
17
  if (!operation) {
18
18
  return false;
19
19
  }
@@ -39,7 +39,7 @@ function operationMember({ name, operation, path }, pathItem, location, context)
39
39
  }
40
40
  function methodMember(method, pathItem, location, context) {
41
41
  const operation = pathItem[method];
42
- if (!isIncluded(operation, context)) {
42
+ if (!isIncludedOperation(operation, context)) {
43
43
  const isReadonly = context.options.immutable;
44
44
  return irProperty(toPropertyName(method), irKeyword("never"), { isOptional: true, isReadonly });
45
45
  }
@@ -48,7 +48,7 @@ function methodMember(method, pathItem, location, context) {
48
48
  }
49
49
  function additionalOperationsMember(pathItem, location, context) {
50
50
  const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);
51
- const members = entries.filter(([, operation]) => isIncluded(operation, context)).map(([method, operation]) => {
51
+ const members = entries.filter(([, operation]) => isIncludedOperation(operation, context)).map(([method, operation]) => {
52
52
  const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);
53
53
  return operationMember({ name: method, operation, path }, pathItem, location, context);
54
54
  });
@@ -72,5 +72,5 @@ function pathItemType(pathItem, location, context) {
72
72
  return irObject(members);
73
73
  }
74
74
 
75
- export { operationKeyOf, pathItemType };
75
+ export { isIncludedOperation, operationKeyOf, pathItemType };
76
76
  //# sourceMappingURL=path-item.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-item.mjs","sources":["../../../../src/application/transform/document/path-item.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.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 { operationMembers } from \"./operation.js\";\nimport { mergedParameters } from \"./parameter-entries.js\";\nimport { parametersMember } from \"./parameters.js\";\n\n/** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */\nconst HASH_RE = /#/g;\n\n/** The `operations` key an `operationId` asks for, before a repeated one gets a number. */\nexport function operationKeyOf(operationId: string): string {\n return operationId.replace(HASH_RE, \"/\");\n}\n\n/** Whether the method has an operation, not removed by `--exclude-deprecated`. */\nfunction isIncluded(\n operation: OperationEntry | undefined,\n context: TransformContext,\n): operation is OperationEntry {\n if (!operation) {\n return false;\n }\n const resolved =\n \"$ref\" in operation\n ? (context.refs.resolve(operation.$ref) as OperationObject | undefined)\n : operation;\n return !(context.options.excludeDeprecated && resolved?.deprecated);\n}\n\n/**\n * An operation with an `operationId` goes into the `operations` interface and is referenced from\n * the path item; others are written inline.\n */\nfunction operationType(\n pathItem: PathItemObject,\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };\n if (!operation.operationId) {\n return irObject(operationMembers(merged, location, context));\n }\n const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));\n context.footer.addOperation(() =>\n irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {\n isReadonly: context.options.immutable,\n }),\n );\n return refType(appendPointer(ROOT_POINTER, [\"operations\", operationId]));\n}\n\n/** An included operation, the member name it gets and its location below the path item. */\ninterface DeclaredOperation {\n readonly name: string;\n readonly operation: OperationEntry;\n readonly path: string;\n}\n\nfunction operationMember(\n { name, operation, path }: DeclaredOperation,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const type =\n \"$ref\" in operation\n ? refType(operation.$ref)\n : operationType(pathItem, operation, { ...location, path }, context);\n return documentMember(name, type, operation, { isReadonly: context.options.immutable });\n}\n\n/** A method member: the operation, or `?: never` when there is none or it is excluded. */\nfunction methodMember(\n method: PathItemMethod,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const operation = pathItem[method];\n if (!isIncluded(operation, context)) {\n const isReadonly = context.options.immutable;\n return irProperty(toPropertyName(method), irKeyword(\"never\"), { isOptional: true, isReadonly });\n }\n const path = appendPointer(location.path, [method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n}\n\n/**\n * `additionalOperations` (OpenAPI 3.2): the included operations keyed by their exact method name,\n * or null when the path item has none left.\n */\nfunction additionalOperationsMember(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);\n const members = entries\n .filter(([, operation]) => isIncluded(operation, context))\n .map(([method, operation]) => {\n const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n });\n return members.length > 0\n ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {\n isReadonly: context.options.immutable,\n })\n : null;\n}\n\n/**\n * A path item (OpenAPI 3.2 §4.8.9): its `parameters`, one member per HTTP method, then `query` and\n * `additionalOperations` when the path item declares them (ADR-020).\n */\nexport function pathItemType(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const parametersLocation = { ...location, path: appendPointer(location.path, [\"parameters\"]) };\n const members: IrMember[] = [\n parametersMember(pathItem.parameters ?? [], parametersLocation, context),\n ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),\n ];\n if (pathItem[QUERY_METHOD] !== undefined) {\n members.push(methodMember(QUERY_METHOD, pathItem, location, context));\n }\n const additionalOperations = additionalOperationsMember(pathItem, location, context);\n if (additionalOperations) {\n members.push(additionalOperations);\n }\n return irObject(members);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAuBA,MAAM,OAAA,GAAU,IAAA;AAGT,SAAS,eAAe,WAAA,EAA6B;AAC1D,EAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,GAAG,CAAA;AACzC;AAGA,SAAS,UAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,QAAA,GACJ,UAAU,SAAA,GACL,OAAA,CAAQ,KAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACpC,SAAA;AACN,EAAA,OAAO,EAAE,OAAA,CAAQ,OAAA,CAAQ,iBAAA,IAAqB,QAAA,EAAU,UAAA,CAAA;AAC1D;AAMA,SAAS,aAAA,CACP,QAAA,EACA,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,MAAA,GAAS,EAAE,GAAG,SAAA,EAAW,UAAA,EAAY,iBAAiB,QAAA,EAAU,SAAA,EAAW,OAAA,CAAQ,IAAI,CAAA,EAAE;AAC/F,EAAA,IAAI,CAAC,UAAU,WAAA,EAAa;AAC1B,IAAA,OAAO,QAAA,CAAS,gBAAA,CAAiB,MAAA,EAAQ,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,EAC7D;AACA,EAAA,MAAM,cAAc,OAAA,CAAQ,MAAA,CAAO,aAAa,cAAA,CAAe,SAA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AA,CAAI,CAAC,MAAA,KAAW,aAAa,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC;AAAA,GACnF;AACA,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,KAAM,MAAA,EAAW;AACxC,IAAA,OAAA,CAAQ,KAAK,YAAA,CAAa,YAAA,EAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,oBAAA,GAAuB,0BAAA,CAA2B,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AACnF,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAA,CAAQ,KAAK,oBAAoB,CAAA;AAAA,EACnC;AACA,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;;"}
1
+ {"version":3,"file":"path-item.mjs","sources":["../../../../src/application/transform/document/path-item.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.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 { operationMembers } from \"./operation.js\";\nimport { mergedParameters } from \"./parameter-entries.js\";\nimport { parametersMember } from \"./parameters.js\";\n\n/** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */\nconst HASH_RE = /#/g;\n\n/** The `operations` key an `operationId` asks for, before a repeated one gets a number. */\nexport function operationKeyOf(operationId: string): string {\n return operationId.replace(HASH_RE, \"/\");\n}\n\n/** Whether the method has an operation, not removed by `--exclude-deprecated`. */\nexport function isIncludedOperation(\n operation: OperationEntry | undefined,\n context: TransformContext,\n): operation is OperationEntry {\n if (!operation) {\n return false;\n }\n const resolved =\n \"$ref\" in operation\n ? (context.refs.resolve(operation.$ref) as OperationObject | undefined)\n : operation;\n return !(context.options.excludeDeprecated && resolved?.deprecated);\n}\n\n/**\n * An operation with an `operationId` goes into the `operations` interface and is referenced from\n * the path item; others are written inline.\n */\nfunction operationType(\n pathItem: PathItemObject,\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };\n if (!operation.operationId) {\n return irObject(operationMembers(merged, location, context));\n }\n const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));\n context.footer.addOperation(() =>\n irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {\n isReadonly: context.options.immutable,\n }),\n );\n return refType(appendPointer(ROOT_POINTER, [\"operations\", operationId]));\n}\n\n/** An included operation, the member name it gets and its location below the path item. */\ninterface DeclaredOperation {\n readonly name: string;\n readonly operation: OperationEntry;\n readonly path: string;\n}\n\nfunction operationMember(\n { name, operation, path }: DeclaredOperation,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const type =\n \"$ref\" in operation\n ? refType(operation.$ref)\n : operationType(pathItem, operation, { ...location, path }, context);\n return documentMember(name, type, operation, { isReadonly: context.options.immutable });\n}\n\n/** A method member: the operation, or `?: never` when there is none or it is excluded. */\nfunction methodMember(\n method: PathItemMethod,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const operation = pathItem[method];\n if (!isIncludedOperation(operation, context)) {\n const isReadonly = context.options.immutable;\n return irProperty(toPropertyName(method), irKeyword(\"never\"), { isOptional: true, isReadonly });\n }\n const path = appendPointer(location.path, [method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n}\n\n/**\n * `additionalOperations` (OpenAPI 3.2): the included operations keyed by their exact method name,\n * or null when the path item has none left.\n */\nfunction additionalOperationsMember(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);\n const members = entries\n .filter(([, operation]) => isIncludedOperation(operation, context))\n .map(([method, operation]) => {\n const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n });\n return members.length > 0\n ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {\n isReadonly: context.options.immutable,\n })\n : null;\n}\n\n/**\n * A path item (OpenAPI 3.2 §4.8.9): its `parameters`, one member per HTTP method, then `query` and\n * `additionalOperations` when the path item declares them (ADR-020).\n */\nexport function pathItemType(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const parametersLocation = { ...location, path: appendPointer(location.path, [\"parameters\"]) };\n const members: IrMember[] = [\n parametersMember(pathItem.parameters ?? [], parametersLocation, context),\n ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),\n ];\n if (pathItem[QUERY_METHOD] !== undefined) {\n members.push(methodMember(QUERY_METHOD, pathItem, location, context));\n }\n const additionalOperations = additionalOperationsMember(pathItem, location, context);\n if (additionalOperations) {\n members.push(additionalOperations);\n }\n return irObject(members);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAuBA,MAAM,OAAA,GAAU,IAAA;AAGT,SAAS,eAAe,WAAA,EAA6B;AAC1D,EAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,GAAG,CAAA;AACzC;AAGO,SAAS,mBAAA,CACd,WACA,OAAA,EAC6B;AAC7B,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA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Q,WAAW,IAAA,EAAK,EAAG,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AAAA,EACvF,CAAC,CAAA;AACH,EAAA,OAAO,OAAA,CAAQ,SAAS,CAAA,GACpB,UAAA,CAAW,eAAe,yBAAyB,CAAA,EAAG,QAAA,CAAS,OAAO,CAAA,EAAG;AAAA,IACvE,UAAA,EAAY,QAAQ,OAAA,CAAQ;AAAA,GAC7B,CAAA,GACD,IAAA;AACN;AAMO,SAAS,YAAA,CACd,QAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,kBAAA,GAAqB,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,aAAA,CAAc,QAAA,CAAS,IAAA,EAAM,CAAC,YAAY,CAAC,CAAA,EAAE;AAC7F,EAAA,MAAM,OAAA,GAAsB;AAAA,IAC1B,iBAAiB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG,oBAAoB,OAAO,CAAA;AAAA,IACvE,GAAG,YAAA,CAAa,GAAA,CAAI,CAAC,MAAA,KAAW,aAAa,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC;AAAA,GACnF;AACA,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,KAAM,MAAA,EAAW;AACxC,IAAA,OAAA,CAAQ,KAAK,YAAA,CAAa,YAAA,EAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,oBAAA,GAAuB,0BAAA,CAA2B,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AACnF,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAA,CAAQ,KAAK,oBAAoB,CAAA;AAAA,EACnC;AACA,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;;"}
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ const rawTextEscapes = require('../../../domain/ir/raw-text-escapes.cjs');
4
+ const pathItemObject = require('../../../domain/openapi/path-item-object.cjs');
5
+ const outputFixes = require('../../../domain/output-fixes.cjs');
6
+ const pathTemplateReplace = require('./path-template-replace.cjs');
7
+
8
+ const PATH_PARAMETER_RE = /\{[^{}]+\}/g;
9
+ const PLACEHOLDERS = /* @__PURE__ */ new Map([
10
+ ["number", "number"],
11
+ ["integer", "number"],
12
+ ["boolean", "boolean"]
13
+ ]);
14
+ const STRING_PLACEHOLDER = "string";
15
+ function resolvedParameter(parameter, context) {
16
+ return "$ref" in parameter && parameter.$ref ? context.refs.resolve(parameter.$ref) : parameter;
17
+ }
18
+ function addPathParameters(parameters, byName, context) {
19
+ for (const parameter of parameters) {
20
+ const resolved = resolvedParameter(parameter, context);
21
+ if (resolved && resolved.in === "path") {
22
+ byName.set(resolved.name, resolved);
23
+ }
24
+ }
25
+ }
26
+ function pathParameters(pathItem, context) {
27
+ const byName = /* @__PURE__ */ new Map();
28
+ addPathParameters(pathItem.parameters ?? [], byName, context);
29
+ for (const { operation: entry } of pathItemObject.pathItemOperations(pathItem)) {
30
+ const operation = entry.$ref ? context.refs.resolve(entry.$ref) : entry;
31
+ addPathParameters(operation?.parameters ?? [], byName, context);
32
+ }
33
+ return byName;
34
+ }
35
+ function splitTemplateParts(url, matches) {
36
+ return url.split(PATH_PARAMETER_RE).flatMap((text, index) => {
37
+ const type = matches[index]?.type;
38
+ const textPart = { kind: "text", text };
39
+ return type === void 0 ? [textPart] : [textPart, { kind: "placeholder", type }];
40
+ });
41
+ }
42
+ function pathTemplateParts(url, pathItem, context) {
43
+ const found = url.match(PATH_PARAMETER_RE);
44
+ if (!found) {
45
+ return null;
46
+ }
47
+ const parameters = pathParameters(pathItem, context);
48
+ const matches = found.map((match) => {
49
+ const schema = parameters.get(match.slice(1, -1))?.schema;
50
+ return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };
51
+ });
52
+ return context.options.fixes.has(outputFixes.FIX.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : pathTemplateReplace.replacedTemplateParts(url, matches);
53
+ }
54
+ function templateText(parts) {
55
+ const text = parts.map(
56
+ (part) => part.kind === "text" ? rawTextEscapes.escapeTemplateText(part.text) : pathTemplateReplace.placeholderText(part.type)
57
+ ).join("");
58
+ return `\`${text}\``;
59
+ }
60
+ const BOOLEAN_TEXTS = ["true", "false"];
61
+ const isBooleanPlaceholder = (part) => part.kind === "placeholder" && part.type === "boolean";
62
+ function booleanExpandedKeys(parts) {
63
+ const isBooleanOnly = parts.every((part) => part.kind === "text" || isBooleanPlaceholder(part));
64
+ if (!isBooleanOnly) {
65
+ return [[...parts]];
66
+ }
67
+ return parts.reduce(
68
+ (keys, part) => {
69
+ const choices = isBooleanPlaceholder(part) ? BOOLEAN_TEXTS.map((text) => ({ kind: "text", text })) : [part];
70
+ return keys.flatMap((key) => choices.map((choice) => [...key, choice]));
71
+ },
72
+ [[]]
73
+ );
74
+ }
75
+ function plainUrlOf(parts) {
76
+ const texts = parts.map((part) => part.kind === "text" ? part.text : null);
77
+ return texts.includes(null) ? null : texts.join("");
78
+ }
79
+
80
+ exports.booleanExpandedKeys = booleanExpandedKeys;
81
+ exports.pathTemplateParts = pathTemplateParts;
82
+ exports.plainUrlOf = plainUrlOf;
83
+ exports.templateText = templateText;
84
+ //# sourceMappingURL=path-template-key.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-template-key.cjs","sources":["../../../../src/application/transform/document/path-template-key.ts"],"sourcesContent":["import { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport type { PathKeyPart, PathPlaceholder } from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\n\n/** The `--path-params-as-types` key of a path: its URL with a placeholder per parameter. */\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nexport function pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nexport function templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\nconst BOOLEAN_TEXTS = [\"true\", \"false\"] as const;\n\nconst isBooleanPlaceholder = (part: PathKeyPart): boolean =>\n part.kind === \"placeholder\" && part.type === \"boolean\";\n\n/**\n * The keys of a template whose only placeholders are `${boolean}`, with each written as `true`\n * and as `false`. Such a template is a union of literals, and an index signature takes none\n * (TS1337), so the original's `` [path: `/flags/${boolean}`] `` did not compile. A path with n\n * boolean parameters gets 2ⁿ plain URLs (`/flags/true`), all with the same path item type. Next to\n * another placeholder the template is a pattern, a valid signature that admits the same URLs, so\n * those parts stay one key.\n */\nexport function booleanExpandedKeys(parts: readonly PathKeyPart[]): PathKeyPart[][] {\n const isBooleanOnly = parts.every((part) => part.kind === \"text\" || isBooleanPlaceholder(part));\n if (!isBooleanOnly) {\n return [[...parts]];\n }\n return parts.reduce<PathKeyPart[][]>(\n (keys, part) => {\n const choices: readonly PathKeyPart[] = isBooleanPlaceholder(part)\n ? BOOLEAN_TEXTS.map((text) => ({ kind: \"text\", text }))\n : [part];\n return keys.flatMap((key) => choices.map((choice) => [...key, choice]));\n },\n [[]],\n );\n}\n\n/** The URL of parts without placeholders; null when one is left. */\nexport function plainUrlOf(parts: readonly PathKeyPart[]): string | null {\n const texts = parts.map((part) => (part.kind === \"text\" ? part.text : null));\n return texts.includes(null) ? null : texts.join(\"\");\n}\n"],"names":["pathItemOperations","FIX","replacedTemplateParts","escapeTemplateText","placeholderText"],"mappings":";;;;;;;AAuBA,MAAM,iBAAA,GAAoB,aAAA;AAG1B,MAAM,YAAA,uBAA0D,GAAA,CAAI;AAAA,EAClE,CAAC,UAAU,QAAQ,CAAA;AAAA,EACnB,CAAC,WAAW,QAAQ,CAAA;AAAA,EACpB,CAAC,WAAW,SAAS;AACvB,CAAC,CAAA;AACD,MAAM,kBAAA,GAAsC,QAAA;AAE5C,SAAS,iBAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,OAAO,MAAA,IAAU,aAAa,SAAA,CAAU,IAAA,GACnC,QAAQ,IAAA,CAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACnC,SAAA;AACP;AAEA,SAAS,iBAAA,CACP,UAAA,EACA,MAAA,EACA,OAAA,EACM;AACN,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,MAAM,QAAA,GAAW,iBAAA,CAAkB,SAAA,EAAW,OAAO,CAAA;AACrD,IAAA,IAAI,QAAA,IAAY,QAAA,CAAS,EAAA,KAAO,MAAA,EAAQ;AACtC,MAAA,MAAA,CAAO,GAAA,CAAI,QAAA,CAAS,IAAA,EAAM,QAAQ,CAAA;AAAA,IACpC;AAAA,EACF;AACF;AAGA,SAAS,cAAA,CACP,UACA,OAA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A,KAAS;AACd,MAAA,MAAM,OAAA,GAAkC,oBAAA,CAAqB,IAAI,CAAA,GAC7D,cAAc,GAAA,CAAI,CAAC,IAAA,MAAU,EAAE,MAAM,MAAA,EAAQ,IAAA,EAAK,CAAE,CAAA,GACpD,CAAC,IAAI,CAAA;AACT,MAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,CAAC,GAAA,KAAQ,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,KAAW,CAAC,GAAG,GAAA,EAAK,MAAM,CAAC,CAAC,CAAA;AAAA,IACxE,CAAA;AAAA,IACA,CAAC,EAAE;AAAA,GACL;AACF;AAGO,SAAS,WAAW,KAAA,EAA8C;AACvE,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,KAAU,KAAK,IAAA,KAAS,MAAA,GAAS,IAAA,CAAK,IAAA,GAAO,IAAK,CAAA;AAC3E,EAAA,OAAO,MAAM,QAAA,CAAS,IAAI,IAAI,IAAA,GAAO,KAAA,CAAM,KAAK,EAAE,CAAA;AACpD;;;;;"}
@@ -0,0 +1,79 @@
1
+ import { escapeTemplateText } from '../../../domain/ir/raw-text-escapes.mjs';
2
+ import { pathItemOperations } from '../../../domain/openapi/path-item-object.mjs';
3
+ import { FIX } from '../../../domain/output-fixes.mjs';
4
+ import { replacedTemplateParts, placeholderText } from './path-template-replace.mjs';
5
+
6
+ const PATH_PARAMETER_RE = /\{[^{}]+\}/g;
7
+ const PLACEHOLDERS = /* @__PURE__ */ new Map([
8
+ ["number", "number"],
9
+ ["integer", "number"],
10
+ ["boolean", "boolean"]
11
+ ]);
12
+ const STRING_PLACEHOLDER = "string";
13
+ function resolvedParameter(parameter, context) {
14
+ return "$ref" in parameter && parameter.$ref ? context.refs.resolve(parameter.$ref) : parameter;
15
+ }
16
+ function addPathParameters(parameters, byName, context) {
17
+ for (const parameter of parameters) {
18
+ const resolved = resolvedParameter(parameter, context);
19
+ if (resolved && resolved.in === "path") {
20
+ byName.set(resolved.name, resolved);
21
+ }
22
+ }
23
+ }
24
+ function pathParameters(pathItem, context) {
25
+ const byName = /* @__PURE__ */ new Map();
26
+ addPathParameters(pathItem.parameters ?? [], byName, context);
27
+ for (const { operation: entry } of pathItemOperations(pathItem)) {
28
+ const operation = entry.$ref ? context.refs.resolve(entry.$ref) : entry;
29
+ addPathParameters(operation?.parameters ?? [], byName, context);
30
+ }
31
+ return byName;
32
+ }
33
+ function splitTemplateParts(url, matches) {
34
+ return url.split(PATH_PARAMETER_RE).flatMap((text, index) => {
35
+ const type = matches[index]?.type;
36
+ const textPart = { kind: "text", text };
37
+ return type === void 0 ? [textPart] : [textPart, { kind: "placeholder", type }];
38
+ });
39
+ }
40
+ function pathTemplateParts(url, pathItem, context) {
41
+ const found = url.match(PATH_PARAMETER_RE);
42
+ if (!found) {
43
+ return null;
44
+ }
45
+ const parameters = pathParameters(pathItem, context);
46
+ const matches = found.map((match) => {
47
+ const schema = parameters.get(match.slice(1, -1))?.schema;
48
+ return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };
49
+ });
50
+ return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : replacedTemplateParts(url, matches);
51
+ }
52
+ function templateText(parts) {
53
+ const text = parts.map(
54
+ (part) => part.kind === "text" ? escapeTemplateText(part.text) : placeholderText(part.type)
55
+ ).join("");
56
+ return `\`${text}\``;
57
+ }
58
+ const BOOLEAN_TEXTS = ["true", "false"];
59
+ const isBooleanPlaceholder = (part) => part.kind === "placeholder" && part.type === "boolean";
60
+ function booleanExpandedKeys(parts) {
61
+ const isBooleanOnly = parts.every((part) => part.kind === "text" || isBooleanPlaceholder(part));
62
+ if (!isBooleanOnly) {
63
+ return [[...parts]];
64
+ }
65
+ return parts.reduce(
66
+ (keys, part) => {
67
+ const choices = isBooleanPlaceholder(part) ? BOOLEAN_TEXTS.map((text) => ({ kind: "text", text })) : [part];
68
+ return keys.flatMap((key) => choices.map((choice) => [...key, choice]));
69
+ },
70
+ [[]]
71
+ );
72
+ }
73
+ function plainUrlOf(parts) {
74
+ const texts = parts.map((part) => part.kind === "text" ? part.text : null);
75
+ return texts.includes(null) ? null : texts.join("");
76
+ }
77
+
78
+ export { booleanExpandedKeys, pathTemplateParts, plainUrlOf, templateText };
79
+ //# sourceMappingURL=path-template-key.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-template-key.mjs","sources":["../../../../src/application/transform/document/path-template-key.ts"],"sourcesContent":["import { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport type { PathKeyPart, PathPlaceholder } from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\n\n/** The `--path-params-as-types` key of a path: its URL with a placeholder per parameter. */\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nexport function pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nexport function templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\nconst BOOLEAN_TEXTS = [\"true\", \"false\"] as const;\n\nconst isBooleanPlaceholder = (part: PathKeyPart): boolean =>\n part.kind === \"placeholder\" && part.type === \"boolean\";\n\n/**\n * The keys of a template whose only placeholders are `${boolean}`, with each written as `true`\n * and as `false`. Such a template is a union of literals, and an index signature takes none\n * (TS1337), so the original's `` [path: `/flags/${boolean}`] `` did not compile. A path with n\n * boolean parameters gets 2ⁿ plain URLs (`/flags/true`), all with the same path item type. Next to\n * another placeholder the template is a pattern, a valid signature that admits the same URLs, so\n * those parts stay one key.\n */\nexport function booleanExpandedKeys(parts: readonly PathKeyPart[]): PathKeyPart[][] {\n const isBooleanOnly = parts.every((part) => part.kind === \"text\" || isBooleanPlaceholder(part));\n if (!isBooleanOnly) {\n return [[...parts]];\n }\n return parts.reduce<PathKeyPart[][]>(\n (keys, part) => {\n const choices: readonly PathKeyPart[] = isBooleanPlaceholder(part)\n ? BOOLEAN_TEXTS.map((text) => ({ kind: \"text\", text }))\n : [part];\n return keys.flatMap((key) => choices.map((choice) => [...key, choice]));\n },\n [[]],\n );\n}\n\n/** The URL of parts without placeholders; null when one is left. */\nexport function plainUrlOf(parts: readonly PathKeyPart[]): string | null {\n const texts = parts.map((part) => (part.kind === \"text\" ? part.text : null));\n return texts.includes(null) ? null : texts.join(\"\");\n}\n"],"names":[],"mappings":";;;;;AAuBA,MAAM,iBAAA,GAAoB,aAAA;AAG1B,MAAM,YAAA,uBAA0D,GAAA,CAAI;AAAA,EAClE,CAAC,UAAU,QAAQ,CAAA;AAAA,EACnB,CAAC,WAAW,QAAQ,CA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