@contentful/experiences-core 1.42.0-prerelease-20250626T1154-6ca57b0.0 → 1.42.0-prerelease-20250630T1135-a8b68d4.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,14 +1047,18 @@ 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
- 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']),
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
+ }),
1056
1060
  }),
1057
- }))
1061
+ })
1058
1062
  .optional(),
1059
1063
  contentTypes: z.record(z.string(), z.object({
1060
1064
  sys: z.object({
@@ -1068,13 +1072,29 @@ const ParameterDefinitionsSchema = z.record(propertyKeySchema, ParameterDefiniti
1068
1072
  const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
1069
1073
  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
1070
1074
  ComponentVariableSchema);
1071
- const ComponentSettingsSchema = z.object({
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({
1072
1092
  variableDefinitions: ComponentVariablesSchema,
1073
1093
  thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
1074
1094
  category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
1075
- variableMappings: VariableMappingsSchema.optional(),
1076
- parameterDefinitions: ParameterDefinitionsSchema.optional(),
1077
- });
1095
+ prebindingDefinitions: z.array(PrebindingDefinitionSchema).optional(),
1096
+ })
1097
+ .strict();
1078
1098
  z.object({
1079
1099
  componentTree: localeWrapper(ComponentTreeSchema),
1080
1100
  dataSource: localeWrapper(DataSourceSchema),
@@ -4152,10 +4172,12 @@ const attachPrebindingDefaultValueAsDataSource = (experienceEntry) => {
4152
4172
  // Only supported for pattern entries since experience entries don't define pattern properties.
4153
4173
  return;
4154
4174
  }
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;
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;
4159
4181
  if (!id)
4160
4182
  return;
4161
4183
  experienceEntry.fields.dataSource = {
@@ -4163,7 +4185,7 @@ const attachPrebindingDefaultValueAsDataSource = (experienceEntry) => {
4163
4185
  [id]: {
4164
4186
  sys: {
4165
4187
  type: 'Link',
4166
- linkType: 'Entry',
4188
+ linkType: type,
4167
4189
  id,
4168
4190
  },
4169
4191
  },