@squiz/dxp-cli-next 5.31.0-develop.3 → 5.31.0-develop.5

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 (38) hide show
  1. package/lib/cdp/instance/activate/activate.js +6 -7
  2. package/lib/cdp/instance/activate/activate.spec.js +2 -8
  3. package/lib/cdp/utils.d.ts +2 -1
  4. package/lib/cdp/utils.js +4 -2
  5. package/lib/page/layouts/deploy/deploy.js +43 -8
  6. package/lib/page/layouts/deploy/deploy.spec.js +110 -19
  7. package/lib/page/layouts/dev/dev.js +7 -3
  8. package/lib/page/layouts/dev/dev.spec.js +35 -8
  9. package/lib/page/layouts/validation/index.d.ts +2 -0
  10. package/lib/page/layouts/validation/index.js +5 -1
  11. package/lib/page/layouts/validation/property-consistency.d.ts +7 -0
  12. package/lib/page/layouts/validation/property-consistency.js +92 -0
  13. package/lib/page/layouts/validation/property-consistency.spec.d.ts +1 -0
  14. package/lib/page/layouts/validation/property-consistency.spec.js +305 -0
  15. package/lib/page/layouts/validation/validateLayoutFormat.d.ts +2 -0
  16. package/lib/page/layouts/validation/validateLayoutFormat.js +25 -0
  17. package/lib/page/layouts/validation/validateLayoutFormat.spec.d.ts +1 -0
  18. package/lib/page/layouts/validation/validateLayoutFormat.spec.js +40 -0
  19. package/lib/page/layouts/validation/zone-consistency.d.ts +1 -1
  20. package/lib/page/layouts/validation/zone-consistency.js +10 -9
  21. package/lib/page/layouts/validation/zone-consistency.spec.js +32 -34
  22. package/lib/page/utils/definitions.d.ts +346 -49
  23. package/lib/page/utils/definitions.js +102 -21
  24. package/lib/page/utils/definitions.spec.js +460 -267
  25. package/lib/page/utils/normalize.d.ts +8 -0
  26. package/lib/page/utils/normalize.js +61 -0
  27. package/lib/page/utils/normalize.spec.d.ts +1 -0
  28. package/lib/page/utils/normalize.spec.js +315 -0
  29. package/lib/page/utils/parse-args.d.ts +20 -4
  30. package/lib/page/utils/parse-args.js +48 -13
  31. package/lib/page/utils/parse-args.spec.js +159 -21
  32. package/lib/page/utils/render.d.ts +27 -9
  33. package/lib/page/utils/render.js +66 -12
  34. package/lib/page/utils/render.spec.js +14 -14
  35. package/lib/page/utils/server.d.ts +1 -1
  36. package/lib/page/utils/server.js +2 -2
  37. package/lib/page/utils/server.spec.js +13 -13
  38. package/package.json +1 -1
@@ -19,6 +19,33 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
19
19
  * Description to provide extra information on the layout
20
20
  */
21
21
  description: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ name: string;
24
+ description: string;
25
+ displayName: string;
26
+ }, {
27
+ name: string;
28
+ description: string;
29
+ displayName: string;
30
+ }>;
31
+ /**
32
+ * Layout definition used for deprecated page-layout.yaml files
33
+ */
34
+ export declare const InputLayoutDefinitionV1: z.ZodObject<z.objectUtil.extendShape<{
35
+ /**
36
+ * User defined identifier for a Page Layout
37
+ */
38
+ name: z.ZodString;
39
+ /**
40
+ * Name displayed in user interfaces
41
+ */
42
+ displayName: z.ZodString;
43
+ /**
44
+ * Description to provide extra information on the layout
45
+ */
46
+ description: z.ZodString;
47
+ }, {
48
+ entry: z.ZodString;
22
49
  /**
23
50
  * Zone input structure configuration
24
51
  *
@@ -49,18 +76,22 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
49
76
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
50
77
  displayName: z.ZodString;
51
78
  description: z.ZodString;
52
- values: z.ZodArray<z.ZodString, "many">;
79
+ valueType: z.ZodOptional<z.ZodEnum<["string-enum", "boolean", "text"]>>;
80
+ values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
53
81
  }, "strip", z.ZodTypeAny, {
54
- values: string[];
55
82
  description: string;
56
83
  displayName: string;
84
+ values?: string[] | undefined;
85
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
57
86
  }, {
58
- values: string[];
59
87
  description: string;
60
88
  displayName: string;
89
+ values?: string[] | undefined;
90
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
61
91
  }>>>;
62
- }, "strip", z.ZodTypeAny, {
92
+ }>, "strip", z.ZodTypeAny, {
63
93
  name: string;
94
+ entry: string;
64
95
  description: string;
65
96
  displayName: string;
66
97
  zones: Record<string, {
@@ -70,12 +101,14 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
70
101
  maxNodes?: number | undefined;
71
102
  }>;
72
103
  options?: Record<string, {
73
- values: string[];
74
104
  description: string;
75
105
  displayName: string;
106
+ values?: string[] | undefined;
107
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
76
108
  }> | undefined;
77
109
  }, {
78
110
  name: string;
111
+ entry: string;
79
112
  description: string;
80
113
  displayName: string;
81
114
  zones: Record<string, {
@@ -85,12 +118,16 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
85
118
  maxNodes?: number | undefined;
86
119
  }>;
87
120
  options?: Record<string, {
88
- values: string[];
89
121
  description: string;
90
122
  displayName: string;
123
+ values?: string[] | undefined;
124
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
91
125
  }> | undefined;
92
126
  }>;
93
- export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
127
+ /**
128
+ * Layout definition used for manifest.json files
129
+ */
130
+ export declare const InputLayoutDefinitionV2: z.ZodObject<z.objectUtil.extendShape<{
94
131
  /**
95
132
  * User defined identifier for a Page Layout
96
133
  */
@@ -103,6 +140,123 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
103
140
  * Description to provide extra information on the layout
104
141
  */
105
142
  description: z.ZodString;
143
+ }, {
144
+ entry: z.ZodString;
145
+ /**
146
+ * Zone input structure configuration
147
+ *
148
+ * Declares the content structure that will be the input to the
149
+ * Handlebars template
150
+ */
151
+ zones: z.ZodArray<z.ZodObject<{
152
+ key: z.ZodString;
153
+ displayName: z.ZodString;
154
+ description: z.ZodString;
155
+ }, "strict", z.ZodTypeAny, {
156
+ key: string;
157
+ description: string;
158
+ displayName: string;
159
+ }, {
160
+ key: string;
161
+ description: string;
162
+ displayName: string;
163
+ }>, "many">;
164
+ /**
165
+ * Layout properties
166
+ *
167
+ * Declares any configurable properties that can be provided by a Content Editor
168
+ */
169
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
170
+ title: z.ZodString;
171
+ description: z.ZodString;
172
+ type: z.ZodLiteral<"boolean">;
173
+ enum: z.ZodOptional<z.ZodArray<z.ZodBoolean, "many">>;
174
+ }, "strict", z.ZodTypeAny, {
175
+ type: "boolean";
176
+ description: string;
177
+ title: string;
178
+ enum?: boolean[] | undefined;
179
+ }, {
180
+ type: "boolean";
181
+ description: string;
182
+ title: string;
183
+ enum?: boolean[] | undefined;
184
+ }>, z.ZodObject<{
185
+ title: z.ZodString;
186
+ description: z.ZodString;
187
+ type: z.ZodLiteral<"string">;
188
+ enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
189
+ }, "strict", z.ZodTypeAny, {
190
+ type: "string";
191
+ description: string;
192
+ title: string;
193
+ enum?: string[] | undefined;
194
+ }, {
195
+ type: "string";
196
+ description: string;
197
+ title: string;
198
+ enum?: string[] | undefined;
199
+ }>]>>>;
200
+ }>, "strict", z.ZodTypeAny, {
201
+ name: string;
202
+ entry: string;
203
+ description: string;
204
+ displayName: string;
205
+ zones: {
206
+ key: string;
207
+ description: string;
208
+ displayName: string;
209
+ }[];
210
+ properties?: Record<string, {
211
+ type: "boolean";
212
+ description: string;
213
+ title: string;
214
+ enum?: boolean[] | undefined;
215
+ } | {
216
+ type: "string";
217
+ description: string;
218
+ title: string;
219
+ enum?: string[] | undefined;
220
+ }> | undefined;
221
+ }, {
222
+ name: string;
223
+ entry: string;
224
+ description: string;
225
+ displayName: string;
226
+ zones: {
227
+ key: string;
228
+ description: string;
229
+ displayName: string;
230
+ }[];
231
+ properties?: Record<string, {
232
+ type: "boolean";
233
+ description: string;
234
+ title: string;
235
+ enum?: boolean[] | undefined;
236
+ } | {
237
+ type: "string";
238
+ description: string;
239
+ title: string;
240
+ enum?: string[] | undefined;
241
+ }> | undefined;
242
+ }>;
243
+ export declare type InputLayoutDefinitionV1 = z.infer<typeof InputLayoutDefinitionV1>;
244
+ export declare type InputLayoutDefinitionV2 = z.infer<typeof InputLayoutDefinitionV2>;
245
+ export declare const InputLayoutDefinition: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
246
+ /**
247
+ * User defined identifier for a Page Layout
248
+ */
249
+ name: z.ZodString;
250
+ /**
251
+ * Name displayed in user interfaces
252
+ */
253
+ displayName: z.ZodString;
254
+ /**
255
+ * Description to provide extra information on the layout
256
+ */
257
+ description: z.ZodString;
258
+ }, {
259
+ entry: z.ZodString;
106
260
  /**
107
261
  * Zone input structure configuration
108
262
  *
@@ -133,18 +287,19 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
133
287
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
134
288
  displayName: z.ZodString;
135
289
  description: z.ZodString;
136
- values: z.ZodArray<z.ZodString, "many">;
290
+ valueType: z.ZodOptional<z.ZodEnum<["string-enum", "boolean", "text"]>>;
291
+ values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
137
292
  }, "strip", z.ZodTypeAny, {
138
- values: string[];
139
293
  description: string;
140
294
  displayName: string;
295
+ values?: string[] | undefined;
296
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
141
297
  }, {
142
- values: string[];
143
298
  description: string;
144
299
  displayName: string;
300
+ values?: string[] | undefined;
301
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
145
302
  }>>>;
146
- }, {
147
- entry: z.ZodString;
148
303
  }>, "strip", z.ZodTypeAny, {
149
304
  name: string;
150
305
  entry: string;
@@ -157,9 +312,10 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
157
312
  maxNodes?: number | undefined;
158
313
  }>;
159
314
  options?: Record<string, {
160
- values: string[];
161
315
  description: string;
162
316
  displayName: string;
317
+ values?: string[] | undefined;
318
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
163
319
  }> | undefined;
164
320
  }, {
165
321
  name: string;
@@ -173,12 +329,12 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
173
329
  maxNodes?: number | undefined;
174
330
  }>;
175
331
  options?: Record<string, {
176
- values: string[];
177
332
  description: string;
178
333
  displayName: string;
334
+ values?: string[] | undefined;
335
+ valueType?: "boolean" | "text" | "string-enum" | undefined;
179
336
  }> | undefined;
180
- }>;
181
- export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
337
+ }>, z.ZodObject<z.objectUtil.extendShape<{
182
338
  /**
183
339
  * User defined identifier for a Page Layout
184
340
  */
@@ -191,80 +347,221 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
191
347
  * Description to provide extra information on the layout
192
348
  */
193
349
  description: z.ZodString;
350
+ }, {
351
+ entry: z.ZodString;
194
352
  /**
195
353
  * Zone input structure configuration
196
354
  *
197
355
  * Declares the content structure that will be the input to the
198
356
  * Handlebars template
199
357
  */
200
- zones: z.ZodRecord<z.ZodString, z.ZodObject<{
358
+ zones: z.ZodArray<z.ZodObject<{
359
+ key: z.ZodString;
201
360
  displayName: z.ZodString;
202
361
  description: z.ZodString;
203
- minNodes: z.ZodDefault<z.ZodNumber>;
204
- maxNodes: z.ZodOptional<z.ZodNumber>;
205
- }, "strip", z.ZodTypeAny, {
362
+ }, "strict", z.ZodTypeAny, {
363
+ key: string;
206
364
  description: string;
207
365
  displayName: string;
208
- minNodes: number;
209
- maxNodes?: number | undefined;
210
366
  }, {
367
+ key: string;
211
368
  description: string;
212
369
  displayName: string;
213
- minNodes?: number | undefined;
214
- maxNodes?: number | undefined;
215
- }>>;
370
+ }>, "many">;
216
371
  /**
217
- * Layout options
372
+ * Layout properties
218
373
  *
219
- * Declares any configurable options that can be provided by a Content Editor
374
+ * Declares any configurable properties that can be provided by a Content Editor
220
375
  */
221
- options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
376
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
377
+ title: z.ZodString;
378
+ description: z.ZodString;
379
+ type: z.ZodLiteral<"boolean">;
380
+ enum: z.ZodOptional<z.ZodArray<z.ZodBoolean, "many">>;
381
+ }, "strict", z.ZodTypeAny, {
382
+ type: "boolean";
383
+ description: string;
384
+ title: string;
385
+ enum?: boolean[] | undefined;
386
+ }, {
387
+ type: "boolean";
388
+ description: string;
389
+ title: string;
390
+ enum?: boolean[] | undefined;
391
+ }>, z.ZodObject<{
392
+ title: z.ZodString;
393
+ description: z.ZodString;
394
+ type: z.ZodLiteral<"string">;
395
+ enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
396
+ }, "strict", z.ZodTypeAny, {
397
+ type: "string";
398
+ description: string;
399
+ title: string;
400
+ enum?: string[] | undefined;
401
+ }, {
402
+ type: "string";
403
+ description: string;
404
+ title: string;
405
+ enum?: string[] | undefined;
406
+ }>]>>>;
407
+ }>, "strict", z.ZodTypeAny, {
408
+ name: string;
409
+ entry: string;
410
+ description: string;
411
+ displayName: string;
412
+ zones: {
413
+ key: string;
414
+ description: string;
415
+ displayName: string;
416
+ }[];
417
+ properties?: Record<string, {
418
+ type: "boolean";
419
+ description: string;
420
+ title: string;
421
+ enum?: boolean[] | undefined;
422
+ } | {
423
+ type: "string";
424
+ description: string;
425
+ title: string;
426
+ enum?: string[] | undefined;
427
+ }> | undefined;
428
+ }, {
429
+ name: string;
430
+ entry: string;
431
+ description: string;
432
+ displayName: string;
433
+ zones: {
434
+ key: string;
435
+ description: string;
436
+ displayName: string;
437
+ }[];
438
+ properties?: Record<string, {
439
+ type: "boolean";
440
+ description: string;
441
+ title: string;
442
+ enum?: boolean[] | undefined;
443
+ } | {
444
+ type: "string";
445
+ description: string;
446
+ title: string;
447
+ enum?: string[] | undefined;
448
+ }> | undefined;
449
+ }>]>;
450
+ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<Omit<z.objectUtil.extendShape<{
451
+ /**
452
+ * User defined identifier for a Page Layout
453
+ */
454
+ name: z.ZodString;
455
+ /**
456
+ * Name displayed in user interfaces
457
+ */
458
+ displayName: z.ZodString;
459
+ /**
460
+ * Description to provide extra information on the layout
461
+ */
462
+ description: z.ZodString;
463
+ }, {
464
+ entry: z.ZodString;
465
+ /**
466
+ * Zone input structure configuration
467
+ *
468
+ * Declares the content structure that will be the input to the
469
+ * Handlebars template
470
+ */
471
+ zones: z.ZodArray<z.ZodObject<{
472
+ key: z.ZodString;
222
473
  displayName: z.ZodString;
223
474
  description: z.ZodString;
224
- values: z.ZodArray<z.ZodString, "many">;
225
- }, "strip", z.ZodTypeAny, {
226
- values: string[];
475
+ }, "strict", z.ZodTypeAny, {
476
+ key: string;
227
477
  description: string;
228
478
  displayName: string;
229
479
  }, {
230
- values: string[];
480
+ key: string;
231
481
  description: string;
232
482
  displayName: string;
233
- }>>>;
234
- }, {
483
+ }>, "many">;
484
+ /**
485
+ * Layout properties
486
+ *
487
+ * Declares any configurable properties that can be provided by a Content Editor
488
+ */
489
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
490
+ title: z.ZodString;
491
+ description: z.ZodString;
492
+ type: z.ZodLiteral<"boolean">;
493
+ enum: z.ZodOptional<z.ZodArray<z.ZodBoolean, "many">>;
494
+ }, "strict", z.ZodTypeAny, {
495
+ type: "boolean";
496
+ description: string;
497
+ title: string;
498
+ enum?: boolean[] | undefined;
499
+ }, {
500
+ type: "boolean";
501
+ description: string;
502
+ title: string;
503
+ enum?: boolean[] | undefined;
504
+ }>, z.ZodObject<{
505
+ title: z.ZodString;
506
+ description: z.ZodString;
507
+ type: z.ZodLiteral<"string">;
508
+ enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
509
+ }, "strict", z.ZodTypeAny, {
510
+ type: "string";
511
+ description: string;
512
+ title: string;
513
+ enum?: string[] | undefined;
514
+ }, {
515
+ type: "string";
516
+ description: string;
517
+ title: string;
518
+ enum?: string[] | undefined;
519
+ }>]>>>;
520
+ }>, "entry">, {
235
521
  template: z.ZodString;
236
- }>, "strip", z.ZodTypeAny, {
522
+ }>, "strict", z.ZodTypeAny, {
237
523
  name: string;
238
524
  description: string;
239
525
  displayName: string;
240
- zones: Record<string, {
526
+ zones: {
527
+ key: string;
241
528
  description: string;
242
529
  displayName: string;
243
- minNodes: number;
244
- maxNodes?: number | undefined;
245
- }>;
530
+ }[];
246
531
  template: string;
247
- options?: Record<string, {
248
- values: string[];
532
+ properties?: Record<string, {
533
+ type: "boolean";
249
534
  description: string;
250
- displayName: string;
535
+ title: string;
536
+ enum?: boolean[] | undefined;
537
+ } | {
538
+ type: "string";
539
+ description: string;
540
+ title: string;
541
+ enum?: string[] | undefined;
251
542
  }> | undefined;
252
543
  }, {
253
544
  name: string;
254
545
  description: string;
255
546
  displayName: string;
256
- zones: Record<string, {
547
+ zones: {
548
+ key: string;
257
549
  description: string;
258
550
  displayName: string;
259
- minNodes?: number | undefined;
260
- maxNodes?: number | undefined;
261
- }>;
551
+ }[];
262
552
  template: string;
263
- options?: Record<string, {
264
- values: string[];
553
+ properties?: Record<string, {
554
+ type: "boolean";
265
555
  description: string;
266
- displayName: string;
556
+ title: string;
557
+ enum?: boolean[] | undefined;
558
+ } | {
559
+ type: "string";
560
+ description: string;
561
+ title: string;
562
+ enum?: string[] | undefined;
267
563
  }> | undefined;
268
564
  }>;
269
565
  export declare type InputLayoutDefinition = z.infer<typeof InputLayoutDefinition>;
270
566
  export declare type LayoutDefinition = z.infer<typeof LayoutDefinition>;
567
+ export declare const LAYOUT_MANIFEST_FILE = "manifest.json";
@@ -36,19 +36,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
36
36
  step((generator = generator.apply(thisArg, _arguments || [])).next());
37
37
  });
38
38
  };
39
- var __rest = (this && this.__rest) || function (s, e) {
40
- var t = {};
41
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
42
- t[p] = s[p];
43
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
44
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
45
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
46
- t[p[i]] = s[p[i]];
47
- }
48
- return t;
49
- };
50
39
  Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.LayoutDefinition = exports.InputLayoutDefinition = exports.BaseLayoutDefinition = exports.loadLayoutFromFile = exports.loadLayoutDefinition = void 0;
40
+ exports.LAYOUT_MANIFEST_FILE = exports.LayoutDefinition = exports.InputLayoutDefinition = exports.InputLayoutDefinitionV2 = exports.InputLayoutDefinitionV1 = exports.BaseLayoutDefinition = exports.loadLayoutFromFile = exports.loadLayoutDefinition = void 0;
52
41
  // External
53
42
  const fs = __importStar(require("node:fs/promises"));
54
43
  const path = __importStar(require("node:path"));
@@ -56,12 +45,24 @@ const zod_1 = require("zod");
56
45
  const yaml_1 = require("yaml");
57
46
  // Local
58
47
  const validation_1 = require("../templates/validation");
48
+ const render_1 = require("./render");
49
+ const normalize_1 = require("./normalize");
59
50
  function loadLayoutDefinition(layoutFile) {
60
51
  return __awaiter(this, void 0, void 0, function* () {
61
52
  try {
62
- const _a = yield loadLayoutFromFile(layoutFile), { entry } = _a, layout = __rest(_a, ["entry"]);
63
- const template = yield loadTemplate(path.dirname(layoutFile), entry);
64
- const layoutDefinition = Object.assign(Object.assign({}, layout), { template });
53
+ const layout = yield loadLayoutFromFile(layoutFile);
54
+ const template = yield loadTemplate(path.dirname(layoutFile), layout.entry);
55
+ const layoutDefinition = {
56
+ name: layout.name,
57
+ displayName: layout.displayName,
58
+ description: layout.description,
59
+ template,
60
+ zones: (0, normalize_1.normalizeZones)(layout.zones),
61
+ };
62
+ const normalizedProperties = (0, normalize_1.normalizeProperties)(layout);
63
+ if (normalizedProperties) {
64
+ layoutDefinition.properties = normalizedProperties;
65
+ }
65
66
  exports.LayoutDefinition.parse(layoutDefinition);
66
67
  return layoutDefinition;
67
68
  }
@@ -82,15 +83,38 @@ function loadLayoutFromFile(layoutFile) {
82
83
  });
83
84
  try {
84
85
  const layout = (0, yaml_1.parse)(content);
85
- exports.InputLayoutDefinition.parse(layout);
86
+ const fileName = path.basename(layoutFile);
87
+ if (fileName === exports.LAYOUT_MANIFEST_FILE) {
88
+ exports.InputLayoutDefinitionV2.parse(layout);
89
+ }
90
+ else {
91
+ exports.InputLayoutDefinitionV1.parse(layout);
92
+ }
86
93
  return layout;
87
94
  }
88
95
  catch (e) {
89
- throw Error(`Failed to parse ${layoutFile}: ${e.message}`);
96
+ const errorMessage = formatLayoutParseError(layoutFile, e);
97
+ throw Error(errorMessage);
90
98
  }
91
99
  });
92
100
  }
93
101
  exports.loadLayoutFromFile = loadLayoutFromFile;
102
+ /**
103
+ * Formats a layout parse error into a user-friendly error message
104
+ */
105
+ function formatLayoutParseError(layoutFile, error) {
106
+ if (error instanceof zod_1.ZodError) {
107
+ const errorMessages = error.issues.map(issue => {
108
+ const pathStr = issue.path.length > 0 ? ` at "${issue.path.join('.')}"` : '';
109
+ return `${issue.message}${pathStr}`;
110
+ });
111
+ return (`Failed to parse ${layoutFile}:\n\n` +
112
+ `Schema validation failed:\n${errorMessages
113
+ .map(err => ` - ${err}`)
114
+ .join('\n')}`);
115
+ }
116
+ return `Failed to parse ${layoutFile}: ${error.message}`;
117
+ }
94
118
  /**
95
119
  * Loads a template file from a file system
96
120
  * @param layoutDirectory - The path to the layout directory
@@ -128,6 +152,12 @@ exports.BaseLayoutDefinition = zod_1.z.object({
128
152
  * Description to provide extra information on the layout
129
153
  */
130
154
  description: zod_1.z.string(),
155
+ });
156
+ /**
157
+ * Layout definition used for deprecated page-layout.yaml files
158
+ */
159
+ exports.InputLayoutDefinitionV1 = exports.BaseLayoutDefinition.extend({
160
+ entry: zod_1.z.string(),
131
161
  /**
132
162
  * Zone input structure configuration
133
163
  *
@@ -149,13 +179,64 @@ exports.BaseLayoutDefinition = zod_1.z.object({
149
179
  .record(zod_1.z.string(), zod_1.z.object({
150
180
  displayName: zod_1.z.string(),
151
181
  description: zod_1.z.string(),
152
- values: zod_1.z.array(zod_1.z.string()),
182
+ valueType: zod_1.z.enum(render_1.LayoutOptionValueTypes).optional(),
183
+ values: zod_1.z.array(zod_1.z.string()).optional(),
153
184
  }))
154
185
  .optional(),
155
186
  });
156
- exports.InputLayoutDefinition = exports.BaseLayoutDefinition.extend({
187
+ /**
188
+ * Layout definition used for manifest.json files
189
+ */
190
+ exports.InputLayoutDefinitionV2 = exports.BaseLayoutDefinition.extend({
157
191
  entry: zod_1.z.string(),
158
- });
159
- exports.LayoutDefinition = exports.BaseLayoutDefinition.extend({
192
+ /**
193
+ * Zone input structure configuration
194
+ *
195
+ * Declares the content structure that will be the input to the
196
+ * Handlebars template
197
+ */
198
+ zones: zod_1.z.array(zod_1.z
199
+ .object({
200
+ key: zod_1.z.string(),
201
+ displayName: zod_1.z.string(),
202
+ description: zod_1.z.string(),
203
+ })
204
+ .strict()),
205
+ /**
206
+ * Layout properties
207
+ *
208
+ * Declares any configurable properties that can be provided by a Content Editor
209
+ */
210
+ properties: zod_1.z
211
+ .record(zod_1.z.string(), zod_1.z.discriminatedUnion('type', [
212
+ // Boolean
213
+ zod_1.z
214
+ .object({
215
+ title: zod_1.z.string(),
216
+ description: zod_1.z.string(),
217
+ type: zod_1.z.literal(render_1.LayoutPropertyType.boolean),
218
+ enum: zod_1.z.array(zod_1.z.boolean()).optional(),
219
+ })
220
+ .strict(),
221
+ // String
222
+ zod_1.z
223
+ .object({
224
+ title: zod_1.z.string(),
225
+ description: zod_1.z.string(),
226
+ type: zod_1.z.literal(render_1.LayoutPropertyType.string),
227
+ enum: zod_1.z.array(zod_1.z.string()).optional(),
228
+ })
229
+ .strict(),
230
+ ]))
231
+ .optional(),
232
+ }).strict();
233
+ exports.InputLayoutDefinition = zod_1.z.union([
234
+ exports.InputLayoutDefinitionV1,
235
+ exports.InputLayoutDefinitionV2,
236
+ ]);
237
+ exports.LayoutDefinition = exports.InputLayoutDefinitionV2.omit({
238
+ entry: true,
239
+ }).extend({
160
240
  template: zod_1.z.string(),
161
241
  });
242
+ exports.LAYOUT_MANIFEST_FILE = 'manifest.json';