@elek-io/core 0.14.4 → 0.15.1
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 +2096 -1461
- package/dist/browser/index.browser.js +193 -126
- package/dist/browser/index.browser.js.map +1 -1
- package/dist/node/index.node.d.ts +2097 -1462
- package/dist/node/index.node.js +293 -262
- package/dist/node/index.node.js.map +1 -1
- package/package.json +35 -26
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { z as z4 } from "@hono/zod-openapi";
|
|
3
3
|
|
|
4
4
|
// src/schema/baseSchema.ts
|
|
5
|
-
import z from "zod";
|
|
5
|
+
import { z } from "@hono/zod-openapi";
|
|
6
6
|
var supportedLanguageSchema = z.enum([
|
|
7
7
|
/**
|
|
8
8
|
* Bulgarian
|
|
@@ -89,7 +89,7 @@ function translatableArrayOf(schema) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// src/schema/fileSchema.ts
|
|
92
|
-
import z2 from "zod";
|
|
92
|
+
import { z as z2 } from "@hono/zod-openapi";
|
|
93
93
|
var baseFileSchema = z2.object({
|
|
94
94
|
/**
|
|
95
95
|
* The object type of the file
|
|
@@ -116,7 +116,7 @@ var fileReferenceSchema = z2.object({
|
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
// src/schema/gitSchema.ts
|
|
119
|
-
import { z as z3 } from "zod";
|
|
119
|
+
import { z as z3 } from "@hono/zod-openapi";
|
|
120
120
|
var gitSignatureSchema = z3.object({
|
|
121
121
|
name: z3.string(),
|
|
122
122
|
email: z3.string().email()
|
|
@@ -305,7 +305,7 @@ import { z as z8 } from "@hono/zod-openapi";
|
|
|
305
305
|
import { z as z6 } from "@hono/zod-openapi";
|
|
306
306
|
|
|
307
307
|
// src/schema/valueSchema.ts
|
|
308
|
-
import z5 from "zod";
|
|
308
|
+
import { z as z5 } from "@hono/zod-openapi";
|
|
309
309
|
var ValueTypeSchema = z5.enum([
|
|
310
310
|
"string",
|
|
311
311
|
"number",
|
|
@@ -402,7 +402,7 @@ var countEntriesSchema = z6.object({
|
|
|
402
402
|
});
|
|
403
403
|
|
|
404
404
|
// src/schema/fieldSchema.ts
|
|
405
|
-
import { z as z7 } from "zod";
|
|
405
|
+
import { z as z7 } from "@hono/zod-openapi";
|
|
406
406
|
var FieldTypeSchema = z7.enum([
|
|
407
407
|
// String Values
|
|
408
408
|
"text",
|
|
@@ -429,7 +429,7 @@ var FieldWidthSchema = z7.enum(["12", "6", "4", "3"]);
|
|
|
429
429
|
var FieldDefinitionBaseSchema = z7.object({
|
|
430
430
|
id: uuidSchema.readonly(),
|
|
431
431
|
label: translatableStringSchema,
|
|
432
|
-
description: translatableStringSchema,
|
|
432
|
+
description: translatableStringSchema.nullable(),
|
|
433
433
|
isRequired: z7.boolean(),
|
|
434
434
|
isDisabled: z7.boolean(),
|
|
435
435
|
isUnique: z7.boolean(),
|
|
@@ -551,104 +551,6 @@ var fieldDefinitionSchema = z7.union([
|
|
|
551
551
|
entryFieldDefinitionSchema
|
|
552
552
|
// sharedValueDefinitionSchema,
|
|
553
553
|
]);
|
|
554
|
-
function getValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
555
|
-
switch (fieldDefinition.valueType) {
|
|
556
|
-
case ValueTypeSchema.enum.boolean:
|
|
557
|
-
return getBooleanValueContentSchema();
|
|
558
|
-
case ValueTypeSchema.enum.number:
|
|
559
|
-
return getNumberValueContentSchema(fieldDefinition);
|
|
560
|
-
case ValueTypeSchema.enum.string:
|
|
561
|
-
return getStringValueContentSchema(fieldDefinition);
|
|
562
|
-
case ValueTypeSchema.enum.reference:
|
|
563
|
-
return getReferenceValueContentSchema(fieldDefinition);
|
|
564
|
-
default:
|
|
565
|
-
throw new Error(
|
|
566
|
-
// @ts-expect-error
|
|
567
|
-
`Error generating schema for unsupported ValueType "${fieldDefinition.valueType}"`
|
|
568
|
-
);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
function getBooleanValueContentSchema() {
|
|
572
|
-
return z7.boolean();
|
|
573
|
-
}
|
|
574
|
-
function getNumberValueContentSchema(definition) {
|
|
575
|
-
let schema = z7.number();
|
|
576
|
-
if (definition.min) {
|
|
577
|
-
schema = schema.min(definition.min);
|
|
578
|
-
}
|
|
579
|
-
if (definition.max) {
|
|
580
|
-
schema = schema.max(definition.max);
|
|
581
|
-
}
|
|
582
|
-
if (definition.isRequired === false) {
|
|
583
|
-
return schema.nullable();
|
|
584
|
-
}
|
|
585
|
-
return schema;
|
|
586
|
-
}
|
|
587
|
-
function getStringValueContentSchema(definition) {
|
|
588
|
-
let schema = null;
|
|
589
|
-
switch (definition.fieldType) {
|
|
590
|
-
case FieldTypeSchema.enum.email:
|
|
591
|
-
schema = z7.email();
|
|
592
|
-
break;
|
|
593
|
-
case FieldTypeSchema.enum.url:
|
|
594
|
-
schema = z7.url();
|
|
595
|
-
break;
|
|
596
|
-
case FieldTypeSchema.enum.ipv4:
|
|
597
|
-
schema = z7.ipv4();
|
|
598
|
-
break;
|
|
599
|
-
case FieldTypeSchema.enum.date:
|
|
600
|
-
schema = z7.iso.date();
|
|
601
|
-
break;
|
|
602
|
-
case FieldTypeSchema.enum.time:
|
|
603
|
-
schema = z7.iso.time();
|
|
604
|
-
break;
|
|
605
|
-
case FieldTypeSchema.enum.datetime:
|
|
606
|
-
schema = z7.iso.datetime();
|
|
607
|
-
break;
|
|
608
|
-
case FieldTypeSchema.enum.telephone:
|
|
609
|
-
schema = z7.e164();
|
|
610
|
-
break;
|
|
611
|
-
case FieldTypeSchema.enum.text:
|
|
612
|
-
case FieldTypeSchema.enum.textarea:
|
|
613
|
-
schema = z7.string().trim();
|
|
614
|
-
break;
|
|
615
|
-
}
|
|
616
|
-
if ("min" in definition && definition.min) {
|
|
617
|
-
schema = schema.min(definition.min);
|
|
618
|
-
}
|
|
619
|
-
if ("max" in definition && definition.max) {
|
|
620
|
-
schema = schema.max(definition.max);
|
|
621
|
-
}
|
|
622
|
-
if (definition.isRequired === false) {
|
|
623
|
-
return schema.nullable();
|
|
624
|
-
}
|
|
625
|
-
return schema.min(1, "shared.stringValueRequired");
|
|
626
|
-
}
|
|
627
|
-
function getReferenceValueContentSchema(definition) {
|
|
628
|
-
let schema;
|
|
629
|
-
switch (definition.fieldType) {
|
|
630
|
-
case FieldTypeSchema.enum.asset:
|
|
631
|
-
{
|
|
632
|
-
schema = z7.array(valueContentReferenceToAssetSchema);
|
|
633
|
-
}
|
|
634
|
-
break;
|
|
635
|
-
case FieldTypeSchema.enum.entry:
|
|
636
|
-
{
|
|
637
|
-
schema = z7.array(valueContentReferenceToEntrySchema);
|
|
638
|
-
}
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
if (definition.isRequired) {
|
|
642
|
-
schema = schema.min(1, "shared.referenceRequired");
|
|
643
|
-
}
|
|
644
|
-
if (definition.min) {
|
|
645
|
-
schema = schema.min(definition.min);
|
|
646
|
-
}
|
|
647
|
-
if (definition.max) {
|
|
648
|
-
schema = schema.max(definition.max);
|
|
649
|
-
}
|
|
650
|
-
return schema;
|
|
651
|
-
}
|
|
652
554
|
|
|
653
555
|
// src/schema/collectionSchema.ts
|
|
654
556
|
var collectionFileSchema = baseFileSchema.extend({
|
|
@@ -703,7 +605,7 @@ var countCollectionsSchema = z8.object({
|
|
|
703
605
|
});
|
|
704
606
|
|
|
705
607
|
// src/schema/coreSchema.ts
|
|
706
|
-
import { z as z9 } from "zod";
|
|
608
|
+
import { z as z9 } from "@hono/zod-openapi";
|
|
707
609
|
var elekIoCoreOptionsSchema = z9.object({
|
|
708
610
|
log: z9.object({
|
|
709
611
|
/**
|
|
@@ -854,9 +756,172 @@ var searchProjectSchema = z10.object({
|
|
|
854
756
|
type: z10.array(objectTypeSchema).optional()
|
|
855
757
|
});
|
|
856
758
|
|
|
759
|
+
// src/schema/schemaFromFieldDefinition.ts
|
|
760
|
+
import { z as z11 } from "@hono/zod-openapi";
|
|
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) {
|
|
898
|
+
const valueSchemas = fieldDefinitions.map((fieldDefinition) => {
|
|
899
|
+
return getValueSchemaFromFieldDefinition(fieldDefinition);
|
|
900
|
+
});
|
|
901
|
+
return z11.object({
|
|
902
|
+
...createEntrySchema.shape,
|
|
903
|
+
values: z11.tuple(
|
|
904
|
+
valueSchemas
|
|
905
|
+
// At least one element is required in a tuple
|
|
906
|
+
)
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
function getUpdateEntrySchemaFromFieldDefinitions(fieldDefinitions) {
|
|
910
|
+
const valueSchemas = fieldDefinitions.map((fieldDefinition) => {
|
|
911
|
+
return getValueSchemaFromFieldDefinition(fieldDefinition);
|
|
912
|
+
});
|
|
913
|
+
return z11.object({
|
|
914
|
+
...updateEntrySchema.shape,
|
|
915
|
+
values: z11.tuple(
|
|
916
|
+
valueSchemas
|
|
917
|
+
// At least one element is required in a tuple
|
|
918
|
+
)
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
|
|
857
922
|
// src/schema/serviceSchema.ts
|
|
858
|
-
import { z as
|
|
859
|
-
var serviceTypeSchema =
|
|
923
|
+
import { z as z12 } from "@hono/zod-openapi";
|
|
924
|
+
var serviceTypeSchema = z12.enum([
|
|
860
925
|
"Git",
|
|
861
926
|
"GitTag",
|
|
862
927
|
"User",
|
|
@@ -869,17 +934,17 @@ var serviceTypeSchema = z11.enum([
|
|
|
869
934
|
"Value"
|
|
870
935
|
]);
|
|
871
936
|
function paginatedListOf(schema) {
|
|
872
|
-
return
|
|
873
|
-
total:
|
|
874
|
-
limit:
|
|
875
|
-
offset:
|
|
876
|
-
list:
|
|
937
|
+
return z12.object({
|
|
938
|
+
total: z12.number(),
|
|
939
|
+
limit: z12.number(),
|
|
940
|
+
offset: z12.number(),
|
|
941
|
+
list: z12.array(schema)
|
|
877
942
|
});
|
|
878
943
|
}
|
|
879
|
-
var listSchema =
|
|
944
|
+
var listSchema = z12.object({
|
|
880
945
|
projectId: uuidSchema,
|
|
881
|
-
limit:
|
|
882
|
-
offset:
|
|
946
|
+
limit: z12.number().optional(),
|
|
947
|
+
offset: z12.number().optional()
|
|
883
948
|
});
|
|
884
949
|
var listCollectionsSchema = listSchema;
|
|
885
950
|
var listEntriesSchema = listSchema.extend({
|
|
@@ -889,35 +954,35 @@ var listAssetsSchema = listSchema;
|
|
|
889
954
|
var listProjectsSchema = listSchema.omit({
|
|
890
955
|
projectId: true
|
|
891
956
|
});
|
|
892
|
-
var listGitTagsSchema =
|
|
893
|
-
path:
|
|
957
|
+
var listGitTagsSchema = z12.object({
|
|
958
|
+
path: z12.string()
|
|
894
959
|
});
|
|
895
960
|
|
|
896
961
|
// src/schema/userSchema.ts
|
|
897
|
-
import
|
|
898
|
-
var UserTypeSchema =
|
|
962
|
+
import { z as z13 } from "@hono/zod-openapi";
|
|
963
|
+
var UserTypeSchema = z13.enum(["local", "cloud"]);
|
|
899
964
|
var baseUserSchema = gitSignatureSchema.extend({
|
|
900
965
|
userType: UserTypeSchema,
|
|
901
966
|
language: supportedLanguageSchema,
|
|
902
|
-
localApi:
|
|
967
|
+
localApi: z13.object({
|
|
903
968
|
/**
|
|
904
969
|
* If set to true the local API is started whenever Core is initialized
|
|
905
970
|
*/
|
|
906
|
-
isEnabled:
|
|
971
|
+
isEnabled: z13.boolean(),
|
|
907
972
|
/**
|
|
908
973
|
* The port the local API uses
|
|
909
974
|
*/
|
|
910
|
-
port:
|
|
975
|
+
port: z13.number()
|
|
911
976
|
})
|
|
912
977
|
});
|
|
913
978
|
var localUserSchema = baseUserSchema.extend({
|
|
914
|
-
userType:
|
|
979
|
+
userType: z13.literal(UserTypeSchema.enum.local)
|
|
915
980
|
});
|
|
916
981
|
var cloudUserSchema = baseUserSchema.extend({
|
|
917
|
-
userType:
|
|
982
|
+
userType: z13.literal(UserTypeSchema.enum.cloud),
|
|
918
983
|
id: uuidSchema
|
|
919
984
|
});
|
|
920
|
-
var userFileSchema =
|
|
985
|
+
var userFileSchema = z13.union([localUserSchema, cloudUserSchema]);
|
|
921
986
|
var userSchema = userFileSchema;
|
|
922
987
|
var setUserSchema = userSchema;
|
|
923
988
|
|
|
@@ -994,8 +1059,10 @@ export {
|
|
|
994
1059
|
fieldDefinitionSchema,
|
|
995
1060
|
fileReferenceSchema,
|
|
996
1061
|
getChangesProjectSchema,
|
|
1062
|
+
getCreateEntrySchemaFromFieldDefinitions,
|
|
997
1063
|
getRemoteOriginUrlProjectSchema,
|
|
998
|
-
|
|
1064
|
+
getUpdateEntrySchemaFromFieldDefinitions,
|
|
1065
|
+
getValueSchemaFromFieldDefinition,
|
|
999
1066
|
gitCloneOptionsSchema,
|
|
1000
1067
|
gitCommitSchema,
|
|
1001
1068
|
gitInitOptionsSchema,
|