@redocly/client-generator 0.3.7 → 0.4.0

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 (617) hide show
  1. package/README.md +32 -54
  2. package/eject-assets/AGENTS.md +137 -0
  3. package/eject-assets/generators/cli/docs.ts +224 -0
  4. package/eject-assets/generators/cli/engine-source.ts +21 -0
  5. package/eject-assets/generators/cli/index.ts +90 -0
  6. package/eject-assets/generators/cli/render.ts +348 -0
  7. package/eject-assets/generators/go/client.ts +57 -0
  8. package/eject-assets/generators/go/descriptor.ts +41 -0
  9. package/eject-assets/generators/go/index.ts +336 -0
  10. package/eject-assets/generators/go/models.ts +179 -0
  11. package/eject-assets/generators/go/naming.ts +49 -0
  12. package/eject-assets/generators/go/operations.ts +296 -0
  13. package/eject-assets/generators/go/pagination.ts +194 -0
  14. package/eject-assets/generators/go/types.ts +60 -0
  15. package/eject-assets/generators/mock/faker.ts +214 -0
  16. package/eject-assets/generators/mock/index.ts +35 -0
  17. package/eject-assets/generators/mock/render.ts +282 -0
  18. package/eject-assets/generators/mock/sample.ts +316 -0
  19. package/eject-assets/generators/mock/values.ts +63 -0
  20. package/eject-assets/generators/php/client.ts +63 -0
  21. package/eject-assets/generators/php/descriptor.ts +58 -0
  22. package/eject-assets/generators/php/index.ts +237 -0
  23. package/eject-assets/generators/php/models.ts +275 -0
  24. package/eject-assets/generators/php/naming.ts +51 -0
  25. package/eject-assets/generators/php/operations.ts +232 -0
  26. package/eject-assets/generators/php/pagination.ts +133 -0
  27. package/eject-assets/generators/php/types.ts +148 -0
  28. package/eject-assets/generators/python/client.ts +123 -0
  29. package/eject-assets/generators/python/descriptor.ts +52 -0
  30. package/eject-assets/generators/python/index.ts +251 -0
  31. package/eject-assets/generators/python/models.ts +242 -0
  32. package/eject-assets/generators/python/naming.ts +46 -0
  33. package/eject-assets/generators/python/operations.ts +147 -0
  34. package/eject-assets/generators/python/pagination.ts +128 -0
  35. package/eject-assets/generators/python/types.ts +54 -0
  36. package/eject-assets/generators/swr/index.ts +37 -0
  37. package/eject-assets/generators/swr/render.ts +78 -0
  38. package/eject-assets/generators/tanstack-query/index.ts +48 -0
  39. package/eject-assets/generators/tanstack-query/render.ts +346 -0
  40. package/eject-assets/generators/transformers/index.ts +46 -0
  41. package/eject-assets/generators/transformers/render.ts +506 -0
  42. package/eject-assets/generators/typescript/banner.ts +35 -0
  43. package/eject-assets/generators/typescript/client.ts +254 -0
  44. package/eject-assets/generators/typescript/descriptor.ts +137 -0
  45. package/eject-assets/generators/typescript/index.ts +101 -0
  46. package/eject-assets/generators/typescript/inline-runtime.ts +135 -0
  47. package/eject-assets/generators/typescript/operation-signature.ts +62 -0
  48. package/eject-assets/generators/typescript/operation-types.ts +17 -0
  49. package/eject-assets/generators/typescript/operations.ts +524 -0
  50. package/eject-assets/generators/typescript/response-headers.ts +74 -0
  51. package/eject-assets/generators/typescript/type-guards.ts +159 -0
  52. package/eject-assets/generators/typescript/types.ts +172 -0
  53. package/eject-assets/generators/zod/index.ts +32 -0
  54. package/eject-assets/generators/zod/schemas.ts +456 -0
  55. package/eject-assets/skills/cli-generator/SKILL.md +121 -0
  56. package/eject-assets/skills/client-generators/SKILL.md +142 -0
  57. package/eject-assets/skills/go-generator/SKILL.md +96 -0
  58. package/eject-assets/skills/mock-generator/SKILL.md +50 -0
  59. package/eject-assets/skills/php-generator/SKILL.md +112 -0
  60. package/eject-assets/skills/python-generator/SKILL.md +110 -0
  61. package/eject-assets/skills/swr-generator/SKILL.md +50 -0
  62. package/eject-assets/skills/tanstack-query-generator/SKILL.md +55 -0
  63. package/eject-assets/skills/transformers-generator/SKILL.md +47 -0
  64. package/eject-assets/skills/typescript-generator/SKILL.md +95 -0
  65. package/eject-assets/skills/zod-generator/SKILL.md +54 -0
  66. package/lib/authoring/index.d.ts +11 -0
  67. package/lib/authoring/index.d.ts.map +1 -0
  68. package/lib/authoring/index.js +42 -0
  69. package/lib/authoring/index.js.map +1 -0
  70. package/lib/authoring/naming.d.ts +34 -0
  71. package/lib/authoring/naming.d.ts.map +1 -0
  72. package/lib/authoring/naming.js +104 -0
  73. package/lib/authoring/naming.js.map +1 -0
  74. package/lib/authoring/operation.d.ts +47 -0
  75. package/lib/authoring/operation.d.ts.map +1 -0
  76. package/lib/authoring/operation.js +86 -0
  77. package/lib/authoring/operation.js.map +1 -0
  78. package/lib/authoring/options.d.ts +9 -0
  79. package/lib/authoring/options.d.ts.map +1 -0
  80. package/lib/authoring/options.js +5 -0
  81. package/lib/authoring/options.js.map +1 -0
  82. package/lib/authoring/pagination.d.ts +19 -0
  83. package/lib/authoring/pagination.d.ts.map +1 -0
  84. package/lib/authoring/pagination.js +45 -0
  85. package/lib/authoring/pagination.js.map +1 -0
  86. package/lib/authoring/printer.d.ts +16 -0
  87. package/lib/authoring/printer.d.ts.map +1 -0
  88. package/lib/authoring/printer.js +36 -0
  89. package/lib/authoring/printer.js.map +1 -0
  90. package/lib/authoring/reference-page.d.ts +31 -0
  91. package/lib/authoring/reference-page.d.ts.map +1 -0
  92. package/lib/authoring/reference-page.js +160 -0
  93. package/lib/authoring/reference-page.js.map +1 -0
  94. package/lib/authoring/schema.d.ts +51 -0
  95. package/lib/authoring/schema.d.ts.map +1 -0
  96. package/lib/authoring/schema.js +190 -0
  97. package/lib/authoring/schema.js.map +1 -0
  98. package/lib/cli-contract.d.ts +126 -0
  99. package/lib/cli-contract.d.ts.map +1 -0
  100. package/lib/cli-contract.js +25 -0
  101. package/lib/cli-contract.js.map +1 -0
  102. package/lib/{emitters/wrapper-support.d.ts → contracts/typescript.d.ts} +13 -24
  103. package/lib/contracts/typescript.d.ts.map +1 -0
  104. package/lib/contracts/typescript.js +87 -0
  105. package/lib/contracts/typescript.js.map +1 -0
  106. package/lib/generate.d.ts +10 -10
  107. package/lib/generate.d.ts.map +1 -1
  108. package/lib/generate.js +25 -106
  109. package/lib/generate.js.map +1 -1
  110. package/lib/generators/cli/docs.d.ts +19 -0
  111. package/lib/generators/cli/docs.d.ts.map +1 -0
  112. package/lib/generators/cli/docs.js +187 -0
  113. package/lib/generators/cli/docs.js.map +1 -0
  114. package/lib/generators/cli/engine-source.d.ts +5 -0
  115. package/lib/generators/cli/engine-source.d.ts.map +1 -0
  116. package/lib/generators/cli/engine-source.js +12 -0
  117. package/lib/generators/cli/engine-source.js.map +1 -0
  118. package/lib/generators/cli/index.d.ts +18 -0
  119. package/lib/generators/cli/index.d.ts.map +1 -0
  120. package/lib/generators/cli/index.js +67 -0
  121. package/lib/generators/cli/index.js.map +1 -0
  122. package/lib/generators/cli/render.d.ts +39 -0
  123. package/lib/generators/cli/render.d.ts.map +1 -0
  124. package/lib/generators/cli/render.js +281 -0
  125. package/lib/generators/cli/render.js.map +1 -0
  126. package/lib/generators/cli/runtime/cli.d.ts +42 -0
  127. package/lib/generators/cli/runtime/cli.d.ts.map +1 -0
  128. package/lib/generators/cli/runtime/cli.js +582 -0
  129. package/lib/generators/cli/runtime/cli.js.map +1 -0
  130. package/lib/generators/compatibility.d.ts +10 -0
  131. package/lib/generators/compatibility.d.ts.map +1 -0
  132. package/lib/generators/compatibility.js +45 -0
  133. package/lib/generators/compatibility.js.map +1 -0
  134. package/lib/generators/go/client.d.ts +5 -0
  135. package/lib/generators/go/client.d.ts.map +1 -0
  136. package/lib/generators/go/client.js +34 -0
  137. package/lib/generators/go/client.js.map +1 -0
  138. package/lib/generators/go/descriptor.d.ts +6 -0
  139. package/lib/generators/go/descriptor.d.ts.map +1 -0
  140. package/lib/generators/go/descriptor.js +26 -0
  141. package/lib/generators/go/descriptor.js.map +1 -0
  142. package/lib/generators/go/index.d.ts +14 -0
  143. package/lib/generators/go/index.d.ts.map +1 -0
  144. package/lib/generators/go/index.js +240 -0
  145. package/lib/generators/go/index.js.map +1 -0
  146. package/lib/generators/go/models.d.ts +4 -0
  147. package/lib/generators/go/models.d.ts.map +1 -0
  148. package/lib/generators/go/models.js +125 -0
  149. package/lib/generators/go/models.js.map +1 -0
  150. package/lib/generators/go/naming.d.ts +15 -0
  151. package/lib/generators/go/naming.d.ts.map +1 -0
  152. package/lib/generators/go/naming.js +36 -0
  153. package/lib/generators/go/naming.js.map +1 -0
  154. package/lib/generators/go/operations.d.ts +16 -0
  155. package/lib/generators/go/operations.d.ts.map +1 -0
  156. package/lib/generators/go/operations.js +200 -0
  157. package/lib/generators/go/operations.js.map +1 -0
  158. package/lib/generators/go/pagination.d.ts +5 -0
  159. package/lib/generators/go/pagination.d.ts.map +1 -0
  160. package/lib/generators/go/pagination.js +93 -0
  161. package/lib/generators/go/pagination.js.map +1 -0
  162. package/lib/generators/go/types.d.ts +4 -0
  163. package/lib/generators/go/types.d.ts.map +1 -0
  164. package/lib/generators/go/types.js +48 -0
  165. package/lib/generators/go/types.js.map +1 -0
  166. package/lib/generators/index.d.ts +2 -3
  167. package/lib/generators/index.d.ts.map +1 -1
  168. package/lib/generators/index.js +31 -53
  169. package/lib/generators/index.js.map +1 -1
  170. package/lib/generators/meta.d.ts +13 -0
  171. package/lib/generators/meta.d.ts.map +1 -0
  172. package/lib/generators/meta.js +157 -0
  173. package/lib/generators/meta.js.map +1 -0
  174. package/lib/{emitters → generators/mock}/faker.d.ts +4 -5
  175. package/lib/generators/mock/faker.d.ts.map +1 -0
  176. package/lib/generators/mock/faker.js +180 -0
  177. package/lib/generators/mock/faker.js.map +1 -0
  178. package/lib/generators/{mock.d.ts → mock/index.d.ts} +2 -2
  179. package/lib/generators/mock/index.d.ts.map +1 -0
  180. package/lib/generators/{mock.js → mock/index.js} +8 -8
  181. package/lib/generators/mock/index.js.map +1 -0
  182. package/lib/{emitters/mock.d.ts → generators/mock/render.d.ts} +2 -3
  183. package/lib/generators/mock/render.d.ts.map +1 -0
  184. package/lib/generators/mock/render.js +228 -0
  185. package/lib/generators/mock/render.js.map +1 -0
  186. package/lib/{emitters → generators/mock}/sample.d.ts +1 -2
  187. package/lib/generators/mock/sample.d.ts.map +1 -0
  188. package/lib/generators/mock/sample.js.map +1 -0
  189. package/lib/generators/mock/values.d.ts +33 -0
  190. package/lib/generators/mock/values.d.ts.map +1 -0
  191. package/lib/generators/mock/values.js +46 -0
  192. package/lib/generators/mock/values.js.map +1 -0
  193. package/lib/generators/options.d.ts +7 -0
  194. package/lib/generators/options.d.ts.map +1 -0
  195. package/lib/generators/options.js +74 -0
  196. package/lib/generators/options.js.map +1 -0
  197. package/lib/generators/php/client.d.ts +5 -0
  198. package/lib/generators/php/client.d.ts.map +1 -0
  199. package/lib/generators/php/client.js +38 -0
  200. package/lib/generators/php/client.js.map +1 -0
  201. package/lib/generators/php/descriptor.d.ts +7 -0
  202. package/lib/generators/php/descriptor.d.ts.map +1 -0
  203. package/lib/generators/php/descriptor.js +42 -0
  204. package/lib/generators/php/descriptor.js.map +1 -0
  205. package/lib/generators/php/index.d.ts +14 -0
  206. package/lib/generators/php/index.d.ts.map +1 -0
  207. package/lib/generators/php/index.js +166 -0
  208. package/lib/generators/php/index.js.map +1 -0
  209. package/lib/generators/php/models.d.ts +8 -0
  210. package/lib/generators/php/models.d.ts.map +1 -0
  211. package/lib/generators/php/models.js +200 -0
  212. package/lib/generators/php/models.js.map +1 -0
  213. package/lib/generators/php/naming.d.ts +16 -0
  214. package/lib/generators/php/naming.d.ts.map +1 -0
  215. package/lib/generators/php/naming.js +31 -0
  216. package/lib/generators/php/naming.js.map +1 -0
  217. package/lib/generators/php/operations.d.ts +21 -0
  218. package/lib/generators/php/operations.d.ts.map +1 -0
  219. package/lib/generators/php/operations.js +156 -0
  220. package/lib/generators/php/operations.js.map +1 -0
  221. package/lib/generators/php/pagination.d.ts +5 -0
  222. package/lib/generators/php/pagination.d.ts.map +1 -0
  223. package/lib/generators/php/pagination.js +68 -0
  224. package/lib/generators/php/pagination.js.map +1 -0
  225. package/lib/generators/php/types.d.ts +27 -0
  226. package/lib/generators/php/types.d.ts.map +1 -0
  227. package/lib/generators/php/types.js +128 -0
  228. package/lib/generators/php/types.js.map +1 -0
  229. package/lib/generators/python/client.d.ts +6 -0
  230. package/lib/generators/python/client.d.ts.map +1 -0
  231. package/lib/generators/python/client.js +80 -0
  232. package/lib/generators/python/client.js.map +1 -0
  233. package/lib/generators/python/descriptor.d.ts +9 -0
  234. package/lib/generators/python/descriptor.d.ts.map +1 -0
  235. package/lib/generators/python/descriptor.js +38 -0
  236. package/lib/generators/python/descriptor.js.map +1 -0
  237. package/lib/generators/python/index.d.ts +15 -0
  238. package/lib/generators/python/index.d.ts.map +1 -0
  239. package/lib/generators/python/index.js +197 -0
  240. package/lib/generators/python/index.js.map +1 -0
  241. package/lib/generators/python/models.d.ts +31 -0
  242. package/lib/generators/python/models.d.ts.map +1 -0
  243. package/lib/generators/python/models.js +203 -0
  244. package/lib/generators/python/models.js.map +1 -0
  245. package/lib/generators/python/naming.d.ts +22 -0
  246. package/lib/generators/python/naming.d.ts.map +1 -0
  247. package/lib/generators/python/naming.js +28 -0
  248. package/lib/generators/python/naming.js.map +1 -0
  249. package/lib/generators/python/operations.d.ts +4 -0
  250. package/lib/generators/python/operations.d.ts.map +1 -0
  251. package/lib/generators/python/operations.js +108 -0
  252. package/lib/generators/python/operations.js.map +1 -0
  253. package/lib/generators/python/pagination.d.ts +5 -0
  254. package/lib/generators/python/pagination.d.ts.map +1 -0
  255. package/lib/generators/python/pagination.js +95 -0
  256. package/lib/generators/python/pagination.js.map +1 -0
  257. package/lib/generators/python/types.d.ts +4 -0
  258. package/lib/generators/python/types.d.ts.map +1 -0
  259. package/lib/generators/python/types.js +45 -0
  260. package/lib/generators/python/types.js.map +1 -0
  261. package/lib/generators/resolve.d.ts.map +1 -1
  262. package/lib/generators/resolve.js +92 -13
  263. package/lib/generators/resolve.js.map +1 -1
  264. package/lib/generators/{swr.d.ts → swr/index.d.ts} +3 -3
  265. package/lib/generators/swr/index.d.ts.map +1 -0
  266. package/lib/generators/{swr.js → swr/index.js} +7 -10
  267. package/lib/generators/swr/index.js.map +1 -0
  268. package/lib/{emitters/swr.d.ts → generators/swr/render.d.ts} +2 -4
  269. package/lib/generators/swr/render.d.ts.map +1 -0
  270. package/lib/generators/swr/render.js +57 -0
  271. package/lib/generators/swr/render.js.map +1 -0
  272. package/lib/generators/{tanstack-query.d.ts → tanstack-query/index.d.ts} +3 -3
  273. package/lib/generators/tanstack-query/index.d.ts.map +1 -0
  274. package/lib/generators/{tanstack-query.js → tanstack-query/index.js} +11 -10
  275. package/lib/generators/tanstack-query/index.js.map +1 -0
  276. package/lib/{emitters/tanstack-query.d.ts → generators/tanstack-query/render.d.ts} +6 -5
  277. package/lib/generators/tanstack-query/render.d.ts.map +1 -0
  278. package/lib/{emitters/tanstack-query.js → generators/tanstack-query/render.js} +33 -21
  279. package/lib/generators/tanstack-query/render.js.map +1 -0
  280. package/lib/generators/{transformers.d.ts → transformers/index.d.ts} +2 -2
  281. package/lib/generators/transformers/index.d.ts.map +1 -0
  282. package/lib/generators/{transformers.js → transformers/index.js} +11 -8
  283. package/lib/generators/transformers/index.js.map +1 -0
  284. package/lib/{emitters/transformers.d.ts → generators/transformers/render.d.ts} +2 -2
  285. package/lib/generators/transformers/render.d.ts.map +1 -0
  286. package/lib/{emitters/transformers.js → generators/transformers/render.js} +125 -165
  287. package/lib/generators/transformers/render.js.map +1 -0
  288. package/lib/generators/types.d.ts +190 -12
  289. package/lib/generators/types.d.ts.map +1 -1
  290. package/lib/generators/typescript/banner.d.ts +12 -0
  291. package/lib/generators/typescript/banner.d.ts.map +1 -0
  292. package/lib/{emitters/emit-options.js → generators/typescript/banner.js} +2 -3
  293. package/lib/generators/typescript/banner.js.map +1 -0
  294. package/lib/generators/typescript/client.d.ts +25 -0
  295. package/lib/generators/typescript/client.d.ts.map +1 -0
  296. package/lib/generators/typescript/client.js +207 -0
  297. package/lib/generators/typescript/client.js.map +1 -0
  298. package/lib/generators/typescript/descriptor.d.ts +11 -0
  299. package/lib/generators/typescript/descriptor.d.ts.map +1 -0
  300. package/lib/generators/typescript/descriptor.js +97 -0
  301. package/lib/generators/typescript/descriptor.js.map +1 -0
  302. package/lib/generators/typescript/index.d.ts +20 -0
  303. package/lib/generators/typescript/index.d.ts.map +1 -0
  304. package/lib/generators/typescript/index.js +80 -0
  305. package/lib/generators/typescript/index.js.map +1 -0
  306. package/lib/generators/typescript/inline-runtime.d.ts +21 -0
  307. package/lib/generators/typescript/inline-runtime.d.ts.map +1 -0
  308. package/lib/generators/typescript/inline-runtime.js +114 -0
  309. package/lib/generators/typescript/inline-runtime.js.map +1 -0
  310. package/lib/generators/typescript/operation-signature.d.ts +23 -0
  311. package/lib/generators/typescript/operation-signature.d.ts.map +1 -0
  312. package/lib/generators/typescript/operation-signature.js +41 -0
  313. package/lib/generators/typescript/operation-signature.js.map +1 -0
  314. package/lib/generators/typescript/operation-types.d.ts +9 -0
  315. package/lib/generators/typescript/operation-types.d.ts.map +1 -0
  316. package/lib/generators/typescript/operation-types.js +11 -0
  317. package/lib/generators/typescript/operation-types.js.map +1 -0
  318. package/lib/generators/typescript/operations.d.ts +60 -0
  319. package/lib/generators/typescript/operations.d.ts.map +1 -0
  320. package/lib/generators/typescript/operations.js +386 -0
  321. package/lib/generators/typescript/operations.js.map +1 -0
  322. package/lib/generators/typescript/response-headers.d.ts +12 -0
  323. package/lib/generators/typescript/response-headers.d.ts.map +1 -0
  324. package/lib/generators/typescript/response-headers.js +40 -0
  325. package/lib/generators/typescript/response-headers.js.map +1 -0
  326. package/lib/generators/typescript/runtime/auth.d.ts.map +1 -0
  327. package/lib/generators/typescript/runtime/auth.js.map +1 -0
  328. package/lib/{runtime → generators/typescript/runtime}/create-client.d.ts +7 -2
  329. package/lib/generators/typescript/runtime/create-client.d.ts.map +1 -0
  330. package/lib/{runtime → generators/typescript/runtime}/create-client.js +84 -30
  331. package/lib/generators/typescript/runtime/create-client.js.map +1 -0
  332. package/lib/generators/typescript/runtime/errors.d.ts.map +1 -0
  333. package/lib/generators/typescript/runtime/errors.js.map +1 -0
  334. package/lib/generators/typescript/runtime/index.d.ts.map +1 -0
  335. package/lib/generators/typescript/runtime/index.js.map +1 -0
  336. package/lib/generators/typescript/runtime/multipart.d.ts.map +1 -0
  337. package/lib/generators/typescript/runtime/multipart.js.map +1 -0
  338. package/lib/{runtime → generators/typescript/runtime}/paginate.d.ts +2 -2
  339. package/lib/generators/typescript/runtime/paginate.d.ts.map +1 -0
  340. package/lib/{runtime → generators/typescript/runtime}/paginate.js +12 -12
  341. package/lib/generators/typescript/runtime/paginate.js.map +1 -0
  342. package/lib/generators/typescript/runtime/parse.d.ts.map +1 -0
  343. package/lib/generators/typescript/runtime/parse.js.map +1 -0
  344. package/lib/generators/typescript/runtime/retry.d.ts.map +1 -0
  345. package/lib/generators/typescript/runtime/retry.js.map +1 -0
  346. package/lib/generators/typescript/runtime/send.d.ts.map +1 -0
  347. package/lib/generators/typescript/runtime/send.js.map +1 -0
  348. package/lib/generators/typescript/runtime/setup.d.ts.map +1 -0
  349. package/lib/generators/typescript/runtime/setup.js.map +1 -0
  350. package/lib/generators/typescript/runtime/sse.d.ts.map +1 -0
  351. package/lib/generators/typescript/runtime/sse.js.map +1 -0
  352. package/lib/{runtime → generators/typescript/runtime}/types.d.ts +17 -95
  353. package/lib/generators/typescript/runtime/types.d.ts.map +1 -0
  354. package/lib/generators/typescript/runtime/types.js.map +1 -0
  355. package/lib/generators/typescript/runtime/url.d.ts.map +1 -0
  356. package/lib/generators/typescript/runtime/url.js.map +1 -0
  357. package/lib/generators/typescript/type-guards.d.ts +4 -0
  358. package/lib/generators/typescript/type-guards.d.ts.map +1 -0
  359. package/lib/{emitters → generators/typescript}/type-guards.js +18 -52
  360. package/lib/generators/typescript/type-guards.js.map +1 -0
  361. package/lib/generators/typescript/types.d.ts +8 -0
  362. package/lib/generators/typescript/types.d.ts.map +1 -0
  363. package/lib/generators/typescript/types.js +132 -0
  364. package/lib/generators/typescript/types.js.map +1 -0
  365. package/lib/generators/{zod.d.ts → zod/index.d.ts} +2 -2
  366. package/lib/generators/zod/index.d.ts.map +1 -0
  367. package/lib/generators/{zod.js → zod/index.js} +5 -7
  368. package/lib/generators/zod/index.js.map +1 -0
  369. package/lib/{emitters/zod.d.ts → generators/zod/schemas.d.ts} +4 -5
  370. package/lib/generators/zod/schemas.d.ts.map +1 -0
  371. package/lib/{emitters/zod.js → generators/zod/schemas.js} +118 -154
  372. package/lib/generators/zod/schemas.js.map +1 -0
  373. package/lib/index.d.ts +8 -3
  374. package/lib/index.d.ts.map +1 -1
  375. package/lib/index.js +18 -11
  376. package/lib/index.js.map +1 -1
  377. package/lib/intermediate-representation/build.d.ts +8 -1
  378. package/lib/intermediate-representation/build.d.ts.map +1 -1
  379. package/lib/intermediate-representation/build.js +59 -4
  380. package/lib/intermediate-representation/build.js.map +1 -1
  381. package/lib/intermediate-representation/model.d.ts +26 -1
  382. package/lib/intermediate-representation/model.d.ts.map +1 -1
  383. package/lib/intermediate-representation/model.js.map +1 -1
  384. package/lib/intermediate-representation/sanitize-identifiers.d.ts +1 -10
  385. package/lib/intermediate-representation/sanitize-identifiers.d.ts.map +1 -1
  386. package/lib/intermediate-representation/sanitize-identifiers.js +37 -38
  387. package/lib/intermediate-representation/sanitize-identifiers.js.map +1 -1
  388. package/lib/{emitters/pagination.d.ts → pagination.d.ts} +39 -15
  389. package/lib/pagination.d.ts.map +1 -0
  390. package/lib/{emitters/pagination.js → pagination.js} +13 -52
  391. package/lib/pagination.js.map +1 -0
  392. package/lib/pipeline.d.ts +17 -0
  393. package/lib/pipeline.d.ts.map +1 -0
  394. package/lib/pipeline.js +244 -0
  395. package/lib/pipeline.js.map +1 -0
  396. package/lib/plugin.d.ts +4 -4
  397. package/lib/plugin.d.ts.map +1 -1
  398. package/lib/plugin.js +12 -9
  399. package/lib/plugin.js.map +1 -1
  400. package/lib/printers/go.d.ts +33 -0
  401. package/lib/printers/go.d.ts.map +1 -0
  402. package/lib/printers/go.js +209 -0
  403. package/lib/printers/go.js.map +1 -0
  404. package/lib/printers/index.d.ts +5 -0
  405. package/lib/printers/index.d.ts.map +1 -0
  406. package/lib/printers/index.js +9 -0
  407. package/lib/printers/index.js.map +1 -0
  408. package/lib/printers/php.d.ts +21 -0
  409. package/lib/printers/php.d.ts.map +1 -0
  410. package/lib/printers/php.js +68 -0
  411. package/lib/printers/php.js.map +1 -0
  412. package/lib/printers/python.d.ts +31 -0
  413. package/lib/printers/python.d.ts.map +1 -0
  414. package/lib/printers/python.js +101 -0
  415. package/lib/printers/python.js.map +1 -0
  416. package/lib/printers/typescript.d.ts +82 -0
  417. package/lib/printers/typescript.d.ts.map +1 -0
  418. package/lib/printers/typescript.js +268 -0
  419. package/lib/printers/typescript.js.map +1 -0
  420. package/lib/reserved-names.d.ts +8 -0
  421. package/lib/reserved-names.d.ts.map +1 -0
  422. package/lib/{emitters/reserved-names.js → reserved-names.js} +16 -27
  423. package/lib/reserved-names.js.map +1 -0
  424. package/lib/runtime-contract.d.ts +62 -2
  425. package/lib/runtime-contract.d.ts.map +1 -1
  426. package/lib/runtime-contract.js +3 -3
  427. package/lib/runtime-contract.js.map +1 -1
  428. package/lib/runtime-sources/go.d.ts +2 -0
  429. package/lib/runtime-sources/go.d.ts.map +1 -0
  430. package/lib/runtime-sources/go.js +3 -0
  431. package/lib/runtime-sources/go.js.map +1 -0
  432. package/lib/runtime-sources/php.d.ts +2 -0
  433. package/lib/runtime-sources/php.d.ts.map +1 -0
  434. package/lib/runtime-sources/php.js +3 -0
  435. package/lib/runtime-sources/php.js.map +1 -0
  436. package/lib/runtime-sources/python.d.ts +12 -0
  437. package/lib/runtime-sources/python.d.ts.map +1 -0
  438. package/lib/runtime-sources/python.js +12 -0
  439. package/lib/runtime-sources/python.js.map +1 -0
  440. package/lib/runtime-sources/typescript.d.ts +36 -0
  441. package/lib/runtime-sources/typescript.d.ts.map +1 -0
  442. package/lib/runtime-sources/typescript.js +152 -0
  443. package/lib/runtime-sources/typescript.js.map +1 -0
  444. package/lib/runtime-sources.d.ts +5 -0
  445. package/lib/runtime-sources.d.ts.map +1 -0
  446. package/lib/runtime-sources.js +10 -0
  447. package/lib/runtime-sources.js.map +1 -0
  448. package/lib/setup-bake.d.ts.map +1 -0
  449. package/lib/{emitters/setup-bake.js → setup-bake.js} +11 -2
  450. package/lib/setup-bake.js.map +1 -0
  451. package/lib/types.d.ts +38 -8
  452. package/lib/types.d.ts.map +1 -1
  453. package/package.json +40 -4
  454. package/lib/emitters/auth.d.ts +0 -14
  455. package/lib/emitters/auth.d.ts.map +0 -1
  456. package/lib/emitters/auth.js +0 -30
  457. package/lib/emitters/auth.js.map +0 -1
  458. package/lib/emitters/client-assembly.d.ts +0 -15
  459. package/lib/emitters/client-assembly.d.ts.map +0 -1
  460. package/lib/emitters/client-assembly.js +0 -358
  461. package/lib/emitters/client-assembly.js.map +0 -1
  462. package/lib/emitters/descriptor.d.ts +0 -22
  463. package/lib/emitters/descriptor.d.ts.map +0 -1
  464. package/lib/emitters/descriptor.js +0 -199
  465. package/lib/emitters/descriptor.js.map +0 -1
  466. package/lib/emitters/emit-options.d.ts +0 -67
  467. package/lib/emitters/emit-options.d.ts.map +0 -1
  468. package/lib/emitters/emit-options.js.map +0 -1
  469. package/lib/emitters/faker.d.ts.map +0 -1
  470. package/lib/emitters/faker.js +0 -221
  471. package/lib/emitters/faker.js.map +0 -1
  472. package/lib/emitters/identifier.d.ts +0 -34
  473. package/lib/emitters/identifier.d.ts.map +0 -1
  474. package/lib/emitters/identifier.js +0 -104
  475. package/lib/emitters/identifier.js.map +0 -1
  476. package/lib/emitters/inline-runtime.d.ts +0 -11
  477. package/lib/emitters/inline-runtime.d.ts.map +0 -1
  478. package/lib/emitters/inline-runtime.js +0 -99
  479. package/lib/emitters/inline-runtime.js.map +0 -1
  480. package/lib/emitters/jsdoc.d.ts +0 -9
  481. package/lib/emitters/jsdoc.d.ts.map +0 -1
  482. package/lib/emitters/jsdoc.js +0 -83
  483. package/lib/emitters/jsdoc.js.map +0 -1
  484. package/lib/emitters/mock.d.ts.map +0 -1
  485. package/lib/emitters/mock.js +0 -265
  486. package/lib/emitters/mock.js.map +0 -1
  487. package/lib/emitters/operation-aliases.d.ts +0 -27
  488. package/lib/emitters/operation-aliases.d.ts.map +0 -1
  489. package/lib/emitters/operation-aliases.js +0 -150
  490. package/lib/emitters/operation-aliases.js.map +0 -1
  491. package/lib/emitters/operation-signature.d.ts +0 -24
  492. package/lib/emitters/operation-signature.d.ts.map +0 -1
  493. package/lib/emitters/operation-signature.js +0 -42
  494. package/lib/emitters/operation-signature.js.map +0 -1
  495. package/lib/emitters/operation-types.d.ts +0 -32
  496. package/lib/emitters/operation-types.d.ts.map +0 -1
  497. package/lib/emitters/operation-types.js +0 -117
  498. package/lib/emitters/operation-types.js.map +0 -1
  499. package/lib/emitters/operations.d.ts +0 -41
  500. package/lib/emitters/operations.d.ts.map +0 -1
  501. package/lib/emitters/operations.js +0 -35
  502. package/lib/emitters/operations.js.map +0 -1
  503. package/lib/emitters/pagination.d.ts.map +0 -1
  504. package/lib/emitters/pagination.js.map +0 -1
  505. package/lib/emitters/reserved-names.d.ts +0 -5
  506. package/lib/emitters/reserved-names.d.ts.map +0 -1
  507. package/lib/emitters/reserved-names.js.map +0 -1
  508. package/lib/emitters/response-headers.d.ts +0 -14
  509. package/lib/emitters/response-headers.d.ts.map +0 -1
  510. package/lib/emitters/response-headers.js +0 -91
  511. package/lib/emitters/response-headers.js.map +0 -1
  512. package/lib/emitters/runtime-sources.d.ts +0 -16
  513. package/lib/emitters/runtime-sources.d.ts.map +0 -1
  514. package/lib/emitters/runtime-sources.js +0 -16
  515. package/lib/emitters/runtime-sources.js.map +0 -1
  516. package/lib/emitters/sample.d.ts.map +0 -1
  517. package/lib/emitters/sample.js.map +0 -1
  518. package/lib/emitters/setup-bake.d.ts.map +0 -1
  519. package/lib/emitters/setup-bake.js.map +0 -1
  520. package/lib/emitters/sse.d.ts +0 -10
  521. package/lib/emitters/sse.d.ts.map +0 -1
  522. package/lib/emitters/sse.js +0 -46
  523. package/lib/emitters/sse.js.map +0 -1
  524. package/lib/emitters/support.d.ts +0 -18
  525. package/lib/emitters/support.d.ts.map +0 -1
  526. package/lib/emitters/support.js +0 -37
  527. package/lib/emitters/support.js.map +0 -1
  528. package/lib/emitters/swr.d.ts.map +0 -1
  529. package/lib/emitters/swr.js +0 -88
  530. package/lib/emitters/swr.js.map +0 -1
  531. package/lib/emitters/tanstack-query.d.ts.map +0 -1
  532. package/lib/emitters/tanstack-query.js.map +0 -1
  533. package/lib/emitters/transformers.d.ts.map +0 -1
  534. package/lib/emitters/transformers.js.map +0 -1
  535. package/lib/emitters/ts.d.ts +0 -42
  536. package/lib/emitters/ts.d.ts.map +0 -1
  537. package/lib/emitters/ts.js +0 -116
  538. package/lib/emitters/ts.js.map +0 -1
  539. package/lib/emitters/type-guards.d.ts +0 -21
  540. package/lib/emitters/type-guards.d.ts.map +0 -1
  541. package/lib/emitters/type-guards.js.map +0 -1
  542. package/lib/emitters/types.d.ts +0 -15
  543. package/lib/emitters/types.d.ts.map +0 -1
  544. package/lib/emitters/types.js +0 -125
  545. package/lib/emitters/types.js.map +0 -1
  546. package/lib/emitters/wrapper-support.d.ts.map +0 -1
  547. package/lib/emitters/wrapper-support.js +0 -127
  548. package/lib/emitters/wrapper-support.js.map +0 -1
  549. package/lib/emitters/zod.d.ts.map +0 -1
  550. package/lib/emitters/zod.js.map +0 -1
  551. package/lib/generators/anchor.d.ts +0 -9
  552. package/lib/generators/anchor.d.ts.map +0 -1
  553. package/lib/generators/anchor.js +0 -10
  554. package/lib/generators/anchor.js.map +0 -1
  555. package/lib/generators/mock.d.ts.map +0 -1
  556. package/lib/generators/mock.js.map +0 -1
  557. package/lib/generators/sdk.d.ts +0 -12
  558. package/lib/generators/sdk.d.ts.map +0 -1
  559. package/lib/generators/sdk.js +0 -26
  560. package/lib/generators/sdk.js.map +0 -1
  561. package/lib/generators/swr.d.ts.map +0 -1
  562. package/lib/generators/swr.js.map +0 -1
  563. package/lib/generators/tanstack-query.d.ts.map +0 -1
  564. package/lib/generators/tanstack-query.js.map +0 -1
  565. package/lib/generators/transformers.d.ts.map +0 -1
  566. package/lib/generators/transformers.js.map +0 -1
  567. package/lib/generators/zod.d.ts.map +0 -1
  568. package/lib/generators/zod.js.map +0 -1
  569. package/lib/runtime/auth.d.ts.map +0 -1
  570. package/lib/runtime/auth.js.map +0 -1
  571. package/lib/runtime/create-client.d.ts.map +0 -1
  572. package/lib/runtime/create-client.js.map +0 -1
  573. package/lib/runtime/errors.d.ts.map +0 -1
  574. package/lib/runtime/errors.js.map +0 -1
  575. package/lib/runtime/index.d.ts.map +0 -1
  576. package/lib/runtime/index.js.map +0 -1
  577. package/lib/runtime/multipart.d.ts.map +0 -1
  578. package/lib/runtime/multipart.js.map +0 -1
  579. package/lib/runtime/paginate.d.ts.map +0 -1
  580. package/lib/runtime/paginate.js.map +0 -1
  581. package/lib/runtime/parse.d.ts.map +0 -1
  582. package/lib/runtime/parse.js.map +0 -1
  583. package/lib/runtime/retry.d.ts.map +0 -1
  584. package/lib/runtime/retry.js.map +0 -1
  585. package/lib/runtime/send.d.ts.map +0 -1
  586. package/lib/runtime/send.js.map +0 -1
  587. package/lib/runtime/setup.d.ts.map +0 -1
  588. package/lib/runtime/setup.js.map +0 -1
  589. package/lib/runtime/sse.d.ts.map +0 -1
  590. package/lib/runtime/sse.js.map +0 -1
  591. package/lib/runtime/types.d.ts.map +0 -1
  592. package/lib/runtime/types.js.map +0 -1
  593. package/lib/runtime/url.d.ts.map +0 -1
  594. package/lib/runtime/url.js.map +0 -1
  595. /package/lib/{emitters → generators/mock}/sample.js +0 -0
  596. /package/lib/{runtime → generators/typescript/runtime}/auth.d.ts +0 -0
  597. /package/lib/{runtime → generators/typescript/runtime}/auth.js +0 -0
  598. /package/lib/{runtime → generators/typescript/runtime}/errors.d.ts +0 -0
  599. /package/lib/{runtime → generators/typescript/runtime}/errors.js +0 -0
  600. /package/lib/{runtime → generators/typescript/runtime}/index.d.ts +0 -0
  601. /package/lib/{runtime → generators/typescript/runtime}/index.js +0 -0
  602. /package/lib/{runtime → generators/typescript/runtime}/multipart.d.ts +0 -0
  603. /package/lib/{runtime → generators/typescript/runtime}/multipart.js +0 -0
  604. /package/lib/{runtime → generators/typescript/runtime}/parse.d.ts +0 -0
  605. /package/lib/{runtime → generators/typescript/runtime}/parse.js +0 -0
  606. /package/lib/{runtime → generators/typescript/runtime}/retry.d.ts +0 -0
  607. /package/lib/{runtime → generators/typescript/runtime}/retry.js +0 -0
  608. /package/lib/{runtime → generators/typescript/runtime}/send.d.ts +0 -0
  609. /package/lib/{runtime → generators/typescript/runtime}/send.js +0 -0
  610. /package/lib/{runtime → generators/typescript/runtime}/setup.d.ts +0 -0
  611. /package/lib/{runtime → generators/typescript/runtime}/setup.js +0 -0
  612. /package/lib/{runtime → generators/typescript/runtime}/sse.d.ts +0 -0
  613. /package/lib/{runtime → generators/typescript/runtime}/sse.js +0 -0
  614. /package/lib/{runtime → generators/typescript/runtime}/types.js +0 -0
  615. /package/lib/{runtime → generators/typescript/runtime}/url.d.ts +0 -0
  616. /package/lib/{runtime → generators/typescript/runtime}/url.js +0 -0
  617. /package/lib/{emitters/setup-bake.d.ts → setup-bake.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  // Emits Zod schemas from the IR. Each named schema becomes an
2
- // `export const <Name>Schema = z.<…>;` built with `ts.factory`, mirroring the
3
- // type emitter (`types.ts`) but targeting runtime validators instead of types.
2
+ // `export const <Name>Schema = z.<…>;` source-text templates mirroring the
3
+ // type renderer (`typescript/types.ts`) but targeting runtime validators instead of types.
4
4
  // Operations with a JSON request or response body additionally land in the
5
5
  // `operationSchemas` map, which powers the `zodValidation` client middleware.
6
6
  //
@@ -8,134 +8,105 @@
8
8
  // (`.min/.max/.int/.gt/.lt/.regex`); format helpers (`.email/.uuid/.url`) diverge
9
9
  // between major versions and are deferred. Refs become `z.lazy(() => …Schema)`,
10
10
  // which sidesteps declaration ordering and recursion uniformly.
11
- import { allOperations, } from '../intermediate-representation/model.js';
12
- import { safeIdent } from './identifier.js';
13
- import { isSseOp } from './sse.js';
14
- import { pascalCase } from './support.js';
15
- import { jsdoc, literalExpression, printStatements, ts } from './ts.js';
16
- const { factory } = ts;
11
+ import { allOperations, } from '@redocly/client-generator';
12
+ import { codeLiteral, pascalCase, safeIdent } from '@redocly/client-generator/printers/typescript';
13
+ const INDENT = ' ';
17
14
  /** `<Name>Schema` — the const identifier a named schema is bound to. */
18
15
  function schemaConstName(name) {
19
16
  return `${pascalCase(name)}Schema`;
20
17
  }
21
- /** `z` member access: `z.<method>`. */
22
- function zMember(method) {
23
- return factory.createPropertyAccessExpression(factory.createIdentifier('z'), method);
24
- }
25
- /** `z.<method>(...args)`. */
26
- function zCall(method, args = []) {
27
- return factory.createCallExpression(zMember(method), undefined, args);
28
- }
29
- /** `<expr>.<method>(...args)` — chains a refinement onto a base expression. */
30
- function chain(expr, method, args = []) {
31
- return factory.createCallExpression(factory.createPropertyAccessExpression(expr, method), undefined, args);
32
- }
33
18
  const NO_SCHEMAS = new Map();
34
- /** Map an IR schema to the Zod expression that validates it. */
35
- export function schemaToZodExpression(schema, byName = NO_SCHEMAS) {
36
- return withRefinements(baseExpression(schema, byName), schema);
19
+ /** Map an IR schema to the Zod expression (source text) that validates it. */
20
+ export function schemaToZodExpression(schema, byName = NO_SCHEMAS, indent = '') {
21
+ return withRefinements(baseExpression(schema, byName, indent), schema);
37
22
  }
38
- function baseExpression(schema, byName) {
23
+ function baseExpression(schema, byName, indent) {
39
24
  switch (schema.kind) {
40
25
  case 'scalar':
41
26
  return scalarExpression(schema.scalar, schema.metadata);
42
27
  case 'object':
43
- return objectExpression(schema.properties, byName);
28
+ return objectExpression(schema.properties, byName, indent);
44
29
  case 'array':
45
- return zCall('array', [schemaToZodExpression(schema.items, byName)]);
30
+ return `z.array(${schemaToZodExpression(schema.items, byName, indent)})`;
46
31
  case 'record':
47
- return zCall('record', [zCall('string'), schemaToZodExpression(schema.value, byName)]);
32
+ return `z.record(z.string(), ${schemaToZodExpression(schema.value, byName, indent)})`;
48
33
  case 'ref':
49
- return lazyRef(schema.name);
34
+ return `z.lazy(() => ${schemaConstName(schema.name)})`;
50
35
  case 'literal':
51
- return zCall('literal', [literalExpression(schema.value)]);
36
+ return `z.literal(${codeLiteral(schema.value)})`;
52
37
  case 'enum':
53
38
  return enumExpression(schema.values);
54
39
  case 'union':
55
- return unionExpression(schema.members, byName);
40
+ return unionExpression(schema.members, byName, indent);
56
41
  case 'intersection':
57
- return intersectionExpression(schema.members, byName);
42
+ return schema.members
43
+ .map((member) => schemaToZodExpression(member, byName, indent))
44
+ .reduce((acc, next) => `${acc}.and(${next})`);
58
45
  case 'null':
59
- return zCall('null');
46
+ return 'z.null()';
60
47
  case 'unknown':
61
- return zCall('unknown');
48
+ return 'z.unknown()';
62
49
  case 'omit':
63
- return omitExpression(schema.base, schema.keys, byName);
50
+ return omitExpression(schema.base, schema.keys, byName, indent);
64
51
  }
65
52
  }
66
53
  function scalarExpression(scalar, metadata) {
67
54
  switch (scalar) {
68
55
  case 'string':
69
- // `format: binary` is typed as `Blob` (see types.ts); validate it as one so the zod
70
- // schema agrees with the generated type instead of expecting a string.
71
- if (metadata?.format === 'binary') {
72
- return zCall('instanceof', [factory.createIdentifier('Blob')]);
73
- }
74
- return zCall('string');
56
+ // `format: binary` is typed as `Blob` (see typescript/types.ts); validate it as one so the
57
+ // zod schema agrees with the generated type instead of expecting a string.
58
+ return metadata?.format === 'binary' ? 'z.instanceof(Blob)' : 'z.string()';
75
59
  case 'integer':
76
- return chain(zCall('number'), 'int');
60
+ return 'z.number().int()';
77
61
  case 'number':
78
- return zCall('number');
62
+ return 'z.number()';
79
63
  case 'boolean':
80
- return zCall('boolean');
64
+ return 'z.boolean()';
81
65
  }
82
66
  }
83
- /** `z.object({ <key>: <expr>(.optional() when !required), })`. */
84
- function objectExpression(properties, byName) {
85
- const props = properties.map((p) => {
86
- const value = p.required
87
- ? schemaToZodExpression(p.schema, byName)
88
- : chain(schemaToZodExpression(p.schema, byName), 'optional');
89
- const safe = safeIdent(p.name);
90
- const key = safe === p.name ? factory.createIdentifier(p.name) : factory.createStringLiteral(p.name);
91
- return factory.createPropertyAssignment(key, value);
92
- });
93
- return zCall('object', [factory.createObjectLiteralExpression(props, props.length > 0)]);
67
+ /** A bare identifier key when valid, a quoted key otherwise. */
68
+ function propertyKeyText(name) {
69
+ return safeIdent(name) === name ? name : JSON.stringify(name);
94
70
  }
95
- /** `z.lazy(() => <Name>Schema)` defers reference resolution to call time. */
96
- function lazyRef(name) {
97
- const arrow = factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), factory.createIdentifier(schemaConstName(name)));
98
- return zCall('lazy', [arrow]);
71
+ /** `z.object({ <key>: <expr>(.optional() when !required), })` multiline when non-empty. */
72
+ function objectExpression(properties, byName, indent) {
73
+ if (properties.length === 0)
74
+ return 'z.object({})';
75
+ const inner = indent + INDENT;
76
+ const lines = properties.map((property, index) => {
77
+ const expr = schemaToZodExpression(property.schema, byName, inner);
78
+ const value = property.required ? expr : `${expr}.optional()`;
79
+ const comma = index === properties.length - 1 ? '' : ',';
80
+ return `${inner}${propertyKeyText(property.name)}: ${value}${comma}`;
81
+ });
82
+ return `z.object({\n${lines.join('\n')}\n${indent}})`;
99
83
  }
100
84
  /** All-string values → `z.enum([…])`; otherwise → a union of literals. */
101
85
  function enumExpression(values) {
102
- if (values.every((v) => typeof v === 'string')) {
103
- return zCall('enum', [
104
- factory.createArrayLiteralExpression(values.map((v) => factory.createStringLiteral(v)), false),
105
- ]);
86
+ if (values.every((value) => typeof value === 'string')) {
87
+ return `z.enum([${values.map((value) => JSON.stringify(value)).join(', ')}])`;
106
88
  }
107
- return zCall('union', [
108
- factory.createArrayLiteralExpression(values.map((v) => zCall('literal', [literalExpression(v)])), false),
109
- ]);
89
+ return `z.union([${values.map((value) => `z.literal(${codeLiteral(value)})`).join(', ')}])`;
110
90
  }
111
91
  /** `z.union([…])`; a single member collapses to that member's expression. */
112
- function unionExpression(members, byName) {
113
- const exprs = members.map((member) => schemaToZodExpression(member, byName));
92
+ function unionExpression(members, byName, indent) {
93
+ const exprs = members.map((member) => schemaToZodExpression(member, byName, indent));
114
94
  if (exprs.length === 1)
115
95
  return exprs[0];
116
- return zCall('union', [factory.createArrayLiteralExpression(exprs, false)]);
117
- }
118
- /** `a.and(b).and(c)` — left-folds `.and` over the members. */
119
- function intersectionExpression(members, byName) {
120
- const exprs = members.map((member) => schemaToZodExpression(member, byName));
121
- return exprs.reduce((acc, next) => chain(acc, 'and', [next]));
96
+ return `z.union([${exprs.join(', ')}])`;
122
97
  }
123
98
  /**
124
99
  * `<Base>Schema.omit({ k1: true, … })` when the base is a plain object schema.
125
100
  * `.omit` exists only on `ZodObject` — for any other base (an `allOf` intersection,
126
101
  * a union, …) the omission is distributed into the base's object members instead.
127
102
  */
128
- function omitExpression(base, keys, byName) {
103
+ function omitExpression(base, keys, byName, indent) {
129
104
  const target = byName.get(base);
130
105
  if (target && target.kind !== 'object') {
131
- return schemaToZodExpression(applyOmit(target, keys, byName, new Set([base])), byName);
106
+ return schemaToZodExpression(applyOmit(target, keys, byName, new Set([base])), byName, indent);
132
107
  }
133
- const mask = factory.createObjectLiteralExpression(keys.map((k) => {
134
- const safe = safeIdent(k);
135
- const key = safe === k ? factory.createIdentifier(k) : factory.createStringLiteral(k);
136
- return factory.createPropertyAssignment(key, factory.createTrue());
137
- }), false);
138
- return chain(factory.createIdentifier(schemaConstName(base)), 'omit', [mask]);
108
+ const mask = keys.map((key) => `${propertyKeyText(key)}: true`).join(', ');
109
+ return `${schemaConstName(base)}.omit({ ${mask} })`;
139
110
  }
140
111
  /**
141
112
  * Remove `keys` from a schema that is not a plain object: objects drop the properties,
@@ -182,64 +153,43 @@ function withRefinements(expr, schema) {
182
153
  let out = expr;
183
154
  if (schema.kind === 'scalar' && schema.scalar === 'string') {
184
155
  if (m.minLength !== undefined)
185
- out = chain(out, 'min', [literalExpression(m.minLength)]);
156
+ out = `${out}.min(${m.minLength})`;
186
157
  if (m.maxLength !== undefined)
187
- out = chain(out, 'max', [literalExpression(m.maxLength)]);
158
+ out = `${out}.max(${m.maxLength})`;
188
159
  if (m.pattern !== undefined)
189
- out = chain(out, 'regex', [regexExpression(m.pattern)]);
160
+ out = `${out}.regex(new RegExp(${JSON.stringify(m.pattern)}))`;
190
161
  }
191
162
  if (schema.kind === 'scalar' && (schema.scalar === 'number' || schema.scalar === 'integer')) {
192
- out = numericRefinements(out, m);
163
+ if (m.minimum !== undefined)
164
+ out = `${out}.min(${m.minimum})`;
165
+ if (m.maximum !== undefined)
166
+ out = `${out}.max(${m.maximum})`;
167
+ if (m.exclusiveMinimum !== undefined)
168
+ out = `${out}.gt(${m.exclusiveMinimum})`;
169
+ if (m.exclusiveMaximum !== undefined)
170
+ out = `${out}.lt(${m.exclusiveMaximum})`;
193
171
  }
194
172
  if (schema.kind === 'array') {
195
173
  if (m.minItems !== undefined)
196
- out = chain(out, 'min', [literalExpression(m.minItems)]);
174
+ out = `${out}.min(${m.minItems})`;
197
175
  if (m.maxItems !== undefined)
198
- out = chain(out, 'max', [literalExpression(m.maxItems)]);
176
+ out = `${out}.max(${m.maxItems})`;
199
177
  }
200
178
  return out;
201
179
  }
202
- function numericRefinements(expr, m) {
203
- let out = expr;
204
- if (m.minimum !== undefined)
205
- out = chain(out, 'min', [literalExpression(m.minimum)]);
206
- if (m.maximum !== undefined)
207
- out = chain(out, 'max', [literalExpression(m.maximum)]);
208
- if (m.exclusiveMinimum !== undefined)
209
- out = chain(out, 'gt', [literalExpression(m.exclusiveMinimum)]);
210
- if (m.exclusiveMaximum !== undefined)
211
- out = chain(out, 'lt', [literalExpression(m.exclusiveMaximum)]);
212
- return out;
213
- }
214
- /** `new RegExp("<pattern>")` — robust across printers regardless of pattern content. */
215
- function regexExpression(pattern) {
216
- return factory.createNewExpression(factory.createIdentifier('RegExp'), undefined, [
217
- factory.createStringLiteral(pattern),
218
- ]);
219
- }
220
- /** `export const <Name>Schema = <expr>;` for one named schema. */
221
- function schemaConstStatement(named, byName) {
222
- return factory.createVariableStatement([factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([
223
- factory.createVariableDeclaration(schemaConstName(named.name), undefined, undefined, schemaToZodExpression(named.schema, byName)),
224
- ], ts.NodeFlags.Const));
225
- }
226
- /** `import { z } from 'zod';` */
227
- function zodImport() {
228
- return factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
229
- factory.createImportSpecifier(false, undefined, factory.createIdentifier('z')),
230
- ])), factory.createStringLiteral('zod'));
231
- }
232
180
  function operationSchemaEntries(model, byName) {
233
181
  const entries = [];
234
182
  for (const op of allOperations(model.services)) {
235
- if (isSseOp(op))
183
+ if (op.sse !== undefined)
236
184
  continue;
237
185
  const requestBody = op.requestBody;
238
186
  const request = requestBody && requestBody.contentType.toLowerCase().includes('json')
239
- ? schemaToZodExpression(requestBody.schema, byName)
187
+ ? schemaToZodExpression(requestBody.schema, byName, INDENT)
240
188
  : undefined;
241
189
  const jsonResponse = op.successResponses.find((response) => response.contentType.toLowerCase().includes('json'));
242
- const response = jsonResponse ? schemaToZodExpression(jsonResponse.schema, byName) : undefined;
190
+ const response = jsonResponse
191
+ ? schemaToZodExpression(jsonResponse.schema, byName, INDENT)
192
+ : undefined;
243
193
  if (!request && !response)
244
194
  continue;
245
195
  // The SPEC operationId — the middleware looks entries up by `ctx.operation.id`,
@@ -248,32 +198,34 @@ function operationSchemaEntries(model, byName) {
248
198
  }
249
199
  return entries;
250
200
  }
251
- /** An entry key as a printable property name: bare when a safe identifier, quoted otherwise. */
252
- function entryKey(name) {
253
- return safeIdent(name) === name
254
- ? factory.createIdentifier(name)
255
- : factory.createStringLiteral(name);
256
- }
257
- function operationSchemasStatement(entries) {
258
- const zodTypeNode = () => factory.createTypeReferenceNode(factory.createQualifiedName(factory.createIdentifier('z'), 'ZodType'));
201
+ function operationSchemasBlock(entries) {
259
202
  // The explicit `z.ZodType` annotation keeps the declaration-emit size proportional to
260
203
  // the operation count: the inferred type would serialize every schema's zod generics
261
204
  // and overflow tsc's limit (TS7056) on large APIs under `declaration: true`.
262
- const typeMembers = entries.map((entry) => factory.createPropertySignature(undefined, entryKey(entry.name), undefined, factory.createTypeLiteralNode([
263
- entry.request
264
- ? factory.createPropertySignature(undefined, 'request', undefined, zodTypeNode())
265
- : undefined,
266
- entry.response
267
- ? factory.createPropertySignature(undefined, 'response', undefined, zodTypeNode())
268
- : undefined,
269
- ].filter((member) => member !== undefined))));
270
- const valueEntries = entries.map((entry) => factory.createPropertyAssignment(entryKey(entry.name), factory.createObjectLiteralExpression([
271
- entry.request ? factory.createPropertyAssignment('request', entry.request) : undefined,
272
- entry.response ? factory.createPropertyAssignment('response', entry.response) : undefined,
273
- ].filter((property) => property !== undefined), false)));
274
- return jsdoc(factory.createVariableStatement([factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([
275
- factory.createVariableDeclaration('operationSchemas', undefined, factory.createTypeLiteralNode(typeMembers), factory.createObjectLiteralExpression(valueEntries, true)),
276
- ], ts.NodeFlags.Const)), 'Request/response validators by operationId — powers `zodValidation`, or import one directly.');
205
+ const typeLines = entries.flatMap((entry) => [
206
+ `${INDENT}${propertyKeyText(entry.name)}: {`,
207
+ ...(entry.request ? [`${INDENT}${INDENT}request: z.ZodType;`] : []),
208
+ ...(entry.response ? [`${INDENT}${INDENT}response: z.ZodType;`] : []),
209
+ `${INDENT}};`,
210
+ ]);
211
+ const valueLines = entries.map((entry, index) => {
212
+ const fields = [
213
+ ...(entry.request ? [`request: ${entry.request}`] : []),
214
+ ...(entry.response ? [`response: ${entry.response}`] : []),
215
+ ].join(', ');
216
+ const comma = index === entries.length - 1 ? '' : ',';
217
+ return `${INDENT}${propertyKeyText(entry.name)}: { ${fields} }${comma}`;
218
+ });
219
+ return [
220
+ '/**',
221
+ ' * Request/response validators by operationId — powers `zodValidation`, or import one directly.',
222
+ ' */',
223
+ 'export const operationSchemas: {',
224
+ ...typeLines,
225
+ '} = {',
226
+ ...valueLines,
227
+ '};',
228
+ ].join('\n');
277
229
  }
278
230
  // The validation middleware, spliced verbatim after the schemas (matches the printer's
279
231
  // double-quote/4-space style). Structurally compatible with the client's `Middleware`
@@ -288,11 +240,19 @@ export type ZodViolation = { path: string; message: string; received: string };
288
240
 
289
241
  /** A request or response payload failed validation. Requests throw it; response handling is configurable. */
290
242
  export class ZodValidationError extends Error {
243
+ // Declared and assigned in the body, NOT as constructor parameter properties: those
244
+ // need a transform, so they break \`node --experimental-strip-types\` for anything
245
+ // importing this module (the generated CLI runs that way).
246
+ readonly operationId: string;
247
+ readonly direction: "request" | "response";
248
+ readonly issues: z.ZodError["issues"];
249
+ readonly violations: ZodViolation[];
250
+
291
251
  constructor(
292
- readonly operationId: string,
293
- readonly direction: "request" | "response",
294
- readonly issues: z.ZodError["issues"],
295
- readonly violations: ZodViolation[]
252
+ operationId: string,
253
+ direction: "request" | "response",
254
+ issues: z.ZodError["issues"],
255
+ violations: ZodViolation[]
296
256
  ) {
297
257
  const detail = violations
298
258
  .slice(0, 5)
@@ -300,6 +260,10 @@ export class ZodValidationError extends Error {
300
260
  .join("; ");
301
261
  const more = violations.length > 5 ? \`; …and \${violations.length - 5} more\` : "";
302
262
  super(\`\${direction === "request" ? "Request" : "Response"} validation failed for operation "\${operationId}": \${detail}\${more}\`);
263
+ this.operationId = operationId;
264
+ this.direction = direction;
265
+ this.issues = issues;
266
+ this.violations = violations;
303
267
  this.name = "ZodValidationError";
304
268
  }
305
269
  }
@@ -434,13 +398,13 @@ export function renderZodModule(model) {
434
398
  const entries = operationSchemaEntries(model, byName);
435
399
  if (model.schemas.length === 0 && entries.length === 0)
436
400
  return '';
437
- const statements = [
438
- zodImport(),
439
- ...model.schemas.map((named) => schemaConstStatement(named, byName)),
401
+ const blocks = [
402
+ 'import { z } from "zod";',
403
+ ...model.schemas.map((named) => `export const ${schemaConstName(named.name)} = ${schemaToZodExpression(named.schema, byName)};`),
440
404
  ];
441
405
  if (entries.length === 0)
442
- return printStatements(statements);
443
- statements.push(operationSchemasStatement(entries));
444
- return `${printStatements(statements)}\n${VALIDATION_SUPPORT}\n`;
406
+ return blocks.join('\n\n');
407
+ blocks.push(operationSchemasBlock(entries));
408
+ return `${blocks.join('\n\n')}\n${VALIDATION_SUPPORT}\n`;
445
409
  }
446
- //# sourceMappingURL=zod.js.map
410
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/generators/zod/schemas.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,6EAA6E;AAC7E,2FAA2F;AAC3F,2EAA2E;AAC3E,8EAA8E;AAC9E,EAAE;AACF,uEAAuE;AACvE,kFAAkF;AAClF,gFAAgF;AAChF,gEAAgE;AAEhE,OAAO,EACL,aAAa,GAMd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAEnG,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,wEAAwE;AACxE,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;AACrC,CAAC;AAID,MAAM,UAAU,GAAiB,IAAI,GAAG,EAAE,CAAC;AAE3C,8EAA8E;AAC9E,MAAM,UAAU,qBAAqB,CACnC,MAAmB,EACnB,SAAuB,UAAU,EACjC,MAAM,GAAG,EAAE;IAEX,OAAO,eAAe,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,cAAc,CAAC,MAAmB,EAAE,MAAoB,EAAE,MAAc;IAC/E,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1D,KAAK,QAAQ;YACX,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AG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/F,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClE,MAAM,MAAM,GAAG;QACb,0BAA0B;QAC1B,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAClB,CAAC,KAAK,EAAE,EAAE,CACR,gBAAgB,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAClG;KACF,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5C,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,kBAAkB,IAAI,CAAC;AAC3D,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,9 +1,14 @@
1
+ export * from './authoring/index.js';
1
2
  export { NotSupportedError } from './errors.js';
2
3
  export { defineClientSetup } from './runtime-contract.js';
3
4
  export type { ClientSetup, ClientSetupConfig, Middleware, OperationContext, RequestContext, RetryConfig, RetryContext, RetryStrategy, } from './runtime-contract.js';
4
- export { ApiError, createClient, defaultRetryOn, mergeSetup, TimeoutError, } from './runtime/index.js';
5
- export type { ApiErrorLike, AuthCredentials, Client, ClientConfig, ClientCore, Envelope, EnvelopeResult, OperationDescriptor, OperationMethodIdentity, OpsShape, ParamSpec, ParseAs, QueryValue, RequestOptions, Result, SecuritySpec, ServerSentEvent, SseOptions, TokenProvider, } from './runtime/index.js';
6
- export type { PaginationConfig, PaginationRule, PaginationStyle } from './emitters/pagination.js';
5
+ export type { ResponseHeaderSpec } from './runtime-contract.js';
6
+ export type { ModelPagination, PaginationSpec } from './pagination.js';
7
+ export { resolveSchemaPointer } from './pagination.js';
8
+ export { WIRING_NAMES } from './reserved-names.js';
9
+ export { constantCase, groupSlug } from './cli-contract.js';
10
+ export type { CliAuthScheme, CliCommand, CliFlag, CliGlobals, CliWiring, CommandContext, CommandSource, CustomCommand, } from './cli-contract.js';
11
+ export type { PaginationConfig, PaginationRule, PaginationStyle } from './pagination.js';
7
12
  export type { GenerateClientConfig, GenerateClientOptions, GenerateClientResult, LoadResult, } from './types.js';
8
13
  export { mergeConfig } from './config-file.js';
9
14
  export * from './plugin.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,EACZ,eAAe,EACf,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,YAAY,EACZ,eAAe,EACf,UAAU,EACV,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAClG,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B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,cAAc,aAAa,CAAC;AAE5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9E,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAG/B"}
package/lib/index.js CHANGED
@@ -1,20 +1,27 @@
1
- // The package ROOT entry — what package-mode clients load at app runtime, so its static
2
- // import graph stays runtime-only (no `typescript`, no `@redocly/openapi-core`, no Node
3
- // builtins; guarded by entry-weight.test.ts). The generation stack lives behind the dynamic
4
- // import inside `generateClient` and the `@redocly/client-generator/generate` entry.
1
+ // The package ROOT entry — the authoring surface: the language-neutral toolkit, the
2
+ // plugin API, the user-facing config types, and the setup contract. Nothing imports
3
+ // this entry at app runtime generated clients embed their runtime (ADR-0022) — and
4
+ // the TypeScript-emitting stack lives behind the dynamic import inside `generateClient`
5
+ // and the `@redocly/client-generator/generate` entry.
6
+ // The language-neutral generator-authoring toolkit — pure functions over the IR.
7
+ export * from './authoring/index.js';
5
8
  export { NotSupportedError } from './errors.js';
6
9
  export { defineClientSetup } from './runtime-contract.js';
7
- // The app-facing client runtime (package-mode clients import these from the package root).
8
- // The setup-contract names above (Middleware, OperationContext, RequestContext, RetryConfig,
9
- // RetryContext, RetryStrategy) are re-exports of the same runtime types — one definition,
10
- // two entry points; the rest of the runtime's type surface is re-exported here.
11
- export { ApiError, createClient, defaultRetryOn, mergeSetup, TimeoutError, } from './runtime/index.js';
10
+ export { resolveSchemaPointer } from './pagination.js';
11
+ // Names the generated sdk wiring reserves the typescript descriptor keeps schema
12
+ // identifiers clear of them.
13
+ export { WIRING_NAMES } from './reserved-names.js';
14
+ // The generated-CLI authoring contract the command/wiring shapes a wrapper around a
15
+ // generated or composed CLI is written against, plus the two casing helpers CLI-flavored
16
+ // generators share; the engine itself (`runCli`) is embedded in, and re-exported by,
17
+ // every generated cli module.
18
+ export { constantCase, groupSlug } from './cli-contract.js';
12
19
  export { mergeConfig } from './config-file.js';
13
20
  // The custom-generator authoring API (`defineGenerator` + the IR types); the
14
21
  // TypeScript-emitting toolkit lives in `@redocly/client-generator/generate`.
15
22
  export * from './plugin.js';
16
23
  export async function generateClient(options) {
17
- const generate = await import('./generate.js');
18
- return generate.generateClient(options);
24
+ const pipeline = await import('./pipeline.js');
25
+ return pipeline.generateClient(options);
19
26
  }
20
27
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wFAAwF;AACxF,4FAA4F;AAC5F,qFAAqF;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW1D,2FAA2F;AAC3F,6FAA6F;AAC7F,0FAA0F;AAC1F,gFAAgF;AAChF,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,oBAAoB,CAAC;AA8B5B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,6EAA6E;AAC7E,6EAA6E;AAC7E,cAAc,aAAa,CAAC;AAI5B,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA8B;IAE9B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,oFAAoF;AACpF,qFAAqF;AACrF,wFAAwF;AACxF,sDAAsD;AAEtD,iFAAiF;AACjF,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAc1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,mFAAmF;AACnF,6BAA6B;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,sFAAsF;AACtF,yFAAyF;AACzF,qFAAqF;AACrF,8BAA8B;AAC9B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAmB5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,6EAA6E;AAC7E,6EAA6E;AAC7E,cAAc,aAAa,CAAC;AAI5B,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA8B;IAE9B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
@@ -1,4 +1,11 @@
1
1
  import { type Oas3Definition } from '@redocly/openapi-core';
2
- import type { ApiModel } from './model.js';
2
+ import type { ApiModel, ResponseBodyModel, SseModel } from './model.js';
3
3
  export declare function buildApiModel(doc: Oas3Definition): ApiModel;
4
+ /**
5
+ * The operation's SSE facts, from its `text/event-stream` success response (exact media
6
+ * type, parameters and case ignored). The event schema prefers the 3.2 `itemSchema` over
7
+ * the response `schema`, skipping typeless slots; structured kinds stream as JSON,
8
+ * scalar-ish ones as raw text.
9
+ */
10
+ export declare function sseFromResponses(successResponses: ResponseBodyModel[]): SseModel | undefined;
4
11
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/intermediate-representation/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EAQpB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,KAAK,EACV,QAAQ,EAcT,MAAM,YAAY,CAAC;AAsLpB,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CA8B3D"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/intermediate-representation/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EAQpB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,KAAK,EACV,QAAQ,EAOR,iBAAiB,EACjB,QAAQ,EAOT,MAAM,YAAY,CAAC;AAkLpB,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CAuC3D;AAsTD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,QAAQ,GAAG,SAAS,CAoB5F"}
@@ -1,6 +1,6 @@
1
1
  import { isPlainObject, isRef, logger, } from '@redocly/openapi-core';
2
2
  import { NotSupportedError } from '../errors.js';
3
- import { assertPathParamsAvoidArgSlots, assertSafeIdentifiers, sanitizeIdentifiers, } from './sanitize-identifiers.js';
3
+ import { assertSafeIdentifiers, sanitizeIdentifiers } from './sanitize-identifiers.js';
4
4
  const HTTP_METHODS = ['get', 'post', 'put', 'delete', 'patch', 'head', 'options'];
5
5
  function resolveRef(doc, ref) {
6
6
  if (!ref.startsWith('#/')) {
@@ -162,6 +162,15 @@ export function buildApiModel(doc) {
162
162
  const version = doc.info?.version ?? '0.0.0';
163
163
  const description = doc.info?.description;
164
164
  const serverUrl = resolveServerUrl(doc.servers?.[0]);
165
+ const servers = (doc.servers ?? []).map((server) => ({
166
+ url: server.url,
167
+ description: server.description,
168
+ variables: Object.entries(server.variables ?? {}).map(([name, variable]) => ({
169
+ name,
170
+ default: variable.default,
171
+ description: variable.description,
172
+ })),
173
+ }));
165
174
  const schemas = buildNamedSchemas(doc);
166
175
  const securitySchemes = buildSecuritySchemes(doc);
167
176
  const services = buildServices(doc, securitySchemes);
@@ -170,6 +179,7 @@ export function buildApiModel(doc) {
170
179
  version,
171
180
  description,
172
181
  serverUrl,
182
+ servers,
173
183
  services,
174
184
  schemas,
175
185
  securitySchemes,
@@ -182,7 +192,6 @@ export function buildApiModel(doc) {
182
192
  // Hard gate: no unsafe name may reach the printer (see sanitize-identifiers.ts).
183
193
  assertSafeIdentifiers(model);
184
194
  // A path parameter named like a request-args slot cannot be routed — fail loudly.
185
- assertPathParamsAvoidArgSlots(model);
186
195
  return model;
187
196
  }
188
197
  /**
@@ -421,7 +430,9 @@ function buildOperation(method, path, operation, name, pathLevelParams, doc, inj
421
430
  const errorResponses = buildErrorResponses(operation, path, doc);
422
431
  const security = resolveOperationSecurity(operation, doc, injectable);
423
432
  // Extensions aren't in the @redocly operation type — read loosely, like `deprecated`.
424
- const paginationExtension = operation['x-redocly-pagination'];
433
+ const extensions = operation;
434
+ const paginationExtension = extensions['x-redoclyPagination'];
435
+ const sse = sseFromResponses(successResponses);
425
436
  return {
426
437
  name,
427
438
  method,
@@ -439,8 +450,34 @@ function buildOperation(method, path, operation, name, pathLevelParams, doc, inj
439
450
  security,
440
451
  tags: Array.isArray(operation.tags) ? operation.tags.filter((t) => typeof t === 'string') : [],
441
452
  ...(paginationExtension !== undefined ? { paginationExtension } : {}),
453
+ ...(sse === undefined ? {} : { sse }),
442
454
  };
443
455
  }
456
+ /**
457
+ * The operation's SSE facts, from its `text/event-stream` success response (exact media
458
+ * type, parameters and case ignored). The event schema prefers the 3.2 `itemSchema` over
459
+ * the response `schema`, skipping typeless slots; structured kinds stream as JSON,
460
+ * scalar-ish ones as raw text.
461
+ */
462
+ export function sseFromResponses(successResponses) {
463
+ const response = successResponses.find((candidate) => candidate.contentType.split(';')[0].trim().toLowerCase() === 'text/event-stream');
464
+ if (response === undefined)
465
+ return undefined;
466
+ const declared = response.itemSchema && response.itemSchema.kind !== 'unknown'
467
+ ? response.itemSchema
468
+ : response.schema.kind !== 'unknown'
469
+ ? response.schema
470
+ : undefined;
471
+ if (declared === undefined)
472
+ return { dataKind: 'text' };
473
+ const streamsJson = declared.kind === 'object' ||
474
+ declared.kind === 'ref' ||
475
+ declared.kind === 'array' ||
476
+ declared.kind === 'record' ||
477
+ declared.kind === 'union' ||
478
+ declared.kind === 'intersection';
479
+ return { eventSchema: declared, dataKind: streamsJson ? 'json' : 'text' };
480
+ }
444
481
  function buildParameter(param, location, doc) {
445
482
  if (!param.in) {
446
483
  throw new NotSupportedError(`Parameter ${param.name} at ${location} is missing "in"`);
@@ -774,11 +811,29 @@ function scalarForEnumValues(values, location) {
774
811
  return 'boolean';
775
812
  return 'string';
776
813
  }
814
+ /**
815
+ * Whether keywords beside a `$ref` apply. OpenAPI 3.1 is JSON Schema 2020-12, where
816
+ * `$ref` is an ordinary keyword and its siblings take effect; 3.0 and 2.0 predate that
817
+ * and a `$ref` replaces the whole schema object, so siblings mean nothing (the
818
+ * `spec-ref-siblings` lint rule reports them). Swagger 2 arrives here normalized to
819
+ * `3.0.3`, so it takes the 3.0 path.
820
+ */
821
+ function refSiblingsApply(doc) {
822
+ return !(doc.openapi ?? '').startsWith('3.0');
823
+ }
777
824
  function buildProperties(schema, location, doc) {
778
825
  const props = schema.properties ?? {};
779
826
  const required = new Set(schema.required ?? []);
827
+ const siblingsApply = refSiblingsApply(doc);
780
828
  return Object.entries(props).map(([name, sub]) => {
781
- const readOnly = !isRef(sub) && sub.readOnly === true;
829
+ const declared = sub.readOnly === true;
830
+ // A `readOnly` sibling on a 3.0 `$ref` is a no-op the author almost certainly did
831
+ // not intend — it leaves a server-computed property in every request body — so it
832
+ // is reported rather than dropped in silence.
833
+ if (declared && isRef(sub) && !siblingsApply) {
834
+ logger.warn(`generate-client: "${name}" declares readOnly beside a $ref, which OpenAPI ${doc.openapi} ignores — the property stays in request bodies. Inline the schema, wrap the $ref in allOf, or move the description to OpenAPI 3.1.\n`);
835
+ }
836
+ const readOnly = declared && (siblingsApply || !isRef(sub));
782
837
  return {
783
838
  name,
784
839
  schema: schemaFromSlot(sub, `${location}.${name}`, doc),