@voyantjs/products-contracts 0.104.1 → 0.105.1
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/content-shape.d.ts
CHANGED
|
@@ -67,6 +67,13 @@ export declare const productOptionSchema: z.ZodObject<{
|
|
|
67
67
|
id: z.ZodString;
|
|
68
68
|
name: z.ZodString;
|
|
69
69
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
board_basis: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
71
|
+
room_only: "room_only";
|
|
72
|
+
bed_breakfast: "bed_breakfast";
|
|
73
|
+
half_board: "half_board";
|
|
74
|
+
full_board: "full_board";
|
|
75
|
+
all_inclusive: "all_inclusive";
|
|
76
|
+
}>>>;
|
|
70
77
|
units: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
71
78
|
id: z.ZodString;
|
|
72
79
|
type: z.ZodString;
|
|
@@ -146,6 +153,13 @@ export declare const productContentSchema: z.ZodObject<{
|
|
|
146
153
|
id: z.ZodString;
|
|
147
154
|
name: z.ZodString;
|
|
148
155
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
156
|
+
board_basis: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
157
|
+
room_only: "room_only";
|
|
158
|
+
bed_breakfast: "bed_breakfast";
|
|
159
|
+
half_board: "half_board";
|
|
160
|
+
full_board: "full_board";
|
|
161
|
+
all_inclusive: "all_inclusive";
|
|
162
|
+
}>>>;
|
|
149
163
|
units: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
150
164
|
id: z.ZodString;
|
|
151
165
|
type: z.ZodString;
|
|
@@ -202,6 +216,7 @@ export type ProductOption = z.infer<typeof productOptionSchema>;
|
|
|
202
216
|
export type ProductDeparture = z.infer<typeof productDepartureSchema>;
|
|
203
217
|
export type ProductDay = z.infer<typeof productDaySchema>;
|
|
204
218
|
export type ProductPolicy = z.infer<typeof productPolicySchema>;
|
|
219
|
+
export { BOARD_BASIS_FROM_SHORT_CODE, BOARD_BASIS_SHORT_CODES, BOARD_BASIS_VALUES, type BoardBasis, type BoardBasisShortCode, boardBasisSchema, } from "@voyantjs/catalog-contracts/content";
|
|
205
220
|
/**
|
|
206
221
|
* Validate a `ProductContent` payload. Returns the parsed result on
|
|
207
222
|
* success or a structured failure on rejection. Used by the cache write
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-shape.d.ts","sourceRoot":"","sources":["../src/content-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"content-shape.d.ts","sourceRoot":"","sources":["../src/content-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,eAAO,MAAM,+BAA+B,gBAAgB,CAAA;AAE5D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;iBAoB/B,CAAA;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;iBAKjC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;iBAMlC,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;iBAO9B,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;iBAQ3B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;iBAK9B,CAAA;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;iBAejC,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO/B,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,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACrE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACrE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,gBAAgB,GACjB,MAAM,qCAAqC,CAAA;AAE5C;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,GACf;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAY7E"}
|
package/dist/content-shape.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* See `docs/architecture/catalog-sourced-content.md` §3.2, §3.5.4, §3.6.
|
|
16
16
|
*/
|
|
17
|
+
import { boardBasisSchema } from "@voyantjs/catalog-contracts/content";
|
|
17
18
|
import { z } from "zod";
|
|
18
19
|
/**
|
|
19
20
|
* The current content-schema version. Stamped on every cache write.
|
|
@@ -63,6 +64,7 @@ export const productOptionSchema = z.object({
|
|
|
63
64
|
id: z.string(),
|
|
64
65
|
name: z.string(),
|
|
65
66
|
description: z.string().nullable().optional(),
|
|
67
|
+
board_basis: boardBasisSchema.nullable().optional(),
|
|
66
68
|
units: z.array(productOptionUnitSchema).optional().default([]),
|
|
67
69
|
inclusions: z.array(z.string()).optional().default([]),
|
|
68
70
|
});
|
|
@@ -120,6 +122,7 @@ export const productContentSchema = z.object({
|
|
|
120
122
|
policies: z.array(productPolicySchema).default([]),
|
|
121
123
|
departures: z.array(productDepartureSchema).default([]),
|
|
122
124
|
});
|
|
125
|
+
export { BOARD_BASIS_FROM_SHORT_CODE, BOARD_BASIS_SHORT_CODES, BOARD_BASIS_VALUES, boardBasisSchema, } from "@voyantjs/catalog-contracts/content";
|
|
123
126
|
/**
|
|
124
127
|
* Validate a `ProductContent` payload. Returns the parsed result on
|
|
125
128
|
* success or a structured failure on rejection. Used by the cache write
|
|
@@ -4,7 +4,7 @@ describe("@voyantjs/products-contracts content shape", () => {
|
|
|
4
4
|
it("validates the products/v1 rich content payload", () => {
|
|
5
5
|
const content = productContentSchema.parse({
|
|
6
6
|
product: { id: "prod_abc", name: "Sahara Desert Trek" },
|
|
7
|
-
options: [{ id: "opt_std", name: "Standard Departure" }],
|
|
7
|
+
options: [{ id: "opt_std", name: "Standard Departure", board_basis: "half_board" }],
|
|
8
8
|
days: [{ day_number: 1, title: "Arrival in Marrakech" }],
|
|
9
9
|
policies: [{ kind: "cancellation", body: "Free cancellation up to 30 days." }],
|
|
10
10
|
});
|
|
@@ -13,6 +13,7 @@ describe("@voyantjs/products-contracts content shape", () => {
|
|
|
13
13
|
expect(content.media).toEqual([]);
|
|
14
14
|
expect(content.departures).toEqual([]);
|
|
15
15
|
expect(content.options[0]?.units).toEqual([]);
|
|
16
|
+
expect(content.options[0]?.board_basis).toBe("half_board");
|
|
16
17
|
});
|
|
17
18
|
it("defaults a media item type to image", () => {
|
|
18
19
|
const content = productContentSchema.parse({
|
|
@@ -31,4 +32,10 @@ describe("@voyantjs/products-contracts content shape", () => {
|
|
|
31
32
|
policies: [{ kind: "loyalty", body: "x" }],
|
|
32
33
|
})).toMatchObject({ valid: false });
|
|
33
34
|
});
|
|
35
|
+
it("rejects unknown option board basis values", () => {
|
|
36
|
+
expect(validateProductContent({
|
|
37
|
+
product: { id: "prod_abc", name: "Sahara Desert Trek" },
|
|
38
|
+
options: [{ id: "opt_std", name: "Standard Departure", board_basis: "brunch_only" }],
|
|
39
|
+
})).toMatchObject({ valid: false });
|
|
40
|
+
});
|
|
34
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/products-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.105.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -58,12 +58,13 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"zod": "^4.3.6",
|
|
61
|
-
"@voyantjs/
|
|
61
|
+
"@voyantjs/catalog-contracts": "^0.105.1",
|
|
62
|
+
"@voyantjs/schema-kit": "^0.105.0"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"typescript": "^6.0.2",
|
|
65
66
|
"vitest": "^4.1.2",
|
|
66
|
-
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
67
|
+
"@voyantjs/voyant-typescript-config": "^0.1.0"
|
|
67
68
|
},
|
|
68
69
|
"repository": {
|
|
69
70
|
"type": "git",
|