@voyantjs/sellability 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.
- package/LICENSE +109 -0
- package/README.md +34 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/routes.d.ts +1382 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +169 -0
- package/dist/schema.d.ts +1716 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +276 -0
- package/dist/service.d.ts +758 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +1219 -0
- package/dist/validation.d.ts +593 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +235 -0
- package/package.json +57 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { booleanQueryParam } from "@voyantjs/db/helpers";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const requestedUnitSchema = z.object({
|
|
4
|
+
requestRef: z.string().min(1).max(100).optional(),
|
|
5
|
+
unitId: z.string().nullable().optional(),
|
|
6
|
+
pricingCategoryId: z.string().nullable().optional(),
|
|
7
|
+
quantity: z.number().int().min(1),
|
|
8
|
+
});
|
|
9
|
+
export const sellabilityResolveQuerySchema = z.object({
|
|
10
|
+
productId: z.string().optional(),
|
|
11
|
+
optionId: z.string().optional(),
|
|
12
|
+
slotId: z.string().optional(),
|
|
13
|
+
dateLocal: z.string().date().optional(),
|
|
14
|
+
startTimeId: z.string().optional(),
|
|
15
|
+
marketId: z.string().optional(),
|
|
16
|
+
channelId: z.string().optional(),
|
|
17
|
+
pickupPointId: z.string().optional(),
|
|
18
|
+
currencyCode: z.string().length(3).optional(),
|
|
19
|
+
requestedUnits: z.array(requestedUnitSchema).default([]),
|
|
20
|
+
limit: z.number().int().min(1).max(100).default(25),
|
|
21
|
+
});
|
|
22
|
+
export const sellabilitySnapshotStatusSchema = z.enum(["resolved", "offer_constructed", "expired"]);
|
|
23
|
+
export const sellabilityPolicyScopeSchema = z.enum([
|
|
24
|
+
"global",
|
|
25
|
+
"product",
|
|
26
|
+
"option",
|
|
27
|
+
"market",
|
|
28
|
+
"channel",
|
|
29
|
+
]);
|
|
30
|
+
export const sellabilityPolicyTypeSchema = z.enum([
|
|
31
|
+
"capability",
|
|
32
|
+
"occupancy",
|
|
33
|
+
"pickup",
|
|
34
|
+
"question",
|
|
35
|
+
"allotment",
|
|
36
|
+
"availability_window",
|
|
37
|
+
"currency",
|
|
38
|
+
"custom",
|
|
39
|
+
]);
|
|
40
|
+
export const sellabilityPolicyResultStatusSchema = z.enum([
|
|
41
|
+
"passed",
|
|
42
|
+
"blocked",
|
|
43
|
+
"warning",
|
|
44
|
+
"adjusted",
|
|
45
|
+
]);
|
|
46
|
+
export const offerRefreshRunStatusSchema = z.enum([
|
|
47
|
+
"pending",
|
|
48
|
+
"running",
|
|
49
|
+
"completed",
|
|
50
|
+
"failed",
|
|
51
|
+
"expired",
|
|
52
|
+
]);
|
|
53
|
+
export const offerExpirationEventStatusSchema = z.enum([
|
|
54
|
+
"scheduled",
|
|
55
|
+
"expired",
|
|
56
|
+
"cancelled",
|
|
57
|
+
"superseded",
|
|
58
|
+
]);
|
|
59
|
+
export const sellabilityExplanationTypeSchema = z.enum([
|
|
60
|
+
"sellable",
|
|
61
|
+
"blocked",
|
|
62
|
+
"warning",
|
|
63
|
+
"pricing",
|
|
64
|
+
"allotment",
|
|
65
|
+
"pickup",
|
|
66
|
+
"policy",
|
|
67
|
+
]);
|
|
68
|
+
export const sellabilityOfferParticipantSchema = z.object({
|
|
69
|
+
personId: z.string().nullable().optional(),
|
|
70
|
+
participantType: z
|
|
71
|
+
.enum(["traveler", "booker", "contact", "occupant", "staff", "other"])
|
|
72
|
+
.default("traveler"),
|
|
73
|
+
travelerCategory: z.enum(["adult", "child", "infant", "senior", "other"]).nullable().optional(),
|
|
74
|
+
firstName: z.string().min(1).max(255),
|
|
75
|
+
lastName: z.string().min(1).max(255),
|
|
76
|
+
email: z.string().email().nullable().optional(),
|
|
77
|
+
phone: z.string().max(50).nullable().optional(),
|
|
78
|
+
preferredLanguage: z.string().max(35).nullable().optional(),
|
|
79
|
+
dateOfBirth: z.string().nullable().optional(),
|
|
80
|
+
nationality: z.string().max(2).nullable().optional(),
|
|
81
|
+
isPrimary: z.boolean().default(false),
|
|
82
|
+
notes: z.string().nullable().optional(),
|
|
83
|
+
requestedUnitRefs: z.array(z.string().min(1).max(100)).default([]),
|
|
84
|
+
assignToAllItems: z.boolean().default(false),
|
|
85
|
+
itemParticipantRole: z
|
|
86
|
+
.enum(["traveler", "occupant", "primary_contact", "beneficiary", "service_assignee", "other"])
|
|
87
|
+
.optional(),
|
|
88
|
+
});
|
|
89
|
+
export const sellabilityConstructOfferSchema = z.object({
|
|
90
|
+
query: sellabilityResolveQuerySchema.omit({ limit: true }).extend({
|
|
91
|
+
slotId: z.string(),
|
|
92
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
93
|
+
}),
|
|
94
|
+
offer: z.object({
|
|
95
|
+
offerNumber: z.string().min(1).max(50).optional(),
|
|
96
|
+
title: z.string().min(1).max(255).optional(),
|
|
97
|
+
status: z
|
|
98
|
+
.enum(["draft", "published", "sent", "accepted", "expired", "withdrawn", "converted"])
|
|
99
|
+
.default("published"),
|
|
100
|
+
personId: z.string().nullable().optional(),
|
|
101
|
+
organizationId: z.string().nullable().optional(),
|
|
102
|
+
opportunityId: z.string().nullable().optional(),
|
|
103
|
+
quoteId: z.string().nullable().optional(),
|
|
104
|
+
validFrom: z.string().nullable().optional(),
|
|
105
|
+
validUntil: z.string().nullable().optional(),
|
|
106
|
+
notes: z.string().nullable().optional(),
|
|
107
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
108
|
+
}),
|
|
109
|
+
participants: z.array(sellabilityOfferParticipantSchema).default([]),
|
|
110
|
+
});
|
|
111
|
+
export const sellabilityPersistSnapshotSchema = z.object({
|
|
112
|
+
query: sellabilityResolveQuerySchema,
|
|
113
|
+
expiresAt: z.string().datetime().nullable().optional(),
|
|
114
|
+
});
|
|
115
|
+
export const sellabilitySnapshotListQuerySchema = z.object({
|
|
116
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
117
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
118
|
+
offerId: z.string().optional(),
|
|
119
|
+
marketId: z.string().optional(),
|
|
120
|
+
channelId: z.string().optional(),
|
|
121
|
+
productId: z.string().optional(),
|
|
122
|
+
optionId: z.string().optional(),
|
|
123
|
+
slotId: z.string().optional(),
|
|
124
|
+
status: sellabilitySnapshotStatusSchema.optional(),
|
|
125
|
+
});
|
|
126
|
+
export const sellabilitySnapshotItemListQuerySchema = z.object({
|
|
127
|
+
limit: z.coerce.number().int().min(1).max(200).default(100),
|
|
128
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
129
|
+
snapshotId: z.string().optional(),
|
|
130
|
+
productId: z.string().optional(),
|
|
131
|
+
optionId: z.string().optional(),
|
|
132
|
+
slotId: z.string().optional(),
|
|
133
|
+
unitId: z.string().optional(),
|
|
134
|
+
});
|
|
135
|
+
export const sellabilityPolicyCoreSchema = z.object({
|
|
136
|
+
name: z.string().min(1).max(255),
|
|
137
|
+
scope: sellabilityPolicyScopeSchema.default("global"),
|
|
138
|
+
policyType: sellabilityPolicyTypeSchema.default("custom"),
|
|
139
|
+
productId: z.string().nullable().optional(),
|
|
140
|
+
optionId: z.string().nullable().optional(),
|
|
141
|
+
marketId: z.string().nullable().optional(),
|
|
142
|
+
channelId: z.string().nullable().optional(),
|
|
143
|
+
priority: z.number().int().default(0),
|
|
144
|
+
active: z.boolean().default(true),
|
|
145
|
+
conditions: z.record(z.string(), z.unknown()).default({}),
|
|
146
|
+
effects: z.record(z.string(), z.unknown()).default({}),
|
|
147
|
+
notes: z.string().nullable().optional(),
|
|
148
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
149
|
+
});
|
|
150
|
+
export const insertSellabilityPolicySchema = sellabilityPolicyCoreSchema;
|
|
151
|
+
export const updateSellabilityPolicySchema = sellabilityPolicyCoreSchema.partial();
|
|
152
|
+
export const sellabilityPolicyListQuerySchema = z.object({
|
|
153
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
154
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
155
|
+
scope: sellabilityPolicyScopeSchema.optional(),
|
|
156
|
+
policyType: sellabilityPolicyTypeSchema.optional(),
|
|
157
|
+
productId: z.string().optional(),
|
|
158
|
+
optionId: z.string().optional(),
|
|
159
|
+
marketId: z.string().optional(),
|
|
160
|
+
channelId: z.string().optional(),
|
|
161
|
+
active: booleanQueryParam.optional(),
|
|
162
|
+
});
|
|
163
|
+
export const sellabilityPolicyResultCoreSchema = z.object({
|
|
164
|
+
snapshotId: z.string(),
|
|
165
|
+
snapshotItemId: z.string().nullable().optional(),
|
|
166
|
+
policyId: z.string().nullable().optional(),
|
|
167
|
+
candidateIndex: z.number().int().min(0).default(0),
|
|
168
|
+
status: sellabilityPolicyResultStatusSchema.default("passed"),
|
|
169
|
+
message: z.string().nullable().optional(),
|
|
170
|
+
details: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
171
|
+
});
|
|
172
|
+
export const insertSellabilityPolicyResultSchema = sellabilityPolicyResultCoreSchema;
|
|
173
|
+
export const updateSellabilityPolicyResultSchema = sellabilityPolicyResultCoreSchema.partial();
|
|
174
|
+
export const sellabilityPolicyResultListQuerySchema = z.object({
|
|
175
|
+
limit: z.coerce.number().int().min(1).max(200).default(100),
|
|
176
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
177
|
+
snapshotId: z.string().optional(),
|
|
178
|
+
snapshotItemId: z.string().optional(),
|
|
179
|
+
policyId: z.string().optional(),
|
|
180
|
+
status: sellabilityPolicyResultStatusSchema.optional(),
|
|
181
|
+
});
|
|
182
|
+
export const offerRefreshRunCoreSchema = z.object({
|
|
183
|
+
offerId: z.string(),
|
|
184
|
+
snapshotId: z.string().nullable().optional(),
|
|
185
|
+
status: offerRefreshRunStatusSchema.default("pending"),
|
|
186
|
+
startedAt: z.string().datetime().nullable().optional(),
|
|
187
|
+
completedAt: z.string().datetime().nullable().optional(),
|
|
188
|
+
notes: z.string().nullable().optional(),
|
|
189
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
190
|
+
});
|
|
191
|
+
export const insertOfferRefreshRunSchema = offerRefreshRunCoreSchema;
|
|
192
|
+
export const updateOfferRefreshRunSchema = offerRefreshRunCoreSchema.partial();
|
|
193
|
+
export const offerRefreshRunListQuerySchema = z.object({
|
|
194
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
195
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
196
|
+
offerId: z.string().optional(),
|
|
197
|
+
snapshotId: z.string().optional(),
|
|
198
|
+
status: offerRefreshRunStatusSchema.optional(),
|
|
199
|
+
});
|
|
200
|
+
export const offerExpirationEventCoreSchema = z.object({
|
|
201
|
+
offerId: z.string(),
|
|
202
|
+
snapshotId: z.string().nullable().optional(),
|
|
203
|
+
expiresAt: z.string().datetime(),
|
|
204
|
+
expiredAt: z.string().datetime().nullable().optional(),
|
|
205
|
+
status: offerExpirationEventStatusSchema.default("scheduled"),
|
|
206
|
+
reason: z.string().nullable().optional(),
|
|
207
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
208
|
+
});
|
|
209
|
+
export const insertOfferExpirationEventSchema = offerExpirationEventCoreSchema;
|
|
210
|
+
export const updateOfferExpirationEventSchema = offerExpirationEventCoreSchema.partial();
|
|
211
|
+
export const offerExpirationEventListQuerySchema = z.object({
|
|
212
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
213
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
214
|
+
offerId: z.string().optional(),
|
|
215
|
+
snapshotId: z.string().optional(),
|
|
216
|
+
status: offerExpirationEventStatusSchema.optional(),
|
|
217
|
+
});
|
|
218
|
+
export const sellabilityExplanationCoreSchema = z.object({
|
|
219
|
+
snapshotId: z.string(),
|
|
220
|
+
snapshotItemId: z.string().nullable().optional(),
|
|
221
|
+
candidateIndex: z.number().int().min(0).default(0),
|
|
222
|
+
explanationType: sellabilityExplanationTypeSchema.default("policy"),
|
|
223
|
+
code: z.string().nullable().optional(),
|
|
224
|
+
message: z.string().min(1),
|
|
225
|
+
details: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
226
|
+
});
|
|
227
|
+
export const insertSellabilityExplanationSchema = sellabilityExplanationCoreSchema;
|
|
228
|
+
export const updateSellabilityExplanationSchema = sellabilityExplanationCoreSchema.partial();
|
|
229
|
+
export const sellabilityExplanationListQuerySchema = z.object({
|
|
230
|
+
limit: z.coerce.number().int().min(1).max(200).default(100),
|
|
231
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
232
|
+
snapshotId: z.string().optional(),
|
|
233
|
+
snapshotItemId: z.string().optional(),
|
|
234
|
+
explanationType: sellabilityExplanationTypeSchema.optional(),
|
|
235
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/sellability",
|
|
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/availability": "0.1.0",
|
|
29
|
+
"@voyantjs/db": "0.1.0",
|
|
30
|
+
"@voyantjs/core": "0.1.0",
|
|
31
|
+
"@voyantjs/distribution": "0.1.0",
|
|
32
|
+
"@voyantjs/hono": "0.1.0",
|
|
33
|
+
"@voyantjs/pricing": "0.1.0",
|
|
34
|
+
"@voyantjs/products": "0.1.0",
|
|
35
|
+
"@voyantjs/transactions": "0.1.0",
|
|
36
|
+
"@voyantjs/markets": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^6.0.2",
|
|
40
|
+
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"lint": "biome check src/",
|
|
51
|
+
"test": "vitest run --passWithNoTests",
|
|
52
|
+
"build": "tsc -p tsconfig.json",
|
|
53
|
+
"clean": "rm -rf dist"
|
|
54
|
+
},
|
|
55
|
+
"main": "./dist/index.js",
|
|
56
|
+
"types": "./dist/index.d.ts"
|
|
57
|
+
}
|