@squiz/dxp-cli-next 5.29.0 → 5.29.1-develop.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.
@@ -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,13 +64,13 @@ 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, {
@@ -84,6 +79,11 @@ export declare const BaseLayoutDefinition: z.ZodObject<{
84
79
  minNodes: number;
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
  /**
@@ -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,13 +151,13 @@ 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;
@@ -172,6 +167,11 @@ export declare const InputLayoutDefinition: z.ZodObject<z.objectUtil.extendShape
172
167
  minNodes: number;
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
  /**
@@ -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,13 +239,13 @@ 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, {
@@ -260,6 +255,11 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<{
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>;
@@ -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,136 @@ 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
+ }));
290
422
  });
@@ -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.1",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },