@burdenoff/be-sdk 2026.1110.2 → 2026.1110.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (497) hide show
  1. package/configs/eslint/index.js +1 -1
  2. package/configs/tsconfig/tsconfig.json +1 -1
  3. package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
  4. package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
  5. package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
  6. package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
  7. package/dist/activity/index.d.ts +165 -0
  8. package/dist/activity/index.js +389 -0
  9. package/dist/activity/index.js.map +1 -0
  10. package/dist/ai-credits/index.d.ts +2 -3
  11. package/dist/ai-credits/index.js +3 -4
  12. package/dist/ai-credits/index.js.map +1 -1
  13. package/dist/ai-credits-xxfwGpHS.js +546 -0
  14. package/dist/ai-credits-xxfwGpHS.js.map +1 -0
  15. package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
  16. package/dist/auth/index.d.ts +2 -77
  17. package/dist/auth/index.js +3 -7
  18. package/dist/auth/index.js.map +1 -1
  19. package/dist/auth-C5ctwSLp.js +228 -0
  20. package/dist/auth-C5ctwSLp.js.map +1 -0
  21. package/dist/bootstrap/index.d.ts +74 -0
  22. package/dist/bootstrap/index.js +282 -0
  23. package/dist/bootstrap/index.js.map +1 -0
  24. package/dist/cache/index.d.ts +2 -3
  25. package/dist/cache/index.js +3 -7
  26. package/dist/cache/index.js.map +1 -1
  27. package/dist/cache-CU0uLwcS.js +1837 -0
  28. package/dist/cache-CU0uLwcS.js.map +1 -0
  29. package/dist/captcha/index.d.ts +2 -1
  30. package/dist/captcha/index.js +3 -3
  31. package/dist/captcha/index.js.map +1 -1
  32. package/dist/captcha-BT7yh1YS.js +77 -0
  33. package/dist/captcha-BT7yh1YS.js.map +1 -0
  34. package/dist/client/internal-client.d.ts +4 -7
  35. package/dist/client/internal-client.js +172 -4
  36. package/dist/client/internal-client.js.map +1 -1
  37. package/dist/client-BgAEvDC2.d.ts +86 -0
  38. package/dist/client-sAJTrb4i.js +565 -0
  39. package/dist/client-sAJTrb4i.js.map +1 -0
  40. package/dist/collector-endpoint-iyQYeI50.js +50 -0
  41. package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
  42. package/dist/context/index.d.ts +35 -0
  43. package/dist/context/index.js +283 -0
  44. package/dist/context/index.js.map +1 -0
  45. package/dist/crypto/index.d.ts +2 -1
  46. package/dist/crypto/index.js +3 -3
  47. package/dist/crypto/index.js.map +1 -1
  48. package/dist/crypto-DO9fM0FO.js +145 -0
  49. package/dist/crypto-DO9fM0FO.js.map +1 -0
  50. package/dist/database/index.d.ts +104 -108
  51. package/dist/database/index.js +468 -6
  52. package/dist/database/index.js.map +1 -1
  53. package/dist/dataloader/index.d.ts +2 -1
  54. package/dist/dataloader/index.js +3 -3
  55. package/dist/dataloader/index.js.map +1 -1
  56. package/dist/dataloader-DwpT3YoS.js +294 -0
  57. package/dist/dataloader-DwpT3YoS.js.map +1 -0
  58. package/dist/deployed-environment-p_Tdl3sT.js +38 -0
  59. package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
  60. package/dist/dist-BGKdXVy3.js +1718 -0
  61. package/dist/dist-BGKdXVy3.js.map +1 -0
  62. package/dist/env-DdaoGjIt.js +74 -0
  63. package/dist/env-DdaoGjIt.js.map +1 -0
  64. package/dist/event-queue/index.d.ts +2 -7
  65. package/dist/event-queue/index.js +7 -9
  66. package/dist/event-queue/index.js.map +1 -1
  67. package/dist/event-queue-Cw-YJPY_.js +1384 -0
  68. package/dist/event-queue-Cw-YJPY_.js.map +1 -0
  69. package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
  70. package/dist/explicit-activity-scope-DikJ7NAE.js +57 -0
  71. package/dist/explicit-activity-scope-DikJ7NAE.js.map +1 -0
  72. package/dist/export/index.d.ts +2 -2
  73. package/dist/export/index.js +3 -14
  74. package/dist/export/index.js.map +1 -1
  75. package/dist/export-DJXE3Osa.js +642 -0
  76. package/dist/export-DJXE3Osa.js.map +1 -0
  77. package/dist/feature-flags/index.d.ts +2 -10
  78. package/dist/feature-flags/index.js +3 -6
  79. package/dist/feature-flags/index.js.map +1 -1
  80. package/dist/feature-flags-CP1KRgwD.js +422 -0
  81. package/dist/feature-flags-CP1KRgwD.js.map +1 -0
  82. package/dist/files/index.d.ts +2 -3
  83. package/dist/files/index.js +3 -4
  84. package/dist/files/index.js.map +1 -1
  85. package/dist/files-h5U-D2AF.js +830 -0
  86. package/dist/files-h5U-D2AF.js.map +1 -0
  87. package/dist/gateway/index.d.ts +4 -6
  88. package/dist/gateway/index.js +7 -13
  89. package/dist/gateway/index.js.map +1 -1
  90. package/dist/gateway/security/index.d.ts +2 -2
  91. package/dist/gateway/security/index.js +3 -5
  92. package/dist/gateway/security/index.js.map +1 -1
  93. package/dist/gateway-ByVo-n37.js +50 -0
  94. package/dist/gateway-ByVo-n37.js.map +1 -0
  95. package/dist/graph/index.d.ts +3 -10
  96. package/dist/graph/index.js +4 -13
  97. package/dist/graph/index.js.map +1 -1
  98. package/dist/graph-CR7u4lpl.js +2152 -0
  99. package/dist/graph-CR7u4lpl.js.map +1 -0
  100. package/dist/graph-emitter-CdOXP7Tn.js +621 -0
  101. package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
  102. package/dist/graphql/index.d.ts +3 -2
  103. package/dist/graphql/index.js +4 -6
  104. package/dist/graphql/index.js.map +1 -1
  105. package/dist/graphql/services/index.d.ts +2 -24
  106. package/dist/graphql/services/index.js +3 -4
  107. package/dist/graphql/services/index.js.map +1 -1
  108. package/dist/graphql-CUDyhibV.d.ts +21 -0
  109. package/dist/graphql-DHAHHcww.js +161 -0
  110. package/dist/graphql-DHAHHcww.js.map +1 -0
  111. package/dist/i18n/index.d.ts +3 -3
  112. package/dist/i18n/index.js +3 -4
  113. package/dist/i18n/index.js.map +1 -1
  114. package/dist/i18n-BBMYFd0P.js +860 -0
  115. package/dist/i18n-BBMYFd0P.js.map +1 -0
  116. package/dist/import-optional-peer-B82VYxeX.js +18 -0
  117. package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
  118. package/dist/index-3KOZ1zN9.d.ts +233 -0
  119. package/dist/index-ADmsX0BI.d.ts +646 -0
  120. package/dist/index-B2LCaK0R.d.ts +500 -0
  121. package/dist/index-BBqooJ52.d.ts +45 -0
  122. package/dist/index-BGzMYJsm.d.ts +209 -0
  123. package/dist/index-BMIMnp6T.d.ts +8 -0
  124. package/dist/index-BVOL7458.d.ts +10 -0
  125. package/dist/index-BcqQs-Uq.d.ts +69 -0
  126. package/dist/index-BeVtqGO-.d.ts +208 -0
  127. package/dist/index-BiTzGUZP.d.ts +114 -0
  128. package/dist/index-C0qLquY0.d.ts +150 -0
  129. package/dist/index-C5uEKchX.d.ts +60 -0
  130. package/dist/index-CDOqxSIi.d.ts +37 -0
  131. package/dist/index-CG6wj66Y.d.ts +148 -0
  132. package/dist/index-CHwMhK6v.d.ts +63 -0
  133. package/dist/index-CIgoeobA.d.ts +145 -0
  134. package/dist/index-CPQDMSFS.d.ts +103 -0
  135. package/dist/index-CSRcgkVi.d.ts +23 -0
  136. package/dist/index-CTTwo9av.d.ts +102 -0
  137. package/dist/index-CVCyKzhB.d.ts +207 -0
  138. package/dist/index-C_GXXF32.d.ts +704 -0
  139. package/dist/index-CaM9JUcc.d.ts +144 -0
  140. package/dist/index-CliOgq6L.d.ts +203 -0
  141. package/dist/index-Cot73bdh.d.ts +63 -0
  142. package/dist/index-DGgh9DWn.d.ts +59 -0
  143. package/dist/index-DY3dNhMN.d.ts +420 -0
  144. package/dist/index-DqbGqfAy.d.ts +127 -0
  145. package/dist/index-Dt1HJPTX.d.ts +12 -0
  146. package/dist/index-DtI6aBtB.d.ts +22 -0
  147. package/dist/index-FKohsiex.d.ts +38 -0
  148. package/dist/index-FRRaa6h2.d.ts +999 -0
  149. package/dist/index-FbXPfen7.d.ts +132 -0
  150. package/dist/index-MArCb8Aq.d.ts +306 -0
  151. package/dist/index-U_tu3zUl.d.ts +303 -0
  152. package/dist/index-YOShAwkq.d.ts +45 -0
  153. package/dist/index-cmR9k9ga.d.ts +26 -0
  154. package/dist/index-yBSjMY32.d.ts +24 -0
  155. package/dist/index-zd_NPGJo.d.ts +206 -0
  156. package/dist/index.d.ts +106 -609
  157. package/dist/index.js +769 -2590
  158. package/dist/index.js.map +1 -1
  159. package/dist/init/index.d.ts +2 -2
  160. package/dist/init/index.js +3 -16
  161. package/dist/init/index.js.map +1 -1
  162. package/dist/init-CQPFmOOe.js +325 -0
  163. package/dist/init-CQPFmOOe.js.map +1 -0
  164. package/dist/instrumentation/index.d.ts +3 -4
  165. package/dist/instrumentation/index.js +5 -5
  166. package/dist/instrumentation/index.js.map +1 -1
  167. package/dist/instrumentation-xkkmDgJ0.js +1678 -0
  168. package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
  169. package/dist/lake/index.d.ts +50 -54
  170. package/dist/lake/index.js +169 -193
  171. package/dist/lake/index.js.map +1 -1
  172. package/dist/layer/index.d.ts +3 -2
  173. package/dist/layer/index.js +4 -5
  174. package/dist/layer/index.js.map +1 -1
  175. package/dist/layer-BZBZZWeV.d.ts +69 -0
  176. package/dist/layer-Bcix-WCl.js +105 -0
  177. package/dist/layer-Bcix-WCl.js.map +1 -0
  178. package/dist/layer-CEKy6cm8.js +252 -0
  179. package/dist/layer-CEKy6cm8.js.map +1 -0
  180. package/dist/lifecycle/index.d.ts +2 -1
  181. package/dist/lifecycle/index.js +3 -4
  182. package/dist/lifecycle/index.js.map +1 -1
  183. package/dist/lifecycle-DeoLSX0U.js +76 -0
  184. package/dist/lifecycle-DeoLSX0U.js.map +1 -0
  185. package/dist/logger/index.d.ts +2 -3
  186. package/dist/logger/index.js +3 -3
  187. package/dist/logger/index.js.map +1 -1
  188. package/dist/logger-B6rCpb7D.js +290 -0
  189. package/dist/logger-B6rCpb7D.js.map +1 -0
  190. package/dist/metrics/index.d.ts +13 -14
  191. package/dist/metrics/index.js +3 -4
  192. package/dist/metrics/index.js.map +1 -1
  193. package/dist/metrics-BrLwNUrb.js +52 -0
  194. package/dist/metrics-BrLwNUrb.js.map +1 -0
  195. package/dist/metrics-collector-C2eShrlW.js +922 -0
  196. package/dist/metrics-collector-C2eShrlW.js.map +1 -0
  197. package/dist/middleware/index.d.ts +3 -3
  198. package/dist/middleware/index.js +3 -4
  199. package/dist/middleware/index.js.map +1 -1
  200. package/dist/middleware-CUxJVUpD.js +1243 -0
  201. package/dist/middleware-CUxJVUpD.js.map +1 -0
  202. package/dist/middleware-Cq0zFMGp.js +253 -0
  203. package/dist/middleware-Cq0zFMGp.js.map +1 -0
  204. package/dist/notifications/index.d.ts +2 -5
  205. package/dist/notifications/index.js +3 -6
  206. package/dist/notifications/index.js.map +1 -1
  207. package/dist/notifications-DY_i37WN.js +869 -0
  208. package/dist/notifications-DY_i37WN.js.map +1 -0
  209. package/dist/observability/index.d.ts +2 -3
  210. package/dist/observability/index.js +3 -4
  211. package/dist/observability/index.js.map +1 -1
  212. package/dist/observability-DBDXipTU.js +272 -0
  213. package/dist/observability-DBDXipTU.js.map +1 -0
  214. package/dist/payments/index.d.ts +144 -0
  215. package/dist/payments/index.js +404 -0
  216. package/dist/payments/index.js.map +1 -0
  217. package/dist/platform/index.d.ts +2 -1
  218. package/dist/platform/index.js +3 -5
  219. package/dist/platform/index.js.map +1 -1
  220. package/dist/platform-DZwczW7v.js +1510 -0
  221. package/dist/platform-DZwczW7v.js.map +1 -0
  222. package/dist/prisma/generator/index.d.ts +1 -1
  223. package/dist/prisma/generator/index.js +97 -84
  224. package/dist/prisma/generator/index.js.map +1 -1
  225. package/dist/prisma/index.d.ts +4 -7
  226. package/dist/prisma/index.js +5 -12
  227. package/dist/prisma/index.js.map +1 -1
  228. package/dist/prisma-BzOOdt79.js +863 -0
  229. package/dist/prisma-BzOOdt79.js.map +1 -0
  230. package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
  231. package/dist/product-alias/index.d.ts +2 -1
  232. package/dist/product-alias/index.js +3 -3
  233. package/dist/product-alias/index.js.map +1 -1
  234. package/dist/product-alias-BPqtskMq.js +273 -0
  235. package/dist/product-alias-BPqtskMq.js.map +1 -0
  236. package/dist/rate-limit-CBrK_U5H.js +142 -0
  237. package/dist/rate-limit-CBrK_U5H.js.map +1 -0
  238. package/dist/rbac/index.d.ts +2 -122
  239. package/dist/rbac/index.js +3 -6
  240. package/dist/rbac/index.js.map +1 -1
  241. package/dist/rbac-Dvz0YzEt.js +1486 -0
  242. package/dist/rbac-Dvz0YzEt.js.map +1 -0
  243. package/dist/resource-caps/index.d.ts +66 -72
  244. package/dist/resource-caps/index.js +430 -5
  245. package/dist/resource-caps/index.js.map +1 -1
  246. package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
  247. package/dist/sdk-Dju9o-sq.js +124 -0
  248. package/dist/sdk-Dju9o-sq.js.map +1 -0
  249. package/dist/search/index.d.ts +112 -0
  250. package/dist/search/index.js +266 -0
  251. package/dist/search/index.js.map +1 -0
  252. package/dist/security/index.d.ts +2 -0
  253. package/dist/security/index.js +4 -0
  254. package/dist/security/index.js.map +1 -0
  255. package/dist/security/rate-limit/index.d.ts +2 -0
  256. package/dist/security/rate-limit/index.js +4 -0
  257. package/dist/security/rate-limit/index.js.map +1 -0
  258. package/dist/security-DIG-95Ic.js +1647 -0
  259. package/dist/security-DIG-95Ic.js.map +1 -0
  260. package/dist/server/index.d.ts +7 -164
  261. package/dist/server/index.js +2001 -1507
  262. package/dist/server/index.js.map +1 -1
  263. package/dist/service-jwt-Bu-WNA_-.js +80 -0
  264. package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
  265. package/dist/services-BWzfz7vG.js +102 -0
  266. package/dist/services-BWzfz7vG.js.map +1 -0
  267. package/dist/sharding/index.d.ts +41 -44
  268. package/dist/sharding/index.js +156 -137
  269. package/dist/sharding/index.js.map +1 -1
  270. package/dist/sharing/index.d.ts +2 -1
  271. package/dist/sharing/index.js +3 -4
  272. package/dist/sharing/index.js.map +1 -1
  273. package/dist/sharing-CflDsSJ-.js +911 -0
  274. package/dist/sharing-CflDsSJ-.js.map +1 -0
  275. package/dist/stub-BUnfMiAS.js +577 -0
  276. package/dist/stub-BUnfMiAS.js.map +1 -0
  277. package/dist/tags/index.d.ts +2 -3
  278. package/dist/tags/index.js +3 -4
  279. package/dist/tags/index.js.map +1 -1
  280. package/dist/tags-CbijgoqR.js +868 -0
  281. package/dist/{chunk-PBZFAAOM.js.map → tags-CbijgoqR.js.map} +1 -1
  282. package/dist/telemetry/index.d.ts +64 -76
  283. package/dist/telemetry/index.js +369 -201
  284. package/dist/telemetry/index.js.map +1 -1
  285. package/dist/temporal/index.d.ts +2 -148
  286. package/dist/temporal/index.js +3 -5
  287. package/dist/temporal/index.js.map +1 -1
  288. package/dist/temporal-B534uYK8.js +706 -0
  289. package/dist/temporal-B534uYK8.js.map +1 -0
  290. package/dist/tracker/index.d.ts +5 -11
  291. package/dist/tracker/index.js +7 -20
  292. package/dist/tracker/index.js.map +1 -1
  293. package/dist/tracker-PQztSlhJ.js +458 -0
  294. package/dist/tracker-PQztSlhJ.js.map +1 -0
  295. package/dist/translation/index.d.ts +120 -0
  296. package/dist/translation/index.js +573 -0
  297. package/dist/translation/index.js.map +1 -0
  298. package/dist/types/index.d.ts +3 -0
  299. package/dist/types/index.js +90 -0
  300. package/dist/types/index.js.map +1 -0
  301. package/dist/types-BYMYND1L.js +44 -0
  302. package/dist/types-BYMYND1L.js.map +1 -0
  303. package/dist/types-C6EKaS3V.d.ts +106 -0
  304. package/dist/types-CWybW61E.d.ts +323 -0
  305. package/dist/types-C_yfu3XK.d.ts +34 -0
  306. package/dist/types-DgaQqvxo.d.ts +70 -0
  307. package/dist/usage/index.d.ts +2 -213
  308. package/dist/usage/index.js +3 -15
  309. package/dist/usage/index.js.map +1 -1
  310. package/dist/usage-BRqVP3CJ.js +682 -0
  311. package/dist/usage-BRqVP3CJ.js.map +1 -0
  312. package/dist/utils/index.d.ts +2 -1
  313. package/dist/utils/index.js +3 -3
  314. package/dist/utils/index.js.map +1 -1
  315. package/dist/utils-DL85Tnbn.js +500 -0
  316. package/dist/utils-DL85Tnbn.js.map +1 -0
  317. package/dist/validation/index.d.ts +2 -2
  318. package/dist/validation/index.js +3 -3
  319. package/dist/validation/index.js.map +1 -1
  320. package/dist/validation-CPUITdMk.js +762 -0
  321. package/dist/validation-CPUITdMk.js.map +1 -0
  322. package/dist/workspace-extension-COrC0dYi.js +979 -0
  323. package/dist/workspace-extension-COrC0dYi.js.map +1 -0
  324. package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
  325. package/package.json +7 -10
  326. package/dist/EventQueueFactory-GXC3A7DH.js +0 -8
  327. package/dist/EventQueueFactory-GXC3A7DH.js.map +0 -1
  328. package/dist/chunk-4XIBXZ6J.js +0 -276
  329. package/dist/chunk-4XIBXZ6J.js.map +0 -1
  330. package/dist/chunk-554Z4C2K.js +0 -1006
  331. package/dist/chunk-554Z4C2K.js.map +0 -1
  332. package/dist/chunk-5CAFHK2Z.js +0 -107
  333. package/dist/chunk-5CAFHK2Z.js.map +0 -1
  334. package/dist/chunk-63ZXJ42X.js +0 -451
  335. package/dist/chunk-63ZXJ42X.js.map +0 -1
  336. package/dist/chunk-6XEXJATV.js +0 -304
  337. package/dist/chunk-6XEXJATV.js.map +0 -1
  338. package/dist/chunk-726AR6Q7.js +0 -1532
  339. package/dist/chunk-726AR6Q7.js.map +0 -1
  340. package/dist/chunk-A5F6Z5UE.js +0 -21
  341. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  342. package/dist/chunk-A6DE32ZS.js +0 -1507
  343. package/dist/chunk-A6DE32ZS.js.map +0 -1
  344. package/dist/chunk-AXJDGQPE.js +0 -690
  345. package/dist/chunk-AXJDGQPE.js.map +0 -1
  346. package/dist/chunk-BJQOGOVW.js +0 -602
  347. package/dist/chunk-BJQOGOVW.js.map +0 -1
  348. package/dist/chunk-CFXWH2IS.js +0 -52
  349. package/dist/chunk-CFXWH2IS.js.map +0 -1
  350. package/dist/chunk-DRWH5XCJ.js +0 -876
  351. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  352. package/dist/chunk-E4QNLVY4.js +0 -909
  353. package/dist/chunk-E4QNLVY4.js.map +0 -1
  354. package/dist/chunk-EBDHIL7V.js +0 -774
  355. package/dist/chunk-EBDHIL7V.js.map +0 -1
  356. package/dist/chunk-ELU7VL3E.js +0 -245
  357. package/dist/chunk-ELU7VL3E.js.map +0 -1
  358. package/dist/chunk-FZRODKIN.js +0 -31
  359. package/dist/chunk-FZRODKIN.js.map +0 -1
  360. package/dist/chunk-GCIB76AJ.js +0 -882
  361. package/dist/chunk-GCIB76AJ.js.map +0 -1
  362. package/dist/chunk-HC6MPUIH.js +0 -1571
  363. package/dist/chunk-HC6MPUIH.js.map +0 -1
  364. package/dist/chunk-HNMHPSAM.js +0 -272
  365. package/dist/chunk-HNMHPSAM.js.map +0 -1
  366. package/dist/chunk-HTLEGD3Q.js +0 -1480
  367. package/dist/chunk-HTLEGD3Q.js.map +0 -1
  368. package/dist/chunk-I3KOWRT3.js +0 -89
  369. package/dist/chunk-I3KOWRT3.js.map +0 -1
  370. package/dist/chunk-ID3WR4JS.js +0 -509
  371. package/dist/chunk-ID3WR4JS.js.map +0 -1
  372. package/dist/chunk-JS52ZHTK.js +0 -1346
  373. package/dist/chunk-JS52ZHTK.js.map +0 -1
  374. package/dist/chunk-JVMAQOA3.js +0 -521
  375. package/dist/chunk-JVMAQOA3.js.map +0 -1
  376. package/dist/chunk-KH4TRQCO.js +0 -1063
  377. package/dist/chunk-KH4TRQCO.js.map +0 -1
  378. package/dist/chunk-KJOSPVB2.js +0 -57
  379. package/dist/chunk-KJOSPVB2.js.map +0 -1
  380. package/dist/chunk-KO2ZXZ7W.js +0 -61
  381. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  382. package/dist/chunk-KS2HQCJR.js +0 -56
  383. package/dist/chunk-KS2HQCJR.js.map +0 -1
  384. package/dist/chunk-LA5KPWZ2.js +0 -413
  385. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  386. package/dist/chunk-MESLAC5W.js +0 -574
  387. package/dist/chunk-MESLAC5W.js.map +0 -1
  388. package/dist/chunk-MWPYA2HD.js +0 -94
  389. package/dist/chunk-MWPYA2HD.js.map +0 -1
  390. package/dist/chunk-NUB5GQTU.js +0 -270
  391. package/dist/chunk-NUB5GQTU.js.map +0 -1
  392. package/dist/chunk-OBBCR6WY.js +0 -277
  393. package/dist/chunk-OBBCR6WY.js.map +0 -1
  394. package/dist/chunk-OQDSAOG3.js +0 -1908
  395. package/dist/chunk-OQDSAOG3.js.map +0 -1
  396. package/dist/chunk-OXNCBE7P.js +0 -971
  397. package/dist/chunk-OXNCBE7P.js.map +0 -1
  398. package/dist/chunk-PBZFAAOM.js +0 -941
  399. package/dist/chunk-PN6GIF3R.js +0 -1185
  400. package/dist/chunk-PN6GIF3R.js.map +0 -1
  401. package/dist/chunk-PYD44IHJ.js +0 -728
  402. package/dist/chunk-PYD44IHJ.js.map +0 -1
  403. package/dist/chunk-QVPIACWD.js +0 -679
  404. package/dist/chunk-QVPIACWD.js.map +0 -1
  405. package/dist/chunk-QWNNFE4P.js +0 -41
  406. package/dist/chunk-QWNNFE4P.js.map +0 -1
  407. package/dist/chunk-RU266375.js +0 -327
  408. package/dist/chunk-RU266375.js.map +0 -1
  409. package/dist/chunk-RYTSVGGA.js +0 -1624
  410. package/dist/chunk-RYTSVGGA.js.map +0 -1
  411. package/dist/chunk-RZOFS2BQ.js +0 -225
  412. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  413. package/dist/chunk-SBS4S2PJ.js +0 -100
  414. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  415. package/dist/chunk-SPRG6G6G.js +0 -530
  416. package/dist/chunk-SPRG6G6G.js.map +0 -1
  417. package/dist/chunk-STWFX5E2.js +0 -233
  418. package/dist/chunk-STWFX5E2.js.map +0 -1
  419. package/dist/chunk-UNASM5VJ.js +0 -419
  420. package/dist/chunk-UNASM5VJ.js.map +0 -1
  421. package/dist/chunk-VAT66FJA.js +0 -245
  422. package/dist/chunk-VAT66FJA.js.map +0 -1
  423. package/dist/chunk-VFCMR5GX.js +0 -49
  424. package/dist/chunk-VFCMR5GX.js.map +0 -1
  425. package/dist/chunk-VGAHZKNJ.js +0 -66
  426. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  427. package/dist/chunk-VTJTAAXC.js +0 -627
  428. package/dist/chunk-VTJTAAXC.js.map +0 -1
  429. package/dist/chunk-VXVLKRU6.js +0 -758
  430. package/dist/chunk-VXVLKRU6.js.map +0 -1
  431. package/dist/chunk-WWUU5ETI.js +0 -163
  432. package/dist/chunk-WWUU5ETI.js.map +0 -1
  433. package/dist/chunk-XE4OXN2W.js +0 -10
  434. package/dist/chunk-XE4OXN2W.js.map +0 -1
  435. package/dist/chunk-XOJORS75.js +0 -1853
  436. package/dist/chunk-XOJORS75.js.map +0 -1
  437. package/dist/chunk-YMZEUTD2.js +0 -110
  438. package/dist/chunk-YMZEUTD2.js.map +0 -1
  439. package/dist/chunk-Z77BTSOK.js +0 -617
  440. package/dist/chunk-Z77BTSOK.js.map +0 -1
  441. package/dist/chunk-ZZK3WEDI.js +0 -181
  442. package/dist/chunk-ZZK3WEDI.js.map +0 -1
  443. package/dist/client-CCXpAZ2r.d.ts +0 -89
  444. package/dist/client-DSI_760t.d.ts +0 -36
  445. package/dist/client-JU6T3UPB.js +0 -11
  446. package/dist/client-JU6T3UPB.js.map +0 -1
  447. package/dist/dist-2X4Q7PJA.js +0 -1491
  448. package/dist/dist-2X4Q7PJA.js.map +0 -1
  449. package/dist/env-4UWSUS64.js +0 -4
  450. package/dist/env-4UWSUS64.js.map +0 -1
  451. package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
  452. package/dist/graphql-CMHMQjvd.d.ts +0 -23
  453. package/dist/i18n-Qm2AkPC-.d.ts +0 -33
  454. package/dist/index--yvpa6ay.d.ts +0 -83
  455. package/dist/index-4gKQKZ2B.d.ts +0 -71
  456. package/dist/index-5x0XMKXN.d.ts +0 -149
  457. package/dist/index-B70b5mYS.d.ts +0 -33
  458. package/dist/index-B8KrxO4j.d.ts +0 -755
  459. package/dist/index-BOuDKnqD.d.ts +0 -201
  460. package/dist/index-BTMt4OjA.d.ts +0 -201
  461. package/dist/index-BejbszA7.d.ts +0 -39
  462. package/dist/index-BkeOYZye.d.ts +0 -198
  463. package/dist/index-BuAj5nXg.d.ts +0 -83
  464. package/dist/index-BvkVcW8I.d.ts +0 -349
  465. package/dist/index-CWmH_-RZ.d.ts +0 -247
  466. package/dist/index-CbgWNcus.d.ts +0 -258
  467. package/dist/index-CmfPeQza.d.ts +0 -166
  468. package/dist/index-CmpG-zak.d.ts +0 -607
  469. package/dist/index-CoMKgL-p.d.ts +0 -12
  470. package/dist/index-D8HGwglK.d.ts +0 -541
  471. package/dist/index-DCaVm66D.d.ts +0 -1101
  472. package/dist/index-DE2w7E0d.d.ts +0 -83
  473. package/dist/index-DSOpj8DI.d.ts +0 -17
  474. package/dist/index-DW9q22GH.d.ts +0 -75
  475. package/dist/index-DnjJ9CwI.d.ts +0 -347
  476. package/dist/index-DwMJZ8PP.d.ts +0 -317
  477. package/dist/index-PaojfSdd.d.ts +0 -71
  478. package/dist/index-aHtYvc3i.d.ts +0 -284
  479. package/dist/index-e_18DzAg.d.ts +0 -18
  480. package/dist/index-ffmipXSA.d.ts +0 -55
  481. package/dist/index-joONjwLt.d.ts +0 -33
  482. package/dist/index-kssw5ziY.d.ts +0 -250
  483. package/dist/index-lFffh5-G.d.ts +0 -125
  484. package/dist/index-pxYge_6k.d.ts +0 -79
  485. package/dist/layer-Cv9vSwBx.d.ts +0 -70
  486. package/dist/pino-logger-H4HPW5P6.js +0 -5
  487. package/dist/pino-logger-H4HPW5P6.js.map +0 -1
  488. package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
  489. package/dist/sdk-L75WWUP3.js +0 -156
  490. package/dist/sdk-L75WWUP3.js.map +0 -1
  491. package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
  492. package/dist/types-Bo2wkjSP.d.ts +0 -35
  493. package/dist/types-DVpvrAhd.d.ts +0 -71
  494. package/dist/types-DgJ4lDYA.d.ts +0 -108
  495. package/dist/types-USOv09qy.d.ts +0 -327
  496. package/dist/workspace-guard-NXVYYBVJ.js +0 -5
  497. package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
@@ -0,0 +1,830 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-ad2WFvuA.js";
2
+ import { n as GatewayError } from "./types-BYMYND1L.js";
3
+ import { createHash } from "node:crypto";
4
+
5
+ // src/files/types.ts
6
+ /** Actor types the gateway forwards in `x-actor-type`. */
7
+ const FILE_ACTOR_TYPES = [
8
+ "user",
9
+ "app",
10
+ "service",
11
+ "super_admin"
12
+ ];
13
+ /** `FileVisibility` enum members accepted by wspace-files-svc. */
14
+ const FILE_VISIBILITIES = [
15
+ "PRIVATE",
16
+ "PUBLIC",
17
+ "TEAM",
18
+ "WORKSPACE"
19
+ ];
20
+
21
+ // src/files/errors.ts
22
+ /**
23
+ * Files client — error type.
24
+ *
25
+ * Services map {@link FilesClientError} onto their own i18n GraphQL errors; the
26
+ * `code` is stable so that mapping never parses messages. Upstream detail
27
+ * (files-svc messages, storage status codes) lives in `details` for logging and
28
+ * must not be returned to clients verbatim.
29
+ */
30
+ /** GraphQL `extensions.code` each {@link FilesClientErrorCode} should surface as. */
31
+ const FILES_CLIENT_GRAPHQL_CODES = {
32
+ INVALID_INPUT: "BAD_USER_INPUT",
33
+ MISSING_CONTEXT: "UNAUTHENTICATED",
34
+ NOT_FOUND: "NOT_FOUND",
35
+ QUOTA_EXCEEDED: "QUOTA_EXCEEDED",
36
+ TOO_LARGE: "BAD_USER_INPUT",
37
+ STORAGE_ERROR: "INTERNAL_SERVER_ERROR",
38
+ UPSTREAM_ERROR: "INTERNAL_SERVER_ERROR",
39
+ CONFIGURATION_ERROR: "INTERNAL_SERVER_ERROR"
40
+ };
41
+ var FilesClientError = class extends Error {
42
+ code;
43
+ details;
44
+ constructor(code, message, details = {}) {
45
+ super(message);
46
+ this.name = "FilesClientError";
47
+ this.code = code;
48
+ this.details = details;
49
+ }
50
+ /** The GraphQL `extensions.code` this error maps to. */
51
+ get graphqlCode() {
52
+ return FILES_CLIENT_GRAPHQL_CODES[this.code];
53
+ }
54
+ };
55
+ function isFilesClientError(error) {
56
+ return error instanceof FilesClientError;
57
+ }
58
+ const NOT_FOUND_UPSTREAM_CODES = /* @__PURE__ */ new Set(["NOT_FOUND", "FORBIDDEN"]);
59
+ const QUOTA_UPSTREAM_CODES = /* @__PURE__ */ new Set([
60
+ "QUOTA_EXCEEDED",
61
+ "QUOTA_EXHAUSTED",
62
+ "USAGE_LIMIT_EXCEEDED"
63
+ ]);
64
+ const INVALID_UPSTREAM_CODES = /* @__PURE__ */ new Set(["BAD_USER_INPUT", "EXPIRED"]);
65
+ function upstreamCode(error) {
66
+ const code = error.extensions?.["code"];
67
+ return typeof code === "string" ? code : null;
68
+ }
69
+ /** Classify files-svc GraphQL errors into a {@link FilesClientErrorCode}. */
70
+ function classifyFilesErrors(errors) {
71
+ const codes = errors.map(upstreamCode).filter((code) => code !== null);
72
+ if (codes.some((code) => QUOTA_UPSTREAM_CODES.has(code))) return "QUOTA_EXCEEDED";
73
+ if (codes.some((code) => NOT_FOUND_UPSTREAM_CODES.has(code))) return "NOT_FOUND";
74
+ if (codes.some((code) => INVALID_UPSTREAM_CODES.has(code))) return "INVALID_INPUT";
75
+ return "UPSTREAM_ERROR";
76
+ }
77
+ /**
78
+ * Normalise anything a files-svc call threw (a `GatewayError` carrying GraphQL
79
+ * errors, a timeout, a network error, …) into a {@link FilesClientError}.
80
+ */
81
+ function toFilesClientError(error, operation) {
82
+ if (error instanceof FilesClientError) return error;
83
+ if (error instanceof GatewayError) {
84
+ const graphqlErrors = error.graphqlErrors ?? [];
85
+ const code = graphqlErrors.length > 0 ? classifyFilesErrors(graphqlErrors) : "UPSTREAM_ERROR";
86
+ return new FilesClientError(code, `wspace-files-svc ${operation} failed: ${error.message}`, {
87
+ operation,
88
+ gatewayErrorType: error.type,
89
+ statusCode: error.statusCode,
90
+ errors: graphqlErrors.map((graphqlError) => ({
91
+ message: graphqlError.message,
92
+ code: upstreamCode(graphqlError)
93
+ }))
94
+ });
95
+ }
96
+ const message = error instanceof Error ? error.message : String(error);
97
+ return new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} failed: ${message}`, { operation });
98
+ }
99
+
100
+ // src/files/client.ts
101
+ /**
102
+ * FilesClient — store and read workspace blobs through wspace-files-svc.
103
+ *
104
+ * Module ownership makes wspace-files-svc the canonical owner of blobs, yet
105
+ * services kept re-implementing storage: VibeControls hand-rolled SigV4 with
106
+ * static S3 keys for security evidence, FluidGrids passed attachments between
107
+ * nodes as base64, HealthyBowl carried its own three-step uploader. This class
108
+ * is the shared client: a service hands it bytes and gets back an opaque
109
+ * `fileId`, and resolves that id back to metadata, a short-lived download URL or
110
+ * the bytes themselves.
111
+ *
112
+ * Every call is same-layer M2M through the internal workspace gateway
113
+ * (`GatewayClient.internalQuery`, which signs the service JWT; the gateway adds
114
+ * its own trusted token toward files-svc). The CALLER's actor and workspace are
115
+ * forwarded explicitly, so the File row is owned by the user who asked for it,
116
+ * shows up in their library, and files-svc applies quota, folder access and read
117
+ * permission to that user. The internal gateway enforces neither `@rbac` nor
118
+ * `@usage` for the product's own resolver, so the service must already have
119
+ * authorized the action (its own `@rbac` plus a workspace-scoped row lookup).
120
+ *
121
+ * Upload is the files-svc protocol: `initiateUpload` → presigned PUT (DIRECT) or
122
+ * per-part PUTs + `registerUploadedPart` (MULTIPART, which files-svc picks for
123
+ * files over 5 MiB) → `completeUpload` with the same `fileSize` (required: it
124
+ * must match the size declared at initiate). A failed upload aborts its session.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * import { FilesClient, toFileReference } from '@burdenoff/be-sdk/files';
129
+ *
130
+ * const files = new FilesClient({ serviceName: 'wspace-vibecontrols-svc' });
131
+ *
132
+ * const stored = await files.uploadFile(
133
+ * { fileName: 'access-review.pdf', data: pdfBytes, mimeType: 'application/pdf', description: 'SOC 2 evidence' },
134
+ * { actorId: ctx.actorId, workspaceId: ctx.workspaceId }
135
+ * );
136
+ * await db.securityEvidence.update({ where: { id }, data: { fileId: stored.fileId } });
137
+ *
138
+ * const url = await files.getDownloadUrl(evidence.fileId, actor, { expiresInSeconds: 300 });
139
+ * ```
140
+ */
141
+ const MIB = 1048576;
142
+ /** S3 refuses presigned URLs that live longer than 7 days; files-svc 500s above it. */
143
+ const MAX_DOWNLOAD_URL_TTL_SECONDS = 604800;
144
+ /** Shortest URL lifetime the client will request. */
145
+ const MIN_DOWNLOAD_URL_TTL_SECONDS = 60;
146
+ const DEFAULT_REQUEST_TIMEOUT_MS = 15e3;
147
+ const DEFAULT_TRANSFER_TIMEOUT_MS = 12e4;
148
+ const DEFAULT_MAX_UPLOAD_BYTES = 100 * MIB;
149
+ const DEFAULT_MAX_DOWNLOAD_BYTES = 25 * MIB;
150
+ const DEFAULT_DOWNLOAD_URL_TTL_SECONDS = 3600;
151
+ /** TTL of the URL `downloadFile` mints for its own immediate GET. */
152
+ const INTERNAL_DOWNLOAD_URL_TTL_SECONDS = 300;
153
+ const PART_URL_BATCH_SIZE = 20;
154
+ const SHA256_HEX = /^[0-9a-f]{64}$/;
155
+ const FILE_FIELDS = "id name mimeType extension size status visibility workspaceId folderId uploadedById description sha256Hash createdAt updatedAt canRead canDelete";
156
+ const INITIATE_UPLOAD = `mutation FilesClientInitiateUpload($input: InitiateUploadInput!) {
157
+ initiateUpload(input: $input) {
158
+ uploadUrl
159
+ session { id uploadType partSize totalParts fileSize expiresAt }
160
+ }
161
+ }`;
162
+ const PART_URLS = `query FilesClientPartUploadUrls($sessionId: ID!, $partNumbers: [Int!]!) {
163
+ getBatchPartUploadUrls(sessionId: $sessionId, partNumbers: $partNumbers) { partNumber url }
164
+ }`;
165
+ const REGISTER_PART = `mutation FilesClientRegisterUploadedPart($input: UploadPartInput!) {
166
+ registerUploadedPart(input: $input) { session { id uploadedParts } }
167
+ }`;
168
+ const COMPLETE_UPLOAD = `mutation FilesClientCompleteUpload($input: CompleteUploadInput!) {
169
+ completeUpload(input: $input) { fileId file { id name mimeType size workspaceId sha256Hash } }
170
+ }`;
171
+ const ABORT_UPLOAD = `mutation FilesClientAbortUpload($sessionId: ID!) { abortUpload(sessionId: $sessionId) }`;
172
+ const GET_FILE = `query FilesClientGetFile($id: ID!) { getFile(id: $id) { ${FILE_FIELDS} } }`;
173
+ const GET_DOWNLOAD_URL = `query FilesClientGetFileDownloadUrl($id: ID!, $expiresIn: Int) {
174
+ getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
175
+ }`;
176
+ const RESOLVE_FOR_DOWNLOAD = `query FilesClientResolveForDownload($id: ID!, $expiresIn: Int) {
177
+ getFile(id: $id) { ${FILE_FIELDS} }
178
+ getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
179
+ }`;
180
+ const DELETE_FILE = `mutation FilesClientDeleteFile($id: ID!) { deleteFile(id: $id) }`;
181
+ const PERMANENTLY_DELETE_FILE = `mutation FilesClientPermanentlyDeleteFile($id: ID!) { permanentlyDeleteFile(id: $id) }`;
182
+ function requireNonEmpty(value, field) {
183
+ const trimmed = typeof value === "string" ? value.trim() : "";
184
+ if (!trimmed) throw new FilesClientError("INVALID_INPUT", `${field} is required`, { field });
185
+ return trimmed;
186
+ }
187
+ function requirePositiveInteger(value, field) {
188
+ if (!Number.isSafeInteger(value) || value <= 0) throw new FilesClientError("CONFIGURATION_ERROR", `${field} must be a positive integer`, {
189
+ field,
190
+ value
191
+ });
192
+ return value;
193
+ }
194
+ function toNumber(value, field) {
195
+ const parsed = typeof value === "number" ? value : Number(value);
196
+ if (!Number.isSafeInteger(parsed) || parsed < 0) throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc returned an invalid ${field}`, {
197
+ field,
198
+ value
199
+ });
200
+ return parsed;
201
+ }
202
+ function toDate(value) {
203
+ if (!value) return null;
204
+ const date = new Date(value);
205
+ return Number.isNaN(date.getTime()) ? null : date;
206
+ }
207
+ /** A view over `data` backed by a plain `ArrayBuffer` (what `fetch` bodies accept). */
208
+ function toBytes(data) {
209
+ if (data instanceof ArrayBuffer) return new Uint8Array(data);
210
+ const { buffer } = data;
211
+ if (buffer instanceof ArrayBuffer) return new Uint8Array(buffer, data.byteOffset, data.byteLength);
212
+ return new Uint8Array(data);
213
+ }
214
+ /** Extension for `fileName` (`report.PDF` → `pdf`), or `bin` when it has none. */
215
+ function fileExtensionOf(fileName) {
216
+ const base = fileName.trim().split(/[\\/]/).pop() ?? "";
217
+ const dot = base.lastIndexOf(".");
218
+ if (dot <= 0 || dot === base.length - 1) return "bin";
219
+ return base.slice(dot + 1).toLowerCase().replace(/[^a-z0-9]/g, "") || "bin";
220
+ }
221
+ /** Clamp a requested URL lifetime to what files-svc / S3 accept. */
222
+ function clampDownloadUrlTtl(seconds, fallback) {
223
+ return Math.min(Math.max(Math.trunc(seconds === null || seconds === void 0 || !Number.isFinite(seconds) ? fallback : seconds), 60), MAX_DOWNLOAD_URL_TTL_SECONDS);
224
+ }
225
+ function isHttpUrl(value) {
226
+ if (typeof value !== "string" || value.length === 0) return false;
227
+ try {
228
+ const { protocol } = new URL(value);
229
+ return protocol === "https:" || protocol === "http:";
230
+ } catch {
231
+ return false;
232
+ }
233
+ }
234
+ /** Lowercase a declared SHA-256 and reject anything that is not 64 hex characters. */
235
+ function normalizeSha256(value) {
236
+ if (value === null || value === void 0 || value.trim() === "") return null;
237
+ const normalized = value.trim().toLowerCase();
238
+ if (!SHA256_HEX.test(normalized)) throw new FilesClientError("INVALID_INPUT", "sha256Hash must be 64 hex characters", { field: "sha256Hash" });
239
+ return normalized;
240
+ }
241
+ /** Validate MULTIPART part ETags: positive, unique part numbers with a non-empty ETag, sorted. */
242
+ function normalizeUploadedParts(parts) {
243
+ const seen = /* @__PURE__ */ new Set();
244
+ return parts.map((part) => {
245
+ const etag = typeof part.etag === "string" ? part.etag.trim() : "";
246
+ if (!Number.isSafeInteger(part.partNumber) || part.partNumber <= 0 || seen.has(part.partNumber) || !etag) throw new FilesClientError("INVALID_INPUT", "parts must have unique positive part numbers and an ETag", {
247
+ field: "parts",
248
+ partNumber: part.partNumber
249
+ });
250
+ seen.add(part.partNumber);
251
+ return {
252
+ partNumber: part.partNumber,
253
+ etag
254
+ };
255
+ }).sort((a, b) => a.partNumber - b.partNumber);
256
+ }
257
+ /** Map a files-svc `File` selection onto {@link FileMetadata}. */
258
+ function mapFileMetadata(raw) {
259
+ return {
260
+ id: raw.id,
261
+ name: raw.name,
262
+ mimeType: raw.mimeType,
263
+ extension: raw.extension,
264
+ size: toNumber(raw.size, "size"),
265
+ status: raw.status,
266
+ visibility: raw.visibility,
267
+ workspaceId: raw.workspaceId,
268
+ folderId: raw.folderId ?? null,
269
+ uploadedById: raw.uploadedById,
270
+ description: raw.description ?? null,
271
+ sha256Hash: raw.sha256Hash ?? null,
272
+ createdAt: toDate(raw.createdAt),
273
+ updatedAt: toDate(raw.updatedAt),
274
+ canRead: raw.canRead ?? null,
275
+ canDelete: raw.canDelete ?? null
276
+ };
277
+ }
278
+ var FilesClient = class {
279
+ clientOption;
280
+ serviceName;
281
+ fetchImpl;
282
+ requestTimeoutMs;
283
+ transferTimeoutMs;
284
+ maxUploadBytes;
285
+ maxDownloadBytes;
286
+ defaultDownloadUrlTtlSeconds;
287
+ clientPromise = null;
288
+ constructor(options = {}) {
289
+ this.clientOption = options.client;
290
+ this.serviceName = options.serviceName;
291
+ this.fetchImpl = options.fetch ?? ((url, init) => fetch(url, init));
292
+ this.requestTimeoutMs = requirePositiveInteger(options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS, "requestTimeoutMs");
293
+ this.transferTimeoutMs = requirePositiveInteger(options.transferTimeoutMs ?? DEFAULT_TRANSFER_TIMEOUT_MS, "transferTimeoutMs");
294
+ this.maxUploadBytes = requirePositiveInteger(options.maxUploadBytes ?? DEFAULT_MAX_UPLOAD_BYTES, "maxUploadBytes");
295
+ this.maxDownloadBytes = requirePositiveInteger(options.maxDownloadBytes ?? DEFAULT_MAX_DOWNLOAD_BYTES, "maxDownloadBytes");
296
+ const ttl = options.defaultDownloadUrlTtlSeconds ?? DEFAULT_DOWNLOAD_URL_TTL_SECONDS;
297
+ if (!Number.isSafeInteger(ttl) || ttl < 60 || ttl > 604800) throw new FilesClientError("CONFIGURATION_ERROR", `defaultDownloadUrlTtlSeconds must be between ${60} and ${MAX_DOWNLOAD_URL_TTL_SECONDS}`, { value: ttl });
298
+ this.defaultDownloadUrlTtlSeconds = ttl;
299
+ }
300
+ /**
301
+ * Store bytes in the actor's workspace file library and return the File's id.
302
+ * Throws {@link FilesClientError}; on any failure after the session was opened
303
+ * the session is aborted so no half-uploaded object is left behind.
304
+ */
305
+ async uploadFile(input, actor) {
306
+ const context = this.requireActor(actor);
307
+ const fileName = requireNonEmpty(input.fileName, "fileName");
308
+ const mimeType = requireNonEmpty(input.mimeType, "mimeType");
309
+ const bytes = toBytes(input.data);
310
+ if (bytes.byteLength === 0) throw new FilesClientError("INVALID_INPUT", "data must not be empty", { field: "data" });
311
+ if (bytes.byteLength > this.maxUploadBytes) throw new FilesClientError("TOO_LARGE", `File is larger than ${this.maxUploadBytes} bytes`, {
312
+ size: bytes.byteLength,
313
+ maxBytes: this.maxUploadBytes
314
+ });
315
+ if (input.visibility !== void 0 && !FILE_VISIBILITIES.includes(input.visibility)) throw new FilesClientError("INVALID_INPUT", `Unknown file visibility "${String(input.visibility)}"`, { field: "visibility" });
316
+ const extension = input.extension?.trim() ? input.extension.trim().replace(/^\./, "").toLowerCase() : fileExtensionOf(fileName);
317
+ const fileSize = String(bytes.byteLength);
318
+ const sha256Hash = input.declareSha256 === false ? null : createHash("sha256").update(bytes).digest("hex");
319
+ const folderId = input.folderId?.trim() || void 0;
320
+ const initiated = await this.request("initiateUpload", INITIATE_UPLOAD, { input: {
321
+ fileName,
322
+ fileSize,
323
+ mimeType,
324
+ extension,
325
+ ...folderId ? { folderId } : {},
326
+ ...input.visibility ? { visibility: input.visibility } : {},
327
+ ...sha256Hash ? { sha256Hash } : {}
328
+ } }, context);
329
+ const rawSession = initiated.initiateUpload?.session;
330
+ if (!rawSession?.id) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no session");
331
+ const session = {
332
+ id: rawSession.id,
333
+ uploadType: rawSession.uploadType,
334
+ partSize: toNumber(rawSession.partSize, "partSize"),
335
+ totalParts: toNumber(rawSession.totalParts, "totalParts")
336
+ };
337
+ try {
338
+ if (session.uploadType === "MULTIPART") await this.uploadParts(session, bytes, context);
339
+ else await this.putDirect(initiated.initiateUpload?.uploadUrl, bytes, mimeType);
340
+ return await this.completeSession(session.id, {
341
+ fileSize,
342
+ fallbackName: fileName,
343
+ fallbackMimeType: mimeType,
344
+ fallbackSize: bytes.byteLength,
345
+ sha256Hash,
346
+ folderId,
347
+ description: input.description ?? null
348
+ }, context);
349
+ } catch (error) {
350
+ await this.abortQuietly(session.id, context);
351
+ throw toFilesClientError(error, "uploadFile");
352
+ }
353
+ }
354
+ /**
355
+ * Open a files-svc upload session on the actor's behalf for bytes that
356
+ * someone else holds (an agent, a CLI, a browser), and return the presigned
357
+ * URL(s) to hand them. The uploader PUTs the bytes — one PUT to `uploadUrl`
358
+ * for DIRECT, one PUT per `parts` entry for MULTIPART (files-svc picks
359
+ * MULTIPART above 5 MiB) — and the service then calls
360
+ * {@link completeUploadSession} with the same `fileSize` (and the part ETags)
361
+ * to turn the session into a File. The service never sees the bytes and never
362
+ * holds storage credentials.
363
+ *
364
+ * Throws {@link FilesClientError}. If files-svc opened the session but the
365
+ * client cannot hand it out (an unsupported upload type, missing part URLs),
366
+ * the session is aborted before the error is thrown.
367
+ */
368
+ async createUploadSession(input, actor) {
369
+ const context = this.requireActor(actor);
370
+ const fileName = requireNonEmpty(input.fileName, "fileName");
371
+ const mimeType = requireNonEmpty(input.mimeType, "mimeType");
372
+ if (!Number.isSafeInteger(input.fileSize) || input.fileSize <= 0) throw new FilesClientError("INVALID_INPUT", "fileSize must be a positive integer", { field: "fileSize" });
373
+ if (input.fileSize > this.maxUploadBytes) throw new FilesClientError("TOO_LARGE", `File is larger than ${this.maxUploadBytes} bytes`, {
374
+ size: input.fileSize,
375
+ maxBytes: this.maxUploadBytes
376
+ });
377
+ if (input.visibility !== void 0 && !FILE_VISIBILITIES.includes(input.visibility)) throw new FilesClientError("INVALID_INPUT", `Unknown file visibility "${String(input.visibility)}"`, { field: "visibility" });
378
+ const sha256Hash = normalizeSha256(input.sha256Hash);
379
+ const extension = input.extension?.trim() ? input.extension.trim().replace(/^\./, "").toLowerCase() : fileExtensionOf(fileName);
380
+ const folderId = input.folderId?.trim() || void 0;
381
+ const initiated = await this.request("initiateUpload", INITIATE_UPLOAD, { input: {
382
+ fileName,
383
+ fileSize: String(input.fileSize),
384
+ mimeType,
385
+ extension,
386
+ ...folderId ? { folderId } : {},
387
+ ...input.visibility ? { visibility: input.visibility } : {},
388
+ ...sha256Hash ? { sha256Hash } : {}
389
+ } }, context);
390
+ const rawSession = initiated.initiateUpload?.session;
391
+ if (!rawSession?.id) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no session");
392
+ try {
393
+ const partSize = toNumber(rawSession.partSize, "partSize");
394
+ const totalParts = toNumber(rawSession.totalParts, "totalParts");
395
+ const base = {
396
+ sessionId: rawSession.id,
397
+ partSize,
398
+ totalParts,
399
+ fileSize: input.fileSize,
400
+ sha256Hash,
401
+ expiresAt: toDate(rawSession.expiresAt)
402
+ };
403
+ if (rawSession.uploadType === "MULTIPART") {
404
+ const session = {
405
+ id: rawSession.id,
406
+ uploadType: "MULTIPART",
407
+ partSize,
408
+ totalParts
409
+ };
410
+ this.assertMultipartPlan(session, input.fileSize);
411
+ const parts = await this.presignParts(session, input.fileSize, context);
412
+ return {
413
+ ...base,
414
+ uploadType: "MULTIPART",
415
+ uploadUrl: null,
416
+ requiredHeaders: {},
417
+ parts
418
+ };
419
+ }
420
+ if (rawSession.uploadType !== "DIRECT") throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc opened an unsupported ${String(rawSession.uploadType)} session`, { sessionId: rawSession.id });
421
+ const uploadUrl = initiated.initiateUpload?.uploadUrl;
422
+ if (!isHttpUrl(uploadUrl)) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no upload URL", { sessionId: rawSession.id });
423
+ return {
424
+ ...base,
425
+ uploadType: "DIRECT",
426
+ uploadUrl,
427
+ requiredHeaders: { "Content-Type": mimeType },
428
+ parts: []
429
+ };
430
+ } catch (error) {
431
+ await this.abortQuietly(rawSession.id, context);
432
+ throw toFilesClientError(error, "createUploadSession");
433
+ }
434
+ }
435
+ /**
436
+ * Turn a session opened by {@link createUploadSession} into a File once the
437
+ * uploader has PUT the bytes: registers the MULTIPART part ETags, then runs
438
+ * `completeUpload` with the declared size (and SHA-256). files-svc verifies
439
+ * the stored object; a size or checksum mismatch surfaces as `INVALID_INPUT`.
440
+ * The session is left open on failure so the caller can retry or
441
+ * {@link abortUploadSession} it.
442
+ */
443
+ async completeUploadSession(sessionId, input, actor) {
444
+ const context = this.requireActor(actor);
445
+ const id = requireNonEmpty(sessionId, "sessionId");
446
+ if (!Number.isSafeInteger(input.fileSize) || input.fileSize <= 0) throw new FilesClientError("INVALID_INPUT", "fileSize must be a positive integer", { field: "fileSize" });
447
+ const sha256Hash = normalizeSha256(input.sha256Hash);
448
+ const parts = normalizeUploadedParts(input.parts ?? []);
449
+ const folderId = input.folderId?.trim() || void 0;
450
+ for (const part of parts) await this.request("registerUploadedPart", REGISTER_PART, { input: {
451
+ sessionId: id,
452
+ partNumber: part.partNumber,
453
+ etag: part.etag
454
+ } }, context);
455
+ return this.completeSession(id, {
456
+ fileSize: String(input.fileSize),
457
+ fallbackName: "",
458
+ fallbackMimeType: "",
459
+ fallbackSize: input.fileSize,
460
+ sha256Hash,
461
+ folderId,
462
+ description: input.description ?? null
463
+ }, context);
464
+ }
465
+ /** Abandon a session opened by {@link createUploadSession}. `true` when files-svc aborted it. */
466
+ async abortUploadSession(sessionId, actor) {
467
+ const id = requireNonEmpty(sessionId, "sessionId");
468
+ return (await this.request("abortUpload", ABORT_UPLOAD, { sessionId: id }, actor)).abortUpload === true;
469
+ }
470
+ /** File metadata, or `null` when it does not exist or the actor cannot see it. */
471
+ async getFile(fileId, actor) {
472
+ const id = requireNonEmpty(fileId, "fileId");
473
+ try {
474
+ const data = await this.request("getFile", GET_FILE, { id }, actor);
475
+ return data.getFile ? mapFileMetadata(data.getFile) : null;
476
+ } catch (error) {
477
+ if (error instanceof FilesClientError && error.code === "NOT_FOUND") return null;
478
+ throw error;
479
+ }
480
+ }
481
+ /**
482
+ * Prove that an opaque file id the caller supplied names a File in the actor's
483
+ * workspace that they may read, before the service stores or acts on it.
484
+ * Throws `NOT_FOUND` (never a permission error) otherwise.
485
+ */
486
+ async requireFile(fileId, actor, options = {}) {
487
+ const context = this.requireActor(actor);
488
+ const file = await this.getFile(fileId, context);
489
+ this.assertUsable(file, fileId, context, options);
490
+ return file;
491
+ }
492
+ /**
493
+ * A presigned download URL for the file, minted for the actor. Mint it when the
494
+ * user opens the file; never persist it. The lifetime is clamped to
495
+ * [60, 604800] seconds.
496
+ */
497
+ async getDownloadUrl(fileId, actor, options = {}) {
498
+ const id = requireNonEmpty(fileId, "fileId");
499
+ const expiresIn = clampDownloadUrlTtl(options.expiresInSeconds, this.defaultDownloadUrlTtlSeconds);
500
+ const data = await this.request("getFileDownloadUrl", GET_DOWNLOAD_URL, {
501
+ id,
502
+ expiresIn
503
+ }, actor);
504
+ if (!isHttpUrl(data.getFileDownloadUrl)) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc returned no usable download URL", { fileId: id });
505
+ return data.getFileDownloadUrl;
506
+ }
507
+ /**
508
+ * Fetch the file's bytes for server-side processing (vision models, parsers,
509
+ * workflow nodes). Checks the file is active, readable by the actor and within
510
+ * `maxBytes` before downloading, and verifies the downloaded size.
511
+ */
512
+ async downloadFile(fileId, actor, options = {}) {
513
+ const context = this.requireActor(actor);
514
+ const id = requireNonEmpty(fileId, "fileId");
515
+ const maxBytes = options.maxBytes ?? this.maxDownloadBytes;
516
+ if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) throw new FilesClientError("INVALID_INPUT", "maxBytes must be a positive integer", { field: "maxBytes" });
517
+ const data = await this.request("downloadFile", RESOLVE_FOR_DOWNLOAD, {
518
+ id,
519
+ expiresIn: INTERNAL_DOWNLOAD_URL_TTL_SECONDS
520
+ }, context);
521
+ const file = data.getFile ? mapFileMetadata(data.getFile) : null;
522
+ this.assertUsable(file, id, context, {});
523
+ if (file.size > maxBytes) throw new FilesClientError("TOO_LARGE", `File is larger than ${maxBytes} bytes`, {
524
+ fileId: id,
525
+ size: file.size,
526
+ maxBytes
527
+ });
528
+ const url = data.getFileDownloadUrl;
529
+ if (!isHttpUrl(url)) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc returned no usable download URL", { fileId: id });
530
+ const response = await this.transfer(url, { method: "GET" }, "download");
531
+ const bytes = await this.readBounded(response, maxBytes, id);
532
+ if (bytes.byteLength !== file.size) throw new FilesClientError("STORAGE_ERROR", "Downloaded size does not match the stored file size", {
533
+ fileId: id,
534
+ expected: file.size,
535
+ actual: bytes.byteLength
536
+ });
537
+ return {
538
+ bytes,
539
+ mimeType: file.mimeType,
540
+ name: file.name,
541
+ size: bytes.byteLength
542
+ };
543
+ }
544
+ /** {@link downloadFile} as base64, for payloads that must stay JSON (model inputs). */
545
+ async downloadFileAsBase64(fileId, actor, options = {}) {
546
+ const file = await this.downloadFile(fileId, actor, options);
547
+ return {
548
+ base64: Buffer.from(file.bytes).toString("base64"),
549
+ mimeType: file.mimeType,
550
+ name: file.name,
551
+ size: file.size
552
+ };
553
+ }
554
+ /** Move the file to trash (or hard-delete with `permanent`). `true` when files-svc deleted it. */
555
+ async deleteFile(fileId, actor, options = {}) {
556
+ const id = requireNonEmpty(fileId, "fileId");
557
+ if (options.permanent) return (await this.request("permanentlyDeleteFile", PERMANENTLY_DELETE_FILE, { id }, actor)).permanentlyDeleteFile === true;
558
+ return (await this.request("deleteFile", DELETE_FILE, { id }, actor)).deleteFile === true;
559
+ }
560
+ async putDirect(uploadUrl, bytes, mimeType) {
561
+ if (!isHttpUrl(uploadUrl)) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no upload URL");
562
+ await this.transfer(uploadUrl, {
563
+ method: "PUT",
564
+ body: bytes,
565
+ headers: { "Content-Type": mimeType }
566
+ }, "upload");
567
+ }
568
+ async uploadParts(session, bytes, actor) {
569
+ this.assertMultipartPlan(session, bytes.byteLength);
570
+ for (let first = 1; first <= session.totalParts; first += PART_URL_BATCH_SIZE) {
571
+ const partNumbers = [];
572
+ for (let part = first; part < first + PART_URL_BATCH_SIZE && part <= session.totalParts; part += 1) partNumbers.push(part);
573
+ const data = await this.request("getBatchPartUploadUrls", PART_URLS, {
574
+ sessionId: session.id,
575
+ partNumbers
576
+ }, actor);
577
+ const urls = new Map((data.getBatchPartUploadUrls ?? []).map((entry) => [entry.partNumber, entry.url]));
578
+ for (const partNumber of partNumbers) {
579
+ const url = urls.get(partNumber);
580
+ if (!isHttpUrl(url)) throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc returned no URL for part ${partNumber}`, {
581
+ sessionId: session.id,
582
+ partNumber
583
+ });
584
+ const start = (partNumber - 1) * session.partSize;
585
+ const body = bytes.subarray(start, Math.min(start + session.partSize, bytes.byteLength));
586
+ const etag = (await this.transfer(url, {
587
+ method: "PUT",
588
+ body
589
+ }, "upload")).headers.get("etag");
590
+ if (!etag) throw new FilesClientError("STORAGE_ERROR", `Object storage returned no ETag for part ${partNumber}`, {
591
+ sessionId: session.id,
592
+ partNumber
593
+ });
594
+ await this.request("registerUploadedPart", REGISTER_PART, { input: {
595
+ sessionId: session.id,
596
+ partNumber,
597
+ etag
598
+ } }, actor);
599
+ }
600
+ }
601
+ }
602
+ async completeSession(sessionId, args, actor) {
603
+ const completed = await this.request("completeUpload", COMPLETE_UPLOAD, { input: {
604
+ sessionId,
605
+ fileSize: args.fileSize,
606
+ ...args.folderId ? { folderId: args.folderId } : {},
607
+ ...args.description ? { description: args.description } : {},
608
+ ...args.sha256Hash ? { sha256Hash: args.sha256Hash } : {}
609
+ } }, actor);
610
+ const file = completed.completeUpload?.file;
611
+ const fileId = completed.completeUpload?.fileId ?? file?.id;
612
+ if (!fileId) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc completeUpload returned no fileId", { sessionId });
613
+ return {
614
+ fileId,
615
+ name: file?.name ?? args.fallbackName,
616
+ mimeType: file?.mimeType ?? args.fallbackMimeType,
617
+ size: file ? toNumber(file.size, "size") : args.fallbackSize,
618
+ workspaceId: file?.workspaceId ?? actor.workspaceId,
619
+ sha256Hash: file?.sha256Hash ?? args.sha256Hash
620
+ };
621
+ }
622
+ assertMultipartPlan(session, size) {
623
+ if (session.partSize <= 0 || session.totalParts !== Math.ceil(size / session.partSize)) throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc returned an inconsistent multipart plan", {
624
+ sessionId: session.id,
625
+ partSize: session.partSize,
626
+ totalParts: session.totalParts,
627
+ size
628
+ });
629
+ }
630
+ /** Presigned URL for every part, fetched in batches. */
631
+ async partUrls(session, actor) {
632
+ const urls = /* @__PURE__ */ new Map();
633
+ for (let first = 1; first <= session.totalParts; first += PART_URL_BATCH_SIZE) {
634
+ const partNumbers = [];
635
+ for (let part = first; part < first + PART_URL_BATCH_SIZE && part <= session.totalParts; part += 1) partNumbers.push(part);
636
+ const data = await this.request("getBatchPartUploadUrls", PART_URLS, {
637
+ sessionId: session.id,
638
+ partNumbers
639
+ }, actor);
640
+ for (const entry of data.getBatchPartUploadUrls ?? []) urls.set(entry.partNumber, entry.url);
641
+ }
642
+ return urls;
643
+ }
644
+ async presignParts(session, size, actor) {
645
+ const urls = await this.partUrls(session, actor);
646
+ const parts = [];
647
+ for (let partNumber = 1; partNumber <= session.totalParts; partNumber += 1) {
648
+ const url = urls.get(partNumber);
649
+ if (!isHttpUrl(url)) throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc returned no URL for part ${partNumber}`, {
650
+ sessionId: session.id,
651
+ partNumber
652
+ });
653
+ const offset = (partNumber - 1) * session.partSize;
654
+ parts.push({
655
+ partNumber,
656
+ url,
657
+ offset,
658
+ length: Math.min(session.partSize, size - offset)
659
+ });
660
+ }
661
+ return parts;
662
+ }
663
+ async abortQuietly(sessionId, actor) {
664
+ try {
665
+ await this.request("abortUpload", ABORT_UPLOAD, { sessionId }, actor);
666
+ } catch {}
667
+ }
668
+ assertUsable(file, fileId, actor, options) {
669
+ const requireActive = options.requireActive ?? true;
670
+ const requireReadable = options.requireReadable ?? true;
671
+ if (!file || file.id !== fileId.trim() || file.workspaceId !== actor.workspaceId || requireActive && file.status !== "ACTIVE" || requireReadable && file.canRead !== true) throw new FilesClientError("NOT_FOUND", "File not found", { fileId });
672
+ }
673
+ async transfer(url, init, leg) {
674
+ let response;
675
+ try {
676
+ response = await this.fetchImpl(url, {
677
+ ...init,
678
+ signal: AbortSignal.timeout(this.transferTimeoutMs)
679
+ });
680
+ } catch (error) {
681
+ throw new FilesClientError("STORAGE_ERROR", `Object storage ${leg} failed`, {
682
+ leg,
683
+ cause: error instanceof Error ? error.message : String(error)
684
+ });
685
+ }
686
+ if (!response.ok) throw new FilesClientError("STORAGE_ERROR", `Object storage ${leg} failed with HTTP ${response.status}`, {
687
+ leg,
688
+ status: response.status
689
+ });
690
+ return response;
691
+ }
692
+ async readBounded(response, maxBytes, fileId) {
693
+ const tooLarge = () => new FilesClientError("TOO_LARGE", `File is larger than ${maxBytes} bytes`, {
694
+ fileId,
695
+ maxBytes
696
+ });
697
+ const declared = Number(response.headers.get("content-length") ?? NaN);
698
+ if (Number.isFinite(declared) && declared > maxBytes) throw tooLarge();
699
+ if (!response.body) {
700
+ const buffer = new Uint8Array(await response.arrayBuffer());
701
+ if (buffer.byteLength > maxBytes) throw tooLarge();
702
+ return buffer;
703
+ }
704
+ const reader = response.body.getReader();
705
+ const chunks = [];
706
+ let total = 0;
707
+ for (;;) {
708
+ const { done, value } = await reader.read();
709
+ if (done) break;
710
+ total += value.byteLength;
711
+ if (total > maxBytes) {
712
+ await reader.cancel();
713
+ throw tooLarge();
714
+ }
715
+ chunks.push(value);
716
+ }
717
+ const bytes = new Uint8Array(total);
718
+ let offset = 0;
719
+ for (const chunk of chunks) {
720
+ bytes.set(chunk, offset);
721
+ offset += chunk.byteLength;
722
+ }
723
+ return bytes;
724
+ }
725
+ requireActor(actor) {
726
+ if (!actor.actorId?.trim() || !actor.workspaceId?.trim()) throw new FilesClientError("MISSING_CONTEXT", "File operations need an authenticated actor and a workspace");
727
+ if (actor.actorType !== void 0 && !FILE_ACTOR_TYPES.includes(actor.actorType)) throw new FilesClientError("MISSING_CONTEXT", `Unknown actor type "${String(actor.actorType)}"`);
728
+ return actor;
729
+ }
730
+ getClient() {
731
+ if (!this.clientPromise) {
732
+ const option = this.clientOption;
733
+ this.clientPromise = (async () => {
734
+ try {
735
+ if (typeof option === "function") return await option();
736
+ if (option) return option;
737
+ const gateway = await import("./client-sAJTrb4i.js").then((n) => n.n);
738
+ if (this.serviceName) return new gateway.GatewayClient({
739
+ layer: "wspace",
740
+ serviceName: this.serviceName,
741
+ serviceIdentity: this.serviceName
742
+ });
743
+ return gateway.createGatewayClientFromEnv();
744
+ } catch (error) {
745
+ throw new FilesClientError("CONFIGURATION_ERROR", "Files gateway client is not configured", { cause: error instanceof Error ? error.message : String(error) });
746
+ }
747
+ })();
748
+ this.clientPromise.catch(() => {
749
+ this.clientPromise = null;
750
+ });
751
+ }
752
+ return this.clientPromise;
753
+ }
754
+ async request(operation, query, variables, actor) {
755
+ const { actorId, workspaceId, actorType } = this.requireActor(actor);
756
+ const client = await this.getClient();
757
+ let response;
758
+ try {
759
+ response = await client.internalQuery({
760
+ query,
761
+ variables,
762
+ timeout: this.requestTimeoutMs,
763
+ headers: {
764
+ "x-actor-id": actorId,
765
+ "x-actor-type": actorType ?? "user",
766
+ "x-workspace-id": workspaceId
767
+ }
768
+ });
769
+ } catch (error) {
770
+ throw toFilesClientError(error, operation);
771
+ }
772
+ if (response.errors?.length) throw new FilesClientError(classifyFilesErrors(response.errors), `wspace-files-svc ${operation} failed`, {
773
+ operation,
774
+ errors: response.errors.map((error) => ({
775
+ message: error.message,
776
+ code: error.extensions?.["code"] ?? null
777
+ }))
778
+ });
779
+ if (!response.data) throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} returned no data`, { operation });
780
+ return response.data;
781
+ }
782
+ };
783
+
784
+ // src/files/reference.ts
785
+ /** Discriminator value of {@link FileReference.kind}. */
786
+ const FILE_REFERENCE_KIND = "burdenoff.file";
787
+ /** Build a {@link FileReference} from an upload result or file metadata. */
788
+ function toFileReference(file) {
789
+ return {
790
+ kind: FILE_REFERENCE_KIND,
791
+ fileId: "fileId" in file ? file.fileId : file.id,
792
+ name: file.name,
793
+ mimeType: file.mimeType,
794
+ size: file.size,
795
+ sha256Hash: file.sha256Hash
796
+ };
797
+ }
798
+ function isRecord(value) {
799
+ return typeof value === "object" && value !== null && !Array.isArray(value);
800
+ }
801
+ /** Type guard for a {@link FileReference} read back from JSON (node output, DB column, …). */
802
+ function isFileReference(value) {
803
+ if (!isRecord(value)) return false;
804
+ const size = value["size"];
805
+ const sha256Hash = value["sha256Hash"];
806
+ return value["kind"] === "burdenoff.file" && typeof value["fileId"] === "string" && value["fileId"].length > 0 && typeof value["name"] === "string" && typeof value["mimeType"] === "string" && typeof size === "number" && Number.isSafeInteger(size) && size >= 0 && (sha256Hash === null || sha256Hash === void 0 || typeof sha256Hash === "string");
807
+ }
808
+
809
+ // src/files/index.ts
810
+ var files_exports = /* @__PURE__ */ __exportAll({
811
+ FILES_CLIENT_GRAPHQL_CODES: () => FILES_CLIENT_GRAPHQL_CODES,
812
+ FILE_ACTOR_TYPES: () => FILE_ACTOR_TYPES,
813
+ FILE_REFERENCE_KIND: () => FILE_REFERENCE_KIND,
814
+ FILE_VISIBILITIES: () => FILE_VISIBILITIES,
815
+ FilesClient: () => FilesClient,
816
+ FilesClientError: () => FilesClientError,
817
+ MAX_DOWNLOAD_URL_TTL_SECONDS: () => MAX_DOWNLOAD_URL_TTL_SECONDS,
818
+ MIN_DOWNLOAD_URL_TTL_SECONDS: () => 60,
819
+ clampDownloadUrlTtl: () => clampDownloadUrlTtl,
820
+ classifyFilesErrors: () => classifyFilesErrors,
821
+ fileExtensionOf: () => fileExtensionOf,
822
+ isFileReference: () => isFileReference,
823
+ isFilesClientError: () => isFilesClientError,
824
+ mapFileMetadata: () => mapFileMetadata,
825
+ toFileReference: () => toFileReference,
826
+ toFilesClientError: () => toFilesClientError
827
+ });
828
+
829
+ export { FILE_VISIBILITIES as _, FilesClient as a, clampDownloadUrlTtl as c, FILES_CLIENT_GRAPHQL_CODES as d, FilesClientError as f, FILE_ACTOR_TYPES as g, toFilesClientError as h, toFileReference as i, fileExtensionOf as l, isFilesClientError as m, FILE_REFERENCE_KIND as n, MAX_DOWNLOAD_URL_TTL_SECONDS as o, classifyFilesErrors as p, isFileReference as r, MIN_DOWNLOAD_URL_TTL_SECONDS as s, files_exports as t, mapFileMetadata as u };
830
+ //# sourceMappingURL=files-h5U-D2AF.js.map