@burdenoff/be-sdk 2026.1110.2 → 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-GXC3A7DH.js +0 -8
  299. package/dist/EventQueueFactory-GXC3A7DH.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-A5F6Z5UE.js +0 -21
  313. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  314. package/dist/chunk-A6DE32ZS.js +0 -1507
  315. package/dist/chunk-A6DE32ZS.js.map +0 -1
  316. package/dist/chunk-AXJDGQPE.js +0 -690
  317. package/dist/chunk-AXJDGQPE.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-DRWH5XCJ.js +0 -876
  323. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  324. package/dist/chunk-E4QNLVY4.js +0 -909
  325. package/dist/chunk-E4QNLVY4.js.map +0 -1
  326. package/dist/chunk-EBDHIL7V.js +0 -774
  327. package/dist/chunk-EBDHIL7V.js.map +0 -1
  328. package/dist/chunk-ELU7VL3E.js +0 -245
  329. package/dist/chunk-ELU7VL3E.js.map +0 -1
  330. package/dist/chunk-FZRODKIN.js +0 -31
  331. package/dist/chunk-FZRODKIN.js.map +0 -1
  332. package/dist/chunk-GCIB76AJ.js +0 -882
  333. package/dist/chunk-GCIB76AJ.js.map +0 -1
  334. package/dist/chunk-HC6MPUIH.js +0 -1571
  335. package/dist/chunk-HC6MPUIH.js.map +0 -1
  336. package/dist/chunk-HNMHPSAM.js +0 -272
  337. package/dist/chunk-HNMHPSAM.js.map +0 -1
  338. package/dist/chunk-HTLEGD3Q.js +0 -1480
  339. package/dist/chunk-HTLEGD3Q.js.map +0 -1
  340. package/dist/chunk-I3KOWRT3.js +0 -89
  341. package/dist/chunk-I3KOWRT3.js.map +0 -1
  342. package/dist/chunk-ID3WR4JS.js +0 -509
  343. package/dist/chunk-ID3WR4JS.js.map +0 -1
  344. package/dist/chunk-JS52ZHTK.js +0 -1346
  345. package/dist/chunk-JS52ZHTK.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-KH4TRQCO.js +0 -1063
  349. package/dist/chunk-KH4TRQCO.js.map +0 -1
  350. package/dist/chunk-KJOSPVB2.js +0 -57
  351. package/dist/chunk-KJOSPVB2.js.map +0 -1
  352. package/dist/chunk-KO2ZXZ7W.js +0 -61
  353. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  354. package/dist/chunk-KS2HQCJR.js +0 -56
  355. package/dist/chunk-KS2HQCJR.js.map +0 -1
  356. package/dist/chunk-LA5KPWZ2.js +0 -413
  357. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  358. package/dist/chunk-MESLAC5W.js +0 -574
  359. package/dist/chunk-MESLAC5W.js.map +0 -1
  360. package/dist/chunk-MWPYA2HD.js +0 -94
  361. package/dist/chunk-MWPYA2HD.js.map +0 -1
  362. package/dist/chunk-NUB5GQTU.js +0 -270
  363. package/dist/chunk-NUB5GQTU.js.map +0 -1
  364. package/dist/chunk-OBBCR6WY.js +0 -277
  365. package/dist/chunk-OBBCR6WY.js.map +0 -1
  366. package/dist/chunk-OQDSAOG3.js +0 -1908
  367. package/dist/chunk-OQDSAOG3.js.map +0 -1
  368. package/dist/chunk-OXNCBE7P.js +0 -971
  369. package/dist/chunk-OXNCBE7P.js.map +0 -1
  370. package/dist/chunk-PBZFAAOM.js +0 -941
  371. package/dist/chunk-PN6GIF3R.js +0 -1185
  372. package/dist/chunk-PN6GIF3R.js.map +0 -1
  373. package/dist/chunk-PYD44IHJ.js +0 -728
  374. package/dist/chunk-PYD44IHJ.js.map +0 -1
  375. package/dist/chunk-QVPIACWD.js +0 -679
  376. package/dist/chunk-QVPIACWD.js.map +0 -1
  377. package/dist/chunk-QWNNFE4P.js +0 -41
  378. package/dist/chunk-QWNNFE4P.js.map +0 -1
  379. package/dist/chunk-RU266375.js +0 -327
  380. package/dist/chunk-RU266375.js.map +0 -1
  381. package/dist/chunk-RYTSVGGA.js +0 -1624
  382. package/dist/chunk-RYTSVGGA.js.map +0 -1
  383. package/dist/chunk-RZOFS2BQ.js +0 -225
  384. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  385. package/dist/chunk-SBS4S2PJ.js +0 -100
  386. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  387. package/dist/chunk-SPRG6G6G.js +0 -530
  388. package/dist/chunk-SPRG6G6G.js.map +0 -1
  389. package/dist/chunk-STWFX5E2.js +0 -233
  390. package/dist/chunk-STWFX5E2.js.map +0 -1
  391. package/dist/chunk-UNASM5VJ.js +0 -419
  392. package/dist/chunk-UNASM5VJ.js.map +0 -1
  393. package/dist/chunk-VAT66FJA.js +0 -245
  394. package/dist/chunk-VAT66FJA.js.map +0 -1
  395. package/dist/chunk-VFCMR5GX.js +0 -49
  396. package/dist/chunk-VFCMR5GX.js.map +0 -1
  397. package/dist/chunk-VGAHZKNJ.js +0 -66
  398. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  399. package/dist/chunk-VTJTAAXC.js +0 -627
  400. package/dist/chunk-VTJTAAXC.js.map +0 -1
  401. package/dist/chunk-VXVLKRU6.js +0 -758
  402. package/dist/chunk-VXVLKRU6.js.map +0 -1
  403. package/dist/chunk-WWUU5ETI.js +0 -163
  404. package/dist/chunk-WWUU5ETI.js.map +0 -1
  405. package/dist/chunk-XE4OXN2W.js +0 -10
  406. package/dist/chunk-XE4OXN2W.js.map +0 -1
  407. package/dist/chunk-XOJORS75.js +0 -1853
  408. package/dist/chunk-XOJORS75.js.map +0 -1
  409. package/dist/chunk-YMZEUTD2.js +0 -110
  410. package/dist/chunk-YMZEUTD2.js.map +0 -1
  411. package/dist/chunk-Z77BTSOK.js +0 -617
  412. package/dist/chunk-Z77BTSOK.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 @@
1
+ {"version":3,"file":"files-DjH0099H.js","names":[],"sources":["../src/files/types.ts","../src/files/errors.ts","../src/files/client.ts","../src/files/reference.ts","../src/files/index.ts"],"sourcesContent":["/**\n * Files client — shared types.\n *\n * wspace-files-svc is the one owner of workspace blobs. Product services never\n * presign S3 themselves or hold storage keys: they hand bytes to files-svc\n * through the internal workspace gateway and keep only the opaque `fileId`.\n * These types describe the wire shape the client reads from files-svc and the\n * projection it hands back to the service.\n */\nimport type { GraphQLRequestOptions, GraphQLResponse } from '../gateway/types.js';\n\n/** Actor types the gateway forwards in `x-actor-type`. */\nexport const FILE_ACTOR_TYPES = ['user', 'app', 'service', 'super_admin'] as const;\n\nexport type FileActorType = (typeof FILE_ACTOR_TYPES)[number];\n\n/**\n * The caller a file operation runs on behalf of (forwarded as `x-actor-*` /\n * `x-workspace-id`).\n *\n * Pass the END USER who asked for the operation, not the service: files-svc\n * records `actorId` as the uploader, scopes the File row to `workspaceId`, and\n * checks quota, folder access and read permission against that actor. A row\n * uploaded \"as the service\" belongs to nobody the workspace can see.\n */\nexport interface FileActor {\n /** `x-actor-id` — the user/app the gateway authenticated. */\n actorId: string;\n /** `x-workspace-id` — the workspace the File row belongs to. */\n workspaceId: string;\n /** `x-actor-type`; defaults to `user`. */\n actorType?: FileActorType;\n}\n\n/** `FileVisibility` enum members accepted by wspace-files-svc. */\nexport const FILE_VISIBILITIES = ['PRIVATE', 'PUBLIC', 'TEAM', 'WORKSPACE'] as const;\n\nexport type FileVisibility = (typeof FILE_VISIBILITIES)[number];\n\n/** `FileStatus` enum members returned by wspace-files-svc. */\nexport type FileStatus = 'ACTIVE' | 'ARCHIVED' | 'DELETED' | 'UPLOADING';\n\n/** `UploadType` chosen by files-svc for a session (it switches large files to MULTIPART). */\nexport type FileUploadType = 'DIRECT' | 'MULTIPART' | 'RESUMABLE';\n\n/** Bytes the client can upload. Node/Bun `Buffer` is a `Uint8Array`. */\nexport type FileBytes = Uint8Array | ArrayBuffer;\n\n/** Input for {@link FilesClient.uploadFile}. */\nexport interface UploadFileInput {\n /** File name shown in the workspace library, e.g. `soc2-evidence.pdf`. */\n fileName: string;\n /** The file contents. */\n data: FileBytes;\n /** MIME type, e.g. `application/pdf`. Sent as the PUT `Content-Type`. */\n mimeType: string;\n /** Extension without the dot. Default: taken from `fileName`, else `bin`. */\n extension?: string;\n /** Folder to file it in. The actor must be allowed to upload there. */\n folderId?: string | null;\n /** Description stored on the File row. */\n description?: string | null;\n /** Visibility. files-svc default is `PRIVATE`. */\n visibility?: FileVisibility;\n /**\n * Declare the SHA-256 of the bytes at initiate and complete, so files-svc can\n * verify what it stored. Default `true`.\n */\n declareSha256?: boolean;\n}\n\n/** What {@link FilesClient.uploadFile} returns: persist `fileId`, nothing else is needed. */\nexport interface StoredFile {\n fileId: string;\n name: string;\n mimeType: string;\n /** Size in bytes. */\n size: number;\n workspaceId: string;\n /** Lowercase hex SHA-256 when it was declared, else `null`. */\n sha256Hash: string | null;\n}\n\n/**\n * File metadata, read through the files graph's ROOT `getFile` field.\n *\n * Only scalars are selected: files-svc's `File` entity has no\n * `__resolveReference`, so federated sub-selections (folder, versions, …) are\n * deliberately not part of this shape.\n */\nexport interface FileMetadata {\n id: string;\n name: string;\n mimeType: string;\n extension: string;\n /** Size in bytes. */\n size: number;\n status: FileStatus;\n visibility: FileVisibility;\n workspaceId: string;\n folderId: string | null;\n uploadedById: string;\n description: string | null;\n sha256Hash: string | null;\n createdAt: Date | null;\n updatedAt: Date | null;\n /** Whether the actor may read the file (files-svc permission check). */\n canRead: boolean | null;\n /** Whether the actor may delete the file. */\n canDelete: boolean | null;\n}\n\n/** Options for {@link FilesClient.requireFile}. */\nexport interface RequireFileOptions {\n /** Reject files that are not `ACTIVE`. Default `true`. */\n requireActive?: boolean;\n /** Reject files the actor cannot read (`canRead !== true`). Default `true`. */\n requireReadable?: boolean;\n}\n\n/** Options for {@link FilesClient.getDownloadUrl}. */\nexport interface DownloadUrlOptions {\n /** URL lifetime in seconds, clamped to [60, 604800] (the S3 presign maximum). */\n expiresInSeconds?: number;\n}\n\n/** Options for {@link FilesClient.downloadFile}. */\nexport interface DownloadFileOptions {\n /** Refuse files larger than this many bytes. Default: the client's `maxDownloadBytes`. */\n maxBytes?: number;\n}\n\n/** What {@link FilesClient.downloadFile} returns. */\nexport interface DownloadedFile {\n bytes: Uint8Array;\n /** MIME type recorded by files-svc. */\n mimeType: string;\n name: string;\n size: number;\n}\n\n/**\n * Input for {@link FilesClient.createUploadSession}: a delegated upload, where\n * the service opens the files-svc session on the actor's behalf and hands the\n * presigned URL(s) to whoever holds the bytes (an agent, a CLI, a browser).\n */\nexport interface CreateUploadSessionInput {\n /** File name shown in the workspace library. */\n fileName: string;\n /** Exact size of the bytes the uploader will PUT. `completeUploadSession` must repeat it. */\n fileSize: number;\n /** MIME type. A DIRECT URL is signed for it, so the uploader must send it as `Content-Type`. */\n mimeType: string;\n /** Extension without the dot. Default: taken from `fileName`, else `bin`. */\n extension?: string;\n /** Lowercase hex SHA-256 the uploader declared; files-svc checks it again at completion. */\n sha256Hash?: string | null;\n /** Folder to file it in. The actor must be allowed to upload there. */\n folderId?: string | null;\n /** Visibility. files-svc default is `PRIVATE`. */\n visibility?: FileVisibility;\n}\n\n/** One presigned part of a MULTIPART {@link UploadSessionTicket}. */\nexport interface UploadSessionPart {\n /** 1-indexed part number. */\n partNumber: number;\n /** Presigned PUT URL for exactly the bytes `[offset, offset + length)`. */\n url: string;\n /** First byte of the part within the file. */\n offset: number;\n /** Number of bytes in the part. */\n length: number;\n}\n\n/**\n * An open files-svc upload session the caller hands to the uploader. Mint it per\n * upload; never persist the URLs (only `sessionId`).\n */\nexport interface UploadSessionTicket {\n sessionId: string;\n /** `DIRECT` → one PUT to `uploadUrl`; `MULTIPART` → one PUT per entry of `parts`. */\n uploadType: 'DIRECT' | 'MULTIPART';\n /** DIRECT only: the presigned PUT URL. `null` for MULTIPART. */\n uploadUrl: string | null;\n /** Headers the uploader must send on the DIRECT PUT (the signed `Content-Type`). Empty for MULTIPART parts. */\n requiredHeaders: Record<string, string>;\n /** MULTIPART only: every part, in order. Empty for DIRECT. */\n parts: UploadSessionPart[];\n partSize: number;\n totalParts: number;\n /** Size in bytes the session was opened for. */\n fileSize: number;\n /** The SHA-256 declared at initiate, or `null`. */\n sha256Hash: string | null;\n /** When files-svc expires the session, if it said. */\n expiresAt: Date | null;\n}\n\n/** An uploaded MULTIPART part: the ETag object storage returned for its PUT. */\nexport interface UploadedPart {\n partNumber: number;\n etag: string;\n}\n\n/** Input for {@link FilesClient.completeUploadSession}. */\nexport interface CompleteUploadSessionInput {\n /** Must equal the `fileSize` the session was opened with. */\n fileSize: number;\n /** Must equal the SHA-256 declared at initiate when one was declared. */\n sha256Hash?: string | null;\n /** Description stored on the File row. */\n description?: string | null;\n /** Folder to file it in (defaults to the one given at initiate). */\n folderId?: string | null;\n /** MULTIPART only: every part's ETag, registered before completion. */\n parts?: readonly UploadedPart[];\n}\n\n/** Options for {@link FilesClient.deleteFile}. */\nexport interface DeleteFileOptions {\n /** Hard delete (`permanentlyDeleteFile`) instead of moving to trash. Default `false`. */\n permanent?: boolean;\n}\n\n/** The slice of be-sdk's `GatewayClient` the files client needs (injectable for tests). */\nexport interface FilesTransport {\n internalQuery<T = unknown>(options: GraphQLRequestOptions): Promise<GraphQLResponse<T>>;\n}\n\n/** `fetch`-compatible function used for the presigned PUT/GET legs (injectable for tests). */\nexport type FilesFetch = (url: string, init?: RequestInit) => Promise<Response>;\n\n/** `File` as selected over the wire (BigInt and DateTime arrive as strings). */\nexport interface RawFileMetadata {\n id: string;\n name: string;\n mimeType: string;\n extension: string;\n size: string | number;\n status: FileStatus;\n visibility: FileVisibility;\n workspaceId: string;\n folderId?: string | null;\n uploadedById: string;\n description?: string | null;\n sha256Hash?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n canRead?: boolean | null;\n canDelete?: boolean | null;\n}\n","/**\n * Files client — error type.\n *\n * Services map {@link FilesClientError} onto their own i18n GraphQL errors; the\n * `code` is stable so that mapping never parses messages. Upstream detail\n * (files-svc messages, storage status codes) lives in `details` for logging and\n * must not be returned to clients verbatim.\n */\nimport { GatewayError, type GraphQLError } from '../gateway/types.js';\n\nexport type FilesClientErrorCode =\n /** A required argument is empty or out of range. */\n | 'INVALID_INPUT'\n /** No actor/workspace on the request — files are always workspace-scoped. */\n | 'MISSING_CONTEXT'\n /** The file does not exist, is in another workspace, or the actor may not read it. */\n | 'NOT_FOUND'\n /** The workspace storage/file quota, or the per-upload size limit, rejected the upload. */\n | 'QUOTA_EXCEEDED'\n /** The bytes exceed the client's configured upload/download cap. */\n | 'TOO_LARGE'\n /** The presigned PUT/GET against object storage failed. */\n | 'STORAGE_ERROR'\n /** files-svc or the gateway failed, or answered without the expected payload. */\n | 'UPSTREAM_ERROR'\n /** The client was configured inconsistently (thrown at boot). */\n | 'CONFIGURATION_ERROR';\n\n/** GraphQL `extensions.code` each {@link FilesClientErrorCode} should surface as. */\nexport const FILES_CLIENT_GRAPHQL_CODES: Record<FilesClientErrorCode, string> = {\n INVALID_INPUT: 'BAD_USER_INPUT',\n MISSING_CONTEXT: 'UNAUTHENTICATED',\n // Never FORBIDDEN: a file the actor cannot see must be indistinguishable from one that does not exist.\n NOT_FOUND: 'NOT_FOUND',\n QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',\n TOO_LARGE: 'BAD_USER_INPUT',\n STORAGE_ERROR: 'INTERNAL_SERVER_ERROR',\n UPSTREAM_ERROR: 'INTERNAL_SERVER_ERROR',\n CONFIGURATION_ERROR: 'INTERNAL_SERVER_ERROR',\n};\n\nexport class FilesClientError extends Error {\n readonly code: FilesClientErrorCode;\n readonly details: Record<string, unknown>;\n\n constructor(code: FilesClientErrorCode, message: string, details: Record<string, unknown> = {}) {\n super(message);\n this.name = 'FilesClientError';\n this.code = code;\n this.details = details;\n }\n\n /** The GraphQL `extensions.code` this error maps to. */\n get graphqlCode(): string {\n return FILES_CLIENT_GRAPHQL_CODES[this.code];\n }\n}\n\nexport function isFilesClientError(error: unknown): error is FilesClientError {\n return error instanceof FilesClientError;\n}\n\nconst NOT_FOUND_UPSTREAM_CODES = new Set(['NOT_FOUND', 'FORBIDDEN']);\nconst QUOTA_UPSTREAM_CODES = new Set(['QUOTA_EXCEEDED', 'QUOTA_EXHAUSTED', 'USAGE_LIMIT_EXCEEDED']);\nconst INVALID_UPSTREAM_CODES = new Set(['BAD_USER_INPUT', 'EXPIRED']);\n\nfunction upstreamCode(error: GraphQLError): string | null {\n const code = error.extensions?.['code'];\n return typeof code === 'string' ? code : null;\n}\n\n/** Classify files-svc GraphQL errors into a {@link FilesClientErrorCode}. */\nexport function classifyFilesErrors(errors: readonly GraphQLError[]): FilesClientErrorCode {\n const codes = errors.map(upstreamCode).filter((code): code is string => code !== null);\n if (codes.some((code) => QUOTA_UPSTREAM_CODES.has(code))) return 'QUOTA_EXCEEDED';\n if (codes.some((code) => NOT_FOUND_UPSTREAM_CODES.has(code))) return 'NOT_FOUND';\n if (codes.some((code) => INVALID_UPSTREAM_CODES.has(code))) return 'INVALID_INPUT';\n return 'UPSTREAM_ERROR';\n}\n\n/**\n * Normalise anything a files-svc call threw (a `GatewayError` carrying GraphQL\n * errors, a timeout, a network error, …) into a {@link FilesClientError}.\n */\nexport function toFilesClientError(error: unknown, operation: string): FilesClientError {\n if (error instanceof FilesClientError) return error;\n if (error instanceof GatewayError) {\n const graphqlErrors = error.graphqlErrors ?? [];\n const code = graphqlErrors.length > 0 ? classifyFilesErrors(graphqlErrors) : 'UPSTREAM_ERROR';\n return new FilesClientError(code, `wspace-files-svc ${operation} failed: ${error.message}`, {\n operation,\n gatewayErrorType: error.type,\n statusCode: error.statusCode,\n errors: graphqlErrors.map((graphqlError) => ({\n message: graphqlError.message,\n code: upstreamCode(graphqlError),\n })),\n });\n }\n const message = error instanceof Error ? error.message : String(error);\n return new FilesClientError('UPSTREAM_ERROR', `wspace-files-svc ${operation} failed: ${message}`, { operation });\n}\n","/**\n * FilesClient — store and read workspace blobs through wspace-files-svc.\n *\n * Module ownership makes wspace-files-svc the canonical owner of blobs, yet\n * services kept re-implementing storage: VibeControls hand-rolled SigV4 with\n * static S3 keys for security evidence, FluidGrids passed attachments between\n * nodes as base64, HealthyBowl carried its own three-step uploader. This class\n * is the shared client: a service hands it bytes and gets back an opaque\n * `fileId`, and resolves that id back to metadata, a short-lived download URL or\n * the bytes themselves.\n *\n * Every call is same-layer M2M through the internal workspace gateway\n * (`GatewayClient.internalQuery`, which signs the service JWT; the gateway adds\n * its own trusted token toward files-svc). The CALLER's actor and workspace are\n * forwarded explicitly, so the File row is owned by the user who asked for it,\n * shows up in their library, and files-svc applies quota, folder access and read\n * permission to that user. The internal gateway enforces neither `@rbac` nor\n * `@usage` for the product's own resolver, so the service must already have\n * authorized the action (its own `@rbac` plus a workspace-scoped row lookup).\n *\n * Upload is the files-svc protocol: `initiateUpload` → presigned PUT (DIRECT) or\n * per-part PUTs + `registerUploadedPart` (MULTIPART, which files-svc picks for\n * files over 5 MiB) → `completeUpload` with the same `fileSize` (required: it\n * must match the size declared at initiate). A failed upload aborts its session.\n *\n * @example\n * ```ts\n * import { FilesClient, toFileReference } from '@burdenoff/be-sdk/files';\n *\n * const files = new FilesClient({ serviceName: 'wspace-vibecontrols-svc' });\n *\n * const stored = await files.uploadFile(\n * { fileName: 'access-review.pdf', data: pdfBytes, mimeType: 'application/pdf', description: 'SOC 2 evidence' },\n * { actorId: ctx.actorId, workspaceId: ctx.workspaceId }\n * );\n * await db.securityEvidence.update({ where: { id }, data: { fileId: stored.fileId } });\n *\n * const url = await files.getDownloadUrl(evidence.fileId, actor, { expiresInSeconds: 300 });\n * ```\n */\nimport { createHash } from 'node:crypto';\n\nimport type { GraphQLResponse } from '../gateway/types.js';\n\nimport { FilesClientError, classifyFilesErrors, toFilesClientError } from './errors.js';\nimport type {\n CompleteUploadSessionInput,\n CreateUploadSessionInput,\n DeleteFileOptions,\n DownloadFileOptions,\n DownloadUrlOptions,\n DownloadedFile,\n FileActor,\n FileBytes,\n FileMetadata,\n FileUploadType,\n FilesFetch,\n FilesTransport,\n RawFileMetadata,\n RequireFileOptions,\n StoredFile,\n UploadFileInput,\n UploadSessionPart,\n UploadSessionTicket,\n UploadedPart,\n} from './types.js';\nimport { FILE_ACTOR_TYPES, FILE_VISIBILITIES } from './types.js';\n\nconst MIB = 1024 * 1024;\n\n/** S3 refuses presigned URLs that live longer than 7 days; files-svc 500s above it. */\nexport const MAX_DOWNLOAD_URL_TTL_SECONDS = 604_800;\n/** Shortest URL lifetime the client will request. */\nexport const MIN_DOWNLOAD_URL_TTL_SECONDS = 60;\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 15_000;\nconst DEFAULT_TRANSFER_TIMEOUT_MS = 120_000;\nconst DEFAULT_MAX_UPLOAD_BYTES = 100 * MIB;\nconst DEFAULT_MAX_DOWNLOAD_BYTES = 25 * MIB;\nconst DEFAULT_DOWNLOAD_URL_TTL_SECONDS = 3_600;\n/** TTL of the URL `downloadFile` mints for its own immediate GET. */\nconst INTERNAL_DOWNLOAD_URL_TTL_SECONDS = 300;\nconst PART_URL_BATCH_SIZE = 20;\nconst SHA256_HEX = /^[0-9a-f]{64}$/;\n\nconst FILE_FIELDS =\n 'id name mimeType extension size status visibility workspaceId folderId uploadedById description sha256Hash createdAt updatedAt canRead canDelete';\n\nconst INITIATE_UPLOAD = `mutation FilesClientInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id uploadType partSize totalParts fileSize expiresAt }\n }\n}`;\n\nconst PART_URLS = `query FilesClientPartUploadUrls($sessionId: ID!, $partNumbers: [Int!]!) {\n getBatchPartUploadUrls(sessionId: $sessionId, partNumbers: $partNumbers) { partNumber url }\n}`;\n\nconst REGISTER_PART = `mutation FilesClientRegisterUploadedPart($input: UploadPartInput!) {\n registerUploadedPart(input: $input) { session { id uploadedParts } }\n}`;\n\nconst COMPLETE_UPLOAD = `mutation FilesClientCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) { fileId file { id name mimeType size workspaceId sha256Hash } }\n}`;\n\nconst ABORT_UPLOAD = `mutation FilesClientAbortUpload($sessionId: ID!) { abortUpload(sessionId: $sessionId) }`;\n\nconst GET_FILE = `query FilesClientGetFile($id: ID!) { getFile(id: $id) { ${FILE_FIELDS} } }`;\n\nconst GET_DOWNLOAD_URL = `query FilesClientGetFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n}`;\n\nconst RESOLVE_FOR_DOWNLOAD = `query FilesClientResolveForDownload($id: ID!, $expiresIn: Int) {\n getFile(id: $id) { ${FILE_FIELDS} }\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n}`;\n\nconst DELETE_FILE = `mutation FilesClientDeleteFile($id: ID!) { deleteFile(id: $id) }`;\n\nconst PERMANENTLY_DELETE_FILE = `mutation FilesClientPermanentlyDeleteFile($id: ID!) { permanentlyDeleteFile(id: $id) }`;\n\nexport interface FilesClientOptions {\n /**\n * Gateway client, or a factory for one. Defaults to a lazily constructed be-sdk\n * `GatewayClient` (`layer: 'wspace'`, `serviceName` below, or the\n * `SERVICE_LAYER`/`SERVICE_NAME` env when `serviceName` is omitted).\n */\n client?: FilesTransport | (() => FilesTransport | Promise<FilesTransport>);\n /** Service name for the default GatewayClient, e.g. `wspace-vibecontrols-svc`. */\n serviceName?: string;\n /** `fetch` used for the presigned PUT/GET legs. Default: the global `fetch`. */\n fetch?: FilesFetch;\n /** Per-request timeout for files-svc GraphQL calls. Default 15s. */\n requestTimeoutMs?: number;\n /** Per-request timeout for each presigned PUT/GET. Default 120s. */\n transferTimeoutMs?: number;\n /** Largest upload accepted (the bytes are held in memory). Default 100 MiB. */\n maxUploadBytes?: number;\n /** Largest download accepted by `downloadFile`. Default 25 MiB. */\n maxDownloadBytes?: number;\n /** Default `getDownloadUrl` lifetime in seconds. Default 3600. */\n defaultDownloadUrlTtlSeconds?: number;\n}\n\ninterface InitiatedSession {\n id: string;\n uploadType: FileUploadType;\n partSize: number;\n totalParts: number;\n}\n\nfunction requireNonEmpty(value: string | null | undefined, field: string): string {\n const trimmed = typeof value === 'string' ? value.trim() : '';\n if (!trimmed) {\n throw new FilesClientError('INVALID_INPUT', `${field} is required`, { field });\n }\n return trimmed;\n}\n\nfunction requirePositiveInteger(value: number, field: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new FilesClientError('CONFIGURATION_ERROR', `${field} must be a positive integer`, { field, value });\n }\n return value;\n}\n\nfunction toNumber(value: string | number, field: string): number {\n const parsed = typeof value === 'number' ? value : Number(value);\n if (!Number.isSafeInteger(parsed) || parsed < 0) {\n throw new FilesClientError('UPSTREAM_ERROR', `wspace-files-svc returned an invalid ${field}`, { field, value });\n }\n return parsed;\n}\n\nfunction toDate(value: string | null | undefined): Date | null {\n if (!value) return null;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\n/** A view over `data` backed by a plain `ArrayBuffer` (what `fetch` bodies accept). */\nfunction toBytes(data: FileBytes): Uint8Array<ArrayBuffer> {\n if (data instanceof ArrayBuffer) return new Uint8Array(data);\n const { buffer } = data;\n if (buffer instanceof ArrayBuffer) return new Uint8Array(buffer, data.byteOffset, data.byteLength);\n // SharedArrayBuffer-backed view: copy, since a shared buffer can change under the upload.\n return new Uint8Array(data);\n}\n\n/** Extension for `fileName` (`report.PDF` → `pdf`), or `bin` when it has none. */\nexport function fileExtensionOf(fileName: string): string {\n const base = fileName.trim().split(/[\\\\/]/).pop() ?? '';\n const dot = base.lastIndexOf('.');\n if (dot <= 0 || dot === base.length - 1) return 'bin';\n const extension = base\n .slice(dot + 1)\n .toLowerCase()\n .replace(/[^a-z0-9]/g, '');\n return extension || 'bin';\n}\n\n/** Clamp a requested URL lifetime to what files-svc / S3 accept. */\nexport function clampDownloadUrlTtl(seconds: number | null | undefined, fallback: number): number {\n const value = seconds === null || seconds === undefined || !Number.isFinite(seconds) ? fallback : seconds;\n return Math.min(Math.max(Math.trunc(value), MIN_DOWNLOAD_URL_TTL_SECONDS), MAX_DOWNLOAD_URL_TTL_SECONDS);\n}\n\nfunction isHttpUrl(value: unknown): value is string {\n if (typeof value !== 'string' || value.length === 0) return false;\n try {\n const { protocol } = new URL(value);\n return protocol === 'https:' || protocol === 'http:';\n } catch {\n return false;\n }\n}\n\n/** Lowercase a declared SHA-256 and reject anything that is not 64 hex characters. */\nfunction normalizeSha256(value: string | null | undefined): string | null {\n if (value === null || value === undefined || value.trim() === '') return null;\n const normalized = value.trim().toLowerCase();\n if (!SHA256_HEX.test(normalized)) {\n throw new FilesClientError('INVALID_INPUT', 'sha256Hash must be 64 hex characters', { field: 'sha256Hash' });\n }\n return normalized;\n}\n\n/** Validate MULTIPART part ETags: positive, unique part numbers with a non-empty ETag, sorted. */\nfunction normalizeUploadedParts(parts: readonly UploadedPart[]): UploadedPart[] {\n const seen = new Set<number>();\n const normalized = parts.map((part) => {\n const etag = typeof part.etag === 'string' ? part.etag.trim() : '';\n if (!Number.isSafeInteger(part.partNumber) || part.partNumber <= 0 || seen.has(part.partNumber) || !etag) {\n throw new FilesClientError('INVALID_INPUT', 'parts must have unique positive part numbers and an ETag', {\n field: 'parts',\n partNumber: part.partNumber,\n });\n }\n seen.add(part.partNumber);\n return { partNumber: part.partNumber, etag };\n });\n return normalized.sort((a, b) => a.partNumber - b.partNumber);\n}\n\n/** Map a files-svc `File` selection onto {@link FileMetadata}. */\nexport function mapFileMetadata(raw: RawFileMetadata): FileMetadata {\n return {\n id: raw.id,\n name: raw.name,\n mimeType: raw.mimeType,\n extension: raw.extension,\n size: toNumber(raw.size, 'size'),\n status: raw.status,\n visibility: raw.visibility,\n workspaceId: raw.workspaceId,\n folderId: raw.folderId ?? null,\n uploadedById: raw.uploadedById,\n description: raw.description ?? null,\n sha256Hash: raw.sha256Hash ?? null,\n createdAt: toDate(raw.createdAt),\n updatedAt: toDate(raw.updatedAt),\n canRead: raw.canRead ?? null,\n canDelete: raw.canDelete ?? null,\n };\n}\n\nexport class FilesClient {\n private readonly clientOption: FilesClientOptions['client'];\n private readonly serviceName: string | undefined;\n private readonly fetchImpl: FilesFetch;\n private readonly requestTimeoutMs: number;\n private readonly transferTimeoutMs: number;\n private readonly maxUploadBytes: number;\n private readonly maxDownloadBytes: number;\n private readonly defaultDownloadUrlTtlSeconds: number;\n private clientPromise: Promise<FilesTransport> | null = null;\n\n constructor(options: FilesClientOptions = {}) {\n this.clientOption = options.client;\n this.serviceName = options.serviceName;\n this.fetchImpl = options.fetch ?? ((url, init) => fetch(url, init));\n this.requestTimeoutMs = requirePositiveInteger(\n options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,\n 'requestTimeoutMs'\n );\n this.transferTimeoutMs = requirePositiveInteger(\n options.transferTimeoutMs ?? DEFAULT_TRANSFER_TIMEOUT_MS,\n 'transferTimeoutMs'\n );\n this.maxUploadBytes = requirePositiveInteger(options.maxUploadBytes ?? DEFAULT_MAX_UPLOAD_BYTES, 'maxUploadBytes');\n this.maxDownloadBytes = requirePositiveInteger(\n options.maxDownloadBytes ?? DEFAULT_MAX_DOWNLOAD_BYTES,\n 'maxDownloadBytes'\n );\n const ttl = options.defaultDownloadUrlTtlSeconds ?? DEFAULT_DOWNLOAD_URL_TTL_SECONDS;\n if (!Number.isSafeInteger(ttl) || ttl < MIN_DOWNLOAD_URL_TTL_SECONDS || ttl > MAX_DOWNLOAD_URL_TTL_SECONDS) {\n throw new FilesClientError(\n 'CONFIGURATION_ERROR',\n `defaultDownloadUrlTtlSeconds must be between ${MIN_DOWNLOAD_URL_TTL_SECONDS} and ${MAX_DOWNLOAD_URL_TTL_SECONDS}`,\n { value: ttl }\n );\n }\n this.defaultDownloadUrlTtlSeconds = ttl;\n }\n\n // ── Upload ────────────────────────────────────────────────────────────\n\n /**\n * Store bytes in the actor's workspace file library and return the File's id.\n * Throws {@link FilesClientError}; on any failure after the session was opened\n * the session is aborted so no half-uploaded object is left behind.\n */\n async uploadFile(input: UploadFileInput, actor: FileActor): Promise<StoredFile> {\n const context = this.requireActor(actor);\n const fileName = requireNonEmpty(input.fileName, 'fileName');\n const mimeType = requireNonEmpty(input.mimeType, 'mimeType');\n const bytes = toBytes(input.data);\n if (bytes.byteLength === 0) {\n throw new FilesClientError('INVALID_INPUT', 'data must not be empty', { field: 'data' });\n }\n if (bytes.byteLength > this.maxUploadBytes) {\n throw new FilesClientError('TOO_LARGE', `File is larger than ${this.maxUploadBytes} bytes`, {\n size: bytes.byteLength,\n maxBytes: this.maxUploadBytes,\n });\n }\n if (input.visibility !== undefined && !FILE_VISIBILITIES.includes(input.visibility)) {\n throw new FilesClientError('INVALID_INPUT', `Unknown file visibility \"${String(input.visibility)}\"`, {\n field: 'visibility',\n });\n }\n const extension = input.extension?.trim()\n ? input.extension.trim().replace(/^\\./, '').toLowerCase()\n : fileExtensionOf(fileName);\n // `BigInt` travels as a string, and completeUpload must repeat exactly the value given to initiate.\n const fileSize = String(bytes.byteLength);\n const sha256Hash = input.declareSha256 === false ? null : createHash('sha256').update(bytes).digest('hex');\n const folderId = input.folderId?.trim() || undefined;\n\n const initiated = await this.request<{\n initiateUpload: {\n uploadUrl?: string | null;\n session?: {\n id: string;\n uploadType: FileUploadType;\n partSize: number | string;\n totalParts: number | string;\n } | null;\n } | null;\n }>(\n 'initiateUpload',\n INITIATE_UPLOAD,\n {\n input: {\n fileName,\n fileSize,\n mimeType,\n extension,\n ...(folderId ? { folderId } : {}),\n ...(input.visibility ? { visibility: input.visibility } : {}),\n ...(sha256Hash ? { sha256Hash } : {}),\n },\n },\n context\n );\n const rawSession = initiated.initiateUpload?.session;\n if (!rawSession?.id) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc initiateUpload returned no session');\n }\n const session: InitiatedSession = {\n id: rawSession.id,\n uploadType: rawSession.uploadType,\n partSize: toNumber(rawSession.partSize, 'partSize'),\n totalParts: toNumber(rawSession.totalParts, 'totalParts'),\n };\n\n try {\n if (session.uploadType === 'MULTIPART') {\n await this.uploadParts(session, bytes, context);\n } else {\n await this.putDirect(initiated.initiateUpload?.uploadUrl, bytes, mimeType);\n }\n\n return await this.completeSession(\n session.id,\n {\n fileSize,\n fallbackName: fileName,\n fallbackMimeType: mimeType,\n fallbackSize: bytes.byteLength,\n sha256Hash,\n folderId,\n description: input.description ?? null,\n },\n context\n );\n } catch (error) {\n await this.abortQuietly(session.id, context);\n throw toFilesClientError(error, 'uploadFile');\n }\n }\n\n // ── Delegated upload ──────────────────────────────────────────────────\n\n /**\n * Open a files-svc upload session on the actor's behalf for bytes that\n * someone else holds (an agent, a CLI, a browser), and return the presigned\n * URL(s) to hand them. The uploader PUTs the bytes — one PUT to `uploadUrl`\n * for DIRECT, one PUT per `parts` entry for MULTIPART (files-svc picks\n * MULTIPART above 5 MiB) — and the service then calls\n * {@link completeUploadSession} with the same `fileSize` (and the part ETags)\n * to turn the session into a File. The service never sees the bytes and never\n * holds storage credentials.\n *\n * Throws {@link FilesClientError}. If files-svc opened the session but the\n * client cannot hand it out (an unsupported upload type, missing part URLs),\n * the session is aborted before the error is thrown.\n */\n async createUploadSession(input: CreateUploadSessionInput, actor: FileActor): Promise<UploadSessionTicket> {\n const context = this.requireActor(actor);\n const fileName = requireNonEmpty(input.fileName, 'fileName');\n const mimeType = requireNonEmpty(input.mimeType, 'mimeType');\n if (!Number.isSafeInteger(input.fileSize) || input.fileSize <= 0) {\n throw new FilesClientError('INVALID_INPUT', 'fileSize must be a positive integer', { field: 'fileSize' });\n }\n if (input.fileSize > this.maxUploadBytes) {\n throw new FilesClientError('TOO_LARGE', `File is larger than ${this.maxUploadBytes} bytes`, {\n size: input.fileSize,\n maxBytes: this.maxUploadBytes,\n });\n }\n if (input.visibility !== undefined && !FILE_VISIBILITIES.includes(input.visibility)) {\n throw new FilesClientError('INVALID_INPUT', `Unknown file visibility \"${String(input.visibility)}\"`, {\n field: 'visibility',\n });\n }\n const sha256Hash = normalizeSha256(input.sha256Hash);\n const extension = input.extension?.trim()\n ? input.extension.trim().replace(/^\\./, '').toLowerCase()\n : fileExtensionOf(fileName);\n const folderId = input.folderId?.trim() || undefined;\n\n const initiated = await this.request<{\n initiateUpload: {\n uploadUrl?: string | null;\n session?: {\n id: string;\n uploadType: FileUploadType;\n partSize: number | string;\n totalParts: number | string;\n expiresAt?: string | null;\n } | null;\n } | null;\n }>(\n 'initiateUpload',\n INITIATE_UPLOAD,\n {\n input: {\n fileName,\n fileSize: String(input.fileSize),\n mimeType,\n extension,\n ...(folderId ? { folderId } : {}),\n ...(input.visibility ? { visibility: input.visibility } : {}),\n ...(sha256Hash ? { sha256Hash } : {}),\n },\n },\n context\n );\n const rawSession = initiated.initiateUpload?.session;\n if (!rawSession?.id) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc initiateUpload returned no session');\n }\n\n try {\n const partSize = toNumber(rawSession.partSize, 'partSize');\n const totalParts = toNumber(rawSession.totalParts, 'totalParts');\n const base = {\n sessionId: rawSession.id,\n partSize,\n totalParts,\n fileSize: input.fileSize,\n sha256Hash,\n expiresAt: toDate(rawSession.expiresAt),\n };\n if (rawSession.uploadType === 'MULTIPART') {\n const session: InitiatedSession = { id: rawSession.id, uploadType: 'MULTIPART', partSize, totalParts };\n this.assertMultipartPlan(session, input.fileSize);\n const parts = await this.presignParts(session, input.fileSize, context);\n return { ...base, uploadType: 'MULTIPART', uploadUrl: null, requiredHeaders: {}, parts };\n }\n if (rawSession.uploadType !== 'DIRECT') {\n throw new FilesClientError(\n 'UPSTREAM_ERROR',\n `wspace-files-svc opened an unsupported ${String(rawSession.uploadType)} session`,\n { sessionId: rawSession.id }\n );\n }\n const uploadUrl = initiated.initiateUpload?.uploadUrl;\n if (!isHttpUrl(uploadUrl)) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc initiateUpload returned no upload URL', {\n sessionId: rawSession.id,\n });\n }\n return { ...base, uploadType: 'DIRECT', uploadUrl, requiredHeaders: { 'Content-Type': mimeType }, parts: [] };\n } catch (error) {\n await this.abortQuietly(rawSession.id, context);\n throw toFilesClientError(error, 'createUploadSession');\n }\n }\n\n /**\n * Turn a session opened by {@link createUploadSession} into a File once the\n * uploader has PUT the bytes: registers the MULTIPART part ETags, then runs\n * `completeUpload` with the declared size (and SHA-256). files-svc verifies\n * the stored object; a size or checksum mismatch surfaces as `INVALID_INPUT`.\n * The session is left open on failure so the caller can retry or\n * {@link abortUploadSession} it.\n */\n async completeUploadSession(\n sessionId: string,\n input: CompleteUploadSessionInput,\n actor: FileActor\n ): Promise<StoredFile> {\n const context = this.requireActor(actor);\n const id = requireNonEmpty(sessionId, 'sessionId');\n if (!Number.isSafeInteger(input.fileSize) || input.fileSize <= 0) {\n throw new FilesClientError('INVALID_INPUT', 'fileSize must be a positive integer', { field: 'fileSize' });\n }\n const sha256Hash = normalizeSha256(input.sha256Hash);\n const parts = normalizeUploadedParts(input.parts ?? []);\n const folderId = input.folderId?.trim() || undefined;\n\n for (const part of parts) {\n await this.request(\n 'registerUploadedPart',\n REGISTER_PART,\n { input: { sessionId: id, partNumber: part.partNumber, etag: part.etag } },\n context\n );\n }\n return this.completeSession(\n id,\n {\n fileSize: String(input.fileSize),\n fallbackName: '',\n fallbackMimeType: '',\n fallbackSize: input.fileSize,\n sha256Hash,\n folderId,\n description: input.description ?? null,\n },\n context\n );\n }\n\n /** Abandon a session opened by {@link createUploadSession}. `true` when files-svc aborted it. */\n async abortUploadSession(sessionId: string, actor: FileActor): Promise<boolean> {\n const id = requireNonEmpty(sessionId, 'sessionId');\n const data = await this.request<{ abortUpload: boolean | null }>(\n 'abortUpload',\n ABORT_UPLOAD,\n { sessionId: id },\n actor\n );\n return data.abortUpload === true;\n }\n\n // ── Read ──────────────────────────────────────────────────────────────\n\n /** File metadata, or `null` when it does not exist or the actor cannot see it. */\n async getFile(fileId: string, actor: FileActor): Promise<FileMetadata | null> {\n const id = requireNonEmpty(fileId, 'fileId');\n try {\n const data = await this.request<{ getFile: RawFileMetadata | null }>('getFile', GET_FILE, { id }, actor);\n return data.getFile ? mapFileMetadata(data.getFile) : null;\n } catch (error) {\n if (error instanceof FilesClientError && error.code === 'NOT_FOUND') return null;\n throw error;\n }\n }\n\n /**\n * Prove that an opaque file id the caller supplied names a File in the actor's\n * workspace that they may read, before the service stores or acts on it.\n * Throws `NOT_FOUND` (never a permission error) otherwise.\n */\n async requireFile(fileId: string, actor: FileActor, options: RequireFileOptions = {}): Promise<FileMetadata> {\n const context = this.requireActor(actor);\n const file = await this.getFile(fileId, context);\n this.assertUsable(file, fileId, context, options);\n return file;\n }\n\n /**\n * A presigned download URL for the file, minted for the actor. Mint it when the\n * user opens the file; never persist it. The lifetime is clamped to\n * [60, 604800] seconds.\n */\n async getDownloadUrl(fileId: string, actor: FileActor, options: DownloadUrlOptions = {}): Promise<string> {\n const id = requireNonEmpty(fileId, 'fileId');\n const expiresIn = clampDownloadUrlTtl(options.expiresInSeconds, this.defaultDownloadUrlTtlSeconds);\n const data = await this.request<{ getFileDownloadUrl: string | null }>(\n 'getFileDownloadUrl',\n GET_DOWNLOAD_URL,\n { id, expiresIn },\n actor\n );\n if (!isHttpUrl(data.getFileDownloadUrl)) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc returned no usable download URL', { fileId: id });\n }\n return data.getFileDownloadUrl;\n }\n\n /**\n * Fetch the file's bytes for server-side processing (vision models, parsers,\n * workflow nodes). Checks the file is active, readable by the actor and within\n * `maxBytes` before downloading, and verifies the downloaded size.\n */\n async downloadFile(fileId: string, actor: FileActor, options: DownloadFileOptions = {}): Promise<DownloadedFile> {\n const context = this.requireActor(actor);\n const id = requireNonEmpty(fileId, 'fileId');\n const maxBytes = options.maxBytes ?? this.maxDownloadBytes;\n if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {\n throw new FilesClientError('INVALID_INPUT', 'maxBytes must be a positive integer', { field: 'maxBytes' });\n }\n\n const data = await this.request<{ getFile: RawFileMetadata | null; getFileDownloadUrl: string | null }>(\n 'downloadFile',\n RESOLVE_FOR_DOWNLOAD,\n { id, expiresIn: INTERNAL_DOWNLOAD_URL_TTL_SECONDS },\n context\n );\n const file = data.getFile ? mapFileMetadata(data.getFile) : null;\n this.assertUsable(file, id, context, {});\n if (file.size > maxBytes) {\n throw new FilesClientError('TOO_LARGE', `File is larger than ${maxBytes} bytes`, {\n fileId: id,\n size: file.size,\n maxBytes,\n });\n }\n const url = data.getFileDownloadUrl;\n if (!isHttpUrl(url)) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc returned no usable download URL', { fileId: id });\n }\n\n const response = await this.transfer(url, { method: 'GET' }, 'download');\n const bytes = await this.readBounded(response, maxBytes, id);\n if (bytes.byteLength !== file.size) {\n throw new FilesClientError('STORAGE_ERROR', 'Downloaded size does not match the stored file size', {\n fileId: id,\n expected: file.size,\n actual: bytes.byteLength,\n });\n }\n return { bytes, mimeType: file.mimeType, name: file.name, size: bytes.byteLength };\n }\n\n /** {@link downloadFile} as base64, for payloads that must stay JSON (model inputs). */\n async downloadFileAsBase64(\n fileId: string,\n actor: FileActor,\n options: DownloadFileOptions = {}\n ): Promise<{ base64: string; mimeType: string; name: string; size: number }> {\n const file = await this.downloadFile(fileId, actor, options);\n return {\n base64: Buffer.from(file.bytes).toString('base64'),\n mimeType: file.mimeType,\n name: file.name,\n size: file.size,\n };\n }\n\n // ── Delete ────────────────────────────────────────────────────────────\n\n /** Move the file to trash (or hard-delete with `permanent`). `true` when files-svc deleted it. */\n async deleteFile(fileId: string, actor: FileActor, options: DeleteFileOptions = {}): Promise<boolean> {\n const id = requireNonEmpty(fileId, 'fileId');\n if (options.permanent) {\n const data = await this.request<{ permanentlyDeleteFile: boolean | null }>(\n 'permanentlyDeleteFile',\n PERMANENTLY_DELETE_FILE,\n { id },\n actor\n );\n return data.permanentlyDeleteFile === true;\n }\n const data = await this.request<{ deleteFile: boolean | null }>('deleteFile', DELETE_FILE, { id }, actor);\n return data.deleteFile === true;\n }\n\n // ── Upload legs ───────────────────────────────────────────────────────\n\n private async putDirect(\n uploadUrl: string | null | undefined,\n bytes: Uint8Array<ArrayBuffer>,\n mimeType: string\n ): Promise<void> {\n if (!isHttpUrl(uploadUrl)) {\n // files-svc returns a DIRECT uploadUrl for every non-multipart session; its absence\n // means the storage provider is misconfigured, not that a fallback is wanted.\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc initiateUpload returned no upload URL');\n }\n // The presigned PUT is signed for this Content-Type, so it must match what initiate declared.\n await this.transfer(uploadUrl, { method: 'PUT', body: bytes, headers: { 'Content-Type': mimeType } }, 'upload');\n }\n\n private async uploadParts(\n session: InitiatedSession,\n bytes: Uint8Array<ArrayBuffer>,\n actor: FileActor\n ): Promise<void> {\n this.assertMultipartPlan(session, bytes.byteLength);\n\n for (let first = 1; first <= session.totalParts; first += PART_URL_BATCH_SIZE) {\n const partNumbers: number[] = [];\n for (let part = first; part < first + PART_URL_BATCH_SIZE && part <= session.totalParts; part += 1) {\n partNumbers.push(part);\n }\n const data = await this.request<{ getBatchPartUploadUrls: Array<{ partNumber: number; url: string }> | null }>(\n 'getBatchPartUploadUrls',\n PART_URLS,\n { sessionId: session.id, partNumbers },\n actor\n );\n const urls = new Map((data.getBatchPartUploadUrls ?? []).map((entry) => [entry.partNumber, entry.url]));\n\n for (const partNumber of partNumbers) {\n const url = urls.get(partNumber);\n if (!isHttpUrl(url)) {\n throw new FilesClientError('UPSTREAM_ERROR', `wspace-files-svc returned no URL for part ${partNumber}`, {\n sessionId: session.id,\n partNumber,\n });\n }\n const start = (partNumber - 1) * session.partSize;\n const body = bytes.subarray(start, Math.min(start + session.partSize, bytes.byteLength));\n const response = await this.transfer(url, { method: 'PUT', body }, 'upload');\n const etag = response.headers.get('etag');\n if (!etag) {\n throw new FilesClientError('STORAGE_ERROR', `Object storage returned no ETag for part ${partNumber}`, {\n sessionId: session.id,\n partNumber,\n });\n }\n await this.request(\n 'registerUploadedPart',\n REGISTER_PART,\n { input: { sessionId: session.id, partNumber, etag } },\n actor\n );\n }\n }\n }\n\n private async completeSession(\n sessionId: string,\n args: {\n fileSize: string;\n fallbackName: string;\n fallbackMimeType: string;\n fallbackSize: number;\n sha256Hash: string | null;\n folderId: string | undefined;\n description: string | null;\n },\n actor: FileActor\n ): Promise<StoredFile> {\n const completed = await this.request<{\n completeUpload: {\n fileId?: string | null;\n file?: {\n id: string;\n name: string;\n mimeType: string;\n size: string | number;\n workspaceId: string;\n sha256Hash?: string | null;\n } | null;\n } | null;\n }>(\n 'completeUpload',\n COMPLETE_UPLOAD,\n {\n input: {\n sessionId,\n fileSize: args.fileSize,\n ...(args.folderId ? { folderId: args.folderId } : {}),\n ...(args.description ? { description: args.description } : {}),\n ...(args.sha256Hash ? { sha256Hash: args.sha256Hash } : {}),\n },\n },\n actor\n );\n const file = completed.completeUpload?.file;\n const fileId = completed.completeUpload?.fileId ?? file?.id;\n if (!fileId) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc completeUpload returned no fileId', {\n sessionId,\n });\n }\n return {\n fileId,\n name: file?.name ?? args.fallbackName,\n mimeType: file?.mimeType ?? args.fallbackMimeType,\n size: file ? toNumber(file.size, 'size') : args.fallbackSize,\n workspaceId: file?.workspaceId ?? actor.workspaceId,\n sha256Hash: file?.sha256Hash ?? args.sha256Hash,\n };\n }\n\n private assertMultipartPlan(session: InitiatedSession, size: number): void {\n if (session.partSize <= 0 || session.totalParts !== Math.ceil(size / session.partSize)) {\n throw new FilesClientError('UPSTREAM_ERROR', 'wspace-files-svc returned an inconsistent multipart plan', {\n sessionId: session.id,\n partSize: session.partSize,\n totalParts: session.totalParts,\n size,\n });\n }\n }\n\n /** Presigned URL for every part, fetched in batches. */\n private async partUrls(session: InitiatedSession, actor: FileActor): Promise<Map<number, string>> {\n const urls = new Map<number, string>();\n for (let first = 1; first <= session.totalParts; first += PART_URL_BATCH_SIZE) {\n const partNumbers: number[] = [];\n for (let part = first; part < first + PART_URL_BATCH_SIZE && part <= session.totalParts; part += 1) {\n partNumbers.push(part);\n }\n const data = await this.request<{ getBatchPartUploadUrls: Array<{ partNumber: number; url: string }> | null }>(\n 'getBatchPartUploadUrls',\n PART_URLS,\n { sessionId: session.id, partNumbers },\n actor\n );\n for (const entry of data.getBatchPartUploadUrls ?? []) urls.set(entry.partNumber, entry.url);\n }\n return urls;\n }\n\n private async presignParts(session: InitiatedSession, size: number, actor: FileActor): Promise<UploadSessionPart[]> {\n const urls = await this.partUrls(session, actor);\n const parts: UploadSessionPart[] = [];\n for (let partNumber = 1; partNumber <= session.totalParts; partNumber += 1) {\n const url = urls.get(partNumber);\n if (!isHttpUrl(url)) {\n throw new FilesClientError('UPSTREAM_ERROR', `wspace-files-svc returned no URL for part ${partNumber}`, {\n sessionId: session.id,\n partNumber,\n });\n }\n const offset = (partNumber - 1) * session.partSize;\n parts.push({\n partNumber,\n url,\n offset,\n length: Math.min(session.partSize, size - offset),\n });\n }\n return parts;\n }\n\n private async abortQuietly(sessionId: string, actor: FileActor): Promise<void> {\n try {\n await this.request('abortUpload', ABORT_UPLOAD, { sessionId }, actor);\n } catch {\n // Best effort: files-svc's upload reaper expires abandoned sessions anyway, and the\n // original failure is what the caller needs to see.\n }\n }\n\n // ── Transport ─────────────────────────────────────────────────────────\n\n private assertUsable(\n file: FileMetadata | null,\n fileId: string,\n actor: FileActor,\n options: RequireFileOptions\n ): asserts file is FileMetadata {\n const requireActive = options.requireActive ?? true;\n const requireReadable = options.requireReadable ?? true;\n if (\n !file ||\n file.id !== fileId.trim() ||\n file.workspaceId !== actor.workspaceId ||\n (requireActive && file.status !== 'ACTIVE') ||\n (requireReadable && file.canRead !== true)\n ) {\n throw new FilesClientError('NOT_FOUND', 'File not found', { fileId });\n }\n }\n\n private async transfer(url: string, init: RequestInit, leg: 'upload' | 'download'): Promise<Response> {\n let response: Response;\n try {\n response = await this.fetchImpl(url, { ...init, signal: AbortSignal.timeout(this.transferTimeoutMs) });\n } catch (error) {\n throw new FilesClientError('STORAGE_ERROR', `Object storage ${leg} failed`, {\n leg,\n cause: error instanceof Error ? error.message : String(error),\n });\n }\n if (!response.ok) {\n throw new FilesClientError('STORAGE_ERROR', `Object storage ${leg} failed with HTTP ${response.status}`, {\n leg,\n status: response.status,\n });\n }\n return response;\n }\n\n private async readBounded(response: Response, maxBytes: number, fileId: string): Promise<Uint8Array> {\n const tooLarge = (): FilesClientError =>\n new FilesClientError('TOO_LARGE', `File is larger than ${maxBytes} bytes`, { fileId, maxBytes });\n\n const declared = Number(response.headers.get('content-length') ?? Number.NaN);\n if (Number.isFinite(declared) && declared > maxBytes) throw tooLarge();\n if (!response.body) {\n const buffer = new Uint8Array(await response.arrayBuffer());\n if (buffer.byteLength > maxBytes) throw tooLarge();\n return buffer;\n }\n\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n total += value.byteLength;\n if (total > maxBytes) {\n await reader.cancel();\n throw tooLarge();\n }\n chunks.push(value);\n }\n const bytes = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n }\n\n private requireActor(actor: FileActor): FileActor {\n if (!actor.actorId?.trim() || !actor.workspaceId?.trim()) {\n throw new FilesClientError('MISSING_CONTEXT', 'File operations need an authenticated actor and a workspace');\n }\n if (actor.actorType !== undefined && !FILE_ACTOR_TYPES.includes(actor.actorType)) {\n throw new FilesClientError('MISSING_CONTEXT', `Unknown actor type \"${String(actor.actorType)}\"`);\n }\n return actor;\n }\n\n private getClient(): Promise<FilesTransport> {\n if (!this.clientPromise) {\n const option = this.clientOption;\n this.clientPromise = (async (): Promise<FilesTransport> => {\n try {\n if (typeof option === 'function') return await option();\n if (option) return option;\n // Dynamic import keeps the gateway client (and its JWT/crypto deps) out of\n // the static module graph of `@burdenoff/be-sdk/files` consumers.\n const gateway = await import('../gateway/client.js');\n if (this.serviceName) {\n return new gateway.GatewayClient({\n layer: 'wspace',\n serviceName: this.serviceName,\n serviceIdentity: this.serviceName,\n });\n }\n return gateway.createGatewayClientFromEnv();\n } catch (error) {\n throw new FilesClientError('CONFIGURATION_ERROR', 'Files gateway client is not configured', {\n cause: error instanceof Error ? error.message : String(error),\n });\n }\n })();\n // A failed construction (bad env) must not be cached forever.\n this.clientPromise.catch(() => {\n this.clientPromise = null;\n });\n }\n return this.clientPromise;\n }\n\n private async request<T>(\n operation: string,\n query: string,\n variables: Record<string, unknown>,\n actor: FileActor\n ): Promise<T> {\n const { actorId, workspaceId, actorType } = this.requireActor(actor);\n const client = await this.getClient();\n let response: GraphQLResponse<T>;\n try {\n response = await client.internalQuery<T>({\n query,\n variables,\n timeout: this.requestTimeoutMs,\n headers: {\n 'x-actor-id': actorId,\n 'x-actor-type': actorType ?? 'user',\n 'x-workspace-id': workspaceId,\n },\n });\n } catch (error) {\n throw toFilesClientError(error, operation);\n }\n if (response.errors?.length) {\n throw new FilesClientError(classifyFilesErrors(response.errors), `wspace-files-svc ${operation} failed`, {\n operation,\n errors: response.errors.map((error) => ({ message: error.message, code: error.extensions?.['code'] ?? null })),\n });\n }\n if (!response.data) {\n throw new FilesClientError('UPSTREAM_ERROR', `wspace-files-svc ${operation} returned no data`, { operation });\n }\n return response.data;\n }\n}\n","/**\n * File references — the binary-data shape that travels instead of inline bytes.\n *\n * Workflow node outputs, attachments and evidence records should carry a small,\n * JSON-safe pointer to a wspace-files-svc File rather than a base64 payload: the\n * bytes stay in the workspace file library (quota-tracked, permission-checked),\n * and whoever needs them resolves the pointer with `FilesClient.downloadFile` or\n * `FilesClient.getDownloadUrl` on behalf of the current actor.\n */\nimport type { FileMetadata, StoredFile } from './types.js';\n\n/** Discriminator value of {@link FileReference.kind}. */\nexport const FILE_REFERENCE_KIND = 'burdenoff.file' as const;\n\n/** JSON-safe pointer to a File owned by wspace-files-svc. */\nexport interface FileReference {\n kind: typeof FILE_REFERENCE_KIND;\n fileId: string;\n name: string;\n mimeType: string;\n /** Size in bytes. */\n size: number;\n /** Lowercase hex SHA-256 when known. */\n sha256Hash: string | null;\n}\n\n/** Build a {@link FileReference} from an upload result or file metadata. */\nexport function toFileReference(file: StoredFile | FileMetadata): FileReference {\n return {\n kind: FILE_REFERENCE_KIND,\n fileId: 'fileId' in file ? file.fileId : file.id,\n name: file.name,\n mimeType: file.mimeType,\n size: file.size,\n sha256Hash: file.sha256Hash,\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Type guard for a {@link FileReference} read back from JSON (node output, DB column, …). */\nexport function isFileReference(value: unknown): value is FileReference {\n if (!isRecord(value)) return false;\n const size = value['size'];\n const sha256Hash = value['sha256Hash'];\n return (\n value['kind'] === FILE_REFERENCE_KIND &&\n typeof value['fileId'] === 'string' &&\n value['fileId'].length > 0 &&\n typeof value['name'] === 'string' &&\n typeof value['mimeType'] === 'string' &&\n typeof size === 'number' &&\n Number.isSafeInteger(size) &&\n size >= 0 &&\n (sha256Hash === null || sha256Hash === undefined || typeof sha256Hash === 'string')\n );\n}\n","/**\n * @burdenoff/be-sdk/files\n *\n * Shared client for workspace blobs owned by wspace-files-svc. Services hand it\n * bytes and keep the opaque `fileId`; they never presign object storage or hold\n * storage credentials themselves.\n *\n * - {@link FilesClient} — upload (DIRECT and MULTIPART, size + SHA-256 declared),\n * metadata, reference validation, short-lived download URLs, bounded byte\n * downloads and delete, all on behalf of the calling actor over the internal\n * workspace gateway. Delegated uploads (`createUploadSession` →\n * `completeUploadSession`) hand presigned URLs to whoever holds the bytes.\n * - {@link FileReference} — the JSON-safe pointer that node outputs, attachments\n * and evidence rows carry instead of inline base64.\n *\n * @example\n * ```ts\n * import { FilesClient, toFileReference } from '@burdenoff/be-sdk/files';\n *\n * const files = new FilesClient({ serviceName: 'wspace-workflow-svc' });\n * const stored = await files.uploadFile({ fileName: 'invoice.pdf', data, mimeType: 'application/pdf' }, actor);\n * return { attachment: toFileReference(stored) };\n * ```\n */\n\nexport {\n FILE_ACTOR_TYPES,\n FILE_VISIBILITIES,\n type CompleteUploadSessionInput,\n type CreateUploadSessionInput,\n type DeleteFileOptions,\n type DownloadFileOptions,\n type DownloadUrlOptions,\n type DownloadedFile,\n type FileActor,\n type FileActorType,\n type FileBytes,\n type FileMetadata,\n type FileStatus,\n type FileUploadType,\n type FileVisibility,\n type FilesFetch,\n type FilesTransport,\n type RawFileMetadata,\n type RequireFileOptions,\n type StoredFile,\n type UploadFileInput,\n type UploadSessionPart,\n type UploadSessionTicket,\n type UploadedPart,\n} from './types.js';\n\nexport {\n FILES_CLIENT_GRAPHQL_CODES,\n FilesClientError,\n classifyFilesErrors,\n isFilesClientError,\n toFilesClientError,\n type FilesClientErrorCode,\n} from './errors.js';\n\nexport {\n FilesClient,\n MAX_DOWNLOAD_URL_TTL_SECONDS,\n MIN_DOWNLOAD_URL_TTL_SECONDS,\n clampDownloadUrlTtl,\n fileExtensionOf,\n mapFileMetadata,\n type FilesClientOptions,\n} from './client.js';\n\nexport { FILE_REFERENCE_KIND, isFileReference, toFileReference, type FileReference } from './reference.js';\n"],"mappings":";;;;;;AAYA,MAAa,mBAAmB;CAAC;CAAQ;CAAO;CAAW;AAAa;;AAuBxE,MAAa,oBAAoB;CAAC;CAAW;CAAU;CAAQ;AAAW;;;;;;;;;;;;ACN1E,MAAa,6BAAmE;CAC9E,eAAe;CACf,iBAAiB;CAEjB,WAAW;CACX,gBAAgB;CAChB,WAAW;CACX,eAAe;CACf,gBAAgB;CAChB,qBAAqB;AACvB;AAEA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,AAAS;CACT,AAAS;CAET,YAAY,MAA4B,SAAiB,UAAmC,CAAC,GAAG;EAC9F,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;;CAGA,IAAI,cAAsB;EACxB,OAAO,2BAA2B,KAAK;CACzC;AACF;AAEA,SAAgB,mBAAmB,OAA2C;CAC5E,OAAO,iBAAiB;AAC1B;AAEA,MAAM,2CAA2B,IAAI,IAAI,CAAC,aAAa,WAAW,CAAC;AACnE,MAAM,uCAAuB,IAAI,IAAI;CAAC;CAAkB;CAAmB;AAAsB,CAAC;AAClG,MAAM,yCAAyB,IAAI,IAAI,CAAC,kBAAkB,SAAS,CAAC;AAEpE,SAAS,aAAa,OAAoC;CACxD,MAAM,OAAO,MAAM,aAAa;CAChC,OAAO,OAAO,SAAS,WAAW,OAAO;AAC3C;;AAGA,SAAgB,oBAAoB,QAAuD;CACzF,MAAM,QAAQ,OAAO,IAAI,YAAY,CAAC,CAAC,QAAQ,SAAyB,SAAS,IAAI;CACrF,IAAI,MAAM,MAAM,SAA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CAAC;EAEH,IAAI,CAAC,SAAS,MACZ,MAAM,IAAI,iBAAiB,kBAAkB,oBAAoB,UAAU,oBAAoB,EAAE,UAAU,CAAC;EAE9G,OAAO,SAAS;CAClB;AACF;;;;ACt/BA,MAAa,sBAAsB;;AAenC,SAAgB,gBAAgB,MAAgD;CAC9E,OAAO;EACL,MAAM;EACN,QAAQ,YAAY,OAAO,KAAK,SAAS,KAAK;EAC9C,MAAM,KAAK;EACX,UAAU,KAAK;EACf,MAAM,KAAK;EACX,YAAY,KAAK;CACnB;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,SAAgB,gBAAgB,OAAwC;CACtE,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO;CAC7B,MAAM,OAAO,MAAM;CACnB,MAAM,aAAa,MAAM;CACzB,OACE,MAAM,gCACN,OAAO,MAAM,cAAc,YAC3B,MAAM,SAAS,CAAC,SAAS,KACzB,OAAO,MAAM,YAAY,YACzB,OAAO,MAAM,gBAAgB,YAC7B,OAAO,SAAS,YAChB,OAAO,cAAc,IAAI,KACzB,QAAQ,MACP,eAAe,QAAQ,eAAe,UAAa,OAAO,eAAe;AAE9E"}
@@ -1,6 +1,4 @@
1
- export { G as GatewayClient, c as createGatewayClient, a as createGatewayClientFromEnv, i as isGatewayClientError } from '../client-DSI_760t.js';
2
- export { D as DELEGATED_AUTHORIZATION_HEADER, a as DelegatedGatewayTransportInput, b as buildDelegatedGatewayHeaders, s as signServiceJwt } from '../index-BejbszA7.js';
3
- export { C as CircuitBreakerStats, e as CircuitState, G as GatewayClientConfig, d as GatewayClientHealth, f as GatewayError, g as GatewayErrorType, h as GraphQLError, a as GraphQLRequestOptions, b as GraphQLResponse, c as ICircuitBreaker, I as IGatewayClient, R as RequestContext } from '../types-DgJ4lDYA.js';
4
- export { i as Security } from '../index-BOuDKnqD.js';
5
- import '../layer-Cv9vSwBx.js';
6
- import 'graphql-yoga';
1
+ import { a as GatewayError, c as GraphQLRequestOptions, d as IGatewayClient, f as RequestContext, i as GatewayClientHealth, l as GraphQLResponse, n as CircuitState, o as GatewayErrorType, r as GatewayClientConfig, s as GraphQLError, t as CircuitBreakerStats, u as ICircuitBreaker } from "../types-C6EKaS3V.js";
2
+ import { a as signServiceJwt, c as createGatewayClientFromEnv, i as buildDelegatedGatewayHeaders, l as isGatewayClientError, n as DELEGATED_AUTHORIZATION_HEADER, o as GatewayClient, r as DelegatedGatewayTransportInput, s as createGatewayClient } from "../index-YOShAwkq.js";
3
+ import { t as index_d_exports } from "../index-C0qLquY0.js";
4
+ export { type CircuitBreakerStats, CircuitState, DELEGATED_AUTHORIZATION_HEADER, type DelegatedGatewayTransportInput, GatewayClient, type GatewayClientConfig, type GatewayClientHealth, GatewayError, GatewayErrorType, type GraphQLError, type GraphQLRequestOptions, type GraphQLResponse, type ICircuitBreaker, type IGatewayClient, type RequestContext, index_d_exports as Security, buildDelegatedGatewayHeaders, createGatewayClient, createGatewayClientFromEnv, isGatewayClientError, signServiceJwt };
@@ -1,14 +1,8 @@
1
- export { DELEGATED_AUTHORIZATION_HEADER, buildDelegatedGatewayHeaders } from '../chunk-CFXWH2IS.js';
2
- export { security_exports as Security } from '../chunk-726AR6Q7.js';
3
- export { GatewayClient, createGatewayClient, createGatewayClientFromEnv, isGatewayClientError } from '../chunk-SPRG6G6G.js';
4
- import '../chunk-FZRODKIN.js';
5
- import '../chunk-STWFX5E2.js';
6
- export { signServiceJwt } from '../chunk-VFCMR5GX.js';
7
- import '../chunk-RZOFS2BQ.js';
8
- export { CircuitState, GatewayError, GatewayErrorType } from '../chunk-QWNNFE4P.js';
9
- import '../chunk-A5F6Z5UE.js';
10
- import '../chunk-5CAFHK2Z.js';
11
- import '../chunk-RU266375.js';
12
- import '../chunk-XE4OXN2W.js';
1
+ import { t as signServiceJwt } from "../service-jwt-Bu-WNA_-.js";
2
+ import { a as isGatewayClientError, i as createGatewayClientFromEnv, r as createGatewayClient, t as GatewayClient } from "../client-DcZ3iGES.js";
3
+ import { n as GatewayError, r as GatewayErrorType, t as CircuitState } from "../types-BYMYND1L.js";
4
+ import { n as DELEGATED_AUTHORIZATION_HEADER, r as buildDelegatedGatewayHeaders } from "../gateway-DBFmxWks.js";
5
+ import { t as security_exports } from "../security-DIG-95Ic.js";
6
+
7
+ export { CircuitState, DELEGATED_AUTHORIZATION_HEADER, GatewayClient, GatewayError, GatewayErrorType, security_exports as Security, buildDelegatedGatewayHeaders, createGatewayClient, createGatewayClientFromEnv, isGatewayClientError, signServiceJwt };
13
8
  //# sourceMappingURL=index.js.map
14
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"file":"index.js","sources":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- export { A as ActorContext, a as ArmorConfig, C as CostMap, D as DEFAULT_ARMOR_CONFIG, b as DEFAULT_COST_MAP, c as DEFAULT_TIERS, G as GatewaySecurityOptions, M as MemoryValkey, O as OperationTimeoutConfig, d as OtelConfig, Q as QueryComplexityConfig, R as RateLimitConfig, e as RateLimitResult, S as SecurityValkeyClient, T as Tier, f as TierLimits, _ as __resetMetricsForTest, g as __setSecurityValkeyForTest, h as buildSecurityPlugins, j as checkRateLimit, k as createArmorPlugins, l as createOperationTimeoutPlugin, m as createOtelPlugin, n as createQueryComplexityPlugin, o as createRateLimitPlugin, p as getMetrics, q as getSecurityValkey, r as initializeMetrics, s as initializeOtel, t as initializeSecurityValkey, u as mergeCostMap, v as resolveActor, w as resolveSecurityOptionsFromEnv, x as resolveTiersFromEnv, y as scrapeMetrics, z as shutdownOtel } from '../../index-BOuDKnqD.js';
2
- import 'graphql-yoga';
1
+ import { A as OperationTimeoutConfig, C as DEFAULT_COST_MAP, D as ArmorConfig, E as ActorContext, F as SecurityValkeyClient, I as Tier, L as TierLimits, M as QueryComplexityConfig, N as RateLimitConfig, O as CostMap, P as RateLimitResult, S as resolveSecurityOptionsFromEnv, T as resolveActor, _ as getSecurityValkey, a as createQueryComplexityPlugin, b as resolveTiersFromEnv, c as shutdownOtel, d as __resetMetricsForTest, f as getMetrics, g as __setSecurityValkeyForTest, h as MemoryValkey, i as createRateLimitPlugin, j as OtelConfig, k as GatewaySecurityOptions, l as createOperationTimeoutPlugin, m as scrapeMetrics, n as buildSecurityPlugins, o as createOtelPlugin, p as initializeMetrics, r as checkRateLimit, s as initializeOtel, u as createArmorPlugins, v as initializeSecurityValkey, w as mergeCostMap, x as DEFAULT_ARMOR_CONFIG, y as DEFAULT_TIERS } from "../../index-C0qLquY0.js";
2
+ export { type ActorContext, type ArmorConfig, type CostMap, DEFAULT_ARMOR_CONFIG, DEFAULT_COST_MAP, DEFAULT_TIERS, type GatewaySecurityOptions, MemoryValkey, type OperationTimeoutConfig, type OtelConfig, type QueryComplexityConfig, type RateLimitConfig, type RateLimitResult, type SecurityValkeyClient, type Tier, type TierLimits, __resetMetricsForTest, __setSecurityValkeyForTest, buildSecurityPlugins, checkRateLimit, createArmorPlugins, createOperationTimeoutPlugin, createOtelPlugin, createQueryComplexityPlugin, createRateLimitPlugin, getMetrics, getSecurityValkey, initializeMetrics, initializeOtel, initializeSecurityValkey, mergeCostMap, resolveActor, resolveSecurityOptionsFromEnv, resolveTiersFromEnv, scrapeMetrics, shutdownOtel };
@@ -1,6 +1,4 @@
1
- export { DEFAULT_ARMOR_CONFIG, DEFAULT_COST_MAP, DEFAULT_TIERS, MemoryValkey, __resetMetricsForTest, __setSecurityValkeyForTest, buildSecurityPlugins, checkRateLimit, createArmorPlugins, createOperationTimeoutPlugin, createOtelPlugin, createQueryComplexityPlugin, createRateLimitPlugin, getMetrics, getSecurityValkey, initializeMetrics, initializeOtel, initializeSecurityValkey, mergeCostMap, resolveActor, resolveSecurityOptionsFromEnv, resolveTiersFromEnv, scrapeMetrics, shutdownOtel } from '../../chunk-726AR6Q7.js';
2
- import '../../chunk-FZRODKIN.js';
3
- import '../../chunk-RU266375.js';
4
- import '../../chunk-XE4OXN2W.js';
1
+ import { C as DEFAULT_COST_MAP, S as resolveTiersFromEnv, T as resolveActor, _ as getSecurityValkey, a as createQueryComplexityPlugin, b as resolveSecurityOptionsFromEnv, c as shutdownOtel, d as __resetMetricsForTest, f as getMetrics, g as __setSecurityValkeyForTest, h as MemoryValkey, i as createRateLimitPlugin, l as createOperationTimeoutPlugin, m as scrapeMetrics, n as buildSecurityPlugins, o as createOtelPlugin, p as initializeMetrics, r as checkRateLimit, s as initializeOtel, u as createArmorPlugins, v as initializeSecurityValkey, w as mergeCostMap, x as DEFAULT_TIERS, y as DEFAULT_ARMOR_CONFIG } from "../../security-DIG-95Ic.js";
2
+
3
+ export { DEFAULT_ARMOR_CONFIG, DEFAULT_COST_MAP, DEFAULT_TIERS, MemoryValkey, __resetMetricsForTest, __setSecurityValkeyForTest, buildSecurityPlugins, checkRateLimit, createArmorPlugins, createOperationTimeoutPlugin, createOtelPlugin, createQueryComplexityPlugin, createRateLimitPlugin, getMetrics, getSecurityValkey, initializeMetrics, initializeOtel, initializeSecurityValkey, mergeCostMap, resolveActor, resolveSecurityOptionsFromEnv, resolveTiersFromEnv, scrapeMetrics, shutdownOtel };
5
4
  //# sourceMappingURL=index.js.map
6
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"file":"index.js","sources":[],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-ad2WFvuA.js";
2
+ import { a as isGatewayClientError, i as createGatewayClientFromEnv, r as createGatewayClient, t as GatewayClient } from "./client-DcZ3iGES.js";
3
+ import { t as signServiceJwt } from "./service-jwt-Bu-WNA_-.js";
4
+ import { n as GatewayError, r as GatewayErrorType, t as CircuitState } from "./types-BYMYND1L.js";
5
+ import { t as security_exports } from "./security-DIG-95Ic.js";
6
+
7
+ // src/gateway/delegated-transport.ts
8
+ /** Header an internal gateway reads a delegated `app_as_user` bearer from. */
9
+ const DELEGATED_AUTHORIZATION_HEADER = "x-delegated-authorization";
10
+ const JWT_SEGMENT = /^[A-Za-z0-9_-]+$/;
11
+ function isCompactJwt(token) {
12
+ const segments = token.split(".");
13
+ return segments.length === 3 && segments.every((segment) => JWT_SEGMENT.test(segment));
14
+ }
15
+ /**
16
+ * Builds the request headers for a delegated internal-gateway call, for use as
17
+ * `GatewayClient.internalQuery({ query, headers })`.
18
+ *
19
+ * @throws Error when the token is not a compact JWS (so a malformed value can
20
+ * never be smuggled into a header) or the workspace id is blank.
21
+ */
22
+ function buildDelegatedGatewayHeaders(input) {
23
+ const token = input.appAsUserToken;
24
+ if (typeof token !== "string" || token.length === 0 || token.length > 8192 || !isCompactJwt(token)) throw new Error("Delegated gateway transport requires a compact app_as_user token");
25
+ const headers = { [DELEGATED_AUTHORIZATION_HEADER]: `Bearer ${token}` };
26
+ if (input.workspaceId !== void 0) {
27
+ const workspaceId = input.workspaceId.trim();
28
+ if (workspaceId.length === 0 || workspaceId !== input.workspaceId) throw new Error("Delegated gateway transport requires a non-blank workspace id");
29
+ headers["x-workspace-id"] = workspaceId;
30
+ }
31
+ return headers;
32
+ }
33
+
34
+ // src/gateway/index.ts
35
+ var gateway_exports = /* @__PURE__ */ __exportAll({
36
+ CircuitState: () => CircuitState,
37
+ DELEGATED_AUTHORIZATION_HEADER: () => DELEGATED_AUTHORIZATION_HEADER,
38
+ GatewayClient: () => GatewayClient,
39
+ GatewayError: () => GatewayError,
40
+ GatewayErrorType: () => GatewayErrorType,
41
+ Security: () => security_exports,
42
+ buildDelegatedGatewayHeaders: () => buildDelegatedGatewayHeaders,
43
+ createGatewayClient: () => createGatewayClient,
44
+ createGatewayClientFromEnv: () => createGatewayClientFromEnv,
45
+ isGatewayClientError: () => isGatewayClientError,
46
+ signServiceJwt: () => signServiceJwt
47
+ });
48
+
49
+ export { DELEGATED_AUTHORIZATION_HEADER as n, buildDelegatedGatewayHeaders as r, gateway_exports as t };
50
+ //# sourceMappingURL=gateway-DBFmxWks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-DBFmxWks.js","names":[],"sources":["../src/gateway/delegated-transport.ts","../src/gateway/index.ts"],"sourcesContent":["/**\n * Delegated gateway transport (BOFF-9962).\n *\n * A service that must call the platform as \"agent X acting for user Y\" does\n * not set actor or consent headers itself: internal gateways strip those.\n * Instead it obtains a short-lived `app_as_user` token from global-auth\n * (`issueAppAsUserTokenInternal`) and presents it on the internal gateway's\n * `x-delegated-authorization` header. The gateway verifies the signature,\n * checks revocation and the grant's workspace bounds, and only then forwards\n * the represented user as the actor together with `x-verified-delegation`.\n *\n * @module gateway/delegated-transport\n */\n\nimport type { GatewayRequestHeaders } from '../types/layer.js';\n\n/** Header an internal gateway reads a delegated `app_as_user` bearer from. */\nexport const DELEGATED_AUTHORIZATION_HEADER = 'x-delegated-authorization';\n\nexport interface DelegatedGatewayTransportInput {\n /** Signed `app_as_user` access token issued by global-auth. */\n appAsUserToken: string;\n /** Workspace the call targets; must be inside the grant's workspace bounds. */\n workspaceId?: string;\n}\n\nconst JWT_SEGMENT = /^[A-Za-z0-9_-]+$/;\n\nfunction isCompactJwt(token: string): boolean {\n const segments = token.split('.');\n return segments.length === 3 && segments.every((segment) => JWT_SEGMENT.test(segment));\n}\n\n/**\n * Builds the request headers for a delegated internal-gateway call, for use as\n * `GatewayClient.internalQuery({ query, headers })`.\n *\n * @throws Error when the token is not a compact JWS (so a malformed value can\n * never be smuggled into a header) or the workspace id is blank.\n */\nexport function buildDelegatedGatewayHeaders(input: DelegatedGatewayTransportInput): GatewayRequestHeaders {\n const token = input.appAsUserToken;\n if (typeof token !== 'string' || token.length === 0 || token.length > 8192 || !isCompactJwt(token)) {\n throw new Error('Delegated gateway transport requires a compact app_as_user token');\n }\n const headers: GatewayRequestHeaders = {\n [DELEGATED_AUTHORIZATION_HEADER]: `Bearer ${token}`,\n };\n if (input.workspaceId !== undefined) {\n const workspaceId = input.workspaceId.trim();\n if (workspaceId.length === 0 || workspaceId !== input.workspaceId) {\n throw new Error('Delegated gateway transport requires a non-blank workspace id');\n }\n headers['x-workspace-id'] = workspaceId;\n }\n return headers;\n}\n","/**\n * Gateway Module\n *\n * Provides unified gateway client for layer-aware M2M communication\n * with circuit breaker and retry logic.\n *\n * @module gateway\n * @category Gateway\n *\n * @example\n * ```typescript\n * import { GatewayClient, createGatewayClientFromEnv } from '@burdenoff/be-sdk/gateway';\n *\n * // Create from environment variables\n * const client = createGatewayClientFromEnv();\n *\n * // Or create manually\n * const client = new GatewayClient({\n * layer: 'wspace',\n * serviceName: 'wspace-tags-svc',\n * });\n *\n * // Internal call (same layer, uses int-gateway with bypass)\n * const internalResult = await client.internalQuery({\n * query: `query { getTag(id: \"123\") { id name } }`,\n * });\n *\n * // Cross-layer call (via public gateway)\n * const crossLayerResult = await client.crossLayerQuery({\n * query: `query { getCurrentUser { id email } }`,\n * });\n * ```\n */\n\n// Client exports\nexport { GatewayClient, createGatewayClient, createGatewayClientFromEnv, isGatewayClientError } from './client.js';\n\n// Service-JWT minting for cross-layer M2M auth. Exposed so non-GatewayClient\n// callers (e.g. bespoke graphql-request clients) can authenticate identically.\nexport { signServiceJwt } from './service-jwt.js';\n\n// Delegated internal-gateway transport (BOFF-9962): call as an agent acting\n// for a user by presenting a verified app_as_user token, never raw headers.\nexport {\n buildDelegatedGatewayHeaders,\n DELEGATED_AUTHORIZATION_HEADER,\n type DelegatedGatewayTransportInput,\n} from './delegated-transport.js';\n\n// Type exports\nexport {\n CircuitState,\n GatewayErrorType,\n GatewayError,\n type GatewayClientConfig,\n type GraphQLRequestOptions,\n type GraphQLResponse,\n type GraphQLError,\n type IGatewayClient,\n type ICircuitBreaker,\n type CircuitBreakerStats,\n type GatewayClientHealth,\n type RequestContext,\n} from './types.js';\n\n// Gateway-side security plugin stack (for public gateways).\n// Imported by consumers as `@burdenoff/be-sdk/gateway/security` — this\n// re-export lets `@burdenoff/be-sdk/gateway` also resolve the namespace.\nexport * as Security from './security/index.js';\n"],"mappings":";;;;;;;;AAiBA,MAAa,iCAAiC;AAS9C,MAAM,cAAc;AAEpB,SAAS,aAAa,OAAwB;CAC5C,MAAM,WAAW,MAAM,MAAM,GAAG;CAChC,OAAO,SAAS,WAAW,KAAK,SAAS,OAAO,YAAY,YAAY,KAAK,OAAO,CAAC;AACvF;;;;;;;;AASA,SAAgB,6BAA6B,OAA8D;CACzG,MAAM,QAAQ,MAAM;CACpB,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,KAAK,MAAM,SAAS,QAAQ,CAAC,aAAa,KAAK,GAC/F,MAAM,IAAI,MAAM,kEAAkE;CAEpF,MAAM,UAAiC,GACpC,iCAAiC,UAAU,QAC9C;CACA,IAAI,MAAM,gBAAgB,QAAW;EACnC,MAAM,cAAc,MAAM,YAAY,KAAK;EAC3C,IAAI,YAAY,WAAW,KAAK,gBAAgB,MAAM,aACpD,MAAM,IAAI,MAAM,+DAA+D;EAEjF,QAAQ,oBAAoB;CAC9B;CACA,OAAO;AACT"}
@@ -1,10 +1,3 @@
1
- import '../graphql-CMHMQjvd.js';
2
- import '../index-DE2w7E0d.js';
3
- export { e as EdgeDocument, b as EntityBulkOperationsConfig, f as EntityEventType, E as EntityGraphConfig, g as EntityVertex, d as GraphEvent, G as GraphEventEmitter, c as GraphEventType, h as GraphMiddlewareConfig, M as ModuleGraphConfig, P as ProductFacet, a as RelationshipGraphConfig, S as SearchFacets, i as SearchFilters, j as SearchResponse, k as SearchResult, T as TypeFacet, l as addGraphExtension } from '../prisma-extension-gYhYriA0.js';
4
- export { A as AUDIT_FIELDS, C as CreateEdgeOptions, a as CreateNodeOptions, D as DeferredGraphResult, b as DefineEntityConfigOptions, c as DefineGraphConfigOptions, d as DefineRelationshipConfigOptions, E as EntityDefinition, e as EntityEventContext, f as EntityEventData, g as EntityEventHook, h as EntityFetcher, j as EntityRbacConfig, k as ExtractedEntityData, l as ExtractedRelationshipData, F as FieldMapper, m as GenericEntityConfig, n as GenericEntityRbacConfig, o as GenericGraphConfig, p as GenericRelationshipConfig, q as GraphEdge, r as GraphEntityConfig, s as GraphEntityExport, t as GraphEventOptions, u as GraphEventPublishOptions, v as GraphEventsHelper, w as GraphEventsHelperConfig, x as GraphEventsPublisher, y as GraphExportResponse, z as GraphExportService, B as GraphExportServiceConfig, G as GraphModule, H as GraphNode, I as GraphRegistry, J as GraphRelationshipData, K as GraphRelationshipExport, L as GraphSchema, M as GraphValidationError, N as GraphValidationResult, O as InitializeGraphOptions, P as ModuleGraph, Q as ModuleGraphDefinition, R as PrismaGraphIntegration, S as PrismaGraphIntegrationOptions, T as QueryGraphOptions, U as RelationshipDefinition, V as RelationshipEventData, W as RelationshipExportData, X as RelationshipFetcher, Y as SOFT_DELETE_FIELDS, Z as STANDARD_FIELDS, _ as TENANT_FIELDS, $ as TraverseDirection, a0 as TraverseOptions, a1 as TraverseResult, a2 as ValidationErrorType, a3 as createEntityEvent, a4 as createGraphEventsHelper, a5 as createGraphExportService, a6 as createPrismaGraphIntegration, a7 as createRelationshipEvent, a8 as createRelationshipFromEntity, a9 as defineEntity, aa as defineGraphConfig, ab as defineModuleGraph, ac as defineRelationship, ad as extractEntityTitle, ae as extractMinimalFields, af as getCollectionForEntity, ag as getGraphEventsPublisher, ah as getGraphStats, ai as initializeGraph, aj as isGraphInitialized, ak as parseRelationship, al as shouldSyncEntity, am as shouldSyncRelationship, an as withDeferredGraphEvents } from '../index-B8KrxO4j.js';
5
- import 'graphql-request';
6
- import '../layer-Cv9vSwBx.js';
7
- import '../client-CCXpAZ2r.js';
8
- import '@prisma/adapter-pg';
9
- import 'pg';
10
- import '../graph-emitter-r5TylDBm.js';
1
+ import { _ as SearchResponse, a as EdgeDocument, c as EntityVertex, d as ModuleGraphConfig, f as ProductFacet, g as SearchFilters, h as SearchFacets, i as addGraphExtension, l as GraphEvent, m as RelationshipGraphConfig, n as GraphEventEmitter, o as EntityBulkOperationsConfig, r as GraphMiddlewareConfig, s as EntityGraphConfig, t as EntityEventType, u as GraphEventType, v as SearchResult, y as TypeFacet } from "../prisma-extension-Cfl09swM.js";
2
+ import { $ as createGraphEventsHelper, A as GraphSchema, B as GraphExportService, C as defineGraphConfig, Ct as shouldSyncRelationship, D as EntityEventHook, E as EntityEventContext, F as RelationshipExportData, G as createRelationshipFromEntity, H as GraphRelationshipExport, I as defineModuleGraph, J as GraphEventPublishOptions, K as EntityEventData, L as EntityFetcher, M as ModuleGraphDefinition, N as RelationshipDefinition, O as EntityRbacConfig, P as RelationshipEventData, Q as GraphRelationshipData, R as GraphEntityExport, S as defineEntity, St as shouldSyncEntity, T as EntityDefinition, U as RelationshipFetcher, V as GraphExportServiceConfig, W as createGraphExportService, X as GraphEventsHelperConfig, Y as GraphEventsHelper, Z as GraphEventsPublisher, _ as DefineGraphConfigOptions, _t as createRelationshipEvent, a as GraphNode, at as createPrismaGraphIntegration, b as STANDARD_FIELDS, bt as getCollectionForEntity, c as TraverseOptions, ct as ExtractedRelationshipData, d as InitializeGraphOptions, dt as GenericGraphConfig, et as getGraphEventsPublisher, f as getGraphStats, ft as GenericRelationshipConfig, g as DefineEntityConfigOptions, gt as createEntityEvent, h as AUDIT_FIELDS, ht as ValidationErrorType, i as GraphModule, it as PrismaGraphIntegrationOptions, j as ModuleGraph, k as GraphEventOptions, l as TraverseResult, lt as FieldMapper, m as isGraphInitialized, mt as GraphValidationResult, n as CreateNodeOptions, nt as withDeferredGraphEvents, o as QueryGraphOptions, ot as EntityRbacConfig$1, p as initializeGraph, pt as GraphValidationError, q as GraphEntityConfig, r as GraphEdge, rt as PrismaGraphIntegration, s as TraverseDirection, st as ExtractedEntityData, t as CreateEdgeOptions, tt as DeferredGraphResult, ut as GenericEntityConfig, v as DefineRelationshipConfigOptions, vt as extractEntityTitle, w as defineRelationship, wt as GraphRegistry, x as TENANT_FIELDS, xt as parseRelationship, y as SOFT_DELETE_FIELDS, yt as extractMinimalFields, z as GraphExportResponse } from "../index-bZKZUvBu.js";
3
+ export { AUDIT_FIELDS, CreateEdgeOptions, CreateNodeOptions, type DeferredGraphResult, type DefineEntityConfigOptions, type DefineGraphConfigOptions, type DefineRelationshipConfigOptions, type EdgeDocument, type EntityBulkOperationsConfig, type EntityDefinition, type EntityEventContext, type EntityEventData, type EntityEventHook, type EntityEventType, type EntityFetcher, type EntityGraphConfig, type EntityRbacConfig, type EntityVertex, type ExtractedEntityData, type ExtractedRelationshipData, type FieldMapper, type GenericEntityConfig, type EntityRbacConfig$1 as GenericEntityRbacConfig, type GenericGraphConfig, type GenericRelationshipConfig, GraphEdge, type GraphEntityConfig, type GraphEntityExport, type GraphEvent, type GraphEventEmitter, type GraphEventOptions, type GraphEventPublishOptions, type GraphEventType, type GraphEventsHelper, type GraphEventsHelperConfig, GraphEventsPublisher, type GraphExportResponse, GraphExportService, type GraphExportServiceConfig, type GraphMiddlewareConfig, GraphModule, GraphNode, GraphRegistry, type GraphRelationshipData, type GraphRelationshipExport, type GraphSchema, type GraphValidationError, type GraphValidationResult, type InitializeGraphOptions, type ModuleGraph, type ModuleGraphConfig, type ModuleGraphDefinition, type PrismaGraphIntegration, type PrismaGraphIntegrationOptions, type ProductFacet, QueryGraphOptions, type RelationshipDefinition, type RelationshipEventData, type RelationshipExportData, type RelationshipFetcher, type RelationshipGraphConfig, SOFT_DELETE_FIELDS, STANDARD_FIELDS, type SearchFacets, type SearchFilters, type SearchResponse, type SearchResult, TENANT_FIELDS, TraverseDirection, TraverseOptions, TraverseResult, type TypeFacet, type ValidationErrorType, addGraphExtension, createEntityEvent, createGraphEventsHelper, createGraphExportService, createPrismaGraphIntegration, createRelationshipEvent, createRelationshipFromEntity, defineEntity, defineGraphConfig, defineModuleGraph, defineRelationship, extractEntityTitle, extractMinimalFields, getCollectionForEntity, getGraphEventsPublisher, getGraphStats, initializeGraph, isGraphInitialized, parseRelationship, shouldSyncEntity, shouldSyncRelationship, withDeferredGraphEvents };
@@ -1,14 +1,5 @@
1
- export { AUDIT_FIELDS, GraphEventsPublisher, GraphExportService, GraphModule, SOFT_DELETE_FIELDS, STANDARD_FIELDS, TENANT_FIELDS, createGraphEventsHelper, createGraphExportService, createPrismaGraphIntegration, createRelationshipFromEntity, defineEntity, defineGraphConfig, defineModuleGraph, defineRelationship, getGraphEventsPublisher, getGraphStats, initializeGraph, isGraphInitialized } from '../chunk-OQDSAOG3.js';
2
- export { GraphRegistry, addGraphExtension, createEntityEvent, createRelationshipEvent, extractEntityTitle, extractMinimalFields, getCollectionForEntity, parseRelationship, shouldSyncEntity, shouldSyncRelationship, withDeferredGraphEvents } from '../chunk-PN6GIF3R.js';
3
- import '../chunk-JS52ZHTK.js';
4
- import '../chunk-Z77BTSOK.js';
5
- import '../chunk-HTLEGD3Q.js';
6
- import '../chunk-KS2HQCJR.js';
7
- import '../chunk-6XEXJATV.js';
8
- import '../chunk-KO2ZXZ7W.js';
9
- import '../chunk-I3KOWRT3.js';
10
- import '../chunk-5CAFHK2Z.js';
11
- import '../chunk-RU266375.js';
12
- import '../chunk-XE4OXN2W.js';
1
+ import { _ as shouldSyncEntity, d as createEntityEvent, f as createRelationshipEvent, g as parseRelationship, h as getCollectionForEntity, m as extractMinimalFields, n as withDeferredGraphEvents, p as extractEntityTitle, t as addGraphExtension, v as shouldSyncRelationship, y as GraphRegistry } from "../middleware-CUxJVUpD.js";
2
+ import { _ as GraphEventsPublisher, a as isGraphInitialized, b as createPrismaGraphIntegration, c as STANDARD_FIELDS, d as defineGraphConfig, f as defineRelationship, g as createRelationshipFromEntity, h as createGraphExportService, i as initializeGraph, l as TENANT_FIELDS, m as GraphExportService, o as AUDIT_FIELDS, p as defineModuleGraph, r as getGraphStats, s as SOFT_DELETE_FIELDS, t as GraphModule, u as defineEntity, v as createGraphEventsHelper, y as getGraphEventsPublisher } from "../graph-DDYgIryR.js";
3
+
4
+ export { AUDIT_FIELDS, GraphEventsPublisher, GraphExportService, GraphModule, GraphRegistry, SOFT_DELETE_FIELDS, STANDARD_FIELDS, TENANT_FIELDS, addGraphExtension, createEntityEvent, createGraphEventsHelper, createGraphExportService, createPrismaGraphIntegration, createRelationshipEvent, createRelationshipFromEntity, defineEntity, defineGraphConfig, defineModuleGraph, defineRelationship, extractEntityTitle, extractMinimalFields, getCollectionForEntity, getGraphEventsPublisher, getGraphStats, initializeGraph, isGraphInitialized, parseRelationship, shouldSyncEntity, shouldSyncRelationship, withDeferredGraphEvents };
13
5
  //# sourceMappingURL=index.js.map
14
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"file":"index.js","sources":[],"names":[],"mappings":""}