@voyant-travel/notifications 0.114.1 → 0.114.2

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.
@@ -0,0 +1,232 @@
1
+ DO $$ BEGIN
2
+ CREATE TYPE "public"."notification_channel" AS ENUM('email', 'sms');
3
+ EXCEPTION WHEN duplicate_object THEN null;
4
+ END $$;--> statement-breakpoint
5
+ DO $$ BEGIN
6
+ CREATE TYPE "public"."notification_delivery_status" AS ENUM('pending', 'sent', 'failed', 'cancelled');
7
+ EXCEPTION WHEN duplicate_object THEN null;
8
+ END $$;--> statement-breakpoint
9
+ DO $$ BEGIN
10
+ CREATE TYPE "public"."notification_reminder_run_status" AS ENUM('queued', 'processing', 'sent', 'skipped', 'failed');
11
+ EXCEPTION WHEN duplicate_object THEN null;
12
+ END $$;--> statement-breakpoint
13
+ DO $$ BEGIN
14
+ CREATE TYPE "public"."notification_reminder_stage_anchor" AS ENUM('due_date', 'booking_created_at', 'departure_date', 'invoice_issued_at', 'last_send_at');
15
+ EXCEPTION WHEN duplicate_object THEN null;
16
+ END $$;--> statement-breakpoint
17
+ DO $$ BEGIN
18
+ CREATE TYPE "public"."notification_reminder_stage_cadence_kind" AS ENUM('once', 'every_n_days', 'escalating');
19
+ EXCEPTION WHEN duplicate_object THEN null;
20
+ END $$;--> statement-breakpoint
21
+ DO $$ BEGIN
22
+ CREATE TYPE "public"."notification_reminder_status" AS ENUM('draft', 'active', 'archived');
23
+ EXCEPTION WHEN duplicate_object THEN null;
24
+ END $$;--> statement-breakpoint
25
+ DO $$ BEGIN
26
+ CREATE TYPE "public"."notification_reminder_target_type" AS ENUM('booking_confirmed', 'booking_payment_schedule', 'payment_complete', 'booking_cancelled_non_payment', 'invoice');
27
+ EXCEPTION WHEN duplicate_object THEN null;
28
+ END $$;--> statement-breakpoint
29
+ DO $$ BEGIN
30
+ CREATE TYPE "public"."notification_stage_recipient_kind" AS ENUM('primary', 'cc', 'bcc');
31
+ EXCEPTION WHEN duplicate_object THEN null;
32
+ END $$;--> statement-breakpoint
33
+ DO $$ BEGIN
34
+ CREATE TYPE "public"."notification_target_type" AS ENUM('booking', 'booking_payment_schedule', 'booking_guarantee', 'invoice', 'payment_session', 'person', 'organization', 'other');
35
+ EXCEPTION WHEN duplicate_object THEN null;
36
+ END $$;--> statement-breakpoint
37
+ DO $$ BEGIN
38
+ CREATE TYPE "public"."notification_template_status" AS ENUM('draft', 'active', 'archived');
39
+ EXCEPTION WHEN duplicate_object THEN null;
40
+ END $$;--> statement-breakpoint
41
+ CREATE TABLE "notification_deliveries" (
42
+ "id" text PRIMARY KEY NOT NULL,
43
+ "template_id" text,
44
+ "template_slug" text,
45
+ "target_type" "notification_target_type" DEFAULT 'other' NOT NULL,
46
+ "target_id" text,
47
+ "person_id" text,
48
+ "organization_id" text,
49
+ "booking_id" text,
50
+ "invoice_id" text,
51
+ "payment_session_id" text,
52
+ "channel" "notification_channel" NOT NULL,
53
+ "provider" text NOT NULL,
54
+ "provider_message_id" text,
55
+ "status" "notification_delivery_status" DEFAULT 'pending' NOT NULL,
56
+ "to_address" text NOT NULL,
57
+ "from_address" text,
58
+ "subject" text,
59
+ "html_body" text,
60
+ "text_body" text,
61
+ "payload_data" jsonb,
62
+ "metadata" jsonb,
63
+ "error_message" text,
64
+ "scheduled_for" timestamp with time zone,
65
+ "sent_at" timestamp with time zone,
66
+ "failed_at" timestamp with time zone,
67
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
68
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
69
+ );
70
+ --> statement-breakpoint
71
+ CREATE TABLE "notification_reminder_rule_authoring_requests" (
72
+ "idempotency_key" text PRIMARY KEY NOT NULL,
73
+ "reminder_rule_id" text NOT NULL,
74
+ "operation" text NOT NULL,
75
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
76
+ );
77
+ --> statement-breakpoint
78
+ CREATE TABLE "notification_reminder_rule_stages" (
79
+ "id" text PRIMARY KEY NOT NULL,
80
+ "reminder_rule_id" text NOT NULL,
81
+ "order_index" integer NOT NULL,
82
+ "name" text,
83
+ "anchor" "notification_reminder_stage_anchor" NOT NULL,
84
+ "window_start_days" integer NOT NULL,
85
+ "window_end_days" integer NOT NULL,
86
+ "cadence_kind" "notification_reminder_stage_cadence_kind" NOT NULL,
87
+ "cadence_every_days" integer,
88
+ "cadence_intervals" jsonb,
89
+ "max_sends_in_stage" integer,
90
+ "respect_quiet_hours" boolean DEFAULT true NOT NULL,
91
+ "metadata" jsonb,
92
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
93
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
94
+ );
95
+ --> statement-breakpoint
96
+ CREATE TABLE "notification_reminder_rules" (
97
+ "id" text PRIMARY KEY NOT NULL,
98
+ "slug" text NOT NULL,
99
+ "name" text NOT NULL,
100
+ "status" "notification_reminder_status" DEFAULT 'draft' NOT NULL,
101
+ "target_type" "notification_reminder_target_type" NOT NULL,
102
+ "channel" "notification_channel" NOT NULL,
103
+ "provider" text,
104
+ "template_id" text,
105
+ "template_slug" text,
106
+ "priority" integer DEFAULT 0 NOT NULL,
107
+ "suppression_group" text,
108
+ "is_system" boolean DEFAULT false NOT NULL,
109
+ "metadata" jsonb,
110
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
111
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
112
+ CONSTRAINT "notification_reminder_rules_slug_unique" UNIQUE("slug")
113
+ );
114
+ --> statement-breakpoint
115
+ CREATE TABLE "notification_reminder_runs" (
116
+ "id" text PRIMARY KEY NOT NULL,
117
+ "reminder_rule_id" text NOT NULL,
118
+ "target_type" "notification_reminder_target_type" NOT NULL,
119
+ "target_id" text NOT NULL,
120
+ "dedupe_key" text NOT NULL,
121
+ "booking_id" text,
122
+ "person_id" text,
123
+ "organization_id" text,
124
+ "payment_session_id" text,
125
+ "notification_delivery_id" text,
126
+ "status" "notification_reminder_run_status" NOT NULL,
127
+ "recipient" text,
128
+ "scheduled_for" timestamp with time zone NOT NULL,
129
+ "processed_at" timestamp with time zone DEFAULT now() NOT NULL,
130
+ "error_message" text,
131
+ "metadata" jsonb,
132
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
133
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
134
+ CONSTRAINT "notification_reminder_runs_dedupe_key_unique" UNIQUE("dedupe_key")
135
+ );
136
+ --> statement-breakpoint
137
+ CREATE TABLE "notification_reminder_stage_channels" (
138
+ "id" text PRIMARY KEY NOT NULL,
139
+ "stage_id" text NOT NULL,
140
+ "order_index" integer DEFAULT 0 NOT NULL,
141
+ "channel" "notification_channel" NOT NULL,
142
+ "provider" text,
143
+ "template_id" text,
144
+ "template_slug" text,
145
+ "recipient_kind" "notification_stage_recipient_kind" DEFAULT 'primary' NOT NULL,
146
+ "recipient_role" text,
147
+ "metadata" jsonb,
148
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
149
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
150
+ );
151
+ --> statement-breakpoint
152
+ CREATE TABLE "notification_settings" (
153
+ "id" text PRIMARY KEY NOT NULL,
154
+ "scope" text DEFAULT 'default' NOT NULL,
155
+ "quiet_hours_local" jsonb,
156
+ "blackout_dates" jsonb,
157
+ "skip_weekends" boolean DEFAULT false NOT NULL,
158
+ "recipient_rate_limit_per_day" integer,
159
+ "suppression_window_hours" integer DEFAULT 24 NOT NULL,
160
+ "metadata" jsonb,
161
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
162
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
163
+ );
164
+ --> statement-breakpoint
165
+ CREATE TABLE "notification_templates" (
166
+ "id" text PRIMARY KEY NOT NULL,
167
+ "slug" text NOT NULL,
168
+ "name" text NOT NULL,
169
+ "channel" "notification_channel" NOT NULL,
170
+ "provider" text,
171
+ "status" "notification_template_status" DEFAULT 'draft' NOT NULL,
172
+ "subject_template" text,
173
+ "html_template" text,
174
+ "text_template" text,
175
+ "from_address" text,
176
+ "is_system" boolean DEFAULT false NOT NULL,
177
+ "metadata" jsonb,
178
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
179
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
180
+ CONSTRAINT "notification_templates_slug_unique" UNIQUE("slug")
181
+ );
182
+ --> statement-breakpoint
183
+ ALTER TABLE "notification_deliveries" ADD CONSTRAINT "notification_deliveries_template_id_notification_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."notification_templates"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
184
+ ALTER TABLE "notification_reminder_rule_authoring_requests" ADD CONSTRAINT "notification_reminder_rule_authoring_requests_reminder_rule_id_notification_reminder_rules_id_fk" FOREIGN KEY ("reminder_rule_id") REFERENCES "public"."notification_reminder_rules"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
185
+ ALTER TABLE "notification_reminder_rule_stages" ADD CONSTRAINT "notification_reminder_rule_stages_reminder_rule_id_notification_reminder_rules_id_fk" FOREIGN KEY ("reminder_rule_id") REFERENCES "public"."notification_reminder_rules"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
186
+ ALTER TABLE "notification_reminder_rules" ADD CONSTRAINT "notification_reminder_rules_template_id_notification_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."notification_templates"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
187
+ ALTER TABLE "notification_reminder_runs" ADD CONSTRAINT "notification_reminder_runs_reminder_rule_id_notification_reminder_rules_id_fk" FOREIGN KEY ("reminder_rule_id") REFERENCES "public"."notification_reminder_rules"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
188
+ ALTER TABLE "notification_reminder_runs" ADD CONSTRAINT "notification_reminder_runs_notification_delivery_id_notification_deliveries_id_fk" FOREIGN KEY ("notification_delivery_id") REFERENCES "public"."notification_deliveries"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
189
+ ALTER TABLE "notification_reminder_stage_channels" ADD CONSTRAINT "notification_reminder_stage_channels_stage_id_notification_reminder_rule_stages_id_fk" FOREIGN KEY ("stage_id") REFERENCES "public"."notification_reminder_rule_stages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
190
+ ALTER TABLE "notification_reminder_stage_channels" ADD CONSTRAINT "notification_reminder_stage_channels_template_id_notification_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."notification_templates"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
191
+ CREATE INDEX "idx_notification_deliveries_created" ON "notification_deliveries" USING btree ("created_at");--> statement-breakpoint
192
+ CREATE INDEX "idx_notification_deliveries_template_created" ON "notification_deliveries" USING btree ("template_id","created_at");--> statement-breakpoint
193
+ CREATE INDEX "idx_notification_deliveries_target_created" ON "notification_deliveries" USING btree ("target_type","target_id","created_at");--> statement-breakpoint
194
+ CREATE INDEX "idx_notification_deliveries_person_created" ON "notification_deliveries" USING btree ("person_id","created_at");--> statement-breakpoint
195
+ CREATE INDEX "idx_notification_deliveries_org_created" ON "notification_deliveries" USING btree ("organization_id","created_at");--> statement-breakpoint
196
+ CREATE INDEX "idx_notification_deliveries_booking_created" ON "notification_deliveries" USING btree ("booking_id","created_at");--> statement-breakpoint
197
+ CREATE INDEX "idx_notification_deliveries_invoice_created" ON "notification_deliveries" USING btree ("invoice_id","created_at");--> statement-breakpoint
198
+ CREATE INDEX "idx_notification_deliveries_payment_session_created" ON "notification_deliveries" USING btree ("payment_session_id","created_at");--> statement-breakpoint
199
+ CREATE INDEX "idx_notification_deliveries_channel_created" ON "notification_deliveries" USING btree ("channel","created_at");--> statement-breakpoint
200
+ CREATE INDEX "idx_notification_deliveries_provider_created" ON "notification_deliveries" USING btree ("provider","created_at");--> statement-breakpoint
201
+ CREATE INDEX "idx_notification_deliveries_status_created" ON "notification_deliveries" USING btree ("status","created_at");--> statement-breakpoint
202
+ CREATE INDEX "idx_notification_deliveries_scheduled_for" ON "notification_deliveries" USING btree ("scheduled_for");--> statement-breakpoint
203
+ CREATE INDEX "idx_notification_reminder_rule_authoring_rule" ON "notification_reminder_rule_authoring_requests" USING btree ("reminder_rule_id");--> statement-breakpoint
204
+ CREATE UNIQUE INDEX "uidx_notification_reminder_rule_stages_rule_order" ON "notification_reminder_rule_stages" USING btree ("reminder_rule_id","order_index");--> statement-breakpoint
205
+ CREATE INDEX "idx_notification_reminder_rule_stages_rule" ON "notification_reminder_rule_stages" USING btree ("reminder_rule_id");--> statement-breakpoint
206
+ CREATE INDEX "idx_notification_reminder_rule_stages_anchor" ON "notification_reminder_rule_stages" USING btree ("anchor");--> statement-breakpoint
207
+ CREATE INDEX "idx_notification_reminder_rules_updated" ON "notification_reminder_rules" USING btree ("updated_at");--> statement-breakpoint
208
+ CREATE INDEX "idx_notification_reminder_rules_status_updated" ON "notification_reminder_rules" USING btree ("status","updated_at");--> statement-breakpoint
209
+ CREATE INDEX "idx_notification_reminder_rules_target_updated" ON "notification_reminder_rules" USING btree ("target_type","updated_at");--> statement-breakpoint
210
+ CREATE INDEX "idx_notification_reminder_rules_channel_updated" ON "notification_reminder_rules" USING btree ("channel","updated_at");--> statement-breakpoint
211
+ CREATE INDEX "idx_notification_reminder_rules_priority" ON "notification_reminder_rules" USING btree ("priority");--> statement-breakpoint
212
+ CREATE INDEX "idx_notification_reminder_rules_suppression_group" ON "notification_reminder_rules" USING btree ("suppression_group");--> statement-breakpoint
213
+ CREATE UNIQUE INDEX "uidx_notification_reminder_rules_slug" ON "notification_reminder_rules" USING btree ("slug");--> statement-breakpoint
214
+ CREATE INDEX "idx_notification_reminder_runs_created" ON "notification_reminder_runs" USING btree ("created_at");--> statement-breakpoint
215
+ CREATE INDEX "idx_notification_reminder_runs_rule_created" ON "notification_reminder_runs" USING btree ("reminder_rule_id","created_at");--> statement-breakpoint
216
+ CREATE INDEX "idx_notification_reminder_runs_target_created" ON "notification_reminder_runs" USING btree ("target_type","target_id","created_at");--> statement-breakpoint
217
+ CREATE INDEX "idx_notification_reminder_runs_booking_created" ON "notification_reminder_runs" USING btree ("booking_id","created_at");--> statement-breakpoint
218
+ CREATE INDEX "idx_notification_reminder_runs_payment_session_created" ON "notification_reminder_runs" USING btree ("payment_session_id","created_at");--> statement-breakpoint
219
+ CREATE INDEX "idx_notification_reminder_runs_delivery_created" ON "notification_reminder_runs" USING btree ("notification_delivery_id","created_at");--> statement-breakpoint
220
+ CREATE INDEX "idx_notification_reminder_runs_person_created" ON "notification_reminder_runs" USING btree ("person_id","created_at");--> statement-breakpoint
221
+ CREATE INDEX "idx_notification_reminder_runs_org_created" ON "notification_reminder_runs" USING btree ("organization_id","created_at");--> statement-breakpoint
222
+ CREATE INDEX "idx_notification_reminder_runs_recipient_created" ON "notification_reminder_runs" USING btree ("recipient","created_at");--> statement-breakpoint
223
+ CREATE INDEX "idx_notification_reminder_runs_status_created" ON "notification_reminder_runs" USING btree ("status","created_at");--> statement-breakpoint
224
+ CREATE UNIQUE INDEX "uidx_notification_reminder_runs_dedupe" ON "notification_reminder_runs" USING btree ("dedupe_key");--> statement-breakpoint
225
+ CREATE INDEX "idx_notification_reminder_stage_channels_stage" ON "notification_reminder_stage_channels" USING btree ("stage_id");--> statement-breakpoint
226
+ CREATE INDEX "idx_notification_reminder_stage_channels_template" ON "notification_reminder_stage_channels" USING btree ("template_id");--> statement-breakpoint
227
+ CREATE UNIQUE INDEX "uidx_notification_settings_scope" ON "notification_settings" USING btree ("scope");--> statement-breakpoint
228
+ CREATE INDEX "idx_notification_templates_updated" ON "notification_templates" USING btree ("updated_at");--> statement-breakpoint
229
+ CREATE INDEX "idx_notification_templates_channel_updated" ON "notification_templates" USING btree ("channel","updated_at");--> statement-breakpoint
230
+ CREATE INDEX "idx_notification_templates_provider_updated" ON "notification_templates" USING btree ("provider","updated_at");--> statement-breakpoint
231
+ CREATE INDEX "idx_notification_templates_status_updated" ON "notification_templates" USING btree ("status","updated_at");--> statement-breakpoint
232
+ CREATE UNIQUE INDEX "uidx_notification_templates_slug" ON "notification_templates" USING btree ("slug");
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1781947492719,
9
+ "tag": "0000_notifications_baseline",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/notifications",
3
- "version": "0.114.1",
3
+ "version": "0.114.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -63,18 +63,21 @@
63
63
  "zod": "^4.3.6",
64
64
  "@voyant-travel/bookings": "^0.126.0",
65
65
  "@voyant-travel/core": "^0.110.0",
66
- "@voyant-travel/db": "^0.108.3",
67
- "@voyant-travel/finance": "^0.126.0",
66
+ "@voyant-travel/db": "^0.108.4",
67
+ "@voyant-travel/finance": "^0.126.1",
68
68
  "@voyant-travel/hono": "^0.112.2",
69
- "@voyant-travel/legal": "^0.126.0"
69
+ "@voyant-travel/legal": "^0.126.1"
70
70
  },
71
71
  "devDependencies": {
72
+ "drizzle-kit": "^0.31.10",
72
73
  "typescript": "^6.0.2",
73
74
  "vitest": "^4.1.2",
74
75
  "@voyant-travel/voyant-typescript-config": "^0.1.0"
75
76
  },
76
77
  "files": [
77
- "dist"
78
+ "dist",
79
+ "migrations/*.sql",
80
+ "migrations/meta/_journal.json"
78
81
  ],
79
82
  "publishConfig": {
80
83
  "access": "public"
@@ -95,7 +98,8 @@
95
98
  "lint": "biome check src/",
96
99
  "test": "vitest run",
97
100
  "build": "tsc -p tsconfig.json",
98
- "clean": "rm -rf dist tsconfig.tsbuildinfo"
101
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
102
+ "db:generate": "drizzle-kit generate --config=drizzle.migrations.config.ts --name=notifications_baseline && node ../../scripts/d2/guard-create-type.mjs ./migrations && node ../../scripts/d2/ensure-extensions.mjs ./migrations"
99
103
  },
100
104
  "main": "./dist/index.js",
101
105
  "types": "./dist/index.d.ts"