@squiz/dx-page-contents-lib 1.78.1 → 1.79.0

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 (46) hide show
  1. package/lib/formatted-text.d.ts +20 -50
  2. package/lib/formatted-text.js +5 -46
  3. package/lib/formatted-text.js.map +1 -1
  4. package/lib/formatted-text.spec.js +0 -10
  5. package/lib/formatted-text.spec.js.map +1 -1
  6. package/lib/layout-content.d.ts +316 -510
  7. package/lib/layout-content.js +30 -24
  8. package/lib/layout-content.js.map +1 -1
  9. package/lib/layout-content.spec.js +49 -10
  10. package/lib/layout-content.spec.js.map +1 -1
  11. package/lib/layouts/custom-layout.d.ts +6 -1056
  12. package/lib/layouts/index.d.ts +10 -4683
  13. package/lib/layouts/index.js +0 -6
  14. package/lib/layouts/index.js.map +1 -1
  15. package/lib/layouts/raw.layout.d.ts +5 -927
  16. package/lib/mocks/PageContentsHelpers.d.ts +37 -6359
  17. package/lib/mocks/PageContentsHelpers.js +40 -76
  18. package/lib/mocks/PageContentsHelpers.js.map +1 -1
  19. package/lib/mocks/PageContentsMocks.d.ts +7 -6
  20. package/lib/mocks/PageContentsMocks.js +54 -36
  21. package/lib/mocks/PageContentsMocks.js.map +1 -1
  22. package/lib/page-contents-lib.d.ts +17 -236
  23. package/lib/page-contents-lib.js +3 -23
  24. package/lib/page-contents-lib.js.map +1 -1
  25. package/lib/page-contents-lib.spec.js +133 -242
  26. package/lib/page-contents-lib.spec.js.map +1 -1
  27. package/lib/resolvers/create-variant-resolver.js +1 -1
  28. package/lib/resolvers/create-variant-resolver.js.map +1 -1
  29. package/lib/resolvers/create-variant-resolver.spec.js +50 -20
  30. package/lib/resolvers/create-variant-resolver.spec.js.map +1 -1
  31. package/lib/resolvers/default-layout-resolver.d.ts +2 -2
  32. package/lib/resolvers/default-layout-resolver.js +10 -4
  33. package/lib/resolvers/default-layout-resolver.js.map +1 -1
  34. package/lib/resolvers/default-layout-resolver.spec.js.map +1 -1
  35. package/lib/resolvers/default-variation-resolver.d.ts +2 -2
  36. package/lib/resolvers/default-variation-resolver.js +15 -5
  37. package/lib/resolvers/default-variation-resolver.js.map +1 -1
  38. package/lib/resolvers/default-variation-resolver.spec.js +22 -5
  39. package/lib/resolvers/default-variation-resolver.spec.js.map +1 -1
  40. package/package.json +1 -1
  41. package/lib/layouts/single-column.layout.d.ts +0 -950
  42. package/lib/layouts/single-column.layout.js +0 -15
  43. package/lib/layouts/single-column.layout.js.map +0 -1
  44. package/lib/layouts/two-column.layout.d.ts +0 -1883
  45. package/lib/layouts/two-column.layout.js +0 -16
  46. package/lib/layouts/two-column.layout.js.map +0 -1
@@ -1,97 +1,170 @@
1
1
  import { z } from 'zod';
2
- import { VariationNode, Variant, LayoutNode } from './formatted-text';
3
- export type DeveloperDefinedLayoutNode = z.infer<typeof LayoutNode> & {
2
+ import { ComponentNode, VariationNode, Variant, FragmentNode, LayoutNode } from './formatted-text';
3
+ type DeveloperDefinedLayoutNode = z.infer<typeof LayoutNode> & {
4
4
  content: Record<string, PageLayoutContent>;
5
5
  };
6
- export declare const DeveloperDefinedLayoutNode: z.ZodType<DeveloperDefinedLayoutNode, z.ZodTypeDef, z.input<typeof LayoutNode>>;
7
- declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
8
- nodeId: z.ZodDefault<z.ZodString>;
9
- type: z.ZodLiteral<"component">;
10
- componentType: z.ZodOptional<z.ZodEnum<["server", "edge"]>>;
11
- componentId: z.ZodString;
12
- componentSet: z.ZodString;
13
- contentItem: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
14
- id: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- id: string;
17
- }, {
18
- id: string;
19
- }>, z.ZodObject<{
20
- content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
21
- schemaName: z.ZodString;
22
- }, "strip", z.ZodTypeAny, {
23
- content: Record<string, unknown>;
24
- schemaName: string;
25
- }, {
26
- content: Record<string, unknown>;
27
- schemaName: string;
28
- }>]>>;
29
- i18n: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
30
- id: z.ZodString;
6
+ export declare const DeveloperDefinedLayoutNode: z.ZodObject<z.objectUtil.extendShape<{
7
+ type: z.ZodLiteral<"layout">;
8
+ layout: z.ZodUnion<[z.ZodObject<{
9
+ name: z.ZodString;
10
+ displayName: z.ZodString;
11
+ description: z.ZodString;
12
+ template: z.ZodString;
13
+ zones: z.ZodRecord<z.ZodString, z.ZodObject<{
14
+ displayName: z.ZodString;
15
+ description: z.ZodString;
16
+ minNodes: z.ZodNumber;
17
+ maxNodes: z.ZodOptional<z.ZodNumber>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ displayName: string;
20
+ description: string;
21
+ minNodes: number;
22
+ maxNodes?: number | undefined;
23
+ }, {
24
+ displayName: string;
25
+ description: string;
26
+ minNodes: number;
27
+ maxNodes?: number | undefined;
28
+ }>>;
29
+ options: z.ZodRecord<z.ZodString, z.ZodObject<{
30
+ displayName: z.ZodString;
31
+ description: z.ZodString;
32
+ values: z.ZodArray<z.ZodString, "many">;
33
+ selectedValue: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ values: string[];
36
+ displayName: string;
37
+ description: string;
38
+ selectedValue: string;
39
+ }, {
40
+ values: string[];
41
+ displayName: string;
42
+ description: string;
43
+ selectedValue: string;
44
+ }>>;
31
45
  }, "strip", z.ZodTypeAny, {
32
- id: string;
46
+ options: Record<string, {
47
+ values: string[];
48
+ displayName: string;
49
+ description: string;
50
+ selectedValue: string;
51
+ }>;
52
+ name: string;
53
+ displayName: string;
54
+ description: string;
55
+ template: string;
56
+ zones: Record<string, {
57
+ displayName: string;
58
+ description: string;
59
+ minNodes: number;
60
+ maxNodes?: number | undefined;
61
+ }>;
33
62
  }, {
34
- id: string;
63
+ options: Record<string, {
64
+ values: string[];
65
+ displayName: string;
66
+ description: string;
67
+ selectedValue: string;
68
+ }>;
69
+ name: string;
70
+ displayName: string;
71
+ description: string;
72
+ template: string;
73
+ zones: Record<string, {
74
+ displayName: string;
75
+ description: string;
76
+ minNodes: number;
77
+ maxNodes?: number | undefined;
78
+ }>;
35
79
  }>, z.ZodObject<{
36
- content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
- schemaName: z.ZodString;
80
+ name: z.ZodString;
81
+ options: z.ZodRecord<z.ZodString, z.ZodObject<{
82
+ selectedValue: z.ZodString;
83
+ }, "strip", z.ZodTypeAny, {
84
+ selectedValue: string;
85
+ }, {
86
+ selectedValue: string;
87
+ }>>;
38
88
  }, "strip", z.ZodTypeAny, {
39
- content: Record<string, unknown>;
40
- schemaName: string;
89
+ options: Record<string, {
90
+ selectedValue: string;
91
+ }>;
92
+ name: string;
41
93
  }, {
42
- content: Record<string, unknown>;
43
- schemaName: string;
44
- }>]>>>;
45
- }, "strip", z.ZodTypeAny, {
46
- type: "component";
47
- nodeId: string;
48
- componentId: string;
49
- componentSet: string;
50
- i18n?: Record<string, {
51
- id: string;
52
- } | {
53
- content: Record<string, unknown>;
54
- schemaName: string;
55
- }> | undefined;
56
- componentType?: "server" | "edge" | undefined;
57
- contentItem?: {
58
- id: string;
59
- } | {
60
- content: Record<string, unknown>;
61
- schemaName: string;
62
- } | undefined;
94
+ options: Record<string, {
95
+ selectedValue: string;
96
+ }>;
97
+ name: string;
98
+ }>]>;
63
99
  }, {
64
- type: "component";
65
- componentId: string;
66
- componentSet: string;
67
- nodeId?: string | undefined;
68
- i18n?: Record<string, {
69
- id: string;
100
+ content: z.ZodLazy<z.ZodRecord<z.ZodString, z.ZodType<LayoutContentNodes[], z.ZodTypeDef, (Omit<LayoutContentNodes, "nodeId"> & {
101
+ nodeId?: string | undefined;
102
+ })[]>>>;
103
+ }>, "strip", z.ZodTypeAny, {
104
+ type: "layout";
105
+ content: Record<string, LayoutContentNodes[]>;
106
+ layout: {
107
+ options: Record<string, {
108
+ values: string[];
109
+ displayName: string;
110
+ description: string;
111
+ selectedValue: string;
112
+ }>;
113
+ name: string;
114
+ displayName: string;
115
+ description: string;
116
+ template: string;
117
+ zones: Record<string, {
118
+ displayName: string;
119
+ description: string;
120
+ minNodes: number;
121
+ maxNodes?: number | undefined;
122
+ }>;
70
123
  } | {
71
- content: Record<string, unknown>;
72
- schemaName: string;
73
- }> | undefined;
74
- componentType?: "server" | "edge" | undefined;
75
- contentItem?: {
76
- id: string;
124
+ options: Record<string, {
125
+ selectedValue: string;
126
+ }>;
127
+ name: string;
128
+ };
129
+ }, {
130
+ type: "layout";
131
+ content: Record<string, (Omit<LayoutContentNodes, "nodeId"> & {
132
+ nodeId?: string | undefined;
133
+ })[]>;
134
+ layout: {
135
+ options: Record<string, {
136
+ values: string[];
137
+ displayName: string;
138
+ description: string;
139
+ selectedValue: string;
140
+ }>;
141
+ name: string;
142
+ displayName: string;
143
+ description: string;
144
+ template: string;
145
+ zones: Record<string, {
146
+ displayName: string;
147
+ description: string;
148
+ minNodes: number;
149
+ maxNodes?: number | undefined;
150
+ }>;
77
151
  } | {
78
- content: Record<string, unknown>;
79
- schemaName: string;
80
- } | undefined;
81
- }>, z.ZodObject<{
82
- nodeId: z.ZodDefault<z.ZodString>;
152
+ options: Record<string, {
153
+ selectedValue: string;
154
+ }>;
155
+ name: string;
156
+ };
157
+ }>;
158
+ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
83
159
  type: z.ZodLiteral<"text">;
84
160
  value: z.ZodString;
85
161
  }, "strip", z.ZodTypeAny, {
86
162
  value: string;
87
163
  type: "text";
88
- nodeId: string;
89
164
  }, {
90
165
  value: string;
91
166
  type: "text";
92
- nodeId?: string | undefined;
93
167
  }>, z.ZodObject<{
94
- nodeId: z.ZodDefault<z.ZodString>;
95
168
  type: z.ZodLiteral<"tag">;
96
169
  tag: z.ZodString;
97
170
  attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -126,7 +199,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
126
199
  }>>;
127
200
  }, "strip", z.ZodTypeAny, {
128
201
  type: "tag";
129
- nodeId: string;
130
202
  tag: string;
131
203
  attributes?: Record<string, string> | undefined;
132
204
  font?: {
@@ -143,7 +215,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
143
215
  }, {
144
216
  type: "tag";
145
217
  tag: string;
146
- nodeId?: string | undefined;
147
218
  attributes?: Record<string, string> | undefined;
148
219
  font?: {
149
220
  bold?: boolean | undefined;
@@ -157,19 +228,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
157
228
  alignment: "left" | "center" | "right" | "justify";
158
229
  } | undefined;
159
230
  }>, z.ZodObject<{
160
- nodeId: z.ZodDefault<z.ZodString>;
161
- type: z.ZodLiteral<"fragment">;
162
- i18n: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
163
- }, "strip", z.ZodTypeAny, {
164
- type: "fragment";
165
- nodeId: string;
166
- i18n?: Record<string, {}> | undefined;
167
- }, {
168
- type: "fragment";
169
- nodeId?: string | undefined;
170
- i18n?: Record<string, {}> | undefined;
171
- }>, z.ZodObject<{
172
- nodeId: z.ZodDefault<z.ZodString>;
173
231
  type: z.ZodLiteral<"link-to-matrix-asset">;
174
232
  matrixIdentifier: z.ZodOptional<z.ZodString>;
175
233
  matrixDomain: z.ZodString;
@@ -194,7 +252,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
194
252
  }>>>;
195
253
  }, "strip", z.ZodTypeAny, {
196
254
  type: "link-to-matrix-asset";
197
- nodeId: string;
198
255
  matrixDomain: string;
199
256
  matrixAssetId: string;
200
257
  target: "_blank" | "_self" | "_parent" | "_top";
@@ -211,7 +268,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
211
268
  matrixDomain: string;
212
269
  matrixAssetId: string;
213
270
  target: "_blank" | "_self" | "_parent" | "_top";
214
- nodeId?: string | undefined;
215
271
  attributes?: (Record<string, string> & {
216
272
  target?: undefined;
217
273
  href?: undefined;
@@ -221,7 +277,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
221
277
  } | undefined;
222
278
  matrixIdentifier?: string | undefined;
223
279
  }>, z.ZodObject<{
224
- nodeId: z.ZodDefault<z.ZodString>;
225
280
  type: z.ZodLiteral<"link-to-dam-asset">;
226
281
  damSystemType: z.ZodString;
227
282
  damSystemIdentifier: z.ZodString;
@@ -253,7 +308,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
253
308
  }>>>;
254
309
  }, "strip", z.ZodTypeAny, {
255
310
  type: "link-to-dam-asset";
256
- nodeId: string;
257
311
  target: "_blank" | "_self" | "_parent" | "_top";
258
312
  damSystemType: string;
259
313
  damSystemIdentifier: string;
@@ -274,7 +328,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
274
328
  damSystemType: string;
275
329
  damSystemIdentifier: string;
276
330
  damObjectId: string;
277
- nodeId?: string | undefined;
278
331
  attributes?: (Record<string, string> & {
279
332
  target?: undefined;
280
333
  href?: undefined;
@@ -286,7 +339,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
286
339
  variant?: string | undefined;
287
340
  } | undefined;
288
341
  }>, z.ZodObject<{
289
- nodeId: z.ZodDefault<z.ZodString>;
290
342
  type: z.ZodLiteral<"matrix-image">;
291
343
  matrixIdentifier: z.ZodOptional<z.ZodString>;
292
344
  matrixDomain: z.ZodString;
@@ -307,7 +359,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
307
359
  }>>>;
308
360
  }, "strip", z.ZodTypeAny, {
309
361
  type: "matrix-image";
310
- nodeId: string;
311
362
  matrixDomain: string;
312
363
  matrixAssetId: string;
313
364
  attributes?: (Record<string, string> & {
@@ -321,7 +372,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
321
372
  type: "matrix-image";
322
373
  matrixDomain: string;
323
374
  matrixAssetId: string;
324
- nodeId?: string | undefined;
325
375
  attributes?: (Record<string, string> & {
326
376
  src?: undefined;
327
377
  }) | undefined;
@@ -330,7 +380,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
330
380
  } | undefined;
331
381
  matrixIdentifier?: string | undefined;
332
382
  }>, z.ZodObject<{
333
- nodeId: z.ZodDefault<z.ZodString>;
334
383
  type: z.ZodLiteral<"dam-image">;
335
384
  damSystemType: z.ZodString;
336
385
  damSystemIdentifier: z.ZodString;
@@ -358,7 +407,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
358
407
  }>>>;
359
408
  }, "strip", z.ZodTypeAny, {
360
409
  type: "dam-image";
361
- nodeId: string;
362
410
  damSystemType: string;
363
411
  damSystemIdentifier: string;
364
412
  damObjectId: string;
@@ -376,7 +424,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
376
424
  damSystemType: string;
377
425
  damSystemIdentifier: string;
378
426
  damObjectId: string;
379
- nodeId?: string | undefined;
380
427
  attributes?: (Record<string, string> & {
381
428
  src?: undefined;
382
429
  }) | undefined;
@@ -388,432 +435,193 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
388
435
  } | undefined;
389
436
  }>]>;
390
437
  type BaseLayoutContentNodes = z.infer<typeof BaseLayoutContentNodes>;
391
- /**
392
- * All the nodes which allow children
393
- */
394
- declare const NODES_WITH_CHILDREN: readonly ["tag", "fragment", "link-to-matrix-asset", "link-to-dam-asset"];
395
- type NodesWithChildren = ChooseNodesWithChildren<(typeof NODES_WITH_CHILDREN)[number]>;
396
438
  export type LayoutVariant = z.infer<typeof Variant> & {
397
439
  node: LayoutContentNodes | null;
398
440
  };
399
- export type LayoutVariationNode = z.infer<typeof VariationNode> & {
441
+ type LayoutVariationNode = z.infer<typeof VariationNode> & {
400
442
  default: {
401
443
  node: LayoutContentNodes | null;
402
444
  };
403
445
  variants: LayoutVariant[];
404
446
  };
405
- export declare const LayoutVariationNode: z.ZodType<LayoutVariationNode, z.ZodTypeDef, z.input<typeof VariationNode>>;
406
- type SimpleContentNodes = Exclude<BaseLayoutContentNodes, NodesWithChildren> | (NodesWithChildren & {
407
- children: LayoutContentNodes[];
408
- });
409
- declare const SimpleContentNodes: z.ZodType<SimpleContentNodes, z.ZodTypeDef, z.input<typeof BaseLayoutContentNodes>>;
447
+ export declare const LayoutVariationNode: z.ZodObject<z.objectUtil.extendShape<{
448
+ type: z.ZodLiteral<"variation">;
449
+ default: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
450
+ }, {
451
+ default: z.ZodObject<{
452
+ node: z.ZodNullable<z.ZodLazy<z.ZodType<LayoutContentNodes, z.ZodTypeDef, Omit<LayoutContentNodes, "nodeId"> & {
453
+ nodeId?: string | undefined;
454
+ }>>>;
455
+ }, "strip", z.ZodTypeAny, {
456
+ node: LayoutContentNodes | null;
457
+ }, {
458
+ node: (Omit<LayoutContentNodes, "nodeId"> & {
459
+ nodeId?: string | undefined;
460
+ }) | null;
461
+ }>;
462
+ variants: z.ZodEffects<z.ZodArray<z.ZodIntersection<z.ZodObject<{
463
+ conditions: z.ZodObject<{
464
+ segment: z.ZodOptional<z.ZodObject<{
465
+ code: z.ZodString;
466
+ }, "strip", z.ZodTypeAny, {
467
+ code: string;
468
+ }, {
469
+ code: string;
470
+ }>>;
471
+ experiment: z.ZodOptional<z.ZodObject<{
472
+ id: z.ZodString;
473
+ variant: z.ZodString;
474
+ }, "strip", z.ZodTypeAny, {
475
+ variant: string;
476
+ id: string;
477
+ }, {
478
+ variant: string;
479
+ id: string;
480
+ }>>;
481
+ }, "strip", z.ZodTypeAny, {
482
+ segment?: {
483
+ code: string;
484
+ } | undefined;
485
+ experiment?: {
486
+ variant: string;
487
+ id: string;
488
+ } | undefined;
489
+ }, {
490
+ segment?: {
491
+ code: string;
492
+ } | undefined;
493
+ experiment?: {
494
+ variant: string;
495
+ id: string;
496
+ } | undefined;
497
+ }>;
498
+ }, "strip", z.ZodTypeAny, {
499
+ conditions: {
500
+ segment?: {
501
+ code: string;
502
+ } | undefined;
503
+ experiment?: {
504
+ variant: string;
505
+ id: string;
506
+ } | undefined;
507
+ };
508
+ }, {
509
+ conditions: {
510
+ segment?: {
511
+ code: string;
512
+ } | undefined;
513
+ experiment?: {
514
+ variant: string;
515
+ id: string;
516
+ } | undefined;
517
+ };
518
+ }>, z.ZodObject<{
519
+ node: z.ZodNullable<z.ZodLazy<z.ZodType<LayoutContentNodes, z.ZodTypeDef, Omit<LayoutContentNodes, "nodeId"> & {
520
+ nodeId?: string | undefined;
521
+ }>>>;
522
+ }, "strip", z.ZodTypeAny, {
523
+ node: LayoutContentNodes | null;
524
+ }, {
525
+ node: (Omit<LayoutContentNodes, "nodeId"> & {
526
+ nodeId?: string | undefined;
527
+ }) | null;
528
+ }>>, "many">, ({
529
+ conditions: {
530
+ segment?: {
531
+ code: string;
532
+ } | undefined;
533
+ experiment?: {
534
+ variant: string;
535
+ id: string;
536
+ } | undefined;
537
+ };
538
+ } & {
539
+ node: LayoutContentNodes | null;
540
+ })[], ({
541
+ conditions: {
542
+ segment?: {
543
+ code: string;
544
+ } | undefined;
545
+ experiment?: {
546
+ variant: string;
547
+ id: string;
548
+ } | undefined;
549
+ };
550
+ } & {
551
+ node: (Omit<LayoutContentNodes, "nodeId"> & {
552
+ nodeId?: string | undefined;
553
+ }) | null;
554
+ })[]>;
555
+ }>, "strip", z.ZodTypeAny, {
556
+ type: "variation";
557
+ default: {
558
+ node: LayoutContentNodes | null;
559
+ };
560
+ variants: ({
561
+ conditions: {
562
+ segment?: {
563
+ code: string;
564
+ } | undefined;
565
+ experiment?: {
566
+ variant: string;
567
+ id: string;
568
+ } | undefined;
569
+ };
570
+ } & {
571
+ node: LayoutContentNodes | null;
572
+ })[];
573
+ }, {
574
+ type: "variation";
575
+ default: {
576
+ node: (Omit<LayoutContentNodes, "nodeId"> & {
577
+ nodeId?: string | undefined;
578
+ }) | null;
579
+ };
580
+ variants: ({
581
+ conditions: {
582
+ segment?: {
583
+ code: string;
584
+ } | undefined;
585
+ experiment?: {
586
+ variant: string;
587
+ id: string;
588
+ } | undefined;
589
+ };
590
+ } & {
591
+ node: (Omit<LayoutContentNodes, "nodeId"> & {
592
+ nodeId?: string | undefined;
593
+ }) | null;
594
+ })[];
595
+ }>;
596
+ type FragmentNodeWithChildren = z.infer<typeof FragmentNode> & {
597
+ children: SimpleContentNodes[];
598
+ };
599
+ export declare const FragmentNodeWithChildren: z.ZodType<FragmentNodeWithChildren>;
600
+ export type SimpleContentNodes = BaseLayoutContentNodes & {
601
+ children?: SimpleContentNodes[] | undefined;
602
+ };
410
603
  /**
411
604
  * Schema for all possible layout content nodes with checks for children
412
605
  */
413
- export declare const LayoutContentNodes: z.ZodUnion<[z.ZodType<SimpleContentNodes, z.ZodTypeDef, {
414
- value: string;
415
- type: "text";
416
- nodeId?: string | undefined;
417
- } | {
418
- type: "tag";
419
- tag: string;
420
- nodeId?: string | undefined;
421
- attributes?: Record<string, string> | undefined;
422
- font?: {
423
- bold?: boolean | undefined;
424
- italics?: boolean | undefined;
425
- underline?: boolean | undefined;
426
- color?: string | undefined;
427
- size?: string | undefined;
428
- fontFamily?: string | undefined;
429
- } | undefined;
430
- formattingOptions?: {
431
- alignment: "left" | "center" | "right" | "justify";
432
- } | undefined;
433
- } | {
434
- type: "fragment";
435
- nodeId?: string | undefined;
436
- i18n?: Record<string, {}> | undefined;
437
- } | {
438
- type: "link-to-matrix-asset";
439
- matrixDomain: string;
440
- matrixAssetId: string;
441
- target: "_blank" | "_self" | "_parent" | "_top";
442
- nodeId?: string | undefined;
443
- attributes?: (Record<string, string> & {
444
- target?: undefined;
445
- href?: undefined;
446
- }) | undefined;
447
- formattingOptions?: {
448
- alignment: "left" | "center" | "right" | "justify";
449
- } | undefined;
450
- matrixIdentifier?: string | undefined;
451
- } | {
452
- type: "link-to-dam-asset";
453
- target: "_blank" | "_self" | "_parent" | "_top";
454
- damSystemType: string;
455
- damSystemIdentifier: string;
456
- damObjectId: string;
457
- nodeId?: string | undefined;
458
- attributes?: (Record<string, string> & {
459
- target?: undefined;
460
- href?: undefined;
461
- }) | undefined;
462
- formattingOptions?: {
463
- alignment: "left" | "center" | "right" | "justify";
464
- } | undefined;
465
- damAdditional?: {
466
- variant?: string | undefined;
467
- } | undefined;
468
- } | {
469
- type: "matrix-image";
470
- matrixDomain: string;
471
- matrixAssetId: string;
472
- nodeId?: string | undefined;
473
- attributes?: (Record<string, string> & {
474
- src?: undefined;
475
- }) | undefined;
476
- formattingOptions?: {
477
- alignment: "left" | "center" | "right" | "justify";
478
- } | undefined;
479
- matrixIdentifier?: string | undefined;
480
- } | {
481
- type: "dam-image";
482
- damSystemType: string;
483
- damSystemIdentifier: string;
484
- damObjectId: string;
485
- nodeId?: string | undefined;
486
- attributes?: (Record<string, string> & {
487
- src?: undefined;
488
- }) | undefined;
489
- formattingOptions?: {
490
- alignment: "left" | "center" | "right" | "justify";
491
- } | undefined;
492
- damAdditional?: {
493
- variant?: string | undefined;
494
- } | undefined;
495
- } | {
496
- type: "component";
497
- componentId: string;
498
- componentSet: string;
499
- nodeId?: string | undefined;
500
- i18n?: Record<string, {
501
- id: string;
502
- } | {
503
- content: Record<string, unknown>;
504
- schemaName: string;
505
- }> | undefined;
506
- componentType?: "server" | "edge" | undefined;
507
- contentItem?: {
508
- id: string;
509
- } | {
510
- content: Record<string, unknown>;
511
- schemaName: string;
512
- } | undefined;
513
- }>, z.ZodType<LayoutVariationNode, z.ZodTypeDef, {
514
- type: "variation";
515
- default: {};
516
- nodeId?: string | undefined;
517
- }>, z.ZodType<DeveloperDefinedLayoutNode, z.ZodTypeDef, {
518
- type: "layout";
519
- layout: {
520
- options: Record<string, {
521
- values: string[];
522
- displayName: string;
523
- description: string;
524
- selectedValue: string;
525
- }>;
526
- name: string;
527
- displayName: string;
528
- description: string;
529
- template: string;
530
- zones: Record<string, {
531
- displayName: string;
532
- description: string;
533
- minNodes: number;
534
- maxNodes?: number | undefined;
535
- }>;
536
- } | {
537
- options: Record<string, {
538
- selectedValue: string;
539
- }>;
540
- name: string;
541
- };
606
+ export type LayoutContentNodes = {
607
+ nodeId: string;
608
+ } & (FragmentNodeWithChildren | LayoutVariationNode | DeveloperDefinedLayoutNode | z.infer<typeof ComponentNode>);
609
+ export declare const LayoutContentNodes: z.ZodType<LayoutContentNodes, z.ZodTypeDef, Omit<LayoutContentNodes, 'nodeId'> & {
542
610
  nodeId?: string | undefined;
543
- }>]>;
611
+ }>;
544
612
  /**
545
613
  * Comprehensive list of all nodes and the existence of child nodes within
546
614
  */
547
- export type LayoutContentNodes = z.infer<typeof LayoutContentNodes>;
615
+ export type LayoutContentNodesInput = z.input<typeof LayoutContentNodes>;
548
616
  export declare function getNestedNodes(nodes: LayoutContentNodes[]): LayoutContentNodes[];
549
- export declare const PageLayoutContent: z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodType<SimpleContentNodes, z.ZodTypeDef, {
550
- value: string;
551
- type: "text";
552
- nodeId?: string | undefined;
553
- } | {
554
- type: "tag";
555
- tag: string;
556
- nodeId?: string | undefined;
557
- attributes?: Record<string, string> | undefined;
558
- font?: {
559
- bold?: boolean | undefined;
560
- italics?: boolean | undefined;
561
- underline?: boolean | undefined;
562
- color?: string | undefined;
563
- size?: string | undefined;
564
- fontFamily?: string | undefined;
565
- } | undefined;
566
- formattingOptions?: {
567
- alignment: "left" | "center" | "right" | "justify";
568
- } | undefined;
569
- } | {
570
- type: "fragment";
571
- nodeId?: string | undefined;
572
- i18n?: Record<string, {}> | undefined;
573
- } | {
574
- type: "link-to-matrix-asset";
575
- matrixDomain: string;
576
- matrixAssetId: string;
577
- target: "_blank" | "_self" | "_parent" | "_top";
578
- nodeId?: string | undefined;
579
- attributes?: (Record<string, string> & {
580
- target?: undefined;
581
- href?: undefined;
582
- }) | undefined;
583
- formattingOptions?: {
584
- alignment: "left" | "center" | "right" | "justify";
585
- } | undefined;
586
- matrixIdentifier?: string | undefined;
587
- } | {
588
- type: "link-to-dam-asset";
589
- target: "_blank" | "_self" | "_parent" | "_top";
590
- damSystemType: string;
591
- damSystemIdentifier: string;
592
- damObjectId: string;
593
- nodeId?: string | undefined;
594
- attributes?: (Record<string, string> & {
595
- target?: undefined;
596
- href?: undefined;
597
- }) | undefined;
598
- formattingOptions?: {
599
- alignment: "left" | "center" | "right" | "justify";
600
- } | undefined;
601
- damAdditional?: {
602
- variant?: string | undefined;
603
- } | undefined;
604
- } | {
605
- type: "matrix-image";
606
- matrixDomain: string;
607
- matrixAssetId: string;
608
- nodeId?: string | undefined;
609
- attributes?: (Record<string, string> & {
610
- src?: undefined;
611
- }) | undefined;
612
- formattingOptions?: {
613
- alignment: "left" | "center" | "right" | "justify";
614
- } | undefined;
615
- matrixIdentifier?: string | undefined;
616
- } | {
617
- type: "dam-image";
618
- damSystemType: string;
619
- damSystemIdentifier: string;
620
- damObjectId: string;
621
- nodeId?: string | undefined;
622
- attributes?: (Record<string, string> & {
623
- src?: undefined;
624
- }) | undefined;
625
- formattingOptions?: {
626
- alignment: "left" | "center" | "right" | "justify";
627
- } | undefined;
628
- damAdditional?: {
629
- variant?: string | undefined;
630
- } | undefined;
631
- } | {
632
- type: "component";
633
- componentId: string;
634
- componentSet: string;
635
- nodeId?: string | undefined;
636
- i18n?: Record<string, {
637
- id: string;
638
- } | {
639
- content: Record<string, unknown>;
640
- schemaName: string;
641
- }> | undefined;
642
- componentType?: "server" | "edge" | undefined;
643
- contentItem?: {
644
- id: string;
645
- } | {
646
- content: Record<string, unknown>;
647
- schemaName: string;
648
- } | undefined;
649
- }>, z.ZodType<LayoutVariationNode, z.ZodTypeDef, {
650
- type: "variation";
651
- default: {};
652
- nodeId?: string | undefined;
653
- }>, z.ZodType<DeveloperDefinedLayoutNode, z.ZodTypeDef, {
654
- type: "layout";
655
- layout: {
656
- options: Record<string, {
657
- values: string[];
658
- displayName: string;
659
- description: string;
660
- selectedValue: string;
661
- }>;
662
- name: string;
663
- displayName: string;
664
- description: string;
665
- template: string;
666
- zones: Record<string, {
667
- displayName: string;
668
- description: string;
669
- minNodes: number;
670
- maxNodes?: number | undefined;
671
- }>;
672
- } | {
673
- options: Record<string, {
674
- selectedValue: string;
675
- }>;
676
- name: string;
677
- };
678
- nodeId?: string | undefined;
679
- }>]>, "many">, (LayoutVariationNode | SimpleContentNodes | DeveloperDefinedLayoutNode)[], ({
680
- value: string;
681
- type: "text";
682
- nodeId?: string | undefined;
683
- } | {
684
- type: "tag";
685
- tag: string;
686
- nodeId?: string | undefined;
687
- attributes?: Record<string, string> | undefined;
688
- font?: {
689
- bold?: boolean | undefined;
690
- italics?: boolean | undefined;
691
- underline?: boolean | undefined;
692
- color?: string | undefined;
693
- size?: string | undefined;
694
- fontFamily?: string | undefined;
695
- } | undefined;
696
- formattingOptions?: {
697
- alignment: "left" | "center" | "right" | "justify";
698
- } | undefined;
699
- } | {
700
- type: "fragment";
701
- nodeId?: string | undefined;
702
- i18n?: Record<string, {}> | undefined;
703
- } | {
704
- type: "link-to-matrix-asset";
705
- matrixDomain: string;
706
- matrixAssetId: string;
707
- target: "_blank" | "_self" | "_parent" | "_top";
708
- nodeId?: string | undefined;
709
- attributes?: (Record<string, string> & {
710
- target?: undefined;
711
- href?: undefined;
712
- }) | undefined;
713
- formattingOptions?: {
714
- alignment: "left" | "center" | "right" | "justify";
715
- } | undefined;
716
- matrixIdentifier?: string | undefined;
717
- } | {
718
- type: "link-to-dam-asset";
719
- target: "_blank" | "_self" | "_parent" | "_top";
720
- damSystemType: string;
721
- damSystemIdentifier: string;
722
- damObjectId: string;
723
- nodeId?: string | undefined;
724
- attributes?: (Record<string, string> & {
725
- target?: undefined;
726
- href?: undefined;
727
- }) | undefined;
728
- formattingOptions?: {
729
- alignment: "left" | "center" | "right" | "justify";
730
- } | undefined;
731
- damAdditional?: {
732
- variant?: string | undefined;
733
- } | undefined;
734
- } | {
735
- type: "matrix-image";
736
- matrixDomain: string;
737
- matrixAssetId: string;
738
- nodeId?: string | undefined;
739
- attributes?: (Record<string, string> & {
740
- src?: undefined;
741
- }) | undefined;
742
- formattingOptions?: {
743
- alignment: "left" | "center" | "right" | "justify";
744
- } | undefined;
745
- matrixIdentifier?: string | undefined;
746
- } | {
747
- type: "dam-image";
748
- damSystemType: string;
749
- damSystemIdentifier: string;
750
- damObjectId: string;
751
- nodeId?: string | undefined;
752
- attributes?: (Record<string, string> & {
753
- src?: undefined;
754
- }) | undefined;
755
- formattingOptions?: {
756
- alignment: "left" | "center" | "right" | "justify";
757
- } | undefined;
758
- damAdditional?: {
759
- variant?: string | undefined;
760
- } | undefined;
761
- } | {
762
- type: "component";
763
- componentId: string;
764
- componentSet: string;
765
- nodeId?: string | undefined;
766
- i18n?: Record<string, {
767
- id: string;
768
- } | {
769
- content: Record<string, unknown>;
770
- schemaName: string;
771
- }> | undefined;
772
- componentType?: "server" | "edge" | undefined;
773
- contentItem?: {
774
- id: string;
775
- } | {
776
- content: Record<string, unknown>;
777
- schemaName: string;
778
- } | undefined;
779
- } | {
780
- type: "variation";
781
- default: {};
782
- nodeId?: string | undefined;
783
- } | {
784
- type: "layout";
785
- layout: {
786
- options: Record<string, {
787
- values: string[];
788
- displayName: string;
789
- description: string;
790
- selectedValue: string;
791
- }>;
792
- name: string;
793
- displayName: string;
794
- description: string;
795
- template: string;
796
- zones: Record<string, {
797
- displayName: string;
798
- description: string;
799
- minNodes: number;
800
- maxNodes?: number | undefined;
801
- }>;
802
- } | {
803
- options: Record<string, {
804
- selectedValue: string;
805
- }>;
806
- name: string;
807
- };
808
- nodeId?: string | undefined;
809
- })[]>;
617
+ export declare const PageLayoutContent: z.ZodType<Array<LayoutContentNodes>, z.ZodTypeDef, z.input<typeof LayoutContentNodes>[]>;
810
618
  export type PageLayoutContent = z.infer<typeof PageLayoutContent>;
811
- export type NodeResolver = (node: LayoutContentNodes) => Promise<LayoutContentNodes | void>;
812
- export type ContentResolver<K extends LayoutContentNodes['type']> = (node: Extract<LayoutContentNodes, {
619
+ export type NodeResolver = (node: LayoutContentNodes) => Promise<LayoutContentNodes>;
620
+ export type ContentResolver<K extends (LayoutContentNodes | SimpleContentNodes)['type']> = (node: Extract<LayoutContentNodes | SimpleContentNodes, {
813
621
  type: K;
814
- }>, resolve: NodeResolver) => Promise<LayoutContentNodes | void>;
622
+ }>, resolve: NodeResolver) => Promise<(LayoutContentNodes | SimpleContentNodes) | void>;
815
623
  type PossibleResolvers = {
816
- [K in LayoutContentNodes['type']]?: ContentResolver<K>;
624
+ [K in (LayoutContentNodes | SimpleContentNodes)['type']]?: ContentResolver<K>;
817
625
  };
818
626
  /**
819
627
  * Walk through the layout content and resolve the content items.
@@ -821,9 +629,7 @@ type PossibleResolvers = {
821
629
  export declare class PageLayoutContentResolver {
822
630
  private contentResolvers;
823
631
  constructor(contentResolvers?: PossibleResolvers);
632
+ private resolveNode;
824
633
  resolve(layoutContent: PageLayoutContent): Promise<PageLayoutContent>;
825
634
  }
826
- type ChooseNodesWithChildren<T extends BaseLayoutContentNodes['type']> = Extract<BaseLayoutContentNodes, {
827
- type: T;
828
- }>;
829
635
  export {};