@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
@@ -1,1908 +0,0 @@
1
- import { withDeferredGraphEvents, shouldSyncRelationship, shouldSyncEntity, parseRelationship, getCollectionForEntity, extractMinimalFields, extractEntityTitle, createRelationshipEvent, createEntityEvent, addGraphExtension, GraphRegistry, ensureServiceApplicationName } from './chunk-PN6GIF3R.js';
2
- import { getGraphEventEmitter, GraphEventEmitterImpl } from './chunk-Z77BTSOK.js';
3
- import { ValidationError } from './chunk-I3KOWRT3.js';
4
- import { logger } from './chunk-RU266375.js';
5
- import { __export, __name } from './chunk-XE4OXN2W.js';
6
-
7
- // src/graph/index.ts
8
- var graph_exports = {};
9
- __export(graph_exports, {
10
- AUDIT_FIELDS: () => AUDIT_FIELDS,
11
- GraphEventsPublisher: () => GraphEventsPublisher,
12
- GraphExportService: () => GraphExportService,
13
- GraphModule: () => GraphModule,
14
- GraphRegistry: () => GraphRegistry,
15
- SOFT_DELETE_FIELDS: () => SOFT_DELETE_FIELDS,
16
- STANDARD_FIELDS: () => STANDARD_FIELDS,
17
- TENANT_FIELDS: () => TENANT_FIELDS,
18
- addGraphExtension: () => addGraphExtension,
19
- createEntityEvent: () => createEntityEvent,
20
- createGraphEventsHelper: () => createGraphEventsHelper,
21
- createGraphExportService: () => createGraphExportService,
22
- createPrismaGraphIntegration: () => createPrismaGraphIntegration,
23
- createRelationshipEvent: () => createRelationshipEvent,
24
- createRelationshipFromEntity: () => createRelationshipFromEntity,
25
- defineEntity: () => defineEntity,
26
- defineGraphConfig: () => defineGraphConfig,
27
- defineModuleGraph: () => defineModuleGraph,
28
- defineRelationship: () => defineRelationship,
29
- extractEntityTitle: () => extractEntityTitle,
30
- extractMinimalFields: () => extractMinimalFields,
31
- getCollectionForEntity: () => getCollectionForEntity,
32
- getGraphEventsPublisher: () => getGraphEventsPublisher,
33
- getGraphStats: () => getGraphStats,
34
- initializeGraph: () => initializeGraph,
35
- isGraphInitialized: () => isGraphInitialized,
36
- parseRelationship: () => parseRelationship,
37
- shouldSyncEntity: () => shouldSyncEntity,
38
- shouldSyncRelationship: () => shouldSyncRelationship,
39
- withDeferredGraphEvents: () => withDeferredGraphEvents
40
- });
41
-
42
- // src/graph/utils/prisma-helpers.ts
43
- function createPrismaGraphIntegration(options) {
44
- const { serviceName, graphConfig, productName = "workspaces", validateRuntime = process.env.NODE_ENV !== "production", autoInit = true, createPrismaClient, bulkOperations } = options;
45
- ensureServiceApplicationName(productName);
46
- const state = {
47
- graphEmitter: null,
48
- basePrismaClient: null,
49
- extendedPrismaClient: null,
50
- emitterInitialized: false,
51
- initializationPromise: null
52
- };
53
- function getOrCreateBasePrismaClient() {
54
- state.basePrismaClient ??= createPrismaClient();
55
- return state.basePrismaClient;
56
- }
57
- __name(getOrCreateBasePrismaClient, "getOrCreateBasePrismaClient");
58
- async function initializeGraphEmitter() {
59
- if (state.initializationPromise) {
60
- return state.initializationPromise;
61
- }
62
- if (state.emitterInitialized) {
63
- return;
64
- }
65
- state.initializationPromise = (async () => {
66
- if (!process.env["GRAPH_EVENTS_ENABLED"] || process.env["GRAPH_EVENTS_ENABLED"] !== "true") {
67
- logger.info(`[${serviceName}] Graph events disabled`);
68
- state.emitterInitialized = true;
69
- return;
70
- }
71
- try {
72
- if (!process.env["NATS_SERVERS"] && process.env["NATS_URL"]) {
73
- process.env["NATS_SERVERS"] = process.env["NATS_URL"];
74
- }
75
- state.graphEmitter = new GraphEventEmitterImpl();
76
- logger.info(`[${serviceName}] Graph event emitter initialized`);
77
- state.emitterInitialized = true;
78
- const basePrisma = getOrCreateBasePrismaClient();
79
- state.extendedPrismaClient = initializeGraph(basePrisma, graphConfig, {
80
- productName,
81
- eventEmitter: state.graphEmitter,
82
- enabled: true,
83
- validateRuntime,
84
- ...bulkOperations && {
85
- bulkOperations
86
- }
87
- });
88
- logger.info(`[${serviceName}] Graph integration initialized successfully`);
89
- } catch (error) {
90
- logger.error(`[${serviceName}] Failed to initialize graph integration:`, error);
91
- state.graphEmitter = null;
92
- state.extendedPrismaClient = null;
93
- state.emitterInitialized = true;
94
- }
95
- })();
96
- return state.initializationPromise;
97
- }
98
- __name(initializeGraphEmitter, "initializeGraphEmitter");
99
- function db() {
100
- if (autoInit && !state.emitterInitialized && !state.initializationPromise) {
101
- logger.warn(`[${serviceName}] Graph emitter not initialized before first database access. Auto-initializing now. Consider calling 'await initializeGraphEmitter()' explicitly during server startup for better control.`);
102
- void initializeGraphEmitter();
103
- }
104
- if (!process.env["GRAPH_EVENTS_ENABLED"] || process.env["GRAPH_EVENTS_ENABLED"] !== "true" || !state.extendedPrismaClient) {
105
- const baseClient = getOrCreateBasePrismaClient();
106
- return {
107
- client: baseClient
108
- };
109
- }
110
- return {
111
- client: state.extendedPrismaClient
112
- };
113
- }
114
- __name(db, "db");
115
- const prisma = new Proxy({}, {
116
- get(_, prop) {
117
- const { client } = db();
118
- const value = client[prop];
119
- if (typeof value === "function") {
120
- return value.bind(client);
121
- }
122
- return value;
123
- }
124
- });
125
- async function cleanup() {
126
- if (state.graphEmitter) {
127
- await state.graphEmitter.disconnect();
128
- logger.info(`[${serviceName}] Graph event emitter disconnected`);
129
- }
130
- const clientToDisconnect = state.extendedPrismaClient ?? state.basePrismaClient;
131
- if (clientToDisconnect) {
132
- await clientToDisconnect.$disconnect();
133
- logger.info(`[${serviceName}] Prisma client disconnected`);
134
- }
135
- state.extendedPrismaClient = null;
136
- state.basePrismaClient = null;
137
- state.emitterInitialized = false;
138
- }
139
- __name(cleanup, "cleanup");
140
- return {
141
- /**
142
- * Initialize graph event emitter
143
- *
144
- * With autoInit=true (default), this is called automatically on first database access.
145
- * You can still call it manually for explicit initialization timing.
146
- *
147
- * With autoInit=false, you must call this during application startup.
148
- */
149
- initializeGraphEmitter,
150
- /**
151
- * Get Prisma client with graph integration
152
- * Returns { client: PrismaClient }
153
- *
154
- * If autoInit is enabled, triggers initialization on first call.
155
- */
156
- db,
157
- /**
158
- * Direct Prisma client accessor (Proxy-based)
159
- * Use this for most database operations
160
- *
161
- * If autoInit is enabled, initialization happens automatically.
162
- */
163
- prisma,
164
- /**
165
- * Cleanup function for graceful shutdown
166
- */
167
- cleanup,
168
- /**
169
- * Get the raw graph emitter instance (for advanced use cases)
170
- */
171
- getGraphEmitter: /* @__PURE__ */ __name(() => state.graphEmitter, "getGraphEmitter"),
172
- /**
173
- * Check if emitter is initialized
174
- */
175
- isInitialized: /* @__PURE__ */ __name(() => state.emitterInitialized, "isInitialized")
176
- };
177
- }
178
- __name(createPrismaGraphIntegration, "createPrismaGraphIntegration");
179
-
180
- // src/graph/events-helper.ts
181
- var GraphEventsPublisher = class _GraphEventsPublisher {
182
- static {
183
- __name(this, "GraphEventsPublisher");
184
- }
185
- static instance = null;
186
- productName;
187
- initialized = false;
188
- emitter = null;
189
- constructor(productName = "unknown") {
190
- this.productName = productName;
191
- }
192
- /**
193
- * Get singleton instance
194
- */
195
- static getInstance(productName) {
196
- if (!_GraphEventsPublisher.instance) {
197
- _GraphEventsPublisher.instance = new _GraphEventsPublisher(productName);
198
- }
199
- return _GraphEventsPublisher.instance;
200
- }
201
- /**
202
- * Set the product name (useful when using singleton)
203
- */
204
- setProductName(name) {
205
- this.productName = name;
206
- }
207
- /**
208
- * Initialize the publisher
209
- */
210
- async initialize() {
211
- if (this.initialized) {
212
- return;
213
- }
214
- try {
215
- this.emitter = getGraphEventEmitter();
216
- logger.info("[GraphEventsPublisher] Graph event emitter initialized");
217
- this.initialized = true;
218
- const natsUrl = process.env["NATS_URL"] || process.env["NATS_SERVERS"];
219
- if (natsUrl) {
220
- logger.info(`[GraphEventsPublisher] NATS configured: ${natsUrl}`);
221
- } else {
222
- logger.warn("[GraphEventsPublisher] NATS not configured, using in-memory fallback");
223
- }
224
- } catch (error) {
225
- logger.error("[GraphEventsPublisher] Failed to initialize:", error);
226
- }
227
- }
228
- /**
229
- * Ensure initialized before publishing
230
- */
231
- async ensureInitialized() {
232
- if (!this.initialized) {
233
- await this.initialize();
234
- }
235
- }
236
- /**
237
- * Publish entity created event
238
- */
239
- async publishEntityCreated(entity, options) {
240
- await this.publishEntityEvent("entity.created", entity, options);
241
- }
242
- /**
243
- * Publish entity updated event
244
- */
245
- async publishEntityUpdated(entity, options) {
246
- await this.publishEntityEvent("entity.updated", entity, options);
247
- }
248
- /**
249
- * Publish entity deleted event
250
- */
251
- async publishEntityDeleted(entity, options) {
252
- await this.publishEntityEvent("entity.deleted", entity, options);
253
- }
254
- /**
255
- * Publish relationship created event
256
- */
257
- async publishRelationshipCreated(relationship, organizationId, options) {
258
- await this.publishRelationshipEvent("relationship.created", relationship, organizationId, options);
259
- }
260
- /**
261
- * Publish relationship deleted event
262
- */
263
- async publishRelationshipDeleted(relationship, organizationId, options) {
264
- await this.publishRelationshipEvent("relationship.deleted", relationship, organizationId, options);
265
- }
266
- /**
267
- * Internal method to publish entity events
268
- */
269
- async publishEntityEvent(eventType, entity, options) {
270
- await this.ensureInitialized();
271
- if (!this.emitter) {
272
- logger.warn("[GraphEventsPublisher] Emitter not initialized, skipping event");
273
- return;
274
- }
275
- try {
276
- await this.emitter.publishEntityEvent(eventType, {
277
- id: entity.id,
278
- type: entity.type,
279
- data: entity.data
280
- }, {
281
- productName: this.productName,
282
- organizationId: entity.organizationId || "unknown",
283
- workspaceId: entity.workspaceId,
284
- actorId: options?.userId
285
- });
286
- logger.debug(`[GraphEventsPublisher] Published ${eventType} for ${entity.type}:${entity.id}`);
287
- } catch (error) {
288
- logger.error(`[GraphEventsPublisher] Failed to publish ${eventType} for ${entity.type}:${entity.id}:`, error);
289
- }
290
- }
291
- /**
292
- * Internal method to publish relationship events
293
- */
294
- async publishRelationshipEvent(eventType, relationship, organizationId, options) {
295
- await this.ensureInitialized();
296
- if (!this.emitter) {
297
- logger.warn("[GraphEventsPublisher] Emitter not initialized, skipping event");
298
- return;
299
- }
300
- try {
301
- await this.emitter.publishEntityEvent(eventType, {
302
- id: `${relationship.from.id}_${relationship.to.id}`,
303
- type: relationship.relationType,
304
- data: {
305
- from: relationship.from,
306
- to: relationship.to,
307
- metadata: relationship.metadata
308
- }
309
- }, {
310
- productName: this.productName,
311
- organizationId,
312
- actorId: options?.userId
313
- });
314
- logger.debug(`[GraphEventsPublisher] Published ${eventType} for ${relationship.relationType}`);
315
- } catch (error) {
316
- logger.error(`[GraphEventsPublisher] Failed to publish ${eventType} for ${relationship.relationType}:`, error);
317
- }
318
- }
319
- /**
320
- * Shutdown the publisher
321
- */
322
- async shutdown() {
323
- this.initialized = false;
324
- this.emitter = null;
325
- logger.info("[GraphEventsPublisher] Shutdown complete");
326
- }
327
- /**
328
- * Reset singleton (for testing)
329
- */
330
- static reset() {
331
- _GraphEventsPublisher.instance = null;
332
- }
333
- };
334
- function getGraphEventsPublisher(productName) {
335
- return GraphEventsPublisher.getInstance(productName);
336
- }
337
- __name(getGraphEventsPublisher, "getGraphEventsPublisher");
338
- function createGraphEventsHelper(config) {
339
- const publisher = new GraphEventsPublisher(config.moduleName);
340
- const helper = {};
341
- for (const [name, entityConfig] of Object.entries(config.entities)) {
342
- helper[name] = {
343
- created: /* @__PURE__ */ __name(async (data, options) => {
344
- await publisher.publishEntityCreated({
345
- id: data["id"],
346
- type: entityConfig.type,
347
- data,
348
- organizationId: entityConfig.getOrgId?.(data),
349
- workspaceId: entityConfig.getWorkspaceId?.(data)
350
- }, options);
351
- if (entityConfig.onCreated) {
352
- await entityConfig.onCreated(data, publisher, options);
353
- }
354
- }, "created"),
355
- updated: /* @__PURE__ */ __name(async (data, options) => {
356
- await publisher.publishEntityUpdated({
357
- id: data["id"],
358
- type: entityConfig.type,
359
- data,
360
- organizationId: entityConfig.getOrgId?.(data),
361
- workspaceId: entityConfig.getWorkspaceId?.(data)
362
- }, options);
363
- if (entityConfig.onUpdated) {
364
- await entityConfig.onUpdated(data, publisher, options);
365
- }
366
- }, "updated"),
367
- deleted: /* @__PURE__ */ __name(async (data, options) => {
368
- await publisher.publishEntityDeleted({
369
- id: data["id"],
370
- type: entityConfig.type,
371
- data,
372
- organizationId: entityConfig.getOrgId?.(data),
373
- workspaceId: entityConfig.getWorkspaceId?.(data)
374
- }, options);
375
- if (entityConfig.onDeleted) {
376
- await entityConfig.onDeleted(data, publisher, options);
377
- }
378
- }, "deleted")
379
- };
380
- }
381
- return helper;
382
- }
383
- __name(createGraphEventsHelper, "createGraphEventsHelper");
384
-
385
- // src/graph/export-service.ts
386
- var GraphExportService = class {
387
- static {
388
- __name(this, "GraphExportService");
389
- }
390
- moduleName;
391
- config;
392
- fetchers;
393
- relationshipFetchers;
394
- customTransformer;
395
- constructor(serviceConfig) {
396
- this.moduleName = serviceConfig.moduleName;
397
- this.config = serviceConfig.config;
398
- this.fetchers = serviceConfig.fetchers;
399
- this.relationshipFetchers = serviceConfig.relationshipFetchers || {};
400
- this.customTransformer = serviceConfig.transformEntity;
401
- }
402
- /**
403
- * Get the graph configuration schema
404
- */
405
- getSchema() {
406
- const entities = {};
407
- const relationships = {};
408
- for (const [entityType, config] of Object.entries(this.config.entities)) {
409
- entities[entityType] = {
410
- fields: Array.isArray(config.fields) ? config.fields : [
411
- "id",
412
- "createdAt",
413
- "updatedAt"
414
- ],
415
- collection: config.collection || "product_entities"
416
- };
417
- }
418
- if (this.config.relationships) {
419
- for (const [relType, config] of Object.entries(this.config.relationships)) {
420
- relationships[relType] = {
421
- from: config.from,
422
- fromType: config.from,
423
- to: config.to,
424
- toType: config.to,
425
- edgeType: config.label || "relates_to"
426
- };
427
- }
428
- }
429
- return {
430
- moduleName: this.config.moduleName,
431
- entities,
432
- relationships
433
- };
434
- }
435
- /**
436
- * Export all entities for a given organization/workspace
437
- */
438
- async exportEntities(organizationId, workspaceId, entityTypes) {
439
- const result = {};
440
- const typesToExport = entityTypes || Object.keys(this.config.entities);
441
- for (const entityType of typesToExport) {
442
- if (!this.config.entities[entityType]) {
443
- continue;
444
- }
445
- const fetcher = this.fetchers[entityType];
446
- if (!fetcher) {
447
- logger.warn(`[GraphExportService] No fetcher for ${entityType}`);
448
- result[entityType] = [];
449
- continue;
450
- }
451
- try {
452
- const entities = await fetcher(organizationId, workspaceId);
453
- result[entityType] = entities.map((item) => this.transformEntity(entityType, item));
454
- } catch (error) {
455
- logger.error(`[GraphExportService] Error fetching ${entityType}:`, error);
456
- result[entityType] = [];
457
- }
458
- }
459
- return result;
460
- }
461
- /**
462
- * Export all relationships for a given organization/workspace
463
- */
464
- async exportRelationships(organizationId, workspaceId) {
465
- const relationships = [];
466
- for (const [name, fetcher] of Object.entries(this.relationshipFetchers)) {
467
- try {
468
- const rels = await fetcher(organizationId, workspaceId);
469
- relationships.push(...rels);
470
- } catch (error) {
471
- logger.error(`[GraphExportService] Error fetching relationships ${name}:`, error);
472
- }
473
- }
474
- return relationships;
475
- }
476
- /**
477
- * Export complete graph data (schema + entities + relationships)
478
- */
479
- async exportAll(organizationId, workspaceId) {
480
- const schema = this.getSchema();
481
- const entities = await this.exportEntities(organizationId, workspaceId);
482
- const relationships = await this.exportRelationships(organizationId, workspaceId);
483
- const entityCounts = {};
484
- let totalEntities = 0;
485
- for (const [type, items] of Object.entries(entities)) {
486
- entityCounts[type] = items.length;
487
- totalEntities += items.length;
488
- }
489
- return {
490
- moduleName: this.config.moduleName,
491
- productSource: this.moduleName,
492
- exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
493
- schema: {
494
- entities: schema.entities,
495
- relationships: schema.relationships
496
- },
497
- data: {
498
- entities,
499
- relationships
500
- },
501
- stats: {
502
- totalEntities,
503
- totalRelationships: relationships.length,
504
- entityCounts
505
- }
506
- };
507
- }
508
- /**
509
- * Transform a database entity to graph export format
510
- */
511
- transformEntity(type, item) {
512
- if (this.customTransformer) {
513
- return this.customTransformer(type, item);
514
- }
515
- const { id, createdAt, updatedAt, workspaceId, tenantId, ...data } = item;
516
- return {
517
- id,
518
- type,
519
- data,
520
- organizationId: tenantId,
521
- workspaceId,
522
- createdAt: createdAt instanceof Date ? createdAt.toISOString() : String(createdAt),
523
- updatedAt: updatedAt instanceof Date ? updatedAt.toISOString() : String(updatedAt)
524
- };
525
- }
526
- };
527
- function createGraphExportService(config) {
528
- return new GraphExportService(config);
529
- }
530
- __name(createGraphExportService, "createGraphExportService");
531
- function createRelationshipFromEntity(entity, relationConfig, relationType) {
532
- const fromId = entity[relationConfig.from];
533
- const toId = entity[relationConfig.to];
534
- if (!fromId || !toId) {
535
- return null;
536
- }
537
- const metadata = relationConfig.extractMetadata ? relationConfig.extractMetadata(entity) : {};
538
- return {
539
- id: `${relationType}_${entity["id"] || fromId}_${toId}`,
540
- type: relationType,
541
- fromId,
542
- fromType: relationConfig.from || "Entity",
543
- toId,
544
- toType: relationConfig.to || "Entity",
545
- metadata,
546
- createdAt: entity["createdAt"] instanceof Date ? entity["createdAt"].toISOString() : String(entity["createdAt"] || (/* @__PURE__ */ new Date()).toISOString()),
547
- updatedAt: entity["updatedAt"] instanceof Date ? entity["updatedAt"].toISOString() : String(entity["updatedAt"] || (/* @__PURE__ */ new Date()).toISOString())
548
- };
549
- }
550
- __name(createRelationshipFromEntity, "createRelationshipFromEntity");
551
-
552
- // src/graph/module-graph.ts
553
- var GraphEventsPublisherInternal = class GraphEventsPublisherInternal2 {
554
- static {
555
- __name(this, "GraphEventsPublisherInternal");
556
- }
557
- productName;
558
- initialized = false;
559
- emitter = null;
560
- constructor(productName) {
561
- this.productName = productName;
562
- }
563
- async initialize() {
564
- if (this.initialized) return;
565
- try {
566
- this.emitter = getGraphEventEmitter();
567
- logger.info(`[ModuleGraph:${this.productName}] Graph event emitter initialized`);
568
- this.initialized = true;
569
- const natsUrl = process.env["NATS_URL"] || process.env["NATS_SERVERS"];
570
- if (natsUrl) {
571
- logger.info(`[ModuleGraph:${this.productName}] NATS configured: ${natsUrl}`);
572
- } else {
573
- logger.warn(`[ModuleGraph:${this.productName}] NATS not configured, using in-memory fallback`);
574
- }
575
- } catch (error) {
576
- logger.error(`[ModuleGraph:${this.productName}] Failed to initialize:`, error);
577
- }
578
- }
579
- async ensureInitialized() {
580
- if (!this.initialized) {
581
- await this.initialize();
582
- }
583
- }
584
- async publishEntityCreated(entity, options, rbac) {
585
- await this.publishEntityEvent("entity.created", entity, options, rbac);
586
- }
587
- async publishEntityUpdated(entity, options, rbac) {
588
- await this.publishEntityEvent("entity.updated", entity, options, rbac);
589
- }
590
- async publishEntityDeleted(entity, options, rbac) {
591
- await this.publishEntityEvent("entity.deleted", entity, options, rbac);
592
- }
593
- async publishRelationshipCreated(relationship, organizationId, options) {
594
- await this.publishRelationshipEvent("relationship.created", relationship, organizationId, options);
595
- }
596
- async publishRelationshipDeleted(relationship, organizationId, options) {
597
- await this.publishRelationshipEvent("relationship.deleted", relationship, organizationId, options);
598
- }
599
- async publishEntityEvent(eventType, entity, options, rbac) {
600
- await this.ensureInitialized();
601
- if (!this.emitter) {
602
- logger.warn(`[ModuleGraph:${this.productName}] Emitter not initialized, skipping event`);
603
- return;
604
- }
605
- try {
606
- await this.emitter.publishEntityEvent(eventType, {
607
- id: entity.id,
608
- type: entity.type,
609
- data: entity.data
610
- }, {
611
- productName: this.productName,
612
- organizationId: options?.organizationId ?? entity.organizationId ?? "unknown",
613
- workspaceId: entity.workspaceId,
614
- actorId: options?.actorId
615
- }, rbac);
616
- logger.debug(`[ModuleGraph:${this.productName}] Published ${eventType} for ${entity.type}:${entity.id}`, {
617
- hasRbac: !!rbac
618
- });
619
- } catch (error) {
620
- logger.error(`[ModuleGraph:${this.productName}] Failed to publish ${eventType}:`, error);
621
- }
622
- }
623
- async publishRelationshipEvent(eventType, relationship, organizationId, options) {
624
- await this.ensureInitialized();
625
- if (!this.emitter) {
626
- logger.warn(`[ModuleGraph:${this.productName}] Emitter not initialized, skipping event`);
627
- return;
628
- }
629
- try {
630
- await this.emitter.publishEntityEvent(eventType, {
631
- id: `${relationship.from.id}_${relationship.to.id}`,
632
- type: relationship.relationType,
633
- data: {
634
- from: relationship.from,
635
- to: relationship.to,
636
- metadata: relationship.metadata
637
- }
638
- }, {
639
- productName: this.productName,
640
- organizationId,
641
- actorId: options?.actorId
642
- });
643
- logger.debug(`[ModuleGraph:${this.productName}] Published ${eventType} for ${relationship.relationType}`);
644
- } catch (error) {
645
- logger.error(`[ModuleGraph:${this.productName}] Failed to publish ${eventType}:`, error);
646
- }
647
- }
648
- async shutdown() {
649
- this.initialized = false;
650
- this.emitter = null;
651
- logger.info(`[ModuleGraph:${this.productName}] Shutdown complete`);
652
- }
653
- };
654
- function defineModuleGraph(definition) {
655
- const { moduleName, productSource, entities, relationships = {} } = definition;
656
- const publisher = new GraphEventsPublisherInternal(productSource ?? moduleName);
657
- const events = {};
658
- for (const [entityName, entityDef] of Object.entries(entities)) {
659
- const getOrgId = entityDef.getOrgId || (() => void 0);
660
- const getWorkspaceId = entityDef.getWorkspaceId || (() => void 0);
661
- const createEventContext = /* @__PURE__ */ __name(() => ({
662
- publishRelationship: /* @__PURE__ */ __name(async (data, orgId) => {
663
- await publisher.publishRelationshipCreated(data, orgId || "unknown");
664
- }, "publishRelationship"),
665
- deleteRelationship: /* @__PURE__ */ __name(async (data, orgId) => {
666
- await publisher.publishRelationshipDeleted(data, orgId || "unknown");
667
- }, "deleteRelationship"),
668
- getOrgId,
669
- getWorkspaceId
670
- }), "createEventContext");
671
- const buildRbacMetadata = /* @__PURE__ */ __name((data) => {
672
- if (!entityDef.rbac) return void 0;
673
- const rbacConfig = entityDef.rbac;
674
- if (rbacConfig.createResource === false) return void 0;
675
- const entityId = data["id"];
676
- const title = data["name"] || data["title"] || data["label"] || entityId;
677
- return {
678
- resourceTypeName: rbacConfig.resourceTypeName,
679
- name: rbacConfig.extractName?.(data) ?? title,
680
- identifier: rbacConfig.extractIdentifier?.(data) ?? entityId,
681
- parentResourceIdentifier: rbacConfig.parentResourceField ? data[rbacConfig.parentResourceField] : void 0,
682
- createResource: rbacConfig.createResource ?? true
683
- };
684
- }, "buildRbacMetadata");
685
- events[entityName] = {
686
- created: /* @__PURE__ */ __name(async (data, options) => {
687
- await publisher.publishEntityCreated({
688
- id: data["id"],
689
- type: entityDef.type,
690
- data,
691
- organizationId: getOrgId(data),
692
- workspaceId: getWorkspaceId(data)
693
- }, options, buildRbacMetadata(data));
694
- if (entityDef.onCreated) {
695
- await entityDef.onCreated(data, createEventContext(), options);
696
- }
697
- }, "created"),
698
- updated: /* @__PURE__ */ __name(async (data, options) => {
699
- await publisher.publishEntityUpdated({
700
- id: data["id"],
701
- type: entityDef.type,
702
- data,
703
- organizationId: getOrgId(data),
704
- workspaceId: getWorkspaceId(data)
705
- }, options, buildRbacMetadata(data));
706
- if (entityDef.onUpdated) {
707
- await entityDef.onUpdated(data, createEventContext(), options);
708
- }
709
- }, "updated"),
710
- deleted: /* @__PURE__ */ __name(async (data, options) => {
711
- await publisher.publishEntityDeleted({
712
- id: data["id"],
713
- type: entityDef.type,
714
- data,
715
- organizationId: getOrgId(data),
716
- workspaceId: getWorkspaceId(data)
717
- }, options, buildRbacMetadata(data));
718
- if (entityDef.onDeleted) {
719
- await entityDef.onDeleted(data, createEventContext(), options);
720
- }
721
- }, "deleted")
722
- };
723
- }
724
- const getSchema = /* @__PURE__ */ __name(() => {
725
- const entitySchema = {};
726
- const relationshipSchema = {};
727
- for (const [, entityDef] of Object.entries(entities)) {
728
- entitySchema[entityDef.type] = {
729
- fields: entityDef.fields || [
730
- "id",
731
- "createdAt",
732
- "updatedAt"
733
- ],
734
- collection: entityDef.collection || "entity"
735
- };
736
- }
737
- for (const [relName, relDef] of Object.entries(relationships)) {
738
- relationshipSchema[relName] = {
739
- fromType: relDef.fromType,
740
- toType: relDef.toType,
741
- edgeType: relDef.edgeType
742
- };
743
- }
744
- return {
745
- moduleName,
746
- entities: entitySchema,
747
- relationships: relationshipSchema
748
- };
749
- }, "getSchema");
750
- const exportEntities = /* @__PURE__ */ __name(async (organizationId, workspaceId, entityTypes) => {
751
- const result = {};
752
- for (const [entityName, entityDef] of Object.entries(entities)) {
753
- if (entityTypes && !entityTypes.includes(entityDef.type)) {
754
- continue;
755
- }
756
- if (!entityDef.fetch) {
757
- result[entityDef.type] = [];
758
- continue;
759
- }
760
- try {
761
- const items = await entityDef.fetch(organizationId, workspaceId);
762
- result[entityDef.type] = items.map((item) => {
763
- const { id, createdAt, updatedAt, workspaceId: ws, tenantId, ...data } = item;
764
- return {
765
- id,
766
- type: entityDef.type,
767
- data,
768
- organizationId: tenantId,
769
- workspaceId: ws,
770
- createdAt: createdAt instanceof Date ? createdAt.toISOString() : String(createdAt),
771
- updatedAt: updatedAt instanceof Date ? updatedAt.toISOString() : String(updatedAt)
772
- };
773
- });
774
- } catch (error) {
775
- logger.error(`[ModuleGraph:${moduleName}] Error fetching ${entityName}:`, error);
776
- result[entityDef.type] = [];
777
- }
778
- }
779
- return result;
780
- }, "exportEntities");
781
- const exportRelationships = /* @__PURE__ */ __name(async (organizationId, workspaceId) => {
782
- const result = [];
783
- for (const [relName, relDef] of Object.entries(relationships)) {
784
- if (!relDef.fetch) {
785
- continue;
786
- }
787
- try {
788
- const items = await relDef.fetch(organizationId, workspaceId);
789
- for (const item of items) {
790
- result.push({
791
- id: item.id,
792
- type: relDef.edgeType,
793
- fromId: item.fromId,
794
- fromType: relDef.fromType,
795
- toId: item.toId,
796
- toType: relDef.toType,
797
- metadata: item.metadata || {},
798
- createdAt: item.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
799
- updatedAt: item.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
800
- });
801
- }
802
- } catch (error) {
803
- logger.error(`[ModuleGraph:${moduleName}] Error fetching relationship ${relName}:`, error);
804
- }
805
- }
806
- return result;
807
- }, "exportRelationships");
808
- const exportAll = /* @__PURE__ */ __name(async (organizationId, workspaceId) => {
809
- const schema = getSchema();
810
- const entitiesData = await exportEntities(organizationId, workspaceId);
811
- const relationshipsData = await exportRelationships(organizationId, workspaceId);
812
- const entityCounts = {};
813
- let totalEntities = 0;
814
- for (const [type, items] of Object.entries(entitiesData)) {
815
- entityCounts[type] = items.length;
816
- totalEntities += items.length;
817
- }
818
- return {
819
- moduleName,
820
- productSource: productSource ?? moduleName,
821
- exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
822
- schema,
823
- data: {
824
- entities: entitiesData,
825
- relationships: relationshipsData
826
- },
827
- stats: {
828
- totalEntities,
829
- totalRelationships: relationshipsData.length,
830
- entityCounts
831
- }
832
- };
833
- }, "exportAll");
834
- return {
835
- moduleName,
836
- events,
837
- initialize: /* @__PURE__ */ __name(() => publisher.initialize(), "initialize"),
838
- shutdown: /* @__PURE__ */ __name(() => publisher.shutdown(), "shutdown"),
839
- getSchema,
840
- exportEntities,
841
- exportRelationships,
842
- exportAll,
843
- getPublisher: /* @__PURE__ */ __name(() => publisher, "getPublisher")
844
- };
845
- }
846
- __name(defineModuleGraph, "defineModuleGraph");
847
-
848
- // src/graph/config/builder.ts
849
- var STANDARD_FIELDS = [
850
- "id",
851
- "createdAt",
852
- "updatedAt"
853
- ];
854
- var SOFT_DELETE_FIELDS = [
855
- "deletedAt"
856
- ];
857
- var AUDIT_FIELDS = [
858
- "metadata",
859
- "context"
860
- ];
861
- var TENANT_FIELDS = [
862
- "workspaceId",
863
- "tenantId"
864
- ];
865
- var DEFAULT_GET_WORKSPACE_ID = /* @__PURE__ */ __name((data) => data["workspaceId"], "DEFAULT_GET_WORKSPACE_ID");
866
- var DEFAULT_GET_ORG_ID = /* @__PURE__ */ __name((data) => {
867
- if (data["tenantId"]) {
868
- return data["tenantId"];
869
- }
870
- const context = data["context"];
871
- return context?.["organizationId"];
872
- }, "DEFAULT_GET_ORG_ID");
873
- function createDefaultExtractTitle(entityType) {
874
- return (data) => {
875
- const id = data["id"];
876
- if (typeof id === "string" && id.length > 0) {
877
- return `${entityType.toLowerCase()}_${id}`;
878
- }
879
- return void 0;
880
- };
881
- }
882
- __name(createDefaultExtractTitle, "createDefaultExtractTitle");
883
- function generateRelationshipLabel(relationshipName) {
884
- return relationshipName.replace(/([A-Z])/g, "_$1").toUpperCase().replace(/^_/, "");
885
- }
886
- __name(generateRelationshipLabel, "generateRelationshipLabel");
887
- function extractFieldsFromModel(modelName, options, prismaFieldsModule) {
888
- if (!prismaFieldsModule.hasModel(modelName)) {
889
- const availableModels = prismaFieldsModule.getAllModelNames().join(", ");
890
- throw new Error(`Prisma model '${modelName}' not found. Available models: ${availableModels}`);
891
- }
892
- const allFields = prismaFieldsModule.getScalarFields(modelName);
893
- const sdkDefaults = [
894
- ...STANDARD_FIELDS,
895
- ...options.softDelete !== false ? SOFT_DELETE_FIELDS : [],
896
- ...options.multiTenant !== false ? TENANT_FIELDS : [],
897
- ...options.audit !== false ? AUDIT_FIELDS : []
898
- ];
899
- const excluded = /* @__PURE__ */ new Set([
900
- ...sdkDefaults,
901
- ...options.exclude ?? []
902
- ]);
903
- const filteredFields = allFields.filter((field) => !excluded.has(field));
904
- const finalFields = [
905
- ...filteredFields,
906
- ...options.include ?? []
907
- ];
908
- return finalFields;
909
- }
910
- __name(extractFieldsFromModel, "extractFieldsFromModel");
911
- function validateEntityConfig(entityType, config) {
912
- const errors = [];
913
- if (!config.fields || config.fields.length === 0) {
914
- errors.push({
915
- type: "INVALID_ENTITY_TYPE",
916
- entityType,
917
- message: `Entity '${entityType}' must have at least one field`
918
- });
919
- }
920
- if (!config.getWorkspaceId) {
921
- errors.push({
922
- type: "MISSING_WORKSPACE_ID",
923
- entityType,
924
- message: `Entity '${entityType}' must define getWorkspaceId() to enforce workspace boundary`
925
- });
926
- }
927
- if (!config.getOrgId) {
928
- errors.push({
929
- type: "MISSING_ORG_ID",
930
- entityType,
931
- message: `Entity '${entityType}' must define getOrgId() for multi-tenant isolation`
932
- });
933
- }
934
- return errors;
935
- }
936
- __name(validateEntityConfig, "validateEntityConfig");
937
- function validateRelationshipConfig(relationshipKey, config, entityTypes) {
938
- const errors = [];
939
- if (!entityTypes.has(config.from)) {
940
- errors.push({
941
- type: "INVALID_RELATIONSHIP",
942
- relationshipKey,
943
- message: `Relationship '${relationshipKey}' references unknown 'from' entity: ${config.from}`
944
- });
945
- }
946
- if (config.to !== "*" && !entityTypes.has(config.to)) {
947
- errors.push({
948
- type: "INVALID_RELATIONSHIP",
949
- relationshipKey,
950
- message: `Relationship '${relationshipKey}' references unknown 'to' entity: ${config.to}`
951
- });
952
- }
953
- if (config.to === "*" && !config.polymorphicTypeField) {
954
- errors.push({
955
- type: "INVALID_RELATIONSHIP",
956
- relationshipKey,
957
- message: `Polymorphic relationship '${relationshipKey}' must define polymorphicTypeField`
958
- });
959
- }
960
- if (!config.fromField) {
961
- errors.push({
962
- type: "INVALID_RELATIONSHIP",
963
- relationshipKey,
964
- message: `Relationship '${relationshipKey}' must define fromField`
965
- });
966
- }
967
- if (!config.label) {
968
- errors.push({
969
- type: "INVALID_RELATIONSHIP",
970
- relationshipKey,
971
- message: `Relationship '${relationshipKey}' must define label`
972
- });
973
- }
974
- return errors;
975
- }
976
- __name(validateRelationshipConfig, "validateRelationshipConfig");
977
- function validateWorkspaceBoundary(config, _entityTypes) {
978
- const errors = [];
979
- const warnings = [];
980
- const rootTypes = /* @__PURE__ */ new Set([
981
- "Workspace",
982
- "Project",
983
- "Organization",
984
- "Tenant"
985
- ]);
986
- for (const [entityType, entityConfig] of Object.entries(config.entities)) {
987
- if (entityConfig.enabled === false) continue;
988
- if (rootTypes.has(entityType)) {
989
- continue;
990
- }
991
- if (!entityConfig.getWorkspaceId) {
992
- errors.push({
993
- type: "ORPHANED_ENTITY",
994
- entityType,
995
- message: `Entity '${entityType}' has no workspace boundary - every entity must connect to a workspace`
996
- });
997
- continue;
998
- }
999
- let hasWorkspaceLink = false;
1000
- if (config.relationships) {
1001
- for (const [, relConfig] of Object.entries(config.relationships)) {
1002
- if (relConfig.enabled === false) continue;
1003
- if (relConfig.from === entityType && (relConfig.to === "Workspace" || relConfig.to === "Project" || rootTypes.has(relConfig.to))) {
1004
- hasWorkspaceLink = true;
1005
- break;
1006
- }
1007
- }
1008
- }
1009
- if (!hasWorkspaceLink) {
1010
- warnings.push(`Entity '${entityType}' has no direct relationship to Workspace/Project. Ensure getWorkspaceId() is correctly implemented.`);
1011
- }
1012
- }
1013
- return {
1014
- errors,
1015
- warnings
1016
- };
1017
- }
1018
- __name(validateWorkspaceBoundary, "validateWorkspaceBoundary");
1019
- function validateNoDuplicates(config, _entityTypes) {
1020
- const errors = [];
1021
- const warnings = [];
1022
- const seenEntityTypes = /* @__PURE__ */ new Set();
1023
- const relationshipLabels = /* @__PURE__ */ new Set();
1024
- for (const entityType of Object.keys(config.entities)) {
1025
- if (seenEntityTypes.has(entityType)) {
1026
- errors.push({
1027
- type: "DUPLICATE_ENTITY_TYPE",
1028
- entityType,
1029
- message: `Duplicate entity type: ${entityType}`
1030
- });
1031
- }
1032
- seenEntityTypes.add(entityType);
1033
- }
1034
- if (config.relationships) {
1035
- for (const [key, relConfig] of Object.entries(config.relationships)) {
1036
- const label = relConfig.label;
1037
- if (relationshipLabels.has(label)) {
1038
- warnings.push(`Duplicate relationship label: ${label} (in ${key}). This may cause query ambiguity.`);
1039
- }
1040
- relationshipLabels.add(label);
1041
- }
1042
- }
1043
- return {
1044
- errors,
1045
- warnings
1046
- };
1047
- }
1048
- __name(validateNoDuplicates, "validateNoDuplicates");
1049
- function validateGraphConfig(config) {
1050
- const allErrors = [];
1051
- const allWarnings = [];
1052
- for (const [entityType, entityConfig] of Object.entries(config.entities)) {
1053
- if (entityConfig.enabled === false) continue;
1054
- const errors = validateEntityConfig(entityType, entityConfig);
1055
- allErrors.push(...errors);
1056
- }
1057
- const entityTypes = new Set(Object.keys(config.entities));
1058
- if (config.relationships) {
1059
- for (const [relationshipKey, relationshipConfig] of Object.entries(config.relationships)) {
1060
- if (relationshipConfig.enabled === false) continue;
1061
- const errors = validateRelationshipConfig(relationshipKey, relationshipConfig, entityTypes);
1062
- allErrors.push(...errors);
1063
- }
1064
- }
1065
- const boundaryResult = validateWorkspaceBoundary(config);
1066
- allErrors.push(...boundaryResult.errors);
1067
- allWarnings.push(...boundaryResult.warnings);
1068
- const duplicateResult = validateNoDuplicates(config);
1069
- allErrors.push(...duplicateResult.errors);
1070
- allWarnings.push(...duplicateResult.warnings);
1071
- return {
1072
- valid: allErrors.length === 0,
1073
- errors: allErrors,
1074
- warnings: allWarnings
1075
- };
1076
- }
1077
- __name(validateGraphConfig, "validateGraphConfig");
1078
- function processEntityConfig(entityName, entityOptions, prismaFieldsModule) {
1079
- const { softDelete = true, multiTenant = true, audit = true, fields, model, exclude, include, collection, getWorkspaceId, getOrgId, extractTitle, rbac, ...rest } = entityOptions;
1080
- let entityFields;
1081
- if (model) {
1082
- if (!prismaFieldsModule) {
1083
- throw new Error(`Entity '${entityName}' uses model='${model}' but prismaFieldsModule is not provided. Import prisma-fields.ts and pass it to defineGraphConfig({ prismaFieldsModule: ... })`);
1084
- }
1085
- entityFields = extractFieldsFromModel(model, {
1086
- exclude,
1087
- include,
1088
- softDelete,
1089
- multiTenant,
1090
- audit
1091
- }, prismaFieldsModule);
1092
- } else if (fields) {
1093
- entityFields = fields;
1094
- } else {
1095
- throw new Error(`Entity '${entityName}' must specify either 'fields' or 'model' for field definition`);
1096
- }
1097
- const autoFields = [
1098
- ...STANDARD_FIELDS,
1099
- ...softDelete ? SOFT_DELETE_FIELDS : [],
1100
- ...multiTenant ? TENANT_FIELDS : [],
1101
- ...audit ? AUDIT_FIELDS : []
1102
- ];
1103
- const mergedFields = [
1104
- .../* @__PURE__ */ new Set([
1105
- ...autoFields,
1106
- ...entityFields
1107
- ])
1108
- ];
1109
- const finalGetWorkspaceId = multiTenant === false ? (_data) => void 0 : getWorkspaceId ?? DEFAULT_GET_WORKSPACE_ID;
1110
- const finalGetOrgId = multiTenant === false ? (_data) => void 0 : getOrgId ?? DEFAULT_GET_ORG_ID;
1111
- return {
1112
- collection: collection ?? "entities",
1113
- fields: mergedFields,
1114
- getWorkspaceId: finalGetWorkspaceId,
1115
- getOrgId: finalGetOrgId,
1116
- extractTitle: extractTitle ?? createDefaultExtractTitle(entityName),
1117
- ...rbac && {
1118
- rbac
1119
- },
1120
- ...rest
1121
- };
1122
- }
1123
- __name(processEntityConfig, "processEntityConfig");
1124
- function processRelationships(relationshipOptions) {
1125
- const relationships = {};
1126
- for (const [relationshipName, options] of Object.entries(relationshipOptions)) {
1127
- const { label, toField, ...rest } = options;
1128
- relationships[relationshipName] = {
1129
- toField: toField ?? "id",
1130
- label: label ?? generateRelationshipLabel(relationshipName),
1131
- ...rest
1132
- };
1133
- }
1134
- return relationships;
1135
- }
1136
- __name(processRelationships, "processRelationships");
1137
- function logValidationResults(moduleName, validationResult) {
1138
- if (validationResult.errors.length > 0) {
1139
- logger.error(`[GraphConfig:${moduleName}] Configuration validation failed:`);
1140
- for (const error of validationResult.errors) {
1141
- logger.error(` - ${error.message}`, {
1142
- type: error.type,
1143
- entityType: error.entityType,
1144
- relationshipKey: error.relationshipKey
1145
- });
1146
- }
1147
- throw new Error(`Graph configuration validation failed for ${moduleName}`);
1148
- }
1149
- if (validationResult.warnings.length > 0) {
1150
- logger.warn(`[GraphConfig:${moduleName}] Configuration warnings:`);
1151
- for (const warning of validationResult.warnings) {
1152
- logger.warn(` - ${warning}`);
1153
- }
1154
- }
1155
- logger.info(`[GraphConfig:${moduleName}] Configuration validated successfully`, {
1156
- valid: validationResult.valid,
1157
- errorCount: validationResult.errors.length,
1158
- warningCount: validationResult.warnings.length,
1159
- autoFieldsApplied: true
1160
- });
1161
- }
1162
- __name(logValidationResults, "logValidationResults");
1163
- function defineGraphConfig(options) {
1164
- const entities = {};
1165
- for (const [entityName, entityOptions] of Object.entries(options.entities)) {
1166
- entities[entityName] = processEntityConfig(entityName, entityOptions, options.prismaFieldsModule);
1167
- }
1168
- const relationships = options.relationships ? processRelationships(options.relationships) : {};
1169
- const config = {
1170
- moduleName: options.moduleName,
1171
- entities,
1172
- relationships
1173
- };
1174
- const validationResult = validateGraphConfig(config);
1175
- logValidationResults(config.moduleName, validationResult);
1176
- autoRegisterWithRegistry(config);
1177
- return config;
1178
- }
1179
- __name(defineGraphConfig, "defineGraphConfig");
1180
- function autoRegisterWithRegistry(config) {
1181
- const { moduleName, entities, relationships = {} } = config;
1182
- const registryEntities = {};
1183
- for (const [entityType, entityConfig] of Object.entries(entities)) {
1184
- registryEntities[entityType] = {
1185
- fields: entityConfig.fields,
1186
- collection: entityConfig.collection || "entities",
1187
- extractTitle: entityConfig.extractTitle,
1188
- getOrgId: entityConfig.getOrgId,
1189
- getWorkspaceId: entityConfig.getWorkspaceId,
1190
- enabled: entityConfig.enabled,
1191
- // Pass through RBAC config so the Prisma graph extension
1192
- // can include RBAC metadata in entity lifecycle events
1193
- ...entityConfig.rbac && {
1194
- rbac: {
1195
- resourceTypeName: entityConfig.rbac.resourceTypeName,
1196
- extractName: entityConfig.rbac.extractName,
1197
- extractIdentifier: entityConfig.rbac.extractIdentifier,
1198
- parentResourceField: entityConfig.rbac.parentResourceField,
1199
- createResource: entityConfig.rbac.createResource
1200
- }
1201
- },
1202
- ...entityConfig.bulkOperations && {
1203
- bulkOperations: {
1204
- ...entityConfig.bulkOperations
1205
- }
1206
- }
1207
- };
1208
- }
1209
- const registryRelationships = {};
1210
- for (const [key, relConfig] of Object.entries(relationships)) {
1211
- registryRelationships[key] = {
1212
- from: relConfig.from,
1213
- to: relConfig.to,
1214
- fromField: relConfig.fromField,
1215
- toField: relConfig.toField,
1216
- label: relConfig.label,
1217
- description: relConfig.description,
1218
- extractMetadata: relConfig.extractMetadata,
1219
- polymorphicTypeField: relConfig.polymorphicTypeField,
1220
- enabled: relConfig.enabled
1221
- };
1222
- }
1223
- GraphRegistry.registerModule({
1224
- moduleName,
1225
- entities: registryEntities,
1226
- relationships: registryRelationships
1227
- });
1228
- logger.info(`[GraphConfig:${moduleName}] Auto-registered ${Object.keys(entities).length} entities with GraphRegistry`);
1229
- }
1230
- __name(autoRegisterWithRegistry, "autoRegisterWithRegistry");
1231
- function defineEntity(config) {
1232
- return config;
1233
- }
1234
- __name(defineEntity, "defineEntity");
1235
- function defineRelationship(config) {
1236
- return config;
1237
- }
1238
- __name(defineRelationship, "defineRelationship");
1239
-
1240
- // src/graph/config/init.ts
1241
- var RuntimeValidator = class RuntimeValidator2 {
1242
- static {
1243
- __name(this, "RuntimeValidator");
1244
- }
1245
- config;
1246
- constructor(config) {
1247
- this.config = config;
1248
- }
1249
- /**
1250
- * Validate entity data extraction
1251
- */
1252
- validateEntityData(entityType, data) {
1253
- const errors = [];
1254
- const entityConfig = this.config.entities[entityType];
1255
- if (!entityConfig) {
1256
- return {
1257
- valid: true,
1258
- errors: []
1259
- };
1260
- }
1261
- try {
1262
- const workspaceId = entityConfig.getWorkspaceId(data);
1263
- if (!workspaceId) {
1264
- errors.push(`Entity ${entityType}:${data["id"]} has no workspaceId`);
1265
- }
1266
- } catch (error) {
1267
- errors.push(`Error extracting workspaceId for ${entityType}: ${error}`);
1268
- }
1269
- try {
1270
- const orgId = entityConfig.getOrgId(data);
1271
- if (!orgId) {
1272
- errors.push(`Entity ${entityType}:${data["id"]} has no organizationId`);
1273
- }
1274
- } catch (error) {
1275
- errors.push(`Error extracting organizationId for ${entityType}: ${error}`);
1276
- }
1277
- for (const field of entityConfig.fields) {
1278
- if (!(field in data)) {
1279
- errors.push(`Entity ${entityType}:${data["id"]} missing configured field: ${field}`);
1280
- }
1281
- }
1282
- return {
1283
- valid: errors.length === 0,
1284
- errors
1285
- };
1286
- }
1287
- };
1288
- function initializeGraph(prismaClient, config, options) {
1289
- const { productName, eventEmitter, monitoredEntityTypes = [], enabled = true, validateRuntime, bulkOperations } = options;
1290
- const shouldValidate = validateRuntime ?? process.env["NODE_ENV"] !== "production";
1291
- logger.info(`[GraphInit:${config.moduleName}] Initializing graph integration`, {
1292
- productName,
1293
- enabled,
1294
- validateRuntime: shouldValidate,
1295
- entities: Object.keys(config.entities).length,
1296
- relationships: config.relationships ? Object.keys(config.relationships).length : 0
1297
- });
1298
- if (!enabled) {
1299
- logger.warn(`[GraphInit:${config.moduleName}] Graph integration disabled by configuration`);
1300
- return prismaClient;
1301
- }
1302
- registerConfigWithRegistry(config);
1303
- const validator = shouldValidate ? new RuntimeValidator(config) : null;
1304
- const wrappedEmitter = {
1305
- publishEntityEvent: /* @__PURE__ */ __name(async (eventType, entity, context, rbac) => {
1306
- if (validator && (eventType === "entity.created" || eventType === "entity.updated")) {
1307
- const validation = validator.validateEntityData(entity.type, entity.data);
1308
- if (!validation.valid) {
1309
- logger.error(`[GraphInit:${config.moduleName}] Runtime validation failed for ${entity.type}:${entity.id}`, {
1310
- errors: validation.errors
1311
- });
1312
- }
1313
- }
1314
- return eventEmitter.publishEntityEvent(eventType, entity, context, rbac);
1315
- }, "publishEntityEvent")
1316
- };
1317
- const extendedClient = addGraphExtension(prismaClient, {
1318
- enabled: true,
1319
- productName,
1320
- eventEmitter: wrappedEmitter,
1321
- entityTypes: monitoredEntityTypes,
1322
- ...bulkOperations && {
1323
- bulkOperations
1324
- }
1325
- });
1326
- logger.info(`[GraphInit:${config.moduleName}] Graph integration initialized successfully`);
1327
- return extendedClient;
1328
- }
1329
- __name(initializeGraph, "initializeGraph");
1330
- function registerConfigWithRegistry(config) {
1331
- const { moduleName, entities, relationships = {} } = config;
1332
- const registryEntities = {};
1333
- for (const [entityType, entityConfig] of Object.entries(entities)) {
1334
- registryEntities[entityType] = {
1335
- fields: entityConfig.fields,
1336
- collection: entityConfig.collection || "entities",
1337
- extractTitle: entityConfig.extractTitle,
1338
- getOrgId: entityConfig.getOrgId,
1339
- getWorkspaceId: entityConfig.getWorkspaceId,
1340
- enabled: entityConfig.enabled,
1341
- ...entityConfig.rbac && {
1342
- rbac: {
1343
- ...entityConfig.rbac
1344
- }
1345
- },
1346
- ...entityConfig.bulkOperations && {
1347
- bulkOperations: {
1348
- ...entityConfig.bulkOperations
1349
- }
1350
- }
1351
- };
1352
- }
1353
- const registryRelationships = {};
1354
- for (const [key, relConfig] of Object.entries(relationships)) {
1355
- registryRelationships[key] = {
1356
- from: relConfig.from,
1357
- to: relConfig.to,
1358
- fromField: relConfig.fromField,
1359
- toField: relConfig.toField,
1360
- label: relConfig.label,
1361
- description: relConfig.description,
1362
- extractMetadata: relConfig.extractMetadata,
1363
- polymorphicTypeField: relConfig.polymorphicTypeField,
1364
- enabled: relConfig.enabled
1365
- };
1366
- }
1367
- GraphRegistry.registerModule({
1368
- moduleName,
1369
- entities: registryEntities,
1370
- relationships: registryRelationships
1371
- });
1372
- logger.info(`[GraphInit:${moduleName}] Configuration registered with GraphRegistry`);
1373
- }
1374
- __name(registerConfigWithRegistry, "registerConfigWithRegistry");
1375
- function isGraphInitialized(moduleName) {
1376
- const registeredModules = GraphRegistry.getRegisteredModules();
1377
- return registeredModules.includes(moduleName);
1378
- }
1379
- __name(isGraphInitialized, "isGraphInitialized");
1380
- function getGraphStats() {
1381
- const stats = GraphRegistry.getStats();
1382
- const registeredModules = GraphRegistry.getRegisteredModules();
1383
- return {
1384
- modules: stats.modules,
1385
- entities: stats.entities,
1386
- relationships: stats.relationships,
1387
- registeredModules
1388
- };
1389
- }
1390
- __name(getGraphStats, "getGraphStats");
1391
-
1392
- // src/graph/index.ts
1393
- var GraphModule = class {
1394
- static {
1395
- __name(this, "GraphModule");
1396
- }
1397
- client;
1398
- context;
1399
- constructor(client, context) {
1400
- this.client = client;
1401
- this.context = context;
1402
- }
1403
- /**
1404
- * Create graph node
1405
- */
1406
- async createNode(options) {
1407
- if (!options.type) {
1408
- throw new ValidationError("Node type is required");
1409
- }
1410
- if (!options.properties || typeof options.properties !== "object") {
1411
- throw new ValidationError("Node properties must be an object");
1412
- }
1413
- logger.debug("[Graph] Creating node", {
1414
- type: options.type
1415
- });
1416
- const mutation = `
1417
- mutation CreateGraphNode($input: CreateGraphNodeInput!) {
1418
- createGraphNode(input: $input) {
1419
- id
1420
- type
1421
- properties
1422
- workspaceId
1423
- organizationId
1424
- createdAt
1425
- updatedAt
1426
- }
1427
- }
1428
- `;
1429
- const variables = {
1430
- input: {
1431
- type: options.type,
1432
- properties: options.properties,
1433
- workspaceId: options.workspaceId || this.context.workspaceId,
1434
- organizationId: options.organizationId
1435
- }
1436
- };
1437
- const response = await this.client.query(mutation, variables, this.context);
1438
- logger.info("[Graph] Node created", {
1439
- nodeId: response.createGraphNode.id
1440
- });
1441
- return response.createGraphNode;
1442
- }
1443
- /**
1444
- * Create graph edge
1445
- */
1446
- async createEdge(options) {
1447
- if (!options.from) {
1448
- throw new ValidationError("Source node ID is required");
1449
- }
1450
- if (!options.to) {
1451
- throw new ValidationError("Target node ID is required");
1452
- }
1453
- if (!options.type) {
1454
- throw new ValidationError("Edge type is required");
1455
- }
1456
- logger.debug("[Graph] Creating edge", {
1457
- from: options.from,
1458
- to: options.to,
1459
- type: options.type
1460
- });
1461
- const mutation = `
1462
- mutation CreateGraphEdge($input: CreateGraphEdgeInput!) {
1463
- createGraphEdge(input: $input) {
1464
- id
1465
- from
1466
- to
1467
- type
1468
- properties
1469
- workspaceId
1470
- organizationId
1471
- createdAt
1472
- }
1473
- }
1474
- `;
1475
- const variables = {
1476
- input: {
1477
- from: options.from,
1478
- to: options.to,
1479
- type: options.type,
1480
- properties: options.properties,
1481
- workspaceId: options.workspaceId || this.context.workspaceId,
1482
- organizationId: options.organizationId
1483
- }
1484
- };
1485
- const response = await this.client.query(mutation, variables, this.context);
1486
- logger.info("[Graph] Edge created", {
1487
- edgeId: response.createGraphEdge.id
1488
- });
1489
- return response.createGraphEdge;
1490
- }
1491
- /**
1492
- * Get node by ID
1493
- */
1494
- async getNode(nodeId) {
1495
- logger.debug("[Graph] Getting node", {
1496
- nodeId
1497
- });
1498
- const query = `
1499
- query GetGraphNode($nodeId: ID!) {
1500
- getGraphNode(nodeId: $nodeId) {
1501
- id
1502
- type
1503
- properties
1504
- workspaceId
1505
- organizationId
1506
- createdAt
1507
- updatedAt
1508
- }
1509
- }
1510
- `;
1511
- const response = await this.client.query(query, {
1512
- nodeId
1513
- }, this.context);
1514
- return response.getGraphNode;
1515
- }
1516
- /**
1517
- * Update node
1518
- */
1519
- async updateNode(nodeId, properties) {
1520
- logger.debug("[Graph] Updating node", {
1521
- nodeId
1522
- });
1523
- const mutation = `
1524
- mutation UpdateGraphNode($nodeId: ID!, $properties: JSON!) {
1525
- updateGraphNode(nodeId: $nodeId, properties: $properties) {
1526
- id
1527
- type
1528
- properties
1529
- workspaceId
1530
- organizationId
1531
- createdAt
1532
- updatedAt
1533
- }
1534
- }
1535
- `;
1536
- const response = await this.client.query(mutation, {
1537
- nodeId,
1538
- properties
1539
- }, this.context);
1540
- logger.info("[Graph] Node updated", {
1541
- nodeId
1542
- });
1543
- return response.updateGraphNode;
1544
- }
1545
- /**
1546
- * Delete node
1547
- */
1548
- async deleteNode(nodeId) {
1549
- logger.debug("[Graph] Deleting node", {
1550
- nodeId
1551
- });
1552
- const mutation = `
1553
- mutation DeleteGraphNode($nodeId: ID!) {
1554
- deleteGraphNode(nodeId: $nodeId) {
1555
- success
1556
- }
1557
- }
1558
- `;
1559
- await this.client.query(mutation, {
1560
- nodeId
1561
- }, this.context);
1562
- logger.info("[Graph] Node deleted", {
1563
- nodeId
1564
- });
1565
- return true;
1566
- }
1567
- /**
1568
- * Delete edge
1569
- */
1570
- async deleteEdge(edgeId) {
1571
- logger.debug("[Graph] Deleting edge", {
1572
- edgeId
1573
- });
1574
- const mutation = `
1575
- mutation DeleteGraphEdge($edgeId: ID!) {
1576
- deleteGraphEdge(edgeId: $edgeId) {
1577
- success
1578
- }
1579
- }
1580
- `;
1581
- await this.client.query(mutation, {
1582
- edgeId
1583
- }, this.context);
1584
- logger.info("[Graph] Edge deleted", {
1585
- edgeId
1586
- });
1587
- return true;
1588
- }
1589
- /**
1590
- * Traverse graph
1591
- */
1592
- async traverse(options) {
1593
- if (!options.startNode) {
1594
- throw new ValidationError("Start node ID is required");
1595
- }
1596
- logger.debug("[Graph] Traversing graph", {
1597
- startNode: options.startNode,
1598
- direction: options.direction || "outbound"
1599
- });
1600
- const query = `
1601
- query TraverseGraph(
1602
- $startNode: ID!
1603
- $direction: GraphDirection
1604
- $edgeTypes: [String!]
1605
- $minDepth: Int
1606
- $maxDepth: Int
1607
- $limit: Int
1608
- ) {
1609
- traverseGraph(
1610
- startNode: $startNode
1611
- direction: $direction
1612
- edgeTypes: $edgeTypes
1613
- minDepth: $minDepth
1614
- maxDepth: $maxDepth
1615
- limit: $limit
1616
- ) {
1617
- nodes {
1618
- id
1619
- type
1620
- properties
1621
- workspaceId
1622
- organizationId
1623
- createdAt
1624
- updatedAt
1625
- }
1626
- edges {
1627
- id
1628
- from
1629
- to
1630
- type
1631
- properties
1632
- workspaceId
1633
- organizationId
1634
- createdAt
1635
- }
1636
- paths {
1637
- nodes {
1638
- id
1639
- type
1640
- properties
1641
- }
1642
- edges {
1643
- id
1644
- from
1645
- to
1646
- type
1647
- }
1648
- }
1649
- }
1650
- }
1651
- `;
1652
- const variables = {
1653
- startNode: options.startNode,
1654
- direction: options.direction || "outbound",
1655
- edgeTypes: options.edgeTypes,
1656
- minDepth: options.minDepth || 1,
1657
- maxDepth: options.maxDepth || 3,
1658
- limit: options.limit || 100
1659
- };
1660
- const response = await this.client.query(query, variables, this.context);
1661
- return response.traverseGraph;
1662
- }
1663
- /**
1664
- * Find shortest path between two nodes
1665
- */
1666
- async findShortestPath(fromNode, toNode, options) {
1667
- logger.debug("[Graph] Finding shortest path", {
1668
- fromNode,
1669
- toNode
1670
- });
1671
- const query = `
1672
- query FindShortestPath(
1673
- $fromNode: ID!
1674
- $toNode: ID!
1675
- $edgeTypes: [String!]
1676
- $maxDepth: Int
1677
- ) {
1678
- findShortestPath(
1679
- fromNode: $fromNode
1680
- toNode: $toNode
1681
- edgeTypes: $edgeTypes
1682
- maxDepth: $maxDepth
1683
- ) {
1684
- nodes {
1685
- id
1686
- type
1687
- properties
1688
- }
1689
- edges {
1690
- id
1691
- from
1692
- to
1693
- type
1694
- }
1695
- distance
1696
- }
1697
- }
1698
- `;
1699
- const response = await this.client.query(query, {
1700
- fromNode,
1701
- toNode,
1702
- edgeTypes: options?.edgeTypes,
1703
- maxDepth: options?.maxDepth || 10
1704
- }, this.context);
1705
- return response.findShortestPath;
1706
- }
1707
- /**
1708
- * Query graph with raw openCypher. Proxied to wspace-graph-svc's
1709
- * `executeCypher` resolver via the federated GraphQL gateway — no direct
1710
- * graph-DB access. (Pre-2026-05 this used `executeNGQL` against NebulaGraph;
1711
- * the federated resolver was renamed during the Apache AGE migration.)
1712
- */
1713
- async query(options) {
1714
- if (!options.query) {
1715
- throw new ValidationError("Cypher query is required");
1716
- }
1717
- logger.debug("[Graph] Executing Cypher query");
1718
- const query = `
1719
- query ExecuteCypher($query: String!, $bindVars: JSON, $limit: Int) {
1720
- executeCypher(query: $query, bindVars: $bindVars, limit: $limit) {
1721
- results
1722
- }
1723
- }
1724
- `;
1725
- const variables = {
1726
- query: options.query,
1727
- bindVars: options.bindVars,
1728
- limit: options.limit || 1e3
1729
- };
1730
- const response = await this.client.query(query, variables, this.context);
1731
- return response.executeCypher.results;
1732
- }
1733
- /**
1734
- * Get neighbors of a node
1735
- */
1736
- async getNeighbors(nodeId, options) {
1737
- logger.debug("[Graph] Getting neighbors", {
1738
- nodeId
1739
- });
1740
- const query = `
1741
- query GetNeighbors(
1742
- $nodeId: ID!
1743
- $direction: GraphDirection
1744
- $edgeTypes: [String!]
1745
- $limit: Int
1746
- ) {
1747
- getNeighbors(
1748
- nodeId: $nodeId
1749
- direction: $direction
1750
- edgeTypes: $edgeTypes
1751
- limit: $limit
1752
- ) {
1753
- nodes {
1754
- id
1755
- type
1756
- properties
1757
- workspaceId
1758
- organizationId
1759
- createdAt
1760
- updatedAt
1761
- }
1762
- edges {
1763
- id
1764
- from
1765
- to
1766
- type
1767
- properties
1768
- workspaceId
1769
- organizationId
1770
- createdAt
1771
- }
1772
- }
1773
- }
1774
- `;
1775
- const response = await this.client.query(query, {
1776
- nodeId,
1777
- direction: options?.direction || "outbound",
1778
- edgeTypes: options?.edgeTypes,
1779
- limit: options?.limit || 100
1780
- }, this.context);
1781
- return response.getNeighbors;
1782
- }
1783
- /**
1784
- * Get node degree (number of connections)
1785
- */
1786
- async getNodeDegree(nodeId, direction) {
1787
- logger.debug("[Graph] Getting node degree", {
1788
- nodeId
1789
- });
1790
- const query = `
1791
- query GetNodeDegree($nodeId: ID!, $direction: GraphDirection) {
1792
- getNodeDegree(nodeId: $nodeId, direction: $direction) {
1793
- inbound
1794
- outbound
1795
- total
1796
- }
1797
- }
1798
- `;
1799
- const response = await this.client.query(query, {
1800
- nodeId,
1801
- direction
1802
- }, this.context);
1803
- return response.getNodeDegree;
1804
- }
1805
- /**
1806
- * Find nodes by properties
1807
- */
1808
- async findNodes(type, filters, options) {
1809
- logger.debug("[Graph] Finding nodes", {
1810
- type,
1811
- filters
1812
- });
1813
- const query = `
1814
- query FindGraphNodes(
1815
- $type: String!
1816
- $filters: JSON!
1817
- $limit: Int
1818
- $offset: Int
1819
- ) {
1820
- findGraphNodes(
1821
- type: $type
1822
- filters: $filters
1823
- limit: $limit
1824
- offset: $offset
1825
- ) {
1826
- nodes {
1827
- id
1828
- type
1829
- properties
1830
- workspaceId
1831
- organizationId
1832
- createdAt
1833
- updatedAt
1834
- }
1835
- total
1836
- }
1837
- }
1838
- `;
1839
- const response = await this.client.query(query, {
1840
- type,
1841
- filters,
1842
- limit: options?.limit || 100,
1843
- offset: options?.offset || 0
1844
- }, this.context);
1845
- return response.findGraphNodes;
1846
- }
1847
- /**
1848
- * Batch create nodes
1849
- */
1850
- async createNodesBatch(nodes) {
1851
- logger.debug("[Graph] Batch creating nodes", {
1852
- count: nodes.length
1853
- });
1854
- const mutation = `
1855
- mutation CreateGraphNodesBatch($nodes: [CreateGraphNodeInput!]!) {
1856
- createGraphNodesBatch(nodes: $nodes) {
1857
- id
1858
- type
1859
- properties
1860
- workspaceId
1861
- organizationId
1862
- createdAt
1863
- updatedAt
1864
- }
1865
- }
1866
- `;
1867
- const response = await this.client.query(mutation, {
1868
- nodes
1869
- }, this.context);
1870
- logger.info("[Graph] Nodes batch created", {
1871
- count: response.createGraphNodesBatch.length
1872
- });
1873
- return response.createGraphNodesBatch;
1874
- }
1875
- /**
1876
- * Batch create edges
1877
- */
1878
- async createEdgesBatch(edges) {
1879
- logger.debug("[Graph] Batch creating edges", {
1880
- count: edges.length
1881
- });
1882
- const mutation = `
1883
- mutation CreateGraphEdgesBatch($edges: [CreateGraphEdgeInput!]!) {
1884
- createGraphEdgesBatch(edges: $edges) {
1885
- id
1886
- from
1887
- to
1888
- type
1889
- properties
1890
- workspaceId
1891
- organizationId
1892
- createdAt
1893
- }
1894
- }
1895
- `;
1896
- const response = await this.client.query(mutation, {
1897
- edges
1898
- }, this.context);
1899
- logger.info("[Graph] Edges batch created", {
1900
- count: response.createGraphEdgesBatch.length
1901
- });
1902
- return response.createGraphEdgesBatch;
1903
- }
1904
- };
1905
-
1906
- export { AUDIT_FIELDS, GraphEventsPublisher, GraphExportService, GraphModule, SOFT_DELETE_FIELDS, STANDARD_FIELDS, TENANT_FIELDS, createGraphEventsHelper, createGraphExportService, createPrismaGraphIntegration, createRelationshipFromEntity, defineEntity, defineGraphConfig, defineModuleGraph, defineRelationship, getGraphEventsPublisher, getGraphStats, graph_exports, initializeGraph, isGraphInitialized };
1907
- //# sourceMappingURL=chunk-OQDSAOG3.js.map
1908
- //# sourceMappingURL=chunk-OQDSAOG3.js.map