@voyantjs/checkout 0.24.1 → 0.24.3
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/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/routes.d.ts +1290 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +96 -0
- package/dist/service.d.ts +117 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +497 -0
- package/dist/validation.d.ts +1041 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +172 -0
- package/package.json +7 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,8BAA8B;;;EAAoC,CAAA;AAC/E,eAAO,MAAM,6BAA6B;;;;EAA4C,CAAA;AACtF,eAAO,MAAM,8BAA8B;;;;EAA2C,CAAA;AACtF,eAAO,MAAM,kCAAkC;;;EAAkC,CAAA;AACjF,eAAO,MAAM,iCAAiC;;;EAAkC,CAAA;AAChF,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAA;AAQF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAS1C,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ3C,CAAA;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,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,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAChG,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,oCAAoC,GAAG,CAAC,CAAC,KAAK,CACxD,OAAO,oCAAoC,CAC5C,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AACzF,MAAM,MAAM,sCAAsC,GAAG,CAAC,CAAC,KAAK,CAC1D,OAAO,sCAAsC,CAC9C,CAAA;AACD,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"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { applyDefaultBookingPaymentPlanSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, publicPaymentSessionSchema, } from "@voyantjs/finance";
|
|
2
|
+
import { notificationChannelSchema, notificationDeliveryStatusSchema, notificationReminderRunStatusSchema, notificationReminderTargetTypeSchema, sendInvoiceNotificationSchema, sendPaymentSessionNotificationSchema, } from "@voyantjs/notifications";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
export const checkoutCollectionMethodSchema = z.enum(["card", "bank_transfer"]);
|
|
5
|
+
export const checkoutCollectionStageSchema = z.enum(["initial", "reminder", "manual"]);
|
|
6
|
+
export const checkoutCollectionIntentSchema = z.enum(["deposit", "balance", "custom"]);
|
|
7
|
+
export const checkoutPaymentSessionTargetSchema = z.enum(["schedule", "invoice"]);
|
|
8
|
+
export const checkoutInvoiceDocumentTypeSchema = z.enum(["proforma", "invoice"]);
|
|
9
|
+
export const checkoutProviderStartInputSchema = z.object({
|
|
10
|
+
provider: z.string().min(1).max(255),
|
|
11
|
+
payload: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
12
|
+
});
|
|
13
|
+
const planOverrideSchema = applyDefaultBookingPaymentPlanSchema.partial();
|
|
14
|
+
const paginationSchema = z.object({
|
|
15
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
16
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
17
|
+
});
|
|
18
|
+
export const previewCheckoutCollectionSchema = z.object({
|
|
19
|
+
method: checkoutCollectionMethodSchema,
|
|
20
|
+
stage: checkoutCollectionStageSchema.default("initial"),
|
|
21
|
+
scheduleId: z.string().optional(),
|
|
22
|
+
invoiceId: z.string().optional(),
|
|
23
|
+
amountCents: z.number().int().min(1).optional(),
|
|
24
|
+
ensureDefaultPaymentPlan: z.boolean().default(true),
|
|
25
|
+
paymentSessionTarget: checkoutPaymentSessionTargetSchema.optional(),
|
|
26
|
+
paymentPlan: planOverrideSchema.optional(),
|
|
27
|
+
});
|
|
28
|
+
export const initiateCheckoutCollectionSchema = previewCheckoutCollectionSchema.extend({
|
|
29
|
+
paymentSession: z
|
|
30
|
+
.union([createPaymentSessionFromScheduleSchema, createPaymentSessionFromInvoiceSchema])
|
|
31
|
+
.optional(),
|
|
32
|
+
paymentSessionNotification: sendPaymentSessionNotificationSchema.optional(),
|
|
33
|
+
invoiceNotification: sendInvoiceNotificationSchema.optional(),
|
|
34
|
+
startProvider: checkoutProviderStartInputSchema.optional(),
|
|
35
|
+
notes: z.string().optional().nullable(),
|
|
36
|
+
});
|
|
37
|
+
export const bootstrapCheckoutCollectionSchema = initiateCheckoutCollectionSchema
|
|
38
|
+
.extend({
|
|
39
|
+
bookingId: z.string().min(1).optional(),
|
|
40
|
+
sessionId: z.string().min(1).optional(),
|
|
41
|
+
intent: checkoutCollectionIntentSchema.optional(),
|
|
42
|
+
})
|
|
43
|
+
.refine((value) => Boolean(value.bookingId || value.sessionId), {
|
|
44
|
+
message: "Provide a bookingId or sessionId",
|
|
45
|
+
path: ["bookingId"],
|
|
46
|
+
});
|
|
47
|
+
export const checkoutCollectionScheduleSchema = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
bookingId: z.string(),
|
|
50
|
+
bookingItemId: z.string().nullable(),
|
|
51
|
+
scheduleType: z.string(),
|
|
52
|
+
status: z.string(),
|
|
53
|
+
dueDate: z.string(),
|
|
54
|
+
currency: z.string(),
|
|
55
|
+
amountCents: z.number().int(),
|
|
56
|
+
notes: z.string().nullable(),
|
|
57
|
+
});
|
|
58
|
+
export const checkoutCollectionInvoiceSchema = z.object({
|
|
59
|
+
id: z.string(),
|
|
60
|
+
invoiceNumber: z.string(),
|
|
61
|
+
invoiceType: z.string(),
|
|
62
|
+
bookingId: z.string(),
|
|
63
|
+
personId: z.string().nullable(),
|
|
64
|
+
organizationId: z.string().nullable(),
|
|
65
|
+
status: z.string(),
|
|
66
|
+
currency: z.string(),
|
|
67
|
+
totalCents: z.number().int(),
|
|
68
|
+
paidCents: z.number().int(),
|
|
69
|
+
balanceDueCents: z.number().int(),
|
|
70
|
+
issueDate: z.string(),
|
|
71
|
+
dueDate: z.string(),
|
|
72
|
+
notes: z.string().nullable(),
|
|
73
|
+
createdAt: z.string(),
|
|
74
|
+
updatedAt: z.string(),
|
|
75
|
+
});
|
|
76
|
+
export const checkoutNotificationDeliverySchema = z.object({
|
|
77
|
+
id: z.string(),
|
|
78
|
+
templateSlug: z.string().nullable(),
|
|
79
|
+
channel: notificationChannelSchema,
|
|
80
|
+
provider: z.string(),
|
|
81
|
+
status: notificationDeliveryStatusSchema,
|
|
82
|
+
toAddress: z.string(),
|
|
83
|
+
subject: z.string().nullable(),
|
|
84
|
+
sentAt: z.string().nullable(),
|
|
85
|
+
failedAt: z.string().nullable(),
|
|
86
|
+
errorMessage: z.string().nullable(),
|
|
87
|
+
});
|
|
88
|
+
export const checkoutBankTransferInstructionsSchema = z.object({
|
|
89
|
+
provider: z.string().nullable(),
|
|
90
|
+
invoiceId: z.string(),
|
|
91
|
+
invoiceNumber: z.string(),
|
|
92
|
+
documentType: checkoutInvoiceDocumentTypeSchema,
|
|
93
|
+
amountCents: z.number().int(),
|
|
94
|
+
currency: z.string(),
|
|
95
|
+
dueDate: z.string().nullable(),
|
|
96
|
+
beneficiary: z.string(),
|
|
97
|
+
iban: z.string(),
|
|
98
|
+
bankName: z.string().nullable(),
|
|
99
|
+
notes: z.string().nullable(),
|
|
100
|
+
});
|
|
101
|
+
export const checkoutProviderStartResultSchema = z.object({
|
|
102
|
+
provider: z.string(),
|
|
103
|
+
paymentSessionId: z.string(),
|
|
104
|
+
redirectUrl: z.string().nullable(),
|
|
105
|
+
externalReference: z.string().nullable(),
|
|
106
|
+
providerSessionId: z.string().nullable(),
|
|
107
|
+
providerPaymentId: z.string().nullable(),
|
|
108
|
+
response: z.record(z.string(), z.unknown()).nullable(),
|
|
109
|
+
});
|
|
110
|
+
export const checkoutCollectionPlanSchema = z.object({
|
|
111
|
+
bookingId: z.string(),
|
|
112
|
+
method: checkoutCollectionMethodSchema,
|
|
113
|
+
stage: checkoutCollectionStageSchema,
|
|
114
|
+
paymentSessionTarget: checkoutPaymentSessionTargetSchema.nullable(),
|
|
115
|
+
documentType: checkoutInvoiceDocumentTypeSchema.nullable(),
|
|
116
|
+
willCreateDefaultPaymentPlan: z.boolean(),
|
|
117
|
+
selectedSchedule: checkoutCollectionScheduleSchema.nullable(),
|
|
118
|
+
selectedInvoice: checkoutCollectionInvoiceSchema.nullable(),
|
|
119
|
+
amountCents: z.number().int(),
|
|
120
|
+
currency: z.string(),
|
|
121
|
+
recommendedAction: z.enum([
|
|
122
|
+
"create_bank_transfer_document",
|
|
123
|
+
"create_payment_session",
|
|
124
|
+
"create_invoice_then_payment_session",
|
|
125
|
+
"none",
|
|
126
|
+
]),
|
|
127
|
+
});
|
|
128
|
+
export const initiatedCheckoutCollectionSchema = z.object({
|
|
129
|
+
plan: checkoutCollectionPlanSchema,
|
|
130
|
+
invoice: checkoutCollectionInvoiceSchema.nullable(),
|
|
131
|
+
paymentSession: publicPaymentSessionSchema.nullable(),
|
|
132
|
+
invoiceNotification: checkoutNotificationDeliverySchema.nullable(),
|
|
133
|
+
paymentSessionNotification: checkoutNotificationDeliverySchema.nullable(),
|
|
134
|
+
bankTransferInstructions: checkoutBankTransferInstructionsSchema.nullable(),
|
|
135
|
+
providerStart: checkoutProviderStartResultSchema.nullable(),
|
|
136
|
+
});
|
|
137
|
+
export const bootstrappedCheckoutCollectionSchema = initiatedCheckoutCollectionSchema.extend({
|
|
138
|
+
bookingId: z.string(),
|
|
139
|
+
sessionId: z.string(),
|
|
140
|
+
sourceType: z.enum(["booking", "session"]),
|
|
141
|
+
intent: checkoutCollectionIntentSchema,
|
|
142
|
+
});
|
|
143
|
+
export const checkoutReminderRunListQuerySchema = paginationSchema.extend({
|
|
144
|
+
status: notificationReminderRunStatusSchema.optional(),
|
|
145
|
+
});
|
|
146
|
+
export const checkoutReminderRunSchema = z.object({
|
|
147
|
+
id: z.string(),
|
|
148
|
+
reminderRuleId: z.string(),
|
|
149
|
+
reminderRuleSlug: z.string().nullable(),
|
|
150
|
+
reminderRuleName: z.string().nullable(),
|
|
151
|
+
targetType: notificationReminderTargetTypeSchema,
|
|
152
|
+
targetId: z.string(),
|
|
153
|
+
bookingId: z.string().nullable(),
|
|
154
|
+
paymentSessionId: z.string().nullable(),
|
|
155
|
+
notificationDeliveryId: z.string().nullable(),
|
|
156
|
+
status: notificationReminderRunStatusSchema,
|
|
157
|
+
deliveryStatus: notificationDeliveryStatusSchema.nullable(),
|
|
158
|
+
channel: notificationChannelSchema.nullable(),
|
|
159
|
+
provider: z.string().nullable(),
|
|
160
|
+
recipient: z.string().nullable(),
|
|
161
|
+
scheduledFor: z.string(),
|
|
162
|
+
processedAt: z.string(),
|
|
163
|
+
errorMessage: z.string().nullable(),
|
|
164
|
+
relativeDaysFromDueDate: z.number().int().nullable(),
|
|
165
|
+
createdAt: z.string(),
|
|
166
|
+
});
|
|
167
|
+
export const checkoutReminderRunListResponseSchema = z.object({
|
|
168
|
+
data: z.array(checkoutReminderRunSchema),
|
|
169
|
+
total: z.number().int(),
|
|
170
|
+
limit: z.number().int(),
|
|
171
|
+
offset: z.number().int(),
|
|
172
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/checkout",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"drizzle-orm": "^0.45.2",
|
|
30
30
|
"hono": "^4.12.10",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@voyantjs/bookings": "0.24.
|
|
33
|
-
"@voyantjs/core": "0.24.
|
|
34
|
-
"@voyantjs/finance": "0.24.
|
|
35
|
-
"@voyantjs/hono": "0.24.
|
|
36
|
-
"@voyantjs/notifications": "0.24.
|
|
32
|
+
"@voyantjs/bookings": "0.24.3",
|
|
33
|
+
"@voyantjs/core": "0.24.3",
|
|
34
|
+
"@voyantjs/finance": "0.24.3",
|
|
35
|
+
"@voyantjs/hono": "0.24.3",
|
|
36
|
+
"@voyantjs/notifications": "0.24.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "^6.0.2",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"lint": "biome check src/",
|
|
57
57
|
"test": "vitest run",
|
|
58
58
|
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
59
|
-
"clean": "rm -rf dist"
|
|
59
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
60
60
|
},
|
|
61
61
|
"main": "./dist/index.js",
|
|
62
62
|
"types": "./dist/index.d.ts"
|