@contentful/experiences-core 3.6.3-dev-20250916T1219-c183de1.0 → 3.7.0-dev-20250917T1203-0e23897.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/deep-binding/DeepReference.d.ts +18 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +257 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/extractPrebindingData.d.ts +46 -0
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DataSourceEntryValueType, Link, ExperienceEntry, ExperienceTreeNode } from '../types.js';
|
|
2
|
+
import { Entry } from 'contentful';
|
|
2
3
|
import { EntityFromLink, EntityStoreBase } from '../entity/EntityStoreBase.js';
|
|
3
4
|
import { ExperienceDataSource } from '@contentful/experiences-validators';
|
|
5
|
+
import { PrebindingData } from '../utils/extractPrebindingData.js';
|
|
4
6
|
|
|
5
7
|
type DeepReferenceOpts = {
|
|
6
8
|
path: string;
|
|
@@ -22,6 +24,21 @@ declare class DeepReference {
|
|
|
22
24
|
static from(opt: DeepReferenceOpts): DeepReference;
|
|
23
25
|
}
|
|
24
26
|
declare function gatherDeepReferencesFromExperienceEntry(experienceEntry: ExperienceEntry): DeepReference[];
|
|
27
|
+
declare function gatherDeepPrebindingReferencesFromExperienceEntry({ experienceEntry, fetchedPatterns, prebindingDataByPatternId, fetchedLevel1Entries, }: {
|
|
28
|
+
experienceEntry: ExperienceEntry;
|
|
29
|
+
fetchedPatterns: Array<ExperienceEntry>;
|
|
30
|
+
prebindingDataByPatternId: Record<string, PrebindingData>;
|
|
31
|
+
fetchedLevel1Entries: Array<Entry>;
|
|
32
|
+
}): DeepReference[];
|
|
33
|
+
declare function gatherDeepPrebindingReferencesFromPatternEntry({ patternEntry, fetchedPatterns, prebindingDataByPatternId, fetchedLevel1Entries, }: {
|
|
34
|
+
patternEntry: ExperienceEntry;
|
|
35
|
+
fetchedPatterns: Array<ExperienceEntry>;
|
|
36
|
+
prebindingDataByPatternId: Record<string, PrebindingData>;
|
|
37
|
+
fetchedLevel1Entries: Array<Entry>;
|
|
38
|
+
}): DeepReference[];
|
|
39
|
+
/**
|
|
40
|
+
* used in editor mode. for delivery mode see `gatherDeepReferencesFromExperienceEntry`
|
|
41
|
+
*/
|
|
25
42
|
declare function gatherDeepReferencesFromTree(startingNode: ExperienceTreeNode, dataSource: ExperienceDataSource, getEntityFromLink: EntityStoreBase['getEntityFromLink']): DeepReference[];
|
|
26
43
|
|
|
27
|
-
export { DeepReference, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree };
|
|
44
|
+
export { DeepReference, gatherDeepPrebindingReferencesFromExperienceEntry, gatherDeepPrebindingReferencesFromPatternEntry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderCo
|
|
|
21
21
|
export { extractLeafLinksReferencedFromExperience } from './utils/schema/experienceSchema.js';
|
|
22
22
|
export { FnShouldFollowReferencesOfEntryField, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, referencesOf, uniqueById } from './utils/schema/references.js';
|
|
23
23
|
export { splitDirectAndSlotChildren } from './utils/splitDirectAndSlotChildren.js';
|
|
24
|
+
export { PrebindingData, extractPrebindingDataByPatternId, flattenNestedPatterns, generateDefaultDataSourceForPrebindingDefinition, getTargetPatternMappingsForParameter } from './utils/extractPrebindingData.js';
|
|
24
25
|
export { builtInStyles, columnsBuiltInStyles, containerBuiltInStyles, dividerBuiltInStyles, optionalBuiltInStyles, sectionBuiltInStyles, singleColumnBuiltInStyles } from './definitions/styles.js';
|
|
25
26
|
export { EditorModeEntityStore } from './entity/EditorModeEntityStore.js';
|
|
26
27
|
export { EntityStore } from './entity/EntityStore.js';
|
|
@@ -38,4 +39,4 @@ export { fetchExperienceEntry } from './fetchers/fetchExperienceEntry.js';
|
|
|
38
39
|
export { defineDesignTokens, designTokensRegistry, getDesignTokenRegistration, resetDesignTokenRegistry } from './registries/designTokenRegistry.js';
|
|
39
40
|
export { breakpointsRegistry, defineBreakpoints, getBreakpointRegistration, resetBreakpointsRegistry, runBreakpointsValidation } from './registries/breakpointsRegistry.js';
|
|
40
41
|
export { defineSdkOptions, getSdkOptions, sdkOptionsRegistry } from './registries/sdkOptionsRegistry.js';
|
|
41
|
-
export { DeepReference, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree } from './deep-binding/DeepReference.js';
|
|
42
|
+
export { DeepReference, gatherDeepPrebindingReferencesFromExperienceEntry, gatherDeepPrebindingReferencesFromPatternEntry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree } from './deep-binding/DeepReference.js';
|
package/dist/index.js
CHANGED
|
@@ -3515,6 +3515,118 @@ const splitDirectAndSlotChildren = (allChildNodes, componentDefinition) => {
|
|
|
3515
3515
|
return { slotNodesMap, directChildNodes };
|
|
3516
3516
|
};
|
|
3517
3517
|
|
|
3518
|
+
const flattenNestedPatterns = (fetchedPatterns) => {
|
|
3519
|
+
const patternsById = {};
|
|
3520
|
+
const queue = [...fetchedPatterns];
|
|
3521
|
+
while (queue.length) {
|
|
3522
|
+
const pattern = queue.shift();
|
|
3523
|
+
if (!pattern) {
|
|
3524
|
+
continue;
|
|
3525
|
+
}
|
|
3526
|
+
if (patternsById[pattern.sys.id]) {
|
|
3527
|
+
continue;
|
|
3528
|
+
}
|
|
3529
|
+
patternsById[pattern.sys.id] = pattern;
|
|
3530
|
+
if (!Array.isArray(pattern.fields.usedComponents) || !pattern.fields.usedComponents.length) {
|
|
3531
|
+
continue;
|
|
3532
|
+
}
|
|
3533
|
+
for (const nestedPattern of pattern.fields.usedComponents) {
|
|
3534
|
+
if (!isLink(nestedPattern)) {
|
|
3535
|
+
queue.push(nestedPattern);
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
return Object.values(patternsById);
|
|
3540
|
+
};
|
|
3541
|
+
/**
|
|
3542
|
+
* Given a list of patterns, extract the prebinding data into a more digestable format indexed by the pattern entry id
|
|
3543
|
+
* @param patterns a list of pattern entries
|
|
3544
|
+
* @returns a map of pattern entry ids to their prebinding data
|
|
3545
|
+
*/
|
|
3546
|
+
const extractPrebindingDataByPatternId = (patterns) => {
|
|
3547
|
+
const prebindingDataByPatternId = {};
|
|
3548
|
+
for (const pattern of patterns) {
|
|
3549
|
+
const patternId = pattern.sys.id;
|
|
3550
|
+
const [prebindingDefinition] = pattern.fields.componentSettings?.prebindingDefinitions ?? [];
|
|
3551
|
+
if (!prebindingDefinition)
|
|
3552
|
+
continue;
|
|
3553
|
+
const [nativeParameterId] = Object.entries(prebindingDefinition.parameterDefinitions ?? {}).find(([, value]) => value.passToNodes === undefined) ?? [];
|
|
3554
|
+
const prebindingData = {
|
|
3555
|
+
prebindingDefinitionId: prebindingDefinition.id,
|
|
3556
|
+
parameterIds: Object.keys(prebindingDefinition.parameterDefinitions),
|
|
3557
|
+
nativeParameterId,
|
|
3558
|
+
parameterDefinitions: prebindingDefinition.parameterDefinitions,
|
|
3559
|
+
variableMappings: prebindingDefinition.variableMappings,
|
|
3560
|
+
};
|
|
3561
|
+
prebindingDataByPatternId[patternId] = prebindingData;
|
|
3562
|
+
}
|
|
3563
|
+
return prebindingDataByPatternId;
|
|
3564
|
+
};
|
|
3565
|
+
const generateDefaultDataSourceForPrebindingDefinition = (prebindingDefinitions = []) => {
|
|
3566
|
+
if (!prebindingDefinitions ||
|
|
3567
|
+
!Array.isArray(prebindingDefinitions) ||
|
|
3568
|
+
!prebindingDefinitions.length) {
|
|
3569
|
+
return { dataSource: {}, parameters: {} };
|
|
3570
|
+
}
|
|
3571
|
+
const prebindingDefinition = prebindingDefinitions[0];
|
|
3572
|
+
const dataSource = {};
|
|
3573
|
+
const parameters = {};
|
|
3574
|
+
for (const [parameterId, parameterDefinition] of Object.entries(prebindingDefinition.parameterDefinitions ?? {})) {
|
|
3575
|
+
if (parameterDefinition.defaultSource && isLink(parameterDefinition.defaultSource.link)) {
|
|
3576
|
+
const dataSourceKey = generateRandomId(7);
|
|
3577
|
+
dataSource[dataSourceKey] = parameterDefinition.defaultSource.link;
|
|
3578
|
+
parameters[parameterId] = {
|
|
3579
|
+
type: 'BoundValue',
|
|
3580
|
+
path: `/${dataSourceKey}`,
|
|
3581
|
+
};
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
return {
|
|
3585
|
+
dataSource,
|
|
3586
|
+
parameters,
|
|
3587
|
+
};
|
|
3588
|
+
};
|
|
3589
|
+
function getTargetPatternMappingsForParameter({ fetchedPatterns, prebindingDataByPatternId, patternNodeDefinitionId, parameterId, }) {
|
|
3590
|
+
const patternPrebindingData = prebindingDataByPatternId[patternNodeDefinitionId];
|
|
3591
|
+
if (!patternPrebindingData)
|
|
3592
|
+
return undefined;
|
|
3593
|
+
if (patternPrebindingData.parameterIds.includes(parameterId)) {
|
|
3594
|
+
if (patternPrebindingData.nativeParameterId === parameterId) {
|
|
3595
|
+
if (!patternPrebindingData.variableMappings)
|
|
3596
|
+
return undefined;
|
|
3597
|
+
return Object.fromEntries(Object.entries(patternPrebindingData.variableMappings).filter(([, mapping]) => mapping.parameterId === parameterId));
|
|
3598
|
+
}
|
|
3599
|
+
else {
|
|
3600
|
+
const parameterDefinition = patternPrebindingData.parameterDefinitions[parameterId];
|
|
3601
|
+
if (!parameterDefinition || !parameterDefinition.passToNodes)
|
|
3602
|
+
return undefined;
|
|
3603
|
+
const patternEntry = fetchedPatterns.find((entry) => entry.sys.id === patternNodeDefinitionId);
|
|
3604
|
+
if (!patternEntry)
|
|
3605
|
+
return undefined;
|
|
3606
|
+
let nestedPatternNode;
|
|
3607
|
+
treeVisit({
|
|
3608
|
+
definitionId: 'root',
|
|
3609
|
+
parameters: {},
|
|
3610
|
+
children: patternEntry.fields.componentTree.children,
|
|
3611
|
+
}, (node) => {
|
|
3612
|
+
if (node.id === parameterDefinition.passToNodes?.[0].nodeId) {
|
|
3613
|
+
nestedPatternNode = node;
|
|
3614
|
+
}
|
|
3615
|
+
return undefined;
|
|
3616
|
+
});
|
|
3617
|
+
if (!nestedPatternNode) {
|
|
3618
|
+
return undefined;
|
|
3619
|
+
}
|
|
3620
|
+
return getTargetPatternMappingsForParameter({
|
|
3621
|
+
fetchedPatterns,
|
|
3622
|
+
prebindingDataByPatternId,
|
|
3623
|
+
patternNodeDefinitionId: nestedPatternNode.definitionId,
|
|
3624
|
+
parameterId: parameterDefinition.passToNodes?.[0].parameterId,
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3518
3630
|
const sendMessage = (eventType, data) => {
|
|
3519
3631
|
if (typeof window === 'undefined') {
|
|
3520
3632
|
return;
|
|
@@ -4341,7 +4453,7 @@ function gatherDeepReferencesFromExperienceEntry(experienceEntry) {
|
|
|
4341
4453
|
}, (node) => {
|
|
4342
4454
|
if (!node.variables)
|
|
4343
4455
|
return;
|
|
4344
|
-
for (const
|
|
4456
|
+
for (const variableMapping of Object.values(node.variables)) {
|
|
4345
4457
|
if (variableMapping.type !== 'BoundValue')
|
|
4346
4458
|
continue;
|
|
4347
4459
|
if (!isDeepPath(variableMapping.path))
|
|
@@ -4354,6 +4466,99 @@ function gatherDeepReferencesFromExperienceEntry(experienceEntry) {
|
|
|
4354
4466
|
});
|
|
4355
4467
|
return deepReferences;
|
|
4356
4468
|
}
|
|
4469
|
+
function gatherDeepPrebindingReferencesFromExperienceEntry({ experienceEntry, fetchedPatterns, prebindingDataByPatternId, fetchedLevel1Entries, }) {
|
|
4470
|
+
const deepPrebindingReferences = [];
|
|
4471
|
+
const dataSource = experienceEntry.fields.dataSource;
|
|
4472
|
+
const { children } = experienceEntry.fields.componentTree;
|
|
4473
|
+
treeVisit({
|
|
4474
|
+
definitionId: 'root',
|
|
4475
|
+
parameters: {},
|
|
4476
|
+
children,
|
|
4477
|
+
}, (node) => {
|
|
4478
|
+
if (!node.parameters)
|
|
4479
|
+
return;
|
|
4480
|
+
for (const [parameterId, parameterValue] of Object.entries(node.parameters)) {
|
|
4481
|
+
const dataSourceKey = parameterValue.path.split('/')[1];
|
|
4482
|
+
const headEntryLink = dataSource[dataSourceKey];
|
|
4483
|
+
if (!headEntryLink)
|
|
4484
|
+
continue;
|
|
4485
|
+
if (headEntryLink.sys.linkType !== 'Entry')
|
|
4486
|
+
continue;
|
|
4487
|
+
const headEntry = fetchedLevel1Entries.find((entry) => entry.sys.id === headEntryLink.sys.id);
|
|
4488
|
+
if (!headEntry)
|
|
4489
|
+
continue;
|
|
4490
|
+
const headEntryContentTypeId = headEntry.sys.contentType.sys.id;
|
|
4491
|
+
// if experience, we don't have any hoisted data on the given experienceEntry
|
|
4492
|
+
// and we have to lookup the pattern instead
|
|
4493
|
+
const variableMappings = getTargetPatternMappingsForParameter({
|
|
4494
|
+
fetchedPatterns,
|
|
4495
|
+
prebindingDataByPatternId,
|
|
4496
|
+
patternNodeDefinitionId: node.definitionId,
|
|
4497
|
+
parameterId,
|
|
4498
|
+
});
|
|
4499
|
+
if (!variableMappings)
|
|
4500
|
+
continue;
|
|
4501
|
+
for (const mappingData of Object.values(variableMappings)) {
|
|
4502
|
+
const targetMapping = mappingData.pathsByContentType[headEntryContentTypeId];
|
|
4503
|
+
if (!targetMapping)
|
|
4504
|
+
continue;
|
|
4505
|
+
// mapping doesn't start with /uuid, but instead starts with /fields
|
|
4506
|
+
// so we add /uuid to make it match the binding path format
|
|
4507
|
+
const path = `/${dataSourceKey}${targetMapping.path}`;
|
|
4508
|
+
if (!isDeepPath(path))
|
|
4509
|
+
continue;
|
|
4510
|
+
deepPrebindingReferences.push(DeepReference.from({
|
|
4511
|
+
path,
|
|
4512
|
+
dataSource,
|
|
4513
|
+
}));
|
|
4514
|
+
}
|
|
4515
|
+
}
|
|
4516
|
+
});
|
|
4517
|
+
return deepPrebindingReferences;
|
|
4518
|
+
}
|
|
4519
|
+
function gatherDeepPrebindingReferencesFromPatternEntry({ patternEntry, fetchedPatterns, prebindingDataByPatternId, fetchedLevel1Entries, }) {
|
|
4520
|
+
const deepPrebindingReferences = [];
|
|
4521
|
+
// patterns can't have parameters in their CDA/CMA JSON, so we can generate random ids here
|
|
4522
|
+
const { dataSource, parameters } = generateDefaultDataSourceForPrebindingDefinition(patternEntry.fields.componentSettings?.prebindingDefinitions);
|
|
4523
|
+
for (const [parameterId, parameterValue] of Object.entries(parameters)) {
|
|
4524
|
+
const dataSourceKey = parameterValue.path.split('/')[1];
|
|
4525
|
+
const headEntryLink = dataSource[dataSourceKey];
|
|
4526
|
+
if (!headEntryLink)
|
|
4527
|
+
continue;
|
|
4528
|
+
if (headEntryLink.sys.linkType !== 'Entry')
|
|
4529
|
+
continue;
|
|
4530
|
+
const headEntry = fetchedLevel1Entries.find((entry) => entry.sys.id === headEntryLink.sys.id);
|
|
4531
|
+
if (!headEntry)
|
|
4532
|
+
continue;
|
|
4533
|
+
const headEntryContentTypeId = headEntry.sys.contentType.sys.id;
|
|
4534
|
+
const variableMappings = getTargetPatternMappingsForParameter({
|
|
4535
|
+
fetchedPatterns,
|
|
4536
|
+
prebindingDataByPatternId,
|
|
4537
|
+
patternNodeDefinitionId: patternEntry.sys.id,
|
|
4538
|
+
parameterId,
|
|
4539
|
+
});
|
|
4540
|
+
if (!variableMappings)
|
|
4541
|
+
continue;
|
|
4542
|
+
for (const mappingData of Object.values(variableMappings)) {
|
|
4543
|
+
const targetMapping = mappingData.pathsByContentType[headEntryContentTypeId];
|
|
4544
|
+
if (!targetMapping)
|
|
4545
|
+
continue;
|
|
4546
|
+
// mapping doesn't start with /uuid, but instead starts with /fields
|
|
4547
|
+
// so we add /uuid to make it match the binding path format
|
|
4548
|
+
const path = `/${dataSourceKey}${targetMapping.path}`;
|
|
4549
|
+
if (!isDeepPath(path))
|
|
4550
|
+
continue;
|
|
4551
|
+
deepPrebindingReferences.push(DeepReference.from({
|
|
4552
|
+
path,
|
|
4553
|
+
dataSource,
|
|
4554
|
+
}));
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
return deepPrebindingReferences;
|
|
4558
|
+
}
|
|
4559
|
+
/**
|
|
4560
|
+
* used in editor mode. for delivery mode see `gatherDeepReferencesFromExperienceEntry`
|
|
4561
|
+
*/
|
|
4357
4562
|
function gatherDeepReferencesFromTree(startingNode, dataSource, getEntityFromLink) {
|
|
4358
4563
|
const deepReferences = [];
|
|
4359
4564
|
treeVisit(startingNode, (node) => {
|
|
@@ -4560,7 +4765,6 @@ const fetchReferencedEntities = async ({ client, experienceEntry, locale, }) =>
|
|
|
4560
4765
|
if (!isExperienceEntry(experienceEntry)) {
|
|
4561
4766
|
throw new Error('Failed to fetch experience entities. Provided "experienceEntry" does not match experience entry schema');
|
|
4562
4767
|
}
|
|
4563
|
-
const deepReferences = gatherDeepReferencesFromExperienceEntry(experienceEntry);
|
|
4564
4768
|
const entryIds = new Set();
|
|
4565
4769
|
const assetIds = new Set();
|
|
4566
4770
|
for (const dataBinding of Object.values(experienceEntry.fields.dataSource)) {
|
|
@@ -4578,12 +4782,52 @@ const fetchReferencedEntities = async ({ client, experienceEntry, locale, }) =>
|
|
|
4578
4782
|
fetchAllEntries({ client, ids: [...entryIds], locale }),
|
|
4579
4783
|
fetchAllAssets({ client, ids: [...assetIds], locale }),
|
|
4580
4784
|
]);
|
|
4581
|
-
const
|
|
4785
|
+
const usedPatterns = experienceEntry.fields.usedComponents ?? [];
|
|
4786
|
+
const isRenderingExperience = Boolean(!experienceEntry.fields.componentSettings);
|
|
4787
|
+
const deepReferences = gatherDeepReferencesFromExperienceEntry(experienceEntry);
|
|
4788
|
+
// If we are previewing a pattern, we want to include the entry itself as well
|
|
4789
|
+
const fetchedPatterns = (isRenderingExperience ? usedPatterns : [...usedPatterns, experienceEntry]);
|
|
4790
|
+
const allFetchedPatterns = flattenNestedPatterns(fetchedPatterns);
|
|
4791
|
+
const prebindingDataByPatternId = extractPrebindingDataByPatternId(allFetchedPatterns);
|
|
4792
|
+
// Patterns do not have dataSource stored in their dataSource field, so head entities won't be there and we need to fetch them
|
|
4793
|
+
if (!isRenderingExperience) {
|
|
4794
|
+
const { dataSource } = generateDefaultDataSourceForPrebindingDefinition(experienceEntry.fields.componentSettings?.prebindingDefinitions);
|
|
4795
|
+
if (Object.keys(dataSource).length) {
|
|
4796
|
+
const prebindingEntriesResponse = await fetchAllEntries({
|
|
4797
|
+
client,
|
|
4798
|
+
ids: Object.values(dataSource).map((link) => link.sys.id),
|
|
4799
|
+
locale,
|
|
4800
|
+
});
|
|
4801
|
+
entriesResponse.items.push(...prebindingEntriesResponse.items);
|
|
4802
|
+
entriesResponse.includes.Asset.push(...(prebindingEntriesResponse.includes?.Asset ?? []));
|
|
4803
|
+
entriesResponse.includes.Entry.push(...(prebindingEntriesResponse.includes?.Entry ?? []));
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4806
|
+
// normally, for experience entry, there should be no need to call this method, as `includes=2` will have them resolved
|
|
4807
|
+
// because the entries used for pre-binding are stored in both - the layout of the experience, as well as the dataSource field
|
|
4808
|
+
const deepPrebindingReferences = isRenderingExperience
|
|
4809
|
+
? gatherDeepPrebindingReferencesFromExperienceEntry({
|
|
4810
|
+
experienceEntry: experienceEntry,
|
|
4811
|
+
fetchedPatterns: allFetchedPatterns,
|
|
4812
|
+
prebindingDataByPatternId,
|
|
4813
|
+
fetchedLevel1Entries: entriesResponse.items,
|
|
4814
|
+
})
|
|
4815
|
+
: // however, for patterns, we have to do it by hand, because a pattern entry doesn't save the pre-binding data neither in the
|
|
4816
|
+
// layout nor in the dataSource field.
|
|
4817
|
+
// for consistency, as well as to be future safe from the change to "includes=2", I added methods for both
|
|
4818
|
+
gatherDeepPrebindingReferencesFromPatternEntry({
|
|
4819
|
+
patternEntry: experienceEntry,
|
|
4820
|
+
fetchedPatterns: allFetchedPatterns,
|
|
4821
|
+
prebindingDataByPatternId,
|
|
4822
|
+
fetchedLevel1Entries: entriesResponse.items,
|
|
4823
|
+
});
|
|
4824
|
+
const allDeepReferences = [...deepReferences, ...deepPrebindingReferences];
|
|
4825
|
+
const { autoFetchedReferentAssets, autoFetchedReferentEntries } = gatherAutoFetchedReferentsFromIncludes(allDeepReferences, entriesResponse);
|
|
4582
4826
|
// Using client getEntries resolves all linked entry references, so we do not need to resolve entries in usedComponents
|
|
4583
4827
|
const allResolvedEntries = [
|
|
4584
4828
|
...(entriesResponse?.items ?? []),
|
|
4585
4829
|
...(entriesResponse.includes?.Entry ?? []),
|
|
4586
|
-
...(
|
|
4830
|
+
...(usedPatterns || []),
|
|
4587
4831
|
...autoFetchedReferentEntries,
|
|
4588
4832
|
];
|
|
4589
4833
|
const allResolvedAssets = [
|
|
@@ -4592,8 +4836,14 @@ const fetchReferencedEntities = async ({ client, experienceEntry, locale, }) =>
|
|
|
4592
4836
|
...autoFetchedReferentAssets,
|
|
4593
4837
|
];
|
|
4594
4838
|
return {
|
|
4595
|
-
|
|
4596
|
-
|
|
4839
|
+
// we have to drop duplicates, becasue of the merge of deepReferences and deepPrebindingReferences above
|
|
4840
|
+
// If not, the same entity might appear in this array more than once
|
|
4841
|
+
entries: [
|
|
4842
|
+
...new Map(allResolvedEntries.map((entry) => [entry.sys.id, entry])).values(),
|
|
4843
|
+
],
|
|
4844
|
+
assets: [
|
|
4845
|
+
...new Map(allResolvedAssets.map((asset) => [asset.sys.id, asset])).values(),
|
|
4846
|
+
],
|
|
4597
4847
|
};
|
|
4598
4848
|
};
|
|
4599
4849
|
|
|
@@ -4872,5 +5122,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
4872
5122
|
}
|
|
4873
5123
|
}
|
|
4874
5124
|
|
|
4875
|
-
export { BREAKPOINTS_STRATEGY_DESKTOP_FIRST, BREAKPOINTS_STRATEGY_MOBILE_FIRST, DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, defineSdkOptions, designTokensRegistry, detachExperienceStyles, detectBreakpointsStrategy, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, extractLeafLinksReferencedFromExperience, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getPrebindingPathBySourceEntry, getSdkOptions, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, inMemoryEntities, inMemoryEntitiesStore, indexByBreakpoint, isArrayOfLinks, isAsset, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isDeepPrebinding, isElementHidden, isEntry, isExperienceEntry, isLink, isLinkToAsset, isLinkToEntry, isPatternComponent, isPatternEntry, isPreboundProp, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, referencesOf, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sdkOptionsRegistry, sectionBuiltInStyles, sendMessage, setDebugLevel, singleColumnBuiltInStyles, splitDirectAndSlotChildren, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, uniqueById, useInMemoryEntities, validateExperienceBuilderConfig };
|
|
5125
|
+
export { BREAKPOINTS_STRATEGY_DESKTOP_FIRST, BREAKPOINTS_STRATEGY_MOBILE_FIRST, DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, defineSdkOptions, designTokensRegistry, detachExperienceStyles, detectBreakpointsStrategy, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, extractLeafLinksReferencedFromExperience, extractPrebindingDataByPatternId, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, flattenNestedPatterns, gatherDeepPrebindingReferencesFromExperienceEntry, gatherDeepPrebindingReferencesFromPatternEntry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateDefaultDataSourceForPrebindingDefinition, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getPrebindingPathBySourceEntry, getSdkOptions, getTargetPatternMappingsForParameter, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, inMemoryEntities, inMemoryEntitiesStore, indexByBreakpoint, isArrayOfLinks, isAsset, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isDeepPrebinding, isElementHidden, isEntry, isExperienceEntry, isLink, isLinkToAsset, isLinkToEntry, isPatternComponent, isPatternEntry, isPreboundProp, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, referencesOf, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sdkOptionsRegistry, sectionBuiltInStyles, sendMessage, setDebugLevel, singleColumnBuiltInStyles, splitDirectAndSlotChildren, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, uniqueById, useInMemoryEntities, validateExperienceBuilderConfig };
|
|
4876
5126
|
//# sourceMappingURL=index.js.map
|