@burdenoff/be-sdk 2026.1107.1 → 2026.1107.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 +28 -48
- package/configs/tsconfig/tsconfig.json +22 -37
- package/dist/EventQueueFactory-PP534MBQ.js +8 -0
- package/dist/{EventQueueFactory-PEYWB2RY.js.map → EventQueueFactory-PP534MBQ.js.map} +1 -1
- package/dist/ai-credits/index.js +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/{chunk-DS3YMJ4X.js → chunk-554Z4C2K.js} +2 -2
- package/dist/chunk-554Z4C2K.js.map +1 -0
- package/dist/{chunk-23WAZL7I.js → chunk-5CS3ZITV.js} +2 -2
- package/dist/chunk-5CS3ZITV.js.map +1 -0
- package/dist/{chunk-MZCBEJ67.js → chunk-63ZXJ42X.js} +3 -3
- package/dist/{chunk-MZCBEJ67.js.map → chunk-63ZXJ42X.js.map} +1 -1
- package/dist/{chunk-6SDWH4OM.js → chunk-726AR6Q7.js} +2 -2
- package/dist/{chunk-6SDWH4OM.js.map → chunk-726AR6Q7.js.map} +1 -1
- package/dist/{chunk-7QCJE6IQ.js → chunk-7EISSMFP.js} +3 -3
- package/dist/{chunk-7QCJE6IQ.js.map → chunk-7EISSMFP.js.map} +1 -1
- package/dist/{chunk-64QUSPYG.js → chunk-BD3SMWUU.js} +3 -3
- package/dist/chunk-BD3SMWUU.js.map +1 -0
- package/dist/{chunk-Q5H45UXV.js → chunk-CFXWH2IS.js} +5 -5
- package/dist/{chunk-Q5H45UXV.js.map → chunk-CFXWH2IS.js.map} +1 -1
- package/dist/{chunk-EHUFQHMV.js → chunk-DIOS6L7M.js} +4 -4
- package/dist/{chunk-EHUFQHMV.js.map → chunk-DIOS6L7M.js.map} +1 -1
- package/dist/{chunk-42PJSEQK.js → chunk-DJNHR37J.js} +3 -3
- package/dist/{chunk-42PJSEQK.js.map → chunk-DJNHR37J.js.map} +1 -1
- package/dist/{chunk-7SWIUDYM.js → chunk-E6OAFS7A.js} +4 -4
- package/dist/chunk-E6OAFS7A.js.map +1 -0
- package/dist/{chunk-AWPNRV3L.js → chunk-GCIB76AJ.js} +2 -2
- package/dist/chunk-GCIB76AJ.js.map +1 -0
- package/dist/{chunk-XXNT4VCM.js → chunk-HC6MPUIH.js} +2 -2
- package/dist/{chunk-XXNT4VCM.js.map → chunk-HC6MPUIH.js.map} +1 -1
- package/dist/{chunk-TANAOLAV.js → chunk-JVMAQOA3.js} +2 -2
- package/dist/chunk-JVMAQOA3.js.map +1 -0
- package/dist/{chunk-DXCWPTKC.js → chunk-K56L7NUR.js} +3 -3
- package/dist/chunk-K56L7NUR.js.map +1 -0
- package/dist/{chunk-UWQ2OKA6.js → chunk-LQYHWC7F.js} +4 -4
- package/dist/{chunk-UWQ2OKA6.js.map → chunk-LQYHWC7F.js.map} +1 -1
- package/dist/{chunk-JSEG3G5L.js → chunk-MESLAC5W.js} +3 -3
- package/dist/{chunk-JSEG3G5L.js.map → chunk-MESLAC5W.js.map} +1 -1
- package/dist/{chunk-IGWTT2YA.js → chunk-OBZQ4AJC.js} +6 -6
- package/dist/{chunk-IGWTT2YA.js.map → chunk-OBZQ4AJC.js.map} +1 -1
- package/dist/{chunk-LCDECFJJ.js → chunk-OXNCBE7P.js} +4 -4
- package/dist/{chunk-LCDECFJJ.js.map → chunk-OXNCBE7P.js.map} +1 -1
- package/dist/{chunk-OHUBPOZ6.js → chunk-PBZFAAOM.js} +3 -3
- package/dist/{chunk-OHUBPOZ6.js.map → chunk-PBZFAAOM.js.map} +1 -1
- package/dist/{chunk-2Q6RH3GE.js → chunk-PYD44IHJ.js} +2 -2
- package/dist/chunk-PYD44IHJ.js.map +1 -0
- package/dist/{chunk-4KK6YJ46.js → chunk-QWNNFE4P.js} +2 -2
- package/dist/chunk-QWNNFE4P.js.map +1 -0
- package/dist/{chunk-E5DTAGCA.js → chunk-RYTSVGGA.js} +3 -3
- package/dist/chunk-RYTSVGGA.js.map +1 -0
- package/dist/{chunk-ZWKJKL6Y.js → chunk-SPRG6G6G.js} +3 -3
- package/dist/{chunk-ZWKJKL6Y.js.map → chunk-SPRG6G6G.js.map} +1 -1
- package/dist/{chunk-WTEHAVBX.js → chunk-VGAHZKNJ.js} +3 -3
- package/dist/{chunk-WTEHAVBX.js.map → chunk-VGAHZKNJ.js.map} +1 -1
- package/dist/{chunk-3YG5JRS5.js → chunk-VTJTAAXC.js} +3 -3
- package/dist/{chunk-3YG5JRS5.js.map → chunk-VTJTAAXC.js.map} +1 -1
- package/dist/{chunk-YK7C5DU6.js → chunk-WWUU5ETI.js} +2 -2
- package/dist/chunk-WWUU5ETI.js.map +1 -0
- package/dist/{chunk-PAQK3YF2.js → chunk-XOJORS75.js} +2 -2
- package/dist/chunk-XOJORS75.js.map +1 -0
- package/dist/{chunk-5ENWB2S6.js → chunk-ZPC3YYAU.js} +5 -5
- package/dist/chunk-ZPC3YYAU.js.map +1 -0
- package/dist/{client-FUR7I6DB.js → client-JU6T3UPB.js} +4 -4
- package/dist/{client-FUR7I6DB.js.map → client-JU6T3UPB.js.map} +1 -1
- package/dist/{esm-M2M7HGV4.js → dist-2X4Q7PJA.js} +628 -493
- package/dist/dist-2X4Q7PJA.js.map +1 -0
- package/dist/event-queue/index.js +3 -3
- package/dist/export/index.js +5 -5
- package/dist/files/index.js +2 -2
- package/dist/gateway/index.js +4 -4
- package/dist/gateway/security/index.js +1 -1
- package/dist/graph/index.js +5 -5
- package/dist/index.js +33 -33
- package/dist/index.js.map +1 -1
- package/dist/init/index.js +7 -7
- package/dist/instrumentation/index.js +2 -2
- package/dist/metrics/index.js +2 -2
- package/dist/notifications/index.js +1 -1
- package/dist/pino-logger-H4HPW5P6.js +5 -0
- package/dist/{pino-logger-GJ2CYLD5.js.map → pino-logger-H4HPW5P6.js.map} +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/prisma/index.js +4 -4
- package/dist/resource-caps/index.js +2 -2
- package/dist/server/index.js +4 -4
- package/dist/server/index.js.map +1 -1
- package/dist/sharing/index.js +1 -1
- package/dist/tags/index.js +1 -1
- package/dist/telemetry/index.js +5 -5
- package/dist/tracker/index.js +8 -8
- package/dist/usage/index.js +5 -5
- package/dist/validation/index.js +1 -1
- package/package.json +66 -44
- package/dist/EventQueueFactory-PEYWB2RY.js +0 -8
- package/dist/chunk-23WAZL7I.js.map +0 -1
- package/dist/chunk-2Q6RH3GE.js.map +0 -1
- package/dist/chunk-4KK6YJ46.js.map +0 -1
- package/dist/chunk-5ENWB2S6.js.map +0 -1
- package/dist/chunk-64QUSPYG.js.map +0 -1
- package/dist/chunk-7SWIUDYM.js.map +0 -1
- package/dist/chunk-AWPNRV3L.js.map +0 -1
- package/dist/chunk-DS3YMJ4X.js.map +0 -1
- package/dist/chunk-DXCWPTKC.js.map +0 -1
- package/dist/chunk-E5DTAGCA.js.map +0 -1
- package/dist/chunk-PAQK3YF2.js.map +0 -1
- package/dist/chunk-TANAOLAV.js.map +0 -1
- package/dist/chunk-YK7C5DU6.js.map +0 -1
- package/dist/esm-M2M7HGV4.js.map +0 -1
- package/dist/pino-logger-GJ2CYLD5.js +0 -5
package/dist/sharing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RESOURCE_CAPABILITY_MAP, RESOURCE_TYPE_LABELS, ROLE_CAPABILITIES, ROLE_ORDER, SHARE_EMAIL_TEMPLATE_SLUG, SHARE_GRANT_PARTIAL_UNIQUE_SQL, SHARE_GRANT_PRISMA, SHARE_GRANT_SDL, ShareRole, ShareService, ShareStatus, ShareVisibility, buildPerEntityShareSdl, buildShareEmailVariables, capabilitiesFor, legacyToRole, makeSendShareEmail, maxRole, normalizeStatus, resourceTypeLabel, roleAtLeast, roleLabel, roleToLegacy } from '../chunk-
|
|
1
|
+
export { RESOURCE_CAPABILITY_MAP, RESOURCE_TYPE_LABELS, ROLE_CAPABILITIES, ROLE_ORDER, SHARE_EMAIL_TEMPLATE_SLUG, SHARE_GRANT_PARTIAL_UNIQUE_SQL, SHARE_GRANT_PRISMA, SHARE_GRANT_SDL, ShareRole, ShareService, ShareStatus, ShareVisibility, buildPerEntityShareSdl, buildShareEmailVariables, capabilitiesFor, legacyToRole, makeSendShareEmail, maxRole, normalizeStatus, resourceTypeLabel, roleAtLeast, roleLabel, roleToLegacy } from '../chunk-554Z4C2K.js';
|
|
2
2
|
import '../chunk-RU266375.js';
|
|
3
3
|
import '../chunk-XE4OXN2W.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/tags/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ENTITY_TAGS_GRAPHQL_CODES, EntityTagsError, TAG_ACTOR_TYPES, TAG_ASSIGNMENT_SOURCES, TagsGatewayAdapter, UNIVERSAL_TAG_STUB_SDL, assertTagPrefix, buildEntityTagsSdl, createEntityTagResolvers, defaultTagActor, entityTagsFieldNames, entityTagsTypeNames, isEntityTagsError, mapTagAssignment, slugifyTagKey } from '../chunk-
|
|
1
|
+
export { ENTITY_TAGS_GRAPHQL_CODES, EntityTagsError, TAG_ACTOR_TYPES, TAG_ASSIGNMENT_SOURCES, TagsGatewayAdapter, UNIVERSAL_TAG_STUB_SDL, assertTagPrefix, buildEntityTagsSdl, createEntityTagResolvers, defaultTagActor, entityTagsFieldNames, entityTagsTypeNames, isEntityTagsError, mapTagAssignment, slugifyTagKey } from '../chunk-PBZFAAOM.js';
|
|
2
2
|
import '../chunk-RU266375.js';
|
|
3
3
|
import '../chunk-XE4OXN2W.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/telemetry/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { DEFAULT_REDACT_PATHS, createPinoLogger } from '../chunk-
|
|
2
|
-
import { setActiveTelemetryLogger, setupInstrumentation } from '../chunk-
|
|
3
|
-
export { initializeInstrumentation, setupInstrumentation } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { DEFAULT_REDACT_PATHS, createPinoLogger } from '../chunk-WWUU5ETI.js';
|
|
2
|
+
import { setActiveTelemetryLogger, setupInstrumentation } from '../chunk-RYTSVGGA.js';
|
|
3
|
+
export { initializeInstrumentation, setupInstrumentation } from '../chunk-RYTSVGGA.js';
|
|
4
|
+
import '../chunk-GCIB76AJ.js';
|
|
5
5
|
import { defaultCollectorEndpoint } from '../chunk-FZRODKIN.js';
|
|
6
6
|
export { COLLECTOR_SERVICE, OTLP_HTTP_PORT, defaultCollectorEndpoint, defaultCollectorTracesEndpoint, resolveCollectorLayer } from '../chunk-FZRODKIN.js';
|
|
7
7
|
import { redactSensitiveFields, logger } from '../chunk-RU266375.js';
|
|
@@ -149,7 +149,7 @@ async function bootstrapTelemetry(cfg) {
|
|
|
149
149
|
const serviceVersion = resolveVersion(cfg.serviceVersion);
|
|
150
150
|
const otlpEndpoint = resolveEndpoint(cfg.serviceName, cfg.boundary, cfg.otlpEndpoint);
|
|
151
151
|
const sampleRatio = resolveSampling(cfg.sampleRatio, env);
|
|
152
|
-
const { createPinoLogger: createPinoLogger2 } = await import('../pino-logger-
|
|
152
|
+
const { createPinoLogger: createPinoLogger2 } = await import('../pino-logger-H4HPW5P6.js');
|
|
153
153
|
const logger2 = await createPinoLogger2({
|
|
154
154
|
serviceName: cfg.serviceName,
|
|
155
155
|
env,
|
package/dist/tracker/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { AGENT_ACTIVITY_ACTIONS, AGENT_ACTIVITY_RESOURCE_TYPE, TrackerModule, trackAgentActivity } from '../chunk-
|
|
2
|
-
export { UsageMetricType } from '../chunk-
|
|
3
|
-
export { AI_ASSISTANT_ACTOR_ORIGIN, UNIFIED_TRACKER_CONSTANTS, UnifiedTrackerStub, createProductTracker, isTrackedActorType, resolveAssistantSession, suppressMutationAudit, trackOperation, trackerStub } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { AGENT_ACTIVITY_ACTIONS, AGENT_ACTIVITY_RESOURCE_TYPE, TrackerModule, trackAgentActivity } from '../chunk-ZPC3YYAU.js';
|
|
2
|
+
export { UsageMetricType } from '../chunk-BD3SMWUU.js';
|
|
3
|
+
export { AI_ASSISTANT_ACTOR_ORIGIN, UNIFIED_TRACKER_CONSTANTS, UnifiedTrackerStub, createProductTracker, isTrackedActorType, resolveAssistantSession, suppressMutationAudit, trackOperation, trackerStub } from '../chunk-JVMAQOA3.js';
|
|
4
|
+
import '../chunk-5CS3ZITV.js';
|
|
5
5
|
import '../chunk-E4QNLVY4.js';
|
|
6
6
|
import '../chunk-Y4N7N2G4.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-CFXWH2IS.js';
|
|
8
|
+
import '../chunk-726AR6Q7.js';
|
|
9
|
+
import '../chunk-SPRG6G6G.js';
|
|
10
10
|
import '../chunk-FZRODKIN.js';
|
|
11
11
|
import '../chunk-STWFX5E2.js';
|
|
12
12
|
import '../chunk-VFCMR5GX.js';
|
|
13
13
|
import '../chunk-RZOFS2BQ.js';
|
|
14
|
-
import '../chunk-
|
|
14
|
+
import '../chunk-QWNNFE4P.js';
|
|
15
15
|
import '../chunk-A5F6Z5UE.js';
|
|
16
16
|
import '../chunk-5SIL5AG2.js';
|
|
17
17
|
import '../chunk-5CAFHK2Z.js';
|
package/dist/usage/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { BillingUsageClient, QuotaPeriod, UsageMetricType, UsageModule } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { BillingUsageClient, QuotaPeriod, UsageMetricType, UsageModule } from '../chunk-BD3SMWUU.js';
|
|
2
|
+
import '../chunk-CFXWH2IS.js';
|
|
3
|
+
import '../chunk-726AR6Q7.js';
|
|
4
|
+
import '../chunk-SPRG6G6G.js';
|
|
5
5
|
import '../chunk-FZRODKIN.js';
|
|
6
6
|
import '../chunk-STWFX5E2.js';
|
|
7
7
|
import '../chunk-VFCMR5GX.js';
|
|
8
8
|
import '../chunk-RZOFS2BQ.js';
|
|
9
|
-
import '../chunk-
|
|
9
|
+
import '../chunk-QWNNFE4P.js';
|
|
10
10
|
import '../chunk-A5F6Z5UE.js';
|
|
11
11
|
import '../chunk-5SIL5AG2.js';
|
|
12
12
|
import '../chunk-5CAFHK2Z.js';
|
package/dist/validation/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DEFAULT_MAX_RBAC_ARG_PATH_SEGMENTS, DEFAULT_RBAC_ROOT_TYPES, MAX_BILLING_AMOUNT, NAME_MAX_LENGTH, NAME_MIN_LENGTH, RBAC_GATED_SCOPE_TYPES, RBAC_SCOPE_TYPES, RbacCoverageError, SUPPORTED_BILLING_CURRENCIES, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, analyzeRbacCoverage, assertRbacCoverage, convertBillingToMinorUnits, isSupportedBillingCurrency, lengthInCodePoints, loadRbacSchemaDocuments, rbacArgPathProblem, readRbacDirectiveArgs, validateBillingAmount, validateBillingMoney, validateName, validateUserFields, validateUsername } from '../chunk-
|
|
1
|
+
export { DEFAULT_MAX_RBAC_ARG_PATH_SEGMENTS, DEFAULT_RBAC_ROOT_TYPES, MAX_BILLING_AMOUNT, NAME_MAX_LENGTH, NAME_MIN_LENGTH, RBAC_GATED_SCOPE_TYPES, RBAC_SCOPE_TYPES, RbacCoverageError, SUPPORTED_BILLING_CURRENCIES, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, analyzeRbacCoverage, assertRbacCoverage, convertBillingToMinorUnits, isSupportedBillingCurrency, lengthInCodePoints, loadRbacSchemaDocuments, rbacArgPathProblem, readRbacDirectiveArgs, validateBillingAmount, validateBillingMoney, validateName, validateUserFields, validateUsername } from '../chunk-PYD44IHJ.js';
|
|
2
2
|
import '../chunk-XE4OXN2W.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/be-sdk",
|
|
3
|
-
"version": "2026.1107.
|
|
3
|
+
"version": "2026.1107.3",
|
|
4
4
|
"description": "Backend SDK for Burdenoff products providing unified access to notifications, RBAC, activity tracking, usage monitoring, and more",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -73,28 +73,28 @@
|
|
|
73
73
|
"scripts": {
|
|
74
74
|
"lake:registry:migrate": "bunx prisma migrate deploy --config prisma.lake.config.ts",
|
|
75
75
|
"lake:grant:timecampus": "bun scripts/lake-grant-timecampus.ts",
|
|
76
|
-
"deps:check": "
|
|
77
|
-
"deps:npm": "
|
|
78
|
-
"deps:status": "
|
|
79
|
-
"deps:workspace": "
|
|
80
|
-
"dev": "
|
|
76
|
+
"deps:check": "boff deps-mode check",
|
|
77
|
+
"deps:npm": "boff deps-mode remote",
|
|
78
|
+
"deps:status": "boff deps-mode status",
|
|
79
|
+
"deps:workspace": "boff deps-mode local",
|
|
80
|
+
"dev": "bun --watch ./src/index.ts",
|
|
81
81
|
"build": "bash scripts/with-private-swc-cache.sh env NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/init/index.ts src/logger/index.ts src/cache/index.ts src/database/index.ts src/event-queue/index.ts src/lifecycle/index.ts src/graph/index.ts src/middleware/index.ts src/observability/index.ts src/graphql/index.ts src/graphql/services/index.ts src/prisma/index.ts src/utils/index.ts src/notifications/index.ts src/tracker/index.ts src/export/index.ts src/dataloader/index.ts src/prisma/generator/index.ts src/server/index.ts src/i18n/index.ts src/instrumentation/index.ts src/rbac/index.ts src/temporal/index.ts src/client/internal-client.ts src/layer/index.ts src/gateway/index.ts src/gateway/security/index.ts src/crypto/index.ts src/feature-flags/index.ts src/telemetry/index.ts src/auth/index.ts src/captcha/index.ts src/metrics/index.ts src/platform/index.ts src/resource-caps/index.ts src/sharding/index.ts src/sharing/index.ts src/validation/index.ts src/tags/index.ts src/files/index.ts src/ai-credits/index.ts src/product-alias/index.ts src/lake/index.ts src/usage/index.ts --format esm --dts --clean --shims && bun run pack:tgz",
|
|
82
82
|
"build:watch": "bash scripts/with-private-swc-cache.sh tsup src/index.ts src/init/index.ts src/logger/index.ts src/cache/index.ts src/database/index.ts src/event-queue/index.ts src/lifecycle/index.ts src/graph/index.ts src/middleware/index.ts src/observability/index.ts src/graphql/index.ts src/graphql/services/index.ts src/prisma/index.ts src/utils/index.ts src/notifications/index.ts src/tracker/index.ts src/export/index.ts src/dataloader/index.ts src/prisma/generator/index.ts src/server/index.ts src/i18n/index.ts src/instrumentation/index.ts src/rbac/index.ts src/temporal/index.ts src/client/internal-client.ts src/layer/index.ts src/gateway/index.ts src/gateway/security/index.ts src/crypto/index.ts src/feature-flags/index.ts src/telemetry/index.ts src/auth/index.ts src/captcha/index.ts src/metrics/index.ts src/platform/index.ts src/resource-caps/index.ts src/sharding/index.ts src/sharing/index.ts src/validation/index.ts src/tags/index.ts src/files/index.ts src/ai-credits/index.ts src/product-alias/index.ts src/lake/index.ts --format esm --dts --watch --shims",
|
|
83
|
-
"typecheck": "bash scripts/build-limits.sh tsc --noEmit",
|
|
84
83
|
"lint": "eslint ./src",
|
|
85
|
-
"lint:sanity": "if [ \"${CI:-}\" = \"true\" ]; then bun run lint; else bun run lint -- --cache --cache-location .eslintcache; fi",
|
|
86
84
|
"lint:fix": "eslint ./src --fix",
|
|
87
|
-
"format": "
|
|
88
|
-
"format:check": "
|
|
85
|
+
"format": "bun fmt src tests scripts",
|
|
86
|
+
"format:check": "bun fmt --check src tests scripts",
|
|
89
87
|
"test": "bun test",
|
|
90
88
|
"test:watch": "bun test --watch",
|
|
91
|
-
"test:coverage": "
|
|
89
|
+
"test:coverage": "boff coverage-gate --run-tests",
|
|
92
90
|
"test:live-pg": "bunx prisma generate --schema tests/live-pg/rls-transactions/schema.prisma && bun test tests/live-pg",
|
|
93
91
|
"test:ci": "bun run test",
|
|
94
92
|
"audit": "bun audit --ignore=GHSA-g3hv-75wg-m249",
|
|
95
|
-
"sanity": "
|
|
93
|
+
"sanity": "boff sanity",
|
|
96
94
|
"prepublishOnly": "bun run build",
|
|
97
|
-
"pack:tgz": "mkdir -p dist && rm -rf dist/burdenoff-be-sdk.tgz && bun pm pack --filename dist/burdenoff-be-sdk.tgz"
|
|
95
|
+
"pack:tgz": "mkdir -p dist && rm -rf dist/burdenoff-be-sdk.tgz && bun pm pack --filename dist/burdenoff-be-sdk.tgz",
|
|
96
|
+
"type:check": "boff gate -- bun check --no-pretty",
|
|
97
|
+
"sanity:force": "boff sanity --force"
|
|
98
98
|
},
|
|
99
99
|
"keywords": [
|
|
100
100
|
"burdenoff",
|
|
@@ -120,11 +120,11 @@
|
|
|
120
120
|
"homepage": "https://github.com/algoshred/burdenoff-be-sdk-node#readme",
|
|
121
121
|
"engines": {
|
|
122
122
|
"node": ">=20.0.0",
|
|
123
|
-
"bun": ">=1.
|
|
123
|
+
"bun": ">=1.4.4"
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
126
|
"@graphql-yoga/logger": "^2.0.2",
|
|
127
|
-
"@prisma/generator-helper": "^7.10.
|
|
127
|
+
"@prisma/generator-helper": "^7.10.1",
|
|
128
128
|
"@sinclair/typebox": "^0.34.52",
|
|
129
129
|
"@valkey/valkey-glide": "^2.5.3",
|
|
130
130
|
"jsonwebtoken": "^9.0.3"
|
|
@@ -197,43 +197,35 @@
|
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
"devDependencies": {
|
|
200
|
-
"@
|
|
201
|
-
"@
|
|
200
|
+
"@burdenoff/toolchain": "2026.1107.3",
|
|
201
|
+
"@clickhouse/client": "^1.25.0",
|
|
202
|
+
"@elysiajs/cors": "^1.4.3",
|
|
202
203
|
"@envelop/graphql-modules": "9.1.1",
|
|
203
|
-
"@
|
|
204
|
-
"@graphql-yoga/plugin-
|
|
205
|
-
"@
|
|
206
|
-
"@prisma/
|
|
207
|
-
"@
|
|
208
|
-
"@
|
|
209
|
-
"@temporalio/
|
|
210
|
-
"@temporalio/
|
|
211
|
-
"@
|
|
212
|
-
"@types/bun": "^1.4.2",
|
|
204
|
+
"@graphql-yoga/plugin-apollo-inline-trace": "^3.24.6",
|
|
205
|
+
"@graphql-yoga/plugin-prometheus": "^6.19.6",
|
|
206
|
+
"@prisma/adapter-pg": "7.10.1",
|
|
207
|
+
"@prisma/client": "7.10.1",
|
|
208
|
+
"@swc/core": "^1.16.22",
|
|
209
|
+
"@temporalio/client": "^1.25.0",
|
|
210
|
+
"@temporalio/common": "^1.25.0",
|
|
211
|
+
"@temporalio/worker": "^1.25.0",
|
|
212
|
+
"@types/bun": "^1.4.4",
|
|
213
213
|
"@types/jsonwebtoken": "^9.0.10",
|
|
214
|
-
"@types/node": "^
|
|
214
|
+
"@types/node": "^26.6.6",
|
|
215
215
|
"@types/pg": "^8.23.1",
|
|
216
|
-
"arangojs": "^10.
|
|
217
|
-
"elysia": "^1.4.
|
|
216
|
+
"arangojs": "^10.6.0",
|
|
217
|
+
"elysia": "^1.4.31",
|
|
218
218
|
"eslint": "^9.39.5",
|
|
219
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
220
|
-
"eslint-plugin-import": "^2.32.0",
|
|
221
|
-
"eslint-plugin-security": "^3.0.1",
|
|
222
|
-
"eslint-plugin-sonarjs": "4.2.2",
|
|
223
|
-
"globals": "^16.5.0",
|
|
224
219
|
"graphql": "16.12.0",
|
|
225
|
-
"graphql-modules": "3.1.
|
|
220
|
+
"graphql-modules": "3.1.2",
|
|
226
221
|
"ioredis": "^5.11.1",
|
|
227
|
-
"jose": "^6.2.
|
|
228
|
-
"lefthook": "^2.
|
|
222
|
+
"jose": "^6.2.15",
|
|
223
|
+
"lefthook": "^2.2.2",
|
|
229
224
|
"pg": "^8.23.1",
|
|
230
|
-
"
|
|
231
|
-
"prisma": "^7.10.0",
|
|
225
|
+
"prisma": "7.10.1",
|
|
232
226
|
"prom-client": "^15.1.3",
|
|
233
227
|
"tsup": "^8.5.1",
|
|
234
|
-
"
|
|
235
|
-
"typescript": "^5.9.3",
|
|
236
|
-
"typescript-eslint": "^8.71.0"
|
|
228
|
+
"typescript": "^5.9.3"
|
|
237
229
|
},
|
|
238
230
|
"publishConfig": {
|
|
239
231
|
"access": "public"
|
|
@@ -255,5 +247,35 @@
|
|
|
255
247
|
},
|
|
256
248
|
"resolutions": {
|
|
257
249
|
"graphql": "16.12.0"
|
|
258
|
-
}
|
|
250
|
+
},
|
|
251
|
+
"packageManager": "bun@1.4.4",
|
|
252
|
+
"boff": {
|
|
253
|
+
"type": "be-sdk",
|
|
254
|
+
"sanity": {
|
|
255
|
+
"formatPaths": [
|
|
256
|
+
"src",
|
|
257
|
+
"tests",
|
|
258
|
+
"scripts"
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
"coverage": {
|
|
262
|
+
"global": 55,
|
|
263
|
+
"diff": 80,
|
|
264
|
+
"exclude": [
|
|
265
|
+
"configs/**"
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
"scripts": {
|
|
269
|
+
"unmanaged": [
|
|
270
|
+
"lint",
|
|
271
|
+
"audit"
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"trustedDependencies": [
|
|
276
|
+
"@prisma/engines",
|
|
277
|
+
"esbuild",
|
|
278
|
+
"lefthook",
|
|
279
|
+
"prisma"
|
|
280
|
+
]
|
|
259
281
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { EventQueueFactory, resolveQueueType } from './chunk-DXCWPTKC.js';
|
|
2
|
-
import './chunk-KS2HQCJR.js';
|
|
3
|
-
import './chunk-6XEXJATV.js';
|
|
4
|
-
import './chunk-KO2ZXZ7W.js';
|
|
5
|
-
import './chunk-RU266375.js';
|
|
6
|
-
import './chunk-XE4OXN2W.js';
|
|
7
|
-
//# sourceMappingURL=EventQueueFactory-PEYWB2RY.js.map
|
|
8
|
-
//# sourceMappingURL=EventQueueFactory-PEYWB2RY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notifications/tenant-notifications.ts","../src/notifications/index.ts"],"names":["NotificationChannel","NotificationPriority","NotificationType","TenantNotificationsModule","client","context","send","input","validateSendInput","notification","createNotificationInput","callContext","scheduledFor","response","tenantQuery","toISOString","timezone","recipient","result","scheduleNotification","notificationId","status","APIError","operation","platform","channel","includeInApp","triggerNotification","id","includes","logger","info","priority","type","subject","body","htmlBody","data","metadata","expiresAt","trackOpens","trackClicks","sendWithTemplate","templateSlug","trim","length","ValidationError","variables","Array","isArray","email","userId","validateDates","mutation","channelId","triggerNotificationWithTemplate","firstNotification","notifications","totalTriggered","totalRequested","totalFailed","sendBatch","schedules","Set","map","size","batchSize","undefined","Number","isInteger","delayBetweenBatches","triggerBatchNotifications","batchId","getNotification","query","getNotifications","filter","startDate","endDate","limit","offset","items","getTemplate","slug","locale","notificationTemplate","getTemplates","templates","seen","page","notificationTemplates","hasMore","template","has","add","push","getStats","notificationStats","markAsRead","notificationIds","success","markNotificationsAsRead","count","markAllAsRead","markAllMyNotificationsAsRead","deleteNotifications","deleteAllReadNotifications","deleteMyReadNotifications","Object","values","recipientKeys","EMAIL","SMS","PUSH","IN_APP","WEBHOOK","WHATSAPP","TEAMS","SLACK","TELEGRAM","DISCORD","some","key","value","Date","isFinite","getTime","mapNotificationType","resolveChannel","options","sms","NotificationsModule","title","message","userIds","userCount","errors","results","Promise","allSettled","redirectUrl","appName","Error","index","settled","entries","reason","String","successCount","failureCount","sendToUser","debug","search","markMultipleAsRead","deleteNotification","deleteMultiple","getUnreadCount","unreadCount","sendChannelNotification","recipients","recipientCount","inAppUserCount","forEach","error","sendTemplateNotification","n"],"mappings":";;;;;AAAA,IAAA,4BAAA,GAAA;;;;;;;AAcO,IAAKA,mBAAAA,6BAAAA,oBAAAA,EAAAA;;;;;;;;;;;AAAAA,EA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A,eAAAA,EAAiBjF,MAAAA,CAAOiF;OAC1B,CAAA;AAEA,MAAA,OAAOjF,MAAAA;AACT,IAAA,CAAA,CAAA,OAASiJ,KAAAA,EAAO;AACdrI,MAAAA,MAAAA,CAAOqI,MAAM,sDAAA,EAAwD;AAAEA,QAAAA;OAAM,CAAA;AAE7E,MAAA,OAAO;QACLf,YAAAA,EAAc,CAAA;QACdC,YAAAA,EAAc,CAAA;QACdb,MAAAA,EAAQ;UAAC2B,KAAAA,YAAiBrB,KAAAA,GAAQqB,MAAM9B,OAAAA,GAAU;;AAClDlC,QAAAA,eAAAA,EAAiB;AACnB,OAAA;AACF,IAAA;AACF,EAAA;AACF","file":"chunk-23WAZL7I.js","sourcesContent":["/**\n * Tenant-Backend Notifications Module\n * Comprehensive notification system supporting 10+ channels via tenant-backend\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { APIError, ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\n\n// ========================================\n// Enums\n// ========================================\n\nexport enum NotificationChannel {\n EMAIL = 'EMAIL',\n SMS = 'SMS',\n PUSH = 'PUSH',\n IN_APP = 'IN_APP',\n WEBHOOK = 'WEBHOOK',\n WHATSAPP = 'WHATSAPP',\n TEAMS = 'TEAMS',\n SLACK = 'SLACK',\n TELEGRAM = 'TELEGRAM',\n DISCORD = 'DISCORD',\n}\n\nexport enum NotificationPriority {\n LOW = 'LOW',\n MEDIUM = 'MEDIUM',\n HIGH = 'HIGH',\n URGENT = 'URGENT',\n}\n\nexport enum NotificationType {\n TRANSACTIONAL = 'TRANSACTIONAL',\n MARKETING = 'MARKETING',\n SYSTEM = 'SYSTEM',\n ALERT = 'ALERT',\n}\n\n// ========================================\n// Types & Interfaces\n// ========================================\n\nexport interface RecipientInput {\n userId?: string;\n email?: string;\n phoneNumber?: string;\n pushToken?: string;\n whatsappNumber?: string;\n teamsUserId?: string;\n slackUserId?: string;\n webhookUrl?: string;\n name?: string;\n locale?: string;\n timezone?: string;\n}\n\nexport interface SendNotificationInput {\n recipient: RecipientInput;\n channel: NotificationChannel;\n type?: NotificationType;\n priority?: NotificationPriority;\n subject?: string;\n body: string;\n htmlBody?: string;\n data?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n scheduledFor?: Date;\n expiresAt?: Date;\n trackOpens?: boolean;\n trackClicks?: boolean;\n}\n\nexport interface SendWithTemplateInput {\n templateSlug: string;\n variables: Record<string, unknown>;\n recipient: RecipientInput;\n priority?: NotificationPriority;\n scheduledFor?: Date;\n expiresAt?: Date;\n trackOpens?: boolean;\n trackClicks?: boolean;\n /** Specific channel instance ID from channel service (takes precedence) */\n channelId?: string;\n /** Platform type for auto-failover (EMAIL, SMS, etc.) - used if channelId not provided */\n platform?: NotificationChannel;\n /** Timezone for scheduling */\n timezone?: string;\n}\n\nexport interface BatchNotificationInput {\n notifications: SendNotificationInput[];\n batchSize?: number;\n delayBetweenBatches?: number;\n priority?: NotificationPriority;\n}\n\nexport interface Notification {\n id: string;\n userId: string;\n channel: NotificationChannel;\n type: NotificationType;\n priority: NotificationPriority;\n status: string;\n deliveryStatus?: string;\n title: string;\n message: string;\n htmlMessage?: string;\n subject?: string;\n recipientEmail?: string;\n recipientPhone?: string;\n trackOpens: boolean;\n trackClicks: boolean;\n openedAt?: string;\n clickedAt?: string;\n sentAt?: string;\n deliveredAt?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NotificationTemplate {\n id: string;\n name: string;\n slug: string;\n description?: string;\n channel: NotificationChannel;\n type: NotificationType;\n locale: string;\n subject?: string;\n bodyTemplate: string;\n htmlTemplate?: string;\n variables: Array<{\n name: string;\n type: string;\n required: boolean;\n defaultValue?: unknown;\n description?: string;\n example?: unknown;\n }>;\n enabled: boolean;\n version: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NotificationStats {\n total: number;\n pending: number;\n /** @deprecated The owner does not publish a queued counter. */\n queued?: number;\n /** @deprecated The owner does not publish a processing counter. */\n processing?: number;\n triggered: number;\n scheduled: number;\n cancelled: number;\n sent: number;\n delivered: number;\n failed: number;\n byChannel: Record<string, number>;\n byType: Record<string, number>;\n}\n\n// ========================================\n// Tenant Notifications Module\n// ========================================\n\n/**\n * Tenant-Backend Notifications Module\n * Provides access to the centralized notification system\n */\nexport class TenantNotificationsModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Send a single notification\n */\n public async send(input: SendNotificationInput, context?: SDKContext): Promise<string> {\n this.validateSendInput(input);\n const notification = this.createNotificationInput(input);\n const callContext = { ...this.context, ...context };\n\n if (input.scheduledFor) {\n const response = await this.client.tenantQuery<{\n scheduleNotification: { notificationId: string; status: string };\n }>(\n `mutation ScheduleTenantNotification($input: ScheduleNotificationInput!) {\n scheduleNotification(input: $input) { notificationId status }\n }`,\n { input: { notification, scheduledFor: input.scheduledFor.toISOString(), timezone: input.recipient.timezone } },\n callContext\n );\n const result = response.scheduleNotification;\n if (!result?.notificationId || result.status !== 'PENDING') {\n throw new APIError('Notification scheduling was not acknowledged', { operation: 'scheduleNotification' });\n }\n return result.notificationId;\n }\n\n const response = await this.client.tenantQuery<{\n triggerNotification: { id: string; status: string; channel: NotificationChannel };\n }>(\n `mutation TriggerTenantNotification($input: TriggerNotificationInput!) {\n triggerNotification(input: $input) { id status channel }\n }`,\n { input: { notification, platform: input.channel, includeInApp: false } },\n callContext\n );\n const result = response.triggerNotification;\n if (\n !result?.id ||\n result.channel !== input.channel ||\n !['TRIGGERED', 'SENT', 'DELIVERED'].includes(result.status)\n ) {\n throw new APIError('Notification trigger was not acknowledged', {\n operation: 'triggerNotification',\n notificationId: result?.id,\n });\n }\n logger.info('[TenantNotifications] Notification accepted', {\n notificationId: result.id,\n channel: result.channel,\n status: result.status,\n });\n return result.id;\n }\n\n /** Owner input deliberately excludes scheduling, which has a separate API. */\n private createNotificationInput(input: SendNotificationInput, priority?: NotificationPriority) {\n return {\n recipient: input.recipient,\n channel: input.channel,\n type: input.type ?? NotificationType.TRANSACTIONAL,\n priority: input.priority ?? priority ?? NotificationPriority.MEDIUM,\n subject: input.subject,\n body: input.body,\n htmlBody: input.htmlBody,\n data: input.data,\n metadata: input.metadata,\n expiresAt: input.expiresAt?.toISOString(),\n trackOpens: input.trackOpens,\n trackClicks: input.trackClicks,\n };\n }\n\n /**\n * Send notification using a template\n */\n public async sendWithTemplate(input: SendWithTemplateInput, context?: SDKContext): Promise<string> {\n // Validate inputs\n if (!input.templateSlug || input.templateSlug.trim().length === 0) {\n throw new ValidationError('Template slug is required');\n }\n\n if (!input.variables || typeof input.variables !== 'object' || Array.isArray(input.variables)) {\n throw new ValidationError('Template variables must be an object');\n }\n\n if (!input.recipient || (!input.recipient.email && !input.recipient.userId)) {\n throw new ValidationError('Recipient email or userId is required');\n }\n\n this.validateDates(input);\n\n logger.info('[TenantNotifications] Sending notification with template', {\n templateSlug: input.templateSlug,\n priority: input.priority || NotificationPriority.MEDIUM,\n });\n\n const mutation = `\n mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {\n triggerNotificationWithTemplate(input: $input) {\n totalRequested\n totalTriggered\n totalFailed\n notifications {\n id\n status\n deliveryStatus\n }\n }\n }\n `;\n\n const variables = {\n input: {\n templateSlug: input.templateSlug,\n variables: input.variables,\n recipient: input.recipient,\n priority: input.priority || NotificationPriority.MEDIUM,\n scheduledFor: input.scheduledFor?.toISOString(),\n expiresAt: input.expiresAt?.toISOString(),\n trackOpens: input.trackOpens,\n trackClicks: input.trackClicks,\n // Platform is required for notification delivery routing\n // If channelId is specified, it takes precedence; otherwise platform determines delivery\n channelId: input.channelId,\n platform: input.platform || NotificationChannel.EMAIL,\n timezone: input.timezone,\n },\n };\n\n const response = await this.client.tenantQuery<{\n triggerNotificationWithTemplate: {\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n notifications: Array<{ id: string; status: string; deliveryStatus?: string }>;\n };\n }>(mutation, variables, { ...this.context, ...context });\n\n const result = response.triggerNotificationWithTemplate;\n const firstNotification = result.notifications[0];\n\n if (result.totalTriggered === 0 || !firstNotification) {\n throw new ValidationError(\n `Notification trigger failed: requested=${result.totalRequested}, triggered=${result.totalTriggered}, failed=${result.totalFailed}`\n );\n }\n\n logger.info('[TenantNotifications] Notification sent with template', {\n notificationId: firstNotification.id,\n status: firstNotification.status,\n totalTriggered: result.totalTriggered,\n totalFailed: result.totalFailed,\n });\n\n return firstNotification.id;\n }\n\n /**\n * Send batch notifications\n */\n public async sendBatch(\n input: BatchNotificationInput,\n context?: SDKContext\n ): Promise<{\n totalRequested: number;\n /** Legacy name for the owner's accepted totalTriggered counter, not final delivery. */\n totalQueued: number;\n totalFailed: number;\n batchId: string;\n }> {\n if (!input.notifications?.length) throw new ValidationError('At least one notification is required');\n for (const notification of input.notifications) this.validateSendInput(notification);\n const schedules = new Set(\n input.notifications.map((notification) => notification.scheduledFor?.toISOString() ?? '')\n );\n if (schedules.size > 1) {\n throw new ValidationError('Batch notifications must share a schedule; use send() for distinct schedules');\n }\n if (input.batchSize !== undefined && (!Number.isInteger(input.batchSize) || input.batchSize <= 0)) {\n throw new ValidationError('Batch size must be a positive integer');\n }\n if (\n input.delayBetweenBatches !== undefined &&\n (!Number.isInteger(input.delayBetweenBatches) || input.delayBetweenBatches < 0)\n ) {\n throw new ValidationError('Batch delay must be a nonnegative integer');\n }\n const response = await this.client.tenantQuery<{\n triggerBatchNotifications: { totalRequested: number; totalQueued: number; totalFailed: number; batchId: string };\n }>(\n `mutation TriggerTenantBatchNotifications($input: TriggerBatchNotificationsInput!) {\n triggerBatchNotifications(input: $input) { totalRequested totalQueued: totalTriggered totalFailed batchId }\n }`,\n {\n input: {\n notifications: input.notifications.map((notification) =>\n this.createNotificationInput(notification, input.priority)\n ),\n priority: input.priority,\n scheduledFor: input.notifications[0]?.scheduledFor?.toISOString(),\n batchSize: input.batchSize,\n delayBetweenBatches: input.delayBetweenBatches,\n },\n },\n { ...this.context, ...context }\n );\n const result = response.triggerBatchNotifications;\n if (!result?.batchId)\n throw new APIError('Notification batch was not acknowledged', { operation: 'triggerBatchNotifications' });\n return result;\n }\n\n /**\n * Get a notification by ID\n */\n public async getNotification(id: string): Promise<Notification | null> {\n const query = `\n query GetNotification($id: ID!) {\n notification(id: $id) {\n id\n userId\n channel\n type\n priority\n status\n deliveryStatus\n title\n message\n htmlMessage\n subject\n recipientEmail\n recipientPhone\n trackOpens\n trackClicks\n openedAt\n clickedAt\n sentAt\n deliveredAt\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notification: Notification | null;\n }>(query, { id }, this.context);\n\n return response.notification;\n }\n\n /**\n * Get notifications with filters\n */\n public async getNotifications(filter?: {\n userId?: string;\n channel?: NotificationChannel;\n type?: NotificationType;\n status?: string;\n priority?: NotificationPriority;\n startDate?: Date;\n endDate?: Date;\n limit?: number;\n offset?: number;\n }): Promise<Notification[]> {\n const query = `\n query GetNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {\n notifications(filter: $filter, limit: $limit, offset: $offset) {\n items {\n id\n userId\n channel\n type\n priority\n status\n deliveryStatus\n title\n message\n subject\n recipientEmail\n trackOpens\n trackClicks\n openedAt\n clickedAt\n sentAt\n deliveredAt\n createdAt\n updatedAt\n }\n }\n }\n `;\n\n const variables = {\n filter: filter\n ? {\n userId: filter.userId,\n channel: filter.channel,\n type: filter.type,\n status: filter.status,\n priority: filter.priority,\n startDate: filter.startDate?.toISOString(),\n endDate: filter.endDate?.toISOString(),\n }\n : undefined,\n limit: filter?.limit ?? 50,\n offset: filter?.offset ?? 0,\n };\n\n const response = await this.client.tenantQuery<{\n notifications: { items: Notification[] };\n }>(query, variables, this.context);\n\n return response.notifications.items;\n }\n\n /**\n * Get notification template\n */\n public async getTemplate(slug: string, locale?: string): Promise<NotificationTemplate | null> {\n const query = `\n query GetNotificationTemplate($slug: String!, $locale: String) {\n notificationTemplate(slug: $slug, locale: $locale) {\n id\n name\n slug\n description\n channel\n type\n locale\n subject\n bodyTemplate\n htmlTemplate\n variables\n enabled\n version\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notificationTemplate: NotificationTemplate | null;\n }>(query, { slug, locale }, this.context);\n\n return response.notificationTemplate;\n }\n\n /**\n * Get all notification templates\n */\n public async getTemplates(filter?: {\n channel?: NotificationChannel;\n type?: NotificationType;\n enabled?: boolean;\n }): Promise<NotificationTemplate[]> {\n const query = `query GetNotificationTemplates($filter: TemplateFilterInput, $limit: Int!, $offset: Int!) {\n notificationTemplates(filter: $filter, limit: $limit, offset: $offset) {\n items { id name slug description channel type locale subject bodyTemplate htmlTemplate variables enabled version createdAt updatedAt }\n hasMore\n }\n }`;\n const templates: NotificationTemplate[] = [];\n const seen = new Set<string>();\n for (let page = 0; page < 100; page++) {\n const response = await this.client.tenantQuery<{\n notificationTemplates: { items: NotificationTemplate[]; hasMore: boolean };\n }>(query, { filter, limit: 100, offset: templates.length }, this.context);\n const result = response.notificationTemplates;\n if (!result || !Array.isArray(result.items) || typeof result.hasMore !== 'boolean') {\n throw new APIError('Notification template page was invalid', { operation: 'notificationTemplates' });\n }\n for (const template of result.items) {\n if (!template.id || seen.has(template.id)) {\n throw new APIError('Notification template pagination did not progress', {\n operation: 'notificationTemplates',\n });\n }\n seen.add(template.id);\n templates.push(template);\n }\n if (!result.hasMore) return templates;\n if (!result.items.length) {\n throw new APIError('Notification template pagination did not progress', { operation: 'notificationTemplates' });\n }\n }\n throw new APIError('Notification template pagination exceeded its bounded limit', {\n operation: 'notificationTemplates',\n });\n }\n\n /**\n * Get notification statistics\n */\n public async getStats(filter?: { userId?: string; startDate?: Date; endDate?: Date }): Promise<NotificationStats> {\n const query = `\n query GetNotificationStats($filter: NotificationFilterInput) {\n notificationStats(filter: $filter) {\n total\n pending\n triggered\n scheduled\n cancelled\n sent\n delivered\n failed\n byChannel\n byType\n }\n }\n `;\n\n const variables = {\n filter: filter\n ? {\n userId: filter.userId,\n startDate: filter.startDate?.toISOString(),\n endDate: filter.endDate?.toISOString(),\n }\n : undefined,\n };\n\n const response = await this.client.tenantQuery<{\n notificationStats: NotificationStats;\n }>(query, variables, this.context);\n\n return response.notificationStats;\n }\n\n /**\n * Mark notifications as read\n */\n public async markAsRead(notificationIds: string[]): Promise<boolean> {\n const mutation = `\n mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {\n markNotificationsAsRead(notificationIds: $notificationIds) { success count failedIds }\n }\n `;\n\n const result = await this.client.tenantQuery<{ markNotificationsAsRead: { success: boolean } }>(\n mutation,\n { notificationIds },\n this.context\n );\n\n logger.info('[TenantNotifications] Read request completed', {\n success: result.markNotificationsAsRead.success,\n count: notificationIds.length,\n });\n\n return result.markNotificationsAsRead.success;\n }\n\n /**\n * Mark all notifications as read for the current user\n */\n public async markAllAsRead(): Promise<boolean> {\n const mutation = `\n mutation MarkAllMyNotificationsAsRead {\n markAllMyNotificationsAsRead { success count failedIds }\n }\n `;\n\n const result = await this.client.tenantQuery<{ markAllMyNotificationsAsRead: { success: boolean } }>(\n mutation,\n {},\n this.context\n );\n\n logger.info('[TenantNotifications] Read-all request completed', {\n success: result.markAllMyNotificationsAsRead.success,\n });\n\n return result.markAllMyNotificationsAsRead.success;\n }\n\n /**\n * Delete notifications\n */\n public async deleteNotifications(notificationIds: string[]): Promise<boolean> {\n const mutation = `\n mutation DeleteNotifications($notificationIds: [ID!]!) {\n deleteNotifications(notificationIds: $notificationIds)\n }\n `;\n\n const result = await this.client.tenantQuery<{ deleteNotifications: boolean }>(\n mutation,\n { notificationIds },\n this.context\n );\n\n logger.info('[TenantNotifications] Delete request completed', {\n success: result.deleteNotifications,\n count: notificationIds.length,\n });\n\n return result.deleteNotifications;\n }\n\n /**\n * Delete all read notifications for the current user\n */\n public async deleteAllReadNotifications(): Promise<boolean> {\n const mutation = `\n mutation DeleteMyReadNotifications {\n deleteMyReadNotifications\n }\n `;\n\n const result = await this.client.tenantQuery<{ deleteMyReadNotifications: boolean }>(mutation, {}, this.context);\n\n logger.info('[TenantNotifications] Delete-read request completed', { success: result.deleteMyReadNotifications });\n\n return result.deleteMyReadNotifications;\n }\n\n /**\n * Validate send notification input\n */\n private validateSendInput(input: SendNotificationInput): void {\n if (!Object.values(NotificationChannel).includes(input.channel)) {\n throw new ValidationError('A supported notification channel is required');\n }\n const recipientKeys: Record<NotificationChannel, Array<keyof RecipientInput>> = {\n EMAIL: ['email', 'userId'],\n SMS: ['phoneNumber', 'userId'],\n PUSH: ['pushToken', 'userId'],\n IN_APP: ['userId'],\n WEBHOOK: ['webhookUrl', 'userId'],\n WHATSAPP: ['whatsappNumber', 'phoneNumber', 'userId'],\n TEAMS: ['teamsUserId', 'userId'],\n SLACK: ['slackUserId', 'userId'],\n TELEGRAM: ['userId'],\n DISCORD: ['userId'],\n };\n if (\n !input.recipient ||\n !recipientKeys[input.channel].some((key) => {\n const value = input.recipient[key];\n return typeof value === 'string' && value.trim().length > 0;\n })\n )\n throw new ValidationError('A recipient address or userId appropriate for the channel is required');\n if (typeof input.body !== 'string' || input.body.trim().length === 0) {\n throw new ValidationError('Notification body is required');\n }\n this.validateDates(input);\n }\n\n private validateDates(input: { scheduledFor?: Date; expiresAt?: Date }): void {\n for (const value of [input.scheduledFor, input.expiresAt]) {\n if (value != null && (!(value instanceof Date) || !Number.isFinite(value.getTime()))) {\n throw new ValidationError('Notification dates must be valid Date values');\n }\n }\n if (input.scheduledFor && input.expiresAt && input.expiresAt <= input.scheduledFor) {\n throw new ValidationError('Notification expiry must follow its scheduled delivery');\n }\n }\n}\n","/**\n * Notifications Module\n * Send in-app, email, SMS, and push notifications via workspaces-backend\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\n\nexport enum NotificationType {\n INFO = 'info',\n SUCCESS = 'success',\n WARNING = 'warning',\n ERROR = 'error',\n}\n\nexport enum NotificationChannel {\n EMAIL = 'EMAIL',\n SMS = 'SMS',\n WHATSAPP = 'WHATSAPP',\n PUSH = 'PUSH',\n SLACK = 'SLACK',\n TEAMS = 'TEAMS',\n WEBHOOK = 'WEBHOOK',\n}\n\n// Re-export from tenant-notifications\nexport {\n NotificationChannel as TenantNotificationChannel,\n NotificationType as TenantNotificationType,\n NotificationPriority,\n TenantNotificationsModule,\n} from './tenant-notifications.js';\nexport type {\n SendNotificationInput as TenantSendNotificationInput,\n SendWithTemplateInput as TenantSendWithTemplateInput,\n BatchNotificationInput as TenantBatchNotificationInput,\n} from './tenant-notifications.js';\n\nexport interface SendNotificationOptions {\n /** Notification title */\n title: string;\n /** Notification message */\n message: string;\n /** Notification type */\n type?: NotificationType;\n /** Target user IDs */\n userIds: string[];\n /** Optional redirect URL */\n redirectUrl?: string;\n /** Application name */\n appName?: string;\n /** Send email notification */\n email?: boolean;\n /** Send SMS notification */\n sms?: boolean;\n /** Structured event metadata retained by the notification owner. */\n metadata?: Record<string, unknown>;\n /** Additional application data retained by the notification owner. */\n data?: Record<string, unknown>;\n /** Optional absolute expiration time. */\n expiresAt?: Date;\n}\n\nexport interface NotificationResponse {\n /** Number of successful notifications */\n successCount: number;\n /** Number of failed notifications */\n failureCount: number;\n /** Error messages if any */\n errors: string[];\n /** Created notification IDs */\n notificationIds?: string[];\n}\n\nexport interface GetNotificationsOptions {\n /** User ID to get notifications for */\n userId: string;\n /** Filter by status */\n status?: 'unread' | 'read' | 'all';\n /** Filter by type */\n type?: NotificationType;\n /** Filter by app name */\n appName?: string;\n /** Search term */\n search?: string;\n /** Limit number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\nexport interface Notification {\n id: string;\n userId: string;\n title: string;\n message: string;\n type: NotificationType;\n status: 'unread' | 'read';\n redirectUrl?: string;\n appName?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RecipientInput {\n email?: string;\n locale?: string;\n name?: string;\n phoneNumber?: string;\n pushToken?: string;\n slackUserId?: string;\n teamsUserId?: string;\n timezone?: string;\n userId?: string;\n webhookUrl?: string;\n whatsappNumber?: string;\n}\n\nexport interface SendChannelNotificationOptions {\n /** Primary delivery channel (EMAIL, SMS, WHATSAPP, etc.) */\n platform: NotificationChannel;\n /** Recipient information for primary channel */\n recipient: RecipientInput;\n /** Multiple recipients for bulk delivery */\n recipients?: RecipientInput[];\n /** Notification subject (for EMAIL) */\n subject?: string;\n /** Notification body/message */\n body: string;\n /** HTML body (for EMAIL) */\n htmlBody?: string;\n /** Notification type */\n type?: NotificationType;\n /** Application name */\n appName?: string;\n /** Redirect URL */\n redirectUrl?: string;\n /** Also send as in-app notification */\n includeInApp?: boolean;\n /** User IDs for in-app notifications (required when includeInApp is true) */\n userIds?: string[];\n /** Additional metadata */\n metadata?: Record<string, unknown>;\n /** Track email opens */\n trackOpens?: boolean;\n /** Track link clicks */\n trackClicks?: boolean;\n /** Expiration time */\n expiresAt?: Date;\n /** Specific channel instance ID (overrides platform) */\n channelId?: string;\n}\n\nexport interface SendTemplateNotificationOptions {\n /** Primary delivery channel (EMAIL, SMS, WHATSAPP, etc.) */\n platform: NotificationChannel;\n /** Template slug to use */\n templateSlug: string;\n /** Template variables */\n variables: Record<string, unknown>;\n /** Recipient information for primary channel */\n recipient?: RecipientInput;\n /** Multiple recipients for bulk delivery */\n recipients?: RecipientInput[];\n /** Also send as in-app notification */\n includeInApp?: boolean;\n /** User IDs for in-app notifications (required when includeInApp is true) */\n userIds?: string[];\n /** Application name */\n appName?: string;\n /** Track email opens */\n trackOpens?: boolean;\n /** Track link clicks */\n trackClicks?: boolean;\n /** Expiration time */\n expiresAt?: Date;\n /** Scheduled delivery time */\n scheduledFor?: Date;\n /** Timezone for scheduling */\n timezone?: string;\n /** Specific channel instance ID (overrides platform) */\n channelId?: string;\n}\n\n/**\n * Map the SDK's severity-flavoured `NotificationType` (info/success/warning/error) onto\n * global-notification-svc's delivery-intent `NotificationType`\n * (ALERT | MARKETING | SYSTEM | TRANSACTIONAL).\n *\n * The two enums describe different things and share no values, so an unmapped value would be\n * rejected by the owner. Warnings and errors are alerts; everything else is transactional.\n */\nfunction mapNotificationType(type?: NotificationType): 'ALERT' | 'TRANSACTIONAL' {\n return type === NotificationType.WARNING || type === NotificationType.ERROR ? 'ALERT' : 'TRANSACTIONAL';\n}\n\n/**\n * Choose the delivery channel required by `CreateNotificationInput.channel` (non-nullable).\n *\n * `SendNotificationOptions` expresses channel intent as the legacy `email`/`sms` booleans; the\n * owner expects a single `NotificationChannel`. In-app is the default so a caller that sets\n * neither flag still gets a delivered, visible notification.\n */\nfunction resolveChannel(options: SendNotificationOptions): 'EMAIL' | 'SMS' | 'IN_APP' {\n if (options.email) return 'EMAIL';\n if (options.sms) return 'SMS';\n return 'IN_APP';\n}\n\n/**\n * Notifications Module\n */\nexport class NotificationsModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Send notification to users\n */\n public async send(options: SendNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.title || options.title.trim().length === 0) {\n throw new ValidationError('Notification title is required');\n }\n\n if (!options.message || options.message.trim().length === 0) {\n throw new ValidationError('Notification message is required');\n }\n\n if (!options.userIds || options.userIds.length === 0) {\n throw new ValidationError('At least one user ID is required');\n }\n if (options.expiresAt && (!(options.expiresAt instanceof Date) || !Number.isFinite(options.expiresAt.getTime()))) {\n throw new ValidationError('Notification expiry must be a valid Date');\n }\n\n logger.info('[Notifications] Sending notification', {\n userCount: options.userIds.length,\n type: options.type || NotificationType.INFO,\n });\n\n // `triggerNotification` both creates AND delivers. `createNotification` only persists —\n // its own schema doc says \"without triggering - use triggerNotification to send\" — so sending\n // through it would silently never deliver.\n const mutation = `\n mutation TriggerNotification($input: TriggerNotificationInput!) {\n triggerNotification(input: $input) {\n id\n status\n }\n }\n `;\n\n // global-notification-svc addresses ONE recipient per notification, so a multi-user send fans\n // out into one mutation per user rather than passing a `userIds` array (which the input does\n // not have). Failures are collected per recipient instead of rejecting the whole batch.\n const channel = resolveChannel(options);\n const notificationIds: string[] = [];\n const errors: string[] = [];\n\n const results = await Promise.allSettled(\n options.userIds.map(async (userId) => {\n const variables = {\n input: {\n notification: {\n recipient: { userId },\n channel,\n type: mapNotificationType(options.type),\n subject: options.title,\n body: options.message,\n metadata: options.metadata,\n data: options.data,\n expiresAt: options.expiresAt?.toISOString(),\n ...(options.redirectUrl ? { redirectUrl: options.redirectUrl } : {}),\n ...(options.appName ? { appName: options.appName } : {}),\n },\n platform: channel,\n // Always leave an in-app trace when the primary channel is external, so the\n // notification is visible in the product even if email/SMS delivery fails.\n includeInApp: channel !== 'IN_APP',\n },\n };\n\n const response = await this.client.tenantQuery<{\n triggerNotification: { id: string; status?: string };\n }>(mutation, variables, this.context);\n\n const id = response.triggerNotification?.id;\n if (!id) {\n throw new Error(`notification service returned no id for user ${userId}`);\n }\n return id;\n })\n );\n\n for (const [index, settled] of results.entries()) {\n if (settled.status === 'fulfilled') {\n notificationIds.push(settled.value);\n } else {\n const reason = settled.reason instanceof Error ? settled.reason.message : String(settled.reason);\n errors.push(`${options.userIds[index] ?? 'unknown user'}: ${reason}`);\n }\n }\n\n const result: NotificationResponse = {\n successCount: notificationIds.length,\n failureCount: errors.length,\n errors,\n notificationIds,\n };\n\n logger.info('[Notifications] Notification sent', {\n successCount: result.successCount,\n failureCount: result.failureCount,\n });\n\n return result;\n }\n\n /**\n * Send notification to a single user (convenience method)\n */\n public async sendToUser(\n userId: string,\n title: string,\n message: string,\n options?: Omit<SendNotificationOptions, 'userIds' | 'title' | 'message'>\n ): Promise<NotificationResponse> {\n return this.send({\n title,\n message,\n userIds: [userId],\n ...options,\n });\n }\n\n /**\n * Get notifications for a user\n */\n public async getNotifications(options: GetNotificationsOptions): Promise<{\n notifications: Notification[];\n total: number;\n unreadCount: number;\n }> {\n logger.debug('[Notifications] Getting notifications', { userId: options.userId });\n\n const query = `\n query GetNotifications(\n $userId: ID!\n $status: NotificationStatus\n $type: NotificationType\n $appName: String\n $search: String\n $limit: Int\n $offset: Int\n ) {\n getNotifications(\n userId: $userId\n status: $status\n type: $type\n appName: $appName\n search: $search\n limit: $limit\n offset: $offset\n ) {\n notifications {\n id\n userId\n title\n message\n type\n status\n redirectUrl\n appName\n createdAt\n updatedAt\n }\n total\n unreadCount\n }\n }\n `;\n\n const variables = {\n userId: options.userId,\n status: options.status,\n type: options.type,\n appName: options.appName,\n search: options.search,\n limit: options.limit || 20,\n offset: options.offset || 0,\n };\n\n const response = await this.client.query<{\n getNotifications: {\n notifications: Notification[];\n total: number;\n unreadCount: number;\n };\n }>(query, variables, this.context);\n\n return response.getNotifications;\n }\n\n /**\n * Mark notification as read\n */\n public async markAsRead(notificationId: string): Promise<boolean> {\n logger.debug('[Notifications] Marking notification as read', { notificationId });\n\n const mutation = `\n mutation MarkNotificationAsRead($notificationId: ID!) {\n markNotificationAsRead(notificationId: $notificationId) {\n id\n status\n }\n }\n `;\n\n await this.client.tenantQuery(mutation, { notificationId }, this.context);\n\n logger.info('[Notifications] Notification marked as read', { notificationId });\n\n return true;\n }\n\n /**\n * Mark multiple notifications as read\n */\n public async markMultipleAsRead(notificationIds: string[]): Promise<number> {\n logger.debug('[Notifications] Marking multiple notifications as read', {\n count: notificationIds.length,\n });\n\n const mutation = `\n mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {\n markNotificationsAsRead(notificationIds: $notificationIds) {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n markNotificationsAsRead: { count: number };\n }>(mutation, { notificationIds }, this.context);\n\n logger.info('[Notifications] Notifications marked as read', {\n count: response.markNotificationsAsRead.count,\n });\n\n return response.markNotificationsAsRead.count;\n }\n\n /**\n * Mark all notifications as read for the current user\n */\n public async markAllAsRead(): Promise<number> {\n logger.debug('[Notifications] Marking all notifications as read');\n\n const mutation = `\n mutation MarkAllMyNotificationsAsRead {\n markAllMyNotificationsAsRead {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n markAllMyNotificationsAsRead: { count: number };\n }>(mutation, {}, this.context);\n\n logger.info('[Notifications] All notifications marked as read', {\n count: response.markAllMyNotificationsAsRead.count,\n });\n\n return response.markAllMyNotificationsAsRead.count;\n }\n\n /**\n * Delete notification\n */\n public async deleteNotification(notificationId: string): Promise<boolean> {\n logger.debug('[Notifications] Deleting notification', { notificationId });\n\n const mutation = `\n mutation DeleteNotification($notificationId: ID!) {\n deleteNotification(notificationId: $notificationId) {\n success\n }\n }\n `;\n\n await this.client.tenantQuery(mutation, { notificationId }, this.context);\n\n logger.info('[Notifications] Notification deleted', { notificationId });\n\n return true;\n }\n\n /**\n * Delete multiple notifications\n */\n public async deleteMultiple(notificationIds: string[]): Promise<number> {\n logger.debug('[Notifications] Deleting multiple notifications', {\n count: notificationIds.length,\n });\n\n const mutation = `\n mutation DeleteNotifications($notificationIds: [ID!]!) {\n deleteNotifications(notificationIds: $notificationIds) {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n deleteNotifications: { count: number };\n }>(mutation, { notificationIds }, this.context);\n\n logger.info('[Notifications] Notifications deleted', {\n count: response.deleteNotifications.count,\n });\n\n return response.deleteNotifications.count;\n }\n\n /**\n * Get unread notification count for a user\n */\n public async getUnreadCount(userId: string): Promise<number> {\n const result = await this.getNotifications({\n userId,\n status: 'unread',\n limit: 0,\n });\n\n return result.unreadCount;\n }\n\n /**\n * Send notification via specific channel (EMAIL, SMS, WHATSAPP, etc.)\n * with optional in-app notification\n */\n public async sendChannelNotification(options: SendChannelNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.body || options.body.trim().length === 0) {\n throw new ValidationError('Notification body is required');\n }\n\n if (!options.recipient && !options.recipients) {\n throw new ValidationError('At least one recipient is required');\n }\n\n if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {\n throw new ValidationError('User IDs are required when includeInApp is true');\n }\n\n logger.info('[Notifications] Sending channel notification', {\n platform: options.platform,\n recipientCount: options.recipients ? options.recipients.length : 1,\n includeInApp: options.includeInApp,\n inAppUserCount: options.userIds ? options.userIds.length : 0,\n });\n\n const mutation = `\n mutation TriggerNotification($input: TriggerNotificationInput!) {\n triggerNotification(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n platform: options.platform,\n channelId: options.channelId,\n includeInApp: options.includeInApp || false,\n userIds: options.userIds || [],\n notification: {\n subject: options.subject || '',\n body: options.body,\n htmlBody: options.htmlBody || '',\n channel: options.platform,\n type: options.type || NotificationType.INFO,\n recipient: options.recipient,\n appName: options.appName,\n redirectUrl: options.redirectUrl || '',\n metadata: options.metadata || {},\n trackOpens: options.trackOpens || false,\n trackClicks: options.trackClicks || false,\n expiresAt: options.expiresAt?.toISOString(),\n },\n },\n };\n\n // Handle bulk recipients\n if (options.recipients && options.recipients.length > 1) {\n const results = await Promise.allSettled(\n options.recipients.map((recipient) =>\n this.client.tenantQuery(\n mutation,\n {\n input: {\n ...variables.input,\n notification: {\n ...variables.input.notification,\n recipient,\n },\n },\n },\n this.context\n )\n )\n );\n\n let successCount = 0;\n let failureCount = 0;\n const errors: string[] = [];\n const notificationIds: string[] = [];\n\n results.forEach((result, index) => {\n if (result.status === 'fulfilled') {\n successCount++;\n const response = result.value as { triggerNotification: { id: string } };\n notificationIds.push(response.triggerNotification.id);\n } else {\n failureCount++;\n errors.push(\n `Recipient ${index + 1}: ${result.reason instanceof Error ? result.reason.message : 'Unknown error'}`\n );\n }\n });\n\n const response: NotificationResponse = {\n successCount,\n failureCount,\n errors,\n notificationIds,\n };\n\n logger.info('[Notifications] Channel notification sent (bulk)', {\n successCount,\n failureCount,\n });\n\n return response;\n } else {\n // Single recipient\n try {\n const response = await this.client.query<{\n triggerNotification: { id: string; status: string; deliveryStatus: string };\n }>(mutation, variables, this.context);\n\n const result: NotificationResponse = {\n successCount: 1,\n failureCount: 0,\n errors: [],\n notificationIds: [response.triggerNotification.id],\n };\n\n logger.info('[Notifications] Channel notification sent', {\n notificationId: response.triggerNotification.id,\n status: response.triggerNotification.status,\n });\n\n return result;\n } catch (error) {\n logger.error('[Notifications] Failed to send channel notification', { error });\n\n return {\n successCount: 0,\n failureCount: 1,\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n notificationIds: [],\n };\n }\n }\n }\n\n /**\n * Send notification using a template with optional in-app notification\n */\n public async sendTemplateNotification(options: SendTemplateNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.templateSlug || options.templateSlug.trim().length === 0) {\n throw new ValidationError('Template slug is required');\n }\n\n if (!options.variables || typeof options.variables !== 'object') {\n throw new ValidationError('Template variables are required');\n }\n\n if (!options.recipient && !options.recipients) {\n throw new ValidationError('At least one recipient is required');\n }\n\n if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {\n throw new ValidationError('User IDs are required when includeInApp is true');\n }\n\n logger.info('[Notifications] Sending template notification', {\n templateSlug: options.templateSlug,\n platform: options.platform,\n recipientCount: options.recipients ? options.recipients.length : 1,\n includeInApp: options.includeInApp,\n inAppUserCount: options.userIds ? options.userIds.length : 0,\n });\n\n const mutation = `\n mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {\n triggerNotificationWithTemplate(input: $input) {\n totalRequested\n totalTriggered\n totalFailed\n notifications {\n id\n status\n deliveryStatus\n }\n }\n }\n `;\n\n const variables = {\n input: {\n platform: options.platform,\n channelId: options.channelId,\n includeInApp: options.includeInApp || false,\n userIds: options.userIds || [],\n templateSlug: options.templateSlug,\n variables: options.variables,\n recipient: options.recipient,\n recipients: options.recipients,\n trackOpens: options.trackOpens || false,\n trackClicks: options.trackClicks || false,\n expiresAt: options.expiresAt?.toISOString(),\n scheduledFor: options.scheduledFor?.toISOString(),\n timezone: options.timezone,\n },\n };\n\n try {\n const response = await this.client.query<{\n triggerNotificationWithTemplate: {\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n notifications: Array<{ id: string; status: string; deliveryStatus?: string }>;\n };\n }>(mutation, variables, this.context);\n\n const data = response.triggerNotificationWithTemplate;\n\n const result: NotificationResponse = {\n successCount: data.totalTriggered,\n failureCount: data.totalFailed,\n errors: [],\n notificationIds: data.notifications.map((n) => n.id),\n };\n\n logger.info('[Notifications] Template notification sent', {\n templateSlug: options.templateSlug,\n totalTriggered: data.totalTriggered,\n totalFailed: data.totalFailed,\n notificationIds: result.notificationIds,\n });\n\n return result;\n } catch (error) {\n logger.error('[Notifications] Failed to send template notification', { error });\n\n return {\n successCount: 0,\n failureCount: 1,\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n notificationIds: [],\n };\n }\n }\n}\n"]}
|