@voyantjs/suppliers 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,231 @@
1
+ import { z } from "zod";
2
+ export declare const insertSupplierSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ type: z.ZodEnum<{
5
+ other: "other";
6
+ hotel: "hotel";
7
+ restaurant: "restaurant";
8
+ transfer: "transfer";
9
+ guide: "guide";
10
+ experience: "experience";
11
+ airline: "airline";
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
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
32
+ }, z.core.$strip>;
33
+ export declare const updateSupplierSchema: z.ZodObject<{
34
+ name: z.ZodOptional<z.ZodString>;
35
+ type: z.ZodOptional<z.ZodEnum<{
36
+ other: "other";
37
+ hotel: "hotel";
38
+ restaurant: "restaurant";
39
+ transfer: "transfer";
40
+ guide: "guide";
41
+ experience: "experience";
42
+ airline: "airline";
43
+ }>>;
44
+ status: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
45
+ active: "active";
46
+ inactive: "inactive";
47
+ pending: "pending";
48
+ }>>>;
49
+ description: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
50
+ email: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
51
+ phone: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
52
+ website: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
53
+ address: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
54
+ city: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
55
+ country: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
56
+ defaultCurrency: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
57
+ primaryFacilityId: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
58
+ contactName: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
59
+ contactEmail: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
60
+ contactPhone: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
61
+ paymentTermsDays: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
62
+ tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
63
+ }, z.core.$strip>;
64
+ export declare const selectSupplierSchema: z.ZodObject<{
65
+ name: z.ZodString;
66
+ type: z.ZodEnum<{
67
+ other: "other";
68
+ hotel: "hotel";
69
+ restaurant: "restaurant";
70
+ transfer: "transfer";
71
+ guide: "guide";
72
+ experience: "experience";
73
+ airline: "airline";
74
+ }>;
75
+ status: z.ZodDefault<z.ZodEnum<{
76
+ active: "active";
77
+ inactive: "inactive";
78
+ pending: "pending";
79
+ }>>;
80
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
81
+ email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
82
+ phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
83
+ website: z.ZodNullable<z.ZodOptional<z.ZodString>>;
84
+ address: z.ZodNullable<z.ZodOptional<z.ZodString>>;
85
+ city: z.ZodNullable<z.ZodOptional<z.ZodString>>;
86
+ country: z.ZodNullable<z.ZodOptional<z.ZodString>>;
87
+ defaultCurrency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
88
+ primaryFacilityId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
89
+ contactName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
90
+ contactEmail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
91
+ contactPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
92
+ paymentTermsDays: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
93
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
94
+ id: z.ZodString;
95
+ createdAt: z.ZodCoercedDate<unknown>;
96
+ updatedAt: z.ZodCoercedDate<unknown>;
97
+ }, z.core.$strip>;
98
+ export declare const supplierListQuerySchema: z.ZodObject<{
99
+ type: z.ZodOptional<z.ZodEnum<{
100
+ other: "other";
101
+ hotel: "hotel";
102
+ restaurant: "restaurant";
103
+ transfer: "transfer";
104
+ guide: "guide";
105
+ experience: "experience";
106
+ airline: "airline";
107
+ }>>;
108
+ status: z.ZodOptional<z.ZodEnum<{
109
+ active: "active";
110
+ inactive: "inactive";
111
+ pending: "pending";
112
+ }>>;
113
+ primaryFacilityId: z.ZodOptional<z.ZodString>;
114
+ search: z.ZodOptional<z.ZodString>;
115
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
116
+ offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
117
+ }, z.core.$strip>;
118
+ export type InsertSupplier = z.infer<typeof insertSupplierSchema>;
119
+ export type UpdateSupplier = z.infer<typeof updateSupplierSchema>;
120
+ export type SelectSupplier = z.infer<typeof selectSupplierSchema>;
121
+ export declare const insertServiceSchema: z.ZodObject<{
122
+ serviceType: z.ZodEnum<{
123
+ other: "other";
124
+ transfer: "transfer";
125
+ guide: "guide";
126
+ experience: "experience";
127
+ accommodation: "accommodation";
128
+ meal: "meal";
129
+ }>;
130
+ facilityId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
131
+ name: z.ZodString;
132
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
133
+ duration: z.ZodNullable<z.ZodOptional<z.ZodString>>;
134
+ capacity: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
135
+ active: z.ZodDefault<z.ZodBoolean>;
136
+ tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
137
+ }, z.core.$strip>;
138
+ export declare const updateServiceSchema: z.ZodObject<{
139
+ serviceType: z.ZodOptional<z.ZodEnum<{
140
+ other: "other";
141
+ transfer: "transfer";
142
+ guide: "guide";
143
+ experience: "experience";
144
+ accommodation: "accommodation";
145
+ meal: "meal";
146
+ }>>;
147
+ facilityId: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
148
+ name: z.ZodOptional<z.ZodString>;
149
+ description: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
150
+ duration: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
151
+ capacity: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
152
+ active: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
153
+ tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
154
+ }, z.core.$strip>;
155
+ export type InsertService = z.infer<typeof insertServiceSchema>;
156
+ export type UpdateService = z.infer<typeof updateServiceSchema>;
157
+ export declare const insertRateSchema: z.ZodObject<{
158
+ name: z.ZodString;
159
+ currency: z.ZodString;
160
+ amountCents: z.ZodNumber;
161
+ unit: z.ZodEnum<{
162
+ flat: "flat";
163
+ per_person: "per_person";
164
+ per_group: "per_group";
165
+ per_night: "per_night";
166
+ per_vehicle: "per_vehicle";
167
+ }>;
168
+ validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
169
+ validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
170
+ minPax: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
171
+ maxPax: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
172
+ notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
173
+ }, z.core.$strip>;
174
+ export declare const updateRateSchema: z.ZodObject<{
175
+ name: z.ZodOptional<z.ZodString>;
176
+ currency: z.ZodOptional<z.ZodString>;
177
+ amountCents: z.ZodOptional<z.ZodNumber>;
178
+ unit: z.ZodOptional<z.ZodEnum<{
179
+ flat: "flat";
180
+ per_person: "per_person";
181
+ per_group: "per_group";
182
+ per_night: "per_night";
183
+ per_vehicle: "per_vehicle";
184
+ }>>;
185
+ validFrom: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
186
+ validTo: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
187
+ minPax: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
188
+ maxPax: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
189
+ notes: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
190
+ }, z.core.$strip>;
191
+ export type InsertRate = z.infer<typeof insertRateSchema>;
192
+ export type UpdateRate = z.infer<typeof updateRateSchema>;
193
+ export declare const insertSupplierNoteSchema: z.ZodObject<{
194
+ content: z.ZodString;
195
+ }, z.core.$strip>;
196
+ export declare const insertAvailabilitySchema: z.ZodObject<{
197
+ date: z.ZodString;
198
+ available: z.ZodDefault<z.ZodBoolean>;
199
+ notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
200
+ }, z.core.$strip>;
201
+ export declare const availabilityQuerySchema: z.ZodObject<{
202
+ from: z.ZodOptional<z.ZodString>;
203
+ to: z.ZodOptional<z.ZodString>;
204
+ }, z.core.$strip>;
205
+ export declare const insertContractSchema: z.ZodObject<{
206
+ agreementNumber: z.ZodNullable<z.ZodOptional<z.ZodString>>;
207
+ startDate: z.ZodString;
208
+ endDate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
209
+ renewalDate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
210
+ terms: z.ZodNullable<z.ZodOptional<z.ZodString>>;
211
+ status: z.ZodDefault<z.ZodEnum<{
212
+ active: "active";
213
+ pending: "pending";
214
+ expired: "expired";
215
+ terminated: "terminated";
216
+ }>>;
217
+ }, z.core.$strip>;
218
+ export declare const updateContractSchema: z.ZodObject<{
219
+ agreementNumber: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
220
+ startDate: z.ZodOptional<z.ZodString>;
221
+ endDate: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
222
+ renewalDate: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
223
+ terms: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
224
+ status: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
225
+ active: "active";
226
+ pending: "pending";
227
+ expired: "expired";
228
+ terminated: "terminated";
229
+ }>>>;
230
+ }, z.core.$strip>;
231
+ //# 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;AA+CvB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAqB,CAAA;AACtD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA+B,CAAA;AAChE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI/B,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;iBAOlC,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,109 @@
1
+ import { typeIdSchema } from "@voyantjs/db/lib/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 supplierCoreSchema = z.object({
24
+ name: z.string().min(1).max(255),
25
+ type: supplierTypeSchema,
26
+ status: supplierStatusSchema.default("active"),
27
+ description: z.string().optional().nullable(),
28
+ email: z.string().email().optional().nullable(),
29
+ phone: z.string().optional().nullable(),
30
+ website: z.string().url().optional().nullable(),
31
+ address: z.string().optional().nullable(),
32
+ city: z.string().optional().nullable(),
33
+ country: z.string().optional().nullable(),
34
+ defaultCurrency: z.string().max(3).optional().nullable(),
35
+ primaryFacilityId: z.string().optional().nullable(),
36
+ contactName: z.string().optional().nullable(),
37
+ contactEmail: z.string().email().optional().nullable(),
38
+ contactPhone: z.string().optional().nullable(),
39
+ paymentTermsDays: z.number().int().positive().optional().nullable(),
40
+ tags: z.array(z.string()).default([]),
41
+ });
42
+ export const insertSupplierSchema = supplierCoreSchema;
43
+ export const updateSupplierSchema = supplierCoreSchema.partial();
44
+ export const selectSupplierSchema = supplierCoreSchema.extend({
45
+ id: typeIdSchema("suppliers"),
46
+ createdAt: z.coerce.date(),
47
+ updatedAt: z.coerce.date(),
48
+ });
49
+ export const supplierListQuerySchema = z.object({
50
+ type: supplierTypeSchema.optional(),
51
+ status: supplierStatusSchema.optional(),
52
+ primaryFacilityId: z.string().optional(),
53
+ search: z.string().optional(),
54
+ limit: z.coerce.number().int().min(1).max(100).default(50),
55
+ offset: z.coerce.number().int().min(0).default(0),
56
+ });
57
+ // ---------- services ----------
58
+ const serviceCoreSchema = z.object({
59
+ serviceType: serviceTypeSchema,
60
+ facilityId: z.string().optional().nullable(),
61
+ name: z.string().min(1).max(255),
62
+ description: z.string().optional().nullable(),
63
+ duration: z.string().optional().nullable(),
64
+ capacity: z.number().int().positive().optional().nullable(),
65
+ active: z.boolean().default(true),
66
+ tags: z.array(z.string()).default([]),
67
+ });
68
+ export const insertServiceSchema = serviceCoreSchema;
69
+ export const updateServiceSchema = serviceCoreSchema.partial();
70
+ // ---------- rates ----------
71
+ const rateCoreSchema = z.object({
72
+ name: z.string().min(1).max(255),
73
+ currency: z.string().min(3).max(3),
74
+ amountCents: z.number().int().min(0),
75
+ unit: rateUnitSchema,
76
+ validFrom: z.string().optional().nullable(),
77
+ validTo: z.string().optional().nullable(),
78
+ minPax: z.number().int().positive().optional().nullable(),
79
+ maxPax: z.number().int().positive().optional().nullable(),
80
+ notes: z.string().optional().nullable(),
81
+ });
82
+ export const insertRateSchema = rateCoreSchema;
83
+ export const updateRateSchema = rateCoreSchema.partial();
84
+ // ---------- notes ----------
85
+ export const insertSupplierNoteSchema = z.object({
86
+ content: z.string().min(1).max(10000),
87
+ });
88
+ // ---------- availability ----------
89
+ export const insertAvailabilitySchema = z.object({
90
+ date: z.string().min(1),
91
+ available: z.boolean().default(true),
92
+ notes: z.string().optional().nullable(),
93
+ });
94
+ export const availabilityQuerySchema = z.object({
95
+ from: z.string().optional(),
96
+ to: z.string().optional(),
97
+ });
98
+ // ---------- contracts ----------
99
+ const supplierContractStatusSchema = z.enum(["active", "expired", "pending", "terminated"]);
100
+ const contractCoreSchema = z.object({
101
+ agreementNumber: z.string().max(255).optional().nullable(),
102
+ startDate: z.string().min(1),
103
+ endDate: z.string().optional().nullable(),
104
+ renewalDate: z.string().optional().nullable(),
105
+ terms: z.string().optional().nullable(),
106
+ status: supplierContractStatusSchema.default("active"),
107
+ });
108
+ export const insertContractSchema = contractCoreSchema;
109
+ export const updateContractSchema = contractCoreSchema.partial();
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@voyantjs/suppliers",
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
+ },
24
+ "dependencies": {
25
+ "drizzle-orm": "^0.45.2",
26
+ "hono": "^4.12.10",
27
+ "zod": "^4.3.6",
28
+ "@voyantjs/core": "0.1.0",
29
+ "@voyantjs/db": "0.1.0",
30
+ "@voyantjs/hono": "0.1.0",
31
+ "@voyantjs/identity": "0.1.0",
32
+ "@voyantjs/facilities": "0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "typescript": "^6.0.2",
36
+ "@voyantjs/voyant-typescript-config": "0.1.0"
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "typecheck": "tsc --noEmit",
46
+ "lint": "biome check src/",
47
+ "test": "vitest run",
48
+ "build": "tsc -p tsconfig.json",
49
+ "clean": "rm -rf dist"
50
+ },
51
+ "main": "./dist/index.js",
52
+ "types": "./dist/index.d.ts"
53
+ }