@squiz/dxp-cli-next 5.32.0 → 5.33.0-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.
- package/lib/page/layouts/validation/property-consistency.spec.js +3 -1
- package/lib/page/layouts/validation/zone-consistency.spec.js +0 -5
- package/lib/page/utils/definitions.d.ts +61 -17
- package/lib/page/utils/definitions.js +10 -4
- package/lib/page/utils/definitions.spec.js +18 -0
- package/lib/page/utils/normalize.spec.js +6 -12
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const property_consistency_1 = require("./property-consistency");
|
|
4
4
|
describe('validatePropertyConsistency', () => {
|
|
5
|
-
const createMockLayout = (layout) => (Object.assign({ name: 'test-layout', displayName: 'Test Layout', description: 'A test layout', zones: [
|
|
5
|
+
const createMockLayout = (layout) => (Object.assign({ name: 'test-layout', displayName: 'Test Layout', description: 'A test layout', zones: [
|
|
6
|
+
{ key: 'main', displayName: 'Main Zone', description: 'Main zone' },
|
|
7
|
+
], template: '' }, layout));
|
|
6
8
|
describe('new format (manifest.json)', () => {
|
|
7
9
|
it('should return null for valid property consistency', () => {
|
|
8
10
|
const layout = createMockLayout({
|
|
@@ -80,11 +80,6 @@ describe('validateZoneConsistency', () => {
|
|
|
80
80
|
const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
|
|
81
81
|
expect(result).toBeNull();
|
|
82
82
|
});
|
|
83
|
-
it('should handle empty zones object', () => {
|
|
84
|
-
const layout = createMockLayout([], '<div>Static content only</div>');
|
|
85
|
-
const result = (0, zone_consistency_1.validateZoneConsistency)(layout);
|
|
86
|
-
expect(result).toBeNull();
|
|
87
|
-
});
|
|
88
83
|
it('should handle undefined zones property', () => {
|
|
89
84
|
const layout = {
|
|
90
85
|
name: 'test-layout',
|
|
@@ -52,7 +52,7 @@ export declare const InputLayoutDefinitionV1: z.ZodObject<z.objectUtil.extendSha
|
|
|
52
52
|
* Declares the content structure that will be the input to the
|
|
53
53
|
* Handlebars template
|
|
54
54
|
*/
|
|
55
|
-
zones: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
55
|
+
zones: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
56
56
|
displayName: z.ZodString;
|
|
57
57
|
description: z.ZodString;
|
|
58
58
|
minNodes: z.ZodDefault<z.ZodNumber>;
|
|
@@ -67,6 +67,16 @@ export declare const InputLayoutDefinitionV1: z.ZodObject<z.objectUtil.extendSha
|
|
|
67
67
|
displayName: string;
|
|
68
68
|
minNodes?: number | undefined;
|
|
69
69
|
maxNodes?: number | undefined;
|
|
70
|
+
}>>, Record<string, {
|
|
71
|
+
description: string;
|
|
72
|
+
displayName: string;
|
|
73
|
+
minNodes: number;
|
|
74
|
+
maxNodes?: number | undefined;
|
|
75
|
+
}>, Record<string, {
|
|
76
|
+
description: string;
|
|
77
|
+
displayName: string;
|
|
78
|
+
minNodes?: number | undefined;
|
|
79
|
+
maxNodes?: number | undefined;
|
|
70
80
|
}>>;
|
|
71
81
|
/**
|
|
72
82
|
* Layout options
|
|
@@ -160,7 +170,7 @@ export declare const InputLayoutDefinitionV2: z.ZodObject<z.objectUtil.extendSha
|
|
|
160
170
|
key: string;
|
|
161
171
|
description: string;
|
|
162
172
|
displayName: string;
|
|
163
|
-
}>, "
|
|
173
|
+
}>, "atleastone">;
|
|
164
174
|
/**
|
|
165
175
|
* Layout properties
|
|
166
176
|
*
|
|
@@ -199,11 +209,15 @@ export declare const InputLayoutDefinitionV2: z.ZodObject<z.objectUtil.extendSha
|
|
|
199
209
|
entry: string;
|
|
200
210
|
description: string;
|
|
201
211
|
displayName: string;
|
|
202
|
-
zones: {
|
|
212
|
+
zones: [{
|
|
203
213
|
key: string;
|
|
204
214
|
description: string;
|
|
205
215
|
displayName: string;
|
|
206
|
-
}
|
|
216
|
+
}, ...{
|
|
217
|
+
key: string;
|
|
218
|
+
description: string;
|
|
219
|
+
displayName: string;
|
|
220
|
+
}[]];
|
|
207
221
|
properties?: Record<string, {
|
|
208
222
|
type: "boolean";
|
|
209
223
|
description: string;
|
|
@@ -219,11 +233,15 @@ export declare const InputLayoutDefinitionV2: z.ZodObject<z.objectUtil.extendSha
|
|
|
219
233
|
entry: string;
|
|
220
234
|
description: string;
|
|
221
235
|
displayName: string;
|
|
222
|
-
zones: {
|
|
236
|
+
zones: [{
|
|
237
|
+
key: string;
|
|
238
|
+
description: string;
|
|
239
|
+
displayName: string;
|
|
240
|
+
}, ...{
|
|
223
241
|
key: string;
|
|
224
242
|
description: string;
|
|
225
243
|
displayName: string;
|
|
226
|
-
}[];
|
|
244
|
+
}[]];
|
|
227
245
|
properties?: Record<string, {
|
|
228
246
|
type: "boolean";
|
|
229
247
|
description: string;
|
|
@@ -258,7 +276,7 @@ export declare const InputLayoutDefinition: z.ZodUnion<[z.ZodObject<z.objectUtil
|
|
|
258
276
|
* Declares the content structure that will be the input to the
|
|
259
277
|
* Handlebars template
|
|
260
278
|
*/
|
|
261
|
-
zones: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
279
|
+
zones: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
262
280
|
displayName: z.ZodString;
|
|
263
281
|
description: z.ZodString;
|
|
264
282
|
minNodes: z.ZodDefault<z.ZodNumber>;
|
|
@@ -273,6 +291,16 @@ export declare const InputLayoutDefinition: z.ZodUnion<[z.ZodObject<z.objectUtil
|
|
|
273
291
|
displayName: string;
|
|
274
292
|
minNodes?: number | undefined;
|
|
275
293
|
maxNodes?: number | undefined;
|
|
294
|
+
}>>, Record<string, {
|
|
295
|
+
description: string;
|
|
296
|
+
displayName: string;
|
|
297
|
+
minNodes: number;
|
|
298
|
+
maxNodes?: number | undefined;
|
|
299
|
+
}>, Record<string, {
|
|
300
|
+
description: string;
|
|
301
|
+
displayName: string;
|
|
302
|
+
minNodes?: number | undefined;
|
|
303
|
+
maxNodes?: number | undefined;
|
|
276
304
|
}>>;
|
|
277
305
|
/**
|
|
278
306
|
* Layout options
|
|
@@ -362,7 +390,7 @@ export declare const InputLayoutDefinition: z.ZodUnion<[z.ZodObject<z.objectUtil
|
|
|
362
390
|
key: string;
|
|
363
391
|
description: string;
|
|
364
392
|
displayName: string;
|
|
365
|
-
}>, "
|
|
393
|
+
}>, "atleastone">;
|
|
366
394
|
/**
|
|
367
395
|
* Layout properties
|
|
368
396
|
*
|
|
@@ -401,11 +429,15 @@ export declare const InputLayoutDefinition: z.ZodUnion<[z.ZodObject<z.objectUtil
|
|
|
401
429
|
entry: string;
|
|
402
430
|
description: string;
|
|
403
431
|
displayName: string;
|
|
404
|
-
zones: {
|
|
432
|
+
zones: [{
|
|
405
433
|
key: string;
|
|
406
434
|
description: string;
|
|
407
435
|
displayName: string;
|
|
408
|
-
}
|
|
436
|
+
}, ...{
|
|
437
|
+
key: string;
|
|
438
|
+
description: string;
|
|
439
|
+
displayName: string;
|
|
440
|
+
}[]];
|
|
409
441
|
properties?: Record<string, {
|
|
410
442
|
type: "boolean";
|
|
411
443
|
description: string;
|
|
@@ -421,11 +453,15 @@ export declare const InputLayoutDefinition: z.ZodUnion<[z.ZodObject<z.objectUtil
|
|
|
421
453
|
entry: string;
|
|
422
454
|
description: string;
|
|
423
455
|
displayName: string;
|
|
424
|
-
zones: {
|
|
456
|
+
zones: [{
|
|
425
457
|
key: string;
|
|
426
458
|
description: string;
|
|
427
459
|
displayName: string;
|
|
428
|
-
}
|
|
460
|
+
}, ...{
|
|
461
|
+
key: string;
|
|
462
|
+
description: string;
|
|
463
|
+
displayName: string;
|
|
464
|
+
}[]];
|
|
429
465
|
properties?: Record<string, {
|
|
430
466
|
type: "boolean";
|
|
431
467
|
description: string;
|
|
@@ -470,7 +506,7 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<Omit
|
|
|
470
506
|
key: string;
|
|
471
507
|
description: string;
|
|
472
508
|
displayName: string;
|
|
473
|
-
}>, "
|
|
509
|
+
}>, "atleastone">;
|
|
474
510
|
/**
|
|
475
511
|
* Layout properties
|
|
476
512
|
*
|
|
@@ -510,11 +546,15 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<Omit
|
|
|
510
546
|
name: string;
|
|
511
547
|
description: string;
|
|
512
548
|
displayName: string;
|
|
513
|
-
zones: {
|
|
549
|
+
zones: [{
|
|
550
|
+
key: string;
|
|
551
|
+
description: string;
|
|
552
|
+
displayName: string;
|
|
553
|
+
}, ...{
|
|
514
554
|
key: string;
|
|
515
555
|
description: string;
|
|
516
556
|
displayName: string;
|
|
517
|
-
}[];
|
|
557
|
+
}[]];
|
|
518
558
|
template: string;
|
|
519
559
|
properties?: Record<string, {
|
|
520
560
|
type: "boolean";
|
|
@@ -530,11 +570,15 @@ export declare const LayoutDefinition: z.ZodObject<z.objectUtil.extendShape<Omit
|
|
|
530
570
|
name: string;
|
|
531
571
|
description: string;
|
|
532
572
|
displayName: string;
|
|
533
|
-
zones: {
|
|
573
|
+
zones: [{
|
|
574
|
+
key: string;
|
|
575
|
+
description: string;
|
|
576
|
+
displayName: string;
|
|
577
|
+
}, ...{
|
|
534
578
|
key: string;
|
|
535
579
|
description: string;
|
|
536
580
|
displayName: string;
|
|
537
|
-
}[];
|
|
581
|
+
}[]];
|
|
538
582
|
template: string;
|
|
539
583
|
properties?: Record<string, {
|
|
540
584
|
type: "boolean";
|
|
@@ -164,12 +164,16 @@ exports.InputLayoutDefinitionV1 = exports.BaseLayoutDefinition.extend({
|
|
|
164
164
|
* Declares the content structure that will be the input to the
|
|
165
165
|
* Handlebars template
|
|
166
166
|
*/
|
|
167
|
-
zones: zod_1.z
|
|
167
|
+
zones: zod_1.z
|
|
168
|
+
.record(zod_1.z.string(), zod_1.z.object({
|
|
168
169
|
displayName: zod_1.z.string(),
|
|
169
170
|
description: zod_1.z.string(),
|
|
170
171
|
minNodes: zod_1.z.number().min(0).default(0),
|
|
171
172
|
maxNodes: zod_1.z.number().min(1).optional(),
|
|
172
|
-
}))
|
|
173
|
+
}))
|
|
174
|
+
.refine(data => Object.keys(data).length > 0, {
|
|
175
|
+
message: 'Must contain at least 1 zone',
|
|
176
|
+
}),
|
|
173
177
|
/**
|
|
174
178
|
* Layout options
|
|
175
179
|
*
|
|
@@ -195,13 +199,15 @@ exports.InputLayoutDefinitionV2 = exports.BaseLayoutDefinition.extend({
|
|
|
195
199
|
* Declares the content structure that will be the input to the
|
|
196
200
|
* Handlebars template
|
|
197
201
|
*/
|
|
198
|
-
zones: zod_1.z
|
|
202
|
+
zones: zod_1.z
|
|
203
|
+
.array(zod_1.z
|
|
199
204
|
.object({
|
|
200
205
|
key: zod_1.z.string(),
|
|
201
206
|
displayName: zod_1.z.string(),
|
|
202
207
|
description: zod_1.z.string(),
|
|
203
208
|
})
|
|
204
|
-
.strict())
|
|
209
|
+
.strict())
|
|
210
|
+
.nonempty(),
|
|
205
211
|
/**
|
|
206
212
|
* Layout properties
|
|
207
213
|
*
|
|
@@ -457,6 +457,15 @@ entry: template.hbs
|
|
|
457
457
|
});
|
|
458
458
|
describe('LayoutDefinitionParse', () => {
|
|
459
459
|
describe('V1 format - zones objects and options (deprecated)', () => {
|
|
460
|
+
it('should not allow empty zones object', () => {
|
|
461
|
+
expect(() => definitions_1.InputLayoutDefinitionV1.parse({
|
|
462
|
+
name: 'test-layout',
|
|
463
|
+
displayName: 'Test Layout',
|
|
464
|
+
description: 'A test layout',
|
|
465
|
+
entry: 'template.hbs',
|
|
466
|
+
zones: {},
|
|
467
|
+
})).toThrow();
|
|
468
|
+
});
|
|
460
469
|
it('should allow zone.minNodes to be undefined', () => {
|
|
461
470
|
const layoutDefinition = definitions_1.InputLayoutDefinitionV1.parse({
|
|
462
471
|
name: 'test-layout',
|
|
@@ -607,6 +616,15 @@ describe('LayoutDefinitionParse', () => {
|
|
|
607
616
|
});
|
|
608
617
|
});
|
|
609
618
|
describe('V2 format - zones arrays and properties', () => {
|
|
619
|
+
it('should not allow empty zones array', () => {
|
|
620
|
+
expect(() => definitions_1.InputLayoutDefinitionV2.parse({
|
|
621
|
+
name: 'test-layout',
|
|
622
|
+
displayName: 'Test Layout',
|
|
623
|
+
description: 'A test layout',
|
|
624
|
+
entry: 'template.hbs',
|
|
625
|
+
zones: [],
|
|
626
|
+
})).toThrow();
|
|
627
|
+
});
|
|
610
628
|
it('should not allow minNodes to be defined in a zone', () => {
|
|
611
629
|
expect(() => definitions_1.InputLayoutDefinitionV2.parse({
|
|
612
630
|
name: 'test-layout',
|
|
@@ -48,16 +48,6 @@ describe('normalizeZones', () => {
|
|
|
48
48
|
},
|
|
49
49
|
]);
|
|
50
50
|
});
|
|
51
|
-
it('should handle empty zones object', () => {
|
|
52
|
-
const zones = {};
|
|
53
|
-
const result = (0, normalize_1.normalizeZones)(zones);
|
|
54
|
-
expect(result).toEqual([]);
|
|
55
|
-
});
|
|
56
|
-
it('should handle empty zones array', () => {
|
|
57
|
-
const zones = [];
|
|
58
|
-
const result = (0, normalize_1.normalizeZones)(zones);
|
|
59
|
-
expect(result).toEqual([]);
|
|
60
|
-
});
|
|
61
51
|
it('should throw error when zones is null', () => {
|
|
62
52
|
expect(() => (0, normalize_1.normalizeZones)(null)).toThrow('zones must be an object or array');
|
|
63
53
|
});
|
|
@@ -79,7 +69,9 @@ describe('normalizeProperties', () => {
|
|
|
79
69
|
displayName: 'Test Layout',
|
|
80
70
|
description: 'A test layout',
|
|
81
71
|
entry: 'template.hbs',
|
|
82
|
-
zones: [
|
|
72
|
+
zones: [
|
|
73
|
+
{ key: 'main', displayName: 'Main Zone', description: 'Main zone' },
|
|
74
|
+
],
|
|
83
75
|
properties: {
|
|
84
76
|
title: {
|
|
85
77
|
type: 'string',
|
|
@@ -103,7 +95,9 @@ describe('normalizeProperties', () => {
|
|
|
103
95
|
displayName: 'Test Layout',
|
|
104
96
|
description: 'A test layout',
|
|
105
97
|
entry: 'template.hbs',
|
|
106
|
-
zones: [
|
|
98
|
+
zones: [
|
|
99
|
+
{ key: 'main', displayName: 'Main Zone', description: 'Main zone' },
|
|
100
|
+
],
|
|
107
101
|
};
|
|
108
102
|
const result = (0, normalize_1.normalizeProperties)(layout);
|
|
109
103
|
expect(result).toBeUndefined();
|