@voyantjs/notifications 0.3.1 → 0.4.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.
- package/README.md +22 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/providers/resend.d.ts.map +1 -1
- package/dist/providers/resend.js +8 -0
- package/dist/routes.d.ts +128 -10
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +42 -1
- package/dist/schema.d.ts +6 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -0
- package/dist/service-booking-documents.d.ts +119 -0
- package/dist/service-booking-documents.d.ts.map +1 -0
- package/dist/service-booking-documents.js +261 -0
- package/dist/service-deliveries.d.ts +5 -5
- package/dist/service-deliveries.d.ts.map +1 -1
- package/dist/service-deliveries.js +25 -2
- package/dist/service-reminders.d.ts.map +1 -1
- package/dist/service-reminders.js +187 -19
- package/dist/service-shared.d.ts +11 -2
- package/dist/service-shared.d.ts.map +1 -1
- package/dist/service-shared.js +12 -0
- package/dist/service-templates.d.ts +5 -5
- package/dist/service.d.ts +111 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +6 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +178 -6
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +64 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ Notifications module for Voyant. It includes:
|
|
|
8
8
|
- database-backed delivery logs
|
|
9
9
|
- notification reminder rules and reminder runs
|
|
10
10
|
- finance-aware send flows for invoices and payment sessions
|
|
11
|
+
- booking document bundle/list + send flows for contract and invoice/proforma
|
|
12
|
+
artifacts
|
|
11
13
|
- routes for template management, delivery listing, reminder management, and sending
|
|
12
14
|
|
|
13
15
|
CRM communication history should remain a business-facing log. This module owns transport templates, delivery attempts, provider message ids, and reminder-oriented operational sends.
|
|
@@ -36,6 +38,13 @@ await notifications.sendWith("resend", {
|
|
|
36
38
|
template: "welcome",
|
|
37
39
|
subject: "Hello",
|
|
38
40
|
html: "<p>Welcome</p>",
|
|
41
|
+
attachments: [
|
|
42
|
+
{
|
|
43
|
+
filename: "invoice.pdf",
|
|
44
|
+
path: "https://cdn.example.com/invoices/invoice.pdf",
|
|
45
|
+
contentType: "application/pdf",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
39
48
|
})
|
|
40
49
|
```
|
|
41
50
|
|
|
@@ -73,13 +82,26 @@ await sendDueNotificationReminders(db, process.env, {
|
|
|
73
82
|
})
|
|
74
83
|
```
|
|
75
84
|
|
|
85
|
+
Reminder rules can currently target:
|
|
86
|
+
|
|
87
|
+
- `booking_payment_schedule`
|
|
88
|
+
- `invoice`
|
|
89
|
+
|
|
76
90
|
For finance-aware collection sends, the routes also support:
|
|
77
91
|
|
|
78
92
|
- `POST /payment-sessions/:id/send`
|
|
79
93
|
- `POST /invoices/:id/send`
|
|
94
|
+
- `GET /bookings/:id/document-bundle`
|
|
95
|
+
- `POST /bookings/:id/send-documents`
|
|
80
96
|
|
|
81
97
|
Those routes resolve recipients from the payment session, invoice, and linked booking participants, then render the selected notification template with finance context such as payment links, invoice balances, and booking references.
|
|
82
98
|
|
|
99
|
+
Booking document sends bundle the latest customer-facing contract attachment and
|
|
100
|
+
ready invoice/proforma rendition for a booking. By default they use `metadata.url`
|
|
101
|
+
or `metadata.downloadUrl` on the legal/finance artifact as the attachment path.
|
|
102
|
+
Apps can override that behavior with `documentAttachmentResolver` when mounting
|
|
103
|
+
`createNotificationsRoutes()` or `createNotificationsHonoModule()`.
|
|
104
|
+
|
|
83
105
|
## Exports
|
|
84
106
|
|
|
85
107
|
| Entry | Description |
|
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ export { createNotificationsRoutes } from "./routes.js";
|
|
|
12
12
|
export type { NewNotificationDelivery, NewNotificationReminderRule, NewNotificationReminderRun, NewNotificationTemplate, NotificationDelivery, NotificationReminderRule, NotificationReminderRun, NotificationsHonoModule, NotificationTemplate, } from "./schema.js";
|
|
13
13
|
export { notificationChannelEnum, notificationDeliveries, notificationDeliveryStatusEnum, notificationReminderRules, notificationReminderRunStatusEnum, notificationReminderRuns, notificationReminderStatusEnum, notificationReminderTargetTypeEnum, notificationsModule, notificationTargetTypeEnum, notificationTemplateStatusEnum, notificationTemplates, } from "./schema.js";
|
|
14
14
|
export type { NotificationService } from "./service.js";
|
|
15
|
-
export { createNotificationService, NotificationError, notificationsService, renderNotificationTemplate, } from "./service.js";
|
|
15
|
+
export { createDefaultBookingDocumentAttachment, createNotificationService, NotificationError, notificationsService, renderNotificationTemplate, } from "./service.js";
|
|
16
|
+
export type { BookingDocumentAttachmentResolver, SendBookingDocumentsRuntimeOptions, } from "./service-booking-documents.js";
|
|
17
|
+
export { bookingDocumentNotificationsService } from "./service-booking-documents.js";
|
|
16
18
|
export { sendDueNotificationReminders } from "./tasks/index.js";
|
|
17
|
-
export type { NotificationChannel, NotificationPayload, NotificationProvider, NotificationResult, } from "./types.js";
|
|
18
|
-
export { insertNotificationReminderRuleSchema, insertNotificationTemplateSchema, notificationChannelSchema, notificationDeliveryListQuerySchema, notificationDeliveryStatusSchema, notificationReminderRuleListQuerySchema, notificationReminderRunListQuerySchema, notificationReminderRunStatusSchema, notificationReminderStatusSchema, notificationReminderTargetTypeSchema, notificationTargetTypeSchema, notificationTemplateListQuerySchema, notificationTemplateStatusSchema, runDueRemindersSchema, sendInvoiceNotificationSchema, sendNotificationSchema, sendPaymentSessionNotificationSchema, updateNotificationReminderRuleSchema, updateNotificationTemplateSchema, } from "./validation.js";
|
|
19
|
+
export type { NotificationAttachment, NotificationChannel, NotificationPayload, NotificationProvider, NotificationResult, } from "./types.js";
|
|
20
|
+
export { bookingDocumentBundleItemSchema, bookingDocumentBundleSchema, insertNotificationReminderRuleSchema, insertNotificationTemplateSchema, notificationAttachmentSchema, notificationChannelSchema, notificationDeliveryListQuerySchema, notificationDeliveryStatusSchema, notificationDocumentSourceSchema, notificationDocumentTypeSchema, notificationReminderRuleListQuerySchema, notificationReminderRunListQuerySchema, notificationReminderRunStatusSchema, notificationReminderStatusSchema, notificationReminderTargetTypeSchema, notificationTargetTypeSchema, notificationTemplateListQuerySchema, notificationTemplateStatusSchema, runDueRemindersSchema, sendBookingDocumentsNotificationResultSchema, sendBookingDocumentsNotificationSchema, sendInvoiceNotificationSchema, sendNotificationSchema, sendPaymentSessionNotificationSchema, updateNotificationReminderRuleSchema, updateNotificationTemplateSchema, } from "./validation.js";
|
|
19
21
|
export declare function createNotificationsHonoModule(options?: Parameters<typeof createNotificationsRoutes>[0]): HonoModule;
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAGvD,YAAY,EAAE,kCAAkC,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,EACL,kCAAkC,EAClC,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC5D,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,aA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AACvC,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAA;AACpF,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAC/D,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,oCAAoC,EACpC,gCAAgC,EAChC,4BAA4B,EAC5B,yBAAyB,EACzB,mCAAmC,EACnC,gCAAgC,EAChC,gCAAgC,EAChC,8BAA8B,EAC9B,uCAAuC,EACvC,sCAAsC,EACtC,mCAAmC,EACnC,gCAAgC,EAChC,oCAAoC,EACpC,4BAA4B,EAC5B,mCAAmC,EACnC,gCAAgC,EAChC,qBAAqB,EACrB,4CAA4C,EAC5C,sCAAsC,EACtC,6BAA6B,EAC7B,sBAAsB,EACtB,oCAAoC,EACpC,oCAAoC,EACpC,gCAAgC,GACjC,MAAM,iBAAiB,CAAA;AAExB,wBAAgB,6BAA6B,CAC3C,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,GACxD,UAAU,CAKZ"}
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,10 @@ export { createResendProvider } from "./providers/resend.js";
|
|
|
6
6
|
export { createTwilioProvider } from "./providers/twilio.js";
|
|
7
7
|
export { createNotificationsRoutes } from "./routes.js";
|
|
8
8
|
export { notificationChannelEnum, notificationDeliveries, notificationDeliveryStatusEnum, notificationReminderRules, notificationReminderRunStatusEnum, notificationReminderRuns, notificationReminderStatusEnum, notificationReminderTargetTypeEnum, notificationsModule, notificationTargetTypeEnum, notificationTemplateStatusEnum, notificationTemplates, } from "./schema.js";
|
|
9
|
-
export { createNotificationService, NotificationError, notificationsService, renderNotificationTemplate, } from "./service.js";
|
|
9
|
+
export { createDefaultBookingDocumentAttachment, createNotificationService, NotificationError, notificationsService, renderNotificationTemplate, } from "./service.js";
|
|
10
|
+
export { bookingDocumentNotificationsService } from "./service-booking-documents.js";
|
|
10
11
|
export { sendDueNotificationReminders } from "./tasks/index.js";
|
|
11
|
-
export { insertNotificationReminderRuleSchema, insertNotificationTemplateSchema, notificationChannelSchema, notificationDeliveryListQuerySchema, notificationDeliveryStatusSchema, notificationReminderRuleListQuerySchema, notificationReminderRunListQuerySchema, notificationReminderRunStatusSchema, notificationReminderStatusSchema, notificationReminderTargetTypeSchema, notificationTargetTypeSchema, notificationTemplateListQuerySchema, notificationTemplateStatusSchema, runDueRemindersSchema, sendInvoiceNotificationSchema, sendNotificationSchema, sendPaymentSessionNotificationSchema, updateNotificationReminderRuleSchema, updateNotificationTemplateSchema, } from "./validation.js";
|
|
12
|
+
export { bookingDocumentBundleItemSchema, bookingDocumentBundleSchema, insertNotificationReminderRuleSchema, insertNotificationTemplateSchema, notificationAttachmentSchema, notificationChannelSchema, notificationDeliveryListQuerySchema, notificationDeliveryStatusSchema, notificationDocumentSourceSchema, notificationDocumentTypeSchema, notificationReminderRuleListQuerySchema, notificationReminderRunListQuerySchema, notificationReminderRunStatusSchema, notificationReminderStatusSchema, notificationReminderTargetTypeSchema, notificationTargetTypeSchema, notificationTemplateListQuerySchema, notificationTemplateStatusSchema, runDueRemindersSchema, sendBookingDocumentsNotificationResultSchema, sendBookingDocumentsNotificationSchema, sendInvoiceNotificationSchema, sendNotificationSchema, sendPaymentSessionNotificationSchema, updateNotificationReminderRuleSchema, updateNotificationTemplateSchema, } from "./validation.js";
|
|
12
13
|
export function createNotificationsHonoModule(options) {
|
|
13
14
|
return {
|
|
14
15
|
module: notificationsModule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resend.d.ts","sourceRoot":"","sources":["../../src/providers/resend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAsB,MAAM,aAAa,CAAA;AAE3E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,E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C,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;CACb,KACE,OAAO,CAAC;IACX,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5B,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CAC5B,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IACZ,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,KACV,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAA;CACxD;AAMD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CAqDzF"}
|
package/dist/providers/resend.js
CHANGED
|
@@ -30,6 +30,14 @@ export function createResendProvider(options) {
|
|
|
30
30
|
subject: payload.subject ?? rendered.subject,
|
|
31
31
|
html: payload.html ?? rendered.html,
|
|
32
32
|
text: payload.text ?? rendered.text,
|
|
33
|
+
attachments: payload.attachments?.map((attachment) => ({
|
|
34
|
+
filename: attachment.filename,
|
|
35
|
+
content: attachment.contentBase64,
|
|
36
|
+
path: attachment.path,
|
|
37
|
+
content_type: attachment.contentType,
|
|
38
|
+
disposition: attachment.disposition,
|
|
39
|
+
content_id: attachment.contentId,
|
|
40
|
+
})),
|
|
33
41
|
};
|
|
34
42
|
const response = await fetchImpl(`${baseUrl}/emails`, {
|
|
35
43
|
method: "POST",
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { BookingDocumentAttachmentResolver } from "./service-booking-documents.js";
|
|
2
3
|
import type { NotificationProvider } from "./types.js";
|
|
3
4
|
type Env = {
|
|
4
5
|
Bindings: Record<string, unknown>;
|
|
@@ -10,6 +11,8 @@ type Env = {
|
|
|
10
11
|
export declare function createNotificationsRoutes(options?: {
|
|
11
12
|
providers?: ReadonlyArray<NotificationProvider>;
|
|
12
13
|
resolveProviders?: (bindings: Record<string, unknown>) => ReadonlyArray<NotificationProvider>;
|
|
14
|
+
documentAttachmentResolver?: BookingDocumentAttachmentResolver;
|
|
15
|
+
resolveDocumentAttachmentResolver?: (bindings: Record<string, unknown>) => BookingDocumentAttachmentResolver | undefined;
|
|
13
16
|
}): import("hono/hono-base").HonoBase<Env, {
|
|
14
17
|
"/templates": {
|
|
15
18
|
$get: {
|
|
@@ -164,7 +167,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
164
167
|
id: string;
|
|
165
168
|
templateId: string | null;
|
|
166
169
|
templateSlug: string | null;
|
|
167
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
170
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
168
171
|
targetId: string | null;
|
|
169
172
|
personId: string | null;
|
|
170
173
|
organizationId: string | null;
|
|
@@ -225,7 +228,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
225
228
|
id: string;
|
|
226
229
|
templateId: string | null;
|
|
227
230
|
templateSlug: string | null;
|
|
228
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
231
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
229
232
|
targetId: string | null;
|
|
230
233
|
personId: string | null;
|
|
231
234
|
organizationId: string | null;
|
|
@@ -269,7 +272,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
269
272
|
slug: string;
|
|
270
273
|
name: string;
|
|
271
274
|
status: "draft" | "active" | "archived";
|
|
272
|
-
targetType: "booking_payment_schedule";
|
|
275
|
+
targetType: "invoice" | "booking_payment_schedule";
|
|
273
276
|
channel: "email" | "sms";
|
|
274
277
|
provider: string | null;
|
|
275
278
|
templateId: string | null;
|
|
@@ -306,7 +309,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
306
309
|
} | null;
|
|
307
310
|
channel: "email" | "sms";
|
|
308
311
|
provider: string | null;
|
|
309
|
-
targetType: "booking_payment_schedule";
|
|
312
|
+
targetType: "invoice" | "booking_payment_schedule";
|
|
310
313
|
templateId: string | null;
|
|
311
314
|
slug: string;
|
|
312
315
|
isSystem: boolean;
|
|
@@ -343,7 +346,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
343
346
|
slug: string;
|
|
344
347
|
name: string;
|
|
345
348
|
status: "draft" | "active" | "archived";
|
|
346
|
-
targetType: "booking_payment_schedule";
|
|
349
|
+
targetType: "invoice" | "booking_payment_schedule";
|
|
347
350
|
channel: "email" | "sms";
|
|
348
351
|
provider: string | null;
|
|
349
352
|
templateId: string | null;
|
|
@@ -386,7 +389,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
386
389
|
slug: string;
|
|
387
390
|
name: string;
|
|
388
391
|
status: "draft" | "active" | "archived";
|
|
389
|
-
targetType: "booking_payment_schedule";
|
|
392
|
+
targetType: "invoice" | "booking_payment_schedule";
|
|
390
393
|
channel: "email" | "sms";
|
|
391
394
|
provider: string | null;
|
|
392
395
|
templateId: string | null;
|
|
@@ -412,7 +415,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
412
415
|
data: {
|
|
413
416
|
id: string;
|
|
414
417
|
reminderRuleId: string;
|
|
415
|
-
targetType: "booking_payment_schedule";
|
|
418
|
+
targetType: "invoice" | "booking_payment_schedule";
|
|
416
419
|
targetId: string;
|
|
417
420
|
dedupeKey: string;
|
|
418
421
|
bookingId: string | null;
|
|
@@ -486,7 +489,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
486
489
|
id: string;
|
|
487
490
|
templateId: string | null;
|
|
488
491
|
templateSlug: string | null;
|
|
489
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
492
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
490
493
|
targetId: string | null;
|
|
491
494
|
personId: string | null;
|
|
492
495
|
organizationId: string | null;
|
|
@@ -555,7 +558,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
555
558
|
id: string;
|
|
556
559
|
templateId: string | null;
|
|
557
560
|
templateSlug: string | null;
|
|
558
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
561
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
559
562
|
targetId: string | null;
|
|
560
563
|
personId: string | null;
|
|
561
564
|
organizationId: string | null;
|
|
@@ -600,6 +603,121 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
600
603
|
status: 400;
|
|
601
604
|
};
|
|
602
605
|
};
|
|
606
|
+
} & {
|
|
607
|
+
"/bookings/:id/document-bundle": {
|
|
608
|
+
$get: {
|
|
609
|
+
input: {
|
|
610
|
+
param: {
|
|
611
|
+
id: string;
|
|
612
|
+
};
|
|
613
|
+
};
|
|
614
|
+
output: {
|
|
615
|
+
error: string;
|
|
616
|
+
};
|
|
617
|
+
outputFormat: "json";
|
|
618
|
+
status: 404;
|
|
619
|
+
} | {
|
|
620
|
+
input: {
|
|
621
|
+
param: {
|
|
622
|
+
id: string;
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
output: {
|
|
626
|
+
data: {
|
|
627
|
+
bookingId: string;
|
|
628
|
+
documents: {
|
|
629
|
+
key: string;
|
|
630
|
+
source: "finance" | "legal";
|
|
631
|
+
documentType: "invoice" | "proforma" | "contract";
|
|
632
|
+
bookingId: string;
|
|
633
|
+
name: string;
|
|
634
|
+
createdAt: string;
|
|
635
|
+
contractId?: string | null | undefined;
|
|
636
|
+
invoiceId?: string | null | undefined;
|
|
637
|
+
attachmentId?: string | null | undefined;
|
|
638
|
+
renditionId?: string | null | undefined;
|
|
639
|
+
contractStatus?: string | null | undefined;
|
|
640
|
+
invoiceStatus?: string | null | undefined;
|
|
641
|
+
format?: string | null | undefined;
|
|
642
|
+
mimeType?: string | null | undefined;
|
|
643
|
+
storageKey?: string | null | undefined;
|
|
644
|
+
downloadUrl?: string | null | undefined;
|
|
645
|
+
language?: string | null | undefined;
|
|
646
|
+
metadata?: {
|
|
647
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
648
|
+
} | null | undefined;
|
|
649
|
+
}[];
|
|
650
|
+
};
|
|
651
|
+
};
|
|
652
|
+
outputFormat: "json";
|
|
653
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
} & {
|
|
657
|
+
"/bookings/:id/send-documents": {
|
|
658
|
+
$post: {
|
|
659
|
+
input: {
|
|
660
|
+
param: {
|
|
661
|
+
id: string;
|
|
662
|
+
};
|
|
663
|
+
};
|
|
664
|
+
output: {
|
|
665
|
+
error: string;
|
|
666
|
+
};
|
|
667
|
+
outputFormat: "json";
|
|
668
|
+
status: 404;
|
|
669
|
+
} | {
|
|
670
|
+
input: {
|
|
671
|
+
param: {
|
|
672
|
+
id: string;
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
output: {
|
|
676
|
+
error: string;
|
|
677
|
+
};
|
|
678
|
+
outputFormat: "json";
|
|
679
|
+
status: 400;
|
|
680
|
+
} | {
|
|
681
|
+
input: {
|
|
682
|
+
param: {
|
|
683
|
+
id: string;
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
output: {
|
|
687
|
+
data: {
|
|
688
|
+
bookingId: string;
|
|
689
|
+
recipient: string;
|
|
690
|
+
documents: {
|
|
691
|
+
key: string;
|
|
692
|
+
source: "finance" | "legal";
|
|
693
|
+
documentType: "invoice" | "proforma" | "contract";
|
|
694
|
+
bookingId: string;
|
|
695
|
+
name: string;
|
|
696
|
+
createdAt: string;
|
|
697
|
+
contractId?: string | null | undefined;
|
|
698
|
+
invoiceId?: string | null | undefined;
|
|
699
|
+
attachmentId?: string | null | undefined;
|
|
700
|
+
renditionId?: string | null | undefined;
|
|
701
|
+
contractStatus?: string | null | undefined;
|
|
702
|
+
invoiceStatus?: string | null | undefined;
|
|
703
|
+
format?: string | null | undefined;
|
|
704
|
+
mimeType?: string | null | undefined;
|
|
705
|
+
storageKey?: string | null | undefined;
|
|
706
|
+
downloadUrl?: string | null | undefined;
|
|
707
|
+
language?: string | null | undefined;
|
|
708
|
+
metadata?: {
|
|
709
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
710
|
+
} | null | undefined;
|
|
711
|
+
}[];
|
|
712
|
+
deliveryId: string;
|
|
713
|
+
status: "cancelled" | "pending" | "failed" | "sent";
|
|
714
|
+
provider?: string | null | undefined;
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
outputFormat: "json";
|
|
718
|
+
status: 201;
|
|
719
|
+
};
|
|
720
|
+
};
|
|
603
721
|
} & {
|
|
604
722
|
"/send": {
|
|
605
723
|
$post: {
|
|
@@ -609,7 +727,7 @@ export declare function createNotificationsRoutes(options?: {
|
|
|
609
727
|
id: string;
|
|
610
728
|
templateId: string | null;
|
|
611
729
|
templateSlug: string | null;
|
|
612
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
730
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
613
731
|
targetId: string | null;
|
|
614
732
|
personId: string | null;
|
|
615
733
|
organizationId: string | null;
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAIjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAIjE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAA;AACvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAmBtD,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,SAAS,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAA;IAC/C,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,aAAa,CAAC,oBAAoB,CAAC,CAAA;IAC7F,0BAA0B,CAAC,EAAE,iCAAiC,CAAA;IAC9D,iCAAiC,CAAC,EAAE,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,iCAAiC,GAAG,SAAS,CAAA;CACnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmMA"}
|
package/dist/routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { createNotificationService, notificationsService } from "./service.js";
|
|
3
|
-
import { insertNotificationReminderRuleSchema, insertNotificationTemplateSchema, notificationDeliveryListQuerySchema, notificationReminderRuleListQuerySchema, notificationReminderRunListQuerySchema, notificationTemplateListQuerySchema, runDueRemindersSchema, sendInvoiceNotificationSchema, sendNotificationSchema, sendPaymentSessionNotificationSchema, updateNotificationReminderRuleSchema, updateNotificationTemplateSchema, } from "./validation.js";
|
|
3
|
+
import { bookingDocumentBundleSchema, insertNotificationReminderRuleSchema, insertNotificationTemplateSchema, notificationDeliveryListQuerySchema, notificationReminderRuleListQuerySchema, notificationReminderRunListQuerySchema, notificationTemplateListQuerySchema, runDueRemindersSchema, sendBookingDocumentsNotificationResultSchema, sendBookingDocumentsNotificationSchema, sendInvoiceNotificationSchema, sendNotificationSchema, sendPaymentSessionNotificationSchema, updateNotificationReminderRuleSchema, updateNotificationTemplateSchema, } from "./validation.js";
|
|
4
4
|
export function createNotificationsRoutes(options) {
|
|
5
5
|
return new Hono()
|
|
6
6
|
.get("/templates", async (c) => {
|
|
@@ -93,6 +93,47 @@ export function createNotificationsRoutes(options) {
|
|
|
93
93
|
const message = error instanceof Error ? error.message : "Invoice notification failed";
|
|
94
94
|
return c.json({ error: message }, 400);
|
|
95
95
|
}
|
|
96
|
+
})
|
|
97
|
+
.get("/bookings/:id/document-bundle", async (c) => {
|
|
98
|
+
const bundle = await notificationsService.listBookingDocumentBundle(c.get("db"), c.req.param("id"));
|
|
99
|
+
if (!bundle)
|
|
100
|
+
return c.json({ error: "Booking not found" }, 404);
|
|
101
|
+
return c.json({ data: bookingDocumentBundleSchema.parse(bundle) });
|
|
102
|
+
})
|
|
103
|
+
.post("/bookings/:id/send-documents", async (c) => {
|
|
104
|
+
try {
|
|
105
|
+
const dispatcher = createNotificationService(options?.resolveProviders?.(c.env) ?? options?.providers ?? []);
|
|
106
|
+
const result = await notificationsService.sendBookingDocumentsNotification(c.get("db"), dispatcher, c.req.param("id"), sendBookingDocumentsNotificationSchema.parse(await c.req.json().catch(() => ({}))), {
|
|
107
|
+
attachmentResolver: options?.resolveDocumentAttachmentResolver?.(c.env) ??
|
|
108
|
+
options?.documentAttachmentResolver,
|
|
109
|
+
});
|
|
110
|
+
if (result.status === "not_found")
|
|
111
|
+
return c.json({ error: "Booking not found" }, 404);
|
|
112
|
+
if (result.status === "no_documents")
|
|
113
|
+
return c.json({ error: "No booking documents" }, 400);
|
|
114
|
+
if (result.status === "no_recipient")
|
|
115
|
+
return c.json({ error: "No recipient available" }, 400);
|
|
116
|
+
if (result.status === "no_attachments") {
|
|
117
|
+
return c.json({ error: "No deliverable document attachments available" }, 400);
|
|
118
|
+
}
|
|
119
|
+
if (result.status === "send_failed") {
|
|
120
|
+
return c.json({ error: "Booking document notification failed" }, 400);
|
|
121
|
+
}
|
|
122
|
+
return c.json({
|
|
123
|
+
data: sendBookingDocumentsNotificationResultSchema.parse({
|
|
124
|
+
bookingId: result.bookingId,
|
|
125
|
+
recipient: result.recipient,
|
|
126
|
+
documents: result.documents,
|
|
127
|
+
deliveryId: result.delivery.id,
|
|
128
|
+
provider: result.delivery.provider,
|
|
129
|
+
status: result.delivery.status,
|
|
130
|
+
}),
|
|
131
|
+
}, 201);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
const message = error instanceof Error ? error.message : "Booking document notification failed";
|
|
135
|
+
return c.json({ error: message }, 400);
|
|
136
|
+
}
|
|
96
137
|
})
|
|
97
138
|
.post("/send", async (c) => {
|
|
98
139
|
try {
|
package/dist/schema.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const notificationTemplateStatusEnum: import("drizzle-orm/pg-core
|
|
|
5
5
|
export declare const notificationDeliveryStatusEnum: import("drizzle-orm/pg-core").PgEnum<["pending", "sent", "failed", "cancelled"]>;
|
|
6
6
|
export declare const notificationTargetTypeEnum: import("drizzle-orm/pg-core").PgEnum<["booking", "booking_payment_schedule", "booking_guarantee", "invoice", "payment_session", "person", "organization", "other"]>;
|
|
7
7
|
export declare const notificationReminderStatusEnum: import("drizzle-orm/pg-core").PgEnum<["draft", "active", "archived"]>;
|
|
8
|
-
export declare const notificationReminderTargetTypeEnum: import("drizzle-orm/pg-core").PgEnum<["booking_payment_schedule"]>;
|
|
8
|
+
export declare const notificationReminderTargetTypeEnum: import("drizzle-orm/pg-core").PgEnum<["booking_payment_schedule", "invoice"]>;
|
|
9
9
|
export declare const notificationReminderRunStatusEnum: import("drizzle-orm/pg-core").PgEnum<["processing", "sent", "skipped", "failed"]>;
|
|
10
10
|
export declare const notificationTemplates: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
11
11
|
name: "notification_templates";
|
|
@@ -316,7 +316,7 @@ export declare const notificationDeliveries: import("drizzle-orm/pg-core").PgTab
|
|
|
316
316
|
tableName: "notification_deliveries";
|
|
317
317
|
dataType: "string";
|
|
318
318
|
columnType: "PgEnumColumn";
|
|
319
|
-
data: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
319
|
+
data: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
320
320
|
driverParam: string;
|
|
321
321
|
notNull: true;
|
|
322
322
|
hasDefault: true;
|
|
@@ -805,14 +805,14 @@ export declare const notificationReminderRules: import("drizzle-orm/pg-core").Pg
|
|
|
805
805
|
tableName: "notification_reminder_rules";
|
|
806
806
|
dataType: "string";
|
|
807
807
|
columnType: "PgEnumColumn";
|
|
808
|
-
data: "booking_payment_schedule";
|
|
808
|
+
data: "invoice" | "booking_payment_schedule";
|
|
809
809
|
driverParam: string;
|
|
810
810
|
notNull: true;
|
|
811
811
|
hasDefault: false;
|
|
812
812
|
isPrimaryKey: false;
|
|
813
813
|
isAutoincrement: false;
|
|
814
814
|
hasRuntimeDefault: false;
|
|
815
|
-
enumValues: ["booking_payment_schedule"];
|
|
815
|
+
enumValues: ["booking_payment_schedule", "invoice"];
|
|
816
816
|
baseColumn: never;
|
|
817
817
|
identity: undefined;
|
|
818
818
|
generated: undefined;
|
|
@@ -1020,14 +1020,14 @@ export declare const notificationReminderRuns: import("drizzle-orm/pg-core").PgT
|
|
|
1020
1020
|
tableName: "notification_reminder_runs";
|
|
1021
1021
|
dataType: "string";
|
|
1022
1022
|
columnType: "PgEnumColumn";
|
|
1023
|
-
data: "booking_payment_schedule";
|
|
1023
|
+
data: "invoice" | "booking_payment_schedule";
|
|
1024
1024
|
driverParam: string;
|
|
1025
1025
|
notNull: true;
|
|
1026
1026
|
hasDefault: false;
|
|
1027
1027
|
isPrimaryKey: false;
|
|
1028
1028
|
isAutoincrement: false;
|
|
1029
1029
|
hasRuntimeDefault: false;
|
|
1030
|
-
enumValues: ["booking_payment_schedule"];
|
|
1030
|
+
enumValues: ["booking_payment_schedule", "invoice"];
|
|
1031
1031
|
baseColumn: never;
|
|
1032
1032
|
identity: undefined;
|
|
1033
1033
|
generated: undefined;
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAcvD,eAAO,MAAM,uBAAuB,wDAAmD,CAAA;AAEvF,eAAO,MAAM,8BAA8B,uEAIzC,CAAA;AAEF,eAAO,MAAM,8BAA8B,kFAKzC,CAAA;AAEF,eAAO,MAAM,0BAA0B,qKASrC,CAAA;AAEF,eAAO,MAAM,8BAA8B,uEAIzC,CAAA;AAEF,eAAO,MAAM,kCAAkC,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAcvD,eAAO,MAAM,uBAAuB,wDAAmD,CAAA;AAEvF,eAAO,MAAM,8BAA8B,uEAIzC,CAAA;AAEF,eAAO,MAAM,8BAA8B,kFAKzC,CAAA;AAEF,eAAO,MAAM,0BAA0B,qKASrC,CAAA;AAEF,eAAO,MAAM,8BAA8B,uEAIzC,CAAA;AAEF,eAAO,MAAM,kCAAkC,+EAG7C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K1C,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,kBAK1C,CAAA;AAED,eAAO,MAAM,gCAAgC,EAAE,kBAK9C,CAAA;AAED,eAAO,MAAM,+BAA+B,EAAE,kBAK7C,CAAA;AAED,eAAO,MAAM,qBAAqB;;;;;CAKjC,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,MAGjC,CAAA;AAGD,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAA"}
|
package/dist/schema.js
CHANGED
|
@@ -30,6 +30,7 @@ export const notificationReminderStatusEnum = pgEnum("notification_reminder_stat
|
|
|
30
30
|
]);
|
|
31
31
|
export const notificationReminderTargetTypeEnum = pgEnum("notification_reminder_target_type", [
|
|
32
32
|
"booking_payment_schedule",
|
|
33
|
+
"invoice",
|
|
33
34
|
]);
|
|
34
35
|
export const notificationReminderRunStatusEnum = pgEnum("notification_reminder_run_status", [
|
|
35
36
|
"processing",
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { BookingDocumentBundleItem, NotificationService, SendBookingDocumentsNotificationInput } from "./service-shared.js";
|
|
3
|
+
import type { NotificationAttachment } from "./types.js";
|
|
4
|
+
export type BookingDocumentAttachmentResolver = (document: BookingDocumentBundleItem) => Promise<NotificationAttachment | null>;
|
|
5
|
+
export interface SendBookingDocumentsRuntimeOptions {
|
|
6
|
+
attachmentResolver?: BookingDocumentAttachmentResolver;
|
|
7
|
+
}
|
|
8
|
+
declare function createDefaultAttachmentFromDocument(document: BookingDocumentBundleItem): NotificationAttachment | null;
|
|
9
|
+
export declare const bookingDocumentNotificationsService: {
|
|
10
|
+
listBookingDocumentBundle(db: PostgresJsDatabase, bookingId: string): Promise<{
|
|
11
|
+
bookingId: string;
|
|
12
|
+
documents: {
|
|
13
|
+
key: string;
|
|
14
|
+
source: "finance" | "legal";
|
|
15
|
+
documentType: "invoice" | "proforma" | "contract";
|
|
16
|
+
bookingId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
contractId?: string | null | undefined;
|
|
20
|
+
invoiceId?: string | null | undefined;
|
|
21
|
+
attachmentId?: string | null | undefined;
|
|
22
|
+
renditionId?: string | null | undefined;
|
|
23
|
+
contractStatus?: string | null | undefined;
|
|
24
|
+
invoiceStatus?: string | null | undefined;
|
|
25
|
+
format?: string | null | undefined;
|
|
26
|
+
mimeType?: string | null | undefined;
|
|
27
|
+
storageKey?: string | null | undefined;
|
|
28
|
+
downloadUrl?: string | null | undefined;
|
|
29
|
+
language?: string | null | undefined;
|
|
30
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
31
|
+
}[];
|
|
32
|
+
} | null>;
|
|
33
|
+
sendBookingDocumentsNotification(db: PostgresJsDatabase, dispatcher: NotificationService, bookingId: string, input: SendBookingDocumentsNotificationInput, runtime?: SendBookingDocumentsRuntimeOptions): Promise<{
|
|
34
|
+
status: "not_found";
|
|
35
|
+
bookingId?: undefined;
|
|
36
|
+
recipient?: undefined;
|
|
37
|
+
documents?: undefined;
|
|
38
|
+
delivery?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
status: "no_documents";
|
|
41
|
+
bookingId?: undefined;
|
|
42
|
+
recipient?: undefined;
|
|
43
|
+
documents?: undefined;
|
|
44
|
+
delivery?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
status: "no_recipient";
|
|
47
|
+
bookingId?: undefined;
|
|
48
|
+
recipient?: undefined;
|
|
49
|
+
documents?: undefined;
|
|
50
|
+
delivery?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
status: "no_attachments";
|
|
53
|
+
bookingId?: undefined;
|
|
54
|
+
recipient?: undefined;
|
|
55
|
+
documents?: undefined;
|
|
56
|
+
delivery?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
status: "send_failed";
|
|
59
|
+
bookingId?: undefined;
|
|
60
|
+
recipient?: undefined;
|
|
61
|
+
documents?: undefined;
|
|
62
|
+
delivery?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
status: "sent";
|
|
65
|
+
bookingId: string;
|
|
66
|
+
recipient: string;
|
|
67
|
+
documents: {
|
|
68
|
+
key: string;
|
|
69
|
+
source: "finance" | "legal";
|
|
70
|
+
documentType: "invoice" | "proforma" | "contract";
|
|
71
|
+
bookingId: string;
|
|
72
|
+
name: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
contractId?: string | null | undefined;
|
|
75
|
+
invoiceId?: string | null | undefined;
|
|
76
|
+
attachmentId?: string | null | undefined;
|
|
77
|
+
renditionId?: string | null | undefined;
|
|
78
|
+
contractStatus?: string | null | undefined;
|
|
79
|
+
invoiceStatus?: string | null | undefined;
|
|
80
|
+
format?: string | null | undefined;
|
|
81
|
+
mimeType?: string | null | undefined;
|
|
82
|
+
storageKey?: string | null | undefined;
|
|
83
|
+
downloadUrl?: string | null | undefined;
|
|
84
|
+
language?: string | null | undefined;
|
|
85
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
86
|
+
}[];
|
|
87
|
+
delivery: {
|
|
88
|
+
id: string;
|
|
89
|
+
templateId: string | null;
|
|
90
|
+
templateSlug: string | null;
|
|
91
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
92
|
+
targetId: string | null;
|
|
93
|
+
personId: string | null;
|
|
94
|
+
organizationId: string | null;
|
|
95
|
+
bookingId: string | null;
|
|
96
|
+
invoiceId: string | null;
|
|
97
|
+
paymentSessionId: string | null;
|
|
98
|
+
channel: "email" | "sms";
|
|
99
|
+
provider: string;
|
|
100
|
+
providerMessageId: string | null;
|
|
101
|
+
status: "cancelled" | "pending" | "failed" | "sent";
|
|
102
|
+
toAddress: string;
|
|
103
|
+
fromAddress: string | null;
|
|
104
|
+
subject: string | null;
|
|
105
|
+
htmlBody: string | null;
|
|
106
|
+
textBody: string | null;
|
|
107
|
+
payloadData: Record<string, unknown> | null;
|
|
108
|
+
metadata: Record<string, unknown> | null;
|
|
109
|
+
errorMessage: string | null;
|
|
110
|
+
scheduledFor: Date | null;
|
|
111
|
+
sentAt: Date | null;
|
|
112
|
+
failedAt: Date | null;
|
|
113
|
+
createdAt: Date;
|
|
114
|
+
updatedAt: Date;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
};
|
|
118
|
+
export { createDefaultAttachmentFromDocument as createDefaultBookingDocumentAttachment };
|
|
119
|
+
//# sourceMappingURL=service-booking-documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-booking-documents.d.ts","sourceRoot":"","sources":["../src/service-booking-documents.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,qCAAqC,EACtC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,MAAM,MAAM,iCAAiC,GAAG,CAC9C,QAAQ,EAAE,yBAAyB,KAChC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAA;AAE3C,MAAM,WAAW,kCAAkC;IACjD,kBAAkB,CAAC,EAAE,iCAAiC,CAAA;CACvD;AA2BD,iBAAS,mCAAmC,CAC1C,QAAQ,EAAE,yBAAyB,GAClC,sBAAsB,GAAG,IAAI,CAU/B;AAwLD,eAAO,MAAM,mCAAmC;kCACV,kBAAkB,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;yCAkBnE,kBAAkB,cACV,mBAAmB,aACpB,MAAM,SACV,qCAAqC,YACnC,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6F9C,CAAA;AAED,OAAO,EAAE,mCAAmC,IAAI,sCAAsC,EAAE,CAAA"}
|