notifkit 0.1.20 → 0.1.21
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 +11 -0
- package/dist/{bootstrap-U1F11-js.mjs → bootstrap-CMvnVD4U.mjs} +1 -1
- package/dist/{bulk-B1Jg4m15.mjs → bulk-BmWBGhJk.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{main-BnjkQTh3.mjs → main-7IdXmQMM.mjs} +3 -3
- package/dist/{main-d4ozU_Uk.mjs → main-BCrlCpfe.mjs} +1 -1
- package/dist/{main-DrTuMt92.mjs → main-BOEynO9b.mjs} +2 -2
- package/dist/{main-BndrE3SN.mjs → main-CJDYKyaG.mjs} +2 -2
- package/dist/{main-B58UJ-o1.mjs → main-D89J5XfV.mjs} +2 -2
- package/dist/{main-0Tug88vm.mjs → main-D98LrZGy.mjs} +3 -3
- package/dist/{main-DMTiTQn5.mjs → main-DQgurSqs.mjs} +3 -3
- package/dist/{main-DmUMrkvb.mjs → main-DT9xv7mb.mjs} +6 -5
- package/dist/{schedule-or-dispatch-Ce_9gHJL.mjs → schedule-or-dispatch-Dr5JygAf.mjs} +1 -1
- package/dist/{src-CDVyt2X2.mjs → src-B3Yy7ryU.mjs} +19 -19
- package/package.json +1 -1
- package/src/services/delivery/main.ts +4 -1
- package/src/services/delivery/throttle.ts +2 -1
package/README.md
CHANGED
|
@@ -10,6 +10,10 @@ 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
|
+
(what it does)
|
|
16
|
+
|
|
13
17
|
</div>
|
|
14
18
|
|
|
15
19
|
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.
|
|
@@ -93,6 +97,7 @@ Bring your own provider accounts. First-party packages:
|
|
|
93
97
|
|
|
94
98
|
- [`@notifkit/provider-resend`](./packages/provider-resend): transactional email via Resend
|
|
95
99
|
- [`@notifkit/provider-smtp`](./packages/provider-smtp): email through any SMTP server, via nodemailer
|
|
100
|
+
- [`@notifkit/provider-ses`](./packages/provider-ses): email via AWS SES (sending only; bounces not handled yet)
|
|
96
101
|
- [`@notifkit/provider-fcm`](./packages/provider-fcm): push notifications via Firebase Cloud Messaging
|
|
97
102
|
- [`@notifkit/provider-twilio`](./packages/provider-twilio): SMS via Twilio, with signature-verified delivery status callbacks
|
|
98
103
|
- [`@notifkit/provider-slack`](./packages/provider-slack): Slack messages via Incoming Webhooks or the Web API
|
|
@@ -156,6 +161,12 @@ The test suite starts its own PostgreSQL and Redis containers, so Docker is the
|
|
|
156
161
|
|
|
157
162
|
Questions, bugs, or ideas: [contact.devkitshq@gmail.com](mailto:contact.devkitshq@gmail.com), or open an issue. If notifkit saved you from building notification plumbing, a [star](https://github.com/devkitshq/notifkit) helps other developers find it.
|
|
158
163
|
|
|
164
|
+
## Contributors
|
|
165
|
+
|
|
166
|
+
<a href="https://github.com/devkitshq/notifkit/graphs/contributors">
|
|
167
|
+
<img src="https://contrib.rocks/image?repo=devkitshq/notifkit" alt="Contributors" />
|
|
168
|
+
</a>
|
|
169
|
+
|
|
159
170
|
## License
|
|
160
171
|
|
|
161
172
|
MIT. Use it for anything, including commercially. Every feature is in this repository: there is no paid edition and no hosted tier.
|
|
@@ -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-B3Yy7ryU.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.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-B3Yy7ryU.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, 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-B3Yy7ryU.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-CMvnVD4U.mjs";
|
|
3
|
+
import { t as insertMessageLogs } from "./bulk-BmWBGhJk.mjs";
|
|
4
4
|
import { and, eq, gt, isNull, or } from "drizzle-orm";
|
|
5
5
|
//#region src/services/events/main.ts
|
|
6
6
|
loadEnv();
|
|
@@ -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-B3Yy7ryU.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,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-B3Yy7ryU.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-CMvnVD4U.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,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-B3Yy7ryU.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-CMvnVD4U.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,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-B3Yy7ryU.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-CMvnVD4U.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/services/enricher/main.ts
|
|
5
5
|
loadEnv();
|
|
@@ -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-B3Yy7ryU.mjs";
|
|
2
|
+
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-Dr5JygAf.mjs";
|
|
3
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-CMvnVD4U.mjs";
|
|
4
4
|
import { generateText } from "ai";
|
|
5
5
|
//#region src/services/ai/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-B3Yy7ryU.mjs";
|
|
2
|
+
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-Dr5JygAf.mjs";
|
|
3
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-CMvnVD4U.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-B3Yy7ryU.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-CMvnVD4U.mjs";
|
|
3
|
+
import { n as upsertOutboxProviderIds } from "./bulk-BmWBGhJk.mjs";
|
|
4
4
|
import { sql } from "drizzle-orm";
|
|
5
5
|
//#region src/services/delivery/live-events.ts
|
|
6
6
|
/**
|
|
@@ -87,7 +87,7 @@ var ProviderThrottle = class {
|
|
|
87
87
|
retryAfterMs: 0
|
|
88
88
|
};
|
|
89
89
|
const retryAfterMs = windowMs - Date.now() % windowMs;
|
|
90
|
-
this.logger?.
|
|
90
|
+
this.logger?.debug({
|
|
91
91
|
channel,
|
|
92
92
|
limit: config.limit,
|
|
93
93
|
windowSeconds: config.windowSeconds,
|
|
@@ -135,7 +135,8 @@ function providerFailure(res) {
|
|
|
135
135
|
return err;
|
|
136
136
|
}
|
|
137
137
|
function retryDelayMs(priorFailures) {
|
|
138
|
-
|
|
138
|
+
const step = RETRY_BACKOFF_MS[Math.min(priorFailures, RETRY_BACKOFF_MS.length - 1)];
|
|
139
|
+
return step + Math.floor(Math.random() * (step / 2));
|
|
139
140
|
}
|
|
140
141
|
var DeliveryWorker = class extends BaseWorker {
|
|
141
142
|
transportRegistry;
|
|
@@ -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-B3Yy7ryU.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region src/services/engine/schedule-or-dispatch.ts
|
|
4
4
|
/**
|
|
@@ -4128,35 +4128,35 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4128
4128
|
}
|
|
4129
4129
|
const startupPromises = [];
|
|
4130
4130
|
if (services.includes("api")) {
|
|
4131
|
-
const { startApiServer } = await import("./main-
|
|
4131
|
+
const { startApiServer } = await import("./main-BCrlCpfe.mjs");
|
|
4132
4132
|
startupPromises.push(startApiServer());
|
|
4133
4133
|
}
|
|
4134
4134
|
if (services.includes("delivery")) {
|
|
4135
|
-
const { startDeliveryWorker } = await import("./main-
|
|
4135
|
+
const { startDeliveryWorker } = await import("./main-DT9xv7mb.mjs");
|
|
4136
4136
|
startupPromises.push(startDeliveryWorker());
|
|
4137
4137
|
}
|
|
4138
4138
|
if (services.includes("engine")) {
|
|
4139
|
-
const { startEngineWorker } = await import("./main-
|
|
4139
|
+
const { startEngineWorker } = await import("./main-DQgurSqs.mjs");
|
|
4140
4140
|
startupPromises.push(startEngineWorker());
|
|
4141
4141
|
}
|
|
4142
4142
|
if (services.includes("enricher")) {
|
|
4143
|
-
const { startEnricherWorker } = await import("./main-
|
|
4143
|
+
const { startEnricherWorker } = await import("./main-D89J5XfV.mjs");
|
|
4144
4144
|
startupPromises.push(startEnricherWorker());
|
|
4145
4145
|
}
|
|
4146
4146
|
if (services.includes("scheduler")) {
|
|
4147
|
-
const { startSchedulerWorker } = await import("./main-
|
|
4147
|
+
const { startSchedulerWorker } = await import("./main-CJDYKyaG.mjs");
|
|
4148
4148
|
startupPromises.push(startSchedulerWorker());
|
|
4149
4149
|
}
|
|
4150
4150
|
if (services.includes("ai")) {
|
|
4151
|
-
const { startAiWorker } = await import("./main-
|
|
4151
|
+
const { startAiWorker } = await import("./main-D98LrZGy.mjs");
|
|
4152
4152
|
startupPromises.push(startAiWorker());
|
|
4153
4153
|
}
|
|
4154
4154
|
if (services.includes("workflow")) {
|
|
4155
|
-
const { startWorkflowWorker } = await import("./main-
|
|
4155
|
+
const { startWorkflowWorker } = await import("./main-BOEynO9b.mjs");
|
|
4156
4156
|
startupPromises.push(startWorkflowWorker());
|
|
4157
4157
|
}
|
|
4158
4158
|
if (services.includes("events")) {
|
|
4159
|
-
const { startEventWorker } = await import("./main-
|
|
4159
|
+
const { startEventWorker } = await import("./main-7IdXmQMM.mjs");
|
|
4160
4160
|
startupPromises.push(startEventWorker());
|
|
4161
4161
|
}
|
|
4162
4162
|
const handleSignal = async (signal) => {
|
|
@@ -4178,9 +4178,9 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4178
4178
|
await Promise.all(startupPromises);
|
|
4179
4179
|
if (readBaseConfig().PIPELINE_FUSED && services.includes("enricher") && services.includes("engine") && services.includes("delivery")) {
|
|
4180
4180
|
const [{ getEnricherWorker }, { getEngineWorker }, { getDeliveryWorker }] = await Promise.all([
|
|
4181
|
-
import("./main-
|
|
4182
|
-
import("./main-
|
|
4183
|
-
import("./main-
|
|
4181
|
+
import("./main-D89J5XfV.mjs"),
|
|
4182
|
+
import("./main-DQgurSqs.mjs"),
|
|
4183
|
+
import("./main-DT9xv7mb.mjs")
|
|
4184
4184
|
]);
|
|
4185
4185
|
const enricher = getEnricherWorker();
|
|
4186
4186
|
const engine = getEngineWorker();
|
|
@@ -4211,14 +4211,14 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4211
4211
|
"events"
|
|
4212
4212
|
] : this.options.services;
|
|
4213
4213
|
const shutdownOrder = [
|
|
4214
|
-
["api", async () => (await import("./main-
|
|
4215
|
-
["workflow", async () => (await import("./main-
|
|
4216
|
-
["enricher", async () => (await import("./main-
|
|
4217
|
-
["ai", async () => (await import("./main-
|
|
4218
|
-
["engine", async () => (await import("./main-
|
|
4219
|
-
["scheduler", async () => (await import("./main-
|
|
4220
|
-
["delivery", async () => (await import("./main-
|
|
4221
|
-
["events", async () => (await import("./main-
|
|
4214
|
+
["api", async () => (await import("./main-BCrlCpfe.mjs")).stopApiServer()],
|
|
4215
|
+
["workflow", async () => (await import("./main-BOEynO9b.mjs")).stopWorkflowWorker()],
|
|
4216
|
+
["enricher", async () => (await import("./main-D89J5XfV.mjs")).stopEnricherWorker()],
|
|
4217
|
+
["ai", async () => (await import("./main-D98LrZGy.mjs")).stopAiWorker()],
|
|
4218
|
+
["engine", async () => (await import("./main-DQgurSqs.mjs")).stopEngineWorker()],
|
|
4219
|
+
["scheduler", async () => (await import("./main-CJDYKyaG.mjs")).stopSchedulerWorker()],
|
|
4220
|
+
["delivery", async () => (await import("./main-DT9xv7mb.mjs")).stopDeliveryWorker()],
|
|
4221
|
+
["events", async () => (await import("./main-7IdXmQMM.mjs")).stopEventWorker()]
|
|
4222
4222
|
];
|
|
4223
4223
|
for (const [name, stop] of shutdownOrder) if (services.includes(name)) await stop();
|
|
4224
4224
|
for (const provider of this.options.providers ?? []) try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notifkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
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",
|
|
@@ -82,7 +82,10 @@ function providerFailure(res: { error?: string; retryable?: boolean }): Error {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export function retryDelayMs(priorFailures: number): number {
|
|
85
|
-
|
|
85
|
+
const step = RETRY_BACKOFF_MS[Math.min(priorFailures, RETRY_BACKOFF_MS.length - 1)]!;
|
|
86
|
+
// Up to half a step later, never earlier, so a burst that failed together
|
|
87
|
+
// (a provider throttling or down) doesn't come back in the same instant.
|
|
88
|
+
return step + Math.floor(Math.random() * (step / 2));
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
export interface DeliveryWorkerOptions extends WorkerOptions {
|
|
@@ -45,7 +45,8 @@ export class ProviderThrottle {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const retryAfterMs = windowMs - (Date.now() % windowMs);
|
|
48
|
-
|
|
48
|
+
// Debug, not warn: a big send lands here on every deferral of every task.
|
|
49
|
+
this.logger?.debug(
|
|
49
50
|
{ channel, limit: config.limit, windowSeconds: config.windowSeconds, retryAfterMs },
|
|
50
51
|
"Provider rate limit hit — task must be rescheduled",
|
|
51
52
|
);
|