@contentful/experiences-validators 1.9.0-dev-20240628T2235-7a4f71f.0 → 1.9.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.cjs +402 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +657 -0
- package/dist/index.js +396 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +589 -0
- package/package.json +2 -2
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// If more than one version is supported, use z.union
|
|
6
|
+
const SchemaVersions = zod.z.literal('2023-09-28');
|
|
7
|
+
// Keep deprecated versions here just for reference
|
|
8
|
+
zod.z.union([
|
|
9
|
+
zod.z.literal('2023-08-23'),
|
|
10
|
+
zod.z.literal('2023-07-26'),
|
|
11
|
+
zod.z.literal('2023-06-27'),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const DefinitionPropertyTypeSchema = zod.z.enum([
|
|
15
|
+
'Text',
|
|
16
|
+
'RichText',
|
|
17
|
+
'Number',
|
|
18
|
+
'Date',
|
|
19
|
+
'Boolean',
|
|
20
|
+
'Location',
|
|
21
|
+
'Media',
|
|
22
|
+
'Object',
|
|
23
|
+
'Hyperlink',
|
|
24
|
+
]);
|
|
25
|
+
const DefinitionPropertyKeySchema = zod.z
|
|
26
|
+
.string()
|
|
27
|
+
.regex(/^[a-zA-Z0-9-_]{1,32}$/, { message: 'Property needs to match: /^[a-zA-Z0-9-_]{1,32}$/' });
|
|
28
|
+
const ComponentDefinitionSchema = zod.z.object({
|
|
29
|
+
id: DefinitionPropertyKeySchema,
|
|
30
|
+
variables: zod.z.record(DefinitionPropertyKeySchema, zod.z.object({
|
|
31
|
+
// TODO - extend with definition of validations and defaultValue
|
|
32
|
+
displayName: zod.z.string().optional(),
|
|
33
|
+
type: DefinitionPropertyTypeSchema,
|
|
34
|
+
description: zod.z.string().optional(),
|
|
35
|
+
group: zod.z.string().optional(),
|
|
36
|
+
})),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const uuidKeySchema = zod.z
|
|
40
|
+
.string()
|
|
41
|
+
.regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
|
|
42
|
+
/**
|
|
43
|
+
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
44
|
+
* property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
|
|
45
|
+
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
46
|
+
*/
|
|
47
|
+
const propertyKeySchema = zod.z
|
|
48
|
+
.string()
|
|
49
|
+
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
50
|
+
const DataSourceSchema = zod.z.record(uuidKeySchema, zod.z.object({
|
|
51
|
+
sys: zod.z.object({
|
|
52
|
+
type: zod.z.literal('Link'),
|
|
53
|
+
id: zod.z.string(),
|
|
54
|
+
linkType: zod.z.enum(['Entry', 'Asset']),
|
|
55
|
+
}),
|
|
56
|
+
}));
|
|
57
|
+
const PrimitiveValueSchema = zod.z.union([
|
|
58
|
+
zod.z.string(),
|
|
59
|
+
zod.z.boolean(),
|
|
60
|
+
zod.z.number(),
|
|
61
|
+
zod.z.record(zod.z.any(), zod.z.any()),
|
|
62
|
+
zod.z.undefined(),
|
|
63
|
+
]);
|
|
64
|
+
const ValuesByBreakpointSchema = zod.z.record(zod.z.lazy(() => PrimitiveValueSchema));
|
|
65
|
+
const DesignValueSchema = zod.z
|
|
66
|
+
.object({
|
|
67
|
+
type: zod.z.literal('DesignValue'),
|
|
68
|
+
valuesByBreakpoint: ValuesByBreakpointSchema,
|
|
69
|
+
})
|
|
70
|
+
.strict();
|
|
71
|
+
const BoundValueSchema = zod.z
|
|
72
|
+
.object({
|
|
73
|
+
type: zod.z.literal('BoundValue'),
|
|
74
|
+
path: zod.z.string(),
|
|
75
|
+
})
|
|
76
|
+
.strict();
|
|
77
|
+
const HyperlinkValueSchema = zod.z
|
|
78
|
+
.object({
|
|
79
|
+
type: zod.z.literal('HyperlinkValue'),
|
|
80
|
+
linkTargetKey: zod.z.string(),
|
|
81
|
+
overrides: zod.z.object({}).optional(),
|
|
82
|
+
})
|
|
83
|
+
.strict();
|
|
84
|
+
const UnboundValueSchema = zod.z
|
|
85
|
+
.object({
|
|
86
|
+
type: zod.z.literal('UnboundValue'),
|
|
87
|
+
key: zod.z.string(),
|
|
88
|
+
})
|
|
89
|
+
.strict();
|
|
90
|
+
const ComponentValueSchema = zod.z
|
|
91
|
+
.object({
|
|
92
|
+
type: zod.z.literal('ComponentValue'),
|
|
93
|
+
key: zod.z.string(),
|
|
94
|
+
})
|
|
95
|
+
.strict();
|
|
96
|
+
const ComponentPropertyValueSchema = zod.z.discriminatedUnion('type', [
|
|
97
|
+
DesignValueSchema,
|
|
98
|
+
BoundValueSchema,
|
|
99
|
+
UnboundValueSchema,
|
|
100
|
+
HyperlinkValueSchema,
|
|
101
|
+
ComponentValueSchema,
|
|
102
|
+
]);
|
|
103
|
+
const BreakpointSchema = zod.z
|
|
104
|
+
.object({
|
|
105
|
+
id: propertyKeySchema,
|
|
106
|
+
query: zod.z.string().regex(/^\*$|^<[0-9*]+px$/),
|
|
107
|
+
previewSize: zod.z.string(),
|
|
108
|
+
displayName: zod.z.string(),
|
|
109
|
+
displayIcon: zod.z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
const UnboundValuesSchema = zod.z.record(uuidKeySchema, zod.z.object({
|
|
113
|
+
value: PrimitiveValueSchema,
|
|
114
|
+
}));
|
|
115
|
+
// Use helper schema to define a recursive schema with its type correctly below
|
|
116
|
+
const BaseComponentTreeNodeSchema = zod.z.object({
|
|
117
|
+
definitionId: DefinitionPropertyKeySchema,
|
|
118
|
+
displayName: zod.z.string().optional(),
|
|
119
|
+
slotId: zod.z.string().optional(),
|
|
120
|
+
variables: zod.z.record(propertyKeySchema, ComponentPropertyValueSchema),
|
|
121
|
+
});
|
|
122
|
+
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
123
|
+
children: zod.z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
124
|
+
});
|
|
125
|
+
const ComponentSettingsSchema = zod.z.object({
|
|
126
|
+
variableDefinitions: zod.z.record(zod.z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
127
|
+
zod.z.object({
|
|
128
|
+
displayName: zod.z.string().optional(),
|
|
129
|
+
type: DefinitionPropertyTypeSchema,
|
|
130
|
+
defaultValue: PrimitiveValueSchema.or(ComponentPropertyValueSchema).optional(),
|
|
131
|
+
description: zod.z.string().optional(),
|
|
132
|
+
group: zod.z.string().optional(),
|
|
133
|
+
validations: zod.z
|
|
134
|
+
.object({
|
|
135
|
+
required: zod.z.boolean().optional(),
|
|
136
|
+
format: zod.z.literal('URL').optional(),
|
|
137
|
+
in: zod.z
|
|
138
|
+
.array(zod.z.object({
|
|
139
|
+
value: zod.z.union([zod.z.string(), zod.z.number()]),
|
|
140
|
+
displayName: zod.z.string().optional(),
|
|
141
|
+
}))
|
|
142
|
+
.optional(),
|
|
143
|
+
})
|
|
144
|
+
.optional(),
|
|
145
|
+
})),
|
|
146
|
+
});
|
|
147
|
+
const UsedComponentsSchema = zod.z.array(zod.z.object({
|
|
148
|
+
sys: zod.z.object({
|
|
149
|
+
type: zod.z.literal('Link'),
|
|
150
|
+
id: zod.z.string(),
|
|
151
|
+
linkType: zod.z.literal('Entry'),
|
|
152
|
+
}),
|
|
153
|
+
}));
|
|
154
|
+
const breakpointsRefinement = (value, ctx) => {
|
|
155
|
+
if (!value.length || value[0].query !== '*') {
|
|
156
|
+
ctx.addIssue({
|
|
157
|
+
code: zod.z.ZodIssueCode.custom,
|
|
158
|
+
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
162
|
+
// check if the current breakpoint id is found in the rest of the array
|
|
163
|
+
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
164
|
+
return breakpointIndex !== currentBreakpointIndex;
|
|
165
|
+
});
|
|
166
|
+
if (hasDuplicateIds) {
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: zod.z.ZodIssueCode.custom,
|
|
169
|
+
message: `Breakpoint IDs must be unique`,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
// Extract the queries boundary by removing the special characters around it
|
|
173
|
+
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
174
|
+
// sort updates queries array in place so we need to create a copy
|
|
175
|
+
const originalQueries = [...queries];
|
|
176
|
+
queries.sort((q1, q2) => {
|
|
177
|
+
if (q1 === '*') {
|
|
178
|
+
return -1;
|
|
179
|
+
}
|
|
180
|
+
if (q2 === '*') {
|
|
181
|
+
return 1;
|
|
182
|
+
}
|
|
183
|
+
return q1 > q2 ? -1 : 1;
|
|
184
|
+
});
|
|
185
|
+
if (originalQueries.join('') !== queries.join('')) {
|
|
186
|
+
ctx.addIssue({
|
|
187
|
+
code: zod.z.ZodIssueCode.custom,
|
|
188
|
+
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const componentSettingsRefinement = (value, ctx) => {
|
|
193
|
+
const { componentSettings, usedComponents } = value;
|
|
194
|
+
if (!componentSettings || !usedComponents) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const localeKey = Object.keys(componentSettings ?? {})[0];
|
|
198
|
+
if (componentSettings[localeKey] !== undefined && usedComponents[localeKey] !== undefined) {
|
|
199
|
+
ctx.addIssue({
|
|
200
|
+
code: zod.z.ZodIssueCode.custom,
|
|
201
|
+
message: `'componentSettings' field cannot be used in conjunction with 'usedComponents' field`,
|
|
202
|
+
path: ['componentSettings', localeKey],
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const ComponentTreeSchema = zod.z
|
|
207
|
+
.object({
|
|
208
|
+
breakpoints: zod.z.array(BreakpointSchema).superRefine(breakpointsRefinement),
|
|
209
|
+
children: zod.z.array(ComponentTreeNodeSchema),
|
|
210
|
+
schemaVersion: SchemaVersions,
|
|
211
|
+
})
|
|
212
|
+
.strict();
|
|
213
|
+
const localeWrapper = (fieldSchema) => zod.z.record(zod.z.string(), fieldSchema);
|
|
214
|
+
const ExperienceFieldsCMAShapeSchema = zod.z
|
|
215
|
+
.object({
|
|
216
|
+
componentTree: localeWrapper(ComponentTreeSchema),
|
|
217
|
+
dataSource: localeWrapper(DataSourceSchema),
|
|
218
|
+
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
219
|
+
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
220
|
+
componentSettings: localeWrapper(ComponentSettingsSchema).optional(),
|
|
221
|
+
})
|
|
222
|
+
.superRefine(componentSettingsRefinement);
|
|
223
|
+
|
|
224
|
+
var CodeNames;
|
|
225
|
+
(function (CodeNames) {
|
|
226
|
+
CodeNames["Type"] = "type";
|
|
227
|
+
CodeNames["Required"] = "required";
|
|
228
|
+
CodeNames["Unexpected"] = "unexpected";
|
|
229
|
+
CodeNames["Regex"] = "regex";
|
|
230
|
+
CodeNames["In"] = "in";
|
|
231
|
+
CodeNames["Size"] = "size";
|
|
232
|
+
CodeNames["Custom"] = "custom";
|
|
233
|
+
})(CodeNames || (CodeNames = {}));
|
|
234
|
+
const convertInvalidType = (issue) => {
|
|
235
|
+
const name = issue.received === 'undefined' ? CodeNames.Required : CodeNames.Type;
|
|
236
|
+
const details = issue.received === 'undefined'
|
|
237
|
+
? `The property "${issue.path.slice(-1)}" is required here`
|
|
238
|
+
: `The type of "${issue.path.slice(-1)}" is incorrect, expected type: ${issue.expected}`;
|
|
239
|
+
return {
|
|
240
|
+
details: details,
|
|
241
|
+
name: name,
|
|
242
|
+
path: issue.path,
|
|
243
|
+
value: issue.received.toString(),
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
const convertUnrecognizedKeys = (issue) => {
|
|
247
|
+
const missingProperties = issue.keys.map((k) => `"${k}"`).join(', ');
|
|
248
|
+
return {
|
|
249
|
+
details: issue.keys.length > 1
|
|
250
|
+
? `The properties ${missingProperties} are not expected`
|
|
251
|
+
: `The property ${missingProperties} is not expected`,
|
|
252
|
+
name: CodeNames.Unexpected,
|
|
253
|
+
path: issue.path,
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
const convertInvalidString = (issue) => {
|
|
257
|
+
return {
|
|
258
|
+
details: issue.message || 'Invalid string',
|
|
259
|
+
name: issue.validation === 'regex' ? CodeNames.Regex : CodeNames.Unexpected,
|
|
260
|
+
path: issue.path,
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
const convertInvalidEnumValue = (issue) => {
|
|
264
|
+
return {
|
|
265
|
+
details: issue.message || 'Value must be one of expected values',
|
|
266
|
+
name: CodeNames.In,
|
|
267
|
+
path: issue.path,
|
|
268
|
+
value: issue.received.toString(),
|
|
269
|
+
expected: issue.options,
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
const convertInvalidLiteral = (issue) => {
|
|
273
|
+
return {
|
|
274
|
+
details: issue.message || 'Value must be one of expected values',
|
|
275
|
+
name: CodeNames.In,
|
|
276
|
+
path: issue.path,
|
|
277
|
+
value: issue.received,
|
|
278
|
+
expected: [issue.expected],
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
const convertTooBig = (issue) => {
|
|
282
|
+
return {
|
|
283
|
+
details: issue.message || `Size should be at most ${issue.maximum}`,
|
|
284
|
+
name: CodeNames.Size,
|
|
285
|
+
path: issue.path,
|
|
286
|
+
max: issue.maximum,
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
const convertTooSmall = (issue) => {
|
|
290
|
+
return {
|
|
291
|
+
details: issue.message || `Size should be at least ${issue.minimum}`,
|
|
292
|
+
name: CodeNames.Size,
|
|
293
|
+
path: issue.path,
|
|
294
|
+
min: issue.minimum,
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
const defaultConversion = (issue) => {
|
|
298
|
+
return {
|
|
299
|
+
details: issue.message || 'An unexpected error occurred',
|
|
300
|
+
name: CodeNames.Custom,
|
|
301
|
+
path: issue.path.map(String),
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
const zodToContentfulError = (issue) => {
|
|
305
|
+
switch (issue.code) {
|
|
306
|
+
case zod.ZodIssueCode.invalid_type:
|
|
307
|
+
return convertInvalidType(issue);
|
|
308
|
+
case zod.ZodIssueCode.unrecognized_keys:
|
|
309
|
+
return convertUnrecognizedKeys(issue);
|
|
310
|
+
case zod.ZodIssueCode.invalid_enum_value:
|
|
311
|
+
return convertInvalidEnumValue(issue);
|
|
312
|
+
case zod.ZodIssueCode.invalid_string:
|
|
313
|
+
return convertInvalidString(issue);
|
|
314
|
+
case zod.ZodIssueCode.too_small:
|
|
315
|
+
return convertTooSmall(issue);
|
|
316
|
+
case zod.ZodIssueCode.too_big:
|
|
317
|
+
return convertTooBig(issue);
|
|
318
|
+
case zod.ZodIssueCode.invalid_literal:
|
|
319
|
+
return convertInvalidLiteral(issue);
|
|
320
|
+
default:
|
|
321
|
+
return defaultConversion(issue);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const VERSION_SCHEMAS = {
|
|
326
|
+
'2023-09-28': ExperienceFieldsCMAShapeSchema,
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
*
|
|
330
|
+
* @param experience The experience entry to validate
|
|
331
|
+
* @param schemaVersionOverride Optional override for the schema version to validate against. By default the schema version is read from the experience entry
|
|
332
|
+
* @returns object with success property and optional errors array
|
|
333
|
+
*/
|
|
334
|
+
const validateExperienceFields = (experience, schemaVersionOverride) => {
|
|
335
|
+
let schemaVersion;
|
|
336
|
+
if (experience.fields.componentTree) {
|
|
337
|
+
const locale = Object.keys(experience.fields.componentTree)[0];
|
|
338
|
+
schemaVersion = experience.fields.componentTree[locale].schemaVersion;
|
|
339
|
+
}
|
|
340
|
+
const schema = VERSION_SCHEMAS[schemaVersionOverride || schemaVersion];
|
|
341
|
+
if (!schema) {
|
|
342
|
+
return {
|
|
343
|
+
success: false,
|
|
344
|
+
errors: [
|
|
345
|
+
{
|
|
346
|
+
name: schemaVersion ? CodeNames.In : CodeNames.Required,
|
|
347
|
+
expected: ['2023-09-28'],
|
|
348
|
+
value: schemaVersion,
|
|
349
|
+
path: ['fields', 'componentTree', 'schemaVersion'],
|
|
350
|
+
details: schemaVersion
|
|
351
|
+
? 'Unsupported schema version'
|
|
352
|
+
: 'The property "schemaVersion" is required here',
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const fieldsToValidate = {
|
|
358
|
+
componentTree: experience.fields.componentTree,
|
|
359
|
+
dataSource: experience.fields.dataSource,
|
|
360
|
+
unboundValues: experience.fields.unboundValues,
|
|
361
|
+
usedComponents: experience.fields.usedComponents,
|
|
362
|
+
componentSettings: experience.fields.componentSettings,
|
|
363
|
+
};
|
|
364
|
+
const result = schema.safeParse(fieldsToValidate);
|
|
365
|
+
if (!result.success) {
|
|
366
|
+
return {
|
|
367
|
+
success: result.success,
|
|
368
|
+
errors: result.error.issues.map(zodToContentfulError),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
return { success: true };
|
|
372
|
+
};
|
|
373
|
+
const validateComponentDefinition = (definition) => {
|
|
374
|
+
const result = ComponentDefinitionSchema.safeParse(definition);
|
|
375
|
+
if (!result.success) {
|
|
376
|
+
return {
|
|
377
|
+
success: false,
|
|
378
|
+
errors: result.error.issues.map(zodToContentfulError),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
return { success: true };
|
|
382
|
+
};
|
|
383
|
+
const validateBreakpointsDefinition = (breakpoints) => {
|
|
384
|
+
const result = zod.z
|
|
385
|
+
.array(BreakpointSchema)
|
|
386
|
+
.superRefine(breakpointsRefinement)
|
|
387
|
+
.safeParse(breakpoints);
|
|
388
|
+
if (!result.success) {
|
|
389
|
+
return {
|
|
390
|
+
success: false,
|
|
391
|
+
errors: result.error.issues.map(zodToContentfulError),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
return { success: true };
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
exports.ComponentDefinitionSchema = ComponentDefinitionSchema;
|
|
398
|
+
exports.Schema_2023_09_28 = ExperienceFieldsCMAShapeSchema;
|
|
399
|
+
exports.validateBreakpointsDefinition = validateBreakpointsDefinition;
|
|
400
|
+
exports.validateComponentDefinition = validateComponentDefinition;
|
|
401
|
+
exports.validateExperienceFields = validateExperienceFields;
|
|
402
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/schemas/schemaVersions.ts","../src/schemas/componentDefinition.ts","../src/schemas/v2023_09_28/experience.ts","../src/utils/zodToContentfulError.ts","../src/validators.ts"],"sourcesContent":["import { z } from 'zod';\n// If more than one version is supported, use z.union\nexport const SchemaVersions = z.literal('2023-09-28');\n\nexport type SchemaVersions = z.infer<typeof SchemaVersions>;\n\n// Keep deprecated versions here just for reference\nexport const UnsupportedSchemaVersions = z.union([\n z.literal('2023-08-23'),\n z.literal('2023-07-26'),\n z.literal('2023-06-27'),\n]);\n","import { z } from 'zod';\n\nexport const DefinitionPropertyTypeSchema = z.enum([\n 'Text',\n 'RichText',\n 'Number',\n 'Date',\n 'Boolean',\n 'Location',\n 'Media',\n 'Object',\n 'Hyperlink',\n]);\n\nexport const DefinitionPropertyKeySchema = z\n .string()\n .regex(/^[a-zA-Z0-9-_]{1,32}$/, { message: 'Property needs to match: /^[a-zA-Z0-9-_]{1,32}$/' });\n\nexport const ComponentDefinitionSchema = z.object({\n id: DefinitionPropertyKeySchema,\n variables: z.record(\n DefinitionPropertyKeySchema,\n z.object({\n // TODO - extend with definition of validations and defaultValue\n displayName: z.string().optional(),\n type: DefinitionPropertyTypeSchema,\n description: z.string().optional(),\n group: z.string().optional(),\n }),\n ),\n});\n\nexport type ComponentDefinitionPropertyType = z.infer<typeof DefinitionPropertyTypeSchema>;\n","import { z } from 'zod';\nimport { SchemaVersions } from '../schemaVersions';\nimport { DefinitionPropertyTypeSchema, DefinitionPropertyKeySchema } from '../componentDefinition';\n\nconst uuidKeySchema = z\n .string()\n .regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });\n\n/**\n * Property keys for imported components have a limit of 32 characters (to be implemented) while\n * property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).\n * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.\n */\nconst propertyKeySchema = z\n .string()\n .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });\n\nconst DataSourceSchema = z.record(\n uuidKeySchema,\n z.object({\n sys: z.object({\n type: z.literal('Link'),\n id: z.string(),\n linkType: z.enum(['Entry', 'Asset']),\n }),\n }),\n);\n\nconst PrimitiveValueSchema = z.union([\n z.string(),\n z.boolean(),\n z.number(),\n z.record(z.any(), z.any()),\n z.undefined(),\n]);\n\nconst ValuesByBreakpointSchema = z.record(z.lazy(() => PrimitiveValueSchema));\n\nconst DesignValueSchema = z\n .object({\n type: z.literal('DesignValue'),\n valuesByBreakpoint: ValuesByBreakpointSchema,\n })\n .strict();\nconst BoundValueSchema = z\n .object({\n type: z.literal('BoundValue'),\n path: z.string(),\n })\n .strict();\nconst HyperlinkValueSchema = z\n .object({\n type: z.literal('HyperlinkValue'),\n linkTargetKey: z.string(),\n overrides: z.object({}).optional(),\n })\n .strict();\nconst UnboundValueSchema = z\n .object({\n type: z.literal('UnboundValue'),\n key: z.string(),\n })\n .strict();\nconst ComponentValueSchema = z\n .object({\n type: z.literal('ComponentValue'),\n key: z.string(),\n })\n .strict();\n\nconst ComponentPropertyValueSchema = z.discriminatedUnion('type', [\n DesignValueSchema,\n BoundValueSchema,\n UnboundValueSchema,\n HyperlinkValueSchema,\n ComponentValueSchema,\n]);\n\nexport type ComponentPropertyValue = z.infer<typeof ComponentPropertyValueSchema>;\n\nexport const BreakpointSchema = z\n .object({\n id: propertyKeySchema,\n query: z.string().regex(/^\\*$|^<[0-9*]+px$/),\n previewSize: z.string(),\n displayName: z.string(),\n displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),\n })\n .strict();\n\nconst UnboundValuesSchema = z.record(\n uuidKeySchema,\n z.object({\n value: PrimitiveValueSchema,\n }),\n);\n\n// Use helper schema to define a recursive schema with its type correctly below\nconst BaseComponentTreeNodeSchema = z.object({\n definitionId: DefinitionPropertyKeySchema,\n displayName: z.string().optional(),\n slotId: z.string().optional(),\n variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),\n});\nexport type ComponentTreeNode = z.infer<typeof BaseComponentTreeNodeSchema> & {\n children: ComponentTreeNode[];\n};\nconst ComponentTreeNodeSchema: z.ZodType<ComponentTreeNode> = BaseComponentTreeNodeSchema.extend({\n children: z.lazy(() => ComponentTreeNodeSchema.array()),\n});\n\nconst ComponentSettingsSchema = z.object({\n variableDefinitions: z.record(\n z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length\n z.object({\n displayName: z.string().optional(),\n type: DefinitionPropertyTypeSchema,\n defaultValue: PrimitiveValueSchema.or(ComponentPropertyValueSchema).optional(),\n description: z.string().optional(),\n group: z.string().optional(),\n validations: z\n .object({\n required: z.boolean().optional(),\n format: z.literal('URL').optional(),\n in: z\n .array(\n z.object({\n value: z.union([z.string(), z.number()]),\n displayName: z.string().optional(),\n }),\n )\n .optional(),\n })\n .optional(),\n }),\n ),\n});\n\nconst UsedComponentsSchema = z.array(\n z.object({\n sys: z.object({\n type: z.literal('Link'),\n id: z.string(),\n linkType: z.literal('Entry'),\n }),\n }),\n);\n\nexport const breakpointsRefinement = (value: Breakpoint[], ctx: z.RefinementCtx) => {\n if (!value.length || value[0].query !== '*') {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `The first breakpoint should include the following attributes: { \"query\": \"*\" }`,\n });\n }\n\n const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {\n // check if the current breakpoint id is found in the rest of the array\n const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);\n return breakpointIndex !== currentBreakpointIndex;\n });\n\n if (hasDuplicateIds) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Breakpoint IDs must be unique`,\n });\n }\n // Extract the queries boundary by removing the special characters around it\n const queries = value.map((bp) =>\n bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')),\n );\n // sort updates queries array in place so we need to create a copy\n const originalQueries = [...queries];\n queries.sort((q1, q2) => {\n if (q1 === '*') {\n return -1;\n }\n if (q2 === '*') {\n return 1;\n }\n return q1 > q2 ? -1 : 1;\n });\n\n if (originalQueries.join('') !== queries.join('')) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Breakpoints should be ordered from largest to smallest pixel value`,\n });\n }\n};\n\nconst componentSettingsRefinement = (value, ctx: z.RefinementCtx) => {\n const { componentSettings, usedComponents } = value as ExperienceFields;\n\n if (!componentSettings || !usedComponents) {\n return;\n }\n const localeKey = Object.keys(componentSettings ?? {})[0];\n\n if (componentSettings[localeKey] !== undefined && usedComponents[localeKey] !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `'componentSettings' field cannot be used in conjunction with 'usedComponents' field`,\n path: ['componentSettings', localeKey],\n });\n }\n};\n\nconst ComponentTreeSchema = z\n .object({\n breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),\n children: z.array(ComponentTreeNodeSchema),\n schemaVersion: SchemaVersions,\n })\n .strict();\n\nconst localeWrapper = (fieldSchema: any) => z.record(z.string(), fieldSchema);\n\nexport const ExperienceFieldsCMAShapeSchema = z\n .object({\n componentTree: localeWrapper(ComponentTreeSchema),\n dataSource: localeWrapper(DataSourceSchema),\n unboundValues: localeWrapper(UnboundValuesSchema),\n usedComponents: localeWrapper(UsedComponentsSchema).optional(),\n componentSettings: localeWrapper(ComponentSettingsSchema).optional(),\n })\n .superRefine(componentSettingsRefinement);\n\nexport type ExperienceFields = z.infer<typeof ExperienceFieldsCMAShapeSchema>;\nexport type ExperienceDataSource = z.infer<typeof DataSourceSchema>;\nexport type ExperienceUnboundValues = z.infer<typeof UnboundValuesSchema>;\nexport type ExperienceUsedComponents = z.infer<typeof UsedComponentsSchema>;\nexport type ExperienceComponentSettings = z.infer<typeof ComponentSettingsSchema>;\nexport type ExperienceComponentTree = z.infer<typeof ComponentTreeSchema>;\nexport type ValuesByBreakpoint = z.infer<typeof ValuesByBreakpointSchema>;\nexport type Breakpoint = z.infer<typeof BreakpointSchema>;\nexport type PrimitiveValue = z.infer<typeof PrimitiveValueSchema>;\nexport type DesignValue = z.infer<typeof DesignValueSchema>;\nexport type BoundValue = z.infer<typeof BoundValueSchema>;\nexport type UnboundValue = z.infer<typeof UnboundValueSchema>;\nexport type ComponentValue = z.infer<typeof ComponentValueSchema>;\n","import { ZodIssueCode, ZodIssue, z } from 'zod';\n\nexport enum CodeNames {\n Type = 'type',\n Required = 'required',\n Unexpected = 'unexpected',\n Regex = 'regex',\n In = 'in',\n Size = 'size',\n Custom = 'custom',\n}\n\nexport type ContentfulErrorDetails = {\n details: string;\n min?: number | bigint;\n max?: number | bigint;\n name: (typeof CodeNames)[keyof typeof CodeNames];\n path: (string | number)[];\n value?: string;\n expected?: (string | number)[];\n};\n\nconst convertInvalidType = (issue: z.ZodInvalidTypeIssue): ContentfulErrorDetails => {\n const name = issue.received === 'undefined' ? CodeNames.Required : CodeNames.Type;\n const details =\n issue.received === 'undefined'\n ? `The property \"${issue.path.slice(-1)}\" is required here`\n : `The type of \"${issue.path.slice(-1)}\" is incorrect, expected type: ${issue.expected}`;\n\n return {\n details: details,\n name: name,\n path: issue.path,\n value: issue.received.toString(),\n };\n};\n\nconst convertUnrecognizedKeys = (issue: z.ZodUnrecognizedKeysIssue): ContentfulErrorDetails => {\n const missingProperties = issue.keys.map((k) => `\"${k}\"`).join(', ');\n return {\n details:\n issue.keys.length > 1\n ? `The properties ${missingProperties} are not expected`\n : `The property ${missingProperties} is not expected`,\n name: CodeNames.Unexpected,\n path: issue.path,\n };\n};\n\nconst convertInvalidString = (issue: z.ZodInvalidStringIssue): ContentfulErrorDetails => {\n return {\n details: issue.message || 'Invalid string',\n name: issue.validation === 'regex' ? CodeNames.Regex : CodeNames.Unexpected,\n path: issue.path,\n };\n};\nconst convertInvalidEnumValue = (issue: z.ZodInvalidEnumValueIssue): ContentfulErrorDetails => {\n return {\n details: issue.message || 'Value must be one of expected values',\n name: CodeNames.In,\n path: issue.path,\n value: issue.received.toString(),\n expected: issue.options,\n };\n};\nconst convertInvalidLiteral = (issue: z.ZodInvalidLiteralIssue): ContentfulErrorDetails => {\n return {\n details: issue.message || 'Value must be one of expected values',\n name: CodeNames.In,\n path: issue.path,\n value: issue.received as string,\n expected: [issue.expected as string],\n };\n};\n\nconst convertTooBig = (issue: z.ZodTooBigIssue): ContentfulErrorDetails => {\n return {\n details: issue.message || `Size should be at most ${issue.maximum}`,\n name: CodeNames.Size,\n path: issue.path,\n max: issue.maximum,\n };\n};\n\nconst convertTooSmall = (issue: z.ZodTooSmallIssue): ContentfulErrorDetails => {\n return {\n details: issue.message || `Size should be at least ${issue.minimum}`,\n name: CodeNames.Size,\n path: issue.path,\n min: issue.minimum,\n };\n};\nconst defaultConversion = (issue: ZodIssue): ContentfulErrorDetails => {\n return {\n details: issue.message || 'An unexpected error occurred',\n name: CodeNames.Custom,\n path: issue.path.map(String),\n };\n};\n\nexport const zodToContentfulError = (issue: ZodIssue): ContentfulErrorDetails => {\n switch (issue.code) {\n case ZodIssueCode.invalid_type:\n return convertInvalidType(issue);\n case ZodIssueCode.unrecognized_keys:\n return convertUnrecognizedKeys(issue);\n case ZodIssueCode.invalid_enum_value:\n return convertInvalidEnumValue(issue);\n case ZodIssueCode.invalid_string:\n return convertInvalidString(issue);\n case ZodIssueCode.too_small:\n return convertTooSmall(issue);\n case ZodIssueCode.too_big:\n return convertTooBig(issue);\n case ZodIssueCode.invalid_literal:\n return convertInvalidLiteral(issue);\n default:\n return defaultConversion(issue);\n }\n};\n","import { z } from 'zod';\nimport { Schema_2023_09_28, ComponentDefinitionSchema } from './schemas';\nimport {\n ContentfulErrorDetails,\n zodToContentfulError,\n CodeNames,\n} from './utils/zodToContentfulError';\n\nimport { type SchemaVersions } from './types';\nimport { BreakpointSchema, breakpointsRefinement } from './schemas/latest';\n\nconst VERSION_SCHEMAS = {\n '2023-09-28': Schema_2023_09_28,\n};\n\ntype ValidatorReturnValue = {\n success: boolean;\n errors?: ContentfulErrorDetails[];\n};\n\n/**\n *\n * @param experience The experience entry to validate\n * @param schemaVersionOverride Optional override for the schema version to validate against. By default the schema version is read from the experience entry\n * @returns object with success property and optional errors array\n */\nexport const validateExperienceFields = (\n experience: any,\n schemaVersionOverride?: SchemaVersions,\n): ValidatorReturnValue => {\n let schemaVersion;\n if (experience.fields.componentTree) {\n const locale = Object.keys(experience.fields.componentTree)[0];\n schemaVersion = experience.fields.componentTree[locale].schemaVersion;\n }\n const schema = VERSION_SCHEMAS[schemaVersionOverride || schemaVersion];\n\n if (!schema) {\n return {\n success: false,\n errors: [\n {\n name: schemaVersion ? CodeNames.In : CodeNames.Required,\n expected: ['2023-09-28'],\n value: schemaVersion,\n path: ['fields', 'componentTree', 'schemaVersion'],\n details: schemaVersion\n ? 'Unsupported schema version'\n : 'The property \"schemaVersion\" is required here',\n },\n ],\n };\n }\n\n const fieldsToValidate = {\n componentTree: experience.fields.componentTree,\n dataSource: experience.fields.dataSource,\n unboundValues: experience.fields.unboundValues,\n usedComponents: experience.fields.usedComponents,\n componentSettings: experience.fields.componentSettings,\n };\n\n const result = schema.safeParse(fieldsToValidate);\n if (!result.success) {\n return {\n success: result.success,\n errors: result.error.issues.map(zodToContentfulError),\n };\n }\n return { success: true };\n};\n\nexport const validateComponentDefinition = (definition): ValidatorReturnValue => {\n const result = ComponentDefinitionSchema.safeParse(definition);\n if (!result.success) {\n return {\n success: false,\n errors: result.error.issues.map(zodToContentfulError),\n };\n }\n return { success: true };\n};\n\nexport const validateBreakpointsDefinition = (breakpoints): ValidatorReturnValue => {\n const result = z\n .array(BreakpointSchema)\n .superRefine(breakpointsRefinement)\n .safeParse(breakpoints);\n if (!result.success) {\n return {\n success: false,\n errors: result.error.issues.map(zodToContentfulError),\n };\n }\n return { success: true };\n};\n"],"names":["z","ZodIssueCode","Schema_2023_09_28"],"mappings":";;;;AACA;AACO,MAAM,cAAc,GAAGA,KAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAItD;AACyCA,KAAC,CAAC,KAAK,CAAC;AAC/C,IAAAA,KAAC,CAAC,OAAO,CAAC,YAAY,CAAC;AACvB,IAAAA,KAAC,CAAC,OAAO,CAAC,YAAY,CAAC;AACvB,IAAAA,KAAC,CAAC,OAAO,CAAC,YAAY,CAAC;AACxB,CAAA;;ACTM,MAAM,4BAA4B,GAAGA,KAAC,CAAC,IAAI,CAAC;IACjD,MAAM;IACN,UAAU;IACV,QAAQ;IACR,MAAM;IACN,SAAS;IACT,UAAU;IACV,OAAO;IACP,QAAQ;IACR,WAAW;AACZ,CAAA,CAAC,CAAC;AAEI,MAAM,2BAA2B,GAAGA,KAAC;AACzC,KAAA,MAAM,EAAE;KACR,KAAK,CAAC,uBAAuB,EAAE,EAAE,OAAO,EA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