@burdenoff/be-sdk 2026.1110.2 → 2026.1110.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-GXC3A7DH.js +0 -8
- package/dist/EventQueueFactory-GXC3A7DH.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-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-AXJDGQPE.js +0 -690
- package/dist/chunk-AXJDGQPE.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-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-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-HNMHPSAM.js +0 -272
- package/dist/chunk-HNMHPSAM.js.map +0 -1
- package/dist/chunk-HTLEGD3Q.js +0 -1480
- package/dist/chunk-HTLEGD3Q.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-JS52ZHTK.js +0 -1346
- package/dist/chunk-JS52ZHTK.js.map +0 -1
- package/dist/chunk-JVMAQOA3.js +0 -521
- package/dist/chunk-JVMAQOA3.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-OBBCR6WY.js +0 -277
- package/dist/chunk-OBBCR6WY.js.map +0 -1
- package/dist/chunk-OQDSAOG3.js +0 -1908
- package/dist/chunk-OQDSAOG3.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-PN6GIF3R.js +0 -1185
- package/dist/chunk-PN6GIF3R.js.map +0 -1
- 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-Z77BTSOK.js +0 -617
- package/dist/chunk-Z77BTSOK.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,1243 @@
|
|
|
1
|
+
import { a as logger } from "./logger-B6rCpb7D.js";
|
|
2
|
+
import { i as safeStringify } from "./EventQueueFactory-9NGZV9jl.js";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
5
|
+
import { Pool } from "pg";
|
|
6
|
+
|
|
7
|
+
// src/graph/utils/registry.ts
|
|
8
|
+
/**
|
|
9
|
+
* Graph Registry - Decentralized Graph Configuration System
|
|
10
|
+
*
|
|
11
|
+
* This registry allows each module to define its own graph configuration
|
|
12
|
+
* without touching the central graph module. Modules register their entity
|
|
13
|
+
* and relationship mappings, which are then used by the graph sync service.
|
|
14
|
+
*
|
|
15
|
+
* @module graph-registry
|
|
16
|
+
* @category Graph
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Central registry for all graph configurations
|
|
20
|
+
*/
|
|
21
|
+
var GraphRegistry = class {
|
|
22
|
+
static entityMappings = /* @__PURE__ */ new Map();
|
|
23
|
+
static relationshipMappings = /* @__PURE__ */ new Map();
|
|
24
|
+
static registeredModules = /* @__PURE__ */ new Set();
|
|
25
|
+
/**
|
|
26
|
+
* Resolve fields from entity configuration
|
|
27
|
+
*
|
|
28
|
+
* @param entityType - Name of the entity type
|
|
29
|
+
* @param config - Entity configuration
|
|
30
|
+
* @returns Resolved array of field names
|
|
31
|
+
*/
|
|
32
|
+
static resolveFields(entityType, config) {
|
|
33
|
+
if (Array.isArray(config.fields)) return config.fields;
|
|
34
|
+
logger.warn(`[GraphRegistry] No fields configuration for ${entityType}, using empty array`);
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Register a module's graph configuration
|
|
39
|
+
* @param config - Module graph configuration
|
|
40
|
+
*/
|
|
41
|
+
static registerModule(config) {
|
|
42
|
+
const { moduleName, entities, relationships } = config;
|
|
43
|
+
if (this.registeredModules.has(moduleName)) {
|
|
44
|
+
logger.warn(`[GraphRegistry] Module '${moduleName}' already registered, skipping`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
logger.info(`[GraphRegistry] Registering module: ${moduleName}`);
|
|
48
|
+
let entityCount = 0;
|
|
49
|
+
for (const [entityType, entityConfig] of Object.entries(entities)) if (entityConfig.enabled !== false) {
|
|
50
|
+
const resolvedFields = this.resolveFields(entityType, entityConfig);
|
|
51
|
+
const resolvedConfig = {
|
|
52
|
+
...entityConfig,
|
|
53
|
+
fields: resolvedFields
|
|
54
|
+
};
|
|
55
|
+
this.entityMappings.set(entityType, resolvedConfig);
|
|
56
|
+
entityCount++;
|
|
57
|
+
}
|
|
58
|
+
let relationshipCount = 0;
|
|
59
|
+
if (relationships) {
|
|
60
|
+
for (const [relationshipType, relationshipConfig] of Object.entries(relationships)) if (relationshipConfig.enabled !== false) {
|
|
61
|
+
this.relationshipMappings.set(relationshipType, relationshipConfig);
|
|
62
|
+
relationshipCount++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.registeredModules.add(moduleName);
|
|
66
|
+
logger.info(`[GraphRegistry] ✅ Registered ${moduleName}: ${entityCount} entities, ${relationshipCount} relationships`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get entity configuration by entity type
|
|
70
|
+
* @param entityType - Entity type name (e.g., 'Calendar', 'Group')
|
|
71
|
+
* @returns Entity configuration or undefined (with resolved fields)
|
|
72
|
+
*/
|
|
73
|
+
static getEntityConfig(entityType) {
|
|
74
|
+
return this.entityMappings.get(entityType);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get relationship configuration by relationship type
|
|
78
|
+
* @param relationshipType - Relationship type name (e.g., 'EventAttendee', 'GroupMembership')
|
|
79
|
+
* @returns Relationship configuration or undefined
|
|
80
|
+
*/
|
|
81
|
+
static getRelationshipConfig(relationshipType) {
|
|
82
|
+
return this.relationshipMappings.get(relationshipType);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get all registered entity types
|
|
86
|
+
* @returns Array of entity type names
|
|
87
|
+
*/
|
|
88
|
+
static getAllEntityTypes() {
|
|
89
|
+
return Array.from(this.entityMappings.keys());
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get all registered relationship types
|
|
93
|
+
* @returns Array of relationship type names
|
|
94
|
+
*/
|
|
95
|
+
static getAllRelationshipTypes() {
|
|
96
|
+
return Array.from(this.relationshipMappings.keys());
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get all registered module names
|
|
100
|
+
* @returns Array of module names
|
|
101
|
+
*/
|
|
102
|
+
static getRegisteredModules() {
|
|
103
|
+
return Array.from(this.registeredModules);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Check if an entity type is registered
|
|
107
|
+
* @param entityType - Entity type to check
|
|
108
|
+
* @returns True if registered
|
|
109
|
+
*/
|
|
110
|
+
static isEntityRegistered(entityType) {
|
|
111
|
+
return this.entityMappings.has(entityType);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if a relationship type is registered
|
|
115
|
+
* @param relationshipType - Relationship type to check
|
|
116
|
+
* @returns True if registered
|
|
117
|
+
*/
|
|
118
|
+
static isRelationshipRegistered(relationshipType) {
|
|
119
|
+
return this.relationshipMappings.has(relationshipType);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Extract organization ID from entity data using configured mapping function
|
|
123
|
+
* @param entityType - Entity type name
|
|
124
|
+
* @param data - Entity data record
|
|
125
|
+
* @returns Organization ID or undefined
|
|
126
|
+
*/
|
|
127
|
+
static getOrganizationId(entityType, data) {
|
|
128
|
+
const config = this.entityMappings.get(entityType);
|
|
129
|
+
if (!config || !config.getOrgId) return;
|
|
130
|
+
return config.getOrgId(data);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Extract workspace ID from entity data using configured mapping function
|
|
134
|
+
* @param entityType - Entity type name
|
|
135
|
+
* @param data - Entity data record
|
|
136
|
+
* @returns Workspace ID or undefined
|
|
137
|
+
*/
|
|
138
|
+
static getWorkspaceId(entityType, data) {
|
|
139
|
+
const config = this.entityMappings.get(entityType);
|
|
140
|
+
if (!config || !config.getWorkspaceId) return;
|
|
141
|
+
return config.getWorkspaceId(data);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get RBAC configuration for an entity type
|
|
145
|
+
* Used by the Prisma graph extension to include RBAC metadata in entity events
|
|
146
|
+
* @param entityType - Entity type name (e.g., 'Conversation', 'Agent')
|
|
147
|
+
* @returns RBAC config or undefined if no RBAC is configured for this entity
|
|
148
|
+
*/
|
|
149
|
+
static getRbacConfig(entityType) {
|
|
150
|
+
return this.entityMappings.get(entityType)?.rbac;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get the bulk-operation (`updateMany` / `deleteMany`) handling configured for an entity type
|
|
154
|
+
* @param entityType - Entity type name (e.g., 'Agent')
|
|
155
|
+
* @returns Bulk-operation config or undefined when the entity does not configure one
|
|
156
|
+
*/
|
|
157
|
+
static getBulkOperationsConfig(entityType) {
|
|
158
|
+
return this.entityMappings.get(entityType)?.bulkOperations;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Resolve RBAC event metadata from entity data
|
|
162
|
+
* Converts the registry's function-based RBAC config into the flat metadata
|
|
163
|
+
* structure expected by the RBAC consumer in the NATS event payload.
|
|
164
|
+
* @param entityType - Entity type name
|
|
165
|
+
* @param entityData - The entity data record
|
|
166
|
+
* @returns RBAC metadata for the event or undefined
|
|
167
|
+
*/
|
|
168
|
+
static resolveRbacMetadata(entityType, entityData) {
|
|
169
|
+
const rbacConfig = this.getRbacConfig(entityType);
|
|
170
|
+
if (!rbacConfig) return;
|
|
171
|
+
const name = rbacConfig.extractName ? rbacConfig.extractName(entityData) : void 0;
|
|
172
|
+
const identifier = rbacConfig.extractIdentifier ? rbacConfig.extractIdentifier(entityData) : void 0;
|
|
173
|
+
const parentResourceIdentifier = rbacConfig.parentResourceField ? entityData[rbacConfig.parentResourceField] : void 0;
|
|
174
|
+
return {
|
|
175
|
+
resourceTypeName: rbacConfig.resourceTypeName,
|
|
176
|
+
...name && { name },
|
|
177
|
+
...identifier && { identifier },
|
|
178
|
+
...parentResourceIdentifier && { parentResourceIdentifier },
|
|
179
|
+
...rbacConfig.createResource !== void 0 && { createResource: rbacConfig.createResource }
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get statistics about registered configurations
|
|
184
|
+
* @returns Statistics object
|
|
185
|
+
*/
|
|
186
|
+
static getStats() {
|
|
187
|
+
const collections = /* @__PURE__ */ new Set();
|
|
188
|
+
const edgeTypes = /* @__PURE__ */ new Set();
|
|
189
|
+
for (const config of this.entityMappings.values()) collections.add(config.collection || "product_entities");
|
|
190
|
+
for (const config of this.relationshipMappings.values()) if (config.label) edgeTypes.add(config.label);
|
|
191
|
+
return {
|
|
192
|
+
modules: this.registeredModules.size,
|
|
193
|
+
entities: this.entityMappings.size,
|
|
194
|
+
relationships: this.relationshipMappings.size,
|
|
195
|
+
collections,
|
|
196
|
+
edgeTypes
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Clear all registrations (for testing)
|
|
201
|
+
*/
|
|
202
|
+
static clear() {
|
|
203
|
+
this.entityMappings.clear();
|
|
204
|
+
this.relationshipMappings.clear();
|
|
205
|
+
this.registeredModules.clear();
|
|
206
|
+
logger.info("[GraphRegistry] Cleared all registrations");
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get all relationships where the given entity type is the "from" side
|
|
210
|
+
* This is used for automatic relationship event emission when entities are created/updated
|
|
211
|
+
* @param entityType - Entity type name (e.g., 'UniversalTag')
|
|
212
|
+
* @returns Array of [relationshipKey, config] tuples
|
|
213
|
+
*/
|
|
214
|
+
static getRelationshipsForEntity(entityType) {
|
|
215
|
+
const result = [];
|
|
216
|
+
for (const [key, config] of this.relationshipMappings.entries()) if (config.from === entityType) result.push([key, config]);
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Print registry status to console
|
|
221
|
+
*/
|
|
222
|
+
static printStatus() {
|
|
223
|
+
const stats = this.getStats();
|
|
224
|
+
logger.info("");
|
|
225
|
+
logger.info("📊 Graph Registry Status");
|
|
226
|
+
logger.info("========================");
|
|
227
|
+
logger.info(`Registered Modules: ${stats.modules}`);
|
|
228
|
+
logger.info(`Total Entities: ${stats.entities}`);
|
|
229
|
+
logger.info(`Total Relationships: ${stats.relationships}`);
|
|
230
|
+
logger.info(`Vertex Collections: ${stats.collections.size}`);
|
|
231
|
+
logger.info(`Edge Types: ${stats.edgeTypes.size}`);
|
|
232
|
+
logger.info("");
|
|
233
|
+
logger.info("Registered Modules:", this.getRegisteredModules().join(", "));
|
|
234
|
+
logger.info("");
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/graph/utils/helpers.ts
|
|
239
|
+
/**
|
|
240
|
+
* Event Helpers - Registry-Based Graph Event Utilities
|
|
241
|
+
*
|
|
242
|
+
* This version uses the GraphRegistry to dynamically load entity and relationship
|
|
243
|
+
* configurations from module-level graph.config.ts files.
|
|
244
|
+
*
|
|
245
|
+
* @module graph-helpers
|
|
246
|
+
* @category Graph
|
|
247
|
+
*/
|
|
248
|
+
const uuidv4 = () => crypto.randomUUID();
|
|
249
|
+
/**
|
|
250
|
+
* Create an entity event for the graph
|
|
251
|
+
*/
|
|
252
|
+
function createEntityEvent(eventType, organizationId, entity, metadata, productSource) {
|
|
253
|
+
return {
|
|
254
|
+
eventId: `evt_${uuidv4()}`,
|
|
255
|
+
eventType,
|
|
256
|
+
organizationId,
|
|
257
|
+
productSource: productSource || process.env["PRODUCT_SOURCE"] || "default",
|
|
258
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
259
|
+
entity,
|
|
260
|
+
metadata: {
|
|
261
|
+
userId: metadata?.userId,
|
|
262
|
+
correlationId: metadata?.correlationId || `req_${uuidv4()}`
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Create a relationship event for the graph
|
|
268
|
+
*/
|
|
269
|
+
function createRelationshipEvent(eventType, organizationId, relationship, metadata, productSource) {
|
|
270
|
+
return {
|
|
271
|
+
eventId: `evt_${uuidv4()}`,
|
|
272
|
+
eventType,
|
|
273
|
+
organizationId,
|
|
274
|
+
productSource: productSource || process.env["PRODUCT_SOURCE"] || "default",
|
|
275
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
276
|
+
entity: {
|
|
277
|
+
id: `${relationship.from.id}_${relationship.to.id}`,
|
|
278
|
+
type: relationship.type,
|
|
279
|
+
data: {}
|
|
280
|
+
},
|
|
281
|
+
relationship,
|
|
282
|
+
metadata: {
|
|
283
|
+
userId: metadata?.userId,
|
|
284
|
+
correlationId: metadata?.correlationId || `req_${uuidv4()}`
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Extract minimal fields for syncing to graph (uses registry)
|
|
290
|
+
*
|
|
291
|
+
* @param modelName - Prisma model name (e.g., 'Calendar', 'Group')
|
|
292
|
+
* @param entity - Full entity data from Prisma
|
|
293
|
+
* @returns Minimal entity data for graph sync
|
|
294
|
+
*/
|
|
295
|
+
function extractMinimalFields(modelName, entity) {
|
|
296
|
+
const config = GraphRegistry.getEntityConfig(modelName);
|
|
297
|
+
if (!config) {
|
|
298
|
+
logger.warn(`[GraphHelpers] No graph config found for entity type: ${modelName}, using fallback`);
|
|
299
|
+
const minimal = {};
|
|
300
|
+
if (entity["id"]) minimal["id"] = entity["id"];
|
|
301
|
+
if (entity["workspaceID"]) minimal["workspaceID"] = entity["workspaceID"];
|
|
302
|
+
if (entity["workspaceId"]) minimal["workspaceId"] = entity["workspaceId"];
|
|
303
|
+
return minimal;
|
|
304
|
+
}
|
|
305
|
+
const minimal = {};
|
|
306
|
+
for (const field of config.fields) if (entity[field] !== void 0) minimal[field] = entity[field];
|
|
307
|
+
return minimal;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Parse relationship from join table models (uses registry)
|
|
311
|
+
*
|
|
312
|
+
* @param modelName - Relationship model name (e.g., 'EventAttendee', 'GroupMembership')
|
|
313
|
+
* @param relationship - Full relationship data from Prisma
|
|
314
|
+
* @returns Parsed relationship with from/to/type/metadata
|
|
315
|
+
*/
|
|
316
|
+
function parseRelationship(modelName, relationship) {
|
|
317
|
+
const config = GraphRegistry.getRelationshipConfig(modelName);
|
|
318
|
+
if (!config) {
|
|
319
|
+
logger.warn(`[GraphHelpers] No graph config found for relationship type: ${modelName}, using fallback`);
|
|
320
|
+
return {
|
|
321
|
+
from: {
|
|
322
|
+
id: "unknown",
|
|
323
|
+
type: "Unknown"
|
|
324
|
+
},
|
|
325
|
+
to: {
|
|
326
|
+
id: "unknown",
|
|
327
|
+
type: "Unknown"
|
|
328
|
+
},
|
|
329
|
+
relationshipType: "relates_to",
|
|
330
|
+
metadata: {}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
from: {
|
|
335
|
+
id: String(relationship[config.fromField] || "unknown"),
|
|
336
|
+
type: config.from
|
|
337
|
+
},
|
|
338
|
+
to: {
|
|
339
|
+
id: String(relationship[config.to] || "unknown"),
|
|
340
|
+
type: config.to
|
|
341
|
+
},
|
|
342
|
+
relationshipType: config.label || "relates_to",
|
|
343
|
+
metadata: config.extractMetadata?.(relationship) ?? {}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Get the graph vertex label for an entity type (uses registry)
|
|
348
|
+
*
|
|
349
|
+
* @param entityType - Entity type name
|
|
350
|
+
* @returns Collection name
|
|
351
|
+
*/
|
|
352
|
+
function getCollectionForEntity(entityType) {
|
|
353
|
+
const config = GraphRegistry.getEntityConfig(entityType);
|
|
354
|
+
if (!config) return "entity";
|
|
355
|
+
return config.collection || "entity";
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Extract title from entity (uses registry or fallback)
|
|
359
|
+
*
|
|
360
|
+
* @param entityType - Entity type name
|
|
361
|
+
* @param entity - Entity data
|
|
362
|
+
* @returns Title string
|
|
363
|
+
*/
|
|
364
|
+
function extractEntityTitle(entityType, entity) {
|
|
365
|
+
const config = GraphRegistry.getEntityConfig(entityType);
|
|
366
|
+
if (config?.extractTitle) return config.extractTitle(entity);
|
|
367
|
+
return String(entity["name"] || entity["title"] || entity["email"] || entity["id"] || "Untitled");
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Check if an entity type should be synced to the graph
|
|
371
|
+
*
|
|
372
|
+
* @param entityType - Entity type name
|
|
373
|
+
* @returns True if entity should be synced
|
|
374
|
+
*/
|
|
375
|
+
function shouldSyncEntity(entityType) {
|
|
376
|
+
const config = GraphRegistry.getEntityConfig(entityType);
|
|
377
|
+
if (!config) return false;
|
|
378
|
+
return config.enabled !== false;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Check if a relationship type should be synced to the graph
|
|
382
|
+
*
|
|
383
|
+
* @param relationshipType - Relationship type name
|
|
384
|
+
* @returns True if relationship should be synced
|
|
385
|
+
*/
|
|
386
|
+
function shouldSyncRelationship(relationshipType) {
|
|
387
|
+
const config = GraphRegistry.getRelationshipConfig(relationshipType);
|
|
388
|
+
if (!config) return false;
|
|
389
|
+
return config.enabled !== false;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// src/prisma/client.ts
|
|
393
|
+
/**
|
|
394
|
+
* Prisma 7 Client Factory with PostgreSQL Adapter
|
|
395
|
+
*
|
|
396
|
+
* This module provides a generic factory for creating Prisma clients
|
|
397
|
+
* configured with the PostgreSQL driver adapter as required by Prisma 7.
|
|
398
|
+
*
|
|
399
|
+
* Breaking Changes in Prisma 7:
|
|
400
|
+
* - Must use database driver adapter (@prisma/adapter-pg for PostgreSQL)
|
|
401
|
+
* - Datasource URL moved from schema.prisma to prisma.config.ts
|
|
402
|
+
* - DMMF no longer available at runtime (use generator for build-time access)
|
|
403
|
+
*
|
|
404
|
+
* @module prisma/client
|
|
405
|
+
*/
|
|
406
|
+
/**
|
|
407
|
+
* Create a PostgreSQL connection pool.
|
|
408
|
+
*
|
|
409
|
+
* The base pool sizing (max / idle / connection timeout) is unchanged. The
|
|
410
|
+
* optional tuning fields (`applicationName`, `statementTimeoutMillis`,
|
|
411
|
+
* `idleInTransactionTimeoutMillis`, `lockTimeoutMillis`) are only attached to
|
|
412
|
+
* the pool config when explicitly provided — when they are all unset, the
|
|
413
|
+
* resulting pool is byte-for-byte identical to the previous behavior. This keeps
|
|
414
|
+
* the change safe to roll out fleet-wide: `application_name` is pure diagnostic
|
|
415
|
+
* metadata, and every DB-enforced timeout defaults to OFF (pg default).
|
|
416
|
+
*/
|
|
417
|
+
function createConnectionPool(config) {
|
|
418
|
+
const idleTimeoutMillis = config.idleTimeoutMillis ?? 3e4;
|
|
419
|
+
const poolConfig = {
|
|
420
|
+
connectionString: config.databaseUrl,
|
|
421
|
+
max: config.maxConnections ?? 20,
|
|
422
|
+
idleTimeoutMillis,
|
|
423
|
+
connectionTimeoutMillis: config.connectionTimeoutMillis ?? 1e4,
|
|
424
|
+
keepAlive: true,
|
|
425
|
+
keepAliveInitialDelayMillis: 1e4
|
|
426
|
+
};
|
|
427
|
+
if (config.applicationName) poolConfig.application_name = config.applicationName;
|
|
428
|
+
if (config.queryTimeoutMillis != null && config.queryTimeoutMillis > 0) poolConfig.query_timeout = config.queryTimeoutMillis;
|
|
429
|
+
if (config.statementTimeoutMillis != null && config.statementTimeoutMillis > 0) poolConfig.statement_timeout = config.statementTimeoutMillis;
|
|
430
|
+
if (config.idleInTransactionTimeoutMillis != null && config.idleInTransactionTimeoutMillis > 0) poolConfig.idle_in_transaction_session_timeout = config.idleInTransactionTimeoutMillis;
|
|
431
|
+
if (config.lockTimeoutMillis != null && config.lockTimeoutMillis > 0) poolConfig.lock_timeout = config.lockTimeoutMillis;
|
|
432
|
+
const pool = new Pool(poolConfig);
|
|
433
|
+
pool.on("error", (error) => {
|
|
434
|
+
logger.warn("[pg-pool] Idle pooled connection errored (dropped by server/network); it will be replaced on next acquire", { error: error.message });
|
|
435
|
+
});
|
|
436
|
+
installAcquireRetry(pool, config.acquireRetries ?? 2, config.acquireRetryDelayMillis ?? 250);
|
|
437
|
+
startPoolWarmer(pool, config, idleTimeoutMillis);
|
|
438
|
+
return pool;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* True for errors that occur while ESTABLISHING a connection and are worth one
|
|
442
|
+
* more attempt: the cold-connect stall past `connectionTimeoutMillis` observed
|
|
443
|
+
* on Azure ACA, a checkout-queue timeout, a reset/refused during handshake, or
|
|
444
|
+
* transient DNS. Anything else (auth failure, TLS misconfig, "pool after end")
|
|
445
|
+
* fails immediately.
|
|
446
|
+
*/
|
|
447
|
+
function isTransientAcquireError(error) {
|
|
448
|
+
if (!(error instanceof Error)) return false;
|
|
449
|
+
const message = error.message.toLowerCase();
|
|
450
|
+
return message.includes("connection terminated due to connection timeout") || message.includes("timeout exceeded when trying to connect") || message.includes("connection terminated unexpectedly") || message.includes("econnreset") || message.includes("econnrefused") || message.includes("eai_again");
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Retry transient connect-phase failures when acquiring a pooled connection.
|
|
454
|
+
*
|
|
455
|
+
* The acquire phase (pool checkout / physical connect) happens BEFORE any query
|
|
456
|
+
* is dispatched, so retrying it is always safe — it can never double-execute a
|
|
457
|
+
* statement. This is the piece the keep-warm ping cannot cover: the warmer keeps
|
|
458
|
+
* one connection live, but a concurrent burst after an idle window still
|
|
459
|
+
* cold-connects clients 2..N, and any of those stalling past
|
|
460
|
+
* `connectionTimeoutMillis` used to surface directly as a resolver 500
|
|
461
|
+
* ("Connection terminated due to connection timeout").
|
|
462
|
+
*
|
|
463
|
+
* Patches `pool.connect` in place (both the promise and callback forms —
|
|
464
|
+
* `pool.query` funnels through the callback form internally, and the Prisma
|
|
465
|
+
* pg adapter uses both), so every consumer of the pool gets the retry.
|
|
466
|
+
*/
|
|
467
|
+
function installAcquireRetry(pool, retries, baseDelayMillis) {
|
|
468
|
+
if (retries <= 0) return;
|
|
469
|
+
const originalConnect = pool.connect.bind(pool);
|
|
470
|
+
const acquireWithRetry = async () => {
|
|
471
|
+
let attempt = 0;
|
|
472
|
+
for (;;) try {
|
|
473
|
+
return await originalConnect();
|
|
474
|
+
} catch (error) {
|
|
475
|
+
if (attempt >= retries || !isTransientAcquireError(error)) throw error;
|
|
476
|
+
attempt += 1;
|
|
477
|
+
const delayMillis = baseDelayMillis * 2 ** (attempt - 1);
|
|
478
|
+
logger.warn(`[pg-pool] Transient connection-acquire failure (attempt ${String(attempt)}/${String(retries)}); retrying in ${String(delayMillis)}ms`, { error: error instanceof Error ? error.message : String(error) });
|
|
479
|
+
await new Promise((resolve) => setTimeout(resolve, delayMillis));
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
const patchedConnect = (callback) => {
|
|
483
|
+
if (typeof callback === "function") {
|
|
484
|
+
acquireWithRetry().then((client) => {
|
|
485
|
+
callback(void 0, client, client.release.bind(client));
|
|
486
|
+
}, (error) => {
|
|
487
|
+
callback(error instanceof Error ? error : new Error(String(error)), void 0, () => void 0);
|
|
488
|
+
});
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
return acquireWithRetry();
|
|
492
|
+
};
|
|
493
|
+
pool.connect = patchedConnect;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Keep at least one pooled connection live during quiet periods.
|
|
497
|
+
*
|
|
498
|
+
* `pg.Pool` closes every idle client after `idleTimeoutMillis`, so a service
|
|
499
|
+
* that goes quiet for that long drains to zero connections and the next request
|
|
500
|
+
* pays a full cold connect. On Azure ACA that cold TLS handshake occasionally
|
|
501
|
+
* stalls past `connectionTimeoutMillis`, 500ing the request. A lightweight
|
|
502
|
+
* `SELECT 1` on an interval shorter than the idle timeout keeps one connection
|
|
503
|
+
* checked-out-and-released just often enough that its idle timer never expires,
|
|
504
|
+
* so post-idle requests reuse a warm socket. The timer is `unref`'d (never keeps
|
|
505
|
+
* the process alive) and cleared when the pool ends.
|
|
506
|
+
*/
|
|
507
|
+
function startPoolWarmer(pool, config, idleTimeoutMillis) {
|
|
508
|
+
if (config.keepWarm === false) return;
|
|
509
|
+
const intervalMs = config.warmupIntervalMillis ?? 2e4;
|
|
510
|
+
if (intervalMs <= 0 || idleTimeoutMillis > 0 && intervalMs >= idleTimeoutMillis) return;
|
|
511
|
+
const WARM_FAILURE_LOG_INTERVAL_MS = 6e4;
|
|
512
|
+
let consecutiveWarmFailures = 0;
|
|
513
|
+
let lastWarmFailureLogAt = 0;
|
|
514
|
+
const timer = setInterval(() => {
|
|
515
|
+
pool.query("SELECT 1").then(() => {
|
|
516
|
+
if (consecutiveWarmFailures > 0) {
|
|
517
|
+
logger.info("[pg-pool] Warm-up query recovered", { failedAttempts: consecutiveWarmFailures });
|
|
518
|
+
consecutiveWarmFailures = 0;
|
|
519
|
+
}
|
|
520
|
+
}, (error) => {
|
|
521
|
+
consecutiveWarmFailures += 1;
|
|
522
|
+
const now = Date.now();
|
|
523
|
+
if (now - lastWarmFailureLogAt >= WARM_FAILURE_LOG_INTERVAL_MS) {
|
|
524
|
+
lastWarmFailureLogAt = now;
|
|
525
|
+
logger.warn("[pg-pool] Warm-up query failing — the pool cannot establish connections to Postgres right now", {
|
|
526
|
+
consecutiveWarmFailures,
|
|
527
|
+
error: error instanceof Error ? error.message : String(error)
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}, intervalMs);
|
|
532
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
533
|
+
const originalEnd = pool.end.bind(pool);
|
|
534
|
+
pool.end = ((...args) => {
|
|
535
|
+
clearInterval(timer);
|
|
536
|
+
return originalEnd(...args);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Ensure a per-service Postgres `application_name` is set process-wide.
|
|
541
|
+
*
|
|
542
|
+
* node-postgres reads the libpq `PGAPPNAME` environment variable as the
|
|
543
|
+
* `application_name` fallback for every Client/Pool it creates. Setting it here
|
|
544
|
+
* guarantees per-service attribution in pg_stat_activity / pg_stat_statements for
|
|
545
|
+
* ALL pools a service opens — including pools a service constructs itself (e.g.
|
|
546
|
+
* via `createPrismaGraphIntegration`'s `createPrismaClient` closure) that bypass
|
|
547
|
+
* `createConnectionPool`.
|
|
548
|
+
*
|
|
549
|
+
* Behavior-preserving: this is pure diagnostic metadata, it is only applied when
|
|
550
|
+
* `PGAPPNAME` is not already set (so an explicit operator/env value wins), and an
|
|
551
|
+
* explicit `application_name` in a pool config still takes precedence over the
|
|
552
|
+
* env fallback.
|
|
553
|
+
*/
|
|
554
|
+
function ensureServiceApplicationName(productName) {
|
|
555
|
+
if (productName && !process.env["PGAPPNAME"]) process.env["PGAPPNAME"] = `svc=${productName}`;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Create a Prisma PostgreSQL adapter
|
|
559
|
+
*/
|
|
560
|
+
function createPrismaAdapter(pool) {
|
|
561
|
+
return new PrismaPg(pool);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Configure Prisma client logging
|
|
565
|
+
*/
|
|
566
|
+
function configurePrismaLogging(client, config) {
|
|
567
|
+
const isDevelopment = process.env["NODE_ENV"] === "development";
|
|
568
|
+
const slowQueryThreshold = config.slowQueryThreshold ?? (isDevelopment ? 100 : 500);
|
|
569
|
+
if (config.enableQueryLogging ?? isDevelopment) client.$on("query", (e) => {
|
|
570
|
+
if ("query" in e && "duration" in e) {
|
|
571
|
+
if (e.duration > slowQueryThreshold) logger.warn("[Prisma] Slow query detected", {
|
|
572
|
+
query: e.query.substring(0, 200) + (e.query.length > 200 ? "..." : ""),
|
|
573
|
+
params: e.params,
|
|
574
|
+
duration: `${e.duration}ms`
|
|
575
|
+
});
|
|
576
|
+
else logger.debug("[Prisma] Query", {
|
|
577
|
+
query: e.query.substring(0, 100) + (e.query.length > 100 ? "..." : ""),
|
|
578
|
+
duration: `${e.duration}ms`
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
client.$on("error", (e) => {
|
|
583
|
+
if ("message" in e) logger.error("[Prisma] Database error", {
|
|
584
|
+
message: e.message,
|
|
585
|
+
target: e.target
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
client.$on("warn", (e) => {
|
|
589
|
+
if ("message" in e) logger.warn("[Prisma] Database warning", {
|
|
590
|
+
message: e.message,
|
|
591
|
+
target: e.target
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
return client;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Prisma Client Wrapper with connection management
|
|
598
|
+
*/
|
|
599
|
+
var PrismaClientWrapper = class {
|
|
600
|
+
client;
|
|
601
|
+
pool;
|
|
602
|
+
connectionState = {
|
|
603
|
+
isConnected: false,
|
|
604
|
+
attempts: 0
|
|
605
|
+
};
|
|
606
|
+
isDisconnecting = false;
|
|
607
|
+
constructor(client, pool, config) {
|
|
608
|
+
this.client = client;
|
|
609
|
+
this.pool = pool;
|
|
610
|
+
configurePrismaLogging(this.client, config);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Get the Prisma client instance
|
|
614
|
+
*/
|
|
615
|
+
getClient() {
|
|
616
|
+
return this.client;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Get the connection pool
|
|
620
|
+
*/
|
|
621
|
+
getPool() {
|
|
622
|
+
return this.pool;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Get connection state
|
|
626
|
+
*/
|
|
627
|
+
getConnectionState() {
|
|
628
|
+
return { ...this.connectionState };
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Connect to database with retry logic
|
|
632
|
+
*/
|
|
633
|
+
async connect(retries = 5, delay = 1e3) {
|
|
634
|
+
if (this.connectionState.isConnected) {
|
|
635
|
+
logger.info("[Prisma] Already connected to database");
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
639
|
+
this.connectionState.attempts = attempt;
|
|
640
|
+
try {
|
|
641
|
+
await this.client.$connect();
|
|
642
|
+
this.connectionState.isConnected = true;
|
|
643
|
+
this.connectionState.lastConnectedAt = /* @__PURE__ */ new Date();
|
|
644
|
+
this.connectionState.lastError = void 0;
|
|
645
|
+
logger.info("[Prisma] Successfully connected to database");
|
|
646
|
+
return;
|
|
647
|
+
} catch (error) {
|
|
648
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
649
|
+
this.connectionState.lastError = errorMessage;
|
|
650
|
+
logger.error(`[Prisma] Connection attempt ${attempt}/${retries} failed`, { error: errorMessage });
|
|
651
|
+
if (attempt === retries) {
|
|
652
|
+
logger.error("[Prisma] Max connection retries reached");
|
|
653
|
+
throw error;
|
|
654
|
+
}
|
|
655
|
+
const waitTime = delay * Math.pow(2, attempt - 1);
|
|
656
|
+
logger.info(`[Prisma] Retrying in ${waitTime}ms...`);
|
|
657
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Gracefully disconnect from database
|
|
663
|
+
*/
|
|
664
|
+
async disconnect() {
|
|
665
|
+
if (this.isDisconnecting) {
|
|
666
|
+
logger.debug("[Prisma] Disconnect already in progress, skipping");
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (!this.connectionState.isConnected) {
|
|
670
|
+
logger.info("[Prisma] Database already disconnected");
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
this.isDisconnecting = true;
|
|
674
|
+
try {
|
|
675
|
+
await this.client.$disconnect();
|
|
676
|
+
await this.pool.end();
|
|
677
|
+
this.connectionState.isConnected = false;
|
|
678
|
+
logger.info("[Prisma] Successfully disconnected from database");
|
|
679
|
+
} catch (error) {
|
|
680
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
681
|
+
if (errorMessage.includes("Called end on pool more than once")) {
|
|
682
|
+
logger.debug("[Prisma] Pool already ended, ignoring duplicate end call");
|
|
683
|
+
this.connectionState.isConnected = false;
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
logger.error("[Prisma] Error disconnecting from database", { error: errorMessage });
|
|
687
|
+
throw error;
|
|
688
|
+
} finally {
|
|
689
|
+
this.isDisconnecting = false;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Register graceful shutdown handlers
|
|
694
|
+
*/
|
|
695
|
+
registerShutdownHandlers() {
|
|
696
|
+
const shutdownHandler = async (signal) => {
|
|
697
|
+
logger.info(`[Prisma] Received ${signal}, starting graceful shutdown...`);
|
|
698
|
+
try {
|
|
699
|
+
await this.disconnect();
|
|
700
|
+
process.exit(0);
|
|
701
|
+
} catch (error) {
|
|
702
|
+
logger.error("[Prisma] Error during graceful shutdown", { error: error instanceof Error ? error.message : String(error) });
|
|
703
|
+
process.exit(1);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
process.on("SIGINT", () => void shutdownHandler("SIGINT"));
|
|
707
|
+
process.on("SIGTERM", () => void shutdownHandler("SIGTERM"));
|
|
708
|
+
process.on("beforeExit", () => void this.disconnect());
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
function createPrismaClient(PrismaClientConstructor, config) {
|
|
712
|
+
const isDevelopment = process.env["NODE_ENV"] === "development";
|
|
713
|
+
const pool = createConnectionPool(config);
|
|
714
|
+
const client = new PrismaClientConstructor({
|
|
715
|
+
adapter: createPrismaAdapter(pool),
|
|
716
|
+
log: config.logLevels ?? (isDevelopment ? [
|
|
717
|
+
{
|
|
718
|
+
emit: "event",
|
|
719
|
+
level: "query"
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
emit: "event",
|
|
723
|
+
level: "info"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
emit: "event",
|
|
727
|
+
level: "warn"
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
emit: "event",
|
|
731
|
+
level: "error"
|
|
732
|
+
}
|
|
733
|
+
] : [{
|
|
734
|
+
emit: "event",
|
|
735
|
+
level: "warn"
|
|
736
|
+
}, {
|
|
737
|
+
emit: "event",
|
|
738
|
+
level: "error"
|
|
739
|
+
}])
|
|
740
|
+
});
|
|
741
|
+
return new PrismaClientWrapper(client, pool, config);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/graph/middleware/deferred-events.ts
|
|
745
|
+
const scopes = new AsyncLocalStorage();
|
|
746
|
+
/**
|
|
747
|
+
* Wrap the entire awaited database transaction, not its callback. Rejection discards
|
|
748
|
+
* events; resolution means COMMIT completed, then delivery is attempted in order.
|
|
749
|
+
* Delivery failure cannot roll back committed data and is reported without throwing
|
|
750
|
+
* a transaction failure. This is in-memory best effort, not a durable outbox or
|
|
751
|
+
* exactly-once guarantee. Await all transaction work; nested scopes are unsupported.
|
|
752
|
+
*/
|
|
753
|
+
async function withDeferredGraphEvents(transaction) {
|
|
754
|
+
if (scopes.getStore()) throw new Error("Nested deferred graph scope is not supported");
|
|
755
|
+
const scope = {
|
|
756
|
+
active: true,
|
|
757
|
+
deliveries: []
|
|
758
|
+
};
|
|
759
|
+
let result;
|
|
760
|
+
try {
|
|
761
|
+
result = await scopes.run(scope, transaction);
|
|
762
|
+
} catch (error) {
|
|
763
|
+
scope.active = false;
|
|
764
|
+
scope.deliveries.length = 0;
|
|
765
|
+
throw error;
|
|
766
|
+
}
|
|
767
|
+
scope.active = false;
|
|
768
|
+
const deliveries = scope.deliveries.splice(0);
|
|
769
|
+
let failed = 0;
|
|
770
|
+
for (const deliver of deliveries) try {
|
|
771
|
+
await deliver();
|
|
772
|
+
} catch {
|
|
773
|
+
failed += 1;
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
result,
|
|
777
|
+
eventDelivery: {
|
|
778
|
+
attempted: deliveries.length,
|
|
779
|
+
failed
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
/** Internal Prisma hook delivery boundary; snapshots queued payloads at admission. */
|
|
784
|
+
function dispatchGraphEvent(emitter, ...event) {
|
|
785
|
+
const scope = scopes.getStore();
|
|
786
|
+
if (scope) {
|
|
787
|
+
if (!scope.active) throw new Error("Deferred graph scope is already closed");
|
|
788
|
+
try {
|
|
789
|
+
const snapshot = JSON.parse(safeStringify(event));
|
|
790
|
+
if (event[3] === void 0) snapshot[3] = void 0;
|
|
791
|
+
scope.deliveries.push(() => emitter.publishEntityEvent(...snapshot));
|
|
792
|
+
} catch {
|
|
793
|
+
scope.deliveries.push(async () => {
|
|
794
|
+
throw new Error("Graph event snapshot serialization failed");
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
emitter.publishEntityEvent(...event).catch((error) => {
|
|
800
|
+
logger.error("[GraphMiddleware] Failed to emit event:", error);
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Internal: run follow-up graph work (e.g. the post-write re-read of an `updateMany`)
|
|
805
|
+
* after the surrounding deferred scope commits, or immediately (fire-and-forget) when
|
|
806
|
+
* there is no scope. Inside a scope the task counts as one delivery: a rejected task is
|
|
807
|
+
* reported as one failed delivery and never fails the transaction. Events the task
|
|
808
|
+
* dispatches run outside the closed scope and are published directly.
|
|
809
|
+
*/
|
|
810
|
+
function deferGraphTask(task) {
|
|
811
|
+
const scope = scopes.getStore();
|
|
812
|
+
if (scope) {
|
|
813
|
+
if (!scope.active) throw new Error("Deferred graph scope is already closed");
|
|
814
|
+
scope.deliveries.push(task);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
task().catch((error) => {
|
|
818
|
+
logger.error("[GraphMiddleware] Deferred graph task failed:", error);
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// src/graph/middleware/bulk-operations.ts
|
|
823
|
+
/**
|
|
824
|
+
* Per-row graph event emission for Prisma bulk writes (`updateMany` / `deleteMany`).
|
|
825
|
+
*
|
|
826
|
+
* Bulk writes return only `{ count }`, so the graph extension cannot see which rows
|
|
827
|
+
* changed. Entities that opt in with `bulkOperations: { mode: 'per-row' }` get:
|
|
828
|
+
*
|
|
829
|
+
* - `updateMany`: the affected ids are read with `args.where` BEFORE the write (the
|
|
830
|
+
* write may change the very columns the filter matches on, e.g. `isActive`), the
|
|
831
|
+
* rows are re-read by id AFTER the write and one `entity.updated` event is emitted
|
|
832
|
+
* per row. Plain scalar values from `args.data` are overlaid on the re-read row, so
|
|
833
|
+
* the payload reflects the write even when the re-read runs before an enclosing
|
|
834
|
+
* interactive transaction commits.
|
|
835
|
+
* - `deleteMany`: the affected rows are read BEFORE the write and one
|
|
836
|
+
* `entity.deleted` event is emitted per row once the delete succeeded.
|
|
837
|
+
*
|
|
838
|
+
* Reads use the un-extended base client. Inside `withDeferredGraphEvents` the re-read
|
|
839
|
+
* and emission run after COMMIT; a failure to read never fails the database write.
|
|
840
|
+
*
|
|
841
|
+
* @module graph/middleware/bulk-operations
|
|
842
|
+
* @category Graph
|
|
843
|
+
*/
|
|
844
|
+
/** Default cap on rows read/emitted for a single bulk write. */
|
|
845
|
+
const DEFAULT_BULK_MAX_ROWS = 500;
|
|
846
|
+
/** Upper bound of rows tracked by the throttle (oldest entries are evicted first). */
|
|
847
|
+
const THROTTLE_CACHE_LIMIT = 1e4;
|
|
848
|
+
/** Prisma field-update operators; an object with exactly one of these keys is an operation, not a value. */
|
|
849
|
+
const UPDATE_OPERATORS = /* @__PURE__ */ new Set([
|
|
850
|
+
"set",
|
|
851
|
+
"increment",
|
|
852
|
+
"decrement",
|
|
853
|
+
"multiply",
|
|
854
|
+
"divide",
|
|
855
|
+
"push",
|
|
856
|
+
"unset"
|
|
857
|
+
]);
|
|
858
|
+
function isRecord(value) {
|
|
859
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
860
|
+
}
|
|
861
|
+
function isFindManyDelegate(value) {
|
|
862
|
+
return isRecord(value) && typeof value["findMany"] === "function";
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Resolve the effective bulk-operation settings for an entity: the entity's own
|
|
866
|
+
* config wins over the extension-wide default. Returns null when per-row emission
|
|
867
|
+
* is not enabled.
|
|
868
|
+
*/
|
|
869
|
+
function resolveBulkOperations(model, defaults) {
|
|
870
|
+
const config = GraphRegistry.getBulkOperationsConfig(model) ?? defaults;
|
|
871
|
+
if (!config || config.mode !== "per-row") return null;
|
|
872
|
+
return {
|
|
873
|
+
maxRows: config.maxRows !== void 0 && Number.isInteger(config.maxRows) && config.maxRows > 0 ? config.maxRows : 500,
|
|
874
|
+
throttleMs: config.throttleMs !== void 0 && config.throttleMs > 0 ? config.throttleMs : 0,
|
|
875
|
+
ignoreFields: new Set(config.ignoreFields ?? [])
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
/** Prisma delegate property name for a model (`DataTable` → `dataTable`). */
|
|
879
|
+
function delegateNameForModel(model) {
|
|
880
|
+
return model.charAt(0).toLowerCase() + model.slice(1);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Overlay plain values from an `updateMany` `data` payload onto a row.
|
|
884
|
+
* `{ set: v }` is applied; other field operators (`increment`, …) are left to the
|
|
885
|
+
* re-read value because the result cannot be computed without the database.
|
|
886
|
+
*/
|
|
887
|
+
function applyScalarUpdates(row, data) {
|
|
888
|
+
if (!isRecord(data)) return row;
|
|
889
|
+
const next = { ...row };
|
|
890
|
+
for (const [field, value] of Object.entries(data)) {
|
|
891
|
+
if (value === void 0) continue;
|
|
892
|
+
if (isRecord(value) && !(value instanceof Date)) {
|
|
893
|
+
const keys = Object.keys(value);
|
|
894
|
+
const [onlyKey] = keys;
|
|
895
|
+
if (keys.length === 1 && onlyKey !== void 0 && UPDATE_OPERATORS.has(onlyKey)) {
|
|
896
|
+
if (onlyKey === "set") next[field] = value["set"];
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
next[field] = value;
|
|
901
|
+
}
|
|
902
|
+
return next;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Throttles bulk-originated `entity.updated` events per row. An event is published when
|
|
906
|
+
* the row's change signature (its emitted fields minus `ignoreFields`) differs from the
|
|
907
|
+
* last published one, or when `throttleMs` elapsed since the last publish.
|
|
908
|
+
*/
|
|
909
|
+
var BulkEmissionThrottle = class {
|
|
910
|
+
limit;
|
|
911
|
+
last = /* @__PURE__ */ new Map();
|
|
912
|
+
constructor(limit = THROTTLE_CACHE_LIMIT) {
|
|
913
|
+
this.limit = limit;
|
|
914
|
+
}
|
|
915
|
+
shouldEmit(key, signature, throttleMs, now) {
|
|
916
|
+
if (throttleMs <= 0) return true;
|
|
917
|
+
const previous = this.last.get(key);
|
|
918
|
+
if (previous && previous.signature === signature && now - previous.at < throttleMs) return false;
|
|
919
|
+
this.last.delete(key);
|
|
920
|
+
this.last.set(key, {
|
|
921
|
+
signature,
|
|
922
|
+
at: now
|
|
923
|
+
});
|
|
924
|
+
while (this.last.size > this.limit) {
|
|
925
|
+
const oldest = this.last.keys().next();
|
|
926
|
+
if (oldest.done) break;
|
|
927
|
+
this.last.delete(oldest.value);
|
|
928
|
+
}
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
/** Forget a row (after it was deleted). */
|
|
932
|
+
forget(key) {
|
|
933
|
+
this.last.delete(key);
|
|
934
|
+
}
|
|
935
|
+
get size() {
|
|
936
|
+
return this.last.size;
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
function changeSignature(model, row, ignoreFields) {
|
|
940
|
+
const minimal = extractMinimalFields(model, row);
|
|
941
|
+
const material = {};
|
|
942
|
+
for (const [field, value] of Object.entries(minimal)) if (!ignoreFields.has(field)) material[field] = value;
|
|
943
|
+
return safeStringify(material);
|
|
944
|
+
}
|
|
945
|
+
function rowIds(rows) {
|
|
946
|
+
const ids = [];
|
|
947
|
+
for (const row of rows) if (isRecord(row) && typeof row["id"] === "string" && row["id"]) ids.push(row["id"]);
|
|
948
|
+
return ids;
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Handles per-row emission of bulk writes for one extended Prisma client.
|
|
952
|
+
*/
|
|
953
|
+
var BulkOperationTracker = class {
|
|
954
|
+
baseClient;
|
|
955
|
+
emitRow;
|
|
956
|
+
now;
|
|
957
|
+
throttle = new BulkEmissionThrottle();
|
|
958
|
+
constructor(baseClient, emitRow, now = Date.now) {
|
|
959
|
+
this.baseClient = baseClient;
|
|
960
|
+
this.emitRow = emitRow;
|
|
961
|
+
this.now = now;
|
|
962
|
+
}
|
|
963
|
+
delegate(model) {
|
|
964
|
+
if (!isRecord(this.baseClient)) return null;
|
|
965
|
+
const candidate = this.baseClient[delegateNameForModel(model)];
|
|
966
|
+
return isFindManyDelegate(candidate) ? candidate : null;
|
|
967
|
+
}
|
|
968
|
+
/** Read the rows a bulk write will touch; null when they cannot be read (the write still proceeds). */
|
|
969
|
+
async readAffected(model, operation, where, settings) {
|
|
970
|
+
const delegate = this.delegate(model);
|
|
971
|
+
if (!delegate) {
|
|
972
|
+
logger.warn(`[GraphMiddleware] ${operation} for ${model}: no Prisma delegate on the base client; not tracked`);
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
975
|
+
try {
|
|
976
|
+
const rows = await delegate.findMany({
|
|
977
|
+
...where !== void 0 && { where },
|
|
978
|
+
...operation === "updateMany" && { select: { id: true } },
|
|
979
|
+
take: settings.maxRows + 1
|
|
980
|
+
});
|
|
981
|
+
if (rows.length > settings.maxRows) {
|
|
982
|
+
logger.warn(`[GraphMiddleware] ${operation} for ${model} matched more than ${settings.maxRows} rows; emitting events for the first ${settings.maxRows} only (run a graph backfill for mass rewrites)`);
|
|
983
|
+
return rows.slice(0, settings.maxRows);
|
|
984
|
+
}
|
|
985
|
+
return rows;
|
|
986
|
+
} catch (error) {
|
|
987
|
+
logger.warn(`[GraphMiddleware] ${operation} for ${model}: pre-write read failed; not tracked`, { error: error instanceof Error ? error.message : String(error) });
|
|
988
|
+
return null;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
/** Wrap an `updateMany` so each affected row emits `entity.updated`. */
|
|
992
|
+
async updateMany(model, args, query, settings) {
|
|
993
|
+
const where = isRecord(args) ? args["where"] : void 0;
|
|
994
|
+
const affected = await this.readAffected(model, "updateMany", where, settings);
|
|
995
|
+
const result = await query(args);
|
|
996
|
+
const ids = affected ? rowIds(affected) : [];
|
|
997
|
+
if (ids.length > 0 && !(isRecord(result) && result["count"] === 0)) deferGraphTask(() => this.emitUpdatedRows(model, ids, args, settings));
|
|
998
|
+
return result;
|
|
999
|
+
}
|
|
1000
|
+
/** Re-read the updated rows by id and emit `entity.updated` for each (throttled). */
|
|
1001
|
+
async emitUpdatedRows(model, ids, args, settings) {
|
|
1002
|
+
const delegate = this.delegate(model);
|
|
1003
|
+
if (!delegate) return;
|
|
1004
|
+
const data = isRecord(args) ? args["data"] : void 0;
|
|
1005
|
+
const rows = await delegate.findMany({
|
|
1006
|
+
where: { id: { in: ids } },
|
|
1007
|
+
take: ids.length
|
|
1008
|
+
});
|
|
1009
|
+
for (const raw of rows) {
|
|
1010
|
+
if (!isRecord(raw)) continue;
|
|
1011
|
+
const row = applyScalarUpdates(raw, data);
|
|
1012
|
+
const id = row["id"];
|
|
1013
|
+
if (typeof id !== "string") continue;
|
|
1014
|
+
const signature = changeSignature(model, row, settings.ignoreFields);
|
|
1015
|
+
if (this.throttle.shouldEmit(`${model}:${id}`, signature, settings.throttleMs, this.now())) this.emitRow("entity.updated", model, row, args);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/** Wrap a `deleteMany` so each removed row emits `entity.deleted`. */
|
|
1019
|
+
async deleteMany(model, args, query, settings) {
|
|
1020
|
+
const where = isRecord(args) ? args["where"] : void 0;
|
|
1021
|
+
const affected = await this.readAffected(model, "deleteMany", where, settings);
|
|
1022
|
+
const result = await query(args);
|
|
1023
|
+
if (!affected || isRecord(result) && result["count"] === 0) return result;
|
|
1024
|
+
for (const row of affected) {
|
|
1025
|
+
if (!isRecord(row) || typeof row["id"] !== "string") continue;
|
|
1026
|
+
this.throttle.forget(`${model}:${row["id"]}`);
|
|
1027
|
+
this.emitRow("entity.deleted", model, row, args);
|
|
1028
|
+
}
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
// src/graph/middleware/prisma-extension.ts
|
|
1034
|
+
/**
|
|
1035
|
+
* Prisma Middleware for Graph Event Emission
|
|
1036
|
+
*
|
|
1037
|
+
* Automatically emits events to the graph event queue when entities are
|
|
1038
|
+
* created, updated, or deleted in PostgreSQL.
|
|
1039
|
+
*
|
|
1040
|
+
* This is a product-agnostic Prisma extension that can be used by any Burdenoff product.
|
|
1041
|
+
*
|
|
1042
|
+
* @module prisma-graph-extension
|
|
1043
|
+
* @category Graph
|
|
1044
|
+
*/
|
|
1045
|
+
/**
|
|
1046
|
+
* Default configuration
|
|
1047
|
+
*/
|
|
1048
|
+
const defaultConfig = {
|
|
1049
|
+
enabled: true,
|
|
1050
|
+
monitoredOperations: [
|
|
1051
|
+
"create",
|
|
1052
|
+
"update",
|
|
1053
|
+
"delete",
|
|
1054
|
+
"deleteMany",
|
|
1055
|
+
"updateMany"
|
|
1056
|
+
]
|
|
1057
|
+
};
|
|
1058
|
+
/**
|
|
1059
|
+
* Extract entity information from Prisma result
|
|
1060
|
+
*/
|
|
1061
|
+
function extractEntityInfo(model, result) {
|
|
1062
|
+
if (!result || typeof result !== "object") return null;
|
|
1063
|
+
const record = result;
|
|
1064
|
+
const id = record["id"];
|
|
1065
|
+
if (!id) return null;
|
|
1066
|
+
return {
|
|
1067
|
+
id,
|
|
1068
|
+
type: model,
|
|
1069
|
+
data: record
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Extract organization and user context from Prisma arguments
|
|
1074
|
+
*/
|
|
1075
|
+
function extractContext(args) {
|
|
1076
|
+
if (!args || typeof args !== "object") return {};
|
|
1077
|
+
const data = args["data"] || args["where"];
|
|
1078
|
+
if (!data || typeof data !== "object") return {};
|
|
1079
|
+
return {
|
|
1080
|
+
organizationId: data["organizationId"],
|
|
1081
|
+
actorId: data["actorId"] || data["createdBy"] || data["updatedBy"] || data["userId"],
|
|
1082
|
+
workspaceId: data["workspaceId"] || data["workspaceID"]
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Whether the extension should emit events for this model at all
|
|
1087
|
+
*/
|
|
1088
|
+
function isMonitoredEntity(model, config) {
|
|
1089
|
+
if (!GraphRegistry.isEntityRegistered(model)) return false;
|
|
1090
|
+
return !config.entityTypes || config.entityTypes.length === 0 || config.entityTypes.includes(model);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Emit event for entity operation
|
|
1094
|
+
*/
|
|
1095
|
+
function emitEntityEvent(eventType, model, result, args, config) {
|
|
1096
|
+
const entityInfo = extractEntityInfo(model, result);
|
|
1097
|
+
if (!entityInfo) return;
|
|
1098
|
+
if (!isMonitoredEntity(model, config)) return;
|
|
1099
|
+
const context = extractContext(args);
|
|
1100
|
+
const minimalData = extractMinimalFields(model, entityInfo.data);
|
|
1101
|
+
const orgId = GraphRegistry.getOrganizationId(model, entityInfo.data) || context.organizationId || "unknown";
|
|
1102
|
+
const workspaceId = GraphRegistry.getWorkspaceId(model, entityInfo.data) || context.workspaceId;
|
|
1103
|
+
const actorId = context.actorId || "unknown";
|
|
1104
|
+
const rbacMetadata = GraphRegistry.resolveRbacMetadata(model, entityInfo.data);
|
|
1105
|
+
if (rbacMetadata) logger.debug(`[GraphMiddleware] Including RBAC metadata for ${model}`, {
|
|
1106
|
+
resourceTypeName: rbacMetadata.resourceTypeName,
|
|
1107
|
+
hasName: !!rbacMetadata.name
|
|
1108
|
+
});
|
|
1109
|
+
dispatchGraphEvent(config.eventEmitter, eventType, {
|
|
1110
|
+
id: entityInfo.id,
|
|
1111
|
+
type: entityInfo.type,
|
|
1112
|
+
data: minimalData
|
|
1113
|
+
}, {
|
|
1114
|
+
productName: config.productName,
|
|
1115
|
+
organizationId: orgId,
|
|
1116
|
+
actorId,
|
|
1117
|
+
workspaceId
|
|
1118
|
+
}, rbacMetadata);
|
|
1119
|
+
if (eventType === "entity.created" || eventType === "entity.updated") emitRelationshipEvents(model, entityInfo.data, orgId, config);
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Emit relationship events based on foreign key values
|
|
1123
|
+
* This automatically creates edges in the graph when entities with foreign keys are created/updated
|
|
1124
|
+
*/
|
|
1125
|
+
function emitRelationshipEvents(entityType, entityData, organizationId, config) {
|
|
1126
|
+
const relationships = GraphRegistry.getRelationshipsForEntity(entityType);
|
|
1127
|
+
if (relationships.length === 0) return;
|
|
1128
|
+
const fromId = entityData["id"];
|
|
1129
|
+
if (!fromId) return;
|
|
1130
|
+
for (const [relationshipKey, relationshipConfig] of relationships) {
|
|
1131
|
+
const foreignKeyValue = entityData[relationshipConfig.fromField];
|
|
1132
|
+
if (!foreignKeyValue) continue;
|
|
1133
|
+
let targetType = relationshipConfig.to;
|
|
1134
|
+
if (relationshipConfig.to === "*") {
|
|
1135
|
+
if (relationshipConfig.polymorphicTypeField) {
|
|
1136
|
+
targetType = entityData[relationshipConfig.polymorphicTypeField];
|
|
1137
|
+
if (!targetType) {
|
|
1138
|
+
logger.warn(`[GraphMiddleware] Polymorphic relationship ${relationshipKey} has no type field value`);
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
} else {
|
|
1142
|
+
logger.debug(`[GraphMiddleware] Skipping polymorphic relationship without type field: ${relationshipKey}`);
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
const metadata = relationshipConfig.extractMetadata ? relationshipConfig.extractMetadata(entityData) : { description: relationshipConfig.description };
|
|
1147
|
+
dispatchGraphEvent(config.eventEmitter, "relationship.created", {
|
|
1148
|
+
id: `${fromId}_${foreignKeyValue}`,
|
|
1149
|
+
type: relationshipConfig.label,
|
|
1150
|
+
data: {
|
|
1151
|
+
from: {
|
|
1152
|
+
id: fromId,
|
|
1153
|
+
type: entityType
|
|
1154
|
+
},
|
|
1155
|
+
to: {
|
|
1156
|
+
id: foreignKeyValue,
|
|
1157
|
+
type: targetType
|
|
1158
|
+
},
|
|
1159
|
+
relationType: relationshipConfig.label,
|
|
1160
|
+
metadata
|
|
1161
|
+
}
|
|
1162
|
+
}, {
|
|
1163
|
+
productName: config.productName,
|
|
1164
|
+
organizationId
|
|
1165
|
+
});
|
|
1166
|
+
logger.debug(`[GraphMiddleware] Emitted relationship.created: ${relationshipConfig.label} (${entityType}:${fromId} -> ${targetType}:${foreignKeyValue})`);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Add graph extension to Prisma client for automatic event emission
|
|
1171
|
+
*
|
|
1172
|
+
* This function uses Prisma Client Extensions (Prisma 6+) to intercept
|
|
1173
|
+
* database operations and emit events to the graph event queue.
|
|
1174
|
+
*
|
|
1175
|
+
* @param baseClient - Base Prisma client instance
|
|
1176
|
+
* @param config - Configuration for the middleware
|
|
1177
|
+
* @returns Extended Prisma client with graph event emission
|
|
1178
|
+
*
|
|
1179
|
+
* @example
|
|
1180
|
+
* ```typescript
|
|
1181
|
+
* import { PrismaClient } from '@prisma/client';
|
|
1182
|
+
* import { addGraphExtension } from '@burdenoff/be-sdk/graph';
|
|
1183
|
+
* import { eventQueue } from './event-queue';
|
|
1184
|
+
*
|
|
1185
|
+
* const baseClient = new PrismaClient();
|
|
1186
|
+
* const client = addGraphExtension(baseClient, {
|
|
1187
|
+
* enabled: true,
|
|
1188
|
+
* productName: 'workspaces',
|
|
1189
|
+
* eventEmitter: eventQueue,
|
|
1190
|
+
* entityTypes: ['Project', 'Group', 'Workspace'], // Optional: monitor specific types
|
|
1191
|
+
* });
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
function addGraphExtension(baseClient, config) {
|
|
1195
|
+
const fullConfig = {
|
|
1196
|
+
...defaultConfig,
|
|
1197
|
+
...config
|
|
1198
|
+
};
|
|
1199
|
+
if (!fullConfig.enabled) {
|
|
1200
|
+
logger.info("[GraphMiddleware] Extension disabled by configuration");
|
|
1201
|
+
return baseClient;
|
|
1202
|
+
}
|
|
1203
|
+
const prismaClient = baseClient;
|
|
1204
|
+
const bulkTracker = new BulkOperationTracker(baseClient, (eventType, model, row, args) => emitEntityEvent(eventType, model, row, args, fullConfig));
|
|
1205
|
+
return prismaClient.$extends({ query: { $allModels: {
|
|
1206
|
+
async create({ model, args, query }) {
|
|
1207
|
+
const result = await query(args);
|
|
1208
|
+
if (fullConfig.monitoredOperations?.includes("create")) emitEntityEvent("entity.created", model, result, args, fullConfig);
|
|
1209
|
+
return result;
|
|
1210
|
+
},
|
|
1211
|
+
async update({ model, args, query }) {
|
|
1212
|
+
const result = await query(args);
|
|
1213
|
+
if (fullConfig.monitoredOperations?.includes("update")) emitEntityEvent("entity.updated", model, result, args, fullConfig);
|
|
1214
|
+
return result;
|
|
1215
|
+
},
|
|
1216
|
+
async delete({ model, args, query }) {
|
|
1217
|
+
const result = await query(args);
|
|
1218
|
+
if (fullConfig.monitoredOperations?.includes("delete")) emitEntityEvent("entity.deleted", model, result, args, fullConfig);
|
|
1219
|
+
return result;
|
|
1220
|
+
},
|
|
1221
|
+
async updateMany({ model, args, query }) {
|
|
1222
|
+
if (!fullConfig.monitoredOperations?.includes("updateMany") || !isMonitoredEntity(model, fullConfig)) return query(args);
|
|
1223
|
+
const settings = resolveBulkOperations(model, fullConfig.bulkOperations);
|
|
1224
|
+
if (!settings) {
|
|
1225
|
+
logger.debug(`[GraphMiddleware] updateMany for ${model} (bulk operation not tracked individually)`);
|
|
1226
|
+
return query(args);
|
|
1227
|
+
}
|
|
1228
|
+
return bulkTracker.updateMany(model, args, query, settings);
|
|
1229
|
+
},
|
|
1230
|
+
async deleteMany({ model, args, query }) {
|
|
1231
|
+
if (!fullConfig.monitoredOperations?.includes("deleteMany") || !isMonitoredEntity(model, fullConfig)) return query(args);
|
|
1232
|
+
const settings = resolveBulkOperations(model, fullConfig.bulkOperations);
|
|
1233
|
+
if (!settings) {
|
|
1234
|
+
logger.debug(`[GraphMiddleware] deleteMany for ${model} (bulk operation not tracked individually)`);
|
|
1235
|
+
return query(args);
|
|
1236
|
+
}
|
|
1237
|
+
return bulkTracker.deleteMany(model, args, query, settings);
|
|
1238
|
+
}
|
|
1239
|
+
} } });
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
export { shouldSyncEntity as _, createConnectionPool as a, ensureServiceApplicationName as c, createEntityEvent as d, createRelationshipEvent as f, parseRelationship as g, getCollectionForEntity as h, configurePrismaLogging as i, installAcquireRetry as l, extractMinimalFields as m, withDeferredGraphEvents as n, createPrismaAdapter as o, extractEntityTitle as p, PrismaClientWrapper as r, createPrismaClient as s, addGraphExtension as t, isTransientAcquireError as u, shouldSyncRelationship as v, GraphRegistry as y };
|
|
1243
|
+
//# sourceMappingURL=middleware-CUxJVUpD.js.map
|