@pattern-stack/codegen 0.15.0 → 0.15.2

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 (562) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/dist/chunk-24CWKBK5.js +94 -0
  3. package/dist/chunk-24CWKBK5.js.map +1 -0
  4. package/dist/chunk-2E224ZSN.js +20 -0
  5. package/dist/chunk-2E224ZSN.js.map +1 -0
  6. package/dist/chunk-2FTZLDBP.js +179 -0
  7. package/dist/chunk-2FTZLDBP.js.map +1 -0
  8. package/dist/chunk-2N4UG4VD.js +20 -0
  9. package/dist/chunk-2N4UG4VD.js.map +1 -0
  10. package/dist/chunk-2TVVBC53.js +92 -0
  11. package/dist/chunk-2TVVBC53.js.map +1 -0
  12. package/dist/chunk-2VHZ7EKC.js +37 -0
  13. package/dist/chunk-2VHZ7EKC.js.map +1 -0
  14. package/dist/chunk-32BMMV4H.js +109 -0
  15. package/dist/chunk-32BMMV4H.js.map +1 -0
  16. package/dist/chunk-32DOFN3T.js +4042 -0
  17. package/dist/chunk-32DOFN3T.js.map +1 -0
  18. package/dist/chunk-36U5UGIO.js +107 -0
  19. package/dist/chunk-36U5UGIO.js.map +1 -0
  20. package/dist/chunk-3CJFPU6Q.js +14 -0
  21. package/dist/chunk-3CJFPU6Q.js.map +1 -0
  22. package/dist/chunk-3NMCDN7L.js +90 -0
  23. package/dist/chunk-3NMCDN7L.js.map +1 -0
  24. package/dist/chunk-3SZFUTXE.js +62 -0
  25. package/dist/chunk-3SZFUTXE.js.map +1 -0
  26. package/dist/chunk-4DOJBQTP.js +117 -0
  27. package/dist/chunk-4DOJBQTP.js.map +1 -0
  28. package/dist/chunk-4JLJYWJC.js +308 -0
  29. package/dist/chunk-4JLJYWJC.js.map +1 -0
  30. package/dist/chunk-4KNXX6TI.js +29 -0
  31. package/dist/chunk-4KNXX6TI.js.map +1 -0
  32. package/dist/chunk-4LH67P4U.js +17 -0
  33. package/dist/chunk-4LH67P4U.js.map +1 -0
  34. package/dist/chunk-4MVGAMUA.js +40 -0
  35. package/dist/chunk-4MVGAMUA.js.map +1 -0
  36. package/dist/chunk-4OMHBMZJ.js +75 -0
  37. package/dist/chunk-4OMHBMZJ.js.map +1 -0
  38. package/dist/chunk-4RFHUZXU.js +635 -0
  39. package/dist/chunk-4RFHUZXU.js.map +1 -0
  40. package/dist/chunk-5A432NZJ.js +7 -0
  41. package/dist/chunk-5A432NZJ.js.map +1 -0
  42. package/dist/chunk-5Y7W3XR6.js +356 -0
  43. package/dist/chunk-5Y7W3XR6.js.map +1 -0
  44. package/dist/chunk-6DWFJNIK.js +15 -0
  45. package/dist/chunk-6DWFJNIK.js.map +1 -0
  46. package/dist/chunk-6I7ULIN6.js +15 -0
  47. package/dist/chunk-6I7ULIN6.js.map +1 -0
  48. package/dist/chunk-6XY6ZMMD.js +25 -0
  49. package/dist/chunk-6XY6ZMMD.js.map +1 -0
  50. package/dist/chunk-7B3RYX45.js +63 -0
  51. package/dist/chunk-7B3RYX45.js.map +1 -0
  52. package/dist/chunk-7C3FOSDI.js +1 -0
  53. package/dist/chunk-7C3FOSDI.js.map +1 -0
  54. package/dist/chunk-7KOW6PU6.js +59 -0
  55. package/dist/chunk-7KOW6PU6.js.map +1 -0
  56. package/dist/chunk-7LKAMLV4.js +92 -0
  57. package/dist/chunk-7LKAMLV4.js.map +1 -0
  58. package/dist/chunk-7RELQJIN.js +22 -0
  59. package/dist/chunk-7RELQJIN.js.map +1 -0
  60. package/dist/chunk-AHV4GDYM.js +63 -0
  61. package/dist/chunk-AHV4GDYM.js.map +1 -0
  62. package/dist/chunk-AQFQ4BYM.js +81 -0
  63. package/dist/chunk-AQFQ4BYM.js.map +1 -0
  64. package/dist/chunk-AS3NAZB6.js +14 -0
  65. package/dist/chunk-AS3NAZB6.js.map +1 -0
  66. package/dist/chunk-BGULBWKJ.js +88 -0
  67. package/dist/chunk-BGULBWKJ.js.map +1 -0
  68. package/dist/chunk-BIO6F7YI.js +17 -0
  69. package/dist/chunk-BIO6F7YI.js.map +1 -0
  70. package/dist/chunk-BOPZWRJK.js +36 -0
  71. package/dist/chunk-BOPZWRJK.js.map +1 -0
  72. package/dist/chunk-BPARRK6F.js +14 -0
  73. package/dist/chunk-BPARRK6F.js.map +1 -0
  74. package/dist/chunk-CO6LUM72.js +59 -0
  75. package/dist/chunk-CO6LUM72.js.map +1 -0
  76. package/dist/chunk-COGHTKXY.js +84 -0
  77. package/dist/chunk-COGHTKXY.js.map +1 -0
  78. package/dist/chunk-DCCZB4UC.js +100 -0
  79. package/dist/chunk-DCCZB4UC.js.map +1 -0
  80. package/dist/chunk-DKKFTHHI.js +53 -0
  81. package/dist/chunk-DKKFTHHI.js.map +1 -0
  82. package/dist/chunk-DV4RV2DC.js +59 -0
  83. package/dist/chunk-DV4RV2DC.js.map +1 -0
  84. package/dist/chunk-EDKJU5BO.js +11 -0
  85. package/dist/chunk-EDKJU5BO.js.map +1 -0
  86. package/dist/chunk-EO2QPOKH.js +116 -0
  87. package/dist/chunk-EO2QPOKH.js.map +1 -0
  88. package/dist/chunk-EOLLMEAH.js +155 -0
  89. package/dist/chunk-EOLLMEAH.js.map +1 -0
  90. package/dist/chunk-EWYCWP4H.js +14 -0
  91. package/dist/chunk-EWYCWP4H.js.map +1 -0
  92. package/dist/chunk-EXVDJMIY.js +33 -0
  93. package/dist/chunk-EXVDJMIY.js.map +1 -0
  94. package/dist/chunk-FASRXRX5.js +19 -0
  95. package/dist/chunk-FASRXRX5.js.map +1 -0
  96. package/dist/chunk-FI34KYZ5.js +1 -0
  97. package/dist/chunk-FI34KYZ5.js.map +1 -0
  98. package/dist/chunk-FN2PYDPP.js +1 -0
  99. package/dist/chunk-FN2PYDPP.js.map +1 -0
  100. package/dist/chunk-GM3RMJIJ.js +92 -0
  101. package/dist/chunk-GM3RMJIJ.js.map +1 -0
  102. package/dist/chunk-GYGNEQSC.js +9 -0
  103. package/dist/chunk-GYGNEQSC.js.map +1 -0
  104. package/dist/chunk-H5NH7KPE.js +21 -0
  105. package/dist/chunk-H5NH7KPE.js.map +1 -0
  106. package/dist/chunk-HNWZFNKP.js +168 -0
  107. package/dist/chunk-HNWZFNKP.js.map +1 -0
  108. package/dist/chunk-HUH73XGI.js +1 -0
  109. package/dist/chunk-HUH73XGI.js.map +1 -0
  110. package/dist/chunk-I6MG4M3F.js +201 -0
  111. package/dist/chunk-I6MG4M3F.js.map +1 -0
  112. package/dist/chunk-I6MVCB5A.js +39 -0
  113. package/dist/chunk-I6MVCB5A.js.map +1 -0
  114. package/dist/chunk-IBGER4YK.js +12 -0
  115. package/dist/chunk-IBGER4YK.js.map +1 -0
  116. package/dist/chunk-IF5I3DAA.js +92 -0
  117. package/dist/chunk-IF5I3DAA.js.map +1 -0
  118. package/dist/chunk-IP4OO26U.js +54 -0
  119. package/dist/chunk-IP4OO26U.js.map +1 -0
  120. package/dist/chunk-IWAOY6KC.js +1 -0
  121. package/dist/chunk-IWAOY6KC.js.map +1 -0
  122. package/dist/chunk-J37YWU7Y.js +19 -0
  123. package/dist/chunk-J37YWU7Y.js.map +1 -0
  124. package/dist/chunk-J6KZS54B.js +269 -0
  125. package/dist/chunk-J6KZS54B.js.map +1 -0
  126. package/dist/chunk-J6MN42LG.js +19 -0
  127. package/dist/chunk-J6MN42LG.js.map +1 -0
  128. package/dist/chunk-JRQO2IOF.js +65 -0
  129. package/dist/chunk-JRQO2IOF.js.map +1 -0
  130. package/dist/chunk-JRVNVKN6.js +212 -0
  131. package/dist/chunk-JRVNVKN6.js.map +1 -0
  132. package/dist/chunk-JWNHNUYL.js +96 -0
  133. package/dist/chunk-JWNHNUYL.js.map +1 -0
  134. package/dist/chunk-K2I6XIK5.js +122 -0
  135. package/dist/chunk-K2I6XIK5.js.map +1 -0
  136. package/dist/chunk-KMZCQASO.js +111 -0
  137. package/dist/chunk-KMZCQASO.js.map +1 -0
  138. package/dist/chunk-KVOWSC5S.js +1 -0
  139. package/dist/chunk-KVOWSC5S.js.map +1 -0
  140. package/dist/chunk-KYR3B3OW.js +79 -0
  141. package/dist/chunk-KYR3B3OW.js.map +1 -0
  142. package/dist/chunk-L3LZWWSX.js +61 -0
  143. package/dist/chunk-L3LZWWSX.js.map +1 -0
  144. package/dist/chunk-L4SDDEEU.js +1 -0
  145. package/dist/chunk-L4SDDEEU.js.map +1 -0
  146. package/dist/chunk-L6FTY45T.js +13 -0
  147. package/dist/chunk-L6FTY45T.js.map +1 -0
  148. package/dist/chunk-L7BNNRGI.js +134 -0
  149. package/dist/chunk-L7BNNRGI.js.map +1 -0
  150. package/dist/chunk-LG57S2SC.js +150 -0
  151. package/dist/chunk-LG57S2SC.js.map +1 -0
  152. package/dist/chunk-M6QLSLPO.js +97 -0
  153. package/dist/chunk-M6QLSLPO.js.map +1 -0
  154. package/dist/chunk-MZ6GV4YF.js +21 -0
  155. package/dist/chunk-MZ6GV4YF.js.map +1 -0
  156. package/dist/chunk-N5OTOWTP.js +55 -0
  157. package/dist/chunk-N5OTOWTP.js.map +1 -0
  158. package/dist/chunk-NN7XZEGF.js +14 -0
  159. package/dist/chunk-NN7XZEGF.js.map +1 -0
  160. package/dist/chunk-NPFPZ2HO.js +13 -0
  161. package/dist/chunk-NPFPZ2HO.js.map +1 -0
  162. package/dist/chunk-NXXDZ6ZF.js +42 -0
  163. package/dist/chunk-NXXDZ6ZF.js.map +1 -0
  164. package/dist/chunk-NYBCQZC7.js +11 -0
  165. package/dist/chunk-NYBCQZC7.js.map +1 -0
  166. package/dist/chunk-OFRRBC7M.js +78 -0
  167. package/dist/chunk-OFRRBC7M.js.map +1 -0
  168. package/dist/chunk-OGIZXGPY.js +222 -0
  169. package/dist/chunk-OGIZXGPY.js.map +1 -0
  170. package/dist/chunk-OKXZ63IA.js +168 -0
  171. package/dist/chunk-OKXZ63IA.js.map +1 -0
  172. package/dist/chunk-OSQRXVG2.js +58 -0
  173. package/dist/chunk-OSQRXVG2.js.map +1 -0
  174. package/dist/chunk-OTDN3OUQ.js +215 -0
  175. package/dist/chunk-OTDN3OUQ.js.map +1 -0
  176. package/dist/chunk-OZZJDRGW.js +122 -0
  177. package/dist/chunk-OZZJDRGW.js.map +1 -0
  178. package/dist/chunk-PNZSGAB2.js +114 -0
  179. package/dist/chunk-PNZSGAB2.js.map +1 -0
  180. package/dist/chunk-PRWIX6UW.js +21 -0
  181. package/dist/chunk-PRWIX6UW.js.map +1 -0
  182. package/dist/chunk-PSXUNOVU.js +7 -0
  183. package/dist/chunk-PSXUNOVU.js.map +1 -0
  184. package/dist/chunk-QLTJSCE6.js +44 -0
  185. package/dist/chunk-QLTJSCE6.js.map +1 -0
  186. package/dist/chunk-RC23QROE.js +447 -0
  187. package/dist/chunk-RC23QROE.js.map +1 -0
  188. package/dist/chunk-RFH7N6EP.js +36 -0
  189. package/dist/chunk-RFH7N6EP.js.map +1 -0
  190. package/dist/chunk-RHVN6NA7.js +134 -0
  191. package/dist/chunk-RHVN6NA7.js.map +1 -0
  192. package/dist/chunk-S7C6TIIF.js +21 -0
  193. package/dist/chunk-S7C6TIIF.js.map +1 -0
  194. package/dist/chunk-SNQ3TOWP.js +20 -0
  195. package/dist/chunk-SNQ3TOWP.js.map +1 -0
  196. package/dist/chunk-SOVM2VEK.js +14 -0
  197. package/dist/chunk-SOVM2VEK.js.map +1 -0
  198. package/dist/chunk-SQDOBLBP.js +13 -0
  199. package/dist/chunk-SQDOBLBP.js.map +1 -0
  200. package/dist/chunk-SR7F3TJY.js +130 -0
  201. package/dist/chunk-SR7F3TJY.js.map +1 -0
  202. package/dist/chunk-SZVPIHWE.js +129 -0
  203. package/dist/chunk-SZVPIHWE.js.map +1 -0
  204. package/dist/chunk-T4BIIU5E.js +89 -0
  205. package/dist/chunk-T4BIIU5E.js.map +1 -0
  206. package/dist/chunk-T6C4LFLC.js +112 -0
  207. package/dist/chunk-T6C4LFLC.js.map +1 -0
  208. package/dist/chunk-TNXH7BJS.js +48 -0
  209. package/dist/chunk-TNXH7BJS.js.map +1 -0
  210. package/dist/chunk-U64T4YZE.js +9 -0
  211. package/dist/chunk-U64T4YZE.js.map +1 -0
  212. package/dist/chunk-UQ5EHOH2.js +39 -0
  213. package/dist/chunk-UQ5EHOH2.js.map +1 -0
  214. package/dist/chunk-UTN4GBPQ.js +1 -0
  215. package/dist/chunk-UTN4GBPQ.js.map +1 -0
  216. package/dist/chunk-V4AF6DI4.js +16 -0
  217. package/dist/chunk-V4AF6DI4.js.map +1 -0
  218. package/dist/chunk-W72PRNJY.js +126 -0
  219. package/dist/chunk-W72PRNJY.js.map +1 -0
  220. package/dist/chunk-WEVWJKOW.js +81 -0
  221. package/dist/chunk-WEVWJKOW.js.map +1 -0
  222. package/dist/chunk-WL67FZGF.js +21 -0
  223. package/dist/chunk-WL67FZGF.js.map +1 -0
  224. package/dist/chunk-WPXNN6QS.js +290 -0
  225. package/dist/chunk-WPXNN6QS.js.map +1 -0
  226. package/dist/chunk-WRUUSZDJ.js +29 -0
  227. package/dist/chunk-WRUUSZDJ.js.map +1 -0
  228. package/dist/chunk-X2GMTYPA.js +50 -0
  229. package/dist/chunk-X2GMTYPA.js.map +1 -0
  230. package/dist/chunk-XCEI7NUH.js +41 -0
  231. package/dist/chunk-XCEI7NUH.js.map +1 -0
  232. package/dist/chunk-Y7GDG744.js +88 -0
  233. package/dist/chunk-Y7GDG744.js.map +1 -0
  234. package/dist/chunk-Y7RRSEOC.js +9 -0
  235. package/dist/chunk-Y7RRSEOC.js.map +1 -0
  236. package/dist/chunk-YPWODKD5.js +184 -0
  237. package/dist/chunk-YPWODKD5.js.map +1 -0
  238. package/dist/chunk-YSLTTQLC.js +25 -0
  239. package/dist/chunk-YSLTTQLC.js.map +1 -0
  240. package/dist/chunk-YTN6BKWA.js +121 -0
  241. package/dist/chunk-YTN6BKWA.js.map +1 -0
  242. package/dist/chunk-Z7PQCAVK.js +200 -0
  243. package/dist/chunk-Z7PQCAVK.js.map +1 -0
  244. package/dist/chunk-ZUKFQL6E.js +47 -0
  245. package/dist/chunk-ZUKFQL6E.js.map +1 -0
  246. package/dist/chunk-ZUMULSEQ.js +1 -0
  247. package/dist/chunk-ZUMULSEQ.js.map +1 -0
  248. package/dist/{job-orchestrator.protocol-CARhMLCO.d.ts → job-orchestrator.protocol-DubMVbm9.d.ts} +1 -1
  249. package/dist/runtime/analytics/index.js +8 -41
  250. package/dist/runtime/analytics/index.js.map +1 -1
  251. package/dist/runtime/analytics/types.js +8 -41
  252. package/dist/runtime/analytics/types.js.map +1 -1
  253. package/dist/runtime/base-classes/activity-entity-repository.js +6 -312
  254. package/dist/runtime/base-classes/activity-entity-repository.js.map +1 -1
  255. package/dist/runtime/base-classes/activity-entity-service.js +6 -212
  256. package/dist/runtime/base-classes/activity-entity-service.js.map +1 -1
  257. package/dist/runtime/base-classes/base-read-use-cases.js +5 -27
  258. package/dist/runtime/base-classes/base-read-use-cases.js.map +1 -1
  259. package/dist/runtime/base-classes/base-repository.js +5 -277
  260. package/dist/runtime/base-classes/base-repository.js.map +1 -1
  261. package/dist/runtime/base-classes/base-service.js +5 -184
  262. package/dist/runtime/base-classes/base-service.js.map +1 -1
  263. package/dist/runtime/base-classes/index.js +59 -1076
  264. package/dist/runtime/base-classes/index.js.map +1 -1
  265. package/dist/runtime/base-classes/integrated-entity-repository.js +6 -486
  266. package/dist/runtime/base-classes/integrated-entity-repository.js.map +1 -1
  267. package/dist/runtime/base-classes/integrated-entity-service.js +6 -213
  268. package/dist/runtime/base-classes/integrated-entity-service.js.map +1 -1
  269. package/dist/runtime/base-classes/junction-integration-repository.js +8 -448
  270. package/dist/runtime/base-classes/junction-integration-repository.js.map +1 -1
  271. package/dist/runtime/base-classes/knowledge-entity-repository.js +6 -283
  272. package/dist/runtime/base-classes/knowledge-entity-repository.js.map +1 -1
  273. package/dist/runtime/base-classes/knowledge-entity-service.js +6 -190
  274. package/dist/runtime/base-classes/knowledge-entity-service.js.map +1 -1
  275. package/dist/runtime/base-classes/lifecycle-events.js +8 -70
  276. package/dist/runtime/base-classes/lifecycle-events.js.map +1 -1
  277. package/dist/runtime/base-classes/metadata-entity-repository.js +6 -330
  278. package/dist/runtime/base-classes/metadata-entity-repository.js.map +1 -1
  279. package/dist/runtime/base-classes/metadata-entity-service.js +6 -212
  280. package/dist/runtime/base-classes/metadata-entity-service.js.map +1 -1
  281. package/dist/runtime/base-classes/tenant-context.js +10 -36
  282. package/dist/runtime/base-classes/tenant-context.js.map +1 -1
  283. package/dist/runtime/base-classes/with-analytics.js +4 -7
  284. package/dist/runtime/base-classes/with-analytics.js.map +1 -1
  285. package/dist/runtime/constants/tokens.js +5 -3
  286. package/dist/runtime/constants/tokens.js.map +1 -1
  287. package/dist/runtime/eav-helpers.js +2 -0
  288. package/dist/runtime/eav-helpers.js.map +1 -1
  289. package/dist/runtime/pipes/zod-validation.pipe.js +3 -10
  290. package/dist/runtime/pipes/zod-validation.pipe.js.map +1 -1
  291. package/dist/runtime/shared/openapi/error-response.dto.js +5 -8
  292. package/dist/runtime/shared/openapi/error-response.dto.js.map +1 -1
  293. package/dist/runtime/shared/openapi/errors.js +5 -19
  294. package/dist/runtime/shared/openapi/errors.js.map +1 -1
  295. package/dist/runtime/shared/openapi/index.js +15 -106
  296. package/dist/runtime/shared/openapi/index.js.map +1 -1
  297. package/dist/runtime/shared/openapi/registry.js +6 -103
  298. package/dist/runtime/shared/openapi/registry.js.map +1 -1
  299. package/dist/runtime/shared/openapi/registry.tokens.js +4 -2
  300. package/dist/runtime/shared/openapi/registry.tokens.js.map +1 -1
  301. package/dist/runtime/subsystems/analytics/analytics.module.js +8 -117
  302. package/dist/runtime/subsystems/analytics/analytics.module.js.map +1 -1
  303. package/dist/runtime/subsystems/analytics/analytics.tokens.js +7 -8
  304. package/dist/runtime/subsystems/analytics/analytics.tokens.js.map +1 -1
  305. package/dist/runtime/subsystems/analytics/cube-backend.js +6 -71
  306. package/dist/runtime/subsystems/analytics/cube-backend.js.map +1 -1
  307. package/dist/runtime/subsystems/analytics/index.js +16 -117
  308. package/dist/runtime/subsystems/analytics/index.js.map +1 -1
  309. package/dist/runtime/subsystems/analytics/noop-backend.js +4 -21
  310. package/dist/runtime/subsystems/analytics/noop-backend.js.map +1 -1
  311. package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js +4 -8
  312. package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js.map +1 -1
  313. package/dist/runtime/subsystems/auth/auth.module.js +12 -359
  314. package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
  315. package/dist/runtime/subsystems/auth/auth.tokens.js +12 -13
  316. package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
  317. package/dist/runtime/subsystems/auth/backends/encryption-key/env.js +4 -49
  318. package/dist/runtime/subsystems/auth/backends/encryption-key/env.js.map +1 -1
  319. package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js +6 -64
  320. package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js.map +1 -1
  321. package/dist/runtime/subsystems/auth/backends/state-store.memory-backend.js +5 -47
  322. package/dist/runtime/subsystems/auth/backends/state-store.memory-backend.js.map +1 -1
  323. package/dist/runtime/subsystems/auth/controllers/auth.controller.js +5 -139
  324. package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
  325. package/dist/runtime/subsystems/auth/index.js +53 -542
  326. package/dist/runtime/subsystems/auth/index.js.map +1 -1
  327. package/dist/runtime/subsystems/auth/middleware/requester-context.js +9 -65
  328. package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
  329. package/dist/runtime/subsystems/auth/protocols/oauth-state-store.js +4 -9
  330. package/dist/runtime/subsystems/auth/protocols/oauth-state-store.js.map +1 -1
  331. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js +4 -15
  332. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js.map +1 -1
  333. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js +5 -104
  334. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
  335. package/dist/runtime/subsystems/auth/runtime/session-expired.error.js +5 -16
  336. package/dist/runtime/subsystems/auth/runtime/session-expired.error.js.map +1 -1
  337. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js +5 -29
  338. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
  339. package/dist/runtime/subsystems/bridge/assert-tenant-id.js +5 -18
  340. package/dist/runtime/subsystems/bridge/assert-tenant-id.js.map +1 -1
  341. package/dist/runtime/subsystems/bridge/bridge-delivery-handler.d.ts +2 -2
  342. package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +12 -184
  343. package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js.map +1 -1
  344. package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.d.ts +1 -1
  345. package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js +10 -448
  346. package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js.map +1 -1
  347. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.d.ts +1 -1
  348. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +5 -126
  349. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
  350. package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js +6 -308
  351. package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js.map +1 -1
  352. package/dist/runtime/subsystems/bridge/bridge-errors.js +6 -35
  353. package/dist/runtime/subsystems/bridge/bridge-errors.js.map +1 -1
  354. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.d.ts +1 -1
  355. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +14 -606
  356. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js.map +1 -1
  357. package/dist/runtime/subsystems/bridge/bridge.module.d.ts +2 -2
  358. package/dist/runtime/subsystems/bridge/bridge.module.js +35 -3476
  359. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  360. package/dist/runtime/subsystems/bridge/bridge.protocol.d.ts +1 -1
  361. package/dist/runtime/subsystems/bridge/bridge.tokens.js +9 -7
  362. package/dist/runtime/subsystems/bridge/bridge.tokens.js.map +1 -1
  363. package/dist/runtime/subsystems/bridge/event-flow.service.d.ts +2 -2
  364. package/dist/runtime/subsystems/bridge/event-flow.service.js +11 -137
  365. package/dist/runtime/subsystems/bridge/event-flow.service.js.map +1 -1
  366. package/dist/runtime/subsystems/bridge/generated/registry.d.ts +1 -1
  367. package/dist/runtime/subsystems/bridge/generated/registry.js +4 -2
  368. package/dist/runtime/subsystems/bridge/generated/registry.js.map +1 -1
  369. package/dist/runtime/subsystems/bridge/index.d.ts +2 -2
  370. package/dist/runtime/subsystems/bridge/index.js +60 -3470
  371. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  372. package/dist/runtime/subsystems/bridge/reserved-pools.js +4 -6
  373. package/dist/runtime/subsystems/bridge/reserved-pools.js.map +1 -1
  374. package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +10 -133
  375. package/dist/runtime/subsystems/cache/cache.drizzle-backend.js.map +1 -1
  376. package/dist/runtime/subsystems/cache/cache.memory-backend.js +6 -101
  377. package/dist/runtime/subsystems/cache/cache.memory-backend.js.map +1 -1
  378. package/dist/runtime/subsystems/cache/cache.module.js +10 -278
  379. package/dist/runtime/subsystems/cache/cache.module.js.map +1 -1
  380. package/dist/runtime/subsystems/cache/cache.schema.js +4 -14
  381. package/dist/runtime/subsystems/cache/cache.schema.js.map +1 -1
  382. package/dist/runtime/subsystems/cache/cache.tokens.js +6 -7
  383. package/dist/runtime/subsystems/cache/cache.tokens.js.map +1 -1
  384. package/dist/runtime/subsystems/cache/index.js +20 -278
  385. package/dist/runtime/subsystems/cache/index.js.map +1 -1
  386. package/dist/runtime/subsystems/events/domain-events.schema.js +3 -72
  387. package/dist/runtime/subsystems/events/domain-events.schema.js.map +1 -1
  388. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.d.ts +1 -1
  389. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +9 -413
  390. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -1
  391. package/dist/runtime/subsystems/events/event-bus.memory-backend.js +7 -235
  392. package/dist/runtime/subsystems/events/event-bus.memory-backend.js.map +1 -1
  393. package/dist/runtime/subsystems/events/event-bus.redis-backend.js +8 -20
  394. package/dist/runtime/subsystems/events/event-bus.redis-backend.js.map +1 -1
  395. package/dist/runtime/subsystems/events/event-keyset-cursor.js +8 -30
  396. package/dist/runtime/subsystems/events/event-keyset-cursor.js.map +1 -1
  397. package/dist/runtime/subsystems/events/event-read.protocol.js +2 -0
  398. package/dist/runtime/subsystems/events/event-read.protocol.js.map +1 -1
  399. package/dist/runtime/subsystems/events/event-registry.d.ts +77 -0
  400. package/dist/runtime/subsystems/events/event-registry.js +1 -0
  401. package/dist/runtime/subsystems/events/event-registry.js.map +1 -0
  402. package/dist/runtime/subsystems/events/events-errors.js +4 -11
  403. package/dist/runtime/subsystems/events/events-errors.js.map +1 -1
  404. package/dist/runtime/subsystems/events/events.module.js +15 -949
  405. package/dist/runtime/subsystems/events/events.module.js.map +1 -1
  406. package/dist/runtime/subsystems/events/events.tokens.js +10 -11
  407. package/dist/runtime/subsystems/events/events.tokens.js.map +1 -1
  408. package/dist/runtime/subsystems/events/generated/bus.js +9 -240
  409. package/dist/runtime/subsystems/events/generated/bus.js.map +1 -1
  410. package/dist/runtime/subsystems/events/generated/index.js +23 -240
  411. package/dist/runtime/subsystems/events/generated/index.js.map +1 -1
  412. package/dist/runtime/subsystems/events/generated/registry.js +5 -82
  413. package/dist/runtime/subsystems/events/generated/registry.js.map +1 -1
  414. package/dist/runtime/subsystems/events/generated/schemas.js +12 -52
  415. package/dist/runtime/subsystems/events/generated/schemas.js.map +1 -1
  416. package/dist/runtime/subsystems/events/generated/types.js +1 -0
  417. package/dist/runtime/subsystems/events/index.d.ts +1 -0
  418. package/dist/runtime/subsystems/events/index.js +32 -949
  419. package/dist/runtime/subsystems/events/index.js.map +1 -1
  420. package/dist/runtime/subsystems/index.d.ts +2 -2
  421. package/dist/runtime/subsystems/index.js +171 -5912
  422. package/dist/runtime/subsystems/index.js.map +1 -1
  423. package/dist/runtime/subsystems/integration/build-change-source.js +6 -178
  424. package/dist/runtime/subsystems/integration/build-change-source.js.map +1 -1
  425. package/dist/runtime/subsystems/integration/deep-equal.differ.js +4 -109
  426. package/dist/runtime/subsystems/integration/deep-equal.differ.js.map +1 -1
  427. package/dist/runtime/subsystems/integration/detection-config.schema.js +11 -78
  428. package/dist/runtime/subsystems/integration/detection-config.schema.js.map +1 -1
  429. package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js +5 -30
  430. package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js.map +1 -1
  431. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js +4 -9
  432. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js.map +1 -1
  433. package/dist/runtime/subsystems/integration/execute-integration.use-case.js +6 -239
  434. package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -1
  435. package/dist/runtime/subsystems/integration/incremental-read.js +5 -144
  436. package/dist/runtime/subsystems/integration/incremental-read.js.map +1 -1
  437. package/dist/runtime/subsystems/integration/index.js +83 -1352
  438. package/dist/runtime/subsystems/integration/index.js.map +1 -1
  439. package/dist/runtime/subsystems/integration/integration-audit.schema.js +10 -155
  440. package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -1
  441. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js +7 -270
  442. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -1
  443. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js +4 -65
  444. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -1
  445. package/dist/runtime/subsystems/integration/integration-errors.js +5 -15
  446. package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -1
  447. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js +5 -7
  448. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -1
  449. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js +8 -303
  450. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -1
  451. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js +5 -125
  452. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -1
  453. package/dist/runtime/subsystems/integration/integration.module.js +13 -700
  454. package/dist/runtime/subsystems/integration/integration.module.js.map +1 -1
  455. package/dist/runtime/subsystems/integration/integration.tokens.js +11 -9
  456. package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -1
  457. package/dist/runtime/subsystems/integration/loopback.middleware.js +4 -16
  458. package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -1
  459. package/dist/runtime/subsystems/integration/poll-change-source.js +4 -89
  460. package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -1
  461. package/dist/runtime/subsystems/integration/webhook-change-source.js +4 -70
  462. package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -1
  463. package/dist/runtime/subsystems/jobs/bullmq.config.js +9 -140
  464. package/dist/runtime/subsystems/jobs/bullmq.config.js.map +1 -1
  465. package/dist/runtime/subsystems/jobs/index.d.ts +2 -2
  466. package/dist/runtime/subsystems/jobs/index.js +88 -2691
  467. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  468. package/dist/runtime/subsystems/jobs/job-handler.base.d.ts +2 -2
  469. package/dist/runtime/subsystems/jobs/job-handler.base.js +10 -49
  470. package/dist/runtime/subsystems/jobs/job-handler.base.js.map +1 -1
  471. package/dist/runtime/subsystems/jobs/job-orchestration.schema.js +13 -152
  472. package/dist/runtime/subsystems/jobs/job-orchestration.schema.js.map +1 -1
  473. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.d.ts +2 -2
  474. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +36 -699
  475. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js.map +1 -1
  476. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.d.ts +2 -2
  477. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +10 -564
  478. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js.map +1 -1
  479. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.d.ts +2 -2
  480. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +10 -824
  481. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
  482. package/dist/runtime/subsystems/jobs/job-orchestrator.protocol.d.ts +2 -2
  483. package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.d.ts +2 -2
  484. package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js +9 -51
  485. package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js.map +1 -1
  486. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.d.ts +2 -2
  487. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +9 -416
  488. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js.map +1 -1
  489. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.d.ts +2 -2
  490. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +9 -290
  491. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
  492. package/dist/runtime/subsystems/jobs/job-run-service.protocol.d.ts +2 -2
  493. package/dist/runtime/subsystems/jobs/job-step-service.drizzle-backend.js +5 -213
  494. package/dist/runtime/subsystems/jobs/job-step-service.drizzle-backend.js.map +1 -1
  495. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +5 -131
  496. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
  497. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.d.ts +2 -2
  498. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +9 -175
  499. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
  500. package/dist/runtime/subsystems/jobs/job-worker.d.ts +2 -2
  501. package/dist/runtime/subsystems/jobs/job-worker.js +14 -613
  502. package/dist/runtime/subsystems/jobs/job-worker.js.map +1 -1
  503. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +2 -2
  504. package/dist/runtime/subsystems/jobs/job-worker.module.js +23 -2647
  505. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  506. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +19 -1897
  507. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  508. package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js +8 -9
  509. package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js.map +1 -1
  510. package/dist/runtime/subsystems/jobs/jobs-errors.d.ts +2 -2
  511. package/dist/runtime/subsystems/jobs/jobs-errors.js +10 -78
  512. package/dist/runtime/subsystems/jobs/jobs-errors.js.map +1 -1
  513. package/dist/runtime/subsystems/jobs/memory-job-store.js +4 -15
  514. package/dist/runtime/subsystems/jobs/memory-job-store.js.map +1 -1
  515. package/dist/runtime/subsystems/jobs/pool-config.loader.js +9 -124
  516. package/dist/runtime/subsystems/jobs/pool-config.loader.js.map +1 -1
  517. package/dist/runtime/subsystems/observability/index.d.ts +2 -2
  518. package/dist/runtime/subsystems/observability/index.js +21 -310
  519. package/dist/runtime/subsystems/observability/index.js.map +1 -1
  520. package/dist/runtime/subsystems/observability/observability-errors.js +4 -9
  521. package/dist/runtime/subsystems/observability/observability-errors.js.map +1 -1
  522. package/dist/runtime/subsystems/observability/observability.module.js +11 -300
  523. package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
  524. package/dist/runtime/subsystems/observability/observability.protocol.d.ts +2 -2
  525. package/dist/runtime/subsystems/observability/observability.service.d.ts +2 -2
  526. package/dist/runtime/subsystems/observability/observability.service.js +9 -197
  527. package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
  528. package/dist/runtime/subsystems/observability/observability.tokens.js +5 -3
  529. package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
  530. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +2 -2
  531. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js +4 -84
  532. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
  533. package/dist/runtime/subsystems/observability/reporters/index.d.ts +2 -2
  534. package/dist/runtime/subsystems/observability/reporters/index.js +5 -84
  535. package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
  536. package/dist/runtime/subsystems/storage/index.js +15 -200
  537. package/dist/runtime/subsystems/storage/index.js.map +1 -1
  538. package/dist/runtime/subsystems/storage/storage.local-backend.js +4 -103
  539. package/dist/runtime/subsystems/storage/storage.local-backend.js.map +1 -1
  540. package/dist/runtime/subsystems/storage/storage.memory-backend.js +5 -68
  541. package/dist/runtime/subsystems/storage/storage.memory-backend.js.map +1 -1
  542. package/dist/runtime/subsystems/storage/storage.module.js +8 -200
  543. package/dist/runtime/subsystems/storage/storage.module.js.map +1 -1
  544. package/dist/runtime/subsystems/storage/storage.tokens.js +5 -6
  545. package/dist/runtime/subsystems/storage/storage.tokens.js.map +1 -1
  546. package/dist/runtime/subsystems/storage/storage.utils.js +4 -14
  547. package/dist/runtime/subsystems/storage/storage.utils.js.map +1 -1
  548. package/dist/runtime/subsystems/token-key.js +5 -3
  549. package/dist/runtime/subsystems/token-key.js.map +1 -1
  550. package/dist/src/cli/index.js +653 -5444
  551. package/dist/src/cli/index.js.map +1 -1
  552. package/dist/src/index.js +68 -4170
  553. package/dist/src/index.js.map +1 -1
  554. package/package.json +1 -1
  555. package/runtime/subsystems/bridge/bridge-delivery-handler.ts +1 -1
  556. package/runtime/subsystems/bridge/bridge-outbox-drain-hook.ts +45 -22
  557. package/runtime/subsystems/bridge/bridge.protocol.ts +1 -1
  558. package/runtime/subsystems/bridge/event-flow.service.ts +1 -1
  559. package/runtime/subsystems/events/event-registry.ts +77 -0
  560. package/runtime/subsystems/events/index.ts +12 -0
  561. package/runtime/subsystems/jobs/job-handler.base.ts +1 -1
  562. package/runtime/subsystems/jobs/job-worker.ts +17 -11
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../runtime/base-classes/lifecycle-events.ts","../../../runtime/base-classes/base-service.ts","../../../runtime/base-classes/metadata-entity-service.ts"],"sourcesContent":["/**\n * Lifecycle event emission for BaseService.\n *\n * Ported from pattern-stack/atoms/patterns/services/base.py — the Python\n * BaseService emits LIFECYCLE and CHANGE events on every CRUD operation.\n * This module provides the same capability for the TypeScript codegen stack.\n *\n * Design:\n * - Fire-and-forget: event emission never fails the CRUD operation.\n * - IEventBus is optional: if no EVENT_BUS is injected, emission is silently\n * skipped. This means base classes work in projects that haven't installed\n * the events subsystem.\n * - LIFECYCLE events carry an entity snapshot in payload.\n * - CHANGE events carry per-field old/new diffs.\n * - Controlled per-entity via `emitLifecycleEvents` flag (default: true).\n *\n * @deprecated EVT-7 — Lifecycle events are untyped and emit outside of the\n * CRUD transaction. New work should declare an `emits:` block on the entity\n * and publish typed domain events from use-cases via TYPED_EVENT_BUS inside\n * the same Drizzle transaction. See `docs/specs/EVT-7.md`. This helper is\n * retained for BaseService backward compatibility until all entities have\n * migrated to typed emits.\n */\n\nimport { randomUUID } from 'crypto';\nimport type { IEventBus, DomainEvent } from '../subsystems/events/event-bus.protocol';\n\n// ============================================================================\n// Event categories (subset of pattern-stack's EventCategory)\n// ============================================================================\n\nexport type EventCategory = 'lifecycle' | 'change';\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/** System fields excluded from entity snapshots and change diffs. */\nconst SYSTEM_FIELDS = new Set([\n\t'id',\n\t'createdAt',\n\t'updatedAt',\n\t'deletedAt',\n]);\n\n/**\n * Snapshot an entity's field values, excluding system fields.\n * Mirrors pattern-stack's `_get_entity_snapshot()`.\n */\nexport function entitySnapshot(entity: Record<string, unknown>): Record<string, unknown> {\n\tconst snap: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(entity)) {\n\t\tif (!SYSTEM_FIELDS.has(key)) {\n\t\t\tsnap[key] = value;\n\t\t}\n\t}\n\treturn snap;\n}\n\n/**\n * Diff two entity snapshots, returning per-field old/new pairs.\n * Only includes fields that actually changed.\n */\nexport function diffSnapshots(\n\tbefore: Record<string, unknown>,\n\tafter: Record<string, unknown>,\n): Array<{ field: string; oldValue: unknown; newValue: unknown }> {\n\tconst changes: Array<{ field: string; oldValue: unknown; newValue: unknown }> = [];\n\tconst allKeys = new Set([...Object.keys(before), ...Object.keys(after)]);\n\n\tfor (const key of allKeys) {\n\t\tif (SYSTEM_FIELDS.has(key)) continue;\n\t\tconst oldVal = before[key];\n\t\tconst newVal = after[key];\n\t\t// Simple equality — good enough for primitives and nulls.\n\t\t// For deep objects, JSON.stringify comparison.\n\t\tif (oldVal !== newVal && JSON.stringify(oldVal) !== JSON.stringify(newVal)) {\n\t\t\tchanges.push({ field: key, oldValue: oldVal, newValue: newVal });\n\t\t}\n\t}\n\n\treturn changes;\n}\n\n// ============================================================================\n// Event builders\n// ============================================================================\n\nexport function buildLifecycleEvent(\n\tentityName: string,\n\taction: 'created' | 'updated' | 'deleted',\n\tentityId: string,\n\tsnapshot?: Record<string, unknown>,\n): DomainEvent {\n\treturn {\n\t\tid: randomUUID(),\n\t\ttype: `${entityName}.${action}`,\n\t\taggregateId: entityId,\n\t\taggregateType: entityName,\n\t\tpayload: snapshot ? { snapshot } : {},\n\t\toccurredAt: new Date(),\n\t\tmetadata: { category: 'lifecycle' as EventCategory },\n\t};\n}\n\nexport function buildChangeEvents(\n\tentityName: string,\n\tentityId: string,\n\tchanges: Array<{ field: string; oldValue: unknown; newValue: unknown }>,\n): DomainEvent[] {\n\treturn changes.map((c) => ({\n\t\tid: randomUUID(),\n\t\ttype: `${entityName}.field_changed`,\n\t\taggregateId: entityId,\n\t\taggregateType: entityName,\n\t\tpayload: {\n\t\t\tfieldName: c.field,\n\t\t\toldValue: c.oldValue,\n\t\t\tnewValue: c.newValue,\n\t\t},\n\t\toccurredAt: new Date(),\n\t\tmetadata: { category: 'change' as EventCategory },\n\t}));\n}\n\n// ============================================================================\n// Emission helper (fire-and-forget)\n// ============================================================================\n\n/**\n * Emit events to the bus, swallowing errors.\n * Mirrors pattern-stack's `_emit_lifecycle_event()` try/except.\n */\nexport async function emitSafely(\n\teventBus: IEventBus | undefined,\n\tevents: DomainEvent[],\n): Promise<void> {\n\tif (!eventBus || events.length === 0) return;\n\ttry {\n\t\tif (events.length === 1) {\n\t\t\tconst only = events[0];\n\t\t\tif (!only) return;\n\t\t\tawait eventBus.publish(only);\n\t\t} else {\n\t\t\tawait eventBus.publishMany(events);\n\t\t}\n\t} catch {\n\t\t// Log but never fail the CRUD operation.\n\t\t// In production, this would use a structured logger.\n\t\tconsole.warn(`[lifecycle-events] failed to emit ${events.length} event(s)`);\n\t}\n}\n","/**\n * BaseService<TRepo, TEntity>\n *\n * Abstract base class providing 8 CRUD pass-through methods delegating to\n * an injected repository. Every generated service extends this class.\n *\n * Lifecycle event emission (LIFECYCLE + CHANGE categories) is built into\n * create/update/delete — matching pattern-stack's BaseService. Events are\n * fire-and-forget: emission never fails the CRUD operation. If no IEventBus\n * is injected (eventBus is undefined), emission is silently skipped.\n *\n * Generated services set `entityName` and optionally inject `eventBus` via\n * NestJS property injection (@Inject(EVENT_BUS) @Optional()).\n *\n * Note: @Injectable() is applied on concrete services (not here) so that\n * NestJS DI metadata is emitted at the concrete class level. This matches\n * the pattern established by BaseRepository.\n */\n\nimport type { IEventBus } from '../subsystems/events/event-bus.protocol';\nimport {\n entitySnapshot,\n diffSnapshots,\n buildLifecycleEvent,\n buildChangeEvents,\n emitSafely,\n} from './lifecycle-events';\n\n// ============================================================================\n// IBaseRepository interface\n// ============================================================================\n\n/**\n * Structural interface that BaseRepository satisfies.\n * Use this as the TRepo constraint so BaseService is not coupled to the\n * concrete Drizzle-backed BaseRepository.\n */\nexport interface IBaseRepository<TEntity> {\n findById(id: string): Promise<TEntity | null>;\n findByIds(ids: string[]): Promise<TEntity[]>;\n list(options?: unknown): Promise<TEntity[]>;\n count(where?: unknown): Promise<number>;\n exists(id: string): Promise<boolean>;\n create(input: Partial<TEntity>, tx?: unknown): Promise<TEntity>;\n update(id: string, input: Partial<TEntity>, tx?: unknown): Promise<TEntity>;\n delete(id: string, tx?: unknown): Promise<void>;\n}\n\n// ============================================================================\n// BaseService\n// ============================================================================\n\nexport abstract class BaseService<TRepo extends IBaseRepository<TEntity>, TEntity> {\n /**\n * Entity name for event types (e.g., 'account' → 'account.created').\n * Set by generated services. If empty, lifecycle events are skipped.\n */\n protected entityName?: string;\n\n /**\n * Event bus for lifecycle/change event emission.\n * Injected via @Inject(EVENT_BUS) @Optional() on generated services.\n * If undefined (no events subsystem installed), emission is silently skipped.\n */\n protected eventBus?: IEventBus;\n\n /**\n * Whether to emit lifecycle events. Default: true.\n * Override to false in entity YAML via behaviors or in the service class.\n */\n protected emitLifecycleEvents = true;\n\n constructor(protected readonly repository: TRepo) {}\n\n /**\n * Find a single entity by its primary key.\n * Returns null if not found.\n */\n findById(id: string): Promise<TEntity | null> {\n return this.repository.findById(id);\n }\n\n /**\n * Find multiple entities by their primary keys.\n */\n findByIds(ids: string[]): Promise<TEntity[]> {\n return this.repository.findByIds(ids);\n }\n\n /**\n * List entities with optional filtering/pagination options.\n */\n list(options?: unknown): Promise<TEntity[]> {\n return this.repository.list(options);\n }\n\n /**\n * Count entities matching an optional filter.\n */\n count(where?: unknown): Promise<number> {\n return this.repository.count(where);\n }\n\n /**\n * Check whether an entity with the given id exists.\n */\n exists(id: string): Promise<boolean> {\n return this.repository.exists(id);\n }\n\n /**\n * Insert a new entity.\n * Emits a LIFECYCLE 'created' event with entity snapshot.\n */\n async create(input: Partial<TEntity>, tx?: unknown): Promise<TEntity> {\n const result = await this.repository.create(input, tx);\n\n if (this._shouldEmit()) {\n const snap = entitySnapshot(result as Record<string, unknown>);\n const id = (result as Record<string, unknown>).id as string;\n const event = buildLifecycleEvent(this.entityName!, 'created', id, snap);\n void emitSafely(this.eventBus, [event]);\n }\n\n return result;\n }\n\n /**\n * Update an existing entity by id.\n * Emits a LIFECYCLE 'updated' event + CHANGE events for each modified field.\n */\n async update(id: string, input: Partial<TEntity>, tx?: unknown): Promise<TEntity> {\n // Snapshot before for change diffing\n let before: Record<string, unknown> | undefined;\n if (this._shouldEmit()) {\n const existing = await this.repository.findById(id);\n if (existing) {\n before = entitySnapshot(existing as Record<string, unknown>);\n }\n }\n\n const result = await this.repository.update(id, input, tx);\n\n if (this._shouldEmit()) {\n const after = entitySnapshot(result as Record<string, unknown>);\n const events = [\n buildLifecycleEvent(this.entityName!, 'updated', id, after),\n ];\n // Append per-field CHANGE events\n if (before) {\n const changes = diffSnapshots(before, after);\n if (changes.length > 0) {\n events.push(...buildChangeEvents(this.entityName!, id, changes));\n }\n }\n void emitSafely(this.eventBus, events);\n }\n\n return result;\n }\n\n /**\n * Delete an entity by id.\n * Emits a LIFECYCLE 'deleted' event.\n */\n async delete(id: string, tx?: unknown): Promise<void> {\n await this.repository.delete(id, tx);\n\n if (this._shouldEmit()) {\n const event = buildLifecycleEvent(this.entityName!, 'deleted', id);\n void emitSafely(this.eventBus, [event]);\n }\n }\n\n /** Check whether lifecycle event emission is active. */\n private _shouldEmit(): boolean {\n return Boolean(\n this.emitLifecycleEvents &&\n this.entityName &&\n this.eventBus,\n );\n }\n}\n","/**\n * MetadataEntityService<TRepo, TEntity>\n *\n * Family-specific base service for metadata entities.\n * Delegates to a metadata repository that provides entity-scoped\n * lookups, history, and bulk upsert.\n */\nimport { BaseService, type IBaseRepository } from './base-service';\n\nexport interface IMetadataEntityRepository<TEntity> extends IBaseRepository<TEntity> {\n findByEntityIdAndType(entityId: string, entityType: string): Promise<TEntity[]>;\n listByEntityId(entityId: string): Promise<TEntity[]>;\n listHistoryByEntityId(entityId: string): Promise<TEntity[]>;\n upsertMany(inputs: Array<Partial<TEntity>>, tx?: unknown, options?: { conflictTarget?: string }): Promise<TEntity[]>;\n}\n\nexport abstract class MetadataEntityService<\n TRepo extends IMetadataEntityRepository<TEntity>,\n TEntity,\n> extends BaseService<TRepo, TEntity> {\n /**\n * Find metadata records by entity ID and entity type (EAV polymorphic lookup).\n */\n findByEntityIdAndType(entityId: string, entityType: string): Promise<TEntity[]> {\n return this.repository.findByEntityIdAndType(entityId, entityType);\n }\n\n /**\n * List all metadata records for an entity.\n */\n listByEntity(entityId: string): Promise<TEntity[]> {\n return this.repository.listByEntityId(entityId);\n }\n\n /**\n * List metadata history for an entity, ordered by validFrom desc.\n */\n listHistory(entityId: string): Promise<TEntity[]> {\n return this.repository.listHistoryByEntityId(entityId);\n }\n\n /**\n * Bulk upsert metadata values.\n */\n upsertValues(inputs: Array<Partial<TEntity>>, conflictTarget: string, tx?: unknown): Promise<TEntity[]> {\n return this.repository.upsertMany(inputs, tx, { conflictTarget });\n }\n}\n"],"mappings":";AAwBA,SAAS,kBAAkB;AAc3B,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAMM,SAAS,eAAe,QAA0D;AACxF,QAAM,OAAgC,CAAC;AACvC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,CAAC,cAAc,IAAI,GAAG,GAAG;AAC5B,WAAK,GAAG,IAAI;AAAA,IACb;AAAA,EACD;AACA,SAAO;AACR;AAMO,SAAS,cACf,QACA,OACiE;AACjE,QAAM,UAA0E,CAAC;AACjF,QAAM,UAAU,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC;AAEvE,aAAW,OAAO,SAAS;AAC1B,QAAI,cAAc,IAAI,GAAG,EAAG;AAC5B,UAAM,SAAS,OAAO,GAAG;AACzB,UAAM,SAAS,MAAM,GAAG;AAGxB,QAAI,WAAW,UAAU,KAAK,UAAU,MAAM,MAAM,KAAK,UAAU,MAAM,GAAG;AAC3E,cAAQ,KAAK,EAAE,OAAO,KAAK,UAAU,QAAQ,UAAU,OAAO,CAAC;AAAA,IAChE;AAAA,EACD;AAEA,SAAO;AACR;AAMO,SAAS,oBACf,YACA,QACA,UACA,UACc;AACd,SAAO;AAAA,IACN,IAAI,WAAW;AAAA,IACf,MAAM,GAAG,UAAU,IAAI,MAAM;AAAA,IAC7B,aAAa;AAAA,IACb,eAAe;AAAA,IACf,SAAS,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,IACpC,YAAY,oBAAI,KAAK;AAAA,IACrB,UAAU,EAAE,UAAU,YAA6B;AAAA,EACpD;AACD;AAEO,SAAS,kBACf,YACA,UACA,SACgB;AAChB,SAAO,QAAQ,IAAI,CAAC,OAAO;AAAA,IAC1B,IAAI,WAAW;AAAA,IACf,MAAM,GAAG,UAAU;AAAA,IACnB,aAAa;AAAA,IACb,eAAe;AAAA,IACf,SAAS;AAAA,MACR,WAAW,EAAE;AAAA,MACb,UAAU,EAAE;AAAA,MACZ,UAAU,EAAE;AAAA,IACb;AAAA,IACA,YAAY,oBAAI,KAAK;AAAA,IACrB,UAAU,EAAE,UAAU,SAA0B;AAAA,EACjD,EAAE;AACH;AAUA,eAAsB,WACrB,UACA,QACgB;AAChB,MAAI,CAAC,YAAY,OAAO,WAAW,EAAG;AACtC,MAAI;AACH,QAAI,OAAO,WAAW,GAAG;AACxB,YAAM,OAAO,OAAO,CAAC;AACrB,UAAI,CAAC,KAAM;AACX,YAAM,SAAS,QAAQ,IAAI;AAAA,IAC5B,OAAO;AACN,YAAM,SAAS,YAAY,MAAM;AAAA,IAClC;AAAA,EACD,QAAQ;AAGP,YAAQ,KAAK,qCAAqC,OAAO,MAAM,WAAW;AAAA,EAC3E;AACD;;;ACnGO,IAAe,cAAf,MAA4E;AAAA,EAoBjF,YAA+B,YAAmB;AAAnB;AAAA,EAAoB;AAAA,EAApB;AAAA;AAAA;AAAA;AAAA;AAAA,EAfrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhC,SAAS,IAAqC;AAC5C,WAAO,KAAK,WAAW,SAAS,EAAE;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,KAAmC;AAC3C,WAAO,KAAK,WAAW,UAAU,GAAG;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAKA,KAAK,SAAuC;AAC1C,WAAO,KAAK,WAAW,KAAK,OAAO;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAkC;AACtC,WAAO,KAAK,WAAW,MAAM,KAAK;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,IAA8B;AACnC,WAAO,KAAK,WAAW,OAAO,EAAE;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,OAAyB,IAAgC;AACpE,UAAM,SAAS,MAAM,KAAK,WAAW,OAAO,OAAO,EAAE;AAErD,QAAI,KAAK,YAAY,GAAG;AACtB,YAAM,OAAO,eAAe,MAAiC;AAC7D,YAAM,KAAM,OAAmC;AAC/C,YAAM,QAAQ,oBAAoB,KAAK,YAAa,WAAW,IAAI,IAAI;AACvE,WAAK,WAAW,KAAK,UAAU,CAAC,KAAK,CAAC;AAAA,IACxC;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,IAAY,OAAyB,IAAgC;AAEhF,QAAI;AACJ,QAAI,KAAK,YAAY,GAAG;AACtB,YAAM,WAAW,MAAM,KAAK,WAAW,SAAS,EAAE;AAClD,UAAI,UAAU;AACZ,iBAAS,eAAe,QAAmC;AAAA,MAC7D;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,KAAK,WAAW,OAAO,IAAI,OAAO,EAAE;AAEzD,QAAI,KAAK,YAAY,GAAG;AACtB,YAAM,QAAQ,eAAe,MAAiC;AAC9D,YAAM,SAAS;AAAA,QACb,oBAAoB,KAAK,YAAa,WAAW,IAAI,KAAK;AAAA,MAC5D;AAEA,UAAI,QAAQ;AACV,cAAM,UAAU,cAAc,QAAQ,KAAK;AAC3C,YAAI,QAAQ,SAAS,GAAG;AACtB,iBAAO,KAAK,GAAG,kBAAkB,KAAK,YAAa,IAAI,OAAO,CAAC;AAAA,QACjE;AAAA,MACF;AACA,WAAK,WAAW,KAAK,UAAU,MAAM;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,IAAY,IAA6B;AACpD,UAAM,KAAK,WAAW,OAAO,IAAI,EAAE;AAEnC,QAAI,KAAK,YAAY,GAAG;AACtB,YAAM,QAAQ,oBAAoB,KAAK,YAAa,WAAW,EAAE;AACjE,WAAK,WAAW,KAAK,UAAU,CAAC,KAAK,CAAC;AAAA,IACxC;AAAA,EACF;AAAA;AAAA,EAGQ,cAAuB;AAC7B,WAAO;AAAA,MACL,KAAK,uBACL,KAAK,cACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;;;ACtKO,IAAe,wBAAf,cAGG,YAA4B;AAAA;AAAA;AAAA;AAAA,EAIpC,sBAAsB,UAAkB,YAAwC;AAC9E,WAAO,KAAK,WAAW,sBAAsB,UAAU,UAAU;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,UAAsC;AACjD,WAAO,KAAK,WAAW,eAAe,QAAQ;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY,UAAsC;AAChD,WAAO,KAAK,WAAW,sBAAsB,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,QAAiC,gBAAwB,IAAkC;AACtG,WAAO,KAAK,WAAW,WAAW,QAAQ,IAAI,EAAE,eAAe,CAAC;AAAA,EAClE;AACF;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,39 +1,13 @@
1
- // runtime/base-classes/tenant-context.ts
2
- import { AsyncLocalStorage } from "async_hooks";
3
- var als = new AsyncLocalStorage();
4
- function withRequester(ctx, fn) {
5
- return als.run(ctx, fn);
6
- }
7
- function requireRequester() {
8
- const ctx = als.getStore();
9
- if (!ctx) {
10
- throw new Error(
11
- "No requester context active. Wrap the entry point in withRequester({ userId, organizationId }, fn). See tenant-context.ts."
12
- );
13
- }
14
- return ctx;
15
- }
16
- function tryGetRequester() {
17
- return als.getStore();
18
- }
19
- function requireRequesterScope() {
20
- return requireRequester().scope ?? "user";
21
- }
22
- function withUserScope(userId, organizationId, fn) {
23
- return withRequester({ userId, organizationId, scope: "user" }, fn);
24
- }
25
- function withOrgScope(userId, organizationId, orgUserIds, fn) {
26
- return withRequester(
27
- { userId, organizationId, scope: "org", orgUserIds },
28
- fn
29
- );
30
- }
31
- function withSuperuserScope(userId, fn) {
32
- return withRequester(
33
- { userId, organizationId: null, scope: "superuser" },
34
- fn
35
- );
36
- }
1
+ import {
2
+ requireRequester,
3
+ requireRequesterScope,
4
+ tryGetRequester,
5
+ withOrgScope,
6
+ withRequester,
7
+ withSuperuserScope,
8
+ withUserScope
9
+ } from "../../chunk-ZUKFQL6E.js";
10
+ import "../../chunk-2E224ZSN.js";
37
11
  export {
38
12
  requireRequester,
39
13
  requireRequesterScope,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../runtime/base-classes/tenant-context.ts"],"sourcesContent":["/**\n * Ambient requester context — AsyncLocalStorage-backed tenant scope.\n *\n * The alternative to threading `userId`/`organizationId` through every\n * repository/service signature. Set ONCE at each boundary the generated app\n * owns, read implicitly inside `BaseRepository` (see `scopePredicate`).\n *\n * ## Where to set it (boundaries)\n *\n * - HTTP / tRPC handlers — from the authenticated `ctx.user`\n * - OAuth callback controllers — from the authenticated session\n * - Queue/worker `process()` — from the job's owning user after the\n * job's record is loaded\n *\n * Each boundary wraps the rest of the request in `withRequester({ userId,\n * organizationId }, () => ...)`. The context propagates through every `await`\n * to all downstream repo/service calls without being passed explicitly.\n *\n * ## Where to read it\n *\n * - `BaseRepository.scopePredicate()` reads it (via `tryGetRequester` in\n * lenient mode, `requireRequester` in strict mode) and filters every read\n * by the ambient scope when the repo declares `userTracking: true`.\n *\n * ## Why AsyncLocalStorage over an explicit parameter\n *\n * Threading `userId` (and later `organizationId`) through dozens of method\n * signatures is pure parameter pollution. Ambient context also lets a repo\n * make the \"I forgot to scope\" mistake impossible at runtime: in strict mode\n * `requireRequester()` throws when no context is active, surfacing a missing\n * boundary call loudly rather than silently leaking cross-tenant data.\n *\n * ## Not-found semantics\n *\n * When a row exists but belongs to a different requester, scoped reads return\n * `null`/`[]` — identical to \"truly doesn't exist\". No existence oracle;\n * callers throw NotFound uniformly. Standard security practice.\n *\n * ## Testing\n *\n * Tests that exercise scoped repos must wrap the call in `withRequester(...)`.\n * In strict mode an unwrapped call hitting `requireRequester()` throws — by\n * design. In lenient mode (the default) an unwrapped call is simply unscoped.\n */\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\n/**\n * Data-visibility scope. The auth layer decides which scope a request is\n * allowed to claim; the repo trusts whatever the ambient context says.\n *\n * - `'user'`: filter every read by `user_id = ctx.userId`. Default.\n * - `'org'`: filter every read by membership in the requester's org, resolved\n * via `user_id IN (ctx.orgUserIds)` rather than via a per-entity\n * `organization_id` column. Works for every user-owned table and keeps repos\n * single-table — the org member list is pre-resolved at the boundary.\n * - `'superuser'`: no scope filter. Engineering / internal-tools only.\n *\n * AUTHORIZATION (who is allowed to claim each scope) lives in boundary\n * middleware, not in the repo. The repo trusts the ambient context — same\n * trust model as a threaded `userId`.\n */\nexport type RequesterScope = 'user' | 'org' | 'superuser';\n\nexport interface RequesterContext {\n /**\n * The user making the request. Always present — even in `'org'` and\n * `'superuser'` scopes it is the audit-trail \"who actually did this\".\n */\n readonly userId: string;\n /**\n * The organization the requester belongs to. Required when\n * `scope === 'org'`; may be null for `'user'` (users with no org) and for\n * `'superuser'` (cross-org reads).\n */\n readonly organizationId: string | null;\n /**\n * Data-visibility scope. Defaults to `'user'` when omitted.\n */\n readonly scope?: RequesterScope;\n /**\n * For `scope === 'org'`: the list of user IDs in the requester's org,\n * pre-resolved by the boundary middleware that established the `'org'`\n * scope (one `SELECT users.id WHERE organization_id = X` at the trust\n * boundary). Repos use this as a literal `IN (...)` filter — they never\n * JOIN to `users` themselves. Required when `scope === 'org'`.\n */\n readonly orgUserIds?: readonly string[];\n}\n\nconst als = new AsyncLocalStorage<RequesterContext>();\n\n/**\n * Set the ambient requester context for the duration of `fn`. The context\n * propagates through `await` boundaries to all downstream calls. Nesting is\n * fine — an inner `withRequester` overrides the outer for its callback.\n */\nexport function withRequester<T>(\n ctx: RequesterContext,\n fn: () => Promise<T>,\n): Promise<T> {\n return als.run(ctx, fn);\n}\n\n/**\n * Read the ambient requester context. Throws if no context is active — by\n * design. Used by repos in strict scope-enforcement mode; an unwrapped call\n * site is a missing boundary.\n */\nexport function requireRequester(): RequesterContext {\n const ctx = als.getStore();\n if (!ctx) {\n throw new Error(\n 'No requester context active. Wrap the entry point in ' +\n 'withRequester({ userId, organizationId }, fn). See tenant-context.ts.',\n );\n }\n return ctx;\n}\n\n/**\n * Read the ambient requester context without throwing. Returns `undefined`\n * when no context is active. Used by repos in lenient scope-enforcement mode\n * (the default) and by code paths that legitimately run outside a request.\n */\nexport function tryGetRequester(): RequesterContext | undefined {\n return als.getStore();\n}\n\n/**\n * Resolve the effective scope for the ambient context, defaulting to `'user'`.\n */\nexport function requireRequesterScope(): RequesterScope {\n return requireRequester().scope ?? 'user';\n}\n\n/**\n * Convenience helpers for setting scope explicitly. All three preserve\n * `userId` in the context (audit trail) regardless of scope.\n *\n * - `withUserScope`: regular end-user requests. Most call sites.\n * - `withOrgScope`: admin / org-shared resource access. The caller MUST verify\n * the requester's role permits `'org'` before calling — the helper does not\n * enforce authorization. `orgUserIds` is pre-resolved at the boundary.\n * - `withSuperuserScope`: engineering scripts / internal tools. `organizationId`\n * is null (cross-org is the point). Same authorization caveat applies.\n */\nexport function withUserScope<T>(\n userId: string,\n organizationId: string | null,\n fn: () => Promise<T>,\n): Promise<T> {\n return withRequester({ userId, organizationId, scope: 'user' }, fn);\n}\n\nexport function withOrgScope<T>(\n userId: string,\n organizationId: string,\n orgUserIds: readonly string[],\n fn: () => Promise<T>,\n): Promise<T> {\n return withRequester(\n { userId, organizationId, scope: 'org', orgUserIds },\n fn,\n );\n}\n\nexport function withSuperuserScope<T>(\n userId: string,\n fn: () => Promise<T>,\n): Promise<T> {\n return withRequester(\n { userId, organizationId: null, scope: 'superuser' },\n fn,\n );\n}\n"],"mappings":";AA4CA,SAAS,yBAAyB;AA6ClC,IAAM,MAAM,IAAI,kBAAoC;AAO7C,SAAS,cACd,KACA,IACY;AACZ,SAAO,IAAI,IAAI,KAAK,EAAE;AACxB;AAOO,SAAS,mBAAqC;AACnD,QAAM,MAAM,IAAI,SAAS;AACzB,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,kBAAgD;AAC9D,SAAO,IAAI,SAAS;AACtB;AAKO,SAAS,wBAAwC;AACtD,SAAO,iBAAiB,EAAE,SAAS;AACrC;AAaO,SAAS,cACd,QACA,gBACA,IACY;AACZ,SAAO,cAAc,EAAE,QAAQ,gBAAgB,OAAO,OAAO,GAAG,EAAE;AACpE;AAEO,SAAS,aACd,QACA,gBACA,YACA,IACY;AACZ,SAAO;AAAA,IACL,EAAE,QAAQ,gBAAgB,OAAO,OAAO,WAAW;AAAA,IACnD;AAAA,EACF;AACF;AAEO,SAAS,mBACd,QACA,IACY;AACZ,SAAO;AAAA,IACL,EAAE,QAAQ,gBAAgB,MAAM,OAAO,YAAY;AAAA,IACnD;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +1,7 @@
1
- // runtime/base-classes/with-analytics.ts
2
- function WithAnalytics(Base) {
3
- class WithAnalyticsMixin extends Base {
4
- analytics;
5
- }
6
- return WithAnalyticsMixin;
7
- }
1
+ import {
2
+ WithAnalytics
3
+ } from "../../chunk-IBGER4YK.js";
4
+ import "../../chunk-2E224ZSN.js";
8
5
  export {
9
6
  WithAnalytics
10
7
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../runtime/base-classes/with-analytics.ts"],"sourcesContent":["/**\n * WithAnalytics mixin\n *\n * Adds an optional `.analytics` property to the service class.\n * The analytics provider is a per-entity @Injectable (e.g., AccountAnalytics)\n * injected via @Optional() in the generated service constructor.\n *\n * Usage: class MyService extends WithAnalytics(BaseService<...>) { ... }\n *\n * The generated service adds:\n * @Optional() @Inject(AccountAnalytics) override analytics?: AccountAnalytics\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport function WithAnalytics<TBase extends Constructor>(Base: TBase) {\n abstract class WithAnalyticsMixin extends Base {\n analytics?: any;\n }\n return WithAnalyticsMixin as TBase & typeof WithAnalyticsMixin;\n}\n"],"mappings":";AAgBO,SAAS,cAAyC,MAAa;AAAA,EACpE,MAAe,2BAA2B,KAAK;AAAA,IAC7C;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,8 @@
1
- // runtime/constants/tokens.ts
2
- var DRIZZLE = "DRIZZLE";
3
- var EVENT_BUS = "EVENT_BUS";
1
+ import {
2
+ DRIZZLE,
3
+ EVENT_BUS
4
+ } from "../../chunk-U64T4YZE.js";
5
+ import "../../chunk-2E224ZSN.js";
4
6
  export {
5
7
  DRIZZLE,
6
8
  EVENT_BUS
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../runtime/constants/tokens.ts"],"sourcesContent":["/**\n * NestJS injection tokens\n *\n * Used with @Inject() decorator in concrete repository constructors.\n */\n\n/**\n * Injection token for the Drizzle ORM database client.\n *\n * Usage in concrete repositories:\n * ```typescript\n * constructor(@Inject(DRIZZLE) db: DrizzleClient) { super(db); }\n * ```\n */\nexport const DRIZZLE = 'DRIZZLE' as const;\n\n/**\n * Injection token for the event bus (IEventBus).\n *\n * Optional — only resolved when EventsModule.forRoot() is registered.\n * BaseService uses this with @Optional() to emit lifecycle events\n * without requiring the events subsystem to be installed.\n *\n * Usage in services/use cases:\n * ```typescript\n * @Optional() @Inject(EVENT_BUS) eventBus?: IEventBus\n * ```\n */\nexport const EVENT_BUS = 'EVENT_BUS' as const;\n"],"mappings":";AAcO,IAAM,UAAU;AAchB,IAAM,YAAY;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1,5 @@
1
+ import "../chunk-2E224ZSN.js";
2
+
1
3
  // runtime/eav-helpers.ts
2
4
  function toEavRows(entityId, entityType, userId, fields, fieldDefIds) {
3
5
  const rows = [];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../runtime/eav-helpers.ts"],"sourcesContent":["/**\n * EAV helpers\n *\n * Small, pure utilities used by services that dual-write to the EAV value\n * table alongside their own table.\n *\n * - `toEavRows` builds value-table insert rows from a flat `{ key: value }`\n * bag, resolving the `fieldDefinitionId` via a caller-supplied map.\n * Callers own the field-definitions lookup / cache.\n * - `mergeEavRows` inverts: given value-table rows + a definition `id -> key`\n * map, collapses them into a flat `{ key: value }` bag.\n *\n * Both are sync + allocation-light. They do not touch the DB.\n */\n\n/**\n * Map of field key -> field_definitions.id, scoped to a single entityType.\n */\nexport type FieldDefinitionIdMap = ReadonlyMap<string, string>;\n\n/**\n * Minimal shape of a value-table row accepted by toEavRows output. Consumers\n * pass their entity's `Insert` type; these are the columns the helper sets.\n */\nexport interface EavInsertShape {\n entityId: string;\n entityType: string;\n userId: string;\n fieldDefinitionId: string;\n value: unknown;\n}\n\n/**\n * Build value-table insert rows from a flat field bag. Keys present in\n * `fields` but missing from `fieldDefIds` are skipped — caller is expected\n * to ensure the definitions exist (first-cut; auto-create is a later step).\n */\nexport function toEavRows(\n entityId: string,\n entityType: string,\n userId: string,\n fields: Record<string, unknown>,\n fieldDefIds: FieldDefinitionIdMap,\n): EavInsertShape[] {\n const rows: EavInsertShape[] = [];\n for (const [key, value] of Object.entries(fields)) {\n const fieldDefinitionId = fieldDefIds.get(key);\n if (!fieldDefinitionId) continue;\n rows.push({ entityId, entityType, userId, fieldDefinitionId, value });\n }\n return rows;\n}\n\n/**\n * Collapse EAV rows back into a flat `{ key: value }` bag.\n *\n * Accepts bare value-table rows plus a separate `id -> { key }` map. Later\n * rows win if the same key appears more than once. Call with temporal\n * filtering already applied (e.g. validTo IS NULL) — this function does not\n * interpret validFrom / validTo.\n */\nexport function mergeEavRows(\n rows: Array<{ fieldDefinitionId: string | null; value: unknown }>,\n defsById: ReadonlyMap<string, { key: string }>,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const row of rows) {\n if (!row.fieldDefinitionId) continue;\n const def = defsById.get(row.fieldDefinitionId);\n if (!def) continue;\n out[def.key] = row.value;\n }\n return out;\n}\n"],"mappings":";AAqCO,SAAS,UACd,UACA,YACA,QACA,QACA,aACkB;AAClB,QAAM,OAAyB,CAAC;AAChC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,UAAM,oBAAoB,YAAY,IAAI,GAAG;AAC7C,QAAI,CAAC,kBAAmB;AACxB,SAAK,KAAK,EAAE,UAAU,YAAY,QAAQ,mBAAmB,MAAM,CAAC;AAAA,EACtE;AACA,SAAO;AACT;AAUO,SAAS,aACd,MACA,UACyB;AACzB,QAAM,MAA+B,CAAC;AACtC,aAAW,OAAO,MAAM;AACtB,QAAI,CAAC,IAAI,kBAAmB;AAC5B,UAAM,MAAM,SAAS,IAAI,IAAI,iBAAiB;AAC9C,QAAI,CAAC,IAAK;AACV,QAAI,IAAI,GAAG,IAAI,IAAI;AAAA,EACrB;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../runtime/eav-helpers.ts"],"sourcesContent":["/**\n * EAV helpers\n *\n * Small, pure utilities used by services that dual-write to the EAV value\n * table alongside their own table.\n *\n * - `toEavRows` builds value-table insert rows from a flat `{ key: value }`\n * bag, resolving the `fieldDefinitionId` via a caller-supplied map.\n * Callers own the field-definitions lookup / cache.\n * - `mergeEavRows` inverts: given value-table rows + a definition `id -> key`\n * map, collapses them into a flat `{ key: value }` bag.\n *\n * Both are sync + allocation-light. They do not touch the DB.\n */\n\n/**\n * Map of field key -> field_definitions.id, scoped to a single entityType.\n */\nexport type FieldDefinitionIdMap = ReadonlyMap<string, string>;\n\n/**\n * Minimal shape of a value-table row accepted by toEavRows output. Consumers\n * pass their entity's `Insert` type; these are the columns the helper sets.\n */\nexport interface EavInsertShape {\n entityId: string;\n entityType: string;\n userId: string;\n fieldDefinitionId: string;\n value: unknown;\n}\n\n/**\n * Build value-table insert rows from a flat field bag. Keys present in\n * `fields` but missing from `fieldDefIds` are skipped — caller is expected\n * to ensure the definitions exist (first-cut; auto-create is a later step).\n */\nexport function toEavRows(\n entityId: string,\n entityType: string,\n userId: string,\n fields: Record<string, unknown>,\n fieldDefIds: FieldDefinitionIdMap,\n): EavInsertShape[] {\n const rows: EavInsertShape[] = [];\n for (const [key, value] of Object.entries(fields)) {\n const fieldDefinitionId = fieldDefIds.get(key);\n if (!fieldDefinitionId) continue;\n rows.push({ entityId, entityType, userId, fieldDefinitionId, value });\n }\n return rows;\n}\n\n/**\n * Collapse EAV rows back into a flat `{ key: value }` bag.\n *\n * Accepts bare value-table rows plus a separate `id -> { key }` map. Later\n * rows win if the same key appears more than once. Call with temporal\n * filtering already applied (e.g. validTo IS NULL) — this function does not\n * interpret validFrom / validTo.\n */\nexport function mergeEavRows(\n rows: Array<{ fieldDefinitionId: string | null; value: unknown }>,\n defsById: ReadonlyMap<string, { key: string }>,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const row of rows) {\n if (!row.fieldDefinitionId) continue;\n const def = defsById.get(row.fieldDefinitionId);\n if (!def) continue;\n out[def.key] = row.value;\n }\n return out;\n}\n"],"mappings":";;;AAqCO,SAAS,UACd,UACA,YACA,QACA,QACA,aACkB;AAClB,QAAM,OAAyB,CAAC;AAChC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,UAAM,oBAAoB,YAAY,IAAI,GAAG;AAC7C,QAAI,CAAC,kBAAmB;AACxB,SAAK,KAAK,EAAE,UAAU,YAAY,QAAQ,mBAAmB,MAAM,CAAC;AAAA,EACtE;AACA,SAAO;AACT;AAUO,SAAS,aACd,MACA,UACyB;AACzB,QAAM,MAA+B,CAAC;AACtC,aAAW,OAAO,MAAM;AACtB,QAAI,CAAC,IAAI,kBAAmB;AAC5B,UAAM,MAAM,SAAS,IAAI,IAAI,iBAAiB;AAC9C,QAAI,CAAC,IAAK;AACV,QAAI,IAAI,GAAG,IAAI,IAAI;AAAA,EACrB;AACA,SAAO;AACT;","names":[]}
@@ -1,13 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
9
- return result;
10
- };
1
+ import {
2
+ __decorateClass
3
+ } from "../../chunk-2E224ZSN.js";
11
4
 
12
5
  // runtime/pipes/zod-validation.pipe.ts
13
6
  import {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../runtime/pipes/zod-validation.pipe.ts"],"sourcesContent":["/**\n * ZodValidationPipe\n *\n * Validates an incoming request body (or any decorated value) against a\n * Zod schema at the controller boundary. Intended for use with Nest's\n * `@Body(new ZodValidationPipe(MySchema))` pattern so generated\n * controllers get runtime validation without relying on a global pipe\n * that every consumer would have to opt into.\n *\n * Why a pipe (vs. validating inside the use case): validation is a\n * presentation-layer concern (ADR-003). The use case should receive a\n * type-safe, already-validated DTO; surfacing a `ZodError` at the pipe\n * stage produces the standard 400 BadRequest response shape that HTTP\n * clients expect.\n *\n * On success: returns parsed, coerced data.\n * On failure: throws BadRequestException with a structured `issues` array\n * (path / code / message) — richer than `.flatten()` for API consumers.\n *\n * One pipe instance per route (cheap — instantiated at module load). Keeps\n * validation explicit in the generated code; no metadata/reflection magic.\n *\n * Vendored into consumer projects at `src/shared/pipes/zod-validation.pipe.ts`\n * via `codegen project init` (see init-scaffold's VENDORED_RUNTIME_FILES).\n */\nimport {\n BadRequestException,\n Injectable,\n PipeTransform,\n type ArgumentMetadata,\n} from '@nestjs/common';\nimport type { ZodIssue, ZodSchema } from 'zod';\n\n@Injectable()\nexport class ZodValidationPipe<TSchema extends ZodSchema = ZodSchema>\n implements PipeTransform\n{\n constructor(private readonly schema: TSchema) {}\n\n transform(value: unknown, _metadata: ArgumentMetadata): unknown {\n const result = this.schema.safeParse(value);\n if (result.success) {\n return result.data;\n }\n throw new BadRequestException({\n statusCode: 400,\n error: 'Bad Request',\n message: 'Validation failed',\n issues: formatIssues(result.error.issues),\n });\n }\n}\n\nfunction formatIssues(issues: readonly ZodIssue[]): Array<{\n path: string;\n code: string;\n message: string;\n}> {\n return issues.map((issue) => ({\n path: issue.path.join('.'),\n code: issue.code,\n message: issue.message,\n }));\n}\n"],"mappings":";;;;;;;;;;;;AAyBA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAIA,IAAM,oBAAN,MAEP;AAAA,EACE,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA,EAAlB;AAAA,EAE7B,UAAU,OAAgB,WAAsC;AAC9D,UAAM,SAAS,KAAK,OAAO,UAAU,KAAK;AAC1C,QAAI,OAAO,SAAS;AAClB,aAAO,OAAO;AAAA,IAChB;AACA,UAAM,IAAI,oBAAoB;AAAA,MAC5B,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,QAAQ,aAAa,OAAO,MAAM,MAAM;AAAA,IAC1C,CAAC;AAAA,EACH;AACF;AAjBa,oBAAN;AAAA,EADN,WAAW;AAAA,GACC;AAmBb,SAAS,aAAa,QAInB;AACD,SAAO,OAAO,IAAI,CAAC,WAAW;AAAA,IAC5B,MAAM,MAAM,KAAK,KAAK,GAAG;AAAA,IACzB,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,EACjB,EAAE;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../runtime/pipes/zod-validation.pipe.ts"],"sourcesContent":["/**\n * ZodValidationPipe\n *\n * Validates an incoming request body (or any decorated value) against a\n * Zod schema at the controller boundary. Intended for use with Nest's\n * `@Body(new ZodValidationPipe(MySchema))` pattern so generated\n * controllers get runtime validation without relying on a global pipe\n * that every consumer would have to opt into.\n *\n * Why a pipe (vs. validating inside the use case): validation is a\n * presentation-layer concern (ADR-003). The use case should receive a\n * type-safe, already-validated DTO; surfacing a `ZodError` at the pipe\n * stage produces the standard 400 BadRequest response shape that HTTP\n * clients expect.\n *\n * On success: returns parsed, coerced data.\n * On failure: throws BadRequestException with a structured `issues` array\n * (path / code / message) — richer than `.flatten()` for API consumers.\n *\n * One pipe instance per route (cheap — instantiated at module load). Keeps\n * validation explicit in the generated code; no metadata/reflection magic.\n *\n * Vendored into consumer projects at `src/shared/pipes/zod-validation.pipe.ts`\n * via `codegen project init` (see init-scaffold's VENDORED_RUNTIME_FILES).\n */\nimport {\n BadRequestException,\n Injectable,\n PipeTransform,\n type ArgumentMetadata,\n} from '@nestjs/common';\nimport type { ZodIssue, ZodSchema } from 'zod';\n\n@Injectable()\nexport class ZodValidationPipe<TSchema extends ZodSchema = ZodSchema>\n implements PipeTransform\n{\n constructor(private readonly schema: TSchema) {}\n\n transform(value: unknown, _metadata: ArgumentMetadata): unknown {\n const result = this.schema.safeParse(value);\n if (result.success) {\n return result.data;\n }\n throw new BadRequestException({\n statusCode: 400,\n error: 'Bad Request',\n message: 'Validation failed',\n issues: formatIssues(result.error.issues),\n });\n }\n}\n\nfunction formatIssues(issues: readonly ZodIssue[]): Array<{\n path: string;\n code: string;\n message: string;\n}> {\n return issues.map((issue) => ({\n path: issue.path.join('.'),\n code: issue.code,\n message: issue.message,\n }));\n}\n"],"mappings":";;;;;AAyBA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAIA,IAAM,oBAAN,MAEP;AAAA,EACE,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA,EAAlB;AAAA,EAE7B,UAAU,OAAgB,WAAsC;AAC9D,UAAM,SAAS,KAAK,OAAO,UAAU,KAAK;AAC1C,QAAI,OAAO,SAAS;AAClB,aAAO,OAAO;AAAA,IAChB;AACA,UAAM,IAAI,oBAAoB;AAAA,MAC5B,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,QAAQ,aAAa,OAAO,MAAM,MAAM;AAAA,IAC1C,CAAC;AAAA,EACH;AACF;AAjBa,oBAAN;AAAA,EADN,WAAW;AAAA,GACC;AAmBb,SAAS,aAAa,QAInB;AACD,SAAO,OAAO,IAAI,CAAC,WAAW;AAAA,IAC5B,MAAM,MAAM,KAAK,KAAK,GAAG;AAAA,IACzB,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,EACjB,EAAE;AACJ;","names":[]}
@@ -1,11 +1,8 @@
1
- // runtime/shared/openapi/error-response.dto.ts
2
- import { z } from "zod";
3
- var errorResponseSchema = z.object({
4
- statusCode: z.number().int(),
5
- message: z.union([z.string(), z.array(z.string())]),
6
- error: z.string().optional()
7
- });
8
- var ERROR_RESPONSE_SCHEMA_NAME = "ErrorResponseDto";
1
+ import {
2
+ ERROR_RESPONSE_SCHEMA_NAME,
3
+ errorResponseSchema
4
+ } from "../../../chunk-SOVM2VEK.js";
5
+ import "../../../chunk-2E224ZSN.js";
9
6
  export {
10
7
  ERROR_RESPONSE_SCHEMA_NAME,
11
8
  errorResponseSchema
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../runtime/shared/openapi/error-response.dto.ts"],"sourcesContent":["/**\n * Shared error response schema (OPENAPI-3).\n *\n * Generated controllers `@ApiResponse(...)` decorators reference this\n * schema by `$ref` (name `ErrorResponseDto`) for non-success status codes\n * (400, 401, 404, etc.). Shape matches NestJS's default `HttpException`\n * JSON body — see `packages/common/src/exceptions/http.exception.ts`.\n *\n * The registry auto-registers this schema on construction so every\n * consumer project exposes `components.schemas.ErrorResponseDto` on\n * `/docs-json` without per-entity duplication.\n */\nimport { z } from 'zod';\n\nexport const errorResponseSchema = z.object({\n statusCode: z.number().int(),\n message: z.union([z.string(), z.array(z.string())]),\n error: z.string().optional(),\n});\n\nexport type ErrorResponseDto = z.infer<typeof errorResponseSchema>;\n\n/** Canonical name used across `$ref` URIs in generated controllers. */\nexport const ERROR_RESPONSE_SCHEMA_NAME = 'ErrorResponseDto';\n"],"mappings":";AAYA,SAAS,SAAS;AAEX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,YAAY,EAAE,OAAO,EAAE,IAAI;AAAA,EAC3B,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,EAClD,OAAO,EAAE,OAAO,EAAE,SAAS;AAC7B,CAAC;AAKM,IAAM,6BAA6B;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,22 +1,8 @@
1
- // runtime/shared/openapi/errors.ts
2
- var OpenApiPeerDepMissingError = class extends Error {
3
- name = "OpenApiPeerDepMissingError";
4
- constructor(message) {
5
- super(
6
- message ?? "OpenApiRegistry requires @anatine/zod-openapi. Install it: bun add @anatine/zod-openapi"
7
- );
8
- }
9
- };
10
- var DuplicateSchemaError = class extends Error {
11
- constructor(schemaName) {
12
- super(
13
- `DuplicateSchemaError: schema '${schemaName}' is already registered. Each schema name must be unique within the OpenApiRegistry.`
14
- );
15
- this.schemaName = schemaName;
16
- }
17
- schemaName;
18
- name = "DuplicateSchemaError";
19
- };
1
+ import {
2
+ DuplicateSchemaError,
3
+ OpenApiPeerDepMissingError
4
+ } from "../../../chunk-YSLTTQLC.js";
5
+ import "../../../chunk-2E224ZSN.js";
20
6
  export {
21
7
  DuplicateSchemaError,
22
8
  OpenApiPeerDepMissingError
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../runtime/shared/openapi/errors.ts"],"sourcesContent":["/**\n * Typed errors for the OpenAPI registry (OPENAPI-1).\n *\n * Same shape as `runtime/subsystems/bridge/bridge-errors.ts` so consumers\n * can catch them with the same exception-filter pattern used elsewhere.\n */\n\n/**\n * Thrown by `OpenApiRegistry.build()` when `@anatine/zod-openapi` is not\n * resolvable. The peer is declared optional (`peerDependenciesMeta`) so\n * consumer apps that don't care about OpenAPI still boot; the cost is a\n * deferred failure here on first `build()`.\n */\nexport class OpenApiPeerDepMissingError extends Error {\n override readonly name = 'OpenApiPeerDepMissingError';\n constructor(message?: string) {\n super(\n message ??\n 'OpenApiRegistry requires @anatine/zod-openapi. Install it: bun add @anatine/zod-openapi',\n );\n }\n}\n\n/**\n * Thrown by `OpenApiRegistry.registerSchema(name, ...)` when `name` is\n * already registered. Silent overwrite would make debugging\n * double-registration bugs (e.g. two entity pipelines both emitting a\n * `User` DTO) painful; loud failure lets the mismatch surface at module\n * init where the stack trace is clear.\n */\nexport class DuplicateSchemaError extends Error {\n override readonly name = 'DuplicateSchemaError';\n constructor(public readonly schemaName: string) {\n super(\n `DuplicateSchemaError: schema '${schemaName}' is already registered. ` +\n `Each schema name must be unique within the OpenApiRegistry.`,\n );\n }\n}\n"],"mappings":";AAaO,IAAM,6BAAN,cAAyC,MAAM;AAAA,EAClC,OAAO;AAAA,EACzB,YAAY,SAAkB;AAC5B;AAAA,MACE,WACE;AAAA,IACJ;AAAA,EACF;AACF;AASO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAE9C,YAA4B,YAAoB;AAC9C;AAAA,MACE,iCAAiC,UAAU;AAAA,IAE7C;AAJ0B;AAAA,EAK5B;AAAA,EAL4B;AAAA,EADV,OAAO;AAO3B;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,109 +1,18 @@
1
- // runtime/shared/openapi/error-response.dto.ts
2
- import { z } from "zod";
3
- var errorResponseSchema = z.object({
4
- statusCode: z.number().int(),
5
- message: z.union([z.string(), z.array(z.string())]),
6
- error: z.string().optional()
7
- });
8
- var ERROR_RESPONSE_SCHEMA_NAME = "ErrorResponseDto";
9
-
10
- // runtime/shared/openapi/errors.ts
11
- var OpenApiPeerDepMissingError = class extends Error {
12
- name = "OpenApiPeerDepMissingError";
13
- constructor(message) {
14
- super(
15
- message ?? "OpenApiRegistry requires @anatine/zod-openapi. Install it: bun add @anatine/zod-openapi"
16
- );
17
- }
18
- };
19
- var DuplicateSchemaError = class extends Error {
20
- constructor(schemaName) {
21
- super(
22
- `DuplicateSchemaError: schema '${schemaName}' is already registered. Each schema name must be unique within the OpenApiRegistry.`
23
- );
24
- this.schemaName = schemaName;
25
- }
26
- schemaName;
27
- name = "DuplicateSchemaError";
28
- };
29
-
30
- // runtime/shared/openapi/registry.ts
31
- var OpenApiRegistry = class {
32
- zodSchemas = /* @__PURE__ */ new Map();
33
- pathEntries = /* @__PURE__ */ new Map();
34
- peer = null;
35
- constructor() {
36
- this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);
37
- }
38
- registerSchema(name, schema) {
39
- if (this.zodSchemas.has(name)) {
40
- throw new DuplicateSchemaError(name);
41
- }
42
- this.zodSchemas.set(name, schema);
43
- }
44
- registerPath(path, method, spec) {
45
- let methods = this.pathEntries.get(path);
46
- if (!methods) {
47
- methods = /* @__PURE__ */ new Map();
48
- this.pathEntries.set(path, methods);
49
- }
50
- methods.set(method, spec);
51
- }
52
- /**
53
- * Emit the full OpenAPI document. Lazy-imports `@anatine/zod-openapi`
54
- * on first call; failure to resolve raises `OpenApiPeerDepMissingError`
55
- * (matches the `CubeAnalyticsBackend.onModuleInit` precedent).
56
- *
57
- * OpenAPI version is pinned to `3.0.3` — Swagger UI tooling is most
58
- * stable on 3.0.x (see OPENAPI-PHASE-1-PLAN §Four locked decisions).
59
- */
60
- async build(info) {
61
- const peer = await this.loadPeer();
62
- const schemas = {};
63
- for (const [name, zodSchema] of this.zodSchemas) {
64
- schemas[name] = peer.generateSchema(zodSchema, false, "3.0");
65
- }
66
- const paths = {};
67
- for (const [path, methods] of this.pathEntries) {
68
- const methodMap = {};
69
- for (const [method, spec] of methods) {
70
- methodMap[method] = spec;
71
- }
72
- paths[path] = methodMap;
73
- }
74
- return {
75
- openapi: "3.0.3",
76
- info,
77
- paths,
78
- components: { schemas }
79
- };
80
- }
81
- /**
82
- * Test helper — clears registered schemas and paths, then re-seeds the
83
- * core `ErrorResponseDto` entry so post-reset state matches the
84
- * invariant established in the constructor.
85
- */
86
- reset() {
87
- this.zodSchemas.clear();
88
- this.pathEntries.clear();
89
- this.peer = null;
90
- this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);
91
- }
92
- async loadPeer() {
93
- if (this.peer) return this.peer;
94
- try {
95
- const specifier = "@anatine/zod-openapi";
96
- const mod = await import(specifier);
97
- this.peer = mod;
98
- return mod;
99
- } catch {
100
- throw new OpenApiPeerDepMissingError();
101
- }
102
- }
103
- };
104
-
105
- // runtime/shared/openapi/registry.tokens.ts
106
- var OPENAPI_REGISTRY = "OPENAPI_REGISTRY";
1
+ import {
2
+ OPENAPI_REGISTRY
3
+ } from "../../../chunk-PSXUNOVU.js";
4
+ import {
5
+ OpenApiRegistry
6
+ } from "../../../chunk-Y7GDG744.js";
7
+ import {
8
+ ERROR_RESPONSE_SCHEMA_NAME,
9
+ errorResponseSchema
10
+ } from "../../../chunk-SOVM2VEK.js";
11
+ import {
12
+ DuplicateSchemaError,
13
+ OpenApiPeerDepMissingError
14
+ } from "../../../chunk-YSLTTQLC.js";
15
+ import "../../../chunk-2E224ZSN.js";
107
16
  export {
108
17
  DuplicateSchemaError,
109
18
  ERROR_RESPONSE_SCHEMA_NAME,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../runtime/shared/openapi/error-response.dto.ts","../../../../runtime/shared/openapi/errors.ts","../../../../runtime/shared/openapi/registry.ts","../../../../runtime/shared/openapi/registry.tokens.ts"],"sourcesContent":["/**\n * Shared error response schema (OPENAPI-3).\n *\n * Generated controllers `@ApiResponse(...)` decorators reference this\n * schema by `$ref` (name `ErrorResponseDto`) for non-success status codes\n * (400, 401, 404, etc.). Shape matches NestJS's default `HttpException`\n * JSON body — see `packages/common/src/exceptions/http.exception.ts`.\n *\n * The registry auto-registers this schema on construction so every\n * consumer project exposes `components.schemas.ErrorResponseDto` on\n * `/docs-json` without per-entity duplication.\n */\nimport { z } from 'zod';\n\nexport const errorResponseSchema = z.object({\n statusCode: z.number().int(),\n message: z.union([z.string(), z.array(z.string())]),\n error: z.string().optional(),\n});\n\nexport type ErrorResponseDto = z.infer<typeof errorResponseSchema>;\n\n/** Canonical name used across `$ref` URIs in generated controllers. */\nexport const ERROR_RESPONSE_SCHEMA_NAME = 'ErrorResponseDto';\n","/**\n * Typed errors for the OpenAPI registry (OPENAPI-1).\n *\n * Same shape as `runtime/subsystems/bridge/bridge-errors.ts` so consumers\n * can catch them with the same exception-filter pattern used elsewhere.\n */\n\n/**\n * Thrown by `OpenApiRegistry.build()` when `@anatine/zod-openapi` is not\n * resolvable. The peer is declared optional (`peerDependenciesMeta`) so\n * consumer apps that don't care about OpenAPI still boot; the cost is a\n * deferred failure here on first `build()`.\n */\nexport class OpenApiPeerDepMissingError extends Error {\n override readonly name = 'OpenApiPeerDepMissingError';\n constructor(message?: string) {\n super(\n message ??\n 'OpenApiRegistry requires @anatine/zod-openapi. Install it: bun add @anatine/zod-openapi',\n );\n }\n}\n\n/**\n * Thrown by `OpenApiRegistry.registerSchema(name, ...)` when `name` is\n * already registered. Silent overwrite would make debugging\n * double-registration bugs (e.g. two entity pipelines both emitting a\n * `User` DTO) painful; loud failure lets the mismatch surface at module\n * init where the stack trace is clear.\n */\nexport class DuplicateSchemaError extends Error {\n override readonly name = 'DuplicateSchemaError';\n constructor(public readonly schemaName: string) {\n super(\n `DuplicateSchemaError: schema '${schemaName}' is already registered. ` +\n `Each schema name must be unique within the OpenApiRegistry.`,\n );\n }\n}\n","/**\n * OpenApiRegistry — collects Zod schemas and path specs, emits a\n * complete `OpenAPIObject` on `build()` (OPENAPI-1).\n *\n * Wraps `@anatine/zod-openapi` as an **optional peer dependency** using\n * the lazy-import pattern from `runtime/subsystems/analytics/cube-backend.ts`\n * — consumer apps that never call `build()` still boot even if\n * `@anatine/zod-openapi` isn't installed.\n *\n * The registry is the single source of truth consumed by OPENAPI-2\n * (generated DTOs register their Zod schemas at module init), OPENAPI-3\n * (controller decorators reference those schemas), and OPENAPI-4\n * (Swagger UI bootstrap calls `build()` once at startup).\n */\nimport type { z } from 'zod';\n\nimport { ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema } from './error-response.dto';\nimport { OpenApiPeerDepMissingError, DuplicateSchemaError } from './errors';\n\nexport type HttpMethod = 'get' | 'post' | 'patch' | 'delete' | 'put';\n\n/**\n * OpenAPI path spec. Structurally compatible with `openapi3-ts`'s\n * `OperationObject` but typed loosely here because the peer type package\n * isn't installed as a direct dep — consumers supply whatever their\n * codegen emits.\n */\nexport interface PathSpec {\n summary?: string;\n description?: string;\n operationId?: string;\n tags?: string[];\n parameters?: unknown[];\n requestBody?: unknown;\n responses?: Record<string, unknown>;\n security?: unknown[];\n [key: string]: unknown;\n}\n\nexport interface OpenAPIInfo {\n title: string;\n version: string;\n description?: string;\n}\n\n/**\n * Minimal OpenAPIObject shape. We redeclare rather than pull\n * `openapi3-ts` types through the peer — the peer's `generateSchema`\n * returns a `SchemaObject`, but the final document assembly is ours.\n */\nexport interface OpenAPIObject {\n openapi: string;\n info: OpenAPIInfo;\n paths: Record<string, Record<string, PathSpec>>;\n components: {\n schemas: Record<string, unknown>;\n };\n}\n\ninterface PeerModule {\n generateSchema: (zodRef: unknown, useOutput?: boolean, version?: '3.0' | '3.1') => unknown;\n}\n\nexport class OpenApiRegistry {\n private zodSchemas = new Map<string, z.ZodType>();\n private pathEntries = new Map<string, Map<HttpMethod, PathSpec>>();\n private peer: PeerModule | null = null;\n\n constructor() {\n // Auto-register the shared error response schema so controllers that\n // reference `#/components/schemas/ErrorResponseDto` always resolve\n // (OPENAPI-3). Consumers can `reset()` + re-register in tests.\n this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);\n }\n\n registerSchema(name: string, schema: z.ZodType): void {\n if (this.zodSchemas.has(name)) {\n throw new DuplicateSchemaError(name);\n }\n this.zodSchemas.set(name, schema);\n }\n\n registerPath(path: string, method: HttpMethod, spec: PathSpec): void {\n let methods = this.pathEntries.get(path);\n if (!methods) {\n methods = new Map();\n this.pathEntries.set(path, methods);\n }\n methods.set(method, spec);\n }\n\n /**\n * Emit the full OpenAPI document. Lazy-imports `@anatine/zod-openapi`\n * on first call; failure to resolve raises `OpenApiPeerDepMissingError`\n * (matches the `CubeAnalyticsBackend.onModuleInit` precedent).\n *\n * OpenAPI version is pinned to `3.0.3` — Swagger UI tooling is most\n * stable on 3.0.x (see OPENAPI-PHASE-1-PLAN §Four locked decisions).\n */\n async build(info: OpenAPIInfo): Promise<OpenAPIObject> {\n const peer = await this.loadPeer();\n\n const schemas: Record<string, unknown> = {};\n for (const [name, zodSchema] of this.zodSchemas) {\n schemas[name] = peer.generateSchema(zodSchema, false, '3.0');\n }\n\n const paths: Record<string, Record<string, PathSpec>> = {};\n for (const [path, methods] of this.pathEntries) {\n const methodMap: Record<string, PathSpec> = {};\n for (const [method, spec] of methods) {\n methodMap[method] = spec;\n }\n paths[path] = methodMap;\n }\n\n return {\n openapi: '3.0.3',\n info,\n paths,\n components: { schemas },\n };\n }\n\n /**\n * Test helper — clears registered schemas and paths, then re-seeds the\n * core `ErrorResponseDto` entry so post-reset state matches the\n * invariant established in the constructor.\n */\n reset(): void {\n this.zodSchemas.clear();\n this.pathEntries.clear();\n this.peer = null;\n this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);\n }\n\n protected async loadPeer(): Promise<PeerModule> {\n if (this.peer) return this.peer;\n try {\n // Computed specifier: prevents tsc from resolving this import at\n // typecheck time. Consumers vendor this file but may not install\n // @anatine/zod-openapi (optional peer).\n const specifier: string = '@anatine/zod-openapi';\n const mod = (await import(specifier)) as PeerModule;\n this.peer = mod;\n return mod;\n } catch {\n throw new OpenApiPeerDepMissingError();\n }\n }\n}\n","/**\n * Injection token for the OpenAPI registry (OPENAPI-1).\n *\n * String constant (not a Symbol) so it matches by value across import\n * boundaries — same convention as `ANALYTICS_QUERY` in analytics and\n * `EVENT_BUS` / `BRIDGE_DELIVERY_REPO` in events / bridge. The OPENAPI-1\n * spec sketched a Symbol, but the repo-wide convention wins — codebase\n * consistency matters more than the spec's initial guess.\n *\n * Consumed by generated DTO providers (OPENAPI-2), controllers\n * (OPENAPI-3), and the Swagger bootstrap (OPENAPI-4).\n */\nexport const OPENAPI_REGISTRY = 'OPENAPI_REGISTRY' as const;\n"],"mappings":";AAYA,SAAS,SAAS;AAEX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,YAAY,EAAE,OAAO,EAAE,IAAI;AAAA,EAC3B,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,EAClD,OAAO,EAAE,OAAO,EAAE,SAAS;AAC7B,CAAC;AAKM,IAAM,6BAA6B;;;ACVnC,IAAM,6BAAN,cAAyC,MAAM;AAAA,EAClC,OAAO;AAAA,EACzB,YAAY,SAAkB;AAC5B;AAAA,MACE,WACE;AAAA,IACJ;AAAA,EACF;AACF;AASO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAE9C,YAA4B,YAAoB;AAC9C;AAAA,MACE,iCAAiC,UAAU;AAAA,IAE7C;AAJ0B;AAAA,EAK5B;AAAA,EAL4B;AAAA,EADV,OAAO;AAO3B;;;ACyBO,IAAM,kBAAN,MAAsB;AAAA,EACnB,aAAa,oBAAI,IAAuB;AAAA,EACxC,cAAc,oBAAI,IAAuC;AAAA,EACzD,OAA0B;AAAA,EAElC,cAAc;AAIZ,SAAK,WAAW,IAAI,4BAA4B,mBAAmB;AAAA,EACrE;AAAA,EAEA,eAAe,MAAc,QAAyB;AACpD,QAAI,KAAK,WAAW,IAAI,IAAI,GAAG;AAC7B,YAAM,IAAI,qBAAqB,IAAI;AAAA,IACrC;AACA,SAAK,WAAW,IAAI,MAAM,MAAM;AAAA,EAClC;AAAA,EAEA,aAAa,MAAc,QAAoB,MAAsB;AACnE,QAAI,UAAU,KAAK,YAAY,IAAI,IAAI;AACvC,QAAI,CAAC,SAAS;AACZ,gBAAU,oBAAI,IAAI;AAClB,WAAK,YAAY,IAAI,MAAM,OAAO;AAAA,IACpC;AACA,YAAQ,IAAI,QAAQ,IAAI;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAM,MAA2C;AACrD,UAAM,OAAO,MAAM,KAAK,SAAS;AAEjC,UAAM,UAAmC,CAAC;AAC1C,eAAW,CAAC,MAAM,SAAS,KAAK,KAAK,YAAY;AAC/C,cAAQ,IAAI,IAAI,KAAK,eAAe,WAAW,OAAO,KAAK;AAAA,IAC7D;AAEA,UAAM,QAAkD,CAAC;AACzD,eAAW,CAAC,MAAM,OAAO,KAAK,KAAK,aAAa;AAC9C,YAAM,YAAsC,CAAC;AAC7C,iBAAW,CAAC,QAAQ,IAAI,KAAK,SAAS;AACpC,kBAAU,MAAM,IAAI;AAAA,MACtB;AACA,YAAM,IAAI,IAAI;AAAA,IAChB;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,YAAY,EAAE,QAAQ;AAAA,IACxB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAc;AACZ,SAAK,WAAW,MAAM;AACtB,SAAK,YAAY,MAAM;AACvB,SAAK,OAAO;AACZ,SAAK,WAAW,IAAI,4BAA4B,mBAAmB;AAAA,EACrE;AAAA,EAEA,MAAgB,WAAgC;AAC9C,QAAI,KAAK,KAAM,QAAO,KAAK;AAC3B,QAAI;AAIF,YAAM,YAAoB;AAC1B,YAAM,MAAO,MAAM,OAAO;AAC1B,WAAK,OAAO;AACZ,aAAO;AAAA,IACT,QAAQ;AACN,YAAM,IAAI,2BAA2B;AAAA,IACvC;AAAA,EACF;AACF;;;AC1IO,IAAM,mBAAmB;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,106 +1,9 @@
1
- // runtime/shared/openapi/error-response.dto.ts
2
- import { z } from "zod";
3
- var errorResponseSchema = z.object({
4
- statusCode: z.number().int(),
5
- message: z.union([z.string(), z.array(z.string())]),
6
- error: z.string().optional()
7
- });
8
- var ERROR_RESPONSE_SCHEMA_NAME = "ErrorResponseDto";
9
-
10
- // runtime/shared/openapi/errors.ts
11
- var OpenApiPeerDepMissingError = class extends Error {
12
- name = "OpenApiPeerDepMissingError";
13
- constructor(message) {
14
- super(
15
- message ?? "OpenApiRegistry requires @anatine/zod-openapi. Install it: bun add @anatine/zod-openapi"
16
- );
17
- }
18
- };
19
- var DuplicateSchemaError = class extends Error {
20
- constructor(schemaName) {
21
- super(
22
- `DuplicateSchemaError: schema '${schemaName}' is already registered. Each schema name must be unique within the OpenApiRegistry.`
23
- );
24
- this.schemaName = schemaName;
25
- }
26
- schemaName;
27
- name = "DuplicateSchemaError";
28
- };
29
-
30
- // runtime/shared/openapi/registry.ts
31
- var OpenApiRegistry = class {
32
- zodSchemas = /* @__PURE__ */ new Map();
33
- pathEntries = /* @__PURE__ */ new Map();
34
- peer = null;
35
- constructor() {
36
- this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);
37
- }
38
- registerSchema(name, schema) {
39
- if (this.zodSchemas.has(name)) {
40
- throw new DuplicateSchemaError(name);
41
- }
42
- this.zodSchemas.set(name, schema);
43
- }
44
- registerPath(path, method, spec) {
45
- let methods = this.pathEntries.get(path);
46
- if (!methods) {
47
- methods = /* @__PURE__ */ new Map();
48
- this.pathEntries.set(path, methods);
49
- }
50
- methods.set(method, spec);
51
- }
52
- /**
53
- * Emit the full OpenAPI document. Lazy-imports `@anatine/zod-openapi`
54
- * on first call; failure to resolve raises `OpenApiPeerDepMissingError`
55
- * (matches the `CubeAnalyticsBackend.onModuleInit` precedent).
56
- *
57
- * OpenAPI version is pinned to `3.0.3` — Swagger UI tooling is most
58
- * stable on 3.0.x (see OPENAPI-PHASE-1-PLAN §Four locked decisions).
59
- */
60
- async build(info) {
61
- const peer = await this.loadPeer();
62
- const schemas = {};
63
- for (const [name, zodSchema] of this.zodSchemas) {
64
- schemas[name] = peer.generateSchema(zodSchema, false, "3.0");
65
- }
66
- const paths = {};
67
- for (const [path, methods] of this.pathEntries) {
68
- const methodMap = {};
69
- for (const [method, spec] of methods) {
70
- methodMap[method] = spec;
71
- }
72
- paths[path] = methodMap;
73
- }
74
- return {
75
- openapi: "3.0.3",
76
- info,
77
- paths,
78
- components: { schemas }
79
- };
80
- }
81
- /**
82
- * Test helper — clears registered schemas and paths, then re-seeds the
83
- * core `ErrorResponseDto` entry so post-reset state matches the
84
- * invariant established in the constructor.
85
- */
86
- reset() {
87
- this.zodSchemas.clear();
88
- this.pathEntries.clear();
89
- this.peer = null;
90
- this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);
91
- }
92
- async loadPeer() {
93
- if (this.peer) return this.peer;
94
- try {
95
- const specifier = "@anatine/zod-openapi";
96
- const mod = await import(specifier);
97
- this.peer = mod;
98
- return mod;
99
- } catch {
100
- throw new OpenApiPeerDepMissingError();
101
- }
102
- }
103
- };
1
+ import {
2
+ OpenApiRegistry
3
+ } from "../../../chunk-Y7GDG744.js";
4
+ import "../../../chunk-SOVM2VEK.js";
5
+ import "../../../chunk-YSLTTQLC.js";
6
+ import "../../../chunk-2E224ZSN.js";
104
7
  export {
105
8
  OpenApiRegistry
106
9
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../runtime/shared/openapi/error-response.dto.ts","../../../../runtime/shared/openapi/errors.ts","../../../../runtime/shared/openapi/registry.ts"],"sourcesContent":["/**\n * Shared error response schema (OPENAPI-3).\n *\n * Generated controllers `@ApiResponse(...)` decorators reference this\n * schema by `$ref` (name `ErrorResponseDto`) for non-success status codes\n * (400, 401, 404, etc.). Shape matches NestJS's default `HttpException`\n * JSON body — see `packages/common/src/exceptions/http.exception.ts`.\n *\n * The registry auto-registers this schema on construction so every\n * consumer project exposes `components.schemas.ErrorResponseDto` on\n * `/docs-json` without per-entity duplication.\n */\nimport { z } from 'zod';\n\nexport const errorResponseSchema = z.object({\n statusCode: z.number().int(),\n message: z.union([z.string(), z.array(z.string())]),\n error: z.string().optional(),\n});\n\nexport type ErrorResponseDto = z.infer<typeof errorResponseSchema>;\n\n/** Canonical name used across `$ref` URIs in generated controllers. */\nexport const ERROR_RESPONSE_SCHEMA_NAME = 'ErrorResponseDto';\n","/**\n * Typed errors for the OpenAPI registry (OPENAPI-1).\n *\n * Same shape as `runtime/subsystems/bridge/bridge-errors.ts` so consumers\n * can catch them with the same exception-filter pattern used elsewhere.\n */\n\n/**\n * Thrown by `OpenApiRegistry.build()` when `@anatine/zod-openapi` is not\n * resolvable. The peer is declared optional (`peerDependenciesMeta`) so\n * consumer apps that don't care about OpenAPI still boot; the cost is a\n * deferred failure here on first `build()`.\n */\nexport class OpenApiPeerDepMissingError extends Error {\n override readonly name = 'OpenApiPeerDepMissingError';\n constructor(message?: string) {\n super(\n message ??\n 'OpenApiRegistry requires @anatine/zod-openapi. Install it: bun add @anatine/zod-openapi',\n );\n }\n}\n\n/**\n * Thrown by `OpenApiRegistry.registerSchema(name, ...)` when `name` is\n * already registered. Silent overwrite would make debugging\n * double-registration bugs (e.g. two entity pipelines both emitting a\n * `User` DTO) painful; loud failure lets the mismatch surface at module\n * init where the stack trace is clear.\n */\nexport class DuplicateSchemaError extends Error {\n override readonly name = 'DuplicateSchemaError';\n constructor(public readonly schemaName: string) {\n super(\n `DuplicateSchemaError: schema '${schemaName}' is already registered. ` +\n `Each schema name must be unique within the OpenApiRegistry.`,\n );\n }\n}\n","/**\n * OpenApiRegistry — collects Zod schemas and path specs, emits a\n * complete `OpenAPIObject` on `build()` (OPENAPI-1).\n *\n * Wraps `@anatine/zod-openapi` as an **optional peer dependency** using\n * the lazy-import pattern from `runtime/subsystems/analytics/cube-backend.ts`\n * — consumer apps that never call `build()` still boot even if\n * `@anatine/zod-openapi` isn't installed.\n *\n * The registry is the single source of truth consumed by OPENAPI-2\n * (generated DTOs register their Zod schemas at module init), OPENAPI-3\n * (controller decorators reference those schemas), and OPENAPI-4\n * (Swagger UI bootstrap calls `build()` once at startup).\n */\nimport type { z } from 'zod';\n\nimport { ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema } from './error-response.dto';\nimport { OpenApiPeerDepMissingError, DuplicateSchemaError } from './errors';\n\nexport type HttpMethod = 'get' | 'post' | 'patch' | 'delete' | 'put';\n\n/**\n * OpenAPI path spec. Structurally compatible with `openapi3-ts`'s\n * `OperationObject` but typed loosely here because the peer type package\n * isn't installed as a direct dep — consumers supply whatever their\n * codegen emits.\n */\nexport interface PathSpec {\n summary?: string;\n description?: string;\n operationId?: string;\n tags?: string[];\n parameters?: unknown[];\n requestBody?: unknown;\n responses?: Record<string, unknown>;\n security?: unknown[];\n [key: string]: unknown;\n}\n\nexport interface OpenAPIInfo {\n title: string;\n version: string;\n description?: string;\n}\n\n/**\n * Minimal OpenAPIObject shape. We redeclare rather than pull\n * `openapi3-ts` types through the peer — the peer's `generateSchema`\n * returns a `SchemaObject`, but the final document assembly is ours.\n */\nexport interface OpenAPIObject {\n openapi: string;\n info: OpenAPIInfo;\n paths: Record<string, Record<string, PathSpec>>;\n components: {\n schemas: Record<string, unknown>;\n };\n}\n\ninterface PeerModule {\n generateSchema: (zodRef: unknown, useOutput?: boolean, version?: '3.0' | '3.1') => unknown;\n}\n\nexport class OpenApiRegistry {\n private zodSchemas = new Map<string, z.ZodType>();\n private pathEntries = new Map<string, Map<HttpMethod, PathSpec>>();\n private peer: PeerModule | null = null;\n\n constructor() {\n // Auto-register the shared error response schema so controllers that\n // reference `#/components/schemas/ErrorResponseDto` always resolve\n // (OPENAPI-3). Consumers can `reset()` + re-register in tests.\n this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);\n }\n\n registerSchema(name: string, schema: z.ZodType): void {\n if (this.zodSchemas.has(name)) {\n throw new DuplicateSchemaError(name);\n }\n this.zodSchemas.set(name, schema);\n }\n\n registerPath(path: string, method: HttpMethod, spec: PathSpec): void {\n let methods = this.pathEntries.get(path);\n if (!methods) {\n methods = new Map();\n this.pathEntries.set(path, methods);\n }\n methods.set(method, spec);\n }\n\n /**\n * Emit the full OpenAPI document. Lazy-imports `@anatine/zod-openapi`\n * on first call; failure to resolve raises `OpenApiPeerDepMissingError`\n * (matches the `CubeAnalyticsBackend.onModuleInit` precedent).\n *\n * OpenAPI version is pinned to `3.0.3` — Swagger UI tooling is most\n * stable on 3.0.x (see OPENAPI-PHASE-1-PLAN §Four locked decisions).\n */\n async build(info: OpenAPIInfo): Promise<OpenAPIObject> {\n const peer = await this.loadPeer();\n\n const schemas: Record<string, unknown> = {};\n for (const [name, zodSchema] of this.zodSchemas) {\n schemas[name] = peer.generateSchema(zodSchema, false, '3.0');\n }\n\n const paths: Record<string, Record<string, PathSpec>> = {};\n for (const [path, methods] of this.pathEntries) {\n const methodMap: Record<string, PathSpec> = {};\n for (const [method, spec] of methods) {\n methodMap[method] = spec;\n }\n paths[path] = methodMap;\n }\n\n return {\n openapi: '3.0.3',\n info,\n paths,\n components: { schemas },\n };\n }\n\n /**\n * Test helper — clears registered schemas and paths, then re-seeds the\n * core `ErrorResponseDto` entry so post-reset state matches the\n * invariant established in the constructor.\n */\n reset(): void {\n this.zodSchemas.clear();\n this.pathEntries.clear();\n this.peer = null;\n this.zodSchemas.set(ERROR_RESPONSE_SCHEMA_NAME, errorResponseSchema);\n }\n\n protected async loadPeer(): Promise<PeerModule> {\n if (this.peer) return this.peer;\n try {\n // Computed specifier: prevents tsc from resolving this import at\n // typecheck time. Consumers vendor this file but may not install\n // @anatine/zod-openapi (optional peer).\n const specifier: string = '@anatine/zod-openapi';\n const mod = (await import(specifier)) as PeerModule;\n this.peer = mod;\n return mod;\n } catch {\n throw new OpenApiPeerDepMissingError();\n }\n }\n}\n"],"mappings":";AAYA,SAAS,SAAS;AAEX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,YAAY,EAAE,OAAO,EAAE,IAAI;AAAA,EAC3B,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,EAClD,OAAO,EAAE,OAAO,EAAE,SAAS;AAC7B,CAAC;AAKM,IAAM,6BAA6B;;;ACVnC,IAAM,6BAAN,cAAyC,MAAM;AAAA,EAClC,OAAO;AAAA,EACzB,YAAY,SAAkB;AAC5B;AAAA,MACE,WACE;AAAA,IACJ;AAAA,EACF;AACF;AASO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAE9C,YAA4B,YAAoB;AAC9C;AAAA,MACE,iCAAiC,UAAU;AAAA,IAE7C;AAJ0B;AAAA,EAK5B;AAAA,EAL4B;AAAA,EADV,OAAO;AAO3B;;;ACyBO,IAAM,kBAAN,MAAsB;AAAA,EACnB,aAAa,oBAAI,IAAuB;AAAA,EACxC,cAAc,oBAAI,IAAuC;AAAA,EACzD,OAA0B;AAAA,EAElC,cAAc;AAIZ,SAAK,WAAW,IAAI,4BAA4B,mBAAmB;AAAA,EACrE;AAAA,EAEA,eAAe,MAAc,QAAyB;AACpD,QAAI,KAAK,WAAW,IAAI,IAAI,GAAG;AAC7B,YAAM,IAAI,qBAAqB,IAAI;AAAA,IACrC;AACA,SAAK,WAAW,IAAI,MAAM,MAAM;AAAA,EAClC;AAAA,EAEA,aAAa,MAAc,QAAoB,MAAsB;AACnE,QAAI,UAAU,KAAK,YAAY,IAAI,IAAI;AACvC,QAAI,CAAC,SAAS;AACZ,gBAAU,oBAAI,IAAI;AAClB,WAAK,YAAY,IAAI,MAAM,OAAO;AAAA,IACpC;AACA,YAAQ,IAAI,QAAQ,IAAI;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAM,MAA2C;AACrD,UAAM,OAAO,MAAM,KAAK,SAAS;AAEjC,UAAM,UAAmC,CAAC;AAC1C,eAAW,CAAC,MAAM,SAAS,KAAK,KAAK,YAAY;AAC/C,cAAQ,IAAI,IAAI,KAAK,eAAe,WAAW,OAAO,KAAK;AAAA,IAC7D;AAEA,UAAM,QAAkD,CAAC;AACzD,eAAW,CAAC,MAAM,OAAO,KAAK,KAAK,aAAa;AAC9C,YAAM,YAAsC,CAAC;AAC7C,iBAAW,CAAC,QAAQ,IAAI,KAAK,SAAS;AACpC,kBAAU,MAAM,IAAI;AAAA,MACtB;AACA,YAAM,IAAI,IAAI;AAAA,IAChB;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,YAAY,EAAE,QAAQ;AAAA,IACxB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAc;AACZ,SAAK,WAAW,MAAM;AACtB,SAAK,YAAY,MAAM;AACvB,SAAK,OAAO;AACZ,SAAK,WAAW,IAAI,4BAA4B,mBAAmB;AAAA,EACrE;AAAA,EAEA,MAAgB,WAAgC;AAC9C,QAAI,KAAK,KAAM,QAAO,KAAK;AAC3B,QAAI;AAIF,YAAM,YAAoB;AAC1B,YAAM,MAAO,MAAM,OAAO;AAC1B,WAAK,OAAO;AACZ,aAAO;AAAA,IACT,QAAQ;AACN,YAAM,IAAI,2BAA2B;AAAA,IACvC;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,5 +1,7 @@
1
- // runtime/shared/openapi/registry.tokens.ts
2
- var OPENAPI_REGISTRY = "OPENAPI_REGISTRY";
1
+ import {
2
+ OPENAPI_REGISTRY
3
+ } from "../../../chunk-PSXUNOVU.js";
4
+ import "../../../chunk-2E224ZSN.js";
3
5
  export {
4
6
  OPENAPI_REGISTRY
5
7
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../runtime/shared/openapi/registry.tokens.ts"],"sourcesContent":["/**\n * Injection token for the OpenAPI registry (OPENAPI-1).\n *\n * String constant (not a Symbol) so it matches by value across import\n * boundaries — same convention as `ANALYTICS_QUERY` in analytics and\n * `EVENT_BUS` / `BRIDGE_DELIVERY_REPO` in events / bridge. The OPENAPI-1\n * spec sketched a Symbol, but the repo-wide convention wins — codebase\n * consistency matters more than the spec's initial guess.\n *\n * Consumed by generated DTO providers (OPENAPI-2), controllers\n * (OPENAPI-3), and the Swagger bootstrap (OPENAPI-4).\n */\nexport const OPENAPI_REGISTRY = 'OPENAPI_REGISTRY' as const;\n"],"mappings":";AAYO,IAAM,mBAAmB;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}