@squiz/dxp-cli-next 5.29.0 → 5.29.1-develop.2

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.
@@ -23,7 +23,7 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
23
23
  zones: z.ZodRecord<z.ZodString, z.ZodObject<{
24
24
  displayName: z.ZodString;
25
25
  description: z.ZodString;
26
- minNodes: z.ZodNumber;
26
+ minNodes: z.ZodDefault<z.ZodNumber>;
27
27
  maxNodes: z.ZodOptional<z.ZodNumber>;
28
28
  }, "strip", z.ZodTypeAny, {
29
29
  description: string;
@@ -33,7 +33,7 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
33
33
  }, {
34
34
  description: string;
35
35
  displayName: string;
36
- minNodes: number;
36
+ minNodes?: number | undefined;
37
37
  maxNodes?: number | undefined;
38
38
  }>>;
39
39
  /**
@@ -41,7 +41,7 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
41
41
  *
42
42
  * Declares any configurable options that can be provided by a Content Editor
43
43
  */
44
- options: z.ZodRecord<z.ZodString, z.ZodObject<{
44
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
45
45
  displayName: z.ZodString;
46
46
  description: z.ZodString;
47
47
  values: z.ZodArray<z.ZodString, "many">;
@@ -53,14 +53,9 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
53
53
  values: string[];
54
54
  description: string;
55
55
  displayName: string;
56
- }>>;
56
+ }>>>;
57
57
  }, "strip", z.ZodTypeAny, {
58
58
  name: string;
59
- options: Record<string, {
60
- values: string[];
61
- description: string;
62
- displayName: string;
63
- }>;
64
59
  description: string;
65
60
  displayName: string;
66
61
  zones: Record<string, {
@@ -69,21 +64,26 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
69
64
  minNodes: number;
70
65
  maxNodes?: number | undefined;
71
66
  }>;
72
- }, {
73
- name: string;
74
- options: Record<string, {
67
+ options?: Record<string, {
75
68
  values: string[];
76
69
  description: string;
77
70
  displayName: string;
78
- }>;
71
+ }> | undefined;
72
+ }, {
73
+ name: string;
79
74
  description: string;
80
75
  displayName: string;
81
76
  zones: Record<string, {
82
77
  description: string;
83
78
  displayName: string;
84
- minNodes: number;
79
+ minNodes?: number | undefined;
85
80
  maxNodes?: number | undefined;
86
81
  }>;
82
+ options?: Record<string, {
83
+ values: string[];
84
+ description: string;
85
+ displayName: string;
86
+ }> | undefined;
87
87
  }>;
88
88
  export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
89
89
  /**
@@ -107,7 +107,7 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
107
107
  zones: z.ZodRecord<z.ZodString, z.ZodObject<{
108
108
  displayName: z.ZodString;
109
109
  description: z.ZodString;
110
- minNodes: z.ZodNumber;
110
+ minNodes: z.ZodDefault<z.ZodNumber>;
111
111
  maxNodes: z.ZodOptional<z.ZodNumber>;
112
112
  }, "strip", z.ZodTypeAny, {
113
113
  description: string;
@@ -117,7 +117,7 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
117
117
  }, {
118
118
  description: string;
119
119
  displayName: string;
120
- minNodes: number;
120
+ minNodes?: number | undefined;
121
121
  maxNodes?: number | undefined;
122
122
  }>>;
123
123
  /**
@@ -125,7 +125,7 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
125
125
  *
126
126
  * Declares any configurable options that can be provided by a Content Editor
127
127
  */
128
- options: z.ZodRecord<z.ZodString, z.ZodObject<{
128
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
129
129
  displayName: z.ZodString;
130
130
  description: z.ZodString;
131
131
  values: z.ZodArray<z.ZodString, "many">;
@@ -137,16 +137,11 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
137
137
  values: string[];
138
138
  description: string;
139
139
  displayName: string;
140
- }>>;
140
+ }>>>;
141
141
  }, {
142
142
  entry: z.ZodString;
143
143
  }>, "strip", z.ZodTypeAny, {
144
144
  name: string;
145
- options: Record<string, {
146
- values: string[];
147
- description: string;
148
- displayName: string;
149
- }>;
150
145
  entry: string;
151
146
  description: string;
152
147
  displayName: string;
@@ -156,22 +151,27 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
156
151
  minNodes: number;
157
152
  maxNodes?: number | undefined;
158
153
  }>;
159
- }, {
160
- name: string;
161
- options: Record<string, {
154
+ options?: Record<string, {
162
155
  values: string[];
163
156
  description: string;
164
157
  displayName: string;
165
- }>;
158
+ }> | undefined;
159
+ }, {
160
+ name: string;
166
161
  entry: string;
167
162
  description: string;
168
163
  displayName: string;
169
164
  zones: Record<string, {
170
165
  description: string;
171
166
  displayName: string;
172
- minNodes: number;
167
+ minNodes?: number | undefined;
173
168
  maxNodes?: number | undefined;
174
169
  }>;
170
+ options?: Record<string, {
171
+ values: string[];
172
+ description: string;
173
+ displayName: string;
174
+ }> | undefined;
175
175
  }>;
176
176
  export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
177
177
  /**
@@ -195,7 +195,7 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
195
195
  zones: z.ZodRecord<z.ZodString, z.ZodObject<{
196
196
  displayName: z.ZodString;
197
197
  description: z.ZodString;
198
- minNodes: z.ZodNumber;
198
+ minNodes: z.ZodDefault<z.ZodNumber>;
199
199
  maxNodes: z.ZodOptional<z.ZodNumber>;
200
200
  }, "strip", z.ZodTypeAny, {
201
201
  description: string;
@@ -205,7 +205,7 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
205
205
  }, {
206
206
  description: string;
207
207
  displayName: string;
208
- minNodes: number;
208
+ minNodes?: number | undefined;
209
209
  maxNodes?: number | undefined;
210
210
  }>>;
211
211
  /**
@@ -213,7 +213,7 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
213
213
  *
214
214
  * Declares any configurable options that can be provided by a Content Editor
215
215
  */
216
- options: z.ZodRecord<z.ZodString, z.ZodObject<{
216
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
217
217
  displayName: z.ZodString;
218
218
  description: z.ZodString;
219
219
  values: z.ZodArray<z.ZodString, "many">;
@@ -225,16 +225,11 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
225
225
  values: string[];
226
226
  description: string;
227
227
  displayName: string;
228
- }>>;
228
+ }>>>;
229
229
  }, {
230
230
  template: z.ZodString;
231
231
  }>, "strip", z.ZodTypeAny, {
232
232
  name: string;
233
- options: Record<string, {
234
- values: string[];
235
- description: string;
236
- displayName: string;
237
- }>;
238
233
  description: string;
239
234
  displayName: string;
240
235
  zones: Record<string, {
@@ -244,22 +239,27 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
244
239
  maxNodes?: number | undefined;
245
240
  }>;
246
241
  template: string;
247
- }, {
248
- name: string;
249
- options: Record<string, {
242
+ options?: Record<string, {
250
243
  values: string[];
251
244
  description: string;
252
245
  displayName: string;
253
- }>;
246
+ }> | undefined;
247
+ }, {
248
+ name: string;
254
249
  description: string;
255
250
  displayName: string;
256
251
  zones: Record<string, {
257
252
  description: string;
258
253
  displayName: string;
259
- minNodes: number;
254
+ minNodes?: number | undefined;
260
255
  maxNodes?: number | undefined;
261
256
  }>;
262
257
  template: string;
258
+ options?: Record<string, {
259
+ values: string[];
260
+ description: string;
261
+ displayName: string;
262
+ }> | undefined;
263
263
  }>;
264
264
  export declare type InputLayoutDefinition = z.infer<typeof InputLayoutDefinition>;
265
265
  export declare type LayoutDefinition = z.infer<typeof LayoutDefinition>;
@@ -117,7 +117,7 @@ exports.BaseLayoutDefinition = zod_1.z.object({
117
117
  zones: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
118
118
  displayName: zod_1.z.string(),
119
119
  description: zod_1.z.string(),
120
- minNodes: zod_1.z.number().min(0),
120
+ minNodes: zod_1.z.number().min(0).default(0),
121
121
  maxNodes: zod_1.z.number().min(1).optional(),
122
122
  })),
123
123
  /**
@@ -125,11 +125,13 @@ exports.BaseLayoutDefinition = zod_1.z.object({
125
125
  *
126
126
  * Declares any configurable options that can be provided by a Content Editor
127
127
  */
128
- options: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
128
+ options: zod_1.z
129
+ .record(zod_1.z.string(), zod_1.z.object({
129
130
  displayName: zod_1.z.string(),
130
131
  description: zod_1.z.string(),
131
132
  values: zod_1.z.array(zod_1.z.string()),
132
- })),
133
+ }))
134
+ .optional(),
133
135
  });
134
136
  exports.InputLayoutDefinition = exports.BaseLayoutDefinition.extend({
135
137
  entry: zod_1.z.string(),
@@ -287,4 +287,152 @@ entry: template.hbs
287
287
  });
288
288
  yield expect((0, definitions_1.loadLayoutDefinition)(paintLayoutFileYaml)).rejects.toThrow('Failed loading layout definition: Failed loading template file "template.hbs": File not found');
289
289
  }));
290
+ it('should load layout definition without options field from YAML file', () => __awaiter(void 0, void 0, void 0, function* () {
291
+ const yamlContentWithoutOptions = `
292
+ name: test-layout
293
+ displayName: Test Layout
294
+ description: A test layout
295
+ zones:
296
+ main:
297
+ displayName: Main Zone
298
+ description: Main content area
299
+ minNodes: 1
300
+ entry: template.hbs
301
+ `;
302
+ fs.readFile.mockImplementation((filePath) => {
303
+ if (filePath.endsWith('page-layout.yaml')) {
304
+ return yamlContentWithoutOptions;
305
+ }
306
+ if (filePath.endsWith('template.hbs')) {
307
+ return templateContent;
308
+ }
309
+ throw new Error('File not found');
310
+ });
311
+ const layoutDefinition = yield (0, definitions_1.loadLayoutDefinition)(paintLayoutFileYaml);
312
+ expect(layoutDefinition).toEqual({
313
+ name: 'test-layout',
314
+ displayName: 'Test Layout',
315
+ description: 'A test layout',
316
+ zones: {
317
+ main: {
318
+ displayName: 'Main Zone',
319
+ description: 'Main content area',
320
+ minNodes: 1,
321
+ },
322
+ },
323
+ template: templateContent,
324
+ });
325
+ }));
326
+ it('should load layout definition without maxNodes in zones from YAML file', () => __awaiter(void 0, void 0, void 0, function* () {
327
+ const yamlContentWithoutMaxNodes = `
328
+ name: test-layout
329
+ displayName: Test Layout
330
+ description: A test layout
331
+ zones:
332
+ main:
333
+ displayName: Main Zone
334
+ description: Main content area
335
+ minNodes: 1
336
+ sidebar:
337
+ displayName: Sidebar Zone
338
+ description: Sidebar content area
339
+ minNodes: 0
340
+ entry: template.hbs
341
+ `;
342
+ fs.readFile.mockImplementation((filePath) => {
343
+ if (filePath.endsWith('page-layout.yaml')) {
344
+ return yamlContentWithoutMaxNodes;
345
+ }
346
+ if (filePath.endsWith('template.hbs')) {
347
+ return templateContent;
348
+ }
349
+ throw new Error('File not found');
350
+ });
351
+ const layoutDefinition = yield (0, definitions_1.loadLayoutDefinition)(paintLayoutFileYaml);
352
+ expect(layoutDefinition).toEqual({
353
+ name: 'test-layout',
354
+ displayName: 'Test Layout',
355
+ description: 'A test layout',
356
+ zones: {
357
+ main: {
358
+ displayName: 'Main Zone',
359
+ description: 'Main content area',
360
+ minNodes: 1,
361
+ },
362
+ sidebar: {
363
+ displayName: 'Sidebar Zone',
364
+ description: 'Sidebar content area',
365
+ minNodes: 0,
366
+ },
367
+ },
368
+ template: templateContent,
369
+ });
370
+ }));
371
+ it('should load layout definition without options and maxNodes from JSON file', () => __awaiter(void 0, void 0, void 0, function* () {
372
+ const jsonContentWithoutOptionsAndMaxNodes = JSON.stringify({
373
+ name: 'test-layout',
374
+ displayName: 'Test Layout',
375
+ description: 'A test layout',
376
+ zones: {
377
+ main: {
378
+ displayName: 'Main Zone',
379
+ description: 'Main content area',
380
+ minNodes: 1,
381
+ },
382
+ sidebar: {
383
+ displayName: 'Sidebar Zone',
384
+ description: 'Sidebar content area',
385
+ minNodes: 0,
386
+ },
387
+ },
388
+ entry: 'template.hbs',
389
+ });
390
+ fs.readFile.mockImplementation((filePath) => {
391
+ if (filePath.endsWith('page-layout.yaml')) {
392
+ throw { code: 'ENOENT' };
393
+ }
394
+ if (filePath.endsWith('page-layout.json')) {
395
+ return jsonContentWithoutOptionsAndMaxNodes;
396
+ }
397
+ if (filePath.endsWith('template.hbs')) {
398
+ return templateContent;
399
+ }
400
+ throw new Error('File not found');
401
+ });
402
+ const layoutDefinition = yield (0, definitions_1.loadLayoutDefinition)(paintLayoutFileJson);
403
+ expect(layoutDefinition).toEqual({
404
+ name: 'test-layout',
405
+ displayName: 'Test Layout',
406
+ description: 'A test layout',
407
+ zones: {
408
+ main: {
409
+ displayName: 'Main Zone',
410
+ description: 'Main content area',
411
+ minNodes: 1,
412
+ },
413
+ sidebar: {
414
+ displayName: 'Sidebar Zone',
415
+ description: 'Sidebar content area',
416
+ minNodes: 0,
417
+ },
418
+ },
419
+ template: templateContent,
420
+ });
421
+ }));
422
+ });
423
+ describe('LayoutDefinitionParse', () => {
424
+ it('should allow zone.minNodes to be undefined', () => {
425
+ const layoutDefinition = definitions_1.BaseLayoutDefinition.parse({
426
+ name: 'test-layout',
427
+ displayName: 'Test Layout',
428
+ description: 'A test layout',
429
+ zones: {
430
+ main: {
431
+ displayName: 'Main Zone',
432
+ description: 'Main content area',
433
+ },
434
+ },
435
+ });
436
+ expect(layoutDefinition.zones.main.minNodes).toBe(0);
437
+ });
290
438
  });
@@ -13,7 +13,7 @@ export interface ExtendedLayoutDefinition extends LayoutDefinition {
13
13
  export interface ZoneDefinition {
14
14
  displayName: string;
15
15
  description: string;
16
- minNodes: number;
16
+ minNodes?: number;
17
17
  maxNodes?: number;
18
18
  }
19
19
  export interface OptionDefinition {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.29.0",
3
+ "version": "5.29.1-develop.2",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },