@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.
Files changed (84) hide show
  1. package/dist/action-ledger.d.ts +5 -5
  2. package/dist/authoring/extension.d.ts +4 -4
  3. package/dist/authoring/spec.d.ts +2 -2
  4. package/dist/booking-extension.js +1 -1
  5. package/dist/extras/routes.d.ts +470 -119
  6. package/dist/extras/routes.d.ts.map +1 -1
  7. package/dist/extras/routes.js +252 -37
  8. package/dist/extras/schema.d.ts +2 -2
  9. package/dist/extras/service.d.ts +11 -11
  10. package/dist/extras/validation.d.ts +37 -37
  11. package/dist/extras.d.ts +15 -15
  12. package/dist/extras.js +1 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +0 -1
  15. package/dist/interface.d.ts +4417 -1994
  16. package/dist/interface.d.ts.map +1 -1
  17. package/dist/interface.js +0 -1
  18. package/dist/public-tags-contract.test.d.ts +2 -0
  19. package/dist/public-tags-contract.test.d.ts.map +1 -0
  20. package/dist/public-tags-contract.test.js +11 -0
  21. package/dist/public-taxonomy-contract.test.d.ts +2 -0
  22. package/dist/public-taxonomy-contract.test.d.ts.map +1 -0
  23. package/dist/public-taxonomy-contract.test.js +37 -0
  24. package/dist/routes-associations.d.ts +101 -42
  25. package/dist/routes-associations.d.ts.map +1 -1
  26. package/dist/routes-associations.js +177 -38
  27. package/dist/routes-brochure.d.ts +3 -2
  28. package/dist/routes-brochure.d.ts.map +1 -1
  29. package/dist/routes-brochure.js +65 -6
  30. package/dist/routes-brochure.test.js +1 -1
  31. package/dist/routes-catalog.d.ts +349 -88
  32. package/dist/routes-catalog.d.ts.map +1 -1
  33. package/dist/routes-catalog.js +390 -62
  34. package/dist/routes-configuration.d.ts +507 -129
  35. package/dist/routes-configuration.d.ts.map +1 -1
  36. package/dist/routes-configuration.js +668 -90
  37. package/dist/routes-content.d.ts +4 -4
  38. package/dist/routes-content.d.ts.map +1 -1
  39. package/dist/routes-content.js +44 -6
  40. package/dist/routes-core.d.ts +307 -66
  41. package/dist/routes-core.d.ts.map +1 -1
  42. package/dist/routes-core.js +226 -29
  43. package/dist/routes-itinerary-translations.d.ts +202 -87
  44. package/dist/routes-itinerary-translations.d.ts.map +1 -1
  45. package/dist/routes-itinerary-translations.js +261 -55
  46. package/dist/routes-itinerary.d.ts +580 -212
  47. package/dist/routes-itinerary.d.ts.map +1 -1
  48. package/dist/routes-itinerary.js +655 -129
  49. package/dist/routes-maintenance.d.ts +21 -9
  50. package/dist/routes-maintenance.d.ts.map +1 -1
  51. package/dist/routes-maintenance.js +38 -9
  52. package/dist/routes-media.d.ts +425 -148
  53. package/dist/routes-media.d.ts.map +1 -1
  54. package/dist/routes-media.js +438 -128
  55. package/dist/routes-merchandising.d.ts +906 -316
  56. package/dist/routes-merchandising.d.ts.map +1 -1
  57. package/dist/routes-merchandising.js +945 -125
  58. package/dist/routes-options.d.ts +356 -115
  59. package/dist/routes-options.d.ts.map +1 -1
  60. package/dist/routes-options.js +288 -52
  61. package/dist/routes-public.d.ts +368 -380
  62. package/dist/routes-public.d.ts.map +1 -1
  63. package/dist/routes-public.js +256 -40
  64. package/dist/routes-translations.d.ts +356 -86
  65. package/dist/routes-translations.d.ts.map +1 -1
  66. package/dist/routes-translations.js +404 -56
  67. package/dist/routes.d.ts +4185 -1595
  68. package/dist/routes.d.ts.map +1 -1
  69. package/dist/routes.js +8 -3
  70. package/dist/schema-core.d.ts +1 -1
  71. package/dist/schema-settings.d.ts +1 -1
  72. package/dist/service-catalog.d.ts +4 -4
  73. package/dist/service-core.d.ts +6 -6
  74. package/dist/service-delivery-formats.d.ts +1 -1
  75. package/dist/service-destinations.d.ts +3 -3
  76. package/dist/service-itinerary-translations.d.ts +1 -1
  77. package/dist/service-itinerary.d.ts +3 -3
  78. package/dist/service-merchandising.d.ts +5 -5
  79. package/dist/service-option-translations.d.ts +4 -4
  80. package/dist/service-options.d.ts +2 -2
  81. package/dist/service-public.d.ts +12 -12
  82. package/dist/service-taxonomy.d.ts +4 -4
  83. package/dist/service.d.ts +41 -41
  84. package/package.json +10 -9
@@ -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 { Hono } from "hono";
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
- hono.post("/:id/brochure/generate", async (c) => {
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.param("id");
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);