@burdenoff/be-sdk 2026.1110.2 → 2026.1110.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (497) hide show
  1. package/configs/eslint/index.js +1 -1
  2. package/configs/tsconfig/tsconfig.json +1 -1
  3. package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
  4. package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
  5. package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
  6. package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
  7. package/dist/activity/index.d.ts +165 -0
  8. package/dist/activity/index.js +389 -0
  9. package/dist/activity/index.js.map +1 -0
  10. package/dist/ai-credits/index.d.ts +2 -3
  11. package/dist/ai-credits/index.js +3 -4
  12. package/dist/ai-credits/index.js.map +1 -1
  13. package/dist/ai-credits-xxfwGpHS.js +546 -0
  14. package/dist/ai-credits-xxfwGpHS.js.map +1 -0
  15. package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
  16. package/dist/auth/index.d.ts +2 -77
  17. package/dist/auth/index.js +3 -7
  18. package/dist/auth/index.js.map +1 -1
  19. package/dist/auth-C5ctwSLp.js +228 -0
  20. package/dist/auth-C5ctwSLp.js.map +1 -0
  21. package/dist/bootstrap/index.d.ts +74 -0
  22. package/dist/bootstrap/index.js +282 -0
  23. package/dist/bootstrap/index.js.map +1 -0
  24. package/dist/cache/index.d.ts +2 -3
  25. package/dist/cache/index.js +3 -7
  26. package/dist/cache/index.js.map +1 -1
  27. package/dist/cache-CU0uLwcS.js +1837 -0
  28. package/dist/cache-CU0uLwcS.js.map +1 -0
  29. package/dist/captcha/index.d.ts +2 -1
  30. package/dist/captcha/index.js +3 -3
  31. package/dist/captcha/index.js.map +1 -1
  32. package/dist/captcha-BT7yh1YS.js +77 -0
  33. package/dist/captcha-BT7yh1YS.js.map +1 -0
  34. package/dist/client/internal-client.d.ts +4 -7
  35. package/dist/client/internal-client.js +172 -4
  36. package/dist/client/internal-client.js.map +1 -1
  37. package/dist/client-BgAEvDC2.d.ts +86 -0
  38. package/dist/client-sAJTrb4i.js +565 -0
  39. package/dist/client-sAJTrb4i.js.map +1 -0
  40. package/dist/collector-endpoint-iyQYeI50.js +50 -0
  41. package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
  42. package/dist/context/index.d.ts +35 -0
  43. package/dist/context/index.js +283 -0
  44. package/dist/context/index.js.map +1 -0
  45. package/dist/crypto/index.d.ts +2 -1
  46. package/dist/crypto/index.js +3 -3
  47. package/dist/crypto/index.js.map +1 -1
  48. package/dist/crypto-DO9fM0FO.js +145 -0
  49. package/dist/crypto-DO9fM0FO.js.map +1 -0
  50. package/dist/database/index.d.ts +104 -108
  51. package/dist/database/index.js +468 -6
  52. package/dist/database/index.js.map +1 -1
  53. package/dist/dataloader/index.d.ts +2 -1
  54. package/dist/dataloader/index.js +3 -3
  55. package/dist/dataloader/index.js.map +1 -1
  56. package/dist/dataloader-DwpT3YoS.js +294 -0
  57. package/dist/dataloader-DwpT3YoS.js.map +1 -0
  58. package/dist/deployed-environment-p_Tdl3sT.js +38 -0
  59. package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
  60. package/dist/dist-BGKdXVy3.js +1718 -0
  61. package/dist/dist-BGKdXVy3.js.map +1 -0
  62. package/dist/env-DdaoGjIt.js +74 -0
  63. package/dist/env-DdaoGjIt.js.map +1 -0
  64. package/dist/event-queue/index.d.ts +2 -7
  65. package/dist/event-queue/index.js +7 -9
  66. package/dist/event-queue/index.js.map +1 -1
  67. package/dist/event-queue-Cw-YJPY_.js +1384 -0
  68. package/dist/event-queue-Cw-YJPY_.js.map +1 -0
  69. package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
  70. package/dist/explicit-activity-scope-DikJ7NAE.js +57 -0
  71. package/dist/explicit-activity-scope-DikJ7NAE.js.map +1 -0
  72. package/dist/export/index.d.ts +2 -2
  73. package/dist/export/index.js +3 -14
  74. package/dist/export/index.js.map +1 -1
  75. package/dist/export-DJXE3Osa.js +642 -0
  76. package/dist/export-DJXE3Osa.js.map +1 -0
  77. package/dist/feature-flags/index.d.ts +2 -10
  78. package/dist/feature-flags/index.js +3 -6
  79. package/dist/feature-flags/index.js.map +1 -1
  80. package/dist/feature-flags-CP1KRgwD.js +422 -0
  81. package/dist/feature-flags-CP1KRgwD.js.map +1 -0
  82. package/dist/files/index.d.ts +2 -3
  83. package/dist/files/index.js +3 -4
  84. package/dist/files/index.js.map +1 -1
  85. package/dist/files-h5U-D2AF.js +830 -0
  86. package/dist/files-h5U-D2AF.js.map +1 -0
  87. package/dist/gateway/index.d.ts +4 -6
  88. package/dist/gateway/index.js +7 -13
  89. package/dist/gateway/index.js.map +1 -1
  90. package/dist/gateway/security/index.d.ts +2 -2
  91. package/dist/gateway/security/index.js +3 -5
  92. package/dist/gateway/security/index.js.map +1 -1
  93. package/dist/gateway-ByVo-n37.js +50 -0
  94. package/dist/gateway-ByVo-n37.js.map +1 -0
  95. package/dist/graph/index.d.ts +3 -10
  96. package/dist/graph/index.js +4 -13
  97. package/dist/graph/index.js.map +1 -1
  98. package/dist/graph-CR7u4lpl.js +2152 -0
  99. package/dist/graph-CR7u4lpl.js.map +1 -0
  100. package/dist/graph-emitter-CdOXP7Tn.js +621 -0
  101. package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
  102. package/dist/graphql/index.d.ts +3 -2
  103. package/dist/graphql/index.js +4 -6
  104. package/dist/graphql/index.js.map +1 -1
  105. package/dist/graphql/services/index.d.ts +2 -24
  106. package/dist/graphql/services/index.js +3 -4
  107. package/dist/graphql/services/index.js.map +1 -1
  108. package/dist/graphql-CUDyhibV.d.ts +21 -0
  109. package/dist/graphql-DHAHHcww.js +161 -0
  110. package/dist/graphql-DHAHHcww.js.map +1 -0
  111. package/dist/i18n/index.d.ts +3 -3
  112. package/dist/i18n/index.js +3 -4
  113. package/dist/i18n/index.js.map +1 -1
  114. package/dist/i18n-BBMYFd0P.js +860 -0
  115. package/dist/i18n-BBMYFd0P.js.map +1 -0
  116. package/dist/import-optional-peer-B82VYxeX.js +18 -0
  117. package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
  118. package/dist/index-3KOZ1zN9.d.ts +233 -0
  119. package/dist/index-ADmsX0BI.d.ts +646 -0
  120. package/dist/index-B2LCaK0R.d.ts +500 -0
  121. package/dist/index-BBqooJ52.d.ts +45 -0
  122. package/dist/index-BGzMYJsm.d.ts +209 -0
  123. package/dist/index-BMIMnp6T.d.ts +8 -0
  124. package/dist/index-BVOL7458.d.ts +10 -0
  125. package/dist/index-BcqQs-Uq.d.ts +69 -0
  126. package/dist/index-BeVtqGO-.d.ts +208 -0
  127. package/dist/index-BiTzGUZP.d.ts +114 -0
  128. package/dist/index-C0qLquY0.d.ts +150 -0
  129. package/dist/index-C5uEKchX.d.ts +60 -0
  130. package/dist/index-CDOqxSIi.d.ts +37 -0
  131. package/dist/index-CG6wj66Y.d.ts +148 -0
  132. package/dist/index-CHwMhK6v.d.ts +63 -0
  133. package/dist/index-CIgoeobA.d.ts +145 -0
  134. package/dist/index-CPQDMSFS.d.ts +103 -0
  135. package/dist/index-CSRcgkVi.d.ts +23 -0
  136. package/dist/index-CTTwo9av.d.ts +102 -0
  137. package/dist/index-CVCyKzhB.d.ts +207 -0
  138. package/dist/index-C_GXXF32.d.ts +704 -0
  139. package/dist/index-CaM9JUcc.d.ts +144 -0
  140. package/dist/index-CliOgq6L.d.ts +203 -0
  141. package/dist/index-Cot73bdh.d.ts +63 -0
  142. package/dist/index-DGgh9DWn.d.ts +59 -0
  143. package/dist/index-DY3dNhMN.d.ts +420 -0
  144. package/dist/index-DqbGqfAy.d.ts +127 -0
  145. package/dist/index-Dt1HJPTX.d.ts +12 -0
  146. package/dist/index-DtI6aBtB.d.ts +22 -0
  147. package/dist/index-FKohsiex.d.ts +38 -0
  148. package/dist/index-FRRaa6h2.d.ts +999 -0
  149. package/dist/index-FbXPfen7.d.ts +132 -0
  150. package/dist/index-MArCb8Aq.d.ts +306 -0
  151. package/dist/index-U_tu3zUl.d.ts +303 -0
  152. package/dist/index-YOShAwkq.d.ts +45 -0
  153. package/dist/index-cmR9k9ga.d.ts +26 -0
  154. package/dist/index-yBSjMY32.d.ts +24 -0
  155. package/dist/index-zd_NPGJo.d.ts +206 -0
  156. package/dist/index.d.ts +106 -609
  157. package/dist/index.js +769 -2590
  158. package/dist/index.js.map +1 -1
  159. package/dist/init/index.d.ts +2 -2
  160. package/dist/init/index.js +3 -16
  161. package/dist/init/index.js.map +1 -1
  162. package/dist/init-CQPFmOOe.js +325 -0
  163. package/dist/init-CQPFmOOe.js.map +1 -0
  164. package/dist/instrumentation/index.d.ts +3 -4
  165. package/dist/instrumentation/index.js +5 -5
  166. package/dist/instrumentation/index.js.map +1 -1
  167. package/dist/instrumentation-xkkmDgJ0.js +1678 -0
  168. package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
  169. package/dist/lake/index.d.ts +50 -54
  170. package/dist/lake/index.js +169 -193
  171. package/dist/lake/index.js.map +1 -1
  172. package/dist/layer/index.d.ts +3 -2
  173. package/dist/layer/index.js +4 -5
  174. package/dist/layer/index.js.map +1 -1
  175. package/dist/layer-BZBZZWeV.d.ts +69 -0
  176. package/dist/layer-Bcix-WCl.js +105 -0
  177. package/dist/layer-Bcix-WCl.js.map +1 -0
  178. package/dist/layer-CEKy6cm8.js +252 -0
  179. package/dist/layer-CEKy6cm8.js.map +1 -0
  180. package/dist/lifecycle/index.d.ts +2 -1
  181. package/dist/lifecycle/index.js +3 -4
  182. package/dist/lifecycle/index.js.map +1 -1
  183. package/dist/lifecycle-DeoLSX0U.js +76 -0
  184. package/dist/lifecycle-DeoLSX0U.js.map +1 -0
  185. package/dist/logger/index.d.ts +2 -3
  186. package/dist/logger/index.js +3 -3
  187. package/dist/logger/index.js.map +1 -1
  188. package/dist/logger-B6rCpb7D.js +290 -0
  189. package/dist/logger-B6rCpb7D.js.map +1 -0
  190. package/dist/metrics/index.d.ts +13 -14
  191. package/dist/metrics/index.js +3 -4
  192. package/dist/metrics/index.js.map +1 -1
  193. package/dist/metrics-BrLwNUrb.js +52 -0
  194. package/dist/metrics-BrLwNUrb.js.map +1 -0
  195. package/dist/metrics-collector-C2eShrlW.js +922 -0
  196. package/dist/metrics-collector-C2eShrlW.js.map +1 -0
  197. package/dist/middleware/index.d.ts +3 -3
  198. package/dist/middleware/index.js +3 -4
  199. package/dist/middleware/index.js.map +1 -1
  200. package/dist/middleware-CUxJVUpD.js +1243 -0
  201. package/dist/middleware-CUxJVUpD.js.map +1 -0
  202. package/dist/middleware-Cq0zFMGp.js +253 -0
  203. package/dist/middleware-Cq0zFMGp.js.map +1 -0
  204. package/dist/notifications/index.d.ts +2 -5
  205. package/dist/notifications/index.js +3 -6
  206. package/dist/notifications/index.js.map +1 -1
  207. package/dist/notifications-DY_i37WN.js +869 -0
  208. package/dist/notifications-DY_i37WN.js.map +1 -0
  209. package/dist/observability/index.d.ts +2 -3
  210. package/dist/observability/index.js +3 -4
  211. package/dist/observability/index.js.map +1 -1
  212. package/dist/observability-DBDXipTU.js +272 -0
  213. package/dist/observability-DBDXipTU.js.map +1 -0
  214. package/dist/payments/index.d.ts +144 -0
  215. package/dist/payments/index.js +404 -0
  216. package/dist/payments/index.js.map +1 -0
  217. package/dist/platform/index.d.ts +2 -1
  218. package/dist/platform/index.js +3 -5
  219. package/dist/platform/index.js.map +1 -1
  220. package/dist/platform-DZwczW7v.js +1510 -0
  221. package/dist/platform-DZwczW7v.js.map +1 -0
  222. package/dist/prisma/generator/index.d.ts +1 -1
  223. package/dist/prisma/generator/index.js +97 -84
  224. package/dist/prisma/generator/index.js.map +1 -1
  225. package/dist/prisma/index.d.ts +4 -7
  226. package/dist/prisma/index.js +5 -12
  227. package/dist/prisma/index.js.map +1 -1
  228. package/dist/prisma-BzOOdt79.js +863 -0
  229. package/dist/prisma-BzOOdt79.js.map +1 -0
  230. package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
  231. package/dist/product-alias/index.d.ts +2 -1
  232. package/dist/product-alias/index.js +3 -3
  233. package/dist/product-alias/index.js.map +1 -1
  234. package/dist/product-alias-BPqtskMq.js +273 -0
  235. package/dist/product-alias-BPqtskMq.js.map +1 -0
  236. package/dist/rate-limit-CBrK_U5H.js +142 -0
  237. package/dist/rate-limit-CBrK_U5H.js.map +1 -0
  238. package/dist/rbac/index.d.ts +2 -122
  239. package/dist/rbac/index.js +3 -6
  240. package/dist/rbac/index.js.map +1 -1
  241. package/dist/rbac-Dvz0YzEt.js +1486 -0
  242. package/dist/rbac-Dvz0YzEt.js.map +1 -0
  243. package/dist/resource-caps/index.d.ts +66 -72
  244. package/dist/resource-caps/index.js +430 -5
  245. package/dist/resource-caps/index.js.map +1 -1
  246. package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
  247. package/dist/sdk-Dju9o-sq.js +124 -0
  248. package/dist/sdk-Dju9o-sq.js.map +1 -0
  249. package/dist/search/index.d.ts +112 -0
  250. package/dist/search/index.js +266 -0
  251. package/dist/search/index.js.map +1 -0
  252. package/dist/security/index.d.ts +2 -0
  253. package/dist/security/index.js +4 -0
  254. package/dist/security/index.js.map +1 -0
  255. package/dist/security/rate-limit/index.d.ts +2 -0
  256. package/dist/security/rate-limit/index.js +4 -0
  257. package/dist/security/rate-limit/index.js.map +1 -0
  258. package/dist/security-DIG-95Ic.js +1647 -0
  259. package/dist/security-DIG-95Ic.js.map +1 -0
  260. package/dist/server/index.d.ts +7 -164
  261. package/dist/server/index.js +2001 -1507
  262. package/dist/server/index.js.map +1 -1
  263. package/dist/service-jwt-Bu-WNA_-.js +80 -0
  264. package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
  265. package/dist/services-BWzfz7vG.js +102 -0
  266. package/dist/services-BWzfz7vG.js.map +1 -0
  267. package/dist/sharding/index.d.ts +41 -44
  268. package/dist/sharding/index.js +156 -137
  269. package/dist/sharding/index.js.map +1 -1
  270. package/dist/sharing/index.d.ts +2 -1
  271. package/dist/sharing/index.js +3 -4
  272. package/dist/sharing/index.js.map +1 -1
  273. package/dist/sharing-CflDsSJ-.js +911 -0
  274. package/dist/sharing-CflDsSJ-.js.map +1 -0
  275. package/dist/stub-BUnfMiAS.js +577 -0
  276. package/dist/stub-BUnfMiAS.js.map +1 -0
  277. package/dist/tags/index.d.ts +2 -3
  278. package/dist/tags/index.js +3 -4
  279. package/dist/tags/index.js.map +1 -1
  280. package/dist/tags-CbijgoqR.js +868 -0
  281. package/dist/{chunk-PBZFAAOM.js.map → tags-CbijgoqR.js.map} +1 -1
  282. package/dist/telemetry/index.d.ts +64 -76
  283. package/dist/telemetry/index.js +369 -201
  284. package/dist/telemetry/index.js.map +1 -1
  285. package/dist/temporal/index.d.ts +2 -148
  286. package/dist/temporal/index.js +3 -5
  287. package/dist/temporal/index.js.map +1 -1
  288. package/dist/temporal-B534uYK8.js +706 -0
  289. package/dist/temporal-B534uYK8.js.map +1 -0
  290. package/dist/tracker/index.d.ts +5 -11
  291. package/dist/tracker/index.js +7 -20
  292. package/dist/tracker/index.js.map +1 -1
  293. package/dist/tracker-PQztSlhJ.js +458 -0
  294. package/dist/tracker-PQztSlhJ.js.map +1 -0
  295. package/dist/translation/index.d.ts +120 -0
  296. package/dist/translation/index.js +573 -0
  297. package/dist/translation/index.js.map +1 -0
  298. package/dist/types/index.d.ts +3 -0
  299. package/dist/types/index.js +90 -0
  300. package/dist/types/index.js.map +1 -0
  301. package/dist/types-BYMYND1L.js +44 -0
  302. package/dist/types-BYMYND1L.js.map +1 -0
  303. package/dist/types-C6EKaS3V.d.ts +106 -0
  304. package/dist/types-CWybW61E.d.ts +323 -0
  305. package/dist/types-C_yfu3XK.d.ts +34 -0
  306. package/dist/types-DgaQqvxo.d.ts +70 -0
  307. package/dist/usage/index.d.ts +2 -213
  308. package/dist/usage/index.js +3 -15
  309. package/dist/usage/index.js.map +1 -1
  310. package/dist/usage-BRqVP3CJ.js +682 -0
  311. package/dist/usage-BRqVP3CJ.js.map +1 -0
  312. package/dist/utils/index.d.ts +2 -1
  313. package/dist/utils/index.js +3 -3
  314. package/dist/utils/index.js.map +1 -1
  315. package/dist/utils-DL85Tnbn.js +500 -0
  316. package/dist/utils-DL85Tnbn.js.map +1 -0
  317. package/dist/validation/index.d.ts +2 -2
  318. package/dist/validation/index.js +3 -3
  319. package/dist/validation/index.js.map +1 -1
  320. package/dist/validation-CPUITdMk.js +762 -0
  321. package/dist/validation-CPUITdMk.js.map +1 -0
  322. package/dist/workspace-extension-COrC0dYi.js +979 -0
  323. package/dist/workspace-extension-COrC0dYi.js.map +1 -0
  324. package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
  325. package/package.json +7 -10
  326. package/dist/EventQueueFactory-GXC3A7DH.js +0 -8
  327. package/dist/EventQueueFactory-GXC3A7DH.js.map +0 -1
  328. package/dist/chunk-4XIBXZ6J.js +0 -276
  329. package/dist/chunk-4XIBXZ6J.js.map +0 -1
  330. package/dist/chunk-554Z4C2K.js +0 -1006
  331. package/dist/chunk-554Z4C2K.js.map +0 -1
  332. package/dist/chunk-5CAFHK2Z.js +0 -107
  333. package/dist/chunk-5CAFHK2Z.js.map +0 -1
  334. package/dist/chunk-63ZXJ42X.js +0 -451
  335. package/dist/chunk-63ZXJ42X.js.map +0 -1
  336. package/dist/chunk-6XEXJATV.js +0 -304
  337. package/dist/chunk-6XEXJATV.js.map +0 -1
  338. package/dist/chunk-726AR6Q7.js +0 -1532
  339. package/dist/chunk-726AR6Q7.js.map +0 -1
  340. package/dist/chunk-A5F6Z5UE.js +0 -21
  341. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  342. package/dist/chunk-A6DE32ZS.js +0 -1507
  343. package/dist/chunk-A6DE32ZS.js.map +0 -1
  344. package/dist/chunk-AXJDGQPE.js +0 -690
  345. package/dist/chunk-AXJDGQPE.js.map +0 -1
  346. package/dist/chunk-BJQOGOVW.js +0 -602
  347. package/dist/chunk-BJQOGOVW.js.map +0 -1
  348. package/dist/chunk-CFXWH2IS.js +0 -52
  349. package/dist/chunk-CFXWH2IS.js.map +0 -1
  350. package/dist/chunk-DRWH5XCJ.js +0 -876
  351. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  352. package/dist/chunk-E4QNLVY4.js +0 -909
  353. package/dist/chunk-E4QNLVY4.js.map +0 -1
  354. package/dist/chunk-EBDHIL7V.js +0 -774
  355. package/dist/chunk-EBDHIL7V.js.map +0 -1
  356. package/dist/chunk-ELU7VL3E.js +0 -245
  357. package/dist/chunk-ELU7VL3E.js.map +0 -1
  358. package/dist/chunk-FZRODKIN.js +0 -31
  359. package/dist/chunk-FZRODKIN.js.map +0 -1
  360. package/dist/chunk-GCIB76AJ.js +0 -882
  361. package/dist/chunk-GCIB76AJ.js.map +0 -1
  362. package/dist/chunk-HC6MPUIH.js +0 -1571
  363. package/dist/chunk-HC6MPUIH.js.map +0 -1
  364. package/dist/chunk-HNMHPSAM.js +0 -272
  365. package/dist/chunk-HNMHPSAM.js.map +0 -1
  366. package/dist/chunk-HTLEGD3Q.js +0 -1480
  367. package/dist/chunk-HTLEGD3Q.js.map +0 -1
  368. package/dist/chunk-I3KOWRT3.js +0 -89
  369. package/dist/chunk-I3KOWRT3.js.map +0 -1
  370. package/dist/chunk-ID3WR4JS.js +0 -509
  371. package/dist/chunk-ID3WR4JS.js.map +0 -1
  372. package/dist/chunk-JS52ZHTK.js +0 -1346
  373. package/dist/chunk-JS52ZHTK.js.map +0 -1
  374. package/dist/chunk-JVMAQOA3.js +0 -521
  375. package/dist/chunk-JVMAQOA3.js.map +0 -1
  376. package/dist/chunk-KH4TRQCO.js +0 -1063
  377. package/dist/chunk-KH4TRQCO.js.map +0 -1
  378. package/dist/chunk-KJOSPVB2.js +0 -57
  379. package/dist/chunk-KJOSPVB2.js.map +0 -1
  380. package/dist/chunk-KO2ZXZ7W.js +0 -61
  381. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  382. package/dist/chunk-KS2HQCJR.js +0 -56
  383. package/dist/chunk-KS2HQCJR.js.map +0 -1
  384. package/dist/chunk-LA5KPWZ2.js +0 -413
  385. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  386. package/dist/chunk-MESLAC5W.js +0 -574
  387. package/dist/chunk-MESLAC5W.js.map +0 -1
  388. package/dist/chunk-MWPYA2HD.js +0 -94
  389. package/dist/chunk-MWPYA2HD.js.map +0 -1
  390. package/dist/chunk-NUB5GQTU.js +0 -270
  391. package/dist/chunk-NUB5GQTU.js.map +0 -1
  392. package/dist/chunk-OBBCR6WY.js +0 -277
  393. package/dist/chunk-OBBCR6WY.js.map +0 -1
  394. package/dist/chunk-OQDSAOG3.js +0 -1908
  395. package/dist/chunk-OQDSAOG3.js.map +0 -1
  396. package/dist/chunk-OXNCBE7P.js +0 -971
  397. package/dist/chunk-OXNCBE7P.js.map +0 -1
  398. package/dist/chunk-PBZFAAOM.js +0 -941
  399. package/dist/chunk-PN6GIF3R.js +0 -1185
  400. package/dist/chunk-PN6GIF3R.js.map +0 -1
  401. package/dist/chunk-PYD44IHJ.js +0 -728
  402. package/dist/chunk-PYD44IHJ.js.map +0 -1
  403. package/dist/chunk-QVPIACWD.js +0 -679
  404. package/dist/chunk-QVPIACWD.js.map +0 -1
  405. package/dist/chunk-QWNNFE4P.js +0 -41
  406. package/dist/chunk-QWNNFE4P.js.map +0 -1
  407. package/dist/chunk-RU266375.js +0 -327
  408. package/dist/chunk-RU266375.js.map +0 -1
  409. package/dist/chunk-RYTSVGGA.js +0 -1624
  410. package/dist/chunk-RYTSVGGA.js.map +0 -1
  411. package/dist/chunk-RZOFS2BQ.js +0 -225
  412. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  413. package/dist/chunk-SBS4S2PJ.js +0 -100
  414. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  415. package/dist/chunk-SPRG6G6G.js +0 -530
  416. package/dist/chunk-SPRG6G6G.js.map +0 -1
  417. package/dist/chunk-STWFX5E2.js +0 -233
  418. package/dist/chunk-STWFX5E2.js.map +0 -1
  419. package/dist/chunk-UNASM5VJ.js +0 -419
  420. package/dist/chunk-UNASM5VJ.js.map +0 -1
  421. package/dist/chunk-VAT66FJA.js +0 -245
  422. package/dist/chunk-VAT66FJA.js.map +0 -1
  423. package/dist/chunk-VFCMR5GX.js +0 -49
  424. package/dist/chunk-VFCMR5GX.js.map +0 -1
  425. package/dist/chunk-VGAHZKNJ.js +0 -66
  426. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  427. package/dist/chunk-VTJTAAXC.js +0 -627
  428. package/dist/chunk-VTJTAAXC.js.map +0 -1
  429. package/dist/chunk-VXVLKRU6.js +0 -758
  430. package/dist/chunk-VXVLKRU6.js.map +0 -1
  431. package/dist/chunk-WWUU5ETI.js +0 -163
  432. package/dist/chunk-WWUU5ETI.js.map +0 -1
  433. package/dist/chunk-XE4OXN2W.js +0 -10
  434. package/dist/chunk-XE4OXN2W.js.map +0 -1
  435. package/dist/chunk-XOJORS75.js +0 -1853
  436. package/dist/chunk-XOJORS75.js.map +0 -1
  437. package/dist/chunk-YMZEUTD2.js +0 -110
  438. package/dist/chunk-YMZEUTD2.js.map +0 -1
  439. package/dist/chunk-Z77BTSOK.js +0 -617
  440. package/dist/chunk-Z77BTSOK.js.map +0 -1
  441. package/dist/chunk-ZZK3WEDI.js +0 -181
  442. package/dist/chunk-ZZK3WEDI.js.map +0 -1
  443. package/dist/client-CCXpAZ2r.d.ts +0 -89
  444. package/dist/client-DSI_760t.d.ts +0 -36
  445. package/dist/client-JU6T3UPB.js +0 -11
  446. package/dist/client-JU6T3UPB.js.map +0 -1
  447. package/dist/dist-2X4Q7PJA.js +0 -1491
  448. package/dist/dist-2X4Q7PJA.js.map +0 -1
  449. package/dist/env-4UWSUS64.js +0 -4
  450. package/dist/env-4UWSUS64.js.map +0 -1
  451. package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
  452. package/dist/graphql-CMHMQjvd.d.ts +0 -23
  453. package/dist/i18n-Qm2AkPC-.d.ts +0 -33
  454. package/dist/index--yvpa6ay.d.ts +0 -83
  455. package/dist/index-4gKQKZ2B.d.ts +0 -71
  456. package/dist/index-5x0XMKXN.d.ts +0 -149
  457. package/dist/index-B70b5mYS.d.ts +0 -33
  458. package/dist/index-B8KrxO4j.d.ts +0 -755
  459. package/dist/index-BOuDKnqD.d.ts +0 -201
  460. package/dist/index-BTMt4OjA.d.ts +0 -201
  461. package/dist/index-BejbszA7.d.ts +0 -39
  462. package/dist/index-BkeOYZye.d.ts +0 -198
  463. package/dist/index-BuAj5nXg.d.ts +0 -83
  464. package/dist/index-BvkVcW8I.d.ts +0 -349
  465. package/dist/index-CWmH_-RZ.d.ts +0 -247
  466. package/dist/index-CbgWNcus.d.ts +0 -258
  467. package/dist/index-CmfPeQza.d.ts +0 -166
  468. package/dist/index-CmpG-zak.d.ts +0 -607
  469. package/dist/index-CoMKgL-p.d.ts +0 -12
  470. package/dist/index-D8HGwglK.d.ts +0 -541
  471. package/dist/index-DCaVm66D.d.ts +0 -1101
  472. package/dist/index-DE2w7E0d.d.ts +0 -83
  473. package/dist/index-DSOpj8DI.d.ts +0 -17
  474. package/dist/index-DW9q22GH.d.ts +0 -75
  475. package/dist/index-DnjJ9CwI.d.ts +0 -347
  476. package/dist/index-DwMJZ8PP.d.ts +0 -317
  477. package/dist/index-PaojfSdd.d.ts +0 -71
  478. package/dist/index-aHtYvc3i.d.ts +0 -284
  479. package/dist/index-e_18DzAg.d.ts +0 -18
  480. package/dist/index-ffmipXSA.d.ts +0 -55
  481. package/dist/index-joONjwLt.d.ts +0 -33
  482. package/dist/index-kssw5ziY.d.ts +0 -250
  483. package/dist/index-lFffh5-G.d.ts +0 -125
  484. package/dist/index-pxYge_6k.d.ts +0 -79
  485. package/dist/layer-Cv9vSwBx.d.ts +0 -70
  486. package/dist/pino-logger-H4HPW5P6.js +0 -5
  487. package/dist/pino-logger-H4HPW5P6.js.map +0 -1
  488. package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
  489. package/dist/sdk-L75WWUP3.js +0 -156
  490. package/dist/sdk-L75WWUP3.js.map +0 -1
  491. package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
  492. package/dist/types-Bo2wkjSP.d.ts +0 -35
  493. package/dist/types-DVpvrAhd.d.ts +0 -71
  494. package/dist/types-DgJ4lDYA.d.ts +0 -108
  495. package/dist/types-USOv09qy.d.ts +0 -327
  496. package/dist/workspace-guard-NXVYYBVJ.js +0 -5
  497. package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
@@ -0,0 +1,863 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-ad2WFvuA.js";
2
+ import { a as logger } from "./logger-B6rCpb7D.js";
3
+ import { a as createConnectionPool, c as ensureServiceApplicationName, i as configurePrismaLogging, l as installAcquireRetry, o as createPrismaAdapter, r as PrismaClientWrapper, s as createPrismaClient, t as addGraphExtension, u as isTransientAcquireError } from "./middleware-CUxJVUpD.js";
4
+ import { r as getGraphEventEmitter } from "./graph-emitter-CdOXP7Tn.js";
5
+ import { a as getScopedWorkspaceContext, c as injectWhereWorkspaceId, d as resetCallerTransactionStateForTests, f as runOperationInCallerTransaction, g as withWorkspaceContextSync, h as withWorkspaceContext, i as getCallerTransaction, l as maybeSetRlsGuc, m as setWorkspaceContext, n as buildTransactionContextStatement, o as getWorkspaceContext, p as runOperationWithRlsGuc, r as defaultWorkspaceExtensionConfig, s as injectCreateFields, t as addWorkspaceExtension, u as maybeTagConnection } from "./workspace-extension-COrC0dYi.js";
6
+ import { D as productSlugVariants, g as isSameProductSlug } from "./product-alias-BPqtskMq.js";
7
+ import { createRequire } from "node:module";
8
+
9
+ // src/prisma/factory.ts
10
+ /**
11
+ * Database Client Factory
12
+ *
13
+ * Provides a unified factory for creating fully-configured database clients
14
+ * with Prisma 7, PostgreSQL adapter, graph extension, and graceful shutdown.
15
+ *
16
+ * This module consolidates all database setup into a single call, reducing
17
+ * boilerplate across all backend services.
18
+ *
19
+ * @module prisma/factory
20
+ * @category Database
21
+ */
22
+ /**
23
+ * Layer-aware default for the workspace extension.
24
+ *
25
+ * Global-layer services (productName starting with `global-`/`global_`, or
26
+ * `WORKSPACE_LAYER=global`) opt out by default because their tables don't carry
27
+ * a workspaceId column — enforcement would break queries like `myOrganizations`,
28
+ * `myAccessibleProducts`, `contentPages`.
29
+ *
30
+ * `WORKSPACE_EXTENSION_ENABLED` is respected as an explicit override.
31
+ */
32
+ function resolveWorkspaceExtensionDefault(productName) {
33
+ const explicit = process.env["WORKSPACE_EXTENSION_ENABLED"];
34
+ if (explicit === "true") return true;
35
+ if (explicit === "false") return false;
36
+ const layer = process.env["WORKSPACE_LAYER"]?.toLowerCase();
37
+ if (layer === "global") return false;
38
+ if (layer === "wspace") return true;
39
+ const name = productName.toLowerCase();
40
+ if (name.startsWith("global-") || name.startsWith("global_")) return false;
41
+ return true;
42
+ }
43
+ /**
44
+ * Create a fully-configured database client with graph extension
45
+ *
46
+ * This is the recommended way to create a database connection in all backend services.
47
+ * It handles:
48
+ * - Prisma client creation with PostgreSQL adapter
49
+ * - Connection pooling configuration
50
+ * - Query logging (in development)
51
+ * - Graph extension for entity sync (via NATS or in-memory)
52
+ * - Graceful shutdown handlers
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // In your service's db.ts
57
+ * import { PrismaClient } from './generated/prisma/client.js';
58
+ * import { createDatabaseClient } from '@burdenoff/be-sdk/prisma';
59
+ *
60
+ * const { db, wrapper, connect, disconnect } = createDatabaseClient(PrismaClient, {
61
+ * productName: 'my-service',
62
+ * databaseUrl: process.env.DATABASE_URL!,
63
+ * });
64
+ *
65
+ * export { db, wrapper, connect, disconnect };
66
+ * export type ExtendedPrismaClient = typeof db;
67
+ * ```
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * // With custom configuration
72
+ * const { db } = createDatabaseClient(PrismaClient, {
73
+ * productName: 'workspaces',
74
+ * databaseUrl: process.env.DATABASE_URL!,
75
+ * maxConnections: 50,
76
+ * enableQueryLogging: true,
77
+ * slowQueryThreshold: 200,
78
+ * enableGraphExtension: true,
79
+ * registerShutdownHandlers: true,
80
+ * });
81
+ * ```
82
+ */
83
+ function createDatabaseClient(PrismaClientConstructor, config) {
84
+ const { productName, enableGraphExtension = process.env["GRAPH_MIDDLEWARE_ENABLED"] !== "false", graphEventEmitter, enableWorkspaceExtension = resolveWorkspaceExtensionDefault(productName), workspaceExtensionConfig, registerShutdownHandlers = true, ...prismaConfig } = config;
85
+ const prismaConfigWithDefaults = {
86
+ ...prismaConfig,
87
+ applicationName: prismaConfig.applicationName ?? `svc=${productName}`
88
+ };
89
+ ensureServiceApplicationName(productName);
90
+ const wrapper = createPrismaClient(PrismaClientConstructor, prismaConfigWithDefaults);
91
+ const baseClient = wrapper.getClient();
92
+ let extendedClient;
93
+ if (enableGraphExtension) {
94
+ const graphConfig = {
95
+ enabled: true,
96
+ productName,
97
+ eventEmitter: graphEventEmitter ?? getGraphEventEmitter()
98
+ };
99
+ extendedClient = addGraphExtension(baseClient, graphConfig);
100
+ logger.info("[Database] Graph extension enabled", { productName });
101
+ } else {
102
+ extendedClient = baseClient;
103
+ logger.info("[Database] Graph extension disabled");
104
+ }
105
+ if (enableWorkspaceExtension) {
106
+ extendedClient = addWorkspaceExtension(extendedClient, workspaceExtensionConfig);
107
+ logger.info("[Database] Workspace extension enabled", { productName });
108
+ } else logger.info("[Database] Workspace extension disabled");
109
+ const db = extendedClient;
110
+ db["client"] = db;
111
+ if (registerShutdownHandlers) {
112
+ wrapper.registerShutdownHandlers();
113
+ logger.debug("[Database] Shutdown handlers registered");
114
+ }
115
+ return {
116
+ db,
117
+ wrapper,
118
+ connect: (retries, delay) => wrapper.connect(retries, delay),
119
+ disconnect: () => wrapper.disconnect()
120
+ };
121
+ }
122
+ /**
123
+ * Parse a strictly-positive integer environment variable.
124
+ *
125
+ * Returns `undefined` for unset, empty, non-numeric, zero, or negative values —
126
+ * so a misconfigured or absent env var can never silently enable an aggressive
127
+ * (or nonsensical) timeout. This is what keeps the DB-enforced timeouts OFF by
128
+ * default and therefore behavior-preserving.
129
+ */
130
+ function parsePositiveIntEnv(name) {
131
+ const raw = process.env[name];
132
+ if (raw == null || raw.trim() === "") return;
133
+ const parsed = Number.parseInt(raw.trim(), 10);
134
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
135
+ }
136
+ /**
137
+ * Resolve pool tuning (application_name + opt-in DB timeouts) from env vars:
138
+ * - DATABASE_APPLICATION_NAME: overrides the default `svc=<productName>` tag
139
+ * - DATABASE_QUERY_TIMEOUT: client-side node-postgres query_timeout in ms (opt-in, pooler-safe)
140
+ * - DATABASE_STATEMENT_TIMEOUT: server-side statement_timeout in ms (opt-in; DIRECT :5432 only — see note)
141
+ * - DATABASE_IDLE_IN_TRANSACTION_TIMEOUT: idle_in_transaction_session_timeout in ms (opt-in)
142
+ * - DATABASE_LOCK_TIMEOUT: lock_timeout in ms (opt-in)
143
+ *
144
+ * Timeouts are omitted entirely unless explicitly set to a positive integer, so
145
+ * the default is exactly today's behavior (no timeouts).
146
+ *
147
+ * NOTE: prefer `DATABASE_QUERY_TIMEOUT` for services whose `DATABASE_URL` points
148
+ * at the built-in PgBouncer (`:6432`). `DATABASE_STATEMENT_TIMEOUT` and friends
149
+ * are Postgres startup parameters that Azure PgBouncer does not pass through, so
150
+ * they silently have no effect (or fail the connection) on the pooled path.
151
+ */
152
+ function resolvePoolTuningFromEnv(productName) {
153
+ const tuning = { applicationName: process.env["DATABASE_APPLICATION_NAME"]?.trim() || `svc=${productName}` };
154
+ const queryTimeout = parsePositiveIntEnv("DATABASE_QUERY_TIMEOUT");
155
+ if (queryTimeout !== void 0) tuning.queryTimeoutMillis = queryTimeout;
156
+ const statementTimeout = parsePositiveIntEnv("DATABASE_STATEMENT_TIMEOUT");
157
+ if (statementTimeout !== void 0) tuning.statementTimeoutMillis = statementTimeout;
158
+ const idleInTransactionTimeout = parsePositiveIntEnv("DATABASE_IDLE_IN_TRANSACTION_TIMEOUT");
159
+ if (idleInTransactionTimeout !== void 0) tuning.idleInTransactionTimeoutMillis = idleInTransactionTimeout;
160
+ const lockTimeout = parsePositiveIntEnv("DATABASE_LOCK_TIMEOUT");
161
+ if (lockTimeout !== void 0) tuning.lockTimeoutMillis = lockTimeout;
162
+ return tuning;
163
+ }
164
+ /**
165
+ * Create a database client from environment variables
166
+ *
167
+ * Convenience function that reads configuration from standard environment variables:
168
+ * - DATABASE_URL: Connection string (required)
169
+ * - DATABASE_MAX_CONNECTIONS: Max pool connections (default: 20)
170
+ * - DATABASE_APPLICATION_NAME: Postgres application_name (default: `svc=<productName>`)
171
+ * - DATABASE_QUERY_TIMEOUT: opt-in client-side query timeout in ms — the
172
+ * PgBouncer-safe query bound (default: OFF, preserving current behavior)
173
+ * - DATABASE_STATEMENT_TIMEOUT / DATABASE_IDLE_IN_TRANSACTION_TIMEOUT / DATABASE_LOCK_TIMEOUT:
174
+ * opt-in server-side timeouts in ms (default: OFF; DIRECT :5432 only — not
175
+ * honored through the built-in PgBouncer :6432 runtime path)
176
+ * - NODE_ENV: Environment for logging settings
177
+ * - GRAPH_MIDDLEWARE_ENABLED: Enable graph sync (default: true)
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * import { PrismaClient } from './generated/prisma/client.js';
182
+ * import { createDatabaseClientFromEnv } from '@burdenoff/be-sdk/prisma';
183
+ *
184
+ * const { db } = createDatabaseClientFromEnv(PrismaClient, 'module-tags');
185
+ * export { db };
186
+ * ```
187
+ */
188
+ function createDatabaseClientFromEnv(PrismaClientConstructor, productName, overrides) {
189
+ const databaseUrl = process.env["DATABASE_URL"];
190
+ if (!databaseUrl) throw new Error("DATABASE_URL environment variable is required");
191
+ const isDevelopment = process.env["NODE_ENV"] === "development";
192
+ const config = {
193
+ productName,
194
+ databaseUrl,
195
+ maxConnections: parseInt(process.env["DATABASE_MAX_CONNECTIONS"] || "20", 10),
196
+ idleTimeoutMillis: parseInt(process.env["DATABASE_IDLE_TIMEOUT"] || "30000", 10),
197
+ connectionTimeoutMillis: parseInt(process.env["DATABASE_CONNECTION_TIMEOUT"] || "10000", 10),
198
+ ...resolvePoolTuningFromEnv(productName),
199
+ enableQueryLogging: isDevelopment,
200
+ slowQueryThreshold: isDevelopment ? 100 : 500,
201
+ ...overrides
202
+ };
203
+ const acquireRetriesRaw = process.env["DATABASE_ACQUIRE_RETRIES"]?.trim();
204
+ if (acquireRetriesRaw !== void 0 && acquireRetriesRaw !== "" && config.acquireRetries === void 0) {
205
+ const parsed = Number.parseInt(acquireRetriesRaw, 10);
206
+ if (Number.isFinite(parsed) && parsed >= 0) config.acquireRetries = parsed;
207
+ }
208
+ const acquireRetryDelay = parsePositiveIntEnv("DATABASE_ACQUIRE_RETRY_DELAY");
209
+ if (acquireRetryDelay !== void 0 && config.acquireRetryDelayMillis === void 0) config.acquireRetryDelayMillis = acquireRetryDelay;
210
+ return createDatabaseClient(PrismaClientConstructor, config);
211
+ }
212
+
213
+ // src/prisma/manager.ts
214
+ /**
215
+ * Database Singleton Manager
216
+ *
217
+ * Provides a singleton pattern for database connections across microservices.
218
+ * Services initialize once at startup and access the db instance globally.
219
+ *
220
+ * This eliminates the need for individual db.ts files in each microservice.
221
+ *
222
+ * @module prisma/manager
223
+ * @category Database
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * // In your service's index.ts (startup)
228
+ * import { PrismaClient } from './generated/prisma/client.js';
229
+ * import { initializeDatabase } from '@burdenoff/be-sdk/prisma';
230
+ *
231
+ * // Initialize once at startup
232
+ * const { db, connect } = initializeDatabase(PrismaClient, 'module-tags');
233
+ * await connect();
234
+ *
235
+ * // In any other file
236
+ * import { getDb } from '@burdenoff/be-sdk/prisma';
237
+ * const db = getDb();
238
+ * await db.client.user.findMany();
239
+ * ```
240
+ */
241
+ /**
242
+ * Singleton state for the database manager
243
+ */
244
+ const state = {
245
+ initialized: false,
246
+ productName: null,
247
+ client: null
248
+ };
249
+ /**
250
+ * Initialize the database singleton
251
+ *
252
+ * Call this once at application startup with your service's PrismaClient.
253
+ * After initialization, use `getDb()` to access the database anywhere.
254
+ *
255
+ * @param PrismaClientConstructor - The generated PrismaClient class from your service
256
+ * @param productName - Product name for graph events (e.g., 'module-tags', 'workspaces')
257
+ * @param config - Optional configuration overrides
258
+ * @returns The database client with db, wrapper, connect, disconnect
259
+ *
260
+ * @throws Error if already initialized with a different product
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * import { PrismaClient } from './generated/prisma/client.js';
265
+ * import { initializeDatabase } from '@burdenoff/be-sdk/prisma';
266
+ *
267
+ * const { db, connect, disconnect } = initializeDatabase(PrismaClient, 'module-tags');
268
+ * await connect();
269
+ * ```
270
+ */
271
+ function initializeDatabase(PrismaClientConstructor, productName, config) {
272
+ if (state.initialized) {
273
+ if (state.productName !== productName) throw new Error(`Database already initialized for product "${state.productName}". Cannot reinitialize for "${productName}".`);
274
+ logger.debug("[DatabaseManager] Already initialized, returning existing client", { productName });
275
+ return state.client;
276
+ }
277
+ const client = createDatabaseClientFromEnv(PrismaClientConstructor, productName, config);
278
+ state.initialized = true;
279
+ state.productName = productName;
280
+ state.client = client;
281
+ logger.info("[DatabaseManager] Database initialized", { productName });
282
+ return client;
283
+ }
284
+ /**
285
+ * Initialize the database with explicit configuration
286
+ *
287
+ * Use this when you need full control over database configuration
288
+ * rather than reading from environment variables.
289
+ *
290
+ * @param PrismaClientConstructor - The generated PrismaClient class
291
+ * @param config - Full database configuration
292
+ * @returns The database client
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * const { db } = initializeDatabaseWithConfig(PrismaClient, {
297
+ * productName: 'module-tags',
298
+ * databaseUrl: 'postgresql://...',
299
+ * maxConnections: 50,
300
+ * enableGraphExtension: false,
301
+ * });
302
+ * ```
303
+ */
304
+ function initializeDatabaseWithConfig(PrismaClientConstructor, config) {
305
+ const { productName } = config;
306
+ if (state.initialized) {
307
+ if (state.productName !== productName) throw new Error(`Database already initialized for product "${state.productName}". Cannot reinitialize for "${productName}".`);
308
+ logger.debug("[DatabaseManager] Already initialized, returning existing client", { productName });
309
+ return state.client;
310
+ }
311
+ const client = createDatabaseClient(PrismaClientConstructor, config);
312
+ state.initialized = true;
313
+ state.productName = productName;
314
+ state.client = client;
315
+ logger.info("[DatabaseManager] Database initialized with custom config", { productName });
316
+ return client;
317
+ }
318
+ /**
319
+ * Get the initialized database client
320
+ *
321
+ * Use this anywhere in your application to access the database.
322
+ * Must call `initializeDatabase()` first at application startup.
323
+ *
324
+ * The returned client provides dynamic model access - you can access any
325
+ * model property (e.g., `db.client.user`, `db.client.universalTag`) and
326
+ * TypeScript will allow common Prisma operations (findMany, create, etc.).
327
+ *
328
+ * @returns The extended Prisma client (db) with dynamic model access
329
+ * @throws Error if database not initialized
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * import { getDb } from '@burdenoff/be-sdk/prisma';
334
+ *
335
+ * const db = getDb();
336
+ * // Dynamic model access works without importing service-specific types
337
+ * const tags = await db.client.universalTag.findMany();
338
+ * const users = await db.client.user.findMany({ where: { active: true } });
339
+ * ```
340
+ */
341
+ function getDb() {
342
+ if (!state.initialized || !state.client) throw new Error("Database not initialized. Call initializeDatabase() at application startup before using getDb().");
343
+ return state.client.db;
344
+ }
345
+ /**
346
+ * Get the full database manager
347
+ *
348
+ * Returns the complete database client including wrapper, connect, and disconnect functions.
349
+ * Useful when you need access to connection management utilities.
350
+ *
351
+ * @returns The full database client
352
+ * @throws Error if database not initialized
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * import { getDatabaseManager } from '@burdenoff/be-sdk/prisma';
357
+ *
358
+ * const { db, wrapper, connect, disconnect } = getDatabaseManager();
359
+ * await connect();
360
+ * ```
361
+ */
362
+ function getDatabaseManager() {
363
+ if (!state.initialized || !state.client) throw new Error("Database not initialized. Call initializeDatabase() at application startup before using getDatabaseManager().");
364
+ return state.client;
365
+ }
366
+ /**
367
+ * Check if database is initialized
368
+ *
369
+ * @returns True if database has been initialized
370
+ *
371
+ * @example
372
+ * ```typescript
373
+ * if (!isDatabaseInitialized()) {
374
+ * await initializeDatabase(PrismaClient, 'my-service');
375
+ * }
376
+ * ```
377
+ */
378
+ function isDatabaseInitialized() {
379
+ return state.initialized;
380
+ }
381
+ /**
382
+ * Get the product name of the initialized database
383
+ *
384
+ * @returns The product name or null if not initialized
385
+ */
386
+ function getDatabaseProductName() {
387
+ return state.productName;
388
+ }
389
+ /**
390
+ * Reset the database manager (for testing purposes only)
391
+ *
392
+ * WARNING: This disconnects and resets the database manager.
393
+ * Only use this in test environments for cleanup between tests.
394
+ *
395
+ * @internal
396
+ */
397
+ async function resetDatabaseManager() {
398
+ if (state.client) try {
399
+ await state.client.disconnect();
400
+ } catch (error) {
401
+ logger.warn("[DatabaseManager] Error during disconnect on reset", { error });
402
+ }
403
+ state.initialized = false;
404
+ state.productName = null;
405
+ state.client = null;
406
+ logger.debug("[DatabaseManager] Database manager reset");
407
+ }
408
+
409
+ // src/prisma/health.ts
410
+ /**
411
+ * Prisma Health Check Utilities
412
+ */
413
+ /**
414
+ * Check database health
415
+ */
416
+ async function checkDatabaseHealth(client) {
417
+ try {
418
+ const start = Date.now();
419
+ await client.$queryRaw`SELECT 1`;
420
+ return {
421
+ healthy: true,
422
+ latency: Date.now() - start
423
+ };
424
+ } catch (error) {
425
+ const errorMessage = error instanceof Error ? error.message : String(error);
426
+ logger.error("[Prisma] Health check failed", { error: errorMessage });
427
+ return {
428
+ healthy: false,
429
+ error: errorMessage
430
+ };
431
+ }
432
+ }
433
+ /**
434
+ * Test database connection
435
+ */
436
+ async function testConnection(client) {
437
+ try {
438
+ await client.$queryRaw`SELECT 1`;
439
+ return true;
440
+ } catch (error) {
441
+ logger.error("[Prisma] Connection test failed", { error: error instanceof Error ? error.message : String(error) });
442
+ return false;
443
+ }
444
+ }
445
+ /**
446
+ * Get database version
447
+ */
448
+ async function getDatabaseVersion(client) {
449
+ try {
450
+ return (await client.$queryRaw`SELECT version()`)[0]?.version ?? null;
451
+ } catch (error) {
452
+ logger.error("[Prisma] Failed to get database version", { error: error instanceof Error ? error.message : String(error) });
453
+ return null;
454
+ }
455
+ }
456
+ /**
457
+ * Get database stats
458
+ */
459
+ async function getDatabaseStats(client) {
460
+ const [health, version] = await Promise.all([checkDatabaseHealth(client), getDatabaseVersion(client)]);
461
+ return {
462
+ health,
463
+ version,
464
+ timestamp: /* @__PURE__ */ new Date()
465
+ };
466
+ }
467
+
468
+ // src/prisma/fields.ts
469
+ /**
470
+ * Prisma Field Extraction Utilities
471
+ *
472
+ * Provides utilities for extracting model fields from Prisma schema.
473
+ * In Prisma 7, DMMF is not available at runtime, so this module provides
474
+ * build-time field extraction through a generator.
475
+ *
476
+ * @module prisma/fields
477
+ */
478
+ const requireFn = createRequire(import.meta.url);
479
+ /**
480
+ * Import generated fields from the consuming package
481
+ * This function should be used by backends to load their generated fields
482
+ */
483
+ function loadGeneratedFields(generatedFieldsPath) {
484
+ try {
485
+ const generated = requireFn(generatedFieldsPath);
486
+ return generated.default || generated;
487
+ } catch (error) {
488
+ logger.error("[Prisma] Failed to load generated fields", {
489
+ error: error instanceof Error ? error.message : String(error),
490
+ path: generatedFieldsPath
491
+ });
492
+ throw new Error(`Failed to load generated fields from ${generatedFieldsPath}`);
493
+ }
494
+ }
495
+ /**
496
+ * Extract fields from generated model fields with options
497
+ */
498
+ function extractFieldsFromModel(modelName, modelFieldsMap, options = {}) {
499
+ const modelFields = modelFieldsMap[modelName];
500
+ if (!modelFields) throw new Error(`Model "${modelName}" not found in generated fields. Available models: ${Object.keys(modelFieldsMap).join(", ")}`);
501
+ const { excludeFields = [], includeRelations = false, customFilter } = options;
502
+ let fields = [...modelFields.fields];
503
+ if (includeRelations) fields = [...fields, ...modelFields.relations];
504
+ const excluded = [];
505
+ if (excludeFields.length > 0) fields = fields.filter((field) => {
506
+ if (excludeFields.includes(field)) {
507
+ excluded.push(field);
508
+ return false;
509
+ }
510
+ return true;
511
+ });
512
+ if (customFilter) fields = fields.filter((fieldName) => {
513
+ const isRelation = modelFields.relations.includes(fieldName);
514
+ const shouldInclude = customFilter({
515
+ name: fieldName,
516
+ type: "unknown",
517
+ isRelation
518
+ });
519
+ if (!shouldInclude) excluded.push(fieldName);
520
+ return shouldInclude;
521
+ });
522
+ return {
523
+ fields,
524
+ metadata: {
525
+ totalFields: modelFields.fields.length + modelFields.relations.length,
526
+ excludedCount: excluded.length,
527
+ excludedFields: excluded,
528
+ relationFields: modelFields.relations.length
529
+ }
530
+ };
531
+ }
532
+ /**
533
+ * Get all field names for a model (without options)
534
+ */
535
+ function getModelFields(modelName, modelFieldsMap, includeRelations = false) {
536
+ return extractFieldsFromModel(modelName, modelFieldsMap, { includeRelations }).fields;
537
+ }
538
+ /**
539
+ * Check if a model exists in the generated fields
540
+ */
541
+ function hasModel(modelName, modelFieldsMap) {
542
+ return modelName in modelFieldsMap;
543
+ }
544
+ /**
545
+ * Get all available model names
546
+ */
547
+ function getAllModelNames(modelFieldsMap) {
548
+ return Object.keys(modelFieldsMap);
549
+ }
550
+
551
+ // src/prisma/context.ts
552
+ /**
553
+ * Prisma Context Filtering Utilities
554
+ *
555
+ * Utilities for handling operation context in queries, mutations, and filtering.
556
+ * Context JSON enables multi-dimensional data isolation across workspaces, users, projects, etc.
557
+ *
558
+ * @module prisma/context
559
+ * @category Database
560
+ */
561
+ /**
562
+ * Build Prisma where condition for context filtering.
563
+ * Uses PostgreSQL JSONB containment operators for efficient queries.
564
+ *
565
+ * @param contextFilter - The context filter input
566
+ * @returns Prisma where clause for context field, or undefined if no filter provided
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * const contextWhere = buildContextWhereClause({
571
+ * workspaceId: '123',
572
+ * projectId: '456'
573
+ * });
574
+ * // Returns: { path: ['workspaceId'], equals: '123' }
575
+ * ```
576
+ */
577
+ function buildContextWhereClause(contextFilter) {
578
+ if (!contextFilter) return;
579
+ const conditions = [];
580
+ if (contextFilter.workspaceId != null) conditions.push({
581
+ path: ["workspaceId"],
582
+ equals: contextFilter.workspaceId
583
+ });
584
+ if (contextFilter.userId != null) conditions.push({
585
+ path: ["userId"],
586
+ equals: contextFilter.userId
587
+ });
588
+ if (contextFilter.projectId != null) conditions.push({
589
+ path: ["projectId"],
590
+ equals: contextFilter.projectId
591
+ });
592
+ if (contextFilter.appId != null) conditions.push({
593
+ path: ["appId"],
594
+ equals: contextFilter.appId
595
+ });
596
+ if (contextFilter.productId != null) conditions.push({
597
+ path: ["productId"],
598
+ equals: contextFilter.productId
599
+ });
600
+ if (contextFilter.organizationId != null) conditions.push({
601
+ path: ["organizationId"],
602
+ equals: contextFilter.organizationId
603
+ });
604
+ if (conditions.length === 0) return;
605
+ if (conditions.length === 1) return conditions[0];
606
+ return conditions[0];
607
+ }
608
+ /**
609
+ * Build context where conditions as an array for use in AND clause.
610
+ * This is useful when you need to filter by multiple context fields.
611
+ *
612
+ * @param contextFilter - The context filter input
613
+ * @returns Array of Prisma where conditions, each targeting the context field
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * const conditions = buildContextWhereConditions({
618
+ * workspaceId: '123',
619
+ * projectId: '456'
620
+ * });
621
+ * // Use in Prisma query:
622
+ * prisma.entity.findMany({
623
+ * where: { AND: conditions }
624
+ * });
625
+ * ```
626
+ */
627
+ function buildContextWhereConditions(contextFilter) {
628
+ if (!contextFilter) return [];
629
+ const conditions = [];
630
+ if (contextFilter.workspaceId != null) conditions.push({ context: {
631
+ path: ["workspaceId"],
632
+ equals: contextFilter.workspaceId
633
+ } });
634
+ if (contextFilter.userId != null) conditions.push({ context: {
635
+ path: ["userId"],
636
+ equals: contextFilter.userId
637
+ } });
638
+ if (contextFilter.projectId != null) conditions.push({ context: {
639
+ path: ["projectId"],
640
+ equals: contextFilter.projectId
641
+ } });
642
+ if (contextFilter.appId != null) conditions.push({ context: {
643
+ path: ["appId"],
644
+ equals: contextFilter.appId
645
+ } });
646
+ if (contextFilter.productId != null) {
647
+ const slugs = productSlugVariants(contextFilter.productId);
648
+ if (slugs.length > 1) conditions.push({ OR: slugs.map((slug) => ({ context: {
649
+ path: ["productId"],
650
+ equals: slug
651
+ } })) });
652
+ else conditions.push({ context: {
653
+ path: ["productId"],
654
+ equals: contextFilter.productId
655
+ } });
656
+ }
657
+ if (contextFilter.organizationId != null) conditions.push({ context: {
658
+ path: ["organizationId"],
659
+ equals: contextFilter.organizationId
660
+ } });
661
+ return conditions;
662
+ }
663
+ /**
664
+ * Convert context input to Prisma JSON format for create/update operations.
665
+ *
666
+ * @param contextInput - The context input
667
+ * @returns JSON value for the context field, or undefined if empty
668
+ *
669
+ * @example
670
+ * ```typescript
671
+ * const contextJson = toContextJson({
672
+ * workspaceId: '123',
673
+ * userId: '456'
674
+ * });
675
+ * // Use in Prisma create:
676
+ * prisma.entity.create({
677
+ * data: { context: contextJson }
678
+ * });
679
+ * ```
680
+ */
681
+ function toContextJson(contextInput) {
682
+ if (!contextInput) return;
683
+ const context = {};
684
+ if (contextInput.workspaceId != null) context["workspaceId"] = contextInput.workspaceId;
685
+ if (contextInput.userId != null) context["userId"] = contextInput.userId;
686
+ if (contextInput.projectId != null) context["projectId"] = contextInput.projectId;
687
+ if (contextInput.appId != null) context["appId"] = contextInput.appId;
688
+ if (contextInput.productId != null) context["productId"] = contextInput.productId;
689
+ if (contextInput.organizationId != null) context["organizationId"] = contextInput.organizationId;
690
+ if (contextInput.custom != null) context["custom"] = contextInput.custom;
691
+ if (Object.keys(context).length === 0) return;
692
+ return context;
693
+ }
694
+ /**
695
+ * Filter out null values from an object for Prisma compatibility
696
+ */
697
+ function filterNullValues(obj) {
698
+ const filtered = {};
699
+ for (const [key, value] of Object.entries(obj)) if (value !== null) filtered[key] = value;
700
+ return filtered;
701
+ }
702
+ /**
703
+ * Merge a single field into the merged context object
704
+ */
705
+ function mergeContextField(merged, fieldName, fieldValue) {
706
+ if (fieldValue === void 0) return;
707
+ if (fieldValue === null) delete merged[fieldName];
708
+ else merged[fieldName] = fieldValue;
709
+ }
710
+ /**
711
+ * Merge existing context with new context input.
712
+ * New values override existing ones, but undefined values are preserved from existing.
713
+ *
714
+ * @param existingContext - The existing context JSON from database
715
+ * @param newContext - The new context input
716
+ * @returns Merged context as InputJsonValue (suitable for Prisma writes)
717
+ *
718
+ * @example
719
+ * ```typescript
720
+ * const merged = mergeContext(
721
+ * { workspaceId: '123', userId: 'old' },
722
+ * { userId: 'new', projectId: '456' }
723
+ * );
724
+ * // Result: { workspaceId: '123', userId: 'new', projectId: '456' }
725
+ * ```
726
+ */
727
+ function mergeContext(existingContext, newContext) {
728
+ if (!newContext) {
729
+ if (!existingContext) return;
730
+ if (typeof existingContext === "object" && !Array.isArray(existingContext)) {
731
+ const filtered = filterNullValues(existingContext);
732
+ return Object.keys(filtered).length > 0 ? filtered : void 0;
733
+ }
734
+ return existingContext;
735
+ }
736
+ if (!existingContext || typeof existingContext !== "object" || Array.isArray(existingContext)) return toContextJson(newContext);
737
+ const merged = filterNullValues(existingContext);
738
+ mergeContextField(merged, "workspaceId", newContext.workspaceId);
739
+ mergeContextField(merged, "userId", newContext.userId);
740
+ mergeContextField(merged, "projectId", newContext.projectId);
741
+ mergeContextField(merged, "appId", newContext.appId);
742
+ mergeContextField(merged, "productId", newContext.productId);
743
+ mergeContextField(merged, "organizationId", newContext.organizationId);
744
+ mergeContextField(merged, "custom", newContext.custom);
745
+ return Object.keys(merged).length > 0 ? merged : void 0;
746
+ }
747
+ /**
748
+ * Parse context JSON from database to OperationContext interface.
749
+ *
750
+ * @param contextJson - The context JSON from database
751
+ * @returns Parsed OperationContext or null
752
+ *
753
+ * @example
754
+ * ```typescript
755
+ * const context = parseContext(entity.context);
756
+ * if (context?.workspaceId) {
757
+ * // Use workspace-specific logic
758
+ * }
759
+ * ```
760
+ */
761
+ function parseContext(contextJson) {
762
+ if (!contextJson || typeof contextJson !== "object" || Array.isArray(contextJson)) return null;
763
+ const ctx = contextJson;
764
+ return {
765
+ workspaceId: typeof ctx["workspaceId"] === "string" ? ctx["workspaceId"] : null,
766
+ userId: typeof ctx["userId"] === "string" ? ctx["userId"] : null,
767
+ projectId: typeof ctx["projectId"] === "string" ? ctx["projectId"] : null,
768
+ appId: typeof ctx["appId"] === "string" ? ctx["appId"] : null,
769
+ productId: typeof ctx["productId"] === "string" ? ctx["productId"] : null,
770
+ organizationId: typeof ctx["organizationId"] === "string" ? ctx["organizationId"] : null,
771
+ custom: typeof ctx["custom"] === "object" ? ctx["custom"] : null
772
+ };
773
+ }
774
+ /**
775
+ * Check if context matches filter criteria
776
+ *
777
+ * @param context - The context to check
778
+ * @param filter - The filter criteria
779
+ * @returns True if context matches all filter criteria
780
+ */
781
+ function contextMatches(context, filter) {
782
+ if (!context) return false;
783
+ if (filter.workspaceId != null && context.workspaceId !== filter.workspaceId) return false;
784
+ if (filter.userId != null && context.userId !== filter.userId) return false;
785
+ if (filter.projectId != null && context.projectId !== filter.projectId) return false;
786
+ if (filter.appId != null && context.appId !== filter.appId) return false;
787
+ if (filter.productId != null && !isSameProductSlug(context.productId, filter.productId)) return false;
788
+ if (filter.organizationId != null && context.organizationId !== filter.organizationId) return false;
789
+ return true;
790
+ }
791
+ /**
792
+ * Create a default context from SDK context
793
+ *
794
+ * @param sdkContext - The SDK context (from AsyncLocalStorage)
795
+ * @returns Operation context with workspace and user info
796
+ */
797
+ function createContextFromSDK(sdkContext) {
798
+ return {
799
+ workspaceId: sdkContext.workspaceId ?? null,
800
+ userId: sdkContext.userId ?? null,
801
+ projectId: sdkContext.projectId ?? null,
802
+ appId: sdkContext.appId ?? null,
803
+ productId: sdkContext.productId ?? null,
804
+ organizationId: sdkContext.organizationId ?? null
805
+ };
806
+ }
807
+
808
+ // src/prisma/index.ts
809
+ var prisma_exports = /* @__PURE__ */ __exportAll({
810
+ PrismaClientWrapper: () => PrismaClientWrapper,
811
+ addWorkspaceExtension: () => addWorkspaceExtension,
812
+ buildContextWhereClause: () => buildContextWhereClause,
813
+ buildContextWhereConditions: () => buildContextWhereConditions,
814
+ buildTransactionContextStatement: () => buildTransactionContextStatement,
815
+ checkDatabaseHealth: () => checkDatabaseHealth,
816
+ configurePrismaLogging: () => configurePrismaLogging,
817
+ contextMatches: () => contextMatches,
818
+ createConnectionPool: () => createConnectionPool,
819
+ createContextFromSDK: () => createContextFromSDK,
820
+ createDatabaseClient: () => createDatabaseClient,
821
+ createDatabaseClientFromEnv: () => createDatabaseClientFromEnv,
822
+ createPrismaAdapter: () => createPrismaAdapter,
823
+ createPrismaClient: () => createPrismaClient,
824
+ defaultWorkspaceExtensionConfig: () => defaultWorkspaceExtensionConfig,
825
+ ensureServiceApplicationName: () => ensureServiceApplicationName,
826
+ extractFieldsFromModel: () => extractFieldsFromModel,
827
+ getAllModelNames: () => getAllModelNames,
828
+ getCallerTransaction: () => getCallerTransaction,
829
+ getDatabaseManager: () => getDatabaseManager,
830
+ getDatabaseProductName: () => getDatabaseProductName,
831
+ getDatabaseStats: () => getDatabaseStats,
832
+ getDatabaseVersion: () => getDatabaseVersion,
833
+ getDb: () => getDb,
834
+ getModelFields: () => getModelFields,
835
+ getScopedWorkspaceContext: () => getScopedWorkspaceContext,
836
+ getWorkspaceContext: () => getWorkspaceContext,
837
+ hasModel: () => hasModel,
838
+ initializeDatabase: () => initializeDatabase,
839
+ initializeDatabaseWithConfig: () => initializeDatabaseWithConfig,
840
+ injectCreateFields: () => injectCreateFields,
841
+ injectWhereWorkspaceId: () => injectWhereWorkspaceId,
842
+ installAcquireRetry: () => installAcquireRetry,
843
+ isDatabaseInitialized: () => isDatabaseInitialized,
844
+ isTransientAcquireError: () => isTransientAcquireError,
845
+ loadGeneratedFields: () => loadGeneratedFields,
846
+ maybeSetRlsGuc: () => maybeSetRlsGuc,
847
+ maybeTagConnection: () => maybeTagConnection,
848
+ mergeContext: () => mergeContext,
849
+ parseContext: () => parseContext,
850
+ resetCallerTransactionStateForTests: () => resetCallerTransactionStateForTests,
851
+ resetDatabaseManager: () => resetDatabaseManager,
852
+ resolvePoolTuningFromEnv: () => resolvePoolTuningFromEnv,
853
+ runOperationInCallerTransaction: () => runOperationInCallerTransaction,
854
+ runOperationWithRlsGuc: () => runOperationWithRlsGuc,
855
+ setWorkspaceContext: () => setWorkspaceContext,
856
+ testConnection: () => testConnection,
857
+ toContextJson: () => toContextJson,
858
+ withWorkspaceContext: () => withWorkspaceContext,
859
+ withWorkspaceContextSync: () => withWorkspaceContextSync
860
+ });
861
+
862
+ export { isDatabaseInitialized as C, resolvePoolTuningFromEnv as D, createDatabaseClientFromEnv as E, initializeDatabaseWithConfig as S, createDatabaseClient as T, testConnection as _, createContextFromSDK as a, getDb as b, toContextJson as c, getModelFields as d, hasModel as f, getDatabaseVersion as g, getDatabaseStats as h, contextMatches as i, extractFieldsFromModel as l, checkDatabaseHealth as m, buildContextWhereClause as n, mergeContext as o, loadGeneratedFields as p, buildContextWhereConditions as r, parseContext as s, prisma_exports as t, getAllModelNames as u, getDatabaseManager as v, resetDatabaseManager as w, initializeDatabase as x, getDatabaseProductName as y };
863
+ //# sourceMappingURL=prisma-BzOOdt79.js.map