notifkit 0.1.16 → 0.1.17
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/dist/{bootstrap-BMDRPjgp.mjs → bootstrap-P63acBG9.mjs} +1 -1
- package/dist/{bulk-CJ5QXiPa.mjs → bulk-Beblt3ny.mjs} +1 -1
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +1 -1
- package/dist/{main-CpaHF1Zw.mjs → main-BIahf4f9.mjs} +2 -2
- package/dist/{main-6_bXQBDH.mjs → main-C3XcLoCb.mjs} +3 -3
- package/dist/{main-g1KEcXXp.mjs → main-CktEylpL.mjs} +1 -1
- package/dist/{main-8nP3qmCT.mjs → main-DB0bUh2r.mjs} +3 -3
- package/dist/{main-DULD8-th.mjs → main-Dk92nti8.mjs} +2 -2
- package/dist/{main-B82bsFoy.mjs → main-Lcbg7aEn.mjs} +3 -3
- package/dist/{main-ZW5RaiOK.mjs → main-NHUvynW2.mjs} +2 -2
- package/dist/{main-mGIT8jv4.mjs → main-_I4b1cmP.mjs} +3 -3
- package/dist/{schedule-or-dispatch-Cd7GLfc3.mjs → schedule-or-dispatch-C5qfxQCv.mjs} +1 -1
- package/dist/{src-BE_EUpZ6.mjs → src-BRatuWJS.mjs} +51 -21
- package/package.json +1 -1
- package/src/config/index.ts +1 -1
- package/src/queue/index.ts +8 -0
- package/src/workers/index.ts +27 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as StreamProducer, K as PendingMessageScanner, Z as createLogger, et as createDatabase, q as StreamConsumer, tn as STREAMS, z as RedisClient } from "./src-
|
|
1
|
+
import { J as StreamProducer, K as PendingMessageScanner, Z as createLogger, et as createDatabase, q as StreamConsumer, tn as STREAMS, z as RedisClient } from "./src-BRatuWJS.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
|
@@ -4141,6 +4141,11 @@ declare class PendingMessageScanner {
|
|
|
4141
4141
|
private readonly consumer;
|
|
4142
4142
|
private readonly logger?;
|
|
4143
4143
|
constructor({ redis, stream, group, consumer, logger }: PendingMessageScannerOptions);
|
|
4144
|
+
/**
|
|
4145
|
+
* Resets a held entry's idle time so no scanner reclaims it while its
|
|
4146
|
+
* handler is still running. JUSTID leaves the delivery count alone.
|
|
4147
|
+
*/
|
|
4148
|
+
touch(id: string, stream: string): Promise<void>;
|
|
4144
4149
|
getPendingCount(): Promise<number>;
|
|
4145
4150
|
/** Pending entries for one stream, or across all of them when `stream` is omitted. */
|
|
4146
4151
|
getPendingEntries(limit?: number, stream?: StreamName): Promise<PendingEntry[]>;
|
|
@@ -4760,6 +4765,14 @@ declare abstract class BaseWorker {
|
|
|
4760
4765
|
*/
|
|
4761
4766
|
processInline(event: StreamEvent): Promise<void>;
|
|
4762
4767
|
private processWithTracking;
|
|
4768
|
+
/**
|
|
4769
|
+
* Runs `process` while keeping the entry's idle time below the reclaim
|
|
4770
|
+
* threshold. Without this, a handler that outlasts `recoveryIntervalMs` (a
|
|
4771
|
+
* large segment fan-out) is reclaimed mid-run and started again elsewhere,
|
|
4772
|
+
* over and over, until it is dead-lettered while the first run still works.
|
|
4773
|
+
* If this process dies the touches stop, so the entry is reclaimed as before.
|
|
4774
|
+
*/
|
|
4775
|
+
private processHoldingLease;
|
|
4763
4776
|
/**
|
|
4764
4777
|
* `recoveryIntervalMs` is how long an entry must sit idle before it is
|
|
4765
4778
|
* claimed, not how often to look. Scanning only once per interval, timed from
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as assertTablesInSchema, $t as OUTBOUND_STREAMS, A as LUA_ACQUIRE_LEASE, An as globalEmitter, At as NotificationTargetSchema, B as redactUrl, Bt as QuietHoursSchema, C as SegmentRepository, Cn as DataLoader, Ct as NotificationDispatchedPayloadSchema, D as ContactRepository, Dn as getPriorityBucket, Dt as RecipientProfileSchema, E as TemplateRepository, En as AsyncSemaphore, Et as NotificationEnrichedPayloadSchema, F as LUA_RENEW_LOCK, Ft as CreateWorkflowSchema, G as ProjectSettingsCache, Gt as UpdateUserSchema, H as ApiRateLimiter, Ht as TemplateSchema, I as LUA_SCHEDULER_POLL, It as IngestEventSchema, J as StreamProducer, Jt as WorkflowStepSchema, K as PendingMessageScanner, Kt as UserContactInputSchema, L as LUA_USER_THROTTLE, Lt as InlineUserSchema, M as LUA_LEASE_API_RATE_LIMIT, Mt as AddUserSchema, N as LUA_MARK_PROCESSED, Nt as BatchAddContactsSchema, O as PreferenceRepository, On as normaliseTarget, Ot as NotificationCreatedPayloadSchema, P as LUA_RELEASE_LOCK, Pt as ContactChannelSchema, Q as IdempotencyGuard, Qt as INBOUND_STREAMS, R as Redis, Rt as NotifyRequestSchema, S as AdminUserRepository, Sn as sleep, St as DeliveryOptionsSchema, T as ProjectRepository, Tn as BatchProcessor, Tt as NotificationScheduledPayloadSchema, U as calculateTokenBatchSize, Ut as TriggerWorkflowSchema, V as registerCustomCommands, Vt as SyncTemplatesSchema, W as UserThrottle, Wt as UpdateProjectSchema, X as metrics, Xt as CONSUMER_GROUPS, Y as getMetricsRegistry, Yt as buildStreamEvent, Z as createLogger, Zt as ENRICHED_STREAMS, _ as TemplateCache, _n as setAiConfig, _t as NotificationAiPendingPayloadSchema, a as SuspendExecutionError, an as EventRegistry, b as interpolate, bn as ValidationError, bt as NotificationFailedPayloadSchema, c as BaseWorker, cn as NotificationChannelSchema, d as startHealthReporter, dn as AI_DEFAULTS, en as PUBSUB_CHANNELS, et as createDatabase, f as buildUnsubscribeHeaders, fn as baseConfigSchema, g as transportRegistry, gn as readBaseConfig, h as registerTransport, hn as parseConfig, i as workflowRegistry, in as StreamEventSchema, it as runMigrations, j as LUA_COUNT_REQUEST, jt as AddContactSchema, k as UserRepository, kn as LRUCache, kt as NotificationRequestedPayloadSchema, l as LockHeldError, ln as NotificationPrioritySchema, m as verifyUnsubscribeToken, mn as loadEnv, n as NotifkitClient, nn as EventEnvelopeSchema, nt as notifkitTableNames, o as buildStepNotifyPayload, on as registry, p as signUnsubscribeToken, pn as getAiConfig, q as StreamConsumer, qt as WorkflowNotifyPayloadSchema, r as workflow, rn as StreamEventMetadataSchema, rt as qualifyMigrationSql, s as resolveStepTarget, sn as EventMetadataSchema, t as NotifkitServer, tn as STREAMS, tt as migrateDatabase, u as NonRetryableError, un as NotificationStatusSchema, v as escapeHeader, vn as setGlobalConfig, vt as NotificationCanceledPayloadSchema, w as WorkflowRepository, wn as CircuitBreaker, wt as RenderedContentSchema, x as renderWithTemplate, xn as generateId, xt as NotificationDeliveredPayloadSchema, y as escapeHtml, yn as AppError, yt as NotificationSkippedPayloadSchema, z as RedisClient, zt as PreferencesSchema } from "./src-
|
|
1
|
+
import { $ as assertTablesInSchema, $t as OUTBOUND_STREAMS, A as LUA_ACQUIRE_LEASE, An as globalEmitter, At as NotificationTargetSchema, B as redactUrl, Bt as QuietHoursSchema, C as SegmentRepository, Cn as DataLoader, Ct as NotificationDispatchedPayloadSchema, D as ContactRepository, Dn as getPriorityBucket, Dt as RecipientProfileSchema, E as TemplateRepository, En as AsyncSemaphore, Et as NotificationEnrichedPayloadSchema, F as LUA_RENEW_LOCK, Ft as CreateWorkflowSchema, G as ProjectSettingsCache, Gt as UpdateUserSchema, H as ApiRateLimiter, Ht as TemplateSchema, I as LUA_SCHEDULER_POLL, It as IngestEventSchema, J as StreamProducer, Jt as WorkflowStepSchema, K as PendingMessageScanner, Kt as UserContactInputSchema, L as LUA_USER_THROTTLE, Lt as InlineUserSchema, M as LUA_LEASE_API_RATE_LIMIT, Mt as AddUserSchema, N as LUA_MARK_PROCESSED, Nt as BatchAddContactsSchema, O as PreferenceRepository, On as normaliseTarget, Ot as NotificationCreatedPayloadSchema, P as LUA_RELEASE_LOCK, Pt as ContactChannelSchema, Q as IdempotencyGuard, Qt as INBOUND_STREAMS, R as Redis, Rt as NotifyRequestSchema, S as AdminUserRepository, Sn as sleep, St as DeliveryOptionsSchema, T as ProjectRepository, Tn as BatchProcessor, Tt as NotificationScheduledPayloadSchema, U as calculateTokenBatchSize, Ut as TriggerWorkflowSchema, V as registerCustomCommands, Vt as SyncTemplatesSchema, W as UserThrottle, Wt as UpdateProjectSchema, X as metrics, Xt as CONSUMER_GROUPS, Y as getMetricsRegistry, Yt as buildStreamEvent, Z as createLogger, Zt as ENRICHED_STREAMS, _ as TemplateCache, _n as setAiConfig, _t as NotificationAiPendingPayloadSchema, a as SuspendExecutionError, an as EventRegistry, b as interpolate, bn as ValidationError, bt as NotificationFailedPayloadSchema, c as BaseWorker, cn as NotificationChannelSchema, d as startHealthReporter, dn as AI_DEFAULTS, en as PUBSUB_CHANNELS, et as createDatabase, f as buildUnsubscribeHeaders, fn as baseConfigSchema, g as transportRegistry, gn as readBaseConfig, h as registerTransport, hn as parseConfig, i as workflowRegistry, in as StreamEventSchema, it as runMigrations, j as LUA_COUNT_REQUEST, jt as AddContactSchema, k as UserRepository, kn as LRUCache, kt as NotificationRequestedPayloadSchema, l as LockHeldError, ln as NotificationPrioritySchema, m as verifyUnsubscribeToken, mn as loadEnv, n as NotifkitClient, nn as EventEnvelopeSchema, nt as notifkitTableNames, o as buildStepNotifyPayload, on as registry, p as signUnsubscribeToken, pn as getAiConfig, q as StreamConsumer, qt as WorkflowNotifyPayloadSchema, r as workflow, rn as StreamEventMetadataSchema, rt as qualifyMigrationSql, s as resolveStepTarget, sn as EventMetadataSchema, t as NotifkitServer, tn as STREAMS, tt as migrateDatabase, u as NonRetryableError, un as NotificationStatusSchema, v as escapeHeader, vn as setGlobalConfig, vt as NotificationCanceledPayloadSchema, w as WorkflowRepository, wn as CircuitBreaker, wt as RenderedContentSchema, x as renderWithTemplate, xn as generateId, xt as NotificationDeliveredPayloadSchema, y as escapeHtml, yn as AppError, yt as NotificationSkippedPayloadSchema, z as RedisClient, zt as PreferencesSchema } from "./src-BRatuWJS.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_ACQUIRE_LEASE, LUA_COUNT_REQUEST, LUA_LEASE_API_RATE_LIMIT, LUA_MARK_PROCESSED, 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,5 +1,5 @@
|
|
|
1
|
-
import { An as globalEmitter, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, On as normaliseTarget, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, k as UserRepository, lt as scheduledPayloads, mn as loadEnv, on as registry, tn as STREAMS, ut as suppressions } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
1
|
+
import { An as globalEmitter, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, On as normaliseTarget, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, k as UserRepository, lt as scheduledPayloads, mn as loadEnv, on as registry, tn as STREAMS, ut as suppressions } from "./src-BRatuWJS.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-P63acBG9.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 { An as globalEmitter, B as redactUrl, E as TemplateRepository, J as StreamProducer, Q as IdempotencyGuard, Xt as CONSUMER_GROUPS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, dn as AI_DEFAULTS, en as PUBSUB_CHANNELS, gn as readBaseConfig, mn as loadEnv, on as registry, pn as getAiConfig, tn as STREAMS, 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 { An as globalEmitter, B as redactUrl, E as TemplateRepository, J as StreamProducer, Q as IdempotencyGuard, Xt as CONSUMER_GROUPS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, dn as AI_DEFAULTS, en as PUBSUB_CHANNELS, gn as readBaseConfig, mn as loadEnv, on as registry, pn as getAiConfig, tn as STREAMS, x as renderWithTemplate } from "./src-BRatuWJS.mjs";
|
|
2
|
+
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-C5qfxQCv.mjs";
|
|
3
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-P63acBG9.mjs";
|
|
4
4
|
import { generateText } from "ai";
|
|
5
5
|
//#region src/services/ai/main.ts
|
|
6
6
|
loadEnv();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { An as globalEmitter, C as SegmentRepository, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, Ft as CreateWorkflowSchema, Gt as UpdateUserSchema, H as ApiRateLimiter, It as IngestEventSchema, J as StreamProducer, Mt as AddUserSchema, Nt as BatchAddContactsSchema, On as normaliseTarget, Pt as ContactChannelSchema, Rt as NotifyRequestSchema, S as AdminUserRepository, T as ProjectRepository, Ut as TriggerWorkflowSchema, Vt as SyncTemplatesSchema, Wt as UpdateProjectSchema, X as metrics, Xt as CONSUMER_GROUPS, Y as getMetricsRegistry, Yt as buildStreamEvent, Z as createLogger, at as deliveryOutbox, ct as projects, dt as userTopicPreferences, en as PUBSUB_CHANNELS, et as createDatabase, ft as users, g as transportRegistry, gn as readBaseConfig, k as UserRepository, kn as LRUCache, lt as scheduledPayloads, m as verifyUnsubscribeToken, mn as loadEnv, ot as messageLogs, pt as workflowDefinitions, st as projectApiKeys, tn as STREAMS, ut as suppressions, w as WorkflowRepository, z as RedisClient, zt as PreferencesSchema } from "./src-
|
|
1
|
+
import { An as globalEmitter, C as SegmentRepository, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, Ft as CreateWorkflowSchema, Gt as UpdateUserSchema, H as ApiRateLimiter, It as IngestEventSchema, J as StreamProducer, Mt as AddUserSchema, Nt as BatchAddContactsSchema, On as normaliseTarget, Pt as ContactChannelSchema, Rt as NotifyRequestSchema, S as AdminUserRepository, T as ProjectRepository, Ut as TriggerWorkflowSchema, Vt as SyncTemplatesSchema, Wt as UpdateProjectSchema, X as metrics, Xt as CONSUMER_GROUPS, Y as getMetricsRegistry, Yt as buildStreamEvent, Z as createLogger, at as deliveryOutbox, ct as projects, dt as userTopicPreferences, en as PUBSUB_CHANNELS, et as createDatabase, ft as users, g as transportRegistry, gn as readBaseConfig, k as UserRepository, kn as LRUCache, lt as scheduledPayloads, m as verifyUnsubscribeToken, mn as loadEnv, ot as messageLogs, pt as workflowDefinitions, st as projectApiKeys, tn as STREAMS, ut as suppressions, w as WorkflowRepository, z as RedisClient, zt as PreferencesSchema } from "./src-BRatuWJS.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,6 +1,6 @@
|
|
|
1
|
-
import { An as globalEmitter, Cn as DataLoader, D as ContactRepository, E as TemplateRepository, G as ProjectSettingsCache, J as StreamProducer, On as normaliseTarget, Q as IdempotencyGuard, T as ProjectRepository, W as UserThrottle, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, Zt as ENRICHED_STREAMS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, en as PUBSUB_CHANNELS, f as buildUnsubscribeHeaders, gn as readBaseConfig, kn as LRUCache, mn as loadEnv, on as registry, tn as STREAMS, ut as suppressions } 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 { An as globalEmitter, Cn as DataLoader, D as ContactRepository, E as TemplateRepository, G as ProjectSettingsCache, J as StreamProducer, On as normaliseTarget, Q as IdempotencyGuard, T as ProjectRepository, W as UserThrottle, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, Zt as ENRICHED_STREAMS, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, en as PUBSUB_CHANNELS, f as buildUnsubscribeHeaders, gn as readBaseConfig, kn as LRUCache, mn as loadEnv, on as registry, tn as STREAMS, ut as suppressions } from "./src-BRatuWJS.mjs";
|
|
2
|
+
import { t as scheduleOrDispatch } from "./schedule-or-dispatch-C5qfxQCv.mjs";
|
|
3
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-P63acBG9.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,5 +1,5 @@
|
|
|
1
|
-
import { An as globalEmitter, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, Q as IdempotencyGuard, Qt as INBOUND_STREAMS, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, k as UserRepository, mn as loadEnv, on as registry } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-
|
|
1
|
+
import { An as globalEmitter, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, Q as IdempotencyGuard, Qt as INBOUND_STREAMS, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, _ as TemplateCache, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, k as UserRepository, mn as loadEnv, on as registry } from "./src-BRatuWJS.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-P63acBG9.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 OUTBOUND_STREAMS, An as globalEmitter, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, H as ApiRateLimiter, J as StreamProducer, Q as IdempotencyGuard, Tn as BatchProcessor, X as metrics, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, _ as TemplateCache, at as deliveryOutbox, c as BaseWorker, d as startHealthReporter, en as PUBSUB_CHANNELS, g as transportRegistry, gn as readBaseConfig, lt as scheduledPayloads, mn as loadEnv, on as registry, tn as STREAMS, u as NonRetryableError, wn as CircuitBreaker, 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 OUTBOUND_STREAMS, An as globalEmitter, D as ContactRepository, Dn as getPriorityBucket, E as TemplateRepository, H as ApiRateLimiter, J as StreamProducer, Q as IdempotencyGuard, Tn as BatchProcessor, X as metrics, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, _ as TemplateCache, at as deliveryOutbox, c as BaseWorker, d as startHealthReporter, en as PUBSUB_CHANNELS, g as transportRegistry, gn as readBaseConfig, lt as scheduledPayloads, mn as loadEnv, on as registry, tn as STREAMS, u as NonRetryableError, wn as CircuitBreaker, x as renderWithTemplate } from "./src-BRatuWJS.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-P63acBG9.mjs";
|
|
3
|
+
import { n as upsertOutboxProviderIds } from "./bulk-Beblt3ny.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 { J as StreamProducer, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, a as SuspendExecutionError, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, gt as workflowWaiters, ht as workflowSteps, i as workflowRegistry, mn as loadEnv, mt as workflowInstances, o as buildStepNotifyPayload, pt as workflowDefinitions, tn as STREAMS } from "./src-
|
|
2
|
-
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-
|
|
1
|
+
import { J as StreamProducer, Xt as CONSUMER_GROUPS, Yt as buildStreamEvent, a as SuspendExecutionError, c as BaseWorker, d as startHealthReporter, gn as readBaseConfig, gt as workflowWaiters, ht as workflowSteps, i as workflowRegistry, mn as loadEnv, mt as workflowInstances, o as buildStepNotifyPayload, pt as workflowDefinitions, tn as STREAMS } from "./src-BRatuWJS.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-P63acBG9.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,6 +1,6 @@
|
|
|
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-
|
|
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-BRatuWJS.mjs";
|
|
2
|
+
import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-P63acBG9.mjs";
|
|
3
|
+
import { t as insertMessageLogs } from "./bulk-Beblt3ny.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 { Dn as getPriorityBucket, Yt as buildStreamEvent, lt as scheduledPayloads } from "./src-
|
|
1
|
+
import { Dn as getPriorityBucket, Yt as buildStreamEvent, lt as scheduledPayloads } from "./src-BRatuWJS.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region src/services/engine/schedule-or-dispatch.ts
|
|
4
4
|
/**
|
|
@@ -382,7 +382,7 @@ const baseConfigSchema = z.object({
|
|
|
382
382
|
DB_SCHEMA: z.string().trim().regex(/^[a-z_][a-z0-9_]{0,62}$/, "must be a lowercase PostgreSQL identifier").default("public"),
|
|
383
383
|
LOG_FLUSH_INTERVAL_MS: z.coerce.number().int().min(50).default(500),
|
|
384
384
|
LOG_BUFFER_MAX_SIZE: z.coerce.number().int().min(100).default(5e3),
|
|
385
|
-
SEGMENT_MAX_USERS: z.coerce.number().int().min(1).default(
|
|
385
|
+
SEGMENT_MAX_USERS: z.coerce.number().int().min(1).default(1e5),
|
|
386
386
|
/**
|
|
387
387
|
* Externally reachable base URL of this API. Unsubscribe links are built from
|
|
388
388
|
* it, so it must be what an inbox can actually reach — not `HOST`/`PORT`,
|
|
@@ -1944,6 +1944,13 @@ var PendingMessageScanner = class {
|
|
|
1944
1944
|
this.consumer = consumer;
|
|
1945
1945
|
this.logger = logger;
|
|
1946
1946
|
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Resets a held entry's idle time so no scanner reclaims it while its
|
|
1949
|
+
* handler is still running. JUSTID leaves the delivery count alone.
|
|
1950
|
+
*/
|
|
1951
|
+
async touch(id, stream) {
|
|
1952
|
+
await this.redis.xclaim(stream, this.group, this.consumer, 0, id, "JUSTID");
|
|
1953
|
+
}
|
|
1947
1954
|
async getPendingCount() {
|
|
1948
1955
|
let total = 0;
|
|
1949
1956
|
for (const s of this.streams) {
|
|
@@ -3676,7 +3683,7 @@ var BaseWorker = class {
|
|
|
3676
3683
|
globalEmitter.emit("notification:failed", message.event.id, "Poison pill: max retries exceeded", message.event.type);
|
|
3677
3684
|
return;
|
|
3678
3685
|
}
|
|
3679
|
-
const result = await this.
|
|
3686
|
+
const result = await this.processHoldingLease(message, retryCount);
|
|
3680
3687
|
if (result && result.ack === false) {
|
|
3681
3688
|
this.logger.debug({
|
|
3682
3689
|
messageId: message.id,
|
|
@@ -3728,6 +3735,29 @@ var BaseWorker = class {
|
|
|
3728
3735
|
}
|
|
3729
3736
|
}
|
|
3730
3737
|
/**
|
|
3738
|
+
* Runs `process` while keeping the entry's idle time below the reclaim
|
|
3739
|
+
* threshold. Without this, a handler that outlasts `recoveryIntervalMs` (a
|
|
3740
|
+
* large segment fan-out) is reclaimed mid-run and started again elsewhere,
|
|
3741
|
+
* over and over, until it is dead-lettered while the first run still works.
|
|
3742
|
+
* If this process dies the touches stop, so the entry is reclaimed as before.
|
|
3743
|
+
*/
|
|
3744
|
+
async processHoldingLease(message, attempt) {
|
|
3745
|
+
const stream = message.stream;
|
|
3746
|
+
const timer = stream ? setInterval(() => {
|
|
3747
|
+
this.pendingScanner.touch(message.id, stream).catch((err) => {
|
|
3748
|
+
this.logger.warn({
|
|
3749
|
+
err,
|
|
3750
|
+
messageId: message.id
|
|
3751
|
+
}, "failed to extend message lease");
|
|
3752
|
+
});
|
|
3753
|
+
}, Math.max(Math.floor(this.recoveryIntervalMs / 2), 10)) : void 0;
|
|
3754
|
+
try {
|
|
3755
|
+
return await this.process(message, attempt);
|
|
3756
|
+
} finally {
|
|
3757
|
+
clearInterval(timer);
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
/**
|
|
3731
3761
|
* `recoveryIntervalMs` is how long an entry must sit idle before it is
|
|
3732
3762
|
* claimed, not how often to look. Scanning only once per interval, timed from
|
|
3733
3763
|
* this worker's start, meant a worker restarted more often than that (a crash
|
|
@@ -4194,35 +4224,35 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4194
4224
|
}
|
|
4195
4225
|
const startupPromises = [];
|
|
4196
4226
|
if (services.includes("api")) {
|
|
4197
|
-
const { startApiServer } = await import("./main-
|
|
4227
|
+
const { startApiServer } = await import("./main-CktEylpL.mjs");
|
|
4198
4228
|
startupPromises.push(startApiServer());
|
|
4199
4229
|
}
|
|
4200
4230
|
if (services.includes("delivery")) {
|
|
4201
|
-
const { startDeliveryWorker } = await import("./main-
|
|
4231
|
+
const { startDeliveryWorker } = await import("./main-Lcbg7aEn.mjs");
|
|
4202
4232
|
startupPromises.push(startDeliveryWorker());
|
|
4203
4233
|
}
|
|
4204
4234
|
if (services.includes("engine")) {
|
|
4205
|
-
const { startEngineWorker } = await import("./main-
|
|
4235
|
+
const { startEngineWorker } = await import("./main-DB0bUh2r.mjs");
|
|
4206
4236
|
startupPromises.push(startEngineWorker());
|
|
4207
4237
|
}
|
|
4208
4238
|
if (services.includes("enricher")) {
|
|
4209
|
-
const { startEnricherWorker } = await import("./main-
|
|
4239
|
+
const { startEnricherWorker } = await import("./main-Dk92nti8.mjs");
|
|
4210
4240
|
startupPromises.push(startEnricherWorker());
|
|
4211
4241
|
}
|
|
4212
4242
|
if (services.includes("scheduler")) {
|
|
4213
|
-
const { startSchedulerWorker } = await import("./main-
|
|
4243
|
+
const { startSchedulerWorker } = await import("./main-BIahf4f9.mjs");
|
|
4214
4244
|
startupPromises.push(startSchedulerWorker());
|
|
4215
4245
|
}
|
|
4216
4246
|
if (services.includes("ai")) {
|
|
4217
|
-
const { startAiWorker } = await import("./main-
|
|
4247
|
+
const { startAiWorker } = await import("./main-C3XcLoCb.mjs");
|
|
4218
4248
|
startupPromises.push(startAiWorker());
|
|
4219
4249
|
}
|
|
4220
4250
|
if (services.includes("workflow")) {
|
|
4221
|
-
const { startWorkflowWorker } = await import("./main-
|
|
4251
|
+
const { startWorkflowWorker } = await import("./main-NHUvynW2.mjs");
|
|
4222
4252
|
startupPromises.push(startWorkflowWorker());
|
|
4223
4253
|
}
|
|
4224
4254
|
if (services.includes("events")) {
|
|
4225
|
-
const { startEventWorker } = await import("./main-
|
|
4255
|
+
const { startEventWorker } = await import("./main-_I4b1cmP.mjs");
|
|
4226
4256
|
startupPromises.push(startEventWorker());
|
|
4227
4257
|
}
|
|
4228
4258
|
const handleSignal = async (signal) => {
|
|
@@ -4244,9 +4274,9 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4244
4274
|
await Promise.all(startupPromises);
|
|
4245
4275
|
if (readBaseConfig().PIPELINE_FUSED && services.includes("enricher") && services.includes("engine") && services.includes("delivery")) {
|
|
4246
4276
|
const [{ getEnricherWorker }, { getEngineWorker }, { getDeliveryWorker }] = await Promise.all([
|
|
4247
|
-
import("./main-
|
|
4248
|
-
import("./main-
|
|
4249
|
-
import("./main-
|
|
4277
|
+
import("./main-Dk92nti8.mjs"),
|
|
4278
|
+
import("./main-DB0bUh2r.mjs"),
|
|
4279
|
+
import("./main-Lcbg7aEn.mjs")
|
|
4250
4280
|
]);
|
|
4251
4281
|
const enricher = getEnricherWorker();
|
|
4252
4282
|
const engine = getEngineWorker();
|
|
@@ -4277,14 +4307,14 @@ var NotifkitServer = class extends EventEmitter {
|
|
|
4277
4307
|
"events"
|
|
4278
4308
|
] : this.options.services;
|
|
4279
4309
|
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-
|
|
4310
|
+
["api", async () => (await import("./main-CktEylpL.mjs")).stopApiServer()],
|
|
4311
|
+
["workflow", async () => (await import("./main-NHUvynW2.mjs")).stopWorkflowWorker()],
|
|
4312
|
+
["enricher", async () => (await import("./main-Dk92nti8.mjs")).stopEnricherWorker()],
|
|
4313
|
+
["ai", async () => (await import("./main-C3XcLoCb.mjs")).stopAiWorker()],
|
|
4314
|
+
["engine", async () => (await import("./main-DB0bUh2r.mjs")).stopEngineWorker()],
|
|
4315
|
+
["scheduler", async () => (await import("./main-BIahf4f9.mjs")).stopSchedulerWorker()],
|
|
4316
|
+
["delivery", async () => (await import("./main-Lcbg7aEn.mjs")).stopDeliveryWorker()],
|
|
4317
|
+
["events", async () => (await import("./main-_I4b1cmP.mjs")).stopEventWorker()]
|
|
4288
4318
|
];
|
|
4289
4319
|
for (const [name, stop] of shutdownOrder) if (services.includes(name)) await stop();
|
|
4290
4320
|
if (this.pgContainer) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notifkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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/config/index.ts
CHANGED
|
@@ -82,7 +82,7 @@ export const baseConfigSchema = z.object({
|
|
|
82
82
|
.default("public"),
|
|
83
83
|
LOG_FLUSH_INTERVAL_MS: z.coerce.number().int().min(50).default(500),
|
|
84
84
|
LOG_BUFFER_MAX_SIZE: z.coerce.number().int().min(100).default(5000),
|
|
85
|
-
SEGMENT_MAX_USERS: z.coerce.number().int().min(1).default(
|
|
85
|
+
SEGMENT_MAX_USERS: z.coerce.number().int().min(1).default(100_000),
|
|
86
86
|
/**
|
|
87
87
|
* Externally reachable base URL of this API. Unsubscribe links are built from
|
|
88
88
|
* it, so it must be what an inbox can actually reach — not `HOST`/`PORT`,
|
package/src/queue/index.ts
CHANGED
|
@@ -582,6 +582,14 @@ export class PendingMessageScanner {
|
|
|
582
582
|
this.logger = logger;
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
+
/**
|
|
586
|
+
* Resets a held entry's idle time so no scanner reclaims it while its
|
|
587
|
+
* handler is still running. JUSTID leaves the delivery count alone.
|
|
588
|
+
*/
|
|
589
|
+
async touch(id: string, stream: string): Promise<void> {
|
|
590
|
+
await this.redis.xclaim(stream, this.group, this.consumer, 0, id, "JUSTID");
|
|
591
|
+
}
|
|
592
|
+
|
|
585
593
|
async getPendingCount(): Promise<number> {
|
|
586
594
|
let total = 0;
|
|
587
595
|
for (const s of this.streams) {
|
package/src/workers/index.ts
CHANGED
|
@@ -258,7 +258,7 @@ export abstract class BaseWorker {
|
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
const result = await this.
|
|
261
|
+
const result = await this.processHoldingLease(message, retryCount);
|
|
262
262
|
if (result && (result as any).ack === false) {
|
|
263
263
|
this.logger.debug(
|
|
264
264
|
{ messageId: message.id, eventType: message.event.type },
|
|
@@ -311,6 +311,32 @@ export abstract class BaseWorker {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Runs `process` while keeping the entry's idle time below the reclaim
|
|
316
|
+
* threshold. Without this, a handler that outlasts `recoveryIntervalMs` (a
|
|
317
|
+
* large segment fan-out) is reclaimed mid-run and started again elsewhere,
|
|
318
|
+
* over and over, until it is dead-lettered while the first run still works.
|
|
319
|
+
* If this process dies the touches stop, so the entry is reclaimed as before.
|
|
320
|
+
*/
|
|
321
|
+
private async processHoldingLease(message: StreamMessage, attempt: number) {
|
|
322
|
+
const stream = message.stream;
|
|
323
|
+
const timer = stream
|
|
324
|
+
? setInterval(
|
|
325
|
+
() => {
|
|
326
|
+
this.pendingScanner.touch(message.id, stream).catch((err: unknown) => {
|
|
327
|
+
this.logger.warn({ err, messageId: message.id }, "failed to extend message lease");
|
|
328
|
+
});
|
|
329
|
+
},
|
|
330
|
+
Math.max(Math.floor(this.recoveryIntervalMs / 2), 10),
|
|
331
|
+
)
|
|
332
|
+
: undefined;
|
|
333
|
+
try {
|
|
334
|
+
return await this.process(message, attempt);
|
|
335
|
+
} finally {
|
|
336
|
+
clearInterval(timer);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
314
340
|
/**
|
|
315
341
|
* `recoveryIntervalMs` is how long an entry must sit idle before it is
|
|
316
342
|
* claimed, not how often to look. Scanning only once per interval, timed from
|