@contentful/experiences-core 3.8.0-prerelease-20250922T2329-e132272.0 → 3.8.0-prerelease-20251001T1442-021a279.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.
- package/dist/constants.cjs +0 -4
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.ts +1 -3
- package/dist/constants.js +1 -3
- package/dist/constants.js.map +1 -1
- package/dist/entity/EntityStore.d.ts +2 -0
- package/dist/exports.d.ts +1 -1
- package/dist/index.cjs +16 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -147
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -137,7 +137,6 @@ var PostMessageMethods;
|
|
|
137
137
|
PostMessageMethods["REQUESTED_ENTITIES"] = "REQUESTED_ENTITIES";
|
|
138
138
|
})(PostMessageMethods || (PostMessageMethods = {}));
|
|
139
139
|
const SUPPORTED_IMAGE_FORMATS = ['jpg', 'png', 'webp', 'gif', 'avif'];
|
|
140
|
-
const SIDELOADED_PREFIX = 'sideloaded_';
|
|
141
140
|
|
|
142
141
|
const structureComponentIds = new Set([
|
|
143
142
|
CONTENTFUL_COMPONENTS.section.id,
|
|
@@ -183,7 +182,6 @@ const builtInStyles = {
|
|
|
183
182
|
},
|
|
184
183
|
type: 'Text',
|
|
185
184
|
group: 'style',
|
|
186
|
-
description: 'The vertical alignment of the section',
|
|
187
185
|
defaultValue: 'center',
|
|
188
186
|
displayName: 'Vertical alignment',
|
|
189
187
|
},
|
|
@@ -210,7 +208,6 @@ const builtInStyles = {
|
|
|
210
208
|
},
|
|
211
209
|
type: 'Text',
|
|
212
210
|
group: 'style',
|
|
213
|
-
description: 'The horizontal alignment of the section',
|
|
214
211
|
defaultValue: 'center',
|
|
215
212
|
displayName: 'Horizontal alignment',
|
|
216
213
|
},
|
|
@@ -219,83 +216,71 @@ const builtInStyles = {
|
|
|
219
216
|
type: 'Boolean',
|
|
220
217
|
group: 'style',
|
|
221
218
|
defaultValue: true,
|
|
222
|
-
description: 'The visibility of the component',
|
|
223
219
|
},
|
|
224
220
|
cfMargin: {
|
|
225
221
|
displayName: 'Margin',
|
|
226
222
|
type: 'Text',
|
|
227
223
|
group: 'style',
|
|
228
|
-
description: 'The margin of the section',
|
|
229
224
|
defaultValue: '0 0 0 0',
|
|
230
225
|
},
|
|
231
226
|
cfPadding: {
|
|
232
227
|
displayName: 'Padding',
|
|
233
228
|
type: 'Text',
|
|
234
229
|
group: 'style',
|
|
235
|
-
description: 'The padding of the section',
|
|
236
230
|
defaultValue: '0 0 0 0',
|
|
237
231
|
},
|
|
238
232
|
cfBackgroundColor: {
|
|
239
233
|
displayName: 'Background color',
|
|
240
234
|
type: 'Text',
|
|
241
235
|
group: 'style',
|
|
242
|
-
description: 'The background color of the section',
|
|
243
236
|
defaultValue: 'rgba(0, 0, 0, 0)',
|
|
244
237
|
},
|
|
245
238
|
cfWidth: {
|
|
246
239
|
displayName: 'Width',
|
|
247
240
|
type: 'Text',
|
|
248
241
|
group: 'style',
|
|
249
|
-
description: 'The width of the section',
|
|
250
242
|
defaultValue: '100%',
|
|
251
243
|
},
|
|
252
244
|
cfHeight: {
|
|
253
245
|
displayName: 'Height',
|
|
254
246
|
type: 'Text',
|
|
255
247
|
group: 'style',
|
|
256
|
-
description: 'The height of the section',
|
|
257
248
|
defaultValue: 'fit-content',
|
|
258
249
|
},
|
|
259
250
|
cfMaxWidth: {
|
|
260
251
|
displayName: 'Max width',
|
|
261
252
|
type: 'Text',
|
|
262
253
|
group: 'style',
|
|
263
|
-
description: 'The max-width of the section',
|
|
264
254
|
defaultValue: 'none',
|
|
265
255
|
},
|
|
266
256
|
cfFlexDirection: {
|
|
267
257
|
displayName: 'Direction',
|
|
268
258
|
type: 'Text',
|
|
269
259
|
group: 'style',
|
|
270
|
-
description: 'The orientation of the section',
|
|
271
260
|
defaultValue: 'column',
|
|
272
261
|
},
|
|
273
262
|
cfFlexReverse: {
|
|
274
263
|
displayName: 'Reverse Direction',
|
|
275
264
|
type: 'Boolean',
|
|
276
265
|
group: 'style',
|
|
277
|
-
description: 'Toggle the flex direction to be reversed',
|
|
278
266
|
defaultValue: false,
|
|
279
267
|
},
|
|
280
268
|
cfFlexWrap: {
|
|
281
269
|
displayName: 'Wrap objects',
|
|
282
270
|
type: 'Text',
|
|
283
271
|
group: 'style',
|
|
284
|
-
description: 'Wrap objects',
|
|
285
272
|
defaultValue: 'nowrap',
|
|
286
273
|
},
|
|
287
274
|
cfBorder: {
|
|
288
275
|
displayName: 'Border',
|
|
289
276
|
type: 'Text',
|
|
290
277
|
group: 'style',
|
|
291
|
-
description: 'The border of the section',
|
|
292
278
|
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
293
279
|
},
|
|
294
280
|
cfGap: {
|
|
295
281
|
displayName: 'Gap',
|
|
296
282
|
type: 'Text',
|
|
297
283
|
group: 'style',
|
|
298
|
-
description: 'The spacing between the elements of the section',
|
|
299
284
|
defaultValue: '0px',
|
|
300
285
|
},
|
|
301
286
|
cfHyperlink: {
|
|
@@ -306,7 +291,6 @@ const builtInStyles = {
|
|
|
306
291
|
format: 'URL',
|
|
307
292
|
bindingSourceType: ['entry', 'experience', 'manual'],
|
|
308
293
|
},
|
|
309
|
-
description: 'hyperlink for section or container',
|
|
310
294
|
},
|
|
311
295
|
cfOpenInNewTab: {
|
|
312
296
|
displayName: 'URL behaviour',
|
|
@@ -320,7 +304,6 @@ const optionalBuiltInStyles = {
|
|
|
320
304
|
displayName: 'Font Size',
|
|
321
305
|
type: 'Text',
|
|
322
306
|
group: 'style',
|
|
323
|
-
description: 'The font size of the element',
|
|
324
307
|
defaultValue: '16px',
|
|
325
308
|
},
|
|
326
309
|
cfFontWeight: {
|
|
@@ -343,13 +326,11 @@ const optionalBuiltInStyles = {
|
|
|
343
326
|
displayName: 'Font Weight',
|
|
344
327
|
type: 'Text',
|
|
345
328
|
group: 'style',
|
|
346
|
-
description: 'The font weight of the element',
|
|
347
329
|
defaultValue: '400',
|
|
348
330
|
},
|
|
349
331
|
cfImageAsset: {
|
|
350
332
|
displayName: 'Image',
|
|
351
333
|
type: 'Media',
|
|
352
|
-
description: 'Image to display',
|
|
353
334
|
validations: {
|
|
354
335
|
bindingSourceType: ['asset', 'entry', 'manual'],
|
|
355
336
|
},
|
|
@@ -368,13 +349,11 @@ const optionalBuiltInStyles = {
|
|
|
368
349
|
displayName: 'Background color',
|
|
369
350
|
type: 'Text',
|
|
370
351
|
group: 'style',
|
|
371
|
-
description: 'The background color of the element',
|
|
372
352
|
defaultValue: 'rgba(0, 0, 0, 0)',
|
|
373
353
|
},
|
|
374
354
|
cfBackgroundImageUrl: {
|
|
375
355
|
displayName: 'Background image',
|
|
376
356
|
type: 'Media',
|
|
377
|
-
description: 'Background image for component',
|
|
378
357
|
validations: {
|
|
379
358
|
bindingSourceType: ['asset', 'entry', 'manual'],
|
|
380
359
|
},
|
|
@@ -393,28 +372,24 @@ const optionalBuiltInStyles = {
|
|
|
393
372
|
displayName: 'Border Radius',
|
|
394
373
|
type: 'Text',
|
|
395
374
|
group: 'style',
|
|
396
|
-
description: 'The border radius of the section',
|
|
397
375
|
defaultValue: '0px',
|
|
398
376
|
},
|
|
399
377
|
cfLineHeight: {
|
|
400
378
|
displayName: 'Line Height',
|
|
401
379
|
type: 'Text',
|
|
402
380
|
group: 'style',
|
|
403
|
-
description: 'The line height of the element',
|
|
404
381
|
defaultValue: '20px',
|
|
405
382
|
},
|
|
406
383
|
cfLetterSpacing: {
|
|
407
384
|
displayName: 'Letter Spacing',
|
|
408
385
|
type: 'Text',
|
|
409
386
|
group: 'style',
|
|
410
|
-
description: 'The letter spacing of the element',
|
|
411
387
|
defaultValue: '0px',
|
|
412
388
|
},
|
|
413
389
|
cfTextColor: {
|
|
414
390
|
displayName: 'Text Color',
|
|
415
391
|
type: 'Text',
|
|
416
392
|
group: 'style',
|
|
417
|
-
description: 'The text color of the element',
|
|
418
393
|
defaultValue: 'rgba(0, 0, 0, 1)',
|
|
419
394
|
},
|
|
420
395
|
cfTextAlign: {
|
|
@@ -437,7 +412,6 @@ const optionalBuiltInStyles = {
|
|
|
437
412
|
displayName: 'Text Align',
|
|
438
413
|
type: 'Text',
|
|
439
414
|
group: 'style',
|
|
440
|
-
description: 'The text alignment of the element',
|
|
441
415
|
defaultValue: 'start',
|
|
442
416
|
},
|
|
443
417
|
cfTextTransform: {
|
|
@@ -464,28 +438,24 @@ const optionalBuiltInStyles = {
|
|
|
464
438
|
displayName: 'Text Transform',
|
|
465
439
|
type: 'Text',
|
|
466
440
|
group: 'style',
|
|
467
|
-
description: 'The text transform of the element',
|
|
468
441
|
defaultValue: 'none',
|
|
469
442
|
},
|
|
470
443
|
cfTextBold: {
|
|
471
444
|
displayName: 'Bold',
|
|
472
445
|
type: 'Boolean',
|
|
473
446
|
group: 'style',
|
|
474
|
-
description: 'The text bold of the element',
|
|
475
447
|
defaultValue: false,
|
|
476
448
|
},
|
|
477
449
|
cfTextItalic: {
|
|
478
450
|
displayName: 'Italic',
|
|
479
451
|
type: 'Boolean',
|
|
480
452
|
group: 'style',
|
|
481
|
-
description: 'The text italic of the element',
|
|
482
453
|
defaultValue: false,
|
|
483
454
|
},
|
|
484
455
|
cfTextUnderline: {
|
|
485
456
|
displayName: 'Underline',
|
|
486
457
|
type: 'Boolean',
|
|
487
458
|
group: 'style',
|
|
488
|
-
description: 'The text underline of the element',
|
|
489
459
|
defaultValue: false,
|
|
490
460
|
},
|
|
491
461
|
};
|
|
@@ -504,7 +474,6 @@ const containerBuiltInStyles = {
|
|
|
504
474
|
displayName: 'Margin',
|
|
505
475
|
type: 'Text',
|
|
506
476
|
group: 'style',
|
|
507
|
-
description: 'The margin of the container',
|
|
508
477
|
// Note: The UI overwrites '0 Auto 0 Auto' as the default value for top-level containers
|
|
509
478
|
defaultValue: '0 0 0 0',
|
|
510
479
|
},
|
|
@@ -512,7 +481,6 @@ const containerBuiltInStyles = {
|
|
|
512
481
|
displayName: 'Max Width',
|
|
513
482
|
type: 'Text',
|
|
514
483
|
group: 'style',
|
|
515
|
-
description: 'The max-width of the section',
|
|
516
484
|
defaultValue: '1192px',
|
|
517
485
|
},
|
|
518
486
|
};
|
|
@@ -523,35 +491,30 @@ const dividerBuiltInStyles = {
|
|
|
523
491
|
displayName: 'Margin',
|
|
524
492
|
type: 'Text',
|
|
525
493
|
group: 'style',
|
|
526
|
-
description: 'The margin of the divider',
|
|
527
494
|
defaultValue: '20px 0px 20px 0px',
|
|
528
495
|
},
|
|
529
496
|
cfWidth: {
|
|
530
497
|
displayName: 'Width',
|
|
531
498
|
type: 'Text',
|
|
532
499
|
group: 'style',
|
|
533
|
-
description: 'The width of the divider',
|
|
534
500
|
defaultValue: '100%',
|
|
535
501
|
},
|
|
536
502
|
cfHeight: {
|
|
537
503
|
displayName: 'Height',
|
|
538
504
|
type: 'Text',
|
|
539
505
|
group: 'style',
|
|
540
|
-
description: 'The height of the divider',
|
|
541
506
|
defaultValue: '1px',
|
|
542
507
|
},
|
|
543
508
|
cfMaxWidth: {
|
|
544
509
|
displayName: 'Max width',
|
|
545
510
|
type: 'Text',
|
|
546
511
|
group: 'style',
|
|
547
|
-
description: 'The max-width of the divider',
|
|
548
512
|
defaultValue: 'none',
|
|
549
513
|
},
|
|
550
514
|
cfBackgroundColor: {
|
|
551
515
|
displayName: 'Background color',
|
|
552
516
|
type: 'Text',
|
|
553
517
|
group: 'style',
|
|
554
|
-
description: 'The background color of the divider',
|
|
555
518
|
defaultValue: 'rgba(204, 204, 204, 1)',
|
|
556
519
|
},
|
|
557
520
|
};
|
|
@@ -584,7 +547,6 @@ const singleColumnBuiltInStyles = {
|
|
|
584
547
|
},
|
|
585
548
|
type: 'Text',
|
|
586
549
|
group: 'style',
|
|
587
|
-
description: 'The vertical alignment of the column',
|
|
588
550
|
defaultValue: 'center',
|
|
589
551
|
displayName: 'Vertical alignment',
|
|
590
552
|
},
|
|
@@ -611,7 +573,6 @@ const singleColumnBuiltInStyles = {
|
|
|
611
573
|
},
|
|
612
574
|
type: 'Text',
|
|
613
575
|
group: 'style',
|
|
614
|
-
description: 'The horizontal alignment of the column',
|
|
615
576
|
defaultValue: 'center',
|
|
616
577
|
displayName: 'Horizontal alignment',
|
|
617
578
|
},
|
|
@@ -619,35 +580,30 @@ const singleColumnBuiltInStyles = {
|
|
|
619
580
|
displayName: 'Padding',
|
|
620
581
|
type: 'Text',
|
|
621
582
|
group: 'style',
|
|
622
|
-
description: 'The padding of the column',
|
|
623
583
|
defaultValue: '0 0 0 0',
|
|
624
584
|
},
|
|
625
585
|
cfFlexDirection: {
|
|
626
586
|
displayName: 'Direction',
|
|
627
587
|
type: 'Text',
|
|
628
588
|
group: 'style',
|
|
629
|
-
description: 'The orientation of the column',
|
|
630
589
|
defaultValue: 'column',
|
|
631
590
|
},
|
|
632
591
|
cfFlexWrap: {
|
|
633
592
|
displayName: 'Wrap objects',
|
|
634
593
|
type: 'Text',
|
|
635
594
|
group: 'style',
|
|
636
|
-
description: 'Wrap objects',
|
|
637
595
|
defaultValue: 'nowrap',
|
|
638
596
|
},
|
|
639
597
|
cfBorder: {
|
|
640
598
|
displayName: 'Border',
|
|
641
599
|
type: 'Text',
|
|
642
600
|
group: 'style',
|
|
643
|
-
description: 'The border of the column',
|
|
644
601
|
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
645
602
|
},
|
|
646
603
|
cfGap: {
|
|
647
604
|
displayName: 'Gap',
|
|
648
605
|
type: 'Text',
|
|
649
606
|
group: 'style',
|
|
650
|
-
description: 'The spacing between the elements of the column',
|
|
651
607
|
defaultValue: '0px',
|
|
652
608
|
},
|
|
653
609
|
cfColumnSpan: {
|
|
@@ -671,7 +627,6 @@ const columnsBuiltInStyles = {
|
|
|
671
627
|
displayName: 'Margin',
|
|
672
628
|
type: 'Text',
|
|
673
629
|
group: 'style',
|
|
674
|
-
description: 'The margin of the columns',
|
|
675
630
|
// Note: The UI overwrites '0 Auto 0 Auto' as the default value for top-level columns
|
|
676
631
|
defaultValue: '0 0 0 0',
|
|
677
632
|
},
|
|
@@ -679,35 +634,30 @@ const columnsBuiltInStyles = {
|
|
|
679
634
|
displayName: 'Width',
|
|
680
635
|
type: 'Text',
|
|
681
636
|
group: 'style',
|
|
682
|
-
description: 'The width of the columns',
|
|
683
637
|
defaultValue: '100%',
|
|
684
638
|
},
|
|
685
639
|
cfMaxWidth: {
|
|
686
640
|
displayName: 'Max width',
|
|
687
641
|
type: 'Text',
|
|
688
642
|
group: 'style',
|
|
689
|
-
description: 'The max-width of the columns',
|
|
690
643
|
defaultValue: '1192px',
|
|
691
644
|
},
|
|
692
645
|
cfPadding: {
|
|
693
646
|
displayName: 'Padding',
|
|
694
647
|
type: 'Text',
|
|
695
648
|
group: 'style',
|
|
696
|
-
description: 'The padding of the columns',
|
|
697
649
|
defaultValue: '10px 10px 10px 10px',
|
|
698
650
|
},
|
|
699
651
|
cfBorder: {
|
|
700
652
|
displayName: 'Border',
|
|
701
653
|
type: 'Text',
|
|
702
654
|
group: 'style',
|
|
703
|
-
description: 'The border of the columns',
|
|
704
655
|
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
705
656
|
},
|
|
706
657
|
cfGap: {
|
|
707
658
|
displayName: 'Gap',
|
|
708
659
|
type: 'Text',
|
|
709
660
|
group: 'style',
|
|
710
|
-
description: 'The spacing between the elements of the columns',
|
|
711
661
|
defaultValue: '10px 10px',
|
|
712
662
|
},
|
|
713
663
|
cfColumns: {
|
|
@@ -1040,18 +990,15 @@ const ComponentVariableSchema = zod.z.object({
|
|
|
1040
990
|
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
1041
991
|
children: zod.z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
1042
992
|
}).superRefine(({ id, prebindingId, parameters }, ctx) => {
|
|
993
|
+
// We don't fail if parameters are present but prebindingId is not because
|
|
994
|
+
// older experiences (updated before 21-09-2025) always included parameters
|
|
995
|
+
// and they will start failing if we do.
|
|
1043
996
|
if (prebindingId && !parameters) {
|
|
1044
997
|
ctx.addIssue({
|
|
1045
998
|
code: zod.z.ZodIssueCode.custom,
|
|
1046
999
|
message: `Found "prebindingId" but no "parameters" for node with id: "${id}"`,
|
|
1047
1000
|
});
|
|
1048
1001
|
}
|
|
1049
|
-
if (parameters && !prebindingId) {
|
|
1050
|
-
ctx.addIssue({
|
|
1051
|
-
code: zod.z.ZodIssueCode.custom,
|
|
1052
|
-
message: `Found "parameters" but no "prebindingId" for node with id: "${id}"`,
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
1002
|
});
|
|
1056
1003
|
const ComponentTreeSchema = zod.z
|
|
1057
1004
|
.object({
|
|
@@ -1155,7 +1102,6 @@ const ParameterDefinitionSchema = zod.z.object({
|
|
|
1155
1102
|
passToNodes: zod.z
|
|
1156
1103
|
.array(PassToNodeSchema)
|
|
1157
1104
|
.max(1, 'At most one "passToNodes" element is allowed per parameter definition.'),
|
|
1158
|
-
// we might change this to be empty array for native parameter definitions, that's why we don't use .length(1)
|
|
1159
1105
|
});
|
|
1160
1106
|
const ParameterDefinitionsSchema = zod.z.record(propertyKeySchema, ParameterDefinitionSchema);
|
|
1161
1107
|
const VariableMappingsSchema = zod.z.record(propertyKeySchema, VariableMappingSchema);
|
|
@@ -2053,6 +1999,9 @@ const getPrebindingPathBySourceEntry = (preboundValueProperty, getHeadEntityByDa
|
|
|
2053
1999
|
return undefined;
|
|
2054
2000
|
}
|
|
2055
2001
|
const contentTypeId = headEntity.sys.contentType.sys.id;
|
|
2002
|
+
if (!preboundValueProperty.pathsByContentType?.[contentTypeId]) {
|
|
2003
|
+
return undefined;
|
|
2004
|
+
}
|
|
2056
2005
|
return preboundValueProperty.pathsByContentType?.[contentTypeId]?.path;
|
|
2057
2006
|
};
|
|
2058
2007
|
const parseDeepPath = (deepPathCandidate) => {
|
|
@@ -2476,6 +2425,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2476
2425
|
if (!experienceTreeRoot) {
|
|
2477
2426
|
return;
|
|
2478
2427
|
}
|
|
2428
|
+
const isRenderingAPatternEntry = experience.entityStore?.isExperienceAPatternEntry;
|
|
2479
2429
|
const mapOfDesignVariableKeys = flattenDesignTokenRegistry(exports.designTokensRegistry);
|
|
2480
2430
|
// getting breakpoints from the entry componentTree field
|
|
2481
2431
|
const { breakpoints } = experienceTreeRoot;
|
|
@@ -2490,7 +2440,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2490
2440
|
}), {});
|
|
2491
2441
|
// getting the breakpoint ids
|
|
2492
2442
|
const breakpointIds = Object.keys(mediaQueryDataByBreakpoint);
|
|
2493
|
-
const iterateOverTreeAndExtractStyles = ({ componentTree, dataSource, unboundValues, componentSettings, componentVariablesOverwrites, patternWrapper, wrappingPatternIds, wrappingPatternNodeIds = [], }) => {
|
|
2443
|
+
const iterateOverTreeAndExtractStyles = ({ componentTree, dataSource, unboundValues, componentSettings, componentVariablesOverwrites, patternWrapper, wrappingPatternIds, wrappingPatternNodeIds = isRenderingAPatternEntry ? ['root'] : [], }) => {
|
|
2494
2444
|
// traversing the tree
|
|
2495
2445
|
const queue = [];
|
|
2496
2446
|
queue.push(...componentTree.children);
|
|
@@ -2581,7 +2531,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2581
2531
|
// Chain IDs to avoid overwriting styles across multiple instances of the same pattern
|
|
2582
2532
|
// e.g. `{outerPatternNodeId}{innerPatternNodeId}-{currentNodeId}`
|
|
2583
2533
|
// (!) Notice that the chain of patterns (before the dash) follows the format of prebinding/ parameters
|
|
2584
|
-
const currentNodeIdsChain =
|
|
2534
|
+
const currentNodeIdsChain = [...wrappingPatternNodeIds, currentNode.id].join('-');
|
|
2585
2535
|
// For each breakpoint, resolve design tokens, create the CSS and generate a unique className.
|
|
2586
2536
|
for (const breakpointId of breakpointIds) {
|
|
2587
2537
|
const propsByBreakpointWithResolvedDesignTokens = Object.entries(propsByBreakpoint[breakpointId]).reduce((acc, [variableName, variableValue]) => {
|
|
@@ -3756,7 +3706,7 @@ const generateDefaultDataSourceForPrebindingDefinition = (prebindingDefinitions
|
|
|
3756
3706
|
const parameters = {};
|
|
3757
3707
|
for (const [parameterId, parameterDefinition] of Object.entries(prebindingDefinition.parameterDefinitions ?? {})) {
|
|
3758
3708
|
if (parameterDefinition.defaultSource && isLink(parameterDefinition.defaultSource.link)) {
|
|
3759
|
-
const dataSourceKey =
|
|
3709
|
+
const dataSourceKey = parameterDefinition.defaultSource.link.sys.id;
|
|
3760
3710
|
dataSource[dataSourceKey] = parameterDefinition.defaultSource.link;
|
|
3761
3711
|
parameters[parameterId] = {
|
|
3762
3712
|
type: 'BoundValue',
|
|
@@ -4297,6 +4247,9 @@ class EntityStore extends EntityStoreBase {
|
|
|
4297
4247
|
this._experienceEntryId = experienceEntry.sys.id;
|
|
4298
4248
|
this._unboundValues = experienceEntry.fields.unboundValues;
|
|
4299
4249
|
}
|
|
4250
|
+
this._isExperienceAPatternEntry = checkIsAssemblyEntry({
|
|
4251
|
+
fields: this._experienceEntryFields,
|
|
4252
|
+
});
|
|
4300
4253
|
// DERIVE ENTITY STORE INSTANCE VARIBLES
|
|
4301
4254
|
// Register prebindings
|
|
4302
4255
|
{
|
|
@@ -4380,6 +4333,9 @@ class EntityStore extends EntityStoreBase {
|
|
|
4380
4333
|
getCurrentLocale() {
|
|
4381
4334
|
return this.locale;
|
|
4382
4335
|
}
|
|
4336
|
+
get isExperienceAPatternEntry() {
|
|
4337
|
+
return this._isExperienceAPatternEntry;
|
|
4338
|
+
}
|
|
4383
4339
|
get hoistedVariableMappings() {
|
|
4384
4340
|
return this._hoistedVariableMappings;
|
|
4385
4341
|
}
|
|
@@ -5092,92 +5048,6 @@ const removeSelfReferencingDataSource = (experienceEntry) => {
|
|
|
5092
5048
|
experienceEntry.fields.dataSource = newDataSource;
|
|
5093
5049
|
};
|
|
5094
5050
|
|
|
5095
|
-
/**
|
|
5096
|
-
* Attaches the default prebinding value (if any) to the experience entry's dataSource.
|
|
5097
|
-
*
|
|
5098
|
-
* This ensures that any default values defined in pattern property definitions are included
|
|
5099
|
-
* in the dataSource, so that linked entities can be fetched and resolved correctly.
|
|
5100
|
-
* Without this, defaults may be omitted, resulting in unresolved references during binding.
|
|
5101
|
-
*
|
|
5102
|
-
* @returns The number of sideloaded default values, or false if the entry is not a pattern.
|
|
5103
|
-
*/
|
|
5104
|
-
const sideloadPrebindingDefaultValues = (patternEntry) => {
|
|
5105
|
-
let sideloadedCount = 0;
|
|
5106
|
-
const addDefaultValueToDataSource = (_definitionId, definition) => {
|
|
5107
|
-
if (!definition.defaultSource) {
|
|
5108
|
-
// prebinding preset doesn't have default value, which is perfectly fine
|
|
5109
|
-
return;
|
|
5110
|
-
}
|
|
5111
|
-
const { contentTypeId, link, type, // At the time of writing, it means that defaultSource is a link to a Contentful Entry, but in the future it could be a link to third party resource or smth.
|
|
5112
|
-
// this .type enumeration will not have the same meaning as `Link#sys#linkType`.
|
|
5113
|
-
} = definition.defaultSource;
|
|
5114
|
-
if (!isLink(link)) {
|
|
5115
|
-
// default value is not a link, maybe due to a bug
|
|
5116
|
-
return;
|
|
5117
|
-
}
|
|
5118
|
-
if (!type || !contentTypeId) {
|
|
5119
|
-
// broken data structure, unlikely to happen, only due to a bug
|
|
5120
|
-
return;
|
|
5121
|
-
}
|
|
5122
|
-
// Throw in the link to the default-entry into the dataSource, this way
|
|
5123
|
-
// we rely on the mechanism of fetchReferencedEntities() to "sideload" them.
|
|
5124
|
-
// Keep in mind that dataSource will be available as EntityStore.dataSource
|
|
5125
|
-
// and now will contain also key for `sideloaded_uuid` entry.
|
|
5126
|
-
// When "sideloading" entries into the entityStore, we must ensure that
|
|
5127
|
-
// there's corresponding entry in the dataSource, because all bound variables
|
|
5128
|
-
// are resolved, via path that is indirectly referencing the dataSource,
|
|
5129
|
-
// eg. { type: 'BoundValue', path: '/sideloaded_uuid/fields/title' }
|
|
5130
|
-
patternEntry.fields.dataSource = {
|
|
5131
|
-
...patternEntry.fields.dataSource,
|
|
5132
|
-
[`${SIDELOADED_PREFIX}${link.sys.id}`]: {
|
|
5133
|
-
// to highlight that this is a sideloaded entry, we prefix it
|
|
5134
|
-
sys: {
|
|
5135
|
-
type: 'Link',
|
|
5136
|
-
linkType: link.sys.linkType,
|
|
5137
|
-
id: link.sys.id,
|
|
5138
|
-
},
|
|
5139
|
-
},
|
|
5140
|
-
};
|
|
5141
|
-
sideloadedCount++;
|
|
5142
|
-
};
|
|
5143
|
-
if (!checkIsAssemblyEntry(patternEntry)) {
|
|
5144
|
-
// Only supported for pattern entries since experience entries don't define pattern properties.
|
|
5145
|
-
return false;
|
|
5146
|
-
}
|
|
5147
|
-
// --------------------
|
|
5148
|
-
// Sideload prebinding values for the L1 parent pattern aka `pA`
|
|
5149
|
-
// --------------------
|
|
5150
|
-
const definitions = patternEntry.fields.componentSettings?.prebindingDefinitions?.[0].parameterDefinitions ?? {};
|
|
5151
|
-
Object.entries(definitions).forEach(([id, definition]) => {
|
|
5152
|
-
addDefaultValueToDataSource(id, definition);
|
|
5153
|
-
});
|
|
5154
|
-
// --------------------
|
|
5155
|
-
// Sideload all default values for the L2 nested patterns, patterns aka`pB`
|
|
5156
|
-
// --------------------
|
|
5157
|
-
const nestedPatternEntriesLevel2 = (patternEntry.fields.usedComponents || []).filter((component) => component !== undefined && checkIsAssemblyEntry(component));
|
|
5158
|
-
nestedPatternEntriesLevel2.forEach((patternEntry) => {
|
|
5159
|
-
const parameterDefinitions = patternEntry.fields.componentSettings?.prebindingDefinitions?.[0].parameterDefinitions ?? {};
|
|
5160
|
-
Object.entries(parameterDefinitions).forEach(([id, definition]) => {
|
|
5161
|
-
addDefaultValueToDataSource(id, definition);
|
|
5162
|
-
});
|
|
5163
|
-
});
|
|
5164
|
-
// --------------------
|
|
5165
|
-
// Sideload all default values for the L3 nested patterns, patterns aka `pC`
|
|
5166
|
-
// --------------------
|
|
5167
|
-
const nestedPatternEntriesLevel3 = nestedPatternEntriesLevel2.flatMap((patternEntryLevel2) => {
|
|
5168
|
-
const usedComponents = patternEntryLevel2.fields.usedComponents || [];
|
|
5169
|
-
const filteredUsedComponents = usedComponents.filter((component) => component !== undefined && checkIsAssemblyEntry(component));
|
|
5170
|
-
return filteredUsedComponents;
|
|
5171
|
-
});
|
|
5172
|
-
nestedPatternEntriesLevel3.forEach((patternEntry) => {
|
|
5173
|
-
const parameterDefinitions = patternEntry.fields.componentSettings?.prebindingDefinitions?.[0].parameterDefinitions ?? {};
|
|
5174
|
-
Object.entries(parameterDefinitions).forEach(([id, definition]) => {
|
|
5175
|
-
addDefaultValueToDataSource(id, definition);
|
|
5176
|
-
});
|
|
5177
|
-
});
|
|
5178
|
-
return sideloadedCount;
|
|
5179
|
-
};
|
|
5180
|
-
|
|
5181
5051
|
/**
|
|
5182
5052
|
* Run additional checks on the references used in the experience entry and
|
|
5183
5053
|
* process data required for prebinding. This must be used after fetching an
|
|
@@ -5188,7 +5058,6 @@ const sideloadPrebindingDefaultValues = (patternEntry) => {
|
|
|
5188
5058
|
const prepareExperienceEntry = (experienceEntry) => {
|
|
5189
5059
|
removeCircularPatternReferences(experienceEntry);
|
|
5190
5060
|
removeSelfReferencingDataSource(experienceEntry);
|
|
5191
|
-
sideloadPrebindingDefaultValues(experienceEntry);
|
|
5192
5061
|
};
|
|
5193
5062
|
|
|
5194
5063
|
const errorMessagesWhileFetching$1 = {
|