@voyantjs/transactions 0.1.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.
@@ -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;AASvB,eAAO,MAAM,iBAAiB;;;;;;;;EAQ5B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;EAO5B,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;EAO3C,CAAA;AAEF,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,mBAAmB;;;;;;;;EAQ9B,CAAA;AAEF,eAAO,MAAM,+BAA+B;;;;;EAK1C,CAAA;AAiIF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAkB,CAAA;AAChD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA4B,CAAA;AAC1D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAQ/B,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEvC,CAAA;AACF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAkC,CAAA;AAC3E,eAAO,MAAM,+BAA+B;;;;;iBAG1C,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEhC,CAAA;AACF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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}
@@ -0,0 +1,284 @@
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
+ export const offerStatusSchema = z.enum([
8
+ "draft",
9
+ "published",
10
+ "sent",
11
+ "accepted",
12
+ "expired",
13
+ "withdrawn",
14
+ "converted",
15
+ ]);
16
+ export const orderStatusSchema = z.enum([
17
+ "draft",
18
+ "pending",
19
+ "confirmed",
20
+ "fulfilled",
21
+ "cancelled",
22
+ "expired",
23
+ ]);
24
+ export const transactionParticipantTypeSchema = z.enum([
25
+ "traveler",
26
+ "booker",
27
+ "contact",
28
+ "occupant",
29
+ "staff",
30
+ "other",
31
+ ]);
32
+ export const transactionTravelerCategorySchema = z.enum([
33
+ "adult",
34
+ "child",
35
+ "infant",
36
+ "senior",
37
+ "other",
38
+ ]);
39
+ export const transactionItemTypeSchema = z.enum([
40
+ "unit",
41
+ "service",
42
+ "extra",
43
+ "fee",
44
+ "tax",
45
+ "discount",
46
+ "adjustment",
47
+ "accommodation",
48
+ "transport",
49
+ "other",
50
+ ]);
51
+ export const transactionItemStatusSchema = z.enum([
52
+ "draft",
53
+ "priced",
54
+ "confirmed",
55
+ "cancelled",
56
+ "fulfilled",
57
+ ]);
58
+ export const transactionItemParticipantRoleSchema = z.enum([
59
+ "traveler",
60
+ "occupant",
61
+ "primary_contact",
62
+ "beneficiary",
63
+ "service_assignee",
64
+ "other",
65
+ ]);
66
+ export const orderTermTypeSchema = z.enum([
67
+ "terms_and_conditions",
68
+ "cancellation",
69
+ "guarantee",
70
+ "payment",
71
+ "pricing",
72
+ "commission",
73
+ "other",
74
+ ]);
75
+ export const orderTermAcceptanceStatusSchema = z.enum([
76
+ "not_required",
77
+ "pending",
78
+ "accepted",
79
+ "declined",
80
+ ]);
81
+ const offerCoreSchema = z.object({
82
+ offerNumber: z.string().min(1).max(50),
83
+ title: z.string().min(1).max(255),
84
+ status: offerStatusSchema.default("draft"),
85
+ personId: z.string().nullable().optional(),
86
+ organizationId: z.string().nullable().optional(),
87
+ opportunityId: z.string().nullable().optional(),
88
+ quoteId: z.string().nullable().optional(),
89
+ marketId: z.string().nullable().optional(),
90
+ sourceChannelId: z.string().nullable().optional(),
91
+ currency: z.string().length(3),
92
+ baseCurrency: z.string().length(3).nullable().optional(),
93
+ fxRateSetId: z.string().nullable().optional(),
94
+ subtotalAmountCents: z.number().int().min(0).default(0),
95
+ taxAmountCents: z.number().int().min(0).default(0),
96
+ feeAmountCents: z.number().int().min(0).default(0),
97
+ totalAmountCents: z.number().int().min(0).default(0),
98
+ costAmountCents: z.number().int().min(0).default(0),
99
+ validFrom: z.string().nullable().optional(),
100
+ validUntil: z.string().nullable().optional(),
101
+ sentAt: z.string().nullable().optional(),
102
+ acceptedAt: z.string().nullable().optional(),
103
+ convertedAt: z.string().nullable().optional(),
104
+ notes: z.string().nullable().optional(),
105
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
106
+ });
107
+ const participantCoreSchema = z.object({
108
+ personId: z.string().nullable().optional(),
109
+ participantType: transactionParticipantTypeSchema.default("traveler"),
110
+ travelerCategory: transactionTravelerCategorySchema.nullable().optional(),
111
+ firstName: z.string().min(1).max(255),
112
+ lastName: z.string().min(1).max(255),
113
+ email: z.string().email().nullable().optional(),
114
+ phone: z.string().max(50).nullable().optional(),
115
+ preferredLanguage: z.string().max(35).nullable().optional(),
116
+ dateOfBirth: z.string().nullable().optional(),
117
+ nationality: z.string().max(2).nullable().optional(),
118
+ isPrimary: z.boolean().default(false),
119
+ notes: z.string().nullable().optional(),
120
+ });
121
+ const itemCoreSchema = z.object({
122
+ productId: z.string().nullable().optional(),
123
+ optionId: z.string().nullable().optional(),
124
+ unitId: z.string().nullable().optional(),
125
+ slotId: z.string().nullable().optional(),
126
+ title: z.string().min(1).max(255),
127
+ description: z.string().nullable().optional(),
128
+ itemType: transactionItemTypeSchema.default("unit"),
129
+ status: transactionItemStatusSchema.default("draft"),
130
+ serviceDate: z.string().nullable().optional(),
131
+ startsAt: z.string().nullable().optional(),
132
+ endsAt: z.string().nullable().optional(),
133
+ quantity: z.number().int().positive().default(1),
134
+ sellCurrency: z.string().length(3),
135
+ unitSellAmountCents: moneySchema,
136
+ totalSellAmountCents: moneySchema,
137
+ taxAmountCents: moneySchema,
138
+ feeAmountCents: moneySchema,
139
+ costCurrency: z.string().length(3).nullable().optional(),
140
+ unitCostAmountCents: moneySchema,
141
+ totalCostAmountCents: moneySchema,
142
+ notes: z.string().nullable().optional(),
143
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
144
+ });
145
+ const itemParticipantCoreSchema = z.object({
146
+ participantId: z.string(),
147
+ role: transactionItemParticipantRoleSchema.default("traveler"),
148
+ isPrimary: z.boolean().default(false),
149
+ });
150
+ const orderCoreSchema = z.object({
151
+ orderNumber: z.string().min(1).max(50),
152
+ offerId: z.string().nullable().optional(),
153
+ title: z.string().min(1).max(255),
154
+ status: orderStatusSchema.default("draft"),
155
+ personId: z.string().nullable().optional(),
156
+ organizationId: z.string().nullable().optional(),
157
+ opportunityId: z.string().nullable().optional(),
158
+ quoteId: z.string().nullable().optional(),
159
+ marketId: z.string().nullable().optional(),
160
+ sourceChannelId: z.string().nullable().optional(),
161
+ currency: z.string().length(3),
162
+ baseCurrency: z.string().length(3).nullable().optional(),
163
+ fxRateSetId: z.string().nullable().optional(),
164
+ subtotalAmountCents: z.number().int().min(0).default(0),
165
+ taxAmountCents: z.number().int().min(0).default(0),
166
+ feeAmountCents: z.number().int().min(0).default(0),
167
+ totalAmountCents: z.number().int().min(0).default(0),
168
+ costAmountCents: z.number().int().min(0).default(0),
169
+ orderedAt: z.string().nullable().optional(),
170
+ confirmedAt: z.string().nullable().optional(),
171
+ cancelledAt: z.string().nullable().optional(),
172
+ expiresAt: z.string().nullable().optional(),
173
+ notes: z.string().nullable().optional(),
174
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
175
+ });
176
+ const orderItemCoreSchema = itemCoreSchema.extend({
177
+ offerItemId: z.string().nullable().optional(),
178
+ });
179
+ const orderTermCoreSchema = z.object({
180
+ offerId: z.string().nullable().optional(),
181
+ orderId: z.string().nullable().optional(),
182
+ termType: orderTermTypeSchema.default("terms_and_conditions"),
183
+ title: z.string().min(1).max(255),
184
+ body: z.string().min(1),
185
+ language: z.string().max(35).nullable().optional(),
186
+ required: z.boolean().default(true),
187
+ sortOrder: z.number().int().default(0),
188
+ acceptanceStatus: orderTermAcceptanceStatusSchema.default("pending"),
189
+ acceptedAt: z.string().nullable().optional(),
190
+ acceptedBy: z.string().max(255).nullable().optional(),
191
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
192
+ });
193
+ const orderTermRequiredParentSchema = orderTermCoreSchema.refine((value) => Boolean(value.offerId || value.orderId), {
194
+ message: "offerId or orderId is required",
195
+ path: ["offerId"],
196
+ });
197
+ export const insertOfferSchema = offerCoreSchema;
198
+ export const updateOfferSchema = offerCoreSchema.partial();
199
+ export const offerListQuerySchema = paginationSchema.extend({
200
+ status: offerStatusSchema.optional(),
201
+ opportunityId: z.string().optional(),
202
+ quoteId: z.string().optional(),
203
+ personId: z.string().optional(),
204
+ organizationId: z.string().optional(),
205
+ marketId: z.string().optional(),
206
+ search: z.string().optional(),
207
+ });
208
+ export const insertOfferParticipantSchema = participantCoreSchema.extend({
209
+ offerId: z.string(),
210
+ });
211
+ export const updateOfferParticipantSchema = participantCoreSchema.partial();
212
+ export const offerParticipantListQuerySchema = paginationSchema.extend({
213
+ offerId: z.string().optional(),
214
+ personId: z.string().optional(),
215
+ });
216
+ export const insertOfferItemSchema = itemCoreSchema.extend({
217
+ offerId: z.string(),
218
+ });
219
+ export const updateOfferItemSchema = itemCoreSchema.partial();
220
+ export const offerItemListQuerySchema = paginationSchema.extend({
221
+ offerId: z.string().optional(),
222
+ productId: z.string().optional(),
223
+ optionId: z.string().optional(),
224
+ unitId: z.string().optional(),
225
+ slotId: z.string().optional(),
226
+ status: transactionItemStatusSchema.optional(),
227
+ });
228
+ export const insertOfferItemParticipantSchema = itemParticipantCoreSchema.extend({
229
+ offerItemId: z.string(),
230
+ });
231
+ export const updateOfferItemParticipantSchema = itemParticipantCoreSchema.partial();
232
+ export const offerItemParticipantListQuerySchema = paginationSchema.extend({
233
+ offerItemId: z.string().optional(),
234
+ participantId: z.string().optional(),
235
+ });
236
+ export const insertOrderSchema = orderCoreSchema;
237
+ export const updateOrderSchema = orderCoreSchema.partial();
238
+ export const orderListQuerySchema = paginationSchema.extend({
239
+ status: orderStatusSchema.optional(),
240
+ offerId: z.string().optional(),
241
+ opportunityId: z.string().optional(),
242
+ quoteId: z.string().optional(),
243
+ personId: z.string().optional(),
244
+ organizationId: z.string().optional(),
245
+ marketId: z.string().optional(),
246
+ search: z.string().optional(),
247
+ });
248
+ export const insertOrderParticipantSchema = participantCoreSchema.extend({
249
+ orderId: z.string(),
250
+ });
251
+ export const updateOrderParticipantSchema = participantCoreSchema.partial();
252
+ export const orderParticipantListQuerySchema = paginationSchema.extend({
253
+ orderId: z.string().optional(),
254
+ personId: z.string().optional(),
255
+ });
256
+ export const insertOrderItemSchema = orderItemCoreSchema.extend({
257
+ orderId: z.string(),
258
+ });
259
+ export const updateOrderItemSchema = orderItemCoreSchema.partial();
260
+ export const orderItemListQuerySchema = paginationSchema.extend({
261
+ orderId: z.string().optional(),
262
+ offerItemId: z.string().optional(),
263
+ productId: z.string().optional(),
264
+ optionId: z.string().optional(),
265
+ unitId: z.string().optional(),
266
+ slotId: z.string().optional(),
267
+ status: transactionItemStatusSchema.optional(),
268
+ });
269
+ export const insertOrderItemParticipantSchema = itemParticipantCoreSchema.extend({
270
+ orderItemId: z.string(),
271
+ });
272
+ export const updateOrderItemParticipantSchema = itemParticipantCoreSchema.partial();
273
+ export const orderItemParticipantListQuerySchema = paginationSchema.extend({
274
+ orderItemId: z.string().optional(),
275
+ participantId: z.string().optional(),
276
+ });
277
+ export const insertOrderTermSchema = orderTermRequiredParentSchema;
278
+ export const updateOrderTermSchema = orderTermCoreSchema.partial();
279
+ export const orderTermListQuerySchema = paginationSchema.extend({
280
+ offerId: z.string().optional(),
281
+ orderId: z.string().optional(),
282
+ termType: orderTermTypeSchema.optional(),
283
+ acceptanceStatus: orderTermAcceptanceStatusSchema.optional(),
284
+ });
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@voyantjs/transactions",
3
+ "version": "0.1.0",
4
+ "license": "FSL-1.1-Apache-2.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ },
11
+ "./schema": {
12
+ "types": "./dist/schema.d.ts",
13
+ "import": "./dist/schema.js"
14
+ },
15
+ "./validation": {
16
+ "types": "./dist/validation.d.ts",
17
+ "import": "./dist/validation.js"
18
+ },
19
+ "./routes": {
20
+ "types": "./dist/routes.d.ts",
21
+ "import": "./dist/routes.js"
22
+ },
23
+ "./booking-extension": {
24
+ "types": "./dist/booking-extension.d.ts",
25
+ "import": "./dist/booking-extension.js"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "drizzle-orm": "^0.45.2",
30
+ "hono": "^4.12.10",
31
+ "zod": "^4.3.6",
32
+ "@voyantjs/core": "0.1.0",
33
+ "@voyantjs/db": "0.1.0",
34
+ "@voyantjs/hono": "0.1.0",
35
+ "@voyantjs/utils": "0.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "^6.0.2",
39
+ "@voyantjs/voyant-typescript-config": "0.1.0"
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "typecheck": "tsc --noEmit",
49
+ "lint": "biome check src/",
50
+ "test": "vitest run --passWithNoTests",
51
+ "build": "tsc -p tsconfig.json",
52
+ "clean": "rm -rf dist"
53
+ },
54
+ "main": "./dist/index.js",
55
+ "types": "./dist/index.d.ts"
56
+ }