@venturekit/notify 0.0.0-dev.20260507015349

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 (75) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +304 -0
  3. package/dist/admin/index.d.ts +88 -0
  4. package/dist/admin/index.d.ts.map +1 -0
  5. package/dist/admin/index.js +105 -0
  6. package/dist/admin/index.js.map +1 -0
  7. package/dist/bounce-handler.d.ts +65 -0
  8. package/dist/bounce-handler.d.ts.map +1 -0
  9. package/dist/bounce-handler.js +171 -0
  10. package/dist/bounce-handler.js.map +1 -0
  11. package/dist/client.d.ts +113 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +213 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/dispatcher.d.ts +95 -0
  16. package/dist/dispatcher.d.ts.map +1 -0
  17. package/dist/dispatcher.js +251 -0
  18. package/dist/dispatcher.js.map +1 -0
  19. package/dist/index.d.ts +60 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +66 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/providers/email-noop.d.ts +30 -0
  24. package/dist/providers/email-noop.d.ts.map +1 -0
  25. package/dist/providers/email-noop.js +39 -0
  26. package/dist/providers/email-noop.js.map +1 -0
  27. package/dist/providers/email-ses.d.ts +39 -0
  28. package/dist/providers/email-ses.d.ts.map +1 -0
  29. package/dist/providers/email-ses.js +114 -0
  30. package/dist/providers/email-ses.js.map +1 -0
  31. package/dist/providers/index.d.ts +20 -0
  32. package/dist/providers/index.d.ts.map +1 -0
  33. package/dist/providers/index.js +20 -0
  34. package/dist/providers/index.js.map +1 -0
  35. package/dist/providers/push-noop.d.ts +12 -0
  36. package/dist/providers/push-noop.d.ts.map +1 -0
  37. package/dist/providers/push-noop.js +30 -0
  38. package/dist/providers/push-noop.js.map +1 -0
  39. package/dist/providers/sms-noop.d.ts +21 -0
  40. package/dist/providers/sms-noop.d.ts.map +1 -0
  41. package/dist/providers/sms-noop.js +42 -0
  42. package/dist/providers/sms-noop.js.map +1 -0
  43. package/dist/providers/types.d.ts +95 -0
  44. package/dist/providers/types.d.ts.map +1 -0
  45. package/dist/providers/types.js +40 -0
  46. package/dist/providers/types.js.map +1 -0
  47. package/dist/providers/whatsapp-meta.d.ts +63 -0
  48. package/dist/providers/whatsapp-meta.d.ts.map +1 -0
  49. package/dist/providers/whatsapp-meta.js +160 -0
  50. package/dist/providers/whatsapp-meta.js.map +1 -0
  51. package/dist/store/index.d.ts +6 -0
  52. package/dist/store/index.d.ts.map +1 -0
  53. package/dist/store/index.js +5 -0
  54. package/dist/store/index.js.map +1 -0
  55. package/dist/store/postgres.d.ts +36 -0
  56. package/dist/store/postgres.d.ts.map +1 -0
  57. package/dist/store/postgres.js +354 -0
  58. package/dist/store/postgres.js.map +1 -0
  59. package/dist/store/types.d.ts +139 -0
  60. package/dist/store/types.d.ts.map +1 -0
  61. package/dist/store/types.js +14 -0
  62. package/dist/store/types.js.map +1 -0
  63. package/dist/templates/registry.d.ts +55 -0
  64. package/dist/templates/registry.d.ts.map +1 -0
  65. package/dist/templates/registry.js +94 -0
  66. package/dist/templates/registry.js.map +1 -0
  67. package/dist/types.d.ts +214 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/types.js +12 -0
  70. package/dist/types.js.map +1 -0
  71. package/migrations/vk_notify_001_init.sql +109 -0
  72. package/package.json +109 -0
  73. package/runtime/bounce-handler-stub.ts +35 -0
  74. package/runtime/dispatcher-stub.ts +63 -0
  75. package/runtime/tsconfig.json +19 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/store/postgres.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiBH,yEAAyE;AAEzE;;;;;;GAMG;AACH,SAAS,kBAAkB;IACzB,MAAM,IAAI,GAAI,UAAyD;SACpE,MAAM,EAAE,UAAU,EAAE,EAAE;WACpB,YAAY,EAAE,CAA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;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @venturekit/notify — store interface
3
+ *
4
+ * The store abstracts the outbox so the dispatcher doesn't care whether
5
+ * rows live in Postgres, DynamoDB, or an in-memory buffer (test). Phase 1
6
+ * ships the Postgres adapter; consumers pick a different adapter by
7
+ * passing it to {@link createNotifyClient}.
8
+ *
9
+ * All timestamps are returned as ISO-8601 strings (per
10
+ * {@link NotificationRow}); persistence-layer types (`Date`,
11
+ * `Timestamp`) stay inside the adapter.
12
+ */
13
+ import type { EnqueueInput, NotificationEventLogRow, NotificationPreferenceRow, NotificationRow, NotificationStatus, NotifyChannel } from '../types.js';
14
+ /**
15
+ * Fields persisted on insert. Most of {@link EnqueueInput} maps 1:1;
16
+ * the dispatcher fills in `id`, `status`, `attempts`, `createdAtISO`.
17
+ */
18
+ export interface CreateNotificationInput extends Omit<EnqueueInput, 'recipientUserId' | 'address'> {
19
+ recipientUserId: string | null;
20
+ address: string | null;
21
+ }
22
+ /**
23
+ * Update applied by the dispatcher after a provider call. Either
24
+ * `status === 'sent'` (with `providerMessageId`) or
25
+ * `status === 'failed'` / `'pending'` (with `error`); both shapes are
26
+ * accepted to keep the dispatcher's atomic-update path single-table.
27
+ */
28
+ export interface UpdateNotificationStatusInput {
29
+ id: string;
30
+ status: NotificationStatus;
31
+ providerMessageId?: string | null;
32
+ error?: string | null;
33
+ /** Increments the row's `attempts` counter on `'failed'` / retry. */
34
+ incrementAttempts?: boolean;
35
+ }
36
+ /** Pagination + filter input for `listNotificationsForUser`. */
37
+ export interface ListForUserOptions {
38
+ /** Default 50, max 200. */
39
+ limit?: number;
40
+ /** Filter by channel. */
41
+ channel?: NotifyChannel;
42
+ /** Filter by status. */
43
+ status?: NotificationStatus;
44
+ }
45
+ /** Pagination + filter input for the admin list view. */
46
+ export interface AdminListOptions {
47
+ /** Default 50, max 200. */
48
+ limit?: number;
49
+ /** Skip the first N rows (offset pagination — fine at the volumes
50
+ * admin views see; cursor pagination would be overkill). */
51
+ offset?: number;
52
+ status?: NotificationStatus;
53
+ channel?: NotifyChannel;
54
+ templateKey?: string;
55
+ /** Substring match on `recipient_user_id` or `address`. */
56
+ search?: string;
57
+ }
58
+ /**
59
+ * Outbox + preferences + bounce-suppression store. Implementations are
60
+ * expected to be transactional: `enqueue` and the dispatcher's
61
+ * claim/update sequence must be safe under concurrent dispatcher
62
+ * replicas.
63
+ */
64
+ export interface NotifyStore {
65
+ /**
66
+ * Persist a new outbox row in `'pending'` state. The store generates
67
+ * the row id (`notif_…`); callers receive the full row back so they
68
+ * can return it from API handlers.
69
+ */
70
+ createNotification(input: CreateNotificationInput): Promise<NotificationRow>;
71
+ /**
72
+ * Atomically claim up to `limit` pending rows whose `scheduled_for`
73
+ * is null or in the past. Implementations must guarantee no two
74
+ * dispatcher replicas claim the same row (Postgres uses
75
+ * `UPDATE … FOR UPDATE SKIP LOCKED`).
76
+ *
77
+ * The returned rows are unchanged on disk apart from a lease flip
78
+ * (e.g. setting `scheduled_for` to NOW() so they don't reappear in
79
+ * the next scan within `visibilityMs`).
80
+ */
81
+ claimPending(limit: number): Promise<NotificationRow[]>;
82
+ /** Apply a status transition produced by the dispatcher. */
83
+ updateStatus(input: UpdateNotificationStatusInput): Promise<NotificationRow | null>;
84
+ /** Look up a single row by id. */
85
+ findById(id: string): Promise<NotificationRow | null>;
86
+ /** List a user's notifications, newest first. */
87
+ listForUser(userId: string, options?: ListForUserOptions): Promise<NotificationRow[]>;
88
+ /** Admin-side list with pagination + filters. */
89
+ adminList(options?: AdminListOptions): Promise<{
90
+ rows: NotificationRow[];
91
+ total: number;
92
+ }>;
93
+ /**
94
+ * Reset a `'failed'` row to `'pending'` so the dispatcher picks it up
95
+ * on the next tick. The admin retry route uses this. Returns
96
+ * `null` if the row doesn't exist or is already `'pending'`.
97
+ */
98
+ retry(id: string): Promise<NotificationRow | null>;
99
+ /**
100
+ * Cancel a `'pending'` row before the dispatcher claims it. Sets
101
+ * status to `'cancelled'`. Returns `null` if the row is already
102
+ * `'sent'` / `'cancelled'` / `'bounced'` / `'failed'`.
103
+ */
104
+ cancel(id: string): Promise<NotificationRow | null>;
105
+ /** Read all preference rows for a user (one per `(channel, category)`). */
106
+ listPreferences(userId: string): Promise<NotificationPreferenceRow[]>;
107
+ /**
108
+ * Upsert a single `(user, channel, category)` preference. Used by
109
+ * admin + self-service preference flows.
110
+ */
111
+ upsertPreference(input: Omit<NotificationPreferenceRow, 'updatedAtISO'>): Promise<NotificationPreferenceRow>;
112
+ /**
113
+ * Bulk-check whether a user has opted in to a specific
114
+ * `(channel, category)`. Returns `true` when:
115
+ * - a row exists with `optedIn = true`, OR
116
+ * - no row exists (default opt-in).
117
+ * Returns `false` only when an explicit opt-out exists.
118
+ *
119
+ * The dispatcher uses this on every send.
120
+ */
121
+ isOptedIn(userId: string, channel: NotifyChannel, category: string): Promise<boolean>;
122
+ /**
123
+ * Record a delivery / bounce / complaint event for a given address.
124
+ * Sets `suppress = true` on hard bounces and complaints so the
125
+ * dispatcher refuses to re-send to the same address.
126
+ */
127
+ recordEvent(input: Omit<NotificationEventLogRow, 'id' | 'receivedAtISO'>): Promise<NotificationEventLogRow>;
128
+ /**
129
+ * Whether a given `(channel, address)` is currently suppressed. The
130
+ * dispatcher consults this before every send.
131
+ */
132
+ isAddressSuppressed(channel: NotifyChannel, address: string): Promise<boolean>;
133
+ /**
134
+ * Manually clear a suppression entry. Operator-only. Used to lift
135
+ * suppression after a recipient confirms a typo or domain fix.
136
+ */
137
+ clearSuppression(channel: NotifyChannel, address: string): Promise<void>;
138
+ }
139
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACd,MAAM,aAAa,C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AAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @venturekit/notify — store interface
3
+ *
4
+ * The store abstracts the outbox so the dispatcher doesn't care whether
5
+ * rows live in Postgres, DynamoDB, or an in-memory buffer (test). Phase 1
6
+ * ships the Postgres adapter; consumers pick a different adapter by
7
+ * passing it to {@link createNotifyClient}.
8
+ *
9
+ * All timestamps are returned as ISO-8601 strings (per
10
+ * {@link NotificationRow}); persistence-layer types (`Date`,
11
+ * `Timestamp`) stay inside the adapter.
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @venturekit/notify — template registry
3
+ *
4
+ * Phase 1 keeps templates in code: each consumer registers a typed
5
+ * `(key) -> RenderedMessage` function at boot time. The registry is a
6
+ * plain Map; no DB hops, no caching layer needed.
7
+ *
8
+ * Phase 2 will introduce external storage (DB / Meta-managed / SES
9
+ * Templates). The shape of {@link NotifyTemplate.render} is forward-
10
+ * compatible: a future loader can produce the same `(payload) -> body`
11
+ * function from external sources without changing this registry's
12
+ * public API.
13
+ *
14
+ * Why we don't ship a string-substitution helper in Phase 1:
15
+ *
16
+ * - Real-world templates need conditionals (`{{#if amount}}…{{/if}}`),
17
+ * localization (`{{t 'application_received', { name }}}`), and
18
+ * per-tenant branding (header / footer fragments). Once we add those,
19
+ * we own a templating language.
20
+ * - Consumers already use a templating language for their pages
21
+ * (Groupi: `groupi-website` is Next.js; the API has its own helpers).
22
+ * Letting them pick — Handlebars, EJS, raw template literals — keeps
23
+ * the registry honest and avoids a fork-in-the-road on naming/scope.
24
+ * - The render function returns a fully-formed {@link RenderedMessage},
25
+ * so the registry doesn't care HOW you produced subject/text/html —
26
+ * only that the result conforms.
27
+ */
28
+ import type { NotifyChannel, NotifyTemplate, RenderedMessage } from '../types.js';
29
+ /**
30
+ * Error thrown when a registry lookup fails. Carries enough context
31
+ * for the dispatcher to mark the row `'failed'` with a useful message.
32
+ */
33
+ export declare class TemplateNotFoundError extends Error {
34
+ constructor(key: string, channel: NotifyChannel);
35
+ }
36
+ export interface TemplateRegistry {
37
+ /** Register (or re-register) a template. Last write wins. */
38
+ register<P>(template: NotifyTemplate<P>): void;
39
+ /**
40
+ * Register many templates at once. Convenience for boot-time wiring
41
+ * where templates live in a `templates/` directory of the consumer.
42
+ */
43
+ registerAll(templates: NotifyTemplate<any>[]): void;
44
+ /** Look up a template, or throw `TemplateNotFoundError`. */
45
+ get(key: string, channel: NotifyChannel): NotifyTemplate<any>;
46
+ /** Render a template + payload to a {@link RenderedMessage}. */
47
+ render(key: string, channel: NotifyChannel, payload: Record<string, unknown>): RenderedMessage;
48
+ /** Whether a `(key, channel)` pair is registered. */
49
+ has(key: string, channel: NotifyChannel): boolean;
50
+ /** List all registered templates (for admin UI / docs). */
51
+ list(): NotifyTemplate<any>[];
52
+ }
53
+ /** Construct an empty in-memory template registry. */
54
+ export declare function createTemplateRegistry(): TemplateRegistry;
55
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAElF;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;CAIhD;AAED,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;IACpD,4DAA4D;IAC5D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9D,gEAAgE;IAChE,MAAM,CACJ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,eAAe,CAAC;IACnB,qDAAqD;IACrD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAClD,2DAA2D;IAC3D,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;CAC/B;AAWD,sDAAsD;AACtD,wBAAgB,sBAAsB,IAAI,gBAAgB,CAwDzD"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @venturekit/notify — template registry
3
+ *
4
+ * Phase 1 keeps templates in code: each consumer registers a typed
5
+ * `(key) -> RenderedMessage` function at boot time. The registry is a
6
+ * plain Map; no DB hops, no caching layer needed.
7
+ *
8
+ * Phase 2 will introduce external storage (DB / Meta-managed / SES
9
+ * Templates). The shape of {@link NotifyTemplate.render} is forward-
10
+ * compatible: a future loader can produce the same `(payload) -> body`
11
+ * function from external sources without changing this registry's
12
+ * public API.
13
+ *
14
+ * Why we don't ship a string-substitution helper in Phase 1:
15
+ *
16
+ * - Real-world templates need conditionals (`{{#if amount}}…{{/if}}`),
17
+ * localization (`{{t 'application_received', { name }}}`), and
18
+ * per-tenant branding (header / footer fragments). Once we add those,
19
+ * we own a templating language.
20
+ * - Consumers already use a templating language for their pages
21
+ * (Groupi: `groupi-website` is Next.js; the API has its own helpers).
22
+ * Letting them pick — Handlebars, EJS, raw template literals — keeps
23
+ * the registry honest and avoids a fork-in-the-road on naming/scope.
24
+ * - The render function returns a fully-formed {@link RenderedMessage},
25
+ * so the registry doesn't care HOW you produced subject/text/html —
26
+ * only that the result conforms.
27
+ */
28
+ /**
29
+ * Error thrown when a registry lookup fails. Carries enough context
30
+ * for the dispatcher to mark the row `'failed'` with a useful message.
31
+ */
32
+ export class TemplateNotFoundError extends Error {
33
+ constructor(key, channel) {
34
+ super(`No template registered for key '${key}' on channel '${channel}'`);
35
+ this.name = 'TemplateNotFoundError';
36
+ }
37
+ }
38
+ /**
39
+ * Registry key: `key + '\u0000' + channel`. The `\u0000` separator is
40
+ * never a legal character in a template key, so collisions are
41
+ * impossible without a deliberate caller bug.
42
+ */
43
+ function makeKey(key, channel) {
44
+ return `${key}\u0000${channel}`;
45
+ }
46
+ /** Construct an empty in-memory template registry. */
47
+ export function createTemplateRegistry() {
48
+ const map = new Map();
49
+ return {
50
+ register(template) {
51
+ // Validate at registration time — better to crash at boot than
52
+ // silently ship a broken template that fails on first send.
53
+ if (!template.key || typeof template.key !== 'string') {
54
+ throw new Error('Template registration: `key` must be a non-empty string');
55
+ }
56
+ if (!template.channel) {
57
+ throw new Error(`Template '${template.key}': \`channel\` is required`);
58
+ }
59
+ if (typeof template.render !== 'function') {
60
+ throw new Error(`Template '${template.key}': \`render\` must be a function`);
61
+ }
62
+ map.set(makeKey(template.key, template.channel), template);
63
+ },
64
+ registerAll(templates) {
65
+ for (const t of templates)
66
+ this.register(t);
67
+ },
68
+ get(key, channel) {
69
+ const found = map.get(makeKey(key, channel));
70
+ if (!found)
71
+ throw new TemplateNotFoundError(key, channel);
72
+ return found;
73
+ },
74
+ render(key, channel, payload) {
75
+ const template = this.get(key, channel);
76
+ const rendered = template.render(payload);
77
+ // Sanity: every channel needs at least a `text` body. The
78
+ // dispatcher would catch this downstream but the message is
79
+ // clearer when it points at the template.
80
+ if (!rendered.text || rendered.text.length === 0) {
81
+ throw new Error(`Template '${key}' (${channel}) rendered an empty text body. ` +
82
+ `Every NotifyTemplate must produce a non-empty 'text' field.`);
83
+ }
84
+ return rendered;
85
+ },
86
+ has(key, channel) {
87
+ return map.has(makeKey(key, channel));
88
+ },
89
+ list() {
90
+ return Array.from(map.values());
91
+ },
92
+ };
93
+ }
94
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,GAAW,EAAE,OAAsB;QAC7C,KAAK,CAAC,mCAAmC,GAAG,iBAAiB,OAAO,GAAG,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAwBD;;;;GAIG;AACH,SAAS,OAAO,CAAC,GAAW,EAAE,OAAsB;IAClD,OAAO,GAAG,GAAG,SAAS,OAAO,EAAE,CAAC;AAClC,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEnD,OAAO;QACL,QAAQ,CAAI,QAA2B;YACrC,+DAA+D;YAC/D,4DAA4D;YAC5D,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC7E,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,CAAC,GAAG,4BAA4B,CACtD,CAAC;YACJ,CAAC;YACD,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,CAAC,GAAG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CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,214 @@
1
+ /**
2
+ * @venturekit/notify — runtime type surface
3
+ *
4
+ * Mirrors the channel set declared by `NotifyIntent` in `@venturekit/core`,
5
+ * with a few runtime-only extras (template definitions, store row shape,
6
+ * provider results) that don't belong on the deploy-time intent.
7
+ *
8
+ * Re-exported from `./index.ts`. Importing from `./types` directly is
9
+ * supported but the public entry point is the package barrel.
10
+ */
11
+ import type { NotifyChannel } from '@venturekit/core';
12
+ export type { NotifyChannel };
13
+ /**
14
+ * Lifecycle state of a single outbox row.
15
+ *
16
+ * - `'pending'` — created by `enqueue()`, awaiting the dispatcher.
17
+ * - `'sent'` — provider accepted delivery (best-effort: a `'sent'`
18
+ * email may still bounce; bounces flip the row to
19
+ * `'bounced'` once the SES bounce handler processes
20
+ * the SNS notification).
21
+ * - `'failed'` — provider rejected the send and retries are exhausted
22
+ * (or the dispatcher decided not to retry — e.g. an
23
+ * unsupported channel).
24
+ * - `'bounced'` — recipient rejected delivery (hard bounce). The
25
+ * bounce handler suppresses the address from future
26
+ * sends in `notification_event_log`.
27
+ * - `'cancelled'` — operator cancelled before send (admin route).
28
+ */
29
+ export type NotificationStatus = 'pending' | 'sent' | 'failed' | 'bounced' | 'cancelled';
30
+ /**
31
+ * A single recipient identifier.
32
+ *
33
+ * The format depends on the channel:
34
+ * - `email` — RFC 5321 address (`'user@example.com'`)
35
+ * - `whatsapp` — E.164 phone number (`'+15551234567'`)
36
+ * - `sms` — E.164 phone number (`'+15551234567'`)
37
+ * - `push` — endpoint ARN / device token (provider-specific)
38
+ *
39
+ * Validation is the caller's responsibility — the dispatcher will mark
40
+ * malformed addresses `'failed'` once the provider rejects them, but it
41
+ * doesn't pre-validate (would duplicate provider logic).
42
+ */
43
+ export type NotifyAddress = string;
44
+ /**
45
+ * Outbox row as stored in Postgres. `*ISO` fields are ISO-8601 strings
46
+ * because that's what the JSON serializer produces and what consumers
47
+ * use unchanged in API responses; the underlying column type is
48
+ * `timestamptz`.
49
+ */
50
+ export interface NotificationRow {
51
+ /** Stable id (`notif_…`). */
52
+ id: string;
53
+ /**
54
+ * Logical recipient — the application's user id (Cognito `sub`,
55
+ * UUID, etc.). The dispatcher resolves this to a channel-specific
56
+ * address via the {@link AddressResolver} the consumer registers, or
57
+ * via the optional `address` field on enqueue (used when the recipient
58
+ * isn't yet a registered user — e.g. anonymous form submitter).
59
+ */
60
+ recipientUserId: string | null;
61
+ /**
62
+ * Pre-resolved address used when `recipientUserId` is `null` or when
63
+ * the caller wants to override the user's profile address (e.g. send
64
+ * to `billing@org.com` instead of the user's personal email).
65
+ */
66
+ address: NotifyAddress | null;
67
+ /** Delivery channel. */
68
+ channel: NotifyChannel;
69
+ /** Template registered via `client.registerTemplate()`. */
70
+ templateKey: string;
71
+ /** Variables interpolated into the template at send time. */
72
+ payload: Record<string, unknown>;
73
+ /** Lifecycle state. */
74
+ status: NotificationStatus;
75
+ /** Earliest moment the dispatcher may attempt delivery. */
76
+ scheduledForISO: string | null;
77
+ /** When the provider accepted the send. */
78
+ sentAtISO: string | null;
79
+ /** Loose FK to the originating entity (application id, event id, …). */
80
+ relatedKind: string | null;
81
+ /** Companion to `relatedKind`. */
82
+ relatedId: string | null;
83
+ /** Provider-side message id (SES message id, Meta `wamid`, …). */
84
+ providerMessageId: string | null;
85
+ /** Last failure message, if any. */
86
+ error: string | null;
87
+ /** Number of dispatch attempts so far. */
88
+ attempts: number;
89
+ /** When the row was created. */
90
+ createdAtISO: string;
91
+ }
92
+ /**
93
+ * Input to {@link NotifyClient.enqueue}. Either `recipientUserId` or
94
+ * `address` must be set; both is allowed (address overrides the user's
95
+ * profile lookup).
96
+ */
97
+ export interface EnqueueInput {
98
+ /** Logical recipient (user id). */
99
+ recipientUserId?: string;
100
+ /** Pre-resolved channel-specific address (overrides resolver). */
101
+ address?: NotifyAddress;
102
+ /** Channel to deliver on. */
103
+ channel: NotifyChannel;
104
+ /** Registered template key. */
105
+ templateKey: string;
106
+ /** Variables passed to the template render function. */
107
+ payload?: Record<string, unknown>;
108
+ /**
109
+ * Earliest moment the dispatcher may attempt delivery. Pass `null` /
110
+ * undefined for "as soon as possible". Useful for J-1 reminders,
111
+ * post-meeting follow-ups, etc.
112
+ */
113
+ scheduledForISO?: string | null;
114
+ /** Loose FK to the originating entity. */
115
+ relatedKind?: string | null;
116
+ relatedId?: string | null;
117
+ }
118
+ /**
119
+ * Result of an enqueue call. Returned synchronously from the calling
120
+ * Lambda — the actual provider call happens later inside the dispatcher.
121
+ */
122
+ export interface EnqueueResult {
123
+ /** Outbox row id (`notif_…`). */
124
+ id: string;
125
+ /** Channel the row was enqueued on (echoes input). */
126
+ channel: NotifyChannel;
127
+ /** Whether the row was suppressed by user preference / bounce log. */
128
+ suppressed: boolean;
129
+ /**
130
+ * When `suppressed === true`, the reason — one of:
131
+ * - `'opted-out'` — user opted out of this channel/category.
132
+ * - `'address-suppressed'` — address is on the bounce/complaint list.
133
+ * - `'no-address'` — neither input nor resolver produced an address.
134
+ * - `'no-channel-provider'` — channel has no provider configured.
135
+ */
136
+ suppressionReason?: 'opted-out' | 'address-suppressed' | 'no-address' | 'no-channel-provider';
137
+ }
138
+ /**
139
+ * Rendered template payload that the provider sends. All fields are
140
+ * optional except `text` (the universal lowest common denominator —
141
+ * email clients without HTML, WhatsApp text messages, SMS bodies all
142
+ * use it).
143
+ */
144
+ export interface RenderedMessage {
145
+ /** Email subject / push title. Channels that don't carry a subject
146
+ * (sms, whatsapp text) ignore this. */
147
+ subject?: string;
148
+ /** Plain-text body (always required). */
149
+ text: string;
150
+ /** Rich HTML body (email only). */
151
+ html?: string;
152
+ /** Optional WhatsApp-specific overrides — see provider docs for the
153
+ * Meta Cloud API template message format. */
154
+ whatsapp?: {
155
+ /** Template id pre-approved by Meta (see Meta Business Manager). */
156
+ metaTemplateName?: string;
157
+ /** Language code ('en_US', 'fr', …). */
158
+ languageCode?: string;
159
+ /** Components in Meta's template-message shape. */
160
+ components?: unknown[];
161
+ };
162
+ }
163
+ /**
164
+ * In-process template definition. Templates render synchronously from
165
+ * a typed payload to a {@link RenderedMessage}. Consumers register
166
+ * templates at boot via `client.registerTemplate(...)`.
167
+ *
168
+ * Phase 1 keeps templates in code only; Phase 2 will introduce
169
+ * external storage (DB / SES Templates / Meta-managed).
170
+ */
171
+ export interface NotifyTemplate<P = Record<string, unknown>> {
172
+ /** Stable identifier (e.g. `'application_registered'`). Must be
173
+ * unique across channels — the consumer is responsible for naming. */
174
+ key: string;
175
+ /** Channel this template is meant for. */
176
+ channel: NotifyChannel;
177
+ /** Optional grouping for `notification_preferences.category` opt-in
178
+ * filtering (e.g. `'transactional_application'`, `'marketing'`). */
179
+ category?: string;
180
+ /** Render function from typed payload to message bodies. */
181
+ render: (payload: P) => RenderedMessage;
182
+ }
183
+ /**
184
+ * Per-(user, channel, category) opt-in preference. The dispatcher
185
+ * checks this before each send and short-circuits if `optedIn === false`.
186
+ */
187
+ export interface NotificationPreferenceRow {
188
+ userId: string;
189
+ channel: NotifyChannel;
190
+ category: string;
191
+ optedIn: boolean;
192
+ updatedAtISO: string;
193
+ }
194
+ /**
195
+ * Address-level suppression event. Populated by the bounce / complaint
196
+ * handler when SES reports a hard bounce or a complaint. The dispatcher
197
+ * consults this table before every send so a single hard-bounced
198
+ * address never receives a second message.
199
+ */
200
+ export interface NotificationEventLogRow {
201
+ id: string;
202
+ channel: NotifyChannel;
203
+ address: string;
204
+ /** `'bounce' | 'complaint' | 'delivery' | 'open' | 'click'`. */
205
+ eventType: string;
206
+ /** Provider message id linking back to the {@link NotificationRow}. */
207
+ providerMessageId: string | null;
208
+ /** Whether this event suppresses future sends to `address`. */
209
+ suppress: boolean;
210
+ /** Raw event payload from the provider, JSON-encoded. */
211
+ raw: Record<string, unknown>;
212
+ receivedAtISO: string;
213
+ }
214
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names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,MAAM,CAAC;IACZ,0CAA0C;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB;yEACqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,eAAe,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,+DAA+D;IAC/D,QAAQ,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;CACvB"}
package/dist/types.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @venturekit/notify — runtime type surface
3
+ *
4
+ * Mirrors the channel set declared by `NotifyIntent` in `@venturekit/core`,
5
+ * with a few runtime-only extras (template definitions, store row shape,
6
+ * provider results) that don't belong on the deploy-time intent.
7
+ *
8
+ * Re-exported from `./index.ts`. Importing from `./types` directly is
9
+ * supported but the public entry point is the package barrel.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}