@contentful/experiences-visual-editor-react 3.6.2 → 3.7.0-prerelease-20250915T1724-8825648.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 +258 -8
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +258 -8
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -44272,6 +44272,25 @@ z.object({
|
|
|
44272
44272
|
usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
|
|
44273
44273
|
});
|
|
44274
44274
|
|
|
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;
|
|
44275
44294
|
const THUMBNAIL_IDS$1 = [
|
|
44276
44295
|
'columns',
|
|
44277
44296
|
'columnsPlusRight',
|
|
@@ -44302,7 +44321,17 @@ const THUMBNAIL_IDS$1 = [
|
|
|
44302
44321
|
const VariableMappingSchema$1 = z.object({
|
|
44303
44322
|
parameterId: propertyKeySchema$1,
|
|
44304
44323
|
type: z.literal('ContentTypeMapping'),
|
|
44305
|
-
pathsByContentType: z
|
|
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
|
+
}),
|
|
44306
44335
|
});
|
|
44307
44336
|
const PassToNodeSchema$1 = z
|
|
44308
44337
|
.object({
|
|
@@ -44326,7 +44355,10 @@ const ParameterDefinitionSchema$1 = z.object({
|
|
|
44326
44355
|
})
|
|
44327
44356
|
.optional(),
|
|
44328
44357
|
contentTypes: z.array(z.string()).min(1),
|
|
44329
|
-
passToNodes: z
|
|
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)
|
|
44330
44362
|
});
|
|
44331
44363
|
const ParameterDefinitionsSchema$1 = z.record(propertyKeySchema$1, ParameterDefinitionSchema$1);
|
|
44332
44364
|
const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSchema$1);
|
|
@@ -44347,14 +44379,107 @@ const ComponentSettingsSchema$1 = z
|
|
|
44347
44379
|
category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
|
|
44348
44380
|
prebindingDefinitions: z.array(PrebindingDefinitionSchema$1).length(1).optional(),
|
|
44349
44381
|
})
|
|
44350
|
-
.strict()
|
|
44351
|
-
|
|
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({
|
|
44352
44396
|
componentTree: localeWrapper$1(ComponentTreeSchema$1),
|
|
44353
44397
|
dataSource: localeWrapper$1(DataSourceSchema$1),
|
|
44354
44398
|
unboundValues: localeWrapper$1(UnboundValuesSchema$1),
|
|
44355
44399
|
usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
|
|
44356
44400
|
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);
|
|
44357
44411
|
});
|
|
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
|
+
};
|
|
44358
44483
|
|
|
44359
44484
|
z
|
|
44360
44485
|
.object({
|
|
@@ -49052,6 +49177,25 @@ z.object({
|
|
|
49052
49177
|
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
49053
49178
|
});
|
|
49054
49179
|
|
|
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;
|
|
49055
49199
|
const THUMBNAIL_IDS = [
|
|
49056
49200
|
'columns',
|
|
49057
49201
|
'columnsPlusRight',
|
|
@@ -49082,7 +49226,17 @@ const THUMBNAIL_IDS = [
|
|
|
49082
49226
|
const VariableMappingSchema = z.object({
|
|
49083
49227
|
parameterId: propertyKeySchema,
|
|
49084
49228
|
type: z.literal('ContentTypeMapping'),
|
|
49085
|
-
pathsByContentType: z
|
|
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
|
+
}),
|
|
49086
49240
|
});
|
|
49087
49241
|
const PassToNodeSchema = z
|
|
49088
49242
|
.object({
|
|
@@ -49106,7 +49260,10 @@ const ParameterDefinitionSchema = z.object({
|
|
|
49106
49260
|
})
|
|
49107
49261
|
.optional(),
|
|
49108
49262
|
contentTypes: z.array(z.string()).min(1),
|
|
49109
|
-
passToNodes: z
|
|
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)
|
|
49110
49267
|
});
|
|
49111
49268
|
const ParameterDefinitionsSchema = z.record(propertyKeySchema, ParameterDefinitionSchema);
|
|
49112
49269
|
const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
|
|
@@ -49127,14 +49284,107 @@ const ComponentSettingsSchema = z
|
|
|
49127
49284
|
category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
|
|
49128
49285
|
prebindingDefinitions: z.array(PrebindingDefinitionSchema).length(1).optional(),
|
|
49129
49286
|
})
|
|
49130
|
-
.strict()
|
|
49131
|
-
|
|
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({
|
|
49132
49301
|
componentTree: localeWrapper(ComponentTreeSchema),
|
|
49133
49302
|
dataSource: localeWrapper(DataSourceSchema),
|
|
49134
49303
|
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
49135
49304
|
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
49136
49305
|
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);
|
|
49137
49316
|
});
|
|
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
|
+
};
|
|
49138
49388
|
|
|
49139
49389
|
z
|
|
49140
49390
|
.object({
|