@ordinatio/scheduling-api 0.9.0 → 0.10.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/CHANGELOG.md +8 -0
- package/README.md +3 -1
- package/package.json +3 -3
- package/dist/agent/index.d.mts +0 -55
- package/dist/agent/index.d.ts +0 -55
- package/dist/agent/index.js +0 -2541
- package/dist/agent/index.mjs +0 -2511
- package/dist/chunk-W3SY2DAU.mjs +0 -516
- package/dist/index.d.mts +0 -597
- package/dist/index.d.ts +0 -597
- package/dist/index.js +0 -9675
- package/dist/index.mjs +0 -9152
- package/dist/routes-h90wEQuD.d.mts +0 -469
- package/dist/routes-h90wEQuD.d.ts +0 -469
- package/dist/schemas/index.d.mts +0 -552
- package/dist/schemas/index.d.ts +0 -552
- package/dist/schemas/index.js +0 -584
- package/dist/schemas/index.mjs +0 -90
package/dist/chunk-W3SY2DAU.mjs
DELETED
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
// src/schemas/types-calendars.schema.ts
|
|
2
|
-
import { z as z2 } from "zod";
|
|
3
|
-
|
|
4
|
-
// src/schemas/helpers.ts
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
var optionalString = (maxLength, fieldName) => z.string().optional().nullable().transform((val) => val?.trim() || null).refine((val) => val === null || val.length <= maxLength, {
|
|
7
|
-
message: `${fieldName} must be less than ${maxLength} characters`
|
|
8
|
-
});
|
|
9
|
-
var optionalStringKeptWhenOmitted = (maxLength, fieldName) => z.string().nullable().optional().transform((val) => val === void 0 ? void 0 : val?.trim() || null).refine((val) => val == null || val.length <= maxLength, {
|
|
10
|
-
message: `${fieldName} must be less than ${maxLength} characters`
|
|
11
|
-
});
|
|
12
|
-
var optionalPrice = z.number().min(0, { message: "Cannot be negative" }).optional().nullable();
|
|
13
|
-
function partialWithoutDefaults(shape) {
|
|
14
|
-
const stripped = {};
|
|
15
|
-
for (const key of Object.keys(shape)) {
|
|
16
|
-
const field = shape[key];
|
|
17
|
-
stripped[key] = field instanceof z.ZodDefault ? field.unwrap() : field;
|
|
18
|
-
}
|
|
19
|
-
return z.object(stripped).partial();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// src/schemas/types-calendars.schema.ts
|
|
23
|
-
var OPTION_TYPES = ["select", "radio", "checkbox"];
|
|
24
|
-
var ShowIfSchema = z2.object({
|
|
25
|
-
fieldId: z2.string().min(1).max(100),
|
|
26
|
-
operator: z2.enum(["equals", "not_equals", "contains", "is_empty", "is_not_empty"]),
|
|
27
|
-
value: z2.string().max(500)
|
|
28
|
-
});
|
|
29
|
-
var IntakeFormFieldSchema = z2.object({
|
|
30
|
-
id: z2.string().min(1).max(100),
|
|
31
|
-
type: z2.enum([
|
|
32
|
-
"text",
|
|
33
|
-
"email",
|
|
34
|
-
"phone",
|
|
35
|
-
"textarea",
|
|
36
|
-
"select",
|
|
37
|
-
"checkbox",
|
|
38
|
-
"radio",
|
|
39
|
-
"date",
|
|
40
|
-
"number"
|
|
41
|
-
]),
|
|
42
|
-
label: z2.string().min(1).max(255),
|
|
43
|
-
placeholder: z2.string().max(255).optional(),
|
|
44
|
-
required: z2.boolean(),
|
|
45
|
-
options: z2.array(z2.string().min(1).max(100)).max(50).optional(),
|
|
46
|
-
showIf: ShowIfSchema.optional()
|
|
47
|
-
}).superRefine((field, ctx) => {
|
|
48
|
-
if (OPTION_TYPES.includes(field.type)) {
|
|
49
|
-
if (!field.options || field.options.length === 0) {
|
|
50
|
-
ctx.addIssue({
|
|
51
|
-
code: z2.ZodIssueCode.custom,
|
|
52
|
-
path: ["options"],
|
|
53
|
-
message: `${field.type} fields must have at least one option`
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
var AppointmentTypeBaseSchema = z2.object({
|
|
59
|
-
name: z2.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Name is required" }).refine((val) => val.length <= 100, { message: "Name must be less than 100 characters" }),
|
|
60
|
-
description: optionalString(500, "Description"),
|
|
61
|
-
location: z2.string().max(500).optional().nullable(),
|
|
62
|
-
locationType: z2.enum(["IN_PERSON", "TRAVEL_TO_CLIENT", "VIRTUAL", "PHONE"]).optional().default("IN_PERSON"),
|
|
63
|
-
duration: z2.number().int({ message: "Duration must be a whole number" }).min(5, { message: "Duration must be at least 5 minutes" }).max(480, { message: "Duration cannot exceed 8 hours" }),
|
|
64
|
-
color: z2.string().regex(/^#[0-9A-Fa-f]{6}$/, { message: "Color must be a valid hex code" }).optional().default("#3B82F6"),
|
|
65
|
-
categoryId: z2.string().optional().nullable(),
|
|
66
|
-
price: optionalPrice,
|
|
67
|
-
deposit: optionalPrice,
|
|
68
|
-
requiresPayment: z2.boolean().optional().default(false),
|
|
69
|
-
requiresApproval: z2.boolean().optional().default(false),
|
|
70
|
-
allowReschedule: z2.boolean().optional().default(true),
|
|
71
|
-
allowCancel: z2.boolean().optional().default(true),
|
|
72
|
-
cancelDeadlineHrs: z2.number().int().min(0, { message: "Cancel deadline cannot be negative" }).max(720, { message: "Cancel deadline cannot exceed 30 days" }).optional().default(24),
|
|
73
|
-
reminder1MinsBefore: z2.number().int().min(0, { message: "Cannot be negative" }).max(10080, { message: "Cannot exceed 7 days" }).optional().default(1440),
|
|
74
|
-
reminder2MinsBefore: z2.number().int().min(0, { message: "Cannot be negative" }).max(10080, { message: "Cannot exceed 7 days" }).optional().default(60),
|
|
75
|
-
followupMinsAfter: z2.number().int().min(0, { message: "Cannot be negative" }).max(10080, { message: "Cannot exceed 7 days" }).optional().default(120),
|
|
76
|
-
isGroup: z2.boolean().optional().default(false),
|
|
77
|
-
maxSeats: z2.number().int().min(2, { message: "Group must have at least 2 seats" }).optional().nullable(),
|
|
78
|
-
intakeForm: z2.array(IntakeFormFieldSchema).optional().nullable(),
|
|
79
|
-
calendarIds: z2.array(z2.string()).optional(),
|
|
80
|
-
// Left unset on create, the package stores 'NONE'. On update, an omitted value keeps the stored one.
|
|
81
|
-
assignmentStrategy: z2.enum(["NONE", "ROUND_ROBIN", "LOAD_BALANCED"]).optional(),
|
|
82
|
-
sortOrder: z2.number().int().optional().default(0)
|
|
83
|
-
});
|
|
84
|
-
function validateReminderTiming(data, ctx) {
|
|
85
|
-
const r1 = data.reminder1MinsBefore ?? 0;
|
|
86
|
-
const r2 = data.reminder2MinsBefore ?? 0;
|
|
87
|
-
if (r1 > 0 && r2 > 0 && r1 === r2) {
|
|
88
|
-
ctx.addIssue({
|
|
89
|
-
code: z2.ZodIssueCode.custom,
|
|
90
|
-
path: ["reminder2MinsBefore"],
|
|
91
|
-
message: "Second reminder must be at a different time than the first reminder"
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
var GROUP_SEATS_REQUIRED = "Group appointments must specify a maximum number of seats";
|
|
96
|
-
var CreateAppointmentTypeSchema = AppointmentTypeBaseSchema.superRefine((data, ctx) => {
|
|
97
|
-
if (data.isGroup && !data.maxSeats) {
|
|
98
|
-
ctx.addIssue({
|
|
99
|
-
code: z2.ZodIssueCode.custom,
|
|
100
|
-
path: ["maxSeats"],
|
|
101
|
-
message: GROUP_SEATS_REQUIRED
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
validateReminderTiming(data, ctx);
|
|
105
|
-
});
|
|
106
|
-
var UpdateAppointmentTypeSchema = partialWithoutDefaults(AppointmentTypeBaseSchema.shape).extend({
|
|
107
|
-
description: optionalStringKeptWhenOmitted(500, "Description"),
|
|
108
|
-
isActive: z2.boolean().optional()
|
|
109
|
-
}).superRefine((data, ctx) => {
|
|
110
|
-
if (data.isGroup === true && data.maxSeats === null) {
|
|
111
|
-
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["maxSeats"], message: GROUP_SEATS_REQUIRED });
|
|
112
|
-
}
|
|
113
|
-
validateReminderTiming(data, ctx);
|
|
114
|
-
});
|
|
115
|
-
var SLOT_GRANULARITY_OPTIONS = [5, 10, 15, 30, 60];
|
|
116
|
-
var SLOT_GRANULARITY_DEFAULT = 15;
|
|
117
|
-
var CreateCalendarSchema = z2.object({
|
|
118
|
-
name: z2.string().transform((v) => v.trim()).refine((v) => v.length >= 1, { message: "Name is required" }).refine((v) => v.length <= 100, { message: "Name must be less than 100 characters" }),
|
|
119
|
-
type: z2.enum(["STAFF", "LOCATION", "RESOURCE"]).default("STAFF"),
|
|
120
|
-
// The same fallback zone is written separately in several places in the scheduling code.
|
|
121
|
-
timezone: z2.string().min(1, { message: "Timezone is required" }).max(100, { message: "Timezone must be less than 100 characters" }).default("America/New_York"),
|
|
122
|
-
staffName: z2.string().max(100).optional().nullable(),
|
|
123
|
-
staffEmail: z2.string().email({ message: "Invalid email address" }).optional().nullable(),
|
|
124
|
-
staffAvatar: z2.string().url({ message: "Invalid URL" }).max(500).optional().nullable(),
|
|
125
|
-
// Explicit staff link — validated against a real OrganizationMembership by
|
|
126
|
-
// validateCalendarStaffUserId() at the route layer (this schema only
|
|
127
|
-
// checks shape, not cross-org membership). No .default() — must flow
|
|
128
|
-
// through UpdateCalendarSchema's partialWithoutDefaults() unchanged so an
|
|
129
|
-
// omitted key means "leave unchanged," not "reset to undefined-as-null".
|
|
130
|
-
userId: z2.string().cuid({ message: "Invalid user id" }).optional().nullable(),
|
|
131
|
-
location: z2.string().max(200).optional().nullable(),
|
|
132
|
-
slotGranularityMinutes: z2.union(
|
|
133
|
-
SLOT_GRANULARITY_OPTIONS.map((v) => z2.literal(v))
|
|
134
|
-
).optional().default(SLOT_GRANULARITY_DEFAULT)
|
|
135
|
-
});
|
|
136
|
-
var UpdateCalendarSchema = partialWithoutDefaults(CreateCalendarSchema.shape).extend({
|
|
137
|
-
isActive: z2.boolean().optional(),
|
|
138
|
-
syncDirection: z2.enum(["one-way", "two-way"]).optional()
|
|
139
|
-
});
|
|
140
|
-
var UNSAFE_CSS_VALUE = /[;{}`@\\\n\r]|url\s*\(|expression\s*\(|(?:^|[^\w-])(?:-[a-z]+-)?(?:image-set|image|src|cross-fade|element|paint)\s*\(/i;
|
|
141
|
-
var themeValue = (max) => z2.string().max(max).refine((v) => !UNSAFE_CSS_VALUE.test(v), { message: "Contains characters that are not allowed in a theme value" });
|
|
142
|
-
var BookingPageThemeSchema = z2.object({
|
|
143
|
-
primaryColor: themeValue(50).optional(),
|
|
144
|
-
accentColor: themeValue(50).optional(),
|
|
145
|
-
backgroundColor: themeValue(50).optional(),
|
|
146
|
-
textColor: themeValue(50).optional(),
|
|
147
|
-
mutedTextColor: themeValue(50).optional(),
|
|
148
|
-
borderColor: themeValue(50).optional(),
|
|
149
|
-
borderRadius: themeValue(20).optional(),
|
|
150
|
-
fontFamily: themeValue(200).optional()
|
|
151
|
-
});
|
|
152
|
-
var BookingPageConfigSchema = z2.object({
|
|
153
|
-
title: z2.string().max(100).optional().nullable(),
|
|
154
|
-
description: z2.string().max(500).optional().nullable(),
|
|
155
|
-
logoUrl: z2.string().url().max(500).refine(
|
|
156
|
-
(v) => /^https:\/\//i.test(v),
|
|
157
|
-
{ message: "Logo URL must use https://" }
|
|
158
|
-
).optional().nullable(),
|
|
159
|
-
confirmationMessage: z2.string().max(500).optional().nullable(),
|
|
160
|
-
redirectUrl: z2.string().url().max(500).refine(
|
|
161
|
-
(v) => /^https:\/\//i.test(v),
|
|
162
|
-
{ message: "Redirect URL must use https://" }
|
|
163
|
-
).optional().nullable(),
|
|
164
|
-
redirectDelay: z2.number().int().min(0).max(30).optional().default(5),
|
|
165
|
-
showContactInfo: z2.boolean().optional().default(true)
|
|
166
|
-
});
|
|
167
|
-
var UpdateBookingPageSchema = z2.object({
|
|
168
|
-
theme: BookingPageThemeSchema.optional().nullable(),
|
|
169
|
-
config: BookingPageConfigSchema.optional().nullable()
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// src/schemas/billing.schema.ts
|
|
173
|
-
import { z as z3 } from "zod";
|
|
174
|
-
var CreateServicePackageSchema = z3.object({
|
|
175
|
-
name: z3.string().transform((v) => v.trim()).refine((v) => v.length >= 1, { message: "Name is required" }).refine((v) => v.length <= 100, { message: "Name must be less than 100 characters" }),
|
|
176
|
-
description: optionalString(500, "Description"),
|
|
177
|
-
price: z3.number().min(0.01, { message: "Price must be greater than zero" }).max(99999, { message: "Price is unreasonably large" }),
|
|
178
|
-
sessions: z3.number().int().min(1, { message: "Must include at least 1 session" }).max(1e3, { message: "Cannot exceed 1000 sessions" }),
|
|
179
|
-
validDays: z3.number().int().min(1).max(3650, { message: "Cannot exceed 10 years" }).default(365),
|
|
180
|
-
typeId: z3.string().optional().nullable()
|
|
181
|
-
});
|
|
182
|
-
var UpdateServicePackageSchema = partialWithoutDefaults(CreateServicePackageSchema.shape).extend({
|
|
183
|
-
description: optionalStringKeptWhenOmitted(500, "Description"),
|
|
184
|
-
isActive: z3.boolean().optional()
|
|
185
|
-
});
|
|
186
|
-
var CreatePackagePurchaseSchema = z3.object({
|
|
187
|
-
packageId: z3.string().min(1),
|
|
188
|
-
clientEmail: z3.string().email(),
|
|
189
|
-
clientName: z3.string().trim().max(200).optional(),
|
|
190
|
-
notes: z3.string().max(1e3).optional(),
|
|
191
|
-
// ISO string for expiry override — defaults to purchasedAt + package.validDays if absent
|
|
192
|
-
expiresAt: z3.string().datetime().optional()
|
|
193
|
-
}).superRefine((data, ctx) => {
|
|
194
|
-
if (data.expiresAt && new Date(data.expiresAt) <= /* @__PURE__ */ new Date()) {
|
|
195
|
-
ctx.addIssue({
|
|
196
|
-
code: z3.ZodIssueCode.custom,
|
|
197
|
-
path: ["expiresAt"],
|
|
198
|
-
message: "Expiry date must be in the future"
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
var UpdatePackagePurchaseSchema = z3.object({
|
|
203
|
-
clientName: z3.string().trim().max(200).optional(),
|
|
204
|
-
clientEmail: z3.string().trim().email().optional(),
|
|
205
|
-
notes: z3.string().max(1e3).optional(),
|
|
206
|
-
status: z3.enum(["ACTIVE", "CANCELLED"]).optional()
|
|
207
|
-
});
|
|
208
|
-
var CouponCodeBaseSchema = z3.object({
|
|
209
|
-
code: z3.string().transform((v) => v.trim().toUpperCase()).refine((v) => v.length >= 3, { message: "Code must be at least 3 characters" }).refine((v) => v.length <= 50, { message: "Code must be less than 50 characters" }).refine(
|
|
210
|
-
(v) => /^[A-Z0-9_-]+$/.test(v),
|
|
211
|
-
{ message: "Code can only contain letters, numbers, hyphens, and underscores" }
|
|
212
|
-
),
|
|
213
|
-
discountType: z3.enum(["PERCENTAGE", "FLAT"], {
|
|
214
|
-
message: "Discount type must be PERCENTAGE or FLAT"
|
|
215
|
-
}),
|
|
216
|
-
discountValue: z3.number().min(0.01, { message: "Discount value must be greater than 0" }).max(1e5, { message: "Discount value is unreasonably large" }),
|
|
217
|
-
maxUses: z3.number().int().min(1).optional().nullable(),
|
|
218
|
-
expiresAt: z3.string().datetime().optional().nullable()
|
|
219
|
-
});
|
|
220
|
-
var CreateCouponCodeSchema = CouponCodeBaseSchema.superRefine((data, ctx) => {
|
|
221
|
-
if (data.discountType === "PERCENTAGE" && data.discountValue > 100) {
|
|
222
|
-
ctx.addIssue({
|
|
223
|
-
code: z3.ZodIssueCode.custom,
|
|
224
|
-
path: ["discountValue"],
|
|
225
|
-
message: "Percentage discount cannot exceed 100%"
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
var UpdateCouponCodeSchema = CouponCodeBaseSchema.partial().extend({
|
|
230
|
-
isActive: z3.boolean().optional()
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// src/schemas/policy-templates.schema.ts
|
|
234
|
-
import { z as z4 } from "zod";
|
|
235
|
-
var CancellationFeeBaseSchema = z4.object({
|
|
236
|
-
enabled: z4.boolean().default(false),
|
|
237
|
-
amount: z4.number().min(0).max(1e4).optional().nullable(),
|
|
238
|
-
feeType: z4.enum(["FLAT", "PERCENTAGE"]).default("FLAT")
|
|
239
|
-
});
|
|
240
|
-
var NoShowPreventionActionSchema = z4.enum(["REQUIRE_APPROVAL", "BLOCK_BOOKING"]);
|
|
241
|
-
var NoShowPreventionSchema = z4.object({
|
|
242
|
-
enabled: z4.boolean().default(false),
|
|
243
|
-
threshold: z4.number().int().min(1).max(20).default(2),
|
|
244
|
-
action: NoShowPreventionActionSchema.default("REQUIRE_APPROVAL")
|
|
245
|
-
});
|
|
246
|
-
var OrgCancellationPolicySchema = z4.object({
|
|
247
|
-
defaultAllowCancel: z4.boolean().default(true),
|
|
248
|
-
defaultCancelDeadlineHrs: z4.number().int().min(0).max(720).default(24),
|
|
249
|
-
noShowFee: CancellationFeeBaseSchema,
|
|
250
|
-
lateCancelFee: CancellationFeeBaseSchema,
|
|
251
|
-
requireCardOnFile: z4.boolean().default(false),
|
|
252
|
-
noShowPrevention: NoShowPreventionSchema.default({ enabled: false, threshold: 2, action: "REQUIRE_APPROVAL" }),
|
|
253
|
-
// Transport field for optimistic locking — destructured out before DB write, never stored.
|
|
254
|
-
clientUpdatedAt: z4.string().datetime().optional()
|
|
255
|
-
}).superRefine((data, ctx) => {
|
|
256
|
-
if (data.noShowFee.enabled && !data.noShowFee.amount) {
|
|
257
|
-
ctx.addIssue({
|
|
258
|
-
code: z4.ZodIssueCode.custom,
|
|
259
|
-
path: ["noShowFee", "amount"],
|
|
260
|
-
message: "No-show fee amount is required when no-show fee is enabled"
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
if (data.lateCancelFee.enabled && !data.lateCancelFee.amount) {
|
|
264
|
-
ctx.addIssue({
|
|
265
|
-
code: z4.ZodIssueCode.custom,
|
|
266
|
-
path: ["lateCancelFee", "amount"],
|
|
267
|
-
message: "Late cancel fee amount is required when late cancel fee is enabled"
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if (data.noShowFee.feeType === "PERCENTAGE" && (data.noShowFee.amount ?? 0) > 100) {
|
|
271
|
-
ctx.addIssue({
|
|
272
|
-
code: z4.ZodIssueCode.custom,
|
|
273
|
-
path: ["noShowFee", "amount"],
|
|
274
|
-
message: "Percentage fee cannot exceed 100%"
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
if (data.lateCancelFee.feeType === "PERCENTAGE" && (data.lateCancelFee.amount ?? 0) > 100) {
|
|
278
|
-
ctx.addIssue({
|
|
279
|
-
code: z4.ZodIssueCode.custom,
|
|
280
|
-
path: ["lateCancelFee", "amount"],
|
|
281
|
-
message: "Percentage fee cannot exceed 100%"
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
var DEFAULT_CANCELLATION_POLICY = {
|
|
286
|
-
defaultAllowCancel: true,
|
|
287
|
-
defaultCancelDeadlineHrs: 24,
|
|
288
|
-
noShowFee: { enabled: false, amount: null, feeType: "FLAT" },
|
|
289
|
-
lateCancelFee: { enabled: false, amount: null, feeType: "FLAT" },
|
|
290
|
-
requireCardOnFile: false,
|
|
291
|
-
noShowPrevention: { enabled: false, threshold: 2, action: "REQUIRE_APPROVAL" }
|
|
292
|
-
};
|
|
293
|
-
var CreateAppointmentCategorySchema = z4.object({
|
|
294
|
-
name: z4.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Category name is required" }).refine((val) => val.length <= 50, { message: "Category name must be less than 50 characters" })
|
|
295
|
-
});
|
|
296
|
-
var UpdateAppointmentCategorySchema = z4.object({
|
|
297
|
-
name: z4.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Category name is required" }).refine((val) => val.length <= 50, { message: "Category name must be less than 50 characters" }).optional(),
|
|
298
|
-
sortOrder: z4.number().int({ message: "Sort order must be a whole number" }).min(0, { message: "Sort order cannot be negative" }).optional()
|
|
299
|
-
});
|
|
300
|
-
var NotificationChannelSchema = z4.enum(["EMAIL", "SMS"]);
|
|
301
|
-
var NotificationTriggerSchema = z4.enum([
|
|
302
|
-
"CONFIRMATION",
|
|
303
|
-
"REMINDER_24H",
|
|
304
|
-
"REMINDER_1H",
|
|
305
|
-
"FOLLOWUP",
|
|
306
|
-
"CANCELLATION",
|
|
307
|
-
"RESCHEDULE"
|
|
308
|
-
]);
|
|
309
|
-
var CreateNotificationTemplateSchema = z4.object({
|
|
310
|
-
name: z4.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Name is required" }).refine((val) => val.length <= 100, { message: "Name must be less than 100 characters" }),
|
|
311
|
-
channel: NotificationChannelSchema,
|
|
312
|
-
trigger: NotificationTriggerSchema,
|
|
313
|
-
recipientType: z4.enum(["CLIENT", "STAFF"]).default("CLIENT"),
|
|
314
|
-
subject: optionalString(200, "Subject"),
|
|
315
|
-
body: z4.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Template body is required" }).refine((val) => val.length <= 5e3, { message: "Template body must be less than 5000 characters" }),
|
|
316
|
-
isActive: z4.boolean().optional().default(true)
|
|
317
|
-
});
|
|
318
|
-
var UpdateNotificationTemplateSchema = z4.object({
|
|
319
|
-
name: z4.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Name is required" }).refine((val) => val.length <= 100, { message: "Name must be less than 100 characters" }).optional(),
|
|
320
|
-
subject: z4.string().max(200, { message: "Subject must be less than 200 characters" }).nullable().optional(),
|
|
321
|
-
body: z4.string().transform((val) => val.trim()).refine((val) => val.length >= 1, { message: "Template body is required" }).refine((val) => val.length <= 5e3, { message: "Template body must be less than 5000 characters" }).optional(),
|
|
322
|
-
isActive: z4.boolean().optional()
|
|
323
|
-
});
|
|
324
|
-
var CreateAvailabilityRuleSchema = z4.object({
|
|
325
|
-
dayOfWeek: z4.number().int().min(0).max(6).optional().nullable(),
|
|
326
|
-
startTime: z4.string().regex(/^\d{2}:\d{2}$/, { message: "Start time must be in HH:MM format" }),
|
|
327
|
-
endTime: z4.string().regex(/^\d{2}:\d{2}$/, { message: "End time must be in HH:MM format" }),
|
|
328
|
-
specificDate: z4.string().datetime().optional().nullable(),
|
|
329
|
-
isBlocked: z4.boolean().optional().default(false),
|
|
330
|
-
blockReason: optionalString(200, "Block reason"),
|
|
331
|
-
bufferBefore: z4.number().int().min(0).max(120).optional().default(0),
|
|
332
|
-
bufferAfter: z4.number().int().min(0).max(120).optional().default(15),
|
|
333
|
-
minNotice: z4.number().int().min(0).max(10080).optional().default(60),
|
|
334
|
-
maxAdvanceBooking: z4.number().int().min(1).max(365).optional().default(60),
|
|
335
|
-
maxPerDay: z4.number().int().min(1).optional().nullable()
|
|
336
|
-
});
|
|
337
|
-
var RecurringFrequencySchema = z4.enum(["DAILY", "WEEKLY", "BIWEEKLY", "MONTHLY"]);
|
|
338
|
-
var CreateRecurringSeriesSchema = z4.object({
|
|
339
|
-
calendarId: z4.string().min(1),
|
|
340
|
-
typeId: z4.string().min(1),
|
|
341
|
-
frequency: RecurringFrequencySchema,
|
|
342
|
-
// Must match the pure function constraint: 1..104
|
|
343
|
-
occurrences: z4.number().int().min(1, { message: "Must have at least 1 occurrence" }).max(104, { message: "Cannot exceed 104 occurrences (~2 years weekly)" }),
|
|
344
|
-
// "HH:MM" 24-hour local time — validated by parseTimeLocal in the pure module
|
|
345
|
-
startTimeLocal: z4.string().regex(/^\d{2}:\d{2}$/, { message: "startTimeLocal must be in HH:MM format" }),
|
|
346
|
-
// ISO-8601 date string for the first occurrence (YYYY-MM-DD accepted)
|
|
347
|
-
firstDate: z4.string().min(1, { message: "firstDate is required" }),
|
|
348
|
-
// Same fallback zone as CreateCalendarSchema.timezone.
|
|
349
|
-
timezone: z4.string().min(1).max(100).default("America/New_York"),
|
|
350
|
-
// Optional hard upper-bound; occurrences falling after this are dropped
|
|
351
|
-
endsAt: z4.string().datetime().optional().nullable(),
|
|
352
|
-
clientEmail: z4.string().email(),
|
|
353
|
-
clientName: z4.string().trim().min(1).max(200),
|
|
354
|
-
clientPhone: z4.string().max(30).optional().nullable(),
|
|
355
|
-
clientId: z4.string().optional().nullable(),
|
|
356
|
-
notes: z4.string().max(1e3).optional().nullable()
|
|
357
|
-
});
|
|
358
|
-
var CancelRecurringScopeSchema = z4.enum(["ONE", "THIS_AND_FOLLOWING", "ALL"]);
|
|
359
|
-
var CancelRecurringSeriesSchema = z4.object({
|
|
360
|
-
scope: CancelRecurringScopeSchema,
|
|
361
|
-
// Required for ONE and THIS_AND_FOLLOWING — which appointment is the pivot
|
|
362
|
-
fromAppointmentId: z4.string().optional()
|
|
363
|
-
}).superRefine((data, ctx) => {
|
|
364
|
-
if ((data.scope === "ONE" || data.scope === "THIS_AND_FOLLOWING") && !data.fromAppointmentId) {
|
|
365
|
-
ctx.addIssue({
|
|
366
|
-
code: z4.ZodIssueCode.custom,
|
|
367
|
-
path: ["fromAppointmentId"],
|
|
368
|
-
message: "fromAppointmentId is required for ONE and THIS_AND_FOLLOWING scope"
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
// src/schemas/webhooks.schema.ts
|
|
374
|
-
import { z as z5 } from "zod";
|
|
375
|
-
var CreateWebhookEndpointSchema = z5.object({
|
|
376
|
-
url: z5.string().trim().min(1, { message: "Address is required" }).max(2e3, { message: "Address is too long" }),
|
|
377
|
-
eventTypes: z5.array(z5.string().max(64)).min(1, { message: "Choose at least one event" }).max(20),
|
|
378
|
-
description: optionalString(200, "Description")
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
// src/schemas/routing.schema.ts
|
|
382
|
-
import { z as z6 } from "zod";
|
|
383
|
-
var bounded = {
|
|
384
|
-
name: z6.string().max(200),
|
|
385
|
-
slug: z6.string().max(100),
|
|
386
|
-
description: z6.string().max(1e3).nullable().optional(),
|
|
387
|
-
isActive: z6.boolean().optional(),
|
|
388
|
-
questions: z6.array(z6.unknown()).max(30),
|
|
389
|
-
rules: z6.array(z6.unknown()).max(60),
|
|
390
|
-
fallback: z6.unknown()
|
|
391
|
-
};
|
|
392
|
-
var CreateRoutingFormSchema = z6.object({
|
|
393
|
-
...bounded,
|
|
394
|
-
fallback: z6.record(z6.string(), z6.unknown())
|
|
395
|
-
});
|
|
396
|
-
var UpdateRoutingFormSchema = z6.object({ ...bounded, fallback: z6.record(z6.string(), z6.unknown()) }).partial().refine((value) => Object.keys(value).length > 0, { message: "Send at least one field to change" });
|
|
397
|
-
var RouteClientSchema = z6.object({
|
|
398
|
-
slug: z6.string().min(1).max(100),
|
|
399
|
-
orgSlug: z6.string().min(1).max(100).optional(),
|
|
400
|
-
answers: z6.record(z6.string(), z6.unknown())
|
|
401
|
-
});
|
|
402
|
-
var TestRoutingFormSchema = z6.object({ answers: z6.record(z6.string(), z6.unknown()) });
|
|
403
|
-
|
|
404
|
-
// src/schemas/privacy.schema.ts
|
|
405
|
-
import { z as z7 } from "zod";
|
|
406
|
-
var subject = {
|
|
407
|
-
email: z7.string().max(320).optional(),
|
|
408
|
-
clientId: z7.string().max(200).optional()
|
|
409
|
-
};
|
|
410
|
-
var namesSomeone = (value) => Boolean(value.email?.trim() || value.clientId?.trim());
|
|
411
|
-
var namesSomeoneMessage = { message: "Send an email address, a client id, or both" };
|
|
412
|
-
var PrivacySubjectSchema = z7.object(subject).strict().refine(namesSomeone, namesSomeoneMessage);
|
|
413
|
-
var PrivacyEraseSchema = z7.object({ ...subject, confirm: z7.boolean().optional() }).strict().refine(namesSomeone, namesSomeoneMessage);
|
|
414
|
-
|
|
415
|
-
// src/schemas/brand.schema.ts
|
|
416
|
-
import { z as z8 } from "zod";
|
|
417
|
-
var optionalText = (max) => z8.string().max(max).nullable().optional();
|
|
418
|
-
var BrandSchema = z8.object({
|
|
419
|
-
displayName: z8.string().max(200),
|
|
420
|
-
logoUrl: optionalText(1e3),
|
|
421
|
-
primaryColor: optionalText(20),
|
|
422
|
-
accentColor: optionalText(20),
|
|
423
|
-
backgroundColor: optionalText(20),
|
|
424
|
-
textColor: optionalText(20),
|
|
425
|
-
fontFamily: optionalText(200),
|
|
426
|
-
footerText: optionalText(1e3),
|
|
427
|
-
replyToEmail: optionalText(400),
|
|
428
|
-
fromName: optionalText(200),
|
|
429
|
-
fromEmail: optionalText(400)
|
|
430
|
-
}).strict();
|
|
431
|
-
|
|
432
|
-
// src/schemas/text-settings.schema.ts
|
|
433
|
-
import { z as z9 } from "zod";
|
|
434
|
-
var TextSettingsSchema = z9.object({
|
|
435
|
-
provider: z9.string().max(40),
|
|
436
|
-
fromNumber: z9.string().max(40),
|
|
437
|
-
enabled: z9.boolean().optional()
|
|
438
|
-
}).strict();
|
|
439
|
-
|
|
440
|
-
// src/schemas/api-key.schema.ts
|
|
441
|
-
import { z as z10 } from "zod";
|
|
442
|
-
var ApiKeySchema = z10.object({
|
|
443
|
-
name: z10.string().max(200),
|
|
444
|
-
access: z10.string().max(20)
|
|
445
|
-
}).strict();
|
|
446
|
-
|
|
447
|
-
// src/schemas/gift-certificate.schema.ts
|
|
448
|
-
import { z as z11 } from "zod";
|
|
449
|
-
var text = (max) => z11.string().max(max).nullable().optional();
|
|
450
|
-
var GiftCertificateSchema = z11.object({
|
|
451
|
-
amountCents: z11.number(),
|
|
452
|
-
currency: z11.string().max(10).optional(),
|
|
453
|
-
expiresAt: z11.string().max(40).nullable().optional(),
|
|
454
|
-
recipientName: text(300),
|
|
455
|
-
recipientEmail: text(300),
|
|
456
|
-
purchaserName: text(300),
|
|
457
|
-
purchaserEmail: text(300),
|
|
458
|
-
message: text(1e3),
|
|
459
|
-
paymentId: text(300),
|
|
460
|
-
notes: text(2e3)
|
|
461
|
-
}).strict();
|
|
462
|
-
var GiftCertificateRestoreSchema = z11.object({
|
|
463
|
-
amountCents: z11.number(),
|
|
464
|
-
appointmentId: z11.string().max(200).optional(),
|
|
465
|
-
note: z11.string().max(1e3).optional()
|
|
466
|
-
}).strict();
|
|
467
|
-
var GiftCertificateCheckSchema = z11.object({
|
|
468
|
-
code: z11.string().max(64),
|
|
469
|
-
calendarId: z11.string().min(1).max(200)
|
|
470
|
-
}).strict();
|
|
471
|
-
|
|
472
|
-
export {
|
|
473
|
-
IntakeFormFieldSchema,
|
|
474
|
-
CreateAppointmentTypeSchema,
|
|
475
|
-
UpdateAppointmentTypeSchema,
|
|
476
|
-
SLOT_GRANULARITY_OPTIONS,
|
|
477
|
-
SLOT_GRANULARITY_DEFAULT,
|
|
478
|
-
CreateCalendarSchema,
|
|
479
|
-
UpdateCalendarSchema,
|
|
480
|
-
BookingPageThemeSchema,
|
|
481
|
-
BookingPageConfigSchema,
|
|
482
|
-
UpdateBookingPageSchema,
|
|
483
|
-
CreateServicePackageSchema,
|
|
484
|
-
UpdateServicePackageSchema,
|
|
485
|
-
CreatePackagePurchaseSchema,
|
|
486
|
-
UpdatePackagePurchaseSchema,
|
|
487
|
-
CreateCouponCodeSchema,
|
|
488
|
-
UpdateCouponCodeSchema,
|
|
489
|
-
NoShowPreventionActionSchema,
|
|
490
|
-
OrgCancellationPolicySchema,
|
|
491
|
-
DEFAULT_CANCELLATION_POLICY,
|
|
492
|
-
CreateAppointmentCategorySchema,
|
|
493
|
-
UpdateAppointmentCategorySchema,
|
|
494
|
-
NotificationChannelSchema,
|
|
495
|
-
NotificationTriggerSchema,
|
|
496
|
-
CreateNotificationTemplateSchema,
|
|
497
|
-
UpdateNotificationTemplateSchema,
|
|
498
|
-
CreateAvailabilityRuleSchema,
|
|
499
|
-
RecurringFrequencySchema,
|
|
500
|
-
CreateRecurringSeriesSchema,
|
|
501
|
-
CancelRecurringScopeSchema,
|
|
502
|
-
CancelRecurringSeriesSchema,
|
|
503
|
-
CreateWebhookEndpointSchema,
|
|
504
|
-
CreateRoutingFormSchema,
|
|
505
|
-
UpdateRoutingFormSchema,
|
|
506
|
-
RouteClientSchema,
|
|
507
|
-
TestRoutingFormSchema,
|
|
508
|
-
PrivacySubjectSchema,
|
|
509
|
-
PrivacyEraseSchema,
|
|
510
|
-
BrandSchema,
|
|
511
|
-
TextSettingsSchema,
|
|
512
|
-
ApiKeySchema,
|
|
513
|
-
GiftCertificateSchema,
|
|
514
|
-
GiftCertificateRestoreSchema,
|
|
515
|
-
GiftCertificateCheckSchema
|
|
516
|
-
};
|