@elek-io/core 0.14.3 → 0.15.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/browser/index.browser.d.ts +12112 -13651
- package/dist/browser/index.browser.js +257 -166
- package/dist/browser/index.browser.js.map +1 -1
- package/dist/node/index.node.d.ts +11447 -12986
- package/dist/node/index.node.js +393 -332
- package/dist/node/index.node.js.map +1 -1
- package/package.json +36 -27
|
@@ -67,21 +67,25 @@ var objectTypeSchema = z.enum([
|
|
|
67
67
|
]);
|
|
68
68
|
var logLevelSchema = z.enum(["error", "warn", "info", "debug"]);
|
|
69
69
|
var versionSchema = z.string();
|
|
70
|
-
var uuidSchema = z.
|
|
71
|
-
var translatableStringSchema = z.
|
|
70
|
+
var uuidSchema = z.uuid("shared.invalidUuid");
|
|
71
|
+
var translatableStringSchema = z.partialRecord(
|
|
72
72
|
supportedLanguageSchema,
|
|
73
73
|
z.string().trim().min(1, "shared.translatableStringRequired")
|
|
74
74
|
);
|
|
75
|
-
var translatableNumberSchema = z.
|
|
75
|
+
var translatableNumberSchema = z.partialRecord(
|
|
76
76
|
supportedLanguageSchema,
|
|
77
|
-
z.number({
|
|
77
|
+
z.number({
|
|
78
|
+
error: (error) => error.input === void 0 ? "shared.translatableNumberRequired" : "shared.translatableNumberNotANumber"
|
|
79
|
+
})
|
|
78
80
|
);
|
|
79
|
-
var translatableBooleanSchema = z.
|
|
81
|
+
var translatableBooleanSchema = z.partialRecord(
|
|
80
82
|
supportedLanguageSchema,
|
|
81
|
-
z.boolean({
|
|
83
|
+
z.boolean({
|
|
84
|
+
error: (error) => error.input === void 0 ? "shared.translatableBooleanRequired" : "shared.translatableBooleanNotABoolean"
|
|
85
|
+
})
|
|
82
86
|
);
|
|
83
87
|
function translatableArrayOf(schema) {
|
|
84
|
-
return z.
|
|
88
|
+
return z.partialRecord(supportedLanguageSchema, z.array(schema));
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
// src/schema/fileSchema.ts
|
|
@@ -231,7 +235,7 @@ var countGitTagsSchema = z3.object({
|
|
|
231
235
|
|
|
232
236
|
// src/schema/assetSchema.ts
|
|
233
237
|
var assetFileSchema = baseFileSchema.extend({
|
|
234
|
-
objectType: z4.literal(objectTypeSchema.
|
|
238
|
+
objectType: z4.literal(objectTypeSchema.enum.asset).readonly(),
|
|
235
239
|
name: z4.string(),
|
|
236
240
|
description: z4.string(),
|
|
237
241
|
extension: z4.string().readonly(),
|
|
@@ -312,13 +316,13 @@ var valueContentReferenceBase = z5.object({
|
|
|
312
316
|
id: uuidSchema
|
|
313
317
|
});
|
|
314
318
|
var valueContentReferenceToAssetSchema = valueContentReferenceBase.extend({
|
|
315
|
-
objectType: z5.literal(objectTypeSchema.
|
|
319
|
+
objectType: z5.literal(objectTypeSchema.enum.asset)
|
|
316
320
|
});
|
|
317
321
|
var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
|
|
318
|
-
objectType: z5.literal(objectTypeSchema.
|
|
322
|
+
objectType: z5.literal(objectTypeSchema.enum.collection)
|
|
319
323
|
});
|
|
320
324
|
var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
|
|
321
|
-
objectType: z5.literal(objectTypeSchema.
|
|
325
|
+
objectType: z5.literal(objectTypeSchema.enum.entry)
|
|
322
326
|
});
|
|
323
327
|
var valueContentReferenceSchema = z5.union([
|
|
324
328
|
valueContentReferenceToAssetSchema,
|
|
@@ -327,19 +331,19 @@ var valueContentReferenceSchema = z5.union([
|
|
|
327
331
|
// valueContentReferenceToSharedValueSchema,
|
|
328
332
|
]);
|
|
329
333
|
var directValueBaseSchema = z5.object({
|
|
330
|
-
objectType: z5.literal(objectTypeSchema.
|
|
334
|
+
objectType: z5.literal(objectTypeSchema.enum.value).readonly(),
|
|
331
335
|
fieldDefinitionId: uuidSchema.readonly()
|
|
332
336
|
});
|
|
333
337
|
var directStringValueSchema = directValueBaseSchema.extend({
|
|
334
|
-
valueType: z5.literal(ValueTypeSchema.
|
|
338
|
+
valueType: z5.literal(ValueTypeSchema.enum.string).readonly(),
|
|
335
339
|
content: translatableStringSchema
|
|
336
340
|
});
|
|
337
341
|
var directNumberValueSchema = directValueBaseSchema.extend({
|
|
338
|
-
valueType: z5.literal(ValueTypeSchema.
|
|
342
|
+
valueType: z5.literal(ValueTypeSchema.enum.number).readonly(),
|
|
339
343
|
content: translatableNumberSchema
|
|
340
344
|
});
|
|
341
345
|
var directBooleanValueSchema = directValueBaseSchema.extend({
|
|
342
|
-
valueType: z5.literal(ValueTypeSchema.
|
|
346
|
+
valueType: z5.literal(ValueTypeSchema.enum.boolean).readonly(),
|
|
343
347
|
content: translatableBooleanSchema
|
|
344
348
|
});
|
|
345
349
|
var directValueSchema = z5.union([
|
|
@@ -348,16 +352,16 @@ var directValueSchema = z5.union([
|
|
|
348
352
|
directBooleanValueSchema
|
|
349
353
|
]);
|
|
350
354
|
var referencedValueSchema = z5.object({
|
|
351
|
-
objectType: z5.literal(objectTypeSchema.
|
|
355
|
+
objectType: z5.literal(objectTypeSchema.enum.value).readonly(),
|
|
352
356
|
fieldDefinitionId: uuidSchema.readonly(),
|
|
353
|
-
valueType: z5.literal(ValueTypeSchema.
|
|
357
|
+
valueType: z5.literal(ValueTypeSchema.enum.reference).readonly(),
|
|
354
358
|
content: translatableArrayOf(valueContentReferenceSchema)
|
|
355
359
|
});
|
|
356
360
|
var valueSchema = z5.union([directValueSchema, referencedValueSchema]);
|
|
357
361
|
|
|
358
362
|
// src/schema/entrySchema.ts
|
|
359
363
|
var entryFileSchema = baseFileSchema.extend({
|
|
360
|
-
objectType: z6.literal(objectTypeSchema.
|
|
364
|
+
objectType: z6.literal(objectTypeSchema.enum.entry).readonly(),
|
|
361
365
|
values: z6.array(valueSchema)
|
|
362
366
|
});
|
|
363
367
|
var entrySchema = entryFileSchema.extend({
|
|
@@ -406,7 +410,7 @@ var FieldTypeSchema = z7.enum([
|
|
|
406
410
|
"email",
|
|
407
411
|
// 'password', @todo maybe if there is a usecase
|
|
408
412
|
"url",
|
|
409
|
-
"
|
|
413
|
+
"ipv4",
|
|
410
414
|
"date",
|
|
411
415
|
"time",
|
|
412
416
|
"datetime",
|
|
@@ -425,7 +429,7 @@ var FieldWidthSchema = z7.enum(["12", "6", "4", "3"]);
|
|
|
425
429
|
var FieldDefinitionBaseSchema = z7.object({
|
|
426
430
|
id: uuidSchema.readonly(),
|
|
427
431
|
label: translatableStringSchema,
|
|
428
|
-
description: translatableStringSchema,
|
|
432
|
+
description: translatableStringSchema.nullable(),
|
|
429
433
|
isRequired: z7.boolean(),
|
|
430
434
|
isDisabled: z7.boolean(),
|
|
431
435
|
isUnique: z7.boolean(),
|
|
@@ -433,60 +437,62 @@ var FieldDefinitionBaseSchema = z7.object({
|
|
|
433
437
|
});
|
|
434
438
|
var StringFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
|
|
435
439
|
{
|
|
436
|
-
valueType: z7.literal(ValueTypeSchema.
|
|
440
|
+
valueType: z7.literal(ValueTypeSchema.enum.string),
|
|
437
441
|
defaultValue: z7.string().nullable()
|
|
438
442
|
}
|
|
439
443
|
);
|
|
440
444
|
var textFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
|
|
441
445
|
{
|
|
442
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
446
|
+
fieldType: z7.literal(FieldTypeSchema.enum.text),
|
|
443
447
|
min: z7.number().nullable(),
|
|
444
448
|
max: z7.number().nullable()
|
|
445
449
|
}
|
|
446
450
|
);
|
|
447
451
|
var textareaFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
|
|
448
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
452
|
+
fieldType: z7.literal(FieldTypeSchema.enum.textarea),
|
|
449
453
|
min: z7.number().nullable(),
|
|
450
454
|
max: z7.number().nullable()
|
|
451
455
|
});
|
|
452
456
|
var emailFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
|
|
453
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
454
|
-
defaultValue: z7.
|
|
457
|
+
fieldType: z7.literal(FieldTypeSchema.enum.email),
|
|
458
|
+
defaultValue: z7.email().nullable()
|
|
455
459
|
});
|
|
456
460
|
var urlFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
|
|
457
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
458
|
-
defaultValue: z7.
|
|
459
|
-
});
|
|
460
|
-
var ipFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
|
|
461
|
-
fieldType: z7.literal(FieldTypeSchema.Enum.ip),
|
|
462
|
-
defaultValue: z7.string().ip().nullable()
|
|
461
|
+
fieldType: z7.literal(FieldTypeSchema.enum.url),
|
|
462
|
+
defaultValue: z7.url().nullable()
|
|
463
463
|
});
|
|
464
|
+
var ipv4FieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
|
|
465
|
+
{
|
|
466
|
+
fieldType: z7.literal(FieldTypeSchema.enum.ipv4),
|
|
467
|
+
defaultValue: z7.ipv4().nullable()
|
|
468
|
+
}
|
|
469
|
+
);
|
|
464
470
|
var dateFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
|
|
465
471
|
{
|
|
466
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
467
|
-
defaultValue: z7.
|
|
472
|
+
fieldType: z7.literal(FieldTypeSchema.enum.date),
|
|
473
|
+
defaultValue: z7.iso.date().nullable()
|
|
468
474
|
}
|
|
469
475
|
);
|
|
470
476
|
var timeFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
|
|
471
477
|
{
|
|
472
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
473
|
-
defaultValue: z7.
|
|
478
|
+
fieldType: z7.literal(FieldTypeSchema.enum.time),
|
|
479
|
+
defaultValue: z7.iso.time().nullable()
|
|
474
480
|
}
|
|
475
481
|
);
|
|
476
482
|
var datetimeFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
|
|
477
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
478
|
-
defaultValue: z7.
|
|
483
|
+
fieldType: z7.literal(FieldTypeSchema.enum.datetime),
|
|
484
|
+
defaultValue: z7.iso.datetime().nullable()
|
|
479
485
|
});
|
|
480
486
|
var telephoneFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
|
|
481
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
482
|
-
|
|
487
|
+
fieldType: z7.literal(FieldTypeSchema.enum.telephone),
|
|
488
|
+
defaultValue: z7.e164().nullable()
|
|
483
489
|
});
|
|
484
490
|
var stringFieldDefinitionSchema = z7.union([
|
|
485
491
|
textFieldDefinitionSchema,
|
|
486
492
|
textareaFieldDefinitionSchema,
|
|
487
493
|
emailFieldDefinitionSchema,
|
|
488
494
|
urlFieldDefinitionSchema,
|
|
489
|
-
|
|
495
|
+
ipv4FieldDefinitionSchema,
|
|
490
496
|
dateFieldDefinitionSchema,
|
|
491
497
|
timeFieldDefinitionSchema,
|
|
492
498
|
datetimeFieldDefinitionSchema,
|
|
@@ -494,7 +500,7 @@ var stringFieldDefinitionSchema = z7.union([
|
|
|
494
500
|
]);
|
|
495
501
|
var NumberFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
|
|
496
502
|
{
|
|
497
|
-
valueType: z7.literal(ValueTypeSchema.
|
|
503
|
+
valueType: z7.literal(ValueTypeSchema.enum.number),
|
|
498
504
|
min: z7.number().nullable(),
|
|
499
505
|
max: z7.number().nullable(),
|
|
500
506
|
isUnique: z7.literal(false),
|
|
@@ -502,10 +508,10 @@ var NumberFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
|
|
|
502
508
|
}
|
|
503
509
|
);
|
|
504
510
|
var numberFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
|
|
505
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
511
|
+
fieldType: z7.literal(FieldTypeSchema.enum.number)
|
|
506
512
|
});
|
|
507
513
|
var rangeFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
|
|
508
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
514
|
+
fieldType: z7.literal(FieldTypeSchema.enum.range),
|
|
509
515
|
// Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
|
|
510
516
|
isRequired: z7.literal(true),
|
|
511
517
|
min: z7.number(),
|
|
@@ -513,25 +519,25 @@ var rangeFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
|
|
|
513
519
|
defaultValue: z7.number()
|
|
514
520
|
});
|
|
515
521
|
var BooleanFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
|
|
516
|
-
valueType: z7.literal(ValueTypeSchema.
|
|
522
|
+
valueType: z7.literal(ValueTypeSchema.enum.boolean),
|
|
517
523
|
// Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
|
|
518
524
|
isRequired: z7.literal(true),
|
|
519
525
|
defaultValue: z7.boolean(),
|
|
520
526
|
isUnique: z7.literal(false)
|
|
521
527
|
});
|
|
522
528
|
var toggleFieldDefinitionSchema = BooleanFieldDefinitionBaseSchema.extend({
|
|
523
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
529
|
+
fieldType: z7.literal(FieldTypeSchema.enum.toggle)
|
|
524
530
|
});
|
|
525
531
|
var ReferenceFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
|
|
526
|
-
valueType: z7.literal(ValueTypeSchema.
|
|
532
|
+
valueType: z7.literal(ValueTypeSchema.enum.reference)
|
|
527
533
|
});
|
|
528
534
|
var assetFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
|
|
529
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
535
|
+
fieldType: z7.literal(FieldTypeSchema.enum.asset),
|
|
530
536
|
min: z7.number().nullable(),
|
|
531
537
|
max: z7.number().nullable()
|
|
532
538
|
});
|
|
533
539
|
var entryFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
|
|
534
|
-
fieldType: z7.literal(FieldTypeSchema.
|
|
540
|
+
fieldType: z7.literal(FieldTypeSchema.enum.entry),
|
|
535
541
|
ofCollections: z7.array(uuidSchema),
|
|
536
542
|
min: z7.number().nullable(),
|
|
537
543
|
max: z7.number().nullable()
|
|
@@ -545,103 +551,10 @@ var fieldDefinitionSchema = z7.union([
|
|
|
545
551
|
entryFieldDefinitionSchema
|
|
546
552
|
// sharedValueDefinitionSchema,
|
|
547
553
|
]);
|
|
548
|
-
function getValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
549
|
-
switch (fieldDefinition.valueType) {
|
|
550
|
-
case ValueTypeSchema.Enum.boolean:
|
|
551
|
-
return getBooleanValueContentSchema();
|
|
552
|
-
case ValueTypeSchema.Enum.number:
|
|
553
|
-
return getNumberValueContentSchema(fieldDefinition);
|
|
554
|
-
case ValueTypeSchema.Enum.string:
|
|
555
|
-
return getStringValueContentSchema(fieldDefinition);
|
|
556
|
-
case ValueTypeSchema.Enum.reference:
|
|
557
|
-
return getReferenceValueContentSchema(fieldDefinition);
|
|
558
|
-
default:
|
|
559
|
-
throw new Error(
|
|
560
|
-
// @ts-expect-error
|
|
561
|
-
`Error generating schema for unsupported ValueType "${fieldDefinition.valueType}"`
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
function getBooleanValueContentSchema() {
|
|
566
|
-
return z7.boolean();
|
|
567
|
-
}
|
|
568
|
-
function getNumberValueContentSchema(definition) {
|
|
569
|
-
let schema = z7.number();
|
|
570
|
-
if (definition.min) {
|
|
571
|
-
schema = schema.min(definition.min);
|
|
572
|
-
}
|
|
573
|
-
if (definition.max) {
|
|
574
|
-
schema = schema.max(definition.max);
|
|
575
|
-
}
|
|
576
|
-
if (definition.isRequired === false) {
|
|
577
|
-
return schema.nullable();
|
|
578
|
-
}
|
|
579
|
-
return schema;
|
|
580
|
-
}
|
|
581
|
-
function getStringValueContentSchema(definition) {
|
|
582
|
-
let schema = z7.string().trim();
|
|
583
|
-
if ("min" in definition && definition.min) {
|
|
584
|
-
schema = schema.min(definition.min);
|
|
585
|
-
}
|
|
586
|
-
if ("max" in definition && definition.max) {
|
|
587
|
-
schema = schema.max(definition.max);
|
|
588
|
-
}
|
|
589
|
-
switch (definition.fieldType) {
|
|
590
|
-
case FieldTypeSchema.Enum.email:
|
|
591
|
-
schema = schema.email();
|
|
592
|
-
break;
|
|
593
|
-
case FieldTypeSchema.Enum.url:
|
|
594
|
-
schema = schema.url();
|
|
595
|
-
break;
|
|
596
|
-
case FieldTypeSchema.Enum.ip:
|
|
597
|
-
schema = schema.ip();
|
|
598
|
-
break;
|
|
599
|
-
case FieldTypeSchema.Enum.date:
|
|
600
|
-
schema = schema.date();
|
|
601
|
-
break;
|
|
602
|
-
case FieldTypeSchema.Enum.time:
|
|
603
|
-
schema = schema.time();
|
|
604
|
-
break;
|
|
605
|
-
case FieldTypeSchema.Enum.datetime:
|
|
606
|
-
schema = schema.datetime();
|
|
607
|
-
break;
|
|
608
|
-
case FieldTypeSchema.Enum.telephone:
|
|
609
|
-
break;
|
|
610
|
-
}
|
|
611
|
-
if (definition.isRequired === false) {
|
|
612
|
-
return schema.nullable();
|
|
613
|
-
}
|
|
614
|
-
return schema.min(1, "shared.stringValueRequired");
|
|
615
|
-
}
|
|
616
|
-
function getReferenceValueContentSchema(definition) {
|
|
617
|
-
let schema;
|
|
618
|
-
switch (definition.fieldType) {
|
|
619
|
-
case FieldTypeSchema.Enum.asset:
|
|
620
|
-
{
|
|
621
|
-
schema = z7.array(valueContentReferenceToAssetSchema);
|
|
622
|
-
}
|
|
623
|
-
break;
|
|
624
|
-
case FieldTypeSchema.Enum.entry:
|
|
625
|
-
{
|
|
626
|
-
schema = z7.array(valueContentReferenceToEntrySchema);
|
|
627
|
-
}
|
|
628
|
-
break;
|
|
629
|
-
}
|
|
630
|
-
if (definition.isRequired) {
|
|
631
|
-
schema = schema.min(1, "shared.referenceRequired");
|
|
632
|
-
}
|
|
633
|
-
if (definition.min) {
|
|
634
|
-
schema = schema.min(definition.min);
|
|
635
|
-
}
|
|
636
|
-
if (definition.max) {
|
|
637
|
-
schema = schema.max(definition.max);
|
|
638
|
-
}
|
|
639
|
-
return schema;
|
|
640
|
-
}
|
|
641
554
|
|
|
642
555
|
// src/schema/collectionSchema.ts
|
|
643
556
|
var collectionFileSchema = baseFileSchema.extend({
|
|
644
|
-
objectType: z8.literal(objectTypeSchema.
|
|
557
|
+
objectType: z8.literal(objectTypeSchema.enum.collection).readonly(),
|
|
645
558
|
name: z8.object({
|
|
646
559
|
singular: translatableStringSchema,
|
|
647
560
|
plural: translatableStringSchema
|
|
@@ -736,7 +649,7 @@ var projectFolderSchema = z10.enum([
|
|
|
736
649
|
]);
|
|
737
650
|
var projectBranchSchema = z10.enum(["production", "work"]);
|
|
738
651
|
var projectFileSchema = baseFileSchema.extend({
|
|
739
|
-
objectType: z10.literal(objectTypeSchema.
|
|
652
|
+
objectType: z10.literal(objectTypeSchema.enum.project).readonly(),
|
|
740
653
|
coreVersion: versionSchema,
|
|
741
654
|
name: z10.string().trim().min(1, "shared.projectNameRequired"),
|
|
742
655
|
description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
|
|
@@ -804,7 +717,10 @@ var projectUpgradeSchema = z10.object({
|
|
|
804
717
|
/**
|
|
805
718
|
* Function that will be executed in the process of upgrading a Project
|
|
806
719
|
*/
|
|
807
|
-
run: z10.function(
|
|
720
|
+
run: z10.function({
|
|
721
|
+
input: [projectFileSchema],
|
|
722
|
+
output: z10.promise(z10.void())
|
|
723
|
+
})
|
|
808
724
|
});
|
|
809
725
|
var cloneProjectSchema = z10.object({
|
|
810
726
|
url: z10.string()
|
|
@@ -840,9 +756,182 @@ var searchProjectSchema = z10.object({
|
|
|
840
756
|
type: z10.array(objectTypeSchema).optional()
|
|
841
757
|
});
|
|
842
758
|
|
|
759
|
+
// src/schema/schemaFromFieldDefinition.ts
|
|
760
|
+
import z11 from "zod";
|
|
761
|
+
function getBooleanValueContentSchemaFromFieldDefinition() {
|
|
762
|
+
return z11.boolean();
|
|
763
|
+
}
|
|
764
|
+
function getNumberValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
765
|
+
let schema = z11.number();
|
|
766
|
+
if (fieldDefinition.min) {
|
|
767
|
+
schema = schema.min(fieldDefinition.min);
|
|
768
|
+
}
|
|
769
|
+
if (fieldDefinition.max) {
|
|
770
|
+
schema = schema.max(fieldDefinition.max);
|
|
771
|
+
}
|
|
772
|
+
if (fieldDefinition.isRequired === false) {
|
|
773
|
+
return schema.nullable();
|
|
774
|
+
}
|
|
775
|
+
return schema;
|
|
776
|
+
}
|
|
777
|
+
function getStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
778
|
+
let schema = null;
|
|
779
|
+
switch (fieldDefinition.fieldType) {
|
|
780
|
+
case FieldTypeSchema.enum.email:
|
|
781
|
+
schema = z11.email();
|
|
782
|
+
break;
|
|
783
|
+
case FieldTypeSchema.enum.url:
|
|
784
|
+
schema = z11.url();
|
|
785
|
+
break;
|
|
786
|
+
case FieldTypeSchema.enum.ipv4:
|
|
787
|
+
schema = z11.ipv4();
|
|
788
|
+
break;
|
|
789
|
+
case FieldTypeSchema.enum.date:
|
|
790
|
+
schema = z11.iso.date();
|
|
791
|
+
break;
|
|
792
|
+
case FieldTypeSchema.enum.time:
|
|
793
|
+
schema = z11.iso.time();
|
|
794
|
+
break;
|
|
795
|
+
case FieldTypeSchema.enum.datetime:
|
|
796
|
+
schema = z11.iso.datetime();
|
|
797
|
+
break;
|
|
798
|
+
case FieldTypeSchema.enum.telephone:
|
|
799
|
+
schema = z11.e164();
|
|
800
|
+
break;
|
|
801
|
+
case FieldTypeSchema.enum.text:
|
|
802
|
+
case FieldTypeSchema.enum.textarea:
|
|
803
|
+
schema = z11.string().trim();
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
if ("min" in fieldDefinition && fieldDefinition.min) {
|
|
807
|
+
schema = schema.min(fieldDefinition.min);
|
|
808
|
+
}
|
|
809
|
+
if ("max" in fieldDefinition && fieldDefinition.max) {
|
|
810
|
+
schema = schema.max(fieldDefinition.max);
|
|
811
|
+
}
|
|
812
|
+
if (fieldDefinition.isRequired === false) {
|
|
813
|
+
return schema.nullable();
|
|
814
|
+
}
|
|
815
|
+
return schema.min(1, "shared.stringValueRequired");
|
|
816
|
+
}
|
|
817
|
+
function getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
818
|
+
let schema;
|
|
819
|
+
switch (fieldDefinition.fieldType) {
|
|
820
|
+
case FieldTypeSchema.enum.asset:
|
|
821
|
+
{
|
|
822
|
+
schema = z11.array(valueContentReferenceToAssetSchema);
|
|
823
|
+
}
|
|
824
|
+
break;
|
|
825
|
+
case FieldTypeSchema.enum.entry:
|
|
826
|
+
{
|
|
827
|
+
schema = z11.array(valueContentReferenceToEntrySchema);
|
|
828
|
+
}
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
if (fieldDefinition.isRequired) {
|
|
832
|
+
schema = schema.min(1, "shared.referenceRequired");
|
|
833
|
+
}
|
|
834
|
+
if (fieldDefinition.min) {
|
|
835
|
+
schema = schema.min(fieldDefinition.min);
|
|
836
|
+
}
|
|
837
|
+
if (fieldDefinition.max) {
|
|
838
|
+
schema = schema.max(fieldDefinition.max);
|
|
839
|
+
}
|
|
840
|
+
return schema;
|
|
841
|
+
}
|
|
842
|
+
function getTranslatableStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
843
|
+
return z11.partialRecord(
|
|
844
|
+
supportedLanguageSchema,
|
|
845
|
+
getStringValueContentSchemaFromFieldDefinition(fieldDefinition)
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
function getTranslatableNumberValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
849
|
+
return z11.partialRecord(
|
|
850
|
+
supportedLanguageSchema,
|
|
851
|
+
getNumberValueContentSchemaFromFieldDefinition(fieldDefinition)
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
function getTranslatableBooleanValueContentSchemaFromFieldDefinition() {
|
|
855
|
+
return z11.partialRecord(
|
|
856
|
+
supportedLanguageSchema,
|
|
857
|
+
getBooleanValueContentSchemaFromFieldDefinition()
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
function getTranslatableReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
861
|
+
return z11.partialRecord(
|
|
862
|
+
supportedLanguageSchema,
|
|
863
|
+
getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition)
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
function getValueSchemaFromFieldDefinition(fieldDefinition) {
|
|
867
|
+
switch (fieldDefinition.valueType) {
|
|
868
|
+
case ValueTypeSchema.enum.boolean:
|
|
869
|
+
return directBooleanValueSchema.extend({
|
|
870
|
+
content: getTranslatableBooleanValueContentSchemaFromFieldDefinition()
|
|
871
|
+
});
|
|
872
|
+
case ValueTypeSchema.enum.number:
|
|
873
|
+
return directNumberValueSchema.extend({
|
|
874
|
+
content: getTranslatableNumberValueContentSchemaFromFieldDefinition(
|
|
875
|
+
fieldDefinition
|
|
876
|
+
)
|
|
877
|
+
});
|
|
878
|
+
case ValueTypeSchema.enum.string:
|
|
879
|
+
return directStringValueSchema.extend({
|
|
880
|
+
content: getTranslatableStringValueContentSchemaFromFieldDefinition(
|
|
881
|
+
fieldDefinition
|
|
882
|
+
)
|
|
883
|
+
});
|
|
884
|
+
case ValueTypeSchema.enum.reference:
|
|
885
|
+
return referencedValueSchema.extend({
|
|
886
|
+
content: getTranslatableReferenceValueContentSchemaFromFieldDefinition(
|
|
887
|
+
fieldDefinition
|
|
888
|
+
)
|
|
889
|
+
});
|
|
890
|
+
default:
|
|
891
|
+
throw new Error(
|
|
892
|
+
// @ts-expect-error Code cannot be reached, but if we add a new ValueType and forget to update this function, we want to be notified about it
|
|
893
|
+
`Error generating schema for unsupported ValueType "${fieldDefinition.valueType}"`
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
function getCreateEntrySchemaFromFieldDefinitions(fieldDefinitions, values) {
|
|
898
|
+
const schema = {
|
|
899
|
+
...createEntrySchema,
|
|
900
|
+
values: values.map((value) => {
|
|
901
|
+
const fieldDefinition = fieldDefinitions.find(
|
|
902
|
+
(fieldDefinition2) => fieldDefinition2.id === value.fieldDefinitionId
|
|
903
|
+
);
|
|
904
|
+
if (!fieldDefinition) {
|
|
905
|
+
throw new Error(
|
|
906
|
+
`Field definition with ID "${value.fieldDefinitionId}" not found`
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
return getValueSchemaFromFieldDefinition(fieldDefinition);
|
|
910
|
+
})
|
|
911
|
+
};
|
|
912
|
+
return schema;
|
|
913
|
+
}
|
|
914
|
+
function getUpdateEntrySchemaFromFieldDefinitions(fieldDefinitions, values) {
|
|
915
|
+
const schema = {
|
|
916
|
+
...updateEntrySchema,
|
|
917
|
+
values: values.map((value) => {
|
|
918
|
+
const fieldDefinition = fieldDefinitions.find(
|
|
919
|
+
(fieldDefinition2) => fieldDefinition2.id === value.fieldDefinitionId
|
|
920
|
+
);
|
|
921
|
+
if (!fieldDefinition) {
|
|
922
|
+
throw new Error(
|
|
923
|
+
`Field definition with ID "${value.fieldDefinitionId}" not found`
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
return getValueSchemaFromFieldDefinition(fieldDefinition);
|
|
927
|
+
})
|
|
928
|
+
};
|
|
929
|
+
return schema;
|
|
930
|
+
}
|
|
931
|
+
|
|
843
932
|
// src/schema/serviceSchema.ts
|
|
844
|
-
import { z as
|
|
845
|
-
var serviceTypeSchema =
|
|
933
|
+
import { z as z12 } from "zod";
|
|
934
|
+
var serviceTypeSchema = z12.enum([
|
|
846
935
|
"Git",
|
|
847
936
|
"GitTag",
|
|
848
937
|
"User",
|
|
@@ -855,17 +944,17 @@ var serviceTypeSchema = z11.enum([
|
|
|
855
944
|
"Value"
|
|
856
945
|
]);
|
|
857
946
|
function paginatedListOf(schema) {
|
|
858
|
-
return
|
|
859
|
-
total:
|
|
860
|
-
limit:
|
|
861
|
-
offset:
|
|
862
|
-
list:
|
|
947
|
+
return z12.object({
|
|
948
|
+
total: z12.number(),
|
|
949
|
+
limit: z12.number(),
|
|
950
|
+
offset: z12.number(),
|
|
951
|
+
list: z12.array(schema)
|
|
863
952
|
});
|
|
864
953
|
}
|
|
865
|
-
var listSchema =
|
|
954
|
+
var listSchema = z12.object({
|
|
866
955
|
projectId: uuidSchema,
|
|
867
|
-
limit:
|
|
868
|
-
offset:
|
|
956
|
+
limit: z12.number().optional(),
|
|
957
|
+
offset: z12.number().optional()
|
|
869
958
|
});
|
|
870
959
|
var listCollectionsSchema = listSchema;
|
|
871
960
|
var listEntriesSchema = listSchema.extend({
|
|
@@ -875,35 +964,35 @@ var listAssetsSchema = listSchema;
|
|
|
875
964
|
var listProjectsSchema = listSchema.omit({
|
|
876
965
|
projectId: true
|
|
877
966
|
});
|
|
878
|
-
var listGitTagsSchema =
|
|
879
|
-
path:
|
|
967
|
+
var listGitTagsSchema = z12.object({
|
|
968
|
+
path: z12.string()
|
|
880
969
|
});
|
|
881
970
|
|
|
882
971
|
// src/schema/userSchema.ts
|
|
883
|
-
import
|
|
884
|
-
var UserTypeSchema =
|
|
972
|
+
import z13 from "zod";
|
|
973
|
+
var UserTypeSchema = z13.enum(["local", "cloud"]);
|
|
885
974
|
var baseUserSchema = gitSignatureSchema.extend({
|
|
886
975
|
userType: UserTypeSchema,
|
|
887
976
|
language: supportedLanguageSchema,
|
|
888
|
-
localApi:
|
|
977
|
+
localApi: z13.object({
|
|
889
978
|
/**
|
|
890
979
|
* If set to true the local API is started whenever Core is initialized
|
|
891
980
|
*/
|
|
892
|
-
isEnabled:
|
|
981
|
+
isEnabled: z13.boolean(),
|
|
893
982
|
/**
|
|
894
983
|
* The port the local API uses
|
|
895
984
|
*/
|
|
896
|
-
port:
|
|
985
|
+
port: z13.number()
|
|
897
986
|
})
|
|
898
987
|
});
|
|
899
988
|
var localUserSchema = baseUserSchema.extend({
|
|
900
|
-
userType:
|
|
989
|
+
userType: z13.literal(UserTypeSchema.enum.local)
|
|
901
990
|
});
|
|
902
991
|
var cloudUserSchema = baseUserSchema.extend({
|
|
903
|
-
userType:
|
|
992
|
+
userType: z13.literal(UserTypeSchema.enum.cloud),
|
|
904
993
|
id: uuidSchema
|
|
905
994
|
});
|
|
906
|
-
var userFileSchema =
|
|
995
|
+
var userFileSchema = z13.union([localUserSchema, cloudUserSchema]);
|
|
907
996
|
var userSchema = userFileSchema;
|
|
908
997
|
var setUserSchema = userSchema;
|
|
909
998
|
|
|
@@ -980,8 +1069,10 @@ export {
|
|
|
980
1069
|
fieldDefinitionSchema,
|
|
981
1070
|
fileReferenceSchema,
|
|
982
1071
|
getChangesProjectSchema,
|
|
1072
|
+
getCreateEntrySchemaFromFieldDefinitions,
|
|
983
1073
|
getRemoteOriginUrlProjectSchema,
|
|
984
|
-
|
|
1074
|
+
getUpdateEntrySchemaFromFieldDefinitions,
|
|
1075
|
+
getValueSchemaFromFieldDefinition,
|
|
985
1076
|
gitCloneOptionsSchema,
|
|
986
1077
|
gitCommitSchema,
|
|
987
1078
|
gitInitOptionsSchema,
|
|
@@ -991,7 +1082,7 @@ export {
|
|
|
991
1082
|
gitSignatureSchema,
|
|
992
1083
|
gitSwitchOptionsSchema,
|
|
993
1084
|
gitTagSchema,
|
|
994
|
-
|
|
1085
|
+
ipv4FieldDefinitionSchema,
|
|
995
1086
|
listAssetsSchema,
|
|
996
1087
|
listBranchesProjectSchema,
|
|
997
1088
|
listCollectionsSchema,
|