@burdenoff/be-sdk 2026.1110.1 → 2026.1110.3

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 (469) 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/ai-credits/index.d.ts +2 -3
  8. package/dist/ai-credits/index.js +3 -4
  9. package/dist/ai-credits/index.js.map +1 -1
  10. package/dist/ai-credits-Ca-NNcVx.js +546 -0
  11. package/dist/ai-credits-Ca-NNcVx.js.map +1 -0
  12. package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
  13. package/dist/auth/index.d.ts +2 -77
  14. package/dist/auth/index.js +3 -7
  15. package/dist/auth/index.js.map +1 -1
  16. package/dist/auth-CEuBEBQN.js +228 -0
  17. package/dist/auth-CEuBEBQN.js.map +1 -0
  18. package/dist/cache/index.d.ts +2 -3
  19. package/dist/cache/index.js +3 -7
  20. package/dist/cache/index.js.map +1 -1
  21. package/dist/cache-CU0uLwcS.js +1837 -0
  22. package/dist/cache-CU0uLwcS.js.map +1 -0
  23. package/dist/captcha/index.d.ts +2 -1
  24. package/dist/captcha/index.js +3 -3
  25. package/dist/captcha/index.js.map +1 -1
  26. package/dist/captcha-BT7yh1YS.js +77 -0
  27. package/dist/captcha-BT7yh1YS.js.map +1 -0
  28. package/dist/client/internal-client.d.ts +4 -7
  29. package/dist/client/internal-client.js +172 -4
  30. package/dist/client/internal-client.js.map +1 -1
  31. package/dist/client-BgAEvDC2.d.ts +86 -0
  32. package/dist/client-DcZ3iGES.js +565 -0
  33. package/dist/client-DcZ3iGES.js.map +1 -0
  34. package/dist/collector-endpoint-iyQYeI50.js +50 -0
  35. package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
  36. package/dist/context-CZnXf2yb.js +247 -0
  37. package/dist/context-CZnXf2yb.js.map +1 -0
  38. package/dist/crypto/index.d.ts +2 -1
  39. package/dist/crypto/index.js +3 -3
  40. package/dist/crypto/index.js.map +1 -1
  41. package/dist/crypto-DO9fM0FO.js +145 -0
  42. package/dist/crypto-DO9fM0FO.js.map +1 -0
  43. package/dist/database/index.d.ts +104 -108
  44. package/dist/database/index.js +468 -6
  45. package/dist/database/index.js.map +1 -1
  46. package/dist/dataloader/index.d.ts +2 -1
  47. package/dist/dataloader/index.js +3 -3
  48. package/dist/dataloader/index.js.map +1 -1
  49. package/dist/dataloader-DwpT3YoS.js +294 -0
  50. package/dist/dataloader-DwpT3YoS.js.map +1 -0
  51. package/dist/deployed-environment-p_Tdl3sT.js +38 -0
  52. package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
  53. package/dist/dist-BGKdXVy3.js +1718 -0
  54. package/dist/dist-BGKdXVy3.js.map +1 -0
  55. package/dist/env-DdaoGjIt.js +74 -0
  56. package/dist/env-DdaoGjIt.js.map +1 -0
  57. package/dist/event-queue/index.d.ts +2 -7
  58. package/dist/event-queue/index.js +7 -9
  59. package/dist/event-queue/index.js.map +1 -1
  60. package/dist/event-queue-Cw-YJPY_.js +1384 -0
  61. package/dist/event-queue-Cw-YJPY_.js.map +1 -0
  62. package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
  63. package/dist/export/index.d.ts +2 -2
  64. package/dist/export/index.js +3 -14
  65. package/dist/export/index.js.map +1 -1
  66. package/dist/export-B6fphx8a.js +642 -0
  67. package/dist/export-B6fphx8a.js.map +1 -0
  68. package/dist/feature-flags/index.d.ts +2 -10
  69. package/dist/feature-flags/index.js +3 -6
  70. package/dist/feature-flags/index.js.map +1 -1
  71. package/dist/feature-flags-71oDkrUe.js +422 -0
  72. package/dist/feature-flags-71oDkrUe.js.map +1 -0
  73. package/dist/files/index.d.ts +2 -3
  74. package/dist/files/index.js +3 -4
  75. package/dist/files/index.js.map +1 -1
  76. package/dist/files-DjH0099H.js +830 -0
  77. package/dist/files-DjH0099H.js.map +1 -0
  78. package/dist/gateway/index.d.ts +4 -6
  79. package/dist/gateway/index.js +7 -13
  80. package/dist/gateway/index.js.map +1 -1
  81. package/dist/gateway/security/index.d.ts +2 -2
  82. package/dist/gateway/security/index.js +3 -5
  83. package/dist/gateway/security/index.js.map +1 -1
  84. package/dist/gateway-DBFmxWks.js +50 -0
  85. package/dist/gateway-DBFmxWks.js.map +1 -0
  86. package/dist/graph/index.d.ts +3 -10
  87. package/dist/graph/index.js +4 -13
  88. package/dist/graph/index.js.map +1 -1
  89. package/dist/graph-DDYgIryR.js +2152 -0
  90. package/dist/graph-DDYgIryR.js.map +1 -0
  91. package/dist/graph-emitter-CdOXP7Tn.js +621 -0
  92. package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
  93. package/dist/graphql/index.d.ts +3 -2
  94. package/dist/graphql/index.js +4 -6
  95. package/dist/graphql/index.js.map +1 -1
  96. package/dist/graphql/services/index.d.ts +2 -24
  97. package/dist/graphql/services/index.js +3 -4
  98. package/dist/graphql/services/index.js.map +1 -1
  99. package/dist/graphql-DHAHHcww.js +161 -0
  100. package/dist/graphql-DHAHHcww.js.map +1 -0
  101. package/dist/graphql-DNkMkGBZ.d.ts +21 -0
  102. package/dist/i18n/index.d.ts +3 -3
  103. package/dist/i18n/index.js +3 -4
  104. package/dist/i18n/index.js.map +1 -1
  105. package/dist/i18n-BBMYFd0P.js +860 -0
  106. package/dist/i18n-BBMYFd0P.js.map +1 -0
  107. package/dist/import-optional-peer-B82VYxeX.js +18 -0
  108. package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
  109. package/dist/index-3KOZ1zN9.d.ts +233 -0
  110. package/dist/index-BBqooJ52.d.ts +45 -0
  111. package/dist/index-BGzMYJsm.d.ts +209 -0
  112. package/dist/index-BKwHQtHQ.d.ts +63 -0
  113. package/dist/index-BMIMnp6T.d.ts +8 -0
  114. package/dist/index-BQDsNAMR.d.ts +81 -0
  115. package/dist/index-BVOL7458.d.ts +10 -0
  116. package/dist/index-BcqQs-Uq.d.ts +69 -0
  117. package/dist/index-BeVtqGO-.d.ts +208 -0
  118. package/dist/index-BiTzGUZP.d.ts +114 -0
  119. package/dist/index-BqYfCQSP.d.ts +500 -0
  120. package/dist/index-C0qLquY0.d.ts +150 -0
  121. package/dist/index-C5uEKchX.d.ts +60 -0
  122. package/dist/index-CDOqxSIi.d.ts +37 -0
  123. package/dist/index-CG6wj66Y.d.ts +148 -0
  124. package/dist/index-CIgoeobA.d.ts +145 -0
  125. package/dist/index-CPQDMSFS.d.ts +103 -0
  126. package/dist/index-CSRcgkVi.d.ts +23 -0
  127. package/dist/index-CZTnQIRU.d.ts +341 -0
  128. package/dist/index-CaM9JUcc.d.ts +144 -0
  129. package/dist/index-CkT2aUr3.d.ts +704 -0
  130. package/dist/index-CliOgq6L.d.ts +203 -0
  131. package/dist/index-CnzbJZP7.d.ts +999 -0
  132. package/dist/index-D6UeLAye.d.ts +63 -0
  133. package/dist/index-DGgh9DWn.d.ts +59 -0
  134. package/dist/index-DY3dNhMN.d.ts +420 -0
  135. package/dist/index-DZC-2o9R.d.ts +207 -0
  136. package/dist/index-DqbGqfAy.d.ts +127 -0
  137. package/dist/index-Dt1HJPTX.d.ts +12 -0
  138. package/dist/index-DtI6aBtB.d.ts +22 -0
  139. package/dist/index-FKohsiex.d.ts +38 -0
  140. package/dist/index-FbXPfen7.d.ts +132 -0
  141. package/dist/index-MArCb8Aq.d.ts +306 -0
  142. package/dist/index-N-huORcj.d.ts +303 -0
  143. package/dist/index-YOShAwkq.d.ts +45 -0
  144. package/dist/index-bZKZUvBu.d.ts +646 -0
  145. package/dist/index-yBSjMY32.d.ts +24 -0
  146. package/dist/index.d.ts +501 -544
  147. package/dist/index.js +1820 -2171
  148. package/dist/index.js.map +1 -1
  149. package/dist/init/index.d.ts +2 -2
  150. package/dist/init/index.js +3 -16
  151. package/dist/init/index.js.map +1 -1
  152. package/dist/init-Dy3KhT6Y.js +325 -0
  153. package/dist/init-Dy3KhT6Y.js.map +1 -0
  154. package/dist/instrumentation/index.d.ts +3 -4
  155. package/dist/instrumentation/index.js +5 -5
  156. package/dist/instrumentation/index.js.map +1 -1
  157. package/dist/instrumentation-xkkmDgJ0.js +1678 -0
  158. package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
  159. package/dist/lake/index.d.ts +50 -54
  160. package/dist/lake/index.js +169 -193
  161. package/dist/lake/index.js.map +1 -1
  162. package/dist/layer/index.d.ts +3 -2
  163. package/dist/layer/index.js +4 -5
  164. package/dist/layer/index.js.map +1 -1
  165. package/dist/layer-BZBZZWeV.d.ts +69 -0
  166. package/dist/layer-Bcix-WCl.js +105 -0
  167. package/dist/layer-Bcix-WCl.js.map +1 -0
  168. package/dist/layer-CEKy6cm8.js +252 -0
  169. package/dist/layer-CEKy6cm8.js.map +1 -0
  170. package/dist/lifecycle/index.d.ts +2 -1
  171. package/dist/lifecycle/index.js +3 -4
  172. package/dist/lifecycle/index.js.map +1 -1
  173. package/dist/lifecycle-DeoLSX0U.js +76 -0
  174. package/dist/lifecycle-DeoLSX0U.js.map +1 -0
  175. package/dist/logger/index.d.ts +2 -3
  176. package/dist/logger/index.js +3 -3
  177. package/dist/logger/index.js.map +1 -1
  178. package/dist/logger-B6rCpb7D.js +290 -0
  179. package/dist/logger-B6rCpb7D.js.map +1 -0
  180. package/dist/metrics/index.d.ts +13 -14
  181. package/dist/metrics/index.js +3 -4
  182. package/dist/metrics/index.js.map +1 -1
  183. package/dist/metrics-BrLwNUrb.js +52 -0
  184. package/dist/metrics-BrLwNUrb.js.map +1 -0
  185. package/dist/metrics-collector-C2eShrlW.js +922 -0
  186. package/dist/metrics-collector-C2eShrlW.js.map +1 -0
  187. package/dist/middleware/index.d.ts +3 -3
  188. package/dist/middleware/index.js +3 -4
  189. package/dist/middleware/index.js.map +1 -1
  190. package/dist/middleware-CUxJVUpD.js +1243 -0
  191. package/dist/middleware-CUxJVUpD.js.map +1 -0
  192. package/dist/middleware-Cq0zFMGp.js +253 -0
  193. package/dist/middleware-Cq0zFMGp.js.map +1 -0
  194. package/dist/notifications/index.d.ts +2 -5
  195. package/dist/notifications/index.js +3 -6
  196. package/dist/notifications/index.js.map +1 -1
  197. package/dist/notifications-CdETrtFK.js +869 -0
  198. package/dist/notifications-CdETrtFK.js.map +1 -0
  199. package/dist/observability/index.d.ts +2 -3
  200. package/dist/observability/index.js +3 -4
  201. package/dist/observability/index.js.map +1 -1
  202. package/dist/observability-DBDXipTU.js +272 -0
  203. package/dist/observability-DBDXipTU.js.map +1 -0
  204. package/dist/platform/index.d.ts +2 -1
  205. package/dist/platform/index.js +3 -5
  206. package/dist/platform/index.js.map +1 -1
  207. package/dist/platform-DZwczW7v.js +1510 -0
  208. package/dist/platform-DZwczW7v.js.map +1 -0
  209. package/dist/prisma/generator/index.d.ts +1 -1
  210. package/dist/prisma/generator/index.js +97 -84
  211. package/dist/prisma/generator/index.js.map +1 -1
  212. package/dist/prisma/index.d.ts +4 -7
  213. package/dist/prisma/index.js +5 -12
  214. package/dist/prisma/index.js.map +1 -1
  215. package/dist/prisma-BzOOdt79.js +863 -0
  216. package/dist/prisma-BzOOdt79.js.map +1 -0
  217. package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
  218. package/dist/product-alias/index.d.ts +2 -1
  219. package/dist/product-alias/index.js +3 -3
  220. package/dist/product-alias/index.js.map +1 -1
  221. package/dist/product-alias-BPqtskMq.js +273 -0
  222. package/dist/product-alias-BPqtskMq.js.map +1 -0
  223. package/dist/rbac/index.d.ts +2 -122
  224. package/dist/rbac/index.js +3 -6
  225. package/dist/rbac/index.js.map +1 -1
  226. package/dist/rbac-BB9l9Xph.js +1486 -0
  227. package/dist/rbac-BB9l9Xph.js.map +1 -0
  228. package/dist/resource-caps/index.d.ts +66 -72
  229. package/dist/resource-caps/index.js +430 -5
  230. package/dist/resource-caps/index.js.map +1 -1
  231. package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
  232. package/dist/sdk-Dju9o-sq.js +124 -0
  233. package/dist/sdk-Dju9o-sq.js.map +1 -0
  234. package/dist/security-DIG-95Ic.js +1647 -0
  235. package/dist/security-DIG-95Ic.js.map +1 -0
  236. package/dist/server/index.d.ts +7 -164
  237. package/dist/server/index.js +2000 -1507
  238. package/dist/server/index.js.map +1 -1
  239. package/dist/service-jwt-Bu-WNA_-.js +80 -0
  240. package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
  241. package/dist/services-BWzfz7vG.js +102 -0
  242. package/dist/services-BWzfz7vG.js.map +1 -0
  243. package/dist/sharding/index.d.ts +41 -44
  244. package/dist/sharding/index.js +156 -137
  245. package/dist/sharding/index.js.map +1 -1
  246. package/dist/sharing/index.d.ts +2 -1
  247. package/dist/sharing/index.js +3 -4
  248. package/dist/sharing/index.js.map +1 -1
  249. package/dist/sharing-CflDsSJ-.js +911 -0
  250. package/dist/sharing-CflDsSJ-.js.map +1 -0
  251. package/dist/stub-BqwKn4eh.js +630 -0
  252. package/dist/stub-BqwKn4eh.js.map +1 -0
  253. package/dist/tags/index.d.ts +2 -3
  254. package/dist/tags/index.js +3 -4
  255. package/dist/tags/index.js.map +1 -1
  256. package/dist/tags-B5xpbgsk.js +868 -0
  257. package/dist/{chunk-PBZFAAOM.js.map → tags-B5xpbgsk.js.map} +1 -1
  258. package/dist/telemetry/index.d.ts +64 -76
  259. package/dist/telemetry/index.js +369 -201
  260. package/dist/telemetry/index.js.map +1 -1
  261. package/dist/temporal/index.d.ts +2 -148
  262. package/dist/temporal/index.js +3 -5
  263. package/dist/temporal/index.js.map +1 -1
  264. package/dist/temporal-B534uYK8.js +706 -0
  265. package/dist/temporal-B534uYK8.js.map +1 -0
  266. package/dist/tracker/index.d.ts +5 -11
  267. package/dist/tracker/index.js +5 -20
  268. package/dist/tracker/index.js.map +1 -1
  269. package/dist/tracker-BQVoEFUo.js +839 -0
  270. package/dist/tracker-BQVoEFUo.js.map +1 -0
  271. package/dist/types-BYMYND1L.js +44 -0
  272. package/dist/types-BYMYND1L.js.map +1 -0
  273. package/dist/types-C6EKaS3V.d.ts +106 -0
  274. package/dist/types-CWybW61E.d.ts +323 -0
  275. package/dist/types-C_yfu3XK.d.ts +34 -0
  276. package/dist/types-Cj2RWXbz.js +90 -0
  277. package/dist/types-Cj2RWXbz.js.map +1 -0
  278. package/dist/types-DgaQqvxo.d.ts +70 -0
  279. package/dist/usage/index.d.ts +2 -213
  280. package/dist/usage/index.js +3 -15
  281. package/dist/usage/index.js.map +1 -1
  282. package/dist/usage-BKFZiWQn.js +682 -0
  283. package/dist/usage-BKFZiWQn.js.map +1 -0
  284. package/dist/utils/index.d.ts +2 -1
  285. package/dist/utils/index.js +3 -3
  286. package/dist/utils/index.js.map +1 -1
  287. package/dist/utils-DL85Tnbn.js +500 -0
  288. package/dist/utils-DL85Tnbn.js.map +1 -0
  289. package/dist/validation/index.d.ts +2 -2
  290. package/dist/validation/index.js +3 -3
  291. package/dist/validation/index.js.map +1 -1
  292. package/dist/validation-CPUITdMk.js +762 -0
  293. package/dist/validation-CPUITdMk.js.map +1 -0
  294. package/dist/workspace-extension-COrC0dYi.js +979 -0
  295. package/dist/workspace-extension-COrC0dYi.js.map +1 -0
  296. package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
  297. package/package.json +7 -10
  298. package/dist/EventQueueFactory-PP534MBQ.js +0 -8
  299. package/dist/EventQueueFactory-PP534MBQ.js.map +0 -1
  300. package/dist/chunk-4XIBXZ6J.js +0 -276
  301. package/dist/chunk-4XIBXZ6J.js.map +0 -1
  302. package/dist/chunk-554Z4C2K.js +0 -1006
  303. package/dist/chunk-554Z4C2K.js.map +0 -1
  304. package/dist/chunk-5CAFHK2Z.js +0 -107
  305. package/dist/chunk-5CAFHK2Z.js.map +0 -1
  306. package/dist/chunk-63ZXJ42X.js +0 -451
  307. package/dist/chunk-63ZXJ42X.js.map +0 -1
  308. package/dist/chunk-6XEXJATV.js +0 -304
  309. package/dist/chunk-6XEXJATV.js.map +0 -1
  310. package/dist/chunk-726AR6Q7.js +0 -1532
  311. package/dist/chunk-726AR6Q7.js.map +0 -1
  312. package/dist/chunk-7EISSMFP.js +0 -617
  313. package/dist/chunk-7EISSMFP.js.map +0 -1
  314. package/dist/chunk-A5F6Z5UE.js +0 -21
  315. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  316. package/dist/chunk-A6DE32ZS.js +0 -1507
  317. package/dist/chunk-A6DE32ZS.js.map +0 -1
  318. package/dist/chunk-BJQOGOVW.js +0 -602
  319. package/dist/chunk-BJQOGOVW.js.map +0 -1
  320. package/dist/chunk-CFXWH2IS.js +0 -52
  321. package/dist/chunk-CFXWH2IS.js.map +0 -1
  322. package/dist/chunk-DIOS6L7M.js +0 -690
  323. package/dist/chunk-DIOS6L7M.js.map +0 -1
  324. package/dist/chunk-DJNHR37J.js +0 -1185
  325. package/dist/chunk-DJNHR37J.js.map +0 -1
  326. package/dist/chunk-DRWH5XCJ.js +0 -876
  327. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  328. package/dist/chunk-E4QNLVY4.js +0 -909
  329. package/dist/chunk-E4QNLVY4.js.map +0 -1
  330. package/dist/chunk-E6OAFS7A.js +0 -1346
  331. package/dist/chunk-E6OAFS7A.js.map +0 -1
  332. package/dist/chunk-EBDHIL7V.js +0 -774
  333. package/dist/chunk-EBDHIL7V.js.map +0 -1
  334. package/dist/chunk-ELU7VL3E.js +0 -245
  335. package/dist/chunk-ELU7VL3E.js.map +0 -1
  336. package/dist/chunk-FZRODKIN.js +0 -31
  337. package/dist/chunk-FZRODKIN.js.map +0 -1
  338. package/dist/chunk-GCIB76AJ.js +0 -882
  339. package/dist/chunk-GCIB76AJ.js.map +0 -1
  340. package/dist/chunk-HC6MPUIH.js +0 -1571
  341. package/dist/chunk-HC6MPUIH.js.map +0 -1
  342. package/dist/chunk-I3KOWRT3.js +0 -89
  343. package/dist/chunk-I3KOWRT3.js.map +0 -1
  344. package/dist/chunk-ID3WR4JS.js +0 -509
  345. package/dist/chunk-ID3WR4JS.js.map +0 -1
  346. package/dist/chunk-JVMAQOA3.js +0 -521
  347. package/dist/chunk-JVMAQOA3.js.map +0 -1
  348. package/dist/chunk-K56L7NUR.js +0 -1444
  349. package/dist/chunk-K56L7NUR.js.map +0 -1
  350. package/dist/chunk-KH4TRQCO.js +0 -1063
  351. package/dist/chunk-KH4TRQCO.js.map +0 -1
  352. package/dist/chunk-KJOSPVB2.js +0 -57
  353. package/dist/chunk-KJOSPVB2.js.map +0 -1
  354. package/dist/chunk-KO2ZXZ7W.js +0 -61
  355. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  356. package/dist/chunk-KS2HQCJR.js +0 -56
  357. package/dist/chunk-KS2HQCJR.js.map +0 -1
  358. package/dist/chunk-LA5KPWZ2.js +0 -413
  359. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  360. package/dist/chunk-MESLAC5W.js +0 -574
  361. package/dist/chunk-MESLAC5W.js.map +0 -1
  362. package/dist/chunk-MWPYA2HD.js +0 -94
  363. package/dist/chunk-MWPYA2HD.js.map +0 -1
  364. package/dist/chunk-NUB5GQTU.js +0 -270
  365. package/dist/chunk-NUB5GQTU.js.map +0 -1
  366. package/dist/chunk-O2JMZHNH.js +0 -1908
  367. package/dist/chunk-O2JMZHNH.js.map +0 -1
  368. package/dist/chunk-OBBCR6WY.js +0 -277
  369. package/dist/chunk-OBBCR6WY.js.map +0 -1
  370. package/dist/chunk-OBZQ4AJC.js +0 -272
  371. package/dist/chunk-OBZQ4AJC.js.map +0 -1
  372. package/dist/chunk-OXNCBE7P.js +0 -971
  373. package/dist/chunk-OXNCBE7P.js.map +0 -1
  374. package/dist/chunk-PBZFAAOM.js +0 -941
  375. package/dist/chunk-PYD44IHJ.js +0 -728
  376. package/dist/chunk-PYD44IHJ.js.map +0 -1
  377. package/dist/chunk-QVPIACWD.js +0 -679
  378. package/dist/chunk-QVPIACWD.js.map +0 -1
  379. package/dist/chunk-QWNNFE4P.js +0 -41
  380. package/dist/chunk-QWNNFE4P.js.map +0 -1
  381. package/dist/chunk-RU266375.js +0 -327
  382. package/dist/chunk-RU266375.js.map +0 -1
  383. package/dist/chunk-RYTSVGGA.js +0 -1624
  384. package/dist/chunk-RYTSVGGA.js.map +0 -1
  385. package/dist/chunk-RZOFS2BQ.js +0 -225
  386. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  387. package/dist/chunk-SBS4S2PJ.js +0 -100
  388. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  389. package/dist/chunk-SPRG6G6G.js +0 -530
  390. package/dist/chunk-SPRG6G6G.js.map +0 -1
  391. package/dist/chunk-STWFX5E2.js +0 -233
  392. package/dist/chunk-STWFX5E2.js.map +0 -1
  393. package/dist/chunk-UNASM5VJ.js +0 -419
  394. package/dist/chunk-UNASM5VJ.js.map +0 -1
  395. package/dist/chunk-VAT66FJA.js +0 -245
  396. package/dist/chunk-VAT66FJA.js.map +0 -1
  397. package/dist/chunk-VFCMR5GX.js +0 -49
  398. package/dist/chunk-VFCMR5GX.js.map +0 -1
  399. package/dist/chunk-VGAHZKNJ.js +0 -66
  400. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  401. package/dist/chunk-VTJTAAXC.js +0 -627
  402. package/dist/chunk-VTJTAAXC.js.map +0 -1
  403. package/dist/chunk-VXVLKRU6.js +0 -758
  404. package/dist/chunk-VXVLKRU6.js.map +0 -1
  405. package/dist/chunk-WWUU5ETI.js +0 -163
  406. package/dist/chunk-WWUU5ETI.js.map +0 -1
  407. package/dist/chunk-XE4OXN2W.js +0 -10
  408. package/dist/chunk-XE4OXN2W.js.map +0 -1
  409. package/dist/chunk-XOJORS75.js +0 -1853
  410. package/dist/chunk-XOJORS75.js.map +0 -1
  411. package/dist/chunk-YMZEUTD2.js +0 -110
  412. package/dist/chunk-YMZEUTD2.js.map +0 -1
  413. package/dist/chunk-ZZK3WEDI.js +0 -181
  414. package/dist/chunk-ZZK3WEDI.js.map +0 -1
  415. package/dist/client-CCXpAZ2r.d.ts +0 -89
  416. package/dist/client-DSI_760t.d.ts +0 -36
  417. package/dist/client-JU6T3UPB.js +0 -11
  418. package/dist/client-JU6T3UPB.js.map +0 -1
  419. package/dist/dist-2X4Q7PJA.js +0 -1491
  420. package/dist/dist-2X4Q7PJA.js.map +0 -1
  421. package/dist/env-4UWSUS64.js +0 -4
  422. package/dist/env-4UWSUS64.js.map +0 -1
  423. package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
  424. package/dist/graphql-CMHMQjvd.d.ts +0 -23
  425. package/dist/i18n-Qm2AkPC-.d.ts +0 -33
  426. package/dist/index--yvpa6ay.d.ts +0 -83
  427. package/dist/index-4gKQKZ2B.d.ts +0 -71
  428. package/dist/index-5x0XMKXN.d.ts +0 -149
  429. package/dist/index-B70b5mYS.d.ts +0 -33
  430. package/dist/index-B8KrxO4j.d.ts +0 -755
  431. package/dist/index-BOuDKnqD.d.ts +0 -201
  432. package/dist/index-BTMt4OjA.d.ts +0 -201
  433. package/dist/index-BejbszA7.d.ts +0 -39
  434. package/dist/index-BkeOYZye.d.ts +0 -198
  435. package/dist/index-BuAj5nXg.d.ts +0 -83
  436. package/dist/index-BvkVcW8I.d.ts +0 -349
  437. package/dist/index-CWmH_-RZ.d.ts +0 -247
  438. package/dist/index-CbgWNcus.d.ts +0 -258
  439. package/dist/index-CmfPeQza.d.ts +0 -166
  440. package/dist/index-CmpG-zak.d.ts +0 -607
  441. package/dist/index-CoMKgL-p.d.ts +0 -12
  442. package/dist/index-D8HGwglK.d.ts +0 -541
  443. package/dist/index-DCaVm66D.d.ts +0 -1101
  444. package/dist/index-DE2w7E0d.d.ts +0 -83
  445. package/dist/index-DSOpj8DI.d.ts +0 -17
  446. package/dist/index-DW9q22GH.d.ts +0 -75
  447. package/dist/index-DnjJ9CwI.d.ts +0 -347
  448. package/dist/index-DwMJZ8PP.d.ts +0 -317
  449. package/dist/index-PaojfSdd.d.ts +0 -71
  450. package/dist/index-aHtYvc3i.d.ts +0 -284
  451. package/dist/index-e_18DzAg.d.ts +0 -18
  452. package/dist/index-ffmipXSA.d.ts +0 -55
  453. package/dist/index-joONjwLt.d.ts +0 -33
  454. package/dist/index-kssw5ziY.d.ts +0 -250
  455. package/dist/index-lFffh5-G.d.ts +0 -125
  456. package/dist/index-pxYge_6k.d.ts +0 -79
  457. package/dist/layer-Cv9vSwBx.d.ts +0 -70
  458. package/dist/pino-logger-H4HPW5P6.js +0 -5
  459. package/dist/pino-logger-H4HPW5P6.js.map +0 -1
  460. package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
  461. package/dist/sdk-L75WWUP3.js +0 -156
  462. package/dist/sdk-L75WWUP3.js.map +0 -1
  463. package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
  464. package/dist/types-Bo2wkjSP.d.ts +0 -35
  465. package/dist/types-DVpvrAhd.d.ts +0 -71
  466. package/dist/types-DgJ4lDYA.d.ts +0 -108
  467. package/dist/types-USOv09qy.d.ts +0 -327
  468. package/dist/workspace-guard-NXVYYBVJ.js +0 -5
  469. package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
@@ -0,0 +1,911 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-ad2WFvuA.js";
2
+ import { a as logger } from "./logger-B6rCpb7D.js";
3
+ import { GraphQLError } from "graphql";
4
+ import { randomBytes } from "node:crypto";
5
+
6
+ // src/sharing/types.ts
7
+ /**
8
+ * Generic Sharing — canonical domain types
9
+ *
10
+ * One sharing model for every entity across the platform (sessions, vibes,
11
+ * vibedecks, files, folders, notes, …). Each service pastes the `ShareGrant`
12
+ * Prisma model (see `prisma-fragment.ts`) into its own schema and drives all
13
+ * share/accept/permission logic through `ShareService` (see `share-service.ts`).
14
+ *
15
+ * The module owns ZERO database tables — three services keep three Postgres DBs,
16
+ * so it talks to whatever Prisma client the host generates via the structural
17
+ * {@link ShareGrantDelegate} type and never imports a concrete `@prisma/client`.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { ShareService, ShareRole, ShareVisibility } from '@burdenoff/be-sdk/sharing';
22
+ * ```
23
+ */
24
+ /** Who can reach a shared resource. */
25
+ let ShareVisibility = /* @__PURE__ */ function(ShareVisibility) {
26
+ /** Only the creator/owner. */
27
+ ShareVisibility["PRIVATE"] = "PRIVATE";
28
+ /** Specific people, by email invite + EXPLICIT accept (no access before accept). */
29
+ ShareVisibility["SHARED_WITH_USERS"] = "SHARED_WITH_USERS";
30
+ /** Everyone who has access to the parent Vibe. */
31
+ ShareVisibility["SHARED_WITH_VIBE"] = "SHARED_WITH_VIBE";
32
+ /** Anyone with the link. */
33
+ ShareVisibility["PUBLIC_LINK"] = "PUBLIC_LINK";
34
+ return ShareVisibility;
35
+ }({});
36
+ /**
37
+ * The canonical permission ladder (ordinal: VIEWER < COMMENTER < EDITOR < MANAGER).
38
+ * Mapped to per-entity verbs via {@link RESOURCE_CAPABILITY_MAP}.
39
+ */
40
+ let ShareRole = /* @__PURE__ */ function(ShareRole) {
41
+ /** Read only. */
42
+ ShareRole["VIEWER"] = "VIEWER";
43
+ /** Read + comment. */
44
+ ShareRole["COMMENTER"] = "COMMENTER";
45
+ /** Read + edit/run (session INTERACT, vibedeck EXECUTE, file EDIT). */
46
+ ShareRole["EDITOR"] = "EDITOR";
47
+ /** Edit + re-share + revoke. */
48
+ ShareRole["MANAGER"] = "MANAGER";
49
+ return ShareRole;
50
+ }({});
51
+ /** Lifecycle of a share grant. */
52
+ let ShareStatus = /* @__PURE__ */ function(ShareStatus) {
53
+ /** Invited; recipient has NOT accepted — grants NO access. */
54
+ ShareStatus["PENDING"] = "PENDING";
55
+ /** Accepted (or immediately-active for public links) — grants access. */
56
+ ShareStatus["ACCEPTED"] = "ACCEPTED";
57
+ /** Manually revoked. */
58
+ ShareStatus["REVOKED"] = "REVOKED";
59
+ /** Past its expiry. */
60
+ ShareStatus["EXPIRED"] = "EXPIRED";
61
+ return ShareStatus;
62
+ }({});
63
+ /** Ordinal rank used for `>=` role comparisons. */
64
+ const ROLE_ORDER = {
65
+ ["VIEWER"]: 0,
66
+ ["COMMENTER"]: 1,
67
+ ["EDITOR"]: 2,
68
+ ["MANAGER"]: 3
69
+ };
70
+ /** True when `role` is at least as powerful as `required`. */
71
+ function roleAtLeast(role, required) {
72
+ return ROLE_ORDER[role] >= ROLE_ORDER[required];
73
+ }
74
+ /** Returns the more powerful of two roles. */
75
+ function maxRole(a, b) {
76
+ return ROLE_ORDER[a] >= ROLE_ORDER[b] ? a : b;
77
+ }
78
+ const ROLE_CAPABILITIES = {
79
+ ["VIEWER"]: {
80
+ canView: true,
81
+ canComment: false,
82
+ canEdit: false,
83
+ canManage: false,
84
+ canExecute: false
85
+ },
86
+ ["COMMENTER"]: {
87
+ canView: true,
88
+ canComment: true,
89
+ canEdit: false,
90
+ canManage: false,
91
+ canExecute: false
92
+ },
93
+ ["EDITOR"]: {
94
+ canView: true,
95
+ canComment: true,
96
+ canEdit: true,
97
+ canManage: false,
98
+ canExecute: true
99
+ },
100
+ ["MANAGER"]: {
101
+ canView: true,
102
+ canComment: true,
103
+ canEdit: true,
104
+ canManage: true,
105
+ canExecute: true
106
+ }
107
+ };
108
+ /** Resolve the capability set for a role. */
109
+ function capabilitiesFor(role) {
110
+ return ROLE_CAPABILITIES[role];
111
+ }
112
+ /**
113
+ * Per-entity translation of the canonical role to the entity's legacy permission
114
+ * verb, for resolvers/data that still speak the old vocabulary. Unmapped
115
+ * (resourceType, role) pairs fall back to the role name itself.
116
+ */
117
+ const RESOURCE_CAPABILITY_MAP = {
118
+ session: {
119
+ ["VIEWER"]: "VIEW",
120
+ ["COMMENTER"]: "VIEW",
121
+ ["EDITOR"]: "INTERACT",
122
+ ["MANAGER"]: "INTERACT"
123
+ },
124
+ vibedeck: {
125
+ ["VIEWER"]: "VIEW",
126
+ ["COMMENTER"]: "VIEW",
127
+ ["EDITOR"]: "EXECUTE",
128
+ ["MANAGER"]: "EXECUTE"
129
+ },
130
+ file: {
131
+ ["VIEWER"]: "VIEW",
132
+ ["COMMENTER"]: "COMMENT",
133
+ ["EDITOR"]: "EDIT",
134
+ ["MANAGER"]: "EDIT"
135
+ },
136
+ folder: {
137
+ ["VIEWER"]: "VIEW",
138
+ ["COMMENTER"]: "COMMENT",
139
+ ["EDITOR"]: "EDIT",
140
+ ["MANAGER"]: "EDIT"
141
+ }
142
+ };
143
+ /** Map a canonical role to a resource's legacy permission verb. */
144
+ function roleToLegacy(resourceType, role) {
145
+ return RESOURCE_CAPABILITY_MAP[resourceType]?.[role] ?? role;
146
+ }
147
+ /**
148
+ * Map a legacy permission verb back to the canonical role for backfills.
149
+ * Unknown verbs default to VIEWER (least privilege).
150
+ */
151
+ function legacyToRole(resourceType, legacy) {
152
+ const table = RESOURCE_CAPABILITY_MAP[resourceType];
153
+ if (table) {
154
+ for (const role of [
155
+ "VIEWER",
156
+ "COMMENTER",
157
+ "EDITOR",
158
+ "MANAGER"
159
+ ]) if (table[role] === legacy) return role;
160
+ }
161
+ switch (legacy.toUpperCase()) {
162
+ case "MANAGER":
163
+ case "OWNER":
164
+ case "ADMIN": return "MANAGER";
165
+ case "EDITOR":
166
+ case "EDIT":
167
+ case "INTERACT":
168
+ case "EXECUTE":
169
+ case "WRITE": return "EDITOR";
170
+ case "COMMENTER":
171
+ case "COMMENT": return "COMMENTER";
172
+ default: return "VIEWER";
173
+ }
174
+ }
175
+ /**
176
+ * Normalize a legacy status string onto the canonical ladder. Older share tables
177
+ * used `ACTIVE`; the canonical model uses `ACCEPTED`. Everything else maps 1:1.
178
+ */
179
+ function normalizeStatus(status) {
180
+ const upper = status.toUpperCase();
181
+ if (upper === "ACTIVE") return "ACCEPTED";
182
+ if (upper in ShareStatus) return upper;
183
+ return "PENDING";
184
+ }
185
+
186
+ // src/sharing/share-service.ts
187
+ /**
188
+ * ShareService — generic, framework-agnostic share/accept/permission engine.
189
+ *
190
+ * Construct one per request, bound to a single resourceType:
191
+ * ```ts
192
+ * const svc = new ShareService({
193
+ * prisma: ctx.prisma.shareGrant as unknown as ShareGrantDelegate,
194
+ * resourceType: 'session',
195
+ * workspaceId: ctx.workspace.id,
196
+ * deps: { ... },
197
+ * });
198
+ * ```
199
+ *
200
+ * The security-critical primitive is {@link ShareService.canAccess}: it is
201
+ * default-DENY, ignores PENDING grants (no access before accept), and fails
202
+ * CLOSED on any thrown dependency.
203
+ */
204
+ const ACTIVE_STATUSES = ["ACCEPTED"];
205
+ const DENY = {
206
+ allowed: false,
207
+ effectiveRole: null,
208
+ via: "none"
209
+ };
210
+ function notFound(message = "Not found") {
211
+ return new GraphQLError(message, { extensions: { code: "NOT_FOUND" } });
212
+ }
213
+ function forbidden(message = "Forbidden") {
214
+ return new GraphQLError(message, { extensions: { code: "FORBIDDEN" } });
215
+ }
216
+ function badRequest(message) {
217
+ return new GraphQLError(message, { extensions: { code: "BAD_REQUEST" } });
218
+ }
219
+ function generateToken() {
220
+ return randomBytes(32).toString("hex");
221
+ }
222
+ function emailsMatch(a, b) {
223
+ return !!a && !!b && a.trim().toLowerCase() === b.trim().toLowerCase();
224
+ }
225
+ /** Highest-role candidate, or null when there are none. */
226
+ function pickHighestRole(candidates) {
227
+ let best = null;
228
+ for (const c of candidates) if (!best || maxRole(best.role, c.role) === c.role && c.role !== best.role) best = c;
229
+ return best;
230
+ }
231
+ var ShareService = class {
232
+ prisma;
233
+ resourceType;
234
+ workspaceId;
235
+ deps;
236
+ sharedWithVibeRole;
237
+ requireWorkspaceMember;
238
+ constructor(config) {
239
+ this.prisma = config.prisma;
240
+ this.resourceType = config.resourceType;
241
+ this.workspaceId = config.workspaceId;
242
+ this.deps = config.deps;
243
+ this.sharedWithVibeRole = config.options?.sharedWithVibeRole ?? "VIEWER";
244
+ this.requireWorkspaceMember = config.options?.requireWorkspaceMember ?? true;
245
+ }
246
+ /**
247
+ * Resolve the EFFECTIVE access of `actorId` on `resourceId`.
248
+ *
249
+ * Default-DENY. Considers (highest wins): owner ⇒ MANAGER, an active
250
+ * PUBLIC_LINK grant ⇒ its role, SHARED_WITH_VIBE + hasVibeAccess ⇒ baseline,
251
+ * an ACCEPTED (never PENDING) non-expired SHARED_WITH_USERS grant ⇒ its role.
252
+ * Fails CLOSED if a dependency throws.
253
+ */
254
+ async resolveAccess(actorId, resourceId) {
255
+ try {
256
+ const meta = await this.deps.loadResourceMeta(resourceId);
257
+ if (!meta) return DENY;
258
+ if (actorId && meta.ownerId === actorId) return {
259
+ allowed: true,
260
+ effectiveRole: "MANAGER",
261
+ via: "owner"
262
+ };
263
+ const candidates = [];
264
+ if (meta.visibility === "SHARED_WITH_VIBE" && meta.vibeId && actorId) {
265
+ if (await this.deps.hasVibeAccess(actorId, meta.vibeId, this.workspaceId)) candidates.push({
266
+ role: this.sharedWithVibeRole,
267
+ via: "vibe"
268
+ });
269
+ }
270
+ for (const grant of await this.queryActiveAccessGrants(actorId, resourceId)) {
271
+ const isPublic = grant.visibility === "PUBLIC_LINK";
272
+ const isMyUserGrant = grant.visibility === "SHARED_WITH_USERS" && grant.granteeUserId === actorId;
273
+ if (isPublic) candidates.push({
274
+ role: grant.role,
275
+ via: "public_link"
276
+ });
277
+ else if (isMyUserGrant) candidates.push({
278
+ role: grant.role,
279
+ via: "user_grant"
280
+ });
281
+ }
282
+ const best = pickHighestRole(candidates);
283
+ if (!best) return DENY;
284
+ return {
285
+ allowed: true,
286
+ effectiveRole: best.role,
287
+ via: best.via
288
+ };
289
+ } catch (err) {
290
+ logger.warn("[ShareService] resolveAccess failed; denying", {
291
+ resourceType: this.resourceType,
292
+ resourceId,
293
+ err
294
+ });
295
+ return DENY;
296
+ }
297
+ }
298
+ /** Active (non-expired) PUBLIC_LINK grants + this actor's SHARED_WITH_USERS grants. */
299
+ async queryActiveAccessGrants(actorId, resourceId) {
300
+ return this.prisma.findMany({ where: {
301
+ resourceType: this.resourceType,
302
+ resourceId,
303
+ deletedAt: null,
304
+ status: { in: [...ACTIVE_STATUSES] },
305
+ OR: [{ visibility: "PUBLIC_LINK" }, ...actorId ? [{
306
+ granteeUserId: actorId,
307
+ visibility: "SHARED_WITH_USERS"
308
+ }] : []],
309
+ AND: [{ OR: [{ expiresAt: null }, { expiresAt: { gt: /* @__PURE__ */ new Date() } }] }]
310
+ } });
311
+ }
312
+ /** True if `actorId` may act on `resourceId` at >= `requiredRole`. */
313
+ async canAccess(actorId, resourceId, requiredRole) {
314
+ const result = await this.resolveAccess(actorId, resourceId);
315
+ return result.allowed && result.effectiveRole !== null && roleAtLeast(result.effectiveRole, requiredRole);
316
+ }
317
+ /** Assert >= requiredRole; throws NOT_FOUND (read) / FORBIDDEN (mutate) otherwise. */
318
+ async assertAccess(actorId, resourceId, requiredRole, mode = "read") {
319
+ if (await this.canAccess(actorId, resourceId, requiredRole)) return;
320
+ throw mode === "read" ? notFound() : forbidden("You do not have permission to perform this action");
321
+ }
322
+ /** Invite a specific person by email (PENDING + token + email). */
323
+ async createUserShare(actor, input) {
324
+ const meta = await this.deps.loadResourceMeta(input.resourceId);
325
+ if (!meta) throw notFound("Resource not found");
326
+ await this.assertAccess(actor.id, input.resourceId, "MANAGER", "mutate");
327
+ const email = input.granteeEmail.trim().toLowerCase();
328
+ if (!email) throw badRequest("A recipient email is required");
329
+ const granteeUserId = await this.deps.resolveUserByEmail(email);
330
+ if (granteeUserId && granteeUserId === actor.id) throw badRequest("You cannot share a resource with yourself");
331
+ if (granteeUserId && this.requireWorkspaceMember) {
332
+ if (await this.deps.isWorkspaceMember(granteeUserId, this.workspaceId) === false) throw forbidden("You can only share with members of this workspace");
333
+ }
334
+ const existing = await this.prisma.findFirst({ where: {
335
+ resourceType: this.resourceType,
336
+ resourceId: input.resourceId,
337
+ deletedAt: null,
338
+ status: { in: ["PENDING", "ACCEPTED"] },
339
+ OR: [...granteeUserId ? [{ granteeUserId }] : [], { granteeEmail: email }]
340
+ } });
341
+ let grant;
342
+ if (existing) grant = await this.prisma.update({
343
+ where: { id: existing.id },
344
+ data: {
345
+ role: input.role,
346
+ message: input.message ?? null,
347
+ expiresAt: input.expiresAt ?? null,
348
+ ...granteeUserId && !existing.granteeUserId ? { granteeUserId } : {}
349
+ }
350
+ });
351
+ else grant = await this.prisma.create({ data: {
352
+ workspaceId: this.workspaceId,
353
+ resourceType: this.resourceType,
354
+ resourceId: input.resourceId,
355
+ granteeUserId: granteeUserId ?? null,
356
+ granteeEmail: email,
357
+ role: input.role,
358
+ visibility: "SHARED_WITH_USERS",
359
+ status: "PENDING",
360
+ token: generateToken(),
361
+ expiresAt: input.expiresAt ?? null,
362
+ message: input.message ?? null,
363
+ createdBy: actor.id,
364
+ onBehalfOf: actor.id
365
+ } });
366
+ await this.fireShareEmail(actor, grant, meta.name);
367
+ return grant;
368
+ }
369
+ /** Create an immediately-active public link (anyone with the URL). */
370
+ async createLinkShare(actor, input) {
371
+ if (!await this.deps.loadResourceMeta(input.resourceId)) throw notFound("Resource not found");
372
+ await this.assertAccess(actor.id, input.resourceId, "MANAGER", "mutate");
373
+ return this.prisma.create({ data: {
374
+ workspaceId: this.workspaceId,
375
+ resourceType: this.resourceType,
376
+ resourceId: input.resourceId,
377
+ granteeUserId: null,
378
+ granteeEmail: null,
379
+ role: input.role,
380
+ visibility: "PUBLIC_LINK",
381
+ status: "ACCEPTED",
382
+ token: generateToken(),
383
+ expiresAt: input.expiresAt ?? null,
384
+ message: null,
385
+ createdBy: actor.id,
386
+ onBehalfOf: actor.id
387
+ } });
388
+ }
389
+ /** Explicitly accept a SHARED_WITH_USERS invite. Idempotent. */
390
+ async acceptShare(token, actor) {
391
+ const grant = await this.findActiveByToken(token);
392
+ if (!grant) throw notFound("This share link is invalid or has expired");
393
+ if (grant.visibility === "PUBLIC_LINK") return grant;
394
+ const idMatches = !!grant.granteeUserId && grant.granteeUserId === actor.id;
395
+ const emailMatches = emailsMatch(grant.granteeEmail, actor.email);
396
+ if (!idMatches && !emailMatches) throw forbidden("This invitation was sent to a different account");
397
+ if (grant.status === "ACCEPTED") {
398
+ if (!grant.granteeUserId) return this.prisma.update({
399
+ where: { id: grant.id },
400
+ data: { granteeUserId: actor.id }
401
+ });
402
+ return grant;
403
+ }
404
+ const now = /* @__PURE__ */ new Date();
405
+ if ((await this.prisma.updateMany({
406
+ where: {
407
+ id: grant.id,
408
+ status: "PENDING"
409
+ },
410
+ data: {
411
+ status: "ACCEPTED",
412
+ acceptedAt: now,
413
+ acceptedBy: actor.id,
414
+ granteeUserId: actor.id
415
+ }
416
+ })).count === 0) {
417
+ const fresh = await this.prisma.findFirst({ where: { id: grant.id } });
418
+ if (fresh) return fresh;
419
+ }
420
+ const updated = await this.prisma.findFirst({ where: { id: grant.id } });
421
+ if (!updated) throw notFound();
422
+ return updated;
423
+ }
424
+ /** Decline an invite (marks it REVOKED). */
425
+ async declineShare(token, actor) {
426
+ const grant = await this.findActiveByToken(token);
427
+ if (!grant) return false;
428
+ const idMatches = !!grant.granteeUserId && grant.granteeUserId === actor.id;
429
+ const emailMatches = emailsMatch(grant.granteeEmail, actor.email);
430
+ if (!idMatches && !emailMatches) throw forbidden("This invitation was sent to a different account");
431
+ await this.prisma.update({
432
+ where: { id: grant.id },
433
+ data: {
434
+ status: "REVOKED",
435
+ revokedAt: /* @__PURE__ */ new Date(),
436
+ revokedBy: actor.id
437
+ }
438
+ });
439
+ return true;
440
+ }
441
+ /** Public preview of a grant by token (safe fields only — never the resource body). */
442
+ async shareGrantByToken(token) {
443
+ return this.findActiveByToken(token);
444
+ }
445
+ /** Revoke a grant or link. Owner/MANAGER only. */
446
+ async revoke(grantId, actor) {
447
+ const grant = await this.prisma.findFirst({ where: {
448
+ id: grantId,
449
+ resourceType: this.resourceType
450
+ } });
451
+ if (!grant || grant.deletedAt) throw notFound();
452
+ await this.assertAccess(actor.id, grant.resourceId, "MANAGER", "mutate");
453
+ return this.prisma.update({
454
+ where: { id: grantId },
455
+ data: {
456
+ status: "REVOKED",
457
+ revokedAt: /* @__PURE__ */ new Date(),
458
+ revokedBy: actor.id
459
+ }
460
+ });
461
+ }
462
+ /** Change the role on a grant. Owner/MANAGER only. */
463
+ async updateRole(grantId, role, actor) {
464
+ const grant = await this.prisma.findFirst({ where: {
465
+ id: grantId,
466
+ resourceType: this.resourceType
467
+ } });
468
+ if (!grant || grant.deletedAt) throw notFound();
469
+ await this.assertAccess(actor.id, grant.resourceId, "MANAGER", "mutate");
470
+ return this.prisma.update({
471
+ where: { id: grantId },
472
+ data: { role }
473
+ });
474
+ }
475
+ /** All active grants on a resource (caller must be owner/MANAGER — gate in resolver). */
476
+ async resourceShares(resourceId) {
477
+ return this.prisma.findMany({
478
+ where: {
479
+ resourceType: this.resourceType,
480
+ resourceId,
481
+ deletedAt: null,
482
+ status: { in: ["PENDING", "ACCEPTED"] }
483
+ },
484
+ orderBy: { createdAt: "desc" }
485
+ });
486
+ }
487
+ /** Grants where the actor is the (accepted-or-pending) grantee. */
488
+ async sharesSharedWithMe(actorId, opts) {
489
+ return this.prisma.findMany({
490
+ where: {
491
+ ...opts?.resourceType ? { resourceType: opts.resourceType } : {},
492
+ granteeUserId: actorId,
493
+ deletedAt: null,
494
+ status: "ACCEPTED",
495
+ OR: [{ expiresAt: null }, { expiresAt: { gt: /* @__PURE__ */ new Date() } }]
496
+ },
497
+ orderBy: { acceptedAt: "desc" },
498
+ take: opts?.take,
499
+ skip: opts?.skip
500
+ });
501
+ }
502
+ /**
503
+ * Resource ids the actor can see via an ACCEPTED user grant — for narrowing
504
+ * list resolvers (`WHERE id IN (...)`).
505
+ */
506
+ async listAccessibleResourceIds(actorId) {
507
+ const grants = await this.prisma.findMany({ where: {
508
+ resourceType: this.resourceType,
509
+ granteeUserId: actorId,
510
+ deletedAt: null,
511
+ status: "ACCEPTED",
512
+ visibility: "SHARED_WITH_USERS",
513
+ OR: [{ expiresAt: null }, { expiresAt: { gt: /* @__PURE__ */ new Date() } }]
514
+ } });
515
+ return Array.from(new Set(grants.map((g) => g.resourceId)));
516
+ }
517
+ /** Resource ids with an active public link — for list narrowing. */
518
+ async listPublicResourceIds() {
519
+ const grants = await this.prisma.findMany({ where: {
520
+ resourceType: this.resourceType,
521
+ deletedAt: null,
522
+ status: { in: [...ACTIVE_STATUSES] },
523
+ visibility: "PUBLIC_LINK",
524
+ OR: [{ expiresAt: null }, { expiresAt: { gt: /* @__PURE__ */ new Date() } }]
525
+ } });
526
+ return Array.from(new Set(grants.map((g) => g.resourceId)));
527
+ }
528
+ /** Increment access analytics (best-effort). */
529
+ async touchAccess(grantId) {
530
+ try {
531
+ await this.prisma.update({
532
+ where: { id: grantId },
533
+ data: {
534
+ lastAccessAt: /* @__PURE__ */ new Date(),
535
+ accessCount: { increment: 1 }
536
+ }
537
+ });
538
+ } catch (err) {
539
+ logger.debug("[ShareService] touchAccess failed", {
540
+ grantId,
541
+ err
542
+ });
543
+ }
544
+ }
545
+ async findActiveByToken(token) {
546
+ if (!token) return null;
547
+ const grant = await this.prisma.findFirst({ where: {
548
+ token,
549
+ deletedAt: null
550
+ } });
551
+ if (!grant) return null;
552
+ if (grant.status === "REVOKED") return null;
553
+ if (grant.expiresAt && grant.expiresAt.getTime() <= Date.now()) return null;
554
+ return grant;
555
+ }
556
+ async fireShareEmail(actor, grant, resourceName) {
557
+ if (!grant.token) return;
558
+ try {
559
+ await this.deps.sendShareEmail({
560
+ recipientEmail: grant.granteeEmail,
561
+ recipientUserId: grant.granteeUserId,
562
+ resourceType: this.resourceType,
563
+ resourceName,
564
+ role: grant.role,
565
+ acceptUrl: this.deps.buildAcceptUrl(grant.token),
566
+ message: grant.message,
567
+ sharerName: actor.name ?? null,
568
+ idempotencyKey: grant.id
569
+ });
570
+ } catch (err) {
571
+ logger.warn("[ShareService] share email failed; grant still created", {
572
+ grantId: grant.id,
573
+ resourceType: this.resourceType,
574
+ err
575
+ });
576
+ }
577
+ }
578
+ };
579
+
580
+ // src/sharing/email.ts
581
+ /**
582
+ * Share-email helpers.
583
+ *
584
+ * The `resource-shared` template must be registered in global-notification-svc.
585
+ * Services wire `ShareServiceDeps.sendShareEmail` via {@link makeSendShareEmail},
586
+ * passing an object that speaks `sendWithTemplate` (e.g. `sdk.tenantNotifications`).
587
+ */
588
+ /** notification-svc template slug for "X shared <entity> with you" emails. */
589
+ const SHARE_EMAIL_TEMPLATE_SLUG = "resource-shared";
590
+ /** Human-friendly labels per resourceType for the email body. */
591
+ const RESOURCE_TYPE_LABELS = {
592
+ session: "terminal session",
593
+ vibe: "Vibe",
594
+ vibedeck: "VibeDeck",
595
+ note: "note",
596
+ aiprompt: "AI prompt",
597
+ aicontext: "AI context",
598
+ instructionfile: "instruction file",
599
+ tunnel: "tunnel",
600
+ action: "action",
601
+ file: "file",
602
+ folder: "folder",
603
+ conversation: "conversation",
604
+ catalog: "catalog",
605
+ component: "component",
606
+ template: "template",
607
+ docs: "docs site"
608
+ };
609
+ function resourceTypeLabel(resourceType) {
610
+ return RESOURCE_TYPE_LABELS[resourceType] ?? resourceType;
611
+ }
612
+ const ROLE_LABELS = {
613
+ ["VIEWER"]: "Viewer",
614
+ ["COMMENTER"]: "Commenter",
615
+ ["EDITOR"]: "Editor",
616
+ ["MANAGER"]: "Manager"
617
+ };
618
+ function roleLabel(role) {
619
+ return ROLE_LABELS[role];
620
+ }
621
+ /** Build the variable bag the `resource-shared` template renders. */
622
+ function buildShareEmailVariables(args) {
623
+ return {
624
+ sharerName: args.sharerName ?? "A teammate",
625
+ resourceType: resourceTypeLabel(args.resourceType),
626
+ resourceName: args.resourceName,
627
+ roleLabel: roleLabel(args.role),
628
+ acceptUrl: args.acceptUrl,
629
+ message: args.message ?? ""
630
+ };
631
+ }
632
+ /**
633
+ * Build a `ShareServiceDeps.sendShareEmail` implementation backed by a
634
+ * notifications module. Skips (no-throw) when there's no addressable recipient.
635
+ */
636
+ function makeSendShareEmail(notifier) {
637
+ return async (args) => {
638
+ const recipient = {};
639
+ if (args.recipientEmail) recipient.email = args.recipientEmail;
640
+ if (args.recipientUserId) recipient.userId = args.recipientUserId;
641
+ if (!recipient.email && !recipient.userId) {
642
+ logger.warn("[ShareEmail] no addressable recipient; skipping", { idempotencyKey: args.idempotencyKey });
643
+ return;
644
+ }
645
+ logger.info("[ShareEmail] Sending resource-shared", {
646
+ templateSlug: SHARE_EMAIL_TEMPLATE_SLUG,
647
+ resourceType: args.resourceType,
648
+ idempotencyKey: args.idempotencyKey
649
+ });
650
+ await notifier.sendWithTemplate({
651
+ templateSlug: SHARE_EMAIL_TEMPLATE_SLUG,
652
+ variables: buildShareEmailVariables(args),
653
+ recipient
654
+ });
655
+ };
656
+ }
657
+
658
+ // src/sharing/sdl.ts
659
+ /**
660
+ * Reusable GraphQL SDL for the generic sharing feature.
661
+ *
662
+ * {@link SHARE_GRANT_SDL} carries the shared types/enums/inputs + the uniform
663
+ * token/self fields and is declared ONCE per subgraph (in a `shared` module).
664
+ * {@link buildPerEntityShareSdl} generates the thin per-entity wrappers that
665
+ * each carry a STATIC `@rbac` directive (the gateway requires a literal
666
+ * action/resource per field — a single generic `shareResource` field cannot be
667
+ * RBAC-protected correctly).
668
+ *
669
+ * Both reference `@rbac` / `@key`, which the host subgraph already declares via
670
+ * its federation/`@link` setup. DateTime is assumed available (be-sdk graphql).
671
+ */
672
+ const SHARE_GRANT_SDL = `
673
+ enum ShareRole {
674
+ VIEWER
675
+ COMMENTER
676
+ EDITOR
677
+ MANAGER
678
+ }
679
+
680
+ enum ShareGrantVisibility {
681
+ PRIVATE
682
+ SHARED_WITH_USERS
683
+ SHARED_WITH_VIBE
684
+ PUBLIC_LINK
685
+ }
686
+
687
+ enum ShareGrantStatus {
688
+ PENDING
689
+ ACCEPTED
690
+ REVOKED
691
+ EXPIRED
692
+ }
693
+
694
+ type ShareCapabilities {
695
+ canView: Boolean!
696
+ canComment: Boolean!
697
+ canEdit: Boolean!
698
+ canManage: Boolean!
699
+ canExecute: Boolean!
700
+ }
701
+
702
+ type ShareGrant @key(fields: "id") {
703
+ id: ID!
704
+ resourceType: String!
705
+ resourceId: ID!
706
+ granteeUserId: ID
707
+ granteeEmail: String
708
+ role: ShareRole!
709
+ visibility: ShareGrantVisibility!
710
+ status: ShareGrantStatus!
711
+ expiresAt: DateTime
712
+ message: String
713
+ createdBy: ID!
714
+ acceptedAt: DateTime
715
+ createdAt: DateTime!
716
+ "Public accept/link URL (present for invites and public links)."
717
+ shareUrl: String
718
+ "Capabilities implied by this grant's role."
719
+ capabilities: ShareCapabilities!
720
+ }
721
+
722
+ type ShareGrantList {
723
+ items: [ShareGrant!]!
724
+ total: Int!
725
+ }
726
+
727
+ "Safe, pre-login preview of a share invitation."
728
+ type ShareGrantPreview {
729
+ id: ID!
730
+ resourceType: String!
731
+ resourceName: String
732
+ role: ShareRole!
733
+ visibility: ShareGrantVisibility!
734
+ status: ShareGrantStatus!
735
+ sharerName: String
736
+ expiresAt: DateTime
737
+ }
738
+
739
+ input ShareEntityInput {
740
+ resourceId: ID!
741
+ email: String!
742
+ role: ShareRole!
743
+ message: String
744
+ expiresAt: DateTime
745
+ }
746
+
747
+ input UpdateShareRoleInput {
748
+ resourceId: ID!
749
+ shareId: ID!
750
+ role: ShareRole!
751
+ }
752
+
753
+ input RevokeShareInput {
754
+ resourceId: ID!
755
+ shareId: ID!
756
+ }
757
+
758
+ input CreateShareLinkInput {
759
+ resourceId: ID!
760
+ role: ShareRole!
761
+ expiresAt: DateTime
762
+ }
763
+
764
+ extend type Query {
765
+ "Pre-login preview of a share invite by token."
766
+ shareGrantByToken(token: String!): ShareGrantPreview @rbac(public: true)
767
+ "Grants where the current user is the accepted grantee."
768
+ sharesSharedWithMe(resourceType: String, pagination: PaginationInput): ShareGrantList! @rbac(scopeType: "self")
769
+ }
770
+
771
+ extend type Mutation {
772
+ "Accept a share invitation (recipient identified by the opaque token + email/id)."
773
+ acceptShare(token: String!): ShareGrant! @rbac(public: true)
774
+ "Decline a share invitation."
775
+ declineShare(token: String!): Boolean! @rbac(public: true)
776
+ }
777
+ `;
778
+ /**
779
+ * Per-entity wrapper SDL. `entity` is the GraphQL-safe PascalCase name used in
780
+ * the field name (e.g. `Session` → `shareSession`); `rbacResource` is the
781
+ * resource string the gateway checks (e.g. `session`, `ai-prompt`).
782
+ */
783
+ function buildPerEntityShareSdl(entity, rbacResource) {
784
+ return `
785
+ extend type Mutation {
786
+ share${entity}(input: ShareEntityInput!): ShareGrant!
787
+ @rbac(action: "share", resource: "${rbacResource}", resourceIdArg: "input.resourceId", scopeType: "wspace")
788
+ revoke${entity}Share(input: RevokeShareInput!): ShareGrant!
789
+ @rbac(action: "share", resource: "${rbacResource}", resourceIdArg: "input.resourceId", scopeType: "wspace")
790
+ update${entity}ShareRole(input: UpdateShareRoleInput!): ShareGrant!
791
+ @rbac(action: "share", resource: "${rbacResource}", resourceIdArg: "input.resourceId", scopeType: "wspace")
792
+ create${entity}ShareLink(input: CreateShareLinkInput!): ShareGrant!
793
+ @rbac(action: "share", resource: "${rbacResource}", resourceIdArg: "input.resourceId", scopeType: "wspace")
794
+ revoke${entity}ShareLink(input: RevokeShareInput!): ShareGrant!
795
+ @rbac(action: "share", resource: "${rbacResource}", resourceIdArg: "input.resourceId", scopeType: "wspace")
796
+ }
797
+ `;
798
+ }
799
+
800
+ // src/sharing/prisma-fragment.ts
801
+ /**
802
+ * Canonical `ShareGrant` Prisma model + indexes, shipped as a copy-paste string.
803
+ *
804
+ * Each service pastes {@link SHARE_GRANT_PRISMA} into its own `prisma/schema/`
805
+ * and runs `gendb`. Enum names are deliberately `ShareRole` /
806
+ * `ShareGrantVisibility` / `ShareGrantStatus` so they never collide with the
807
+ * legacy per-service `ShareStatus` / `VibeVisibility` enums. The Prisma FIELD
808
+ * names stay camelCase (what {@link ShareService} reads/writes); `@map` keeps the
809
+ * DB columns snake_case so {@link SHARE_GRANT_PARTIAL_UNIQUE_SQL} reads cleanly.
810
+ */
811
+ const SHARE_GRANT_PRISMA = `
812
+ enum ShareRole {
813
+ VIEWER
814
+ COMMENTER
815
+ EDITOR
816
+ MANAGER
817
+ }
818
+
819
+ enum ShareGrantVisibility {
820
+ PRIVATE
821
+ SHARED_WITH_USERS
822
+ SHARED_WITH_VIBE
823
+ PUBLIC_LINK
824
+ }
825
+
826
+ enum ShareGrantStatus {
827
+ PENDING
828
+ ACCEPTED
829
+ REVOKED
830
+ EXPIRED
831
+ }
832
+
833
+ /// Generic resource share grant. \`resourceType\` discriminates the entity; one
834
+ /// row per (resource, recipient) or per public link. See @burdenoff/be-sdk/sharing.
835
+ model ShareGrant {
836
+ id String @id @default(uuid())
837
+ workspaceId String @map("workspace_id") @db.VarChar(255)
838
+ resourceType String @map("resource_type") @db.VarChar(64)
839
+ resourceId String @map("resource_id") @db.VarChar(255)
840
+ granteeUserId String? @map("grantee_user_id") @db.VarChar(255)
841
+ granteeEmail String? @map("grantee_email") @db.VarChar(320)
842
+ role ShareRole @default(VIEWER)
843
+ visibility ShareGrantVisibility @default(SHARED_WITH_USERS)
844
+ status ShareGrantStatus @default(PENDING)
845
+ token String? @unique @db.VarChar(64)
846
+ expiresAt DateTime? @map("expires_at")
847
+ message String? @db.Text
848
+ createdBy String @map("created_by") @db.VarChar(255)
849
+ onBehalfOf String @map("on_behalf_of") @db.VarChar(255)
850
+ acceptedAt DateTime? @map("accepted_at")
851
+ acceptedBy String? @map("accepted_by") @db.VarChar(255)
852
+ revokedAt DateTime? @map("revoked_at")
853
+ revokedBy String? @map("revoked_by") @db.VarChar(255)
854
+ lastAccessAt DateTime? @map("last_access_at")
855
+ accessCount Int @default(0) @map("access_count")
856
+ context Json?
857
+ createdAt DateTime @default(now()) @map("created_at")
858
+ updatedAt DateTime @updatedAt @map("updated_at")
859
+ deletedAt DateTime? @map("deleted_at")
860
+
861
+ @@index([workspaceId])
862
+ @@index([resourceType, resourceId])
863
+ @@index([granteeUserId])
864
+ @@index([granteeEmail])
865
+ @@index([status])
866
+ @@index([expiresAt])
867
+ @@index([resourceType, resourceId, status])
868
+ @@map("share_grants")
869
+ }
870
+ `;
871
+ /**
872
+ * Partial-unique index that Prisma's `@@unique` cannot express (it has no WHERE
873
+ * predicate). Add this as a raw SQL step in the same migration that creates the
874
+ * table. The table is brand new, so a plain (non-CONCURRENT) create is safe and
875
+ * transaction-friendly.
876
+ */
877
+ const SHARE_GRANT_PARTIAL_UNIQUE_SQL = `
878
+ CREATE UNIQUE INDEX IF NOT EXISTS share_grants_active_user_uq
879
+ ON share_grants (resource_type, resource_id, grantee_user_id)
880
+ WHERE status IN ('PENDING', 'ACCEPTED') AND deleted_at IS NULL AND grantee_user_id IS NOT NULL;
881
+ `;
882
+
883
+ // src/sharing/index.ts
884
+ var sharing_exports = /* @__PURE__ */ __exportAll({
885
+ RESOURCE_CAPABILITY_MAP: () => RESOURCE_CAPABILITY_MAP,
886
+ RESOURCE_TYPE_LABELS: () => RESOURCE_TYPE_LABELS,
887
+ ROLE_CAPABILITIES: () => ROLE_CAPABILITIES,
888
+ ROLE_ORDER: () => ROLE_ORDER,
889
+ SHARE_EMAIL_TEMPLATE_SLUG: () => SHARE_EMAIL_TEMPLATE_SLUG,
890
+ SHARE_GRANT_PARTIAL_UNIQUE_SQL: () => SHARE_GRANT_PARTIAL_UNIQUE_SQL,
891
+ SHARE_GRANT_PRISMA: () => SHARE_GRANT_PRISMA,
892
+ SHARE_GRANT_SDL: () => SHARE_GRANT_SDL,
893
+ ShareRole: () => ShareRole,
894
+ ShareService: () => ShareService,
895
+ ShareStatus: () => ShareStatus,
896
+ ShareVisibility: () => ShareVisibility,
897
+ buildPerEntityShareSdl: () => buildPerEntityShareSdl,
898
+ buildShareEmailVariables: () => buildShareEmailVariables,
899
+ capabilitiesFor: () => capabilitiesFor,
900
+ legacyToRole: () => legacyToRole,
901
+ makeSendShareEmail: () => makeSendShareEmail,
902
+ maxRole: () => maxRole,
903
+ normalizeStatus: () => normalizeStatus,
904
+ resourceTypeLabel: () => resourceTypeLabel,
905
+ roleAtLeast: () => roleAtLeast,
906
+ roleLabel: () => roleLabel,
907
+ roleToLegacy: () => roleToLegacy
908
+ });
909
+
910
+ export { roleAtLeast as C, normalizeStatus as S, ShareStatus as _, buildPerEntityShareSdl as a, legacyToRole as b, buildShareEmailVariables as c, roleLabel as d, ShareService as f, ShareRole as g, ROLE_ORDER as h, SHARE_GRANT_SDL as i, makeSendShareEmail as l, ROLE_CAPABILITIES as m, SHARE_GRANT_PARTIAL_UNIQUE_SQL as n, RESOURCE_TYPE_LABELS as o, RESOURCE_CAPABILITY_MAP as p, SHARE_GRANT_PRISMA as r, SHARE_EMAIL_TEMPLATE_SLUG as s, sharing_exports as t, resourceTypeLabel as u, ShareVisibility as v, roleToLegacy as w, maxRole as x, capabilitiesFor as y };
911
+ //# sourceMappingURL=sharing-CflDsSJ-.js.map