@voyantjs/notifications 0.3.1 → 0.4.1

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.
@@ -36,6 +36,18 @@ export function createNotificationService(providers) {
36
36
  },
37
37
  };
38
38
  }
39
+ export function summarizeNotificationAttachments(attachments) {
40
+ if (!attachments || attachments.length === 0) {
41
+ return [];
42
+ }
43
+ return attachments.map((attachment) => ({
44
+ filename: attachment.filename,
45
+ path: attachment.path ?? null,
46
+ contentType: attachment.contentType ?? null,
47
+ disposition: attachment.disposition ?? null,
48
+ contentId: attachment.contentId ?? null,
49
+ }));
50
+ }
39
51
  function resolveMustachePath(path, scope) {
40
52
  const parts = path.match(/[^.[\]]+/g) ?? [];
41
53
  let current = scope;
@@ -91,7 +91,7 @@ export declare function listReminderRules(db: PostgresJsDatabase, query: Notific
91
91
  slug: string;
92
92
  name: string;
93
93
  status: "draft" | "active" | "archived";
94
- targetType: "booking_payment_schedule";
94
+ targetType: "invoice" | "booking_payment_schedule";
95
95
  channel: "email" | "sms";
96
96
  provider: string | null;
97
97
  templateId: string | null;
@@ -111,7 +111,7 @@ export declare function getReminderRuleById(db: PostgresJsDatabase, id: string):
111
111
  slug: string;
112
112
  name: string;
113
113
  status: "draft" | "active" | "archived";
114
- targetType: "booking_payment_schedule";
114
+ targetType: "invoice" | "booking_payment_schedule";
115
115
  channel: "email" | "sms";
116
116
  provider: string | null;
117
117
  templateId: string | null;
@@ -131,7 +131,7 @@ export declare function createReminderRule(db: PostgresJsDatabase, data: CreateN
131
131
  metadata: Record<string, unknown> | null;
132
132
  channel: "email" | "sms";
133
133
  provider: string | null;
134
- targetType: "booking_payment_schedule";
134
+ targetType: "invoice" | "booking_payment_schedule";
135
135
  templateId: string | null;
136
136
  slug: string;
137
137
  isSystem: boolean;
@@ -143,7 +143,7 @@ export declare function updateReminderRule(db: PostgresJsDatabase, id: string, d
143
143
  slug: string;
144
144
  name: string;
145
145
  status: "draft" | "active" | "archived";
146
- targetType: "booking_payment_schedule";
146
+ targetType: "invoice" | "booking_payment_schedule";
147
147
  channel: "email" | "sms";
148
148
  provider: string | null;
149
149
  templateId: string | null;
@@ -158,7 +158,7 @@ export declare function listReminderRuns(db: PostgresJsDatabase, query: Notifica
158
158
  data: {
159
159
  id: string;
160
160
  reminderRuleId: string;
161
- targetType: "booking_payment_schedule";
161
+ targetType: "invoice" | "booking_payment_schedule";
162
162
  targetId: string;
163
163
  dedupeKey: string;
164
164
  bookingId: string | null;
package/dist/service.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ export { createDefaultBookingDocumentAttachment } from "./service-booking-documents.js";
1
2
  export type { NotificationService } from "./service-shared.js";
2
- export { createNotificationService, NotificationError, renderNotificationTemplate, } from "./service-shared.js";
3
+ export { createNotificationService, NotificationError, renderNotificationTemplate, summarizeNotificationAttachments, } from "./service-shared.js";
4
+ import { createDefaultBookingDocumentAttachment } from "./service-booking-documents.js";
3
5
  import { getDeliveryById, listDeliveries, sendInvoiceNotification, sendNotification, sendPaymentSessionNotification } from "./service-deliveries.js";
4
6
  import { runDueReminders } from "./service-reminders.js";
5
7
  import { createReminderRule, createTemplate, getReminderRuleById, getTemplateById, getTemplateBySlug, listReminderRules, listReminderRuns, listTemplates, updateReminderRule, updateTemplate } from "./service-templates.js";
@@ -20,5 +22,113 @@ export declare const notificationsService: {
20
22
  runDueReminders: typeof runDueReminders;
21
23
  sendPaymentSessionNotification: typeof sendPaymentSessionNotification;
22
24
  sendInvoiceNotification: typeof sendInvoiceNotification;
25
+ listBookingDocumentBundle: (db: import("drizzle-orm/postgres-js").PostgresJsDatabase, bookingId: string) => Promise<{
26
+ bookingId: string;
27
+ documents: {
28
+ key: string;
29
+ source: "finance" | "legal";
30
+ documentType: "invoice" | "proforma" | "contract";
31
+ bookingId: string;
32
+ name: string;
33
+ createdAt: string;
34
+ contractId?: string | null | undefined;
35
+ invoiceId?: string | null | undefined;
36
+ attachmentId?: string | null | undefined;
37
+ renditionId?: string | null | undefined;
38
+ contractStatus?: string | null | undefined;
39
+ invoiceStatus?: string | null | undefined;
40
+ format?: string | null | undefined;
41
+ mimeType?: string | null | undefined;
42
+ storageKey?: string | null | undefined;
43
+ downloadUrl?: string | null | undefined;
44
+ language?: string | null | undefined;
45
+ metadata?: Record<string, unknown> | null | undefined;
46
+ }[];
47
+ } | null>;
48
+ sendBookingDocumentsNotification: (db: import("drizzle-orm/postgres-js").PostgresJsDatabase, dispatcher: import("./service-shared.js").NotificationService, bookingId: string, input: import("./service-shared.js").SendBookingDocumentsNotificationInput, runtime?: import("./service-booking-documents.js").SendBookingDocumentsRuntimeOptions) => Promise<{
49
+ status: "not_found";
50
+ bookingId?: undefined;
51
+ recipient?: undefined;
52
+ documents?: undefined;
53
+ delivery?: undefined;
54
+ } | {
55
+ status: "no_documents";
56
+ bookingId?: undefined;
57
+ recipient?: undefined;
58
+ documents?: undefined;
59
+ delivery?: undefined;
60
+ } | {
61
+ status: "no_recipient";
62
+ bookingId?: undefined;
63
+ recipient?: undefined;
64
+ documents?: undefined;
65
+ delivery?: undefined;
66
+ } | {
67
+ status: "no_attachments";
68
+ bookingId?: undefined;
69
+ recipient?: undefined;
70
+ documents?: undefined;
71
+ delivery?: undefined;
72
+ } | {
73
+ status: "send_failed";
74
+ bookingId?: undefined;
75
+ recipient?: undefined;
76
+ documents?: undefined;
77
+ delivery?: undefined;
78
+ } | {
79
+ status: "sent";
80
+ bookingId: string;
81
+ recipient: string;
82
+ documents: {
83
+ key: string;
84
+ source: "finance" | "legal";
85
+ documentType: "invoice" | "proforma" | "contract";
86
+ bookingId: string;
87
+ name: string;
88
+ createdAt: string;
89
+ contractId?: string | null | undefined;
90
+ invoiceId?: string | null | undefined;
91
+ attachmentId?: string | null | undefined;
92
+ renditionId?: string | null | undefined;
93
+ contractStatus?: string | null | undefined;
94
+ invoiceStatus?: string | null | undefined;
95
+ format?: string | null | undefined;
96
+ mimeType?: string | null | undefined;
97
+ storageKey?: string | null | undefined;
98
+ downloadUrl?: string | null | undefined;
99
+ language?: string | null | undefined;
100
+ metadata?: Record<string, unknown> | null | undefined;
101
+ }[];
102
+ delivery: {
103
+ id: string;
104
+ templateId: string | null;
105
+ templateSlug: string | null;
106
+ targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
107
+ targetId: string | null;
108
+ personId: string | null;
109
+ organizationId: string | null;
110
+ bookingId: string | null;
111
+ invoiceId: string | null;
112
+ paymentSessionId: string | null;
113
+ channel: "email" | "sms";
114
+ provider: string;
115
+ providerMessageId: string | null;
116
+ status: "cancelled" | "pending" | "failed" | "sent";
117
+ toAddress: string;
118
+ fromAddress: string | null;
119
+ subject: string | null;
120
+ htmlBody: string | null;
121
+ textBody: string | null;
122
+ payloadData: Record<string, unknown> | null;
123
+ metadata: Record<string, unknown> | null;
124
+ errorMessage: string | null;
125
+ scheduledFor: Date | null;
126
+ sentAt: Date | null;
127
+ failedAt: Date | null;
128
+ createdAt: Date;
129
+ updatedAt: Date;
130
+ };
131
+ }>;
132
+ createDefaultBookingDocumentAttachment: typeof createDefaultBookingDocumentAttachment;
23
133
  };
24
134
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,gBAAgB,EAChB,8BAA8B,EAC/B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;CAiBhC,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,MAAM,gCAAgC,CAAA;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAEL,sCAAsC,EACvC,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,gBAAgB,EAChB,8BAA8B,EAC/B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAA"}
package/dist/service.js CHANGED
@@ -1,4 +1,6 @@
1
- export { createNotificationService, NotificationError, renderNotificationTemplate, } from "./service-shared.js";
1
+ export { createDefaultBookingDocumentAttachment } from "./service-booking-documents.js";
2
+ export { createNotificationService, NotificationError, renderNotificationTemplate, summarizeNotificationAttachments, } from "./service-shared.js";
3
+ import { bookingDocumentNotificationsService, createDefaultBookingDocumentAttachment, } from "./service-booking-documents.js";
2
4
  import { getDeliveryById, listDeliveries, sendInvoiceNotification, sendNotification, sendPaymentSessionNotification, } from "./service-deliveries.js";
3
5
  import { runDueReminders } from "./service-reminders.js";
4
6
  import { createReminderRule, createTemplate, getReminderRuleById, getTemplateById, getTemplateBySlug, listReminderRules, listReminderRuns, listTemplates, updateReminderRule, updateTemplate, } from "./service-templates.js";
@@ -19,4 +21,7 @@ export const notificationsService = {
19
21
  runDueReminders,
20
22
  sendPaymentSessionNotification,
21
23
  sendInvoiceNotification,
24
+ listBookingDocumentBundle: bookingDocumentNotificationsService.listBookingDocumentBundle,
25
+ sendBookingDocumentsNotification: bookingDocumentNotificationsService.sendBookingDocumentsNotification,
26
+ createDefaultBookingDocumentAttachment,
22
27
  };
package/dist/types.d.ts CHANGED
@@ -4,6 +4,26 @@
4
4
  * identifiers (e.g. `"slack"`, `"push"`).
5
5
  */
6
6
  export type NotificationChannel = "email" | "sms" | (string & {});
7
+ /**
8
+ * Attachment payload for channels that support file delivery, such as email.
9
+ *
10
+ * Use `contentBase64` when the caller already has the rendered bytes, or `path`
11
+ * when the downstream provider can fetch the attachment from a URL/file path.
12
+ */
13
+ export interface NotificationAttachment {
14
+ /** User-visible file name. */
15
+ filename: string;
16
+ /** Base64-encoded content for inline upload. */
17
+ contentBase64?: string;
18
+ /** Provider-resolvable URL or path. */
19
+ path?: string;
20
+ /** MIME type hint. */
21
+ contentType?: string;
22
+ /** Optional disposition override. */
23
+ disposition?: "attachment" | "inline";
24
+ /** Optional inline content id. */
25
+ contentId?: string;
26
+ }
7
27
  /**
8
28
  * Payload describing a single notification to send. The `template` and
9
29
  * `data` fields are interpreted by the handling provider.
@@ -27,6 +47,8 @@ export interface NotificationPayload {
27
47
  html?: string;
28
48
  /** Optional pre-rendered text body. */
29
49
  text?: string;
50
+ /** Optional attachments for providers that support them. */
51
+ attachments?: ReadonlyArray<NotificationAttachment>;
30
52
  }
31
53
  /**
32
54
  * Result returned after a provider handles a send.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAA;IACV,yCAAyC;IACzC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAA;IAChB,iDAAiD;IACjD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;IACrD,mDAAmD;IACnD,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAChE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjE;;;;;GAKG;A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IACnD,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAChE"}
@@ -20,9 +20,9 @@ export declare const notificationTargetTypeSchema: z.ZodEnum<{
20
20
  invoice: "invoice";
21
21
  booking_payment_schedule: "booking_payment_schedule";
22
22
  booking_guarantee: "booking_guarantee";
23
- payment_session: "payment_session";
24
- person: "person";
25
23
  organization: "organization";
24
+ person: "person";
25
+ payment_session: "payment_session";
26
26
  }>;
27
27
  export declare const notificationReminderStatusSchema: z.ZodEnum<{
28
28
  draft: "draft";
@@ -30,6 +30,7 @@ export declare const notificationReminderStatusSchema: z.ZodEnum<{
30
30
  archived: "archived";
31
31
  }>;
32
32
  export declare const notificationReminderTargetTypeSchema: z.ZodEnum<{
33
+ invoice: "invoice";
33
34
  booking_payment_schedule: "booking_payment_schedule";
34
35
  }>;
35
36
  export declare const notificationReminderRunStatusSchema: z.ZodEnum<{
@@ -38,6 +39,26 @@ export declare const notificationReminderRunStatusSchema: z.ZodEnum<{
38
39
  processing: "processing";
39
40
  skipped: "skipped";
40
41
  }>;
42
+ export declare const notificationDocumentTypeSchema: z.ZodEnum<{
43
+ invoice: "invoice";
44
+ proforma: "proforma";
45
+ contract: "contract";
46
+ }>;
47
+ export declare const notificationDocumentSourceSchema: z.ZodEnum<{
48
+ finance: "finance";
49
+ legal: "legal";
50
+ }>;
51
+ export declare const notificationAttachmentSchema: z.ZodObject<{
52
+ filename: z.ZodString;
53
+ contentBase64: z.ZodNullable<z.ZodOptional<z.ZodString>>;
54
+ path: z.ZodNullable<z.ZodOptional<z.ZodString>>;
55
+ contentType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
56
+ disposition: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
57
+ attachment: "attachment";
58
+ inline: "inline";
59
+ }>>>;
60
+ contentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
61
+ }, z.core.$strip>;
41
62
  export declare const insertNotificationTemplateSchema: z.ZodObject<{
42
63
  slug: z.ZodString;
43
64
  name: z.ZodString;
@@ -114,9 +135,9 @@ export declare const notificationDeliveryListQuerySchema: z.ZodObject<{
114
135
  invoice: "invoice";
115
136
  booking_payment_schedule: "booking_payment_schedule";
116
137
  booking_guarantee: "booking_guarantee";
117
- payment_session: "payment_session";
118
- person: "person";
119
138
  organization: "organization";
139
+ person: "person";
140
+ payment_session: "payment_session";
120
141
  }>>;
121
142
  targetId: z.ZodOptional<z.ZodString>;
122
143
  bookingId: z.ZodOptional<z.ZodString>;
@@ -134,6 +155,7 @@ export declare const insertNotificationReminderRuleSchema: z.ZodObject<{
134
155
  archived: "archived";
135
156
  }>>;
136
157
  targetType: z.ZodEnum<{
158
+ invoice: "invoice";
137
159
  booking_payment_schedule: "booking_payment_schedule";
138
160
  }>;
139
161
  channel: z.ZodEnum<{
@@ -156,6 +178,7 @@ export declare const updateNotificationReminderRuleSchema: z.ZodObject<{
156
178
  archived: "archived";
157
179
  }>>>;
158
180
  targetType: z.ZodOptional<z.ZodEnum<{
181
+ invoice: "invoice";
159
182
  booking_payment_schedule: "booking_payment_schedule";
160
183
  }>>;
161
184
  channel: z.ZodOptional<z.ZodEnum<{
@@ -178,6 +201,7 @@ export declare const notificationReminderRuleListQuerySchema: z.ZodObject<{
178
201
  archived: "archived";
179
202
  }>>;
180
203
  targetType: z.ZodOptional<z.ZodEnum<{
204
+ invoice: "invoice";
181
205
  booking_payment_schedule: "booking_payment_schedule";
182
206
  }>>;
183
207
  channel: z.ZodOptional<z.ZodEnum<{
@@ -191,6 +215,7 @@ export declare const notificationReminderRunListQuerySchema: z.ZodObject<{
191
215
  offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
192
216
  reminderRuleId: z.ZodOptional<z.ZodString>;
193
217
  targetType: z.ZodOptional<z.ZodEnum<{
218
+ invoice: "invoice";
194
219
  booking_payment_schedule: "booking_payment_schedule";
195
220
  }>>;
196
221
  targetId: z.ZodOptional<z.ZodString>;
@@ -218,6 +243,17 @@ export declare const sendPaymentSessionNotificationSchema: z.ZodObject<{
218
243
  subject: z.ZodNullable<z.ZodOptional<z.ZodString>>;
219
244
  html: z.ZodNullable<z.ZodOptional<z.ZodString>>;
220
245
  text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
246
+ attachments: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
247
+ filename: z.ZodString;
248
+ contentBase64: z.ZodNullable<z.ZodOptional<z.ZodString>>;
249
+ path: z.ZodNullable<z.ZodOptional<z.ZodString>>;
250
+ contentType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
251
+ disposition: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
252
+ attachment: "attachment";
253
+ inline: "inline";
254
+ }>>>;
255
+ contentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
256
+ }, z.core.$strip>>>>;
221
257
  data: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
222
258
  metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
223
259
  scheduledFor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -235,6 +271,17 @@ export declare const sendInvoiceNotificationSchema: z.ZodObject<{
235
271
  subject: z.ZodNullable<z.ZodOptional<z.ZodString>>;
236
272
  html: z.ZodNullable<z.ZodOptional<z.ZodString>>;
237
273
  text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
274
+ attachments: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
275
+ filename: z.ZodString;
276
+ contentBase64: z.ZodNullable<z.ZodOptional<z.ZodString>>;
277
+ path: z.ZodNullable<z.ZodOptional<z.ZodString>>;
278
+ contentType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
279
+ disposition: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
280
+ attachment: "attachment";
281
+ inline: "inline";
282
+ }>>>;
283
+ contentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
284
+ }, z.core.$strip>>>>;
238
285
  data: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
239
286
  metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
240
287
  scheduledFor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -252,6 +299,17 @@ export declare const sendNotificationSchema: z.ZodObject<{
252
299
  subject: z.ZodNullable<z.ZodOptional<z.ZodString>>;
253
300
  html: z.ZodNullable<z.ZodOptional<z.ZodString>>;
254
301
  text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
302
+ attachments: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
303
+ filename: z.ZodString;
304
+ contentBase64: z.ZodNullable<z.ZodOptional<z.ZodString>>;
305
+ path: z.ZodNullable<z.ZodOptional<z.ZodString>>;
306
+ contentType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
307
+ disposition: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
308
+ attachment: "attachment";
309
+ inline: "inline";
310
+ }>>>;
311
+ contentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
312
+ }, z.core.$strip>>>>;
255
313
  data: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
256
314
  targetType: z.ZodDefault<z.ZodEnum<{
257
315
  other: "other";
@@ -259,9 +317,9 @@ export declare const sendNotificationSchema: z.ZodObject<{
259
317
  invoice: "invoice";
260
318
  booking_payment_schedule: "booking_payment_schedule";
261
319
  booking_guarantee: "booking_guarantee";
262
- payment_session: "payment_session";
263
- person: "person";
264
320
  organization: "organization";
321
+ person: "person";
322
+ payment_session: "payment_session";
265
323
  }>>;
266
324
  targetId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
267
325
  bookingId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -272,4 +330,118 @@ export declare const sendNotificationSchema: z.ZodObject<{
272
330
  metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
273
331
  scheduledFor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
274
332
  }, z.core.$strip>;
333
+ export declare const bookingDocumentBundleItemSchema: z.ZodObject<{
334
+ key: z.ZodString;
335
+ source: z.ZodEnum<{
336
+ finance: "finance";
337
+ legal: "legal";
338
+ }>;
339
+ documentType: z.ZodEnum<{
340
+ invoice: "invoice";
341
+ proforma: "proforma";
342
+ contract: "contract";
343
+ }>;
344
+ bookingId: z.ZodString;
345
+ contractId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
346
+ invoiceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
347
+ attachmentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
348
+ renditionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
349
+ contractStatus: z.ZodNullable<z.ZodOptional<z.ZodString>>;
350
+ invoiceStatus: z.ZodNullable<z.ZodOptional<z.ZodString>>;
351
+ name: z.ZodString;
352
+ format: z.ZodNullable<z.ZodOptional<z.ZodString>>;
353
+ mimeType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
354
+ storageKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
355
+ downloadUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
356
+ language: z.ZodNullable<z.ZodOptional<z.ZodString>>;
357
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
358
+ createdAt: z.ZodString;
359
+ }, z.core.$strip>;
360
+ export declare const bookingDocumentBundleSchema: z.ZodObject<{
361
+ bookingId: z.ZodString;
362
+ documents: z.ZodArray<z.ZodObject<{
363
+ key: z.ZodString;
364
+ source: z.ZodEnum<{
365
+ finance: "finance";
366
+ legal: "legal";
367
+ }>;
368
+ documentType: z.ZodEnum<{
369
+ invoice: "invoice";
370
+ proforma: "proforma";
371
+ contract: "contract";
372
+ }>;
373
+ bookingId: z.ZodString;
374
+ contractId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
375
+ invoiceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
376
+ attachmentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
377
+ renditionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
378
+ contractStatus: z.ZodNullable<z.ZodOptional<z.ZodString>>;
379
+ invoiceStatus: z.ZodNullable<z.ZodOptional<z.ZodString>>;
380
+ name: z.ZodString;
381
+ format: z.ZodNullable<z.ZodOptional<z.ZodString>>;
382
+ mimeType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
383
+ storageKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
384
+ downloadUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
385
+ language: z.ZodNullable<z.ZodOptional<z.ZodString>>;
386
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
387
+ createdAt: z.ZodString;
388
+ }, z.core.$strip>>;
389
+ }, z.core.$strip>;
390
+ export declare const sendBookingDocumentsNotificationSchema: z.ZodObject<{
391
+ templateId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
392
+ templateSlug: z.ZodNullable<z.ZodOptional<z.ZodString>>;
393
+ provider: z.ZodNullable<z.ZodOptional<z.ZodString>>;
394
+ to: z.ZodNullable<z.ZodOptional<z.ZodString>>;
395
+ from: z.ZodNullable<z.ZodOptional<z.ZodString>>;
396
+ subject: z.ZodNullable<z.ZodOptional<z.ZodString>>;
397
+ html: z.ZodNullable<z.ZodOptional<z.ZodString>>;
398
+ text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
399
+ data: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
400
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
401
+ scheduledFor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
402
+ documentTypes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodEnum<{
403
+ invoice: "invoice";
404
+ proforma: "proforma";
405
+ contract: "contract";
406
+ }>>>>;
407
+ }, z.core.$strip>;
408
+ export declare const sendBookingDocumentsNotificationResultSchema: z.ZodObject<{
409
+ bookingId: z.ZodString;
410
+ recipient: z.ZodString;
411
+ documents: z.ZodArray<z.ZodObject<{
412
+ key: z.ZodString;
413
+ source: z.ZodEnum<{
414
+ finance: "finance";
415
+ legal: "legal";
416
+ }>;
417
+ documentType: z.ZodEnum<{
418
+ invoice: "invoice";
419
+ proforma: "proforma";
420
+ contract: "contract";
421
+ }>;
422
+ bookingId: z.ZodString;
423
+ contractId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
424
+ invoiceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
425
+ attachmentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
426
+ renditionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
427
+ contractStatus: z.ZodNullable<z.ZodOptional<z.ZodString>>;
428
+ invoiceStatus: z.ZodNullable<z.ZodOptional<z.ZodString>>;
429
+ name: z.ZodString;
430
+ format: z.ZodNullable<z.ZodOptional<z.ZodString>>;
431
+ mimeType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
432
+ storageKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
433
+ downloadUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
434
+ language: z.ZodNullable<z.ZodOptional<z.ZodString>>;
435
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
436
+ createdAt: z.ZodString;
437
+ }, z.core.$strip>>;
438
+ deliveryId: z.ZodString;
439
+ provider: z.ZodNullable<z.ZodOptional<z.ZodString>>;
440
+ status: z.ZodEnum<{
441
+ cancelled: "cancelled";
442
+ pending: "pending";
443
+ failed: "failed";
444
+ sent: "sent";
445
+ }>;
446
+ }, z.core.$strip>;
275
447
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/valid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BA6BhC,CAAA;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmB1C,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGtC,CAAA;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;iBAajD,CAAA;AAEF,eAAO,MAAM,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOvD,CAAA"}
@@ -13,13 +13,28 @@ export const notificationTargetTypeSchema = z.enum([
13
13
  "other",
14
14
  ]);
15
15
  export const notificationReminderStatusSchema = z.enum(["draft", "active", "archived"]);
16
- export const notificationReminderTargetTypeSchema = z.enum(["booking_payment_schedule"]);
16
+ export const notificationReminderTargetTypeSchema = z.enum(["booking_payment_schedule", "invoice"]);
17
17
  export const notificationReminderRunStatusSchema = z.enum([
18
18
  "processing",
19
19
  "sent",
20
20
  "skipped",
21
21
  "failed",
22
22
  ]);
23
+ export const notificationDocumentTypeSchema = z.enum(["contract", "invoice", "proforma"]);
24
+ export const notificationDocumentSourceSchema = z.enum(["legal", "finance"]);
25
+ export const notificationAttachmentSchema = z
26
+ .object({
27
+ filename: z.string().min(1).max(500),
28
+ contentBase64: z.string().min(1).optional().nullable(),
29
+ path: z.string().min(1).max(4000).optional().nullable(),
30
+ contentType: z.string().max(255).optional().nullable(),
31
+ disposition: z.enum(["attachment", "inline"]).optional().nullable(),
32
+ contentId: z.string().max(255).optional().nullable(),
33
+ })
34
+ .refine((value) => Boolean(value.contentBase64 || value.path), {
35
+ message: "contentBase64 or path is required",
36
+ path: ["contentBase64"],
37
+ });
23
38
  const paginationSchema = z.object({
24
39
  limit: z.coerce.number().int().min(1).max(100).default(20),
25
40
  offset: z.coerce.number().int().min(0).default(0),
@@ -106,6 +121,7 @@ const transportNotificationCoreSchema = z.object({
106
121
  subject: z.string().max(2000).optional().nullable(),
107
122
  html: z.string().optional().nullable(),
108
123
  text: z.string().optional().nullable(),
124
+ attachments: z.array(notificationAttachmentSchema).optional().nullable(),
109
125
  data: z.record(z.string(), z.unknown()).optional().nullable(),
110
126
  metadata: z.record(z.string(), z.unknown()).optional().nullable(),
111
127
  scheduledFor: z.string().optional().nullable(),
@@ -127,6 +143,7 @@ export const sendNotificationSchema = z
127
143
  subject: z.string().max(2000).optional().nullable(),
128
144
  html: z.string().optional().nullable(),
129
145
  text: z.string().optional().nullable(),
146
+ attachments: z.array(notificationAttachmentSchema).optional().nullable(),
130
147
  data: z.record(z.string(), z.unknown()).optional().nullable(),
131
148
  targetType: notificationTargetTypeSchema.default("other"),
132
149
  targetId: z.string().optional().nullable(),
@@ -141,3 +158,49 @@ export const sendNotificationSchema = z
141
158
  .refine((value) => Boolean(value.templateId || value.templateSlug || value.subject || value.html || value.text), {
142
159
  message: "templateId, templateSlug, or direct content is required",
143
160
  });
161
+ export const bookingDocumentBundleItemSchema = z.object({
162
+ key: z.string().min(1),
163
+ source: notificationDocumentSourceSchema,
164
+ documentType: notificationDocumentTypeSchema,
165
+ bookingId: z.string().min(1),
166
+ contractId: z.string().optional().nullable(),
167
+ invoiceId: z.string().optional().nullable(),
168
+ attachmentId: z.string().optional().nullable(),
169
+ renditionId: z.string().optional().nullable(),
170
+ contractStatus: z.string().optional().nullable(),
171
+ invoiceStatus: z.string().optional().nullable(),
172
+ name: z.string().min(1),
173
+ format: z.string().optional().nullable(),
174
+ mimeType: z.string().optional().nullable(),
175
+ storageKey: z.string().optional().nullable(),
176
+ downloadUrl: z.string().url().optional().nullable(),
177
+ language: z.string().optional().nullable(),
178
+ metadata: z.record(z.string(), z.unknown()).optional().nullable(),
179
+ createdAt: z.string().datetime(),
180
+ });
181
+ export const bookingDocumentBundleSchema = z.object({
182
+ bookingId: z.string().min(1),
183
+ documents: z.array(bookingDocumentBundleItemSchema),
184
+ });
185
+ export const sendBookingDocumentsNotificationSchema = z.object({
186
+ templateId: z.string().optional().nullable(),
187
+ templateSlug: z.string().optional().nullable(),
188
+ provider: z.string().optional().nullable(),
189
+ to: z.string().min(1).optional().nullable(),
190
+ from: z.string().max(500).optional().nullable(),
191
+ subject: z.string().max(2000).optional().nullable(),
192
+ html: z.string().optional().nullable(),
193
+ text: z.string().optional().nullable(),
194
+ data: z.record(z.string(), z.unknown()).optional().nullable(),
195
+ metadata: z.record(z.string(), z.unknown()).optional().nullable(),
196
+ scheduledFor: z.string().optional().nullable(),
197
+ documentTypes: z.array(notificationDocumentTypeSchema).optional().nullable(),
198
+ });
199
+ export const sendBookingDocumentsNotificationResultSchema = z.object({
200
+ bookingId: z.string().min(1),
201
+ recipient: z.string().min(1),
202
+ documents: z.array(bookingDocumentBundleItemSchema),
203
+ deliveryId: z.string().min(1),
204
+ provider: z.string().optional().nullable(),
205
+ status: notificationDeliveryStatusSchema,
206
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/notifications",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,11 +49,12 @@
49
49
  "drizzle-orm": "^0.45.2",
50
50
  "hono": "^4.12.10",
51
51
  "zod": "^4.3.6",
52
- "@voyantjs/bookings": "0.3.1",
53
- "@voyantjs/core": "0.3.1",
54
- "@voyantjs/db": "0.3.1",
55
- "@voyantjs/finance": "0.3.1",
56
- "@voyantjs/hono": "0.3.1"
52
+ "@voyantjs/bookings": "0.4.1",
53
+ "@voyantjs/core": "0.4.1",
54
+ "@voyantjs/db": "0.4.1",
55
+ "@voyantjs/finance": "0.4.1",
56
+ "@voyantjs/hono": "0.4.1",
57
+ "@voyantjs/legal": "0.4.1"
57
58
  },
58
59
  "devDependencies": {
59
60
  "typescript": "^6.0.2",