@voyantjs/checkout 0.3.0 → 0.3.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.
package/README.md CHANGED
@@ -16,9 +16,12 @@ This package sits above `@voyantjs/finance` and `@voyantjs/notifications`. It do
16
16
 
17
17
  - `POST /v1/checkout/bookings/:bookingId/collection-plan`
18
18
  - `POST /v1/checkout/bookings/:bookingId/initiate-collection`
19
+ - `GET /v1/admin/checkout/bookings/:bookingId/reminder-runs`
19
20
 
20
21
  ## Notes
21
22
 
22
23
  - payment-provider plugins like Netopia remain optional
23
24
  - email-provider choice remains app-owned
24
- - projects can override the default collection policy when mounting the routes
25
+ - projects can override the default collection policy when mounting checkout
26
+ - `createCheckoutHonoModule()` now mounts checkout through Voyant's module
27
+ system while preserving the legacy `/v1/checkout/*` public path
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { createCheckoutRoutes } from "./routes.js";
2
- export type { CheckoutCollectionPlan, CheckoutPolicyOptions, InitiatedCheckoutCollection, } from "./service.js";
3
- export { initiateCheckoutCollection, previewCheckoutCollection, resolvePaymentSessionTarget, } from "./service.js";
4
- export type { InitiateCheckoutCollectionInput, PreviewCheckoutCollectionInput, } from "./validation.js";
5
- export { checkoutCollectionMethodSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutPaymentSessionTargetSchema, initiateCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
1
+ export { checkoutModule, createCheckoutAdminRoutes, createCheckoutHonoModule, createCheckoutRoutes, } from "./routes.js";
2
+ export type { CheckoutCollectionPlan, CheckoutPolicyOptions, CheckoutReminderRunList, CheckoutReminderRunSummary, InitiatedCheckoutCollection, } from "./service.js";
3
+ export { initiateCheckoutCollection, listBookingReminderRuns, previewCheckoutCollection, resolvePaymentSessionTarget, } from "./service.js";
4
+ export type { CheckoutCollectionPlanRecord, CheckoutReminderRunListQuery, CheckoutReminderRunRecord, InitiateCheckoutCollectionInput, InitiatedCheckoutCollectionRecord, PreviewCheckoutCollectionInput, } from "./validation.js";
5
+ export { checkoutCollectionInvoiceSchema, checkoutCollectionMethodSchema, checkoutCollectionPlanSchema, checkoutCollectionScheduleSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutNotificationDeliverySchema, checkoutPaymentSessionTargetSchema, checkoutReminderRunListQuerySchema, checkoutReminderRunListResponseSchema, checkoutReminderRunSchema, initiateCheckoutCollectionSchema, initiatedCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,+BAA+B,EAC/B,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,EAClC,kCAAkC,EAClC,qCAAqC,EACrC,yBAAyB,EACzB,gCAAgC,EAChC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,iBAAiB,CAAA"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { createCheckoutRoutes } from "./routes.js";
2
- export { initiateCheckoutCollection, previewCheckoutCollection, resolvePaymentSessionTarget, } from "./service.js";
3
- export { checkoutCollectionMethodSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutPaymentSessionTargetSchema, initiateCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
1
+ export { checkoutModule, createCheckoutAdminRoutes, createCheckoutHonoModule, createCheckoutRoutes, } from "./routes.js";
2
+ export { initiateCheckoutCollection, listBookingReminderRuns, previewCheckoutCollection, resolvePaymentSessionTarget, } from "./service.js";
3
+ export { checkoutCollectionInvoiceSchema, checkoutCollectionMethodSchema, checkoutCollectionPlanSchema, checkoutCollectionScheduleSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutNotificationDeliverySchema, checkoutPaymentSessionTargetSchema, checkoutReminderRunListQuerySchema, checkoutReminderRunListResponseSchema, checkoutReminderRunSchema, initiateCheckoutCollectionSchema, initiatedCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
package/dist/routes.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { Module } from "@voyantjs/core";
2
+ import type { HonoModule } from "@voyantjs/hono/module";
1
3
  import type { NotificationProvider } from "@voyantjs/notifications";
2
4
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
3
5
  import { type CheckoutPolicyOptions } from "./service.js";
@@ -351,5 +353,46 @@ export declare function createCheckoutRoutes(options?: {
351
353
  };
352
354
  };
353
355
  }, "/", "/v1/checkout/bookings/:bookingId/initiate-collection">;
356
+ export declare function createCheckoutAdminRoutes(): import("hono/hono-base").HonoBase<Env, {
357
+ "/bookings/:bookingId/reminder-runs": {
358
+ $get: {
359
+ input: {
360
+ param: {
361
+ bookingId: string;
362
+ };
363
+ };
364
+ output: {
365
+ data: {
366
+ id: string;
367
+ reminderRuleId: string;
368
+ reminderRuleSlug: string | null;
369
+ reminderRuleName: string | null;
370
+ targetType: "booking_payment_schedule";
371
+ targetId: string;
372
+ bookingId: string | null;
373
+ paymentSessionId: string | null;
374
+ notificationDeliveryId: string | null;
375
+ status: "processing" | "sent" | "skipped" | "failed";
376
+ deliveryStatus: "pending" | "sent" | "failed" | "cancelled" | null;
377
+ channel: "email" | "sms" | null;
378
+ provider: string | null;
379
+ recipient: string | null;
380
+ scheduledFor: string;
381
+ processedAt: string;
382
+ errorMessage: string | null;
383
+ relativeDaysFromDueDate: number | null;
384
+ createdAt: string;
385
+ }[];
386
+ total: number;
387
+ limit: number;
388
+ offset: number;
389
+ };
390
+ outputFormat: "json";
391
+ status: import("hono/utils/http-status").ContentfulStatusCode;
392
+ };
393
+ };
394
+ }, "/", "/bookings/:bookingId/reminder-runs">;
395
+ export declare const checkoutModule: Module;
396
+ export declare function createCheckoutHonoModule(options?: Parameters<typeof createCheckoutRoutes>[0]): HonoModule;
354
397
  export {};
355
398
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EACL,KAAK,qBAA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B,EAI3B,MAAM,cAAc,CAAA;AAOrB,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,oBAAoB,CAClC,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,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;CACzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gEAkDP;AAED,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAQxC;AAED,eAAO,MAAM,cAAc,EAAE,MAE5B,CAAA;AAED,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACnD,UAAU,CAMZ"}
package/dist/routes.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createNotificationService } from "@voyantjs/notifications";
2
2
  import { Hono } from "hono";
3
- import { initiateCheckoutCollection, previewCheckoutCollection, } from "./service.js";
4
- import { initiateCheckoutCollectionSchema, previewCheckoutCollectionSchema } from "./validation.js";
3
+ import { initiateCheckoutCollection, listBookingReminderRuns, previewCheckoutCollection, } from "./service.js";
4
+ import { checkoutReminderRunListQuerySchema, initiateCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
5
5
  export function createCheckoutRoutes(options = {}) {
6
6
  return new Hono()
7
7
  .post("/v1/checkout/bookings/:bookingId/collection-plan", async (c) => {
@@ -35,3 +35,19 @@ export function createCheckoutRoutes(options = {}) {
35
35
  }
36
36
  });
37
37
  }
38
+ export function createCheckoutAdminRoutes() {
39
+ return new Hono().get("/bookings/:bookingId/reminder-runs", async (c) => {
40
+ const query = checkoutReminderRunListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
41
+ return c.json(await listBookingReminderRuns(c.get("db"), c.req.param("bookingId"), query));
42
+ });
43
+ }
44
+ export const checkoutModule = {
45
+ name: "checkout",
46
+ };
47
+ export function createCheckoutHonoModule(options) {
48
+ return {
49
+ module: checkoutModule,
50
+ routes: createCheckoutRoutes(options),
51
+ adminRoutes: createCheckoutAdminRoutes(),
52
+ };
53
+ }
package/dist/service.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { bookingPaymentSchedules, invoices, type PaymentSession } from "@voyantjs/finance";
2
2
  import type { NotificationDelivery, NotificationService } from "@voyantjs/notifications";
3
3
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
4
- import type { InitiateCheckoutCollectionInput, PreviewCheckoutCollectionInput } from "./validation.js";
4
+ import type { CheckoutReminderRunListQuery, InitiateCheckoutCollectionInput, PreviewCheckoutCollectionInput } from "./validation.js";
5
5
  export interface CheckoutPolicyOptions {
6
6
  defaultCardCollectionTarget?: "schedule" | "invoice";
7
7
  defaultReminderCardCollectionTarget?: "schedule" | "invoice";
@@ -36,7 +36,35 @@ export interface InitiatedCheckoutCollection {
36
36
  invoiceNotification: NotificationDelivery | null;
37
37
  paymentSessionNotification: NotificationDelivery | null;
38
38
  }
39
+ export interface CheckoutReminderRunSummary {
40
+ id: string;
41
+ reminderRuleId: string;
42
+ reminderRuleSlug: string | null;
43
+ reminderRuleName: string | null;
44
+ targetType: "booking_payment_schedule";
45
+ targetId: string;
46
+ bookingId: string | null;
47
+ paymentSessionId: string | null;
48
+ notificationDeliveryId: string | null;
49
+ status: "processing" | "sent" | "skipped" | "failed";
50
+ deliveryStatus: "pending" | "sent" | "failed" | "cancelled" | null;
51
+ channel: "email" | "sms" | null;
52
+ provider: string | null;
53
+ recipient: string | null;
54
+ scheduledFor: string;
55
+ processedAt: string;
56
+ errorMessage: string | null;
57
+ relativeDaysFromDueDate: number | null;
58
+ createdAt: string;
59
+ }
60
+ export interface CheckoutReminderRunList {
61
+ data: CheckoutReminderRunSummary[];
62
+ total: number;
63
+ limit: number;
64
+ offset: number;
65
+ }
39
66
  export declare function resolvePaymentSessionTarget(method: "card" | "bank_transfer", stage: "initial" | "reminder" | "manual", override: "schedule" | "invoice" | undefined, options: CheckoutPolicyOptions): "invoice" | "schedule";
40
67
  export declare function previewCheckoutCollection(db: PostgresJsDatabase, bookingId: string, input: PreviewCheckoutCollectionInput, options?: CheckoutPolicyOptions): Promise<CheckoutCollectionPlan | null>;
41
68
  export declare function initiateCheckoutCollection(db: PostgresJsDatabase, bookingId: string, input: InitiateCheckoutCollectionInput, options?: CheckoutPolicyOptions, dispatcher?: NotificationService): Promise<InitiatedCheckoutCollection | null>;
69
+ export declare function listBookingReminderRuns(db: PostgresJsDatabase, bookingId: string, query: CheckoutReminderRunListQuery): Promise<CheckoutReminderRunList>;
42
70
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAIvB,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAA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B,CACzC,MAAM,EAAE,MAAM,GAAG,eAAe,EAChC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,EACxC,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,EAC5C,OAAO,EAAE,qBAAqB,0BAM/B;AAwJD,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,8BAA8B,EACrC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAyDxC;AAkED,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,+BAA+B,EACtC,OAAO,GAAE,qBAA0B,EACnC,UAAU,CAAC,EAAE,mBAAmB,GAC/B,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CAiG7C;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAwElC"}
package/dist/service.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { bookingItems, bookingParticipants, bookings } from "@voyantjs/bookings";
2
2
  import { bookingPaymentSchedules, financeService, invoiceLineItems, invoiceNumberSeries, invoices, } from "@voyantjs/finance";
3
- import { notificationsService } from "@voyantjs/notifications";
4
- import { and, asc, desc, eq, gt, inArray } from "drizzle-orm";
3
+ import { notificationDeliveries, notificationReminderRules, notificationReminderRuns, notificationsService, } from "@voyantjs/notifications";
4
+ import { and, asc, desc, eq, gt, inArray, sql } from "drizzle-orm";
5
5
  const OUTSTANDING_SCHEDULE_STATUSES = ["pending", "due"];
6
6
  const OUTSTANDING_INVOICE_STATUSES = [
7
7
  "draft",
@@ -9,6 +9,9 @@ const OUTSTANDING_INVOICE_STATUSES = [
9
9
  "partially_paid",
10
10
  "overdue",
11
11
  ];
12
+ function normalizeRequiredDateTime(value) {
13
+ return value instanceof Date ? value.toISOString() : value;
14
+ }
12
15
  function defaultPaymentPlan(options) {
13
16
  return {
14
17
  depositMode: options.defaultPaymentPlan?.depositMode ?? "percentage",
@@ -281,3 +284,65 @@ export async function initiateCheckoutCollection(db, bookingId, input, options =
281
284
  paymentSessionNotification,
282
285
  };
283
286
  }
287
+ export async function listBookingReminderRuns(db, bookingId, query) {
288
+ const where = and(eq(notificationReminderRuns.bookingId, bookingId), ...(query.status ? [eq(notificationReminderRuns.status, query.status)] : []));
289
+ const [rows, countResult] = await Promise.all([
290
+ db
291
+ .select({
292
+ id: notificationReminderRuns.id,
293
+ reminderRuleId: notificationReminderRuns.reminderRuleId,
294
+ targetType: notificationReminderRuns.targetType,
295
+ targetId: notificationReminderRuns.targetId,
296
+ bookingId: notificationReminderRuns.bookingId,
297
+ paymentSessionId: notificationReminderRuns.paymentSessionId,
298
+ notificationDeliveryId: notificationReminderRuns.notificationDeliveryId,
299
+ status: notificationReminderRuns.status,
300
+ recipient: notificationReminderRuns.recipient,
301
+ scheduledFor: notificationReminderRuns.scheduledFor,
302
+ processedAt: notificationReminderRuns.processedAt,
303
+ errorMessage: notificationReminderRuns.errorMessage,
304
+ createdAt: notificationReminderRuns.createdAt,
305
+ reminderRuleSlug: notificationReminderRules.slug,
306
+ reminderRuleName: notificationReminderRules.name,
307
+ relativeDaysFromDueDate: notificationReminderRules.relativeDaysFromDueDate,
308
+ channel: notificationReminderRules.channel,
309
+ ruleProvider: notificationReminderRules.provider,
310
+ deliveryStatus: notificationDeliveries.status,
311
+ deliveryProvider: notificationDeliveries.provider,
312
+ })
313
+ .from(notificationReminderRuns)
314
+ .leftJoin(notificationReminderRules, eq(notificationReminderRules.id, notificationReminderRuns.reminderRuleId))
315
+ .leftJoin(notificationDeliveries, eq(notificationDeliveries.id, notificationReminderRuns.notificationDeliveryId))
316
+ .where(where)
317
+ .orderBy(desc(notificationReminderRuns.createdAt))
318
+ .limit(query.limit)
319
+ .offset(query.offset),
320
+ db.select({ count: sql `count(*)::int` }).from(notificationReminderRuns).where(where),
321
+ ]);
322
+ return {
323
+ data: rows.map((row) => ({
324
+ id: row.id,
325
+ reminderRuleId: row.reminderRuleId,
326
+ reminderRuleSlug: row.reminderRuleSlug ?? null,
327
+ reminderRuleName: row.reminderRuleName ?? null,
328
+ targetType: row.targetType,
329
+ targetId: row.targetId,
330
+ bookingId: row.bookingId ?? null,
331
+ paymentSessionId: row.paymentSessionId ?? null,
332
+ notificationDeliveryId: row.notificationDeliveryId ?? null,
333
+ status: row.status,
334
+ deliveryStatus: row.deliveryStatus ?? null,
335
+ channel: row.channel ?? null,
336
+ provider: row.deliveryProvider ?? row.ruleProvider ?? null,
337
+ recipient: row.recipient ?? null,
338
+ scheduledFor: normalizeRequiredDateTime(row.scheduledFor),
339
+ processedAt: normalizeRequiredDateTime(row.processedAt),
340
+ errorMessage: row.errorMessage ?? null,
341
+ relativeDaysFromDueDate: row.relativeDaysFromDueDate ?? null,
342
+ createdAt: normalizeRequiredDateTime(row.createdAt),
343
+ })),
344
+ total: countResult[0]?.count ?? 0,
345
+ limit: query.limit,
346
+ offset: query.offset,
347
+ };
348
+ }
@@ -188,6 +188,371 @@ export declare const initiateCheckoutCollectionSchema: z.ZodObject<{
188
188
  }, z.core.$strip>>;
189
189
  notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
190
190
  }, z.core.$strip>;
191
+ export declare const checkoutCollectionScheduleSchema: z.ZodObject<{
192
+ id: z.ZodString;
193
+ bookingId: z.ZodString;
194
+ bookingItemId: z.ZodNullable<z.ZodString>;
195
+ scheduleType: z.ZodString;
196
+ status: z.ZodString;
197
+ dueDate: z.ZodString;
198
+ currency: z.ZodString;
199
+ amountCents: z.ZodNumber;
200
+ notes: z.ZodNullable<z.ZodString>;
201
+ }, z.core.$strip>;
202
+ export declare const checkoutCollectionInvoiceSchema: z.ZodObject<{
203
+ id: z.ZodString;
204
+ invoiceNumber: z.ZodString;
205
+ invoiceType: z.ZodString;
206
+ bookingId: z.ZodString;
207
+ personId: z.ZodNullable<z.ZodString>;
208
+ organizationId: z.ZodNullable<z.ZodString>;
209
+ status: z.ZodString;
210
+ currency: z.ZodString;
211
+ totalCents: z.ZodNumber;
212
+ paidCents: z.ZodNumber;
213
+ balanceDueCents: z.ZodNumber;
214
+ issueDate: z.ZodString;
215
+ dueDate: z.ZodString;
216
+ notes: z.ZodNullable<z.ZodString>;
217
+ createdAt: z.ZodString;
218
+ updatedAt: z.ZodString;
219
+ }, z.core.$strip>;
220
+ export declare const checkoutNotificationDeliverySchema: z.ZodObject<{
221
+ id: z.ZodString;
222
+ templateSlug: z.ZodNullable<z.ZodString>;
223
+ channel: z.ZodEnum<{
224
+ email: "email";
225
+ sms: "sms";
226
+ }>;
227
+ provider: z.ZodString;
228
+ status: z.ZodEnum<{
229
+ cancelled: "cancelled";
230
+ pending: "pending";
231
+ failed: "failed";
232
+ sent: "sent";
233
+ }>;
234
+ toAddress: z.ZodString;
235
+ subject: z.ZodNullable<z.ZodString>;
236
+ sentAt: z.ZodNullable<z.ZodString>;
237
+ failedAt: z.ZodNullable<z.ZodString>;
238
+ errorMessage: z.ZodNullable<z.ZodString>;
239
+ }, z.core.$strip>;
240
+ export declare const checkoutCollectionPlanSchema: z.ZodObject<{
241
+ bookingId: z.ZodString;
242
+ method: z.ZodEnum<{
243
+ bank_transfer: "bank_transfer";
244
+ card: "card";
245
+ }>;
246
+ stage: z.ZodEnum<{
247
+ manual: "manual";
248
+ initial: "initial";
249
+ reminder: "reminder";
250
+ }>;
251
+ paymentSessionTarget: z.ZodNullable<z.ZodEnum<{
252
+ invoice: "invoice";
253
+ schedule: "schedule";
254
+ }>>;
255
+ documentType: z.ZodNullable<z.ZodEnum<{
256
+ invoice: "invoice";
257
+ proforma: "proforma";
258
+ }>>;
259
+ willCreateDefaultPaymentPlan: z.ZodBoolean;
260
+ selectedSchedule: z.ZodNullable<z.ZodObject<{
261
+ id: z.ZodString;
262
+ bookingId: z.ZodString;
263
+ bookingItemId: z.ZodNullable<z.ZodString>;
264
+ scheduleType: z.ZodString;
265
+ status: z.ZodString;
266
+ dueDate: z.ZodString;
267
+ currency: z.ZodString;
268
+ amountCents: z.ZodNumber;
269
+ notes: z.ZodNullable<z.ZodString>;
270
+ }, z.core.$strip>>;
271
+ selectedInvoice: z.ZodNullable<z.ZodObject<{
272
+ id: z.ZodString;
273
+ invoiceNumber: z.ZodString;
274
+ invoiceType: z.ZodString;
275
+ bookingId: z.ZodString;
276
+ personId: z.ZodNullable<z.ZodString>;
277
+ organizationId: z.ZodNullable<z.ZodString>;
278
+ status: z.ZodString;
279
+ currency: z.ZodString;
280
+ totalCents: z.ZodNumber;
281
+ paidCents: z.ZodNumber;
282
+ balanceDueCents: z.ZodNumber;
283
+ issueDate: z.ZodString;
284
+ dueDate: z.ZodString;
285
+ notes: z.ZodNullable<z.ZodString>;
286
+ createdAt: z.ZodString;
287
+ updatedAt: z.ZodString;
288
+ }, z.core.$strip>>;
289
+ amountCents: z.ZodNumber;
290
+ currency: z.ZodString;
291
+ recommendedAction: z.ZodEnum<{
292
+ none: "none";
293
+ create_bank_transfer_document: "create_bank_transfer_document";
294
+ create_payment_session: "create_payment_session";
295
+ create_invoice_then_payment_session: "create_invoice_then_payment_session";
296
+ }>;
297
+ }, z.core.$strip>;
298
+ export declare const initiatedCheckoutCollectionSchema: z.ZodObject<{
299
+ plan: z.ZodObject<{
300
+ bookingId: z.ZodString;
301
+ method: z.ZodEnum<{
302
+ bank_transfer: "bank_transfer";
303
+ card: "card";
304
+ }>;
305
+ stage: z.ZodEnum<{
306
+ manual: "manual";
307
+ initial: "initial";
308
+ reminder: "reminder";
309
+ }>;
310
+ paymentSessionTarget: z.ZodNullable<z.ZodEnum<{
311
+ invoice: "invoice";
312
+ schedule: "schedule";
313
+ }>>;
314
+ documentType: z.ZodNullable<z.ZodEnum<{
315
+ invoice: "invoice";
316
+ proforma: "proforma";
317
+ }>>;
318
+ willCreateDefaultPaymentPlan: z.ZodBoolean;
319
+ selectedSchedule: z.ZodNullable<z.ZodObject<{
320
+ id: z.ZodString;
321
+ bookingId: z.ZodString;
322
+ bookingItemId: z.ZodNullable<z.ZodString>;
323
+ scheduleType: z.ZodString;
324
+ status: z.ZodString;
325
+ dueDate: z.ZodString;
326
+ currency: z.ZodString;
327
+ amountCents: z.ZodNumber;
328
+ notes: z.ZodNullable<z.ZodString>;
329
+ }, z.core.$strip>>;
330
+ selectedInvoice: z.ZodNullable<z.ZodObject<{
331
+ id: z.ZodString;
332
+ invoiceNumber: z.ZodString;
333
+ invoiceType: z.ZodString;
334
+ bookingId: z.ZodString;
335
+ personId: z.ZodNullable<z.ZodString>;
336
+ organizationId: z.ZodNullable<z.ZodString>;
337
+ status: z.ZodString;
338
+ currency: z.ZodString;
339
+ totalCents: z.ZodNumber;
340
+ paidCents: z.ZodNumber;
341
+ balanceDueCents: z.ZodNumber;
342
+ issueDate: z.ZodString;
343
+ dueDate: z.ZodString;
344
+ notes: z.ZodNullable<z.ZodString>;
345
+ createdAt: z.ZodString;
346
+ updatedAt: z.ZodString;
347
+ }, z.core.$strip>>;
348
+ amountCents: z.ZodNumber;
349
+ currency: z.ZodString;
350
+ recommendedAction: z.ZodEnum<{
351
+ none: "none";
352
+ create_bank_transfer_document: "create_bank_transfer_document";
353
+ create_payment_session: "create_payment_session";
354
+ create_invoice_then_payment_session: "create_invoice_then_payment_session";
355
+ }>;
356
+ }, z.core.$strip>;
357
+ invoice: z.ZodNullable<z.ZodObject<{
358
+ id: z.ZodString;
359
+ invoiceNumber: z.ZodString;
360
+ invoiceType: z.ZodString;
361
+ bookingId: z.ZodString;
362
+ personId: z.ZodNullable<z.ZodString>;
363
+ organizationId: z.ZodNullable<z.ZodString>;
364
+ status: z.ZodString;
365
+ currency: z.ZodString;
366
+ totalCents: z.ZodNumber;
367
+ paidCents: z.ZodNumber;
368
+ balanceDueCents: z.ZodNumber;
369
+ issueDate: z.ZodString;
370
+ dueDate: z.ZodString;
371
+ notes: z.ZodNullable<z.ZodString>;
372
+ createdAt: z.ZodString;
373
+ updatedAt: z.ZodString;
374
+ }, z.core.$strip>>;
375
+ paymentSession: z.ZodNullable<z.ZodObject<{
376
+ id: z.ZodString;
377
+ targetType: z.ZodEnum<{
378
+ other: "other";
379
+ booking: "booking";
380
+ order: "order";
381
+ invoice: "invoice";
382
+ booking_payment_schedule: "booking_payment_schedule";
383
+ booking_guarantee: "booking_guarantee";
384
+ }>;
385
+ targetId: z.ZodNullable<z.ZodString>;
386
+ bookingId: z.ZodNullable<z.ZodString>;
387
+ invoiceId: z.ZodNullable<z.ZodString>;
388
+ bookingPaymentScheduleId: z.ZodNullable<z.ZodString>;
389
+ bookingGuaranteeId: z.ZodNullable<z.ZodString>;
390
+ status: z.ZodEnum<{
391
+ expired: "expired";
392
+ cancelled: "cancelled";
393
+ pending: "pending";
394
+ failed: "failed";
395
+ paid: "paid";
396
+ requires_redirect: "requires_redirect";
397
+ processing: "processing";
398
+ authorized: "authorized";
399
+ }>;
400
+ provider: z.ZodNullable<z.ZodString>;
401
+ providerSessionId: z.ZodNullable<z.ZodString>;
402
+ providerPaymentId: z.ZodNullable<z.ZodString>;
403
+ externalReference: z.ZodNullable<z.ZodString>;
404
+ clientReference: z.ZodNullable<z.ZodString>;
405
+ currency: z.ZodString;
406
+ amountCents: z.ZodNumber;
407
+ paymentMethod: z.ZodNullable<z.ZodEnum<{
408
+ other: "other";
409
+ voucher: "voucher";
410
+ wallet: "wallet";
411
+ bank_transfer: "bank_transfer";
412
+ credit_card: "credit_card";
413
+ debit_card: "debit_card";
414
+ cash: "cash";
415
+ cheque: "cheque";
416
+ direct_bill: "direct_bill";
417
+ }>>;
418
+ payerEmail: z.ZodNullable<z.ZodString>;
419
+ payerName: z.ZodNullable<z.ZodString>;
420
+ redirectUrl: z.ZodNullable<z.ZodString>;
421
+ returnUrl: z.ZodNullable<z.ZodString>;
422
+ cancelUrl: z.ZodNullable<z.ZodString>;
423
+ expiresAt: z.ZodNullable<z.ZodString>;
424
+ completedAt: z.ZodNullable<z.ZodString>;
425
+ failureCode: z.ZodNullable<z.ZodString>;
426
+ failureMessage: z.ZodNullable<z.ZodString>;
427
+ }, z.core.$strip>>;
428
+ invoiceNotification: z.ZodNullable<z.ZodObject<{
429
+ id: z.ZodString;
430
+ templateSlug: z.ZodNullable<z.ZodString>;
431
+ channel: z.ZodEnum<{
432
+ email: "email";
433
+ sms: "sms";
434
+ }>;
435
+ provider: z.ZodString;
436
+ status: z.ZodEnum<{
437
+ cancelled: "cancelled";
438
+ pending: "pending";
439
+ failed: "failed";
440
+ sent: "sent";
441
+ }>;
442
+ toAddress: z.ZodString;
443
+ subject: z.ZodNullable<z.ZodString>;
444
+ sentAt: z.ZodNullable<z.ZodString>;
445
+ failedAt: z.ZodNullable<z.ZodString>;
446
+ errorMessage: z.ZodNullable<z.ZodString>;
447
+ }, z.core.$strip>>;
448
+ paymentSessionNotification: z.ZodNullable<z.ZodObject<{
449
+ id: z.ZodString;
450
+ templateSlug: z.ZodNullable<z.ZodString>;
451
+ channel: z.ZodEnum<{
452
+ email: "email";
453
+ sms: "sms";
454
+ }>;
455
+ provider: z.ZodString;
456
+ status: z.ZodEnum<{
457
+ cancelled: "cancelled";
458
+ pending: "pending";
459
+ failed: "failed";
460
+ sent: "sent";
461
+ }>;
462
+ toAddress: z.ZodString;
463
+ subject: z.ZodNullable<z.ZodString>;
464
+ sentAt: z.ZodNullable<z.ZodString>;
465
+ failedAt: z.ZodNullable<z.ZodString>;
466
+ errorMessage: z.ZodNullable<z.ZodString>;
467
+ }, z.core.$strip>>;
468
+ }, z.core.$strip>;
469
+ export declare const checkoutReminderRunListQuerySchema: z.ZodObject<{
470
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
471
+ offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
472
+ status: z.ZodOptional<z.ZodEnum<{
473
+ failed: "failed";
474
+ sent: "sent";
475
+ processing: "processing";
476
+ skipped: "skipped";
477
+ }>>;
478
+ }, z.core.$strip>;
479
+ export declare const checkoutReminderRunSchema: z.ZodObject<{
480
+ id: z.ZodString;
481
+ reminderRuleId: z.ZodString;
482
+ reminderRuleSlug: z.ZodNullable<z.ZodString>;
483
+ reminderRuleName: z.ZodNullable<z.ZodString>;
484
+ targetType: z.ZodLiteral<"booking_payment_schedule">;
485
+ targetId: z.ZodString;
486
+ bookingId: z.ZodNullable<z.ZodString>;
487
+ paymentSessionId: z.ZodNullable<z.ZodString>;
488
+ notificationDeliveryId: z.ZodNullable<z.ZodString>;
489
+ status: z.ZodEnum<{
490
+ failed: "failed";
491
+ sent: "sent";
492
+ processing: "processing";
493
+ skipped: "skipped";
494
+ }>;
495
+ deliveryStatus: z.ZodNullable<z.ZodEnum<{
496
+ cancelled: "cancelled";
497
+ pending: "pending";
498
+ failed: "failed";
499
+ sent: "sent";
500
+ }>>;
501
+ channel: z.ZodNullable<z.ZodEnum<{
502
+ email: "email";
503
+ sms: "sms";
504
+ }>>;
505
+ provider: z.ZodNullable<z.ZodString>;
506
+ recipient: z.ZodNullable<z.ZodString>;
507
+ scheduledFor: z.ZodString;
508
+ processedAt: z.ZodString;
509
+ errorMessage: z.ZodNullable<z.ZodString>;
510
+ relativeDaysFromDueDate: z.ZodNullable<z.ZodNumber>;
511
+ createdAt: z.ZodString;
512
+ }, z.core.$strip>;
513
+ export declare const checkoutReminderRunListResponseSchema: z.ZodObject<{
514
+ data: z.ZodArray<z.ZodObject<{
515
+ id: z.ZodString;
516
+ reminderRuleId: z.ZodString;
517
+ reminderRuleSlug: z.ZodNullable<z.ZodString>;
518
+ reminderRuleName: z.ZodNullable<z.ZodString>;
519
+ targetType: z.ZodLiteral<"booking_payment_schedule">;
520
+ targetId: z.ZodString;
521
+ bookingId: z.ZodNullable<z.ZodString>;
522
+ paymentSessionId: z.ZodNullable<z.ZodString>;
523
+ notificationDeliveryId: z.ZodNullable<z.ZodString>;
524
+ status: z.ZodEnum<{
525
+ failed: "failed";
526
+ sent: "sent";
527
+ processing: "processing";
528
+ skipped: "skipped";
529
+ }>;
530
+ deliveryStatus: z.ZodNullable<z.ZodEnum<{
531
+ cancelled: "cancelled";
532
+ pending: "pending";
533
+ failed: "failed";
534
+ sent: "sent";
535
+ }>>;
536
+ channel: z.ZodNullable<z.ZodEnum<{
537
+ email: "email";
538
+ sms: "sms";
539
+ }>>;
540
+ provider: z.ZodNullable<z.ZodString>;
541
+ recipient: z.ZodNullable<z.ZodString>;
542
+ scheduledFor: z.ZodString;
543
+ processedAt: z.ZodString;
544
+ errorMessage: z.ZodNullable<z.ZodString>;
545
+ relativeDaysFromDueDate: z.ZodNullable<z.ZodNumber>;
546
+ createdAt: z.ZodString;
547
+ }, z.core.$strip>>;
548
+ total: z.ZodNumber;
549
+ limit: z.ZodNumber;
550
+ offset: z.ZodNumber;
551
+ }, z.core.$strip>;
191
552
  export type PreviewCheckoutCollectionInput = z.infer<typeof previewCheckoutCollectionSchema>;
192
553
  export type InitiateCheckoutCollectionInput = z.infer<typeof initiateCheckoutCollectionSchema>;
554
+ export type CheckoutCollectionPlanRecord = z.infer<typeof checkoutCollectionPlanSchema>;
555
+ export type InitiatedCheckoutCollectionRecord = z.infer<typeof initiatedCheckoutCollectionSchema>;
556
+ export type CheckoutReminderRunListQuery = z.infer<typeof checkoutReminderRunListQuerySchema>;
557
+ export type CheckoutReminderRunRecord = z.infer<typeof checkoutReminderRunSchema>;
193
558
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,8BAA8B;;;EAAoC,CAAA;AAC/E,eAAO,MAAM,6BAA6B;;;;EAA4C,CAAA;AACtF,eAAO,MAAM,kCAAkC;;;EAAkC,CAAA;AACjF,eAAO,MAAM,iCAAiC;;;EAAkC,CAAA;AAIhF,eAAO,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBvC,CAAA;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM5C,CAAA;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;iBAE7C,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoBpC,CAAA;AAEF,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAA;AAEF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAC5F,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAC9F,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AACvF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AACjG,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC7F,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA"}
@@ -1,11 +1,15 @@
1
- import { applyDefaultBookingPaymentPlanSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, } from "@voyantjs/finance";
2
- import { sendInvoiceNotificationSchema, sendPaymentSessionNotificationSchema, } from "@voyantjs/notifications";
1
+ import { applyDefaultBookingPaymentPlanSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, publicPaymentSessionSchema, } from "@voyantjs/finance";
2
+ import { notificationChannelSchema, notificationDeliveryStatusSchema, notificationReminderRunStatusSchema, sendInvoiceNotificationSchema, sendPaymentSessionNotificationSchema, } from "@voyantjs/notifications";
3
3
  import { z } from "zod";
4
4
  export const checkoutCollectionMethodSchema = z.enum(["card", "bank_transfer"]);
5
5
  export const checkoutCollectionStageSchema = z.enum(["initial", "reminder", "manual"]);
6
6
  export const checkoutPaymentSessionTargetSchema = z.enum(["schedule", "invoice"]);
7
7
  export const checkoutInvoiceDocumentTypeSchema = z.enum(["proforma", "invoice"]);
8
8
  const planOverrideSchema = applyDefaultBookingPaymentPlanSchema.partial();
9
+ const paginationSchema = z.object({
10
+ limit: z.coerce.number().int().min(1).max(100).default(20),
11
+ offset: z.coerce.number().int().min(0).default(0),
12
+ });
9
13
  export const previewCheckoutCollectionSchema = z.object({
10
14
  method: checkoutCollectionMethodSchema,
11
15
  stage: checkoutCollectionStageSchema.default("initial"),
@@ -23,3 +27,99 @@ export const initiateCheckoutCollectionSchema = previewCheckoutCollectionSchema.
23
27
  invoiceNotification: sendInvoiceNotificationSchema.optional(),
24
28
  notes: z.string().optional().nullable(),
25
29
  });
30
+ export const checkoutCollectionScheduleSchema = z.object({
31
+ id: z.string(),
32
+ bookingId: z.string(),
33
+ bookingItemId: z.string().nullable(),
34
+ scheduleType: z.string(),
35
+ status: z.string(),
36
+ dueDate: z.string(),
37
+ currency: z.string(),
38
+ amountCents: z.number().int(),
39
+ notes: z.string().nullable(),
40
+ });
41
+ export const checkoutCollectionInvoiceSchema = z.object({
42
+ id: z.string(),
43
+ invoiceNumber: z.string(),
44
+ invoiceType: z.string(),
45
+ bookingId: z.string(),
46
+ personId: z.string().nullable(),
47
+ organizationId: z.string().nullable(),
48
+ status: z.string(),
49
+ currency: z.string(),
50
+ totalCents: z.number().int(),
51
+ paidCents: z.number().int(),
52
+ balanceDueCents: z.number().int(),
53
+ issueDate: z.string(),
54
+ dueDate: z.string(),
55
+ notes: z.string().nullable(),
56
+ createdAt: z.string(),
57
+ updatedAt: z.string(),
58
+ });
59
+ export const checkoutNotificationDeliverySchema = z.object({
60
+ id: z.string(),
61
+ templateSlug: z.string().nullable(),
62
+ channel: notificationChannelSchema,
63
+ provider: z.string(),
64
+ status: notificationDeliveryStatusSchema,
65
+ toAddress: z.string(),
66
+ subject: z.string().nullable(),
67
+ sentAt: z.string().nullable(),
68
+ failedAt: z.string().nullable(),
69
+ errorMessage: z.string().nullable(),
70
+ });
71
+ export const checkoutCollectionPlanSchema = z.object({
72
+ bookingId: z.string(),
73
+ method: checkoutCollectionMethodSchema,
74
+ stage: checkoutCollectionStageSchema,
75
+ paymentSessionTarget: checkoutPaymentSessionTargetSchema.nullable(),
76
+ documentType: checkoutInvoiceDocumentTypeSchema.nullable(),
77
+ willCreateDefaultPaymentPlan: z.boolean(),
78
+ selectedSchedule: checkoutCollectionScheduleSchema.nullable(),
79
+ selectedInvoice: checkoutCollectionInvoiceSchema.nullable(),
80
+ amountCents: z.number().int(),
81
+ currency: z.string(),
82
+ recommendedAction: z.enum([
83
+ "create_bank_transfer_document",
84
+ "create_payment_session",
85
+ "create_invoice_then_payment_session",
86
+ "none",
87
+ ]),
88
+ });
89
+ export const initiatedCheckoutCollectionSchema = z.object({
90
+ plan: checkoutCollectionPlanSchema,
91
+ invoice: checkoutCollectionInvoiceSchema.nullable(),
92
+ paymentSession: publicPaymentSessionSchema.nullable(),
93
+ invoiceNotification: checkoutNotificationDeliverySchema.nullable(),
94
+ paymentSessionNotification: checkoutNotificationDeliverySchema.nullable(),
95
+ });
96
+ export const checkoutReminderRunListQuerySchema = paginationSchema.extend({
97
+ status: notificationReminderRunStatusSchema.optional(),
98
+ });
99
+ export const checkoutReminderRunSchema = z.object({
100
+ id: z.string(),
101
+ reminderRuleId: z.string(),
102
+ reminderRuleSlug: z.string().nullable(),
103
+ reminderRuleName: z.string().nullable(),
104
+ targetType: z.literal("booking_payment_schedule"),
105
+ targetId: z.string(),
106
+ bookingId: z.string().nullable(),
107
+ paymentSessionId: z.string().nullable(),
108
+ notificationDeliveryId: z.string().nullable(),
109
+ status: notificationReminderRunStatusSchema,
110
+ deliveryStatus: notificationDeliveryStatusSchema.nullable(),
111
+ channel: notificationChannelSchema.nullable(),
112
+ provider: z.string().nullable(),
113
+ recipient: z.string().nullable(),
114
+ scheduledFor: z.string(),
115
+ processedAt: z.string(),
116
+ errorMessage: z.string().nullable(),
117
+ relativeDaysFromDueDate: z.number().int().nullable(),
118
+ createdAt: z.string(),
119
+ });
120
+ export const checkoutReminderRunListResponseSchema = z.object({
121
+ data: z.array(checkoutReminderRunSchema),
122
+ total: z.number().int(),
123
+ limit: z.number().int(),
124
+ offset: z.number().int(),
125
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/checkout",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,11 +25,11 @@
25
25
  "drizzle-orm": "^0.45.2",
26
26
  "hono": "^4.12.10",
27
27
  "zod": "^4.3.6",
28
- "@voyantjs/bookings": "0.3.0",
29
- "@voyantjs/core": "0.3.0",
30
- "@voyantjs/finance": "0.3.0",
31
- "@voyantjs/hono": "0.3.0",
32
- "@voyantjs/notifications": "0.3.0"
28
+ "@voyantjs/bookings": "0.3.1",
29
+ "@voyantjs/core": "0.3.1",
30
+ "@voyantjs/finance": "0.3.1",
31
+ "@voyantjs/hono": "0.3.1",
32
+ "@voyantjs/notifications": "0.3.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "typescript": "^6.0.2",