@burdenoff/be-sdk 2026.1110.2 → 2026.1110.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/activity/index.d.ts +165 -0
- package/dist/activity/index.js +389 -0
- package/dist/activity/index.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-xxfwGpHS.js +546 -0
- package/dist/ai-credits-xxfwGpHS.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-C5ctwSLp.js +228 -0
- package/dist/auth-C5ctwSLp.js.map +1 -0
- package/dist/bootstrap/index.d.ts +74 -0
- package/dist/bootstrap/index.js +282 -0
- package/dist/bootstrap/index.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-sAJTrb4i.js +565 -0
- package/dist/client-sAJTrb4i.js.map +1 -0
- package/dist/collector-endpoint-iyQYeI50.js +50 -0
- package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
- package/dist/context/index.d.ts +35 -0
- package/dist/context/index.js +283 -0
- package/dist/context/index.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/explicit-activity-scope-DikJ7NAE.js +57 -0
- package/dist/explicit-activity-scope-DikJ7NAE.js.map +1 -0
- 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-DJXE3Osa.js +642 -0
- package/dist/export-DJXE3Osa.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-CP1KRgwD.js +422 -0
- package/dist/feature-flags-CP1KRgwD.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-h5U-D2AF.js +830 -0
- package/dist/files-h5U-D2AF.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-ByVo-n37.js +50 -0
- package/dist/gateway-ByVo-n37.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-CR7u4lpl.js +2152 -0
- package/dist/graph-CR7u4lpl.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-CUDyhibV.d.ts +21 -0
- package/dist/graphql-DHAHHcww.js +161 -0
- package/dist/graphql-DHAHHcww.js.map +1 -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-ADmsX0BI.d.ts +646 -0
- package/dist/index-B2LCaK0R.d.ts +500 -0
- package/dist/index-BBqooJ52.d.ts +45 -0
- package/dist/index-BGzMYJsm.d.ts +209 -0
- package/dist/index-BMIMnp6T.d.ts +8 -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-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-CHwMhK6v.d.ts +63 -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-CTTwo9av.d.ts +102 -0
- package/dist/index-CVCyKzhB.d.ts +207 -0
- package/dist/index-C_GXXF32.d.ts +704 -0
- package/dist/index-CaM9JUcc.d.ts +144 -0
- package/dist/index-CliOgq6L.d.ts +203 -0
- package/dist/index-Cot73bdh.d.ts +63 -0
- package/dist/index-DGgh9DWn.d.ts +59 -0
- package/dist/index-DY3dNhMN.d.ts +420 -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-FRRaa6h2.d.ts +999 -0
- package/dist/index-FbXPfen7.d.ts +132 -0
- package/dist/index-MArCb8Aq.d.ts +306 -0
- package/dist/index-U_tu3zUl.d.ts +303 -0
- package/dist/index-YOShAwkq.d.ts +45 -0
- package/dist/index-cmR9k9ga.d.ts +26 -0
- package/dist/index-yBSjMY32.d.ts +24 -0
- package/dist/index-zd_NPGJo.d.ts +206 -0
- package/dist/index.d.ts +106 -609
- package/dist/index.js +769 -2590
- 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-CQPFmOOe.js +325 -0
- package/dist/init-CQPFmOOe.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-DY_i37WN.js +869 -0
- package/dist/notifications-DY_i37WN.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/payments/index.d.ts +144 -0
- package/dist/payments/index.js +404 -0
- package/dist/payments/index.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/rate-limit-CBrK_U5H.js +142 -0
- package/dist/rate-limit-CBrK_U5H.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-Dvz0YzEt.js +1486 -0
- package/dist/rbac-Dvz0YzEt.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/search/index.d.ts +112 -0
- package/dist/search/index.js +266 -0
- package/dist/search/index.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.js +4 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/rate-limit/index.d.ts +2 -0
- package/dist/security/rate-limit/index.js +4 -0
- package/dist/security/rate-limit/index.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 +2001 -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-BUnfMiAS.js +577 -0
- package/dist/stub-BUnfMiAS.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-CbijgoqR.js +868 -0
- package/dist/{chunk-PBZFAAOM.js.map → tags-CbijgoqR.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 +7 -20
- package/dist/tracker/index.js.map +1 -1
- package/dist/tracker-PQztSlhJ.js +458 -0
- package/dist/tracker-PQztSlhJ.js.map +1 -0
- package/dist/translation/index.d.ts +120 -0
- package/dist/translation/index.js +573 -0
- package/dist/translation/index.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +90 -0
- package/dist/types/index.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-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-BRqVP3CJ.js +682 -0
- package/dist/usage-BRqVP3CJ.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
package/dist/chunk-KH4TRQCO.js
DELETED
|
@@ -1,1063 +0,0 @@
|
|
|
1
|
-
import { APIError, ValidationError } from './chunk-I3KOWRT3.js';
|
|
2
|
-
import { logger } from './chunk-RU266375.js';
|
|
3
|
-
import { __export, __name } from './chunk-XE4OXN2W.js';
|
|
4
|
-
|
|
5
|
-
// src/notifications/tenant-notifications.ts
|
|
6
|
-
var tenant_notifications_exports = {};
|
|
7
|
-
__export(tenant_notifications_exports, {
|
|
8
|
-
NotificationChannel: () => NotificationChannel,
|
|
9
|
-
NotificationPriority: () => NotificationPriority,
|
|
10
|
-
NotificationType: () => NotificationType,
|
|
11
|
-
TenantNotificationsModule: () => TenantNotificationsModule
|
|
12
|
-
});
|
|
13
|
-
var NotificationChannel = /* @__PURE__ */ (function(NotificationChannel3) {
|
|
14
|
-
NotificationChannel3["EMAIL"] = "EMAIL";
|
|
15
|
-
NotificationChannel3["SMS"] = "SMS";
|
|
16
|
-
NotificationChannel3["PUSH"] = "PUSH";
|
|
17
|
-
NotificationChannel3["IN_APP"] = "IN_APP";
|
|
18
|
-
NotificationChannel3["WEBHOOK"] = "WEBHOOK";
|
|
19
|
-
NotificationChannel3["WHATSAPP"] = "WHATSAPP";
|
|
20
|
-
NotificationChannel3["TEAMS"] = "TEAMS";
|
|
21
|
-
NotificationChannel3["SLACK"] = "SLACK";
|
|
22
|
-
NotificationChannel3["TELEGRAM"] = "TELEGRAM";
|
|
23
|
-
NotificationChannel3["DISCORD"] = "DISCORD";
|
|
24
|
-
return NotificationChannel3;
|
|
25
|
-
})({});
|
|
26
|
-
var NotificationPriority = /* @__PURE__ */ (function(NotificationPriority2) {
|
|
27
|
-
NotificationPriority2["LOW"] = "LOW";
|
|
28
|
-
NotificationPriority2["MEDIUM"] = "MEDIUM";
|
|
29
|
-
NotificationPriority2["HIGH"] = "HIGH";
|
|
30
|
-
NotificationPriority2["URGENT"] = "URGENT";
|
|
31
|
-
return NotificationPriority2;
|
|
32
|
-
})({});
|
|
33
|
-
var NotificationType = /* @__PURE__ */ (function(NotificationType3) {
|
|
34
|
-
NotificationType3["TRANSACTIONAL"] = "TRANSACTIONAL";
|
|
35
|
-
NotificationType3["MARKETING"] = "MARKETING";
|
|
36
|
-
NotificationType3["SYSTEM"] = "SYSTEM";
|
|
37
|
-
NotificationType3["ALERT"] = "ALERT";
|
|
38
|
-
return NotificationType3;
|
|
39
|
-
})({});
|
|
40
|
-
var TenantNotificationsModule = class {
|
|
41
|
-
static {
|
|
42
|
-
__name(this, "TenantNotificationsModule");
|
|
43
|
-
}
|
|
44
|
-
client;
|
|
45
|
-
context;
|
|
46
|
-
constructor(client, context) {
|
|
47
|
-
this.client = client;
|
|
48
|
-
this.context = context;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Send a single notification
|
|
52
|
-
*/
|
|
53
|
-
async send(input, context) {
|
|
54
|
-
this.validateSendInput(input);
|
|
55
|
-
const notification = this.createNotificationInput(input);
|
|
56
|
-
const callContext = {
|
|
57
|
-
...this.context,
|
|
58
|
-
...context
|
|
59
|
-
};
|
|
60
|
-
if (input.scheduledFor) {
|
|
61
|
-
const response2 = await this.client.tenantQuery(`mutation ScheduleTenantNotification($input: ScheduleNotificationInput!) {
|
|
62
|
-
scheduleNotification(input: $input) { notificationId status }
|
|
63
|
-
}`, {
|
|
64
|
-
input: {
|
|
65
|
-
notification,
|
|
66
|
-
scheduledFor: input.scheduledFor.toISOString(),
|
|
67
|
-
timezone: input.recipient.timezone
|
|
68
|
-
}
|
|
69
|
-
}, callContext);
|
|
70
|
-
const result2 = response2.scheduleNotification;
|
|
71
|
-
if (!result2?.notificationId || result2.status !== "PENDING") {
|
|
72
|
-
throw new APIError("Notification scheduling was not acknowledged", {
|
|
73
|
-
operation: "scheduleNotification"
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return result2.notificationId;
|
|
77
|
-
}
|
|
78
|
-
const response = await this.client.tenantQuery(`mutation TriggerTenantNotification($input: TriggerNotificationInput!) {
|
|
79
|
-
triggerNotification(input: $input) { id status channel }
|
|
80
|
-
}`, {
|
|
81
|
-
input: {
|
|
82
|
-
notification,
|
|
83
|
-
platform: input.channel,
|
|
84
|
-
includeInApp: false
|
|
85
|
-
}
|
|
86
|
-
}, callContext);
|
|
87
|
-
const result = response.triggerNotification;
|
|
88
|
-
if (!result?.id || result.channel !== input.channel || ![
|
|
89
|
-
"TRIGGERED",
|
|
90
|
-
"SENT",
|
|
91
|
-
"DELIVERED"
|
|
92
|
-
].includes(result.status)) {
|
|
93
|
-
throw new APIError("Notification trigger was not acknowledged", {
|
|
94
|
-
operation: "triggerNotification",
|
|
95
|
-
notificationId: result?.id
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
logger.info("[TenantNotifications] Notification accepted", {
|
|
99
|
-
notificationId: result.id,
|
|
100
|
-
channel: result.channel,
|
|
101
|
-
status: result.status
|
|
102
|
-
});
|
|
103
|
-
return result.id;
|
|
104
|
-
}
|
|
105
|
-
/** Owner input deliberately excludes scheduling, which has a separate API. */
|
|
106
|
-
createNotificationInput(input, priority) {
|
|
107
|
-
return {
|
|
108
|
-
recipient: input.recipient,
|
|
109
|
-
channel: input.channel,
|
|
110
|
-
type: input.type ?? "TRANSACTIONAL",
|
|
111
|
-
priority: input.priority ?? priority ?? "MEDIUM",
|
|
112
|
-
subject: input.subject,
|
|
113
|
-
body: input.body,
|
|
114
|
-
htmlBody: input.htmlBody,
|
|
115
|
-
data: input.data,
|
|
116
|
-
metadata: input.metadata,
|
|
117
|
-
expiresAt: input.expiresAt?.toISOString(),
|
|
118
|
-
trackOpens: input.trackOpens,
|
|
119
|
-
trackClicks: input.trackClicks
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Send notification using a template
|
|
124
|
-
*/
|
|
125
|
-
async sendWithTemplate(input, context) {
|
|
126
|
-
if (!input.templateSlug || input.templateSlug.trim().length === 0) {
|
|
127
|
-
throw new ValidationError("Template slug is required");
|
|
128
|
-
}
|
|
129
|
-
if (!input.variables || typeof input.variables !== "object" || Array.isArray(input.variables)) {
|
|
130
|
-
throw new ValidationError("Template variables must be an object");
|
|
131
|
-
}
|
|
132
|
-
if (!input.recipient || !input.recipient.email && !input.recipient.userId) {
|
|
133
|
-
throw new ValidationError("Recipient email or userId is required");
|
|
134
|
-
}
|
|
135
|
-
this.validateDates(input);
|
|
136
|
-
logger.info("[TenantNotifications] Sending notification with template", {
|
|
137
|
-
templateSlug: input.templateSlug,
|
|
138
|
-
priority: input.priority || "MEDIUM"
|
|
139
|
-
});
|
|
140
|
-
const mutation = `
|
|
141
|
-
mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {
|
|
142
|
-
triggerNotificationWithTemplate(input: $input) {
|
|
143
|
-
totalRequested
|
|
144
|
-
totalTriggered
|
|
145
|
-
totalFailed
|
|
146
|
-
notifications {
|
|
147
|
-
id
|
|
148
|
-
status
|
|
149
|
-
deliveryStatus
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
`;
|
|
154
|
-
const variables = {
|
|
155
|
-
input: {
|
|
156
|
-
templateSlug: input.templateSlug,
|
|
157
|
-
variables: input.variables,
|
|
158
|
-
recipient: input.recipient,
|
|
159
|
-
priority: input.priority || "MEDIUM",
|
|
160
|
-
scheduledFor: input.scheduledFor?.toISOString(),
|
|
161
|
-
expiresAt: input.expiresAt?.toISOString(),
|
|
162
|
-
trackOpens: input.trackOpens,
|
|
163
|
-
trackClicks: input.trackClicks,
|
|
164
|
-
// Platform is required for notification delivery routing
|
|
165
|
-
// If channelId is specified, it takes precedence; otherwise platform determines delivery
|
|
166
|
-
channelId: input.channelId,
|
|
167
|
-
platform: input.platform || "EMAIL",
|
|
168
|
-
timezone: input.timezone
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
const response = await this.client.tenantQuery(mutation, variables, {
|
|
172
|
-
...this.context,
|
|
173
|
-
...context
|
|
174
|
-
});
|
|
175
|
-
const result = response.triggerNotificationWithTemplate;
|
|
176
|
-
const firstNotification = result.notifications[0];
|
|
177
|
-
if (result.totalTriggered === 0 || !firstNotification) {
|
|
178
|
-
throw new ValidationError(`Notification trigger failed: requested=${result.totalRequested}, triggered=${result.totalTriggered}, failed=${result.totalFailed}`);
|
|
179
|
-
}
|
|
180
|
-
logger.info("[TenantNotifications] Notification sent with template", {
|
|
181
|
-
notificationId: firstNotification.id,
|
|
182
|
-
status: firstNotification.status,
|
|
183
|
-
totalTriggered: result.totalTriggered,
|
|
184
|
-
totalFailed: result.totalFailed
|
|
185
|
-
});
|
|
186
|
-
return firstNotification.id;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Send batch notifications
|
|
190
|
-
*/
|
|
191
|
-
async sendBatch(input, context) {
|
|
192
|
-
if (!input.notifications?.length) throw new ValidationError("At least one notification is required");
|
|
193
|
-
for (const notification of input.notifications) this.validateSendInput(notification);
|
|
194
|
-
const schedules = new Set(input.notifications.map((notification) => notification.scheduledFor?.toISOString() ?? ""));
|
|
195
|
-
if (schedules.size > 1) {
|
|
196
|
-
throw new ValidationError("Batch notifications must share a schedule; use send() for distinct schedules");
|
|
197
|
-
}
|
|
198
|
-
if (input.batchSize !== void 0 && (!Number.isInteger(input.batchSize) || input.batchSize <= 0)) {
|
|
199
|
-
throw new ValidationError("Batch size must be a positive integer");
|
|
200
|
-
}
|
|
201
|
-
if (input.delayBetweenBatches !== void 0 && (!Number.isInteger(input.delayBetweenBatches) || input.delayBetweenBatches < 0)) {
|
|
202
|
-
throw new ValidationError("Batch delay must be a nonnegative integer");
|
|
203
|
-
}
|
|
204
|
-
const response = await this.client.tenantQuery(`mutation TriggerTenantBatchNotifications($input: TriggerBatchNotificationsInput!) {
|
|
205
|
-
triggerBatchNotifications(input: $input) { totalRequested totalQueued: totalTriggered totalFailed batchId }
|
|
206
|
-
}`, {
|
|
207
|
-
input: {
|
|
208
|
-
notifications: input.notifications.map((notification) => this.createNotificationInput(notification, input.priority)),
|
|
209
|
-
priority: input.priority,
|
|
210
|
-
scheduledFor: input.notifications[0]?.scheduledFor?.toISOString(),
|
|
211
|
-
batchSize: input.batchSize,
|
|
212
|
-
delayBetweenBatches: input.delayBetweenBatches
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
...this.context,
|
|
216
|
-
...context
|
|
217
|
-
});
|
|
218
|
-
const result = response.triggerBatchNotifications;
|
|
219
|
-
if (!result?.batchId) throw new APIError("Notification batch was not acknowledged", {
|
|
220
|
-
operation: "triggerBatchNotifications"
|
|
221
|
-
});
|
|
222
|
-
return result;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Get a notification by ID
|
|
226
|
-
*/
|
|
227
|
-
async getNotification(id) {
|
|
228
|
-
const query = `
|
|
229
|
-
query GetNotification($id: ID!) {
|
|
230
|
-
notification(id: $id) {
|
|
231
|
-
id
|
|
232
|
-
userId
|
|
233
|
-
channel
|
|
234
|
-
type
|
|
235
|
-
priority
|
|
236
|
-
status
|
|
237
|
-
deliveryStatus
|
|
238
|
-
title
|
|
239
|
-
message
|
|
240
|
-
htmlMessage
|
|
241
|
-
subject
|
|
242
|
-
recipientEmail
|
|
243
|
-
recipientPhone
|
|
244
|
-
trackOpens
|
|
245
|
-
trackClicks
|
|
246
|
-
openedAt
|
|
247
|
-
clickedAt
|
|
248
|
-
sentAt
|
|
249
|
-
deliveredAt
|
|
250
|
-
createdAt
|
|
251
|
-
updatedAt
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
`;
|
|
255
|
-
const response = await this.client.tenantQuery(query, {
|
|
256
|
-
id
|
|
257
|
-
}, this.context);
|
|
258
|
-
return response.notification;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Get notifications with filters
|
|
262
|
-
*/
|
|
263
|
-
async getNotifications(filter) {
|
|
264
|
-
const query = `
|
|
265
|
-
query GetNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
|
|
266
|
-
notifications(filter: $filter, limit: $limit, offset: $offset) {
|
|
267
|
-
items {
|
|
268
|
-
id
|
|
269
|
-
userId
|
|
270
|
-
channel
|
|
271
|
-
type
|
|
272
|
-
priority
|
|
273
|
-
status
|
|
274
|
-
deliveryStatus
|
|
275
|
-
title
|
|
276
|
-
message
|
|
277
|
-
subject
|
|
278
|
-
recipientEmail
|
|
279
|
-
trackOpens
|
|
280
|
-
trackClicks
|
|
281
|
-
openedAt
|
|
282
|
-
clickedAt
|
|
283
|
-
sentAt
|
|
284
|
-
deliveredAt
|
|
285
|
-
createdAt
|
|
286
|
-
updatedAt
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
`;
|
|
291
|
-
const variables = {
|
|
292
|
-
filter: filter ? {
|
|
293
|
-
userId: filter.userId,
|
|
294
|
-
channel: filter.channel,
|
|
295
|
-
type: filter.type,
|
|
296
|
-
status: filter.status,
|
|
297
|
-
priority: filter.priority,
|
|
298
|
-
startDate: filter.startDate?.toISOString(),
|
|
299
|
-
endDate: filter.endDate?.toISOString()
|
|
300
|
-
} : void 0,
|
|
301
|
-
limit: filter?.limit ?? 50,
|
|
302
|
-
offset: filter?.offset ?? 0
|
|
303
|
-
};
|
|
304
|
-
const response = await this.client.tenantQuery(query, variables, this.context);
|
|
305
|
-
return response.notifications.items;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Get notification template
|
|
309
|
-
*/
|
|
310
|
-
async getTemplate(slug, locale) {
|
|
311
|
-
const query = `
|
|
312
|
-
query GetNotificationTemplate($slug: String!, $locale: String) {
|
|
313
|
-
notificationTemplate(slug: $slug, locale: $locale) {
|
|
314
|
-
id
|
|
315
|
-
name
|
|
316
|
-
slug
|
|
317
|
-
description
|
|
318
|
-
channel
|
|
319
|
-
type
|
|
320
|
-
locale
|
|
321
|
-
subject
|
|
322
|
-
bodyTemplate
|
|
323
|
-
htmlTemplate
|
|
324
|
-
variables
|
|
325
|
-
enabled
|
|
326
|
-
version
|
|
327
|
-
createdAt
|
|
328
|
-
updatedAt
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
`;
|
|
332
|
-
const response = await this.client.tenantQuery(query, {
|
|
333
|
-
slug,
|
|
334
|
-
locale
|
|
335
|
-
}, this.context);
|
|
336
|
-
return response.notificationTemplate;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Get all notification templates
|
|
340
|
-
*/
|
|
341
|
-
async getTemplates(filter) {
|
|
342
|
-
const query = `query GetNotificationTemplates($filter: TemplateFilterInput, $limit: Int!, $offset: Int!) {
|
|
343
|
-
notificationTemplates(filter: $filter, limit: $limit, offset: $offset) {
|
|
344
|
-
items { id name slug description channel type locale subject bodyTemplate htmlTemplate variables enabled version createdAt updatedAt }
|
|
345
|
-
hasMore
|
|
346
|
-
}
|
|
347
|
-
}`;
|
|
348
|
-
const templates = [];
|
|
349
|
-
const seen = /* @__PURE__ */ new Set();
|
|
350
|
-
for (let page = 0; page < 100; page++) {
|
|
351
|
-
const response = await this.client.tenantQuery(query, {
|
|
352
|
-
filter,
|
|
353
|
-
limit: 100,
|
|
354
|
-
offset: templates.length
|
|
355
|
-
}, this.context);
|
|
356
|
-
const result = response.notificationTemplates;
|
|
357
|
-
if (!result || !Array.isArray(result.items) || typeof result.hasMore !== "boolean") {
|
|
358
|
-
throw new APIError("Notification template page was invalid", {
|
|
359
|
-
operation: "notificationTemplates"
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
for (const template of result.items) {
|
|
363
|
-
if (!template.id || seen.has(template.id)) {
|
|
364
|
-
throw new APIError("Notification template pagination did not progress", {
|
|
365
|
-
operation: "notificationTemplates"
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
seen.add(template.id);
|
|
369
|
-
templates.push(template);
|
|
370
|
-
}
|
|
371
|
-
if (!result.hasMore) return templates;
|
|
372
|
-
if (!result.items.length) {
|
|
373
|
-
throw new APIError("Notification template pagination did not progress", {
|
|
374
|
-
operation: "notificationTemplates"
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
throw new APIError("Notification template pagination exceeded its bounded limit", {
|
|
379
|
-
operation: "notificationTemplates"
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Get notification statistics
|
|
384
|
-
*/
|
|
385
|
-
async getStats(filter) {
|
|
386
|
-
const query = `
|
|
387
|
-
query GetNotificationStats($filter: NotificationFilterInput) {
|
|
388
|
-
notificationStats(filter: $filter) {
|
|
389
|
-
total
|
|
390
|
-
pending
|
|
391
|
-
triggered
|
|
392
|
-
scheduled
|
|
393
|
-
cancelled
|
|
394
|
-
sent
|
|
395
|
-
delivered
|
|
396
|
-
failed
|
|
397
|
-
byChannel
|
|
398
|
-
byType
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
`;
|
|
402
|
-
const variables = {
|
|
403
|
-
filter: filter ? {
|
|
404
|
-
userId: filter.userId,
|
|
405
|
-
startDate: filter.startDate?.toISOString(),
|
|
406
|
-
endDate: filter.endDate?.toISOString()
|
|
407
|
-
} : void 0
|
|
408
|
-
};
|
|
409
|
-
const response = await this.client.tenantQuery(query, variables, this.context);
|
|
410
|
-
return response.notificationStats;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Mark notifications as read
|
|
414
|
-
*/
|
|
415
|
-
async markAsRead(notificationIds) {
|
|
416
|
-
const mutation = `
|
|
417
|
-
mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {
|
|
418
|
-
markNotificationsAsRead(notificationIds: $notificationIds) { success count failedIds }
|
|
419
|
-
}
|
|
420
|
-
`;
|
|
421
|
-
const result = await this.client.tenantQuery(mutation, {
|
|
422
|
-
notificationIds
|
|
423
|
-
}, this.context);
|
|
424
|
-
logger.info("[TenantNotifications] Read request completed", {
|
|
425
|
-
success: result.markNotificationsAsRead.success,
|
|
426
|
-
count: notificationIds.length
|
|
427
|
-
});
|
|
428
|
-
return result.markNotificationsAsRead.success;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Mark all notifications as read for the current user
|
|
432
|
-
*/
|
|
433
|
-
async markAllAsRead() {
|
|
434
|
-
const mutation = `
|
|
435
|
-
mutation MarkAllMyNotificationsAsRead {
|
|
436
|
-
markAllMyNotificationsAsRead { success count failedIds }
|
|
437
|
-
}
|
|
438
|
-
`;
|
|
439
|
-
const result = await this.client.tenantQuery(mutation, {}, this.context);
|
|
440
|
-
logger.info("[TenantNotifications] Read-all request completed", {
|
|
441
|
-
success: result.markAllMyNotificationsAsRead.success
|
|
442
|
-
});
|
|
443
|
-
return result.markAllMyNotificationsAsRead.success;
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Delete notifications
|
|
447
|
-
*/
|
|
448
|
-
async deleteNotifications(notificationIds) {
|
|
449
|
-
const mutation = `
|
|
450
|
-
mutation DeleteNotifications($notificationIds: [ID!]!) {
|
|
451
|
-
deleteNotifications(notificationIds: $notificationIds)
|
|
452
|
-
}
|
|
453
|
-
`;
|
|
454
|
-
const result = await this.client.tenantQuery(mutation, {
|
|
455
|
-
notificationIds
|
|
456
|
-
}, this.context);
|
|
457
|
-
logger.info("[TenantNotifications] Delete request completed", {
|
|
458
|
-
success: result.deleteNotifications,
|
|
459
|
-
count: notificationIds.length
|
|
460
|
-
});
|
|
461
|
-
return result.deleteNotifications;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Delete all read notifications for the current user
|
|
465
|
-
*/
|
|
466
|
-
async deleteAllReadNotifications() {
|
|
467
|
-
const mutation = `
|
|
468
|
-
mutation DeleteMyReadNotifications {
|
|
469
|
-
deleteMyReadNotifications
|
|
470
|
-
}
|
|
471
|
-
`;
|
|
472
|
-
const result = await this.client.tenantQuery(mutation, {}, this.context);
|
|
473
|
-
logger.info("[TenantNotifications] Delete-read request completed", {
|
|
474
|
-
success: result.deleteMyReadNotifications
|
|
475
|
-
});
|
|
476
|
-
return result.deleteMyReadNotifications;
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Validate send notification input
|
|
480
|
-
*/
|
|
481
|
-
validateSendInput(input) {
|
|
482
|
-
if (!Object.values(NotificationChannel).includes(input.channel)) {
|
|
483
|
-
throw new ValidationError("A supported notification channel is required");
|
|
484
|
-
}
|
|
485
|
-
const recipientKeys = {
|
|
486
|
-
EMAIL: [
|
|
487
|
-
"email",
|
|
488
|
-
"userId"
|
|
489
|
-
],
|
|
490
|
-
SMS: [
|
|
491
|
-
"phoneNumber",
|
|
492
|
-
"userId"
|
|
493
|
-
],
|
|
494
|
-
PUSH: [
|
|
495
|
-
"pushToken",
|
|
496
|
-
"userId"
|
|
497
|
-
],
|
|
498
|
-
IN_APP: [
|
|
499
|
-
"userId"
|
|
500
|
-
],
|
|
501
|
-
WEBHOOK: [
|
|
502
|
-
"webhookUrl",
|
|
503
|
-
"userId"
|
|
504
|
-
],
|
|
505
|
-
WHATSAPP: [
|
|
506
|
-
"whatsappNumber",
|
|
507
|
-
"phoneNumber",
|
|
508
|
-
"userId"
|
|
509
|
-
],
|
|
510
|
-
TEAMS: [
|
|
511
|
-
"teamsUserId",
|
|
512
|
-
"userId"
|
|
513
|
-
],
|
|
514
|
-
SLACK: [
|
|
515
|
-
"slackUserId",
|
|
516
|
-
"userId"
|
|
517
|
-
],
|
|
518
|
-
TELEGRAM: [
|
|
519
|
-
"userId"
|
|
520
|
-
],
|
|
521
|
-
DISCORD: [
|
|
522
|
-
"userId"
|
|
523
|
-
]
|
|
524
|
-
};
|
|
525
|
-
if (!input.recipient || !recipientKeys[input.channel].some((key) => {
|
|
526
|
-
const value = input.recipient[key];
|
|
527
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
528
|
-
})) throw new ValidationError("A recipient address or userId appropriate for the channel is required");
|
|
529
|
-
if (typeof input.body !== "string" || input.body.trim().length === 0) {
|
|
530
|
-
throw new ValidationError("Notification body is required");
|
|
531
|
-
}
|
|
532
|
-
this.validateDates(input);
|
|
533
|
-
}
|
|
534
|
-
validateDates(input) {
|
|
535
|
-
for (const value of [
|
|
536
|
-
input.scheduledFor,
|
|
537
|
-
input.expiresAt
|
|
538
|
-
]) {
|
|
539
|
-
if (value != null && (!(value instanceof Date) || !Number.isFinite(value.getTime()))) {
|
|
540
|
-
throw new ValidationError("Notification dates must be valid Date values");
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (input.scheduledFor && input.expiresAt && input.expiresAt <= input.scheduledFor) {
|
|
544
|
-
throw new ValidationError("Notification expiry must follow its scheduled delivery");
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
// src/notifications/index.ts
|
|
550
|
-
var NotificationType2 = /* @__PURE__ */ (function(NotificationType3) {
|
|
551
|
-
NotificationType3["INFO"] = "info";
|
|
552
|
-
NotificationType3["SUCCESS"] = "success";
|
|
553
|
-
NotificationType3["WARNING"] = "warning";
|
|
554
|
-
NotificationType3["ERROR"] = "error";
|
|
555
|
-
return NotificationType3;
|
|
556
|
-
})({});
|
|
557
|
-
var NotificationChannel2 = /* @__PURE__ */ (function(NotificationChannel3) {
|
|
558
|
-
NotificationChannel3["EMAIL"] = "EMAIL";
|
|
559
|
-
NotificationChannel3["SMS"] = "SMS";
|
|
560
|
-
NotificationChannel3["WHATSAPP"] = "WHATSAPP";
|
|
561
|
-
NotificationChannel3["PUSH"] = "PUSH";
|
|
562
|
-
NotificationChannel3["SLACK"] = "SLACK";
|
|
563
|
-
NotificationChannel3["TEAMS"] = "TEAMS";
|
|
564
|
-
NotificationChannel3["WEBHOOK"] = "WEBHOOK";
|
|
565
|
-
return NotificationChannel3;
|
|
566
|
-
})({});
|
|
567
|
-
function mapNotificationType(type) {
|
|
568
|
-
return type === "warning" || type === "error" ? "ALERT" : "TRANSACTIONAL";
|
|
569
|
-
}
|
|
570
|
-
__name(mapNotificationType, "mapNotificationType");
|
|
571
|
-
function resolveChannel(options) {
|
|
572
|
-
if (options.email) return "EMAIL";
|
|
573
|
-
if (options.sms) return "SMS";
|
|
574
|
-
return "IN_APP";
|
|
575
|
-
}
|
|
576
|
-
__name(resolveChannel, "resolveChannel");
|
|
577
|
-
var NotificationsModule = class {
|
|
578
|
-
static {
|
|
579
|
-
__name(this, "NotificationsModule");
|
|
580
|
-
}
|
|
581
|
-
client;
|
|
582
|
-
context;
|
|
583
|
-
constructor(client, context) {
|
|
584
|
-
this.client = client;
|
|
585
|
-
this.context = context;
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Send notification to users
|
|
589
|
-
*/
|
|
590
|
-
async send(options) {
|
|
591
|
-
if (!options.title || options.title.trim().length === 0) {
|
|
592
|
-
throw new ValidationError("Notification title is required");
|
|
593
|
-
}
|
|
594
|
-
if (!options.message || options.message.trim().length === 0) {
|
|
595
|
-
throw new ValidationError("Notification message is required");
|
|
596
|
-
}
|
|
597
|
-
if (!options.userIds || options.userIds.length === 0) {
|
|
598
|
-
throw new ValidationError("At least one user ID is required");
|
|
599
|
-
}
|
|
600
|
-
if (options.expiresAt && (!(options.expiresAt instanceof Date) || !Number.isFinite(options.expiresAt.getTime()))) {
|
|
601
|
-
throw new ValidationError("Notification expiry must be a valid Date");
|
|
602
|
-
}
|
|
603
|
-
logger.info("[Notifications] Sending notification", {
|
|
604
|
-
userCount: options.userIds.length,
|
|
605
|
-
type: options.type || "info"
|
|
606
|
-
});
|
|
607
|
-
const mutation = `
|
|
608
|
-
mutation TriggerNotification($input: TriggerNotificationInput!) {
|
|
609
|
-
triggerNotification(input: $input) {
|
|
610
|
-
id
|
|
611
|
-
status
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
`;
|
|
615
|
-
const channel = resolveChannel(options);
|
|
616
|
-
const notificationIds = [];
|
|
617
|
-
const errors = [];
|
|
618
|
-
const results = await Promise.allSettled(options.userIds.map(async (userId) => {
|
|
619
|
-
const variables = {
|
|
620
|
-
input: {
|
|
621
|
-
notification: {
|
|
622
|
-
recipient: {
|
|
623
|
-
userId
|
|
624
|
-
},
|
|
625
|
-
channel,
|
|
626
|
-
type: mapNotificationType(options.type),
|
|
627
|
-
subject: options.title,
|
|
628
|
-
body: options.message,
|
|
629
|
-
metadata: options.metadata,
|
|
630
|
-
data: options.data,
|
|
631
|
-
expiresAt: options.expiresAt?.toISOString(),
|
|
632
|
-
...options.redirectUrl ? {
|
|
633
|
-
redirectUrl: options.redirectUrl
|
|
634
|
-
} : {},
|
|
635
|
-
...options.appName ? {
|
|
636
|
-
appName: options.appName
|
|
637
|
-
} : {}
|
|
638
|
-
},
|
|
639
|
-
platform: channel,
|
|
640
|
-
// Always leave an in-app trace when the primary channel is external, so the
|
|
641
|
-
// notification is visible in the product even if email/SMS delivery fails.
|
|
642
|
-
includeInApp: channel !== "IN_APP"
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
const response = await this.client.tenantQuery(mutation, variables, this.context);
|
|
646
|
-
const id = response.triggerNotification?.id;
|
|
647
|
-
if (!id) {
|
|
648
|
-
throw new Error(`notification service returned no id for user ${userId}`);
|
|
649
|
-
}
|
|
650
|
-
return id;
|
|
651
|
-
}));
|
|
652
|
-
for (const [index, settled] of results.entries()) {
|
|
653
|
-
if (settled.status === "fulfilled") {
|
|
654
|
-
notificationIds.push(settled.value);
|
|
655
|
-
} else {
|
|
656
|
-
const reason = settled.reason instanceof Error ? settled.reason.message : String(settled.reason);
|
|
657
|
-
errors.push(`${options.userIds[index] ?? "unknown user"}: ${reason}`);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
const result = {
|
|
661
|
-
successCount: notificationIds.length,
|
|
662
|
-
failureCount: errors.length,
|
|
663
|
-
errors,
|
|
664
|
-
notificationIds
|
|
665
|
-
};
|
|
666
|
-
logger.info("[Notifications] Notification sent", {
|
|
667
|
-
successCount: result.successCount,
|
|
668
|
-
failureCount: result.failureCount
|
|
669
|
-
});
|
|
670
|
-
return result;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Send notification to a single user (convenience method)
|
|
674
|
-
*/
|
|
675
|
-
async sendToUser(userId, title, message, options) {
|
|
676
|
-
return this.send({
|
|
677
|
-
title,
|
|
678
|
-
message,
|
|
679
|
-
userIds: [
|
|
680
|
-
userId
|
|
681
|
-
],
|
|
682
|
-
...options
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Get notifications for a user
|
|
687
|
-
*/
|
|
688
|
-
async getNotifications(options) {
|
|
689
|
-
logger.debug("[Notifications] Getting notifications", {
|
|
690
|
-
userId: options.userId
|
|
691
|
-
});
|
|
692
|
-
const query = `
|
|
693
|
-
query GetNotifications(
|
|
694
|
-
$userId: ID!
|
|
695
|
-
$status: NotificationStatus
|
|
696
|
-
$type: NotificationType
|
|
697
|
-
$appName: String
|
|
698
|
-
$search: String
|
|
699
|
-
$limit: Int
|
|
700
|
-
$offset: Int
|
|
701
|
-
) {
|
|
702
|
-
getNotifications(
|
|
703
|
-
userId: $userId
|
|
704
|
-
status: $status
|
|
705
|
-
type: $type
|
|
706
|
-
appName: $appName
|
|
707
|
-
search: $search
|
|
708
|
-
limit: $limit
|
|
709
|
-
offset: $offset
|
|
710
|
-
) {
|
|
711
|
-
notifications {
|
|
712
|
-
id
|
|
713
|
-
userId
|
|
714
|
-
title
|
|
715
|
-
message
|
|
716
|
-
type
|
|
717
|
-
status
|
|
718
|
-
redirectUrl
|
|
719
|
-
appName
|
|
720
|
-
createdAt
|
|
721
|
-
updatedAt
|
|
722
|
-
}
|
|
723
|
-
total
|
|
724
|
-
unreadCount
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
`;
|
|
728
|
-
const variables = {
|
|
729
|
-
userId: options.userId,
|
|
730
|
-
status: options.status,
|
|
731
|
-
type: options.type,
|
|
732
|
-
appName: options.appName,
|
|
733
|
-
search: options.search,
|
|
734
|
-
limit: options.limit || 20,
|
|
735
|
-
offset: options.offset || 0
|
|
736
|
-
};
|
|
737
|
-
const response = await this.client.query(query, variables, this.context);
|
|
738
|
-
return response.getNotifications;
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Mark notification as read
|
|
742
|
-
*/
|
|
743
|
-
async markAsRead(notificationId) {
|
|
744
|
-
logger.debug("[Notifications] Marking notification as read", {
|
|
745
|
-
notificationId
|
|
746
|
-
});
|
|
747
|
-
const mutation = `
|
|
748
|
-
mutation MarkNotificationAsRead($notificationId: ID!) {
|
|
749
|
-
markNotificationAsRead(notificationId: $notificationId) {
|
|
750
|
-
id
|
|
751
|
-
status
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
`;
|
|
755
|
-
await this.client.tenantQuery(mutation, {
|
|
756
|
-
notificationId
|
|
757
|
-
}, this.context);
|
|
758
|
-
logger.info("[Notifications] Notification marked as read", {
|
|
759
|
-
notificationId
|
|
760
|
-
});
|
|
761
|
-
return true;
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Mark multiple notifications as read
|
|
765
|
-
*/
|
|
766
|
-
async markMultipleAsRead(notificationIds) {
|
|
767
|
-
logger.debug("[Notifications] Marking multiple notifications as read", {
|
|
768
|
-
count: notificationIds.length
|
|
769
|
-
});
|
|
770
|
-
const mutation = `
|
|
771
|
-
mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {
|
|
772
|
-
markNotificationsAsRead(notificationIds: $notificationIds) {
|
|
773
|
-
count
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
`;
|
|
777
|
-
const response = await this.client.query(mutation, {
|
|
778
|
-
notificationIds
|
|
779
|
-
}, this.context);
|
|
780
|
-
logger.info("[Notifications] Notifications marked as read", {
|
|
781
|
-
count: response.markNotificationsAsRead.count
|
|
782
|
-
});
|
|
783
|
-
return response.markNotificationsAsRead.count;
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* Mark all notifications as read for the current user
|
|
787
|
-
*/
|
|
788
|
-
async markAllAsRead() {
|
|
789
|
-
logger.debug("[Notifications] Marking all notifications as read");
|
|
790
|
-
const mutation = `
|
|
791
|
-
mutation MarkAllMyNotificationsAsRead {
|
|
792
|
-
markAllMyNotificationsAsRead {
|
|
793
|
-
count
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
`;
|
|
797
|
-
const response = await this.client.query(mutation, {}, this.context);
|
|
798
|
-
logger.info("[Notifications] All notifications marked as read", {
|
|
799
|
-
count: response.markAllMyNotificationsAsRead.count
|
|
800
|
-
});
|
|
801
|
-
return response.markAllMyNotificationsAsRead.count;
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Delete notification
|
|
805
|
-
*/
|
|
806
|
-
async deleteNotification(notificationId) {
|
|
807
|
-
logger.debug("[Notifications] Deleting notification", {
|
|
808
|
-
notificationId
|
|
809
|
-
});
|
|
810
|
-
const mutation = `
|
|
811
|
-
mutation DeleteNotification($notificationId: ID!) {
|
|
812
|
-
deleteNotification(notificationId: $notificationId) {
|
|
813
|
-
success
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
`;
|
|
817
|
-
await this.client.tenantQuery(mutation, {
|
|
818
|
-
notificationId
|
|
819
|
-
}, this.context);
|
|
820
|
-
logger.info("[Notifications] Notification deleted", {
|
|
821
|
-
notificationId
|
|
822
|
-
});
|
|
823
|
-
return true;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Delete multiple notifications
|
|
827
|
-
*/
|
|
828
|
-
async deleteMultiple(notificationIds) {
|
|
829
|
-
logger.debug("[Notifications] Deleting multiple notifications", {
|
|
830
|
-
count: notificationIds.length
|
|
831
|
-
});
|
|
832
|
-
const mutation = `
|
|
833
|
-
mutation DeleteNotifications($notificationIds: [ID!]!) {
|
|
834
|
-
deleteNotifications(notificationIds: $notificationIds) {
|
|
835
|
-
count
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
`;
|
|
839
|
-
const response = await this.client.query(mutation, {
|
|
840
|
-
notificationIds
|
|
841
|
-
}, this.context);
|
|
842
|
-
logger.info("[Notifications] Notifications deleted", {
|
|
843
|
-
count: response.deleteNotifications.count
|
|
844
|
-
});
|
|
845
|
-
return response.deleteNotifications.count;
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Get unread notification count for a user
|
|
849
|
-
*/
|
|
850
|
-
async getUnreadCount(userId) {
|
|
851
|
-
const result = await this.getNotifications({
|
|
852
|
-
userId,
|
|
853
|
-
status: "unread",
|
|
854
|
-
limit: 0
|
|
855
|
-
});
|
|
856
|
-
return result.unreadCount;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* Send notification via specific channel (EMAIL, SMS, WHATSAPP, etc.)
|
|
860
|
-
* with optional in-app notification
|
|
861
|
-
*/
|
|
862
|
-
async sendChannelNotification(options) {
|
|
863
|
-
if (!options.body || options.body.trim().length === 0) {
|
|
864
|
-
throw new ValidationError("Notification body is required");
|
|
865
|
-
}
|
|
866
|
-
if (!options.recipient && !options.recipients) {
|
|
867
|
-
throw new ValidationError("At least one recipient is required");
|
|
868
|
-
}
|
|
869
|
-
if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {
|
|
870
|
-
throw new ValidationError("User IDs are required when includeInApp is true");
|
|
871
|
-
}
|
|
872
|
-
logger.info("[Notifications] Sending channel notification", {
|
|
873
|
-
platform: options.platform,
|
|
874
|
-
recipientCount: options.recipients ? options.recipients.length : 1,
|
|
875
|
-
includeInApp: options.includeInApp,
|
|
876
|
-
inAppUserCount: options.userIds ? options.userIds.length : 0
|
|
877
|
-
});
|
|
878
|
-
const mutation = `
|
|
879
|
-
mutation TriggerNotification($input: TriggerNotificationInput!) {
|
|
880
|
-
triggerNotification(input: $input) {
|
|
881
|
-
id
|
|
882
|
-
status
|
|
883
|
-
deliveryStatus
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
`;
|
|
887
|
-
const variables = {
|
|
888
|
-
input: {
|
|
889
|
-
platform: options.platform,
|
|
890
|
-
channelId: options.channelId,
|
|
891
|
-
includeInApp: options.includeInApp || false,
|
|
892
|
-
userIds: options.userIds || [],
|
|
893
|
-
notification: {
|
|
894
|
-
subject: options.subject || "",
|
|
895
|
-
body: options.body,
|
|
896
|
-
htmlBody: options.htmlBody || "",
|
|
897
|
-
channel: options.platform,
|
|
898
|
-
type: options.type || "info",
|
|
899
|
-
recipient: options.recipient,
|
|
900
|
-
appName: options.appName,
|
|
901
|
-
redirectUrl: options.redirectUrl || "",
|
|
902
|
-
metadata: options.metadata || {},
|
|
903
|
-
trackOpens: options.trackOpens || false,
|
|
904
|
-
trackClicks: options.trackClicks || false,
|
|
905
|
-
expiresAt: options.expiresAt?.toISOString()
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
if (options.recipients && options.recipients.length > 1) {
|
|
910
|
-
const results = await Promise.allSettled(options.recipients.map((recipient) => this.client.tenantQuery(mutation, {
|
|
911
|
-
input: {
|
|
912
|
-
...variables.input,
|
|
913
|
-
notification: {
|
|
914
|
-
...variables.input.notification,
|
|
915
|
-
recipient
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}, this.context)));
|
|
919
|
-
let successCount = 0;
|
|
920
|
-
let failureCount = 0;
|
|
921
|
-
const errors = [];
|
|
922
|
-
const notificationIds = [];
|
|
923
|
-
results.forEach((result, index) => {
|
|
924
|
-
if (result.status === "fulfilled") {
|
|
925
|
-
successCount++;
|
|
926
|
-
const response2 = result.value;
|
|
927
|
-
notificationIds.push(response2.triggerNotification.id);
|
|
928
|
-
} else {
|
|
929
|
-
failureCount++;
|
|
930
|
-
errors.push(`Recipient ${index + 1}: ${result.reason instanceof Error ? result.reason.message : "Unknown error"}`);
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
const response = {
|
|
934
|
-
successCount,
|
|
935
|
-
failureCount,
|
|
936
|
-
errors,
|
|
937
|
-
notificationIds
|
|
938
|
-
};
|
|
939
|
-
logger.info("[Notifications] Channel notification sent (bulk)", {
|
|
940
|
-
successCount,
|
|
941
|
-
failureCount
|
|
942
|
-
});
|
|
943
|
-
return response;
|
|
944
|
-
} else {
|
|
945
|
-
try {
|
|
946
|
-
const response = await this.client.query(mutation, variables, this.context);
|
|
947
|
-
const result = {
|
|
948
|
-
successCount: 1,
|
|
949
|
-
failureCount: 0,
|
|
950
|
-
errors: [],
|
|
951
|
-
notificationIds: [
|
|
952
|
-
response.triggerNotification.id
|
|
953
|
-
]
|
|
954
|
-
};
|
|
955
|
-
logger.info("[Notifications] Channel notification sent", {
|
|
956
|
-
notificationId: response.triggerNotification.id,
|
|
957
|
-
status: response.triggerNotification.status
|
|
958
|
-
});
|
|
959
|
-
return result;
|
|
960
|
-
} catch (error) {
|
|
961
|
-
logger.error("[Notifications] Failed to send channel notification", {
|
|
962
|
-
error
|
|
963
|
-
});
|
|
964
|
-
return {
|
|
965
|
-
successCount: 0,
|
|
966
|
-
failureCount: 1,
|
|
967
|
-
errors: [
|
|
968
|
-
error instanceof Error ? error.message : "Unknown error"
|
|
969
|
-
],
|
|
970
|
-
notificationIds: []
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Send notification using a template with optional in-app notification
|
|
977
|
-
*/
|
|
978
|
-
async sendTemplateNotification(options) {
|
|
979
|
-
if (!options.templateSlug || options.templateSlug.trim().length === 0) {
|
|
980
|
-
throw new ValidationError("Template slug is required");
|
|
981
|
-
}
|
|
982
|
-
if (!options.variables || typeof options.variables !== "object") {
|
|
983
|
-
throw new ValidationError("Template variables are required");
|
|
984
|
-
}
|
|
985
|
-
if (!options.recipient && !options.recipients) {
|
|
986
|
-
throw new ValidationError("At least one recipient is required");
|
|
987
|
-
}
|
|
988
|
-
if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {
|
|
989
|
-
throw new ValidationError("User IDs are required when includeInApp is true");
|
|
990
|
-
}
|
|
991
|
-
logger.info("[Notifications] Sending template notification", {
|
|
992
|
-
templateSlug: options.templateSlug,
|
|
993
|
-
platform: options.platform,
|
|
994
|
-
recipientCount: options.recipients ? options.recipients.length : 1,
|
|
995
|
-
includeInApp: options.includeInApp,
|
|
996
|
-
inAppUserCount: options.userIds ? options.userIds.length : 0
|
|
997
|
-
});
|
|
998
|
-
const mutation = `
|
|
999
|
-
mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {
|
|
1000
|
-
triggerNotificationWithTemplate(input: $input) {
|
|
1001
|
-
totalRequested
|
|
1002
|
-
totalTriggered
|
|
1003
|
-
totalFailed
|
|
1004
|
-
notifications {
|
|
1005
|
-
id
|
|
1006
|
-
status
|
|
1007
|
-
deliveryStatus
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
`;
|
|
1012
|
-
const variables = {
|
|
1013
|
-
input: {
|
|
1014
|
-
platform: options.platform,
|
|
1015
|
-
channelId: options.channelId,
|
|
1016
|
-
includeInApp: options.includeInApp || false,
|
|
1017
|
-
userIds: options.userIds || [],
|
|
1018
|
-
templateSlug: options.templateSlug,
|
|
1019
|
-
variables: options.variables,
|
|
1020
|
-
recipient: options.recipient,
|
|
1021
|
-
recipients: options.recipients,
|
|
1022
|
-
trackOpens: options.trackOpens || false,
|
|
1023
|
-
trackClicks: options.trackClicks || false,
|
|
1024
|
-
expiresAt: options.expiresAt?.toISOString(),
|
|
1025
|
-
scheduledFor: options.scheduledFor?.toISOString(),
|
|
1026
|
-
timezone: options.timezone
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
try {
|
|
1030
|
-
const response = await this.client.query(mutation, variables, this.context);
|
|
1031
|
-
const data = response.triggerNotificationWithTemplate;
|
|
1032
|
-
const result = {
|
|
1033
|
-
successCount: data.totalTriggered,
|
|
1034
|
-
failureCount: data.totalFailed,
|
|
1035
|
-
errors: [],
|
|
1036
|
-
notificationIds: data.notifications.map((n) => n.id)
|
|
1037
|
-
};
|
|
1038
|
-
logger.info("[Notifications] Template notification sent", {
|
|
1039
|
-
templateSlug: options.templateSlug,
|
|
1040
|
-
totalTriggered: data.totalTriggered,
|
|
1041
|
-
totalFailed: data.totalFailed,
|
|
1042
|
-
notificationIds: result.notificationIds
|
|
1043
|
-
});
|
|
1044
|
-
return result;
|
|
1045
|
-
} catch (error) {
|
|
1046
|
-
logger.error("[Notifications] Failed to send template notification", {
|
|
1047
|
-
error
|
|
1048
|
-
});
|
|
1049
|
-
return {
|
|
1050
|
-
successCount: 0,
|
|
1051
|
-
failureCount: 1,
|
|
1052
|
-
errors: [
|
|
1053
|
-
error instanceof Error ? error.message : "Unknown error"
|
|
1054
|
-
],
|
|
1055
|
-
notificationIds: []
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
|
|
1061
|
-
export { NotificationChannel, NotificationChannel2, NotificationPriority, NotificationType, NotificationType2, NotificationsModule, TenantNotificationsModule, tenant_notifications_exports };
|
|
1062
|
-
//# sourceMappingURL=chunk-KH4TRQCO.js.map
|
|
1063
|
-
//# sourceMappingURL=chunk-KH4TRQCO.js.map
|