@voyantjs/notifications 0.6.8 → 0.7.0

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.
@@ -222,6 +222,27 @@ export const sendNotificationSchema = z
222
222
  .refine((value) => Boolean(value.templateId || value.templateSlug || value.subject || value.html || value.text), {
223
223
  message: "templateId, templateSlug, or direct content is required",
224
224
  });
225
+ export const previewNotificationTemplateSchema = z
226
+ .object({
227
+ channel: notificationChannelSchema,
228
+ provider: z.string().optional().nullable(),
229
+ subjectTemplate: z.string().max(2000).optional().nullable(),
230
+ htmlTemplate: z.string().optional().nullable(),
231
+ textTemplate: z.string().optional().nullable(),
232
+ fromAddress: z.string().max(500).optional().nullable(),
233
+ data: z.record(z.string(), z.unknown()).optional().nullable(),
234
+ })
235
+ .refine((value) => Boolean(value.subjectTemplate || value.htmlTemplate || value.textTemplate), {
236
+ message: "subjectTemplate, htmlTemplate, or textTemplate is required",
237
+ });
238
+ export const previewNotificationTemplateResultSchema = z.object({
239
+ channel: notificationChannelSchema,
240
+ provider: z.string().nullable(),
241
+ fromAddress: z.string().nullable(),
242
+ subject: z.string().nullable(),
243
+ html: z.string().nullable(),
244
+ text: z.string().nullable(),
245
+ });
225
246
  export const bookingDocumentBundleItemSchema = z.object({
226
247
  key: z.string().min(1),
227
248
  source: notificationDocumentSourceSchema,
@@ -268,3 +289,39 @@ export const sendBookingDocumentsNotificationResultSchema = z.object({
268
289
  provider: z.string().optional().nullable(),
269
290
  status: notificationDeliveryStatusSchema,
270
291
  });
292
+ /**
293
+ * Confirm-and-dispatch — single orchestrated request that lists the booking's
294
+ * document bundle and (optionally) sends it to the client in one round-trip.
295
+ *
296
+ * `sendNotification: false` turns the call into a preview: the bundle comes
297
+ * back but no delivery is attempted. Templates use the preview to render the
298
+ * "here's what's ready" checkbox list before the operator confirms.
299
+ */
300
+ export const confirmAndDispatchBookingSchema = sendBookingDocumentsNotificationSchema.extend({
301
+ sendNotification: z.boolean().default(true),
302
+ });
303
+ export const confirmAndDispatchBookingResultSchema = z.object({
304
+ bookingId: z.string().min(1),
305
+ documents: z.array(bookingDocumentBundleItemSchema),
306
+ /**
307
+ * Non-null when `sendNotification` was true and a delivery actually went
308
+ * out. Null when either the operator asked for a preview only, or the send
309
+ * couldn't proceed (no recipient / no attachments / no matching documents).
310
+ */
311
+ notification: z
312
+ .object({
313
+ recipient: z.string().min(1),
314
+ deliveryId: z.string().min(1),
315
+ provider: z.string().optional().nullable(),
316
+ status: notificationDeliveryStatusSchema,
317
+ })
318
+ .nullable(),
319
+ /**
320
+ * When `sendNotification` was true but the dispatcher declined to send,
321
+ * this captures which guard tripped so the UI can explain it — e.g.
322
+ * "No recipient on file, add an email to the lead traveler and retry".
323
+ */
324
+ skipReason: z
325
+ .enum(["preview_only", "no_documents", "no_recipient", "no_attachments", "send_failed"])
326
+ .nullable(),
327
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/notifications",
3
- "version": "0.6.8",
3
+ "version": "0.7.0",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -48,13 +48,14 @@
48
48
  "dependencies": {
49
49
  "drizzle-orm": "^0.45.2",
50
50
  "hono": "^4.12.10",
51
+ "liquidjs": "^10.24.0",
51
52
  "zod": "^4.3.6",
52
- "@voyantjs/bookings": "0.6.8",
53
- "@voyantjs/core": "0.6.8",
54
- "@voyantjs/db": "0.6.8",
55
- "@voyantjs/finance": "0.6.8",
56
- "@voyantjs/hono": "0.6.8",
57
- "@voyantjs/legal": "0.6.8"
53
+ "@voyantjs/bookings": "0.7.0",
54
+ "@voyantjs/core": "0.7.0",
55
+ "@voyantjs/db": "0.7.0",
56
+ "@voyantjs/finance": "0.7.0",
57
+ "@voyantjs/hono": "0.7.0",
58
+ "@voyantjs/legal": "0.7.0"
58
59
  },
59
60
  "devDependencies": {
60
61
  "typescript": "^6.0.2",