@contentful/experiences-visual-editor-react 3.7.0-prerelease-20250915T1724-8825648.0 → 3.7.0-prerelease-20250917T1034-42f0486.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/renderApp.js CHANGED
@@ -44255,6 +44255,19 @@ const ComponentVariableSchema$1 = z.object({
44255
44255
  });
44256
44256
  const ComponentTreeNodeSchema$1 = BaseComponentTreeNodeSchema$1.extend({
44257
44257
  children: z.lazy(() => ComponentTreeNodeSchema$1.array()),
44258
+ }).superRefine(({ id, prebindingId, parameters }, ctx) => {
44259
+ if (prebindingId && !parameters) {
44260
+ ctx.addIssue({
44261
+ code: z.ZodIssueCode.custom,
44262
+ message: `Found "prebindingId" but no "parameters" for node with id: "${id}"`,
44263
+ });
44264
+ }
44265
+ if (parameters && !prebindingId) {
44266
+ ctx.addIssue({
44267
+ code: z.ZodIssueCode.custom,
44268
+ message: `Found "parameters" but no "prebindingId" for node with id: "${id}"`,
44269
+ });
44270
+ }
44258
44271
  });
44259
44272
  const ComponentTreeSchema$1 = z
44260
44273
  .object({
@@ -44272,25 +44285,6 @@ z.object({
44272
44285
  usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
44273
44286
  });
44274
44287
 
44275
- function treeVisit$1$1(initialNode, onNode) {
44276
- const _treeVisit = (currentNode) => {
44277
- const children = [...currentNode.children];
44278
- onNode(currentNode);
44279
- for (const child of children) {
44280
- _treeVisit(child);
44281
- }
44282
- };
44283
- if (Array.isArray(initialNode)) {
44284
- for (const node of initialNode) {
44285
- _treeVisit(node);
44286
- }
44287
- }
44288
- else {
44289
- _treeVisit(initialNode);
44290
- }
44291
- }
44292
-
44293
- const MAX_ALLOWED_PATHS$1 = 200;
44294
44288
  const THUMBNAIL_IDS$1 = [
44295
44289
  'columns',
44296
44290
  'columnsPlusRight',
@@ -44321,17 +44315,7 @@ const THUMBNAIL_IDS$1 = [
44321
44315
  const VariableMappingSchema$1 = z.object({
44322
44316
  parameterId: propertyKeySchema$1,
44323
44317
  type: z.literal('ContentTypeMapping'),
44324
- pathsByContentType: z
44325
- .record(z.string(), z.object({ path: z.string() }))
44326
- .superRefine((paths, ctx) => {
44327
- const variableId = ctx.path[ctx.path.length - 2];
44328
- if (Object.keys(paths).length > MAX_ALLOWED_PATHS$1) {
44329
- ctx.addIssue({
44330
- code: z.ZodIssueCode.custom,
44331
- message: `Too many paths defined for variable mapping with id "${variableId}", maximum allowed is ${MAX_ALLOWED_PATHS$1}`,
44332
- });
44333
- }
44334
- }),
44318
+ pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
44335
44319
  });
44336
44320
  const PassToNodeSchema$1 = z
44337
44321
  .object({
@@ -44355,10 +44339,7 @@ const ParameterDefinitionSchema$1 = z.object({
44355
44339
  })
44356
44340
  .optional(),
44357
44341
  contentTypes: z.array(z.string()).min(1),
44358
- passToNodes: z
44359
- .array(PassToNodeSchema$1)
44360
- .max(1, 'At most one "passToNodes" element is allowed per parameter definition.')
44361
- .optional(), // we might change this to be empty array for native parameter definitions, that's why we don't use .length(1)
44342
+ passToNodes: z.array(PassToNodeSchema$1).optional(),
44362
44343
  });
44363
44344
  const ParameterDefinitionsSchema$1 = z.record(propertyKeySchema$1, ParameterDefinitionSchema$1);
44364
44345
  const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSchema$1);
@@ -44379,107 +44360,14 @@ const ComponentSettingsSchema$1 = z
44379
44360
  category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
44380
44361
  prebindingDefinitions: z.array(PrebindingDefinitionSchema$1).length(1).optional(),
44381
44362
  })
44382
- .strict()
44383
- .superRefine((componentSettings, ctx) => {
44384
- const { variableDefinitions, prebindingDefinitions } = componentSettings;
44385
- if (!prebindingDefinitions || prebindingDefinitions.length === 0) {
44386
- return;
44387
- }
44388
- const { parameterDefinitions, variableMappings, allowedVariableOverrides } = prebindingDefinitions[0];
44389
- validateAtMostOneNativeParameterDefinition$1(parameterDefinitions, ctx);
44390
- validateNoOverlapBetweenMappingAndOverrides$1(variableMappings, allowedVariableOverrides, ctx);
44391
- validateMappingsAgainstVariableDefinitions$1(variableMappings, allowedVariableOverrides, variableDefinitions, ctx);
44392
- validateMappingsAgainstParameterDefinitions$1(variableMappings, parameterDefinitions, ctx);
44393
- });
44394
- z
44395
- .object({
44363
+ .strict();
44364
+ z.object({
44396
44365
  componentTree: localeWrapper$1(ComponentTreeSchema$1),
44397
44366
  dataSource: localeWrapper$1(DataSourceSchema$1),
44398
44367
  unboundValues: localeWrapper$1(UnboundValuesSchema$1),
44399
44368
  usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
44400
44369
  componentSettings: localeWrapper$1(ComponentSettingsSchema$1),
44401
- })
44402
- .superRefine((patternFields, ctx) => {
44403
- const { componentTree, componentSettings } = patternFields;
44404
- // values at this point are wrapped under locale code
44405
- const nonLocalisedComponentTree = Object.values(componentTree)[0];
44406
- const nonLocalisedComponentSettings = Object.values(componentSettings)[0];
44407
- if (!nonLocalisedComponentSettings || !nonLocalisedComponentTree) {
44408
- return;
44409
- }
44410
- validatePassToNodes$1(nonLocalisedComponentTree.children || [], nonLocalisedComponentSettings || {}, ctx);
44411
44370
  });
44412
- const validateAtMostOneNativeParameterDefinition$1 = (parameterDefinitions, ctx) => {
44413
- const nativeParamDefinitions = Object.values(parameterDefinitions).filter((paramDefinition) => !(paramDefinition.passToNodes && paramDefinition.passToNodes.length > 0));
44414
- if (nativeParamDefinitions.length > 1) {
44415
- ctx.addIssue({
44416
- code: z.ZodIssueCode.custom,
44417
- message: `Only one native parameter definition (parameter definition without passToNodes) is allowed per prebinding definition.`,
44418
- });
44419
- }
44420
- };
44421
- const validateNoOverlapBetweenMappingAndOverrides$1 = (variableMappings, allowedVariableOverrides, ctx) => {
44422
- const variableMappingKeys = Object.keys(variableMappings || {});
44423
- const overlap = variableMappingKeys.filter((key) => allowedVariableOverrides?.includes(key));
44424
- if (overlap.length > 0) {
44425
- ctx.addIssue({
44426
- code: z.ZodIssueCode.custom,
44427
- message: `Found both variable mapping and allowed override for the following keys: ${overlap.map((key) => `"${key}"`).join(', ')}.`,
44428
- });
44429
- }
44430
- };
44431
- const validateMappingsAgainstVariableDefinitions$1 = (variableMappings, allowedVariableOverrides, variableDefinitions, ctx) => {
44432
- const nonDesignVariableDefinitionKeys = Object.entries(variableDefinitions)
44433
- .filter(([_, def]) => def.group !== 'style')
44434
- .map(([key]) => key);
44435
- const variableMappingKeys = Object.keys(variableMappings || {});
44436
- const allKeys = [...variableMappingKeys, ...(allowedVariableOverrides || [])];
44437
- const invalidMappings = allKeys.filter((key) => !nonDesignVariableDefinitionKeys.includes(key));
44438
- if (invalidMappings.length > 0) {
44439
- ctx.addIssue({
44440
- code: z.ZodIssueCode.custom,
44441
- message: `The following variable mappings or overrides are missing from the variable definitions: ${invalidMappings.map((key) => `"${key}"`).join(', ')}.`,
44442
- });
44443
- }
44444
- };
44445
- const validateMappingsAgainstParameterDefinitions$1 = (variableMappings, parameterDefinitions, ctx) => {
44446
- const parameterDefinitionKeys = Object.keys(parameterDefinitions || {});
44447
- for (const [mappingKey, mappingValue] of Object.entries(variableMappings || {})) {
44448
- if (!parameterDefinitionKeys.includes(mappingValue.parameterId)) {
44449
- ctx.addIssue({
44450
- code: z.ZodIssueCode.custom,
44451
- message: `The variable mapping with id "${mappingKey}" references a non-existing parameterId "${mappingValue.parameterId}".`,
44452
- });
44453
- }
44454
- }
44455
- };
44456
- const validatePassToNodes$1 = (rootChildren, componentSettings, ctx) => {
44457
- if (!componentSettings.prebindingDefinitions ||
44458
- componentSettings.prebindingDefinitions.length === 0) {
44459
- return;
44460
- }
44461
- const { parameterDefinitions } = componentSettings.prebindingDefinitions[0];
44462
- let nodeIds = new Set();
44463
- for (const paramDef of Object.values(parameterDefinitions || {})) {
44464
- paramDef.passToNodes?.forEach((n) => nodeIds.add(n.nodeId));
44465
- }
44466
- treeVisit$1$1(rootChildren, (node) => {
44467
- if (!node.id)
44468
- return;
44469
- if (nodeIds.has(node.id)) {
44470
- nodeIds.delete(node.id);
44471
- }
44472
- });
44473
- if (nodeIds.size > 0) {
44474
- const stringifiedNodeIds = Array.from(nodeIds)
44475
- .map((id) => `"${id}"`)
44476
- .join(', ');
44477
- ctx.addIssue({
44478
- code: z.ZodIssueCode.custom,
44479
- message: `The following node IDs referenced in passToNodes are not present in the component tree: ${stringifiedNodeIds}.`,
44480
- });
44481
- }
44482
- };
44483
44371
 
44484
44372
  z
44485
44373
  .object({
@@ -49160,6 +49048,19 @@ const ComponentVariableSchema = z.object({
49160
49048
  });
49161
49049
  const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
49162
49050
  children: z.lazy(() => ComponentTreeNodeSchema.array()),
49051
+ }).superRefine(({ id, prebindingId, parameters }, ctx) => {
49052
+ if (prebindingId && !parameters) {
49053
+ ctx.addIssue({
49054
+ code: z.ZodIssueCode.custom,
49055
+ message: `Found "prebindingId" but no "parameters" for node with id: "${id}"`,
49056
+ });
49057
+ }
49058
+ if (parameters && !prebindingId) {
49059
+ ctx.addIssue({
49060
+ code: z.ZodIssueCode.custom,
49061
+ message: `Found "parameters" but no "prebindingId" for node with id: "${id}"`,
49062
+ });
49063
+ }
49163
49064
  });
49164
49065
  const ComponentTreeSchema = z
49165
49066
  .object({
@@ -49177,25 +49078,6 @@ z.object({
49177
49078
  usedComponents: localeWrapper(UsedComponentsSchema).optional(),
49178
49079
  });
49179
49080
 
49180
- function treeVisit$1(initialNode, onNode) {
49181
- const _treeVisit = (currentNode) => {
49182
- const children = [...currentNode.children];
49183
- onNode(currentNode);
49184
- for (const child of children) {
49185
- _treeVisit(child);
49186
- }
49187
- };
49188
- if (Array.isArray(initialNode)) {
49189
- for (const node of initialNode) {
49190
- _treeVisit(node);
49191
- }
49192
- }
49193
- else {
49194
- _treeVisit(initialNode);
49195
- }
49196
- }
49197
-
49198
- const MAX_ALLOWED_PATHS = 200;
49199
49081
  const THUMBNAIL_IDS = [
49200
49082
  'columns',
49201
49083
  'columnsPlusRight',
@@ -49226,17 +49108,7 @@ const THUMBNAIL_IDS = [
49226
49108
  const VariableMappingSchema = z.object({
49227
49109
  parameterId: propertyKeySchema,
49228
49110
  type: z.literal('ContentTypeMapping'),
49229
- pathsByContentType: z
49230
- .record(z.string(), z.object({ path: z.string() }))
49231
- .superRefine((paths, ctx) => {
49232
- const variableId = ctx.path[ctx.path.length - 2];
49233
- if (Object.keys(paths).length > MAX_ALLOWED_PATHS) {
49234
- ctx.addIssue({
49235
- code: z.ZodIssueCode.custom,
49236
- message: `Too many paths defined for variable mapping with id "${variableId}", maximum allowed is ${MAX_ALLOWED_PATHS}`,
49237
- });
49238
- }
49239
- }),
49111
+ pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
49240
49112
  });
49241
49113
  const PassToNodeSchema = z
49242
49114
  .object({
@@ -49260,10 +49132,7 @@ const ParameterDefinitionSchema = z.object({
49260
49132
  })
49261
49133
  .optional(),
49262
49134
  contentTypes: z.array(z.string()).min(1),
49263
- passToNodes: z
49264
- .array(PassToNodeSchema)
49265
- .max(1, 'At most one "passToNodes" element is allowed per parameter definition.')
49266
- .optional(), // we might change this to be empty array for native parameter definitions, that's why we don't use .length(1)
49135
+ passToNodes: z.array(PassToNodeSchema).optional(),
49267
49136
  });
49268
49137
  const ParameterDefinitionsSchema = z.record(propertyKeySchema, ParameterDefinitionSchema);
49269
49138
  const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
@@ -49284,107 +49153,14 @@ const ComponentSettingsSchema = z
49284
49153
  category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
49285
49154
  prebindingDefinitions: z.array(PrebindingDefinitionSchema).length(1).optional(),
49286
49155
  })
49287
- .strict()
49288
- .superRefine((componentSettings, ctx) => {
49289
- const { variableDefinitions, prebindingDefinitions } = componentSettings;
49290
- if (!prebindingDefinitions || prebindingDefinitions.length === 0) {
49291
- return;
49292
- }
49293
- const { parameterDefinitions, variableMappings, allowedVariableOverrides } = prebindingDefinitions[0];
49294
- validateAtMostOneNativeParameterDefinition(parameterDefinitions, ctx);
49295
- validateNoOverlapBetweenMappingAndOverrides(variableMappings, allowedVariableOverrides, ctx);
49296
- validateMappingsAgainstVariableDefinitions(variableMappings, allowedVariableOverrides, variableDefinitions, ctx);
49297
- validateMappingsAgainstParameterDefinitions(variableMappings, parameterDefinitions, ctx);
49298
- });
49299
- z
49300
- .object({
49156
+ .strict();
49157
+ z.object({
49301
49158
  componentTree: localeWrapper(ComponentTreeSchema),
49302
49159
  dataSource: localeWrapper(DataSourceSchema),
49303
49160
  unboundValues: localeWrapper(UnboundValuesSchema),
49304
49161
  usedComponents: localeWrapper(UsedComponentsSchema).optional(),
49305
49162
  componentSettings: localeWrapper(ComponentSettingsSchema),
49306
- })
49307
- .superRefine((patternFields, ctx) => {
49308
- const { componentTree, componentSettings } = patternFields;
49309
- // values at this point are wrapped under locale code
49310
- const nonLocalisedComponentTree = Object.values(componentTree)[0];
49311
- const nonLocalisedComponentSettings = Object.values(componentSettings)[0];
49312
- if (!nonLocalisedComponentSettings || !nonLocalisedComponentTree) {
49313
- return;
49314
- }
49315
- validatePassToNodes(nonLocalisedComponentTree.children || [], nonLocalisedComponentSettings || {}, ctx);
49316
49163
  });
49317
- const validateAtMostOneNativeParameterDefinition = (parameterDefinitions, ctx) => {
49318
- const nativeParamDefinitions = Object.values(parameterDefinitions).filter((paramDefinition) => !(paramDefinition.passToNodes && paramDefinition.passToNodes.length > 0));
49319
- if (nativeParamDefinitions.length > 1) {
49320
- ctx.addIssue({
49321
- code: z.ZodIssueCode.custom,
49322
- message: `Only one native parameter definition (parameter definition without passToNodes) is allowed per prebinding definition.`,
49323
- });
49324
- }
49325
- };
49326
- const validateNoOverlapBetweenMappingAndOverrides = (variableMappings, allowedVariableOverrides, ctx) => {
49327
- const variableMappingKeys = Object.keys(variableMappings || {});
49328
- const overlap = variableMappingKeys.filter((key) => allowedVariableOverrides?.includes(key));
49329
- if (overlap.length > 0) {
49330
- ctx.addIssue({
49331
- code: z.ZodIssueCode.custom,
49332
- message: `Found both variable mapping and allowed override for the following keys: ${overlap.map((key) => `"${key}"`).join(', ')}.`,
49333
- });
49334
- }
49335
- };
49336
- const validateMappingsAgainstVariableDefinitions = (variableMappings, allowedVariableOverrides, variableDefinitions, ctx) => {
49337
- const nonDesignVariableDefinitionKeys = Object.entries(variableDefinitions)
49338
- .filter(([_, def]) => def.group !== 'style')
49339
- .map(([key]) => key);
49340
- const variableMappingKeys = Object.keys(variableMappings || {});
49341
- const allKeys = [...variableMappingKeys, ...(allowedVariableOverrides || [])];
49342
- const invalidMappings = allKeys.filter((key) => !nonDesignVariableDefinitionKeys.includes(key));
49343
- if (invalidMappings.length > 0) {
49344
- ctx.addIssue({
49345
- code: z.ZodIssueCode.custom,
49346
- message: `The following variable mappings or overrides are missing from the variable definitions: ${invalidMappings.map((key) => `"${key}"`).join(', ')}.`,
49347
- });
49348
- }
49349
- };
49350
- const validateMappingsAgainstParameterDefinitions = (variableMappings, parameterDefinitions, ctx) => {
49351
- const parameterDefinitionKeys = Object.keys(parameterDefinitions || {});
49352
- for (const [mappingKey, mappingValue] of Object.entries(variableMappings || {})) {
49353
- if (!parameterDefinitionKeys.includes(mappingValue.parameterId)) {
49354
- ctx.addIssue({
49355
- code: z.ZodIssueCode.custom,
49356
- message: `The variable mapping with id "${mappingKey}" references a non-existing parameterId "${mappingValue.parameterId}".`,
49357
- });
49358
- }
49359
- }
49360
- };
49361
- const validatePassToNodes = (rootChildren, componentSettings, ctx) => {
49362
- if (!componentSettings.prebindingDefinitions ||
49363
- componentSettings.prebindingDefinitions.length === 0) {
49364
- return;
49365
- }
49366
- const { parameterDefinitions } = componentSettings.prebindingDefinitions[0];
49367
- let nodeIds = new Set();
49368
- for (const paramDef of Object.values(parameterDefinitions || {})) {
49369
- paramDef.passToNodes?.forEach((n) => nodeIds.add(n.nodeId));
49370
- }
49371
- treeVisit$1(rootChildren, (node) => {
49372
- if (!node.id)
49373
- return;
49374
- if (nodeIds.has(node.id)) {
49375
- nodeIds.delete(node.id);
49376
- }
49377
- });
49378
- if (nodeIds.size > 0) {
49379
- const stringifiedNodeIds = Array.from(nodeIds)
49380
- .map((id) => `"${id}"`)
49381
- .join(', ');
49382
- ctx.addIssue({
49383
- code: z.ZodIssueCode.custom,
49384
- message: `The following node IDs referenced in passToNodes are not present in the component tree: ${stringifiedNodeIds}.`,
49385
- });
49386
- }
49387
- };
49388
49164
 
49389
49165
  z
49390
49166
  .object({