@contentful/experiences-core 1.41.0-dev-20250612T0852-ddef0ff.0 → 1.41.0-dev-20250612T1212-618fdd9.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/entity/EntityStoreBase.d.ts +0 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -19
- package/dist/index.js.map +1 -1
- package/dist/utils/entityTypeChecks.d.ts +6 -0
- package/package.json +3 -3
|
@@ -33,8 +33,6 @@ declare abstract class EntityStoreBase {
|
|
|
33
33
|
fetchEntry(id: string): Promise<Entry | undefined>;
|
|
34
34
|
fetchEntries(ids: string[]): Promise<Entry[]>;
|
|
35
35
|
private getDeepEntry;
|
|
36
|
-
private isAsset;
|
|
37
|
-
private isEntry;
|
|
38
36
|
private getEntity;
|
|
39
37
|
toJSON(): {
|
|
40
38
|
entryMap: {
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { treeMap, treeVisit } from './utils/treeTraversal.js';
|
|
|
17
17
|
export { isExperienceEntry } from './utils/typeguards.js';
|
|
18
18
|
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
19
19
|
export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
|
|
20
|
+
export { isAsset, isEntry } from './utils/entityTypeChecks.js';
|
|
20
21
|
export { builtInStyles, columnsBuiltInStyles, containerBuiltInStyles, dividerBuiltInStyles, optionalBuiltInStyles, sectionBuiltInStyles, singleColumnBuiltInStyles } from './definitions/styles.js';
|
|
21
22
|
export { EditorModeEntityStore } from './entity/EditorModeEntityStore.js';
|
|
22
23
|
export { EntityStore } from './entity/EntityStore.js';
|
package/dist/index.js
CHANGED
|
@@ -2872,10 +2872,26 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
2872
2872
|
return asset.fields.file?.url;
|
|
2873
2873
|
};
|
|
2874
2874
|
|
|
2875
|
+
const isAsset = (value) => {
|
|
2876
|
+
return (null !== value &&
|
|
2877
|
+
typeof value === 'object' &&
|
|
2878
|
+
'sys' in value &&
|
|
2879
|
+
value.sys?.type === 'Asset');
|
|
2880
|
+
};
|
|
2881
|
+
const isEntry = (value) => {
|
|
2882
|
+
return (null !== value &&
|
|
2883
|
+
typeof value === 'object' &&
|
|
2884
|
+
'sys' in value &&
|
|
2885
|
+
value.sys?.type === 'Entry');
|
|
2886
|
+
};
|
|
2887
|
+
|
|
2875
2888
|
function getResolvedEntryFromLink(entryOrAsset, path, entityStore) {
|
|
2876
|
-
if (entryOrAsset
|
|
2889
|
+
if (isAsset(entryOrAsset)) {
|
|
2877
2890
|
return entryOrAsset;
|
|
2878
2891
|
}
|
|
2892
|
+
else if (!isEntry(entryOrAsset)) {
|
|
2893
|
+
throw new Error(`Expected an Entry or Asset, but got: ${JSON.stringify(entryOrAsset)}`);
|
|
2894
|
+
}
|
|
2879
2895
|
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
2880
2896
|
if (value?.sys.type !== 'Link') {
|
|
2881
2897
|
console.warn(`Expected a link to a reference, but got: ${JSON.stringify(value)}`);
|
|
@@ -3239,10 +3255,13 @@ class EntityStoreBase {
|
|
|
3239
3255
|
}
|
|
3240
3256
|
entity = resolvedEntity;
|
|
3241
3257
|
}
|
|
3242
|
-
else {
|
|
3258
|
+
else if (isAsset(linkOrEntryOrAsset) || isEntry(linkOrEntryOrAsset)) {
|
|
3243
3259
|
// We already have the complete entity in preview & delivery (resolved by the CMA client)
|
|
3244
3260
|
entity = linkOrEntryOrAsset;
|
|
3245
3261
|
}
|
|
3262
|
+
else {
|
|
3263
|
+
throw new Error(`Unexpected object when resolving entity: ${JSON.stringify(linkOrEntryOrAsset)}`);
|
|
3264
|
+
}
|
|
3246
3265
|
return entity;
|
|
3247
3266
|
}
|
|
3248
3267
|
/**
|
|
@@ -3288,14 +3307,14 @@ class EntityStoreBase {
|
|
|
3288
3307
|
};
|
|
3289
3308
|
}
|
|
3290
3309
|
addEntity(entity) {
|
|
3291
|
-
if (
|
|
3310
|
+
if (isAsset(entity)) {
|
|
3292
3311
|
this.assetMap.set(entity.sys.id, entity);
|
|
3293
3312
|
}
|
|
3294
|
-
else if (
|
|
3313
|
+
else if (isEntry(entity)) {
|
|
3295
3314
|
this.entryMap.set(entity.sys.id, entity);
|
|
3296
3315
|
}
|
|
3297
3316
|
else {
|
|
3298
|
-
|
|
3317
|
+
throw new Error(`Attempted to add an entity to the store that is neither Asset nor Entry: '${JSON.stringify(entity)}'`);
|
|
3299
3318
|
}
|
|
3300
3319
|
}
|
|
3301
3320
|
async fetchAsset(id) {
|
|
@@ -3365,7 +3384,7 @@ class EntityStoreBase {
|
|
|
3365
3384
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
3366
3385
|
entityToResolveFieldsFrom = entity; // we move up
|
|
3367
3386
|
}
|
|
3368
|
-
else if (
|
|
3387
|
+
else if (isAsset(fieldValue) || isEntry(fieldValue)) {
|
|
3369
3388
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
3370
3389
|
entityToResolveFieldsFrom = fieldValue; // we move up
|
|
3371
3390
|
}
|
|
@@ -3401,18 +3420,6 @@ class EntityStoreBase {
|
|
|
3401
3420
|
const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
|
|
3402
3421
|
return leafEntity;
|
|
3403
3422
|
}
|
|
3404
|
-
isAsset(value) {
|
|
3405
|
-
return (null !== value &&
|
|
3406
|
-
typeof value === 'object' &&
|
|
3407
|
-
'sys' in value &&
|
|
3408
|
-
value.sys?.type === 'Asset');
|
|
3409
|
-
}
|
|
3410
|
-
isEntry(value) {
|
|
3411
|
-
return (null !== value &&
|
|
3412
|
-
typeof value === 'object' &&
|
|
3413
|
-
'sys' in value &&
|
|
3414
|
-
value.sys?.type === 'Entry');
|
|
3415
|
-
}
|
|
3416
3423
|
getEntity(type, id) {
|
|
3417
3424
|
if (type === 'Asset') {
|
|
3418
3425
|
return this.assetMap.get(id);
|
|
@@ -4247,5 +4254,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
4247
4254
|
}
|
|
4248
4255
|
}
|
|
4249
4256
|
|
|
4250
|
-
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4257
|
+
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isAsset, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isEntry, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4251
4258
|
//# sourceMappingURL=index.js.map
|