@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,979 @@
1
+ import { a as logger } from "./logger-B6rCpb7D.js";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+
4
+ // src/prisma/transaction-context.ts
5
+ const contextFields = [
6
+ "workspaceId",
7
+ "tenantId",
8
+ "actorId",
9
+ "actorType",
10
+ "organizationId",
11
+ "projectId",
12
+ "appId",
13
+ "onBehalfOf"
14
+ ];
15
+ function sameContext(a, b) {
16
+ return contextFields.every((field) => a[field] === b[field]);
17
+ }
18
+ /**
19
+ * Bun can assimilate a returned lazy thenable outside its async callback's ALS
20
+ * scope. Bind only consumption of native PrismaPromises, never their creation:
21
+ * the query stays cold and retains Prisma's brand/spec/continuation machinery.
22
+ * This facade belongs to exactly one interactive callback, not the root client.
23
+ */
24
+ function bindTransactionContext(client, scope, getWorkspaceContext) {
25
+ const delegates = /* @__PURE__ */ new WeakMap();
26
+ function bindOperation(value) {
27
+ if (!value || typeof value !== "object" || Reflect.get(value, Symbol.toStringTag) !== "PrismaPromise") return value;
28
+ const sourceContext = getWorkspaceContext();
29
+ const captured = sourceContext ? { ...sourceContext } : void 0;
30
+ const restore = AsyncLocalStorage.snapshot();
31
+ return new Proxy(value, { get(target, property, receiver) {
32
+ const original = Reflect.get(target, property, receiver);
33
+ if (typeof original !== "function" || property === "constructor") return original;
34
+ return (...args) => {
35
+ if (!scope.active) throw new Error("[WorkspaceExtension] Lazy operation belongs to a completed interactive transaction.");
36
+ if (sourceContext && captured && !sameContext(sourceContext, captured)) throw new Error("[WorkspaceExtension] Captured workspace/actor context changed before lazy execution.");
37
+ const current = getWorkspaceContext();
38
+ if (captured && current && !sameContext(captured, current)) throw new Error("[WorkspaceExtension] Lazy operation cannot cross workspace/actor context.");
39
+ if (property === "requestTransaction") throw new Error("[WorkspaceExtension] Interactive operation cannot be rebound to another transaction.");
40
+ return restore(() => {
41
+ const result = Reflect.apply(original, target, args);
42
+ return [
43
+ "then",
44
+ "catch",
45
+ "finally"
46
+ ].includes(String(property)) ? result : bindOperation(result);
47
+ });
48
+ };
49
+ } });
50
+ }
51
+ function facade(target, model) {
52
+ const existing = delegates.get(target);
53
+ if (existing) return existing;
54
+ const proxy = new Proxy(target, { get(object, property, receiver) {
55
+ const value = Reflect.get(object, property, receiver);
56
+ if (typeof value === "function" && (model || typeof property === "string" && !property.startsWith("_") && property !== "constructor")) return (...args) => bindOperation(Reflect.apply(value, object, args));
57
+ if (!model && typeof property === "string" && !property.startsWith("_") && !property.startsWith("$") && value && typeof value === "object" && typeof Reflect.get(value, "findMany") === "function") return facade(value, true);
58
+ return value;
59
+ } });
60
+ delegates.set(target, proxy);
61
+ return proxy;
62
+ }
63
+ return facade(client, false);
64
+ }
65
+
66
+ // src/prisma/workspace-extension.ts
67
+ /**
68
+ * Prisma Workspace Extension
69
+ *
70
+ * Automatically injects workspaceId into ALL Prisma operations using
71
+ * request-scoped context from AsyncLocalStorage:
72
+ *
73
+ * **Write operations** (create, createMany, update, upsert):
74
+ * - Auto-populates `workspaceId`, `tenantId`, `createdBy`, `updatedBy`, `context` JSON
75
+ *
76
+ * **Read operations** (findMany, findFirst, findUnique, count, aggregate, groupBy):
77
+ * - Auto-injects `workspaceId` into the `where` clause for workspace isolation
78
+ *
79
+ * **Delete operations** (delete, deleteMany):
80
+ * - Auto-injects `workspaceId` into the `where` clause to prevent cross-workspace deletion
81
+ *
82
+ * **Update where clause** (update, updateMany):
83
+ * - Auto-injects `workspaceId` into the `where` clause to prevent cross-workspace updates
84
+ *
85
+ * **How it works:**
86
+ * 1. The GraphQL server's buildContext extracts workspaceId from x-workspace-id header
87
+ * 2. The workspace context store (AsyncLocalStorage) holds the current request's workspace info
88
+ * 3. This Prisma extension intercepts ALL operations and auto-injects workspaceId
89
+ *
90
+ * **What gets auto-populated on writes:**
91
+ * - `workspaceId` field (String or String?) - set from context if not explicitly provided
92
+ * - `context` field (Json) - merged with workspace/actor info if not explicitly provided
93
+ * - `tenantId` field (String or String?) - set from context if not explicitly provided
94
+ * - `createdBy` / `updatedBy` fields - set from actor context if not explicitly provided
95
+ *
96
+ * **What gets auto-injected on reads/updates/deletes:**
97
+ * - `workspaceId` in the `where` clause - ensures queries only access data within the workspace
98
+ *
99
+ * **Opt-out:**
100
+ * - Explicitly providing `workspaceId` in the where/data will override auto-injection
101
+ * - Pass `_skipWorkspaceInjection: true` in the query args to skip entirely
102
+ * - Set `enableReadIsolation: false` in config to disable read-side injection only
103
+ * - Add model names to `excludeModels` to skip specific models
104
+ *
105
+ * @module prisma/workspace-extension
106
+ * @category Database
107
+ */
108
+ /**
109
+ * AsyncLocalStorage for workspace context
110
+ * This is separate from the SDK's general ContextManager to allow
111
+ * fine-grained control over workspace-specific context propagation.
112
+ */
113
+ const workspaceContextStore = new AsyncLocalStorage();
114
+ /**
115
+ * Fallback context for environments where AsyncLocalStorage.enterWith()
116
+ * doesn't propagate across async boundaries (e.g., Bun + GraphQL Yoga).
117
+ *
118
+ * IMPORTANT: This is NOT request-isolated — it's a module-level singleton.
119
+ * It works for single-request-at-a-time scenarios but could race under
120
+ * concurrent requests. The ALS is the primary mechanism; this is a fallback.
121
+ */
122
+ let fallbackContext;
123
+ /**
124
+ * Set workspace context for the current async scope.
125
+ * Call this in your GraphQL context builder or middleware.
126
+ *
127
+ * Uses AsyncLocalStorage.enterWith() as the primary mechanism,
128
+ * with a module-level fallback for runtimes where enterWith()
129
+ * doesn't propagate through all async chains (e.g., Bun).
130
+ *
131
+ * @param context - The workspace context for this request
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * // In your server's buildContext:
136
+ * import { setWorkspaceContext } from '@burdenoff/be-sdk/prisma';
137
+ *
138
+ * buildContext: async (defaultContext) => {
139
+ * setWorkspaceContext({
140
+ * workspaceId: defaultContext.workspace?.id,
141
+ * tenantId: defaultContext.tenant?.id,
142
+ * actorId: defaultContext.actor?.id,
143
+ * actorType: defaultContext.actor?.type,
144
+ * organizationId: defaultContext.organization?.id,
145
+ * });
146
+ * return defaultContext;
147
+ * }
148
+ * ```
149
+ */
150
+ function setWorkspaceContext(context) {
151
+ workspaceContextStore.enterWith(context);
152
+ fallbackContext = context;
153
+ }
154
+ /**
155
+ * Get the current workspace context from AsyncLocalStorage.
156
+ * Falls back to module-level context if ALS returns undefined
157
+ * (can happen in Bun where enterWith() doesn't propagate through
158
+ * some async chains like GraphQL Yoga's execution pipeline).
159
+ *
160
+ * @returns The current workspace context, or undefined if not set
161
+ */
162
+ function getWorkspaceContext() {
163
+ return workspaceContextStore.getStore() ?? fallbackContext;
164
+ }
165
+ /**
166
+ * The workspace context bound to the CURRENT async scope only, without the module-level fallback.
167
+ *
168
+ * Use it for values that must never leak between requests (for example the assistant-session
169
+ * attribution on activity rows): the fallback holds whichever request built its context last, so a
170
+ * background job or a concurrent request could otherwise read another request's values.
171
+ */
172
+ function getScopedWorkspaceContext() {
173
+ return workspaceContextStore.getStore();
174
+ }
175
+ /**
176
+ * Run a function with a specific workspace context.
177
+ * The context is isolated to this execution and its children.
178
+ *
179
+ * @param context - The workspace context
180
+ * @param fn - The function to run
181
+ * @returns The result of the function
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const result = await withWorkspaceContext(
186
+ * { workspaceId: 'ws-123', actorId: 'user-456' },
187
+ * async () => {
188
+ * // All Prisma operations in here will auto-inject workspaceId
189
+ * return await prisma.tag.create({ data: { name: 'test' } });
190
+ * }
191
+ * );
192
+ * ```
193
+ */
194
+ async function withWorkspaceContext(context, fn) {
195
+ return workspaceContextStore.run(context, fn);
196
+ }
197
+ /**
198
+ * Run a synchronous function with a specific workspace context.
199
+ */
200
+ function withWorkspaceContextSync(context, fn) {
201
+ return workspaceContextStore.run(context, fn);
202
+ }
203
+ /**
204
+ * Default configuration. Exported so consumers/tests can spread over the
205
+ * real defaults (`{ ...defaultWorkspaceExtensionConfig, populateOnBehalfOf: false }`)
206
+ * instead of re-declaring every field.
207
+ */
208
+ const defaultWorkspaceExtensionConfig = {
209
+ enabled: true,
210
+ enableReadIsolation: true,
211
+ enableDeleteIsolation: true,
212
+ enableUpdateWhereIsolation: true,
213
+ populateContextJson: true,
214
+ populateCreatedBy: true,
215
+ populateUpdatedBy: true,
216
+ populateTenantId: false,
217
+ populateOnBehalfOf: true,
218
+ excludeModels: [],
219
+ excludeModelsFromReadIsolation: [],
220
+ strictMode: true,
221
+ allowedUnguardedOperations: [],
222
+ debug: false,
223
+ enableApplicationNameTagging: false,
224
+ enableRlsGucTagging: false
225
+ };
226
+ /**
227
+ * Check if a field exists in the data object (including being set to null/undefined explicitly)
228
+ */
229
+ function hasField(data, field) {
230
+ return field in data;
231
+ }
232
+ /**
233
+ * Inject workspace-related fields into create data.
234
+ *
235
+ * Exported (alongside `injectWhereWorkspaceId`) so consumers can unit-test
236
+ * exactly what a given `WorkspaceExtensionConfig` injects for their own
237
+ * Prisma schema — in particular, to verify `populateOnBehalfOf: false` /
238
+ * `populateContextJson: false` actually suppress `onBehalfOf`/`context`
239
+ * before wiring the extension against models that don't have those columns.
240
+ */
241
+ function injectCreateFields(data, wsCtx, config) {
242
+ const injected = { ...data };
243
+ if (wsCtx.workspaceId && !hasField(injected, "workspaceId")) injected["workspaceId"] = wsCtx.workspaceId;
244
+ if (config.populateTenantId && wsCtx.tenantId && !hasField(injected, "tenantId")) injected["tenantId"] = wsCtx.tenantId;
245
+ if (config.populateCreatedBy && wsCtx.actorId && !hasField(injected, "createdBy")) injected["createdBy"] = wsCtx.actorId;
246
+ if (config.populateUpdatedBy && wsCtx.actorId && !hasField(injected, "updatedBy")) injected["updatedBy"] = wsCtx.actorId;
247
+ if (config.populateOnBehalfOf && wsCtx.onBehalfOf && !hasField(injected, "onBehalfOf")) injected["onBehalfOf"] = wsCtx.onBehalfOf;
248
+ else if (config.populateOnBehalfOf && wsCtx.actorId && !hasField(injected, "onBehalfOf")) injected["onBehalfOf"] = wsCtx.actorId;
249
+ if (config.populateContextJson && !hasField(injected, "context")) {
250
+ const contextJson = buildContextJsonFromWorkspaceContext(wsCtx);
251
+ if (contextJson) injected["context"] = contextJson;
252
+ }
253
+ return injected;
254
+ }
255
+ /**
256
+ * Inject workspace-related fields into update data
257
+ */
258
+ function injectUpdateFields(data, wsCtx, config) {
259
+ const injected = { ...data };
260
+ if (config.populateUpdatedBy && wsCtx.actorId && !hasField(injected, "updatedBy")) injected["updatedBy"] = wsCtx.actorId;
261
+ return injected;
262
+ }
263
+ /**
264
+ * Inject workspaceId into a where clause.
265
+ * Only injects if workspaceId is available in context and not already present in where.
266
+ *
267
+ * For operations that may not have a where clause (e.g., findMany without filters),
268
+ * creates a new where object with just workspaceId.
269
+ */
270
+ function injectWhereClause(where, wsCtx) {
271
+ if (!wsCtx.workspaceId) return where;
272
+ if (!where) return { workspaceId: wsCtx.workspaceId };
273
+ if (!hasField(where, "workspaceId")) return {
274
+ ...where,
275
+ workspaceId: wsCtx.workspaceId
276
+ };
277
+ return where;
278
+ }
279
+ /**
280
+ * Build context JSON from workspace context
281
+ */
282
+ function buildContextJsonFromWorkspaceContext(wsCtx) {
283
+ const context = {};
284
+ if (wsCtx.workspaceId) context["workspaceId"] = wsCtx.workspaceId;
285
+ if (wsCtx.actorId) context["userId"] = wsCtx.actorId;
286
+ if (wsCtx.organizationId) context["organizationId"] = wsCtx.organizationId;
287
+ if (wsCtx.projectId) context["projectId"] = wsCtx.projectId;
288
+ if (wsCtx.appId) context["appId"] = wsCtx.appId;
289
+ return Object.keys(context).length > 0 ? context : void 0;
290
+ }
291
+ /**
292
+ * Inject workspaceId into where clause for read/update/delete operations.
293
+ * This is a utility function exported for services that want to manually
294
+ * add workspace scoping to their queries.
295
+ *
296
+ * @param where - The existing where clause
297
+ * @param wsCtx - The workspace context (or auto-detected from AsyncLocalStorage)
298
+ * @returns The where clause with workspaceId injected if not already present
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * import { injectWhereWorkspaceId, getWorkspaceContext } from '@burdenoff/be-sdk/prisma';
303
+ *
304
+ * const wsCtx = getWorkspaceContext();
305
+ * const where = injectWhereWorkspaceId({ status: 'ACTIVE' }, wsCtx);
306
+ * // Result: { status: 'ACTIVE', workspaceId: 'ws-123' }
307
+ * ```
308
+ */
309
+ function injectWhereWorkspaceId(where, wsCtx) {
310
+ const ctx = wsCtx ?? getWorkspaceContext();
311
+ if (!where || !ctx?.workspaceId) return where;
312
+ if (!hasField(where, "workspaceId")) return {
313
+ ...where,
314
+ workspaceId: ctx.workspaceId
315
+ };
316
+ return where;
317
+ }
318
+ /**
319
+ * Remove the _skipWorkspaceInjection flag from args before passing to Prisma.
320
+ * Using a dedicated function avoids ESLint unused-variable warnings from destructuring.
321
+ */
322
+ function stripSkipFlag(args) {
323
+ const cleaned = { ...args };
324
+ delete cleaned["_skipWorkspaceInjection"];
325
+ return cleaned;
326
+ }
327
+ /**
328
+ * Check if a model should be excluded from read isolation.
329
+ * A model is excluded if it's in excludeModels OR excludeModelsFromReadIsolation.
330
+ */
331
+ function isExcludedFromReadIsolation(model, config) {
332
+ return config.excludeModels.includes(model) || config.excludeModelsFromReadIsolation.includes(model);
333
+ }
334
+ /**
335
+ * Enforce strict mode: throw if workspace context is missing and the operation
336
+ * is not explicitly allowed to run without it.
337
+ *
338
+ * @returns true if the operation should proceed without workspace injection (non-strict or allowed)
339
+ * @throws Error if strict mode is enabled and the operation is not allowed
340
+ */
341
+ function enforceStrictMode(model, operation, wsCtx, config) {
342
+ if (wsCtx?.workspaceId) return;
343
+ if (!config.strictMode) return;
344
+ const opKey = `${model}.${operation}`;
345
+ if (config.allowedUnguardedOperations.includes(opKey)) return;
346
+ throw new Error(`[WorkspaceExtension] Workspace context required for ${model}.${operation}. No workspaceId found in request context. To bypass, either: (1) add "${model}" to excludeModels, (2) add "${opKey}" to allowedUnguardedOperations, or (3) pass _skipWorkspaceInjection: true in the query args.`);
347
+ }
348
+ /**
349
+ * WeakSet of contexts that have already had the connection tagged this request.
350
+ * WorkspaceContext objects live only for the duration of a request, so entries
351
+ * are automatically GC'd when the context goes out of scope — no manual cleanup.
352
+ */
353
+ const taggedContexts = /* @__PURE__ */ new WeakSet();
354
+ /**
355
+ * Tag the current Postgres connection with workspace attribution (once per context).
356
+ * Sets `application_name = 'svc=<name>;ws=<workspaceId>'` at the session level.
357
+ * Non-fatal: tagging failures are swallowed so the main operation still proceeds.
358
+ *
359
+ * @internal Exported for unit testing only — do not call from product code.
360
+ */
361
+ async function maybeTagConnection(rawPrisma, wsCtx) {
362
+ if (taggedContexts.has(wsCtx)) return;
363
+ taggedContexts.add(wsCtx);
364
+ const tag = `svc=${(process.env["SERVICE_NAME"] ?? "svc").replace(/[^a-zA-Z0-9\-_]/g, "")};ws=${(wsCtx.workspaceId ?? "").replace(/[^a-zA-Z0-9\-_]/g, "")}`;
365
+ try {
366
+ await rawPrisma.$executeRawUnsafe(`SET application_name = '${tag}'`);
367
+ } catch {
368
+ taggedContexts.delete(wsCtx);
369
+ }
370
+ }
371
+ /**
372
+ * WeakSet of contexts that have already had the RLS GUC set this request.
373
+ */
374
+ const rlsTaggedContexts = /* @__PURE__ */ new WeakSet();
375
+ /**
376
+ * Set `app.workspace_id` GUC for RLS enforcement (once per context, session-level).
377
+ *
378
+ * When set, RLS policies using `current_setting('app.workspace_id', true)` filter
379
+ * rows to the current workspace. Non-fatal: failures are swallowed and retried on
380
+ * the next operation via WeakSet entry removal.
381
+ *
382
+ * NOT used by the extension's operation handlers below (see
383
+ * `runOperationWithRlsGuc`) — session-level `SET` is unsafe once traffic is routed
384
+ * through PgBouncer in transaction-pooling mode (see that function's doc comment
385
+ * for the full incident writeup, BOFF-5488). Kept as a standalone export, still
386
+ * unit tested, for any caller that genuinely runs on an unpooled/session-pooled
387
+ * connection where session-level `SET` is sufficient.
388
+ *
389
+ * @internal Exported for unit testing only — do not call from product code.
390
+ */
391
+ async function maybeSetRlsGuc(rawPrisma, wsCtx) {
392
+ if (rlsTaggedContexts.has(wsCtx)) return;
393
+ rlsTaggedContexts.add(wsCtx);
394
+ const safeWs = (wsCtx.workspaceId ?? "").replace(/[^a-zA-Z0-9\-_]/g, "");
395
+ try {
396
+ await rawPrisma.$executeRawUnsafe(`SET app.workspace_id = '${safeWs}'`);
397
+ } catch {
398
+ rlsTaggedContexts.delete(wsCtx);
399
+ }
400
+ }
401
+ /**
402
+ * Prisma DMMF model name (e.g. `Customer`) -> Prisma Client delegate property
403
+ * (e.g. `customer`). Matches Prisma's own client-generation rule: lower-case the
404
+ * first character, leave the rest untouched.
405
+ */
406
+ function modelToClientProperty(model) {
407
+ return model.length > 0 ? model.charAt(0).toLowerCase() + model.slice(1) : model;
408
+ }
409
+ /**
410
+ * Run a single Prisma operation with `app.workspace_id` set as a
411
+ * **transaction-scoped** (`SET LOCAL`) GUC immediately ahead of it, so Postgres
412
+ * RLS policies using `current_setting('app.workspace_id', true)` see the right
413
+ * value for both the `USING` (read) and `WITH CHECK` (write) clauses.
414
+ *
415
+ * Session-level `SET` (`maybeSetRlsGuc` above, the original Phase 3
416
+ * implementation) is NOT safe once traffic goes through PgBouncer in
417
+ * **transaction pooling mode** — the mode configured on all four
418
+ * `boff-pg-{global,wspace}-{alpha,prod}-cin` servers' built-in PgBouncer (see
419
+ * infra-specs/current-architecture/02-database-postgres-age.md). PgBouncer hands
420
+ * the physical backend connection back to the pool after every standalone
421
+ * statement/implicit transaction, so a `SET` executed by one statement is not
422
+ * guaranteed visible to the very next one, even over what looks like the same
423
+ * logical client connection.
424
+ *
425
+ * This was exactly BOFF-5488: `wspace-movethewheels-svc`'s RLS Phase 3b (FORCE
426
+ * ROW LEVEL SECURITY + a non-owner runtime role, `wspace_movethewheels_app`,
427
+ * pointed at the pooled `:6432` connection) made the `ws_isolation` policy bind
428
+ * for real, but the session-level `SET` from `maybeSetRlsGuc` was landing on a
429
+ * different pooled backend connection than the write that followed it — so every
430
+ * write failed `WITH CHECK` (`new row violates row-level security policy`) and
431
+ * every read matched zero rows.
432
+ *
433
+ * A Prisma **interactive transaction** (`$transaction(async (tx) => …)`) pins one
434
+ * physical connection for the callback's full duration — PgBouncer sees a single
435
+ * unbroken `BEGIN … COMMIT` and cannot reassign the backend mid-transaction — so
436
+ * `SET LOCAL` inside it is guaranteed visible to the operation issued right after
437
+ * it in the same callback. Safe under transaction-mode pooling, session-mode
438
+ * pooling, and with no pooler in front of Postgres at all. The extra round trip
439
+ * (one interactive transaction instead of one direct call) only applies to
440
+ * services that opt into `enableRlsGucTagging` — off by default.
441
+ *
442
+ * @internal Legacy exported helper retained for compatibility and its historical
443
+ * tests. It reissues a model call and cannot preserve surrounding query hooks;
444
+ * addWorkspaceExtension uses the continuation-based route below instead. Do not
445
+ * call this helper from product code.
446
+ */
447
+ async function runOperationWithRlsGuc(rootClient, wsCtx, model, operation, args) {
448
+ const safeWs = (wsCtx.workspaceId ?? "").replace(/[^a-zA-Z0-9\-_]/g, "");
449
+ const clientProperty = modelToClientProperty(model);
450
+ return rootClient.$transaction(async (tx) => {
451
+ await tx.$executeRawUnsafe(`SET LOCAL app.workspace_id = '${safeWs}'`);
452
+ const method = tx[clientProperty]?.[operation];
453
+ if (typeof method !== "function") throw new Error(`[WorkspaceExtension] Unable to resolve ${model}.${operation} (client property "${clientProperty}") on the interactive-transaction client for RLS GUC tagging.`);
454
+ return method(args);
455
+ });
456
+ }
457
+ /**
458
+ * Keep the original query continuation, including later query extensions, inside
459
+ * the GUC-tagged transaction. Reissuing a model call on the root client would
460
+ * skip later hooks, or execute an earlier hook twice (BOFF-8874).
461
+ */
462
+ async function runQueryWithRlsGuc(rootClient, wsCtx, query) {
463
+ const pendingQuery = query();
464
+ const pendingContext = rootClient.$executeRawUnsafe("SELECT set_config('app.workspace_id', $1, true), set_config('statement_timeout', CASE WHEN current_setting('statement_timeout')::interval > interval '0' AND current_setting('statement_timeout')::interval < interval '5 seconds' THEN current_setting('statement_timeout') ELSE '5000ms' END, true)", sanitizeWorkspaceId(wsCtx.workspaceId));
465
+ if (typeof pendingQuery.requestTransaction !== "function" || typeof pendingContext.requestTransaction !== "function") throw new Error("[WorkspaceExtension] RLS query continuation requires transaction-bindable PrismaPromises; refusing the unsupported Prisma integration (BOFF-8874).");
466
+ const [, result] = await rootClient.$transaction([pendingContext, pendingQuery]);
467
+ return result;
468
+ }
469
+ /**
470
+ * Classify the transaction an extension callback is running in.
471
+ *
472
+ * Throws on a transaction descriptor this version does not understand rather
473
+ * than guessing: running such an operation down the standalone path would
474
+ * silently break the caller's atomicity again.
475
+ *
476
+ * @internal Exported for unit testing only — do not call from product code.
477
+ */
478
+ function getCallerTransaction(internalParams) {
479
+ const transaction = internalParams?.transaction;
480
+ if (transaction === void 0 || transaction === null) return void 0;
481
+ if (typeof transaction === "object") {
482
+ const { kind, id } = transaction;
483
+ if (kind === "itx" && typeof id === "string" && id.length > 0) return {
484
+ kind: "itx",
485
+ id,
486
+ descriptor: transaction
487
+ };
488
+ if (kind === "batch") return { kind: "batch" };
489
+ }
490
+ throw new Error("[WorkspaceExtension] Unrecognised Prisma transaction descriptor on __internalParams.transaction; refusing to run the operation outside the caller transaction. This Prisma version is not supported by the be-sdk RLS transaction integration (BOFF-8874).");
491
+ }
492
+ /** Same sanitisation as the standalone path: CUID/UUID-safe, prevents SQL injection. */
493
+ function sanitizeWorkspaceId(workspaceId) {
494
+ return (workspaceId ?? "").replace(/[^a-zA-Z0-9\-_]/g, "");
495
+ }
496
+ /** Same tag `maybeTagConnection` sets: `svc=<SERVICE_NAME>;ws=<workspaceId>`. */
497
+ function buildApplicationNameTag(wsCtx) {
498
+ return `svc=${(process.env["SERVICE_NAME"] ?? "svc").replace(/[^a-zA-Z0-9\-_]/g, "")};ws=${sanitizeWorkspaceId(wsCtx.workspaceId)}`;
499
+ }
500
+ /**
501
+ * Build the transaction-local context statement for the enabled tagging modes,
502
+ * or `undefined` when neither RLS GUC nor application_name tagging is on.
503
+ * `set_config(name, value, true)` is exactly `SET LOCAL name = value`.
504
+ *
505
+ * @internal Exported for unit testing only — do not call from product code.
506
+ */
507
+ function buildTransactionContextStatement(wsCtx, config) {
508
+ const settings = [];
509
+ const params = [];
510
+ if (config.enableRlsGucTagging) {
511
+ params.push(sanitizeWorkspaceId(wsCtx.workspaceId));
512
+ settings.push(`set_config('app.workspace_id', $${params.length}, true)`);
513
+ }
514
+ if (config.enableApplicationNameTagging) {
515
+ params.push(buildApplicationNameTag(wsCtx));
516
+ settings.push(`set_config('application_name', $${params.length}, true)`);
517
+ }
518
+ if (settings.length === 0) return void 0;
519
+ return {
520
+ sql: `SELECT ${settings.join(", ")}`,
521
+ params,
522
+ key: params.join("\0")
523
+ };
524
+ }
525
+ /**
526
+ * Context already applied per caller transaction id. Bounded: an evicted entry
527
+ * only costs one repeated context statement, never correctness.
528
+ */
529
+ const MAX_TRACKED_CALLER_TRANSACTIONS = 4096;
530
+ const callerTransactionStates = /* @__PURE__ */ new Map();
531
+ function rememberCallerTransaction(id, state) {
532
+ callerTransactionStates.delete(id);
533
+ callerTransactionStates.set(id, state);
534
+ if (callerTransactionStates.size > MAX_TRACKED_CALLER_TRANSACTIONS) {
535
+ const oldest = callerTransactionStates.keys().next().value;
536
+ if (oldest !== void 0) callerTransactionStates.delete(oldest);
537
+ }
538
+ }
539
+ async function applyCallerTransactionContext(rawPrisma, descriptor, statement) {
540
+ const pending = rawPrisma.$executeRawUnsafe(statement.sql, ...statement.params);
541
+ if (typeof pending.requestTransaction !== "function") throw new Error("[WorkspaceExtension] Cannot bind the RLS context statement to the caller transaction (PrismaPromise.requestTransaction is unavailable); refusing to run it on another connection (BOFF-8874).");
542
+ await pending.requestTransaction(descriptor);
543
+ }
544
+ /**
545
+ * Run `run` (the operation, already bound to the caller's interactive
546
+ * transaction by Prisma) after making sure that transaction carries the
547
+ * workspace context. The context statement runs on the caller's transaction,
548
+ * once per transaction level and workspace: a later operation for the same
549
+ * workspace costs no extra round trip, a workspace switch re-runs it, and so does
550
+ * the first operation after entering or leaving a nested transaction (a
551
+ * savepoint rollback reverts `SET LOCAL`, a release keeps it).
552
+ *
553
+ * Concurrent operations for *different* workspaces on one transaction cannot be
554
+ * isolated from each other, so that case throws instead of risking one running
555
+ * under the other's GUC.
556
+ *
557
+ * @internal Exported for unit testing only — do not call from product code.
558
+ */
559
+ async function runOperationInCallerTransaction(rawPrisma, transaction, wsCtx, config, run) {
560
+ const statement = buildTransactionContextStatement(wsCtx, config);
561
+ if (!statement) return run();
562
+ let state = callerTransactionStates.get(transaction.id);
563
+ if (!state || state.descriptor !== transaction.descriptor || state.key !== statement.key) {
564
+ if (state && state.inflight > 0 && state.key !== statement.key) throw new Error("[WorkspaceExtension] Concurrent operations for different workspaces inside one transaction are not supported: the RLS context is per transaction. Await the other workspace’s operations first.");
565
+ const next = {
566
+ descriptor: transaction.descriptor,
567
+ key: statement.key,
568
+ ready: applyCallerTransactionContext(rawPrisma, transaction.descriptor, statement),
569
+ inflight: 0
570
+ };
571
+ next.ready.catch(() => {
572
+ if (callerTransactionStates.get(transaction.id) === next) callerTransactionStates.delete(transaction.id);
573
+ });
574
+ rememberCallerTransaction(transaction.id, next);
575
+ state = next;
576
+ }
577
+ state.inflight += 1;
578
+ try {
579
+ await state.ready;
580
+ return await run();
581
+ } finally {
582
+ state.inflight -= 1;
583
+ }
584
+ }
585
+ /** @internal Test hook: forget all tracked caller transactions. */
586
+ function resetCallerTransactionStateForTests() {
587
+ callerTransactionStates.clear();
588
+ }
589
+ function addWorkspaceExtension(baseClient, config) {
590
+ const fullConfig = {
591
+ ...defaultWorkspaceExtensionConfig,
592
+ ...config
593
+ };
594
+ if (!fullConfig.enabled) {
595
+ logger.info("[WorkspaceExtension] Extension disabled by configuration");
596
+ return baseClient;
597
+ }
598
+ const rawPrisma = baseClient;
599
+ const rawPrismaForContinuations = baseClient;
600
+ const transactionDelegate = baseClient.$transaction;
601
+ const rawPrismaForCallerTransactions = baseClient;
602
+ const tagsTransactions = fullConfig.enableRlsGucTagging || fullConfig.enableApplicationNameTagging;
603
+ /**
604
+ * Execute an operation whose args have already been workspace-injected.
605
+ *
606
+ * - Inside a caller's interactive transaction: set the context on that
607
+ * transaction (once) and run the operation in place, so it is atomic with
608
+ * the rest of the caller's transaction and its locks last until commit.
609
+ * - Inside a batch `$transaction([...])`: run in place; the `$transaction`
610
+ * wrapper below prepended the context statement to the batch.
611
+ * - Standalone: unchanged — session application_name tag, then the
612
+ * operation in its own `SET LOCAL` transaction when RLS tagging is on.
613
+ */
614
+ const dispatch = async (params, wsCtx, _operation, finalArgs) => {
615
+ if (!tagsTransactions) return params.query(finalArgs);
616
+ const callerTransaction = getCallerTransaction(params.__internalParams);
617
+ if (callerTransaction?.kind === "itx") return runOperationInCallerTransaction(rawPrismaForCallerTransactions, callerTransaction, wsCtx, fullConfig, () => params.query(finalArgs));
618
+ if (callerTransaction?.kind === "batch") return params.query(finalArgs);
619
+ if (fullConfig.enableApplicationNameTagging) await maybeTagConnection(rawPrisma, wsCtx);
620
+ if (fullConfig.enableRlsGucTagging) return runQueryWithRlsGuc(rawPrismaForContinuations, wsCtx, () => params.query(finalArgs));
621
+ return params.query(finalArgs);
622
+ };
623
+ /**
624
+ * Raw SQL inside a caller's interactive transaction gets the same context, so
625
+ * `SELECT … FOR UPDATE` fences and raw reads/writes see the caller's workspace
626
+ * under FORCE RLS. Standalone raw SQL is unchanged (no context statement).
627
+ */
628
+ const rawOperation = async ({ args, query, __internalParams }) => {
629
+ if (!tagsTransactions) return query(args);
630
+ const callerTransaction = getCallerTransaction(__internalParams);
631
+ if (callerTransaction?.kind !== "itx") return query(args);
632
+ const wsCtx = getWorkspaceContext();
633
+ if (!wsCtx?.workspaceId) return query(args);
634
+ return runOperationInCallerTransaction(rawPrismaForCallerTransactions, callerTransaction, wsCtx, fullConfig, () => query(args));
635
+ };
636
+ const prismaClient = baseClient;
637
+ logger.info("[WorkspaceExtension] Workspace extension enabled", {
638
+ populateContextJson: fullConfig.populateContextJson,
639
+ populateCreatedBy: fullConfig.populateCreatedBy,
640
+ populateUpdatedBy: fullConfig.populateUpdatedBy,
641
+ populateTenantId: fullConfig.populateTenantId,
642
+ enableReadIsolation: fullConfig.enableReadIsolation,
643
+ enableDeleteIsolation: fullConfig.enableDeleteIsolation,
644
+ enableUpdateWhereIsolation: fullConfig.enableUpdateWhereIsolation,
645
+ strictMode: fullConfig.strictMode,
646
+ excludeModels: fullConfig.excludeModels,
647
+ excludeModelsFromReadIsolation: fullConfig.excludeModelsFromReadIsolation,
648
+ allowedUnguardedOperations: fullConfig.allowedUnguardedOperations,
649
+ enableApplicationNameTagging: fullConfig.enableApplicationNameTagging,
650
+ enableRlsGucTagging: fullConfig.enableRlsGucTagging
651
+ });
652
+ const rawOperationHooks = tagsTransactions ? {
653
+ $queryRaw: rawOperation,
654
+ $executeRaw: rawOperation,
655
+ $queryRawUnsafe: rawOperation,
656
+ $executeRawUnsafe: rawOperation,
657
+ $queryRawTyped: rawOperation
658
+ } : {};
659
+ return prismaClient.$extends({ query: {
660
+ ...rawOperationHooks,
661
+ $allModels: {
662
+ async create({ model, args, query, __internalParams }) {
663
+ if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
664
+ const wsCtx = getWorkspaceContext();
665
+ enforceStrictMode(model, "create", wsCtx, fullConfig);
666
+ if (!wsCtx?.workspaceId) return query(args);
667
+ const injectedData = injectCreateFields(args.data, wsCtx, fullConfig);
668
+ if (fullConfig.debug) {
669
+ const injectedKeys = Object.keys(injectedData).filter((k) => !(k in args.data));
670
+ if (injectedKeys.length > 0) logger.debug(`[WorkspaceExtension] ${model}.create - injected: ${injectedKeys.join(", ")}`, {
671
+ workspaceId: wsCtx.workspaceId,
672
+ actorId: wsCtx.actorId
673
+ });
674
+ }
675
+ const finalArgs = {
676
+ ...stripSkipFlag(args),
677
+ data: injectedData
678
+ };
679
+ return dispatch({
680
+ model,
681
+ query,
682
+ __internalParams
683
+ }, wsCtx, "create", finalArgs);
684
+ },
685
+ async createMany({ model, args, query, __internalParams }) {
686
+ if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
687
+ const wsCtx = getWorkspaceContext();
688
+ enforceStrictMode(model, "createMany", wsCtx, fullConfig);
689
+ if (!wsCtx?.workspaceId) return query(args);
690
+ const injectedData = (Array.isArray(args.data) ? args.data : [args.data]).map((item) => injectCreateFields(item, wsCtx, fullConfig));
691
+ const finalArgs = {
692
+ ...stripSkipFlag(args),
693
+ data: Array.isArray(args.data) ? injectedData : injectedData[0]
694
+ };
695
+ return dispatch({
696
+ model,
697
+ query,
698
+ __internalParams
699
+ }, wsCtx, "createMany", finalArgs);
700
+ },
701
+ async createManyAndReturn({ model, args, query, __internalParams }) {
702
+ if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
703
+ const wsCtx = getWorkspaceContext();
704
+ enforceStrictMode(model, "createManyAndReturn", wsCtx, fullConfig);
705
+ if (!wsCtx?.workspaceId) return query(args);
706
+ const injectedData = (Array.isArray(args.data) ? args.data : [args.data]).map((item) => injectCreateFields(item, wsCtx, fullConfig));
707
+ const finalArgs = {
708
+ ...stripSkipFlag(args),
709
+ data: Array.isArray(args.data) ? injectedData : injectedData[0]
710
+ };
711
+ return dispatch({
712
+ model,
713
+ query,
714
+ __internalParams
715
+ }, wsCtx, "createManyAndReturn", finalArgs);
716
+ },
717
+ async update({ model, args, query, __internalParams }) {
718
+ if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
719
+ const wsCtx = getWorkspaceContext();
720
+ enforceStrictMode(model, "update", wsCtx, fullConfig);
721
+ if (!wsCtx?.workspaceId) return query(args);
722
+ const injectedData = injectUpdateFields(args.data, wsCtx, fullConfig);
723
+ let injectedWhere = args.where;
724
+ if (fullConfig.enableUpdateWhereIsolation && !isExcludedFromReadIsolation(model, fullConfig)) injectedWhere = injectWhereClause(args.where, wsCtx);
725
+ if (fullConfig.debug) {
726
+ const injectedDataKeys = Object.keys(injectedData).filter((k) => !(k in args.data));
727
+ const whereChanged = injectedWhere !== args.where;
728
+ if (injectedDataKeys.length > 0 || whereChanged) logger.debug(`[WorkspaceExtension] ${model}.update - injected data: ${injectedDataKeys.join(", ")}${whereChanged ? ", where: workspaceId" : ""}`);
729
+ }
730
+ const finalArgs = {
731
+ ...stripSkipFlag(args),
732
+ data: injectedData,
733
+ where: injectedWhere
734
+ };
735
+ return dispatch({
736
+ model,
737
+ query,
738
+ __internalParams
739
+ }, wsCtx, "update", finalArgs);
740
+ },
741
+ async updateMany({ model, args, query, __internalParams }) {
742
+ if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
743
+ const wsCtx = getWorkspaceContext();
744
+ enforceStrictMode(model, "updateMany", wsCtx, fullConfig);
745
+ if (!wsCtx?.workspaceId) return query(args);
746
+ const injectedData = injectUpdateFields(args.data, wsCtx, fullConfig);
747
+ let injectedWhere = args.where;
748
+ if (fullConfig.enableUpdateWhereIsolation && !isExcludedFromReadIsolation(model, fullConfig)) injectedWhere = injectWhereClause(args.where, wsCtx);
749
+ const finalArgs = {
750
+ ...stripSkipFlag(args),
751
+ data: injectedData,
752
+ where: injectedWhere
753
+ };
754
+ return dispatch({
755
+ model,
756
+ query,
757
+ __internalParams
758
+ }, wsCtx, "updateMany", finalArgs);
759
+ },
760
+ async upsert({ model, args, query, __internalParams }) {
761
+ if (fullConfig.excludeModels.includes(model) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
762
+ const wsCtx = getWorkspaceContext();
763
+ enforceStrictMode(model, "upsert", wsCtx, fullConfig);
764
+ if (!wsCtx?.workspaceId) return query(args);
765
+ const injectedCreate = injectCreateFields(args.create, wsCtx, fullConfig);
766
+ const injectedUpdate = injectUpdateFields(args.update, wsCtx, fullConfig);
767
+ let injectedWhere = args.where;
768
+ if (fullConfig.enableUpdateWhereIsolation && !isExcludedFromReadIsolation(model, fullConfig)) injectedWhere = injectWhereClause(args.where, wsCtx);
769
+ const finalArgs = {
770
+ ...stripSkipFlag(args),
771
+ create: injectedCreate,
772
+ update: injectedUpdate,
773
+ where: injectedWhere
774
+ };
775
+ return dispatch({
776
+ model,
777
+ query,
778
+ __internalParams
779
+ }, wsCtx, "upsert", finalArgs);
780
+ },
781
+ async findMany({ model, args, query, __internalParams }) {
782
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
783
+ const wsCtx = getWorkspaceContext();
784
+ enforceStrictMode(model, "findMany", wsCtx, fullConfig);
785
+ if (!wsCtx?.workspaceId) return query(args);
786
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
787
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.findMany - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
788
+ const finalArgs = {
789
+ ...stripSkipFlag(args),
790
+ where: injectedWhere
791
+ };
792
+ return dispatch({
793
+ model,
794
+ query,
795
+ __internalParams
796
+ }, wsCtx, "findMany", finalArgs);
797
+ },
798
+ async findFirst({ model, args, query, __internalParams }) {
799
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
800
+ const wsCtx = getWorkspaceContext();
801
+ enforceStrictMode(model, "findFirst", wsCtx, fullConfig);
802
+ if (!wsCtx?.workspaceId) return query(args);
803
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
804
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.findFirst - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
805
+ const finalArgs = {
806
+ ...stripSkipFlag(args),
807
+ where: injectedWhere
808
+ };
809
+ return dispatch({
810
+ model,
811
+ query,
812
+ __internalParams
813
+ }, wsCtx, "findFirst", finalArgs);
814
+ },
815
+ async findFirstOrThrow({ model, args, query, __internalParams }) {
816
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
817
+ const wsCtx = getWorkspaceContext();
818
+ enforceStrictMode(model, "findFirstOrThrow", wsCtx, fullConfig);
819
+ if (!wsCtx?.workspaceId) return query(args);
820
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
821
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.findFirstOrThrow - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
822
+ const finalArgs = {
823
+ ...stripSkipFlag(args),
824
+ where: injectedWhere
825
+ };
826
+ return dispatch({
827
+ model,
828
+ query,
829
+ __internalParams
830
+ }, wsCtx, "findFirstOrThrow", finalArgs);
831
+ },
832
+ async findUnique({ model, args, query, __internalParams }) {
833
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
834
+ const wsCtx = getWorkspaceContext();
835
+ enforceStrictMode(model, "findUnique", wsCtx, fullConfig);
836
+ if (!wsCtx?.workspaceId) return query(args);
837
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
838
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.findUnique - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
839
+ const finalArgs = {
840
+ ...stripSkipFlag(args),
841
+ where: injectedWhere
842
+ };
843
+ return dispatch({
844
+ model,
845
+ query,
846
+ __internalParams
847
+ }, wsCtx, "findUnique", finalArgs);
848
+ },
849
+ async findUniqueOrThrow({ model, args, query, __internalParams }) {
850
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
851
+ const wsCtx = getWorkspaceContext();
852
+ enforceStrictMode(model, "findUniqueOrThrow", wsCtx, fullConfig);
853
+ if (!wsCtx?.workspaceId) return query(args);
854
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
855
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.findUniqueOrThrow - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
856
+ const finalArgs = {
857
+ ...stripSkipFlag(args),
858
+ where: injectedWhere
859
+ };
860
+ return dispatch({
861
+ model,
862
+ query,
863
+ __internalParams
864
+ }, wsCtx, "findUniqueOrThrow", finalArgs);
865
+ },
866
+ async count({ model, args, query, __internalParams }) {
867
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
868
+ const wsCtx = getWorkspaceContext();
869
+ enforceStrictMode(model, "count", wsCtx, fullConfig);
870
+ if (!wsCtx?.workspaceId) return query(args);
871
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
872
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.count - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
873
+ const finalArgs = {
874
+ ...stripSkipFlag(args),
875
+ where: injectedWhere
876
+ };
877
+ return dispatch({
878
+ model,
879
+ query,
880
+ __internalParams
881
+ }, wsCtx, "count", finalArgs);
882
+ },
883
+ async aggregate({ model, args, query, __internalParams }) {
884
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
885
+ const wsCtx = getWorkspaceContext();
886
+ enforceStrictMode(model, "aggregate", wsCtx, fullConfig);
887
+ if (!wsCtx?.workspaceId) return query(args);
888
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
889
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.aggregate - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
890
+ const finalArgs = {
891
+ ...stripSkipFlag(args),
892
+ where: injectedWhere
893
+ };
894
+ return dispatch({
895
+ model,
896
+ query,
897
+ __internalParams
898
+ }, wsCtx, "aggregate", finalArgs);
899
+ },
900
+ async groupBy({ model, args, query, __internalParams }) {
901
+ if (!fullConfig.enableReadIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
902
+ const wsCtx = getWorkspaceContext();
903
+ enforceStrictMode(model, "groupBy", wsCtx, fullConfig);
904
+ if (!wsCtx?.workspaceId) return query(args);
905
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
906
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.groupBy - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
907
+ const finalArgs = {
908
+ ...stripSkipFlag(args),
909
+ where: injectedWhere
910
+ };
911
+ return dispatch({
912
+ model,
913
+ query,
914
+ __internalParams
915
+ }, wsCtx, "groupBy", finalArgs);
916
+ },
917
+ async delete({ model, args, query, __internalParams }) {
918
+ if (!fullConfig.enableDeleteIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
919
+ const wsCtx = getWorkspaceContext();
920
+ enforceStrictMode(model, "delete", wsCtx, fullConfig);
921
+ if (!wsCtx?.workspaceId) return query(args);
922
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
923
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.delete - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
924
+ const finalArgs = {
925
+ ...stripSkipFlag(args),
926
+ where: injectedWhere
927
+ };
928
+ return dispatch({
929
+ model,
930
+ query,
931
+ __internalParams
932
+ }, wsCtx, "delete", finalArgs);
933
+ },
934
+ async deleteMany({ model, args, query, __internalParams }) {
935
+ if (!fullConfig.enableDeleteIsolation || isExcludedFromReadIsolation(model, fullConfig) || args._skipWorkspaceInjection) return query(stripSkipFlag(args));
936
+ const wsCtx = getWorkspaceContext();
937
+ enforceStrictMode(model, "deleteMany", wsCtx, fullConfig);
938
+ if (!wsCtx?.workspaceId) return query(args);
939
+ const injectedWhere = injectWhereClause(args.where, wsCtx);
940
+ if (fullConfig.debug) logger.debug(`[WorkspaceExtension] ${model}.deleteMany - injected workspaceId into where`, { workspaceId: wsCtx.workspaceId });
941
+ const finalArgs = {
942
+ ...stripSkipFlag(args),
943
+ where: injectedWhere
944
+ };
945
+ return dispatch({
946
+ model,
947
+ query,
948
+ __internalParams
949
+ }, wsCtx, "deleteMany", finalArgs);
950
+ }
951
+ }
952
+ } }).$extends({ client: { $transaction(input, options) {
953
+ const parent = this.$parent;
954
+ if (!parent) throw new Error("[WorkspaceExtension] $transaction wrapper could not resolve its parent client.");
955
+ if (Array.isArray(input)) {
956
+ const wsCtx = getWorkspaceContext();
957
+ const statement = tagsTransactions && wsCtx?.workspaceId ? buildTransactionContextStatement(wsCtx, fullConfig) : void 0;
958
+ if (statement) {
959
+ const setContext = rawPrismaForCallerTransactions.$executeRawUnsafe(statement.sql, ...statement.params);
960
+ return parent.$transaction([setContext, ...input], options).then((results) => Array.isArray(results) ? results.slice(1) : results);
961
+ }
962
+ }
963
+ if (typeof input === "function") {
964
+ const callback = input;
965
+ return transactionDelegate.call(this, async (tx) => {
966
+ const scope = { active: true };
967
+ try {
968
+ return await callback(bindTransactionContext(tx, scope, getWorkspaceContext));
969
+ } finally {
970
+ scope.active = false;
971
+ }
972
+ }, options);
973
+ }
974
+ return transactionDelegate.call(this, input, options);
975
+ } } });
976
+ }
977
+
978
+ export { getScopedWorkspaceContext as a, injectWhereWorkspaceId as c, resetCallerTransactionStateForTests as d, runOperationInCallerTransaction as f, withWorkspaceContextSync as g, withWorkspaceContext as h, getCallerTransaction as i, maybeSetRlsGuc as l, setWorkspaceContext as m, buildTransactionContextStatement as n, getWorkspaceContext as o, runOperationWithRlsGuc as p, defaultWorkspaceExtensionConfig as r, injectCreateFields as s, addWorkspaceExtension as t, maybeTagConnection as u };
979
+ //# sourceMappingURL=workspace-extension-COrC0dYi.js.map