@voyantjs/suppliers-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 +24 -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 +304 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +144 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @voyantjs/suppliers-contracts
|
|
2
|
+
|
|
3
|
+
Pure suppliers validation schemas (suppliers, services, rates) and enums,
|
|
4
|
+
zod-only, for consumers (admin SDK, Voyant Connect) that validate supplier
|
|
5
|
+
payloads without the suppliers runtime. `@voyantjs/suppliers` re-exports these
|
|
6
|
+
so existing import paths are unchanged.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @voyantjs/suppliers-contracts zod
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {
|
|
18
|
+
insertSupplierSchema,
|
|
19
|
+
selectSupplierSchema,
|
|
20
|
+
type InsertSupplier,
|
|
21
|
+
} from "@voyantjs/suppliers-contracts"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Existing `@voyantjs/suppliers/validation` imports remain available for
|
|
25
|
+
applications that already depend on the full runtime package.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.test.d.ts","sourceRoot":"","sources":["../src/contracts.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { insertRateSchema, insertSupplierSchema } from "./index.js";
|
|
3
|
+
describe("suppliers-contracts", () => {
|
|
4
|
+
it("accepts a valid supplier and rejects an unknown type", () => {
|
|
5
|
+
const parsed = insertSupplierSchema.parse({ name: "Acme Tours", type: "guide" });
|
|
6
|
+
expect(parsed.status).toBe("active");
|
|
7
|
+
expect(insertSupplierSchema.safeParse({ name: "Acme Tours", type: "spaceship" }).success).toBe(false);
|
|
8
|
+
});
|
|
9
|
+
it("accepts a valid rate and rejects a non-3-char currency", () => {
|
|
10
|
+
const parsed = insertRateSchema.parse({
|
|
11
|
+
name: "Standard",
|
|
12
|
+
currency: "EUR",
|
|
13
|
+
amountCents: 1000,
|
|
14
|
+
unit: "per_person",
|
|
15
|
+
});
|
|
16
|
+
expect(parsed.unit).toBe("per_person");
|
|
17
|
+
expect(insertRateSchema.safeParse({
|
|
18
|
+
name: "Standard",
|
|
19
|
+
currency: "EURO",
|
|
20
|
+
amountCents: 1000,
|
|
21
|
+
unit: "per_person",
|
|
22
|
+
}).success).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./validation.js";
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const insertSupplierSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
type: z.ZodEnum<{
|
|
5
|
+
hotel: "hotel";
|
|
6
|
+
transfer: "transfer";
|
|
7
|
+
guide: "guide";
|
|
8
|
+
experience: "experience";
|
|
9
|
+
airline: "airline";
|
|
10
|
+
restaurant: "restaurant";
|
|
11
|
+
other: "other";
|
|
12
|
+
}>;
|
|
13
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
14
|
+
active: "active";
|
|
15
|
+
inactive: "inactive";
|
|
16
|
+
pending: "pending";
|
|
17
|
+
}>>;
|
|
18
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
website: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
address: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
23
|
+
city: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
24
|
+
country: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
25
|
+
defaultCurrency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
26
|
+
primaryFacilityId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
27
|
+
contactName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
28
|
+
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
29
|
+
contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
30
|
+
paymentTermsDays: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
31
|
+
reservationTimeoutMinutes: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
32
|
+
customerPaymentPolicy: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
33
|
+
deposit: z.ZodObject<{
|
|
34
|
+
kind: z.ZodEnum<{
|
|
35
|
+
none: "none";
|
|
36
|
+
percent: "percent";
|
|
37
|
+
fixed_cents: "fixed_cents";
|
|
38
|
+
}>;
|
|
39
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
minDaysBeforeDepartureForDeposit: z.ZodNumber;
|
|
43
|
+
balanceDueDaysBeforeDeparture: z.ZodNumber;
|
|
44
|
+
balanceDueMinDaysFromNow: z.ZodNumber;
|
|
45
|
+
}, z.core.$strip>>>;
|
|
46
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export declare const updateSupplierSchema: z.ZodObject<{
|
|
49
|
+
name: z.ZodOptional<z.ZodString>;
|
|
50
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
hotel: "hotel";
|
|
52
|
+
transfer: "transfer";
|
|
53
|
+
guide: "guide";
|
|
54
|
+
experience: "experience";
|
|
55
|
+
airline: "airline";
|
|
56
|
+
restaurant: "restaurant";
|
|
57
|
+
other: "other";
|
|
58
|
+
}>>;
|
|
59
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
60
|
+
active: "active";
|
|
61
|
+
inactive: "inactive";
|
|
62
|
+
pending: "pending";
|
|
63
|
+
}>>>;
|
|
64
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
65
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
66
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
67
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
68
|
+
address: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
69
|
+
city: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
70
|
+
country: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
71
|
+
defaultCurrency: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
72
|
+
primaryFacilityId: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
73
|
+
contactName: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
74
|
+
contactEmail: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
75
|
+
contactPhone: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
76
|
+
paymentTermsDays: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
77
|
+
reservationTimeoutMinutes: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
78
|
+
customerPaymentPolicy: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
79
|
+
deposit: z.ZodObject<{
|
|
80
|
+
kind: z.ZodEnum<{
|
|
81
|
+
none: "none";
|
|
82
|
+
percent: "percent";
|
|
83
|
+
fixed_cents: "fixed_cents";
|
|
84
|
+
}>;
|
|
85
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
minDaysBeforeDepartureForDeposit: z.ZodNumber;
|
|
89
|
+
balanceDueDaysBeforeDeparture: z.ZodNumber;
|
|
90
|
+
balanceDueMinDaysFromNow: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>>>>;
|
|
92
|
+
tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
export declare const selectSupplierSchema: z.ZodObject<{
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
type: z.ZodEnum<{
|
|
97
|
+
hotel: "hotel";
|
|
98
|
+
transfer: "transfer";
|
|
99
|
+
guide: "guide";
|
|
100
|
+
experience: "experience";
|
|
101
|
+
airline: "airline";
|
|
102
|
+
restaurant: "restaurant";
|
|
103
|
+
other: "other";
|
|
104
|
+
}>;
|
|
105
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
106
|
+
active: "active";
|
|
107
|
+
inactive: "inactive";
|
|
108
|
+
pending: "pending";
|
|
109
|
+
}>>;
|
|
110
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
111
|
+
email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
112
|
+
phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
113
|
+
website: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
114
|
+
address: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
115
|
+
city: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
116
|
+
country: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
117
|
+
defaultCurrency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
118
|
+
primaryFacilityId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
119
|
+
contactName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
120
|
+
contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
121
|
+
contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
122
|
+
paymentTermsDays: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
123
|
+
reservationTimeoutMinutes: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
124
|
+
customerPaymentPolicy: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
125
|
+
deposit: z.ZodObject<{
|
|
126
|
+
kind: z.ZodEnum<{
|
|
127
|
+
none: "none";
|
|
128
|
+
percent: "percent";
|
|
129
|
+
fixed_cents: "fixed_cents";
|
|
130
|
+
}>;
|
|
131
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
minDaysBeforeDepartureForDeposit: z.ZodNumber;
|
|
135
|
+
balanceDueDaysBeforeDeparture: z.ZodNumber;
|
|
136
|
+
balanceDueMinDaysFromNow: z.ZodNumber;
|
|
137
|
+
}, z.core.$strip>>>;
|
|
138
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
141
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
export declare const supplierListSortFieldSchema: z.ZodEnum<{
|
|
144
|
+
type: "type";
|
|
145
|
+
name: "name";
|
|
146
|
+
status: "status";
|
|
147
|
+
defaultCurrency: "defaultCurrency";
|
|
148
|
+
createdAt: "createdAt";
|
|
149
|
+
}>;
|
|
150
|
+
export declare const supplierListSortDirSchema: z.ZodEnum<{
|
|
151
|
+
asc: "asc";
|
|
152
|
+
desc: "desc";
|
|
153
|
+
}>;
|
|
154
|
+
export declare const supplierListQuerySchema: z.ZodObject<{
|
|
155
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
156
|
+
hotel: "hotel";
|
|
157
|
+
transfer: "transfer";
|
|
158
|
+
guide: "guide";
|
|
159
|
+
experience: "experience";
|
|
160
|
+
airline: "airline";
|
|
161
|
+
restaurant: "restaurant";
|
|
162
|
+
other: "other";
|
|
163
|
+
}>>;
|
|
164
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
165
|
+
active: "active";
|
|
166
|
+
inactive: "inactive";
|
|
167
|
+
pending: "pending";
|
|
168
|
+
}>>;
|
|
169
|
+
primaryFacilityId: z.ZodOptional<z.ZodString>;
|
|
170
|
+
country: z.ZodOptional<z.ZodString>;
|
|
171
|
+
defaultCurrency: z.ZodOptional<z.ZodString>;
|
|
172
|
+
search: z.ZodOptional<z.ZodString>;
|
|
173
|
+
sortBy: z.ZodDefault<z.ZodEnum<{
|
|
174
|
+
type: "type";
|
|
175
|
+
name: "name";
|
|
176
|
+
status: "status";
|
|
177
|
+
defaultCurrency: "defaultCurrency";
|
|
178
|
+
createdAt: "createdAt";
|
|
179
|
+
}>>;
|
|
180
|
+
sortDir: z.ZodDefault<z.ZodEnum<{
|
|
181
|
+
asc: "asc";
|
|
182
|
+
desc: "desc";
|
|
183
|
+
}>>;
|
|
184
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
185
|
+
offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
export declare const supplierAggregatesQuerySchema: z.ZodObject<{
|
|
188
|
+
from: z.ZodOptional<z.ZodString>;
|
|
189
|
+
to: z.ZodOptional<z.ZodString>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
export type InsertSupplier = z.infer<typeof insertSupplierSchema>;
|
|
192
|
+
export type UpdateSupplier = z.infer<typeof updateSupplierSchema>;
|
|
193
|
+
export type SelectSupplier = z.infer<typeof selectSupplierSchema>;
|
|
194
|
+
export declare const insertServiceSchema: z.ZodObject<{
|
|
195
|
+
serviceType: z.ZodEnum<{
|
|
196
|
+
transfer: "transfer";
|
|
197
|
+
guide: "guide";
|
|
198
|
+
experience: "experience";
|
|
199
|
+
other: "other";
|
|
200
|
+
accommodation: "accommodation";
|
|
201
|
+
meal: "meal";
|
|
202
|
+
}>;
|
|
203
|
+
facilityId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
204
|
+
name: z.ZodString;
|
|
205
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
206
|
+
duration: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
207
|
+
capacity: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
208
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
209
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
export declare const updateServiceSchema: z.ZodObject<{
|
|
212
|
+
serviceType: z.ZodOptional<z.ZodEnum<{
|
|
213
|
+
transfer: "transfer";
|
|
214
|
+
guide: "guide";
|
|
215
|
+
experience: "experience";
|
|
216
|
+
other: "other";
|
|
217
|
+
accommodation: "accommodation";
|
|
218
|
+
meal: "meal";
|
|
219
|
+
}>>;
|
|
220
|
+
facilityId: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
221
|
+
name: z.ZodOptional<z.ZodString>;
|
|
222
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
223
|
+
duration: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
224
|
+
capacity: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
225
|
+
active: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
226
|
+
tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
export type InsertService = z.infer<typeof insertServiceSchema>;
|
|
229
|
+
export type UpdateService = z.infer<typeof updateServiceSchema>;
|
|
230
|
+
export declare const insertRateSchema: z.ZodObject<{
|
|
231
|
+
name: z.ZodString;
|
|
232
|
+
currency: z.ZodString;
|
|
233
|
+
amountCents: z.ZodNumber;
|
|
234
|
+
unit: z.ZodEnum<{
|
|
235
|
+
per_person: "per_person";
|
|
236
|
+
per_group: "per_group";
|
|
237
|
+
per_night: "per_night";
|
|
238
|
+
per_vehicle: "per_vehicle";
|
|
239
|
+
flat: "flat";
|
|
240
|
+
}>;
|
|
241
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
242
|
+
validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
243
|
+
minPax: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
244
|
+
maxPax: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
245
|
+
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
export declare const updateRateSchema: z.ZodObject<{
|
|
248
|
+
name: z.ZodOptional<z.ZodString>;
|
|
249
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
250
|
+
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
251
|
+
unit: z.ZodOptional<z.ZodEnum<{
|
|
252
|
+
per_person: "per_person";
|
|
253
|
+
per_group: "per_group";
|
|
254
|
+
per_night: "per_night";
|
|
255
|
+
per_vehicle: "per_vehicle";
|
|
256
|
+
flat: "flat";
|
|
257
|
+
}>>;
|
|
258
|
+
validFrom: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
259
|
+
validTo: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
260
|
+
minPax: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
261
|
+
maxPax: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
262
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
263
|
+
}, z.core.$strip>;
|
|
264
|
+
export type InsertRate = z.infer<typeof insertRateSchema>;
|
|
265
|
+
export type UpdateRate = z.infer<typeof updateRateSchema>;
|
|
266
|
+
export declare const insertSupplierNoteSchema: z.ZodObject<{
|
|
267
|
+
content: z.ZodString;
|
|
268
|
+
}, z.core.$strip>;
|
|
269
|
+
export declare const insertAvailabilitySchema: z.ZodObject<{
|
|
270
|
+
date: z.ZodString;
|
|
271
|
+
available: z.ZodDefault<z.ZodBoolean>;
|
|
272
|
+
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
273
|
+
}, z.core.$strip>;
|
|
274
|
+
export declare const availabilityQuerySchema: z.ZodObject<{
|
|
275
|
+
from: z.ZodOptional<z.ZodString>;
|
|
276
|
+
to: z.ZodOptional<z.ZodString>;
|
|
277
|
+
}, z.core.$strip>;
|
|
278
|
+
export declare const insertContractSchema: z.ZodObject<{
|
|
279
|
+
agreementNumber: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
280
|
+
startDate: z.ZodString;
|
|
281
|
+
endDate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
282
|
+
renewalDate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
283
|
+
terms: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
284
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
285
|
+
active: "active";
|
|
286
|
+
pending: "pending";
|
|
287
|
+
expired: "expired";
|
|
288
|
+
terminated: "terminated";
|
|
289
|
+
}>>;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
export declare const updateContractSchema: z.ZodObject<{
|
|
292
|
+
agreementNumber: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
293
|
+
startDate: z.ZodOptional<z.ZodString>;
|
|
294
|
+
endDate: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
295
|
+
renewalDate: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
296
|
+
terms: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
297
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
298
|
+
active: "active";
|
|
299
|
+
pending: "pending";
|
|
300
|
+
expired: "expired";
|
|
301
|
+
terminated: "terminated";
|
|
302
|
+
}>>>;
|
|
303
|
+
}, z.core.$strip>;
|
|
304
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -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;AAoEvB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAqB,CAAA;AACtD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA+B,CAAA;AAChE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI/B,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;;;;EAMtC,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;EAA0B,CAAA;AAEhE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAWlC,CAAA;AAEF,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAejE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;iBAAoB,CAAA;AACpD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;iBAA8B,CAAA;AAE9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAgB/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;iBAAiB,CAAA;AAC9C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;iBAA2B,CAAA;AAExD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIzD,eAAO,MAAM,wBAAwB;;iBAEnC,CAAA;AAIF,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAA;AAeF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;iBAAqB,CAAA;AACtD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;iBAA+B,CAAA"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { typeIdSchema } from "@voyantjs/schema-kit/typeid";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const supplierTypeSchema = z.enum([
|
|
4
|
+
"hotel",
|
|
5
|
+
"transfer",
|
|
6
|
+
"guide",
|
|
7
|
+
"experience",
|
|
8
|
+
"airline",
|
|
9
|
+
"restaurant",
|
|
10
|
+
"other",
|
|
11
|
+
]);
|
|
12
|
+
const supplierStatusSchema = z.enum(["active", "inactive", "pending"]);
|
|
13
|
+
const serviceTypeSchema = z.enum([
|
|
14
|
+
"accommodation",
|
|
15
|
+
"transfer",
|
|
16
|
+
"experience",
|
|
17
|
+
"guide",
|
|
18
|
+
"meal",
|
|
19
|
+
"other",
|
|
20
|
+
]);
|
|
21
|
+
const rateUnitSchema = z.enum(["per_person", "per_group", "per_night", "per_vehicle", "flat"]);
|
|
22
|
+
// ---------- suppliers ----------
|
|
23
|
+
const depositRuleSchema = z.object({
|
|
24
|
+
kind: z.enum(["none", "percent", "fixed_cents"]),
|
|
25
|
+
percent: z.number().min(0).max(100).optional(),
|
|
26
|
+
amountCents: z.number().int().min(0).optional(),
|
|
27
|
+
});
|
|
28
|
+
const customerPaymentPolicySchema = z.object({
|
|
29
|
+
deposit: depositRuleSchema,
|
|
30
|
+
minDaysBeforeDepartureForDeposit: z.number().int().min(0),
|
|
31
|
+
balanceDueDaysBeforeDeparture: z.number().int().min(0),
|
|
32
|
+
balanceDueMinDaysFromNow: z.number().int().min(0),
|
|
33
|
+
});
|
|
34
|
+
const supplierCoreSchema = z.object({
|
|
35
|
+
name: z.string().min(1).max(255),
|
|
36
|
+
type: supplierTypeSchema,
|
|
37
|
+
status: supplierStatusSchema.default("active"),
|
|
38
|
+
description: z.string().optional().nullable(),
|
|
39
|
+
email: z.string().email().optional().nullable(),
|
|
40
|
+
phone: z.string().optional().nullable(),
|
|
41
|
+
website: z.string().url().optional().nullable(),
|
|
42
|
+
address: z.string().optional().nullable(),
|
|
43
|
+
city: z.string().optional().nullable(),
|
|
44
|
+
country: z.string().optional().nullable(),
|
|
45
|
+
defaultCurrency: z.string().max(3).optional().nullable(),
|
|
46
|
+
primaryFacilityId: z.string().optional().nullable(),
|
|
47
|
+
contactName: z.string().optional().nullable(),
|
|
48
|
+
contactEmail: z.string().email().optional().nullable(),
|
|
49
|
+
contactPhone: z.string().optional().nullable(),
|
|
50
|
+
paymentTermsDays: z.number().int().positive().optional().nullable(),
|
|
51
|
+
reservationTimeoutMinutes: z
|
|
52
|
+
.number()
|
|
53
|
+
.int()
|
|
54
|
+
.min(0)
|
|
55
|
+
.max(24 * 60)
|
|
56
|
+
.optional()
|
|
57
|
+
.nullable(),
|
|
58
|
+
customerPaymentPolicy: customerPaymentPolicySchema.optional().nullable(),
|
|
59
|
+
tags: z.array(z.string()).default([]),
|
|
60
|
+
});
|
|
61
|
+
export const insertSupplierSchema = supplierCoreSchema;
|
|
62
|
+
export const updateSupplierSchema = supplierCoreSchema.partial();
|
|
63
|
+
export const selectSupplierSchema = supplierCoreSchema.extend({
|
|
64
|
+
id: typeIdSchema("suppliers"),
|
|
65
|
+
createdAt: z.coerce.date(),
|
|
66
|
+
updatedAt: z.coerce.date(),
|
|
67
|
+
});
|
|
68
|
+
export const supplierListSortFieldSchema = z.enum([
|
|
69
|
+
"name",
|
|
70
|
+
"type",
|
|
71
|
+
"status",
|
|
72
|
+
"defaultCurrency",
|
|
73
|
+
"createdAt",
|
|
74
|
+
]);
|
|
75
|
+
export const supplierListSortDirSchema = z.enum(["asc", "desc"]);
|
|
76
|
+
export const supplierListQuerySchema = z.object({
|
|
77
|
+
type: supplierTypeSchema.optional(),
|
|
78
|
+
status: supplierStatusSchema.optional(),
|
|
79
|
+
primaryFacilityId: z.string().optional(),
|
|
80
|
+
country: z.string().optional(),
|
|
81
|
+
defaultCurrency: z.string().optional(),
|
|
82
|
+
search: z.string().optional(),
|
|
83
|
+
sortBy: supplierListSortFieldSchema.default("createdAt"),
|
|
84
|
+
sortDir: supplierListSortDirSchema.default("desc"),
|
|
85
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
86
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
87
|
+
});
|
|
88
|
+
export const supplierAggregatesQuerySchema = z.object({
|
|
89
|
+
from: z.string().datetime().optional(),
|
|
90
|
+
to: z.string().datetime().optional(),
|
|
91
|
+
});
|
|
92
|
+
// ---------- services ----------
|
|
93
|
+
const serviceCoreSchema = z.object({
|
|
94
|
+
serviceType: serviceTypeSchema,
|
|
95
|
+
facilityId: z.string().optional().nullable(),
|
|
96
|
+
name: z.string().min(1).max(255),
|
|
97
|
+
description: z.string().optional().nullable(),
|
|
98
|
+
duration: z.string().optional().nullable(),
|
|
99
|
+
capacity: z.number().int().positive().optional().nullable(),
|
|
100
|
+
active: z.boolean().default(true),
|
|
101
|
+
tags: z.array(z.string()).default([]),
|
|
102
|
+
});
|
|
103
|
+
export const insertServiceSchema = serviceCoreSchema;
|
|
104
|
+
export const updateServiceSchema = serviceCoreSchema.partial();
|
|
105
|
+
// ---------- rates ----------
|
|
106
|
+
const rateCoreSchema = z.object({
|
|
107
|
+
name: z.string().min(1).max(255),
|
|
108
|
+
currency: z.string().min(3).max(3),
|
|
109
|
+
amountCents: z.number().int().min(0),
|
|
110
|
+
unit: rateUnitSchema,
|
|
111
|
+
validFrom: z.string().optional().nullable(),
|
|
112
|
+
validTo: z.string().optional().nullable(),
|
|
113
|
+
minPax: z.number().int().positive().optional().nullable(),
|
|
114
|
+
maxPax: z.number().int().positive().optional().nullable(),
|
|
115
|
+
notes: z.string().optional().nullable(),
|
|
116
|
+
});
|
|
117
|
+
export const insertRateSchema = rateCoreSchema;
|
|
118
|
+
export const updateRateSchema = rateCoreSchema.partial();
|
|
119
|
+
// ---------- notes ----------
|
|
120
|
+
export const insertSupplierNoteSchema = z.object({
|
|
121
|
+
content: z.string().min(1).max(10000),
|
|
122
|
+
});
|
|
123
|
+
// ---------- availability ----------
|
|
124
|
+
export const insertAvailabilitySchema = z.object({
|
|
125
|
+
date: z.string().min(1),
|
|
126
|
+
available: z.boolean().default(true),
|
|
127
|
+
notes: z.string().optional().nullable(),
|
|
128
|
+
});
|
|
129
|
+
export const availabilityQuerySchema = z.object({
|
|
130
|
+
from: z.string().optional(),
|
|
131
|
+
to: z.string().optional(),
|
|
132
|
+
});
|
|
133
|
+
// ---------- contracts ----------
|
|
134
|
+
const supplierContractStatusSchema = z.enum(["active", "expired", "pending", "terminated"]);
|
|
135
|
+
const contractCoreSchema = z.object({
|
|
136
|
+
agreementNumber: z.string().max(255).optional().nullable(),
|
|
137
|
+
startDate: z.string().min(1),
|
|
138
|
+
endDate: z.string().optional().nullable(),
|
|
139
|
+
renewalDate: z.string().optional().nullable(),
|
|
140
|
+
terms: z.string().optional().nullable(),
|
|
141
|
+
status: supplierContractStatusSchema.default("active"),
|
|
142
|
+
});
|
|
143
|
+
export const insertContractSchema = contractCoreSchema;
|
|
144
|
+
export const updateContractSchema = contractCoreSchema.partial();
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/suppliers-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
|
+
"@voyantjs/schema-kit": "workspace:*",
|
|
40
|
+
"zod": "^4.3.6"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
44
|
+
"typescript": "^6.0.2",
|
|
45
|
+
"vitest": "^4.1.2"
|
|
46
|
+
},
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
50
|
+
"directory": "packages/suppliers-contracts"
|
|
51
|
+
}
|
|
52
|
+
}
|