@contentful/experiences-core 1.42.0-prerelease-20250630T1135-a8b68d4.0 → 1.42.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
@@ -1047,18 +1047,14 @@ const VariableMappingSchema = z.object({
1047
1047
  // TODO: finalize schema structure before release
1048
1048
  // https://contentful.atlassian.net/browse/LUMOS-523
1049
1049
  const ParameterDefinitionSchema = z.object({
1050
- defaultSource: z
1051
- .strictObject({
1052
- type: z.enum(['Entry']),
1053
- contentTypeId: z.string(),
1054
- link: z.strictObject({
1055
- sys: z.strictObject({
1056
- type: z.literal('Link'),
1057
- id: z.string(),
1058
- linkType: z.enum(['Entry']),
1059
- }),
1050
+ defaultValue: z
1051
+ .record(z.string(), z.object({
1052
+ sys: z.object({
1053
+ type: z.literal('Link'),
1054
+ id: z.string(),
1055
+ linkType: z.enum(['Entry']),
1060
1056
  }),
1061
- })
1057
+ }))
1062
1058
  .optional(),
1063
1059
  contentTypes: z.record(z.string(), z.object({
1064
1060
  sys: z.object({
@@ -1072,29 +1068,13 @@ const ParameterDefinitionsSchema = z.record(propertyKeySchema, ParameterDefiniti
1072
1068
  const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
1073
1069
  const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
1074
1070
  ComponentVariableSchema);
1075
- const PassToNodeSchema = z
1076
- .object({
1077
- nodeId: propertyKeySchema,
1078
- parameterId: propertyKeySchema,
1079
- prebindingId: propertyKeySchema,
1080
- })
1081
- .strict();
1082
- const PrebindingDefinitionSchema = z
1083
- .object({
1084
- id: propertyKeySchema,
1085
- variableMappings: VariableMappingsSchema.optional(),
1086
- parameterDefinitions: ParameterDefinitionsSchema,
1087
- passToNodes: z.array(PassToNodeSchema).optional(),
1088
- })
1089
- .strict();
1090
- const ComponentSettingsSchema = z
1091
- .object({
1071
+ const ComponentSettingsSchema = z.object({
1092
1072
  variableDefinitions: ComponentVariablesSchema,
1093
1073
  thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
1094
1074
  category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
1095
- prebindingDefinitions: z.array(PrebindingDefinitionSchema).optional(),
1096
- })
1097
- .strict();
1075
+ variableMappings: VariableMappingsSchema.optional(),
1076
+ parameterDefinitions: ParameterDefinitionsSchema.optional(),
1077
+ });
1098
1078
  z.object({
1099
1079
  componentTree: localeWrapper(ComponentTreeSchema),
1100
1080
  dataSource: localeWrapper(DataSourceSchema),
@@ -4172,12 +4152,10 @@ const attachPrebindingDefaultValueAsDataSource = (experienceEntry) => {
4172
4152
  // Only supported for pattern entries since experience entries don't define pattern properties.
4173
4153
  return;
4174
4154
  }
4175
- const patternDefs = experienceEntry.fields.componentSettings?.prebindingDefinitions?.[0].parameterDefinitions ?? {};
4176
- const defaultPrebinding = Object.values(patternDefs).find((def) => def.defaultSource)?.defaultSource;
4177
- const { link, type } = defaultPrebinding ?? {};
4178
- if (!link || !type)
4179
- return;
4180
- const id = link.sys?.id;
4155
+ const patternDefs = experienceEntry.fields.componentSettings?.parameterDefinitions ?? {};
4156
+ const defaultPrebinding = Object.values(patternDefs).find((def) => def.defaultValue)?.defaultValue;
4157
+ const [value] = Object.values(defaultPrebinding ?? {});
4158
+ const id = value?.sys?.id;
4181
4159
  if (!id)
4182
4160
  return;
4183
4161
  experienceEntry.fields.dataSource = {
@@ -4185,7 +4163,7 @@ const attachPrebindingDefaultValueAsDataSource = (experienceEntry) => {
4185
4163
  [id]: {
4186
4164
  sys: {
4187
4165
  type: 'Link',
4188
- linkType: type,
4166
+ linkType: 'Entry',
4189
4167
  id,
4190
4168
  },
4191
4169
  },