@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.
@@ -10,7 +10,7 @@ import Fs7 from "fs-extra";
10
10
  // package.json
11
11
  var package_default = {
12
12
  name: "@elek-io/core",
13
- version: "0.14.3",
13
+ version: "0.15.0",
14
14
  description: "Handles core functionality of elek.io Projects like file IO and version control.",
15
15
  homepage: "https://elek.io",
16
16
  repository: "https://github.com/elek-io/core",
@@ -37,7 +37,10 @@ var package_default = {
37
37
  }
38
38
  },
39
39
  scripts: {
40
- lint: "tsc",
40
+ lint: "eslint",
41
+ "check-types": "tsc --noEmit",
42
+ "check-format": "prettier --check . || exit 0",
43
+ format: "prettier --write .",
41
44
  dev: "vitest",
42
45
  test: "vitest run",
43
46
  coverage: "vitest run --coverage",
@@ -45,32 +48,38 @@ var package_default = {
45
48
  release: "changeset publish"
46
49
  },
47
50
  dependencies: {
48
- "@hono/node-server": "1.15.0",
51
+ "@hono/node-server": "1.19.5",
49
52
  "@hono/swagger-ui": "0.5.2",
50
- "@hono/zod-openapi": "0.19.9",
51
- "@sindresorhus/slugify": "2.2.1",
52
- "fs-extra": "11.3.0",
53
- hono: "4.8.4",
54
- mime: "4.0.7",
55
- "p-queue": "8.1.0",
53
+ "@hono/zod-openapi": "1.1.3",
54
+ "@sindresorhus/slugify": "3.0.0",
55
+ "fs-extra": "11.3.2",
56
+ hono: "4.9.9",
57
+ mime: "4.1.0",
58
+ "p-queue": "8.1.1",
56
59
  semver: "7.7.2",
57
- uuid: "11.1.0",
58
- winston: "3.17.0",
60
+ uuid: "13.0.0",
61
+ winston: "3.18.2",
59
62
  "winston-daily-rotate-file": "5.0.0",
60
- zod: "3.25.74"
63
+ zod: "4.1.11"
61
64
  },
62
65
  devDependencies: {
63
- "@changesets/cli": "2.29.5",
64
- "@faker-js/faker": "9.9.0",
66
+ "@changesets/cli": "2.29.7",
67
+ "@eslint/js": "9.36.0",
68
+ "@faker-js/faker": "10.0.0",
65
69
  "@tsconfig/node22": "22.0.2",
66
- "@tsconfig/strictest": "2.0.5",
70
+ "@tsconfig/strictest": "2.0.6",
67
71
  "@types/fs-extra": "11.0.4",
68
- "@types/node": "22.16.0",
69
- "@types/semver": "7.7.0",
70
- "@types/uuid": "10.0.0",
72
+ "@types/node": "22.13.14",
73
+ "@types/semver": "7.7.1",
71
74
  "@vitest/coverage-v8": "3.2.4",
75
+ eslint: "9.36.0",
76
+ "eslint-config-prettier": "10.1.8",
77
+ globals: "16.4.0",
78
+ jiti: "2.6.0",
79
+ prettier: "3.6.2",
72
80
  tsup: "8.5.0",
73
- typescript: "5.8.3",
81
+ typescript: "5.9.2",
82
+ "typescript-eslint": "8.45.0",
74
83
  vitest: "3.2.4"
75
84
  },
76
85
  peerDependencies: {
@@ -110,7 +119,7 @@ var LoggerMiddleware = class {
110
119
  };
111
120
 
112
121
  // src/api/v1/asset.ts
113
- import { createRoute, OpenAPIHono, z as z13 } from "@hono/zod-openapi";
122
+ import { createRoute, OpenAPIHono, z as z14 } from "@hono/zod-openapi";
114
123
 
115
124
  // src/schema/assetSchema.ts
116
125
  import { z as z4 } from "@hono/zod-openapi";
@@ -181,21 +190,25 @@ var objectTypeSchema = z.enum([
181
190
  ]);
182
191
  var logLevelSchema = z.enum(["error", "warn", "info", "debug"]);
183
192
  var versionSchema = z.string();
184
- var uuidSchema = z.string().uuid("shared.invalidUuid");
185
- var translatableStringSchema = z.record(
193
+ var uuidSchema = z.uuid("shared.invalidUuid");
194
+ var translatableStringSchema = z.partialRecord(
186
195
  supportedLanguageSchema,
187
196
  z.string().trim().min(1, "shared.translatableStringRequired")
188
197
  );
189
- var translatableNumberSchema = z.record(
198
+ var translatableNumberSchema = z.partialRecord(
190
199
  supportedLanguageSchema,
191
- z.number({ required_error: "shared.translatableNumberRequired" })
200
+ z.number({
201
+ error: (error) => error.input === void 0 ? "shared.translatableNumberRequired" : "shared.translatableNumberNotANumber"
202
+ })
192
203
  );
193
- var translatableBooleanSchema = z.record(
204
+ var translatableBooleanSchema = z.partialRecord(
194
205
  supportedLanguageSchema,
195
- z.boolean({ required_error: "shared.translatableBooleanRequired" })
206
+ z.boolean({
207
+ error: (error) => error.input === void 0 ? "shared.translatableBooleanRequired" : "shared.translatableBooleanNotABoolean"
208
+ })
196
209
  );
197
210
  function translatableArrayOf(schema) {
198
- return z.record(supportedLanguageSchema, z.array(schema));
211
+ return z.partialRecord(supportedLanguageSchema, z.array(schema));
199
212
  }
200
213
 
201
214
  // src/schema/fileSchema.ts
@@ -345,7 +358,7 @@ var countGitTagsSchema = z3.object({
345
358
 
346
359
  // src/schema/assetSchema.ts
347
360
  var assetFileSchema = baseFileSchema.extend({
348
- objectType: z4.literal(objectTypeSchema.Enum.asset).readonly(),
361
+ objectType: z4.literal(objectTypeSchema.enum.asset).readonly(),
349
362
  name: z4.string(),
350
363
  description: z4.string(),
351
364
  extension: z4.string().readonly(),
@@ -426,13 +439,13 @@ var valueContentReferenceBase = z5.object({
426
439
  id: uuidSchema
427
440
  });
428
441
  var valueContentReferenceToAssetSchema = valueContentReferenceBase.extend({
429
- objectType: z5.literal(objectTypeSchema.Enum.asset)
442
+ objectType: z5.literal(objectTypeSchema.enum.asset)
430
443
  });
431
444
  var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
432
- objectType: z5.literal(objectTypeSchema.Enum.collection)
445
+ objectType: z5.literal(objectTypeSchema.enum.collection)
433
446
  });
434
447
  var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
435
- objectType: z5.literal(objectTypeSchema.Enum.entry)
448
+ objectType: z5.literal(objectTypeSchema.enum.entry)
436
449
  });
437
450
  var valueContentReferenceSchema = z5.union([
438
451
  valueContentReferenceToAssetSchema,
@@ -441,19 +454,19 @@ var valueContentReferenceSchema = z5.union([
441
454
  // valueContentReferenceToSharedValueSchema,
442
455
  ]);
443
456
  var directValueBaseSchema = z5.object({
444
- objectType: z5.literal(objectTypeSchema.Enum.value).readonly(),
457
+ objectType: z5.literal(objectTypeSchema.enum.value).readonly(),
445
458
  fieldDefinitionId: uuidSchema.readonly()
446
459
  });
447
460
  var directStringValueSchema = directValueBaseSchema.extend({
448
- valueType: z5.literal(ValueTypeSchema.Enum.string).readonly(),
461
+ valueType: z5.literal(ValueTypeSchema.enum.string).readonly(),
449
462
  content: translatableStringSchema
450
463
  });
451
464
  var directNumberValueSchema = directValueBaseSchema.extend({
452
- valueType: z5.literal(ValueTypeSchema.Enum.number).readonly(),
465
+ valueType: z5.literal(ValueTypeSchema.enum.number).readonly(),
453
466
  content: translatableNumberSchema
454
467
  });
455
468
  var directBooleanValueSchema = directValueBaseSchema.extend({
456
- valueType: z5.literal(ValueTypeSchema.Enum.boolean).readonly(),
469
+ valueType: z5.literal(ValueTypeSchema.enum.boolean).readonly(),
457
470
  content: translatableBooleanSchema
458
471
  });
459
472
  var directValueSchema = z5.union([
@@ -462,16 +475,16 @@ var directValueSchema = z5.union([
462
475
  directBooleanValueSchema
463
476
  ]);
464
477
  var referencedValueSchema = z5.object({
465
- objectType: z5.literal(objectTypeSchema.Enum.value).readonly(),
478
+ objectType: z5.literal(objectTypeSchema.enum.value).readonly(),
466
479
  fieldDefinitionId: uuidSchema.readonly(),
467
- valueType: z5.literal(ValueTypeSchema.Enum.reference).readonly(),
480
+ valueType: z5.literal(ValueTypeSchema.enum.reference).readonly(),
468
481
  content: translatableArrayOf(valueContentReferenceSchema)
469
482
  });
470
483
  var valueSchema = z5.union([directValueSchema, referencedValueSchema]);
471
484
 
472
485
  // src/schema/entrySchema.ts
473
486
  var entryFileSchema = baseFileSchema.extend({
474
- objectType: z6.literal(objectTypeSchema.Enum.entry).readonly(),
487
+ objectType: z6.literal(objectTypeSchema.enum.entry).readonly(),
475
488
  values: z6.array(valueSchema)
476
489
  });
477
490
  var entrySchema = entryFileSchema.extend({
@@ -520,7 +533,7 @@ var FieldTypeSchema = z7.enum([
520
533
  "email",
521
534
  // 'password', @todo maybe if there is a usecase
522
535
  "url",
523
- "ip",
536
+ "ipv4",
524
537
  "date",
525
538
  "time",
526
539
  "datetime",
@@ -539,7 +552,7 @@ var FieldWidthSchema = z7.enum(["12", "6", "4", "3"]);
539
552
  var FieldDefinitionBaseSchema = z7.object({
540
553
  id: uuidSchema.readonly(),
541
554
  label: translatableStringSchema,
542
- description: translatableStringSchema,
555
+ description: translatableStringSchema.nullable(),
543
556
  isRequired: z7.boolean(),
544
557
  isDisabled: z7.boolean(),
545
558
  isUnique: z7.boolean(),
@@ -547,60 +560,62 @@ var FieldDefinitionBaseSchema = z7.object({
547
560
  });
548
561
  var StringFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
549
562
  {
550
- valueType: z7.literal(ValueTypeSchema.Enum.string),
563
+ valueType: z7.literal(ValueTypeSchema.enum.string),
551
564
  defaultValue: z7.string().nullable()
552
565
  }
553
566
  );
554
567
  var textFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
555
568
  {
556
- fieldType: z7.literal(FieldTypeSchema.Enum.text),
569
+ fieldType: z7.literal(FieldTypeSchema.enum.text),
557
570
  min: z7.number().nullable(),
558
571
  max: z7.number().nullable()
559
572
  }
560
573
  );
561
574
  var textareaFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
562
- fieldType: z7.literal(FieldTypeSchema.Enum.textarea),
575
+ fieldType: z7.literal(FieldTypeSchema.enum.textarea),
563
576
  min: z7.number().nullable(),
564
577
  max: z7.number().nullable()
565
578
  });
566
579
  var emailFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
567
- fieldType: z7.literal(FieldTypeSchema.Enum.email),
568
- defaultValue: z7.string().email().nullable()
580
+ fieldType: z7.literal(FieldTypeSchema.enum.email),
581
+ defaultValue: z7.email().nullable()
569
582
  });
570
583
  var urlFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
571
- fieldType: z7.literal(FieldTypeSchema.Enum.url),
572
- defaultValue: z7.string().url().nullable()
573
- });
574
- var ipFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
575
- fieldType: z7.literal(FieldTypeSchema.Enum.ip),
576
- defaultValue: z7.string().ip().nullable()
584
+ fieldType: z7.literal(FieldTypeSchema.enum.url),
585
+ defaultValue: z7.url().nullable()
577
586
  });
587
+ var ipv4FieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
588
+ {
589
+ fieldType: z7.literal(FieldTypeSchema.enum.ipv4),
590
+ defaultValue: z7.ipv4().nullable()
591
+ }
592
+ );
578
593
  var dateFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
579
594
  {
580
- fieldType: z7.literal(FieldTypeSchema.Enum.date),
581
- defaultValue: z7.string().date().nullable()
595
+ fieldType: z7.literal(FieldTypeSchema.enum.date),
596
+ defaultValue: z7.iso.date().nullable()
582
597
  }
583
598
  );
584
599
  var timeFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
585
600
  {
586
- fieldType: z7.literal(FieldTypeSchema.Enum.time),
587
- defaultValue: z7.string().time().nullable()
601
+ fieldType: z7.literal(FieldTypeSchema.enum.time),
602
+ defaultValue: z7.iso.time().nullable()
588
603
  }
589
604
  );
590
605
  var datetimeFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
591
- fieldType: z7.literal(FieldTypeSchema.Enum.datetime),
592
- defaultValue: z7.string().datetime().nullable()
606
+ fieldType: z7.literal(FieldTypeSchema.enum.datetime),
607
+ defaultValue: z7.iso.datetime().nullable()
593
608
  });
594
609
  var telephoneFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
595
- fieldType: z7.literal(FieldTypeSchema.Enum.telephone)
596
- // defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
610
+ fieldType: z7.literal(FieldTypeSchema.enum.telephone),
611
+ defaultValue: z7.e164().nullable()
597
612
  });
598
613
  var stringFieldDefinitionSchema = z7.union([
599
614
  textFieldDefinitionSchema,
600
615
  textareaFieldDefinitionSchema,
601
616
  emailFieldDefinitionSchema,
602
617
  urlFieldDefinitionSchema,
603
- ipFieldDefinitionSchema,
618
+ ipv4FieldDefinitionSchema,
604
619
  dateFieldDefinitionSchema,
605
620
  timeFieldDefinitionSchema,
606
621
  datetimeFieldDefinitionSchema,
@@ -608,7 +623,7 @@ var stringFieldDefinitionSchema = z7.union([
608
623
  ]);
609
624
  var NumberFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
610
625
  {
611
- valueType: z7.literal(ValueTypeSchema.Enum.number),
626
+ valueType: z7.literal(ValueTypeSchema.enum.number),
612
627
  min: z7.number().nullable(),
613
628
  max: z7.number().nullable(),
614
629
  isUnique: z7.literal(false),
@@ -616,10 +631,10 @@ var NumberFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
616
631
  }
617
632
  );
618
633
  var numberFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
619
- fieldType: z7.literal(FieldTypeSchema.Enum.number)
634
+ fieldType: z7.literal(FieldTypeSchema.enum.number)
620
635
  });
621
636
  var rangeFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
622
- fieldType: z7.literal(FieldTypeSchema.Enum.range),
637
+ fieldType: z7.literal(FieldTypeSchema.enum.range),
623
638
  // Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
624
639
  isRequired: z7.literal(true),
625
640
  min: z7.number(),
@@ -627,25 +642,25 @@ var rangeFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
627
642
  defaultValue: z7.number()
628
643
  });
629
644
  var BooleanFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
630
- valueType: z7.literal(ValueTypeSchema.Enum.boolean),
645
+ valueType: z7.literal(ValueTypeSchema.enum.boolean),
631
646
  // Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
632
647
  isRequired: z7.literal(true),
633
648
  defaultValue: z7.boolean(),
634
649
  isUnique: z7.literal(false)
635
650
  });
636
651
  var toggleFieldDefinitionSchema = BooleanFieldDefinitionBaseSchema.extend({
637
- fieldType: z7.literal(FieldTypeSchema.Enum.toggle)
652
+ fieldType: z7.literal(FieldTypeSchema.enum.toggle)
638
653
  });
639
654
  var ReferenceFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
640
- valueType: z7.literal(ValueTypeSchema.Enum.reference)
655
+ valueType: z7.literal(ValueTypeSchema.enum.reference)
641
656
  });
642
657
  var assetFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
643
- fieldType: z7.literal(FieldTypeSchema.Enum.asset),
658
+ fieldType: z7.literal(FieldTypeSchema.enum.asset),
644
659
  min: z7.number().nullable(),
645
660
  max: z7.number().nullable()
646
661
  });
647
662
  var entryFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
648
- fieldType: z7.literal(FieldTypeSchema.Enum.entry),
663
+ fieldType: z7.literal(FieldTypeSchema.enum.entry),
649
664
  ofCollections: z7.array(uuidSchema),
650
665
  min: z7.number().nullable(),
651
666
  max: z7.number().nullable()
@@ -659,103 +674,10 @@ var fieldDefinitionSchema = z7.union([
659
674
  entryFieldDefinitionSchema
660
675
  // sharedValueDefinitionSchema,
661
676
  ]);
662
- function getValueContentSchemaFromFieldDefinition(fieldDefinition) {
663
- switch (fieldDefinition.valueType) {
664
- case ValueTypeSchema.Enum.boolean:
665
- return getBooleanValueContentSchema();
666
- case ValueTypeSchema.Enum.number:
667
- return getNumberValueContentSchema(fieldDefinition);
668
- case ValueTypeSchema.Enum.string:
669
- return getStringValueContentSchema(fieldDefinition);
670
- case ValueTypeSchema.Enum.reference:
671
- return getReferenceValueContentSchema(fieldDefinition);
672
- default:
673
- throw new Error(
674
- // @ts-expect-error
675
- `Error generating schema for unsupported ValueType "${fieldDefinition.valueType}"`
676
- );
677
- }
678
- }
679
- function getBooleanValueContentSchema() {
680
- return z7.boolean();
681
- }
682
- function getNumberValueContentSchema(definition) {
683
- let schema = z7.number();
684
- if (definition.min) {
685
- schema = schema.min(definition.min);
686
- }
687
- if (definition.max) {
688
- schema = schema.max(definition.max);
689
- }
690
- if (definition.isRequired === false) {
691
- return schema.nullable();
692
- }
693
- return schema;
694
- }
695
- function getStringValueContentSchema(definition) {
696
- let schema = z7.string().trim();
697
- if ("min" in definition && definition.min) {
698
- schema = schema.min(definition.min);
699
- }
700
- if ("max" in definition && definition.max) {
701
- schema = schema.max(definition.max);
702
- }
703
- switch (definition.fieldType) {
704
- case FieldTypeSchema.Enum.email:
705
- schema = schema.email();
706
- break;
707
- case FieldTypeSchema.Enum.url:
708
- schema = schema.url();
709
- break;
710
- case FieldTypeSchema.Enum.ip:
711
- schema = schema.ip();
712
- break;
713
- case FieldTypeSchema.Enum.date:
714
- schema = schema.date();
715
- break;
716
- case FieldTypeSchema.Enum.time:
717
- schema = schema.time();
718
- break;
719
- case FieldTypeSchema.Enum.datetime:
720
- schema = schema.datetime();
721
- break;
722
- case FieldTypeSchema.Enum.telephone:
723
- break;
724
- }
725
- if (definition.isRequired === false) {
726
- return schema.nullable();
727
- }
728
- return schema.min(1, "shared.stringValueRequired");
729
- }
730
- function getReferenceValueContentSchema(definition) {
731
- let schema;
732
- switch (definition.fieldType) {
733
- case FieldTypeSchema.Enum.asset:
734
- {
735
- schema = z7.array(valueContentReferenceToAssetSchema);
736
- }
737
- break;
738
- case FieldTypeSchema.Enum.entry:
739
- {
740
- schema = z7.array(valueContentReferenceToEntrySchema);
741
- }
742
- break;
743
- }
744
- if (definition.isRequired) {
745
- schema = schema.min(1, "shared.referenceRequired");
746
- }
747
- if (definition.min) {
748
- schema = schema.min(definition.min);
749
- }
750
- if (definition.max) {
751
- schema = schema.max(definition.max);
752
- }
753
- return schema;
754
- }
755
677
 
756
678
  // src/schema/collectionSchema.ts
757
679
  var collectionFileSchema = baseFileSchema.extend({
758
- objectType: z8.literal(objectTypeSchema.Enum.collection).readonly(),
680
+ objectType: z8.literal(objectTypeSchema.enum.collection).readonly(),
759
681
  name: z8.object({
760
682
  singular: translatableStringSchema,
761
683
  plural: translatableStringSchema
@@ -850,7 +772,7 @@ var projectFolderSchema = z10.enum([
850
772
  ]);
851
773
  var projectBranchSchema = z10.enum(["production", "work"]);
852
774
  var projectFileSchema = baseFileSchema.extend({
853
- objectType: z10.literal(objectTypeSchema.Enum.project).readonly(),
775
+ objectType: z10.literal(objectTypeSchema.enum.project).readonly(),
854
776
  coreVersion: versionSchema,
855
777
  name: z10.string().trim().min(1, "shared.projectNameRequired"),
856
778
  description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
@@ -918,7 +840,10 @@ var projectUpgradeSchema = z10.object({
918
840
  /**
919
841
  * Function that will be executed in the process of upgrading a Project
920
842
  */
921
- run: z10.function().args(projectFileSchema).returns(z10.promise(z10.void()))
843
+ run: z10.function({
844
+ input: [projectFileSchema],
845
+ output: z10.promise(z10.void())
846
+ })
922
847
  });
923
848
  var cloneProjectSchema = z10.object({
924
849
  url: z10.string()
@@ -954,9 +879,182 @@ var searchProjectSchema = z10.object({
954
879
  type: z10.array(objectTypeSchema).optional()
955
880
  });
956
881
 
882
+ // src/schema/schemaFromFieldDefinition.ts
883
+ import z11 from "zod";
884
+ function getBooleanValueContentSchemaFromFieldDefinition() {
885
+ return z11.boolean();
886
+ }
887
+ function getNumberValueContentSchemaFromFieldDefinition(fieldDefinition) {
888
+ let schema = z11.number();
889
+ if (fieldDefinition.min) {
890
+ schema = schema.min(fieldDefinition.min);
891
+ }
892
+ if (fieldDefinition.max) {
893
+ schema = schema.max(fieldDefinition.max);
894
+ }
895
+ if (fieldDefinition.isRequired === false) {
896
+ return schema.nullable();
897
+ }
898
+ return schema;
899
+ }
900
+ function getStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
901
+ let schema = null;
902
+ switch (fieldDefinition.fieldType) {
903
+ case FieldTypeSchema.enum.email:
904
+ schema = z11.email();
905
+ break;
906
+ case FieldTypeSchema.enum.url:
907
+ schema = z11.url();
908
+ break;
909
+ case FieldTypeSchema.enum.ipv4:
910
+ schema = z11.ipv4();
911
+ break;
912
+ case FieldTypeSchema.enum.date:
913
+ schema = z11.iso.date();
914
+ break;
915
+ case FieldTypeSchema.enum.time:
916
+ schema = z11.iso.time();
917
+ break;
918
+ case FieldTypeSchema.enum.datetime:
919
+ schema = z11.iso.datetime();
920
+ break;
921
+ case FieldTypeSchema.enum.telephone:
922
+ schema = z11.e164();
923
+ break;
924
+ case FieldTypeSchema.enum.text:
925
+ case FieldTypeSchema.enum.textarea:
926
+ schema = z11.string().trim();
927
+ break;
928
+ }
929
+ if ("min" in fieldDefinition && fieldDefinition.min) {
930
+ schema = schema.min(fieldDefinition.min);
931
+ }
932
+ if ("max" in fieldDefinition && fieldDefinition.max) {
933
+ schema = schema.max(fieldDefinition.max);
934
+ }
935
+ if (fieldDefinition.isRequired === false) {
936
+ return schema.nullable();
937
+ }
938
+ return schema.min(1, "shared.stringValueRequired");
939
+ }
940
+ function getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
941
+ let schema;
942
+ switch (fieldDefinition.fieldType) {
943
+ case FieldTypeSchema.enum.asset:
944
+ {
945
+ schema = z11.array(valueContentReferenceToAssetSchema);
946
+ }
947
+ break;
948
+ case FieldTypeSchema.enum.entry:
949
+ {
950
+ schema = z11.array(valueContentReferenceToEntrySchema);
951
+ }
952
+ break;
953
+ }
954
+ if (fieldDefinition.isRequired) {
955
+ schema = schema.min(1, "shared.referenceRequired");
956
+ }
957
+ if (fieldDefinition.min) {
958
+ schema = schema.min(fieldDefinition.min);
959
+ }
960
+ if (fieldDefinition.max) {
961
+ schema = schema.max(fieldDefinition.max);
962
+ }
963
+ return schema;
964
+ }
965
+ function getTranslatableStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
966
+ return z11.partialRecord(
967
+ supportedLanguageSchema,
968
+ getStringValueContentSchemaFromFieldDefinition(fieldDefinition)
969
+ );
970
+ }
971
+ function getTranslatableNumberValueContentSchemaFromFieldDefinition(fieldDefinition) {
972
+ return z11.partialRecord(
973
+ supportedLanguageSchema,
974
+ getNumberValueContentSchemaFromFieldDefinition(fieldDefinition)
975
+ );
976
+ }
977
+ function getTranslatableBooleanValueContentSchemaFromFieldDefinition() {
978
+ return z11.partialRecord(
979
+ supportedLanguageSchema,
980
+ getBooleanValueContentSchemaFromFieldDefinition()
981
+ );
982
+ }
983
+ function getTranslatableReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
984
+ return z11.partialRecord(
985
+ supportedLanguageSchema,
986
+ getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition)
987
+ );
988
+ }
989
+ function getValueSchemaFromFieldDefinition(fieldDefinition) {
990
+ switch (fieldDefinition.valueType) {
991
+ case ValueTypeSchema.enum.boolean:
992
+ return directBooleanValueSchema.extend({
993
+ content: getTranslatableBooleanValueContentSchemaFromFieldDefinition()
994
+ });
995
+ case ValueTypeSchema.enum.number:
996
+ return directNumberValueSchema.extend({
997
+ content: getTranslatableNumberValueContentSchemaFromFieldDefinition(
998
+ fieldDefinition
999
+ )
1000
+ });
1001
+ case ValueTypeSchema.enum.string:
1002
+ return directStringValueSchema.extend({
1003
+ content: getTranslatableStringValueContentSchemaFromFieldDefinition(
1004
+ fieldDefinition
1005
+ )
1006
+ });
1007
+ case ValueTypeSchema.enum.reference:
1008
+ return referencedValueSchema.extend({
1009
+ content: getTranslatableReferenceValueContentSchemaFromFieldDefinition(
1010
+ fieldDefinition
1011
+ )
1012
+ });
1013
+ default:
1014
+ throw new Error(
1015
+ // @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
1016
+ `Error generating schema for unsupported ValueType "${fieldDefinition.valueType}"`
1017
+ );
1018
+ }
1019
+ }
1020
+ function getCreateEntrySchemaFromFieldDefinitions(fieldDefinitions, values) {
1021
+ const schema = {
1022
+ ...createEntrySchema,
1023
+ values: values.map((value) => {
1024
+ const fieldDefinition = fieldDefinitions.find(
1025
+ (fieldDefinition2) => fieldDefinition2.id === value.fieldDefinitionId
1026
+ );
1027
+ if (!fieldDefinition) {
1028
+ throw new Error(
1029
+ `Field definition with ID "${value.fieldDefinitionId}" not found`
1030
+ );
1031
+ }
1032
+ return getValueSchemaFromFieldDefinition(fieldDefinition);
1033
+ })
1034
+ };
1035
+ return schema;
1036
+ }
1037
+ function getUpdateEntrySchemaFromFieldDefinitions(fieldDefinitions, values) {
1038
+ const schema = {
1039
+ ...updateEntrySchema,
1040
+ values: values.map((value) => {
1041
+ const fieldDefinition = fieldDefinitions.find(
1042
+ (fieldDefinition2) => fieldDefinition2.id === value.fieldDefinitionId
1043
+ );
1044
+ if (!fieldDefinition) {
1045
+ throw new Error(
1046
+ `Field definition with ID "${value.fieldDefinitionId}" not found`
1047
+ );
1048
+ }
1049
+ return getValueSchemaFromFieldDefinition(fieldDefinition);
1050
+ })
1051
+ };
1052
+ return schema;
1053
+ }
1054
+
957
1055
  // src/schema/serviceSchema.ts
958
- import { z as z11 } from "zod";
959
- var serviceTypeSchema = z11.enum([
1056
+ import { z as z12 } from "zod";
1057
+ var serviceTypeSchema = z12.enum([
960
1058
  "Git",
961
1059
  "GitTag",
962
1060
  "User",
@@ -969,17 +1067,17 @@ var serviceTypeSchema = z11.enum([
969
1067
  "Value"
970
1068
  ]);
971
1069
  function paginatedListOf(schema) {
972
- return z11.object({
973
- total: z11.number(),
974
- limit: z11.number(),
975
- offset: z11.number(),
976
- list: z11.array(schema)
1070
+ return z12.object({
1071
+ total: z12.number(),
1072
+ limit: z12.number(),
1073
+ offset: z12.number(),
1074
+ list: z12.array(schema)
977
1075
  });
978
1076
  }
979
- var listSchema = z11.object({
1077
+ var listSchema = z12.object({
980
1078
  projectId: uuidSchema,
981
- limit: z11.number().optional(),
982
- offset: z11.number().optional()
1079
+ limit: z12.number().optional(),
1080
+ offset: z12.number().optional()
983
1081
  });
984
1082
  var listCollectionsSchema = listSchema;
985
1083
  var listEntriesSchema = listSchema.extend({
@@ -989,35 +1087,35 @@ var listAssetsSchema = listSchema;
989
1087
  var listProjectsSchema = listSchema.omit({
990
1088
  projectId: true
991
1089
  });
992
- var listGitTagsSchema = z11.object({
993
- path: z11.string()
1090
+ var listGitTagsSchema = z12.object({
1091
+ path: z12.string()
994
1092
  });
995
1093
 
996
1094
  // src/schema/userSchema.ts
997
- import z12 from "zod";
998
- var UserTypeSchema = z12.enum(["local", "cloud"]);
1095
+ import z13 from "zod";
1096
+ var UserTypeSchema = z13.enum(["local", "cloud"]);
999
1097
  var baseUserSchema = gitSignatureSchema.extend({
1000
1098
  userType: UserTypeSchema,
1001
1099
  language: supportedLanguageSchema,
1002
- localApi: z12.object({
1100
+ localApi: z13.object({
1003
1101
  /**
1004
1102
  * If set to true the local API is started whenever Core is initialized
1005
1103
  */
1006
- isEnabled: z12.boolean(),
1104
+ isEnabled: z13.boolean(),
1007
1105
  /**
1008
1106
  * The port the local API uses
1009
1107
  */
1010
- port: z12.number()
1108
+ port: z13.number()
1011
1109
  })
1012
1110
  });
1013
1111
  var localUserSchema = baseUserSchema.extend({
1014
- userType: z12.literal(UserTypeSchema.Enum.local)
1112
+ userType: z13.literal(UserTypeSchema.enum.local)
1015
1113
  });
1016
1114
  var cloudUserSchema = baseUserSchema.extend({
1017
- userType: z12.literal(UserTypeSchema.Enum.cloud),
1115
+ userType: z13.literal(UserTypeSchema.enum.cloud),
1018
1116
  id: uuidSchema
1019
1117
  });
1020
- var userFileSchema = z12.union([localUserSchema, cloudUserSchema]);
1118
+ var userFileSchema = z13.union([localUserSchema, cloudUserSchema]);
1021
1119
  var userSchema = userFileSchema;
1022
1120
  var setUserSchema = userSchema;
1023
1121
 
@@ -1063,7 +1161,7 @@ var listAssetsRoute = createRoute({
1063
1161
  path: "/projects/{projectId}/assets",
1064
1162
  operationId: "listAssets",
1065
1163
  request: {
1066
- params: z13.object({
1164
+ params: z14.object({
1067
1165
  projectId: uuidSchema.openapi({
1068
1166
  param: {
1069
1167
  name: "projectId",
@@ -1071,12 +1169,12 @@ var listAssetsRoute = createRoute({
1071
1169
  }
1072
1170
  })
1073
1171
  }),
1074
- query: z13.object({
1075
- limit: z13.string().pipe(z13.coerce.number()).optional().openapi({
1172
+ query: z14.object({
1173
+ limit: z14.string().pipe(z14.coerce.number()).optional().openapi({
1076
1174
  default: "15",
1077
1175
  description: "The maximum number of items to return"
1078
1176
  }),
1079
- offset: z13.string().pipe(z13.coerce.number()).optional().openapi({
1177
+ offset: z14.string().pipe(z14.coerce.number()).optional().openapi({
1080
1178
  default: "0",
1081
1179
  description: "The number of items to skip before starting to collect the result set"
1082
1180
  })
@@ -1100,7 +1198,7 @@ var countAssetsRoute = createRoute({
1100
1198
  path: "/projects/{projectId}/assets/count",
1101
1199
  operationId: "countAssets",
1102
1200
  request: {
1103
- params: z13.object({
1201
+ params: z14.object({
1104
1202
  projectId: uuidSchema.openapi({
1105
1203
  param: {
1106
1204
  name: "projectId",
@@ -1113,7 +1211,7 @@ var countAssetsRoute = createRoute({
1113
1211
  200: {
1114
1212
  content: {
1115
1213
  "application/json": {
1116
- schema: z13.number()
1214
+ schema: z14.number()
1117
1215
  }
1118
1216
  },
1119
1217
  description: "The number of Assets of the given Project"
@@ -1127,7 +1225,7 @@ var readAssetRoute = createRoute({
1127
1225
  path: "/projects/{projectId}/assets/{assetId}",
1128
1226
  operationId: "readAsset",
1129
1227
  request: {
1130
- params: z13.object({
1228
+ params: z14.object({
1131
1229
  projectId: uuidSchema.openapi({
1132
1230
  param: {
1133
1231
  name: "projectId",
@@ -1158,7 +1256,7 @@ var readAssetRoute = createRoute({
1158
1256
  });
1159
1257
 
1160
1258
  // src/api/v1/collection.ts
1161
- import { createRoute as createRoute2, OpenAPIHono as OpenAPIHono2, z as z14 } from "@hono/zod-openapi";
1259
+ import { createRoute as createRoute2, OpenAPIHono as OpenAPIHono2, z as z15 } from "@hono/zod-openapi";
1162
1260
  var CollectionApiV1 = class {
1163
1261
  api;
1164
1262
  collectionService;
@@ -1200,7 +1298,7 @@ var listCollectionsRoute = createRoute2({
1200
1298
  path: "/projects/{projectId}/collections",
1201
1299
  operationId: "listCollections",
1202
1300
  request: {
1203
- params: z14.object({
1301
+ params: z15.object({
1204
1302
  projectId: uuidSchema.openapi({
1205
1303
  param: {
1206
1304
  name: "projectId",
@@ -1208,12 +1306,12 @@ var listCollectionsRoute = createRoute2({
1208
1306
  }
1209
1307
  })
1210
1308
  }),
1211
- query: z14.object({
1212
- limit: z14.string().pipe(z14.coerce.number()).optional().openapi({
1309
+ query: z15.object({
1310
+ limit: z15.string().pipe(z15.coerce.number()).optional().openapi({
1213
1311
  default: "15",
1214
1312
  description: "The maximum number of items to return"
1215
1313
  }),
1216
- offset: z14.string().pipe(z14.coerce.number()).optional().openapi({
1314
+ offset: z15.string().pipe(z15.coerce.number()).optional().openapi({
1217
1315
  default: "0",
1218
1316
  description: "The number of items to skip before starting to collect the result set"
1219
1317
  })
@@ -1237,7 +1335,7 @@ var countCollectionsRoute = createRoute2({
1237
1335
  path: "/projects/{projectId}/collections/count",
1238
1336
  operationId: "countCollections",
1239
1337
  request: {
1240
- params: z14.object({
1338
+ params: z15.object({
1241
1339
  projectId: uuidSchema.openapi({
1242
1340
  param: {
1243
1341
  name: "projectId",
@@ -1250,7 +1348,7 @@ var countCollectionsRoute = createRoute2({
1250
1348
  200: {
1251
1349
  content: {
1252
1350
  "application/json": {
1253
- schema: z14.number()
1351
+ schema: z15.number()
1254
1352
  }
1255
1353
  },
1256
1354
  description: "The number of Collections of the given Project"
@@ -1264,7 +1362,7 @@ var readCollectionRoute = createRoute2({
1264
1362
  path: "/projects/{projectId}/collections/{collectionId}",
1265
1363
  operationId: "readCollection",
1266
1364
  request: {
1267
- params: z14.object({
1365
+ params: z15.object({
1268
1366
  projectId: uuidSchema.openapi({
1269
1367
  param: {
1270
1368
  name: "projectId",
@@ -1295,7 +1393,7 @@ var readCollectionRoute = createRoute2({
1295
1393
  });
1296
1394
 
1297
1395
  // src/api/v1/entry.ts
1298
- import { createRoute as createRoute3, OpenAPIHono as OpenAPIHono3, z as z15 } from "@hono/zod-openapi";
1396
+ import { createRoute as createRoute3, OpenAPIHono as OpenAPIHono3, z as z16 } from "@hono/zod-openapi";
1299
1397
  var EntryApiV1 = class {
1300
1398
  api;
1301
1399
  entryService;
@@ -1339,7 +1437,7 @@ var listEntriesRoute = createRoute3({
1339
1437
  path: "/projects/{projectId}/collections/{collectionId}/entries",
1340
1438
  operationId: "listEntries",
1341
1439
  request: {
1342
- params: z15.object({
1440
+ params: z16.object({
1343
1441
  projectId: uuidSchema.openapi({
1344
1442
  param: {
1345
1443
  name: "projectId",
@@ -1353,12 +1451,12 @@ var listEntriesRoute = createRoute3({
1353
1451
  }
1354
1452
  })
1355
1453
  }),
1356
- query: z15.object({
1357
- limit: z15.string().pipe(z15.coerce.number()).optional().openapi({
1454
+ query: z16.object({
1455
+ limit: z16.string().pipe(z16.coerce.number()).optional().openapi({
1358
1456
  default: "15",
1359
1457
  description: "The maximum number of items to return"
1360
1458
  }),
1361
- offset: z15.string().pipe(z15.coerce.number()).optional().openapi({
1459
+ offset: z16.string().pipe(z16.coerce.number()).optional().openapi({
1362
1460
  default: "0",
1363
1461
  description: "The number of items to skip before starting to collect the result set"
1364
1462
  })
@@ -1382,7 +1480,7 @@ var countEntriesRoute = createRoute3({
1382
1480
  path: "/projects/{projectId}/collections/{collectionId}/entries/count",
1383
1481
  operationId: "countEntries",
1384
1482
  request: {
1385
- params: z15.object({
1483
+ params: z16.object({
1386
1484
  projectId: uuidSchema.openapi({
1387
1485
  param: {
1388
1486
  name: "projectId",
@@ -1401,7 +1499,7 @@ var countEntriesRoute = createRoute3({
1401
1499
  200: {
1402
1500
  content: {
1403
1501
  "application/json": {
1404
- schema: z15.number()
1502
+ schema: z16.number()
1405
1503
  }
1406
1504
  },
1407
1505
  description: "The number of Entries of the given Project"
@@ -1415,7 +1513,7 @@ var readEntryRoute = createRoute3({
1415
1513
  path: "/projects/{projectId}/collections/{collectionId}/entries/{entryId}",
1416
1514
  operationId: "readCollection",
1417
1515
  request: {
1418
- params: z15.object({
1516
+ params: z16.object({
1419
1517
  projectId: uuidSchema.openapi({
1420
1518
  param: {
1421
1519
  name: "projectId",
@@ -1452,7 +1550,7 @@ var readEntryRoute = createRoute3({
1452
1550
  });
1453
1551
 
1454
1552
  // src/api/v1/project.ts
1455
- import { createRoute as createRoute4, OpenAPIHono as OpenAPIHono4, z as z16 } from "@hono/zod-openapi";
1553
+ import { createRoute as createRoute4, OpenAPIHono as OpenAPIHono4, z as z17 } from "@hono/zod-openapi";
1456
1554
  var ProjectApiV1 = class {
1457
1555
  api;
1458
1556
  projectService;
@@ -1485,12 +1583,12 @@ var listProjectsRoute = createRoute4({
1485
1583
  path: "/projects",
1486
1584
  operationId: "listProjects",
1487
1585
  request: {
1488
- query: z16.object({
1489
- limit: z16.string().pipe(z16.coerce.number()).optional().openapi({
1586
+ query: z17.object({
1587
+ limit: z17.string().pipe(z17.coerce.number()).optional().openapi({
1490
1588
  default: "15",
1491
1589
  description: "The maximum number of items to return"
1492
1590
  }),
1493
- offset: z16.string().pipe(z16.coerce.number()).optional().openapi({
1591
+ offset: z17.string().pipe(z17.coerce.number()).optional().openapi({
1494
1592
  default: "0",
1495
1593
  description: "The number of items to skip before starting to collect the result set"
1496
1594
  })
@@ -1517,7 +1615,7 @@ var countProjectsRoute = createRoute4({
1517
1615
  200: {
1518
1616
  content: {
1519
1617
  "application/json": {
1520
- schema: z16.number()
1618
+ schema: z17.number()
1521
1619
  }
1522
1620
  },
1523
1621
  description: "The number of Projects you have acces to"
@@ -1531,7 +1629,7 @@ var readProjectRoute = createRoute4({
1531
1629
  path: "/projects/{projectId}",
1532
1630
  operationId: "readProject",
1533
1631
  request: {
1534
- params: z16.object({
1632
+ params: z17.object({
1535
1633
  projectId: uuidSchema.openapi({
1536
1634
  param: {
1537
1635
  name: "projectId",
@@ -1730,18 +1828,18 @@ var pathTo = {
1730
1828
  return Path.join(pathTo.project(projectId), "project.json");
1731
1829
  },
1732
1830
  // projectLogs: (projectId: string): string => {
1733
- // return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.logs);
1831
+ // return Path.join(pathTo.project(projectId), projectFolderSchema.enum.logs);
1734
1832
  // },
1735
1833
  // public: (projectId: string): string => {
1736
1834
  // return Path.join(pathTo.project(projectId), 'public');
1737
1835
  // },
1738
1836
  lfs: (projectId) => {
1739
- return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
1837
+ return Path.join(pathTo.project(projectId), projectFolderSchema.enum.lfs);
1740
1838
  },
1741
1839
  collections: (projectId) => {
1742
1840
  return Path.join(
1743
1841
  pathTo.project(projectId),
1744
- projectFolderSchema.Enum.collections
1842
+ projectFolderSchema.enum.collections
1745
1843
  );
1746
1844
  },
1747
1845
  collection: (projectId, id) => {
@@ -1765,7 +1863,7 @@ var pathTo = {
1765
1863
  assets: (projectId) => {
1766
1864
  return Path.join(
1767
1865
  pathTo.project(projectId),
1768
- projectFolderSchema.Enum.assets
1866
+ projectFolderSchema.enum.assets
1769
1867
  );
1770
1868
  },
1771
1869
  assetFile: (projectId, id) => {
@@ -1833,12 +1931,14 @@ async function files(path, extension) {
1833
1931
  var AbstractCrudService = class {
1834
1932
  type;
1835
1933
  options;
1934
+ logService;
1836
1935
  /**
1837
1936
  * Do not instantiate directly as this is an abstract class
1838
1937
  */
1839
- constructor(type, options) {
1938
+ constructor(type, options, logService) {
1840
1939
  this.type = type;
1841
1940
  this.options = options;
1941
+ this.logService = logService;
1842
1942
  }
1843
1943
  /**
1844
1944
  * Returns a list of all file references of given project and type
@@ -1849,20 +1949,20 @@ var AbstractCrudService = class {
1849
1949
  */
1850
1950
  async listReferences(type, projectId, collectionId) {
1851
1951
  switch (type) {
1852
- case objectTypeSchema.Enum.asset:
1952
+ case objectTypeSchema.enum.asset:
1853
1953
  if (!projectId) {
1854
1954
  throw new RequiredParameterMissingError("projectId");
1855
1955
  }
1856
1956
  return this.getFileReferences(pathTo.lfs(projectId));
1857
1957
  // LFS folder is correct, since we want the extension of the file itself, not the AssetFile (.json)
1858
- case objectTypeSchema.Enum.project:
1958
+ case objectTypeSchema.enum.project:
1859
1959
  return this.getFolderReferences(pathTo.projects);
1860
- case objectTypeSchema.Enum.collection:
1960
+ case objectTypeSchema.enum.collection:
1861
1961
  if (!projectId) {
1862
1962
  throw new RequiredParameterMissingError("projectId");
1863
1963
  }
1864
1964
  return this.getFolderReferences(pathTo.collections(projectId));
1865
- case objectTypeSchema.Enum.entry:
1965
+ case objectTypeSchema.enum.entry:
1866
1966
  if (!projectId) {
1867
1967
  throw new RequiredParameterMissingError("projectId");
1868
1968
  }
@@ -1872,7 +1972,7 @@ var AbstractCrudService = class {
1872
1972
  return this.getFileReferences(
1873
1973
  pathTo.collection(projectId, collectionId)
1874
1974
  );
1875
- case objectTypeSchema.Enum.sharedValue:
1975
+ case objectTypeSchema.enum.sharedValue:
1876
1976
  if (!projectId) {
1877
1977
  throw new RequiredParameterMissingError("projectId");
1878
1978
  }
@@ -1889,7 +1989,10 @@ var AbstractCrudService = class {
1889
1989
  };
1890
1990
  try {
1891
1991
  return fileReferenceSchema.parse(folderReference);
1892
- } catch (error) {
1992
+ } catch {
1993
+ this.logService.warn(
1994
+ `[getFolderReferences] Ignoring folder "${possibleFolder.name}" in "${path}" as it does not match the expected format`
1995
+ );
1893
1996
  return null;
1894
1997
  }
1895
1998
  });
@@ -1912,7 +2015,10 @@ var AbstractCrudService = class {
1912
2015
  };
1913
2016
  try {
1914
2017
  return fileReferenceSchema.parse(fileReference);
1915
- } catch (error) {
2018
+ } catch {
2019
+ this.logService.warn(
2020
+ `[getFileReferences] Ignoring file "${possibleFile.name}" in "${path}" as it does not match the expected format`
2021
+ );
1916
2022
  return null;
1917
2023
  }
1918
2024
  })
@@ -1947,13 +2053,10 @@ function slug(string) {
1947
2053
 
1948
2054
  // src/service/AssetService.ts
1949
2055
  var AssetService = class extends AbstractCrudService {
1950
- // @ts-ignore
1951
- logService;
1952
2056
  jsonFileService;
1953
2057
  gitService;
1954
2058
  constructor(options, logService, jsonFileService, gitService) {
1955
- super(serviceTypeSchema.Enum.Asset, options);
1956
- this.logService = logService;
2059
+ super(serviceTypeSchema.enum.Asset, options, logService);
1957
2060
  this.jsonFileService = jsonFileService;
1958
2061
  this.gitService = gitService;
1959
2062
  }
@@ -2111,7 +2214,7 @@ var AssetService = class extends AbstractCrudService {
2111
2214
  const offset = props.offset || 0;
2112
2215
  const limit = props.limit || 15;
2113
2216
  const assetReferences = await this.listReferences(
2114
- objectTypeSchema.Enum.asset,
2217
+ objectTypeSchema.enum.asset,
2115
2218
  props.projectId
2116
2219
  );
2117
2220
  const partialAssetReferences = assetReferences.slice(offset, limit);
@@ -2132,7 +2235,7 @@ var AssetService = class extends AbstractCrudService {
2132
2235
  }
2133
2236
  async count(props) {
2134
2237
  countAssetsSchema.parse(props);
2135
- const count = (await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)).length;
2238
+ const count = (await this.listReferences(objectTypeSchema.enum.asset, props.projectId)).length;
2136
2239
  return count;
2137
2240
  }
2138
2241
  /**
@@ -2202,8 +2305,8 @@ import Fs3 from "fs-extra";
2202
2305
  var CollectionService = class extends AbstractCrudService {
2203
2306
  jsonFileService;
2204
2307
  gitService;
2205
- constructor(options, jsonFileService, gitService) {
2206
- super(serviceTypeSchema.Enum.Collection, options);
2308
+ constructor(options, logService, jsonFileService, gitService) {
2309
+ super(serviceTypeSchema.enum.Collection, options, logService);
2207
2310
  this.jsonFileService = jsonFileService;
2208
2311
  this.gitService = gitService;
2209
2312
  }
@@ -2319,7 +2422,7 @@ var CollectionService = class extends AbstractCrudService {
2319
2422
  const offset = props.offset || 0;
2320
2423
  const limit = props.limit || 15;
2321
2424
  const collectionReferences = await this.listReferences(
2322
- objectTypeSchema.Enum.collection,
2425
+ objectTypeSchema.enum.collection,
2323
2426
  props.projectId
2324
2427
  );
2325
2428
  const partialCollectionReferences = collectionReferences.slice(
@@ -2344,7 +2447,7 @@ var CollectionService = class extends AbstractCrudService {
2344
2447
  async count(props) {
2345
2448
  countCollectionsSchema.parse(props);
2346
2449
  const count = (await this.listReferences(
2347
- objectTypeSchema.Enum.collection,
2450
+ objectTypeSchema.enum.collection,
2348
2451
  props.projectId
2349
2452
  )).length;
2350
2453
  return count;
@@ -2382,14 +2485,12 @@ var CollectionService = class extends AbstractCrudService {
2382
2485
  // src/service/EntryService.ts
2383
2486
  import Fs4 from "fs-extra";
2384
2487
  var EntryService = class extends AbstractCrudService {
2385
- logService;
2386
2488
  jsonFileService;
2387
2489
  gitService;
2388
2490
  collectionService;
2389
2491
  // private sharedValueService: SharedValueService;
2390
2492
  constructor(options, logService, jsonFileService, gitService, collectionService) {
2391
- super(serviceTypeSchema.Enum.Entry, options);
2392
- this.logService = logService;
2493
+ super(serviceTypeSchema.enum.Entry, options, logService);
2393
2494
  this.jsonFileService = jsonFileService;
2394
2495
  this.gitService = gitService;
2395
2496
  this.collectionService = collectionService;
@@ -2422,11 +2523,11 @@ var EntryService = class extends AbstractCrudService {
2422
2523
  props.collectionId,
2423
2524
  entryFile
2424
2525
  );
2425
- this.validateValues({
2426
- collectionId: props.collectionId,
2427
- fieldDefinitions: collection.fieldDefinitions,
2428
- values: entry.values
2429
- });
2526
+ const createEntrySchemaFromFieldDefinitions = getCreateEntrySchemaFromFieldDefinitions(
2527
+ collection.fieldDefinitions,
2528
+ entry.values
2529
+ );
2530
+ createEntrySchemaFromFieldDefinitions.parse(props);
2430
2531
  await this.jsonFileService.create(
2431
2532
  entryFile,
2432
2533
  entryFilePath,
@@ -2499,11 +2600,11 @@ var EntryService = class extends AbstractCrudService {
2499
2600
  props.collectionId,
2500
2601
  entryFile
2501
2602
  );
2502
- this.validateValues({
2503
- collectionId: props.collectionId,
2504
- fieldDefinitions: collection.fieldDefinitions,
2505
- values: entry.values
2506
- });
2603
+ const updateEntrySchemaFromFieldDefinitions = getUpdateEntrySchemaFromFieldDefinitions(
2604
+ collection.fieldDefinitions,
2605
+ entry.values
2606
+ );
2607
+ updateEntrySchemaFromFieldDefinitions.parse(props);
2507
2608
  await this.jsonFileService.update(
2508
2609
  entryFile,
2509
2610
  entryFilePath,
@@ -2547,7 +2648,7 @@ var EntryService = class extends AbstractCrudService {
2547
2648
  const offset = props.offset || 0;
2548
2649
  const limit = props.limit || 15;
2549
2650
  const entryReferences = await this.listReferences(
2550
- objectTypeSchema.Enum.entry,
2651
+ objectTypeSchema.enum.entry,
2551
2652
  props.projectId,
2552
2653
  props.collectionId
2553
2654
  );
@@ -2571,7 +2672,7 @@ var EntryService = class extends AbstractCrudService {
2571
2672
  async count(props) {
2572
2673
  countEntriesSchema.parse(props);
2573
2674
  return (await this.listReferences(
2574
- objectTypeSchema.Enum.entry,
2675
+ objectTypeSchema.enum.entry,
2575
2676
  props.projectId,
2576
2677
  props.collectionId
2577
2678
  )).length;
@@ -2588,47 +2689,6 @@ var EntryService = class extends AbstractCrudService {
2588
2689
  migrate(potentiallyOutdatedEntryFile) {
2589
2690
  return entryFileSchema.parse(potentiallyOutdatedEntryFile);
2590
2691
  }
2591
- /**
2592
- * Returns a Field definition by ID
2593
- */
2594
- getFieldDefinitionById(props) {
2595
- const fieldDefinition = props.fieldDefinitions.find((definition) => {
2596
- if (definition.id === props.id) {
2597
- return true;
2598
- }
2599
- return false;
2600
- });
2601
- if (!fieldDefinition) {
2602
- throw new Error(
2603
- `No Field definition with ID "${props.id}" found in Collection "${props.collectionId}" for given Value reference`
2604
- );
2605
- }
2606
- return fieldDefinition;
2607
- }
2608
- /**
2609
- * Validates given Values against their Collections Field definitions
2610
- */
2611
- validateValues(props) {
2612
- props.values.map((value) => {
2613
- const fieldDefinition = this.getFieldDefinitionById({
2614
- collectionId: props.collectionId,
2615
- fieldDefinitions: props.fieldDefinitions,
2616
- id: value.fieldDefinitionId
2617
- });
2618
- const contentSchema = getValueContentSchemaFromFieldDefinition(fieldDefinition);
2619
- this.logService.debug(
2620
- "Validating Value against content schema generated from Field definition",
2621
- {
2622
- value,
2623
- contentSchema,
2624
- fieldDefinition
2625
- }
2626
- );
2627
- for (const [_language, content] of Object.entries(value.content)) {
2628
- contentSchema.parse(content);
2629
- }
2630
- });
2631
- }
2632
2692
  /**
2633
2693
  * Creates an Entry from given EntryFile by resolving it's Values
2634
2694
  */
@@ -2651,8 +2711,8 @@ import Path2 from "path";
2651
2711
  // src/service/GitTagService.ts
2652
2712
  var GitTagService = class extends AbstractCrudService {
2653
2713
  git;
2654
- constructor(options, git) {
2655
- super(serviceTypeSchema.Enum.GitTag, options);
2714
+ constructor(options, git, logService) {
2715
+ super(serviceTypeSchema.enum.GitTag, options, logService);
2656
2716
  this.git = git;
2657
2717
  }
2658
2718
  /**
@@ -2796,7 +2856,11 @@ var GitService = class {
2796
2856
  concurrency: 1
2797
2857
  // No concurrency because git operations are sequencial
2798
2858
  });
2799
- this.gitTagService = new GitTagService(options, this.git.bind(this));
2859
+ this.gitTagService = new GitTagService(
2860
+ options,
2861
+ this.git.bind(this),
2862
+ logService
2863
+ );
2800
2864
  this.logService = logService;
2801
2865
  this.userService = userService;
2802
2866
  this.updateVersion();
@@ -3322,10 +3386,8 @@ var GitService = class {
3322
3386
  import Fs5 from "fs-extra";
3323
3387
  var JsonFileService = class extends AbstractCrudService {
3324
3388
  cache = /* @__PURE__ */ new Map();
3325
- logService;
3326
3389
  constructor(options, logService) {
3327
- super(serviceTypeSchema.Enum.JsonFile, options);
3328
- this.logService = logService;
3390
+ super(serviceTypeSchema.enum.JsonFile, options, logService);
3329
3391
  }
3330
3392
  /**
3331
3393
  * Creates a new file on disk. Fails if path already exists
@@ -3342,7 +3404,9 @@ var JsonFileService = class extends AbstractCrudService {
3342
3404
  flag: "wx",
3343
3405
  encoding: "utf8"
3344
3406
  });
3345
- this.options.file.cache === true && this.cache.set(path, parsedData);
3407
+ if (this.options.file.cache === true) {
3408
+ this.cache.set(path, parsedData);
3409
+ }
3346
3410
  this.logService.debug(`Created file "${path}"`);
3347
3411
  return parsedData;
3348
3412
  }
@@ -3367,7 +3431,9 @@ var JsonFileService = class extends AbstractCrudService {
3367
3431
  });
3368
3432
  const json = this.deserialize(data);
3369
3433
  const parsedData = schema.parse(json);
3370
- this.options.file.cache === true && this.cache.set(path, parsedData);
3434
+ if (this.options.file.cache === true) {
3435
+ this.cache.set(path, parsedData);
3436
+ }
3371
3437
  return parsedData;
3372
3438
  }
3373
3439
  /**
@@ -3408,7 +3474,9 @@ var JsonFileService = class extends AbstractCrudService {
3408
3474
  flag: "w",
3409
3475
  encoding: "utf8"
3410
3476
  });
3411
- this.options.file.cache === true && this.cache.set(path, parsedData);
3477
+ if (this.options.file.cache === true) {
3478
+ this.cache.set(path, parsedData);
3479
+ }
3412
3480
  this.logService.debug(`Updated file "${path}"`);
3413
3481
  return parsedData;
3414
3482
  }
@@ -3509,7 +3577,6 @@ var SynchronizeLocalChangesError = class extends Error {
3509
3577
  // src/service/ProjectService.ts
3510
3578
  var ProjectService = class extends AbstractCrudService {
3511
3579
  coreVersion;
3512
- logService;
3513
3580
  jsonFileService;
3514
3581
  userService;
3515
3582
  gitService;
@@ -3517,9 +3584,8 @@ var ProjectService = class extends AbstractCrudService {
3517
3584
  collectionService;
3518
3585
  entryService;
3519
3586
  constructor(coreVersion, options, logService, jsonFileService, userService, gitService, assetService, collectionService, entryService) {
3520
- super(serviceTypeSchema.Enum.Project, options);
3587
+ super(serviceTypeSchema.enum.Project, options, logService);
3521
3588
  this.coreVersion = coreVersion;
3522
- this.logService = logService;
3523
3589
  this.jsonFileService = jsonFileService;
3524
3590
  this.userService = userService;
3525
3591
  this.gitService = gitService;
@@ -3561,7 +3627,7 @@ var ProjectService = class extends AbstractCrudService {
3561
3627
  await this.createFolderStructure(projectPath);
3562
3628
  await this.createGitignore(projectPath);
3563
3629
  await this.gitService.init(projectPath, {
3564
- initialBranch: projectBranchSchema.Enum.production
3630
+ initialBranch: projectBranchSchema.enum.production
3565
3631
  });
3566
3632
  await this.jsonFileService.create(
3567
3633
  projectFile,
@@ -3575,7 +3641,7 @@ var ProjectService = class extends AbstractCrudService {
3575
3641
  });
3576
3642
  await this.gitService.branches.switch(
3577
3643
  projectPath,
3578
- projectBranchSchema.Enum.work,
3644
+ projectBranchSchema.enum.work,
3579
3645
  {
3580
3646
  isNew: true
3581
3647
  }
@@ -3677,10 +3743,10 @@ var ProjectService = class extends AbstractCrudService {
3677
3743
  const projectPath = pathTo.project(props.id);
3678
3744
  const projectFilePath = pathTo.projectFile(props.id);
3679
3745
  const currentBranch = await this.gitService.branches.current(projectPath);
3680
- if (currentBranch !== projectBranchSchema.Enum.work) {
3746
+ if (currentBranch !== projectBranchSchema.enum.work) {
3681
3747
  await this.gitService.branches.switch(
3682
3748
  projectPath,
3683
- projectBranchSchema.Enum.work
3749
+ projectBranchSchema.enum.work
3684
3750
  );
3685
3751
  }
3686
3752
  const currentProjectFile = outdatedProjectSchema.passthrough().parse(await this.jsonFileService.unsafeRead(projectFilePath));
@@ -3740,7 +3806,7 @@ var ProjectService = class extends AbstractCrudService {
3740
3806
  await this.update(migratedProjectFile);
3741
3807
  await this.gitService.branches.switch(
3742
3808
  projectPath,
3743
- projectBranchSchema.Enum.work
3809
+ projectBranchSchema.enum.work
3744
3810
  );
3745
3811
  await this.gitService.merge(projectPath, upgradeBranchName, {
3746
3812
  squash: true
@@ -3768,7 +3834,7 @@ var ProjectService = class extends AbstractCrudService {
3768
3834
  } catch (error) {
3769
3835
  await this.gitService.branches.switch(
3770
3836
  projectPath,
3771
- projectBranchSchema.Enum.work
3837
+ projectBranchSchema.enum.work
3772
3838
  );
3773
3839
  await this.gitService.branches.delete(
3774
3840
  projectPath,
@@ -3830,9 +3896,7 @@ var ProjectService = class extends AbstractCrudService {
3830
3896
  async getChanges(props) {
3831
3897
  getChangesProjectSchema.parse(props);
3832
3898
  const projectPath = pathTo.project(props.id);
3833
- const hasRemoteOrigin = await this.gitService.remotes.hasOrigin(
3834
- projectPath
3835
- );
3899
+ const hasRemoteOrigin = await this.gitService.remotes.hasOrigin(projectPath);
3836
3900
  if (hasRemoteOrigin === false) {
3837
3901
  throw new Error(`Project "${props.id}" does not have a remote origin`);
3838
3902
  }
@@ -3887,7 +3951,7 @@ var ProjectService = class extends AbstractCrudService {
3887
3951
  */
3888
3952
  async listOutdated() {
3889
3953
  const projectReferences = await this.listReferences(
3890
- objectTypeSchema.Enum.project
3954
+ objectTypeSchema.enum.project
3891
3955
  );
3892
3956
  const result = await Promise.all(
3893
3957
  projectReferences.map(async (reference) => {
@@ -3910,7 +3974,7 @@ var ProjectService = class extends AbstractCrudService {
3910
3974
  const offset = props?.offset || 0;
3911
3975
  const limit = props?.limit || 15;
3912
3976
  const projectReferences = await this.listReferences(
3913
- objectTypeSchema.Enum.project
3977
+ objectTypeSchema.enum.project
3914
3978
  );
3915
3979
  const partialProjectReferences = projectReferences.slice(offset, limit);
3916
3980
  const projects = await returnResolved(
@@ -3926,7 +3990,7 @@ var ProjectService = class extends AbstractCrudService {
3926
3990
  };
3927
3991
  }
3928
3992
  async count() {
3929
- return (await this.listReferences(objectTypeSchema.Enum.project)).length;
3993
+ return (await this.listReferences(objectTypeSchema.enum.project)).length;
3930
3994
  }
3931
3995
  /**
3932
3996
  * Checks if given object is of type Project
@@ -3999,7 +4063,7 @@ var ProjectService = class extends AbstractCrudService {
3999
4063
  * committed
4000
4064
  */
4001
4065
  async createFolderStructure(path) {
4002
- const folders2 = Object.values(projectFolderSchema.Values);
4066
+ const folders2 = Object.values(projectFolderSchema.enum);
4003
4067
  await Promise.all(
4004
4068
  folders2.map(async (folder) => {
4005
4069
  await Fs6.mkdirp(Path4.join(path, folder));
@@ -4023,9 +4087,9 @@ var ProjectService = class extends AbstractCrudService {
4023
4087
  "!/**/.gitkeep",
4024
4088
  "",
4025
4089
  "# elek.io related ignores"
4026
- // projectFolderSchema.Enum.theme + '/',
4027
- // projectFolderSchema.Enum.public + '/',
4028
- // projectFolderSchema.Enum.logs + '/',
4090
+ // projectFolderSchema.enum.theme + '/',
4091
+ // projectFolderSchema.enum.public + '/',
4092
+ // projectFolderSchema.enum.logs + '/',
4029
4093
  ];
4030
4094
  await Fs6.writeFile(Path4.join(path, ".gitignore"), lines.join(Os2.EOL));
4031
4095
  }
@@ -4033,9 +4097,7 @@ var ProjectService = class extends AbstractCrudService {
4033
4097
  switch (objectType) {
4034
4098
  case "asset": {
4035
4099
  const assetFilePath = pathTo.assetFile(projectId, reference.id);
4036
- const prevAssetFile = await this.jsonFileService.unsafeRead(
4037
- assetFilePath
4038
- );
4100
+ const prevAssetFile = await this.jsonFileService.unsafeRead(assetFilePath);
4039
4101
  const migratedAssetFile = this.assetService.migrate(prevAssetFile);
4040
4102
  await this.assetService.update({ projectId, ...migratedAssetFile });
4041
4103
  this.logService.info(`Upgraded ${objectType} "${assetFilePath}"`, {
@@ -4049,9 +4111,7 @@ var ProjectService = class extends AbstractCrudService {
4049
4111
  projectId,
4050
4112
  reference.id
4051
4113
  );
4052
- const prevCollectionFile = await this.jsonFileService.unsafeRead(
4053
- collectionFilePath
4054
- );
4114
+ const prevCollectionFile = await this.jsonFileService.unsafeRead(collectionFilePath);
4055
4115
  const migratedCollectionFile = this.collectionService.migrate(prevCollectionFile);
4056
4116
  await this.collectionService.update({
4057
4117
  projectId,
@@ -4072,9 +4132,7 @@ var ProjectService = class extends AbstractCrudService {
4072
4132
  collectionId,
4073
4133
  reference.id
4074
4134
  );
4075
- const prevEntryFile = await this.jsonFileService.unsafeRead(
4076
- entryFilePath
4077
- );
4135
+ const prevEntryFile = await this.jsonFileService.unsafeRead(entryFilePath);
4078
4136
  const migratedEntryFile = this.entryService.migrate(prevEntryFile);
4079
4137
  await this.entryService.update({
4080
4138
  projectId,
@@ -4109,7 +4167,7 @@ var UserService = class {
4109
4167
  async get() {
4110
4168
  try {
4111
4169
  return await this.jsonFileService.read(pathTo.userFile, userFileSchema);
4112
- } catch (error) {
4170
+ } catch {
4113
4171
  this.logService.info("No User found");
4114
4172
  return null;
4115
4173
  }
@@ -4125,7 +4183,7 @@ var UserService = class {
4125
4183
  const userFile = {
4126
4184
  ...props
4127
4185
  };
4128
- if (userFile.userType === UserTypeSchema.Enum.cloud) {
4186
+ if (userFile.userType === UserTypeSchema.enum.cloud) {
4129
4187
  }
4130
4188
  await this.jsonFileService.update(userFile, userFilePath, userFileSchema);
4131
4189
  this.logService.debug("Updated User");
@@ -4174,6 +4232,7 @@ var ElekIoCore = class {
4174
4232
  );
4175
4233
  this.collectionService = new CollectionService(
4176
4234
  this.options,
4235
+ this.logService,
4177
4236
  this.jsonFileService,
4178
4237
  this.gitService
4179
4238
  );
@@ -4320,8 +4379,10 @@ export {
4320
4379
  fieldDefinitionSchema,
4321
4380
  fileReferenceSchema,
4322
4381
  getChangesProjectSchema,
4382
+ getCreateEntrySchemaFromFieldDefinitions,
4323
4383
  getRemoteOriginUrlProjectSchema,
4324
- getValueContentSchemaFromFieldDefinition,
4384
+ getUpdateEntrySchemaFromFieldDefinitions,
4385
+ getValueSchemaFromFieldDefinition,
4325
4386
  gitCloneOptionsSchema,
4326
4387
  gitCommitSchema,
4327
4388
  gitInitOptionsSchema,
@@ -4331,7 +4392,7 @@ export {
4331
4392
  gitSignatureSchema,
4332
4393
  gitSwitchOptionsSchema,
4333
4394
  gitTagSchema,
4334
- ipFieldDefinitionSchema,
4395
+ ipv4FieldDefinitionSchema,
4335
4396
  listAssetsSchema,
4336
4397
  listBranchesProjectSchema,
4337
4398
  listCollectionsSchema,