@contentful/experiences-core 1.41.0-dev-20250611T1249-85aabd5.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 -20
- 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
|
@@ -953,7 +953,6 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
|
953
953
|
const PatternPropertySchema = z.object({
|
|
954
954
|
type: z.literal('BoundValue'),
|
|
955
955
|
path: z.string(),
|
|
956
|
-
contentType: z.string(),
|
|
957
956
|
});
|
|
958
957
|
const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
|
|
959
958
|
const BreakpointSchema = z
|
|
@@ -2873,10 +2872,26 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
2873
2872
|
return asset.fields.file?.url;
|
|
2874
2873
|
};
|
|
2875
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
|
+
|
|
2876
2888
|
function getResolvedEntryFromLink(entryOrAsset, path, entityStore) {
|
|
2877
|
-
if (entryOrAsset
|
|
2889
|
+
if (isAsset(entryOrAsset)) {
|
|
2878
2890
|
return entryOrAsset;
|
|
2879
2891
|
}
|
|
2892
|
+
else if (!isEntry(entryOrAsset)) {
|
|
2893
|
+
throw new Error(`Expected an Entry or Asset, but got: ${JSON.stringify(entryOrAsset)}`);
|
|
2894
|
+
}
|
|
2880
2895
|
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
2881
2896
|
if (value?.sys.type !== 'Link') {
|
|
2882
2897
|
console.warn(`Expected a link to a reference, but got: ${JSON.stringify(value)}`);
|
|
@@ -3240,10 +3255,13 @@ class EntityStoreBase {
|
|
|
3240
3255
|
}
|
|
3241
3256
|
entity = resolvedEntity;
|
|
3242
3257
|
}
|
|
3243
|
-
else {
|
|
3258
|
+
else if (isAsset(linkOrEntryOrAsset) || isEntry(linkOrEntryOrAsset)) {
|
|
3244
3259
|
// We already have the complete entity in preview & delivery (resolved by the CMA client)
|
|
3245
3260
|
entity = linkOrEntryOrAsset;
|
|
3246
3261
|
}
|
|
3262
|
+
else {
|
|
3263
|
+
throw new Error(`Unexpected object when resolving entity: ${JSON.stringify(linkOrEntryOrAsset)}`);
|
|
3264
|
+
}
|
|
3247
3265
|
return entity;
|
|
3248
3266
|
}
|
|
3249
3267
|
/**
|
|
@@ -3289,14 +3307,14 @@ class EntityStoreBase {
|
|
|
3289
3307
|
};
|
|
3290
3308
|
}
|
|
3291
3309
|
addEntity(entity) {
|
|
3292
|
-
if (
|
|
3310
|
+
if (isAsset(entity)) {
|
|
3293
3311
|
this.assetMap.set(entity.sys.id, entity);
|
|
3294
3312
|
}
|
|
3295
|
-
else if (
|
|
3313
|
+
else if (isEntry(entity)) {
|
|
3296
3314
|
this.entryMap.set(entity.sys.id, entity);
|
|
3297
3315
|
}
|
|
3298
3316
|
else {
|
|
3299
|
-
|
|
3317
|
+
throw new Error(`Attempted to add an entity to the store that is neither Asset nor Entry: '${JSON.stringify(entity)}'`);
|
|
3300
3318
|
}
|
|
3301
3319
|
}
|
|
3302
3320
|
async fetchAsset(id) {
|
|
@@ -3366,7 +3384,7 @@ class EntityStoreBase {
|
|
|
3366
3384
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
3367
3385
|
entityToResolveFieldsFrom = entity; // we move up
|
|
3368
3386
|
}
|
|
3369
|
-
else if (
|
|
3387
|
+
else if (isAsset(fieldValue) || isEntry(fieldValue)) {
|
|
3370
3388
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
3371
3389
|
entityToResolveFieldsFrom = fieldValue; // we move up
|
|
3372
3390
|
}
|
|
@@ -3402,18 +3420,6 @@ class EntityStoreBase {
|
|
|
3402
3420
|
const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
|
|
3403
3421
|
return leafEntity;
|
|
3404
3422
|
}
|
|
3405
|
-
isAsset(value) {
|
|
3406
|
-
return (null !== value &&
|
|
3407
|
-
typeof value === 'object' &&
|
|
3408
|
-
'sys' in value &&
|
|
3409
|
-
value.sys?.type === 'Asset');
|
|
3410
|
-
}
|
|
3411
|
-
isEntry(value) {
|
|
3412
|
-
return (null !== value &&
|
|
3413
|
-
typeof value === 'object' &&
|
|
3414
|
-
'sys' in value &&
|
|
3415
|
-
value.sys?.type === 'Entry');
|
|
3416
|
-
}
|
|
3417
3423
|
getEntity(type, id) {
|
|
3418
3424
|
if (type === 'Asset') {
|
|
3419
3425
|
return this.assetMap.get(id);
|
|
@@ -4248,5 +4254,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
4248
4254
|
}
|
|
4249
4255
|
}
|
|
4250
4256
|
|
|
4251
|
-
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 };
|
|
4252
4258
|
//# sourceMappingURL=index.js.map
|