@squiz/dx-page-contents-lib 1.78.1 → 1.80.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 (40) 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 +302 -510
  7. package/lib/layout-content.js +40 -24
  8. package/lib/layout-content.js.map +1 -1
  9. package/lib/layout-content.spec.js +67 -10
  10. package/lib/layout-content.spec.js.map +1 -1
  11. package/lib/layouts/custom-layout.d.ts +6 -1064
  12. package/lib/layouts/index.d.ts +25 -4665
  13. package/lib/layouts/raw.layout.d.ts +5 -933
  14. package/lib/layouts/single-column.layout.d.ts +5 -933
  15. package/lib/layouts/two-column.layout.d.ts +10 -1866
  16. package/lib/mocks/PageContentsHelpers.d.ts +58 -6333
  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 +88 -36
  21. package/lib/mocks/PageContentsMocks.js.map +1 -1
  22. package/lib/page-contents-lib.d.ts +24 -242
  23. package/lib/page-contents-lib.js +146 -64
  24. package/lib/page-contents-lib.js.map +1 -1
  25. package/lib/page-contents-lib.spec.js +1382 -798
  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
@@ -1,97 +1,166 @@
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, unknown[]>>>;
101
+ }>, "strip", z.ZodTypeAny, {
102
+ type: "layout";
103
+ content: Record<string, LayoutContentNodes[]>;
104
+ layout: {
105
+ options: Record<string, {
106
+ values: string[];
107
+ displayName: string;
108
+ description: string;
109
+ selectedValue: string;
110
+ }>;
111
+ name: string;
112
+ displayName: string;
113
+ description: string;
114
+ template: string;
115
+ zones: Record<string, {
116
+ displayName: string;
117
+ description: string;
118
+ minNodes: number;
119
+ maxNodes?: number | undefined;
120
+ }>;
70
121
  } | {
71
- content: Record<string, unknown>;
72
- schemaName: string;
73
- }> | undefined;
74
- componentType?: "server" | "edge" | undefined;
75
- contentItem?: {
76
- id: string;
122
+ options: Record<string, {
123
+ selectedValue: string;
124
+ }>;
125
+ name: string;
126
+ };
127
+ }, {
128
+ type: "layout";
129
+ content: Record<string, unknown[]>;
130
+ layout: {
131
+ options: Record<string, {
132
+ values: string[];
133
+ displayName: string;
134
+ description: string;
135
+ selectedValue: string;
136
+ }>;
137
+ name: string;
138
+ displayName: string;
139
+ description: string;
140
+ template: string;
141
+ zones: Record<string, {
142
+ displayName: string;
143
+ description: string;
144
+ minNodes: number;
145
+ maxNodes?: number | undefined;
146
+ }>;
77
147
  } | {
78
- content: Record<string, unknown>;
79
- schemaName: string;
80
- } | undefined;
81
- }>, z.ZodObject<{
82
- nodeId: z.ZodDefault<z.ZodString>;
148
+ options: Record<string, {
149
+ selectedValue: string;
150
+ }>;
151
+ name: string;
152
+ };
153
+ }>;
154
+ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
83
155
  type: z.ZodLiteral<"text">;
84
156
  value: z.ZodString;
85
157
  }, "strip", z.ZodTypeAny, {
86
158
  value: string;
87
159
  type: "text";
88
- nodeId: string;
89
160
  }, {
90
161
  value: string;
91
162
  type: "text";
92
- nodeId?: string | undefined;
93
163
  }>, z.ZodObject<{
94
- nodeId: z.ZodDefault<z.ZodString>;
95
164
  type: z.ZodLiteral<"tag">;
96
165
  tag: z.ZodString;
97
166
  attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -126,7 +195,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
126
195
  }>>;
127
196
  }, "strip", z.ZodTypeAny, {
128
197
  type: "tag";
129
- nodeId: string;
130
198
  tag: string;
131
199
  attributes?: Record<string, string> | undefined;
132
200
  font?: {
@@ -143,7 +211,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
143
211
  }, {
144
212
  type: "tag";
145
213
  tag: string;
146
- nodeId?: string | undefined;
147
214
  attributes?: Record<string, string> | undefined;
148
215
  font?: {
149
216
  bold?: boolean | undefined;
@@ -157,19 +224,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
157
224
  alignment: "left" | "center" | "right" | "justify";
158
225
  } | undefined;
159
226
  }>, 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
227
  type: z.ZodLiteral<"link-to-matrix-asset">;
174
228
  matrixIdentifier: z.ZodOptional<z.ZodString>;
175
229
  matrixDomain: z.ZodString;
@@ -194,7 +248,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
194
248
  }>>>;
195
249
  }, "strip", z.ZodTypeAny, {
196
250
  type: "link-to-matrix-asset";
197
- nodeId: string;
198
251
  matrixDomain: string;
199
252
  matrixAssetId: string;
200
253
  target: "_blank" | "_self" | "_parent" | "_top";
@@ -211,7 +264,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
211
264
  matrixDomain: string;
212
265
  matrixAssetId: string;
213
266
  target: "_blank" | "_self" | "_parent" | "_top";
214
- nodeId?: string | undefined;
215
267
  attributes?: (Record<string, string> & {
216
268
  target?: undefined;
217
269
  href?: undefined;
@@ -221,7 +273,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
221
273
  } | undefined;
222
274
  matrixIdentifier?: string | undefined;
223
275
  }>, z.ZodObject<{
224
- nodeId: z.ZodDefault<z.ZodString>;
225
276
  type: z.ZodLiteral<"link-to-dam-asset">;
226
277
  damSystemType: z.ZodString;
227
278
  damSystemIdentifier: z.ZodString;
@@ -253,7 +304,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
253
304
  }>>>;
254
305
  }, "strip", z.ZodTypeAny, {
255
306
  type: "link-to-dam-asset";
256
- nodeId: string;
257
307
  target: "_blank" | "_self" | "_parent" | "_top";
258
308
  damSystemType: string;
259
309
  damSystemIdentifier: string;
@@ -274,7 +324,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
274
324
  damSystemType: string;
275
325
  damSystemIdentifier: string;
276
326
  damObjectId: string;
277
- nodeId?: string | undefined;
278
327
  attributes?: (Record<string, string> & {
279
328
  target?: undefined;
280
329
  href?: undefined;
@@ -286,7 +335,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
286
335
  variant?: string | undefined;
287
336
  } | undefined;
288
337
  }>, z.ZodObject<{
289
- nodeId: z.ZodDefault<z.ZodString>;
290
338
  type: z.ZodLiteral<"matrix-image">;
291
339
  matrixIdentifier: z.ZodOptional<z.ZodString>;
292
340
  matrixDomain: z.ZodString;
@@ -307,7 +355,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
307
355
  }>>>;
308
356
  }, "strip", z.ZodTypeAny, {
309
357
  type: "matrix-image";
310
- nodeId: string;
311
358
  matrixDomain: string;
312
359
  matrixAssetId: string;
313
360
  attributes?: (Record<string, string> & {
@@ -321,7 +368,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
321
368
  type: "matrix-image";
322
369
  matrixDomain: string;
323
370
  matrixAssetId: string;
324
- nodeId?: string | undefined;
325
371
  attributes?: (Record<string, string> & {
326
372
  src?: undefined;
327
373
  }) | undefined;
@@ -330,7 +376,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
330
376
  } | undefined;
331
377
  matrixIdentifier?: string | undefined;
332
378
  }>, z.ZodObject<{
333
- nodeId: z.ZodDefault<z.ZodString>;
334
379
  type: z.ZodLiteral<"dam-image">;
335
380
  damSystemType: z.ZodString;
336
381
  damSystemIdentifier: z.ZodString;
@@ -358,7 +403,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
358
403
  }>>>;
359
404
  }, "strip", z.ZodTypeAny, {
360
405
  type: "dam-image";
361
- nodeId: string;
362
406
  damSystemType: string;
363
407
  damSystemIdentifier: string;
364
408
  damObjectId: string;
@@ -376,7 +420,6 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
376
420
  damSystemType: string;
377
421
  damSystemIdentifier: string;
378
422
  damObjectId: string;
379
- nodeId?: string | undefined;
380
423
  attributes?: (Record<string, string> & {
381
424
  src?: undefined;
382
425
  }) | undefined;
@@ -388,432 +431,183 @@ declare const BaseLayoutContentNodes: z.ZodDiscriminatedUnion<"type", [z.ZodObje
388
431
  } | undefined;
389
432
  }>]>;
390
433
  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
434
  export type LayoutVariant = z.infer<typeof Variant> & {
397
435
  node: LayoutContentNodes | null;
398
436
  };
399
- export type LayoutVariationNode = z.infer<typeof VariationNode> & {
437
+ type LayoutVariationNode = z.infer<typeof VariationNode> & {
400
438
  default: {
401
439
  node: LayoutContentNodes | null;
402
440
  };
403
441
  variants: LayoutVariant[];
404
442
  };
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>>;
443
+ export declare const LayoutVariationNode: z.ZodObject<z.objectUtil.extendShape<{
444
+ type: z.ZodLiteral<"variation">;
445
+ default: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
446
+ }, {
447
+ default: z.ZodObject<{
448
+ node: z.ZodNullable<z.ZodLazy<z.ZodEffects<z.ZodType<LayoutContentNodes, z.ZodTypeDef, Omit<LayoutContentNodes, "nodeId"> & {
449
+ nodeId?: string | undefined;
450
+ }>, LayoutContentNodes, unknown>>>;
451
+ }, "strip", z.ZodTypeAny, {
452
+ node: LayoutContentNodes | null;
453
+ }, {
454
+ node?: unknown;
455
+ }>;
456
+ variants: z.ZodEffects<z.ZodArray<z.ZodIntersection<z.ZodObject<{
457
+ conditions: z.ZodObject<{
458
+ segment: z.ZodOptional<z.ZodObject<{
459
+ code: z.ZodString;
460
+ }, "strip", z.ZodTypeAny, {
461
+ code: string;
462
+ }, {
463
+ code: string;
464
+ }>>;
465
+ experiment: z.ZodOptional<z.ZodObject<{
466
+ id: z.ZodString;
467
+ variant: z.ZodString;
468
+ }, "strip", z.ZodTypeAny, {
469
+ variant: string;
470
+ id: string;
471
+ }, {
472
+ variant: string;
473
+ id: string;
474
+ }>>;
475
+ }, "strip", z.ZodTypeAny, {
476
+ segment?: {
477
+ code: string;
478
+ } | undefined;
479
+ experiment?: {
480
+ variant: string;
481
+ id: string;
482
+ } | undefined;
483
+ }, {
484
+ segment?: {
485
+ code: string;
486
+ } | undefined;
487
+ experiment?: {
488
+ variant: string;
489
+ id: string;
490
+ } | undefined;
491
+ }>;
492
+ }, "strip", z.ZodTypeAny, {
493
+ conditions: {
494
+ segment?: {
495
+ code: string;
496
+ } | undefined;
497
+ experiment?: {
498
+ variant: string;
499
+ id: string;
500
+ } | undefined;
501
+ };
502
+ }, {
503
+ conditions: {
504
+ segment?: {
505
+ code: string;
506
+ } | undefined;
507
+ experiment?: {
508
+ variant: string;
509
+ id: string;
510
+ } | undefined;
511
+ };
512
+ }>, z.ZodObject<{
513
+ node: z.ZodNullable<z.ZodLazy<z.ZodEffects<z.ZodType<LayoutContentNodes, z.ZodTypeDef, Omit<LayoutContentNodes, "nodeId"> & {
514
+ nodeId?: string | undefined;
515
+ }>, LayoutContentNodes, unknown>>>;
516
+ }, "strip", z.ZodTypeAny, {
517
+ node: LayoutContentNodes | null;
518
+ }, {
519
+ node?: unknown;
520
+ }>>, "many">, ({
521
+ conditions: {
522
+ segment?: {
523
+ code: string;
524
+ } | undefined;
525
+ experiment?: {
526
+ variant: string;
527
+ id: string;
528
+ } | undefined;
529
+ };
530
+ } & {
531
+ node: LayoutContentNodes | null;
532
+ })[], ({
533
+ conditions: {
534
+ segment?: {
535
+ code: string;
536
+ } | undefined;
537
+ experiment?: {
538
+ variant: string;
539
+ id: string;
540
+ } | undefined;
541
+ };
542
+ } & {
543
+ node?: unknown;
544
+ })[]>;
545
+ }>, "strip", z.ZodTypeAny, {
546
+ type: "variation";
547
+ default: {
548
+ node: LayoutContentNodes | null;
549
+ };
550
+ variants: ({
551
+ conditions: {
552
+ segment?: {
553
+ code: string;
554
+ } | undefined;
555
+ experiment?: {
556
+ variant: string;
557
+ id: string;
558
+ } | undefined;
559
+ };
560
+ } & {
561
+ node: LayoutContentNodes | null;
562
+ })[];
563
+ }, {
564
+ type: "variation";
565
+ default: {
566
+ node?: unknown;
567
+ };
568
+ variants: ({
569
+ conditions: {
570
+ segment?: {
571
+ code: string;
572
+ } | undefined;
573
+ experiment?: {
574
+ variant: string;
575
+ id: string;
576
+ } | undefined;
577
+ };
578
+ } & {
579
+ node?: unknown;
580
+ })[];
581
+ }>;
582
+ type FragmentNodeWithChildren = z.infer<typeof FragmentNode> & {
583
+ children: SimpleContentNodes[];
584
+ };
585
+ export declare const FragmentNodeWithChildren: z.ZodType<FragmentNodeWithChildren>;
586
+ export type SimpleContentNodes = BaseLayoutContentNodes & {
587
+ children?: SimpleContentNodes[] | undefined;
588
+ };
410
589
  /**
411
590
  * Schema for all possible layout content nodes with checks for children
412
591
  */
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
- };
592
+ export type LayoutContentNodes = {
593
+ nodeId: string;
594
+ } & (FragmentNodeWithChildren | LayoutVariationNode | DeveloperDefinedLayoutNode | z.infer<typeof ComponentNode>);
595
+ export declare const LayoutContentNodes: z.ZodEffects<z.ZodType<LayoutContentNodes, z.ZodTypeDef, Omit<LayoutContentNodes, 'nodeId'> & {
542
596
  nodeId?: string | undefined;
543
- }>]>;
597
+ }>, LayoutContentNodes, unknown>;
544
598
  /**
545
599
  * Comprehensive list of all nodes and the existence of child nodes within
546
600
  */
547
- export type LayoutContentNodes = z.infer<typeof LayoutContentNodes>;
601
+ export type LayoutContentNodesInput = z.input<typeof LayoutContentNodes>;
548
602
  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
- })[]>;
603
+ export declare const PageLayoutContent: z.ZodType<Array<LayoutContentNodes>, z.ZodTypeDef, z.input<typeof LayoutContentNodes>[]>;
810
604
  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, {
605
+ export type NodeResolver = (node: LayoutContentNodes) => Promise<LayoutContentNodes>;
606
+ export type ContentResolver<K extends (LayoutContentNodes | SimpleContentNodes)['type']> = (node: Extract<LayoutContentNodes | SimpleContentNodes, {
813
607
  type: K;
814
- }>, resolve: NodeResolver) => Promise<LayoutContentNodes | void>;
608
+ }>, resolve: NodeResolver) => Promise<(LayoutContentNodes | SimpleContentNodes) | void>;
815
609
  type PossibleResolvers = {
816
- [K in LayoutContentNodes['type']]?: ContentResolver<K>;
610
+ [K in (LayoutContentNodes | SimpleContentNodes)['type']]?: ContentResolver<K>;
817
611
  };
818
612
  /**
819
613
  * Walk through the layout content and resolve the content items.
@@ -821,9 +615,7 @@ type PossibleResolvers = {
821
615
  export declare class PageLayoutContentResolver {
822
616
  private contentResolvers;
823
617
  constructor(contentResolvers?: PossibleResolvers);
618
+ private resolveNode;
824
619
  resolve(layoutContent: PageLayoutContent): Promise<PageLayoutContent>;
825
620
  }
826
- type ChooseNodesWithChildren<T extends BaseLayoutContentNodes['type']> = Extract<BaseLayoutContentNodes, {
827
- type: T;
828
- }>;
829
621
  export {};