notifkit 0.1.15 → 0.1.16
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/dashboard/dist/assets/index-C-DJYu0_.css +1 -0
- package/dashboard/dist/assets/index-CzFZcEon.js +318 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/{bootstrap-BOmT69OH.mjs → bootstrap-BMDRPjgp.mjs} +1 -1
- package/dist/{bulk-ZPiOJRx-.mjs → bulk-CJ5QXiPa.mjs} +1 -1
- package/dist/index.d.mts +71 -27
- package/dist/index.mjs +2 -2
- package/dist/{main-CCqcFDDe.mjs → main-6_bXQBDH.mjs} +21 -41
- package/dist/{main-BdZvBgV7.mjs → main-8nP3qmCT.mjs} +22 -48
- package/dist/{main-C0m9-Eos.mjs → main-B82bsFoy.mjs} +183 -334
- package/dist/{main-CTjaZ7ZD.mjs → main-CpaHF1Zw.mjs} +13 -15
- package/dist/{main-JEXBLP2A.mjs → main-DULD8-th.mjs} +8 -6
- package/dist/{main-C6S3EsJ3.mjs → main-ZW5RaiOK.mjs} +77 -64
- package/dist/{main-g33jpia4.mjs → main-g1KEcXXp.mjs} +676 -582
- package/dist/{main-24J4U8yP.mjs → main-mGIT8jv4.mjs} +4 -4
- package/dist/schedule-or-dispatch-Cd7GLfc3.mjs +52 -0
- package/dist/{src-9LXITcNi.mjs → src-BE_EUpZ6.mjs} +93 -93
- package/package.json +1 -1
- package/scripts/create-project.mjs +6 -2
- package/src/client.ts +3 -3
- package/src/config/index.ts +1 -0
- package/src/contracts/common.ts +2 -0
- package/src/contracts/envelope.ts +1 -1
- package/src/contracts/events/notification-created.ts +2 -0
- package/src/contracts/events/notification-delivered.ts +1 -1
- package/src/contracts/events/notification-failed.ts +1 -1
- package/src/contracts/events/notification-requested.ts +3 -2
- package/src/contracts/helpers.ts +1 -2
- package/src/contracts/index.ts +1 -0
- package/src/contracts/registry.ts +1 -0
- package/src/contracts/sdk.ts +8 -37
- package/src/db/schema.ts +8 -13
- package/src/idempotency/index.ts +6 -8
- package/src/metrics/index.ts +2 -0
- package/src/rate-limiter/api-rate-limiter.ts +208 -0
- package/src/rate-limiter/index.ts +3 -411
- package/src/rate-limiter/project-settings-cache.ts +99 -0
- package/src/rate-limiter/user-throttle.ts +100 -0
- package/src/redis/index.ts +10 -3
- package/src/repositories/admin-user.ts +83 -0
- package/src/repositories/contact.ts +359 -0
- package/src/repositories/index.ts +9 -1416
- package/src/repositories/preference.ts +35 -0
- package/src/repositories/project.ts +110 -0
- package/src/repositories/segment.ts +16 -0
- package/src/repositories/template.ts +72 -0
- package/src/repositories/types.ts +49 -0
- package/src/repositories/user.ts +644 -0
- package/src/repositories/workflow.ts +64 -0
- package/src/services/ai/main.ts +29 -71
- package/src/services/api/admin-static.ts +4 -1
- package/src/services/api/handlers/auth.ts +109 -0
- package/src/services/api/handlers/campaigns.ts +191 -0
- package/src/services/api/handlers/events.ts +99 -0
- package/src/services/api/handlers/notifications.ts +356 -0
- package/src/services/api/handlers/projects.ts +116 -0
- package/src/services/api/handlers/shared.ts +262 -0
- package/src/services/api/handlers/suppressions.ts +95 -0
- package/src/services/api/handlers/system.ts +314 -0
- package/src/services/api/handlers/templates.ts +97 -0
- package/src/services/api/handlers/unsubscribe.ts +215 -0
- package/src/services/api/handlers/users.ts +262 -0
- package/src/services/api/handlers/workflows.ts +150 -0
- package/src/services/api/handlers.ts +25 -2190
- package/src/services/api/health.ts +133 -0
- package/src/services/api/http.ts +12 -0
- package/src/services/api/main.ts +32 -322
- package/src/services/api/router.ts +1 -1
- package/src/services/api/webhooks.ts +172 -0
- package/src/services/delivery/main.ts +256 -498
- package/src/services/engine/main.ts +31 -247
- package/src/services/engine/quiet-hours.ts +151 -0
- package/src/services/engine/schedule-or-dispatch.ts +104 -0
- package/src/services/enricher/main.ts +9 -21
- package/src/services/events/main.ts +2 -2
- package/src/services/scheduler/main.ts +16 -25
- package/src/services/workflow/duration.ts +24 -0
- package/src/services/workflow/main.ts +6 -164
- package/src/services/workflow/timers.ts +157 -0
- package/src/shared/events.ts +3 -2
- package/src/templates/render.ts +1 -0
- package/src/workers/index.ts +7 -4
- package/src/workflows/sdk.ts +1 -0
- package/dashboard/dist/assets/index-ggpJKZqZ.js +0 -315
- package/dashboard/dist/assets/index-s-SXGIwv.css +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-
|
|
3
|
-
import { t as insertMessageLogs } from "./bulk-
|
|
1
|
+
import { J as StreamProducer, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, gt as workflowWaiters, ht as workflowSteps, mn as loadEnv, mt as workflowInstances, tn as STREAMS } from "./src-BE_EUpZ6.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-BMDRPjgp.mjs";
|
|
3
|
+
import { t as insertMessageLogs } from "./bulk-CJ5QXiPa.mjs";
|
|
4
4
|
import { and, eq, gt, isNull, or } from "drizzle-orm";
|
|
5
5
|
//#region src/services/events/main.ts
|
|
6
6
|
loadEnv();
|
|
@@ -74,7 +74,7 @@ var EventWorker = class EventWorker extends BaseWorker {
|
|
|
74
74
|
} catch (error) {
|
|
75
75
|
this.logger.error({
|
|
76
76
|
batchSize: batch.length,
|
|
77
|
-
|
|
77
|
+
err: error
|
|
78
78
|
}, "failed to flush delivery logs — dropping batch");
|
|
79
79
|
for (const b of batch) b.reject(error);
|
|
80
80
|
for (const e of events) e.reject(error);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Dn as getPriorityBucket, Yt as buildStreamEvent, lt as scheduledPayloads } from "./src-BE_EUpZ6.mjs";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
//#region src/services/engine/schedule-or-dispatch.ts
|
|
4
|
+
/**
|
|
5
|
+
* Caches the payload and publishes `notification.scheduled` when the task is due
|
|
6
|
+
* later, otherwise publishes `notification.dispatched` to the outbound stream
|
|
7
|
+
* for its priority (or hands it to the fused delivery worker).
|
|
8
|
+
*/
|
|
9
|
+
async function scheduleOrDispatch(deps, taskPayload, opts) {
|
|
10
|
+
const { taskId } = taskPayload;
|
|
11
|
+
const envelope = buildStreamEvent("notification.dispatched", taskPayload, opts.source, opts.traceId);
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
if ((opts.scheduledAt ? new Date(opts.scheduledAt).getTime() : now) > now) {
|
|
14
|
+
await deps.db.insert(scheduledPayloads).values({
|
|
15
|
+
taskId,
|
|
16
|
+
payload: {
|
|
17
|
+
...taskPayload,
|
|
18
|
+
scheduledAt: opts.scheduledAt
|
|
19
|
+
}
|
|
20
|
+
}).onConflictDoNothing();
|
|
21
|
+
const scheduledEnvelope = buildStreamEvent("notification.scheduled", {
|
|
22
|
+
projectId: taskPayload.projectId,
|
|
23
|
+
enrichedEventId: taskPayload.enrichedEventId,
|
|
24
|
+
taskId,
|
|
25
|
+
scheduledAt: opts.scheduledAt
|
|
26
|
+
}, opts.source, opts.traceId);
|
|
27
|
+
await deps.scheduledProducer.publish(scheduledEnvelope);
|
|
28
|
+
deps.logger[opts.logLevel]({
|
|
29
|
+
messageId: opts.messageId,
|
|
30
|
+
taskId,
|
|
31
|
+
scheduledAt: opts.scheduledAt,
|
|
32
|
+
traceId: opts.traceId
|
|
33
|
+
}, opts.scheduledMessage);
|
|
34
|
+
} else {
|
|
35
|
+
const p = getPriorityBucket(taskPayload.priority);
|
|
36
|
+
const outboundProducer = deps.outboundProducers[p] ?? deps.outboundProducers["normal"];
|
|
37
|
+
if (deps.inlineNext) await deps.inlineNext({
|
|
38
|
+
...envelope,
|
|
39
|
+
id: randomUUID(),
|
|
40
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
41
|
+
});
|
|
42
|
+
else await outboundProducer.publish(envelope);
|
|
43
|
+
deps.logger[opts.logLevel]({
|
|
44
|
+
messageId: opts.messageId,
|
|
45
|
+
taskId,
|
|
46
|
+
recipientId: taskPayload.recipientId,
|
|
47
|
+
traceId: opts.traceId
|
|
48
|
+
}, opts.dispatchedMessage);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { scheduleOrDispatch as t };
|
|
@@ -448,6 +448,7 @@ const NotificationPrioritySchema = z.enum([
|
|
|
448
448
|
"high",
|
|
449
449
|
"critical"
|
|
450
450
|
]);
|
|
451
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
451
452
|
const NotificationStatusSchema = z.enum([
|
|
452
453
|
"pending",
|
|
453
454
|
"queued",
|
|
@@ -601,8 +602,8 @@ function buildStreamEvent(type, payload, source, traceId) {
|
|
|
601
602
|
//#endregion
|
|
602
603
|
//#region src/contracts/sdk.ts
|
|
603
604
|
const QuietHoursSchema = z.object({
|
|
604
|
-
start: z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "expected HH:MM (24h,
|
|
605
|
-
end: z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "expected HH:MM (24h,
|
|
605
|
+
start: z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "expected HH:MM (24h, user's timezone)"),
|
|
606
|
+
end: z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "expected HH:MM (24h, user's timezone)")
|
|
606
607
|
});
|
|
607
608
|
const PreferencesSchema = z.object({
|
|
608
609
|
channels: z.record(z.string(), z.boolean()).optional(),
|
|
@@ -610,17 +611,7 @@ const PreferencesSchema = z.object({
|
|
|
610
611
|
quietHours: z.array(QuietHoursSchema).optional()
|
|
611
612
|
});
|
|
612
613
|
/** Channels that carry an addressable target (email address, phone, push token, url, chat id). */
|
|
613
|
-
const ContactChannelSchema =
|
|
614
|
-
"email",
|
|
615
|
-
"sms",
|
|
616
|
-
"push",
|
|
617
|
-
"webhook",
|
|
618
|
-
"in-app",
|
|
619
|
-
"telegram",
|
|
620
|
-
"discord",
|
|
621
|
-
"whatsapp",
|
|
622
|
-
"slack"
|
|
623
|
-
]);
|
|
614
|
+
const ContactChannelSchema = NotificationChannelSchema;
|
|
624
615
|
/** Accept a single value or an array; always normalise to a non-empty array. */
|
|
625
616
|
const stringOrArray = z.union([z.string().min(1), z.array(z.string().min(1))]).transform((v) => Array.isArray(v) ? v : [v]);
|
|
626
617
|
const UserContactInputSchema = z.object({
|
|
@@ -659,35 +650,18 @@ const UpdateUserSchema = z.object({
|
|
|
659
650
|
preferences: PreferencesSchema.optional()
|
|
660
651
|
});
|
|
661
652
|
/** addUserContact(userId, channel, { target, preferences, label, isPrimary, enabled }) */
|
|
662
|
-
const AddContactSchema =
|
|
663
|
-
channel: ContactChannelSchema,
|
|
664
|
-
target: z.string().min(1),
|
|
665
|
-
label: z.string().optional(),
|
|
666
|
-
isPrimary: z.boolean().optional(),
|
|
667
|
-
enabled: z.boolean().optional(),
|
|
668
|
-
preferences: PreferencesSchema.optional()
|
|
669
|
-
});
|
|
653
|
+
const AddContactSchema = UserContactInputSchema;
|
|
670
654
|
const BatchAddContactsSchema = z.union([AddContactSchema, z.array(AddContactSchema).min(1)]);
|
|
671
655
|
const TemplateSchema = z.object({
|
|
672
656
|
id: z.string().min(1),
|
|
673
657
|
channel: NotificationChannelSchema,
|
|
674
|
-
topic:
|
|
658
|
+
topic: stringOrArray.optional(),
|
|
675
659
|
content: z.record(z.string(), z.unknown()),
|
|
676
660
|
aiPrompts: z.record(z.string(), z.string()).optional()
|
|
677
661
|
});
|
|
678
662
|
const SyncTemplatesSchema = z.object({ templates: z.array(TemplateSchema).min(1) });
|
|
679
663
|
/** Inline user object accepted by notify({ user: {...} }). */
|
|
680
|
-
const InlineUserSchema =
|
|
681
|
-
id: z.string().min(1),
|
|
682
|
-
language: z.string().optional(),
|
|
683
|
-
timezone: z.string().optional(),
|
|
684
|
-
contacts: z.array(UserContactInputSchema).optional(),
|
|
685
|
-
email: stringOrArray.optional(),
|
|
686
|
-
phone: stringOrArray.optional(),
|
|
687
|
-
pushToken: stringOrArray.optional(),
|
|
688
|
-
segments: z.array(z.string().min(1)).optional(),
|
|
689
|
-
preferences: PreferencesSchema.optional()
|
|
690
|
-
});
|
|
664
|
+
const InlineUserSchema = AddUserSchema;
|
|
691
665
|
/**
|
|
692
666
|
* notify(...) request body.
|
|
693
667
|
*
|
|
@@ -801,10 +775,11 @@ const UpdateProjectSchema = z.object({
|
|
|
801
775
|
/**
|
|
802
776
|
* A high-level notification request as issued by the SDK's `notify()` call.
|
|
803
777
|
*
|
|
804
|
-
* Unlike `notification.
|
|
778
|
+
* Unlike `notification.enriched` (which targets a single resolved address),
|
|
805
779
|
* this event carries the *unresolved* target — a user id, a segment, or a
|
|
806
780
|
* topic. A downstream resolver stage fans it out into one
|
|
807
|
-
* `notification.
|
|
781
|
+
* `notification.enriched` per matching address and channel, applying
|
|
782
|
+
* preference filters.
|
|
808
783
|
*/
|
|
809
784
|
const NotificationTargetSchema = z.discriminatedUnion("type", [
|
|
810
785
|
z.object({
|
|
@@ -841,6 +816,7 @@ const NotificationRequestedPayloadSchema = z.object({
|
|
|
841
816
|
});
|
|
842
817
|
//#endregion
|
|
843
818
|
//#region src/contracts/events/notification-created.ts
|
|
819
|
+
/** @deprecated Nothing publishes `notification.created`; removed in the next minor version. */
|
|
844
820
|
const NotificationCreatedPayloadSchema = z.object({
|
|
845
821
|
projectId: z.string().uuid(),
|
|
846
822
|
recipientId: z.string().min(1),
|
|
@@ -970,7 +946,7 @@ const NotificationDeliveredPayloadSchema = z.object({
|
|
|
970
946
|
deliveredAt: z.string().datetime(),
|
|
971
947
|
providerMessageId: z.string().optional(),
|
|
972
948
|
providerResponse: z.record(z.string(), z.unknown()).optional(),
|
|
973
|
-
templateId: z.string().
|
|
949
|
+
templateId: z.string().min(1).optional(),
|
|
974
950
|
workflowInstanceId: z.string().uuid().optional(),
|
|
975
951
|
/** Campaign this message belongs to, carried from the originating request. */
|
|
976
952
|
campaignId: z.string().min(1).max(128).optional(),
|
|
@@ -994,7 +970,7 @@ const NotificationFailedPayloadSchema = z.object({
|
|
|
994
970
|
retryable: z.boolean(),
|
|
995
971
|
attempt: z.number().int().positive(),
|
|
996
972
|
providerResponse: z.record(z.string(), z.unknown()).optional(),
|
|
997
|
-
templateId: z.string().
|
|
973
|
+
templateId: z.string().min(1).optional(),
|
|
998
974
|
workflowInstanceId: z.string().uuid().optional(),
|
|
999
975
|
/** Campaign this message belongs to, carried from the originating request. */
|
|
1000
976
|
campaignId: z.string().min(1).max(128).optional(),
|
|
@@ -1080,17 +1056,7 @@ var schema_exports = /* @__PURE__ */ __exportAll({
|
|
|
1080
1056
|
workflowSteps: () => workflowSteps,
|
|
1081
1057
|
workflowWaiters: () => workflowWaiters
|
|
1082
1058
|
});
|
|
1083
|
-
const channelEnum = pgEnum("channel",
|
|
1084
|
-
"email",
|
|
1085
|
-
"sms",
|
|
1086
|
-
"push",
|
|
1087
|
-
"webhook",
|
|
1088
|
-
"in-app",
|
|
1089
|
-
"telegram",
|
|
1090
|
-
"discord",
|
|
1091
|
-
"whatsapp",
|
|
1092
|
-
"slack"
|
|
1093
|
-
]);
|
|
1059
|
+
const channelEnum = pgEnum("channel", NotificationChannelSchema.options);
|
|
1094
1060
|
const projects = pgTable("projects", {
|
|
1095
1061
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
1096
1062
|
name: varchar("name").notNull(),
|
|
@@ -1456,10 +1422,8 @@ async function migrateDatabase({ url, schema: dbSchema }) {
|
|
|
1456
1422
|
//#endregion
|
|
1457
1423
|
//#region src/idempotency/index.ts
|
|
1458
1424
|
/**
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1461
|
-
* - Phase 1 (:lock): Short lease acquired at the start of message processing.
|
|
1462
|
-
* - Phase 2 (:sent): Long-lived completion marker recorded when processing succeeds.
|
|
1425
|
+
* SET NX-based idempotency guard.
|
|
1426
|
+
* One key per id: `L` while leased, `1` once processed.
|
|
1463
1427
|
*/
|
|
1464
1428
|
var IdempotencyGuard = class {
|
|
1465
1429
|
redis;
|
|
@@ -1473,17 +1437,17 @@ var IdempotencyGuard = class {
|
|
|
1473
1437
|
key(id) {
|
|
1474
1438
|
return `${this.keyPrefix}:${id}`;
|
|
1475
1439
|
}
|
|
1440
|
+
/** @deprecated Nothing writes `:lock` keys any more; read only for markers from older versions. Remove in the next minor. */
|
|
1476
1441
|
lockKey(id) {
|
|
1477
1442
|
return `${this.keyPrefix}:${id}:lock`;
|
|
1478
1443
|
}
|
|
1444
|
+
/** @deprecated Nothing writes `:sent` keys any more; read only for markers from older versions. Remove in the next minor. */
|
|
1479
1445
|
completedKey(id) {
|
|
1480
1446
|
return `${this.keyPrefix}:${id}:sent`;
|
|
1481
1447
|
}
|
|
1482
1448
|
/**
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
* - Happy path (new message): single native SET NX command storing "L" (lock lease).
|
|
1486
|
-
* - If already present: checks if "S" (sent/completed) or "L" (locked by another worker).
|
|
1449
|
+
* Leases the id with SET NX. One key per id: `L` while leased, `1` once processed.
|
|
1450
|
+
* Returns "completed" if already processed, "locked" if another worker holds the lease.
|
|
1487
1451
|
*/
|
|
1488
1452
|
async acquireLease(id, lockTtlSeconds = 30) {
|
|
1489
1453
|
const mainKey = this.key(id);
|
|
@@ -1584,6 +1548,7 @@ const metrics = {
|
|
|
1584
1548
|
labelNames: ["channel", "reason"],
|
|
1585
1549
|
registers: [register]
|
|
1586
1550
|
}),
|
|
1551
|
+
/** @deprecated Never set, so it always reads 0. Removed in the next minor version. */
|
|
1587
1552
|
workerActiveTasks: new promClient.Gauge({
|
|
1588
1553
|
name: "notifkit_worker_active_tasks",
|
|
1589
1554
|
help: "Number of currently active tasks per worker",
|
|
@@ -1596,6 +1561,7 @@ const metrics = {
|
|
|
1596
1561
|
labelNames: ["stream"],
|
|
1597
1562
|
registers: [register]
|
|
1598
1563
|
}),
|
|
1564
|
+
/** @deprecated Never set, so it always reads 0. Removed in the next minor version. */
|
|
1599
1565
|
pendingAcks: new promClient.Gauge({
|
|
1600
1566
|
name: "notifkit_pending_acks",
|
|
1601
1567
|
help: "Number of pending un-acked messages per group",
|
|
@@ -2036,7 +2002,7 @@ var PendingMessageScanner = class {
|
|
|
2036
2002
|
}
|
|
2037
2003
|
};
|
|
2038
2004
|
//#endregion
|
|
2039
|
-
//#region src/rate-limiter/
|
|
2005
|
+
//#region src/rate-limiter/project-settings-cache.ts
|
|
2040
2006
|
const NO_OVERRIDES = {
|
|
2041
2007
|
throttleLimit: null,
|
|
2042
2008
|
throttleWindowHours: null
|
|
@@ -2096,6 +2062,8 @@ var ProjectSettingsCache = class {
|
|
|
2096
2062
|
this.inFlight.clear();
|
|
2097
2063
|
}
|
|
2098
2064
|
};
|
|
2065
|
+
//#endregion
|
|
2066
|
+
//#region src/rate-limiter/user-throttle.ts
|
|
2099
2067
|
/** Reject stored values that would make the window meaningless. */
|
|
2100
2068
|
function positiveOrNull(value) {
|
|
2101
2069
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
@@ -2143,6 +2111,8 @@ var UserThrottle = class {
|
|
|
2143
2111
|
};
|
|
2144
2112
|
}
|
|
2145
2113
|
};
|
|
2114
|
+
//#endregion
|
|
2115
|
+
//#region src/rate-limiter/api-rate-limiter.ts
|
|
2146
2116
|
/**
|
|
2147
2117
|
* Computes dynamic token lease batch size based on RPM.
|
|
2148
2118
|
* Targets ~5s of limit capacity so Redis is contacted at most ~12 times/min
|
|
@@ -2381,7 +2351,10 @@ const LUA_COUNT_REQUEST = `
|
|
|
2381
2351
|
end
|
|
2382
2352
|
return count
|
|
2383
2353
|
`;
|
|
2384
|
-
/**
|
|
2354
|
+
/**
|
|
2355
|
+
* Two-phase idempotency lease acquisition. Checks sent/legacy, then attempts SET NX lock.
|
|
2356
|
+
* @deprecated Nothing calls the `acquireLease` command; removed in the next minor version.
|
|
2357
|
+
*/
|
|
2385
2358
|
const LUA_ACQUIRE_LEASE = `
|
|
2386
2359
|
if redis.call('EXISTS', KEYS[1]) == 1 or redis.call('EXISTS', KEYS[3]) == 1 then
|
|
2387
2360
|
return 'completed'
|
|
@@ -2395,7 +2368,10 @@ const LUA_ACQUIRE_LEASE = `
|
|
|
2395
2368
|
end
|
|
2396
2369
|
return 'locked'
|
|
2397
2370
|
`;
|
|
2398
|
-
/**
|
|
2371
|
+
/**
|
|
2372
|
+
* Two-phase idempotency completion marker. Atomically sets completed + legacy and deletes lock.
|
|
2373
|
+
* @deprecated Nothing calls the `markProcessed` command; removed in the next minor version.
|
|
2374
|
+
*/
|
|
2399
2375
|
const LUA_MARK_PROCESSED = `
|
|
2400
2376
|
redis.call('SET', KEYS[1], '1', 'EX', ARGV[1])
|
|
2401
2377
|
redis.call('SET', KEYS[2], '1', 'EX', ARGV[1])
|
|
@@ -2544,7 +2520,7 @@ function redactUrl(url) {
|
|
|
2544
2520
|
}
|
|
2545
2521
|
}
|
|
2546
2522
|
//#endregion
|
|
2547
|
-
//#region src/repositories/
|
|
2523
|
+
//#region src/repositories/user.ts
|
|
2548
2524
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
2549
2525
|
/**
|
|
2550
2526
|
* Applied when a profile is read, not when it is written: an upsert that
|
|
@@ -2552,12 +2528,16 @@ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
|
2552
2528
|
*/
|
|
2553
2529
|
const DEFAULT_LANGUAGE = "en";
|
|
2554
2530
|
const DEFAULT_TIMEZONE = "UTC";
|
|
2555
|
-
var UserRepository = class {
|
|
2531
|
+
var UserRepository = class UserRepository {
|
|
2556
2532
|
db;
|
|
2557
2533
|
recordCache = new LRUCache(5e3, 3e4);
|
|
2558
2534
|
constructor(db) {
|
|
2559
2535
|
this.db = db;
|
|
2560
2536
|
}
|
|
2537
|
+
/** A repository that runs its queries inside `tx`. */
|
|
2538
|
+
withTx(tx) {
|
|
2539
|
+
return new UserRepository(tx);
|
|
2540
|
+
}
|
|
2561
2541
|
async findById(projectId, userId) {
|
|
2562
2542
|
const rows = await this.db.select().from(users).where(and(eq(users.externalId, userId), eq(users.projectId, projectId))).limit(1);
|
|
2563
2543
|
if (!rows[0]) return null;
|
|
@@ -2882,6 +2862,9 @@ var UserRepository = class {
|
|
|
2882
2862
|
return (await this.db.select({ externalId: users.externalId }).from(users).innerJoin(userTopicPreferences, eq(users.id, userTopicPreferences.userId)).where(and(eq(userTopicPreferences.topic, topicName), eq(userTopicPreferences.enabled, true), eq(users.projectId, projectId)))).map((r) => r.externalId);
|
|
2883
2863
|
}
|
|
2884
2864
|
};
|
|
2865
|
+
//#endregion
|
|
2866
|
+
//#region src/repositories/preference.ts
|
|
2867
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
2885
2868
|
var PreferenceRepository = class {
|
|
2886
2869
|
db;
|
|
2887
2870
|
constructor(db) {
|
|
@@ -2901,12 +2884,18 @@ var PreferenceRepository = class {
|
|
|
2901
2884
|
}));
|
|
2902
2885
|
}
|
|
2903
2886
|
};
|
|
2904
|
-
|
|
2887
|
+
//#endregion
|
|
2888
|
+
//#region src/repositories/contact.ts
|
|
2889
|
+
var ContactRepository = class ContactRepository {
|
|
2905
2890
|
db;
|
|
2906
2891
|
activeContactsCache = new LRUCache(5e3, 3e4);
|
|
2907
2892
|
constructor(db) {
|
|
2908
2893
|
this.db = db;
|
|
2909
2894
|
}
|
|
2895
|
+
/** A repository that runs its queries inside `tx`. */
|
|
2896
|
+
withTx(tx) {
|
|
2897
|
+
return new ContactRepository(tx);
|
|
2898
|
+
}
|
|
2910
2899
|
async findByUserId(projectId, userId) {
|
|
2911
2900
|
const internalId = (await this.db.select({ id: users.id }).from(users).where(and(eq(users.externalId, userId), eq(users.projectId, projectId))))[0]?.id;
|
|
2912
2901
|
if (!internalId) return [];
|
|
@@ -3086,6 +3075,8 @@ var ContactRepository = class {
|
|
|
3086
3075
|
return (await this.db.delete(userContacts).where(and(eq(userContacts.userId, internalId), eq(userContacts.channel, channel), eq(userContacts.target, target))).returning()).length > 0;
|
|
3087
3076
|
}
|
|
3088
3077
|
};
|
|
3078
|
+
//#endregion
|
|
3079
|
+
//#region src/repositories/template.ts
|
|
3089
3080
|
var TemplateRepository = class {
|
|
3090
3081
|
db;
|
|
3091
3082
|
constructor(db) {
|
|
@@ -3137,6 +3128,8 @@ var TemplateRepository = class {
|
|
|
3137
3128
|
return (await this.db.delete(templates).where(and(eq(templates.id, id), eq(templates.projectId, projectId))).returning()).length > 0;
|
|
3138
3129
|
}
|
|
3139
3130
|
};
|
|
3131
|
+
//#endregion
|
|
3132
|
+
//#region src/repositories/project.ts
|
|
3140
3133
|
var ProjectRepository = class {
|
|
3141
3134
|
db;
|
|
3142
3135
|
constructor(db) {
|
|
@@ -3154,15 +3147,7 @@ var ProjectRepository = class {
|
|
|
3154
3147
|
}
|
|
3155
3148
|
async delete(id) {
|
|
3156
3149
|
return await this.db.transaction(async (tx) => {
|
|
3157
|
-
|
|
3158
|
-
if (userIds.length > 0) {
|
|
3159
|
-
await tx.delete(userContacts).where(inArray(userContacts.userId, userIds));
|
|
3160
|
-
await tx.delete(userSegments).where(inArray(userSegments.userId, userIds));
|
|
3161
|
-
await tx.delete(userTopicPreferences).where(inArray(userTopicPreferences.userId, userIds));
|
|
3162
|
-
await tx.delete(userChannelPreferences).where(inArray(userChannelPreferences.userId, userIds));
|
|
3163
|
-
await tx.delete(quietHours).where(inArray(quietHours.userId, userIds));
|
|
3164
|
-
await tx.delete(users).where(eq(users.projectId, id));
|
|
3165
|
-
}
|
|
3150
|
+
await tx.delete(users).where(eq(users.projectId, id));
|
|
3166
3151
|
await tx.delete(suppressions).where(eq(suppressions.projectId, id));
|
|
3167
3152
|
await tx.delete(messageLogs).where(eq(messageLogs.projectId, id));
|
|
3168
3153
|
await tx.delete(workflowInstances).where(eq(workflowInstances.projectId, id));
|
|
@@ -3201,6 +3186,8 @@ var ProjectRepository = class {
|
|
|
3201
3186
|
return (await this.db.delete(projectApiKeys).where(and(eq(projectApiKeys.id, keyId), eq(projectApiKeys.projectId, projectId))).returning()).length > 0;
|
|
3202
3187
|
}
|
|
3203
3188
|
};
|
|
3189
|
+
//#endregion
|
|
3190
|
+
//#region src/repositories/workflow.ts
|
|
3204
3191
|
var WorkflowRepository = class {
|
|
3205
3192
|
db;
|
|
3206
3193
|
constructor(db) {
|
|
@@ -3228,6 +3215,8 @@ var WorkflowRepository = class {
|
|
|
3228
3215
|
});
|
|
3229
3216
|
}
|
|
3230
3217
|
};
|
|
3218
|
+
//#endregion
|
|
3219
|
+
//#region src/repositories/segment.ts
|
|
3231
3220
|
var SegmentRepository = class {
|
|
3232
3221
|
db;
|
|
3233
3222
|
constructor(db) {
|
|
@@ -3242,6 +3231,8 @@ var SegmentRepository = class {
|
|
|
3242
3231
|
`)).map((r) => r.segment);
|
|
3243
3232
|
}
|
|
3244
3233
|
};
|
|
3234
|
+
//#endregion
|
|
3235
|
+
//#region src/repositories/admin-user.ts
|
|
3245
3236
|
var AdminUserRepository = class {
|
|
3246
3237
|
db;
|
|
3247
3238
|
constructor(db) {
|
|
@@ -3262,12 +3253,14 @@ var AdminUserRepository = class {
|
|
|
3262
3253
|
role: data.role || "admin"
|
|
3263
3254
|
}).returning())[0];
|
|
3264
3255
|
}
|
|
3256
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
3265
3257
|
async updatePassword(id, passwordHash) {
|
|
3266
3258
|
return (await this.db.update(adminUsers).set({
|
|
3267
3259
|
passwordHash,
|
|
3268
3260
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3269
3261
|
}).where(eq(adminUsers.id, id)).returning()).length > 0;
|
|
3270
3262
|
}
|
|
3263
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
3271
3264
|
async list() {
|
|
3272
3265
|
return await this.db.select({
|
|
3273
3266
|
id: adminUsers.id,
|
|
@@ -3291,6 +3284,7 @@ function escapeHtml(unsafe) {
|
|
|
3291
3284
|
function escapeHeader(unsafe) {
|
|
3292
3285
|
return String(unsafe).replace(/[\r\n]+/g, " ").trim();
|
|
3293
3286
|
}
|
|
3287
|
+
/** @deprecated Unused; templates render through renderWithTemplate. Removed in the next minor version. */
|
|
3294
3288
|
function interpolate(tmpl, variables, sanitize = true) {
|
|
3295
3289
|
return tmpl.replace(/\{\{\{(\w+)\}\}\}/g, (_, k) => {
|
|
3296
3290
|
return String(variables[k] ?? "");
|
|
@@ -3584,7 +3578,12 @@ var BaseWorker = class {
|
|
|
3584
3578
|
this.state = "stopping";
|
|
3585
3579
|
await this.consumer.stop();
|
|
3586
3580
|
this.stopRecoveryLoop();
|
|
3587
|
-
if (this.runLoop)
|
|
3581
|
+
if (this.runLoop) {
|
|
3582
|
+
let timer;
|
|
3583
|
+
await Promise.race([this.runLoop, new Promise((_, reject) => {
|
|
3584
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error("Worker stop timeout")), 3e4);
|
|
3585
|
+
})]).catch((err) => this.logger.warn({ err }, "Worker shutdown timeout or error")).finally(() => clearTimeout(timer));
|
|
3586
|
+
}
|
|
3588
3587
|
this.logger.info("worker shutdown complete");
|
|
3589
3588
|
}
|
|
3590
3589
|
async recover() {
|
|
@@ -3817,6 +3816,7 @@ function buildStepNotifyPayload(args, instanceInput, projectId, idempotencyKey,
|
|
|
3817
3816
|
fallback: args.fallback ?? false,
|
|
3818
3817
|
scheduledAt: args.sendAt,
|
|
3819
3818
|
idempotencyKey,
|
|
3819
|
+
campaignId: args.campaign,
|
|
3820
3820
|
...workflowInstanceId ? { workflowInstanceId } : {}
|
|
3821
3821
|
};
|
|
3822
3822
|
}
|
|
@@ -3886,7 +3886,7 @@ var NotifkitClient = class {
|
|
|
3886
3886
|
return this.request("/v1/users", "POST", idOrInput);
|
|
3887
3887
|
}
|
|
3888
3888
|
async identify(idOrInput, contacts, options) {
|
|
3889
|
-
return this.addUser(idOrInput, contacts, options);
|
|
3889
|
+
return typeof idOrInput === "string" ? this.addUser(idOrInput, contacts, options) : this.addUser(idOrInput);
|
|
3890
3890
|
}
|
|
3891
3891
|
/** Update user profile. */
|
|
3892
3892
|
async updateUser(id, input) {
|
|
@@ -4194,35 +4194,35 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4194
4194
|
}
|
|
4195
4195
|
const startupPromises = [];
|
|
4196
4196
|
if (services.includes("api")) {
|
|
4197
|
-
const { startApiServer } = await import("./main-
|
|
4197
|
+
const { startApiServer } = await import("./main-g1KEcXXp.mjs");
|
|
4198
4198
|
startupPromises.push(startApiServer());
|
|
4199
4199
|
}
|
|
4200
4200
|
if (services.includes("delivery")) {
|
|
4201
|
-
const { startDeliveryWorker } = await import("./main-
|
|
4201
|
+
const { startDeliveryWorker } = await import("./main-B82bsFoy.mjs");
|
|
4202
4202
|
startupPromises.push(startDeliveryWorker());
|
|
4203
4203
|
}
|
|
4204
4204
|
if (services.includes("engine")) {
|
|
4205
|
-
const { startEngineWorker } = await import("./main-
|
|
4205
|
+
const { startEngineWorker } = await import("./main-8nP3qmCT.mjs");
|
|
4206
4206
|
startupPromises.push(startEngineWorker());
|
|
4207
4207
|
}
|
|
4208
4208
|
if (services.includes("enricher")) {
|
|
4209
|
-
const { startEnricherWorker } = await import("./main-
|
|
4209
|
+
const { startEnricherWorker } = await import("./main-DULD8-th.mjs");
|
|
4210
4210
|
startupPromises.push(startEnricherWorker());
|
|
4211
4211
|
}
|
|
4212
4212
|
if (services.includes("scheduler")) {
|
|
4213
|
-
const { startSchedulerWorker } = await import("./main-
|
|
4213
|
+
const { startSchedulerWorker } = await import("./main-CpaHF1Zw.mjs");
|
|
4214
4214
|
startupPromises.push(startSchedulerWorker());
|
|
4215
4215
|
}
|
|
4216
4216
|
if (services.includes("ai")) {
|
|
4217
|
-
const { startAiWorker } = await import("./main-
|
|
4217
|
+
const { startAiWorker } = await import("./main-6_bXQBDH.mjs");
|
|
4218
4218
|
startupPromises.push(startAiWorker());
|
|
4219
4219
|
}
|
|
4220
4220
|
if (services.includes("workflow")) {
|
|
4221
|
-
const { startWorkflowWorker } = await import("./main-
|
|
4221
|
+
const { startWorkflowWorker } = await import("./main-ZW5RaiOK.mjs");
|
|
4222
4222
|
startupPromises.push(startWorkflowWorker());
|
|
4223
4223
|
}
|
|
4224
4224
|
if (services.includes("events")) {
|
|
4225
|
-
const { startEventWorker } = await import("./main-
|
|
4225
|
+
const { startEventWorker } = await import("./main-mGIT8jv4.mjs");
|
|
4226
4226
|
startupPromises.push(startEventWorker());
|
|
4227
4227
|
}
|
|
4228
4228
|
const handleSignal = async (signal) => {
|
|
@@ -4244,9 +4244,9 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4244
4244
|
await Promise.all(startupPromises);
|
|
4245
4245
|
if (readBaseConfig().PIPELINE_FUSED && services.includes("enricher") && services.includes("engine") && services.includes("delivery")) {
|
|
4246
4246
|
const [{ getEnricherWorker }, { getEngineWorker }, { getDeliveryWorker }] = await Promise.all([
|
|
4247
|
-
import("./main-
|
|
4248
|
-
import("./main-
|
|
4249
|
-
import("./main-
|
|
4247
|
+
import("./main-DULD8-th.mjs"),
|
|
4248
|
+
import("./main-8nP3qmCT.mjs"),
|
|
4249
|
+
import("./main-B82bsFoy.mjs")
|
|
4250
4250
|
]);
|
|
4251
4251
|
const enricher = getEnricherWorker();
|
|
4252
4252
|
const engine = getEngineWorker();
|
|
@@ -4277,14 +4277,14 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4277
4277
|
"events"
|
|
4278
4278
|
] : this.options.services;
|
|
4279
4279
|
const shutdownOrder = [
|
|
4280
|
-
["api", async () => (await import("./main-
|
|
4281
|
-
["workflow", async () => (await import("./main-
|
|
4282
|
-
["enricher", async () => (await import("./main-
|
|
4283
|
-
["ai", async () => (await import("./main-
|
|
4284
|
-
["engine", async () => (await import("./main-
|
|
4285
|
-
["scheduler", async () => (await import("./main-
|
|
4286
|
-
["delivery", async () => (await import("./main-
|
|
4287
|
-
["events", async () => (await import("./main-
|
|
4280
|
+
["api", async () => (await import("./main-g1KEcXXp.mjs")).stopApiServer()],
|
|
4281
|
+
["workflow", async () => (await import("./main-ZW5RaiOK.mjs")).stopWorkflowWorker()],
|
|
4282
|
+
["enricher", async () => (await import("./main-DULD8-th.mjs")).stopEnricherWorker()],
|
|
4283
|
+
["ai", async () => (await import("./main-6_bXQBDH.mjs")).stopAiWorker()],
|
|
4284
|
+
["engine", async () => (await import("./main-8nP3qmCT.mjs")).stopEngineWorker()],
|
|
4285
|
+
["scheduler", async () => (await import("./main-CpaHF1Zw.mjs")).stopSchedulerWorker()],
|
|
4286
|
+
["delivery", async () => (await import("./main-B82bsFoy.mjs")).stopDeliveryWorker()],
|
|
4287
|
+
["events", async () => (await import("./main-mGIT8jv4.mjs")).stopEventWorker()]
|
|
4288
4288
|
];
|
|
4289
4289
|
for (const [name, stop] of shutdownOrder) if (services.includes(name)) await stop();
|
|
4290
4290
|
if (this.pgContainer) {
|
|
@@ -4298,4 +4298,4 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4298
4298
|
}
|
|
4299
4299
|
};
|
|
4300
4300
|
//#endregion
|
|
4301
|
-
export {
|
|
4301
|
+
export { assertTablesInSchema as $, OUTBOUND_STREAMS as $t, LUA_ACQUIRE_LEASE as A, globalEmitter as An, NotificationTargetSchema as At, redactUrl as B, QuietHoursSchema as Bt, SegmentRepository as C, DataLoader as Cn, NotificationDispatchedPayloadSchema as Ct, ContactRepository as D, getPriorityBucket as Dn, RecipientProfileSchema as Dt, TemplateRepository as E, AsyncSemaphore as En, NotificationEnrichedPayloadSchema as Et, LUA_RENEW_LOCK as F, CreateWorkflowSchema as Ft, ProjectSettingsCache as G, UpdateUserSchema as Gt, ApiRateLimiter as H, TemplateSchema as Ht, LUA_SCHEDULER_POLL as I, IngestEventSchema as It, StreamProducer as J, WorkflowStepSchema as Jt, PendingMessageScanner as K, UserContactInputSchema as Kt, LUA_USER_THROTTLE as L, InlineUserSchema as Lt, LUA_LEASE_API_RATE_LIMIT as M, AddUserSchema as Mt, LUA_MARK_PROCESSED as N, BatchAddContactsSchema as Nt, PreferenceRepository as O, normaliseTarget as On, NotificationCreatedPayloadSchema as Ot, LUA_RELEASE_LOCK as P, ContactChannelSchema as Pt, IdempotencyGuard as Q, INBOUND_STREAMS as Qt, Redis as R, NotifyRequestSchema as Rt, AdminUserRepository as S, sleep as Sn, DeliveryOptionsSchema as St, ProjectRepository as T, BatchProcessor as Tn, NotificationScheduledPayloadSchema as Tt, calculateTokenBatchSize as U, TriggerWorkflowSchema as Ut, registerCustomCommands as V, SyncTemplatesSchema as Vt, UserThrottle as W, UpdateProjectSchema as Wt, metrics as X, CONSUMER_GROUPS as Xt, getMetricsRegistry as Y, buildStreamEvent as Yt, createLogger as Z, ENRICHED_STREAMS as Zt, TemplateCache as _, setAiConfig as _n, NotificationAiPendingPayloadSchema as _t, SuspendExecutionError as a, EventRegistry as an, deliveryOutbox as at, interpolate as b, ValidationError as bn, NotificationFailedPayloadSchema as bt, BaseWorker as c, NotificationChannelSchema as cn, projects as ct, startHealthReporter as d, AI_DEFAULTS as dn, userTopicPreferences as dt, PUBSUB_CHANNELS as en, createDatabase as et, buildUnsubscribeHeaders as f, baseConfigSchema as fn, users as ft, transportRegistry as g, readBaseConfig as gn, workflowWaiters as gt, registerTransport as h, parseConfig as hn, workflowSteps as ht, workflowRegistry as i, StreamEventSchema as in, runMigrations as it, LUA_COUNT_REQUEST as j, AddContactSchema as jt, UserRepository as k, LRUCache as kn, NotificationRequestedPayloadSchema as kt, LockHeldError as l, NotificationPrioritySchema as ln, scheduledPayloads as lt, verifyUnsubscribeToken as m, loadEnv as mn, workflowInstances as mt, NotifkitClient as n, EventEnvelopeSchema as nn, notifkitTableNames as nt, buildStepNotifyPayload as o, registry as on, messageLogs as ot, signUnsubscribeToken as p, getAiConfig as pn, workflowDefinitions as pt, StreamConsumer as q, WorkflowNotifyPayloadSchema as qt, workflow as r, StreamEventMetadataSchema as rn, qualifyMigrationSql as rt, resolveStepTarget as s, EventMetadataSchema as sn, projectApiKeys as st, NotifkitServer as t, STREAMS as tn, migrateDatabase as tt, NonRetryableError as u, NotificationStatusSchema as un, suppressions as ut, escapeHeader as v, setGlobalConfig as vn, NotificationCanceledPayloadSchema as vt, WorkflowRepository as w, CircuitBreaker as wn, RenderedContentSchema as wt, renderWithTemplate as x, generateId as xn, NotificationDeliveredPayloadSchema as xt, escapeHtml as y, AppError as yn, NotificationSkippedPayloadSchema as yt, RedisClient as z, PreferencesSchema as zt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notifkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Self-hosted notification infrastructure. One call delivers to email, SMS, push, and webhook — routed by preference, quiet hours, and consent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "devkitshq",
|
|
@@ -41,11 +41,15 @@ try {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (res.status === 401) {
|
|
44
|
-
fail(
|
|
44
|
+
fail(
|
|
45
|
+
"admin credential rejected. It must match the server's ADMIN_API_KEY exactly, " +
|
|
46
|
+
"and the server must have been started with ADMIN_API_KEY set.",
|
|
47
|
+
);
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
// The server answers 403 only to a dashboard session whose user is read-only.
|
|
47
51
|
if (res.status === 403) {
|
|
48
|
-
fail("
|
|
52
|
+
fail("that credential is a read-only dashboard session. Use the server's ADMIN_API_KEY.");
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
if (!res.ok) {
|
package/src/client.ts
CHANGED
|
@@ -123,7 +123,9 @@ export class NotifkitClient {
|
|
|
123
123
|
contacts?: UserContactInput[],
|
|
124
124
|
options?: Omit<AddUserInput, "id" | "contacts">,
|
|
125
125
|
): Promise<{ id: string }> {
|
|
126
|
-
return
|
|
126
|
+
return typeof idOrInput === "string"
|
|
127
|
+
? this.addUser(idOrInput, contacts, options)
|
|
128
|
+
: this.addUser(idOrInput);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
/** Update user profile. */
|
|
@@ -192,8 +194,6 @@ export class NotifkitClient {
|
|
|
192
194
|
return this.syncTemplates({ templates: this.options.templates });
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
// ─── Missing Endpoints additions ─────────────────────────────────────────────
|
|
196
|
-
|
|
197
197
|
/** List registered workflow definitions. */
|
|
198
198
|
async listWorkflows(options?: {
|
|
199
199
|
limit?: number;
|
package/src/config/index.ts
CHANGED
|
@@ -128,6 +128,7 @@ export function readBaseConfig(data: NodeJS.ProcessEnv = process.env): BaseConfi
|
|
|
128
128
|
return parseConfig(baseConfigSchema, data);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
131
132
|
export interface RateLimitConfig {
|
|
132
133
|
limit: number;
|
|
133
134
|
windowSeconds: number;
|
package/src/contracts/common.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type NotificationChannel = z.infer<typeof NotificationChannelSchema>;
|
|
|
16
16
|
export const NotificationPrioritySchema = z.enum(["low", "normal", "high", "critical"]);
|
|
17
17
|
export type NotificationPriority = z.infer<typeof NotificationPrioritySchema>;
|
|
18
18
|
|
|
19
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
19
20
|
export const NotificationStatusSchema = z.enum([
|
|
20
21
|
"pending",
|
|
21
22
|
"queued",
|
|
@@ -25,4 +26,5 @@ export const NotificationStatusSchema = z.enum([
|
|
|
25
26
|
"bounced",
|
|
26
27
|
"suppressed",
|
|
27
28
|
]);
|
|
29
|
+
/** @deprecated Unused; removed in the next minor version. */
|
|
28
30
|
export type NotificationStatus = z.infer<typeof NotificationStatusSchema>;
|
|
@@ -24,7 +24,7 @@ export type TypedEventEnvelope<K extends KnownEventType> = Omit<
|
|
|
24
24
|
payload: EventPayloadMap[K];
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// The name the queue and workers use for an envelope.
|
|
28
28
|
export type StreamEvent = EventEnvelope;
|
|
29
29
|
export const StreamEventSchema = EventEnvelopeSchema;
|
|
30
30
|
export type StreamEventMetadata = EventMetadata;
|