@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
package/dist/chunk-DJNHR37J.js
DELETED
|
@@ -1,1185 +0,0 @@
|
|
|
1
|
-
import { safeStringify } from './chunk-K56L7NUR.js';
|
|
2
|
-
import { logger } from './chunk-RU266375.js';
|
|
3
|
-
import { __name } from './chunk-XE4OXN2W.js';
|
|
4
|
-
import { PrismaPg } from '@prisma/adapter-pg';
|
|
5
|
-
import { Pool } from 'pg';
|
|
6
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
7
|
-
|
|
8
|
-
// src/graph/utils/registry.ts
|
|
9
|
-
var GraphRegistry = class {
|
|
10
|
-
static {
|
|
11
|
-
__name(this, "GraphRegistry");
|
|
12
|
-
}
|
|
13
|
-
static entityMappings = /* @__PURE__ */ new Map();
|
|
14
|
-
static relationshipMappings = /* @__PURE__ */ new Map();
|
|
15
|
-
static registeredModules = /* @__PURE__ */ new Set();
|
|
16
|
-
/**
|
|
17
|
-
* Resolve fields from entity configuration
|
|
18
|
-
*
|
|
19
|
-
* @param entityType - Name of the entity type
|
|
20
|
-
* @param config - Entity configuration
|
|
21
|
-
* @returns Resolved array of field names
|
|
22
|
-
*/
|
|
23
|
-
static resolveFields(entityType, config) {
|
|
24
|
-
if (Array.isArray(config.fields)) {
|
|
25
|
-
return config.fields;
|
|
26
|
-
}
|
|
27
|
-
logger.warn(`[GraphRegistry] No fields configuration for ${entityType}, using empty array`);
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Register a module's graph configuration
|
|
32
|
-
* @param config - Module graph configuration
|
|
33
|
-
*/
|
|
34
|
-
static registerModule(config) {
|
|
35
|
-
const { moduleName, entities, relationships } = config;
|
|
36
|
-
if (this.registeredModules.has(moduleName)) {
|
|
37
|
-
logger.warn(`[GraphRegistry] Module '${moduleName}' already registered, skipping`);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
logger.info(`[GraphRegistry] Registering module: ${moduleName}`);
|
|
41
|
-
let entityCount = 0;
|
|
42
|
-
for (const [entityType, entityConfig] of Object.entries(entities)) {
|
|
43
|
-
if (entityConfig.enabled !== false) {
|
|
44
|
-
const resolvedFields = this.resolveFields(entityType, entityConfig);
|
|
45
|
-
const resolvedConfig = {
|
|
46
|
-
...entityConfig,
|
|
47
|
-
fields: resolvedFields
|
|
48
|
-
};
|
|
49
|
-
this.entityMappings.set(entityType, resolvedConfig);
|
|
50
|
-
entityCount++;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
let relationshipCount = 0;
|
|
54
|
-
if (relationships) {
|
|
55
|
-
for (const [relationshipType, relationshipConfig] of Object.entries(relationships)) {
|
|
56
|
-
if (relationshipConfig.enabled !== false) {
|
|
57
|
-
this.relationshipMappings.set(relationshipType, relationshipConfig);
|
|
58
|
-
relationshipCount++;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
this.registeredModules.add(moduleName);
|
|
63
|
-
logger.info(`[GraphRegistry] \u2705 Registered ${moduleName}: ${entityCount} entities, ${relationshipCount} relationships`);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get entity configuration by entity type
|
|
67
|
-
* @param entityType - Entity type name (e.g., 'Calendar', 'Group')
|
|
68
|
-
* @returns Entity configuration or undefined (with resolved fields)
|
|
69
|
-
*/
|
|
70
|
-
static getEntityConfig(entityType) {
|
|
71
|
-
return this.entityMappings.get(entityType);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Get relationship configuration by relationship type
|
|
75
|
-
* @param relationshipType - Relationship type name (e.g., 'EventAttendee', 'GroupMembership')
|
|
76
|
-
* @returns Relationship configuration or undefined
|
|
77
|
-
*/
|
|
78
|
-
static getRelationshipConfig(relationshipType) {
|
|
79
|
-
return this.relationshipMappings.get(relationshipType);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Get all registered entity types
|
|
83
|
-
* @returns Array of entity type names
|
|
84
|
-
*/
|
|
85
|
-
static getAllEntityTypes() {
|
|
86
|
-
return Array.from(this.entityMappings.keys());
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get all registered relationship types
|
|
90
|
-
* @returns Array of relationship type names
|
|
91
|
-
*/
|
|
92
|
-
static getAllRelationshipTypes() {
|
|
93
|
-
return Array.from(this.relationshipMappings.keys());
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get all registered module names
|
|
97
|
-
* @returns Array of module names
|
|
98
|
-
*/
|
|
99
|
-
static getRegisteredModules() {
|
|
100
|
-
return Array.from(this.registeredModules);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Check if an entity type is registered
|
|
104
|
-
* @param entityType - Entity type to check
|
|
105
|
-
* @returns True if registered
|
|
106
|
-
*/
|
|
107
|
-
static isEntityRegistered(entityType) {
|
|
108
|
-
return this.entityMappings.has(entityType);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Check if a relationship type is registered
|
|
112
|
-
* @param relationshipType - Relationship type to check
|
|
113
|
-
* @returns True if registered
|
|
114
|
-
*/
|
|
115
|
-
static isRelationshipRegistered(relationshipType) {
|
|
116
|
-
return this.relationshipMappings.has(relationshipType);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Extract organization ID from entity data using configured mapping function
|
|
120
|
-
* @param entityType - Entity type name
|
|
121
|
-
* @param data - Entity data record
|
|
122
|
-
* @returns Organization ID or undefined
|
|
123
|
-
*/
|
|
124
|
-
static getOrganizationId(entityType, data) {
|
|
125
|
-
const config = this.entityMappings.get(entityType);
|
|
126
|
-
if (!config || !config.getOrgId) {
|
|
127
|
-
return void 0;
|
|
128
|
-
}
|
|
129
|
-
return config.getOrgId(data);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Extract workspace ID from entity data using configured mapping function
|
|
133
|
-
* @param entityType - Entity type name
|
|
134
|
-
* @param data - Entity data record
|
|
135
|
-
* @returns Workspace ID or undefined
|
|
136
|
-
*/
|
|
137
|
-
static getWorkspaceId(entityType, data) {
|
|
138
|
-
const config = this.entityMappings.get(entityType);
|
|
139
|
-
if (!config || !config.getWorkspaceId) {
|
|
140
|
-
return void 0;
|
|
141
|
-
}
|
|
142
|
-
return config.getWorkspaceId(data);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get RBAC configuration for an entity type
|
|
146
|
-
* Used by the Prisma graph extension to include RBAC metadata in entity events
|
|
147
|
-
* @param entityType - Entity type name (e.g., 'Conversation', 'Agent')
|
|
148
|
-
* @returns RBAC config or undefined if no RBAC is configured for this entity
|
|
149
|
-
*/
|
|
150
|
-
static getRbacConfig(entityType) {
|
|
151
|
-
const config = this.entityMappings.get(entityType);
|
|
152
|
-
return config?.rbac;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get the bulk-operation (`updateMany` / `deleteMany`) handling configured for an entity type
|
|
156
|
-
* @param entityType - Entity type name (e.g., 'Agent')
|
|
157
|
-
* @returns Bulk-operation config or undefined when the entity does not configure one
|
|
158
|
-
*/
|
|
159
|
-
static getBulkOperationsConfig(entityType) {
|
|
160
|
-
return this.entityMappings.get(entityType)?.bulkOperations;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Resolve RBAC event metadata from entity data
|
|
164
|
-
* Converts the registry's function-based RBAC config into the flat metadata
|
|
165
|
-
* structure expected by the RBAC consumer in the NATS event payload.
|
|
166
|
-
* @param entityType - Entity type name
|
|
167
|
-
* @param entityData - The entity data record
|
|
168
|
-
* @returns RBAC metadata for the event or undefined
|
|
169
|
-
*/
|
|
170
|
-
static resolveRbacMetadata(entityType, entityData) {
|
|
171
|
-
const rbacConfig = this.getRbacConfig(entityType);
|
|
172
|
-
if (!rbacConfig) {
|
|
173
|
-
return void 0;
|
|
174
|
-
}
|
|
175
|
-
const name = rbacConfig.extractName ? rbacConfig.extractName(entityData) : void 0;
|
|
176
|
-
const identifier = rbacConfig.extractIdentifier ? rbacConfig.extractIdentifier(entityData) : void 0;
|
|
177
|
-
const parentResourceIdentifier = rbacConfig.parentResourceField ? entityData[rbacConfig.parentResourceField] : void 0;
|
|
178
|
-
return {
|
|
179
|
-
resourceTypeName: rbacConfig.resourceTypeName,
|
|
180
|
-
...name && {
|
|
181
|
-
name
|
|
182
|
-
},
|
|
183
|
-
...identifier && {
|
|
184
|
-
identifier
|
|
185
|
-
},
|
|
186
|
-
...parentResourceIdentifier && {
|
|
187
|
-
parentResourceIdentifier
|
|
188
|
-
},
|
|
189
|
-
...rbacConfig.createResource !== void 0 && {
|
|
190
|
-
createResource: rbacConfig.createResource
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Get statistics about registered configurations
|
|
196
|
-
* @returns Statistics object
|
|
197
|
-
*/
|
|
198
|
-
static getStats() {
|
|
199
|
-
const collections = /* @__PURE__ */ new Set();
|
|
200
|
-
const edgeTypes = /* @__PURE__ */ new Set();
|
|
201
|
-
for (const config of this.entityMappings.values()) {
|
|
202
|
-
collections.add(config.collection || "product_entities");
|
|
203
|
-
}
|
|
204
|
-
for (const config of this.relationshipMappings.values()) {
|
|
205
|
-
if (config.label) {
|
|
206
|
-
edgeTypes.add(config.label);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
modules: this.registeredModules.size,
|
|
211
|
-
entities: this.entityMappings.size,
|
|
212
|
-
relationships: this.relationshipMappings.size,
|
|
213
|
-
collections,
|
|
214
|
-
edgeTypes
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Clear all registrations (for testing)
|
|
219
|
-
*/
|
|
220
|
-
static clear() {
|
|
221
|
-
this.entityMappings.clear();
|
|
222
|
-
this.relationshipMappings.clear();
|
|
223
|
-
this.registeredModules.clear();
|
|
224
|
-
logger.info("[GraphRegistry] Cleared all registrations");
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Get all relationships where the given entity type is the "from" side
|
|
228
|
-
* This is used for automatic relationship event emission when entities are created/updated
|
|
229
|
-
* @param entityType - Entity type name (e.g., 'UniversalTag')
|
|
230
|
-
* @returns Array of [relationshipKey, config] tuples
|
|
231
|
-
*/
|
|
232
|
-
static getRelationshipsForEntity(entityType) {
|
|
233
|
-
const result = [];
|
|
234
|
-
for (const [key, config] of this.relationshipMappings.entries()) {
|
|
235
|
-
if (config.from === entityType) {
|
|
236
|
-
result.push([
|
|
237
|
-
key,
|
|
238
|
-
config
|
|
239
|
-
]);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Print registry status to console
|
|
246
|
-
*/
|
|
247
|
-
static printStatus() {
|
|
248
|
-
const stats = this.getStats();
|
|
249
|
-
logger.info("");
|
|
250
|
-
logger.info("\u{1F4CA} Graph Registry Status");
|
|
251
|
-
logger.info("========================");
|
|
252
|
-
logger.info(`Registered Modules: ${stats.modules}`);
|
|
253
|
-
logger.info(`Total Entities: ${stats.entities}`);
|
|
254
|
-
logger.info(`Total Relationships: ${stats.relationships}`);
|
|
255
|
-
logger.info(`Vertex Collections: ${stats.collections.size}`);
|
|
256
|
-
logger.info(`Edge Types: ${stats.edgeTypes.size}`);
|
|
257
|
-
logger.info("");
|
|
258
|
-
logger.info("Registered Modules:", this.getRegisteredModules().join(", "));
|
|
259
|
-
logger.info("");
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
// src/graph/utils/helpers.ts
|
|
264
|
-
var uuidv4 = /* @__PURE__ */ __name(() => crypto.randomUUID(), "uuidv4");
|
|
265
|
-
function createEntityEvent(eventType, organizationId, entity, metadata, productSource) {
|
|
266
|
-
return {
|
|
267
|
-
eventId: `evt_${uuidv4()}`,
|
|
268
|
-
eventType,
|
|
269
|
-
organizationId,
|
|
270
|
-
productSource: productSource || process.env["PRODUCT_SOURCE"] || "default",
|
|
271
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
272
|
-
entity,
|
|
273
|
-
metadata: {
|
|
274
|
-
userId: metadata?.userId,
|
|
275
|
-
correlationId: metadata?.correlationId || `req_${uuidv4()}`
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
__name(createEntityEvent, "createEntityEvent");
|
|
280
|
-
function createRelationshipEvent(eventType, organizationId, relationship, metadata, productSource) {
|
|
281
|
-
return {
|
|
282
|
-
eventId: `evt_${uuidv4()}`,
|
|
283
|
-
eventType,
|
|
284
|
-
organizationId,
|
|
285
|
-
productSource: productSource || process.env["PRODUCT_SOURCE"] || "default",
|
|
286
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
287
|
-
entity: {
|
|
288
|
-
id: `${relationship.from.id}_${relationship.to.id}`,
|
|
289
|
-
type: relationship.type,
|
|
290
|
-
data: {}
|
|
291
|
-
},
|
|
292
|
-
relationship,
|
|
293
|
-
metadata: {
|
|
294
|
-
userId: metadata?.userId,
|
|
295
|
-
correlationId: metadata?.correlationId || `req_${uuidv4()}`
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
__name(createRelationshipEvent, "createRelationshipEvent");
|
|
300
|
-
function extractMinimalFields(modelName, entity) {
|
|
301
|
-
const config = GraphRegistry.getEntityConfig(modelName);
|
|
302
|
-
if (!config) {
|
|
303
|
-
logger.warn(`[GraphHelpers] No graph config found for entity type: ${modelName}, using fallback`);
|
|
304
|
-
const minimal2 = {};
|
|
305
|
-
if (entity["id"]) minimal2["id"] = entity["id"];
|
|
306
|
-
if (entity["workspaceID"]) minimal2["workspaceID"] = entity["workspaceID"];
|
|
307
|
-
if (entity["workspaceId"]) minimal2["workspaceId"] = entity["workspaceId"];
|
|
308
|
-
return minimal2;
|
|
309
|
-
}
|
|
310
|
-
const minimal = {};
|
|
311
|
-
for (const field of config.fields) {
|
|
312
|
-
if (entity[field] !== void 0) {
|
|
313
|
-
minimal[field] = entity[field];
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return minimal;
|
|
317
|
-
}
|
|
318
|
-
__name(extractMinimalFields, "extractMinimalFields");
|
|
319
|
-
function parseRelationship(modelName, relationship) {
|
|
320
|
-
const config = GraphRegistry.getRelationshipConfig(modelName);
|
|
321
|
-
if (!config) {
|
|
322
|
-
logger.warn(`[GraphHelpers] No graph config found for relationship type: ${modelName}, using fallback`);
|
|
323
|
-
return {
|
|
324
|
-
from: {
|
|
325
|
-
id: "unknown",
|
|
326
|
-
type: "Unknown"
|
|
327
|
-
},
|
|
328
|
-
to: {
|
|
329
|
-
id: "unknown",
|
|
330
|
-
type: "Unknown"
|
|
331
|
-
},
|
|
332
|
-
relationshipType: "relates_to",
|
|
333
|
-
metadata: {}
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
return {
|
|
337
|
-
from: {
|
|
338
|
-
id: String(relationship[config.fromField] || "unknown"),
|
|
339
|
-
type: config.from
|
|
340
|
-
},
|
|
341
|
-
to: {
|
|
342
|
-
id: String(relationship[config.to] || "unknown"),
|
|
343
|
-
type: config.to
|
|
344
|
-
},
|
|
345
|
-
relationshipType: config.label || "relates_to",
|
|
346
|
-
metadata: config.extractMetadata?.(relationship) ?? {}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
__name(parseRelationship, "parseRelationship");
|
|
350
|
-
function getCollectionForEntity(entityType) {
|
|
351
|
-
const config = GraphRegistry.getEntityConfig(entityType);
|
|
352
|
-
if (!config) {
|
|
353
|
-
return "entity";
|
|
354
|
-
}
|
|
355
|
-
return config.collection || "entity";
|
|
356
|
-
}
|
|
357
|
-
__name(getCollectionForEntity, "getCollectionForEntity");
|
|
358
|
-
function extractEntityTitle(entityType, entity) {
|
|
359
|
-
const config = GraphRegistry.getEntityConfig(entityType);
|
|
360
|
-
if (config?.extractTitle) {
|
|
361
|
-
return config.extractTitle(entity);
|
|
362
|
-
}
|
|
363
|
-
return String(entity["name"] || entity["title"] || entity["email"] || entity["id"] || "Untitled");
|
|
364
|
-
}
|
|
365
|
-
__name(extractEntityTitle, "extractEntityTitle");
|
|
366
|
-
function shouldSyncEntity(entityType) {
|
|
367
|
-
const config = GraphRegistry.getEntityConfig(entityType);
|
|
368
|
-
if (!config) {
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
return config.enabled !== false;
|
|
372
|
-
}
|
|
373
|
-
__name(shouldSyncEntity, "shouldSyncEntity");
|
|
374
|
-
function shouldSyncRelationship(relationshipType) {
|
|
375
|
-
const config = GraphRegistry.getRelationshipConfig(relationshipType);
|
|
376
|
-
if (!config) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
return config.enabled !== false;
|
|
380
|
-
}
|
|
381
|
-
__name(shouldSyncRelationship, "shouldSyncRelationship");
|
|
382
|
-
function createConnectionPool(config) {
|
|
383
|
-
const idleTimeoutMillis = config.idleTimeoutMillis ?? 3e4;
|
|
384
|
-
const poolConfig = {
|
|
385
|
-
connectionString: config.databaseUrl,
|
|
386
|
-
max: config.maxConnections ?? 20,
|
|
387
|
-
idleTimeoutMillis,
|
|
388
|
-
connectionTimeoutMillis: config.connectionTimeoutMillis ?? 1e4,
|
|
389
|
-
// Keep pooled TCP sockets alive so Azure's load balancer / Postgres does not
|
|
390
|
-
// silently drop an idle connection out from under the pool. Without this the
|
|
391
|
-
// first query after a quiet window re-establishes a socket — the slow cold
|
|
392
|
-
// TLS handshake that intermittently exceeds connectionTimeoutMillis and 500s
|
|
393
|
-
// the request (context-switcher bootstrap after ~30s idle). Pure transport
|
|
394
|
-
// hygiene; no effect on query behavior.
|
|
395
|
-
keepAlive: true,
|
|
396
|
-
keepAliveInitialDelayMillis: 1e4
|
|
397
|
-
};
|
|
398
|
-
if (config.applicationName) {
|
|
399
|
-
poolConfig.application_name = config.applicationName;
|
|
400
|
-
}
|
|
401
|
-
if (config.queryTimeoutMillis != null && config.queryTimeoutMillis > 0) {
|
|
402
|
-
poolConfig.query_timeout = config.queryTimeoutMillis;
|
|
403
|
-
}
|
|
404
|
-
if (config.statementTimeoutMillis != null && config.statementTimeoutMillis > 0) {
|
|
405
|
-
poolConfig.statement_timeout = config.statementTimeoutMillis;
|
|
406
|
-
}
|
|
407
|
-
if (config.idleInTransactionTimeoutMillis != null && config.idleInTransactionTimeoutMillis > 0) {
|
|
408
|
-
poolConfig.idle_in_transaction_session_timeout = config.idleInTransactionTimeoutMillis;
|
|
409
|
-
}
|
|
410
|
-
if (config.lockTimeoutMillis != null && config.lockTimeoutMillis > 0) {
|
|
411
|
-
poolConfig.lock_timeout = config.lockTimeoutMillis;
|
|
412
|
-
}
|
|
413
|
-
const pool = new Pool(poolConfig);
|
|
414
|
-
pool.on("error", (error) => {
|
|
415
|
-
logger.warn("[pg-pool] Idle pooled connection errored (dropped by server/network); it will be replaced on next acquire", {
|
|
416
|
-
error: error.message
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
installAcquireRetry(pool, config.acquireRetries ?? 2, config.acquireRetryDelayMillis ?? 250);
|
|
420
|
-
startPoolWarmer(pool, config, idleTimeoutMillis);
|
|
421
|
-
return pool;
|
|
422
|
-
}
|
|
423
|
-
__name(createConnectionPool, "createConnectionPool");
|
|
424
|
-
function isTransientAcquireError(error) {
|
|
425
|
-
if (!(error instanceof Error)) return false;
|
|
426
|
-
const message = error.message.toLowerCase();
|
|
427
|
-
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");
|
|
428
|
-
}
|
|
429
|
-
__name(isTransientAcquireError, "isTransientAcquireError");
|
|
430
|
-
function installAcquireRetry(pool, retries, baseDelayMillis) {
|
|
431
|
-
if (retries <= 0) return;
|
|
432
|
-
const originalConnect = pool.connect.bind(pool);
|
|
433
|
-
const acquireWithRetry = /* @__PURE__ */ __name(async () => {
|
|
434
|
-
let attempt = 0;
|
|
435
|
-
for (; ; ) {
|
|
436
|
-
try {
|
|
437
|
-
return await originalConnect();
|
|
438
|
-
} catch (error) {
|
|
439
|
-
if (attempt >= retries || !isTransientAcquireError(error)) {
|
|
440
|
-
throw error;
|
|
441
|
-
}
|
|
442
|
-
attempt += 1;
|
|
443
|
-
const delayMillis = baseDelayMillis * 2 ** (attempt - 1);
|
|
444
|
-
logger.warn(`[pg-pool] Transient connection-acquire failure (attempt ${String(attempt)}/${String(retries)}); retrying in ${String(delayMillis)}ms`, {
|
|
445
|
-
error: error instanceof Error ? error.message : String(error)
|
|
446
|
-
});
|
|
447
|
-
await new Promise((resolve) => setTimeout(resolve, delayMillis));
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}, "acquireWithRetry");
|
|
451
|
-
const patchedConnect = /* @__PURE__ */ __name((callback) => {
|
|
452
|
-
if (typeof callback === "function") {
|
|
453
|
-
acquireWithRetry().then((client) => {
|
|
454
|
-
callback(void 0, client, client.release.bind(client));
|
|
455
|
-
}, (error) => {
|
|
456
|
-
callback(error instanceof Error ? error : new Error(String(error)), void 0, () => void 0);
|
|
457
|
-
});
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
return acquireWithRetry();
|
|
461
|
-
}, "patchedConnect");
|
|
462
|
-
pool.connect = patchedConnect;
|
|
463
|
-
}
|
|
464
|
-
__name(installAcquireRetry, "installAcquireRetry");
|
|
465
|
-
function startPoolWarmer(pool, config, idleTimeoutMillis) {
|
|
466
|
-
if (config.keepWarm === false) return;
|
|
467
|
-
const intervalMs = config.warmupIntervalMillis ?? 2e4;
|
|
468
|
-
if (intervalMs <= 0 || idleTimeoutMillis > 0 && intervalMs >= idleTimeoutMillis) return;
|
|
469
|
-
const WARM_FAILURE_LOG_INTERVAL_MS = 6e4;
|
|
470
|
-
let consecutiveWarmFailures = 0;
|
|
471
|
-
let lastWarmFailureLogAt = 0;
|
|
472
|
-
const timer = setInterval(() => {
|
|
473
|
-
pool.query("SELECT 1").then(() => {
|
|
474
|
-
if (consecutiveWarmFailures > 0) {
|
|
475
|
-
logger.info("[pg-pool] Warm-up query recovered", {
|
|
476
|
-
failedAttempts: consecutiveWarmFailures
|
|
477
|
-
});
|
|
478
|
-
consecutiveWarmFailures = 0;
|
|
479
|
-
}
|
|
480
|
-
}, (error) => {
|
|
481
|
-
consecutiveWarmFailures += 1;
|
|
482
|
-
const now = Date.now();
|
|
483
|
-
if (now - lastWarmFailureLogAt >= WARM_FAILURE_LOG_INTERVAL_MS) {
|
|
484
|
-
lastWarmFailureLogAt = now;
|
|
485
|
-
logger.warn("[pg-pool] Warm-up query failing \u2014 the pool cannot establish connections to Postgres right now", {
|
|
486
|
-
consecutiveWarmFailures,
|
|
487
|
-
error: error instanceof Error ? error.message : String(error)
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}, intervalMs);
|
|
492
|
-
if (typeof timer.unref === "function") timer.unref();
|
|
493
|
-
const originalEnd = pool.end.bind(pool);
|
|
494
|
-
pool.end = (...args) => {
|
|
495
|
-
clearInterval(timer);
|
|
496
|
-
return originalEnd(...args);
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
__name(startPoolWarmer, "startPoolWarmer");
|
|
500
|
-
function ensureServiceApplicationName(productName) {
|
|
501
|
-
if (productName && !process.env["PGAPPNAME"]) {
|
|
502
|
-
process.env["PGAPPNAME"] = `svc=${productName}`;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
__name(ensureServiceApplicationName, "ensureServiceApplicationName");
|
|
506
|
-
function createPrismaAdapter(pool) {
|
|
507
|
-
return new PrismaPg(pool);
|
|
508
|
-
}
|
|
509
|
-
__name(createPrismaAdapter, "createPrismaAdapter");
|
|
510
|
-
function configurePrismaLogging(client, config) {
|
|
511
|
-
const isDevelopment = process.env["NODE_ENV"] === "development";
|
|
512
|
-
const slowQueryThreshold = config.slowQueryThreshold ?? (isDevelopment ? 100 : 500);
|
|
513
|
-
if (config.enableQueryLogging ?? isDevelopment) {
|
|
514
|
-
client.$on("query", (e) => {
|
|
515
|
-
if ("query" in e && "duration" in e) {
|
|
516
|
-
if (e.duration > slowQueryThreshold) {
|
|
517
|
-
logger.warn("[Prisma] Slow query detected", {
|
|
518
|
-
query: e.query.substring(0, 200) + (e.query.length > 200 ? "..." : ""),
|
|
519
|
-
params: e.params,
|
|
520
|
-
duration: `${e.duration}ms`
|
|
521
|
-
});
|
|
522
|
-
} else {
|
|
523
|
-
logger.debug("[Prisma] Query", {
|
|
524
|
-
query: e.query.substring(0, 100) + (e.query.length > 100 ? "..." : ""),
|
|
525
|
-
duration: `${e.duration}ms`
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
client.$on("error", (e) => {
|
|
532
|
-
if ("message" in e) {
|
|
533
|
-
logger.error("[Prisma] Database error", {
|
|
534
|
-
message: e.message,
|
|
535
|
-
target: e.target
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
client.$on("warn", (e) => {
|
|
540
|
-
if ("message" in e) {
|
|
541
|
-
logger.warn("[Prisma] Database warning", {
|
|
542
|
-
message: e.message,
|
|
543
|
-
target: e.target
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
return client;
|
|
548
|
-
}
|
|
549
|
-
__name(configurePrismaLogging, "configurePrismaLogging");
|
|
550
|
-
var PrismaClientWrapper = class {
|
|
551
|
-
static {
|
|
552
|
-
__name(this, "PrismaClientWrapper");
|
|
553
|
-
}
|
|
554
|
-
client;
|
|
555
|
-
pool;
|
|
556
|
-
connectionState = {
|
|
557
|
-
isConnected: false,
|
|
558
|
-
attempts: 0
|
|
559
|
-
};
|
|
560
|
-
isDisconnecting = false;
|
|
561
|
-
constructor(client, pool, config) {
|
|
562
|
-
this.client = client;
|
|
563
|
-
this.pool = pool;
|
|
564
|
-
configurePrismaLogging(this.client, config);
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Get the Prisma client instance
|
|
568
|
-
*/
|
|
569
|
-
getClient() {
|
|
570
|
-
return this.client;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Get the connection pool
|
|
574
|
-
*/
|
|
575
|
-
getPool() {
|
|
576
|
-
return this.pool;
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Get connection state
|
|
580
|
-
*/
|
|
581
|
-
getConnectionState() {
|
|
582
|
-
return {
|
|
583
|
-
...this.connectionState
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Connect to database with retry logic
|
|
588
|
-
*/
|
|
589
|
-
async connect(retries = 5, delay = 1e3) {
|
|
590
|
-
if (this.connectionState.isConnected) {
|
|
591
|
-
logger.info("[Prisma] Already connected to database");
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
595
|
-
this.connectionState.attempts = attempt;
|
|
596
|
-
try {
|
|
597
|
-
await this.client.$connect();
|
|
598
|
-
this.connectionState.isConnected = true;
|
|
599
|
-
this.connectionState.lastConnectedAt = /* @__PURE__ */ new Date();
|
|
600
|
-
this.connectionState.lastError = void 0;
|
|
601
|
-
logger.info("[Prisma] Successfully connected to database");
|
|
602
|
-
return;
|
|
603
|
-
} catch (error) {
|
|
604
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
605
|
-
this.connectionState.lastError = errorMessage;
|
|
606
|
-
logger.error(`[Prisma] Connection attempt ${attempt}/${retries} failed`, {
|
|
607
|
-
error: errorMessage
|
|
608
|
-
});
|
|
609
|
-
if (attempt === retries) {
|
|
610
|
-
logger.error("[Prisma] Max connection retries reached");
|
|
611
|
-
throw error;
|
|
612
|
-
}
|
|
613
|
-
const waitTime = delay * Math.pow(2, attempt - 1);
|
|
614
|
-
logger.info(`[Prisma] Retrying in ${waitTime}ms...`);
|
|
615
|
-
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Gracefully disconnect from database
|
|
621
|
-
*/
|
|
622
|
-
async disconnect() {
|
|
623
|
-
if (this.isDisconnecting) {
|
|
624
|
-
logger.debug("[Prisma] Disconnect already in progress, skipping");
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
if (!this.connectionState.isConnected) {
|
|
628
|
-
logger.info("[Prisma] Database already disconnected");
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
this.isDisconnecting = true;
|
|
632
|
-
try {
|
|
633
|
-
await this.client.$disconnect();
|
|
634
|
-
await this.pool.end();
|
|
635
|
-
this.connectionState.isConnected = false;
|
|
636
|
-
logger.info("[Prisma] Successfully disconnected from database");
|
|
637
|
-
} catch (error) {
|
|
638
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
639
|
-
if (errorMessage.includes("Called end on pool more than once")) {
|
|
640
|
-
logger.debug("[Prisma] Pool already ended, ignoring duplicate end call");
|
|
641
|
-
this.connectionState.isConnected = false;
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
logger.error("[Prisma] Error disconnecting from database", {
|
|
645
|
-
error: errorMessage
|
|
646
|
-
});
|
|
647
|
-
throw error;
|
|
648
|
-
} finally {
|
|
649
|
-
this.isDisconnecting = false;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Register graceful shutdown handlers
|
|
654
|
-
*/
|
|
655
|
-
registerShutdownHandlers() {
|
|
656
|
-
const shutdownHandler = /* @__PURE__ */ __name(async (signal) => {
|
|
657
|
-
logger.info(`[Prisma] Received ${signal}, starting graceful shutdown...`);
|
|
658
|
-
try {
|
|
659
|
-
await this.disconnect();
|
|
660
|
-
process.exit(0);
|
|
661
|
-
} catch (error) {
|
|
662
|
-
logger.error("[Prisma] Error during graceful shutdown", {
|
|
663
|
-
error: error instanceof Error ? error.message : String(error)
|
|
664
|
-
});
|
|
665
|
-
process.exit(1);
|
|
666
|
-
}
|
|
667
|
-
}, "shutdownHandler");
|
|
668
|
-
process.on("SIGINT", () => void shutdownHandler("SIGINT"));
|
|
669
|
-
process.on("SIGTERM", () => void shutdownHandler("SIGTERM"));
|
|
670
|
-
process.on("beforeExit", () => void this.disconnect());
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
function createPrismaClient(PrismaClientConstructor, config) {
|
|
674
|
-
const isDevelopment = process.env["NODE_ENV"] === "development";
|
|
675
|
-
const pool = createConnectionPool(config);
|
|
676
|
-
const adapter = createPrismaAdapter(pool);
|
|
677
|
-
const logLevels = config.logLevels ?? (isDevelopment ? [
|
|
678
|
-
{
|
|
679
|
-
emit: "event",
|
|
680
|
-
level: "query"
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
emit: "event",
|
|
684
|
-
level: "info"
|
|
685
|
-
},
|
|
686
|
-
{
|
|
687
|
-
emit: "event",
|
|
688
|
-
level: "warn"
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
emit: "event",
|
|
692
|
-
level: "error"
|
|
693
|
-
}
|
|
694
|
-
] : [
|
|
695
|
-
{
|
|
696
|
-
emit: "event",
|
|
697
|
-
level: "warn"
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
emit: "event",
|
|
701
|
-
level: "error"
|
|
702
|
-
}
|
|
703
|
-
]);
|
|
704
|
-
const client = new PrismaClientConstructor({
|
|
705
|
-
adapter,
|
|
706
|
-
log: logLevels
|
|
707
|
-
});
|
|
708
|
-
return new PrismaClientWrapper(client, pool, config);
|
|
709
|
-
}
|
|
710
|
-
__name(createPrismaClient, "createPrismaClient");
|
|
711
|
-
var scopes = new AsyncLocalStorage();
|
|
712
|
-
async function withDeferredGraphEvents(transaction) {
|
|
713
|
-
if (scopes.getStore()) throw new Error("Nested deferred graph scope is not supported");
|
|
714
|
-
const scope = {
|
|
715
|
-
active: true,
|
|
716
|
-
deliveries: []
|
|
717
|
-
};
|
|
718
|
-
let result;
|
|
719
|
-
try {
|
|
720
|
-
result = await scopes.run(scope, transaction);
|
|
721
|
-
} catch (error) {
|
|
722
|
-
scope.active = false;
|
|
723
|
-
scope.deliveries.length = 0;
|
|
724
|
-
throw error;
|
|
725
|
-
}
|
|
726
|
-
scope.active = false;
|
|
727
|
-
const deliveries = scope.deliveries.splice(0);
|
|
728
|
-
let failed = 0;
|
|
729
|
-
for (const deliver of deliveries) {
|
|
730
|
-
try {
|
|
731
|
-
await deliver();
|
|
732
|
-
} catch {
|
|
733
|
-
failed += 1;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
return {
|
|
737
|
-
result,
|
|
738
|
-
eventDelivery: {
|
|
739
|
-
attempted: deliveries.length,
|
|
740
|
-
failed
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
__name(withDeferredGraphEvents, "withDeferredGraphEvents");
|
|
745
|
-
function dispatchGraphEvent(emitter, ...event) {
|
|
746
|
-
const scope = scopes.getStore();
|
|
747
|
-
if (scope) {
|
|
748
|
-
if (!scope.active) throw new Error("Deferred graph scope is already closed");
|
|
749
|
-
try {
|
|
750
|
-
const snapshot = JSON.parse(safeStringify(event));
|
|
751
|
-
if (event[3] === void 0) snapshot[3] = void 0;
|
|
752
|
-
scope.deliveries.push(() => emitter.publishEntityEvent(...snapshot));
|
|
753
|
-
} catch {
|
|
754
|
-
scope.deliveries.push(async () => {
|
|
755
|
-
throw new Error("Graph event snapshot serialization failed");
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
emitter.publishEntityEvent(...event).catch((error) => {
|
|
761
|
-
logger.error("[GraphMiddleware] Failed to emit event:", error);
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
__name(dispatchGraphEvent, "dispatchGraphEvent");
|
|
765
|
-
function deferGraphTask(task) {
|
|
766
|
-
const scope = scopes.getStore();
|
|
767
|
-
if (scope) {
|
|
768
|
-
if (!scope.active) throw new Error("Deferred graph scope is already closed");
|
|
769
|
-
scope.deliveries.push(task);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
task().catch((error) => {
|
|
773
|
-
logger.error("[GraphMiddleware] Deferred graph task failed:", error);
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
__name(deferGraphTask, "deferGraphTask");
|
|
777
|
-
|
|
778
|
-
// src/graph/middleware/bulk-operations.ts
|
|
779
|
-
var DEFAULT_BULK_MAX_ROWS = 500;
|
|
780
|
-
var THROTTLE_CACHE_LIMIT = 1e4;
|
|
781
|
-
var UPDATE_OPERATORS = /* @__PURE__ */ new Set([
|
|
782
|
-
"set",
|
|
783
|
-
"increment",
|
|
784
|
-
"decrement",
|
|
785
|
-
"multiply",
|
|
786
|
-
"divide",
|
|
787
|
-
"push",
|
|
788
|
-
"unset"
|
|
789
|
-
]);
|
|
790
|
-
function isRecord(value) {
|
|
791
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
792
|
-
}
|
|
793
|
-
__name(isRecord, "isRecord");
|
|
794
|
-
function isFindManyDelegate(value) {
|
|
795
|
-
return isRecord(value) && typeof value["findMany"] === "function";
|
|
796
|
-
}
|
|
797
|
-
__name(isFindManyDelegate, "isFindManyDelegate");
|
|
798
|
-
function resolveBulkOperations(model, defaults) {
|
|
799
|
-
const config = GraphRegistry.getBulkOperationsConfig(model) ?? defaults;
|
|
800
|
-
if (!config || config.mode !== "per-row") return null;
|
|
801
|
-
const maxRows = config.maxRows !== void 0 && Number.isInteger(config.maxRows) && config.maxRows > 0 ? config.maxRows : DEFAULT_BULK_MAX_ROWS;
|
|
802
|
-
const throttleMs = config.throttleMs !== void 0 && config.throttleMs > 0 ? config.throttleMs : 0;
|
|
803
|
-
return {
|
|
804
|
-
maxRows,
|
|
805
|
-
throttleMs,
|
|
806
|
-
ignoreFields: new Set(config.ignoreFields ?? [])
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
__name(resolveBulkOperations, "resolveBulkOperations");
|
|
810
|
-
function delegateNameForModel(model) {
|
|
811
|
-
return model.charAt(0).toLowerCase() + model.slice(1);
|
|
812
|
-
}
|
|
813
|
-
__name(delegateNameForModel, "delegateNameForModel");
|
|
814
|
-
function applyScalarUpdates(row, data) {
|
|
815
|
-
if (!isRecord(data)) return row;
|
|
816
|
-
const next = {
|
|
817
|
-
...row
|
|
818
|
-
};
|
|
819
|
-
for (const [field, value] of Object.entries(data)) {
|
|
820
|
-
if (value === void 0) continue;
|
|
821
|
-
if (isRecord(value) && !(value instanceof Date)) {
|
|
822
|
-
const keys = Object.keys(value);
|
|
823
|
-
const [onlyKey] = keys;
|
|
824
|
-
if (keys.length === 1 && onlyKey !== void 0 && UPDATE_OPERATORS.has(onlyKey)) {
|
|
825
|
-
if (onlyKey === "set") next[field] = value["set"];
|
|
826
|
-
continue;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
next[field] = value;
|
|
830
|
-
}
|
|
831
|
-
return next;
|
|
832
|
-
}
|
|
833
|
-
__name(applyScalarUpdates, "applyScalarUpdates");
|
|
834
|
-
var BulkEmissionThrottle = class {
|
|
835
|
-
static {
|
|
836
|
-
__name(this, "BulkEmissionThrottle");
|
|
837
|
-
}
|
|
838
|
-
limit;
|
|
839
|
-
last = /* @__PURE__ */ new Map();
|
|
840
|
-
constructor(limit = THROTTLE_CACHE_LIMIT) {
|
|
841
|
-
this.limit = limit;
|
|
842
|
-
}
|
|
843
|
-
shouldEmit(key, signature, throttleMs, now) {
|
|
844
|
-
if (throttleMs <= 0) return true;
|
|
845
|
-
const previous = this.last.get(key);
|
|
846
|
-
if (previous && previous.signature === signature && now - previous.at < throttleMs) {
|
|
847
|
-
return false;
|
|
848
|
-
}
|
|
849
|
-
this.last.delete(key);
|
|
850
|
-
this.last.set(key, {
|
|
851
|
-
signature,
|
|
852
|
-
at: now
|
|
853
|
-
});
|
|
854
|
-
while (this.last.size > this.limit) {
|
|
855
|
-
const oldest = this.last.keys().next();
|
|
856
|
-
if (oldest.done) break;
|
|
857
|
-
this.last.delete(oldest.value);
|
|
858
|
-
}
|
|
859
|
-
return true;
|
|
860
|
-
}
|
|
861
|
-
/** Forget a row (after it was deleted). */
|
|
862
|
-
forget(key) {
|
|
863
|
-
this.last.delete(key);
|
|
864
|
-
}
|
|
865
|
-
get size() {
|
|
866
|
-
return this.last.size;
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
function changeSignature(model, row, ignoreFields) {
|
|
870
|
-
const minimal = extractMinimalFields(model, row);
|
|
871
|
-
const material = {};
|
|
872
|
-
for (const [field, value] of Object.entries(minimal)) {
|
|
873
|
-
if (!ignoreFields.has(field)) material[field] = value;
|
|
874
|
-
}
|
|
875
|
-
return safeStringify(material);
|
|
876
|
-
}
|
|
877
|
-
__name(changeSignature, "changeSignature");
|
|
878
|
-
function rowIds(rows) {
|
|
879
|
-
const ids = [];
|
|
880
|
-
for (const row of rows) {
|
|
881
|
-
if (isRecord(row) && typeof row["id"] === "string" && row["id"]) ids.push(row["id"]);
|
|
882
|
-
}
|
|
883
|
-
return ids;
|
|
884
|
-
}
|
|
885
|
-
__name(rowIds, "rowIds");
|
|
886
|
-
var BulkOperationTracker = class {
|
|
887
|
-
static {
|
|
888
|
-
__name(this, "BulkOperationTracker");
|
|
889
|
-
}
|
|
890
|
-
baseClient;
|
|
891
|
-
emitRow;
|
|
892
|
-
now;
|
|
893
|
-
throttle = new BulkEmissionThrottle();
|
|
894
|
-
constructor(baseClient, emitRow, now = Date.now) {
|
|
895
|
-
this.baseClient = baseClient;
|
|
896
|
-
this.emitRow = emitRow;
|
|
897
|
-
this.now = now;
|
|
898
|
-
}
|
|
899
|
-
delegate(model) {
|
|
900
|
-
if (!isRecord(this.baseClient)) return null;
|
|
901
|
-
const candidate = this.baseClient[delegateNameForModel(model)];
|
|
902
|
-
return isFindManyDelegate(candidate) ? candidate : null;
|
|
903
|
-
}
|
|
904
|
-
/** Read the rows a bulk write will touch; null when they cannot be read (the write still proceeds). */
|
|
905
|
-
async readAffected(model, operation, where, settings) {
|
|
906
|
-
const delegate = this.delegate(model);
|
|
907
|
-
if (!delegate) {
|
|
908
|
-
logger.warn(`[GraphMiddleware] ${operation} for ${model}: no Prisma delegate on the base client; not tracked`);
|
|
909
|
-
return null;
|
|
910
|
-
}
|
|
911
|
-
try {
|
|
912
|
-
const rows = await delegate.findMany({
|
|
913
|
-
...where !== void 0 && {
|
|
914
|
-
where
|
|
915
|
-
},
|
|
916
|
-
...operation === "updateMany" && {
|
|
917
|
-
select: {
|
|
918
|
-
id: true
|
|
919
|
-
}
|
|
920
|
-
},
|
|
921
|
-
take: settings.maxRows + 1
|
|
922
|
-
});
|
|
923
|
-
if (rows.length > settings.maxRows) {
|
|
924
|
-
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)`);
|
|
925
|
-
return rows.slice(0, settings.maxRows);
|
|
926
|
-
}
|
|
927
|
-
return rows;
|
|
928
|
-
} catch (error) {
|
|
929
|
-
logger.warn(`[GraphMiddleware] ${operation} for ${model}: pre-write read failed; not tracked`, {
|
|
930
|
-
error: error instanceof Error ? error.message : String(error)
|
|
931
|
-
});
|
|
932
|
-
return null;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
/** Wrap an `updateMany` so each affected row emits `entity.updated`. */
|
|
936
|
-
async updateMany(model, args, query, settings) {
|
|
937
|
-
const where = isRecord(args) ? args["where"] : void 0;
|
|
938
|
-
const affected = await this.readAffected(model, "updateMany", where, settings);
|
|
939
|
-
const result = await query(args);
|
|
940
|
-
const ids = affected ? rowIds(affected) : [];
|
|
941
|
-
if (ids.length > 0 && !(isRecord(result) && result["count"] === 0)) {
|
|
942
|
-
deferGraphTask(() => this.emitUpdatedRows(model, ids, args, settings));
|
|
943
|
-
}
|
|
944
|
-
return result;
|
|
945
|
-
}
|
|
946
|
-
/** Re-read the updated rows by id and emit `entity.updated` for each (throttled). */
|
|
947
|
-
async emitUpdatedRows(model, ids, args, settings) {
|
|
948
|
-
const delegate = this.delegate(model);
|
|
949
|
-
if (!delegate) return;
|
|
950
|
-
const data = isRecord(args) ? args["data"] : void 0;
|
|
951
|
-
const rows = await delegate.findMany({
|
|
952
|
-
where: {
|
|
953
|
-
id: {
|
|
954
|
-
in: ids
|
|
955
|
-
}
|
|
956
|
-
},
|
|
957
|
-
take: ids.length
|
|
958
|
-
});
|
|
959
|
-
for (const raw of rows) {
|
|
960
|
-
if (!isRecord(raw)) continue;
|
|
961
|
-
const row = applyScalarUpdates(raw, data);
|
|
962
|
-
const id = row["id"];
|
|
963
|
-
if (typeof id !== "string") continue;
|
|
964
|
-
const signature = changeSignature(model, row, settings.ignoreFields);
|
|
965
|
-
if (this.throttle.shouldEmit(`${model}:${id}`, signature, settings.throttleMs, this.now())) {
|
|
966
|
-
this.emitRow("entity.updated", model, row, args);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
/** Wrap a `deleteMany` so each removed row emits `entity.deleted`. */
|
|
971
|
-
async deleteMany(model, args, query, settings) {
|
|
972
|
-
const where = isRecord(args) ? args["where"] : void 0;
|
|
973
|
-
const affected = await this.readAffected(model, "deleteMany", where, settings);
|
|
974
|
-
const result = await query(args);
|
|
975
|
-
if (!affected || isRecord(result) && result["count"] === 0) return result;
|
|
976
|
-
for (const row of affected) {
|
|
977
|
-
if (!isRecord(row) || typeof row["id"] !== "string") continue;
|
|
978
|
-
this.throttle.forget(`${model}:${row["id"]}`);
|
|
979
|
-
this.emitRow("entity.deleted", model, row, args);
|
|
980
|
-
}
|
|
981
|
-
return result;
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
|
|
985
|
-
// src/graph/middleware/prisma-extension.ts
|
|
986
|
-
var defaultConfig = {
|
|
987
|
-
enabled: true,
|
|
988
|
-
monitoredOperations: [
|
|
989
|
-
"create",
|
|
990
|
-
"update",
|
|
991
|
-
"delete",
|
|
992
|
-
"deleteMany",
|
|
993
|
-
"updateMany"
|
|
994
|
-
]
|
|
995
|
-
};
|
|
996
|
-
function extractEntityInfo(model, result) {
|
|
997
|
-
if (!result || typeof result !== "object") {
|
|
998
|
-
return null;
|
|
999
|
-
}
|
|
1000
|
-
const record = result;
|
|
1001
|
-
const id = record["id"];
|
|
1002
|
-
if (!id) {
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
return {
|
|
1006
|
-
id,
|
|
1007
|
-
type: model,
|
|
1008
|
-
data: record
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
__name(extractEntityInfo, "extractEntityInfo");
|
|
1012
|
-
function extractContext(args) {
|
|
1013
|
-
if (!args || typeof args !== "object") {
|
|
1014
|
-
return {};
|
|
1015
|
-
}
|
|
1016
|
-
const data = args["data"] || args["where"];
|
|
1017
|
-
if (!data || typeof data !== "object") {
|
|
1018
|
-
return {};
|
|
1019
|
-
}
|
|
1020
|
-
return {
|
|
1021
|
-
organizationId: data["organizationId"],
|
|
1022
|
-
actorId: data["actorId"] || data["createdBy"] || data["updatedBy"] || data["userId"],
|
|
1023
|
-
workspaceId: data["workspaceId"] || data["workspaceID"]
|
|
1024
|
-
};
|
|
1025
|
-
}
|
|
1026
|
-
__name(extractContext, "extractContext");
|
|
1027
|
-
function isMonitoredEntity(model, config) {
|
|
1028
|
-
if (!GraphRegistry.isEntityRegistered(model)) return false;
|
|
1029
|
-
return !config.entityTypes || config.entityTypes.length === 0 || config.entityTypes.includes(model);
|
|
1030
|
-
}
|
|
1031
|
-
__name(isMonitoredEntity, "isMonitoredEntity");
|
|
1032
|
-
function emitEntityEvent(eventType, model, result, args, config) {
|
|
1033
|
-
const entityInfo = extractEntityInfo(model, result);
|
|
1034
|
-
if (!entityInfo) {
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
if (!isMonitoredEntity(model, config)) {
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
const context = extractContext(args);
|
|
1041
|
-
const minimalData = extractMinimalFields(model, entityInfo.data);
|
|
1042
|
-
const orgId = GraphRegistry.getOrganizationId(model, entityInfo.data) || context.organizationId || "unknown";
|
|
1043
|
-
const workspaceId = GraphRegistry.getWorkspaceId(model, entityInfo.data) || context.workspaceId;
|
|
1044
|
-
const actorId = context.actorId || "unknown";
|
|
1045
|
-
const rbacMetadata = GraphRegistry.resolveRbacMetadata(model, entityInfo.data);
|
|
1046
|
-
if (rbacMetadata) {
|
|
1047
|
-
logger.debug(`[GraphMiddleware] Including RBAC metadata for ${model}`, {
|
|
1048
|
-
resourceTypeName: rbacMetadata.resourceTypeName,
|
|
1049
|
-
hasName: !!rbacMetadata.name
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
dispatchGraphEvent(config.eventEmitter, eventType, {
|
|
1053
|
-
id: entityInfo.id,
|
|
1054
|
-
type: entityInfo.type,
|
|
1055
|
-
data: minimalData
|
|
1056
|
-
}, {
|
|
1057
|
-
productName: config.productName,
|
|
1058
|
-
organizationId: orgId,
|
|
1059
|
-
actorId,
|
|
1060
|
-
workspaceId
|
|
1061
|
-
}, rbacMetadata);
|
|
1062
|
-
if (eventType === "entity.created" || eventType === "entity.updated") {
|
|
1063
|
-
emitRelationshipEvents(model, entityInfo.data, orgId, config);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
__name(emitEntityEvent, "emitEntityEvent");
|
|
1067
|
-
function emitRelationshipEvents(entityType, entityData, organizationId, config) {
|
|
1068
|
-
const relationships = GraphRegistry.getRelationshipsForEntity(entityType);
|
|
1069
|
-
if (relationships.length === 0) {
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
const fromId = entityData["id"];
|
|
1073
|
-
if (!fromId) {
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
for (const [relationshipKey, relationshipConfig] of relationships) {
|
|
1077
|
-
const foreignKeyValue = entityData[relationshipConfig.fromField];
|
|
1078
|
-
if (!foreignKeyValue) {
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
let targetType = relationshipConfig.to;
|
|
1082
|
-
if (relationshipConfig.to === "*") {
|
|
1083
|
-
if (relationshipConfig.polymorphicTypeField) {
|
|
1084
|
-
targetType = entityData[relationshipConfig.polymorphicTypeField];
|
|
1085
|
-
if (!targetType) {
|
|
1086
|
-
logger.warn(`[GraphMiddleware] Polymorphic relationship ${relationshipKey} has no type field value`);
|
|
1087
|
-
continue;
|
|
1088
|
-
}
|
|
1089
|
-
} else {
|
|
1090
|
-
logger.debug(`[GraphMiddleware] Skipping polymorphic relationship without type field: ${relationshipKey}`);
|
|
1091
|
-
continue;
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
const metadata = relationshipConfig.extractMetadata ? relationshipConfig.extractMetadata(entityData) : {
|
|
1095
|
-
description: relationshipConfig.description
|
|
1096
|
-
};
|
|
1097
|
-
dispatchGraphEvent(config.eventEmitter, "relationship.created", {
|
|
1098
|
-
id: `${fromId}_${foreignKeyValue}`,
|
|
1099
|
-
type: relationshipConfig.label,
|
|
1100
|
-
data: {
|
|
1101
|
-
from: {
|
|
1102
|
-
id: fromId,
|
|
1103
|
-
type: entityType
|
|
1104
|
-
},
|
|
1105
|
-
to: {
|
|
1106
|
-
id: foreignKeyValue,
|
|
1107
|
-
type: targetType
|
|
1108
|
-
},
|
|
1109
|
-
relationType: relationshipConfig.label,
|
|
1110
|
-
metadata
|
|
1111
|
-
}
|
|
1112
|
-
}, {
|
|
1113
|
-
productName: config.productName,
|
|
1114
|
-
organizationId
|
|
1115
|
-
});
|
|
1116
|
-
logger.debug(`[GraphMiddleware] Emitted relationship.created: ${relationshipConfig.label} (${entityType}:${fromId} -> ${targetType}:${foreignKeyValue})`);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
__name(emitRelationshipEvents, "emitRelationshipEvents");
|
|
1120
|
-
function addGraphExtension(baseClient, config) {
|
|
1121
|
-
const fullConfig = {
|
|
1122
|
-
...defaultConfig,
|
|
1123
|
-
...config
|
|
1124
|
-
};
|
|
1125
|
-
if (!fullConfig.enabled) {
|
|
1126
|
-
logger.info("[GraphMiddleware] Extension disabled by configuration");
|
|
1127
|
-
return baseClient;
|
|
1128
|
-
}
|
|
1129
|
-
const prismaClient = baseClient;
|
|
1130
|
-
const bulkTracker = new BulkOperationTracker(baseClient, (eventType, model, row, args) => emitEntityEvent(eventType, model, row, args, fullConfig));
|
|
1131
|
-
return prismaClient.$extends({
|
|
1132
|
-
query: {
|
|
1133
|
-
$allModels: {
|
|
1134
|
-
async create({ model, args, query }) {
|
|
1135
|
-
const result = await query(args);
|
|
1136
|
-
if (fullConfig.monitoredOperations?.includes("create")) {
|
|
1137
|
-
emitEntityEvent("entity.created", model, result, args, fullConfig);
|
|
1138
|
-
}
|
|
1139
|
-
return result;
|
|
1140
|
-
},
|
|
1141
|
-
async update({ model, args, query }) {
|
|
1142
|
-
const result = await query(args);
|
|
1143
|
-
if (fullConfig.monitoredOperations?.includes("update")) {
|
|
1144
|
-
emitEntityEvent("entity.updated", model, result, args, fullConfig);
|
|
1145
|
-
}
|
|
1146
|
-
return result;
|
|
1147
|
-
},
|
|
1148
|
-
async delete({ model, args, query }) {
|
|
1149
|
-
const result = await query(args);
|
|
1150
|
-
if (fullConfig.monitoredOperations?.includes("delete")) {
|
|
1151
|
-
emitEntityEvent("entity.deleted", model, result, args, fullConfig);
|
|
1152
|
-
}
|
|
1153
|
-
return result;
|
|
1154
|
-
},
|
|
1155
|
-
async updateMany({ model, args, query }) {
|
|
1156
|
-
if (!fullConfig.monitoredOperations?.includes("updateMany") || !isMonitoredEntity(model, fullConfig)) {
|
|
1157
|
-
return query(args);
|
|
1158
|
-
}
|
|
1159
|
-
const settings = resolveBulkOperations(model, fullConfig.bulkOperations);
|
|
1160
|
-
if (!settings) {
|
|
1161
|
-
logger.debug(`[GraphMiddleware] updateMany for ${model} (bulk operation not tracked individually)`);
|
|
1162
|
-
return query(args);
|
|
1163
|
-
}
|
|
1164
|
-
return bulkTracker.updateMany(model, args, query, settings);
|
|
1165
|
-
},
|
|
1166
|
-
async deleteMany({ model, args, query }) {
|
|
1167
|
-
if (!fullConfig.monitoredOperations?.includes("deleteMany") || !isMonitoredEntity(model, fullConfig)) {
|
|
1168
|
-
return query(args);
|
|
1169
|
-
}
|
|
1170
|
-
const settings = resolveBulkOperations(model, fullConfig.bulkOperations);
|
|
1171
|
-
if (!settings) {
|
|
1172
|
-
logger.debug(`[GraphMiddleware] deleteMany for ${model} (bulk operation not tracked individually)`);
|
|
1173
|
-
return query(args);
|
|
1174
|
-
}
|
|
1175
|
-
return bulkTracker.deleteMany(model, args, query, settings);
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
__name(addGraphExtension, "addGraphExtension");
|
|
1182
|
-
|
|
1183
|
-
export { GraphRegistry, PrismaClientWrapper, addGraphExtension, configurePrismaLogging, createConnectionPool, createEntityEvent, createPrismaAdapter, createPrismaClient, createRelationshipEvent, ensureServiceApplicationName, extractEntityTitle, extractMinimalFields, getCollectionForEntity, installAcquireRetry, isTransientAcquireError, parseRelationship, shouldSyncEntity, shouldSyncRelationship, withDeferredGraphEvents };
|
|
1184
|
-
//# sourceMappingURL=chunk-DJNHR37J.js.map
|
|
1185
|
-
//# sourceMappingURL=chunk-DJNHR37J.js.map
|