notifkit 0.1.13 → 0.1.15

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.
Files changed (35) hide show
  1. package/README.md +4 -0
  2. package/dist/{bootstrap-omGPIBny.mjs → bootstrap-BOmT69OH.mjs} +1 -1
  3. package/dist/{bulk-C4hTcnLu.mjs → bulk-ZPiOJRx-.mjs} +1 -1
  4. package/dist/index.d.mts +16 -4
  5. package/dist/index.mjs +2 -2
  6. package/dist/{main-DAXO-MiH.mjs → main-24J4U8yP.mjs} +3 -3
  7. package/dist/{main-BtnGmyaT.mjs → main-BdZvBgV7.mjs} +9 -3
  8. package/dist/{main-B5BwjIMu.mjs → main-C0m9-Eos.mjs} +58 -5
  9. package/dist/{main-DYGCl7Ja.mjs → main-C6S3EsJ3.mjs} +2 -2
  10. package/dist/{main-B-AZ-xoN.mjs → main-CCqcFDDe.mjs} +2 -2
  11. package/dist/{main-Bes11Ad3.mjs → main-CTjaZ7ZD.mjs} +2 -2
  12. package/dist/{main-BU27VjDC.mjs → main-JEXBLP2A.mjs} +2 -2
  13. package/dist/{main-BxAeC_k6.mjs → main-g33jpia4.mjs} +157 -76
  14. package/dist/{src-CIPTzq9i.mjs → src-9LXITcNi.mjs} +64 -39
  15. package/drizzle/0008_delivery_outbox_destination_idx.sql +3 -0
  16. package/drizzle/meta/_journal.json +7 -0
  17. package/package.json +3 -2
  18. package/scripts/create-admin.mjs +8 -0
  19. package/scripts/create-project.mjs +0 -0
  20. package/scripts/migrate.mjs +0 -0
  21. package/scripts/notifkit.mjs +0 -0
  22. package/src/config/index.ts +6 -3
  23. package/src/contracts/streams.ts +4 -0
  24. package/src/db/schema.ts +3 -0
  25. package/src/queue/index.ts +19 -23
  26. package/src/redis/index.ts +20 -0
  27. package/src/services/api/admin-static.ts +21 -11
  28. package/src/services/api/handlers.ts +51 -43
  29. package/src/services/api/http.ts +12 -9
  30. package/src/services/api/live-events.ts +74 -0
  31. package/src/services/api/main.ts +57 -23
  32. package/src/services/delivery/live-events.ts +68 -0
  33. package/src/services/delivery/main.ts +14 -2
  34. package/src/services/engine/main.ts +13 -1
  35. package/dashboard/README.md +0 -29
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) · [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
+
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.
@@ -1,4 +1,4 @@
1
- import { $t as STREAMS, G as StreamConsumer, K as StreamProducer, Q as createDatabase, R as RedisClient, W as PendingMessageScanner, Y as createLogger } from "./src-CIPTzq9i.mjs";
1
+ import { $ as createDatabase, G as PendingMessageScanner, K as StreamConsumer, X as createLogger, en as STREAMS, q as StreamProducer, z as RedisClient } from "./src-9LXITcNi.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) {
@@ -1,4 +1,4 @@
1
- import { it as messageLogs, rt as deliveryOutbox } from "./src-CIPTzq9i.mjs";
1
+ import { at as messageLogs, it as deliveryOutbox } from "./src-9LXITcNi.mjs";
2
2
  import { sql } from "drizzle-orm";
3
3
  //#region src/db/bulk.ts
4
4
  function rawClient(db) {
package/dist/index.d.mts CHANGED
@@ -44,7 +44,7 @@ declare const baseConfigSchema: z.ZodObject<{
44
44
  SEGMENT_MAX_USERS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
45
45
  PUBLIC_URL: z.ZodOptional<z.ZodString>;
46
46
  UNSUBSCRIBE_SECRET: z.ZodOptional<z.ZodString>;
47
- TRUST_PROXY: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<boolean, string | undefined>>;
47
+ TRUST_PROXY: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<number, string | undefined>>;
48
48
  CORS_ORIGIN: z.ZodOptional<z.ZodString>;
49
49
  }, z.core.$strip>;
50
50
  type BaseConfig = z.infer<typeof baseConfigSchema>;
@@ -698,6 +698,10 @@ declare const PUBSUB_CHANNELS: {
698
698
  readonly PROJECT_INVALIDATED: "project.invalidated";
699
699
  /** Payload: a token hash, or `*` for the whole cache. */
700
700
  readonly API_KEY_INVALIDATED: "apikey.invalidated";
701
+ /** Delivery outcomes for GET /v1/events/stream; see services/delivery/live-events. */
702
+ readonly DELIVERY_EVENTS: "delivery.events";
703
+ /** An API began listening on DELIVERY_EVENTS: delivery workers resume publishing. */
704
+ readonly DELIVERY_EVENTS_WANTED: "delivery.events.wanted";
701
705
  };
702
706
  type PubSubChannel = (typeof PUBSUB_CHANNELS)[keyof typeof PUBSUB_CHANNELS];
703
707
  declare const CONSUMER_GROUPS: {
@@ -4077,7 +4081,7 @@ interface StreamConsumerOptions {
4077
4081
  }
4078
4082
  declare class StreamConsumer {
4079
4083
  readonly redis: Redis;
4080
- private readonly blockingRedis;
4084
+ private blockingRedis;
4081
4085
  private readonly streams;
4082
4086
  private readonly group;
4083
4087
  private readonly consumer;
@@ -4098,7 +4102,7 @@ declare class StreamConsumer {
4098
4102
  /**
4099
4103
  * Acks and then deletes the entries. Every stream is read by exactly one
4100
4104
  * consumer group, so an acked entry is never read again; leaving it in place
4101
- * holds Redis memory until MAXLEN trims it, and a group recreated from "0"
4105
+ * holds Redis memory for good, and a group recreated from "0"
4102
4106
  * (ensureGroup) would process it a second time. Both commands are issued
4103
4107
  * before either is awaited, so auto-pipelining sends them in one round trip,
4104
4108
  * and Redis runs them in order.
@@ -4258,6 +4262,7 @@ declare module "ioredis" {
4258
4262
  interface Redis {
4259
4263
  leaseApiRateLimit(currentKey: string, prevKey: string, now: number | string, window: number | string, maxReqs: number | string, requested: number | string, ttl?: number | string): Promise<number>;
4260
4264
  releaseLock(lockKey: string, lockToken: string): Promise<number>;
4265
+ countRequest(key: string, ttlSeconds: number | string): Promise<number>;
4261
4266
  renewLock(lockKey: string, lockToken: string, ttlSeconds: number | string): Promise<number>;
4262
4267
  throttleUser(key: string, windowStart: number | string, limit: number | string, targetTime: number | string, memberId: string, ttlSeconds: number | string, pruneBefore?: number | string): Promise<number>;
4263
4268
  schedulerPoll(key: string, maxScore: number | string, limit: number | string, visibilityTimeout: number | string): Promise<string[]>;
@@ -4293,6 +4298,13 @@ declare const LUA_RENEW_LOCK = "\n if redis.call('GET', KEYS[1]) == ARGV[1] the
4293
4298
  declare const LUA_USER_THROTTLE = "\n local limit = tonumber(ARGV[2])\n local targetTime = tonumber(ARGV[3])\n local ttl = tonumber(ARGV[5])\n redis.call(\"ZREMRANGEBYSCORE\", KEYS[1], \"-inf\", ARGV[6] or ARGV[1])\n if redis.call(\"ZSCORE\", KEYS[1], ARGV[4]) then\n return 0\n end\n local count = redis.call(\"ZCOUNT\", KEYS[1], \"(\" .. ARGV[1], targetTime)\n if count < limit then\n redis.call(\"ZADD\", KEYS[1], targetTime, ARGV[4])\n -- Only ever extend: a send today must not cut short the life of a key\n -- that is still holding a send scheduled for next week.\n if redis.call(\"TTL\", KEYS[1]) < ttl then\n redis.call(\"EXPIRE\", KEYS[1], ttl)\n end\n end\n return count + 1\n";
4294
4299
  /** Polls scheduler zsets with visibility timeouts. */
4295
4300
  declare const LUA_SCHEDULER_POLL = "\n local key = KEYS[1]\n local maxScore = tonumber(ARGV[1])\n local limit = tonumber(ARGV[2])\n local visibilityTimeout = tonumber(ARGV[3]) or 0\n local tasks = redis.call('ZRANGE', key, 0, maxScore, 'BYSCORE', 'LIMIT', 0, limit)\n if #tasks > 0 then\n for i, task in ipairs(tasks) do\n redis.call('ZADD', key, maxScore + visibilityTimeout, task)\n end\n end\n return tasks\n";
4301
+ /**
4302
+ * Fixed-window request counter: INCR, and an expiry whenever the key has none.
4303
+ * One script so the two cannot come apart. With INCR and EXPIRE sent
4304
+ * separately, a failure between them left a counter with no expiry, and the
4305
+ * address it counted stayed over its limit for good.
4306
+ */
4307
+ declare const LUA_COUNT_REQUEST = "\n local count = redis.call('INCR', KEYS[1])\n if redis.call('TTL', KEYS[1]) < 0 then\n redis.call('EXPIRE', KEYS[1], ARGV[1])\n end\n return count\n";
4296
4308
  /** Two-phase idempotency lease acquisition. Checks sent/legacy, then attempts SET NX lock. */
4297
4309
  declare const LUA_ACQUIRE_LEASE = "\n if redis.call('EXISTS', KEYS[1]) == 1 or redis.call('EXISTS', KEYS[3]) == 1 then\n return 'completed'\n end\n local lockAcquired = redis.call('SET', KEYS[2], '1', 'EX', ARGV[1], 'NX')\n if lockAcquired then\n return 'acquired'\n end\n if redis.call('EXISTS', KEYS[1]) == 1 or redis.call('EXISTS', KEYS[3]) == 1 then\n return 'completed'\n end\n return 'locked'\n";
4298
4310
  /** Two-phase idempotency completion marker. Atomically sets completed + legacy and deletes lock. */
@@ -5236,4 +5248,4 @@ declare class NotifkitServer extends EventEmitter {
5236
5248
  stop(): Promise<void>;
5237
5249
  }
5238
5250
  //#endregion
5239
- export { AI_DEFAULTS, AddContactInput, AddContactSchema, AddUserInput, AddUserSchema, AdminUserRecord, AdminUserRepository, AiConfig, ApiRateLimiter, ApiRateLimiterOptions, AppError, AsyncSemaphore, BaseConfig, BaseWorker, BatchAddContactsInput, BatchAddContactsSchema, BatchItem, BatchProcessor, CONSUMER_GROUPS, CircuitBreaker, CircuitBreakerOptions, ConsumerGroup, ContactChannel, ContactChannelSchema, ContactRepository, CreateWorkflowInput, CreateWorkflowSchema, CreatedProjectKeyRecord, DLQMessageRecord, DataLoader, DataLoaderOptions, DatabaseClients, DatabaseOptions, Db, DeliveryOptions, DeliveryOptionsSchema, DeliveryResult, DevicePlatform, DeviceToken, DispatchedTaskPayload, ENRICHED_STREAMS, EscapeMode, EventEnvelope, EventEnvelopeSchema, EventMetadata, EventMetadataSchema, EventPayloadMap, EventRegistry, INBOUND_STREAMS, IdempotencyGuard, IdempotencyOptions, IngestEventInput, IngestEventSchema, InlineUser, InlineUserSchema, KnownEventType, LRUCache, LUA_ACQUIRE_LEASE, LUA_LEASE_API_RATE_LIMIT, LUA_MARK_PROCESSED, LUA_RELEASE_LOCK, LUA_RENEW_LOCK, LUA_SCHEDULER_POLL, LUA_USER_THROTTLE, LeaseResult, LockHeldError, LogLevel, Logger, LoggerOptions, MigrationOptions, NonRetryableError, NotificationAiPendingPayload, NotificationAiPendingPayloadSchema, NotificationCanceledPayload, NotificationCanceledPayloadSchema, NotificationChannel, NotificationChannelSchema, NotificationCreatedPayload, NotificationCreatedPayloadSchema, NotificationDeliveredPayload, NotificationDeliveredPayloadSchema, NotificationDispatchedPayload, NotificationDispatchedPayloadSchema, NotificationEnrichedPayload, NotificationEnrichedPayloadSchema, NotificationFailedPayload, NotificationFailedPayloadSchema, NotificationLogRecord, NotificationPreference, NotificationPriority, NotificationPrioritySchema, NotificationRequestedPayload, NotificationRequestedPayloadSchema, NotificationScheduledPayload, NotificationScheduledPayloadSchema, NotificationSkippedPayload, NotificationSkippedPayloadSchema, NotificationStatus, NotificationStatusSchema, NotificationTarget, NotificationTargetSchema, NotifkitClient, NotifkitClientOptions, NotifkitOptions, NotifkitServer, NotifyRequestInput, NotifyRequestSchema, OUTBOUND_STREAMS, PUBSUB_CHANNELS, ParseResult, PendingEntry, PendingMessageScanner, PendingMessageScannerOptions, PreferenceRepository, Preferences, PreferencesSchema, ProcessResult, ProjectKeyRecord, ProjectRecord, ProjectRepository, ProjectSettingsCache, ProjectSettingsCacheOptions, ProjectThrottleSettings, PubSubChannel, QuietHours, QuietHoursSchema, RateLimitConfig, RecipientProfile, RecipientProfileSchema, Redis, RedisClient, RedisClientOptions, type RedisOptions, RenderedContent, RenderedContentSchema, STREAMS, SegmentRepository, Sql, StreamConsumer, StreamConsumerOptions, StreamEvent, StreamEventMetadata, StreamEventMetadataSchema, StreamEventSchema, StreamMessage, StreamName, StreamProducer, StreamProducerOptions, SuppressionRecord, SuspendExecutionError, SyncTemplatesInput, SyncTemplatesSchema, SystemHealthRecord, SystemMetricsRecord, TemplateCache, TemplateInput, TemplateRecord, TemplateRecordResponse, TemplateRepository, TemplateSchema, ThrottleCheckOptions, ThrottleResult, Transport, TriggerWorkflowInput, TriggerWorkflowSchema, TypedEventEnvelope, UnsubscribeClaim, UnsubscribeHeaderOptions, UpdateProjectInput, UpdateProjectSchema, UpdateUserInput, UpdateUserSchema, UserContact, UserContactInput, UserContactInputSchema, UserContactResponse, UserDetailResponse, UserProfile, UserProfileResponse, UserRecord, UserRepository, UserResponse, UserThrottle, UserThrottleOptions, ValidationError, WebhookEvent, WorkerHealth, WorkerOptions, WorkerState, WorkflowContext, WorkflowDefinitionRecord, WorkflowEvent, WorkflowInstanceRecord, WorkflowNotifyInput, WorkflowNotifyPayloadSchema, WorkflowNotifyResult, WorkflowRepository, WorkflowStepContext, WorkflowStepDef, WorkflowStepRecord, WorkflowStepSchema, WorkflowWaiterRecord, assertTablesInSchema, baseConfigSchema, buildStepNotifyPayload, buildStreamEvent, buildUnsubscribeHeaders, calculateTokenBatchSize, createDatabase, createLogger, escapeHeader, escapeHtml, generateId, getAiConfig, getMetricsRegistry, getPriorityBucket, globalEmitter, interpolate, loadEnv, metrics, migrateDatabase, normaliseTarget, notifkitTableNames, parseConfig, qualifyMigrationSql, readBaseConfig, registerCustomCommands, registerTransport, registry, renderWithTemplate, resolveStepTarget, runMigrations, setAiConfig, setGlobalConfig, signUnsubscribeToken, sleep, startHealthReporter, transportRegistry, verifyUnsubscribeToken, workflow, workflowRegistry };
5251
+ export { AI_DEFAULTS, AddContactInput, AddContactSchema, AddUserInput, AddUserSchema, AdminUserRecord, AdminUserRepository, AiConfig, ApiRateLimiter, ApiRateLimiterOptions, AppError, AsyncSemaphore, BaseConfig, BaseWorker, BatchAddContactsInput, BatchAddContactsSchema, BatchItem, BatchProcessor, CONSUMER_GROUPS, CircuitBreaker, CircuitBreakerOptions, ConsumerGroup, ContactChannel, ContactChannelSchema, ContactRepository, CreateWorkflowInput, CreateWorkflowSchema, CreatedProjectKeyRecord, DLQMessageRecord, DataLoader, DataLoaderOptions, DatabaseClients, DatabaseOptions, Db, DeliveryOptions, DeliveryOptionsSchema, DeliveryResult, DevicePlatform, DeviceToken, DispatchedTaskPayload, ENRICHED_STREAMS, EscapeMode, EventEnvelope, EventEnvelopeSchema, EventMetadata, EventMetadataSchema, EventPayloadMap, EventRegistry, INBOUND_STREAMS, IdempotencyGuard, IdempotencyOptions, IngestEventInput, IngestEventSchema, InlineUser, InlineUserSchema, KnownEventType, 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, LeaseResult, LockHeldError, LogLevel, Logger, LoggerOptions, MigrationOptions, NonRetryableError, NotificationAiPendingPayload, NotificationAiPendingPayloadSchema, NotificationCanceledPayload, NotificationCanceledPayloadSchema, NotificationChannel, NotificationChannelSchema, NotificationCreatedPayload, NotificationCreatedPayloadSchema, NotificationDeliveredPayload, NotificationDeliveredPayloadSchema, NotificationDispatchedPayload, NotificationDispatchedPayloadSchema, NotificationEnrichedPayload, NotificationEnrichedPayloadSchema, NotificationFailedPayload, NotificationFailedPayloadSchema, NotificationLogRecord, NotificationPreference, NotificationPriority, NotificationPrioritySchema, NotificationRequestedPayload, NotificationRequestedPayloadSchema, NotificationScheduledPayload, NotificationScheduledPayloadSchema, NotificationSkippedPayload, NotificationSkippedPayloadSchema, NotificationStatus, NotificationStatusSchema, NotificationTarget, NotificationTargetSchema, NotifkitClient, NotifkitClientOptions, NotifkitOptions, NotifkitServer, NotifyRequestInput, NotifyRequestSchema, OUTBOUND_STREAMS, PUBSUB_CHANNELS, ParseResult, PendingEntry, PendingMessageScanner, PendingMessageScannerOptions, PreferenceRepository, Preferences, PreferencesSchema, ProcessResult, ProjectKeyRecord, ProjectRecord, ProjectRepository, ProjectSettingsCache, ProjectSettingsCacheOptions, ProjectThrottleSettings, PubSubChannel, QuietHours, QuietHoursSchema, RateLimitConfig, RecipientProfile, RecipientProfileSchema, Redis, RedisClient, RedisClientOptions, type RedisOptions, RenderedContent, RenderedContentSchema, STREAMS, SegmentRepository, Sql, StreamConsumer, StreamConsumerOptions, StreamEvent, StreamEventMetadata, StreamEventMetadataSchema, StreamEventSchema, StreamMessage, StreamName, StreamProducer, StreamProducerOptions, SuppressionRecord, SuspendExecutionError, SyncTemplatesInput, SyncTemplatesSchema, SystemHealthRecord, SystemMetricsRecord, TemplateCache, TemplateInput, TemplateRecord, TemplateRecordResponse, TemplateRepository, TemplateSchema, ThrottleCheckOptions, ThrottleResult, Transport, TriggerWorkflowInput, TriggerWorkflowSchema, TypedEventEnvelope, UnsubscribeClaim, UnsubscribeHeaderOptions, UpdateProjectInput, UpdateProjectSchema, UpdateUserInput, UpdateUserSchema, UserContact, UserContactInput, UserContactInputSchema, UserContactResponse, UserDetailResponse, UserProfile, UserProfileResponse, UserRecord, UserRepository, UserResponse, UserThrottle, UserThrottleOptions, ValidationError, WebhookEvent, WorkerHealth, WorkerOptions, WorkerState, WorkflowContext, WorkflowDefinitionRecord, WorkflowEvent, WorkflowInstanceRecord, WorkflowNotifyInput, WorkflowNotifyPayloadSchema, WorkflowNotifyResult, WorkflowRepository, WorkflowStepContext, WorkflowStepDef, WorkflowStepRecord, WorkflowStepSchema, WorkflowWaiterRecord, assertTablesInSchema, baseConfigSchema, buildStepNotifyPayload, buildStreamEvent, buildUnsubscribeHeaders, calculateTokenBatchSize, createDatabase, createLogger, escapeHeader, escapeHtml, generateId, getAiConfig, getMetricsRegistry, getPriorityBucket, globalEmitter, interpolate, loadEnv, metrics, migrateDatabase, normaliseTarget, notifkitTableNames, parseConfig, qualifyMigrationSql, readBaseConfig, registerCustomCommands, registerTransport, registry, renderWithTemplate, resolveStepTarget, runMigrations, setAiConfig, setGlobalConfig, signUnsubscribeToken, sleep, startHealthReporter, transportRegistry, verifyUnsubscribeToken, workflow, workflowRegistry };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as migrateDatabase, $t as STREAMS, A as LUA_ACQUIRE_LEASE, At as AddUserSchema, B as ApiRateLimiter, Bt as TemplateSchema, C as ContactRepository, Cn as BatchProcessor, Ct as NotificationScheduledPayloadSchema, D as TemplateRepository, Dn as LRUCache, Dt as NotificationRequestedPayloadSchema, E as SegmentRepository, En as normaliseTarget, Et as NotificationCreatedPayloadSchema, F as LUA_SCHEDULER_POLL, Ft as InlineUserSchema, G as StreamConsumer, Gt as WorkflowNotifyPayloadSchema, H as UserThrottle, Ht as UpdateProjectSchema, I as LUA_USER_THROTTLE, It as NotifyRequestSchema, J as metrics, Jt as CONSUMER_GROUPS, K as StreamProducer, Kt as WorkflowStepSchema, L as Redis, Lt as PreferencesSchema, M as LUA_MARK_PROCESSED, Mt as ContactChannelSchema, N as LUA_RELEASE_LOCK, Nt as CreateWorkflowSchema, O as UserRepository, On as globalEmitter, Ot as NotificationTargetSchema, P as LUA_RENEW_LOCK, Pt as IngestEventSchema, Q as createDatabase, Qt as PUBSUB_CHANNELS, R as RedisClient, Rt as QuietHoursSchema, S as AdminUserRepository, Sn as CircuitBreaker, St as RenderedContentSchema, T as ProjectRepository, Tn as getPriorityBucket, Tt as RecipientProfileSchema, U as calculateTokenBatchSize, Ut as UpdateUserSchema, V as ProjectSettingsCache, 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 WorkflowRepository, 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 PreferenceRepository, 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-CIPTzq9i.mjs";
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_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, registerCustomCommands, registerTransport, registry, renderWithTemplate, resolveStepTarget, runMigrations, setAiConfig, setGlobalConfig, signUnsubscribeToken, sleep, startHealthReporter, transportRegistry, verifyUnsubscribeToken, workflow, workflowRegistry };
1
+ import { $ as createDatabase, $t as PUBSUB_CHANNELS, A as LUA_ACQUIRE_LEASE, At as AddContactSchema, B as registerCustomCommands, Bt as SyncTemplatesSchema, C as ContactRepository, Cn as CircuitBreaker, Ct as RenderedContentSchema, D as TemplateRepository, Dn as normaliseTarget, Dt as NotificationCreatedPayloadSchema, E as SegmentRepository, En as getPriorityBucket, Et as RecipientProfileSchema, F as LUA_RENEW_LOCK, Ft as IngestEventSchema, G as PendingMessageScanner, Gt as UserContactInputSchema, H as ProjectSettingsCache, Ht as TriggerWorkflowSchema, I as LUA_SCHEDULER_POLL, It as InlineUserSchema, J as getMetricsRegistry, Jt as buildStreamEvent, K as StreamConsumer, Kt as WorkflowNotifyPayloadSchema, L as LUA_USER_THROTTLE, Lt as NotifyRequestSchema, M as LUA_LEASE_API_RATE_LIMIT, Mt as BatchAddContactsSchema, N as LUA_MARK_PROCESSED, Nt as ContactChannelSchema, O as UserRepository, On as LRUCache, Ot as NotificationRequestedPayloadSchema, P as LUA_RELEASE_LOCK, Pt as CreateWorkflowSchema, Q as assertTablesInSchema, Qt as OUTBOUND_STREAMS, R as Redis, Rt as PreferencesSchema, S as AdminUserRepository, Sn as DataLoader, St as NotificationDispatchedPayloadSchema, T as ProjectRepository, Tn as AsyncSemaphore, Tt as NotificationEnrichedPayloadSchema, U as UserThrottle, Ut as UpdateProjectSchema, V as ApiRateLimiter, Vt as TemplateSchema, W as calculateTokenBatchSize, Wt as UpdateUserSchema, X as createLogger, Xt as ENRICHED_STREAMS, Y as metrics, Yt as CONSUMER_GROUPS, Z as IdempotencyGuard, Zt as INBOUND_STREAMS, _ as TemplateCache, _n as setGlobalConfig, _t as NotificationCanceledPayloadSchema, a as SuspendExecutionError, an as registry, b as interpolate, bn as generateId, bt as NotificationDeliveredPayloadSchema, c as BaseWorker, cn as NotificationPrioritySchema, d as startHealthReporter, dn as baseConfigSchema, en as STREAMS, et as migrateDatabase, f as buildUnsubscribeHeaders, fn as getAiConfig, g as transportRegistry, gn as setAiConfig, gt as NotificationAiPendingPayloadSchema, h as registerTransport, hn as readBaseConfig, i as workflowRegistry, in as EventRegistry, j as LUA_COUNT_REQUEST, jt as AddUserSchema, k as WorkflowRepository, kn as globalEmitter, kt as NotificationTargetSchema, l as LockHeldError, ln as NotificationStatusSchema, m as verifyUnsubscribeToken, mn as parseConfig, n as NotifkitClient, nn as StreamEventMetadataSchema, nt as qualifyMigrationSql, o as buildStepNotifyPayload, on as EventMetadataSchema, p as signUnsubscribeToken, pn as loadEnv, q as StreamProducer, qt as WorkflowStepSchema, r as workflow, rn as StreamEventSchema, rt as runMigrations, s as resolveStepTarget, sn as NotificationChannelSchema, t as NotifkitServer, tn as EventEnvelopeSchema, tt as notifkitTableNames, u as NonRetryableError, un as AI_DEFAULTS, v as escapeHeader, vn as AppError, vt as NotificationSkippedPayloadSchema, w as PreferenceRepository, wn as BatchProcessor, wt as NotificationScheduledPayloadSchema, x as renderWithTemplate, xn as sleep, xt as DeliveryOptionsSchema, y as escapeHtml, yn as ValidationError, yt as NotificationFailedPayloadSchema, z as RedisClient, zt as QuietHoursSchema } from "./src-9LXITcNi.mjs";
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, 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-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-omGPIBny.mjs";
3
- import { t as insertMessageLogs } from "./bulk-C4hTcnLu.mjs";
1
+ import { Jt as buildStreamEvent, Yt as CONSUMER_GROUPS, c as BaseWorker, d as startHealthReporter, en as STREAMS, hn as readBaseConfig, ht as workflowWaiters, mt as workflowSteps, pn as loadEnv, pt as workflowInstances, q as StreamProducer } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-BOmT69OH.mjs";
3
+ import { t as insertMessageLogs } from "./bulk-ZPiOJRx-.mjs";
4
4
  import { and, eq, gt, isNull, or } from "drizzle-orm";
5
5
  //#region src/services/events/main.ts
6
6
  loadEnv();
@@ -1,5 +1,5 @@
1
- import { $t as STREAMS, C as ContactRepository, D as TemplateRepository, Dn as LRUCache, En as normaliseTarget, H as UserThrottle, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Qt as PUBSUB_CHANNELS, T as ProjectRepository, Tn as getPriorityBucket, V 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, st as scheduledPayloads, xn as DataLoader } from "./src-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-omGPIBny.mjs";
1
+ import { $t as PUBSUB_CHANNELS, C as ContactRepository, D as TemplateRepository, Dn as normaliseTarget, En as getPriorityBucket, H as ProjectSettingsCache, Jt as buildStreamEvent, On as LRUCache, Sn as DataLoader, T as ProjectRepository, U as UserThrottle, Xt as ENRICHED_STREAMS, Yt as CONSUMER_GROUPS, Z as IdempotencyGuard, _ as TemplateCache, an as registry, c as BaseWorker, ct as scheduledPayloads, d as startHealthReporter, en as STREAMS, f as buildUnsubscribeHeaders, hn as readBaseConfig, kn as globalEmitter, lt as suppressions, pn as loadEnv, q as StreamProducer } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-BOmT69OH.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { and, eq } from "drizzle-orm";
5
5
  //#region src/services/engine/main.ts
@@ -72,9 +72,15 @@ function isInQuietHours(timezone, quietHours, fromDate = /* @__PURE__ */ new Dat
72
72
  targetMonth = nextDay.getUTCMonth() + 1;
73
73
  targetDay = nextDay.getUTCDate();
74
74
  }
75
+ let nextActive = localTimeToUtc(targetYear, targetMonth, targetDay, endH, endM, 0, timezone);
76
+ if (nextActive.getTime() <= date.getTime()) {
77
+ const currentSec = parseInt(parts.find((p) => p.type === "second")?.value ?? "0", 10);
78
+ const offsetMs = Date.UTC(year, month - 1, day, currentHour, currentMin, currentSec) - Math.floor(date.getTime() / 1e3) * 1e3;
79
+ nextActive = new Date(Date.UTC(targetYear, targetMonth - 1, targetDay, endH, endM, 0) - offsetMs);
80
+ }
75
81
  return {
76
82
  inQuietHours: true,
77
- nextActiveTime: localTimeToUtc(targetYear, targetMonth, targetDay, endH, endM, 0, timezone)
83
+ nextActiveTime: nextActive
78
84
  };
79
85
  }
80
86
  }
@@ -1,7 +1,56 @@
1
- import { $t as STREAMS, B as ApiRateLimiter, C as ContactRepository, Cn as BatchProcessor, D 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, pn as parseConfig, qt as buildStreamEvent, rt as deliveryOutbox, st as scheduledPayloads, u as NonRetryableError, un as baseConfigSchema, x as renderWithTemplate } from "./src-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-omGPIBny.mjs";
3
- import { n as upsertOutboxProviderIds } from "./bulk-C4hTcnLu.mjs";
1
+ import { $t as PUBSUB_CHANNELS, C as ContactRepository, Cn as CircuitBreaker, D as TemplateRepository, En as getPriorityBucket, Jt as buildStreamEvent, Qt as OUTBOUND_STREAMS, V as ApiRateLimiter, Y as metrics, Yt as CONSUMER_GROUPS, Z as IdempotencyGuard, _ as TemplateCache, an as registry, c as BaseWorker, ct as scheduledPayloads, d as startHealthReporter, dn as baseConfigSchema, en as STREAMS, g as transportRegistry, it as deliveryOutbox, kn as globalEmitter, mn as parseConfig, pn as loadEnv, q as StreamProducer, u as NonRetryableError, wn as BatchProcessor, x as renderWithTemplate } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-BOmT69OH.mjs";
3
+ import { n as upsertOutboxProviderIds } from "./bulk-ZPiOJRx-.mjs";
4
4
  import { sql } from "drizzle-orm";
5
+ //#region src/services/delivery/live-events.ts
6
+ /**
7
+ * How long to stop publishing after a publish nobody was subscribed to. Only
8
+ * a fallback: an API that starts listening says so on DELIVERY_EVENTS_WANTED,
9
+ * which ends the quiet straight away.
10
+ */
11
+ const QUIET_MS = 5e3;
12
+ /**
13
+ * Forwards the delivery worker's `delivery:*` events to Redis.
14
+ *
15
+ * The API subscribes only while a client has the stream open, so most of the
16
+ * time a publish reaches nobody. PUBLISH says how many received it; after a 0
17
+ * this goes quiet rather than paying a round trip per delivery for no one,
18
+ * until an API announces it is listening.
19
+ */
20
+ function publishDeliveryEvents(redis, emitter) {
21
+ let quietUntil = 0;
22
+ const wanted = redis.duplicate({ enableAutoPipelining: false });
23
+ wanted.on("message", () => quietUntil = 0);
24
+ wanted.subscribe(PUBSUB_CHANNELS.DELIVERY_EVENTS_WANTED).catch(() => {});
25
+ const publish = (message) => {
26
+ if (Date.now() < quietUntil) return;
27
+ redis.publish(PUBSUB_CHANNELS.DELIVERY_EVENTS, JSON.stringify(message)).then((receivers) => {
28
+ if (receivers === 0) quietUntil = Date.now() + QUIET_MS;
29
+ }).catch(() => {});
30
+ };
31
+ const onDelivered = (taskId, providerMessageId, channel, projectId) => publish({
32
+ event: "delivery:delivered",
33
+ taskId,
34
+ providerMessageId,
35
+ channel,
36
+ projectId
37
+ });
38
+ const onFailed = (taskId, error, channel, projectId) => publish({
39
+ event: "delivery:failed",
40
+ taskId,
41
+ error,
42
+ channel,
43
+ projectId
44
+ });
45
+ emitter.on("delivery:delivered", onDelivered);
46
+ emitter.on("delivery:failed", onFailed);
47
+ return () => {
48
+ emitter.off("delivery:delivered", onDelivered);
49
+ emitter.off("delivery:failed", onFailed);
50
+ wanted.disconnect();
51
+ };
52
+ }
53
+ //#endregion
5
54
  //#region src/services/delivery/throttle.ts
6
55
  /**
7
56
  * Provider rate limit enforced through locally leased tokens.
@@ -66,6 +115,7 @@ let scheduledProducer;
66
115
  let enrichedProducers;
67
116
  let healthInterval = null;
68
117
  let subscriber = null;
118
+ let stopLiveEvents = null;
69
119
  global._telemetry = global._telemetry || {
70
120
  count: 0,
71
121
  insert: 0,
@@ -476,7 +526,7 @@ var DeliveryWorker = class extends BaseWorker {
476
526
  if (controller.signal.aborted) return reject(controller.signal.reason);
477
527
  controller.signal.addEventListener("abort", () => reject(controller.signal.reason));
478
528
  })]);
479
- if (!res.success && !res.invalidToken) throw providerFailure(res);
529
+ if (!res.success && !res.invalidToken && res.retryable !== false) throw providerFailure(res);
480
530
  return res;
481
531
  } finally {
482
532
  clearTimeout(timeout);
@@ -613,7 +663,7 @@ var DeliveryWorker = class extends BaseWorker {
613
663
  if (controller.signal.aborted) return reject(controller.signal.reason);
614
664
  controller.signal.addEventListener("abort", () => reject(controller.signal.reason));
615
665
  })]);
616
- if (!res.success) throw providerFailure(res);
666
+ if (!res.success && res.retryable !== false) throw providerFailure(res);
617
667
  return res;
618
668
  } finally {
619
669
  clearTimeout(timeout);
@@ -785,6 +835,7 @@ async function startDeliveryWorker() {
785
835
  subscriber = redis.native.duplicate({ enableAutoPipelining: false });
786
836
  await subscriber.subscribe(PUBSUB_CHANNELS.TEMPLATE_INVALIDATED);
787
837
  subscriber.on("message", (_channel, key) => templateCache.invalidateKey(key));
838
+ stopLiveEvents = publishDeliveryEvents(redis.native, globalEmitter);
788
839
  healthInterval = startHealthReporter("delivery", worker, redis, logger);
789
840
  logger.info({
790
841
  env: config.NODE_ENV,
@@ -806,6 +857,8 @@ async function stopDeliveryWorker() {
806
857
  });
807
858
  healthInterval = null;
808
859
  subscriber = null;
860
+ stopLiveEvents?.();
861
+ stopLiveEvents = null;
809
862
  }
810
863
  //#endregion
811
864
  export { DeliveryWorker, MAX_THROTTLE_DEFERRALS, getDeliveryWorker, retryDelayMs, startDeliveryWorker, stopDeliveryWorker };
@@ -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-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-omGPIBny.mjs";
1
+ import { Jt as buildStreamEvent, Yt as CONSUMER_GROUPS, a as SuspendExecutionError, c as BaseWorker, d as startHealthReporter, en as STREAMS, ft as workflowDefinitions, hn as readBaseConfig, ht as workflowWaiters, i as workflowRegistry, mt as workflowSteps, o as buildStepNotifyPayload, pn as loadEnv, pt as workflowInstances, q as StreamProducer } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime } from "./bootstrap-BOmT69OH.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { and, eq } from "drizzle-orm";
5
5
  //#region src/services/workflow/main.ts
@@ -1,5 +1,5 @@
1
- import { $t as STREAMS, D as TemplateRepository, Jt as CONSUMER_GROUPS, K as StreamProducer, On as globalEmitter, Tn as getPriorityBucket, 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, qt as buildStreamEvent, st as scheduledPayloads, x as renderWithTemplate } from "./src-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-omGPIBny.mjs";
1
+ import { D as TemplateRepository, En as getPriorityBucket, Jt as buildStreamEvent, Yt as CONSUMER_GROUPS, Z as IdempotencyGuard, _ as TemplateCache, an as registry, c as BaseWorker, ct as scheduledPayloads, d as startHealthReporter, en as STREAMS, fn as getAiConfig, hn as readBaseConfig, kn as globalEmitter, pn as loadEnv, q as StreamProducer, un as AI_DEFAULTS, x as renderWithTemplate } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-BOmT69OH.mjs";
3
3
  import { generateText } from "ai";
4
4
  //#region src/services/ai/main.ts
5
5
  loadEnv();
@@ -1,5 +1,5 @@
1
- import { $t as STREAMS, C as ContactRepository, D as TemplateRepository, En as normaliseTarget, Jt as CONSUMER_GROUPS, O as UserRepository, On as globalEmitter, Tn as getPriorityBucket, c as BaseWorker, ct as suppressions, d as startHealthReporter, fn as loadEnv, in as registry, mn as readBaseConfig, qt as buildStreamEvent, st as scheduledPayloads } from "./src-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-omGPIBny.mjs";
1
+ import { C as ContactRepository, D as TemplateRepository, Dn as normaliseTarget, En as getPriorityBucket, Jt as buildStreamEvent, O as UserRepository, Yt as CONSUMER_GROUPS, an as registry, c as BaseWorker, ct as scheduledPayloads, d as startHealthReporter, en as STREAMS, hn as readBaseConfig, kn as globalEmitter, lt as suppressions, pn as loadEnv } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-BOmT69OH.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 { C as ContactRepository, D as TemplateRepository, Jt as CONSUMER_GROUPS, O as UserRepository, 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, mn as readBaseConfig, qt as buildStreamEvent, w as PreferenceRepository } from "./src-CIPTzq9i.mjs";
2
- import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-omGPIBny.mjs";
1
+ import { C as ContactRepository, D as TemplateRepository, En as getPriorityBucket, Jt as buildStreamEvent, O as UserRepository, Yt as CONSUMER_GROUPS, Z as IdempotencyGuard, Zt as INBOUND_STREAMS, _ as TemplateCache, an as registry, c as BaseWorker, d as startHealthReporter, hn as readBaseConfig, kn as globalEmitter, pn as loadEnv, w as PreferenceRepository } from "./src-9LXITcNi.mjs";
2
+ import { a as uniqueConsumerId, i as shutdownWorker, n as createStreamConsumer, r as createWorkerRuntime, t as createPriorityProducers } from "./bootstrap-BOmT69OH.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  //#region src/services/enricher/main.ts
5
5
  loadEnv();