@contentful/experiences-sdk-react 1.42.3-dev-20250630T1524-5545f29.0 → 1.42.3-dev-20250701T1530-7e94407.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/index.d.ts +1 -1
- package/dist/sdkVersion.js +1 -1
- package/dist/sdkVersion.js.map +1 -1
- package/dist/src/sdkVersion.d.ts +1 -1
- package/dist/src/utils/prebindingUtils.d.ts +1 -1
- package/dist/test/__fixtures__/createAsset.d.ts +3 -0
- package/dist/test/__fixtures__/createEntry.d.ts +3 -0
- package/dist/test/__fixtures__/index.d.ts +2 -0
- package/dist/utils/prebindingUtils.js +32 -23
- package/dist/utils/prebindingUtils.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as _contentful_experiences_core_constants from '@contentful/experiences
|
|
|
8
8
|
export { CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, LATEST_SCHEMA_VERSION } from '@contentful/experiences-core/constants';
|
|
9
9
|
import { ContentfulClientApi } from 'contentful';
|
|
10
10
|
|
|
11
|
-
declare const SDK_VERSION = "1.42.3-dev-
|
|
11
|
+
declare const SDK_VERSION = "1.42.3-dev-20250701T1530-7e94407.0";
|
|
12
12
|
|
|
13
13
|
type ExperienceRootProps = {
|
|
14
14
|
experience?: Experience<EntityStore> | string | null;
|
package/dist/sdkVersion.js
CHANGED
package/dist/sdkVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.42.3-dev-
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.42.3-dev-20250701T1530-7e94407.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
|
package/dist/src/sdkVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.42.3-dev-
|
|
1
|
+
export declare const SDK_VERSION = "1.42.3-dev-20250701T1530-7e94407.0";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityStore } from '@contentful/experiences-core';
|
|
1
|
+
import { type EntityStore } from '@contentful/experiences-core';
|
|
2
2
|
import { ComponentPropertyValue, ExperienceComponentSettings, Parameter } from '@contentful/experiences-validators';
|
|
3
3
|
export declare const shouldUsePrebinding: ({ componentValueKey, componentSettings, parameters, variable, }: {
|
|
4
4
|
componentValueKey: string;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isLink } from '@contentful/experiences-core';
|
|
2
|
+
import { SIDELOADED_PREFIX } from '@contentful/experiences-core/constants';
|
|
3
|
+
|
|
1
4
|
const shouldUsePrebinding = ({ componentValueKey, componentSettings, parameters, variable, }) => {
|
|
2
5
|
const { prebindingDefinitions } = componentSettings;
|
|
3
6
|
const { parameterDefinitions, variableMappings } = prebindingDefinitions?.[0] || {};
|
|
@@ -31,32 +34,38 @@ const resolvePrebindingPath = ({ componentValueKey, componentSettings, parameter
|
|
|
31
34
|
return parameter.path + fieldPath;
|
|
32
35
|
};
|
|
33
36
|
const resolveMaybePrebindingDefaultValuePath = ({ componentValueKey, entityStore, }) => {
|
|
34
|
-
|
|
37
|
+
const variableMapping = entityStore.hoistedVariableMappings[componentValueKey];
|
|
38
|
+
if (!variableMapping)
|
|
35
39
|
return;
|
|
36
|
-
const
|
|
37
|
-
const prebindingDefinition =
|
|
38
|
-
if (!prebindingDefinition)
|
|
39
|
-
|
|
40
|
-
const mapping = prebindingDefinition.variableMappings?.[componentValueKey];
|
|
41
|
-
if (!mapping)
|
|
40
|
+
const pdID = variableMapping.parameterId;
|
|
41
|
+
const prebindingDefinition = entityStore.hoistedParameterDefinitions[pdID];
|
|
42
|
+
if (!prebindingDefinition) {
|
|
43
|
+
// probably shouldn't happen, as if ppd is not defined, then variableMapping should not be defined either
|
|
42
44
|
return;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
}
|
|
46
|
+
if (!prebindingDefinition.defaultSource) {
|
|
47
|
+
// pretty normal, prebinding definitions are not required to have default source
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const { contentTypeId, link: defaultEntryLink } = prebindingDefinition.defaultSource;
|
|
51
|
+
if (!isLink(defaultEntryLink)) {
|
|
52
|
+
// just extra safety check, defaultEntryLink should always be a link
|
|
46
53
|
return;
|
|
47
|
-
|
|
48
|
-
if (contentTypeId in
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
54
|
+
}
|
|
55
|
+
if (contentTypeId in prebindingDefinition.contentTypes) {
|
|
56
|
+
const entity = entityStore.getEntityFromLink(defaultEntryLink);
|
|
57
|
+
if (!entity) {
|
|
58
|
+
// looks like sideloading of the prebinding default value didn't work as expected.
|
|
59
|
+
// And didn't sideload the entry into entityStore (and didn't add it's sideloaded_dsKey to the entityStore.dataSource)
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const fieldPath = variableMapping.pathsByContentType[contentTypeId].path;
|
|
63
|
+
if (!fieldPath) {
|
|
64
|
+
// Path not found or degenerate shape (e.g. empty string '')
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const fullDefaultValuePath = `/${SIDELOADED_PREFIX}${defaultEntryLink.sys.id}${fieldPath}`;
|
|
68
|
+
return fullDefaultValuePath;
|
|
60
69
|
}
|
|
61
70
|
};
|
|
62
71
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prebindingUtils.js","sources":["../../../src/utils/prebindingUtils.ts"],"sourcesContent":["import { EntityStore } from '@contentful/experiences-core';\nimport {\n ComponentPropertyValue,\n ExperienceComponentSettings,\n Parameter,\n} from '@contentful/experiences-validators';\n\nexport const shouldUsePrebinding = ({\n componentValueKey,\n componentSettings,\n parameters,\n variable,\n}: {\n componentValueKey: string;\n componentSettings: ExperienceComponentSettings;\n parameters: Record<string, Parameter>;\n variable: ComponentPropertyValue;\n}) => {\n const { prebindingDefinitions } = componentSettings;\n const { parameterDefinitions, variableMappings } = prebindingDefinitions?.[0] || {};\n\n const variableMapping = variableMappings?.[componentValueKey];\n\n const parameterDefinition = parameterDefinitions?.[variableMapping?.parameterId || ''];\n const parameter = parameters?.[variableMapping?.parameterId || ''];\n\n const isValidForPrebinding = !!parameterDefinition && !!parameter && !!variableMapping;\n\n return isValidForPrebinding && variable?.type === 'NoValue';\n};\n\nexport const resolvePrebindingPath = ({\n componentValueKey,\n componentSettings,\n parameters,\n entityStore,\n}: {\n componentValueKey: string;\n componentSettings: ExperienceComponentSettings;\n parameters: Record<string, Parameter>;\n entityStore: EntityStore;\n}) => {\n const prebindingDefinition = componentSettings.prebindingDefinitions?.[0];\n if (!prebindingDefinition) return '';\n\n const variableMapping = prebindingDefinition.variableMappings?.[componentValueKey];\n\n if (!variableMapping) return '';\n\n const parameter = parameters?.[variableMapping.parameterId];\n\n if (!parameter) return '';\n\n const dataSourceKey = parameter.path.split('/')[1];\n\n const entityLink = entityStore.dataSource[dataSourceKey];\n if (!entityLink) return '';\n\n const entity = entityStore.getEntityFromLink(entityLink);\n if (!entity || entity.sys.type === 'Asset') return '';\n\n const contentType = entity.sys.contentType.sys.id;\n\n const fieldPath = variableMapping?.pathsByContentType?.[contentType]?.path;\n\n if (!fieldPath) return '';\n\n return parameter.path + fieldPath;\n};\n\nexport const resolveMaybePrebindingDefaultValuePath = ({\n componentValueKey,\n entityStore,\n}: {\n componentValueKey: string;\n entityStore: EntityStore;\n}): string | undefined => {\n if (!
|
|
1
|
+
{"version":3,"file":"prebindingUtils.js","sources":["../../../src/utils/prebindingUtils.ts"],"sourcesContent":["import { type EntityStore, isLink } from '@contentful/experiences-core';\nimport { SIDELOADED_PREFIX } from '@contentful/experiences-core/constants';\nimport {\n ComponentPropertyValue,\n ExperienceComponentSettings,\n Parameter,\n} from '@contentful/experiences-validators';\n\nexport const shouldUsePrebinding = ({\n componentValueKey,\n componentSettings,\n parameters,\n variable,\n}: {\n componentValueKey: string;\n componentSettings: ExperienceComponentSettings;\n parameters: Record<string, Parameter>;\n variable: ComponentPropertyValue;\n}) => {\n const { prebindingDefinitions } = componentSettings;\n const { parameterDefinitions, variableMappings } = prebindingDefinitions?.[0] || {};\n\n const variableMapping = variableMappings?.[componentValueKey];\n\n const parameterDefinition = parameterDefinitions?.[variableMapping?.parameterId || ''];\n const parameter = parameters?.[variableMapping?.parameterId || ''];\n\n const isValidForPrebinding = !!parameterDefinition && !!parameter && !!variableMapping;\n\n return isValidForPrebinding && variable?.type === 'NoValue';\n};\n\nexport const resolvePrebindingPath = ({\n componentValueKey,\n componentSettings,\n parameters,\n entityStore,\n}: {\n componentValueKey: string;\n componentSettings: ExperienceComponentSettings;\n parameters: Record<string, Parameter>;\n entityStore: EntityStore;\n}) => {\n const prebindingDefinition = componentSettings.prebindingDefinitions?.[0];\n if (!prebindingDefinition) return '';\n\n const variableMapping = prebindingDefinition.variableMappings?.[componentValueKey];\n\n if (!variableMapping) return '';\n\n const parameter = parameters?.[variableMapping.parameterId];\n\n if (!parameter) return '';\n\n const dataSourceKey = parameter.path.split('/')[1];\n\n const entityLink = entityStore.dataSource[dataSourceKey];\n if (!entityLink) return '';\n\n const entity = entityStore.getEntityFromLink(entityLink);\n if (!entity || entity.sys.type === 'Asset') return '';\n\n const contentType = entity.sys.contentType.sys.id;\n\n const fieldPath = variableMapping?.pathsByContentType?.[contentType]?.path;\n\n if (!fieldPath) return '';\n\n return parameter.path + fieldPath;\n};\n\nexport const resolveMaybePrebindingDefaultValuePath = ({\n componentValueKey,\n entityStore,\n}: {\n componentValueKey: string;\n entityStore: EntityStore;\n}): string | undefined => {\n const variableMapping = entityStore.hoistedVariableMappings[componentValueKey];\n if (!variableMapping) return;\n\n const pdID = variableMapping.parameterId;\n const prebindingDefinition = entityStore.hoistedParameterDefinitions[pdID];\n\n if (!prebindingDefinition) {\n // probably shouldn't happen, as if ppd is not defined, then variableMapping should not be defined either\n return;\n }\n if (!prebindingDefinition.defaultSource) {\n // pretty normal, prebinding definitions are not required to have default source\n return;\n }\n\n const { contentTypeId, link: defaultEntryLink } = prebindingDefinition.defaultSource;\n\n if (!isLink(defaultEntryLink)) {\n // just extra safety check, defaultEntryLink should always be a link\n return;\n }\n\n if (contentTypeId in prebindingDefinition.contentTypes) {\n const entity = entityStore.getEntityFromLink(defaultEntryLink);\n if (!entity) {\n // looks like sideloading of the prebinding default value didn't work as expected.\n // And didn't sideload the entry into entityStore (and didn't add it's sideloaded_dsKey to the entityStore.dataSource)\n return;\n }\n\n const fieldPath = variableMapping.pathsByContentType[contentTypeId].path;\n if (!fieldPath) {\n // Path not found or degenerate shape (e.g. empty string '')\n return;\n }\n\n const fullDefaultValuePath = `/${SIDELOADED_PREFIX}${defaultEntryLink.sys.id}${fieldPath}`;\n return fullDefaultValuePath;\n }\n};\n"],"names":[],"mappings":";;;AAQO,MAAM,mBAAmB,GAAG,CAAC,EAClC,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,QAAQ,GAMT,KAAI;AACH,IAAA,MAAM,EAAE,qBAAqB,EAAE,GAAG,iBAAiB,CAAC;AACpD,IAAA,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,GAAG,qBAAqB,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAEpF,IAAA,MAAM,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,CAAC;IAE9D,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,eAAe,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;IACvF,MAAM,SAAS,GAAG,UAAU,GAAG,eAAe,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;AAEnE,IAAA,MAAM,oBAAoB,GAAG,CAAC,CAAC,mBAAm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
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-sdk-react",
|
|
3
|
-
"version": "1.42.3-dev-
|
|
3
|
+
"version": "1.42.3-dev-20250701T1530-7e94407.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/src/index.d.ts",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"depcruise": "depcruise src"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@contentful/experiences-components-react": "1.42.3-dev-
|
|
45
|
-
"@contentful/experiences-core": "1.42.3-dev-
|
|
46
|
-
"@contentful/experiences-validators": "1.42.3-dev-
|
|
47
|
-
"@contentful/experiences-visual-editor-react": "1.42.3-dev-
|
|
44
|
+
"@contentful/experiences-components-react": "1.42.3-dev-20250701T1530-7e94407.0",
|
|
45
|
+
"@contentful/experiences-core": "1.42.3-dev-20250701T1530-7e94407.0",
|
|
46
|
+
"@contentful/experiences-validators": "1.42.3-dev-20250701T1530-7e94407.0",
|
|
47
|
+
"@contentful/experiences-visual-editor-react": "1.42.3-dev-20250701T1530-7e94407.0",
|
|
48
48
|
"@contentful/rich-text-types": "^17.0.0",
|
|
49
49
|
"classnames": "^2.3.2",
|
|
50
50
|
"csstype": "^3.1.2",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"dist",
|
|
101
101
|
"package.json"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "99353edf7501aa64e7b3e5db4e4bbf26d892a90a"
|
|
104
104
|
}
|