@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.
- package/configs/eslint/index.js +1 -1
- package/configs/tsconfig/tsconfig.json +1 -1
- package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
- package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
- package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
- package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
- package/dist/ai-credits/index.d.ts +2 -3
- package/dist/ai-credits/index.js +3 -4
- package/dist/ai-credits/index.js.map +1 -1
- package/dist/ai-credits-Ca-NNcVx.js +546 -0
- package/dist/ai-credits-Ca-NNcVx.js.map +1 -0
- package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
- package/dist/auth/index.d.ts +2 -77
- package/dist/auth/index.js +3 -7
- package/dist/auth/index.js.map +1 -1
- package/dist/auth-CEuBEBQN.js +228 -0
- package/dist/auth-CEuBEBQN.js.map +1 -0
- package/dist/cache/index.d.ts +2 -3
- package/dist/cache/index.js +3 -7
- package/dist/cache/index.js.map +1 -1
- package/dist/cache-CU0uLwcS.js +1837 -0
- package/dist/cache-CU0uLwcS.js.map +1 -0
- package/dist/captcha/index.d.ts +2 -1
- package/dist/captcha/index.js +3 -3
- package/dist/captcha/index.js.map +1 -1
- package/dist/captcha-BT7yh1YS.js +77 -0
- package/dist/captcha-BT7yh1YS.js.map +1 -0
- package/dist/client/internal-client.d.ts +4 -7
- package/dist/client/internal-client.js +172 -4
- package/dist/client/internal-client.js.map +1 -1
- package/dist/client-BgAEvDC2.d.ts +86 -0
- package/dist/client-DcZ3iGES.js +565 -0
- package/dist/client-DcZ3iGES.js.map +1 -0
- package/dist/collector-endpoint-iyQYeI50.js +50 -0
- package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
- package/dist/context-CZnXf2yb.js +247 -0
- package/dist/context-CZnXf2yb.js.map +1 -0
- package/dist/crypto/index.d.ts +2 -1
- package/dist/crypto/index.js +3 -3
- package/dist/crypto/index.js.map +1 -1
- package/dist/crypto-DO9fM0FO.js +145 -0
- package/dist/crypto-DO9fM0FO.js.map +1 -0
- package/dist/database/index.d.ts +104 -108
- package/dist/database/index.js +468 -6
- package/dist/database/index.js.map +1 -1
- package/dist/dataloader/index.d.ts +2 -1
- package/dist/dataloader/index.js +3 -3
- package/dist/dataloader/index.js.map +1 -1
- package/dist/dataloader-DwpT3YoS.js +294 -0
- package/dist/dataloader-DwpT3YoS.js.map +1 -0
- package/dist/deployed-environment-p_Tdl3sT.js +38 -0
- package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
- package/dist/dist-BGKdXVy3.js +1718 -0
- package/dist/dist-BGKdXVy3.js.map +1 -0
- package/dist/env-DdaoGjIt.js +74 -0
- package/dist/env-DdaoGjIt.js.map +1 -0
- package/dist/event-queue/index.d.ts +2 -7
- package/dist/event-queue/index.js +7 -9
- package/dist/event-queue/index.js.map +1 -1
- package/dist/event-queue-Cw-YJPY_.js +1384 -0
- package/dist/event-queue-Cw-YJPY_.js.map +1 -0
- package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
- package/dist/export/index.d.ts +2 -2
- package/dist/export/index.js +3 -14
- package/dist/export/index.js.map +1 -1
- package/dist/export-B6fphx8a.js +642 -0
- package/dist/export-B6fphx8a.js.map +1 -0
- package/dist/feature-flags/index.d.ts +2 -10
- package/dist/feature-flags/index.js +3 -6
- package/dist/feature-flags/index.js.map +1 -1
- package/dist/feature-flags-71oDkrUe.js +422 -0
- package/dist/feature-flags-71oDkrUe.js.map +1 -0
- package/dist/files/index.d.ts +2 -3
- package/dist/files/index.js +3 -4
- package/dist/files/index.js.map +1 -1
- package/dist/files-DjH0099H.js +830 -0
- package/dist/files-DjH0099H.js.map +1 -0
- package/dist/gateway/index.d.ts +4 -6
- package/dist/gateway/index.js +7 -13
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/security/index.d.ts +2 -2
- package/dist/gateway/security/index.js +3 -5
- package/dist/gateway/security/index.js.map +1 -1
- package/dist/gateway-DBFmxWks.js +50 -0
- package/dist/gateway-DBFmxWks.js.map +1 -0
- package/dist/graph/index.d.ts +3 -10
- package/dist/graph/index.js +4 -13
- package/dist/graph/index.js.map +1 -1
- package/dist/graph-DDYgIryR.js +2152 -0
- package/dist/graph-DDYgIryR.js.map +1 -0
- package/dist/graph-emitter-CdOXP7Tn.js +621 -0
- package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
- package/dist/graphql/index.d.ts +3 -2
- package/dist/graphql/index.js +4 -6
- package/dist/graphql/index.js.map +1 -1
- package/dist/graphql/services/index.d.ts +2 -24
- package/dist/graphql/services/index.js +3 -4
- package/dist/graphql/services/index.js.map +1 -1
- package/dist/graphql-DHAHHcww.js +161 -0
- package/dist/graphql-DHAHHcww.js.map +1 -0
- package/dist/graphql-DNkMkGBZ.d.ts +21 -0
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/index.js +3 -4
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n-BBMYFd0P.js +860 -0
- package/dist/i18n-BBMYFd0P.js.map +1 -0
- package/dist/import-optional-peer-B82VYxeX.js +18 -0
- package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
- package/dist/index-3KOZ1zN9.d.ts +233 -0
- package/dist/index-BBqooJ52.d.ts +45 -0
- package/dist/index-BGzMYJsm.d.ts +209 -0
- package/dist/index-BKwHQtHQ.d.ts +63 -0
- package/dist/index-BMIMnp6T.d.ts +8 -0
- package/dist/index-BQDsNAMR.d.ts +81 -0
- package/dist/index-BVOL7458.d.ts +10 -0
- package/dist/index-BcqQs-Uq.d.ts +69 -0
- package/dist/index-BeVtqGO-.d.ts +208 -0
- package/dist/index-BiTzGUZP.d.ts +114 -0
- package/dist/index-BqYfCQSP.d.ts +500 -0
- package/dist/index-C0qLquY0.d.ts +150 -0
- package/dist/index-C5uEKchX.d.ts +60 -0
- package/dist/index-CDOqxSIi.d.ts +37 -0
- package/dist/index-CG6wj66Y.d.ts +148 -0
- package/dist/index-CIgoeobA.d.ts +145 -0
- package/dist/index-CPQDMSFS.d.ts +103 -0
- package/dist/index-CSRcgkVi.d.ts +23 -0
- package/dist/index-CZTnQIRU.d.ts +341 -0
- package/dist/index-CaM9JUcc.d.ts +144 -0
- package/dist/index-CkT2aUr3.d.ts +704 -0
- package/dist/index-CliOgq6L.d.ts +203 -0
- package/dist/index-CnzbJZP7.d.ts +999 -0
- package/dist/index-D6UeLAye.d.ts +63 -0
- package/dist/index-DGgh9DWn.d.ts +59 -0
- package/dist/index-DY3dNhMN.d.ts +420 -0
- package/dist/index-DZC-2o9R.d.ts +207 -0
- package/dist/index-DqbGqfAy.d.ts +127 -0
- package/dist/index-Dt1HJPTX.d.ts +12 -0
- package/dist/index-DtI6aBtB.d.ts +22 -0
- package/dist/index-FKohsiex.d.ts +38 -0
- package/dist/index-FbXPfen7.d.ts +132 -0
- package/dist/index-MArCb8Aq.d.ts +306 -0
- package/dist/index-N-huORcj.d.ts +303 -0
- package/dist/index-YOShAwkq.d.ts +45 -0
- package/dist/index-bZKZUvBu.d.ts +646 -0
- package/dist/index-yBSjMY32.d.ts +24 -0
- package/dist/index.d.ts +501 -544
- package/dist/index.js +1820 -2171
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +2 -2
- package/dist/init/index.js +3 -16
- package/dist/init/index.js.map +1 -1
- package/dist/init-Dy3KhT6Y.js +325 -0
- package/dist/init-Dy3KhT6Y.js.map +1 -0
- package/dist/instrumentation/index.d.ts +3 -4
- package/dist/instrumentation/index.js +5 -5
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/instrumentation-xkkmDgJ0.js +1678 -0
- package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
- package/dist/lake/index.d.ts +50 -54
- package/dist/lake/index.js +169 -193
- package/dist/lake/index.js.map +1 -1
- package/dist/layer/index.d.ts +3 -2
- package/dist/layer/index.js +4 -5
- package/dist/layer/index.js.map +1 -1
- package/dist/layer-BZBZZWeV.d.ts +69 -0
- package/dist/layer-Bcix-WCl.js +105 -0
- package/dist/layer-Bcix-WCl.js.map +1 -0
- package/dist/layer-CEKy6cm8.js +252 -0
- package/dist/layer-CEKy6cm8.js.map +1 -0
- package/dist/lifecycle/index.d.ts +2 -1
- package/dist/lifecycle/index.js +3 -4
- package/dist/lifecycle/index.js.map +1 -1
- package/dist/lifecycle-DeoLSX0U.js +76 -0
- package/dist/lifecycle-DeoLSX0U.js.map +1 -0
- package/dist/logger/index.d.ts +2 -3
- package/dist/logger/index.js +3 -3
- package/dist/logger/index.js.map +1 -1
- package/dist/logger-B6rCpb7D.js +290 -0
- package/dist/logger-B6rCpb7D.js.map +1 -0
- package/dist/metrics/index.d.ts +13 -14
- package/dist/metrics/index.js +3 -4
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics-BrLwNUrb.js +52 -0
- package/dist/metrics-BrLwNUrb.js.map +1 -0
- package/dist/metrics-collector-C2eShrlW.js +922 -0
- package/dist/metrics-collector-C2eShrlW.js.map +1 -0
- package/dist/middleware/index.d.ts +3 -3
- package/dist/middleware/index.js +3 -4
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware-CUxJVUpD.js +1243 -0
- package/dist/middleware-CUxJVUpD.js.map +1 -0
- package/dist/middleware-Cq0zFMGp.js +253 -0
- package/dist/middleware-Cq0zFMGp.js.map +1 -0
- package/dist/notifications/index.d.ts +2 -5
- package/dist/notifications/index.js +3 -6
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications-CdETrtFK.js +869 -0
- package/dist/notifications-CdETrtFK.js.map +1 -0
- package/dist/observability/index.d.ts +2 -3
- package/dist/observability/index.js +3 -4
- package/dist/observability/index.js.map +1 -1
- package/dist/observability-DBDXipTU.js +272 -0
- package/dist/observability-DBDXipTU.js.map +1 -0
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +3 -5
- package/dist/platform/index.js.map +1 -1
- package/dist/platform-DZwczW7v.js +1510 -0
- package/dist/platform-DZwczW7v.js.map +1 -0
- package/dist/prisma/generator/index.d.ts +1 -1
- package/dist/prisma/generator/index.js +97 -84
- package/dist/prisma/generator/index.js.map +1 -1
- package/dist/prisma/index.d.ts +4 -7
- package/dist/prisma/index.js +5 -12
- package/dist/prisma/index.js.map +1 -1
- package/dist/prisma-BzOOdt79.js +863 -0
- package/dist/prisma-BzOOdt79.js.map +1 -0
- package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
- package/dist/product-alias/index.d.ts +2 -1
- package/dist/product-alias/index.js +3 -3
- package/dist/product-alias/index.js.map +1 -1
- package/dist/product-alias-BPqtskMq.js +273 -0
- package/dist/product-alias-BPqtskMq.js.map +1 -0
- package/dist/rbac/index.d.ts +2 -122
- package/dist/rbac/index.js +3 -6
- package/dist/rbac/index.js.map +1 -1
- package/dist/rbac-BB9l9Xph.js +1486 -0
- package/dist/rbac-BB9l9Xph.js.map +1 -0
- package/dist/resource-caps/index.d.ts +66 -72
- package/dist/resource-caps/index.js +430 -5
- package/dist/resource-caps/index.js.map +1 -1
- package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
- package/dist/sdk-Dju9o-sq.js +124 -0
- package/dist/sdk-Dju9o-sq.js.map +1 -0
- package/dist/security-DIG-95Ic.js +1647 -0
- package/dist/security-DIG-95Ic.js.map +1 -0
- package/dist/server/index.d.ts +7 -164
- package/dist/server/index.js +2000 -1507
- package/dist/server/index.js.map +1 -1
- package/dist/service-jwt-Bu-WNA_-.js +80 -0
- package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
- package/dist/services-BWzfz7vG.js +102 -0
- package/dist/services-BWzfz7vG.js.map +1 -0
- package/dist/sharding/index.d.ts +41 -44
- package/dist/sharding/index.js +156 -137
- package/dist/sharding/index.js.map +1 -1
- package/dist/sharing/index.d.ts +2 -1
- package/dist/sharing/index.js +3 -4
- package/dist/sharing/index.js.map +1 -1
- package/dist/sharing-CflDsSJ-.js +911 -0
- package/dist/sharing-CflDsSJ-.js.map +1 -0
- package/dist/stub-BqwKn4eh.js +630 -0
- package/dist/stub-BqwKn4eh.js.map +1 -0
- package/dist/tags/index.d.ts +2 -3
- package/dist/tags/index.js +3 -4
- package/dist/tags/index.js.map +1 -1
- package/dist/tags-B5xpbgsk.js +868 -0
- package/dist/{chunk-PBZFAAOM.js.map → tags-B5xpbgsk.js.map} +1 -1
- package/dist/telemetry/index.d.ts +64 -76
- package/dist/telemetry/index.js +369 -201
- package/dist/telemetry/index.js.map +1 -1
- package/dist/temporal/index.d.ts +2 -148
- package/dist/temporal/index.js +3 -5
- package/dist/temporal/index.js.map +1 -1
- package/dist/temporal-B534uYK8.js +706 -0
- package/dist/temporal-B534uYK8.js.map +1 -0
- package/dist/tracker/index.d.ts +5 -11
- package/dist/tracker/index.js +5 -20
- package/dist/tracker/index.js.map +1 -1
- package/dist/tracker-BQVoEFUo.js +839 -0
- package/dist/tracker-BQVoEFUo.js.map +1 -0
- package/dist/types-BYMYND1L.js +44 -0
- package/dist/types-BYMYND1L.js.map +1 -0
- package/dist/types-C6EKaS3V.d.ts +106 -0
- package/dist/types-CWybW61E.d.ts +323 -0
- package/dist/types-C_yfu3XK.d.ts +34 -0
- package/dist/types-Cj2RWXbz.js +90 -0
- package/dist/types-Cj2RWXbz.js.map +1 -0
- package/dist/types-DgaQqvxo.d.ts +70 -0
- package/dist/usage/index.d.ts +2 -213
- package/dist/usage/index.js +3 -15
- package/dist/usage/index.js.map +1 -1
- package/dist/usage-BKFZiWQn.js +682 -0
- package/dist/usage-BKFZiWQn.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils-DL85Tnbn.js +500 -0
- package/dist/utils-DL85Tnbn.js.map +1 -0
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +3 -3
- package/dist/validation/index.js.map +1 -1
- package/dist/validation-CPUITdMk.js +762 -0
- package/dist/validation-CPUITdMk.js.map +1 -0
- package/dist/workspace-extension-COrC0dYi.js +979 -0
- package/dist/workspace-extension-COrC0dYi.js.map +1 -0
- package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
- package/package.json +7 -10
- package/dist/EventQueueFactory-PP534MBQ.js +0 -8
- package/dist/EventQueueFactory-PP534MBQ.js.map +0 -1
- package/dist/chunk-4XIBXZ6J.js +0 -276
- package/dist/chunk-4XIBXZ6J.js.map +0 -1
- package/dist/chunk-554Z4C2K.js +0 -1006
- package/dist/chunk-554Z4C2K.js.map +0 -1
- package/dist/chunk-5CAFHK2Z.js +0 -107
- package/dist/chunk-5CAFHK2Z.js.map +0 -1
- package/dist/chunk-63ZXJ42X.js +0 -451
- package/dist/chunk-63ZXJ42X.js.map +0 -1
- package/dist/chunk-6XEXJATV.js +0 -304
- package/dist/chunk-6XEXJATV.js.map +0 -1
- package/dist/chunk-726AR6Q7.js +0 -1532
- package/dist/chunk-726AR6Q7.js.map +0 -1
- package/dist/chunk-7EISSMFP.js +0 -617
- package/dist/chunk-7EISSMFP.js.map +0 -1
- package/dist/chunk-A5F6Z5UE.js +0 -21
- package/dist/chunk-A5F6Z5UE.js.map +0 -1
- package/dist/chunk-A6DE32ZS.js +0 -1507
- package/dist/chunk-A6DE32ZS.js.map +0 -1
- package/dist/chunk-BJQOGOVW.js +0 -602
- package/dist/chunk-BJQOGOVW.js.map +0 -1
- package/dist/chunk-CFXWH2IS.js +0 -52
- package/dist/chunk-CFXWH2IS.js.map +0 -1
- package/dist/chunk-DIOS6L7M.js +0 -690
- package/dist/chunk-DIOS6L7M.js.map +0 -1
- package/dist/chunk-DJNHR37J.js +0 -1185
- package/dist/chunk-DJNHR37J.js.map +0 -1
- package/dist/chunk-DRWH5XCJ.js +0 -876
- package/dist/chunk-DRWH5XCJ.js.map +0 -1
- package/dist/chunk-E4QNLVY4.js +0 -909
- package/dist/chunk-E4QNLVY4.js.map +0 -1
- package/dist/chunk-E6OAFS7A.js +0 -1346
- package/dist/chunk-E6OAFS7A.js.map +0 -1
- package/dist/chunk-EBDHIL7V.js +0 -774
- package/dist/chunk-EBDHIL7V.js.map +0 -1
- package/dist/chunk-ELU7VL3E.js +0 -245
- package/dist/chunk-ELU7VL3E.js.map +0 -1
- package/dist/chunk-FZRODKIN.js +0 -31
- package/dist/chunk-FZRODKIN.js.map +0 -1
- package/dist/chunk-GCIB76AJ.js +0 -882
- package/dist/chunk-GCIB76AJ.js.map +0 -1
- package/dist/chunk-HC6MPUIH.js +0 -1571
- package/dist/chunk-HC6MPUIH.js.map +0 -1
- package/dist/chunk-I3KOWRT3.js +0 -89
- package/dist/chunk-I3KOWRT3.js.map +0 -1
- package/dist/chunk-ID3WR4JS.js +0 -509
- package/dist/chunk-ID3WR4JS.js.map +0 -1
- package/dist/chunk-JVMAQOA3.js +0 -521
- package/dist/chunk-JVMAQOA3.js.map +0 -1
- package/dist/chunk-K56L7NUR.js +0 -1444
- package/dist/chunk-K56L7NUR.js.map +0 -1
- package/dist/chunk-KH4TRQCO.js +0 -1063
- package/dist/chunk-KH4TRQCO.js.map +0 -1
- package/dist/chunk-KJOSPVB2.js +0 -57
- package/dist/chunk-KJOSPVB2.js.map +0 -1
- package/dist/chunk-KO2ZXZ7W.js +0 -61
- package/dist/chunk-KO2ZXZ7W.js.map +0 -1
- package/dist/chunk-KS2HQCJR.js +0 -56
- package/dist/chunk-KS2HQCJR.js.map +0 -1
- package/dist/chunk-LA5KPWZ2.js +0 -413
- package/dist/chunk-LA5KPWZ2.js.map +0 -1
- package/dist/chunk-MESLAC5W.js +0 -574
- package/dist/chunk-MESLAC5W.js.map +0 -1
- package/dist/chunk-MWPYA2HD.js +0 -94
- package/dist/chunk-MWPYA2HD.js.map +0 -1
- package/dist/chunk-NUB5GQTU.js +0 -270
- package/dist/chunk-NUB5GQTU.js.map +0 -1
- package/dist/chunk-O2JMZHNH.js +0 -1908
- package/dist/chunk-O2JMZHNH.js.map +0 -1
- package/dist/chunk-OBBCR6WY.js +0 -277
- package/dist/chunk-OBBCR6WY.js.map +0 -1
- package/dist/chunk-OBZQ4AJC.js +0 -272
- package/dist/chunk-OBZQ4AJC.js.map +0 -1
- package/dist/chunk-OXNCBE7P.js +0 -971
- package/dist/chunk-OXNCBE7P.js.map +0 -1
- package/dist/chunk-PBZFAAOM.js +0 -941
- package/dist/chunk-PYD44IHJ.js +0 -728
- package/dist/chunk-PYD44IHJ.js.map +0 -1
- package/dist/chunk-QVPIACWD.js +0 -679
- package/dist/chunk-QVPIACWD.js.map +0 -1
- package/dist/chunk-QWNNFE4P.js +0 -41
- package/dist/chunk-QWNNFE4P.js.map +0 -1
- package/dist/chunk-RU266375.js +0 -327
- package/dist/chunk-RU266375.js.map +0 -1
- package/dist/chunk-RYTSVGGA.js +0 -1624
- package/dist/chunk-RYTSVGGA.js.map +0 -1
- package/dist/chunk-RZOFS2BQ.js +0 -225
- package/dist/chunk-RZOFS2BQ.js.map +0 -1
- package/dist/chunk-SBS4S2PJ.js +0 -100
- package/dist/chunk-SBS4S2PJ.js.map +0 -1
- package/dist/chunk-SPRG6G6G.js +0 -530
- package/dist/chunk-SPRG6G6G.js.map +0 -1
- package/dist/chunk-STWFX5E2.js +0 -233
- package/dist/chunk-STWFX5E2.js.map +0 -1
- package/dist/chunk-UNASM5VJ.js +0 -419
- package/dist/chunk-UNASM5VJ.js.map +0 -1
- package/dist/chunk-VAT66FJA.js +0 -245
- package/dist/chunk-VAT66FJA.js.map +0 -1
- package/dist/chunk-VFCMR5GX.js +0 -49
- package/dist/chunk-VFCMR5GX.js.map +0 -1
- package/dist/chunk-VGAHZKNJ.js +0 -66
- package/dist/chunk-VGAHZKNJ.js.map +0 -1
- package/dist/chunk-VTJTAAXC.js +0 -627
- package/dist/chunk-VTJTAAXC.js.map +0 -1
- package/dist/chunk-VXVLKRU6.js +0 -758
- package/dist/chunk-VXVLKRU6.js.map +0 -1
- package/dist/chunk-WWUU5ETI.js +0 -163
- package/dist/chunk-WWUU5ETI.js.map +0 -1
- package/dist/chunk-XE4OXN2W.js +0 -10
- package/dist/chunk-XE4OXN2W.js.map +0 -1
- package/dist/chunk-XOJORS75.js +0 -1853
- package/dist/chunk-XOJORS75.js.map +0 -1
- package/dist/chunk-YMZEUTD2.js +0 -110
- package/dist/chunk-YMZEUTD2.js.map +0 -1
- package/dist/chunk-ZZK3WEDI.js +0 -181
- package/dist/chunk-ZZK3WEDI.js.map +0 -1
- package/dist/client-CCXpAZ2r.d.ts +0 -89
- package/dist/client-DSI_760t.d.ts +0 -36
- package/dist/client-JU6T3UPB.js +0 -11
- package/dist/client-JU6T3UPB.js.map +0 -1
- package/dist/dist-2X4Q7PJA.js +0 -1491
- package/dist/dist-2X4Q7PJA.js.map +0 -1
- package/dist/env-4UWSUS64.js +0 -4
- package/dist/env-4UWSUS64.js.map +0 -1
- package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
- package/dist/graphql-CMHMQjvd.d.ts +0 -23
- package/dist/i18n-Qm2AkPC-.d.ts +0 -33
- package/dist/index--yvpa6ay.d.ts +0 -83
- package/dist/index-4gKQKZ2B.d.ts +0 -71
- package/dist/index-5x0XMKXN.d.ts +0 -149
- package/dist/index-B70b5mYS.d.ts +0 -33
- package/dist/index-B8KrxO4j.d.ts +0 -755
- package/dist/index-BOuDKnqD.d.ts +0 -201
- package/dist/index-BTMt4OjA.d.ts +0 -201
- package/dist/index-BejbszA7.d.ts +0 -39
- package/dist/index-BkeOYZye.d.ts +0 -198
- package/dist/index-BuAj5nXg.d.ts +0 -83
- package/dist/index-BvkVcW8I.d.ts +0 -349
- package/dist/index-CWmH_-RZ.d.ts +0 -247
- package/dist/index-CbgWNcus.d.ts +0 -258
- package/dist/index-CmfPeQza.d.ts +0 -166
- package/dist/index-CmpG-zak.d.ts +0 -607
- package/dist/index-CoMKgL-p.d.ts +0 -12
- package/dist/index-D8HGwglK.d.ts +0 -541
- package/dist/index-DCaVm66D.d.ts +0 -1101
- package/dist/index-DE2w7E0d.d.ts +0 -83
- package/dist/index-DSOpj8DI.d.ts +0 -17
- package/dist/index-DW9q22GH.d.ts +0 -75
- package/dist/index-DnjJ9CwI.d.ts +0 -347
- package/dist/index-DwMJZ8PP.d.ts +0 -317
- package/dist/index-PaojfSdd.d.ts +0 -71
- package/dist/index-aHtYvc3i.d.ts +0 -284
- package/dist/index-e_18DzAg.d.ts +0 -18
- package/dist/index-ffmipXSA.d.ts +0 -55
- package/dist/index-joONjwLt.d.ts +0 -33
- package/dist/index-kssw5ziY.d.ts +0 -250
- package/dist/index-lFffh5-G.d.ts +0 -125
- package/dist/index-pxYge_6k.d.ts +0 -79
- package/dist/layer-Cv9vSwBx.d.ts +0 -70
- package/dist/pino-logger-H4HPW5P6.js +0 -5
- package/dist/pino-logger-H4HPW5P6.js.map +0 -1
- package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
- package/dist/sdk-L75WWUP3.js +0 -156
- package/dist/sdk-L75WWUP3.js.map +0 -1
- package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
- package/dist/types-Bo2wkjSP.d.ts +0 -35
- package/dist/types-DVpvrAhd.d.ts +0 -71
- package/dist/types-DgJ4lDYA.d.ts +0 -108
- package/dist/types-USOv09qy.d.ts +0 -327
- package/dist/workspace-guard-NXVYYBVJ.js +0 -5
- package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
|
@@ -0,0 +1,2152 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-ad2WFvuA.js";
|
|
2
|
+
import { c as ValidationError } from "./types-Cj2RWXbz.js";
|
|
3
|
+
import { a as logger } from "./logger-B6rCpb7D.js";
|
|
4
|
+
import { _ as shouldSyncEntity, c as ensureServiceApplicationName, d as createEntityEvent, f as createRelationshipEvent, g as parseRelationship, h as getCollectionForEntity, m as extractMinimalFields, n as withDeferredGraphEvents, p as extractEntityTitle, t as addGraphExtension, v as shouldSyncRelationship, y as GraphRegistry } from "./middleware-CUxJVUpD.js";
|
|
5
|
+
import "./event-queue-Cw-YJPY_.js";
|
|
6
|
+
import { r as getGraphEventEmitter, t as GraphEventEmitterImpl } from "./graph-emitter-CdOXP7Tn.js";
|
|
7
|
+
|
|
8
|
+
// src/graph/utils/prisma-helpers.ts
|
|
9
|
+
/**
|
|
10
|
+
* Create a reusable Prisma graph integration manager
|
|
11
|
+
*
|
|
12
|
+
* This factory function creates a complete set of utilities for integrating
|
|
13
|
+
* Prisma with the Graph module, handling initialization, client access, and cleanup.
|
|
14
|
+
*
|
|
15
|
+
* @template TPrismaClient The Prisma client type (supports generic for type safety)
|
|
16
|
+
* @param options Configuration options
|
|
17
|
+
* @returns Object with initialization functions and client accessors
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Standard Prisma with auto-initialization (default)
|
|
22
|
+
* import { PrismaClient as PrismaClientClass } from '@prisma/client';
|
|
23
|
+
* import { createPrismaGraphIntegration } from '@burdenoff/be-sdk/graph/utils/prisma-helpers';
|
|
24
|
+
* import { graphConfig } from './graph.config.js';
|
|
25
|
+
*
|
|
26
|
+
* const {
|
|
27
|
+
* prisma
|
|
28
|
+
* } = createPrismaGraphIntegration({
|
|
29
|
+
* serviceName: 'Tags Service',
|
|
30
|
+
* graphConfig,
|
|
31
|
+
* createPrismaClient: () => new PrismaClientClass(),
|
|
32
|
+
* // autoInit: true is default - initialization happens automatically
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Just use it! Initialization happens automatically on first access
|
|
36
|
+
* const tags = await prisma.universalTag.findMany();
|
|
37
|
+
*
|
|
38
|
+
* // If you need manual control over initialization timing:
|
|
39
|
+
* const {
|
|
40
|
+
* initializeGraphEmitter,
|
|
41
|
+
* prisma
|
|
42
|
+
* } = createPrismaGraphIntegration({
|
|
43
|
+
* serviceName: 'Tags Service',
|
|
44
|
+
* graphConfig,
|
|
45
|
+
* createPrismaClient: () => new PrismaClientClass(),
|
|
46
|
+
* autoInit: false, // Disable auto-initialization
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // In your server startup (with autoInit: false):
|
|
50
|
+
* await initializeGraphEmitter();
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Prisma 7 with Adapter (VibeControls Service)
|
|
56
|
+
* import { Pool } from 'pg';
|
|
57
|
+
* import { PrismaClient as PrismaClientClass } from '@prisma/client';
|
|
58
|
+
* import { PrismaPg } from '@prisma/adapter-pg';
|
|
59
|
+
* import { createPrismaGraphIntegration } from '@burdenoff/be-sdk/graph/utils/prisma-helpers';
|
|
60
|
+
* import { graphConfig } from './graph.config.js';
|
|
61
|
+
*
|
|
62
|
+
* const {
|
|
63
|
+
* initializeGraphEmitter,
|
|
64
|
+
* db,
|
|
65
|
+
* prisma
|
|
66
|
+
* } = createPrismaGraphIntegration({
|
|
67
|
+
* serviceName: 'VibeControls Service',
|
|
68
|
+
* graphConfig,
|
|
69
|
+
* createPrismaClient: () => {
|
|
70
|
+
* const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
71
|
+
* const adapter = new PrismaPg(pool);
|
|
72
|
+
* return new PrismaClientClass({ adapter });
|
|
73
|
+
* },
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
function createPrismaGraphIntegration(options) {
|
|
78
|
+
const { serviceName, graphConfig, productName = "workspaces", validateRuntime = process.env.NODE_ENV !== "production", autoInit = true, createPrismaClient, bulkOperations } = options;
|
|
79
|
+
ensureServiceApplicationName(productName);
|
|
80
|
+
const state = {
|
|
81
|
+
graphEmitter: null,
|
|
82
|
+
basePrismaClient: null,
|
|
83
|
+
extendedPrismaClient: null,
|
|
84
|
+
emitterInitialized: false,
|
|
85
|
+
initializationPromise: null
|
|
86
|
+
};
|
|
87
|
+
function getOrCreateBasePrismaClient() {
|
|
88
|
+
state.basePrismaClient ??= createPrismaClient();
|
|
89
|
+
return state.basePrismaClient;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Initialize the graph event emitter
|
|
93
|
+
* Call this once during application startup before using the database
|
|
94
|
+
*
|
|
95
|
+
* If called multiple times, returns the same initialization promise
|
|
96
|
+
*
|
|
97
|
+
* @returns Promise that resolves when initialization is complete
|
|
98
|
+
*/
|
|
99
|
+
async function initializeGraphEmitter() {
|
|
100
|
+
if (state.initializationPromise) return state.initializationPromise;
|
|
101
|
+
if (state.emitterInitialized) return;
|
|
102
|
+
state.initializationPromise = (async () => {
|
|
103
|
+
if (!process.env["GRAPH_EVENTS_ENABLED"] || process.env["GRAPH_EVENTS_ENABLED"] !== "true") {
|
|
104
|
+
logger.info(`[${serviceName}] Graph events disabled`);
|
|
105
|
+
state.emitterInitialized = true;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
if (!process.env["NATS_SERVERS"] && process.env["NATS_URL"]) process.env["NATS_SERVERS"] = process.env["NATS_URL"];
|
|
110
|
+
state.graphEmitter = new GraphEventEmitterImpl();
|
|
111
|
+
logger.info(`[${serviceName}] Graph event emitter initialized`);
|
|
112
|
+
state.emitterInitialized = true;
|
|
113
|
+
const basePrisma = getOrCreateBasePrismaClient();
|
|
114
|
+
state.extendedPrismaClient = initializeGraph(basePrisma, graphConfig, {
|
|
115
|
+
productName,
|
|
116
|
+
eventEmitter: state.graphEmitter,
|
|
117
|
+
enabled: true,
|
|
118
|
+
validateRuntime,
|
|
119
|
+
...bulkOperations && { bulkOperations }
|
|
120
|
+
});
|
|
121
|
+
logger.info(`[${serviceName}] Graph integration initialized successfully`);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
logger.error(`[${serviceName}] Failed to initialize graph integration:`, error);
|
|
124
|
+
state.graphEmitter = null;
|
|
125
|
+
state.extendedPrismaClient = null;
|
|
126
|
+
state.emitterInitialized = true;
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
return state.initializationPromise;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get the Prisma client with graph integration
|
|
133
|
+
*
|
|
134
|
+
* Returns the extended Prisma client if graph events are enabled,
|
|
135
|
+
* otherwise returns the integration's singleton base client.
|
|
136
|
+
*
|
|
137
|
+
* When autoInit is enabled, triggers initialization on first call
|
|
138
|
+
*
|
|
139
|
+
* @returns Object with the Prisma client
|
|
140
|
+
*/
|
|
141
|
+
function db() {
|
|
142
|
+
if (autoInit && !state.emitterInitialized && !state.initializationPromise) {
|
|
143
|
+
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.`);
|
|
144
|
+
initializeGraphEmitter();
|
|
145
|
+
}
|
|
146
|
+
if (!process.env["GRAPH_EVENTS_ENABLED"] || process.env["GRAPH_EVENTS_ENABLED"] !== "true" || !state.extendedPrismaClient) return { client: getOrCreateBasePrismaClient() };
|
|
147
|
+
return { client: state.extendedPrismaClient };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Direct Prisma client accessor via Proxy
|
|
151
|
+
*
|
|
152
|
+
* A Proxy-based accessor that provides direct access to Prisma models
|
|
153
|
+
* without needing to call a function.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const tags = await prisma.universalTag.findMany();
|
|
158
|
+
* await prisma.$transaction([...]);
|
|
159
|
+
* await prisma.$queryRaw`SELECT * FROM "UniversalTag"`;
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
const prisma = new Proxy({}, { get(_, prop) {
|
|
163
|
+
const { client } = db();
|
|
164
|
+
const value = client[prop];
|
|
165
|
+
if (typeof value === "function") return value.bind(client);
|
|
166
|
+
return value;
|
|
167
|
+
} });
|
|
168
|
+
/**
|
|
169
|
+
* Cleanup function to disconnect clients and close emitters
|
|
170
|
+
* Call this during application shutdown
|
|
171
|
+
*/
|
|
172
|
+
async function cleanup() {
|
|
173
|
+
if (state.graphEmitter) {
|
|
174
|
+
await state.graphEmitter.disconnect();
|
|
175
|
+
logger.info(`[${serviceName}] Graph event emitter disconnected`);
|
|
176
|
+
}
|
|
177
|
+
const clientToDisconnect = state.extendedPrismaClient ?? state.basePrismaClient;
|
|
178
|
+
if (clientToDisconnect) {
|
|
179
|
+
await clientToDisconnect.$disconnect();
|
|
180
|
+
logger.info(`[${serviceName}] Prisma client disconnected`);
|
|
181
|
+
}
|
|
182
|
+
state.extendedPrismaClient = null;
|
|
183
|
+
state.basePrismaClient = null;
|
|
184
|
+
state.emitterInitialized = false;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
/**
|
|
188
|
+
* Initialize graph event emitter
|
|
189
|
+
*
|
|
190
|
+
* With autoInit=true (default), this is called automatically on first database access.
|
|
191
|
+
* You can still call it manually for explicit initialization timing.
|
|
192
|
+
*
|
|
193
|
+
* With autoInit=false, you must call this during application startup.
|
|
194
|
+
*/
|
|
195
|
+
initializeGraphEmitter,
|
|
196
|
+
/**
|
|
197
|
+
* Get Prisma client with graph integration
|
|
198
|
+
* Returns { client: PrismaClient }
|
|
199
|
+
*
|
|
200
|
+
* If autoInit is enabled, triggers initialization on first call.
|
|
201
|
+
*/
|
|
202
|
+
db,
|
|
203
|
+
/**
|
|
204
|
+
* Direct Prisma client accessor (Proxy-based)
|
|
205
|
+
* Use this for most database operations
|
|
206
|
+
*
|
|
207
|
+
* If autoInit is enabled, initialization happens automatically.
|
|
208
|
+
*/
|
|
209
|
+
prisma,
|
|
210
|
+
/**
|
|
211
|
+
* Cleanup function for graceful shutdown
|
|
212
|
+
*/
|
|
213
|
+
cleanup,
|
|
214
|
+
/**
|
|
215
|
+
* Get the raw graph emitter instance (for advanced use cases)
|
|
216
|
+
*/
|
|
217
|
+
getGraphEmitter: () => state.graphEmitter,
|
|
218
|
+
/**
|
|
219
|
+
* Check if emitter is initialized
|
|
220
|
+
*/
|
|
221
|
+
isInitialized: () => state.emitterInitialized
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/graph/events-helper.ts
|
|
226
|
+
/**
|
|
227
|
+
* Graph Events Helper
|
|
228
|
+
*
|
|
229
|
+
* Provides a configurable helper for publishing graph entity and relationship events.
|
|
230
|
+
* This allows modules to define their entity types and automatically get event publishing
|
|
231
|
+
* for graph synchronization.
|
|
232
|
+
*
|
|
233
|
+
* @module graph/events-helper
|
|
234
|
+
* @category Graph
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* import { createGraphEventsHelper } from '@burdenoff/be-sdk/graph';
|
|
239
|
+
*
|
|
240
|
+
* // Create a helper for the tags module
|
|
241
|
+
* const graphEvents = createGraphEventsHelper({
|
|
242
|
+
* moduleName: 'module-tags',
|
|
243
|
+
* entities: {
|
|
244
|
+
* vocabulary: {
|
|
245
|
+
* type: 'UniversalTagVocabulary',
|
|
246
|
+
* getOrgId: (data) => data.tenantId as string,
|
|
247
|
+
* getWorkspaceId: (data) => data.workspaceId as string,
|
|
248
|
+
* },
|
|
249
|
+
* tag: {
|
|
250
|
+
* type: 'UniversalTag',
|
|
251
|
+
* getOrgId: (data) => data.tenantId as string,
|
|
252
|
+
* getWorkspaceId: (data) => data.workspaceId as string,
|
|
253
|
+
* onCreated: async (data, publisher) => {
|
|
254
|
+
* // Publish parent relationship if exists
|
|
255
|
+
* if (data.parentId) {
|
|
256
|
+
* await publisher.publishRelationshipCreated({ ... });
|
|
257
|
+
* }
|
|
258
|
+
* },
|
|
259
|
+
* },
|
|
260
|
+
* },
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* // Use the helper
|
|
264
|
+
* await graphEvents.vocabulary.created(vocabularyData);
|
|
265
|
+
* await graphEvents.tag.updated(tagData);
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
/**
|
|
269
|
+
* Graph Events Publisher
|
|
270
|
+
*
|
|
271
|
+
* Singleton service for publishing entity and relationship events
|
|
272
|
+
* to the graph synchronization system.
|
|
273
|
+
*/
|
|
274
|
+
var GraphEventsPublisher = class GraphEventsPublisher {
|
|
275
|
+
static instance = null;
|
|
276
|
+
productName;
|
|
277
|
+
initialized = false;
|
|
278
|
+
emitter = null;
|
|
279
|
+
constructor(productName = "unknown") {
|
|
280
|
+
this.productName = productName;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get singleton instance
|
|
284
|
+
*/
|
|
285
|
+
static getInstance(productName) {
|
|
286
|
+
if (!GraphEventsPublisher.instance) GraphEventsPublisher.instance = new GraphEventsPublisher(productName);
|
|
287
|
+
return GraphEventsPublisher.instance;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Set the product name (useful when using singleton)
|
|
291
|
+
*/
|
|
292
|
+
setProductName(name) {
|
|
293
|
+
this.productName = name;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Initialize the publisher
|
|
297
|
+
*/
|
|
298
|
+
async initialize() {
|
|
299
|
+
if (this.initialized) return;
|
|
300
|
+
try {
|
|
301
|
+
this.emitter = getGraphEventEmitter();
|
|
302
|
+
logger.info("[GraphEventsPublisher] Graph event emitter initialized");
|
|
303
|
+
this.initialized = true;
|
|
304
|
+
const natsUrl = process.env["NATS_URL"] || process.env["NATS_SERVERS"];
|
|
305
|
+
if (natsUrl) logger.info(`[GraphEventsPublisher] NATS configured: ${natsUrl}`);
|
|
306
|
+
else logger.warn("[GraphEventsPublisher] NATS not configured, using in-memory fallback");
|
|
307
|
+
} catch (error) {
|
|
308
|
+
logger.error("[GraphEventsPublisher] Failed to initialize:", error);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Ensure initialized before publishing
|
|
313
|
+
*/
|
|
314
|
+
async ensureInitialized() {
|
|
315
|
+
if (!this.initialized) await this.initialize();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Publish entity created event
|
|
319
|
+
*/
|
|
320
|
+
async publishEntityCreated(entity, options) {
|
|
321
|
+
await this.publishEntityEvent("entity.created", entity, options);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Publish entity updated event
|
|
325
|
+
*/
|
|
326
|
+
async publishEntityUpdated(entity, options) {
|
|
327
|
+
await this.publishEntityEvent("entity.updated", entity, options);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Publish entity deleted event
|
|
331
|
+
*/
|
|
332
|
+
async publishEntityDeleted(entity, options) {
|
|
333
|
+
await this.publishEntityEvent("entity.deleted", entity, options);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Publish relationship created event
|
|
337
|
+
*/
|
|
338
|
+
async publishRelationshipCreated(relationship, organizationId, options) {
|
|
339
|
+
await this.publishRelationshipEvent("relationship.created", relationship, organizationId, options);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Publish relationship deleted event
|
|
343
|
+
*/
|
|
344
|
+
async publishRelationshipDeleted(relationship, organizationId, options) {
|
|
345
|
+
await this.publishRelationshipEvent("relationship.deleted", relationship, organizationId, options);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Internal method to publish entity events
|
|
349
|
+
*/
|
|
350
|
+
async publishEntityEvent(eventType, entity, options) {
|
|
351
|
+
await this.ensureInitialized();
|
|
352
|
+
if (!this.emitter) {
|
|
353
|
+
logger.warn("[GraphEventsPublisher] Emitter not initialized, skipping event");
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
await this.emitter.publishEntityEvent(eventType, {
|
|
358
|
+
id: entity.id,
|
|
359
|
+
type: entity.type,
|
|
360
|
+
data: entity.data
|
|
361
|
+
}, {
|
|
362
|
+
productName: this.productName,
|
|
363
|
+
organizationId: entity.organizationId || "unknown",
|
|
364
|
+
workspaceId: entity.workspaceId,
|
|
365
|
+
actorId: options?.userId
|
|
366
|
+
});
|
|
367
|
+
logger.debug(`[GraphEventsPublisher] Published ${eventType} for ${entity.type}:${entity.id}`);
|
|
368
|
+
} catch (error) {
|
|
369
|
+
logger.error(`[GraphEventsPublisher] Failed to publish ${eventType} for ${entity.type}:${entity.id}:`, error);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Internal method to publish relationship events
|
|
374
|
+
*/
|
|
375
|
+
async publishRelationshipEvent(eventType, relationship, organizationId, options) {
|
|
376
|
+
await this.ensureInitialized();
|
|
377
|
+
if (!this.emitter) {
|
|
378
|
+
logger.warn("[GraphEventsPublisher] Emitter not initialized, skipping event");
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
try {
|
|
382
|
+
await this.emitter.publishEntityEvent(eventType, {
|
|
383
|
+
id: `${relationship.from.id}_${relationship.to.id}`,
|
|
384
|
+
type: relationship.relationType,
|
|
385
|
+
data: {
|
|
386
|
+
from: relationship.from,
|
|
387
|
+
to: relationship.to,
|
|
388
|
+
metadata: relationship.metadata
|
|
389
|
+
}
|
|
390
|
+
}, {
|
|
391
|
+
productName: this.productName,
|
|
392
|
+
organizationId,
|
|
393
|
+
actorId: options?.userId
|
|
394
|
+
});
|
|
395
|
+
logger.debug(`[GraphEventsPublisher] Published ${eventType} for ${relationship.relationType}`);
|
|
396
|
+
} catch (error) {
|
|
397
|
+
logger.error(`[GraphEventsPublisher] Failed to publish ${eventType} for ${relationship.relationType}:`, error);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Shutdown the publisher
|
|
402
|
+
*/
|
|
403
|
+
async shutdown() {
|
|
404
|
+
this.initialized = false;
|
|
405
|
+
this.emitter = null;
|
|
406
|
+
logger.info("[GraphEventsPublisher] Shutdown complete");
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Reset singleton (for testing)
|
|
410
|
+
*/
|
|
411
|
+
static reset() {
|
|
412
|
+
GraphEventsPublisher.instance = null;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Get singleton GraphEventsPublisher instance
|
|
417
|
+
*/
|
|
418
|
+
function getGraphEventsPublisher(productName) {
|
|
419
|
+
return GraphEventsPublisher.getInstance(productName);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Create a graph events helper with configured entity types
|
|
423
|
+
*/
|
|
424
|
+
function createGraphEventsHelper(config) {
|
|
425
|
+
const publisher = new GraphEventsPublisher(config.moduleName);
|
|
426
|
+
const helper = {};
|
|
427
|
+
for (const [name, entityConfig] of Object.entries(config.entities)) helper[name] = {
|
|
428
|
+
created: async (data, options) => {
|
|
429
|
+
await publisher.publishEntityCreated({
|
|
430
|
+
id: data["id"],
|
|
431
|
+
type: entityConfig.type,
|
|
432
|
+
data,
|
|
433
|
+
organizationId: entityConfig.getOrgId?.(data),
|
|
434
|
+
workspaceId: entityConfig.getWorkspaceId?.(data)
|
|
435
|
+
}, options);
|
|
436
|
+
if (entityConfig.onCreated) await entityConfig.onCreated(data, publisher, options);
|
|
437
|
+
},
|
|
438
|
+
updated: async (data, options) => {
|
|
439
|
+
await publisher.publishEntityUpdated({
|
|
440
|
+
id: data["id"],
|
|
441
|
+
type: entityConfig.type,
|
|
442
|
+
data,
|
|
443
|
+
organizationId: entityConfig.getOrgId?.(data),
|
|
444
|
+
workspaceId: entityConfig.getWorkspaceId?.(data)
|
|
445
|
+
}, options);
|
|
446
|
+
if (entityConfig.onUpdated) await entityConfig.onUpdated(data, publisher, options);
|
|
447
|
+
},
|
|
448
|
+
deleted: async (data, options) => {
|
|
449
|
+
await publisher.publishEntityDeleted({
|
|
450
|
+
id: data["id"],
|
|
451
|
+
type: entityConfig.type,
|
|
452
|
+
data,
|
|
453
|
+
organizationId: entityConfig.getOrgId?.(data),
|
|
454
|
+
workspaceId: entityConfig.getWorkspaceId?.(data)
|
|
455
|
+
}, options);
|
|
456
|
+
if (entityConfig.onDeleted) await entityConfig.onDeleted(data, publisher, options);
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
return helper;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/graph/export-service.ts
|
|
463
|
+
/**
|
|
464
|
+
* Graph Export Service
|
|
465
|
+
*
|
|
466
|
+
* Provides a configurable service for exporting entities and relationships
|
|
467
|
+
* to be consumed by the graph module for synchronization.
|
|
468
|
+
*
|
|
469
|
+
* @module graph/export-service
|
|
470
|
+
* @category Graph
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```typescript
|
|
474
|
+
* import { createGraphExportService } from '@burdenoff/be-sdk/graph';
|
|
475
|
+
*
|
|
476
|
+
* const exportService = createGraphExportService({
|
|
477
|
+
* moduleName: 'module-tags',
|
|
478
|
+
* config: tagsGraphConfig,
|
|
479
|
+
* fetchers: {
|
|
480
|
+
* UniversalTag: async (workspaceId) => db.universalTag.findMany({ where: { workspaceId } }),
|
|
481
|
+
* UniversalTagVocabulary: async (workspaceId) => db.universalTagVocabulary.findMany({ where: { workspaceId } }),
|
|
482
|
+
* },
|
|
483
|
+
* relationshipFetchers: {
|
|
484
|
+
* tagHierarchy: async (workspaceId) => fetchTagHierarchyRelationships(workspaceId),
|
|
485
|
+
* },
|
|
486
|
+
* });
|
|
487
|
+
*
|
|
488
|
+
* // Export all data
|
|
489
|
+
* const result = await exportService.exportAll(organizationId, workspaceId);
|
|
490
|
+
*
|
|
491
|
+
* // Export only entities
|
|
492
|
+
* const entities = await exportService.exportEntities(organizationId, workspaceId);
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
/**
|
|
496
|
+
* Graph Export Service
|
|
497
|
+
*
|
|
498
|
+
* Handles exporting entity and relationship data for graph synchronization.
|
|
499
|
+
*/
|
|
500
|
+
var GraphExportService = class {
|
|
501
|
+
moduleName;
|
|
502
|
+
config;
|
|
503
|
+
fetchers;
|
|
504
|
+
relationshipFetchers;
|
|
505
|
+
customTransformer;
|
|
506
|
+
constructor(serviceConfig) {
|
|
507
|
+
this.moduleName = serviceConfig.moduleName;
|
|
508
|
+
this.config = serviceConfig.config;
|
|
509
|
+
this.fetchers = serviceConfig.fetchers;
|
|
510
|
+
this.relationshipFetchers = serviceConfig.relationshipFetchers || {};
|
|
511
|
+
this.customTransformer = serviceConfig.transformEntity;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get the graph configuration schema
|
|
515
|
+
*/
|
|
516
|
+
getSchema() {
|
|
517
|
+
const entities = {};
|
|
518
|
+
const relationships = {};
|
|
519
|
+
for (const [entityType, config] of Object.entries(this.config.entities)) entities[entityType] = {
|
|
520
|
+
fields: Array.isArray(config.fields) ? config.fields : [
|
|
521
|
+
"id",
|
|
522
|
+
"createdAt",
|
|
523
|
+
"updatedAt"
|
|
524
|
+
],
|
|
525
|
+
collection: config.collection || "product_entities"
|
|
526
|
+
};
|
|
527
|
+
if (this.config.relationships) for (const [relType, config] of Object.entries(this.config.relationships)) relationships[relType] = {
|
|
528
|
+
from: config.from,
|
|
529
|
+
fromType: config.from,
|
|
530
|
+
to: config.to,
|
|
531
|
+
toType: config.to,
|
|
532
|
+
edgeType: config.label || "relates_to"
|
|
533
|
+
};
|
|
534
|
+
return {
|
|
535
|
+
moduleName: this.config.moduleName,
|
|
536
|
+
entities,
|
|
537
|
+
relationships
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Export all entities for a given organization/workspace
|
|
542
|
+
*/
|
|
543
|
+
async exportEntities(organizationId, workspaceId, entityTypes) {
|
|
544
|
+
const result = {};
|
|
545
|
+
const typesToExport = entityTypes || Object.keys(this.config.entities);
|
|
546
|
+
for (const entityType of typesToExport) {
|
|
547
|
+
if (!this.config.entities[entityType]) continue;
|
|
548
|
+
const fetcher = this.fetchers[entityType];
|
|
549
|
+
if (!fetcher) {
|
|
550
|
+
logger.warn(`[GraphExportService] No fetcher for ${entityType}`);
|
|
551
|
+
result[entityType] = [];
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
try {
|
|
555
|
+
result[entityType] = (await fetcher(organizationId, workspaceId)).map((item) => this.transformEntity(entityType, item));
|
|
556
|
+
} catch (error) {
|
|
557
|
+
logger.error(`[GraphExportService] Error fetching ${entityType}:`, error);
|
|
558
|
+
result[entityType] = [];
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return result;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Export all relationships for a given organization/workspace
|
|
565
|
+
*/
|
|
566
|
+
async exportRelationships(organizationId, workspaceId) {
|
|
567
|
+
const relationships = [];
|
|
568
|
+
for (const [name, fetcher] of Object.entries(this.relationshipFetchers)) try {
|
|
569
|
+
const rels = await fetcher(organizationId, workspaceId);
|
|
570
|
+
relationships.push(...rels);
|
|
571
|
+
} catch (error) {
|
|
572
|
+
logger.error(`[GraphExportService] Error fetching relationships ${name}:`, error);
|
|
573
|
+
}
|
|
574
|
+
return relationships;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Export complete graph data (schema + entities + relationships)
|
|
578
|
+
*/
|
|
579
|
+
async exportAll(organizationId, workspaceId) {
|
|
580
|
+
const schema = this.getSchema();
|
|
581
|
+
const entities = await this.exportEntities(organizationId, workspaceId);
|
|
582
|
+
const relationships = await this.exportRelationships(organizationId, workspaceId);
|
|
583
|
+
const entityCounts = {};
|
|
584
|
+
let totalEntities = 0;
|
|
585
|
+
for (const [type, items] of Object.entries(entities)) {
|
|
586
|
+
entityCounts[type] = items.length;
|
|
587
|
+
totalEntities += items.length;
|
|
588
|
+
}
|
|
589
|
+
return {
|
|
590
|
+
moduleName: this.config.moduleName,
|
|
591
|
+
productSource: this.moduleName,
|
|
592
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
593
|
+
schema: {
|
|
594
|
+
entities: schema.entities,
|
|
595
|
+
relationships: schema.relationships
|
|
596
|
+
},
|
|
597
|
+
data: {
|
|
598
|
+
entities,
|
|
599
|
+
relationships
|
|
600
|
+
},
|
|
601
|
+
stats: {
|
|
602
|
+
totalEntities,
|
|
603
|
+
totalRelationships: relationships.length,
|
|
604
|
+
entityCounts
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Transform a database entity to graph export format
|
|
610
|
+
*/
|
|
611
|
+
transformEntity(type, item) {
|
|
612
|
+
if (this.customTransformer) return this.customTransformer(type, item);
|
|
613
|
+
const { id, createdAt, updatedAt, workspaceId, tenantId, ...data } = item;
|
|
614
|
+
return {
|
|
615
|
+
id,
|
|
616
|
+
type,
|
|
617
|
+
data,
|
|
618
|
+
organizationId: tenantId,
|
|
619
|
+
workspaceId,
|
|
620
|
+
createdAt: createdAt instanceof Date ? createdAt.toISOString() : String(createdAt),
|
|
621
|
+
updatedAt: updatedAt instanceof Date ? updatedAt.toISOString() : String(updatedAt)
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* Create a graph export service instance
|
|
627
|
+
*/
|
|
628
|
+
function createGraphExportService(config) {
|
|
629
|
+
return new GraphExportService(config);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Helper function to create a relationship from entity data
|
|
633
|
+
*/
|
|
634
|
+
function createRelationshipFromEntity(entity, relationConfig, relationType) {
|
|
635
|
+
const fromId = entity[relationConfig.from];
|
|
636
|
+
const toId = entity[relationConfig.to];
|
|
637
|
+
if (!fromId || !toId) return null;
|
|
638
|
+
const metadata = relationConfig.extractMetadata ? relationConfig.extractMetadata(entity) : {};
|
|
639
|
+
return {
|
|
640
|
+
id: `${relationType}_${entity["id"] || fromId}_${toId}`,
|
|
641
|
+
type: relationType,
|
|
642
|
+
fromId,
|
|
643
|
+
fromType: relationConfig.from || "Entity",
|
|
644
|
+
toId,
|
|
645
|
+
toType: relationConfig.to || "Entity",
|
|
646
|
+
metadata,
|
|
647
|
+
createdAt: entity["createdAt"] instanceof Date ? entity["createdAt"].toISOString() : String(entity["createdAt"] || (/* @__PURE__ */ new Date()).toISOString()),
|
|
648
|
+
updatedAt: entity["updatedAt"] instanceof Date ? entity["updatedAt"].toISOString() : String(entity["updatedAt"] || (/* @__PURE__ */ new Date()).toISOString())
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// src/graph/module-graph.ts
|
|
653
|
+
/**
|
|
654
|
+
* Unified Module Graph Definition
|
|
655
|
+
*
|
|
656
|
+
* Provides a single, simplified configuration for graph integration in microservices.
|
|
657
|
+
* Combines schema definition, event publishing, and data export into one unified API.
|
|
658
|
+
*
|
|
659
|
+
* @module graph/module-graph
|
|
660
|
+
* @category Graph
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```typescript
|
|
664
|
+
* // In your microservice: src/modules/[module]/graph.ts
|
|
665
|
+
* import { defineModuleGraph } from '@burdenoff/be-sdk/graph';
|
|
666
|
+
* import { getDb } from '@burdenoff/be-sdk/prisma';
|
|
667
|
+
*
|
|
668
|
+
* export const tagsGraph = defineModuleGraph({
|
|
669
|
+
* moduleName: 'module-tags',
|
|
670
|
+
*
|
|
671
|
+
* entities: {
|
|
672
|
+
* vocabulary: {
|
|
673
|
+
* type: 'UniversalTagVocabulary',
|
|
674
|
+
* fields: ['id', 'name', 'description', 'workspaceId'],
|
|
675
|
+
* getOrgId: (data) => data.tenantId,
|
|
676
|
+
* getWorkspaceId: (data) => data.workspaceId,
|
|
677
|
+
* fetch: async (_, workspaceId) =>
|
|
678
|
+
* getDb().client.universalTagVocabulary.findMany({
|
|
679
|
+
* where: { deletedAt: null, ...(workspaceId && { workspaceId }) },
|
|
680
|
+
* }),
|
|
681
|
+
* },
|
|
682
|
+
*
|
|
683
|
+
* tag: {
|
|
684
|
+
* type: 'UniversalTag',
|
|
685
|
+
* fields: ['id', 'name', 'vocabularyId', 'parentId'],
|
|
686
|
+
* getOrgId: (data) => data.tenantId,
|
|
687
|
+
* getWorkspaceId: (data) => data.workspaceId,
|
|
688
|
+
* onCreated: async (data, ctx) => {
|
|
689
|
+
* if (data.parentId) {
|
|
690
|
+
* await ctx.publishRelationship({
|
|
691
|
+
* from: { id: data.id, type: 'UniversalTag' },
|
|
692
|
+
* to: { id: data.parentId, type: 'UniversalTag' },
|
|
693
|
+
* relationType: 'child_of',
|
|
694
|
+
* });
|
|
695
|
+
* }
|
|
696
|
+
* },
|
|
697
|
+
* fetch: async (_, workspaceId) =>
|
|
698
|
+
* getDb().client.universalTag.findMany({
|
|
699
|
+
* where: { deletedAt: null, ...(workspaceId && { workspaceId }) },
|
|
700
|
+
* }),
|
|
701
|
+
* },
|
|
702
|
+
* },
|
|
703
|
+
*
|
|
704
|
+
* relationships: {
|
|
705
|
+
* tagHierarchy: {
|
|
706
|
+
* fromType: 'UniversalTag',
|
|
707
|
+
* toType: 'UniversalTag',
|
|
708
|
+
* edgeType: 'child_of',
|
|
709
|
+
* fetch: async (_, workspaceId) => {
|
|
710
|
+
* const tags = await getDb().client.universalTag.findMany({
|
|
711
|
+
* where: { deletedAt: null, parentId: { not: null }, ...(workspaceId && { workspaceId }) },
|
|
712
|
+
* });
|
|
713
|
+
* return tags.map(t => ({
|
|
714
|
+
* id: `hierarchy_${t.id}`,
|
|
715
|
+
* fromId: t.id,
|
|
716
|
+
* toId: t.parentId!,
|
|
717
|
+
* metadata: { hierarchyPath: t.hierarchyPath },
|
|
718
|
+
* }));
|
|
719
|
+
* },
|
|
720
|
+
* },
|
|
721
|
+
* },
|
|
722
|
+
* });
|
|
723
|
+
*
|
|
724
|
+
* // Usage in providers:
|
|
725
|
+
* await tagsGraph.events.vocabulary.created(data);
|
|
726
|
+
* await tagsGraph.events.tag.updated(data);
|
|
727
|
+
*
|
|
728
|
+
* // Usage in index.ts:
|
|
729
|
+
* await tagsGraph.initialize();
|
|
730
|
+
* const schema = tagsGraph.getSchema();
|
|
731
|
+
* const exportData = await tagsGraph.exportAll(orgId, workspaceId);
|
|
732
|
+
* ```
|
|
733
|
+
*/
|
|
734
|
+
/**
|
|
735
|
+
* Internal graph events publisher
|
|
736
|
+
*/
|
|
737
|
+
var GraphEventsPublisherInternal = class {
|
|
738
|
+
productName;
|
|
739
|
+
initialized = false;
|
|
740
|
+
emitter = null;
|
|
741
|
+
constructor(productName) {
|
|
742
|
+
this.productName = productName;
|
|
743
|
+
}
|
|
744
|
+
async initialize() {
|
|
745
|
+
if (this.initialized) return;
|
|
746
|
+
try {
|
|
747
|
+
this.emitter = getGraphEventEmitter();
|
|
748
|
+
logger.info(`[ModuleGraph:${this.productName}] Graph event emitter initialized`);
|
|
749
|
+
this.initialized = true;
|
|
750
|
+
const natsUrl = process.env["NATS_URL"] || process.env["NATS_SERVERS"];
|
|
751
|
+
if (natsUrl) logger.info(`[ModuleGraph:${this.productName}] NATS configured: ${natsUrl}`);
|
|
752
|
+
else logger.warn(`[ModuleGraph:${this.productName}] NATS not configured, using in-memory fallback`);
|
|
753
|
+
} catch (error) {
|
|
754
|
+
logger.error(`[ModuleGraph:${this.productName}] Failed to initialize:`, error);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
async ensureInitialized() {
|
|
758
|
+
if (!this.initialized) await this.initialize();
|
|
759
|
+
}
|
|
760
|
+
async publishEntityCreated(entity, options, rbac) {
|
|
761
|
+
await this.publishEntityEvent("entity.created", entity, options, rbac);
|
|
762
|
+
}
|
|
763
|
+
async publishEntityUpdated(entity, options, rbac) {
|
|
764
|
+
await this.publishEntityEvent("entity.updated", entity, options, rbac);
|
|
765
|
+
}
|
|
766
|
+
async publishEntityDeleted(entity, options, rbac) {
|
|
767
|
+
await this.publishEntityEvent("entity.deleted", entity, options, rbac);
|
|
768
|
+
}
|
|
769
|
+
async publishRelationshipCreated(relationship, organizationId, options) {
|
|
770
|
+
await this.publishRelationshipEvent("relationship.created", relationship, organizationId, options);
|
|
771
|
+
}
|
|
772
|
+
async publishRelationshipDeleted(relationship, organizationId, options) {
|
|
773
|
+
await this.publishRelationshipEvent("relationship.deleted", relationship, organizationId, options);
|
|
774
|
+
}
|
|
775
|
+
async publishEntityEvent(eventType, entity, options, rbac) {
|
|
776
|
+
await this.ensureInitialized();
|
|
777
|
+
if (!this.emitter) {
|
|
778
|
+
logger.warn(`[ModuleGraph:${this.productName}] Emitter not initialized, skipping event`);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
try {
|
|
782
|
+
await this.emitter.publishEntityEvent(eventType, {
|
|
783
|
+
id: entity.id,
|
|
784
|
+
type: entity.type,
|
|
785
|
+
data: entity.data
|
|
786
|
+
}, {
|
|
787
|
+
productName: this.productName,
|
|
788
|
+
organizationId: options?.organizationId ?? entity.organizationId ?? "unknown",
|
|
789
|
+
workspaceId: entity.workspaceId,
|
|
790
|
+
actorId: options?.actorId
|
|
791
|
+
}, rbac);
|
|
792
|
+
logger.debug(`[ModuleGraph:${this.productName}] Published ${eventType} for ${entity.type}:${entity.id}`, { hasRbac: !!rbac });
|
|
793
|
+
} catch (error) {
|
|
794
|
+
logger.error(`[ModuleGraph:${this.productName}] Failed to publish ${eventType}:`, error);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
async publishRelationshipEvent(eventType, relationship, organizationId, options) {
|
|
798
|
+
await this.ensureInitialized();
|
|
799
|
+
if (!this.emitter) {
|
|
800
|
+
logger.warn(`[ModuleGraph:${this.productName}] Emitter not initialized, skipping event`);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
try {
|
|
804
|
+
await this.emitter.publishEntityEvent(eventType, {
|
|
805
|
+
id: `${relationship.from.id}_${relationship.to.id}`,
|
|
806
|
+
type: relationship.relationType,
|
|
807
|
+
data: {
|
|
808
|
+
from: relationship.from,
|
|
809
|
+
to: relationship.to,
|
|
810
|
+
metadata: relationship.metadata
|
|
811
|
+
}
|
|
812
|
+
}, {
|
|
813
|
+
productName: this.productName,
|
|
814
|
+
organizationId,
|
|
815
|
+
actorId: options?.actorId
|
|
816
|
+
});
|
|
817
|
+
logger.debug(`[ModuleGraph:${this.productName}] Published ${eventType} for ${relationship.relationType}`);
|
|
818
|
+
} catch (error) {
|
|
819
|
+
logger.error(`[ModuleGraph:${this.productName}] Failed to publish ${eventType}:`, error);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
async shutdown() {
|
|
823
|
+
this.initialized = false;
|
|
824
|
+
this.emitter = null;
|
|
825
|
+
logger.info(`[ModuleGraph:${this.productName}] Shutdown complete`);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
/**
|
|
829
|
+
* Define a module graph configuration
|
|
830
|
+
*
|
|
831
|
+
* This is the main entry point for configuring graph integration in a microservice.
|
|
832
|
+
* It provides a unified API for schema definition, event publishing, and data export.
|
|
833
|
+
*
|
|
834
|
+
* @param definition - The module graph definition
|
|
835
|
+
* @returns A ModuleGraph instance with all graph functionality
|
|
836
|
+
*
|
|
837
|
+
* @example
|
|
838
|
+
* ```typescript
|
|
839
|
+
* export const myGraph = defineModuleGraph({
|
|
840
|
+
* moduleName: 'module-tags',
|
|
841
|
+
* entities: {
|
|
842
|
+
* tag: {
|
|
843
|
+
* type: 'UniversalTag',
|
|
844
|
+
* fields: ['id', 'name'],
|
|
845
|
+
* getOrgId: (d) => d.tenantId as string,
|
|
846
|
+
* fetch: async () => db.tag.findMany(),
|
|
847
|
+
* },
|
|
848
|
+
* },
|
|
849
|
+
* });
|
|
850
|
+
*
|
|
851
|
+
* // In providers:
|
|
852
|
+
* await myGraph.events.tag.created(tagData);
|
|
853
|
+
*
|
|
854
|
+
* // In index.ts:
|
|
855
|
+
* await myGraph.initialize();
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
858
|
+
function defineModuleGraph(definition) {
|
|
859
|
+
const { moduleName, productSource, entities, relationships = {} } = definition;
|
|
860
|
+
const publisher = new GraphEventsPublisherInternal(productSource ?? moduleName);
|
|
861
|
+
const events = {};
|
|
862
|
+
for (const [entityName, entityDef] of Object.entries(entities)) {
|
|
863
|
+
const getOrgId = entityDef.getOrgId || (() => void 0);
|
|
864
|
+
const getWorkspaceId = entityDef.getWorkspaceId || (() => void 0);
|
|
865
|
+
const createEventContext = () => ({
|
|
866
|
+
publishRelationship: async (data, orgId) => {
|
|
867
|
+
await publisher.publishRelationshipCreated(data, orgId || "unknown");
|
|
868
|
+
},
|
|
869
|
+
deleteRelationship: async (data, orgId) => {
|
|
870
|
+
await publisher.publishRelationshipDeleted(data, orgId || "unknown");
|
|
871
|
+
},
|
|
872
|
+
getOrgId,
|
|
873
|
+
getWorkspaceId
|
|
874
|
+
});
|
|
875
|
+
const buildRbacMetadata = (data) => {
|
|
876
|
+
if (!entityDef.rbac) return void 0;
|
|
877
|
+
const rbacConfig = entityDef.rbac;
|
|
878
|
+
if (rbacConfig.createResource === false) return void 0;
|
|
879
|
+
const entityId = data["id"];
|
|
880
|
+
const title = data["name"] || data["title"] || data["label"] || entityId;
|
|
881
|
+
return {
|
|
882
|
+
resourceTypeName: rbacConfig.resourceTypeName,
|
|
883
|
+
name: rbacConfig.extractName?.(data) ?? title,
|
|
884
|
+
identifier: rbacConfig.extractIdentifier?.(data) ?? entityId,
|
|
885
|
+
parentResourceIdentifier: rbacConfig.parentResourceField ? data[rbacConfig.parentResourceField] : void 0,
|
|
886
|
+
createResource: rbacConfig.createResource ?? true
|
|
887
|
+
};
|
|
888
|
+
};
|
|
889
|
+
events[entityName] = {
|
|
890
|
+
created: async (data, options) => {
|
|
891
|
+
await publisher.publishEntityCreated({
|
|
892
|
+
id: data["id"],
|
|
893
|
+
type: entityDef.type,
|
|
894
|
+
data,
|
|
895
|
+
organizationId: getOrgId(data),
|
|
896
|
+
workspaceId: getWorkspaceId(data)
|
|
897
|
+
}, options, buildRbacMetadata(data));
|
|
898
|
+
if (entityDef.onCreated) await entityDef.onCreated(data, createEventContext(), options);
|
|
899
|
+
},
|
|
900
|
+
updated: async (data, options) => {
|
|
901
|
+
await publisher.publishEntityUpdated({
|
|
902
|
+
id: data["id"],
|
|
903
|
+
type: entityDef.type,
|
|
904
|
+
data,
|
|
905
|
+
organizationId: getOrgId(data),
|
|
906
|
+
workspaceId: getWorkspaceId(data)
|
|
907
|
+
}, options, buildRbacMetadata(data));
|
|
908
|
+
if (entityDef.onUpdated) await entityDef.onUpdated(data, createEventContext(), options);
|
|
909
|
+
},
|
|
910
|
+
deleted: async (data, options) => {
|
|
911
|
+
await publisher.publishEntityDeleted({
|
|
912
|
+
id: data["id"],
|
|
913
|
+
type: entityDef.type,
|
|
914
|
+
data,
|
|
915
|
+
organizationId: getOrgId(data),
|
|
916
|
+
workspaceId: getWorkspaceId(data)
|
|
917
|
+
}, options, buildRbacMetadata(data));
|
|
918
|
+
if (entityDef.onDeleted) await entityDef.onDeleted(data, createEventContext(), options);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
const getSchema = () => {
|
|
923
|
+
const entitySchema = {};
|
|
924
|
+
const relationshipSchema = {};
|
|
925
|
+
for (const [, entityDef] of Object.entries(entities)) entitySchema[entityDef.type] = {
|
|
926
|
+
fields: entityDef.fields || [
|
|
927
|
+
"id",
|
|
928
|
+
"createdAt",
|
|
929
|
+
"updatedAt"
|
|
930
|
+
],
|
|
931
|
+
collection: entityDef.collection || "entity"
|
|
932
|
+
};
|
|
933
|
+
for (const [relName, relDef] of Object.entries(relationships)) relationshipSchema[relName] = {
|
|
934
|
+
fromType: relDef.fromType,
|
|
935
|
+
toType: relDef.toType,
|
|
936
|
+
edgeType: relDef.edgeType
|
|
937
|
+
};
|
|
938
|
+
return {
|
|
939
|
+
moduleName,
|
|
940
|
+
entities: entitySchema,
|
|
941
|
+
relationships: relationshipSchema
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
const exportEntities = async (organizationId, workspaceId, entityTypes) => {
|
|
945
|
+
const result = {};
|
|
946
|
+
for (const [entityName, entityDef] of Object.entries(entities)) {
|
|
947
|
+
if (entityTypes && !entityTypes.includes(entityDef.type)) continue;
|
|
948
|
+
if (!entityDef.fetch) {
|
|
949
|
+
result[entityDef.type] = [];
|
|
950
|
+
continue;
|
|
951
|
+
}
|
|
952
|
+
try {
|
|
953
|
+
const items = await entityDef.fetch(organizationId, workspaceId);
|
|
954
|
+
result[entityDef.type] = items.map((item) => {
|
|
955
|
+
const { id, createdAt, updatedAt, workspaceId: ws, tenantId, ...data } = item;
|
|
956
|
+
return {
|
|
957
|
+
id,
|
|
958
|
+
type: entityDef.type,
|
|
959
|
+
data,
|
|
960
|
+
organizationId: tenantId,
|
|
961
|
+
workspaceId: ws,
|
|
962
|
+
createdAt: createdAt instanceof Date ? createdAt.toISOString() : String(createdAt),
|
|
963
|
+
updatedAt: updatedAt instanceof Date ? updatedAt.toISOString() : String(updatedAt)
|
|
964
|
+
};
|
|
965
|
+
});
|
|
966
|
+
} catch (error) {
|
|
967
|
+
logger.error(`[ModuleGraph:${moduleName}] Error fetching ${entityName}:`, error);
|
|
968
|
+
result[entityDef.type] = [];
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return result;
|
|
972
|
+
};
|
|
973
|
+
const exportRelationships = async (organizationId, workspaceId) => {
|
|
974
|
+
const result = [];
|
|
975
|
+
for (const [relName, relDef] of Object.entries(relationships)) {
|
|
976
|
+
if (!relDef.fetch) continue;
|
|
977
|
+
try {
|
|
978
|
+
const items = await relDef.fetch(organizationId, workspaceId);
|
|
979
|
+
for (const item of items) result.push({
|
|
980
|
+
id: item.id,
|
|
981
|
+
type: relDef.edgeType,
|
|
982
|
+
fromId: item.fromId,
|
|
983
|
+
fromType: relDef.fromType,
|
|
984
|
+
toId: item.toId,
|
|
985
|
+
toType: relDef.toType,
|
|
986
|
+
metadata: item.metadata || {},
|
|
987
|
+
createdAt: item.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
988
|
+
updatedAt: item.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
989
|
+
});
|
|
990
|
+
} catch (error) {
|
|
991
|
+
logger.error(`[ModuleGraph:${moduleName}] Error fetching relationship ${relName}:`, error);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
return result;
|
|
995
|
+
};
|
|
996
|
+
const exportAll = async (organizationId, workspaceId) => {
|
|
997
|
+
const schema = getSchema();
|
|
998
|
+
const entitiesData = await exportEntities(organizationId, workspaceId);
|
|
999
|
+
const relationshipsData = await exportRelationships(organizationId, workspaceId);
|
|
1000
|
+
const entityCounts = {};
|
|
1001
|
+
let totalEntities = 0;
|
|
1002
|
+
for (const [type, items] of Object.entries(entitiesData)) {
|
|
1003
|
+
entityCounts[type] = items.length;
|
|
1004
|
+
totalEntities += items.length;
|
|
1005
|
+
}
|
|
1006
|
+
return {
|
|
1007
|
+
moduleName,
|
|
1008
|
+
productSource: productSource ?? moduleName,
|
|
1009
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1010
|
+
schema,
|
|
1011
|
+
data: {
|
|
1012
|
+
entities: entitiesData,
|
|
1013
|
+
relationships: relationshipsData
|
|
1014
|
+
},
|
|
1015
|
+
stats: {
|
|
1016
|
+
totalEntities,
|
|
1017
|
+
totalRelationships: relationshipsData.length,
|
|
1018
|
+
entityCounts
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
return {
|
|
1023
|
+
moduleName,
|
|
1024
|
+
events,
|
|
1025
|
+
initialize: () => publisher.initialize(),
|
|
1026
|
+
shutdown: () => publisher.shutdown(),
|
|
1027
|
+
getSchema,
|
|
1028
|
+
exportEntities,
|
|
1029
|
+
exportRelationships,
|
|
1030
|
+
exportAll,
|
|
1031
|
+
getPublisher: () => publisher
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// src/graph/config/builder.ts
|
|
1036
|
+
/**
|
|
1037
|
+
* Standard field presets for automatic inclusion
|
|
1038
|
+
*/
|
|
1039
|
+
const STANDARD_FIELDS = [
|
|
1040
|
+
"id",
|
|
1041
|
+
"createdAt",
|
|
1042
|
+
"updatedAt"
|
|
1043
|
+
];
|
|
1044
|
+
const SOFT_DELETE_FIELDS = ["deletedAt"];
|
|
1045
|
+
const AUDIT_FIELDS = ["metadata", "context"];
|
|
1046
|
+
const TENANT_FIELDS = ["workspaceId", "tenantId"];
|
|
1047
|
+
/**
|
|
1048
|
+
* Smart default implementations
|
|
1049
|
+
*/
|
|
1050
|
+
/**
|
|
1051
|
+
* Default getWorkspaceId - reads workspaceId field directly
|
|
1052
|
+
*/
|
|
1053
|
+
const DEFAULT_GET_WORKSPACE_ID = (data) => data["workspaceId"];
|
|
1054
|
+
/**
|
|
1055
|
+
* Default getOrgId - tries tenantId first, then context.organizationId
|
|
1056
|
+
* This handles both direct tenantId fields and context-based organization references
|
|
1057
|
+
*/
|
|
1058
|
+
const DEFAULT_GET_ORG_ID = (data) => {
|
|
1059
|
+
if (data["tenantId"]) return data["tenantId"];
|
|
1060
|
+
return data["context"]?.["organizationId"];
|
|
1061
|
+
};
|
|
1062
|
+
/**
|
|
1063
|
+
* Default extractTitle - generates {entityType}_{id} pattern
|
|
1064
|
+
*
|
|
1065
|
+
* This provides a consistent, unambiguous title for all entities.
|
|
1066
|
+
* For example: workspace_abc123, agent_xyz789, session_def456
|
|
1067
|
+
*
|
|
1068
|
+
* The entityType is passed in via the entity configuration context.
|
|
1069
|
+
*/
|
|
1070
|
+
function createDefaultExtractTitle(entityType) {
|
|
1071
|
+
return (data) => {
|
|
1072
|
+
const id = data["id"];
|
|
1073
|
+
if (typeof id === "string" && id.length > 0) return `${entityType.toLowerCase()}_${id}`;
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Generate relationship label from camelCase name to SCREAMING_SNAKE_CASE
|
|
1078
|
+
* Example: TagToVocabulary → TAG_TO_VOCABULARY
|
|
1079
|
+
*/
|
|
1080
|
+
function generateRelationshipLabel(relationshipName) {
|
|
1081
|
+
return relationshipName.replace(/([A-Z])/g, "_$1").toUpperCase().replace(/^_/, "");
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Extract fields from Prisma model, excluding SDK defaults
|
|
1085
|
+
*
|
|
1086
|
+
* This function auto-extracts scalar fields from a Prisma model using the
|
|
1087
|
+
* generated prisma-fields.ts, then applies exclusions and inclusions.
|
|
1088
|
+
*
|
|
1089
|
+
* @param modelName - Prisma model name (e.g., 'User', 'Project', 'Agent')
|
|
1090
|
+
* @param options - Field extraction options
|
|
1091
|
+
* @param prismaFieldsModule - Generated Prisma fields module
|
|
1092
|
+
* @returns Array of field names for the entity
|
|
1093
|
+
*/
|
|
1094
|
+
function extractFieldsFromModel(modelName, options, prismaFieldsModule) {
|
|
1095
|
+
if (!prismaFieldsModule.hasModel(modelName)) {
|
|
1096
|
+
const availableModels = prismaFieldsModule.getAllModelNames().join(", ");
|
|
1097
|
+
throw new Error(`Prisma model '${modelName}' not found. Available models: ${availableModels}`);
|
|
1098
|
+
}
|
|
1099
|
+
const allFields = prismaFieldsModule.getScalarFields(modelName);
|
|
1100
|
+
const sdkDefaults = [
|
|
1101
|
+
...STANDARD_FIELDS,
|
|
1102
|
+
...options.softDelete !== false ? SOFT_DELETE_FIELDS : [],
|
|
1103
|
+
...options.multiTenant !== false ? TENANT_FIELDS : [],
|
|
1104
|
+
...options.audit !== false ? AUDIT_FIELDS : []
|
|
1105
|
+
];
|
|
1106
|
+
const excluded = /* @__PURE__ */ new Set([...sdkDefaults, ...options.exclude ?? []]);
|
|
1107
|
+
return [...allFields.filter((field) => !excluded.has(field)), ...options.include ?? []];
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Validate entity configuration
|
|
1111
|
+
*
|
|
1112
|
+
* Ensures the entity config has all required fields and valid functions.
|
|
1113
|
+
*/
|
|
1114
|
+
function validateEntityConfig(entityType, config) {
|
|
1115
|
+
const errors = [];
|
|
1116
|
+
if (!config.fields || config.fields.length === 0) errors.push({
|
|
1117
|
+
type: "INVALID_ENTITY_TYPE",
|
|
1118
|
+
entityType,
|
|
1119
|
+
message: `Entity '${entityType}' must have at least one field`
|
|
1120
|
+
});
|
|
1121
|
+
if (!config.getWorkspaceId) errors.push({
|
|
1122
|
+
type: "MISSING_WORKSPACE_ID",
|
|
1123
|
+
entityType,
|
|
1124
|
+
message: `Entity '${entityType}' must define getWorkspaceId() to enforce workspace boundary`
|
|
1125
|
+
});
|
|
1126
|
+
if (!config.getOrgId) errors.push({
|
|
1127
|
+
type: "MISSING_ORG_ID",
|
|
1128
|
+
entityType,
|
|
1129
|
+
message: `Entity '${entityType}' must define getOrgId() for multi-tenant isolation`
|
|
1130
|
+
});
|
|
1131
|
+
return errors;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Validate relationship configuration
|
|
1135
|
+
*/
|
|
1136
|
+
function validateRelationshipConfig(relationshipKey, config, entityTypes) {
|
|
1137
|
+
const errors = [];
|
|
1138
|
+
if (!entityTypes.has(config.from)) errors.push({
|
|
1139
|
+
type: "INVALID_RELATIONSHIP",
|
|
1140
|
+
relationshipKey,
|
|
1141
|
+
message: `Relationship '${relationshipKey}' references unknown 'from' entity: ${config.from}`
|
|
1142
|
+
});
|
|
1143
|
+
if (config.to !== "*" && !entityTypes.has(config.to)) errors.push({
|
|
1144
|
+
type: "INVALID_RELATIONSHIP",
|
|
1145
|
+
relationshipKey,
|
|
1146
|
+
message: `Relationship '${relationshipKey}' references unknown 'to' entity: ${config.to}`
|
|
1147
|
+
});
|
|
1148
|
+
if (config.to === "*" && !config.polymorphicTypeField) errors.push({
|
|
1149
|
+
type: "INVALID_RELATIONSHIP",
|
|
1150
|
+
relationshipKey,
|
|
1151
|
+
message: `Polymorphic relationship '${relationshipKey}' must define polymorphicTypeField`
|
|
1152
|
+
});
|
|
1153
|
+
if (!config.fromField) errors.push({
|
|
1154
|
+
type: "INVALID_RELATIONSHIP",
|
|
1155
|
+
relationshipKey,
|
|
1156
|
+
message: `Relationship '${relationshipKey}' must define fromField`
|
|
1157
|
+
});
|
|
1158
|
+
if (!config.label) errors.push({
|
|
1159
|
+
type: "INVALID_RELATIONSHIP",
|
|
1160
|
+
relationshipKey,
|
|
1161
|
+
message: `Relationship '${relationshipKey}' must define label`
|
|
1162
|
+
});
|
|
1163
|
+
return errors;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Validate workspace boundary enforcement
|
|
1167
|
+
*
|
|
1168
|
+
* This ensures no entity can exist without a workspace connection.
|
|
1169
|
+
* Special entities like Workspace and Project can be roots.
|
|
1170
|
+
*/
|
|
1171
|
+
function validateWorkspaceBoundary(config, _entityTypes) {
|
|
1172
|
+
const errors = [];
|
|
1173
|
+
const warnings = [];
|
|
1174
|
+
const rootTypes = /* @__PURE__ */ new Set([
|
|
1175
|
+
"Workspace",
|
|
1176
|
+
"Project",
|
|
1177
|
+
"Organization",
|
|
1178
|
+
"Tenant"
|
|
1179
|
+
]);
|
|
1180
|
+
for (const [entityType, entityConfig] of Object.entries(config.entities)) {
|
|
1181
|
+
if (entityConfig.enabled === false) continue;
|
|
1182
|
+
if (rootTypes.has(entityType)) continue;
|
|
1183
|
+
if (!entityConfig.getWorkspaceId) {
|
|
1184
|
+
errors.push({
|
|
1185
|
+
type: "ORPHANED_ENTITY",
|
|
1186
|
+
entityType,
|
|
1187
|
+
message: `Entity '${entityType}' has no workspace boundary - every entity must connect to a workspace`
|
|
1188
|
+
});
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
let hasWorkspaceLink = false;
|
|
1192
|
+
if (config.relationships) for (const [, relConfig] of Object.entries(config.relationships)) {
|
|
1193
|
+
if (relConfig.enabled === false) continue;
|
|
1194
|
+
if (relConfig.from === entityType && (relConfig.to === "Workspace" || relConfig.to === "Project" || rootTypes.has(relConfig.to))) {
|
|
1195
|
+
hasWorkspaceLink = true;
|
|
1196
|
+
break;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
if (!hasWorkspaceLink) warnings.push(`Entity '${entityType}' has no direct relationship to Workspace/Project. Ensure getWorkspaceId() is correctly implemented.`);
|
|
1200
|
+
}
|
|
1201
|
+
return {
|
|
1202
|
+
errors,
|
|
1203
|
+
warnings
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Validate no duplicate entity types
|
|
1208
|
+
*/
|
|
1209
|
+
function validateNoDuplicates(config, _entityTypes) {
|
|
1210
|
+
const errors = [];
|
|
1211
|
+
const warnings = [];
|
|
1212
|
+
const seenEntityTypes = /* @__PURE__ */ new Set();
|
|
1213
|
+
const relationshipLabels = /* @__PURE__ */ new Set();
|
|
1214
|
+
for (const entityType of Object.keys(config.entities)) {
|
|
1215
|
+
if (seenEntityTypes.has(entityType)) errors.push({
|
|
1216
|
+
type: "DUPLICATE_ENTITY_TYPE",
|
|
1217
|
+
entityType,
|
|
1218
|
+
message: `Duplicate entity type: ${entityType}`
|
|
1219
|
+
});
|
|
1220
|
+
seenEntityTypes.add(entityType);
|
|
1221
|
+
}
|
|
1222
|
+
if (config.relationships) for (const [key, relConfig] of Object.entries(config.relationships)) {
|
|
1223
|
+
const label = relConfig.label;
|
|
1224
|
+
if (relationshipLabels.has(label)) warnings.push(`Duplicate relationship label: ${label} (in ${key}). This may cause query ambiguity.`);
|
|
1225
|
+
relationshipLabels.add(label);
|
|
1226
|
+
}
|
|
1227
|
+
return {
|
|
1228
|
+
errors,
|
|
1229
|
+
warnings
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Perform full validation of graph configuration
|
|
1234
|
+
*/
|
|
1235
|
+
function validateGraphConfig(config) {
|
|
1236
|
+
const allErrors = [];
|
|
1237
|
+
const allWarnings = [];
|
|
1238
|
+
for (const [entityType, entityConfig] of Object.entries(config.entities)) {
|
|
1239
|
+
if (entityConfig.enabled === false) continue;
|
|
1240
|
+
const errors = validateEntityConfig(entityType, entityConfig);
|
|
1241
|
+
allErrors.push(...errors);
|
|
1242
|
+
}
|
|
1243
|
+
const entityTypes = new Set(Object.keys(config.entities));
|
|
1244
|
+
if (config.relationships) for (const [relationshipKey, relationshipConfig] of Object.entries(config.relationships)) {
|
|
1245
|
+
if (relationshipConfig.enabled === false) continue;
|
|
1246
|
+
const errors = validateRelationshipConfig(relationshipKey, relationshipConfig, entityTypes);
|
|
1247
|
+
allErrors.push(...errors);
|
|
1248
|
+
}
|
|
1249
|
+
const boundaryResult = validateWorkspaceBoundary(config, entityTypes);
|
|
1250
|
+
allErrors.push(...boundaryResult.errors);
|
|
1251
|
+
allWarnings.push(...boundaryResult.warnings);
|
|
1252
|
+
const duplicateResult = validateNoDuplicates(config, entityTypes);
|
|
1253
|
+
allErrors.push(...duplicateResult.errors);
|
|
1254
|
+
allWarnings.push(...duplicateResult.warnings);
|
|
1255
|
+
return {
|
|
1256
|
+
valid: allErrors.length === 0,
|
|
1257
|
+
errors: allErrors,
|
|
1258
|
+
warnings: allWarnings
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Define graph configuration for a microservice
|
|
1263
|
+
*
|
|
1264
|
+
* This is the ONLY function developers need to call in their microservice.
|
|
1265
|
+
* It provides full type inference, validation, and intelligent defaults.
|
|
1266
|
+
*
|
|
1267
|
+
* **Automatic Defaults Applied**:
|
|
1268
|
+
* - **Collection**: Defaults to 'entities' for all entities
|
|
1269
|
+
* - **Standard Fields**: Auto-includes id, createdAt, updatedAt
|
|
1270
|
+
* - **Soft Delete**: Auto-includes deletedAt (disable with `softDelete: false`)
|
|
1271
|
+
* - **Multi-Tenant**: Auto-includes workspaceId, tenantId (disable with `multiTenant: false`)
|
|
1272
|
+
* - **Audit**: Auto-includes metadata, context (disable with `audit: false`)
|
|
1273
|
+
* - **getWorkspaceId**: Reads data['workspaceId'] (can override)
|
|
1274
|
+
* - **getOrgId**: Tries data['tenantId'], then data['context']['organizationId'] (can override)
|
|
1275
|
+
* - **extractTitle**: Generates {entityType}_{id} pattern (e.g., user_abc123) (can override)
|
|
1276
|
+
* - **toField**: Defaults to 'id' for relationships (can override)
|
|
1277
|
+
* - **label**: Auto-generates from relationship name (e.g., UserToProject → USER_TO_PROJECT)
|
|
1278
|
+
* - **multiTenant: false**: Automatically sets getWorkspaceId/getOrgId to return undefined
|
|
1279
|
+
*
|
|
1280
|
+
* @param config - The graph configuration with extended options
|
|
1281
|
+
* @returns Fully resolved configuration with all defaults applied
|
|
1282
|
+
*
|
|
1283
|
+
* @example
|
|
1284
|
+
* ```typescript
|
|
1285
|
+
* // BEFORE - Old approach with explicit everything
|
|
1286
|
+
* export const graphConfig = defineGraphConfig({
|
|
1287
|
+
* moduleName: 'module-users',
|
|
1288
|
+
* entities: {
|
|
1289
|
+
* User: {
|
|
1290
|
+
* collection: 'entities',
|
|
1291
|
+
* fields: ['id', 'email', 'name', 'workspaceId', 'tenantId', 'context', 'createdAt', 'updatedAt'],
|
|
1292
|
+
* getWorkspaceId: (data) => data.workspaceId as string,
|
|
1293
|
+
* getOrgId: (data) => data.tenantId as string,
|
|
1294
|
+
* extractTitle: (data) => data.name as string,
|
|
1295
|
+
* },
|
|
1296
|
+
* },
|
|
1297
|
+
* relationships: {
|
|
1298
|
+
* UserToProject: {
|
|
1299
|
+
* from: 'User',
|
|
1300
|
+
* to: 'Project',
|
|
1301
|
+
* fromField: 'projectId',
|
|
1302
|
+
* toField: 'id',
|
|
1303
|
+
* label: 'BELONGS_TO_PROJECT',
|
|
1304
|
+
* },
|
|
1305
|
+
* },
|
|
1306
|
+
* });
|
|
1307
|
+
*
|
|
1308
|
+
* // AFTER - New approach with intelligent defaults + model extraction
|
|
1309
|
+
* export const graphConfig = defineGraphConfig({
|
|
1310
|
+
* moduleName: 'module-users',
|
|
1311
|
+
* prismaFieldsModule: prismaFields, // Enable model-based extraction
|
|
1312
|
+
* entities: {
|
|
1313
|
+
* User: {
|
|
1314
|
+
* model: 'User', // Auto-extracts all fields from Prisma model
|
|
1315
|
+
* // All defaults auto-applied:
|
|
1316
|
+
* // - collection: 'entities'
|
|
1317
|
+
* // - Standard fields: id, createdAt, updatedAt
|
|
1318
|
+
* // - Multi-tenant: workspaceId, tenantId
|
|
1319
|
+
* // - Audit: metadata, context
|
|
1320
|
+
* // - getWorkspaceId: reads workspaceId
|
|
1321
|
+
* // - getOrgId: tries tenantId, then context.organizationId
|
|
1322
|
+
* // - extractTitle: generates user_{id} pattern
|
|
1323
|
+
* },
|
|
1324
|
+
* },
|
|
1325
|
+
* relationships: {
|
|
1326
|
+
* UserToProject: {
|
|
1327
|
+
* from: 'User',
|
|
1328
|
+
* to: 'Project',
|
|
1329
|
+
* fromField: 'projectId',
|
|
1330
|
+
* description: 'User belongs to a project',
|
|
1331
|
+
* // Auto-defaults:
|
|
1332
|
+
* // - toField: 'id'
|
|
1333
|
+
* // - label: 'USER_TO_PROJECT' (generated from key name)
|
|
1334
|
+
* },
|
|
1335
|
+
* },
|
|
1336
|
+
* });
|
|
1337
|
+
* ```
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* // Custom overrides when needed
|
|
1342
|
+
* export const graphConfig = defineGraphConfig({
|
|
1343
|
+
* moduleName: 'module-projects',
|
|
1344
|
+
* prismaFieldsModule: prismaFields,
|
|
1345
|
+
* entities: {
|
|
1346
|
+
* ProjectRelation: {
|
|
1347
|
+
* model: 'ProjectRelation',
|
|
1348
|
+
* multiTenant: false, // Auto-sets getWorkspaceId/getOrgId to undefined
|
|
1349
|
+
* extractTitle: (data) => `Relation: ${data.type}`, // Custom title
|
|
1350
|
+
* },
|
|
1351
|
+
* },
|
|
1352
|
+
* relationships: {
|
|
1353
|
+
* ProjectHierarchy: {
|
|
1354
|
+
* from: 'Project',
|
|
1355
|
+
* to: 'Project',
|
|
1356
|
+
* fromField: 'parentId',
|
|
1357
|
+
* label: 'HAS_PARENT', // Override auto-generated 'PROJECT_HIERARCHY'
|
|
1358
|
+
* extractMetadata: (data) => ({ depth: data.depth }),
|
|
1359
|
+
* },
|
|
1360
|
+
* },
|
|
1361
|
+
* });
|
|
1362
|
+
* ```
|
|
1363
|
+
*/
|
|
1364
|
+
/**
|
|
1365
|
+
* Process a single entity configuration with smart defaults
|
|
1366
|
+
*/
|
|
1367
|
+
function processEntityConfig(entityName, entityOptions, prismaFieldsModule) {
|
|
1368
|
+
const { softDelete = true, multiTenant = true, audit = true, fields, model, exclude, include, collection, getWorkspaceId, getOrgId, extractTitle, rbac, ...rest } = entityOptions;
|
|
1369
|
+
let entityFields;
|
|
1370
|
+
if (model) {
|
|
1371
|
+
if (!prismaFieldsModule) throw new Error(`Entity '${entityName}' uses model='${model}' but prismaFieldsModule is not provided. Import prisma-fields.ts and pass it to defineGraphConfig({ prismaFieldsModule: ... })`);
|
|
1372
|
+
entityFields = extractFieldsFromModel(model, {
|
|
1373
|
+
exclude,
|
|
1374
|
+
include,
|
|
1375
|
+
softDelete,
|
|
1376
|
+
multiTenant,
|
|
1377
|
+
audit
|
|
1378
|
+
}, prismaFieldsModule);
|
|
1379
|
+
} else if (fields) entityFields = fields;
|
|
1380
|
+
else throw new Error(`Entity '${entityName}' must specify either 'fields' or 'model' for field definition`);
|
|
1381
|
+
const autoFields = [
|
|
1382
|
+
...STANDARD_FIELDS,
|
|
1383
|
+
...softDelete ? SOFT_DELETE_FIELDS : [],
|
|
1384
|
+
...multiTenant ? TENANT_FIELDS : [],
|
|
1385
|
+
...audit ? AUDIT_FIELDS : []
|
|
1386
|
+
];
|
|
1387
|
+
const mergedFields = [.../* @__PURE__ */ new Set([...autoFields, ...entityFields])];
|
|
1388
|
+
return {
|
|
1389
|
+
collection: collection ?? "entities",
|
|
1390
|
+
fields: mergedFields,
|
|
1391
|
+
getWorkspaceId: multiTenant === false ? (_data) => void 0 : getWorkspaceId ?? DEFAULT_GET_WORKSPACE_ID,
|
|
1392
|
+
getOrgId: multiTenant === false ? (_data) => void 0 : getOrgId ?? DEFAULT_GET_ORG_ID,
|
|
1393
|
+
extractTitle: extractTitle ?? createDefaultExtractTitle(entityName),
|
|
1394
|
+
...rbac && { rbac },
|
|
1395
|
+
...rest
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Process all relationships with smart defaults
|
|
1400
|
+
*/
|
|
1401
|
+
function processRelationships(relationshipOptions) {
|
|
1402
|
+
const relationships = {};
|
|
1403
|
+
for (const [relationshipName, options] of Object.entries(relationshipOptions)) {
|
|
1404
|
+
const { label, toField, ...rest } = options;
|
|
1405
|
+
relationships[relationshipName] = {
|
|
1406
|
+
toField: toField ?? "id",
|
|
1407
|
+
label: label ?? generateRelationshipLabel(relationshipName),
|
|
1408
|
+
...rest
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
return relationships;
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Log validation results and throw on errors
|
|
1415
|
+
*/
|
|
1416
|
+
function logValidationResults(moduleName, validationResult) {
|
|
1417
|
+
if (validationResult.errors.length > 0) {
|
|
1418
|
+
logger.error(`[GraphConfig:${moduleName}] Configuration validation failed:`);
|
|
1419
|
+
for (const error of validationResult.errors) logger.error(` - ${error.message}`, {
|
|
1420
|
+
type: error.type,
|
|
1421
|
+
entityType: error.entityType,
|
|
1422
|
+
relationshipKey: error.relationshipKey
|
|
1423
|
+
});
|
|
1424
|
+
throw new Error(`Graph configuration validation failed for ${moduleName}`);
|
|
1425
|
+
}
|
|
1426
|
+
if (validationResult.warnings.length > 0) {
|
|
1427
|
+
logger.warn(`[GraphConfig:${moduleName}] Configuration warnings:`);
|
|
1428
|
+
for (const warning of validationResult.warnings) logger.warn(` - ${warning}`);
|
|
1429
|
+
}
|
|
1430
|
+
logger.info(`[GraphConfig:${moduleName}] Configuration validated successfully`, {
|
|
1431
|
+
valid: validationResult.valid,
|
|
1432
|
+
errorCount: validationResult.errors.length,
|
|
1433
|
+
warningCount: validationResult.warnings.length,
|
|
1434
|
+
autoFieldsApplied: true
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
function defineGraphConfig(options) {
|
|
1438
|
+
const entities = {};
|
|
1439
|
+
for (const [entityName, entityOptions] of Object.entries(options.entities)) entities[entityName] = processEntityConfig(entityName, entityOptions, options.prismaFieldsModule);
|
|
1440
|
+
const relationships = options.relationships ? processRelationships(options.relationships) : {};
|
|
1441
|
+
const config = {
|
|
1442
|
+
moduleName: options.moduleName,
|
|
1443
|
+
entities,
|
|
1444
|
+
relationships
|
|
1445
|
+
};
|
|
1446
|
+
const validationResult = validateGraphConfig(config);
|
|
1447
|
+
logValidationResults(config.moduleName, validationResult);
|
|
1448
|
+
autoRegisterWithRegistry(config);
|
|
1449
|
+
return config;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Auto-register graph config entities with GraphRegistry
|
|
1453
|
+
* Called automatically by defineGraphConfig() so Prisma graph extension
|
|
1454
|
+
* knows which entity types to monitor.
|
|
1455
|
+
*/
|
|
1456
|
+
function autoRegisterWithRegistry(config) {
|
|
1457
|
+
const { moduleName, entities, relationships = {} } = config;
|
|
1458
|
+
const registryEntities = {};
|
|
1459
|
+
for (const [entityType, entityConfig] of Object.entries(entities)) registryEntities[entityType] = {
|
|
1460
|
+
fields: entityConfig.fields,
|
|
1461
|
+
collection: entityConfig.collection || "entities",
|
|
1462
|
+
extractTitle: entityConfig.extractTitle,
|
|
1463
|
+
getOrgId: entityConfig.getOrgId,
|
|
1464
|
+
getWorkspaceId: entityConfig.getWorkspaceId,
|
|
1465
|
+
enabled: entityConfig.enabled,
|
|
1466
|
+
...entityConfig.rbac && { rbac: {
|
|
1467
|
+
resourceTypeName: entityConfig.rbac.resourceTypeName,
|
|
1468
|
+
extractName: entityConfig.rbac.extractName,
|
|
1469
|
+
extractIdentifier: entityConfig.rbac.extractIdentifier,
|
|
1470
|
+
parentResourceField: entityConfig.rbac.parentResourceField,
|
|
1471
|
+
createResource: entityConfig.rbac.createResource
|
|
1472
|
+
} },
|
|
1473
|
+
...entityConfig.bulkOperations && { bulkOperations: { ...entityConfig.bulkOperations } }
|
|
1474
|
+
};
|
|
1475
|
+
const registryRelationships = {};
|
|
1476
|
+
for (const [key, relConfig] of Object.entries(relationships)) registryRelationships[key] = {
|
|
1477
|
+
from: relConfig.from,
|
|
1478
|
+
to: relConfig.to,
|
|
1479
|
+
fromField: relConfig.fromField,
|
|
1480
|
+
toField: relConfig.toField,
|
|
1481
|
+
label: relConfig.label,
|
|
1482
|
+
description: relConfig.description,
|
|
1483
|
+
extractMetadata: relConfig.extractMetadata,
|
|
1484
|
+
polymorphicTypeField: relConfig.polymorphicTypeField,
|
|
1485
|
+
enabled: relConfig.enabled
|
|
1486
|
+
};
|
|
1487
|
+
GraphRegistry.registerModule({
|
|
1488
|
+
moduleName,
|
|
1489
|
+
entities: registryEntities,
|
|
1490
|
+
relationships: registryRelationships
|
|
1491
|
+
});
|
|
1492
|
+
logger.info(`[GraphConfig:${moduleName}] Auto-registered ${Object.keys(entities).length} entities with GraphRegistry`);
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Helper to create entity config with type safety
|
|
1496
|
+
*
|
|
1497
|
+
* This is optional but provides better autocomplete in IDEs.
|
|
1498
|
+
*/
|
|
1499
|
+
function defineEntity(config) {
|
|
1500
|
+
return config;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Helper to create relationship config with type safety
|
|
1504
|
+
*/
|
|
1505
|
+
function defineRelationship(config) {
|
|
1506
|
+
return config;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
// src/graph/config/init.ts
|
|
1510
|
+
/**
|
|
1511
|
+
* Runtime validator for entity data
|
|
1512
|
+
*
|
|
1513
|
+
* Validates that extracted data matches configuration expectations.
|
|
1514
|
+
* Only runs if validateRuntime is enabled.
|
|
1515
|
+
*/
|
|
1516
|
+
var RuntimeValidator = class {
|
|
1517
|
+
config;
|
|
1518
|
+
constructor(config) {
|
|
1519
|
+
this.config = config;
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Validate entity data extraction
|
|
1523
|
+
*/
|
|
1524
|
+
validateEntityData(entityType, data) {
|
|
1525
|
+
const errors = [];
|
|
1526
|
+
const entityConfig = this.config.entities[entityType];
|
|
1527
|
+
if (!entityConfig) return {
|
|
1528
|
+
valid: true,
|
|
1529
|
+
errors: []
|
|
1530
|
+
};
|
|
1531
|
+
try {
|
|
1532
|
+
if (!entityConfig.getWorkspaceId(data)) errors.push(`Entity ${entityType}:${data["id"]} has no workspaceId`);
|
|
1533
|
+
} catch (error) {
|
|
1534
|
+
errors.push(`Error extracting workspaceId for ${entityType}: ${error}`);
|
|
1535
|
+
}
|
|
1536
|
+
try {
|
|
1537
|
+
if (!entityConfig.getOrgId(data)) errors.push(`Entity ${entityType}:${data["id"]} has no organizationId`);
|
|
1538
|
+
} catch (error) {
|
|
1539
|
+
errors.push(`Error extracting organizationId for ${entityType}: ${error}`);
|
|
1540
|
+
}
|
|
1541
|
+
for (const field of entityConfig.fields) if (!(field in data)) errors.push(`Entity ${entityType}:${data["id"]} missing configured field: ${field}`);
|
|
1542
|
+
return {
|
|
1543
|
+
valid: errors.length === 0,
|
|
1544
|
+
errors
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
/**
|
|
1549
|
+
* Initialize graph integration for a microservice
|
|
1550
|
+
*
|
|
1551
|
+
* This function:
|
|
1552
|
+
* 1. Registers the configuration with GraphRegistry
|
|
1553
|
+
* 2. Sets up the Prisma extension for automatic event emission
|
|
1554
|
+
* 3. Validates workspace boundaries
|
|
1555
|
+
* 4. Returns an extended Prisma client
|
|
1556
|
+
*
|
|
1557
|
+
* @param prismaClient - Base Prisma client instance
|
|
1558
|
+
* @param config - Graph configuration from defineGraphConfig()
|
|
1559
|
+
* @param options - Initialization options
|
|
1560
|
+
* @returns Extended Prisma client with graph event emission
|
|
1561
|
+
*
|
|
1562
|
+
* @example
|
|
1563
|
+
* ```typescript
|
|
1564
|
+
* // microservice/src/index.ts
|
|
1565
|
+
* import { PrismaClient } from '@prisma/client';
|
|
1566
|
+
* import { initializeGraph } from '@burdenoff/be-sdk/graph';
|
|
1567
|
+
* import { graphConfig } from './graph.config.js';
|
|
1568
|
+
* import { graphEventEmitter } from './events.js';
|
|
1569
|
+
*
|
|
1570
|
+
* const basePrisma = new PrismaClient();
|
|
1571
|
+
*
|
|
1572
|
+
* const prisma = initializeGraph(basePrisma, graphConfig, {
|
|
1573
|
+
* productName: 'module-tags',
|
|
1574
|
+
* eventEmitter: graphEventEmitter,
|
|
1575
|
+
* });
|
|
1576
|
+
*
|
|
1577
|
+
* // Now use prisma normally - events are emitted automatically
|
|
1578
|
+
* const tag = await prisma.universalTag.create({
|
|
1579
|
+
* data: { name: 'Important', workspaceId: '...' }
|
|
1580
|
+
* });
|
|
1581
|
+
* // -> entity.created event emitted automatically
|
|
1582
|
+
* // -> relationship.created event emitted if vocabularyId is set
|
|
1583
|
+
* ```
|
|
1584
|
+
*/
|
|
1585
|
+
function initializeGraph(prismaClient, config, options) {
|
|
1586
|
+
const { productName, eventEmitter, monitoredEntityTypes = [], enabled = true, validateRuntime, bulkOperations } = options;
|
|
1587
|
+
const shouldValidate = validateRuntime ?? process.env["NODE_ENV"] !== "production";
|
|
1588
|
+
logger.info(`[GraphInit:${config.moduleName}] Initializing graph integration`, {
|
|
1589
|
+
productName,
|
|
1590
|
+
enabled,
|
|
1591
|
+
validateRuntime: shouldValidate,
|
|
1592
|
+
entities: Object.keys(config.entities).length,
|
|
1593
|
+
relationships: config.relationships ? Object.keys(config.relationships).length : 0
|
|
1594
|
+
});
|
|
1595
|
+
if (!enabled) {
|
|
1596
|
+
logger.warn(`[GraphInit:${config.moduleName}] Graph integration disabled by configuration`);
|
|
1597
|
+
return prismaClient;
|
|
1598
|
+
}
|
|
1599
|
+
registerConfigWithRegistry(config);
|
|
1600
|
+
const validator = shouldValidate ? new RuntimeValidator(config) : null;
|
|
1601
|
+
const extendedClient = addGraphExtension(prismaClient, {
|
|
1602
|
+
enabled: true,
|
|
1603
|
+
productName,
|
|
1604
|
+
eventEmitter: { publishEntityEvent: async (eventType, entity, context, rbac) => {
|
|
1605
|
+
if (validator && (eventType === "entity.created" || eventType === "entity.updated")) {
|
|
1606
|
+
const validation = validator.validateEntityData(entity.type, entity.data);
|
|
1607
|
+
if (!validation.valid) logger.error(`[GraphInit:${config.moduleName}] Runtime validation failed for ${entity.type}:${entity.id}`, { errors: validation.errors });
|
|
1608
|
+
}
|
|
1609
|
+
return eventEmitter.publishEntityEvent(eventType, entity, context, rbac);
|
|
1610
|
+
} },
|
|
1611
|
+
entityTypes: monitoredEntityTypes,
|
|
1612
|
+
...bulkOperations && { bulkOperations }
|
|
1613
|
+
});
|
|
1614
|
+
logger.info(`[GraphInit:${config.moduleName}] Graph integration initialized successfully`);
|
|
1615
|
+
return extendedClient;
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Register configuration with GraphRegistry
|
|
1619
|
+
*
|
|
1620
|
+
* Converts GenericGraphConfig to ModuleGraphConfig format
|
|
1621
|
+
* that GraphRegistry expects.
|
|
1622
|
+
*/
|
|
1623
|
+
function registerConfigWithRegistry(config) {
|
|
1624
|
+
const { moduleName, entities, relationships = {} } = config;
|
|
1625
|
+
const registryEntities = {};
|
|
1626
|
+
for (const [entityType, entityConfig] of Object.entries(entities)) registryEntities[entityType] = {
|
|
1627
|
+
fields: entityConfig.fields,
|
|
1628
|
+
collection: entityConfig.collection || "entities",
|
|
1629
|
+
extractTitle: entityConfig.extractTitle,
|
|
1630
|
+
getOrgId: entityConfig.getOrgId,
|
|
1631
|
+
getWorkspaceId: entityConfig.getWorkspaceId,
|
|
1632
|
+
enabled: entityConfig.enabled,
|
|
1633
|
+
...entityConfig.rbac && { rbac: { ...entityConfig.rbac } },
|
|
1634
|
+
...entityConfig.bulkOperations && { bulkOperations: { ...entityConfig.bulkOperations } }
|
|
1635
|
+
};
|
|
1636
|
+
const registryRelationships = {};
|
|
1637
|
+
for (const [key, relConfig] of Object.entries(relationships)) registryRelationships[key] = {
|
|
1638
|
+
from: relConfig.from,
|
|
1639
|
+
to: relConfig.to,
|
|
1640
|
+
fromField: relConfig.fromField,
|
|
1641
|
+
toField: relConfig.toField,
|
|
1642
|
+
label: relConfig.label,
|
|
1643
|
+
description: relConfig.description,
|
|
1644
|
+
extractMetadata: relConfig.extractMetadata,
|
|
1645
|
+
polymorphicTypeField: relConfig.polymorphicTypeField,
|
|
1646
|
+
enabled: relConfig.enabled
|
|
1647
|
+
};
|
|
1648
|
+
GraphRegistry.registerModule({
|
|
1649
|
+
moduleName,
|
|
1650
|
+
entities: registryEntities,
|
|
1651
|
+
relationships: registryRelationships
|
|
1652
|
+
});
|
|
1653
|
+
logger.info(`[GraphInit:${moduleName}] Configuration registered with GraphRegistry`);
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Validate that a Prisma client has been properly initialized with graph support
|
|
1657
|
+
*
|
|
1658
|
+
* This is a runtime check to ensure initializeGraph() was called.
|
|
1659
|
+
*
|
|
1660
|
+
* @param moduleName - Module name for logging
|
|
1661
|
+
* @returns Whether the module is registered
|
|
1662
|
+
*/
|
|
1663
|
+
function isGraphInitialized(moduleName) {
|
|
1664
|
+
return GraphRegistry.getRegisteredModules().includes(moduleName);
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Get graph statistics for a module
|
|
1668
|
+
*
|
|
1669
|
+
* Useful for debugging and monitoring.
|
|
1670
|
+
*/
|
|
1671
|
+
function getGraphStats() {
|
|
1672
|
+
const stats = GraphRegistry.getStats();
|
|
1673
|
+
const registeredModules = GraphRegistry.getRegisteredModules();
|
|
1674
|
+
return {
|
|
1675
|
+
modules: stats.modules,
|
|
1676
|
+
entities: stats.entities,
|
|
1677
|
+
relationships: stats.relationships,
|
|
1678
|
+
registeredModules
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
// src/graph/index.ts
|
|
1683
|
+
var graph_exports = /* @__PURE__ */ __exportAll({
|
|
1684
|
+
AUDIT_FIELDS: () => AUDIT_FIELDS,
|
|
1685
|
+
GraphEventsPublisher: () => GraphEventsPublisher,
|
|
1686
|
+
GraphExportService: () => GraphExportService,
|
|
1687
|
+
GraphModule: () => GraphModule,
|
|
1688
|
+
GraphRegistry: () => GraphRegistry,
|
|
1689
|
+
SOFT_DELETE_FIELDS: () => SOFT_DELETE_FIELDS,
|
|
1690
|
+
STANDARD_FIELDS: () => STANDARD_FIELDS,
|
|
1691
|
+
TENANT_FIELDS: () => TENANT_FIELDS,
|
|
1692
|
+
addGraphExtension: () => addGraphExtension,
|
|
1693
|
+
createEntityEvent: () => createEntityEvent,
|
|
1694
|
+
createGraphEventsHelper: () => createGraphEventsHelper,
|
|
1695
|
+
createGraphExportService: () => createGraphExportService,
|
|
1696
|
+
createPrismaGraphIntegration: () => createPrismaGraphIntegration,
|
|
1697
|
+
createRelationshipEvent: () => createRelationshipEvent,
|
|
1698
|
+
createRelationshipFromEntity: () => createRelationshipFromEntity,
|
|
1699
|
+
defineEntity: () => defineEntity,
|
|
1700
|
+
defineGraphConfig: () => defineGraphConfig,
|
|
1701
|
+
defineModuleGraph: () => defineModuleGraph,
|
|
1702
|
+
defineRelationship: () => defineRelationship,
|
|
1703
|
+
extractEntityTitle: () => extractEntityTitle,
|
|
1704
|
+
extractMinimalFields: () => extractMinimalFields,
|
|
1705
|
+
getCollectionForEntity: () => getCollectionForEntity,
|
|
1706
|
+
getGraphEventsPublisher: () => getGraphEventsPublisher,
|
|
1707
|
+
getGraphStats: () => getGraphStats,
|
|
1708
|
+
initializeGraph: () => initializeGraph,
|
|
1709
|
+
isGraphInitialized: () => isGraphInitialized,
|
|
1710
|
+
parseRelationship: () => parseRelationship,
|
|
1711
|
+
shouldSyncEntity: () => shouldSyncEntity,
|
|
1712
|
+
shouldSyncRelationship: () => shouldSyncRelationship,
|
|
1713
|
+
withDeferredGraphEvents: () => withDeferredGraphEvents
|
|
1714
|
+
});
|
|
1715
|
+
/**
|
|
1716
|
+
* Graph Integration Module
|
|
1717
|
+
*/
|
|
1718
|
+
var GraphModule = class {
|
|
1719
|
+
client;
|
|
1720
|
+
context;
|
|
1721
|
+
constructor(client, context) {
|
|
1722
|
+
this.client = client;
|
|
1723
|
+
this.context = context;
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Create graph node
|
|
1727
|
+
*/
|
|
1728
|
+
async createNode(options) {
|
|
1729
|
+
if (!options.type) throw new ValidationError("Node type is required");
|
|
1730
|
+
if (!options.properties || typeof options.properties !== "object") throw new ValidationError("Node properties must be an object");
|
|
1731
|
+
logger.debug("[Graph] Creating node", { type: options.type });
|
|
1732
|
+
const mutation = `
|
|
1733
|
+
mutation CreateGraphNode($input: CreateGraphNodeInput!) {
|
|
1734
|
+
createGraphNode(input: $input) {
|
|
1735
|
+
id
|
|
1736
|
+
type
|
|
1737
|
+
properties
|
|
1738
|
+
workspaceId
|
|
1739
|
+
organizationId
|
|
1740
|
+
createdAt
|
|
1741
|
+
updatedAt
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
`;
|
|
1745
|
+
const variables = { input: {
|
|
1746
|
+
type: options.type,
|
|
1747
|
+
properties: options.properties,
|
|
1748
|
+
workspaceId: options.workspaceId || this.context.workspaceId,
|
|
1749
|
+
organizationId: options.organizationId
|
|
1750
|
+
} };
|
|
1751
|
+
const response = await this.client.query(mutation, variables, this.context);
|
|
1752
|
+
logger.info("[Graph] Node created", { nodeId: response.createGraphNode.id });
|
|
1753
|
+
return response.createGraphNode;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Create graph edge
|
|
1757
|
+
*/
|
|
1758
|
+
async createEdge(options) {
|
|
1759
|
+
if (!options.from) throw new ValidationError("Source node ID is required");
|
|
1760
|
+
if (!options.to) throw new ValidationError("Target node ID is required");
|
|
1761
|
+
if (!options.type) throw new ValidationError("Edge type is required");
|
|
1762
|
+
logger.debug("[Graph] Creating edge", {
|
|
1763
|
+
from: options.from,
|
|
1764
|
+
to: options.to,
|
|
1765
|
+
type: options.type
|
|
1766
|
+
});
|
|
1767
|
+
const mutation = `
|
|
1768
|
+
mutation CreateGraphEdge($input: CreateGraphEdgeInput!) {
|
|
1769
|
+
createGraphEdge(input: $input) {
|
|
1770
|
+
id
|
|
1771
|
+
from
|
|
1772
|
+
to
|
|
1773
|
+
type
|
|
1774
|
+
properties
|
|
1775
|
+
workspaceId
|
|
1776
|
+
organizationId
|
|
1777
|
+
createdAt
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
`;
|
|
1781
|
+
const variables = { input: {
|
|
1782
|
+
from: options.from,
|
|
1783
|
+
to: options.to,
|
|
1784
|
+
type: options.type,
|
|
1785
|
+
properties: options.properties,
|
|
1786
|
+
workspaceId: options.workspaceId || this.context.workspaceId,
|
|
1787
|
+
organizationId: options.organizationId
|
|
1788
|
+
} };
|
|
1789
|
+
const response = await this.client.query(mutation, variables, this.context);
|
|
1790
|
+
logger.info("[Graph] Edge created", { edgeId: response.createGraphEdge.id });
|
|
1791
|
+
return response.createGraphEdge;
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Get node by ID
|
|
1795
|
+
*/
|
|
1796
|
+
async getNode(nodeId) {
|
|
1797
|
+
logger.debug("[Graph] Getting node", { nodeId });
|
|
1798
|
+
return (await this.client.query(`
|
|
1799
|
+
query GetGraphNode($nodeId: ID!) {
|
|
1800
|
+
getGraphNode(nodeId: $nodeId) {
|
|
1801
|
+
id
|
|
1802
|
+
type
|
|
1803
|
+
properties
|
|
1804
|
+
workspaceId
|
|
1805
|
+
organizationId
|
|
1806
|
+
createdAt
|
|
1807
|
+
updatedAt
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
`, { nodeId }, this.context)).getGraphNode;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Update node
|
|
1814
|
+
*/
|
|
1815
|
+
async updateNode(nodeId, properties) {
|
|
1816
|
+
logger.debug("[Graph] Updating node", { nodeId });
|
|
1817
|
+
const response = await this.client.query(`
|
|
1818
|
+
mutation UpdateGraphNode($nodeId: ID!, $properties: JSON!) {
|
|
1819
|
+
updateGraphNode(nodeId: $nodeId, properties: $properties) {
|
|
1820
|
+
id
|
|
1821
|
+
type
|
|
1822
|
+
properties
|
|
1823
|
+
workspaceId
|
|
1824
|
+
organizationId
|
|
1825
|
+
createdAt
|
|
1826
|
+
updatedAt
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
`, {
|
|
1830
|
+
nodeId,
|
|
1831
|
+
properties
|
|
1832
|
+
}, this.context);
|
|
1833
|
+
logger.info("[Graph] Node updated", { nodeId });
|
|
1834
|
+
return response.updateGraphNode;
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Delete node
|
|
1838
|
+
*/
|
|
1839
|
+
async deleteNode(nodeId) {
|
|
1840
|
+
logger.debug("[Graph] Deleting node", { nodeId });
|
|
1841
|
+
await this.client.query(`
|
|
1842
|
+
mutation DeleteGraphNode($nodeId: ID!) {
|
|
1843
|
+
deleteGraphNode(nodeId: $nodeId) {
|
|
1844
|
+
success
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
`, { nodeId }, this.context);
|
|
1848
|
+
logger.info("[Graph] Node deleted", { nodeId });
|
|
1849
|
+
return true;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Delete edge
|
|
1853
|
+
*/
|
|
1854
|
+
async deleteEdge(edgeId) {
|
|
1855
|
+
logger.debug("[Graph] Deleting edge", { edgeId });
|
|
1856
|
+
await this.client.query(`
|
|
1857
|
+
mutation DeleteGraphEdge($edgeId: ID!) {
|
|
1858
|
+
deleteGraphEdge(edgeId: $edgeId) {
|
|
1859
|
+
success
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
`, { edgeId }, this.context);
|
|
1863
|
+
logger.info("[Graph] Edge deleted", { edgeId });
|
|
1864
|
+
return true;
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Traverse graph
|
|
1868
|
+
*/
|
|
1869
|
+
async traverse(options) {
|
|
1870
|
+
if (!options.startNode) throw new ValidationError("Start node ID is required");
|
|
1871
|
+
logger.debug("[Graph] Traversing graph", {
|
|
1872
|
+
startNode: options.startNode,
|
|
1873
|
+
direction: options.direction || "outbound"
|
|
1874
|
+
});
|
|
1875
|
+
const query = `
|
|
1876
|
+
query TraverseGraph(
|
|
1877
|
+
$startNode: ID!
|
|
1878
|
+
$direction: GraphDirection
|
|
1879
|
+
$edgeTypes: [String!]
|
|
1880
|
+
$minDepth: Int
|
|
1881
|
+
$maxDepth: Int
|
|
1882
|
+
$limit: Int
|
|
1883
|
+
) {
|
|
1884
|
+
traverseGraph(
|
|
1885
|
+
startNode: $startNode
|
|
1886
|
+
direction: $direction
|
|
1887
|
+
edgeTypes: $edgeTypes
|
|
1888
|
+
minDepth: $minDepth
|
|
1889
|
+
maxDepth: $maxDepth
|
|
1890
|
+
limit: $limit
|
|
1891
|
+
) {
|
|
1892
|
+
nodes {
|
|
1893
|
+
id
|
|
1894
|
+
type
|
|
1895
|
+
properties
|
|
1896
|
+
workspaceId
|
|
1897
|
+
organizationId
|
|
1898
|
+
createdAt
|
|
1899
|
+
updatedAt
|
|
1900
|
+
}
|
|
1901
|
+
edges {
|
|
1902
|
+
id
|
|
1903
|
+
from
|
|
1904
|
+
to
|
|
1905
|
+
type
|
|
1906
|
+
properties
|
|
1907
|
+
workspaceId
|
|
1908
|
+
organizationId
|
|
1909
|
+
createdAt
|
|
1910
|
+
}
|
|
1911
|
+
paths {
|
|
1912
|
+
nodes {
|
|
1913
|
+
id
|
|
1914
|
+
type
|
|
1915
|
+
properties
|
|
1916
|
+
}
|
|
1917
|
+
edges {
|
|
1918
|
+
id
|
|
1919
|
+
from
|
|
1920
|
+
to
|
|
1921
|
+
type
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
`;
|
|
1927
|
+
const variables = {
|
|
1928
|
+
startNode: options.startNode,
|
|
1929
|
+
direction: options.direction || "outbound",
|
|
1930
|
+
edgeTypes: options.edgeTypes,
|
|
1931
|
+
minDepth: options.minDepth || 1,
|
|
1932
|
+
maxDepth: options.maxDepth || 3,
|
|
1933
|
+
limit: options.limit || 100
|
|
1934
|
+
};
|
|
1935
|
+
return (await this.client.query(query, variables, this.context)).traverseGraph;
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Find shortest path between two nodes
|
|
1939
|
+
*/
|
|
1940
|
+
async findShortestPath(fromNode, toNode, options) {
|
|
1941
|
+
logger.debug("[Graph] Finding shortest path", {
|
|
1942
|
+
fromNode,
|
|
1943
|
+
toNode
|
|
1944
|
+
});
|
|
1945
|
+
return (await this.client.query(`
|
|
1946
|
+
query FindShortestPath(
|
|
1947
|
+
$fromNode: ID!
|
|
1948
|
+
$toNode: ID!
|
|
1949
|
+
$edgeTypes: [String!]
|
|
1950
|
+
$maxDepth: Int
|
|
1951
|
+
) {
|
|
1952
|
+
findShortestPath(
|
|
1953
|
+
fromNode: $fromNode
|
|
1954
|
+
toNode: $toNode
|
|
1955
|
+
edgeTypes: $edgeTypes
|
|
1956
|
+
maxDepth: $maxDepth
|
|
1957
|
+
) {
|
|
1958
|
+
nodes {
|
|
1959
|
+
id
|
|
1960
|
+
type
|
|
1961
|
+
properties
|
|
1962
|
+
}
|
|
1963
|
+
edges {
|
|
1964
|
+
id
|
|
1965
|
+
from
|
|
1966
|
+
to
|
|
1967
|
+
type
|
|
1968
|
+
}
|
|
1969
|
+
distance
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
`, {
|
|
1973
|
+
fromNode,
|
|
1974
|
+
toNode,
|
|
1975
|
+
edgeTypes: options?.edgeTypes,
|
|
1976
|
+
maxDepth: options?.maxDepth || 10
|
|
1977
|
+
}, this.context)).findShortestPath;
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* Query graph with raw openCypher. Proxied to wspace-graph-svc's
|
|
1981
|
+
* `executeCypher` resolver via the federated GraphQL gateway — no direct
|
|
1982
|
+
* graph-DB access. (Pre-2026-05 this used `executeNGQL` against NebulaGraph;
|
|
1983
|
+
* the federated resolver was renamed during the Apache AGE migration.)
|
|
1984
|
+
*/
|
|
1985
|
+
async query(options) {
|
|
1986
|
+
if (!options.query) throw new ValidationError("Cypher query is required");
|
|
1987
|
+
logger.debug("[Graph] Executing Cypher query");
|
|
1988
|
+
const query = `
|
|
1989
|
+
query ExecuteCypher($query: String!, $bindVars: JSON, $limit: Int) {
|
|
1990
|
+
executeCypher(query: $query, bindVars: $bindVars, limit: $limit) {
|
|
1991
|
+
results
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
`;
|
|
1995
|
+
const variables = {
|
|
1996
|
+
query: options.query,
|
|
1997
|
+
bindVars: options.bindVars,
|
|
1998
|
+
limit: options.limit || 1e3
|
|
1999
|
+
};
|
|
2000
|
+
return (await this.client.query(query, variables, this.context)).executeCypher.results;
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Get neighbors of a node
|
|
2004
|
+
*/
|
|
2005
|
+
async getNeighbors(nodeId, options) {
|
|
2006
|
+
logger.debug("[Graph] Getting neighbors", { nodeId });
|
|
2007
|
+
return (await this.client.query(`
|
|
2008
|
+
query GetNeighbors(
|
|
2009
|
+
$nodeId: ID!
|
|
2010
|
+
$direction: GraphDirection
|
|
2011
|
+
$edgeTypes: [String!]
|
|
2012
|
+
$limit: Int
|
|
2013
|
+
) {
|
|
2014
|
+
getNeighbors(
|
|
2015
|
+
nodeId: $nodeId
|
|
2016
|
+
direction: $direction
|
|
2017
|
+
edgeTypes: $edgeTypes
|
|
2018
|
+
limit: $limit
|
|
2019
|
+
) {
|
|
2020
|
+
nodes {
|
|
2021
|
+
id
|
|
2022
|
+
type
|
|
2023
|
+
properties
|
|
2024
|
+
workspaceId
|
|
2025
|
+
organizationId
|
|
2026
|
+
createdAt
|
|
2027
|
+
updatedAt
|
|
2028
|
+
}
|
|
2029
|
+
edges {
|
|
2030
|
+
id
|
|
2031
|
+
from
|
|
2032
|
+
to
|
|
2033
|
+
type
|
|
2034
|
+
properties
|
|
2035
|
+
workspaceId
|
|
2036
|
+
organizationId
|
|
2037
|
+
createdAt
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
`, {
|
|
2042
|
+
nodeId,
|
|
2043
|
+
direction: options?.direction || "outbound",
|
|
2044
|
+
edgeTypes: options?.edgeTypes,
|
|
2045
|
+
limit: options?.limit || 100
|
|
2046
|
+
}, this.context)).getNeighbors;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Get node degree (number of connections)
|
|
2050
|
+
*/
|
|
2051
|
+
async getNodeDegree(nodeId, direction) {
|
|
2052
|
+
logger.debug("[Graph] Getting node degree", { nodeId });
|
|
2053
|
+
return (await this.client.query(`
|
|
2054
|
+
query GetNodeDegree($nodeId: ID!, $direction: GraphDirection) {
|
|
2055
|
+
getNodeDegree(nodeId: $nodeId, direction: $direction) {
|
|
2056
|
+
inbound
|
|
2057
|
+
outbound
|
|
2058
|
+
total
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
`, {
|
|
2062
|
+
nodeId,
|
|
2063
|
+
direction
|
|
2064
|
+
}, this.context)).getNodeDegree;
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Find nodes by properties
|
|
2068
|
+
*/
|
|
2069
|
+
async findNodes(type, filters, options) {
|
|
2070
|
+
logger.debug("[Graph] Finding nodes", {
|
|
2071
|
+
type,
|
|
2072
|
+
filters
|
|
2073
|
+
});
|
|
2074
|
+
return (await this.client.query(`
|
|
2075
|
+
query FindGraphNodes(
|
|
2076
|
+
$type: String!
|
|
2077
|
+
$filters: JSON!
|
|
2078
|
+
$limit: Int
|
|
2079
|
+
$offset: Int
|
|
2080
|
+
) {
|
|
2081
|
+
findGraphNodes(
|
|
2082
|
+
type: $type
|
|
2083
|
+
filters: $filters
|
|
2084
|
+
limit: $limit
|
|
2085
|
+
offset: $offset
|
|
2086
|
+
) {
|
|
2087
|
+
nodes {
|
|
2088
|
+
id
|
|
2089
|
+
type
|
|
2090
|
+
properties
|
|
2091
|
+
workspaceId
|
|
2092
|
+
organizationId
|
|
2093
|
+
createdAt
|
|
2094
|
+
updatedAt
|
|
2095
|
+
}
|
|
2096
|
+
total
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
`, {
|
|
2100
|
+
type,
|
|
2101
|
+
filters,
|
|
2102
|
+
limit: options?.limit || 100,
|
|
2103
|
+
offset: options?.offset || 0
|
|
2104
|
+
}, this.context)).findGraphNodes;
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* Batch create nodes
|
|
2108
|
+
*/
|
|
2109
|
+
async createNodesBatch(nodes) {
|
|
2110
|
+
logger.debug("[Graph] Batch creating nodes", { count: nodes.length });
|
|
2111
|
+
const response = await this.client.query(`
|
|
2112
|
+
mutation CreateGraphNodesBatch($nodes: [CreateGraphNodeInput!]!) {
|
|
2113
|
+
createGraphNodesBatch(nodes: $nodes) {
|
|
2114
|
+
id
|
|
2115
|
+
type
|
|
2116
|
+
properties
|
|
2117
|
+
workspaceId
|
|
2118
|
+
organizationId
|
|
2119
|
+
createdAt
|
|
2120
|
+
updatedAt
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
`, { nodes }, this.context);
|
|
2124
|
+
logger.info("[Graph] Nodes batch created", { count: response.createGraphNodesBatch.length });
|
|
2125
|
+
return response.createGraphNodesBatch;
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Batch create edges
|
|
2129
|
+
*/
|
|
2130
|
+
async createEdgesBatch(edges) {
|
|
2131
|
+
logger.debug("[Graph] Batch creating edges", { count: edges.length });
|
|
2132
|
+
const response = await this.client.query(`
|
|
2133
|
+
mutation CreateGraphEdgesBatch($edges: [CreateGraphEdgeInput!]!) {
|
|
2134
|
+
createGraphEdgesBatch(edges: $edges) {
|
|
2135
|
+
id
|
|
2136
|
+
from
|
|
2137
|
+
to
|
|
2138
|
+
type
|
|
2139
|
+
properties
|
|
2140
|
+
workspaceId
|
|
2141
|
+
organizationId
|
|
2142
|
+
createdAt
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
`, { edges }, this.context);
|
|
2146
|
+
logger.info("[Graph] Edges batch created", { count: response.createGraphEdgesBatch.length });
|
|
2147
|
+
return response.createGraphEdgesBatch;
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
export { GraphEventsPublisher as _, isGraphInitialized as a, createPrismaGraphIntegration as b, STANDARD_FIELDS as c, defineGraphConfig as d, defineRelationship as f, createRelationshipFromEntity as g, createGraphExportService as h, initializeGraph as i, TENANT_FIELDS as l, GraphExportService as m, graph_exports as n, AUDIT_FIELDS as o, defineModuleGraph as p, getGraphStats as r, SOFT_DELETE_FIELDS as s, GraphModule as t, defineEntity as u, createGraphEventsHelper as v, getGraphEventsPublisher as y };
|
|
2152
|
+
//# sourceMappingURL=graph-DDYgIryR.js.map
|