notifkit 0.1.18 → 0.1.20
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/README.md +1 -4
- package/dist/{bootstrap-Cs1XIp6b.mjs → bootstrap-U1F11-js.mjs} +1 -1
- package/dist/{bulk-4pRIiG2o.mjs → bulk-B1Jg4m15.mjs} +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{main-Bl0S4GDd.mjs → main-0Tug88vm.mjs} +3 -3
- package/dist/{main-yL5VinQ5.mjs → main-B58UJ-o1.mjs} +2 -2
- package/dist/{main-Ppr7Pq1g.mjs → main-BndrE3SN.mjs} +2 -2
- package/dist/{main-C5DiM7_r.mjs → main-BnjkQTh3.mjs} +3 -3
- package/dist/{main-BN7ZfvxN.mjs → main-DMTiTQn5.mjs} +3 -3
- package/dist/{main-DVzp0DLn.mjs → main-DmUMrkvb.mjs} +3 -3
- package/dist/{main-O9iZ6iz2.mjs → main-DrTuMt92.mjs} +2 -2
- package/dist/{main-zgxAlH3l.mjs → main-d4ozU_Uk.mjs} +1 -1
- package/dist/{schedule-or-dispatch-BwCZWS_P.mjs → schedule-or-dispatch-Ce_9gHJL.mjs} +1 -1
- package/dist/{src-C38w4jR4.mjs → src-CDVyt2X2.mjs} +47 -23
- package/package.json +1 -1
- package/src/contracts/sdk.ts +41 -12
- package/src/server.ts +10 -0
- package/src/transport/index.ts +2 -0
package/README.md
CHANGED
|
@@ -10,10 +10,6 @@ Self-hosted notification infrastructure for product notifications. One API call
|
|
|
10
10
|
|
|
11
11
|
[Documentation](https://notifkit.dev/docs/) · [Quickstart](https://notifkit.dev/docs/quickstart.html) · [Examples](https://notifkit.dev/docs/examples.html) · [Production support](#production-support) · [notifkit.dev](https://notifkit.dev)
|
|
12
12
|
|
|
13
|
-
https://github.com/user-attachments/assets/ad8955bd-4205-4d47-8dfc-9010abd3ad62
|
|
14
|
-
|
|
15
|
-
(note: this video is generated using claude)
|
|
16
|
-
|
|
17
13
|
</div>
|
|
18
14
|
|
|
19
15
|
Like Knock or Courier, except it runs on the PostgreSQL and Redis you already have, your workflows live in your code, and there is no per-message bill.
|
|
@@ -96,6 +92,7 @@ Longer comparisons: [Novu](https://notifkit.dev/docs/vs/novu.html) · [Knock](ht
|
|
|
96
92
|
Bring your own provider accounts. First-party packages:
|
|
97
93
|
|
|
98
94
|
- [`@notifkit/provider-resend`](./packages/provider-resend): transactional email via Resend
|
|
95
|
+
- [`@notifkit/provider-smtp`](./packages/provider-smtp): email through any SMTP server, via nodemailer
|
|
99
96
|
- [`@notifkit/provider-fcm`](./packages/provider-fcm): push notifications via Firebase Cloud Messaging
|
|
100
97
|
- [`@notifkit/provider-twilio`](./packages/provider-twilio): SMS via Twilio, with signature-verified delivery status callbacks
|
|
101
98
|
- [`@notifkit/provider-slack`](./packages/provider-slack): Slack messages via Incoming Webhooks or the Web API
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as STREAMS, G as StreamConsumer, K as StreamProducer, L as RedisClient, Q as createDatabase, W as PendingMessageScanner, Y as createLogger } from "./src-
|
|
1
|
+
import { $t as STREAMS, G as StreamConsumer, K as StreamProducer, L as RedisClient, Q as createDatabase, W as PendingMessageScanner, Y as createLogger } from "./src-CDVyt2X2.mjs";
|
|
2
2
|
//#region src/workers/bootstrap.ts
|
|
3
3
|
/** Logger, shared Redis connection and Postgres pool for one service. */
|
|
4
4
|
function createWorkerRuntime(config, name, loggerName = name) {
|
package/dist/index.d.mts
CHANGED
|
@@ -4795,6 +4795,8 @@ interface Transport {
|
|
|
4795
4795
|
windowSeconds: number;
|
|
4796
4796
|
};
|
|
4797
4797
|
send(task: NotificationDispatchedPayload): Promise<DeliveryResult>;
|
|
4798
|
+
/** Releases held connections. `NotifkitServer.stop()` calls it after delivery stops. */
|
|
4799
|
+
close?: () => void | Promise<void>;
|
|
4798
4800
|
webhookPath?: string;
|
|
4799
4801
|
/**
|
|
4800
4802
|
* Handles the one-time GET verification handshake some providers require
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as migrateDatabase, $t as STREAMS, A as LUA_COUNT_REQUEST, At as AddUserSchema, B as ApiRateLimiter, Bt as TemplateSchema, C as SegmentRepository, Cn as BatchProcessor, Ct as NotificationScheduledPayloadSchema, D as ContactRepository, Dn as LRUCache, Dt as NotificationRequestedPayloadSchema, E as TemplateRepository, En as normaliseTarget, Et as NotificationCreatedPayloadSchema, F as LUA_USER_THROTTLE, Ft as InlineUserSchema, G as StreamConsumer, Gt as WorkflowNotifyPayloadSchema, H as UserThrottle, Ht as UpdateProjectSchema, I as Redis, It as NotifyRequestSchema, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, Kt as WorkflowStepSchema, L as RedisClient, Lt as PreferencesSchema, M as LUA_RELEASE_LOCK, Mt as ContactChannelSchema, N as LUA_RENEW_LOCK, Nt as CreateWorkflowSchema, O as PreferenceRepository, On as globalEmitter, Ot as NotificationTargetSchema, P as LUA_SCHEDULER_POLL, Pt as IngestEventSchema, Q as createDatabase, Qt as PUBSUB_CHANNELS, R as redactUrl, Rt as QuietHoursSchema, S as AdminUserRepository, Sn as CircuitBreaker, St as RenderedContentSchema, T as ProjectRepository, Tn as getPriorityBucket, Tt as RecipientProfileSchema, U as ProjectSettingsCache, Ut as UpdateUserSchema, V as calculateTokenBatchSize, Vt as TriggerWorkflowSchema, W as PendingMessageScanner, Wt as UserContactInputSchema, X as IdempotencyGuard, Xt as INBOUND_STREAMS, Y as createLogger, Yt as ENRICHED_STREAMS, Z as assertTablesInSchema, Zt as OUTBOUND_STREAMS, _ as TemplateCache, _n as AppError, _t as NotificationSkippedPayloadSchema, a as SuspendExecutionError, an as EventMetadataSchema, b as interpolate, bn as sleep, bt as DeliveryOptionsSchema, c as BaseWorker, cn as NotificationStatusSchema, d as startHealthReporter, dn as getAiConfig, en as EventEnvelopeSchema, et as notifkitTableNames, f as buildUnsubscribeHeaders, fn as loadEnv, g as transportRegistry, gn as setGlobalConfig, gt as NotificationCanceledPayloadSchema, h as registerTransport, hn as setAiConfig, ht as NotificationAiPendingPayloadSchema, i as workflowRegistry, in as registry, j as LUA_LEASE_API_RATE_LIMIT, jt as BatchAddContactsSchema, k as UserRepository, kt as AddContactSchema, l as LockHeldError, ln as AI_DEFAULTS, m as verifyUnsubscribeToken, mn as readBaseConfig, n as NotifkitClient, nn as StreamEventSchema, nt as runMigrations, o as buildStepNotifyPayload, on as NotificationChannelSchema, p as signUnsubscribeToken, pn as parseConfig, q as getMetricsRegistry, qt as buildStreamEvent, r as workflow, rn as EventRegistry, s as resolveStepTarget, sn as NotificationPrioritySchema, t as NotifkitServer, tn as StreamEventMetadataSchema, tt as qualifyMigrationSql, u as NonRetryableError, un as baseConfigSchema, v as escapeHeader, vn as ValidationError, vt as NotificationFailedPayloadSchema, w as WorkflowRepository, wn as AsyncSemaphore, wt as NotificationEnrichedPayloadSchema, x as renderWithTemplate, xn as DataLoader, xt as NotificationDispatchedPayloadSchema, y as escapeHtml, yn as generateId, yt as NotificationDeliveredPayloadSchema, z as registerCustomCommands, zt as SyncTemplatesSchema } from "./src-
|
|
1
|
+
import { $ as migrateDatabase, $t as STREAMS, A as LUA_COUNT_REQUEST, At as AddUserSchema, B as ApiRateLimiter, Bt as TemplateSchema, C as SegmentRepository, Cn as BatchProcessor, Ct as NotificationScheduledPayloadSchema, D as ContactRepository, Dn as LRUCache, Dt as NotificationRequestedPayloadSchema, E as TemplateRepository, En as normaliseTarget, Et as NotificationCreatedPayloadSchema, F as LUA_USER_THROTTLE, Ft as InlineUserSchema, G as StreamConsumer, Gt as WorkflowNotifyPayloadSchema, H as UserThrottle, Ht as UpdateProjectSchema, I as Redis, It as NotifyRequestSchema, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, Kt as WorkflowStepSchema, L as RedisClient, Lt as PreferencesSchema, M as LUA_RELEASE_LOCK, Mt as ContactChannelSchema, N as LUA_RENEW_LOCK, Nt as CreateWorkflowSchema, O as PreferenceRepository, On as globalEmitter, Ot as NotificationTargetSchema, P as LUA_SCHEDULER_POLL, Pt as IngestEventSchema, Q as createDatabase, Qt as PUBSUB_CHANNELS, R as redactUrl, Rt as QuietHoursSchema, S as AdminUserRepository, Sn as CircuitBreaker, St as RenderedContentSchema, T as ProjectRepository, Tn as getPriorityBucket, Tt as RecipientProfileSchema, U as ProjectSettingsCache, Ut as UpdateUserSchema, V as calculateTokenBatchSize, Vt as TriggerWorkflowSchema, W as PendingMessageScanner, Wt as UserContactInputSchema, X as IdempotencyGuard, Xt as INBOUND_STREAMS, Y as createLogger, Yt as ENRICHED_STREAMS, Z as assertTablesInSchema, Zt as OUTBOUND_STREAMS, _ as TemplateCache, _n as AppError, _t as NotificationSkippedPayloadSchema, a as SuspendExecutionError, an as EventMetadataSchema, b as interpolate, bn as sleep, bt as DeliveryOptionsSchema, c as BaseWorker, cn as NotificationStatusSchema, d as startHealthReporter, dn as getAiConfig, en as EventEnvelopeSchema, et as notifkitTableNames, f as buildUnsubscribeHeaders, fn as loadEnv, g as transportRegistry, gn as setGlobalConfig, gt as NotificationCanceledPayloadSchema, h as registerTransport, hn as setAiConfig, ht as NotificationAiPendingPayloadSchema, i as workflowRegistry, in as registry, j as LUA_LEASE_API_RATE_LIMIT, jt as BatchAddContactsSchema, k as UserRepository, kt as AddContactSchema, l as LockHeldError, ln as AI_DEFAULTS, m as verifyUnsubscribeToken, mn as readBaseConfig, n as NotifkitClient, nn as StreamEventSchema, nt as runMigrations, o as buildStepNotifyPayload, on as NotificationChannelSchema, p as signUnsubscribeToken, pn as parseConfig, q as getMetricsRegistry, qt as buildStreamEvent, r as workflow, rn as EventRegistry, s as resolveStepTarget, sn as NotificationPrioritySchema, t as NotifkitServer, tn as StreamEventMetadataSchema, tt as qualifyMigrationSql, u as NonRetryableError, un as baseConfigSchema, v as escapeHeader, vn as ValidationError, vt as NotificationFailedPayloadSchema, w as WorkflowRepository, wn as AsyncSemaphore, wt as NotificationEnrichedPayloadSchema, x as renderWithTemplate, xn as DataLoader, xt as NotificationDispatchedPayloadSchema, y as escapeHtml, yn as generateId, yt as NotificationDeliveredPayloadSchema, z as registerCustomCommands, zt as SyncTemplatesSchema } from "./src-CDVyt2X2.mjs";
|
|
2
2
|
export { AI_DEFAULTS, AddContactSchema, AddUserSchema, AdminUserRepository, ApiRateLimiter, AppError, AsyncSemaphore, BaseWorker, BatchAddContactsSchema, BatchProcessor, CONSUMER_GROUPS, CircuitBreaker, ContactChannelSchema, ContactRepository, CreateWorkflowSchema, DataLoader, DeliveryOptionsSchema, ENRICHED_STREAMS, EventEnvelopeSchema, EventMetadataSchema, EventRegistry, INBOUND_STREAMS, IdempotencyGuard, IngestEventSchema, InlineUserSchema, LRUCache, LUA_COUNT_REQUEST, LUA_LEASE_API_RATE_LIMIT, LUA_RELEASE_LOCK, LUA_RENEW_LOCK, LUA_SCHEDULER_POLL, LUA_USER_THROTTLE, LockHeldError, NonRetryableError, NotificationAiPendingPayloadSchema, NotificationCanceledPayloadSchema, NotificationChannelSchema, NotificationCreatedPayloadSchema, NotificationDeliveredPayloadSchema, NotificationDispatchedPayloadSchema, NotificationEnrichedPayloadSchema, NotificationFailedPayloadSchema, NotificationPrioritySchema, NotificationRequestedPayloadSchema, NotificationScheduledPayloadSchema, NotificationSkippedPayloadSchema, NotificationStatusSchema, NotificationTargetSchema, NotifkitClient, NotifkitServer, NotifyRequestSchema, OUTBOUND_STREAMS, PUBSUB_CHANNELS, PendingMessageScanner, PreferenceRepository, PreferencesSchema, ProjectRepository, ProjectSettingsCache, QuietHoursSchema, RecipientProfileSchema, Redis, RedisClient, RenderedContentSchema, STREAMS, SegmentRepository, StreamConsumer, StreamEventMetadataSchema, StreamEventSchema, StreamProducer, SuspendExecutionError, SyncTemplatesSchema, TemplateCache, TemplateRepository, TemplateSchema, TriggerWorkflowSchema, UpdateProjectSchema, UpdateUserSchema, UserContactInputSchema, UserRepository, UserThrottle, ValidationError, WorkflowNotifyPayloadSchema, WorkflowRepository, WorkflowStepSchema, assertTablesInSchema, baseConfigSchema, buildStepNotifyPayload, buildStreamEvent, buildUnsubscribeHeaders, calculateTokenBatchSize, createDatabase, createLogger, escapeHeader, escapeHtml, generateId, getAiConfig, getMetricsRegistry, getPriorityBucket, globalEmitter, interpolate, loadEnv, metrics, migrateDatabase, normaliseTarget, notifkitTableNames, parseConfig, qualifyMigrationSql, readBaseConfig, redactUrl, registerCustomCommands, registerTransport, registry, renderWithTemplate, resolveStepTarget, runMigrations, setAiConfig, setGlobalConfig, signUnsubscribeToken, sleep, startHealthReporter, transportRegistry, verifyUnsubscribeToken, workflow, workflowRegistry };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $t as STREAMS, E as TemplateRepository, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, R as redactUrl, X as IdempotencyGuard, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, dn as getAiConfig, fn as loadEnv, in as registry, ln as AI_DEFAULTS, mn as readBaseConfig, x as renderWithTemplate } from "./src-
|
|
2
|
-
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-
|
|
3
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
1
|
+
import { $t as STREAMS, E as TemplateRepository, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, R as redactUrl, X as IdempotencyGuard, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, dn as getAiConfig, fn as loadEnv, in as registry, ln as AI_DEFAULTS, mn as readBaseConfig, x as renderWithTemplate } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-Ce_9gHJL.mjs";
|
|
3
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-U1F11-js.mjs";
|
|
4
4
|
import { generateText } from "ai";
|
|
5
5
|
//#region src/services/ai/main.ts
|
|
6
6
|
loadEnv();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as ContactRepository, E as TemplateRepository, Jt as CONSUMER_GROUPS, On as globalEmitter, Tn as getPriorityBucket, X as IdempotencyGuard, Xt as INBOUND_STREAMS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, fn as loadEnv, in as registry, k as UserRepository, mn as readBaseConfig, qt as buildStreamEvent } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
1
|
+
import { D as ContactRepository, E as TemplateRepository, Jt as CONSUMER_GROUPS, On as globalEmitter, Tn as getPriorityBucket, X as IdempotencyGuard, Xt as INBOUND_STREAMS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, fn as loadEnv, in as registry, k as UserRepository, mn as readBaseConfig, qt as buildStreamEvent } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-U1F11-js.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/services/enricher/main.ts
|
|
5
5
|
loadEnv();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $t as STREAMS, D as ContactRepository, E as TemplateRepository, En as normaliseTarget, Jt as CONSUMER_GROUPS, On as globalEmitter, Tn as getPriorityBucket, c as BaseWorker, ct as suppressions, d as startHealthReporter, fn as loadEnv, in as registry, it as messageLogs, k as UserRepository, mn as readBaseConfig, qt as buildStreamEvent, rt as deliveryOutbox, st as scheduledPayloads } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
1
|
+
import { $t as STREAMS, D as ContactRepository, E as TemplateRepository, En as normaliseTarget, Jt as CONSUMER_GROUPS, On as globalEmitter, Tn as getPriorityBucket, c as BaseWorker, ct as suppressions, d as startHealthReporter, fn as loadEnv, in as registry, it as messageLogs, k as UserRepository, mn as readBaseConfig, qt as buildStreamEvent, rt as deliveryOutbox, st as scheduledPayloads } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-U1F11-js.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { and, asc, eq, gt, inArray, or, sql } from "drizzle-orm";
|
|
5
5
|
//#region src/services/scheduler/send-gate.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $t as STREAMS, Jt as CONSUMER_GROUPS, K as StreamProducer, c as BaseWorker, d as startHealthReporter, fn as loadEnv, ft as workflowInstances, mn as readBaseConfig, mt as workflowWaiters, pt as workflowSteps, qt as buildStreamEvent } from "./src-
|
|
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 { $t as STREAMS, Jt as CONSUMER_GROUPS, K as StreamProducer, c as BaseWorker, d as startHealthReporter, fn as loadEnv, ft as workflowInstances, mn as readBaseConfig, mt as workflowWaiters, pt as workflowSteps, qt as buildStreamEvent } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-U1F11-js.mjs";
|
|
3
|
+
import { t as insertMessageLogs } from "./bulk-B1Jg4m15.mjs";
|
|
4
4
|
import { and, eq, gt, isNull, or } from "drizzle-orm";
|
|
5
5
|
//#region src/services/events/main.ts
|
|
6
6
|
loadEnv();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $t as STREAMS, D as ContactRepository, Dn as LRUCache, E as TemplateRepository, En as normaliseTarget, H as UserThrottle, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, T as ProjectRepository, U as ProjectSettingsCache, X as IdempotencyGuard, Yt as ENRICHED_STREAMS, _ as TemplateCache, c as BaseWorker, ct as suppressions, d as startHealthReporter, f as buildUnsubscribeHeaders, fn as loadEnv, in as registry, mn as readBaseConfig, qt as buildStreamEvent, xn as DataLoader } from "./src-
|
|
2
|
-
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-
|
|
3
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
1
|
+
import { $t as STREAMS, D as ContactRepository, Dn as LRUCache, E as TemplateRepository, En as normaliseTarget, H as UserThrottle, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, T as ProjectRepository, U as ProjectSettingsCache, X as IdempotencyGuard, Yt as ENRICHED_STREAMS, _ as TemplateCache, c as BaseWorker, ct as suppressions, d as startHealthReporter, f as buildUnsubscribeHeaders, fn as loadEnv, in as registry, mn as readBaseConfig, qt as buildStreamEvent, xn as DataLoader } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-Ce_9gHJL.mjs";
|
|
3
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-U1F11-js.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { and, eq } from "drizzle-orm";
|
|
6
6
|
//#region src/services/engine/quiet-hours.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $t as STREAMS, B as ApiRateLimiter, Cn as BatchProcessor, D as ContactRepository, E as TemplateRepository, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, Sn as CircuitBreaker, Tn as getPriorityBucket, X as IdempotencyGuard, Zt as OUTBOUND_STREAMS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, fn as loadEnv, g as transportRegistry, in as registry, mn as readBaseConfig, qt as buildStreamEvent, st as scheduledPayloads, u as NonRetryableError, x as renderWithTemplate } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
3
|
-
import { n as upsertOutboxProviderIds } from "./bulk-
|
|
1
|
+
import { $t as STREAMS, B as ApiRateLimiter, Cn as BatchProcessor, D as ContactRepository, E as TemplateRepository, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, Sn as CircuitBreaker, Tn as getPriorityBucket, X as IdempotencyGuard, Zt as OUTBOUND_STREAMS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, fn as loadEnv, g as transportRegistry, in as registry, mn as readBaseConfig, qt as buildStreamEvent, st as scheduledPayloads, u as NonRetryableError, x as renderWithTemplate } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-U1F11-js.mjs";
|
|
3
|
+
import { n as upsertOutboxProviderIds } from "./bulk-B1Jg4m15.mjs";
|
|
4
4
|
import { sql } from "drizzle-orm";
|
|
5
5
|
//#region src/services/delivery/live-events.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $t as STREAMS, Jt as CONSUMER_GROUPS, K as StreamProducer, a as SuspendExecutionError, c as BaseWorker, d as startHealthReporter, dt as workflowDefinitions, fn as loadEnv, ft as workflowInstances, i as workflowRegistry, mn as readBaseConfig, mt as workflowWaiters, o as buildStepNotifyPayload, pt as workflowSteps, qt as buildStreamEvent } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-
|
|
1
|
+
import { $t as STREAMS, Jt as CONSUMER_GROUPS, K as StreamProducer, a as SuspendExecutionError, c as BaseWorker, d as startHealthReporter, dt as workflowDefinitions, fn as loadEnv, ft as workflowInstances, i as workflowRegistry, mn as readBaseConfig, mt as workflowWaiters, o as buildStepNotifyPayload, pt as workflowSteps, qt as buildStreamEvent } from "./src-CDVyt2X2.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-U1F11-js.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { and, eq } from "drizzle-orm";
|
|
5
5
|
//#region src/services/workflow/timers.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as STREAMS, At as AddUserSchema, B as ApiRateLimiter, C as SegmentRepository, D as ContactRepository, Dn as LRUCache, E as TemplateRepository, En as normaliseTarget, Ht as UpdateProjectSchema, It as NotifyRequestSchema, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, L as RedisClient, Lt as PreferencesSchema, Mt as ContactChannelSchema, Nt as CreateWorkflowSchema, On as globalEmitter, Pt as IngestEventSchema, Q as createDatabase, Qt as PUBSUB_CHANNELS, S as AdminUserRepository, T as ProjectRepository, Tn as getPriorityBucket, Ut as UpdateUserSchema, Vt as TriggerWorkflowSchema, Y as createLogger, at as projectApiKeys, ct as suppressions, dt as workflowDefinitions, fn as loadEnv, g as transportRegistry, it as messageLogs, jt as BatchAddContactsSchema, k as UserRepository, lt as userTopicPreferences, m as verifyUnsubscribeToken, mn as readBaseConfig, ot as projects, q as getMetricsRegistry, qt as buildStreamEvent, rt as deliveryOutbox, st as scheduledPayloads, ut as users, w as WorkflowRepository, zt as SyncTemplatesSchema } from "./src-
|
|
1
|
+
import { $t as STREAMS, At as AddUserSchema, B as ApiRateLimiter, C as SegmentRepository, D as ContactRepository, Dn as LRUCache, E as TemplateRepository, En as normaliseTarget, Ht as UpdateProjectSchema, It as NotifyRequestSchema, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, L as RedisClient, Lt as PreferencesSchema, Mt as ContactChannelSchema, Nt as CreateWorkflowSchema, On as globalEmitter, Pt as IngestEventSchema, Q as createDatabase, Qt as PUBSUB_CHANNELS, S as AdminUserRepository, T as ProjectRepository, Tn as getPriorityBucket, Ut as UpdateUserSchema, Vt as TriggerWorkflowSchema, Y as createLogger, at as projectApiKeys, ct as suppressions, dt as workflowDefinitions, fn as loadEnv, g as transportRegistry, it as messageLogs, jt as BatchAddContactsSchema, k as UserRepository, lt as userTopicPreferences, m as verifyUnsubscribeToken, mn as readBaseConfig, ot as projects, q as getMetricsRegistry, qt as buildStreamEvent, rt as deliveryOutbox, st as scheduledPayloads, ut as users, w as WorkflowRepository, zt as SyncTemplatesSchema } from "./src-CDVyt2X2.mjs";
|
|
2
2
|
import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { createHash, randomBytes, randomUUID, scrypt, timingSafeEqual } from "node:crypto";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tn as getPriorityBucket, qt as buildStreamEvent, st as scheduledPayloads } from "./src-
|
|
1
|
+
import { Tn as getPriorityBucket, qt as buildStreamEvent, st as scheduledPayloads } from "./src-CDVyt2X2.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region src/services/engine/schedule-or-dispatch.ts
|
|
4
4
|
/**
|
|
@@ -601,10 +601,23 @@ const PreferencesSchema = z.object({
|
|
|
601
601
|
topics: z.record(z.string(), z.boolean()).optional(),
|
|
602
602
|
quietHours: z.array(QuietHoursSchema).optional()
|
|
603
603
|
});
|
|
604
|
+
const TimezoneSchema = z.string().refine((tz) => {
|
|
605
|
+
if (tz !== "UTC" && !tz.includes("/")) return false;
|
|
606
|
+
try {
|
|
607
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
608
|
+
return true;
|
|
609
|
+
} catch {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
}, { message: "expected an IANA timezone, e.g. America/New_York" });
|
|
604
613
|
/** Channels that carry an addressable target (email address, phone, push token, url, chat id). */
|
|
605
614
|
const ContactChannelSchema = NotificationChannelSchema;
|
|
606
615
|
/** Accept a single value or an array; always normalise to a non-empty array. */
|
|
607
616
|
const stringOrArray = z.union([z.string().min(1), z.array(z.string().min(1))]).transform((v) => Array.isArray(v) ? v : [v]);
|
|
617
|
+
const PLAIN_ADDRESS = /^[^\s@<>,;:()"]+@[^\s@<>,;:()"]+$/;
|
|
618
|
+
const EMAIL_TARGET_MESSAGE = "expected one plain email address, e.g. alice@example.com";
|
|
619
|
+
const emailTarget = z.string().regex(PLAIN_ADDRESS, EMAIL_TARGET_MESSAGE);
|
|
620
|
+
const emailOrArray = z.union([emailTarget, z.array(emailTarget)]).transform((v) => Array.isArray(v) ? v : [v]);
|
|
608
621
|
const UserContactInputSchema = z.object({
|
|
609
622
|
channel: ContactChannelSchema,
|
|
610
623
|
target: z.string().min(1),
|
|
@@ -612,6 +625,9 @@ const UserContactInputSchema = z.object({
|
|
|
612
625
|
isPrimary: z.boolean().optional(),
|
|
613
626
|
enabled: z.boolean().optional(),
|
|
614
627
|
preferences: PreferencesSchema.optional()
|
|
628
|
+
}).refine((c) => c.channel !== "email" || PLAIN_ADDRESS.test(c.target), {
|
|
629
|
+
message: EMAIL_TARGET_MESSAGE,
|
|
630
|
+
path: ["target"]
|
|
615
631
|
});
|
|
616
632
|
/**
|
|
617
633
|
* addUser({ id, contacts, email, phone, pushToken, segments, preferences })
|
|
@@ -621,9 +637,9 @@ const UserContactInputSchema = z.object({
|
|
|
621
637
|
const AddUserSchema = z.object({
|
|
622
638
|
id: z.string().min(1),
|
|
623
639
|
language: z.string().optional(),
|
|
624
|
-
timezone:
|
|
640
|
+
timezone: TimezoneSchema.optional(),
|
|
625
641
|
contacts: z.array(UserContactInputSchema).optional(),
|
|
626
|
-
email:
|
|
642
|
+
email: emailOrArray.optional(),
|
|
627
643
|
phone: stringOrArray.optional(),
|
|
628
644
|
pushToken: stringOrArray.optional(),
|
|
629
645
|
segments: z.array(z.string().min(1)).optional(),
|
|
@@ -632,9 +648,9 @@ const AddUserSchema = z.object({
|
|
|
632
648
|
/** updateUser(id, patch) — every field optional; id comes from the path. */
|
|
633
649
|
const UpdateUserSchema = z.object({
|
|
634
650
|
language: z.string().optional(),
|
|
635
|
-
timezone:
|
|
651
|
+
timezone: TimezoneSchema.optional(),
|
|
636
652
|
contacts: z.array(UserContactInputSchema).optional(),
|
|
637
|
-
email:
|
|
653
|
+
email: emailOrArray.optional(),
|
|
638
654
|
phone: stringOrArray.optional(),
|
|
639
655
|
pushToken: stringOrArray.optional(),
|
|
640
656
|
segments: z.array(z.string().min(1)).optional(),
|
|
@@ -4112,35 +4128,35 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4112
4128
|
}
|
|
4113
4129
|
const startupPromises = [];
|
|
4114
4130
|
if (services.includes("api")) {
|
|
4115
|
-
const { startApiServer } = await import("./main-
|
|
4131
|
+
const { startApiServer } = await import("./main-d4ozU_Uk.mjs");
|
|
4116
4132
|
startupPromises.push(startApiServer());
|
|
4117
4133
|
}
|
|
4118
4134
|
if (services.includes("delivery")) {
|
|
4119
|
-
const { startDeliveryWorker } = await import("./main-
|
|
4135
|
+
const { startDeliveryWorker } = await import("./main-DmUMrkvb.mjs");
|
|
4120
4136
|
startupPromises.push(startDeliveryWorker());
|
|
4121
4137
|
}
|
|
4122
4138
|
if (services.includes("engine")) {
|
|
4123
|
-
const { startEngineWorker } = await import("./main-
|
|
4139
|
+
const { startEngineWorker } = await import("./main-DMTiTQn5.mjs");
|
|
4124
4140
|
startupPromises.push(startEngineWorker());
|
|
4125
4141
|
}
|
|
4126
4142
|
if (services.includes("enricher")) {
|
|
4127
|
-
const { startEnricherWorker } = await import("./main-
|
|
4143
|
+
const { startEnricherWorker } = await import("./main-B58UJ-o1.mjs");
|
|
4128
4144
|
startupPromises.push(startEnricherWorker());
|
|
4129
4145
|
}
|
|
4130
4146
|
if (services.includes("scheduler")) {
|
|
4131
|
-
const { startSchedulerWorker } = await import("./main-
|
|
4147
|
+
const { startSchedulerWorker } = await import("./main-BndrE3SN.mjs");
|
|
4132
4148
|
startupPromises.push(startSchedulerWorker());
|
|
4133
4149
|
}
|
|
4134
4150
|
if (services.includes("ai")) {
|
|
4135
|
-
const { startAiWorker } = await import("./main-
|
|
4151
|
+
const { startAiWorker } = await import("./main-0Tug88vm.mjs");
|
|
4136
4152
|
startupPromises.push(startAiWorker());
|
|
4137
4153
|
}
|
|
4138
4154
|
if (services.includes("workflow")) {
|
|
4139
|
-
const { startWorkflowWorker } = await import("./main-
|
|
4155
|
+
const { startWorkflowWorker } = await import("./main-DrTuMt92.mjs");
|
|
4140
4156
|
startupPromises.push(startWorkflowWorker());
|
|
4141
4157
|
}
|
|
4142
4158
|
if (services.includes("events")) {
|
|
4143
|
-
const { startEventWorker } = await import("./main-
|
|
4159
|
+
const { startEventWorker } = await import("./main-BnjkQTh3.mjs");
|
|
4144
4160
|
startupPromises.push(startEventWorker());
|
|
4145
4161
|
}
|
|
4146
4162
|
const handleSignal = async (signal) => {
|
|
@@ -4162,9 +4178,9 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4162
4178
|
await Promise.all(startupPromises);
|
|
4163
4179
|
if (readBaseConfig().PIPELINE_FUSED && services.includes("enricher") && services.includes("engine") && services.includes("delivery")) {
|
|
4164
4180
|
const [{ getEnricherWorker }, { getEngineWorker }, { getDeliveryWorker }] = await Promise.all([
|
|
4165
|
-
import("./main-
|
|
4166
|
-
import("./main-
|
|
4167
|
-
import("./main-
|
|
4181
|
+
import("./main-B58UJ-o1.mjs"),
|
|
4182
|
+
import("./main-DMTiTQn5.mjs"),
|
|
4183
|
+
import("./main-DmUMrkvb.mjs")
|
|
4168
4184
|
]);
|
|
4169
4185
|
const enricher = getEnricherWorker();
|
|
4170
4186
|
const engine = getEngineWorker();
|
|
@@ -4195,16 +4211,24 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4195
4211
|
"events"
|
|
4196
4212
|
] : this.options.services;
|
|
4197
4213
|
const shutdownOrder = [
|
|
4198
|
-
["api", async () => (await import("./main-
|
|
4199
|
-
["workflow", async () => (await import("./main-
|
|
4200
|
-
["enricher", async () => (await import("./main-
|
|
4201
|
-
["ai", async () => (await import("./main-
|
|
4202
|
-
["engine", async () => (await import("./main-
|
|
4203
|
-
["scheduler", async () => (await import("./main-
|
|
4204
|
-
["delivery", async () => (await import("./main-
|
|
4205
|
-
["events", async () => (await import("./main-
|
|
4214
|
+
["api", async () => (await import("./main-d4ozU_Uk.mjs")).stopApiServer()],
|
|
4215
|
+
["workflow", async () => (await import("./main-DrTuMt92.mjs")).stopWorkflowWorker()],
|
|
4216
|
+
["enricher", async () => (await import("./main-B58UJ-o1.mjs")).stopEnricherWorker()],
|
|
4217
|
+
["ai", async () => (await import("./main-0Tug88vm.mjs")).stopAiWorker()],
|
|
4218
|
+
["engine", async () => (await import("./main-DMTiTQn5.mjs")).stopEngineWorker()],
|
|
4219
|
+
["scheduler", async () => (await import("./main-BndrE3SN.mjs")).stopSchedulerWorker()],
|
|
4220
|
+
["delivery", async () => (await import("./main-DmUMrkvb.mjs")).stopDeliveryWorker()],
|
|
4221
|
+
["events", async () => (await import("./main-BnjkQTh3.mjs")).stopEventWorker()]
|
|
4206
4222
|
];
|
|
4207
4223
|
for (const [name, stop] of shutdownOrder) if (services.includes(name)) await stop();
|
|
4224
|
+
for (const provider of this.options.providers ?? []) try {
|
|
4225
|
+
await provider.close?.();
|
|
4226
|
+
} catch (err) {
|
|
4227
|
+
this.logger.warn({
|
|
4228
|
+
err,
|
|
4229
|
+
channel: provider.channel
|
|
4230
|
+
}, "provider close failed");
|
|
4231
|
+
}
|
|
4208
4232
|
if (this.pgContainer) {
|
|
4209
4233
|
this.logger.info("Stopping PostgreSQL container...");
|
|
4210
4234
|
await this.pgContainer.stop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notifkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
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",
|
package/src/contracts/sdk.ts
CHANGED
|
@@ -21,6 +21,21 @@ export const PreferencesSchema = z.object({
|
|
|
21
21
|
});
|
|
22
22
|
export type Preferences = z.infer<typeof PreferencesSchema>;
|
|
23
23
|
|
|
24
|
+
// The quiet-hours engine formats with this zone, so an unknown one would silently skip quiet hours.
|
|
25
|
+
// ICU also accepts ambiguous abbreviations like "IST", so require Area/Location (or UTC).
|
|
26
|
+
const TimezoneSchema = z.string().refine(
|
|
27
|
+
(tz) => {
|
|
28
|
+
if (tz !== "UTC" && !tz.includes("/")) return false;
|
|
29
|
+
try {
|
|
30
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
31
|
+
return true;
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{ message: "expected an IANA timezone, e.g. America/New_York" },
|
|
37
|
+
);
|
|
38
|
+
|
|
24
39
|
// Contacts
|
|
25
40
|
|
|
26
41
|
/** Channels that carry an addressable target (email address, phone, push token, url, chat id). */
|
|
@@ -32,14 +47,28 @@ const stringOrArray = z
|
|
|
32
47
|
.union([z.string().min(1), z.array(z.string().min(1))])
|
|
33
48
|
.transform((v) => (Array.isArray(v) ? v : [v]));
|
|
34
49
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
// One plain address: suppressions match the stored target, and a display name or
|
|
51
|
+
// list would also be delivered to every address nodemailer parses out of it.
|
|
52
|
+
const PLAIN_ADDRESS = /^[^\s@<>,;:()"]+@[^\s@<>,;:()"]+$/;
|
|
53
|
+
const EMAIL_TARGET_MESSAGE = "expected one plain email address, e.g. alice@example.com";
|
|
54
|
+
const emailTarget = z.string().regex(PLAIN_ADDRESS, EMAIL_TARGET_MESSAGE);
|
|
55
|
+
const emailOrArray = z
|
|
56
|
+
.union([emailTarget, z.array(emailTarget)])
|
|
57
|
+
.transform((v) => (Array.isArray(v) ? v : [v]));
|
|
58
|
+
|
|
59
|
+
export const UserContactInputSchema = z
|
|
60
|
+
.object({
|
|
61
|
+
channel: ContactChannelSchema,
|
|
62
|
+
target: z.string().min(1),
|
|
63
|
+
label: z.string().optional(),
|
|
64
|
+
isPrimary: z.boolean().optional(),
|
|
65
|
+
enabled: z.boolean().optional(),
|
|
66
|
+
preferences: PreferencesSchema.optional(),
|
|
67
|
+
})
|
|
68
|
+
.refine((c) => c.channel !== "email" || PLAIN_ADDRESS.test(c.target), {
|
|
69
|
+
message: EMAIL_TARGET_MESSAGE,
|
|
70
|
+
path: ["target"],
|
|
71
|
+
});
|
|
43
72
|
export type UserContactInput = z.infer<typeof UserContactInputSchema>;
|
|
44
73
|
|
|
45
74
|
// Users
|
|
@@ -52,9 +81,9 @@ export type UserContactInput = z.infer<typeof UserContactInputSchema>;
|
|
|
52
81
|
export const AddUserSchema = z.object({
|
|
53
82
|
id: z.string().min(1),
|
|
54
83
|
language: z.string().optional(),
|
|
55
|
-
timezone:
|
|
84
|
+
timezone: TimezoneSchema.optional(),
|
|
56
85
|
contacts: z.array(UserContactInputSchema).optional(),
|
|
57
|
-
email:
|
|
86
|
+
email: emailOrArray.optional(),
|
|
58
87
|
phone: stringOrArray.optional(),
|
|
59
88
|
pushToken: stringOrArray.optional(),
|
|
60
89
|
segments: z.array(z.string().min(1)).optional(),
|
|
@@ -65,9 +94,9 @@ export type AddUserInput = z.input<typeof AddUserSchema>;
|
|
|
65
94
|
/** updateUser(id, patch) — every field optional; id comes from the path. */
|
|
66
95
|
export const UpdateUserSchema = z.object({
|
|
67
96
|
language: z.string().optional(),
|
|
68
|
-
timezone:
|
|
97
|
+
timezone: TimezoneSchema.optional(),
|
|
69
98
|
contacts: z.array(UserContactInputSchema).optional(),
|
|
70
|
-
email:
|
|
99
|
+
email: emailOrArray.optional(),
|
|
71
100
|
phone: stringOrArray.optional(),
|
|
72
101
|
pushToken: stringOrArray.optional(),
|
|
73
102
|
segments: z.array(z.string().min(1)).optional(),
|
package/src/server.ts
CHANGED
|
@@ -295,6 +295,16 @@ export class NotifkitServer extends EventEmitter {
|
|
|
295
295
|
if (services.includes(name)) await stop();
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
+
// After delivery, so no send is still using them. A pooled SMTP connection
|
|
299
|
+
// would otherwise keep the process alive.
|
|
300
|
+
for (const provider of this.options.providers ?? []) {
|
|
301
|
+
try {
|
|
302
|
+
await provider.close?.();
|
|
303
|
+
} catch (err) {
|
|
304
|
+
this.logger.warn({ err, channel: provider.channel }, "provider close failed");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
298
308
|
if (this.pgContainer) {
|
|
299
309
|
this.logger.info("Stopping PostgreSQL container...");
|
|
300
310
|
await this.pgContainer.stop();
|
package/src/transport/index.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface Transport {
|
|
|
42
42
|
readonly channel: NotificationChannel;
|
|
43
43
|
readonly limits?: { limit: number; windowSeconds: number };
|
|
44
44
|
send(task: NotificationDispatchedPayload): Promise<DeliveryResult>;
|
|
45
|
+
/** Releases held connections. `NotifkitServer.stop()` calls it after delivery stops. */
|
|
46
|
+
close?: () => void | Promise<void>;
|
|
45
47
|
|
|
46
48
|
webhookPath?: string;
|
|
47
49
|
/**
|