@voyant-travel/inventory 0.5.4 → 0.5.6
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/dist/action-ledger.d.ts +5 -5
- package/dist/authoring/extension.d.ts +4 -4
- package/dist/authoring/spec.d.ts +2 -2
- package/dist/booking-extension.js +1 -1
- package/dist/extras/routes.d.ts +470 -119
- package/dist/extras/routes.d.ts.map +1 -1
- package/dist/extras/routes.js +252 -37
- package/dist/extras/schema.d.ts +2 -2
- package/dist/extras/service.d.ts +11 -11
- package/dist/extras/validation.d.ts +37 -37
- package/dist/extras.d.ts +15 -15
- package/dist/extras.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/interface.d.ts +4417 -1994
- package/dist/interface.d.ts.map +1 -1
- package/dist/interface.js +0 -1
- package/dist/public-tags-contract.test.d.ts +2 -0
- package/dist/public-tags-contract.test.d.ts.map +1 -0
- package/dist/public-tags-contract.test.js +11 -0
- package/dist/public-taxonomy-contract.test.d.ts +2 -0
- package/dist/public-taxonomy-contract.test.d.ts.map +1 -0
- package/dist/public-taxonomy-contract.test.js +37 -0
- package/dist/routes-associations.d.ts +101 -42
- package/dist/routes-associations.d.ts.map +1 -1
- package/dist/routes-associations.js +177 -38
- package/dist/routes-brochure.d.ts +3 -2
- package/dist/routes-brochure.d.ts.map +1 -1
- package/dist/routes-brochure.js +65 -6
- package/dist/routes-brochure.test.js +1 -1
- package/dist/routes-catalog.d.ts +349 -88
- package/dist/routes-catalog.d.ts.map +1 -1
- package/dist/routes-catalog.js +390 -62
- package/dist/routes-configuration.d.ts +507 -129
- package/dist/routes-configuration.d.ts.map +1 -1
- package/dist/routes-configuration.js +668 -90
- package/dist/routes-content.d.ts +4 -4
- package/dist/routes-content.d.ts.map +1 -1
- package/dist/routes-content.js +44 -6
- package/dist/routes-core.d.ts +307 -66
- package/dist/routes-core.d.ts.map +1 -1
- package/dist/routes-core.js +226 -29
- package/dist/routes-itinerary-translations.d.ts +202 -87
- package/dist/routes-itinerary-translations.d.ts.map +1 -1
- package/dist/routes-itinerary-translations.js +261 -55
- package/dist/routes-itinerary.d.ts +580 -212
- package/dist/routes-itinerary.d.ts.map +1 -1
- package/dist/routes-itinerary.js +655 -129
- package/dist/routes-maintenance.d.ts +21 -9
- package/dist/routes-maintenance.d.ts.map +1 -1
- package/dist/routes-maintenance.js +38 -9
- package/dist/routes-media.d.ts +425 -148
- package/dist/routes-media.d.ts.map +1 -1
- package/dist/routes-media.js +438 -128
- package/dist/routes-merchandising.d.ts +906 -316
- package/dist/routes-merchandising.d.ts.map +1 -1
- package/dist/routes-merchandising.js +945 -125
- package/dist/routes-options.d.ts +356 -115
- package/dist/routes-options.d.ts.map +1 -1
- package/dist/routes-options.js +288 -52
- package/dist/routes-public.d.ts +368 -380
- package/dist/routes-public.d.ts.map +1 -1
- package/dist/routes-public.js +256 -40
- package/dist/routes-translations.d.ts +356 -86
- package/dist/routes-translations.d.ts.map +1 -1
- package/dist/routes-translations.js +404 -56
- package/dist/routes.d.ts +4185 -1595
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +8 -3
- package/dist/schema-core.d.ts +1 -1
- package/dist/schema-settings.d.ts +1 -1
- package/dist/service-catalog.d.ts +4 -4
- package/dist/service-core.d.ts +6 -6
- package/dist/service-delivery-formats.d.ts +1 -1
- package/dist/service-destinations.d.ts +3 -3
- package/dist/service-itinerary-translations.d.ts +1 -1
- package/dist/service-itinerary.d.ts +3 -3
- package/dist/service-merchandising.d.ts +5 -5
- package/dist/service-option-translations.d.ts +4 -4
- package/dist/service-options.d.ts +2 -2
- package/dist/service-public.d.ts +12 -12
- package/dist/service-taxonomy.d.ts +4 -4
- package/dist/service.d.ts +41 -41
- package/package.json +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/extras/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/extras/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAe,WAAW,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAG/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAejE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;KACvB,CAAA;CACF,CAAA;AAiSD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAIK,CAAA;AAEvC,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAA;AAEhE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGpB,CAAA"}
|
package/dist/extras/routes.js
CHANGED
|
@@ -1,59 +1,274 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Admin routes for inventory extras — a separately, independently mounted
|
|
3
|
+
* surface (`inventoryExtrasRoutes`) composed into the framework's combined
|
|
4
|
+
* "extras" `OpenAPIHono` module. Covers two resource sub-chains: product-extras
|
|
5
|
+
* CRUD and option-extra-configs CRUD.
|
|
6
|
+
*
|
|
7
|
+
* Migrated to `@hono/zod-openapi` for the OpenAPI admin backfill (voyant#2114 —
|
|
8
|
+
* inventory extras sub-batch, the last inventory batch). Request schemas reuse
|
|
9
|
+
* the existing `validation.ts` schemas the handlers already parse; the list
|
|
10
|
+
* endpoints use the framework's canonical `listResponseSchema(...)` envelope;
|
|
11
|
+
* response row schemas are authored from the Drizzle `$inferSelect` shapes in
|
|
12
|
+
* `schema.ts` (§17: timestamp columns serialize to ISO strings over the wire,
|
|
13
|
+
* integer columns stay numbers). Business logic + service wiring are unchanged;
|
|
14
|
+
* handlers read `c.req.valid(...)`.
|
|
15
|
+
*
|
|
16
|
+
* The routes are split into per-resource child `OpenAPIHono` sub-chains
|
|
17
|
+
* (`.route("/", child)`) rather than one long flat `.openapi()` chain to keep
|
|
18
|
+
* the tsc inference cost linear. Within each child, the static collection paths
|
|
19
|
+
* are registered before the dynamic `/{id}` legs.
|
|
20
|
+
*/
|
|
21
|
+
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
22
|
+
import { openApiValidationHook } from "@voyant-travel/hono";
|
|
23
|
+
import { listResponseSchema } from "@voyant-travel/types";
|
|
3
24
|
import { inventoryExtrasService } from "./service.js";
|
|
4
|
-
import { insertOptionExtraConfigSchema, insertProductExtraSchema, optionExtraConfigListQuerySchema, productExtraListQuerySchema, updateOptionExtraConfigSchema, updateProductExtraSchema, } from "./validation.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
25
|
+
import { extraCollectionModeSchema, extraPricingModeSchema, extraSelectionTypeSchema, insertOptionExtraConfigSchema, insertProductExtraSchema, optionExtraConfigListQuerySchema, productExtraListQuerySchema, updateOptionExtraConfigSchema, updateProductExtraSchema, } from "./validation.js";
|
|
26
|
+
// --- shared response building blocks ---------------------------------------
|
|
27
|
+
// Authored from the Drizzle `$inferSelect` shapes; §17: timestamp columns are
|
|
28
|
+
// ISO strings on the wire.
|
|
29
|
+
const isoTimestamp = z.string();
|
|
30
|
+
const errorResponseSchema = z.object({ error: z.string() });
|
|
31
|
+
const deleteResponseSchema = z.object({ success: z.boolean() });
|
|
32
|
+
const idParamSchema = z.object({ id: z.string() });
|
|
33
|
+
const jsonObject = z.record(z.string(), z.unknown());
|
|
34
|
+
// --- row response schemas (from $inferSelect) ------------------------------
|
|
35
|
+
const productExtraSchema = z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
productId: z.string(),
|
|
38
|
+
supplierId: z.string().nullable(),
|
|
39
|
+
code: z.string().nullable(),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
description: z.string().nullable(),
|
|
42
|
+
selectionType: extraSelectionTypeSchema,
|
|
43
|
+
pricingMode: extraPricingModeSchema,
|
|
44
|
+
pricedPerPerson: z.boolean(),
|
|
45
|
+
collectionMode: extraCollectionModeSchema,
|
|
46
|
+
showOnSlotManifest: z.boolean(),
|
|
47
|
+
minQuantity: z.number().int().nullable(),
|
|
48
|
+
maxQuantity: z.number().int().nullable(),
|
|
49
|
+
defaultQuantity: z.number().int().nullable(),
|
|
50
|
+
active: z.boolean(),
|
|
51
|
+
sortOrder: z.number().int(),
|
|
52
|
+
metadata: jsonObject.nullable(),
|
|
53
|
+
createdAt: isoTimestamp,
|
|
54
|
+
updatedAt: isoTimestamp,
|
|
55
|
+
});
|
|
56
|
+
const optionExtraConfigSchema = z.object({
|
|
57
|
+
id: z.string(),
|
|
58
|
+
optionId: z.string(),
|
|
59
|
+
productExtraId: z.string(),
|
|
60
|
+
selectionType: extraSelectionTypeSchema.nullable(),
|
|
61
|
+
pricingMode: extraPricingModeSchema.nullable(),
|
|
62
|
+
pricedPerPerson: z.boolean().nullable(),
|
|
63
|
+
minQuantity: z.number().int().nullable(),
|
|
64
|
+
maxQuantity: z.number().int().nullable(),
|
|
65
|
+
defaultQuantity: z.number().int().nullable(),
|
|
66
|
+
isDefault: z.boolean(),
|
|
67
|
+
active: z.boolean(),
|
|
68
|
+
sortOrder: z.number().int(),
|
|
69
|
+
notes: z.string().nullable(),
|
|
70
|
+
metadata: jsonObject.nullable(),
|
|
71
|
+
createdAt: isoTimestamp,
|
|
72
|
+
updatedAt: isoTimestamp,
|
|
73
|
+
});
|
|
74
|
+
// --- helpers ---------------------------------------------------------------
|
|
75
|
+
function jsonBody(schema, required, description) {
|
|
76
|
+
return {
|
|
77
|
+
required,
|
|
78
|
+
description,
|
|
79
|
+
content: { "application/json": { schema } },
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function dataResponse(schema, description) {
|
|
83
|
+
return {
|
|
84
|
+
description,
|
|
85
|
+
content: { "application/json": { schema: z.object({ data: schema }) } },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function listResponse(schema, description) {
|
|
89
|
+
return {
|
|
90
|
+
description,
|
|
91
|
+
content: { "application/json": { schema: listResponseSchema(schema) } },
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function notFoundResponse(description) {
|
|
95
|
+
return {
|
|
96
|
+
description,
|
|
97
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function deletedResponse(description) {
|
|
101
|
+
return {
|
|
102
|
+
description,
|
|
103
|
+
content: { "application/json": { schema: deleteResponseSchema } },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const invalidRequestResponse = {
|
|
107
|
+
description: "invalid_request — request input failed validation",
|
|
108
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
109
|
+
};
|
|
110
|
+
// --- product-extras sub-chain ----------------------------------------------
|
|
111
|
+
const listProductExtrasRoute = createRoute({
|
|
112
|
+
method: "get",
|
|
113
|
+
path: "/product-extras",
|
|
114
|
+
request: { query: productExtraListQuerySchema },
|
|
115
|
+
responses: {
|
|
116
|
+
200: listResponse(productExtraSchema, "Paginated product extras"),
|
|
117
|
+
400: invalidRequestResponse,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
const createProductExtraRoute = createRoute({
|
|
121
|
+
method: "post",
|
|
122
|
+
path: "/product-extras",
|
|
123
|
+
request: { body: jsonBody(insertProductExtraSchema, true, "Product extra") },
|
|
124
|
+
responses: {
|
|
125
|
+
201: dataResponse(productExtraSchema, "The created product extra"),
|
|
126
|
+
400: invalidRequestResponse,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
const getProductExtraRoute = createRoute({
|
|
130
|
+
method: "get",
|
|
131
|
+
path: "/product-extras/{id}",
|
|
132
|
+
request: { params: idParamSchema },
|
|
133
|
+
responses: {
|
|
134
|
+
200: dataResponse(productExtraSchema, "A product extra by id"),
|
|
135
|
+
404: notFoundResponse("Product extra not found"),
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
const updateProductExtraRoute = createRoute({
|
|
139
|
+
method: "patch",
|
|
140
|
+
path: "/product-extras/{id}",
|
|
141
|
+
request: {
|
|
142
|
+
params: idParamSchema,
|
|
143
|
+
body: jsonBody(updateProductExtraSchema, false, "Partial product extra update"),
|
|
144
|
+
},
|
|
145
|
+
responses: {
|
|
146
|
+
200: dataResponse(productExtraSchema, "The updated product extra"),
|
|
147
|
+
400: invalidRequestResponse,
|
|
148
|
+
404: notFoundResponse("Product extra not found"),
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
const deleteProductExtraRoute = createRoute({
|
|
152
|
+
method: "delete",
|
|
153
|
+
path: "/product-extras/{id}",
|
|
154
|
+
request: { params: idParamSchema },
|
|
155
|
+
responses: {
|
|
156
|
+
200: deletedResponse("The product extra was deleted"),
|
|
157
|
+
404: notFoundResponse("Product extra not found"),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
const productExtrasRoutes = new OpenAPIHono({ defaultHook: openApiValidationHook })
|
|
161
|
+
.openapi(listProductExtrasRoute, async (c) => {
|
|
162
|
+
return c.json(await inventoryExtrasService.listProductExtras(c.get("db"), c.req.valid("query")), 200);
|
|
9
163
|
})
|
|
10
|
-
.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
164
|
+
.openapi(createProductExtraRoute, async (c) => {
|
|
165
|
+
const row = await inventoryExtrasService.createProductExtra(c.get("db"), c.req.valid("json"));
|
|
166
|
+
if (!row)
|
|
167
|
+
throw new Error("Failed to create product extra");
|
|
168
|
+
return c.json({ data: row }, 201);
|
|
14
169
|
})
|
|
15
|
-
.
|
|
16
|
-
const row = await inventoryExtrasService.getProductExtraById(c.get("db"), c.req.
|
|
170
|
+
.openapi(getProductExtraRoute, async (c) => {
|
|
171
|
+
const row = await inventoryExtrasService.getProductExtraById(c.get("db"), c.req.valid("param").id);
|
|
17
172
|
if (!row)
|
|
18
173
|
return c.json({ error: "Product extra not found" }, 404);
|
|
19
|
-
return c.json({ data: row });
|
|
174
|
+
return c.json({ data: row }, 200);
|
|
20
175
|
})
|
|
21
|
-
.
|
|
22
|
-
const row = await inventoryExtrasService.updateProductExtra(c.get("db"), c.req.
|
|
176
|
+
.openapi(updateProductExtraRoute, async (c) => {
|
|
177
|
+
const row = await inventoryExtrasService.updateProductExtra(c.get("db"), c.req.valid("param").id, c.req.valid("json"));
|
|
23
178
|
if (!row)
|
|
24
179
|
return c.json({ error: "Product extra not found" }, 404);
|
|
25
|
-
return c.json({ data: row });
|
|
180
|
+
return c.json({ data: row }, 200);
|
|
26
181
|
})
|
|
27
|
-
.
|
|
28
|
-
const row = await inventoryExtrasService.deleteProductExtra(c.get("db"), c.req.
|
|
182
|
+
.openapi(deleteProductExtraRoute, async (c) => {
|
|
183
|
+
const row = await inventoryExtrasService.deleteProductExtra(c.get("db"), c.req.valid("param").id);
|
|
29
184
|
if (!row)
|
|
30
185
|
return c.json({ error: "Product extra not found" }, 404);
|
|
31
|
-
return c.json({ success: true });
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
186
|
+
return c.json({ success: true }, 200);
|
|
187
|
+
});
|
|
188
|
+
// --- option-extra-configs sub-chain ----------------------------------------
|
|
189
|
+
const listOptionExtraConfigsRoute = createRoute({
|
|
190
|
+
method: "get",
|
|
191
|
+
path: "/option-extra-configs",
|
|
192
|
+
request: { query: optionExtraConfigListQuerySchema },
|
|
193
|
+
responses: {
|
|
194
|
+
200: listResponse(optionExtraConfigSchema, "Paginated option extra configs"),
|
|
195
|
+
400: invalidRequestResponse,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
const createOptionExtraConfigRoute = createRoute({
|
|
199
|
+
method: "post",
|
|
200
|
+
path: "/option-extra-configs",
|
|
201
|
+
request: { body: jsonBody(insertOptionExtraConfigSchema, true, "Option extra config") },
|
|
202
|
+
responses: {
|
|
203
|
+
201: dataResponse(optionExtraConfigSchema, "The created option extra config"),
|
|
204
|
+
400: invalidRequestResponse,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
const getOptionExtraConfigRoute = createRoute({
|
|
208
|
+
method: "get",
|
|
209
|
+
path: "/option-extra-configs/{id}",
|
|
210
|
+
request: { params: idParamSchema },
|
|
211
|
+
responses: {
|
|
212
|
+
200: dataResponse(optionExtraConfigSchema, "An option extra config by id"),
|
|
213
|
+
404: notFoundResponse("Option extra config not found"),
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
const updateOptionExtraConfigRoute = createRoute({
|
|
217
|
+
method: "patch",
|
|
218
|
+
path: "/option-extra-configs/{id}",
|
|
219
|
+
request: {
|
|
220
|
+
params: idParamSchema,
|
|
221
|
+
body: jsonBody(updateOptionExtraConfigSchema, false, "Partial option extra config update"),
|
|
222
|
+
},
|
|
223
|
+
responses: {
|
|
224
|
+
200: dataResponse(optionExtraConfigSchema, "The updated option extra config"),
|
|
225
|
+
400: invalidRequestResponse,
|
|
226
|
+
404: notFoundResponse("Option extra config not found"),
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
const deleteOptionExtraConfigRoute = createRoute({
|
|
230
|
+
method: "delete",
|
|
231
|
+
path: "/option-extra-configs/{id}",
|
|
232
|
+
request: { params: idParamSchema },
|
|
233
|
+
responses: {
|
|
234
|
+
200: deletedResponse("The option extra config was deleted"),
|
|
235
|
+
404: notFoundResponse("Option extra config not found"),
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
const optionExtraConfigsRoutes = new OpenAPIHono({ defaultHook: openApiValidationHook })
|
|
239
|
+
.openapi(listOptionExtraConfigsRoute, async (c) => {
|
|
240
|
+
return c.json(await inventoryExtrasService.listOptionExtraConfigs(c.get("db"), c.req.valid("query")), 200);
|
|
36
241
|
})
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
242
|
+
.openapi(createOptionExtraConfigRoute, async (c) => {
|
|
243
|
+
const row = await inventoryExtrasService.createOptionExtraConfig(c.get("db"), c.req.valid("json"));
|
|
244
|
+
if (!row)
|
|
245
|
+
throw new Error("Failed to create option extra config");
|
|
246
|
+
return c.json({ data: row }, 201);
|
|
41
247
|
})
|
|
42
|
-
.
|
|
43
|
-
const row = await inventoryExtrasService.getOptionExtraConfigById(c.get("db"), c.req.
|
|
248
|
+
.openapi(getOptionExtraConfigRoute, async (c) => {
|
|
249
|
+
const row = await inventoryExtrasService.getOptionExtraConfigById(c.get("db"), c.req.valid("param").id);
|
|
44
250
|
if (!row)
|
|
45
251
|
return c.json({ error: "Option extra config not found" }, 404);
|
|
46
|
-
return c.json({ data: row });
|
|
252
|
+
return c.json({ data: row }, 200);
|
|
47
253
|
})
|
|
48
|
-
.
|
|
49
|
-
const row = await inventoryExtrasService.updateOptionExtraConfig(c.get("db"), c.req.
|
|
254
|
+
.openapi(updateOptionExtraConfigRoute, async (c) => {
|
|
255
|
+
const row = await inventoryExtrasService.updateOptionExtraConfig(c.get("db"), c.req.valid("param").id, c.req.valid("json"));
|
|
50
256
|
if (!row)
|
|
51
257
|
return c.json({ error: "Option extra config not found" }, 404);
|
|
52
|
-
return c.json({ data: row });
|
|
258
|
+
return c.json({ data: row }, 200);
|
|
53
259
|
})
|
|
54
|
-
.
|
|
55
|
-
const row = await inventoryExtrasService.deleteOptionExtraConfig(c.get("db"), c.req.
|
|
260
|
+
.openapi(deleteOptionExtraConfigRoute, async (c) => {
|
|
261
|
+
const row = await inventoryExtrasService.deleteOptionExtraConfig(c.get("db"), c.req.valid("param").id);
|
|
56
262
|
if (!row)
|
|
57
263
|
return c.json({ error: "Option extra config not found" }, 404);
|
|
58
|
-
return c.json({ success: true });
|
|
264
|
+
return c.json({ success: true }, 200);
|
|
59
265
|
});
|
|
266
|
+
export const inventoryExtrasRoutes = new OpenAPIHono({
|
|
267
|
+
defaultHook: openApiValidationHook,
|
|
268
|
+
})
|
|
269
|
+
.route("/", productExtrasRoutes)
|
|
270
|
+
.route("/", optionExtraConfigsRoutes);
|
|
271
|
+
export const __test__ = {
|
|
272
|
+
productExtraSchema,
|
|
273
|
+
optionExtraConfigSchema,
|
|
274
|
+
};
|
package/dist/extras/schema.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ export declare const productExtras: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
112
112
|
tableName: "product_extras";
|
|
113
113
|
dataType: "string";
|
|
114
114
|
columnType: "PgEnumColumn";
|
|
115
|
-
data: "optional" | "required" | "
|
|
115
|
+
data: "optional" | "required" | "default_selected" | "unavailable";
|
|
116
116
|
driverParam: string;
|
|
117
117
|
notNull: true;
|
|
118
118
|
hasDefault: true;
|
|
@@ -393,7 +393,7 @@ export declare const optionExtraConfigs: import("drizzle-orm/pg-core").PgTableWi
|
|
|
393
393
|
tableName: "option_extra_configs";
|
|
394
394
|
dataType: "string";
|
|
395
395
|
columnType: "PgEnumColumn";
|
|
396
|
-
data: "optional" | "required" | "
|
|
396
|
+
data: "optional" | "required" | "default_selected" | "unavailable";
|
|
397
397
|
driverParam: string;
|
|
398
398
|
notNull: false;
|
|
399
399
|
hasDefault: false;
|
package/dist/extras/service.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const inventoryExtrasService: {
|
|
|
15
15
|
code: string | null;
|
|
16
16
|
name: string;
|
|
17
17
|
description: string | null;
|
|
18
|
-
selectionType: "optional" | "required" | "
|
|
18
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable";
|
|
19
19
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free";
|
|
20
20
|
pricedPerPerson: boolean;
|
|
21
21
|
collectionMode: "none" | "external" | "included" | "booking_total" | "cash_on_trip";
|
|
@@ -36,7 +36,7 @@ export declare const inventoryExtrasService: {
|
|
|
36
36
|
code: string | null;
|
|
37
37
|
name: string;
|
|
38
38
|
description: string | null;
|
|
39
|
-
selectionType: "optional" | "required" | "
|
|
39
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable";
|
|
40
40
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free";
|
|
41
41
|
pricedPerPerson: boolean;
|
|
42
42
|
collectionMode: "none" | "external" | "included" | "booking_total" | "cash_on_trip";
|
|
@@ -51,12 +51,12 @@ export declare const inventoryExtrasService: {
|
|
|
51
51
|
updatedAt: Date;
|
|
52
52
|
} | null>;
|
|
53
53
|
createProductExtra(db: PostgresJsDatabase, data: CreateProductExtraInput): Promise<{
|
|
54
|
+
active: boolean;
|
|
54
55
|
id: string;
|
|
55
56
|
name: string;
|
|
56
|
-
createdAt: Date;
|
|
57
57
|
description: string | null;
|
|
58
|
-
active: boolean;
|
|
59
58
|
supplierId: string | null;
|
|
59
|
+
createdAt: Date;
|
|
60
60
|
updatedAt: Date;
|
|
61
61
|
productId: string;
|
|
62
62
|
code: string | null;
|
|
@@ -64,7 +64,7 @@ export declare const inventoryExtrasService: {
|
|
|
64
64
|
minQuantity: number | null;
|
|
65
65
|
maxQuantity: number | null;
|
|
66
66
|
metadata: Record<string, unknown> | null;
|
|
67
|
-
selectionType: "optional" | "required" | "
|
|
67
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable";
|
|
68
68
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free";
|
|
69
69
|
pricedPerPerson: boolean;
|
|
70
70
|
collectionMode: "none" | "external" | "included" | "booking_total" | "cash_on_trip";
|
|
@@ -78,7 +78,7 @@ export declare const inventoryExtrasService: {
|
|
|
78
78
|
code: string | null;
|
|
79
79
|
name: string;
|
|
80
80
|
description: string | null;
|
|
81
|
-
selectionType: "optional" | "required" | "
|
|
81
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable";
|
|
82
82
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free";
|
|
83
83
|
pricedPerPerson: boolean;
|
|
84
84
|
collectionMode: "none" | "external" | "included" | "booking_total" | "cash_on_trip";
|
|
@@ -99,7 +99,7 @@ export declare const inventoryExtrasService: {
|
|
|
99
99
|
id: string;
|
|
100
100
|
optionId: string;
|
|
101
101
|
productExtraId: string;
|
|
102
|
-
selectionType: "optional" | "required" | "
|
|
102
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
|
|
103
103
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free" | null;
|
|
104
104
|
pricedPerPerson: boolean | null;
|
|
105
105
|
minQuantity: number | null;
|
|
@@ -117,7 +117,7 @@ export declare const inventoryExtrasService: {
|
|
|
117
117
|
id: string;
|
|
118
118
|
optionId: string;
|
|
119
119
|
productExtraId: string;
|
|
120
|
-
selectionType: "optional" | "required" | "
|
|
120
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
|
|
121
121
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free" | null;
|
|
122
122
|
pricedPerPerson: boolean | null;
|
|
123
123
|
minQuantity: number | null;
|
|
@@ -132,9 +132,9 @@ export declare const inventoryExtrasService: {
|
|
|
132
132
|
updatedAt: Date;
|
|
133
133
|
} | null>;
|
|
134
134
|
createOptionExtraConfig(db: PostgresJsDatabase, data: CreateOptionExtraConfigInput): Promise<{
|
|
135
|
+
active: boolean;
|
|
135
136
|
id: string;
|
|
136
137
|
createdAt: Date;
|
|
137
|
-
active: boolean;
|
|
138
138
|
updatedAt: Date;
|
|
139
139
|
isDefault: boolean;
|
|
140
140
|
sortOrder: number;
|
|
@@ -143,7 +143,7 @@ export declare const inventoryExtrasService: {
|
|
|
143
143
|
maxQuantity: number | null;
|
|
144
144
|
notes: string | null;
|
|
145
145
|
metadata: Record<string, unknown> | null;
|
|
146
|
-
selectionType: "optional" | "required" | "
|
|
146
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
|
|
147
147
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free" | null;
|
|
148
148
|
pricedPerPerson: boolean | null;
|
|
149
149
|
defaultQuantity: number | null;
|
|
@@ -153,7 +153,7 @@ export declare const inventoryExtrasService: {
|
|
|
153
153
|
id: string;
|
|
154
154
|
optionId: string;
|
|
155
155
|
productExtraId: string;
|
|
156
|
-
selectionType: "optional" | "required" | "
|
|
156
|
+
selectionType: "optional" | "required" | "default_selected" | "unavailable" | null;
|
|
157
157
|
pricingMode: "on_request" | "per_booking" | "included" | "per_person" | "quantity_based" | "free" | null;
|
|
158
158
|
pricedPerPerson: boolean | null;
|
|
159
159
|
minQuantity: number | null;
|