@strapi/content-type-builder 5.52.0 → 5.52.2

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.
@@ -1,17 +1,37 @@
1
1
  'use strict';
2
2
 
3
- var zod = require('zod');
3
+ var z = require('zod/v4');
4
4
  var utils = require('@strapi/utils');
5
5
  var fp = require('lodash/fp');
6
6
  var builder = require('../../services/builder.js');
7
7
  var constants = require('../../services/constants.js');
8
8
  var common = require('./common.js');
9
9
 
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var z__namespace = /*#__PURE__*/_interopNamespace(z);
29
+
10
30
  const uniqueAttributeName = (attributes, ctx)=>{
11
31
  const names = new Set(attributes.map((attribute)=>fp.snakeCase(attribute.name)));
12
32
  if (names.size !== attributes.length) {
13
33
  ctx.addIssue({
14
- code: zod.z.ZodIssueCode.custom,
34
+ code: 'custom',
15
35
  message: 'Attributes must have unique names'
16
36
  });
17
37
  }
@@ -28,13 +48,13 @@ const verifyUidTargetField = (attributes, ctx)=>{
28
48
  // NOTE: on update we are setting it to undefined later in the process instead to handle renames
29
49
  if (action === 'create') {
30
50
  ctx.addIssue({
31
- code: zod.z.ZodIssueCode.custom,
51
+ code: 'custom',
32
52
  message: 'Target does not exist'
33
53
  });
34
54
  }
35
55
  } else if (!constants.VALID_UID_TARGETS.some((validUIdTarget)=>validUIdTarget === targetAttr.properties?.type)) {
36
56
  ctx.addIssue({
37
- code: zod.z.ZodIssueCode.custom,
57
+ code: 'custom',
38
58
  message: 'Invalid target type'
39
59
  });
40
60
  }
@@ -48,7 +68,7 @@ const verifySingularAndPluralNames = (obj, ctx)=>{
48
68
  }
49
69
  if (obj.singularName === obj.pluralName) {
50
70
  ctx.addIssue({
51
- code: zod.z.ZodIssueCode.custom,
71
+ code: 'custom',
52
72
  message: 'Singular and plural names must be different',
53
73
  path: [
54
74
  'singularName'
@@ -83,7 +103,7 @@ const verifyDraftAndPublishReservedAttributes = (contentType, ctx)=>{
83
103
  const reservedAttributeNames = utils.contentTypes.findDraftAndPublishReservedAttributeNames(getEffectiveAttributeNames(contentType));
84
104
  if (reservedAttributeNames.length > 0) {
85
105
  ctx.addIssue({
86
- code: zod.z.ZodIssueCode.custom,
106
+ code: 'custom',
87
107
  message: utils.contentTypes.getDraftAndPublishEnableBlockedMessage(reservedAttributeNames),
88
108
  path: [
89
109
  'draftAndPublish'
@@ -95,7 +115,7 @@ const maxLengthGreaterThanMinLength = (value, ctx)=>{
95
115
  if (!fp.isNil(value.maxLength) && !fp.isNil(value.minLength) && fp.isNumber(value.maxLength) && fp.isNumber(value.minLength)) {
96
116
  if (value.maxLength < value.minLength) {
97
117
  ctx.addIssue({
98
- code: zod.z.ZodIssueCode.custom,
118
+ code: 'custom',
99
119
  message: 'maxLength must be greater or equal to minLength',
100
120
  path: [
101
121
  'maxLength'
@@ -108,7 +128,7 @@ const maxGreaterThanMin = (value, ctx)=>{
108
128
  if (!fp.isNil(value.max) && !fp.isNil(value.min) && fp.isNumber(value.max) && fp.isNumber(value.min)) {
109
129
  if (value.max < value.min) {
110
130
  ctx.addIssue({
111
- code: zod.z.ZodIssueCode.custom,
131
+ code: 'custom',
112
132
  message: 'max must be greater or equal to min',
113
133
  path: [
114
134
  'max'
@@ -127,7 +147,7 @@ const checkUserTarget = (value, ctx)=>{
127
147
  const { target, relation, targetAttribute } = value;
128
148
  if (target === constants.coreUids.STRAPI_USER && (!STRAPI_USER_RELATIONS.includes(relation) || !fp.isUndefined(targetAttribute))) {
129
149
  ctx.addIssue({
130
- code: zod.z.ZodIssueCode.custom,
150
+ code: 'custom',
131
151
  path: [
132
152
  'relation'
133
153
  ],
@@ -138,7 +158,7 @@ const checkUserTarget = (value, ctx)=>{
138
158
  const uidRefinement = (value, ctx)=>{
139
159
  if (!fp.isNil(value.targetField) && !fp.isNil(value.default)) {
140
160
  ctx.addIssue({
141
- code: zod.z.ZodIssueCode.custom,
161
+ code: 'custom',
142
162
  message: 'Cannot define a default UID if the targetField is set',
143
163
  path: [
144
164
  'default'
@@ -150,7 +170,7 @@ const enumRefinement = (value, ctx)=>{
150
170
  if (value.type === 'enumeration' && !fp.isNil(value.default) && !fp.isNil(value.enum)) {
151
171
  if (value.default === '' || !value.enum.some((v)=>v === value.default)) {
152
172
  ctx.addIssue({
153
- code: zod.z.ZodIssueCode.custom,
173
+ code: 'custom',
154
174
  message: 'Default value must be one of the enum values',
155
175
  path: [
156
176
  'default'
@@ -159,11 +179,11 @@ const enumRefinement = (value, ctx)=>{
159
179
  }
160
180
  }
161
181
  };
162
- const conditionSchema = zod.z.object({
163
- visible: zod.z.record(zod.z.string(), zod.z.array(zod.z.any()))
182
+ const conditionSchema = z__namespace.object({
183
+ visible: z__namespace.record(z__namespace.string(), z__namespace.array(z__namespace.any()))
164
184
  });
165
- const basePropertiesSchema = zod.z.object({
166
- type: zod.z.enum([
185
+ const basePropertiesSchema = z__namespace.object({
186
+ type: z__namespace.enum([
167
187
  'string',
168
188
  'text',
169
189
  'richtext',
@@ -188,24 +208,24 @@ const basePropertiesSchema = zod.z.object({
188
208
  'relation',
189
209
  'dynamiczone'
190
210
  ]),
191
- configurable: zod.z.boolean().nullish(),
192
- private: zod.z.boolean().nullish(),
193
- pluginOptions: zod.z.record(zod.z.unknown()).optional(),
194
- conditions: zod.z.preprocess((val)=>{
211
+ configurable: z__namespace.boolean().nullish(),
212
+ private: z__namespace.boolean().nullish(),
213
+ pluginOptions: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional(),
214
+ conditions: z__namespace.preprocess((val)=>{
195
215
  return val;
196
216
  }, conditionSchema.optional())
197
217
  });
198
- const maxLengthSchema = zod.z.number().int().positive().optional();
199
- const minLengthSchema = zod.z.number().int().positive().optional();
200
- const requiredSchema = zod.z.boolean().optional();
201
- const uniqueSchema = zod.z.boolean().optional();
218
+ const maxLengthSchema = z__namespace.number().int().positive().optional();
219
+ const minLengthSchema = z__namespace.number().int().positive().optional();
220
+ const requiredSchema = z__namespace.boolean().optional();
221
+ const uniqueSchema = z__namespace.boolean().optional();
202
222
  const STRAPI_USER_RELATIONS = [
203
223
  'oneToOne',
204
224
  'oneToMany'
205
225
  ];
206
- const baseRelationSchema = zod.z.object({
207
- type: zod.z.literal('relation'),
208
- relation: zod.z.enum([
226
+ const baseRelationSchema = z__namespace.object({
227
+ type: z__namespace.literal('relation'),
228
+ relation: z__namespace.enum([
209
229
  'oneToOne',
210
230
  'oneToMany',
211
231
  'manyToOne',
@@ -215,57 +235,57 @@ const baseRelationSchema = zod.z.object({
215
235
  'morphToOne',
216
236
  'morphToMany'
217
237
  ]),
218
- configurable: zod.z.boolean().nullish(),
238
+ configurable: z__namespace.boolean().nullish(),
219
239
  required: requiredSchema,
220
- private: zod.z.boolean().nullish(),
221
- pluginOptions: zod.z.record(zod.z.unknown()).optional(),
222
- conditions: zod.z.preprocess((val)=>{
240
+ private: z__namespace.boolean().nullish(),
241
+ pluginOptions: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional(),
242
+ conditions: z__namespace.preprocess((val)=>{
223
243
  return val;
224
244
  }, conditionSchema.optional())
225
245
  });
226
246
  const oneToOneSchema = baseRelationSchema.extend({
227
- relation: zod.z.literal('oneToOne'),
228
- target: zod.z.string(),
229
- targetAttribute: zod.z.string().nullish()
247
+ relation: z__namespace.literal('oneToOne'),
248
+ target: z__namespace.string(),
249
+ targetAttribute: z__namespace.string().nullish()
230
250
  });
231
251
  const oneWaySchema = baseRelationSchema.extend({
232
- relation: zod.z.literal('oneToOne'),
233
- target: zod.z.string()
252
+ relation: z__namespace.literal('oneToOne'),
253
+ target: z__namespace.string()
234
254
  });
235
255
  const oneToManySchema = baseRelationSchema.extend({
236
- relation: zod.z.literal('oneToMany'),
237
- target: zod.z.string(),
238
- targetAttribute: zod.z.string().nullish()
256
+ relation: z__namespace.literal('oneToMany'),
257
+ target: z__namespace.string(),
258
+ targetAttribute: z__namespace.string().nullish()
239
259
  });
240
260
  const manyWaySchema = baseRelationSchema.extend({
241
- relation: zod.z.literal('oneToMany'),
242
- target: zod.z.string()
261
+ relation: z__namespace.literal('oneToMany'),
262
+ target: z__namespace.string()
243
263
  });
244
264
  const manyToOneSchema = baseRelationSchema.extend({
245
- relation: zod.z.literal('manyToOne'),
246
- target: zod.z.string(),
247
- targetAttribute: zod.z.string().nullish()
265
+ relation: z__namespace.literal('manyToOne'),
266
+ target: z__namespace.string(),
267
+ targetAttribute: z__namespace.string().nullish()
248
268
  });
249
269
  const manyToManySchema = baseRelationSchema.extend({
250
- relation: zod.z.literal('manyToMany'),
251
- target: zod.z.string(),
252
- targetAttribute: zod.z.string().nullish()
270
+ relation: z__namespace.literal('manyToMany'),
271
+ target: z__namespace.string(),
272
+ targetAttribute: z__namespace.string().nullish()
253
273
  });
254
274
  const morphOneSchema = baseRelationSchema.extend({
255
- relation: zod.z.literal('morphOne'),
256
- target: zod.z.string(),
257
- targetAttribute: zod.z.string().nullish()
275
+ relation: z__namespace.literal('morphOne'),
276
+ target: z__namespace.string(),
277
+ targetAttribute: z__namespace.string().nullish()
258
278
  });
259
279
  const morphManySchema = baseRelationSchema.extend({
260
- relation: zod.z.literal('morphMany'),
261
- target: zod.z.string(),
262
- targetAttribute: zod.z.string().nullish()
280
+ relation: z__namespace.literal('morphMany'),
281
+ target: z__namespace.string(),
282
+ targetAttribute: z__namespace.string().nullish()
263
283
  });
264
284
  const morphToOneSchema = baseRelationSchema.extend({
265
- relation: zod.z.literal('morphToOne')
285
+ relation: z__namespace.literal('morphToOne')
266
286
  });
267
287
  const morphToManySchema = baseRelationSchema.extend({
268
- relation: zod.z.literal('morphToMany')
288
+ relation: z__namespace.literal('morphToMany')
269
289
  });
270
290
  const createRelationSchema = (meta)=>{
271
291
  switch(meta.modelType){
@@ -273,7 +293,7 @@ const createRelationSchema = (meta)=>{
273
293
  {
274
294
  switch(meta.kind){
275
295
  case 'singleType':
276
- return zod.z.discriminatedUnion('relation', [
296
+ return z__namespace.discriminatedUnion('relation', [
277
297
  oneToOneSchema,
278
298
  oneToManySchema,
279
299
  morphOneSchema,
@@ -282,7 +302,7 @@ const createRelationSchema = (meta)=>{
282
302
  morphToManySchema
283
303
  ]);
284
304
  case 'collectionType':
285
- return zod.z.discriminatedUnion('relation', [
305
+ return z__namespace.discriminatedUnion('relation', [
286
306
  oneToOneSchema,
287
307
  oneToManySchema,
288
308
  manyToOneSchema,
@@ -298,7 +318,7 @@ const createRelationSchema = (meta)=>{
298
318
  }
299
319
  case 'component':
300
320
  {
301
- return zod.z.discriminatedUnion('relation', [
321
+ return z__namespace.discriminatedUnion('relation', [
302
322
  oneWaySchema,
303
323
  manyWaySchema
304
324
  ]);
@@ -308,20 +328,20 @@ const createRelationSchema = (meta)=>{
308
328
  }
309
329
  };
310
330
  const richTextSchema = basePropertiesSchema.extend({
311
- type: zod.z.literal('richtext'),
331
+ type: z__namespace.literal('richtext'),
312
332
  required: requiredSchema,
313
333
  minLength: minLengthSchema,
314
334
  maxLength: maxLengthSchema,
315
- default: zod.z.string().optional()
335
+ default: z__namespace.string().optional()
316
336
  });
317
337
  const blocksSchema = basePropertiesSchema.extend({
318
- type: zod.z.literal('blocks'),
338
+ type: z__namespace.literal('blocks'),
319
339
  required: requiredSchema
320
340
  });
321
341
  const jsonSchema = basePropertiesSchema.extend({
322
- type: zod.z.literal('json'),
342
+ type: z__namespace.literal('json'),
323
343
  required: requiredSchema,
324
- default: zod.z.unknown().optional().refine((value)=>{
344
+ default: z__namespace.unknown().optional().refine((value)=>{
325
345
  if (value === undefined) {
326
346
  return true;
327
347
  }
@@ -337,13 +357,13 @@ const jsonSchema = basePropertiesSchema.extend({
337
357
  })
338
358
  });
339
359
  const enumerationSchema = basePropertiesSchema.extend({
340
- type: zod.z.literal('enumeration'),
360
+ type: z__namespace.literal('enumeration'),
341
361
  required: requiredSchema,
342
- default: zod.z.string().optional(),
343
- enumName: zod.z.string().optional().refine((value)=>{
362
+ default: z__namespace.string().optional(),
363
+ enumName: z__namespace.string().optional().refine((value)=>{
344
364
  return value === '' || common.NAME_REGEX.test(value);
345
365
  }, 'Invalid enum name'),
346
- enum: zod.z.array(zod.z.string().refine((value)=>{
366
+ enum: z__namespace.array(z__namespace.string().refine((value)=>{
347
367
  return value === '' || !utils.strings.startsWithANumber(value);
348
368
  })).min(1).refine((values)=>{
349
369
  const filtered = [
@@ -353,105 +373,105 @@ const enumerationSchema = basePropertiesSchema.extend({
353
373
  })
354
374
  });
355
375
  const textSchema = basePropertiesSchema.extend({
356
- type: zod.z.literal('text'),
357
- default: zod.z.string().nullish(),
376
+ type: z__namespace.literal('text'),
377
+ default: z__namespace.string().nullish(),
358
378
  minLength: minLengthSchema,
359
379
  maxLength: maxLengthSchema,
360
380
  required: requiredSchema,
361
381
  unique: uniqueSchema,
362
- regex: zod.z.string().optional().refine((value)=>{
382
+ regex: z__namespace.string().optional().refine((value)=>{
363
383
  return value === '' || !!new RegExp(value);
364
384
  }, 'Invalid regular expression pattern')
365
385
  });
366
386
  const stringSchema = textSchema.extend({
367
- type: zod.z.literal('string')
387
+ type: z__namespace.literal('string')
368
388
  });
369
389
  const passwordSchema = basePropertiesSchema.extend({
370
- type: zod.z.literal('password'),
390
+ type: z__namespace.literal('password'),
371
391
  required: requiredSchema,
372
392
  minLength: minLengthSchema,
373
393
  maxLength: maxLengthSchema
374
394
  });
375
395
  const emailSchema = basePropertiesSchema.extend({
376
- type: zod.z.literal('email'),
396
+ type: z__namespace.literal('email'),
377
397
  required: requiredSchema,
378
398
  minLength: minLengthSchema,
379
399
  maxLength: maxLengthSchema,
380
- default: zod.z.string().email().optional(),
400
+ default: z__namespace.string().email().optional(),
381
401
  unique: uniqueSchema
382
402
  });
383
403
  const integerSchema = basePropertiesSchema.extend({
384
- type: zod.z.literal('integer'),
404
+ type: z__namespace.literal('integer'),
385
405
  required: requiredSchema,
386
- default: zod.z.number().int().optional(),
406
+ default: z__namespace.number().int().optional(),
387
407
  unique: uniqueSchema,
388
- min: zod.z.number().int().optional(),
389
- max: zod.z.number().int().optional()
408
+ min: z__namespace.number().int().optional(),
409
+ max: z__namespace.number().int().optional()
390
410
  });
391
411
  const bigIntegerSchema = basePropertiesSchema.extend({
392
- type: zod.z.literal('biginteger'),
412
+ type: z__namespace.literal('biginteger'),
393
413
  required: requiredSchema,
394
414
  unique: uniqueSchema,
395
- default: zod.z.string().regex(/^\d*$/).nullish(),
396
- min: zod.z.string().regex(/^\d*$/).nullish(),
397
- max: zod.z.string().regex(/^\d*$/).nullish()
415
+ default: z__namespace.string().regex(/^\d*$/).nullish(),
416
+ min: z__namespace.string().regex(/^\d*$/).nullish(),
417
+ max: z__namespace.string().regex(/^\d*$/).nullish()
398
418
  });
399
419
  const floatSchema = basePropertiesSchema.extend({
400
- type: zod.z.literal('float'),
420
+ type: z__namespace.literal('float'),
401
421
  required: requiredSchema,
402
422
  unique: uniqueSchema,
403
- default: zod.z.number().optional(),
404
- min: zod.z.number().optional(),
405
- max: zod.z.number().optional()
423
+ default: z__namespace.number().optional(),
424
+ min: z__namespace.number().optional(),
425
+ max: z__namespace.number().optional()
406
426
  });
407
427
  const decimalSchema = basePropertiesSchema.extend({
408
- type: zod.z.literal('decimal'),
428
+ type: z__namespace.literal('decimal'),
409
429
  required: requiredSchema,
410
430
  unique: uniqueSchema,
411
- default: zod.z.number().optional(),
412
- min: zod.z.number().optional(),
413
- max: zod.z.number().optional()
431
+ default: z__namespace.number().optional(),
432
+ min: z__namespace.number().optional(),
433
+ max: z__namespace.number().optional()
414
434
  });
415
435
  const timeSchema = basePropertiesSchema.extend({
416
- type: zod.z.literal('time'),
436
+ type: z__namespace.literal('time'),
417
437
  required: requiredSchema,
418
438
  unique: uniqueSchema,
419
- default: zod.z.string().optional()
439
+ default: z__namespace.string().optional()
420
440
  });
421
441
  const dateSchema = timeSchema.extend({
422
- type: zod.z.literal('date')
442
+ type: z__namespace.literal('date')
423
443
  });
424
444
  const dateTimeSchema = timeSchema.extend({
425
- type: zod.z.literal('datetime')
445
+ type: z__namespace.literal('datetime')
426
446
  });
427
447
  const timeStampSchema = basePropertiesSchema.extend({
428
- type: zod.z.literal('timestamp')
448
+ type: z__namespace.literal('timestamp')
429
449
  });
430
450
  const booleanSchema = basePropertiesSchema.extend({
431
- type: zod.z.literal('boolean'),
451
+ type: z__namespace.literal('boolean'),
432
452
  required: requiredSchema,
433
- default: zod.z.boolean().optional()
453
+ default: z__namespace.boolean().optional()
434
454
  });
435
455
  const componentSchema = basePropertiesSchema.extend({
436
- type: zod.z.literal('component'),
437
- component: zod.z.string(),
438
- repeatable: zod.z.boolean().optional(),
456
+ type: z__namespace.literal('component'),
457
+ component: z__namespace.string(),
458
+ repeatable: z__namespace.boolean().optional(),
439
459
  required: requiredSchema,
440
- min: zod.z.number().optional(),
441
- max: zod.z.number().optional()
460
+ min: z__namespace.number().optional(),
461
+ max: z__namespace.number().optional()
442
462
  });
443
463
  const dynamicZoneSchema = basePropertiesSchema.extend({
444
- type: zod.z.literal('dynamiczone'),
445
- components: zod.z.array(zod.z.string()).nonempty(),
464
+ type: z__namespace.literal('dynamiczone'),
465
+ components: z__namespace.array(z__namespace.string()).nonempty(),
446
466
  required: requiredSchema,
447
- min: zod.z.number().optional(),
448
- max: zod.z.number().optional()
467
+ min: z__namespace.number().optional(),
468
+ max: z__namespace.number().optional()
449
469
  });
450
470
  const mediaSchema = basePropertiesSchema.extend({
451
- type: zod.z.literal('media'),
452
- multiple: zod.z.boolean().optional(),
471
+ type: z__namespace.literal('media'),
472
+ multiple: z__namespace.boolean().optional(),
453
473
  required: requiredSchema,
454
- allowedTypes: zod.z.array(zod.z.enum([
474
+ allowedTypes: z__namespace.array(z__namespace.enum([
455
475
  'images',
456
476
  'videos',
457
477
  'files',
@@ -459,30 +479,30 @@ const mediaSchema = basePropertiesSchema.extend({
459
479
  ])).nonempty().optional()
460
480
  });
461
481
  const uidSchema = basePropertiesSchema.extend({
462
- type: zod.z.literal('uid'),
463
- targetField: zod.z.string().nullish(),
482
+ type: z__namespace.literal('uid'),
483
+ targetField: z__namespace.string().nullish(),
464
484
  required: requiredSchema,
465
- default: zod.z.string().nullish(),
485
+ default: z__namespace.string().nullish(),
466
486
  minLength: minLengthSchema,
467
487
  maxLength: maxLengthSchema,
468
- options: zod.z.object({
469
- separator: zod.z.string().optional(),
470
- lowercase: zod.z.boolean().optional(),
471
- decamelize: zod.z.boolean().optional(),
472
- customReplacements: zod.z.array(zod.z.array(zod.z.string()).length(2)).optional(),
473
- preserveLeadingUnderscore: zod.z.boolean().optional()
488
+ options: z__namespace.object({
489
+ separator: z__namespace.string().optional(),
490
+ lowercase: z__namespace.boolean().optional(),
491
+ decamelize: z__namespace.boolean().optional(),
492
+ customReplacements: z__namespace.array(z__namespace.array(z__namespace.string()).length(2)).optional(),
493
+ preserveLeadingUnderscore: z__namespace.boolean().optional()
474
494
  }).optional(),
475
- regex: zod.z.string().optional().refine((value)=>{
495
+ regex: z__namespace.string().optional().refine((value)=>{
476
496
  return value === '' || !!new RegExp(value);
477
497
  }, 'Invalid regular expression pattern')
478
498
  });
479
499
  const customFieldSchema = basePropertiesSchema.extend({
480
- type: zod.z.literal('customField'),
481
- customField: zod.z.string()
500
+ type: z__namespace.literal('customField'),
501
+ customField: z__namespace.string()
482
502
  });
483
503
  const attributePropertiesSchema = (meta)=>{
484
504
  const relationSchema = createRelationSchema(meta);
485
- const base = zod.z.union([
505
+ const base = z__namespace.union([
486
506
  mediaSchema,
487
507
  textSchema,
488
508
  stringSchema,
@@ -508,52 +528,52 @@ const attributePropertiesSchema = (meta)=>{
508
528
  if (meta.modelType === 'component') {
509
529
  return base.superRefine(enumRefinement).superRefine(checkUserTarget).superRefine(maxGreaterThanMin).superRefine(maxLengthGreaterThanMinLength);
510
530
  }
511
- return zod.z.union([
531
+ return z__namespace.union([
512
532
  ...base.options,
513
533
  uidSchema,
514
534
  dynamicZoneSchema
515
535
  ]).superRefine(enumRefinement).superRefine(checkUserTarget).superRefine(uidRefinement).superRefine(maxGreaterThanMin).superRefine(maxLengthGreaterThanMinLength);
516
536
  };
517
- const createAttributeSchema = (meta)=>zod.z.object({
518
- action: zod.z.literal('create'),
519
- name: zod.z.string().regex(common.NAME_REGEX).refine((value)=>!builder.isReservedAttributeName(value), 'Attribute name is reserved'),
537
+ const createAttributeSchema = (meta)=>z__namespace.object({
538
+ action: z__namespace.literal('create'),
539
+ name: z__namespace.string().regex(common.NAME_REGEX).refine((value)=>!builder.isReservedAttributeName(value), 'Attribute name is reserved'),
520
540
  properties: attributePropertiesSchema(meta)
521
541
  });
522
- const updateAttributeSchema = (meta)=>zod.z.object({
523
- action: zod.z.literal('update'),
524
- name: zod.z.string(),
542
+ const updateAttributeSchema = (meta)=>z__namespace.object({
543
+ action: z__namespace.literal('update'),
544
+ name: z__namespace.string(),
525
545
  properties: attributePropertiesSchema(meta)
526
546
  });
527
- const deleteAttributeSchema = zod.z.object({
528
- action: zod.z.literal('delete'),
529
- name: zod.z.string()
547
+ const deleteAttributeSchema = z__namespace.object({
548
+ action: z__namespace.literal('delete'),
549
+ name: z__namespace.string()
530
550
  });
531
- const contentTypeUIDSchema = zod.z.custom((value)=>{
551
+ const contentTypeUIDSchema = z__namespace.custom((value)=>{
532
552
  return typeof value === 'string' && value.length > 0;
533
553
  });
534
- const componentUIDSchema = zod.z.custom((value)=>{
554
+ const componentUIDSchema = z__namespace.custom((value)=>{
535
555
  return typeof value === 'string' && value.length > 0;
536
556
  });
537
- const categorySchema = zod.z.string().min(1).regex(common.CATEGORY_NAME_REGEX);
538
- const baseComponentSchema = zod.z.object({
557
+ const categorySchema = z__namespace.string().min(1).regex(common.CATEGORY_NAME_REGEX);
558
+ const baseComponentSchema = z__namespace.object({
539
559
  uid: componentUIDSchema,
540
- displayName: zod.z.string().min(1),
541
- icon: zod.z.string().regex(common.ICON_REGEX).optional(),
542
- description: zod.z.string().optional(),
560
+ displayName: z__namespace.string().min(1),
561
+ icon: z__namespace.string().regex(common.ICON_REGEX).optional(),
562
+ description: z__namespace.string().optional(),
543
563
  category: categorySchema,
544
- pluginOptions: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
564
+ pluginOptions: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional()
545
565
  });
546
566
  const createComponentSchema = baseComponentSchema.extend({
547
- action: zod.z.literal('create'),
548
- config: zod.z.record(zod.z.string(), zod.z.unknown()).optional().default({}),
549
- attributes: zod.z.array(createAttributeSchema({
567
+ action: z__namespace.literal('create'),
568
+ config: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional().default({}),
569
+ attributes: z__namespace.array(createAttributeSchema({
550
570
  modelType: 'component'
551
571
  })).superRefine(uniqueAttributeName)
552
572
  });
553
573
  const updateComponentSchema = baseComponentSchema.extend({
554
- action: zod.z.literal('update'),
574
+ action: z__namespace.literal('update'),
555
575
  category: categorySchema.optional(),
556
- attributes: zod.z.array(zod.z.discriminatedUnion('action', [
576
+ attributes: z__namespace.array(z__namespace.discriminatedUnion('action', [
557
577
  createAttributeSchema({
558
578
  modelType: 'component'
559
579
  }),
@@ -563,50 +583,50 @@ const updateComponentSchema = baseComponentSchema.extend({
563
583
  deleteAttributeSchema
564
584
  ])).superRefine(uniqueAttributeName)
565
585
  });
566
- const deleteComponentSchema = zod.z.object({
567
- action: zod.z.literal('delete'),
586
+ const deleteComponentSchema = z__namespace.object({
587
+ action: z__namespace.literal('delete'),
568
588
  uid: componentUIDSchema
569
589
  });
570
- const baseContentTypeSchema = zod.z.object({
590
+ const baseContentTypeSchema = z__namespace.object({
571
591
  uid: contentTypeUIDSchema,
572
- displayName: zod.z.string().min(1),
573
- description: zod.z.string().optional(),
574
- draftAndPublish: zod.z.boolean(),
575
- options: zod.z.record(zod.z.unknown()).optional().default({}),
576
- pluginOptions: zod.z.record(zod.z.unknown()).optional().default({}),
577
- kind: zod.z.enum([
592
+ displayName: z__namespace.string().min(1),
593
+ description: z__namespace.string().optional(),
594
+ draftAndPublish: z__namespace.boolean(),
595
+ options: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional().default({}),
596
+ pluginOptions: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional().default({}),
597
+ kind: z__namespace.enum([
578
598
  constants.typeKinds.SINGLE_TYPE,
579
599
  constants.typeKinds.COLLECTION_TYPE
580
600
  ]).optional()
581
601
  });
582
602
  const baseCreateContentTypeSchema = baseContentTypeSchema.extend({
583
- action: zod.z.literal('create'),
584
- plugin: zod.z.string().min(1).optional(),
585
- collectionName: zod.z.string().regex(common.COLLECTION_NAME_REGEX).optional(),
586
- singularName: zod.z.string().min(1).regex(common.KEBAB_BASE_REGEX, 'Must be kebab case').refine((value)=>!builder.isReservedModelName(value), 'Model name is reserved'),
587
- pluralName: zod.z.string().min(1).regex(common.KEBAB_BASE_REGEX, 'Must be kebab case').refine((value)=>!builder.isReservedModelName(value), 'Model name is reserved'),
588
- config: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
603
+ action: z__namespace.literal('create'),
604
+ plugin: z__namespace.string().min(1).optional(),
605
+ collectionName: z__namespace.string().regex(common.COLLECTION_NAME_REGEX).optional(),
606
+ singularName: z__namespace.string().min(1).regex(common.KEBAB_BASE_REGEX, 'Must be kebab case').refine((value)=>!builder.isReservedModelName(value), 'Model name is reserved'),
607
+ pluralName: z__namespace.string().min(1).regex(common.KEBAB_BASE_REGEX, 'Must be kebab case').refine((value)=>!builder.isReservedModelName(value), 'Model name is reserved'),
608
+ config: z__namespace.record(z__namespace.string(), z__namespace.unknown()).optional()
589
609
  });
590
610
  const createSingleTypeSchema = baseCreateContentTypeSchema.extend({
591
- kind: zod.z.literal(constants.typeKinds.SINGLE_TYPE),
592
- attributes: zod.z.array(createAttributeSchema({
611
+ kind: z__namespace.literal(constants.typeKinds.SINGLE_TYPE),
612
+ attributes: z__namespace.array(createAttributeSchema({
593
613
  modelType: 'contentType',
594
614
  kind: 'singleType'
595
615
  })).superRefine(uniqueAttributeName).superRefine(verifyUidTargetField)
596
616
  });
597
617
  const createCollectionTypeSchema = baseCreateContentTypeSchema.extend({
598
- kind: zod.z.literal(constants.typeKinds.COLLECTION_TYPE),
599
- attributes: zod.z.array(createAttributeSchema({
618
+ kind: z__namespace.literal(constants.typeKinds.COLLECTION_TYPE),
619
+ attributes: z__namespace.array(createAttributeSchema({
600
620
  modelType: 'contentType',
601
621
  kind: 'collectionType'
602
622
  })).superRefine(uniqueAttributeName).superRefine(verifyUidTargetField)
603
623
  });
604
624
  const baseUpdateContentTypeSchema = baseContentTypeSchema.extend({
605
- action: zod.z.literal('update')
625
+ action: z__namespace.literal('update')
606
626
  });
607
627
  const updateSingleTypeSchema = baseUpdateContentTypeSchema.extend({
608
- kind: zod.z.literal(constants.typeKinds.SINGLE_TYPE).optional(),
609
- attributes: zod.z.array(zod.z.discriminatedUnion('action', [
628
+ kind: z__namespace.literal(constants.typeKinds.SINGLE_TYPE).optional(),
629
+ attributes: z__namespace.array(z__namespace.discriminatedUnion('action', [
610
630
  createAttributeSchema({
611
631
  modelType: 'contentType',
612
632
  kind: 'singleType'
@@ -619,8 +639,8 @@ const updateSingleTypeSchema = baseUpdateContentTypeSchema.extend({
619
639
  ])).superRefine(uniqueAttributeName).superRefine(verifyUidTargetField)
620
640
  });
621
641
  const updateCollectionTypeSchema = baseUpdateContentTypeSchema.extend({
622
- kind: zod.z.literal(constants.typeKinds.COLLECTION_TYPE).optional(),
623
- attributes: zod.z.array(zod.z.union([
642
+ kind: z__namespace.literal(constants.typeKinds.COLLECTION_TYPE).optional(),
643
+ attributes: z__namespace.array(z__namespace.union([
624
644
  createAttributeSchema({
625
645
  modelType: 'contentType',
626
646
  kind: 'collectionType'
@@ -632,17 +652,17 @@ const updateCollectionTypeSchema = baseUpdateContentTypeSchema.extend({
632
652
  deleteAttributeSchema
633
653
  ])).superRefine(uniqueAttributeName).superRefine(verifyUidTargetField)
634
654
  });
635
- const deleteContentTypeSchema = zod.z.object({
636
- action: zod.z.literal('delete'),
655
+ const deleteContentTypeSchema = z__namespace.object({
656
+ action: z__namespace.literal('delete'),
637
657
  uid: contentTypeUIDSchema
638
658
  });
639
- const schemaSchema = zod.z.object({
640
- components: zod.z.array(zod.z.union([
659
+ const schemaSchema = z__namespace.object({
660
+ components: z__namespace.array(z__namespace.union([
641
661
  createComponentSchema,
642
662
  updateComponentSchema,
643
663
  deleteComponentSchema
644
664
  ])).optional().default([]),
645
- contentTypes: zod.z.array(zod.z.union([
665
+ contentTypes: z__namespace.array(z__namespace.union([
646
666
  createSingleTypeSchema,
647
667
  createCollectionTypeSchema,
648
668
  updateSingleTypeSchema,
@@ -650,13 +670,11 @@ const schemaSchema = zod.z.object({
650
670
  deleteContentTypeSchema
651
671
  ]).superRefine(verifySingularAndPluralNames).superRefine(verifyDraftAndPublishReservedAttributes)).optional().default([])
652
672
  });
653
- const updateSchemaInput = zod.z.object({
673
+ const updateSchemaInput = z__namespace.object({
654
674
  data: schemaSchema
655
675
  }, {
656
- invalid_type_error: 'Invalid schema, expected an object with a data property',
657
- required_error: 'Schema is required'
676
+ error: (issue)=>issue.input === undefined ? 'Schema is required' : 'Invalid schema, expected an object with a data property'
658
677
  });
659
- // TODO: Remove cast when content-type-builder migrates to Zod 4
660
678
  const validateUpdateSchema = utils.validateZodSchema(updateSchemaInput);
661
679
 
662
680
  exports.maxGreaterThanMin = maxGreaterThanMin;