@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
package/dist/routes-brochure.js
CHANGED
|
@@ -17,25 +17,85 @@
|
|
|
17
17
|
* Keeping these injected means inventory never imports the deployment's R2
|
|
18
18
|
* binding or cloud client.
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
20
|
+
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
21
|
+
import { openApiValidationHook } from "@voyant-travel/hono";
|
|
21
22
|
import { emitProductContentChanged } from "./events.js";
|
|
22
23
|
import { createDefaultProductBrochureTemplate, generateAndStoreProductBrochure, } from "./tasks/index.js";
|
|
23
24
|
/** 5 MiB cap on a generated brochure PDF before it's rejected with 413. */
|
|
24
25
|
const DEFAULT_MAX_BROCHURE_PDF_BYTES = 5 * 1024 * 1024;
|
|
26
|
+
const errorResponseSchema = z.object({ error: z.string() });
|
|
27
|
+
/**
|
|
28
|
+
* Generated-brochure row schema, authored from the `product_media`
|
|
29
|
+
* `$inferSelect` shape (the brochure is persisted via `upsertBrochure`). §17:
|
|
30
|
+
* timestamp columns serialize to strings over the wire.
|
|
31
|
+
*/
|
|
32
|
+
const brochureMediaSchema = z.object({
|
|
33
|
+
id: z.string(),
|
|
34
|
+
productId: z.string(),
|
|
35
|
+
dayId: z.string().nullable(),
|
|
36
|
+
mediaType: z.enum(["image", "video", "document"]),
|
|
37
|
+
name: z.string(),
|
|
38
|
+
url: z.string(),
|
|
39
|
+
storageKey: z.string().nullable(),
|
|
40
|
+
mimeType: z.string().nullable(),
|
|
41
|
+
fileSize: z.number().nullable(),
|
|
42
|
+
altText: z.string().nullable(),
|
|
43
|
+
sortOrder: z.number(),
|
|
44
|
+
isCover: z.boolean(),
|
|
45
|
+
isBrochure: z.boolean(),
|
|
46
|
+
isBrochureCurrent: z.boolean(),
|
|
47
|
+
brochureVersion: z.number().nullable(),
|
|
48
|
+
createdAt: z.string(),
|
|
49
|
+
updatedAt: z.string(),
|
|
50
|
+
});
|
|
51
|
+
const generateBrochureRoute = createRoute({
|
|
52
|
+
method: "post",
|
|
53
|
+
path: "/{id}/brochure/generate",
|
|
54
|
+
request: { params: z.object({ id: z.string() }) },
|
|
55
|
+
responses: {
|
|
56
|
+
200: {
|
|
57
|
+
description: "The generated + stored brochure with upload metadata",
|
|
58
|
+
content: {
|
|
59
|
+
"application/json": {
|
|
60
|
+
schema: z.object({
|
|
61
|
+
data: brochureMediaSchema,
|
|
62
|
+
metadata: z.object({
|
|
63
|
+
filename: z.string(),
|
|
64
|
+
sizeBytes: z.number(),
|
|
65
|
+
storageKey: z.string(),
|
|
66
|
+
url: z.string(),
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
400: {
|
|
73
|
+
description: "id route param is required",
|
|
74
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
75
|
+
},
|
|
76
|
+
413: {
|
|
77
|
+
description: "Generated brochure exceeds the configured size cap",
|
|
78
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
79
|
+
},
|
|
80
|
+
503: {
|
|
81
|
+
description: "Storage not configured",
|
|
82
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
25
86
|
/**
|
|
26
87
|
* Build the product brochure route (relative path; mount at
|
|
27
88
|
* `/v1/admin/products`). Storage + the optional printer are injected via
|
|
28
89
|
* `options`.
|
|
29
90
|
*/
|
|
30
91
|
export function createProductBrochureRoutes(options) {
|
|
31
|
-
const hono = new Hono();
|
|
32
92
|
const maxSizeBytes = options.maxSizeBytes ?? DEFAULT_MAX_BROCHURE_PDF_BYTES;
|
|
33
|
-
|
|
93
|
+
return new OpenAPIHono({ defaultHook: openApiValidationHook }).openapi(generateBrochureRoute, async (c) => {
|
|
34
94
|
const storage = options.resolveStorage(c);
|
|
35
95
|
if (!storage) {
|
|
36
96
|
return c.json({ error: "Storage not configured" }, 503);
|
|
37
97
|
}
|
|
38
|
-
const productId = c.req.
|
|
98
|
+
const productId = c.req.valid("param").id;
|
|
39
99
|
if (!productId)
|
|
40
100
|
return c.json({ error: "id route param is required" }, 400);
|
|
41
101
|
const printer = options.resolvePrinter?.(c) ?? null;
|
|
@@ -67,7 +127,6 @@ export function createProductBrochureRoutes(options) {
|
|
|
67
127
|
storageKey: generated.storageKey,
|
|
68
128
|
url: generated.url,
|
|
69
129
|
},
|
|
70
|
-
});
|
|
130
|
+
}, 200);
|
|
71
131
|
});
|
|
72
|
-
return hono;
|
|
73
132
|
}
|
|
@@ -43,7 +43,7 @@ describe("product brochure routes", () => {
|
|
|
43
43
|
filename: "brochure-prod_1.pdf",
|
|
44
44
|
sizeBytes: 1234,
|
|
45
45
|
storageKey: "brochures/products/prod_1/brochure-prod_1.pdf",
|
|
46
|
-
url: "/api/v1/media/brochures/products/prod_1/brochure-prod_1.pdf",
|
|
46
|
+
url: "/api/v1/admin/media/brochures/products/prod_1/brochure-prod_1.pdf",
|
|
47
47
|
});
|
|
48
48
|
const storage = storageStub();
|
|
49
49
|
const app = mountApp(() => storage);
|