@burdenoff/be-sdk 2026.1110.1 → 2026.1110.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (469) hide show
  1. package/configs/eslint/index.js +1 -1
  2. package/configs/tsconfig/tsconfig.json +1 -1
  3. package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
  4. package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
  5. package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
  6. package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
  7. package/dist/ai-credits/index.d.ts +2 -3
  8. package/dist/ai-credits/index.js +3 -4
  9. package/dist/ai-credits/index.js.map +1 -1
  10. package/dist/ai-credits-Ca-NNcVx.js +546 -0
  11. package/dist/ai-credits-Ca-NNcVx.js.map +1 -0
  12. package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
  13. package/dist/auth/index.d.ts +2 -77
  14. package/dist/auth/index.js +3 -7
  15. package/dist/auth/index.js.map +1 -1
  16. package/dist/auth-CEuBEBQN.js +228 -0
  17. package/dist/auth-CEuBEBQN.js.map +1 -0
  18. package/dist/cache/index.d.ts +2 -3
  19. package/dist/cache/index.js +3 -7
  20. package/dist/cache/index.js.map +1 -1
  21. package/dist/cache-CU0uLwcS.js +1837 -0
  22. package/dist/cache-CU0uLwcS.js.map +1 -0
  23. package/dist/captcha/index.d.ts +2 -1
  24. package/dist/captcha/index.js +3 -3
  25. package/dist/captcha/index.js.map +1 -1
  26. package/dist/captcha-BT7yh1YS.js +77 -0
  27. package/dist/captcha-BT7yh1YS.js.map +1 -0
  28. package/dist/client/internal-client.d.ts +4 -7
  29. package/dist/client/internal-client.js +172 -4
  30. package/dist/client/internal-client.js.map +1 -1
  31. package/dist/client-BgAEvDC2.d.ts +86 -0
  32. package/dist/client-DcZ3iGES.js +565 -0
  33. package/dist/client-DcZ3iGES.js.map +1 -0
  34. package/dist/collector-endpoint-iyQYeI50.js +50 -0
  35. package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
  36. package/dist/context-CZnXf2yb.js +247 -0
  37. package/dist/context-CZnXf2yb.js.map +1 -0
  38. package/dist/crypto/index.d.ts +2 -1
  39. package/dist/crypto/index.js +3 -3
  40. package/dist/crypto/index.js.map +1 -1
  41. package/dist/crypto-DO9fM0FO.js +145 -0
  42. package/dist/crypto-DO9fM0FO.js.map +1 -0
  43. package/dist/database/index.d.ts +104 -108
  44. package/dist/database/index.js +468 -6
  45. package/dist/database/index.js.map +1 -1
  46. package/dist/dataloader/index.d.ts +2 -1
  47. package/dist/dataloader/index.js +3 -3
  48. package/dist/dataloader/index.js.map +1 -1
  49. package/dist/dataloader-DwpT3YoS.js +294 -0
  50. package/dist/dataloader-DwpT3YoS.js.map +1 -0
  51. package/dist/deployed-environment-p_Tdl3sT.js +38 -0
  52. package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
  53. package/dist/dist-BGKdXVy3.js +1718 -0
  54. package/dist/dist-BGKdXVy3.js.map +1 -0
  55. package/dist/env-DdaoGjIt.js +74 -0
  56. package/dist/env-DdaoGjIt.js.map +1 -0
  57. package/dist/event-queue/index.d.ts +2 -7
  58. package/dist/event-queue/index.js +7 -9
  59. package/dist/event-queue/index.js.map +1 -1
  60. package/dist/event-queue-Cw-YJPY_.js +1384 -0
  61. package/dist/event-queue-Cw-YJPY_.js.map +1 -0
  62. package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
  63. package/dist/export/index.d.ts +2 -2
  64. package/dist/export/index.js +3 -14
  65. package/dist/export/index.js.map +1 -1
  66. package/dist/export-B6fphx8a.js +642 -0
  67. package/dist/export-B6fphx8a.js.map +1 -0
  68. package/dist/feature-flags/index.d.ts +2 -10
  69. package/dist/feature-flags/index.js +3 -6
  70. package/dist/feature-flags/index.js.map +1 -1
  71. package/dist/feature-flags-71oDkrUe.js +422 -0
  72. package/dist/feature-flags-71oDkrUe.js.map +1 -0
  73. package/dist/files/index.d.ts +2 -3
  74. package/dist/files/index.js +3 -4
  75. package/dist/files/index.js.map +1 -1
  76. package/dist/files-DjH0099H.js +830 -0
  77. package/dist/files-DjH0099H.js.map +1 -0
  78. package/dist/gateway/index.d.ts +4 -6
  79. package/dist/gateway/index.js +7 -13
  80. package/dist/gateway/index.js.map +1 -1
  81. package/dist/gateway/security/index.d.ts +2 -2
  82. package/dist/gateway/security/index.js +3 -5
  83. package/dist/gateway/security/index.js.map +1 -1
  84. package/dist/gateway-DBFmxWks.js +50 -0
  85. package/dist/gateway-DBFmxWks.js.map +1 -0
  86. package/dist/graph/index.d.ts +3 -10
  87. package/dist/graph/index.js +4 -13
  88. package/dist/graph/index.js.map +1 -1
  89. package/dist/graph-DDYgIryR.js +2152 -0
  90. package/dist/graph-DDYgIryR.js.map +1 -0
  91. package/dist/graph-emitter-CdOXP7Tn.js +621 -0
  92. package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
  93. package/dist/graphql/index.d.ts +3 -2
  94. package/dist/graphql/index.js +4 -6
  95. package/dist/graphql/index.js.map +1 -1
  96. package/dist/graphql/services/index.d.ts +2 -24
  97. package/dist/graphql/services/index.js +3 -4
  98. package/dist/graphql/services/index.js.map +1 -1
  99. package/dist/graphql-DHAHHcww.js +161 -0
  100. package/dist/graphql-DHAHHcww.js.map +1 -0
  101. package/dist/graphql-DNkMkGBZ.d.ts +21 -0
  102. package/dist/i18n/index.d.ts +3 -3
  103. package/dist/i18n/index.js +3 -4
  104. package/dist/i18n/index.js.map +1 -1
  105. package/dist/i18n-BBMYFd0P.js +860 -0
  106. package/dist/i18n-BBMYFd0P.js.map +1 -0
  107. package/dist/import-optional-peer-B82VYxeX.js +18 -0
  108. package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
  109. package/dist/index-3KOZ1zN9.d.ts +233 -0
  110. package/dist/index-BBqooJ52.d.ts +45 -0
  111. package/dist/index-BGzMYJsm.d.ts +209 -0
  112. package/dist/index-BKwHQtHQ.d.ts +63 -0
  113. package/dist/index-BMIMnp6T.d.ts +8 -0
  114. package/dist/index-BQDsNAMR.d.ts +81 -0
  115. package/dist/index-BVOL7458.d.ts +10 -0
  116. package/dist/index-BcqQs-Uq.d.ts +69 -0
  117. package/dist/index-BeVtqGO-.d.ts +208 -0
  118. package/dist/index-BiTzGUZP.d.ts +114 -0
  119. package/dist/index-BqYfCQSP.d.ts +500 -0
  120. package/dist/index-C0qLquY0.d.ts +150 -0
  121. package/dist/index-C5uEKchX.d.ts +60 -0
  122. package/dist/index-CDOqxSIi.d.ts +37 -0
  123. package/dist/index-CG6wj66Y.d.ts +148 -0
  124. package/dist/index-CIgoeobA.d.ts +145 -0
  125. package/dist/index-CPQDMSFS.d.ts +103 -0
  126. package/dist/index-CSRcgkVi.d.ts +23 -0
  127. package/dist/index-CZTnQIRU.d.ts +341 -0
  128. package/dist/index-CaM9JUcc.d.ts +144 -0
  129. package/dist/index-CkT2aUr3.d.ts +704 -0
  130. package/dist/index-CliOgq6L.d.ts +203 -0
  131. package/dist/index-CnzbJZP7.d.ts +999 -0
  132. package/dist/index-D6UeLAye.d.ts +63 -0
  133. package/dist/index-DGgh9DWn.d.ts +59 -0
  134. package/dist/index-DY3dNhMN.d.ts +420 -0
  135. package/dist/index-DZC-2o9R.d.ts +207 -0
  136. package/dist/index-DqbGqfAy.d.ts +127 -0
  137. package/dist/index-Dt1HJPTX.d.ts +12 -0
  138. package/dist/index-DtI6aBtB.d.ts +22 -0
  139. package/dist/index-FKohsiex.d.ts +38 -0
  140. package/dist/index-FbXPfen7.d.ts +132 -0
  141. package/dist/index-MArCb8Aq.d.ts +306 -0
  142. package/dist/index-N-huORcj.d.ts +303 -0
  143. package/dist/index-YOShAwkq.d.ts +45 -0
  144. package/dist/index-bZKZUvBu.d.ts +646 -0
  145. package/dist/index-yBSjMY32.d.ts +24 -0
  146. package/dist/index.d.ts +501 -544
  147. package/dist/index.js +1820 -2171
  148. package/dist/index.js.map +1 -1
  149. package/dist/init/index.d.ts +2 -2
  150. package/dist/init/index.js +3 -16
  151. package/dist/init/index.js.map +1 -1
  152. package/dist/init-Dy3KhT6Y.js +325 -0
  153. package/dist/init-Dy3KhT6Y.js.map +1 -0
  154. package/dist/instrumentation/index.d.ts +3 -4
  155. package/dist/instrumentation/index.js +5 -5
  156. package/dist/instrumentation/index.js.map +1 -1
  157. package/dist/instrumentation-xkkmDgJ0.js +1678 -0
  158. package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
  159. package/dist/lake/index.d.ts +50 -54
  160. package/dist/lake/index.js +169 -193
  161. package/dist/lake/index.js.map +1 -1
  162. package/dist/layer/index.d.ts +3 -2
  163. package/dist/layer/index.js +4 -5
  164. package/dist/layer/index.js.map +1 -1
  165. package/dist/layer-BZBZZWeV.d.ts +69 -0
  166. package/dist/layer-Bcix-WCl.js +105 -0
  167. package/dist/layer-Bcix-WCl.js.map +1 -0
  168. package/dist/layer-CEKy6cm8.js +252 -0
  169. package/dist/layer-CEKy6cm8.js.map +1 -0
  170. package/dist/lifecycle/index.d.ts +2 -1
  171. package/dist/lifecycle/index.js +3 -4
  172. package/dist/lifecycle/index.js.map +1 -1
  173. package/dist/lifecycle-DeoLSX0U.js +76 -0
  174. package/dist/lifecycle-DeoLSX0U.js.map +1 -0
  175. package/dist/logger/index.d.ts +2 -3
  176. package/dist/logger/index.js +3 -3
  177. package/dist/logger/index.js.map +1 -1
  178. package/dist/logger-B6rCpb7D.js +290 -0
  179. package/dist/logger-B6rCpb7D.js.map +1 -0
  180. package/dist/metrics/index.d.ts +13 -14
  181. package/dist/metrics/index.js +3 -4
  182. package/dist/metrics/index.js.map +1 -1
  183. package/dist/metrics-BrLwNUrb.js +52 -0
  184. package/dist/metrics-BrLwNUrb.js.map +1 -0
  185. package/dist/metrics-collector-C2eShrlW.js +922 -0
  186. package/dist/metrics-collector-C2eShrlW.js.map +1 -0
  187. package/dist/middleware/index.d.ts +3 -3
  188. package/dist/middleware/index.js +3 -4
  189. package/dist/middleware/index.js.map +1 -1
  190. package/dist/middleware-CUxJVUpD.js +1243 -0
  191. package/dist/middleware-CUxJVUpD.js.map +1 -0
  192. package/dist/middleware-Cq0zFMGp.js +253 -0
  193. package/dist/middleware-Cq0zFMGp.js.map +1 -0
  194. package/dist/notifications/index.d.ts +2 -5
  195. package/dist/notifications/index.js +3 -6
  196. package/dist/notifications/index.js.map +1 -1
  197. package/dist/notifications-CdETrtFK.js +869 -0
  198. package/dist/notifications-CdETrtFK.js.map +1 -0
  199. package/dist/observability/index.d.ts +2 -3
  200. package/dist/observability/index.js +3 -4
  201. package/dist/observability/index.js.map +1 -1
  202. package/dist/observability-DBDXipTU.js +272 -0
  203. package/dist/observability-DBDXipTU.js.map +1 -0
  204. package/dist/platform/index.d.ts +2 -1
  205. package/dist/platform/index.js +3 -5
  206. package/dist/platform/index.js.map +1 -1
  207. package/dist/platform-DZwczW7v.js +1510 -0
  208. package/dist/platform-DZwczW7v.js.map +1 -0
  209. package/dist/prisma/generator/index.d.ts +1 -1
  210. package/dist/prisma/generator/index.js +97 -84
  211. package/dist/prisma/generator/index.js.map +1 -1
  212. package/dist/prisma/index.d.ts +4 -7
  213. package/dist/prisma/index.js +5 -12
  214. package/dist/prisma/index.js.map +1 -1
  215. package/dist/prisma-BzOOdt79.js +863 -0
  216. package/dist/prisma-BzOOdt79.js.map +1 -0
  217. package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
  218. package/dist/product-alias/index.d.ts +2 -1
  219. package/dist/product-alias/index.js +3 -3
  220. package/dist/product-alias/index.js.map +1 -1
  221. package/dist/product-alias-BPqtskMq.js +273 -0
  222. package/dist/product-alias-BPqtskMq.js.map +1 -0
  223. package/dist/rbac/index.d.ts +2 -122
  224. package/dist/rbac/index.js +3 -6
  225. package/dist/rbac/index.js.map +1 -1
  226. package/dist/rbac-BB9l9Xph.js +1486 -0
  227. package/dist/rbac-BB9l9Xph.js.map +1 -0
  228. package/dist/resource-caps/index.d.ts +66 -72
  229. package/dist/resource-caps/index.js +430 -5
  230. package/dist/resource-caps/index.js.map +1 -1
  231. package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
  232. package/dist/sdk-Dju9o-sq.js +124 -0
  233. package/dist/sdk-Dju9o-sq.js.map +1 -0
  234. package/dist/security-DIG-95Ic.js +1647 -0
  235. package/dist/security-DIG-95Ic.js.map +1 -0
  236. package/dist/server/index.d.ts +7 -164
  237. package/dist/server/index.js +2000 -1507
  238. package/dist/server/index.js.map +1 -1
  239. package/dist/service-jwt-Bu-WNA_-.js +80 -0
  240. package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
  241. package/dist/services-BWzfz7vG.js +102 -0
  242. package/dist/services-BWzfz7vG.js.map +1 -0
  243. package/dist/sharding/index.d.ts +41 -44
  244. package/dist/sharding/index.js +156 -137
  245. package/dist/sharding/index.js.map +1 -1
  246. package/dist/sharing/index.d.ts +2 -1
  247. package/dist/sharing/index.js +3 -4
  248. package/dist/sharing/index.js.map +1 -1
  249. package/dist/sharing-CflDsSJ-.js +911 -0
  250. package/dist/sharing-CflDsSJ-.js.map +1 -0
  251. package/dist/stub-BqwKn4eh.js +630 -0
  252. package/dist/stub-BqwKn4eh.js.map +1 -0
  253. package/dist/tags/index.d.ts +2 -3
  254. package/dist/tags/index.js +3 -4
  255. package/dist/tags/index.js.map +1 -1
  256. package/dist/tags-B5xpbgsk.js +868 -0
  257. package/dist/{chunk-PBZFAAOM.js.map → tags-B5xpbgsk.js.map} +1 -1
  258. package/dist/telemetry/index.d.ts +64 -76
  259. package/dist/telemetry/index.js +369 -201
  260. package/dist/telemetry/index.js.map +1 -1
  261. package/dist/temporal/index.d.ts +2 -148
  262. package/dist/temporal/index.js +3 -5
  263. package/dist/temporal/index.js.map +1 -1
  264. package/dist/temporal-B534uYK8.js +706 -0
  265. package/dist/temporal-B534uYK8.js.map +1 -0
  266. package/dist/tracker/index.d.ts +5 -11
  267. package/dist/tracker/index.js +5 -20
  268. package/dist/tracker/index.js.map +1 -1
  269. package/dist/tracker-BQVoEFUo.js +839 -0
  270. package/dist/tracker-BQVoEFUo.js.map +1 -0
  271. package/dist/types-BYMYND1L.js +44 -0
  272. package/dist/types-BYMYND1L.js.map +1 -0
  273. package/dist/types-C6EKaS3V.d.ts +106 -0
  274. package/dist/types-CWybW61E.d.ts +323 -0
  275. package/dist/types-C_yfu3XK.d.ts +34 -0
  276. package/dist/types-Cj2RWXbz.js +90 -0
  277. package/dist/types-Cj2RWXbz.js.map +1 -0
  278. package/dist/types-DgaQqvxo.d.ts +70 -0
  279. package/dist/usage/index.d.ts +2 -213
  280. package/dist/usage/index.js +3 -15
  281. package/dist/usage/index.js.map +1 -1
  282. package/dist/usage-BKFZiWQn.js +682 -0
  283. package/dist/usage-BKFZiWQn.js.map +1 -0
  284. package/dist/utils/index.d.ts +2 -1
  285. package/dist/utils/index.js +3 -3
  286. package/dist/utils/index.js.map +1 -1
  287. package/dist/utils-DL85Tnbn.js +500 -0
  288. package/dist/utils-DL85Tnbn.js.map +1 -0
  289. package/dist/validation/index.d.ts +2 -2
  290. package/dist/validation/index.js +3 -3
  291. package/dist/validation/index.js.map +1 -1
  292. package/dist/validation-CPUITdMk.js +762 -0
  293. package/dist/validation-CPUITdMk.js.map +1 -0
  294. package/dist/workspace-extension-COrC0dYi.js +979 -0
  295. package/dist/workspace-extension-COrC0dYi.js.map +1 -0
  296. package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
  297. package/package.json +7 -10
  298. package/dist/EventQueueFactory-PP534MBQ.js +0 -8
  299. package/dist/EventQueueFactory-PP534MBQ.js.map +0 -1
  300. package/dist/chunk-4XIBXZ6J.js +0 -276
  301. package/dist/chunk-4XIBXZ6J.js.map +0 -1
  302. package/dist/chunk-554Z4C2K.js +0 -1006
  303. package/dist/chunk-554Z4C2K.js.map +0 -1
  304. package/dist/chunk-5CAFHK2Z.js +0 -107
  305. package/dist/chunk-5CAFHK2Z.js.map +0 -1
  306. package/dist/chunk-63ZXJ42X.js +0 -451
  307. package/dist/chunk-63ZXJ42X.js.map +0 -1
  308. package/dist/chunk-6XEXJATV.js +0 -304
  309. package/dist/chunk-6XEXJATV.js.map +0 -1
  310. package/dist/chunk-726AR6Q7.js +0 -1532
  311. package/dist/chunk-726AR6Q7.js.map +0 -1
  312. package/dist/chunk-7EISSMFP.js +0 -617
  313. package/dist/chunk-7EISSMFP.js.map +0 -1
  314. package/dist/chunk-A5F6Z5UE.js +0 -21
  315. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  316. package/dist/chunk-A6DE32ZS.js +0 -1507
  317. package/dist/chunk-A6DE32ZS.js.map +0 -1
  318. package/dist/chunk-BJQOGOVW.js +0 -602
  319. package/dist/chunk-BJQOGOVW.js.map +0 -1
  320. package/dist/chunk-CFXWH2IS.js +0 -52
  321. package/dist/chunk-CFXWH2IS.js.map +0 -1
  322. package/dist/chunk-DIOS6L7M.js +0 -690
  323. package/dist/chunk-DIOS6L7M.js.map +0 -1
  324. package/dist/chunk-DJNHR37J.js +0 -1185
  325. package/dist/chunk-DJNHR37J.js.map +0 -1
  326. package/dist/chunk-DRWH5XCJ.js +0 -876
  327. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  328. package/dist/chunk-E4QNLVY4.js +0 -909
  329. package/dist/chunk-E4QNLVY4.js.map +0 -1
  330. package/dist/chunk-E6OAFS7A.js +0 -1346
  331. package/dist/chunk-E6OAFS7A.js.map +0 -1
  332. package/dist/chunk-EBDHIL7V.js +0 -774
  333. package/dist/chunk-EBDHIL7V.js.map +0 -1
  334. package/dist/chunk-ELU7VL3E.js +0 -245
  335. package/dist/chunk-ELU7VL3E.js.map +0 -1
  336. package/dist/chunk-FZRODKIN.js +0 -31
  337. package/dist/chunk-FZRODKIN.js.map +0 -1
  338. package/dist/chunk-GCIB76AJ.js +0 -882
  339. package/dist/chunk-GCIB76AJ.js.map +0 -1
  340. package/dist/chunk-HC6MPUIH.js +0 -1571
  341. package/dist/chunk-HC6MPUIH.js.map +0 -1
  342. package/dist/chunk-I3KOWRT3.js +0 -89
  343. package/dist/chunk-I3KOWRT3.js.map +0 -1
  344. package/dist/chunk-ID3WR4JS.js +0 -509
  345. package/dist/chunk-ID3WR4JS.js.map +0 -1
  346. package/dist/chunk-JVMAQOA3.js +0 -521
  347. package/dist/chunk-JVMAQOA3.js.map +0 -1
  348. package/dist/chunk-K56L7NUR.js +0 -1444
  349. package/dist/chunk-K56L7NUR.js.map +0 -1
  350. package/dist/chunk-KH4TRQCO.js +0 -1063
  351. package/dist/chunk-KH4TRQCO.js.map +0 -1
  352. package/dist/chunk-KJOSPVB2.js +0 -57
  353. package/dist/chunk-KJOSPVB2.js.map +0 -1
  354. package/dist/chunk-KO2ZXZ7W.js +0 -61
  355. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  356. package/dist/chunk-KS2HQCJR.js +0 -56
  357. package/dist/chunk-KS2HQCJR.js.map +0 -1
  358. package/dist/chunk-LA5KPWZ2.js +0 -413
  359. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  360. package/dist/chunk-MESLAC5W.js +0 -574
  361. package/dist/chunk-MESLAC5W.js.map +0 -1
  362. package/dist/chunk-MWPYA2HD.js +0 -94
  363. package/dist/chunk-MWPYA2HD.js.map +0 -1
  364. package/dist/chunk-NUB5GQTU.js +0 -270
  365. package/dist/chunk-NUB5GQTU.js.map +0 -1
  366. package/dist/chunk-O2JMZHNH.js +0 -1908
  367. package/dist/chunk-O2JMZHNH.js.map +0 -1
  368. package/dist/chunk-OBBCR6WY.js +0 -277
  369. package/dist/chunk-OBBCR6WY.js.map +0 -1
  370. package/dist/chunk-OBZQ4AJC.js +0 -272
  371. package/dist/chunk-OBZQ4AJC.js.map +0 -1
  372. package/dist/chunk-OXNCBE7P.js +0 -971
  373. package/dist/chunk-OXNCBE7P.js.map +0 -1
  374. package/dist/chunk-PBZFAAOM.js +0 -941
  375. package/dist/chunk-PYD44IHJ.js +0 -728
  376. package/dist/chunk-PYD44IHJ.js.map +0 -1
  377. package/dist/chunk-QVPIACWD.js +0 -679
  378. package/dist/chunk-QVPIACWD.js.map +0 -1
  379. package/dist/chunk-QWNNFE4P.js +0 -41
  380. package/dist/chunk-QWNNFE4P.js.map +0 -1
  381. package/dist/chunk-RU266375.js +0 -327
  382. package/dist/chunk-RU266375.js.map +0 -1
  383. package/dist/chunk-RYTSVGGA.js +0 -1624
  384. package/dist/chunk-RYTSVGGA.js.map +0 -1
  385. package/dist/chunk-RZOFS2BQ.js +0 -225
  386. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  387. package/dist/chunk-SBS4S2PJ.js +0 -100
  388. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  389. package/dist/chunk-SPRG6G6G.js +0 -530
  390. package/dist/chunk-SPRG6G6G.js.map +0 -1
  391. package/dist/chunk-STWFX5E2.js +0 -233
  392. package/dist/chunk-STWFX5E2.js.map +0 -1
  393. package/dist/chunk-UNASM5VJ.js +0 -419
  394. package/dist/chunk-UNASM5VJ.js.map +0 -1
  395. package/dist/chunk-VAT66FJA.js +0 -245
  396. package/dist/chunk-VAT66FJA.js.map +0 -1
  397. package/dist/chunk-VFCMR5GX.js +0 -49
  398. package/dist/chunk-VFCMR5GX.js.map +0 -1
  399. package/dist/chunk-VGAHZKNJ.js +0 -66
  400. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  401. package/dist/chunk-VTJTAAXC.js +0 -627
  402. package/dist/chunk-VTJTAAXC.js.map +0 -1
  403. package/dist/chunk-VXVLKRU6.js +0 -758
  404. package/dist/chunk-VXVLKRU6.js.map +0 -1
  405. package/dist/chunk-WWUU5ETI.js +0 -163
  406. package/dist/chunk-WWUU5ETI.js.map +0 -1
  407. package/dist/chunk-XE4OXN2W.js +0 -10
  408. package/dist/chunk-XE4OXN2W.js.map +0 -1
  409. package/dist/chunk-XOJORS75.js +0 -1853
  410. package/dist/chunk-XOJORS75.js.map +0 -1
  411. package/dist/chunk-YMZEUTD2.js +0 -110
  412. package/dist/chunk-YMZEUTD2.js.map +0 -1
  413. package/dist/chunk-ZZK3WEDI.js +0 -181
  414. package/dist/chunk-ZZK3WEDI.js.map +0 -1
  415. package/dist/client-CCXpAZ2r.d.ts +0 -89
  416. package/dist/client-DSI_760t.d.ts +0 -36
  417. package/dist/client-JU6T3UPB.js +0 -11
  418. package/dist/client-JU6T3UPB.js.map +0 -1
  419. package/dist/dist-2X4Q7PJA.js +0 -1491
  420. package/dist/dist-2X4Q7PJA.js.map +0 -1
  421. package/dist/env-4UWSUS64.js +0 -4
  422. package/dist/env-4UWSUS64.js.map +0 -1
  423. package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
  424. package/dist/graphql-CMHMQjvd.d.ts +0 -23
  425. package/dist/i18n-Qm2AkPC-.d.ts +0 -33
  426. package/dist/index--yvpa6ay.d.ts +0 -83
  427. package/dist/index-4gKQKZ2B.d.ts +0 -71
  428. package/dist/index-5x0XMKXN.d.ts +0 -149
  429. package/dist/index-B70b5mYS.d.ts +0 -33
  430. package/dist/index-B8KrxO4j.d.ts +0 -755
  431. package/dist/index-BOuDKnqD.d.ts +0 -201
  432. package/dist/index-BTMt4OjA.d.ts +0 -201
  433. package/dist/index-BejbszA7.d.ts +0 -39
  434. package/dist/index-BkeOYZye.d.ts +0 -198
  435. package/dist/index-BuAj5nXg.d.ts +0 -83
  436. package/dist/index-BvkVcW8I.d.ts +0 -349
  437. package/dist/index-CWmH_-RZ.d.ts +0 -247
  438. package/dist/index-CbgWNcus.d.ts +0 -258
  439. package/dist/index-CmfPeQza.d.ts +0 -166
  440. package/dist/index-CmpG-zak.d.ts +0 -607
  441. package/dist/index-CoMKgL-p.d.ts +0 -12
  442. package/dist/index-D8HGwglK.d.ts +0 -541
  443. package/dist/index-DCaVm66D.d.ts +0 -1101
  444. package/dist/index-DE2w7E0d.d.ts +0 -83
  445. package/dist/index-DSOpj8DI.d.ts +0 -17
  446. package/dist/index-DW9q22GH.d.ts +0 -75
  447. package/dist/index-DnjJ9CwI.d.ts +0 -347
  448. package/dist/index-DwMJZ8PP.d.ts +0 -317
  449. package/dist/index-PaojfSdd.d.ts +0 -71
  450. package/dist/index-aHtYvc3i.d.ts +0 -284
  451. package/dist/index-e_18DzAg.d.ts +0 -18
  452. package/dist/index-ffmipXSA.d.ts +0 -55
  453. package/dist/index-joONjwLt.d.ts +0 -33
  454. package/dist/index-kssw5ziY.d.ts +0 -250
  455. package/dist/index-lFffh5-G.d.ts +0 -125
  456. package/dist/index-pxYge_6k.d.ts +0 -79
  457. package/dist/layer-Cv9vSwBx.d.ts +0 -70
  458. package/dist/pino-logger-H4HPW5P6.js +0 -5
  459. package/dist/pino-logger-H4HPW5P6.js.map +0 -1
  460. package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
  461. package/dist/sdk-L75WWUP3.js +0 -156
  462. package/dist/sdk-L75WWUP3.js.map +0 -1
  463. package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
  464. package/dist/types-Bo2wkjSP.d.ts +0 -35
  465. package/dist/types-DVpvrAhd.d.ts +0 -71
  466. package/dist/types-DgJ4lDYA.d.ts +0 -108
  467. package/dist/types-USOv09qy.d.ts +0 -327
  468. package/dist/workspace-guard-NXVYYBVJ.js +0 -5
  469. package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"internal-client.js"}
1
+ {"version":3,"file":"internal-client.js","names":[],"sources":["../../src/client/internal-client.ts"],"sourcesContent":["/**\n * Internal Client for Service-to-Service Communication\n *\n * This module provides helper functions to create GraphQL clients for internal\n * service-to-service calls with automatic RBAC bypass.\n *\n * Features:\n * - Automatic injection of bypass headers (x-bypass-permission, x-service-identity)\n * - Pre-configured for workspaces and tenant gateways\n * - Environment variable validation\n *\n * ⚠️ IMPORTANT: Header Transformation Architecture\n * ================================================\n * This client sends headers to the INTERNAL API GATEWAY, which transforms them\n * before forwarding to downstream services with RBAC directives.\n *\n * Header Flow:\n * 1. This client → Gateway: x-bypass-permission, x-service-identity, x-call-type\n * 2. Gateway → Service: x-rbac-bypass, x-bypass-source, x-bypass-timestamp\n *\n * The headers sent by this client DO NOT match the headers expected by the RBAC\n * directive (src/rbac/directive.ts). This is INTENTIONAL - the gateway handles\n * the transformation as part of the security architecture.\n *\n * @module client/internal-client\n * @example\n * ```typescript\n * import { createInternalClient } from '@burdenoff/be-sdk/client/internal';\n *\n * const client = createInternalClient(\n * 'http://localhost:4001/workspaces/graphql',\n * 'scheduler-service'\n * );\n *\n * const result = await client.request(`\n * mutation {\n * createProject(input: { name: \"Test\" }) {\n * id\n * }\n * }\n * `);\n * ```\n */\n\nimport { GraphQLClient } from 'graphql-request';\nimport { logger } from '../logger/index.js';\n\n/**\n * Create GraphQL client for internal service-to-service calls\n *\n * This client automatically injects bypass headers for RBAC bypass:\n * - x-bypass-permission: Internal service token (from env)\n * - x-service-identity: Service identifier\n * - x-call-type: \"internal\"\n *\n * IMPORTANT: This should ONLY be used for internal service-to-service calls,\n * never for user-initiated requests.\n *\n * @param serviceUrl - GraphQL endpoint URL (e.g., 'http://localhost:4001/workspaces/graphql')\n * @param serviceIdentity - Service identifier (e.g., 'scheduler-service')\n * @param additionalHeaders - Optional additional headers to include\n * @returns Configured GraphQL client with bypass headers\n * @throws Error if INTERNAL_SERVICE_TOKEN is not configured\n *\n * @example\n * ```typescript\n * const client = createInternalClient(\n * process.env.WORKSPACES_GATEWAY_URL,\n * 'scheduler-service'\n * );\n *\n * const result = await client.request(`\n * query {\n * workspace(id: \"ws123\") {\n * id\n * name\n * }\n * }\n * `);\n * ```\n */\nexport function createInternalClient(\n serviceUrl: string,\n serviceIdentity: string,\n additionalHeaders?: Record<string, string>\n): GraphQLClient {\n const INTERNAL_TOKEN = process.env['INTERNAL_SERVICE_TOKEN'];\n\n if (!INTERNAL_TOKEN) {\n const error = new Error(\n 'INTERNAL_SERVICE_TOKEN environment variable is not configured. ' +\n 'This is required for internal service-to-service communication with RBAC bypass.'\n );\n logger.error('[Internal Client] Missing INTERNAL_SERVICE_TOKEN', {\n serviceIdentity,\n serviceUrl,\n });\n throw error;\n }\n\n if (!serviceIdentity || serviceIdentity.trim().length === 0) {\n throw new Error('serviceIdentity is required and cannot be empty');\n }\n\n if (!serviceUrl || serviceUrl.trim().length === 0) {\n throw new Error('serviceUrl is required and cannot be empty');\n }\n\n logger.debug('[Internal Client] Creating internal client', {\n serviceUrl,\n serviceIdentity,\n });\n\n // ⚠️ ARCHITECTURE NOTE: Header Transformation Flow\n // ================================================\n // These headers are sent to the INTERNAL API GATEWAY, NOT directly to downstream services.\n //\n // Flow:\n // 1. Service A (this client) → Internal API Gateway\n // Headers: x-bypass-permission, x-service-identity, x-call-type\n //\n // 2. Internal API Gateway → Service B (with RBAC directive)\n // Headers transformed to: x-rbac-bypass, x-bypass-source, x-bypass-timestamp\n //\n // The RBAC directive (src/rbac/directive.ts:472-474) expects the TRANSFORMED headers,\n // not these original headers. This is intentional and part of the security architecture.\n //\n // DO NOT \"fix\" this to match RBAC directive headers - the gateway handles the transformation.\n const headers: Record<string, string> = {\n 'x-bypass-permission': INTERNAL_TOKEN,\n 'x-service-identity': serviceIdentity,\n 'x-call-type': 'internal',\n ...additionalHeaders,\n };\n\n return new GraphQLClient(serviceUrl, { headers });\n}\n\n/**\n * Create GraphQL client for Workspaces Gateway (internal)\n *\n * Convenience wrapper for createInternalClient that uses WORKSPACES_GATEWAY_URL\n * from environment variables.\n *\n * @param serviceIdentity - Service identifier (e.g., 'scheduler-service')\n * @param additionalHeaders - Optional additional headers\n * @returns Configured GraphQL client\n * @throws Error if WORKSPACES_GATEWAY_URL or INTERNAL_SERVICE_TOKEN not configured\n *\n * @example\n * ```typescript\n * const client = createInternalClientForWorkspaces('scheduler-service');\n *\n * const result = await client.request(`\n * mutation {\n * generateReport(workspaceId: \"ws123\") {\n * id\n * }\n * }\n * `);\n * ```\n */\nexport function createInternalClientForWorkspaces(\n serviceIdentity: string,\n additionalHeaders?: Record<string, string>\n): GraphQLClient {\n const WORKSPACES_GATEWAY_URL = process.env['WORKSPACES_GATEWAY_URL'] || 'http://localhost:4001/workspaces/graphql';\n\n logger.debug('[Internal Client] Creating Workspaces client', {\n serviceIdentity,\n gatewayUrl: WORKSPACES_GATEWAY_URL,\n });\n\n return createInternalClient(WORKSPACES_GATEWAY_URL, serviceIdentity, additionalHeaders);\n}\n\n/**\n * Create GraphQL client for Tenant Gateway (internal)\n *\n * Convenience wrapper for createInternalClient that uses TENANT_GATEWAY_URL\n * from environment variables.\n *\n * @param serviceIdentity - Service identifier (e.g., 'notification-dispatcher')\n * @param additionalHeaders - Optional additional headers\n * @returns Configured GraphQL client\n * @throws Error if TENANT_GATEWAY_URL or INTERNAL_SERVICE_TOKEN not configured\n *\n * @example\n * ```typescript\n * const client = createInternalClientForTenant('notification-dispatcher');\n *\n * const result = await client.request(`\n * query {\n * notifications(workspaceId: \"ws123\") {\n * id\n * type\n * }\n * }\n * `);\n * ```\n */\nexport function createInternalClientForTenant(\n serviceIdentity: string,\n additionalHeaders?: Record<string, string>\n): GraphQLClient {\n const TENANT_GATEWAY_URL = process.env['TENANT_GATEWAY_URL'] || 'http://localhost:4002/tenant/graphql';\n\n logger.debug('[Internal Client] Creating Tenant client', {\n serviceIdentity,\n gatewayUrl: TENANT_GATEWAY_URL,\n });\n\n return createInternalClient(TENANT_GATEWAY_URL, serviceIdentity, additionalHeaders);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,SAAgB,qBACd,YACA,iBACA,mBACe;CACf,MAAM,iBAAiB,QAAQ,IAAI;CAEnC,IAAI,CAAC,gBAAgB;EACnB,MAAM,wBAAQ,IAAI,MAChB,iJAEF;EACA,OAAO,MAAM,oDAAoD;GAC/D;GACA;EACF,CAAC;EACD,MAAM;CACR;CAEA,IAAI,CAAC,mBAAmB,gBAAgB,KAAK,CAAC,CAAC,WAAW,GACxD,MAAM,IAAI,MAAM,iDAAiD;CAGnE,IAAI,CAAC,cAAc,WAAW,KAAK,CAAC,CAAC,WAAW,GAC9C,MAAM,IAAI,MAAM,4CAA4C;CAG9D,OAAO,MAAM,8CAA8C;EACzD;EACA;CACF,CAAC;CAiBD,MAAM,UAAkC;EACtC,uBAAuB;EACvB,sBAAsB;EACtB,eAAe;EACf,GAAG;CACL;CAEA,OAAO,IAAI,cAAc,YAAY,EAAE,QAAQ,CAAC;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,kCACd,iBACA,mBACe;CACf,MAAM,yBAAyB,QAAQ,IAAI,6BAA6B;CAExE,OAAO,MAAM,gDAAgD;EAC3D;EACA,YAAY;CACd,CAAC;CAED,OAAO,qBAAqB,wBAAwB,iBAAiB,iBAAiB;AACxF;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,8BACd,iBACA,mBACe;CACf,MAAM,qBAAqB,QAAQ,IAAI,yBAAyB;CAEhE,OAAO,MAAM,4CAA4C;EACvD;EACA,YAAY;CACd,CAAC;CAED,OAAO,qBAAqB,oBAAoB,iBAAiB,iBAAiB;AACpF"}
@@ -0,0 +1,86 @@
1
+ import { PrismaPg } from "@prisma/adapter-pg";
2
+ import { Pool } from "pg";
3
+ interface PrismaClientConfig {
4
+ databaseUrl: string;
5
+ maxConnections?: number;
6
+ idleTimeoutMillis?: number;
7
+ connectionTimeoutMillis?: number;
8
+ applicationName?: string;
9
+ queryTimeoutMillis?: number;
10
+ statementTimeoutMillis?: number;
11
+ idleInTransactionTimeoutMillis?: number;
12
+ lockTimeoutMillis?: number;
13
+ enableQueryLogging?: boolean;
14
+ slowQueryThreshold?: number;
15
+ logLevels?: Array<'query' | 'info' | 'warn' | 'error'>;
16
+ keepWarm?: boolean;
17
+ warmupIntervalMillis?: number;
18
+ acquireRetries?: number;
19
+ acquireRetryDelayMillis?: number;
20
+ }
21
+ interface DatabaseHealth {
22
+ healthy: boolean;
23
+ latency?: number;
24
+ error?: string;
25
+ }
26
+ interface ConnectionState {
27
+ isConnected: boolean;
28
+ attempts: number;
29
+ lastError?: string;
30
+ lastConnectedAt?: Date;
31
+ }
32
+ interface PrismaQueryEvent {
33
+ query: string;
34
+ params: string;
35
+ duration: number;
36
+ target?: string;
37
+ }
38
+ interface PrismaLogEvent {
39
+ message: string;
40
+ target?: string;
41
+ }
42
+ type PrismaEvent = PrismaQueryEvent | PrismaLogEvent;
43
+ interface PrismaTransactionOptions {
44
+ maxWait?: number;
45
+ timeout?: number;
46
+ isolationLevel?: string;
47
+ }
48
+ interface PrismaClientBase {
49
+ $connect(): Promise<void>;
50
+ $disconnect(): Promise<void>;
51
+ $on(event: string, callback: (e: PrismaEvent) => void): void;
52
+ $queryRaw<T = unknown>(query: TemplateStringsArray, ...values: unknown[]): Promise<T>;
53
+ }
54
+ type DatabaseReturnType<T extends PrismaClientBase = PrismaClientBase> = T & {
55
+ client: T;
56
+ };
57
+ declare function createConnectionPool(config: PrismaClientConfig): Pool;
58
+ declare function isTransientAcquireError(error: unknown): boolean;
59
+ declare function installAcquireRetry(pool: Pool, retries: number, baseDelayMillis: number): void;
60
+ declare function ensureServiceApplicationName(productName: string | undefined): void;
61
+ declare function createPrismaAdapter(pool: Pool): PrismaPg;
62
+ declare function configurePrismaLogging<T extends PrismaClientBase>(client: T, config: PrismaClientConfig): T;
63
+ declare class PrismaClientWrapper<T extends PrismaClientBase> {
64
+ private client;
65
+ private pool;
66
+ private connectionState;
67
+ private isDisconnecting;
68
+ constructor(client: T, pool: Pool, config: PrismaClientConfig);
69
+ getClient(): T;
70
+ getPool(): Pool;
71
+ getConnectionState(): ConnectionState;
72
+ connect(retries?: number, delay?: number): Promise<void>;
73
+ disconnect(): Promise<void>;
74
+ registerShutdownHandlers(): void;
75
+ }
76
+ type PrismaLogLevel = 'info' | 'query' | 'warn' | 'error';
77
+ interface PrismaLogDefinition {
78
+ level: PrismaLogLevel;
79
+ emit: 'stdout' | 'event';
80
+ }
81
+ interface PrismaClientConstructorOptions {
82
+ adapter: PrismaPg;
83
+ log?: (PrismaLogLevel | PrismaLogDefinition)[];
84
+ }
85
+ declare function createPrismaClient<T extends PrismaClientBase>(PrismaClientConstructor: new (options: PrismaClientConstructorOptions) => T, config: PrismaClientConfig): PrismaClientWrapper<T>;
86
+ export { isTransientAcquireError as _, PrismaEvent as a, PrismaClientConfig as b, PrismaLogLevel as c, configurePrismaLogging as d, createConnectionPool as f, installAcquireRetry as g, ensureServiceApplicationName as h, PrismaClientWrapper as i, PrismaQueryEvent as l, createPrismaClient as m, PrismaClientBase as n, PrismaLogDefinition as o, createPrismaAdapter as p, PrismaClientConstructorOptions as r, PrismaLogEvent as s, DatabaseReturnType as t, PrismaTransactionOptions as u, ConnectionState as v, DatabaseHealth as y };
@@ -0,0 +1,565 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-ad2WFvuA.js";
2
+ import { t as ContextManager } from "./context-CZnXf2yb.js";
3
+ import { t as LayerManager } from "./layer-CEKy6cm8.js";
4
+ import { a as logger } from "./logger-B6rCpb7D.js";
5
+ import { t as signServiceJwt } from "./service-jwt-Bu-WNA_-.js";
6
+ import { n as currentEnvironment, r as isDeployedEnvironment } from "./deployed-environment-p_Tdl3sT.js";
7
+ import { n as DEFAULT_GATEWAY_RETRY_CONFIG, t as DEFAULT_CIRCUIT_BREAKER_CONFIG } from "./layer-Bcix-WCl.js";
8
+ import { n as GatewayError, r as GatewayErrorType, t as CircuitState } from "./types-BYMYND1L.js";
9
+
10
+ // src/gateway/service-jwt-guard.ts
11
+ /**
12
+ * Cross-layer service-JWT configuration guard.
13
+ *
14
+ * A cross-layer call transits the peer layer's PUBLIC gateway, which propagates
15
+ * `x-actor-*` context to subgraphs only when the request carries a valid JWT.
16
+ * Without one the gateway strips those headers as potential client spoofing and
17
+ * the subgraph rejects the call. So on a cross-layer request with no
18
+ * Authorization header and no mintable service JWT, the outcome is already
19
+ * decided before the request leaves the process: it will fail, downstream, with
20
+ * an authentication error that names the callee rather than the missing secret.
21
+ *
22
+ * That is a bad trade in a deployed environment. It converts a one-line config
23
+ * problem into an opaque failure attributed to the wrong service, and — because
24
+ * several cross-layer callers treat these calls as best-effort and swallow the
25
+ * error — into no visible failure at all. Alpha ran exactly that way: 414 calls
26
+ * in 24h on `AddWorkspaceMemberFromWspace` and `WorkspaceOrganization`, every
27
+ * one rejected, workspace-member mirroring silently not happening, and nothing
28
+ * in the caller's logs above debug level.
29
+ *
30
+ * So in alpha, staging and production this throws before the request is sent,
31
+ * naming the secret and the bundle to fix. Locally it stays a log: a laptop
32
+ * calling across layers without a service JWT is a normal state while a
33
+ * developer is mid-setup, and failing their `bun run dev` would be hostile.
34
+ *
35
+ * Verified inert before shipping, the same way the cache guard was: of the
36
+ * alpha and prod service bundles in Secrets Manager, every be-sdk service that
37
+ * makes cross-layer calls already carries `SERVICE_JWT_SECRET` (166 bundles).
38
+ * The bundles without it are Temporal, OPA, the OTel collectors, NATS, Gatus,
39
+ * the vibetunnels pair, the ai-assistant trio, the dormant `*-community`
40
+ * deployments and the retired `state-archive-*` configs — none of which
41
+ * constructs a GatewayClient or makes a cross-layer call. Nothing changes
42
+ * today; this only catches the next caller rolled out without the secret.
43
+ */
44
+ /** Env var that must hold the signing key for service-actor JWTs. */
45
+ const SERVICE_JWT_SECRET_ENV = "SERVICE_JWT_SECRET";
46
+ /**
47
+ * Build the operator-facing explanation. Exported so the message itself is
48
+ * covered by tests — a guard whose text does not say what to change just moves
49
+ * the debugging, it does not remove it.
50
+ */
51
+ function serviceJwtMisconfigurationMessage(context) {
52
+ const environment = currentEnvironment() || "unset";
53
+ const layer = context.layer ?? "{layer}";
54
+ const operation = context.operationName ? ` (operation ${context.operationName})` : "";
55
+ const identity = context.serviceIdentity ? ` as '${context.serviceIdentity}'` : "";
56
+ return `[GatewayClient] Cross-layer call to ${context.gatewayUrl}${operation} cannot be authenticated${identity}: ${SERVICE_JWT_SECRET_ENV} is not set, so no service JWT can be minted. The peer layer's public gateway will strip actor headers and the subgraph will reject the request, so this call cannot succeed. Refusing to send it with DEPLOY_ENV=${environment}. Set ${SERVICE_JWT_SECRET_ENV} in boff/${environment}/${layer}/{module} — it must match the value the peer layer's gateway verifies with, which is per-environment and must never be copied across environments.`;
57
+ }
58
+ /**
59
+ * Throw in a deployed environment when a cross-layer call is about to be sent
60
+ * with no way to authenticate it. Returns normally everywhere else, and
61
+ * whenever a JWT was available — so this costs nothing on the happy path.
62
+ */
63
+ function assertServiceJwtConfigured(context) {
64
+ if (!isDeployedEnvironment()) return;
65
+ throw new Error(serviceJwtMisconfigurationMessage(context));
66
+ }
67
+
68
+ // src/gateway/client.ts
69
+ /**
70
+ * Unified Gateway Client
71
+ *
72
+ * Provides a layer-aware GraphQL client with circuit breaker,
73
+ * retry logic, and automatic header management for M2M communication.
74
+ *
75
+ * @module gateway/client
76
+ * @category Gateway
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * import { GatewayClient } from '@burdenoff/be-sdk/gateway';
81
+ *
82
+ * const client = new GatewayClient({
83
+ * layer: 'wspace',
84
+ * serviceName: 'wspace-tags-svc',
85
+ * });
86
+ *
87
+ * // Internal call (same layer)
88
+ * const result = await client.internalQuery({
89
+ * query: `query { getTag(id: "123") { id name } }`,
90
+ * });
91
+ *
92
+ * // Cross-layer call
93
+ * const authResult = await client.crossLayerQuery({
94
+ * query: `query { getCurrentUser { id email } }`,
95
+ * });
96
+ * ```
97
+ */
98
+ var client_exports = /* @__PURE__ */ __exportAll({
99
+ GatewayClient: () => GatewayClient,
100
+ createGatewayClientFromEnv: () => createGatewayClientFromEnv
101
+ });
102
+ const uuidv4 = () => crypto.randomUUID();
103
+ /**
104
+ * Case-insensitive presence check for the `Authorization` header. HTTP header
105
+ * names are case-insensitive (RFC 7230), and while the outbound `fetch` will
106
+ * preserve whatever casing the caller supplies, callers may legitimately set
107
+ * `authorization` / `Authorization` / even `AUTHORIZATION` via defaultHeaders
108
+ * or options.headers. We must not overwrite an already-supplied token.
109
+ */
110
+ function hasAuthorizationHeader(headers) {
111
+ for (const key of Object.keys(headers)) if (key.toLowerCase() === "authorization") return true;
112
+ return false;
113
+ }
114
+ function isGraphQLError(value) {
115
+ return value !== null && typeof value === "object" && "message" in value && typeof value.message === "string" && (!("extensions" in value) || value.extensions !== null && typeof value.extensions === "object" && !Array.isArray(value.extensions));
116
+ }
117
+ /**
118
+ * HTTP statuses in the 4xx range that describe a transient condition rather than
119
+ * a problem with the request itself: the request timed out at the peer (408) or
120
+ * the peer is shedding load (429 without a GraphQL body, i.e. an edge or proxy
121
+ * limit). Those stay retryable and still count toward the circuit breaker.
122
+ */
123
+ const TRANSIENT_CLIENT_STATUSES = /* @__PURE__ */ new Set([408, 429]);
124
+ /**
125
+ * Is this failure a definitive answer about the request rather than a sign that
126
+ * the gateway or the transport is unhealthy?
127
+ *
128
+ * True for:
129
+ * - `GRAPHQL_ERROR`: the gateway executed the operation and answered with
130
+ * GraphQL errors (for example `NOT_FOUND`, `BAD_USER_INPUT`, `FORBIDDEN`),
131
+ * whether that arrived with HTTP 200 or with a 4xx status;
132
+ * - an HTTP 4xx without a GraphQL body (for example an edge 403 or 404), except
133
+ * the transient statuses 408 and 429.
134
+ *
135
+ * Such failures are never retried (the same request gets the same answer) and
136
+ * are not counted toward the circuit breaker: a burst of legitimate "not found"
137
+ * lookups must not open the circuit for every other call the service makes.
138
+ *
139
+ * @param error - Anything thrown by a GatewayClient call
140
+ * @returns Whether the error is a client error in the sense above
141
+ */
142
+ function isGatewayClientError(error) {
143
+ if (!(error instanceof GatewayError)) return false;
144
+ if (error.type === "GRAPHQL_ERROR") return true;
145
+ if (error.type !== "NETWORK_ERROR" || error.statusCode === void 0) return false;
146
+ return error.statusCode >= 400 && error.statusCode < 500 && !TRANSIENT_CLIENT_STATUSES.has(error.statusCode);
147
+ }
148
+ function resolveBypassPermissionValue(token = process.env["INTERNAL_SERVICE_TOKEN"]) {
149
+ const normalizedToken = token?.trim();
150
+ if (!normalizedToken) throw new Error("INTERNAL_SERVICE_TOKEN must be configured for bypass-enabled gateway calls");
151
+ return normalizedToken;
152
+ }
153
+ /**
154
+ * Circuit Breaker Implementation
155
+ */
156
+ var CircuitBreaker = class {
157
+ state = "CLOSED";
158
+ failures = 0;
159
+ successes = 0;
160
+ consecutiveFailures = 0;
161
+ lastFailureTime = null;
162
+ lastSuccessTime = null;
163
+ openedAt = null;
164
+ failureTimestamps = [];
165
+ config;
166
+ constructor(config) {
167
+ this.config = config;
168
+ }
169
+ getState() {
170
+ this.checkStateTransition();
171
+ return this.state;
172
+ }
173
+ recordSuccess() {
174
+ this.successes++;
175
+ this.consecutiveFailures = 0;
176
+ this.lastSuccessTime = Date.now();
177
+ if (this.state === "HALF_OPEN") {
178
+ this.state = "CLOSED";
179
+ this.failures = 0;
180
+ this.failureTimestamps = [];
181
+ this.openedAt = null;
182
+ logger.info("[CircuitBreaker] Circuit closed after successful test");
183
+ }
184
+ }
185
+ recordFailure() {
186
+ this.failures++;
187
+ this.consecutiveFailures++;
188
+ this.lastFailureTime = Date.now();
189
+ this.failureTimestamps.push(Date.now());
190
+ const windowStart = Date.now() - this.config.failureWindow;
191
+ this.failureTimestamps = this.failureTimestamps.filter((t) => t > windowStart);
192
+ if (this.state === "CLOSED" && this.failureTimestamps.length >= this.config.failureThreshold) {
193
+ this.state = "OPEN";
194
+ this.openedAt = Date.now();
195
+ logger.warn("[CircuitBreaker] Circuit opened due to failures", {
196
+ failures: this.failureTimestamps.length,
197
+ threshold: this.config.failureThreshold
198
+ });
199
+ }
200
+ if (this.state === "HALF_OPEN") {
201
+ this.state = "OPEN";
202
+ this.openedAt = Date.now();
203
+ logger.warn("[CircuitBreaker] Circuit re-opened after failed test");
204
+ }
205
+ }
206
+ allowRequest() {
207
+ this.checkStateTransition();
208
+ switch (this.state) {
209
+ case "CLOSED": return true;
210
+ case "OPEN": return false;
211
+ case "HALF_OPEN": return true;
212
+ default: return true;
213
+ }
214
+ }
215
+ forceOpen() {
216
+ this.state = "OPEN";
217
+ this.openedAt = Date.now();
218
+ logger.info("[CircuitBreaker] Circuit force-opened");
219
+ }
220
+ forceClose() {
221
+ this.state = "CLOSED";
222
+ this.failures = 0;
223
+ this.consecutiveFailures = 0;
224
+ this.failureTimestamps = [];
225
+ this.openedAt = null;
226
+ logger.info("[CircuitBreaker] Circuit force-closed");
227
+ }
228
+ getStats() {
229
+ return {
230
+ state: this.state,
231
+ failures: this.failures,
232
+ successes: this.successes,
233
+ consecutiveFailures: this.consecutiveFailures,
234
+ lastFailureTime: this.lastFailureTime,
235
+ lastSuccessTime: this.lastSuccessTime,
236
+ openedAt: this.openedAt
237
+ };
238
+ }
239
+ checkStateTransition() {
240
+ if (this.state === "OPEN" && this.openedAt) {
241
+ if (Date.now() - this.openedAt >= this.config.resetTimeout) {
242
+ this.state = "HALF_OPEN";
243
+ logger.info("[CircuitBreaker] Circuit transitioning to half-open");
244
+ }
245
+ }
246
+ }
247
+ };
248
+ /**
249
+ * Unified Gateway Client
250
+ */
251
+ var GatewayClient = class {
252
+ config;
253
+ layerManager;
254
+ internalCircuitBreaker;
255
+ crossLayerCircuitBreaker;
256
+ retryConfig;
257
+ defaultHeaders;
258
+ constructor(config) {
259
+ this.config = {
260
+ timeout: 3e4,
261
+ enableLogging: true,
262
+ ...config
263
+ };
264
+ this.layerManager = new LayerManager({
265
+ layer: config.layer,
266
+ serviceName: config.serviceName,
267
+ serviceIdentity: config.serviceIdentity
268
+ });
269
+ if (config.internalGatewayUrl) {}
270
+ if (config.crossLayerGatewayUrl) {}
271
+ const cbConfig = {
272
+ ...DEFAULT_CIRCUIT_BREAKER_CONFIG,
273
+ ...config.circuitBreaker
274
+ };
275
+ this.internalCircuitBreaker = new CircuitBreaker(cbConfig);
276
+ this.crossLayerCircuitBreaker = new CircuitBreaker(cbConfig);
277
+ this.retryConfig = {
278
+ ...DEFAULT_GATEWAY_RETRY_CONFIG,
279
+ ...config.retry
280
+ };
281
+ this.defaultHeaders = {
282
+ "x-service-identity": this.layerManager.getServiceIdentity(),
283
+ "x-actor-type": "service",
284
+ ...config.defaultHeaders
285
+ };
286
+ logger.debug("[GatewayClient] Initialized", {
287
+ layer: config.layer,
288
+ serviceName: config.serviceName,
289
+ internalUrl: this.getInternalUrl(),
290
+ crossLayerUrl: this.getCrossLayerUrl()
291
+ });
292
+ }
293
+ getInternalUrl() {
294
+ return this.config.internalGatewayUrl || this.layerManager.getInternalGatewayUrl();
295
+ }
296
+ getCrossLayerUrl() {
297
+ return this.config.crossLayerGatewayUrl || this.layerManager.getCrossLayerGatewayUrl();
298
+ }
299
+ /**
300
+ * Execute internal (same layer) GraphQL query/mutation
301
+ */
302
+ async internalQuery(options) {
303
+ const context = this.createRequestContext("internal", options);
304
+ return this.executeWithRetry(this.getInternalUrl(), options, this.internalCircuitBreaker, context, { bypassPermission: true });
305
+ }
306
+ /**
307
+ * Execute cross-layer GraphQL query/mutation
308
+ */
309
+ async crossLayerQuery(options) {
310
+ const context = this.createRequestContext("cross-layer", options);
311
+ return this.executeWithRetry(this.getCrossLayerUrl(), options, this.crossLayerCircuitBreaker, context, { bypassPermission: false });
312
+ }
313
+ /**
314
+ * Execute GraphQL query/mutation with explicit gateway URL
315
+ */
316
+ async query(gatewayUrl, options) {
317
+ const context = this.createRequestContext("direct", options);
318
+ return this.executeWithRetry(gatewayUrl, options, this.internalCircuitBreaker, context, { bypassPermission: false });
319
+ }
320
+ getInternalCircuitBreaker() {
321
+ return this.internalCircuitBreaker;
322
+ }
323
+ getCrossLayerCircuitBreaker() {
324
+ return this.crossLayerCircuitBreaker;
325
+ }
326
+ getHealthStatus() {
327
+ return {
328
+ internal: {
329
+ url: this.getInternalUrl(),
330
+ circuitState: this.internalCircuitBreaker.getState(),
331
+ stats: this.internalCircuitBreaker.getStats()
332
+ },
333
+ crossLayer: {
334
+ url: this.getCrossLayerUrl(),
335
+ circuitState: this.crossLayerCircuitBreaker.getState(),
336
+ stats: this.crossLayerCircuitBreaker.getStats()
337
+ }
338
+ };
339
+ }
340
+ updateDefaultHeaders(headers) {
341
+ this.defaultHeaders = {
342
+ ...this.defaultHeaders,
343
+ ...headers
344
+ };
345
+ }
346
+ createRequestContext(callType, options) {
347
+ return {
348
+ requestId: uuidv4(),
349
+ actorId: options.headers?.["x-actor-id"] || this.defaultHeaders["x-actor-id"],
350
+ workspaceId: options.headers?.["x-workspace-id"] || this.defaultHeaders["x-workspace-id"],
351
+ startTime: Date.now(),
352
+ callType
353
+ };
354
+ }
355
+ /**
356
+ * Check if an error should be retried
357
+ */
358
+ shouldRetryError(error) {
359
+ if (!(error instanceof GatewayError)) return true;
360
+ return error.type !== "GRAPHQL_ERROR" && error.type !== "CIRCUIT_OPEN";
361
+ }
362
+ /**
363
+ * Calculate retry delay with exponential backoff
364
+ */
365
+ calculateRetryDelay(attempt) {
366
+ return Math.min(this.retryConfig.initialDelay * Math.pow(this.retryConfig.backoffMultiplier, attempt - 1), this.retryConfig.maxDelay);
367
+ }
368
+ /**
369
+ * Log retry attempt if logging is enabled
370
+ */
371
+ logRetryAttempt(context, attempt, maxAttempts, delay, error) {
372
+ if (this.config.enableLogging) logger.warn("[GatewayClient] Request failed, retrying", {
373
+ requestId: context.requestId,
374
+ attempt,
375
+ maxAttempts,
376
+ delay,
377
+ error: error.message
378
+ });
379
+ }
380
+ async executeWithRetry(gatewayUrl, options, circuitBreaker, context, settings) {
381
+ if (!options.skipCircuitBreaker && !circuitBreaker.allowRequest()) throw new GatewayError(`Circuit breaker is open for ${gatewayUrl}`, "CIRCUIT_OPEN", gatewayUrl);
382
+ const maxAttempts = options.skipRetry ? 1 : this.retryConfig.maxAttempts;
383
+ let lastError = null;
384
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
385
+ const result = await this.executeRequest(gatewayUrl, options, context, settings.bypassPermission);
386
+ if (!options.skipCircuitBreaker) circuitBreaker.recordSuccess();
387
+ return result;
388
+ } catch (error) {
389
+ lastError = error instanceof Error ? error : new Error(String(error));
390
+ const clientError = isGatewayClientError(error);
391
+ if (!options.skipCircuitBreaker) {
392
+ if (clientError) circuitBreaker.recordSuccess();
393
+ else circuitBreaker.recordFailure();
394
+ }
395
+ if (clientError || !this.shouldRetryError(error)) throw error;
396
+ if (attempt < maxAttempts) {
397
+ const delay = this.calculateRetryDelay(attempt);
398
+ this.logRetryAttempt(context, attempt, maxAttempts, delay, lastError);
399
+ await this.sleep(delay);
400
+ }
401
+ }
402
+ throw lastError || new GatewayError("Request failed after retries", "UNKNOWN_ERROR", gatewayUrl);
403
+ }
404
+ /**
405
+ * Build headers for a request
406
+ */
407
+ buildRequestHeaders(context, options, bypassPermission) {
408
+ const headers = {
409
+ "Content-Type": "application/json",
410
+ "x-request-id": context.requestId,
411
+ "x-call-type": context.callType
412
+ };
413
+ const cfHeaders = context.callType === "cross-layer" ? ContextManager.getCfAccessHeaders() : {};
414
+ Object.assign(headers, cfHeaders);
415
+ for (const [key, value] of Object.entries(this.defaultHeaders)) if (value !== void 0) headers[key] = String(value);
416
+ if (options.headers) {
417
+ for (const [key, value] of Object.entries(options.headers)) if (value !== void 0) headers[key] = String(value);
418
+ }
419
+ if (bypassPermission) {
420
+ headers["x-bypass-permission"] = resolveBypassPermissionValue();
421
+ headers["x-bypass-source"] = this.layerManager.getServiceIdentity();
422
+ headers["x-bypass-timestamp"] = Date.now().toString();
423
+ }
424
+ const cfCookie = cfHeaders["cookie"];
425
+ if (cfCookie) {
426
+ const existing = headers["cookie"];
427
+ if (!existing) headers["cookie"] = cfCookie;
428
+ else if (!existing.split(";").some((c) => c.trim() === cfCookie)) headers["cookie"] = `${existing}; ${cfCookie}`;
429
+ }
430
+ return headers;
431
+ }
432
+ /**
433
+ * Handle GraphQL errors in response
434
+ */
435
+ handleGraphQLErrors(result, context, gatewayUrl, duration) {
436
+ if (!result.errors || result.errors.length === 0) return;
437
+ const errorMessages = result.errors.map((e) => e.message).join(", ");
438
+ if (this.config.enableLogging) logger.warn("[GatewayClient] GraphQL errors", {
439
+ requestId: context.requestId,
440
+ errors: result.errors,
441
+ duration
442
+ });
443
+ throw new GatewayError(`GraphQL error: ${errorMessages}`, "GRAPHQL_ERROR", gatewayUrl, { graphqlErrors: result.errors });
444
+ }
445
+ /**
446
+ * Handle fetch errors
447
+ */
448
+ handleFetchError(error, context, gatewayUrl, timeout, duration) {
449
+ if (error instanceof GatewayError) throw error;
450
+ if (error instanceof Error) {
451
+ if (error.name === "AbortError") throw new GatewayError(`Request timed out after ${timeout}ms`, "TIMEOUT_ERROR", gatewayUrl, { cause: error });
452
+ if (this.config.enableLogging) logger.error("[GatewayClient] Request failed", {
453
+ requestId: context.requestId,
454
+ error: error.message,
455
+ duration
456
+ });
457
+ throw new GatewayError(error.message, "NETWORK_ERROR", gatewayUrl, { cause: error });
458
+ }
459
+ throw new GatewayError(String(error), "UNKNOWN_ERROR", gatewayUrl);
460
+ }
461
+ async executeRequest(gatewayUrl, options, context, bypassPermission) {
462
+ const timeout = options.timeout || this.config.timeout || 3e4;
463
+ const headers = this.buildRequestHeaders(context, options, bypassPermission);
464
+ if (context.callType === "cross-layer" && !hasAuthorizationHeader(headers)) {
465
+ const serviceActorId = this.layerManager.getServiceIdentity();
466
+ const serviceJwt = await signServiceJwt(serviceActorId);
467
+ if (serviceJwt) headers["Authorization"] = `Bearer ${serviceJwt}`;
468
+ else {
469
+ assertServiceJwtConfigured({
470
+ gatewayUrl,
471
+ operationName: options.operationName,
472
+ layer: this.layerManager.getLayer(),
473
+ serviceIdentity: serviceActorId
474
+ });
475
+ if (this.config.enableLogging) logger.debug("[GatewayClient] SERVICE_JWT_SECRET not configured — cross-layer call will proceed without service JWT", {
476
+ requestId: context.requestId,
477
+ gatewayUrl
478
+ });
479
+ }
480
+ }
481
+ const body = JSON.stringify({
482
+ query: options.query,
483
+ variables: options.variables || {},
484
+ operationName: options.operationName
485
+ });
486
+ if (this.config.enableLogging) logger.debug("[GatewayClient] Executing request", {
487
+ requestId: context.requestId,
488
+ gatewayUrl,
489
+ operationName: options.operationName,
490
+ callType: context.callType,
491
+ bypassPermission
492
+ });
493
+ try {
494
+ const controller = new AbortController();
495
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
496
+ const response = await fetch(gatewayUrl, {
497
+ method: "POST",
498
+ headers,
499
+ body,
500
+ signal: controller.signal
501
+ });
502
+ clearTimeout(timeoutId);
503
+ const duration = Date.now() - context.startTime;
504
+ if (!response.ok) {
505
+ let graphqlErrors;
506
+ try {
507
+ const body = await response.json();
508
+ if (body !== null && typeof body === "object" && "errors" in body && Array.isArray(body.errors) && body.errors.length > 0 && body.errors.every(isGraphQLError)) graphqlErrors = body.errors;
509
+ } catch {}
510
+ const httpMessage = `HTTP ${response.status}: ${response.statusText}`;
511
+ throw new GatewayError(graphqlErrors ? `${httpMessage} (GraphQL error: ${graphqlErrors.map((e) => e.message).join(", ")})` : httpMessage, graphqlErrors && response.status < 500 ? "GRAPHQL_ERROR" : "NETWORK_ERROR", gatewayUrl, {
512
+ statusCode: response.status,
513
+ graphqlErrors
514
+ });
515
+ }
516
+ const result = await response.json();
517
+ this.handleGraphQLErrors(result, context, gatewayUrl, duration);
518
+ if (this.config.enableLogging) logger.debug("[GatewayClient] Request completed", {
519
+ requestId: context.requestId,
520
+ duration,
521
+ hasData: !!result.data
522
+ });
523
+ return result;
524
+ } catch (error) {
525
+ const duration = Date.now() - context.startTime;
526
+ this.handleFetchError(error, context, gatewayUrl, timeout, duration);
527
+ }
528
+ }
529
+ sleep(ms) {
530
+ return new Promise((resolve) => setTimeout(resolve, ms));
531
+ }
532
+ };
533
+ /**
534
+ * Create a gateway client for a specific layer
535
+ */
536
+ function createGatewayClient(config) {
537
+ return new GatewayClient(config);
538
+ }
539
+ /**
540
+ * Create a gateway client from environment variables
541
+ *
542
+ * Required environment variables:
543
+ * - SERVICE_LAYER: 'wspace' | 'global'
544
+ * - SERVICE_NAME: Service name
545
+ *
546
+ * Optional:
547
+ * - SERVICE_IDENTITY: Service identity (defaults to SERVICE_NAME)
548
+ * - {LAYER}_INT_GATEWAY_URL: Internal gateway URL
549
+ * - {OPPOSITE_LAYER}_PUBLIC_GATEWAY_URL: Cross-layer gateway URL
550
+ */
551
+ function createGatewayClientFromEnv() {
552
+ const layer = process.env["SERVICE_LAYER"];
553
+ if (!layer || layer !== "wspace" && layer !== "global") throw new Error(`[GatewayClient] Invalid or missing SERVICE_LAYER. Expected 'wspace' or 'global', got '${layer}'`);
554
+ const serviceName = process.env["SERVICE_NAME"];
555
+ if (!serviceName) throw new Error("[GatewayClient] SERVICE_NAME environment variable is required");
556
+ const serviceIdentity = process.env["SERVICE_IDENTITY"] || serviceName;
557
+ return new GatewayClient({
558
+ layer,
559
+ serviceName,
560
+ serviceIdentity
561
+ });
562
+ }
563
+
564
+ export { isGatewayClientError as a, createGatewayClientFromEnv as i, client_exports as n, createGatewayClient as r, GatewayClient as t };
565
+ //# sourceMappingURL=client-DcZ3iGES.js.map