@contentful/experiences-core 1.41.1-dev-20250616T1604-5af1e75.0 → 1.42.0-dev-20250617T0920-3f313ab.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.js CHANGED
@@ -4145,6 +4145,36 @@ const removeSelfReferencingDataSource = (experienceEntry) => {
4145
4145
  experienceEntry.fields.dataSource = newDataSource;
4146
4146
  };
4147
4147
 
4148
+ /**
4149
+ * Attaches the default prebinding value (if any) to the experience entry's dataSource.
4150
+ *
4151
+ * This ensures that any default values defined in pattern property definitions are included
4152
+ * in the dataSource, so that linked entities can be fetched and resolved correctly.
4153
+ * Without this, defaults may be omitted, resulting in unresolved references during binding.
4154
+ */
4155
+ const attachPrebindingDefaultValueAsDataSource = (experienceEntry) => {
4156
+ if (!checkIsAssemblyEntry(experienceEntry)) {
4157
+ // Only supported for pattern entries since experience entries don't define pattern properties.
4158
+ return;
4159
+ }
4160
+ const patternDefs = experienceEntry.fields.componentSettings?.patternPropertyDefinitions ?? {};
4161
+ const defaultPrebinding = Object.values(patternDefs).find((def) => def.defaultValue)?.defaultValue;
4162
+ const [value] = Object.values(defaultPrebinding ?? {});
4163
+ const id = value?.sys?.id;
4164
+ if (!id)
4165
+ return;
4166
+ experienceEntry.fields.dataSource = {
4167
+ ...experienceEntry.fields.dataSource,
4168
+ [id]: {
4169
+ sys: {
4170
+ type: 'Link',
4171
+ linkType: 'Entry',
4172
+ id,
4173
+ },
4174
+ },
4175
+ };
4176
+ };
4177
+
4148
4178
  const errorMessagesWhileFetching$1 = {
4149
4179
  experience: 'Failed to fetch experience',
4150
4180
  experienceReferences: 'Failed to fetch entities, referenced in experience',
@@ -4180,6 +4210,7 @@ async function fetchBySlug({ client, experienceTypeId, slug, localeCode, isEdito
4180
4210
  }
4181
4211
  removeCircularPatternReferences(experienceEntry);
4182
4212
  removeSelfReferencingDataSource(experienceEntry);
4213
+ attachPrebindingDefaultValueAsDataSource(experienceEntry);
4183
4214
  try {
4184
4215
  const { entries, assets } = await fetchReferencedEntities({
4185
4216
  client,
@@ -4238,6 +4269,7 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
4238
4269
  }
4239
4270
  removeCircularPatternReferences(experienceEntry);
4240
4271
  removeSelfReferencingDataSource(experienceEntry);
4272
+ attachPrebindingDefaultValueAsDataSource(experienceEntry);
4241
4273
  try {
4242
4274
  const { entries, assets } = await fetchReferencedEntities({
4243
4275
  client,