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