@voyantjs/transactions-contracts 0.95.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 +25 -0
- package/dist/contracts.test.d.ts +2 -0
- package/dist/contracts.test.d.ts.map +1 -0
- package/dist/contracts.test.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/validation.d.ts +1462 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +472 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,eAAO,MAAM,iCAAiC;;;EAAyC,CAAA;AAEvF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBrC,CAAA;AAEL,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAIR,CAAA;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;EAQ5B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;EAO5B,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;EAAqD,CAAA;AAElG,eAAO,MAAM,iCAAiC;;;;;;EAM5C,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;EAWpC,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;;;;EAMtC,CAAA;AAEF,eAAO,MAAM,oCAAoC;;;;;;;EAO/C,CAAA;AAEF,eAAO,MAAM,sCAAsC;;;EAAuC,CAAA;AAE1F,eAAO,MAAM,oCAAoC;;;EAAwC,CAAA;AAEzF,eAAO,MAAM,iCAAiC;;;EAAoC,CAAA;AAElF,eAAO,MAAM,mBAAmB;;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AM,kCAAkC;;;;;;;;;;;;;;;iBAInC,CAAA;AACZ,eAAO,MAAM,qCAAqC;;;;;;;;;;iBAKhD,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;iBAG3C,CAAA;AACF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;iBAIjC,CAAA;AACZ,eAAO,MAAM,mCAAmC;;;;;;;;;;iBAK9C,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEhC,CAAA;AACF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgC,CAAA;AAClE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;iBAQnC,CAAA;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;GAQuC,CAAA;AACjF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;GAE0B,CAAA;AACpE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;GAKuB,CAAA;AACpE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;GAAgC,CAAA;AAC7E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;GAAgC,CAAA;AAC7E,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;GAAmC,CAAA;AAEnF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgC,CAAA;AAClE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgC,CAAA;AAClE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;iBAKnC,CAAA"}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const paginationSchema = z.object({
|
|
3
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
4
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
5
|
+
});
|
|
6
|
+
const moneySchema = z.number().int().nullable().optional();
|
|
7
|
+
const metadataRecordSchema = z.record(z.string(), z.unknown());
|
|
8
|
+
export const storefrontOfferDiscountTypeSchema = z.enum(["percentage", "fixed_amount"]);
|
|
9
|
+
export const storefrontOfferMetadataSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
enabled: z.boolean().default(true),
|
|
12
|
+
locale: z.string().trim().min(2).optional().nullable(),
|
|
13
|
+
slug: z.string().trim().min(1).optional().nullable(),
|
|
14
|
+
description: z.string().trim().min(1).optional().nullable(),
|
|
15
|
+
discountType: storefrontOfferDiscountTypeSchema,
|
|
16
|
+
discountValue: z.string().trim().min(1),
|
|
17
|
+
currency: z.string().trim().length(3).optional().nullable(),
|
|
18
|
+
applicableProductIds: z.array(z.string()).default([]),
|
|
19
|
+
applicableDepartureIds: z.array(z.string()).default([]),
|
|
20
|
+
validFrom: z.string().optional().nullable(),
|
|
21
|
+
validTo: z.string().optional().nullable(),
|
|
22
|
+
minTravelers: z.number().int().min(1).optional().nullable(),
|
|
23
|
+
minPassengers: z.number().int().min(1).optional().nullable(),
|
|
24
|
+
imageMobileUrl: z.string().trim().min(1).optional().nullable(),
|
|
25
|
+
imageDesktopUrl: z.string().trim().min(1).optional().nullable(),
|
|
26
|
+
stackable: z.boolean().default(false),
|
|
27
|
+
})
|
|
28
|
+
.transform(({ minPassengers, minTravelers, ...rest }) => ({
|
|
29
|
+
...rest,
|
|
30
|
+
minTravelers: minTravelers ?? minPassengers ?? null,
|
|
31
|
+
}));
|
|
32
|
+
export const offerMetadataSchema = z
|
|
33
|
+
.object({
|
|
34
|
+
storefrontPromotionalOffer: storefrontOfferMetadataSchema.optional(),
|
|
35
|
+
})
|
|
36
|
+
.catchall(z.unknown());
|
|
37
|
+
export const offerStatusSchema = z.enum([
|
|
38
|
+
"draft",
|
|
39
|
+
"published",
|
|
40
|
+
"sent",
|
|
41
|
+
"accepted",
|
|
42
|
+
"expired",
|
|
43
|
+
"withdrawn",
|
|
44
|
+
"converted",
|
|
45
|
+
]);
|
|
46
|
+
export const orderStatusSchema = z.enum([
|
|
47
|
+
"draft",
|
|
48
|
+
"pending",
|
|
49
|
+
"confirmed",
|
|
50
|
+
"fulfilled",
|
|
51
|
+
"cancelled",
|
|
52
|
+
"expired",
|
|
53
|
+
]);
|
|
54
|
+
export const transactionParticipantTypeSchema = z.enum(["traveler", "occupant", "staff", "other"]);
|
|
55
|
+
export const transactionTravelerCategorySchema = z.enum([
|
|
56
|
+
"adult",
|
|
57
|
+
"child",
|
|
58
|
+
"infant",
|
|
59
|
+
"senior",
|
|
60
|
+
"other",
|
|
61
|
+
]);
|
|
62
|
+
export const transactionItemTypeSchema = z.enum([
|
|
63
|
+
"unit",
|
|
64
|
+
"service",
|
|
65
|
+
"extra",
|
|
66
|
+
"fee",
|
|
67
|
+
"tax",
|
|
68
|
+
"discount",
|
|
69
|
+
"adjustment",
|
|
70
|
+
"accommodation",
|
|
71
|
+
"transport",
|
|
72
|
+
"other",
|
|
73
|
+
]);
|
|
74
|
+
export const transactionItemStatusSchema = z.enum([
|
|
75
|
+
"draft",
|
|
76
|
+
"priced",
|
|
77
|
+
"confirmed",
|
|
78
|
+
"cancelled",
|
|
79
|
+
"fulfilled",
|
|
80
|
+
]);
|
|
81
|
+
export const transactionItemParticipantRoleSchema = z.enum([
|
|
82
|
+
"traveler",
|
|
83
|
+
"occupant",
|
|
84
|
+
"primary_contact",
|
|
85
|
+
"beneficiary",
|
|
86
|
+
"service_assignee",
|
|
87
|
+
"other",
|
|
88
|
+
]);
|
|
89
|
+
export const transactionContactAssignmentRoleSchema = z.enum(["primary_contact", "other"]);
|
|
90
|
+
export const transactionStaffAssignmentRoleSchema = z.enum(["service_assignee", "other"]);
|
|
91
|
+
export const transactionContactPartyTypeSchema = z.enum(["individual", "company"]);
|
|
92
|
+
export const orderTermTypeSchema = z.enum([
|
|
93
|
+
"terms_and_conditions",
|
|
94
|
+
"cancellation",
|
|
95
|
+
"guarantee",
|
|
96
|
+
"payment",
|
|
97
|
+
"pricing",
|
|
98
|
+
"commission",
|
|
99
|
+
"other",
|
|
100
|
+
]);
|
|
101
|
+
export const orderTermAcceptanceStatusSchema = z.enum([
|
|
102
|
+
"not_required",
|
|
103
|
+
"pending",
|
|
104
|
+
"accepted",
|
|
105
|
+
"declined",
|
|
106
|
+
]);
|
|
107
|
+
const offerCoreSchema = z.object({
|
|
108
|
+
offerNumber: z.string().min(1).max(50),
|
|
109
|
+
title: z.string().min(1).max(255),
|
|
110
|
+
status: offerStatusSchema.default("draft"),
|
|
111
|
+
personId: z.string().nullable().optional(),
|
|
112
|
+
organizationId: z.string().nullable().optional(),
|
|
113
|
+
opportunityId: z.string().nullable().optional(),
|
|
114
|
+
quoteId: z.string().nullable().optional(),
|
|
115
|
+
marketId: z.string().nullable().optional(),
|
|
116
|
+
sourceChannelId: z.string().nullable().optional(),
|
|
117
|
+
contactPartyType: transactionContactPartyTypeSchema.nullable().optional(),
|
|
118
|
+
contactFirstName: z.string().max(255).nullable().optional(),
|
|
119
|
+
contactLastName: z.string().max(255).nullable().optional(),
|
|
120
|
+
contactTaxId: z.string().max(100).nullable().optional(),
|
|
121
|
+
contactEmail: z.string().email().nullable().optional(),
|
|
122
|
+
contactPhone: z.string().max(50).nullable().optional(),
|
|
123
|
+
contactPreferredLanguage: z.string().max(35).nullable().optional(),
|
|
124
|
+
contactCountry: z.string().max(100).nullable().optional(),
|
|
125
|
+
contactRegion: z.string().max(255).nullable().optional(),
|
|
126
|
+
contactCity: z.string().max(255).nullable().optional(),
|
|
127
|
+
contactAddressLine1: z.string().max(255).nullable().optional(),
|
|
128
|
+
contactAddressLine2: z.string().max(255).nullable().optional(),
|
|
129
|
+
contactPostalCode: z.string().max(50).nullable().optional(),
|
|
130
|
+
currency: z.string().length(3),
|
|
131
|
+
baseCurrency: z.string().length(3).nullable().optional(),
|
|
132
|
+
fxRateSetId: z.string().nullable().optional(),
|
|
133
|
+
subtotalAmountCents: z.number().int().min(0).default(0),
|
|
134
|
+
taxAmountCents: z.number().int().min(0).default(0),
|
|
135
|
+
feeAmountCents: z.number().int().min(0).default(0),
|
|
136
|
+
totalAmountCents: z.number().int().min(0).default(0),
|
|
137
|
+
costAmountCents: z.number().int().min(0).default(0),
|
|
138
|
+
validFrom: z.string().nullable().optional(),
|
|
139
|
+
validUntil: z.string().nullable().optional(),
|
|
140
|
+
sentAt: z.string().nullable().optional(),
|
|
141
|
+
acceptedAt: z.string().nullable().optional(),
|
|
142
|
+
convertedAt: z.string().nullable().optional(),
|
|
143
|
+
notes: z.string().nullable().optional(),
|
|
144
|
+
metadata: offerMetadataSchema.nullable().optional(),
|
|
145
|
+
});
|
|
146
|
+
const participantCoreSchema = z.object({
|
|
147
|
+
personId: z.string().nullable().optional(),
|
|
148
|
+
participantType: transactionParticipantTypeSchema.default("traveler"),
|
|
149
|
+
travelerCategory: transactionTravelerCategorySchema.nullable().optional(),
|
|
150
|
+
firstName: z.string().min(1).max(255),
|
|
151
|
+
lastName: z.string().min(1).max(255),
|
|
152
|
+
email: z.string().email().nullable().optional(),
|
|
153
|
+
phone: z.string().max(50).nullable().optional(),
|
|
154
|
+
preferredLanguage: z.string().max(35).nullable().optional(),
|
|
155
|
+
dateOfBirth: z.string().nullable().optional(),
|
|
156
|
+
nationality: z.string().max(2).nullable().optional(),
|
|
157
|
+
isPrimary: z.boolean().default(false),
|
|
158
|
+
notes: z.string().nullable().optional(),
|
|
159
|
+
});
|
|
160
|
+
const itemCoreSchema = z.object({
|
|
161
|
+
productId: z.string().nullable().optional(),
|
|
162
|
+
optionId: z.string().nullable().optional(),
|
|
163
|
+
unitId: z.string().nullable().optional(),
|
|
164
|
+
slotId: z.string().nullable().optional(),
|
|
165
|
+
title: z.string().min(1).max(255),
|
|
166
|
+
description: z.string().nullable().optional(),
|
|
167
|
+
itemType: transactionItemTypeSchema.default("unit"),
|
|
168
|
+
status: transactionItemStatusSchema.default("draft"),
|
|
169
|
+
serviceDate: z.string().nullable().optional(),
|
|
170
|
+
startsAt: z.string().nullable().optional(),
|
|
171
|
+
endsAt: z.string().nullable().optional(),
|
|
172
|
+
quantity: z.number().int().positive().default(1),
|
|
173
|
+
sellCurrency: z.string().length(3),
|
|
174
|
+
unitSellAmountCents: moneySchema,
|
|
175
|
+
totalSellAmountCents: moneySchema,
|
|
176
|
+
taxAmountCents: moneySchema,
|
|
177
|
+
feeAmountCents: moneySchema,
|
|
178
|
+
costCurrency: z.string().length(3).nullable().optional(),
|
|
179
|
+
unitCostAmountCents: moneySchema,
|
|
180
|
+
totalCostAmountCents: moneySchema,
|
|
181
|
+
notes: z.string().nullable().optional(),
|
|
182
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
183
|
+
});
|
|
184
|
+
const itemParticipantCoreSchema = z.object({
|
|
185
|
+
travelerId: z.string().optional(),
|
|
186
|
+
role: transactionItemParticipantRoleSchema.default("traveler"),
|
|
187
|
+
isPrimary: z.boolean().default(false),
|
|
188
|
+
});
|
|
189
|
+
const staffAssignmentCoreSchema = z.object({
|
|
190
|
+
personId: z.string().nullable().optional(),
|
|
191
|
+
role: transactionStaffAssignmentRoleSchema.default("service_assignee"),
|
|
192
|
+
firstName: z.string().min(1).max(255),
|
|
193
|
+
lastName: z.string().min(1).max(255),
|
|
194
|
+
email: z.string().email().nullable().optional(),
|
|
195
|
+
phone: z.string().max(50).nullable().optional(),
|
|
196
|
+
preferredLanguage: z.string().max(35).nullable().optional(),
|
|
197
|
+
isPrimary: z.boolean().default(false),
|
|
198
|
+
notes: z.string().nullable().optional(),
|
|
199
|
+
metadata: metadataRecordSchema.nullable().optional(),
|
|
200
|
+
});
|
|
201
|
+
const contactAssignmentCoreSchema = z.object({
|
|
202
|
+
personId: z.string().nullable().optional(),
|
|
203
|
+
role: transactionContactAssignmentRoleSchema.default("primary_contact"),
|
|
204
|
+
firstName: z.string().min(1).max(255),
|
|
205
|
+
lastName: z.string().min(1).max(255),
|
|
206
|
+
email: z.string().email().nullable().optional(),
|
|
207
|
+
phone: z.string().max(50).nullable().optional(),
|
|
208
|
+
preferredLanguage: z.string().max(35).nullable().optional(),
|
|
209
|
+
isPrimary: z.boolean().default(false),
|
|
210
|
+
notes: z.string().nullable().optional(),
|
|
211
|
+
metadata: metadataRecordSchema.nullable().optional(),
|
|
212
|
+
});
|
|
213
|
+
const orderCoreSchema = z.object({
|
|
214
|
+
orderNumber: z.string().min(1).max(50),
|
|
215
|
+
offerId: z.string().nullable().optional(),
|
|
216
|
+
title: z.string().min(1).max(255),
|
|
217
|
+
status: orderStatusSchema.default("draft"),
|
|
218
|
+
personId: z.string().nullable().optional(),
|
|
219
|
+
organizationId: z.string().nullable().optional(),
|
|
220
|
+
opportunityId: z.string().nullable().optional(),
|
|
221
|
+
quoteId: z.string().nullable().optional(),
|
|
222
|
+
marketId: z.string().nullable().optional(),
|
|
223
|
+
sourceChannelId: z.string().nullable().optional(),
|
|
224
|
+
contactPartyType: transactionContactPartyTypeSchema.nullable().optional(),
|
|
225
|
+
contactFirstName: z.string().max(255).nullable().optional(),
|
|
226
|
+
contactLastName: z.string().max(255).nullable().optional(),
|
|
227
|
+
contactTaxId: z.string().max(100).nullable().optional(),
|
|
228
|
+
contactEmail: z.string().email().nullable().optional(),
|
|
229
|
+
contactPhone: z.string().max(50).nullable().optional(),
|
|
230
|
+
contactPreferredLanguage: z.string().max(35).nullable().optional(),
|
|
231
|
+
contactCountry: z.string().max(100).nullable().optional(),
|
|
232
|
+
contactRegion: z.string().max(255).nullable().optional(),
|
|
233
|
+
contactCity: z.string().max(255).nullable().optional(),
|
|
234
|
+
contactAddressLine1: z.string().max(255).nullable().optional(),
|
|
235
|
+
contactAddressLine2: z.string().max(255).nullable().optional(),
|
|
236
|
+
contactPostalCode: z.string().max(50).nullable().optional(),
|
|
237
|
+
currency: z.string().length(3),
|
|
238
|
+
baseCurrency: z.string().length(3).nullable().optional(),
|
|
239
|
+
fxRateSetId: z.string().nullable().optional(),
|
|
240
|
+
subtotalAmountCents: z.number().int().min(0).default(0),
|
|
241
|
+
taxAmountCents: z.number().int().min(0).default(0),
|
|
242
|
+
feeAmountCents: z.number().int().min(0).default(0),
|
|
243
|
+
totalAmountCents: z.number().int().min(0).default(0),
|
|
244
|
+
costAmountCents: z.number().int().min(0).default(0),
|
|
245
|
+
orderedAt: z.string().nullable().optional(),
|
|
246
|
+
confirmedAt: z.string().nullable().optional(),
|
|
247
|
+
cancelledAt: z.string().nullable().optional(),
|
|
248
|
+
expiresAt: z.string().nullable().optional(),
|
|
249
|
+
notes: z.string().nullable().optional(),
|
|
250
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
251
|
+
});
|
|
252
|
+
const orderItemCoreSchema = itemCoreSchema.extend({
|
|
253
|
+
offerItemId: z.string().nullable().optional(),
|
|
254
|
+
});
|
|
255
|
+
const orderTermCoreSchema = z.object({
|
|
256
|
+
offerId: z.string().nullable().optional(),
|
|
257
|
+
orderId: z.string().nullable().optional(),
|
|
258
|
+
termType: orderTermTypeSchema.default("terms_and_conditions"),
|
|
259
|
+
title: z.string().min(1).max(255),
|
|
260
|
+
body: z.string().min(1),
|
|
261
|
+
language: z.string().max(35).nullable().optional(),
|
|
262
|
+
required: z.boolean().default(true),
|
|
263
|
+
sortOrder: z.number().int().default(0),
|
|
264
|
+
acceptanceStatus: orderTermAcceptanceStatusSchema.default("pending"),
|
|
265
|
+
acceptedAt: z.string().nullable().optional(),
|
|
266
|
+
acceptedBy: z.string().max(255).nullable().optional(),
|
|
267
|
+
metadata: metadataRecordSchema.nullable().optional(),
|
|
268
|
+
});
|
|
269
|
+
const orderTermRequiredParentSchema = orderTermCoreSchema.refine((value) => Boolean(value.offerId || value.orderId), {
|
|
270
|
+
message: "offerId or orderId is required",
|
|
271
|
+
path: ["offerId"],
|
|
272
|
+
});
|
|
273
|
+
export const insertOfferSchema = offerCoreSchema;
|
|
274
|
+
export const updateOfferSchema = offerCoreSchema.partial();
|
|
275
|
+
export const offerListQuerySchema = paginationSchema.extend({
|
|
276
|
+
status: offerStatusSchema.optional(),
|
|
277
|
+
opportunityId: z.string().optional(),
|
|
278
|
+
quoteId: z.string().optional(),
|
|
279
|
+
personId: z.string().optional(),
|
|
280
|
+
organizationId: z.string().optional(),
|
|
281
|
+
marketId: z.string().optional(),
|
|
282
|
+
search: z.string().optional(),
|
|
283
|
+
});
|
|
284
|
+
export const insertOfferTravelerSchema = participantCoreSchema
|
|
285
|
+
.extend({
|
|
286
|
+
offerId: z.string(),
|
|
287
|
+
})
|
|
288
|
+
.refine((value) => value.participantType !== "staff", {
|
|
289
|
+
message: "Use explicit staff assignments instead of traveler rows for staff participants",
|
|
290
|
+
path: ["participantType"],
|
|
291
|
+
});
|
|
292
|
+
export const updateOfferTravelerSchema = participantCoreSchema
|
|
293
|
+
.partial()
|
|
294
|
+
.refine((value) => (value.participantType ?? "") !== "staff", {
|
|
295
|
+
message: "Use explicit staff assignments instead of traveler rows for staff participants",
|
|
296
|
+
path: ["participantType"],
|
|
297
|
+
});
|
|
298
|
+
export const offerTravelerListQuerySchema = paginationSchema.extend({
|
|
299
|
+
offerId: z.string().optional(),
|
|
300
|
+
personId: z.string().optional(),
|
|
301
|
+
});
|
|
302
|
+
export const insertOfferParticipantSchema = insertOfferTravelerSchema;
|
|
303
|
+
export const updateOfferParticipantSchema = updateOfferTravelerSchema;
|
|
304
|
+
export const offerParticipantListQuerySchema = offerTravelerListQuerySchema;
|
|
305
|
+
export const insertOfferContactAssignmentSchema = contactAssignmentCoreSchema.extend({
|
|
306
|
+
offerId: z.string(),
|
|
307
|
+
offerItemId: z.string().nullable().optional(),
|
|
308
|
+
});
|
|
309
|
+
export const updateOfferContactAssignmentSchema = contactAssignmentCoreSchema
|
|
310
|
+
.extend({
|
|
311
|
+
offerItemId: z.string().nullable().optional(),
|
|
312
|
+
})
|
|
313
|
+
.partial();
|
|
314
|
+
export const offerContactAssignmentListQuerySchema = paginationSchema.extend({
|
|
315
|
+
offerId: z.string().optional(),
|
|
316
|
+
offerItemId: z.string().optional(),
|
|
317
|
+
personId: z.string().optional(),
|
|
318
|
+
role: transactionContactAssignmentRoleSchema.optional(),
|
|
319
|
+
});
|
|
320
|
+
export const insertOfferStaffAssignmentSchema = staffAssignmentCoreSchema.extend({
|
|
321
|
+
offerId: z.string(),
|
|
322
|
+
offerItemId: z.string().nullable().optional(),
|
|
323
|
+
});
|
|
324
|
+
export const updateOfferStaffAssignmentSchema = staffAssignmentCoreSchema
|
|
325
|
+
.extend({
|
|
326
|
+
offerItemId: z.string().nullable().optional(),
|
|
327
|
+
})
|
|
328
|
+
.partial();
|
|
329
|
+
export const offerStaffAssignmentListQuerySchema = paginationSchema.extend({
|
|
330
|
+
offerId: z.string().optional(),
|
|
331
|
+
offerItemId: z.string().optional(),
|
|
332
|
+
personId: z.string().optional(),
|
|
333
|
+
role: transactionStaffAssignmentRoleSchema.optional(),
|
|
334
|
+
});
|
|
335
|
+
export const insertOfferItemSchema = itemCoreSchema.extend({
|
|
336
|
+
offerId: z.string(),
|
|
337
|
+
});
|
|
338
|
+
export const updateOfferItemSchema = itemCoreSchema.partial();
|
|
339
|
+
export const offerItemListQuerySchema = paginationSchema.extend({
|
|
340
|
+
offerId: z.string().optional(),
|
|
341
|
+
productId: z.string().optional(),
|
|
342
|
+
optionId: z.string().optional(),
|
|
343
|
+
unitId: z.string().optional(),
|
|
344
|
+
slotId: z.string().optional(),
|
|
345
|
+
status: transactionItemStatusSchema.optional(),
|
|
346
|
+
});
|
|
347
|
+
export const insertOfferItemTravelerSchema = itemParticipantCoreSchema
|
|
348
|
+
.extend({
|
|
349
|
+
offerItemId: z.string(),
|
|
350
|
+
})
|
|
351
|
+
.refine((value) => Boolean(value.travelerId), {
|
|
352
|
+
message: "travelerId is required",
|
|
353
|
+
path: ["travelerId"],
|
|
354
|
+
})
|
|
355
|
+
.transform(({ travelerId, ...rest }) => ({ ...rest, travelerId: travelerId }));
|
|
356
|
+
export const updateOfferItemTravelerSchema = itemParticipantCoreSchema
|
|
357
|
+
.partial()
|
|
358
|
+
.transform(({ travelerId, ...rest }) => ({ ...rest, travelerId }));
|
|
359
|
+
export const offerItemTravelerListQuerySchema = paginationSchema
|
|
360
|
+
.extend({
|
|
361
|
+
offerItemId: z.string().optional(),
|
|
362
|
+
travelerId: z.string().optional(),
|
|
363
|
+
})
|
|
364
|
+
.transform(({ travelerId, ...rest }) => ({ ...rest, travelerId }));
|
|
365
|
+
export const insertOfferItemParticipantSchema = insertOfferItemTravelerSchema;
|
|
366
|
+
export const updateOfferItemParticipantSchema = updateOfferItemTravelerSchema;
|
|
367
|
+
export const offerItemParticipantListQuerySchema = offerItemTravelerListQuerySchema;
|
|
368
|
+
export const insertOrderSchema = orderCoreSchema;
|
|
369
|
+
export const updateOrderSchema = orderCoreSchema.partial();
|
|
370
|
+
export const orderListQuerySchema = paginationSchema.extend({
|
|
371
|
+
status: orderStatusSchema.optional(),
|
|
372
|
+
offerId: z.string().optional(),
|
|
373
|
+
opportunityId: z.string().optional(),
|
|
374
|
+
quoteId: z.string().optional(),
|
|
375
|
+
personId: z.string().optional(),
|
|
376
|
+
organizationId: z.string().optional(),
|
|
377
|
+
marketId: z.string().optional(),
|
|
378
|
+
search: z.string().optional(),
|
|
379
|
+
});
|
|
380
|
+
export const insertOrderTravelerSchema = participantCoreSchema
|
|
381
|
+
.extend({
|
|
382
|
+
orderId: z.string(),
|
|
383
|
+
})
|
|
384
|
+
.refine((value) => value.participantType !== "staff", {
|
|
385
|
+
message: "Use explicit staff assignments instead of traveler rows for staff participants",
|
|
386
|
+
path: ["participantType"],
|
|
387
|
+
});
|
|
388
|
+
export const updateOrderTravelerSchema = participantCoreSchema
|
|
389
|
+
.partial()
|
|
390
|
+
.refine((value) => (value.participantType ?? "") !== "staff", {
|
|
391
|
+
message: "Use explicit staff assignments instead of traveler rows for staff participants",
|
|
392
|
+
path: ["participantType"],
|
|
393
|
+
});
|
|
394
|
+
export const orderTravelerListQuerySchema = paginationSchema.extend({
|
|
395
|
+
orderId: z.string().optional(),
|
|
396
|
+
personId: z.string().optional(),
|
|
397
|
+
});
|
|
398
|
+
export const insertOrderParticipantSchema = insertOrderTravelerSchema;
|
|
399
|
+
export const updateOrderParticipantSchema = updateOrderTravelerSchema;
|
|
400
|
+
export const orderParticipantListQuerySchema = orderTravelerListQuerySchema;
|
|
401
|
+
export const insertOrderContactAssignmentSchema = contactAssignmentCoreSchema.extend({
|
|
402
|
+
orderId: z.string(),
|
|
403
|
+
orderItemId: z.string().nullable().optional(),
|
|
404
|
+
});
|
|
405
|
+
export const updateOrderContactAssignmentSchema = contactAssignmentCoreSchema
|
|
406
|
+
.extend({
|
|
407
|
+
orderItemId: z.string().nullable().optional(),
|
|
408
|
+
})
|
|
409
|
+
.partial();
|
|
410
|
+
export const orderContactAssignmentListQuerySchema = paginationSchema.extend({
|
|
411
|
+
orderId: z.string().optional(),
|
|
412
|
+
orderItemId: z.string().optional(),
|
|
413
|
+
personId: z.string().optional(),
|
|
414
|
+
role: transactionContactAssignmentRoleSchema.optional(),
|
|
415
|
+
});
|
|
416
|
+
export const insertOrderStaffAssignmentSchema = staffAssignmentCoreSchema.extend({
|
|
417
|
+
orderId: z.string(),
|
|
418
|
+
orderItemId: z.string().nullable().optional(),
|
|
419
|
+
});
|
|
420
|
+
export const updateOrderStaffAssignmentSchema = staffAssignmentCoreSchema
|
|
421
|
+
.extend({
|
|
422
|
+
orderItemId: z.string().nullable().optional(),
|
|
423
|
+
})
|
|
424
|
+
.partial();
|
|
425
|
+
export const orderStaffAssignmentListQuerySchema = paginationSchema.extend({
|
|
426
|
+
orderId: z.string().optional(),
|
|
427
|
+
orderItemId: z.string().optional(),
|
|
428
|
+
personId: z.string().optional(),
|
|
429
|
+
role: transactionStaffAssignmentRoleSchema.optional(),
|
|
430
|
+
});
|
|
431
|
+
export const insertOrderItemSchema = orderItemCoreSchema.extend({
|
|
432
|
+
orderId: z.string(),
|
|
433
|
+
});
|
|
434
|
+
export const updateOrderItemSchema = orderItemCoreSchema.partial();
|
|
435
|
+
export const orderItemListQuerySchema = paginationSchema.extend({
|
|
436
|
+
orderId: z.string().optional(),
|
|
437
|
+
offerItemId: z.string().optional(),
|
|
438
|
+
productId: z.string().optional(),
|
|
439
|
+
optionId: z.string().optional(),
|
|
440
|
+
unitId: z.string().optional(),
|
|
441
|
+
slotId: z.string().optional(),
|
|
442
|
+
status: transactionItemStatusSchema.optional(),
|
|
443
|
+
});
|
|
444
|
+
export const insertOrderItemTravelerSchema = itemParticipantCoreSchema
|
|
445
|
+
.extend({
|
|
446
|
+
orderItemId: z.string(),
|
|
447
|
+
})
|
|
448
|
+
.refine((value) => Boolean(value.travelerId), {
|
|
449
|
+
message: "travelerId is required",
|
|
450
|
+
path: ["travelerId"],
|
|
451
|
+
})
|
|
452
|
+
.transform(({ travelerId, ...rest }) => ({ ...rest, travelerId: travelerId }));
|
|
453
|
+
export const updateOrderItemTravelerSchema = itemParticipantCoreSchema
|
|
454
|
+
.partial()
|
|
455
|
+
.transform(({ travelerId, ...rest }) => ({ ...rest, travelerId }));
|
|
456
|
+
export const orderItemTravelerListQuerySchema = paginationSchema
|
|
457
|
+
.extend({
|
|
458
|
+
orderItemId: z.string().optional(),
|
|
459
|
+
travelerId: z.string().optional(),
|
|
460
|
+
})
|
|
461
|
+
.transform(({ travelerId, ...rest }) => ({ ...rest, travelerId }));
|
|
462
|
+
export const insertOrderItemParticipantSchema = insertOrderItemTravelerSchema;
|
|
463
|
+
export const updateOrderItemParticipantSchema = updateOrderItemTravelerSchema;
|
|
464
|
+
export const orderItemParticipantListQuerySchema = orderItemTravelerListQuerySchema;
|
|
465
|
+
export const insertOrderTermSchema = orderTermRequiredParentSchema;
|
|
466
|
+
export const updateOrderTermSchema = orderTermCoreSchema.partial();
|
|
467
|
+
export const orderTermListQuerySchema = paginationSchema.extend({
|
|
468
|
+
offerId: z.string().optional(),
|
|
469
|
+
orderId: z.string().optional(),
|
|
470
|
+
termType: orderTermTypeSchema.optional(),
|
|
471
|
+
acceptanceStatus: orderTermAcceptanceStatusSchema.optional(),
|
|
472
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/transactions-contracts",
|
|
3
|
+
"version": "0.95.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./validation": "./src/validation.ts"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"lint": "biome check src/",
|
|
13
|
+
"test": "vitest run --passWithNoTests",
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
16
|
+
"prepack": "pnpm run build"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./validation": {
|
|
30
|
+
"types": "./dist/validation.d.ts",
|
|
31
|
+
"import": "./dist/validation.js",
|
|
32
|
+
"default": "./dist/validation.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"zod": "^4.3.6"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
43
|
+
"typescript": "^6.0.2",
|
|
44
|
+
"vitest": "^4.1.2"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
49
|
+
"directory": "packages/transactions-contracts"
|
|
50
|
+
}
|
|
51
|
+
}
|