@elek-io/core 0.4.2 → 0.5.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.
@@ -0,0 +1,1049 @@
1
+ // src/schema/assetSchema.ts
2
+ import z3 from "zod";
3
+
4
+ // src/schema/baseSchema.ts
5
+ import z from "zod";
6
+ var environmentSchema = z.enum(["production", "development", "test"]);
7
+ var supportedLanguageSchema = z.enum([
8
+ /**
9
+ * Bulgarian
10
+ */
11
+ "bg",
12
+ //
13
+ "cs",
14
+ // Czech
15
+ "da",
16
+ // Danish
17
+ "de",
18
+ // German
19
+ "el",
20
+ // Greek
21
+ "en",
22
+ // (US) English
23
+ "es",
24
+ // Spanish
25
+ "et",
26
+ // Estonian
27
+ "fi",
28
+ // Finnish
29
+ "fr",
30
+ // French
31
+ "hu",
32
+ // Hungarian
33
+ "it",
34
+ // Italian
35
+ "ja",
36
+ // Japanese
37
+ "lt",
38
+ // Lithuanian
39
+ "lv",
40
+ // Latvian
41
+ "nl",
42
+ // Dutch
43
+ "pl",
44
+ // Polish
45
+ "pt",
46
+ // Portuguese
47
+ "ro",
48
+ // Romanian
49
+ "ru",
50
+ // Russian
51
+ "sk",
52
+ // Slovak
53
+ "sl",
54
+ // Slovenian
55
+ "sv",
56
+ // Swedish
57
+ "zh"
58
+ // (Simplified) Chinese
59
+ ]);
60
+ var supportedIconSchema = z.enum(["home", "plus", "foobar"]);
61
+ var supportedAssetMimeTypeSchema = z.enum([
62
+ "image/avif",
63
+ "image/gif",
64
+ "image/jpeg",
65
+ "image/png",
66
+ "image/svg+xml",
67
+ "image/webp",
68
+ "application/pdf",
69
+ "application/zip",
70
+ "video/mp4",
71
+ "video/webm",
72
+ "audio/webm",
73
+ "audio/flac"
74
+ ]);
75
+ var supportedAssetExtensionSchema = z.enum([
76
+ "avif",
77
+ "gif",
78
+ "jpg",
79
+ "jpeg",
80
+ "png",
81
+ "svg",
82
+ "webp",
83
+ "pdf",
84
+ "zip",
85
+ "mp4",
86
+ "webm",
87
+ "flac",
88
+ "json"
89
+ ]);
90
+ var supportedAssetTypeSchema = z.object({
91
+ extension: supportedAssetExtensionSchema,
92
+ mimeType: supportedAssetMimeTypeSchema
93
+ });
94
+ var objectTypeSchema = z.enum([
95
+ "project",
96
+ "asset",
97
+ "collection",
98
+ "entry",
99
+ "value",
100
+ "sharedValue"
101
+ ]);
102
+ var versionSchema = z.string();
103
+ var uuidSchema = z.string().uuid("shared.invalidUuid");
104
+ var translatableStringSchema = z.record(
105
+ supportedLanguageSchema,
106
+ z.string().trim().min(1, "shared.translatableStringRequired")
107
+ );
108
+ var translatableNumberSchema = z.record(
109
+ supportedLanguageSchema,
110
+ z.number({ required_error: "shared.translatableNumberRequired" })
111
+ );
112
+ var translatableBooleanSchema = z.record(
113
+ supportedLanguageSchema,
114
+ z.boolean({ required_error: "shared.translatableBooleanRequired" })
115
+ );
116
+ function translatableArrayOf(schema) {
117
+ return z.record(supportedLanguageSchema, z.array(schema));
118
+ }
119
+
120
+ // src/schema/fileSchema.ts
121
+ import z2 from "zod";
122
+ var baseFileSchema = z2.object({
123
+ /**
124
+ * The ID of the file
125
+ *
126
+ * The ID is part of the files name.
127
+ */
128
+ id: uuidSchema.readonly(),
129
+ /**
130
+ * The timestamp of the file being created is set by the service of "objectType" while creating it
131
+ */
132
+ created: z2.number().readonly(),
133
+ /**
134
+ * The timestamp of the file being updated is set by the service of "objectType" while updating it
135
+ */
136
+ updated: z2.number().nullable()
137
+ });
138
+ var baseFileWithLanguageSchema = baseFileSchema.extend({
139
+ /**
140
+ * The language of the file
141
+ *
142
+ * The language is part of the files name and together with it's ID the only unique identifier.
143
+ * That's why the language cannot be changed after creating the file.
144
+ *
145
+ * @todo Maybe remove the above restriction by implementing logic to handle changing the files language inside all services
146
+ */
147
+ language: supportedLanguageSchema.readonly()
148
+ });
149
+ var fileReferenceSchema = z2.object({
150
+ id: uuidSchema,
151
+ language: supportedLanguageSchema.optional(),
152
+ extension: supportedAssetExtensionSchema.optional()
153
+ });
154
+
155
+ // src/schema/assetSchema.ts
156
+ var assetFileSchema = baseFileWithLanguageSchema.extend({
157
+ objectType: z3.literal(objectTypeSchema.Enum.asset).readonly(),
158
+ name: z3.string(),
159
+ description: z3.string(),
160
+ extension: supportedAssetExtensionSchema.readonly(),
161
+ mimeType: supportedAssetMimeTypeSchema.readonly(),
162
+ /**
163
+ * Total size in bytes
164
+ */
165
+ size: z3.number().readonly()
166
+ });
167
+ var assetSchema = assetFileSchema.extend({
168
+ /**
169
+ * Absolute path on this filesystem
170
+ */
171
+ absolutePath: z3.string().readonly()
172
+ });
173
+ var assetExportSchema = assetSchema.extend({});
174
+ var createAssetSchema = assetFileSchema.pick({
175
+ name: true,
176
+ description: true,
177
+ language: true
178
+ }).extend({
179
+ projectId: uuidSchema.readonly(),
180
+ /**
181
+ * Path of the file to add as a new Asset
182
+ */
183
+ filePath: z3.string().readonly()
184
+ });
185
+ var readAssetSchema = assetFileSchema.pick({
186
+ id: true,
187
+ language: true
188
+ }).extend({
189
+ projectId: uuidSchema.readonly()
190
+ });
191
+ var updateAssetSchema = assetFileSchema.pick({
192
+ id: true,
193
+ name: true,
194
+ description: true,
195
+ language: true
196
+ }).extend({
197
+ projectId: uuidSchema.readonly(),
198
+ /**
199
+ * Path of the new file to update the Asset with
200
+ */
201
+ newFilePath: z3.string().readonly().optional()
202
+ });
203
+ var deleteAssetSchema = assetFileSchema.pick({
204
+ id: true,
205
+ language: true,
206
+ extension: true
207
+ }).extend({
208
+ projectId: uuidSchema.readonly()
209
+ });
210
+ var countAssetsSchema = z3.object({ projectId: uuidSchema.readonly() });
211
+
212
+ // src/schema/collectionSchema.ts
213
+ import z6 from "zod";
214
+
215
+ // src/schema/entrySchema.ts
216
+ import z5 from "zod";
217
+
218
+ // src/schema/valueSchema.ts
219
+ import z4 from "zod";
220
+ var ValueTypeSchema = z4.enum([
221
+ "string",
222
+ "number",
223
+ "boolean",
224
+ "reference"
225
+ ]);
226
+ var ValueInputTypeSchema = z4.enum([
227
+ // String
228
+ "text",
229
+ "textarea",
230
+ "email",
231
+ // 'password', @todo maybe if there is a usecase
232
+ "url",
233
+ "ip",
234
+ "date",
235
+ "time",
236
+ "datetime",
237
+ "telephone",
238
+ // Number
239
+ "number",
240
+ "range",
241
+ // Boolean
242
+ "toggle",
243
+ // Reference
244
+ "asset",
245
+ "entry"
246
+ // 'sharedValue', // @todo
247
+ ]);
248
+ var ValueInputWidthSchema = z4.enum(["12", "6", "4", "3"]);
249
+ var ValueDefinitionBaseSchema = z4.object({
250
+ id: uuidSchema.readonly(),
251
+ label: translatableStringSchema,
252
+ description: translatableStringSchema,
253
+ isRequired: z4.boolean(),
254
+ isDisabled: z4.boolean(),
255
+ isUnique: z4.boolean(),
256
+ inputWidth: ValueInputWidthSchema
257
+ });
258
+ var StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
259
+ {
260
+ valueType: z4.literal(ValueTypeSchema.Enum.string),
261
+ defaultValue: z4.string().nullable()
262
+ }
263
+ );
264
+ var textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
265
+ {
266
+ inputType: z4.literal(ValueInputTypeSchema.Enum.text),
267
+ min: z4.number().nullable(),
268
+ max: z4.number().nullable()
269
+ }
270
+ );
271
+ var textareaValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
272
+ inputType: z4.literal(ValueInputTypeSchema.Enum.textarea),
273
+ min: z4.number().nullable(),
274
+ max: z4.number().nullable()
275
+ });
276
+ var emailValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
277
+ inputType: z4.literal(ValueInputTypeSchema.Enum.email),
278
+ defaultValue: z4.string().email().nullable()
279
+ });
280
+ var urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
281
+ inputType: z4.literal(ValueInputTypeSchema.Enum.url),
282
+ defaultValue: z4.string().url().nullable()
283
+ });
284
+ var ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
285
+ inputType: z4.literal(ValueInputTypeSchema.Enum.ip),
286
+ defaultValue: z4.string().ip().nullable()
287
+ });
288
+ var dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
289
+ {
290
+ inputType: z4.literal(ValueInputTypeSchema.Enum.date),
291
+ defaultValue: z4.string().date().nullable()
292
+ }
293
+ );
294
+ var timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
295
+ {
296
+ inputType: z4.literal(ValueInputTypeSchema.Enum.time),
297
+ defaultValue: z4.string().time().nullable()
298
+ }
299
+ );
300
+ var datetimeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
301
+ inputType: z4.literal(ValueInputTypeSchema.Enum.datetime),
302
+ defaultValue: z4.string().datetime().nullable()
303
+ });
304
+ var telephoneValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
305
+ inputType: z4.literal(ValueInputTypeSchema.Enum.telephone)
306
+ // defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
307
+ });
308
+ var stringValueDefinitionSchema = z4.union([
309
+ textValueDefinitionSchema,
310
+ textareaValueDefinitionSchema,
311
+ emailValueDefinitionSchema,
312
+ urlValueDefinitionSchema,
313
+ ipValueDefinitionSchema,
314
+ dateValueDefinitionSchema,
315
+ timeValueDefinitionSchema,
316
+ datetimeValueDefinitionSchema,
317
+ telephoneValueDefinitionSchema
318
+ ]);
319
+ var NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
320
+ {
321
+ valueType: z4.literal(ValueTypeSchema.Enum.number),
322
+ min: z4.number().nullable(),
323
+ max: z4.number().nullable(),
324
+ isUnique: z4.literal(false),
325
+ defaultValue: z4.number().nullable()
326
+ }
327
+ );
328
+ var numberValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
329
+ inputType: z4.literal(ValueInputTypeSchema.Enum.number)
330
+ });
331
+ var rangeValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
332
+ inputType: z4.literal(ValueInputTypeSchema.Enum.range),
333
+ // Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
334
+ isRequired: z4.literal(true),
335
+ min: z4.number(),
336
+ max: z4.number(),
337
+ defaultValue: z4.number()
338
+ });
339
+ var BooleanValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
340
+ valueType: z4.literal(ValueTypeSchema.Enum.boolean),
341
+ // Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
342
+ isRequired: z4.literal(true),
343
+ defaultValue: z4.boolean(),
344
+ isUnique: z4.literal(false)
345
+ });
346
+ var toggleValueDefinitionSchema = BooleanValueDefinitionBaseSchema.extend({
347
+ inputType: z4.literal(ValueInputTypeSchema.Enum.toggle)
348
+ });
349
+ var ReferenceValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
350
+ valueType: z4.literal(ValueTypeSchema.Enum.reference)
351
+ });
352
+ var assetValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
353
+ inputType: z4.literal(ValueInputTypeSchema.Enum.asset),
354
+ allowedMimeTypes: z4.array(supportedAssetMimeTypeSchema).min(1),
355
+ min: z4.number().nullable(),
356
+ max: z4.number().nullable()
357
+ });
358
+ var entryValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
359
+ inputType: z4.literal(ValueInputTypeSchema.Enum.entry),
360
+ ofCollections: z4.array(uuidSchema),
361
+ min: z4.number().nullable(),
362
+ max: z4.number().nullable()
363
+ });
364
+ var valueDefinitionSchema = z4.union([
365
+ stringValueDefinitionSchema,
366
+ numberValueDefinitionSchema,
367
+ rangeValueDefinitionSchema,
368
+ toggleValueDefinitionSchema,
369
+ assetValueDefinitionSchema,
370
+ entryValueDefinitionSchema
371
+ // sharedValueDefinitionSchema,
372
+ ]);
373
+ var valueContentReferenceBase = z4.object({
374
+ id: uuidSchema
375
+ });
376
+ var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
377
+ language: supportedLanguageSchema
378
+ });
379
+ var valueContentReferenceToAssetSchema = valueContentReferenceWithLanguageBase.extend({
380
+ objectType: z4.literal(objectTypeSchema.Enum.asset)
381
+ });
382
+ var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
383
+ objectType: z4.literal(objectTypeSchema.Enum.collection)
384
+ });
385
+ var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
386
+ objectType: z4.literal(objectTypeSchema.Enum.entry)
387
+ });
388
+ var valueContentReferenceSchema = z4.union([
389
+ valueContentReferenceToAssetSchema,
390
+ valueContentReferenceToCollectionSchema,
391
+ valueContentReferenceToEntrySchema
392
+ // valueContentReferenceToSharedValueSchema,
393
+ ]);
394
+ var resolvedValueContentReferenceSchema = z4.union([
395
+ assetSchema,
396
+ z4.lazy(() => entrySchema)
397
+ // Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types
398
+ // resolvedValueContentReferenceToSharedValueSchema,
399
+ ]);
400
+ var directValueBaseSchema = z4.object({
401
+ objectType: z4.literal(objectTypeSchema.Enum.value).readonly(),
402
+ definitionId: uuidSchema.readonly()
403
+ });
404
+ var directStringValueSchema = directValueBaseSchema.extend({
405
+ valueType: z4.literal(ValueTypeSchema.Enum.string).readonly(),
406
+ content: translatableStringSchema
407
+ });
408
+ var directNumberValueSchema = directValueBaseSchema.extend({
409
+ valueType: z4.literal(ValueTypeSchema.Enum.number).readonly(),
410
+ content: translatableNumberSchema
411
+ });
412
+ var directBooleanValueSchema = directValueBaseSchema.extend({
413
+ valueType: z4.literal(ValueTypeSchema.Enum.boolean).readonly(),
414
+ content: translatableBooleanSchema
415
+ });
416
+ var directValueSchema = z4.union([
417
+ directStringValueSchema,
418
+ directNumberValueSchema,
419
+ directBooleanValueSchema
420
+ ]);
421
+ var referencedValueSchema = z4.object({
422
+ objectType: z4.literal(objectTypeSchema.Enum.value).readonly(),
423
+ definitionId: uuidSchema.readonly(),
424
+ valueType: z4.literal(ValueTypeSchema.Enum.reference).readonly(),
425
+ content: translatableArrayOf(valueContentReferenceSchema)
426
+ });
427
+ var valueSchema = z4.union([directValueSchema, referencedValueSchema]);
428
+ var resolvedReferencedValueSchema = referencedValueSchema.extend({
429
+ content: translatableArrayOf(resolvedValueContentReferenceSchema)
430
+ });
431
+ var resolvedValueSchema = z4.union([
432
+ directValueSchema,
433
+ resolvedReferencedValueSchema
434
+ ]);
435
+ function getValueContentSchemaFromDefinition(definition) {
436
+ switch (definition.valueType) {
437
+ case ValueTypeSchema.Enum.boolean:
438
+ return getBooleanValueContentSchema(definition);
439
+ case ValueTypeSchema.Enum.number:
440
+ return getNumberValueContentSchema(definition);
441
+ case ValueTypeSchema.Enum.string:
442
+ return getStringValueContentSchema(definition);
443
+ case ValueTypeSchema.Enum.reference:
444
+ return getReferenceValueContentSchema(definition);
445
+ default:
446
+ throw new Error(
447
+ // @ts-expect-error
448
+ `Error generating schema for unsupported ValueType "${definition.valueType}"`
449
+ );
450
+ }
451
+ }
452
+ function getBooleanValueContentSchema(definition) {
453
+ return z4.boolean();
454
+ }
455
+ function getNumberValueContentSchema(definition) {
456
+ let schema = z4.number();
457
+ if (definition.min) {
458
+ schema = schema.min(definition.min);
459
+ }
460
+ if (definition.max) {
461
+ schema = schema.max(definition.max);
462
+ }
463
+ if (definition.isRequired === false) {
464
+ return schema.nullable();
465
+ }
466
+ return schema;
467
+ }
468
+ function getStringValueContentSchema(definition) {
469
+ let schema = z4.string().trim();
470
+ if ("min" in definition && definition.min) {
471
+ schema = schema.min(definition.min);
472
+ }
473
+ if ("max" in definition && definition.max) {
474
+ schema = schema.max(definition.max);
475
+ }
476
+ switch (definition.inputType) {
477
+ case ValueInputTypeSchema.Enum.email:
478
+ schema = schema.email();
479
+ break;
480
+ case ValueInputTypeSchema.Enum.url:
481
+ schema = schema.url();
482
+ break;
483
+ case ValueInputTypeSchema.Enum.ip:
484
+ schema = schema.ip();
485
+ break;
486
+ case ValueInputTypeSchema.Enum.date:
487
+ schema = schema.date();
488
+ break;
489
+ case ValueInputTypeSchema.Enum.time:
490
+ schema = schema.time();
491
+ break;
492
+ case ValueInputTypeSchema.Enum.datetime:
493
+ schema = schema.datetime();
494
+ break;
495
+ case ValueInputTypeSchema.Enum.telephone:
496
+ break;
497
+ }
498
+ if (definition.isRequired === false) {
499
+ return schema.nullable();
500
+ }
501
+ return schema.min(1, "shared.stringValueRequired");
502
+ }
503
+ function getReferenceValueContentSchema(definition) {
504
+ let schema;
505
+ switch (definition.inputType) {
506
+ case ValueInputTypeSchema.Enum.asset:
507
+ {
508
+ schema = z4.array(valueContentReferenceToAssetSchema);
509
+ }
510
+ break;
511
+ case ValueInputTypeSchema.Enum.entry:
512
+ {
513
+ schema = z4.array(valueContentReferenceToEntrySchema);
514
+ }
515
+ break;
516
+ }
517
+ if (definition.isRequired) {
518
+ schema = schema.min(1, "shared.referenceRequired");
519
+ }
520
+ if (definition.min) {
521
+ schema = schema.min(definition.min);
522
+ }
523
+ if (definition.max) {
524
+ schema = schema.max(definition.max);
525
+ }
526
+ return schema;
527
+ }
528
+
529
+ // src/schema/entrySchema.ts
530
+ var entryFileSchema = baseFileSchema.extend({
531
+ objectType: z5.literal(objectTypeSchema.Enum.entry).readonly(),
532
+ values: z5.array(valueSchema)
533
+ });
534
+ var entrySchema = entryFileSchema.extend({
535
+ values: z5.array(z5.lazy(() => resolvedValueSchema))
536
+ });
537
+ var entryExportSchema = entrySchema.extend({});
538
+ var createEntrySchema = entryFileSchema.omit({
539
+ id: true,
540
+ objectType: true,
541
+ created: true,
542
+ updated: true
543
+ }).extend({
544
+ projectId: uuidSchema.readonly(),
545
+ collectionId: uuidSchema.readonly(),
546
+ values: z5.array(valueSchema)
547
+ });
548
+ var readEntrySchema = z5.object({
549
+ id: uuidSchema.readonly(),
550
+ projectId: uuidSchema.readonly(),
551
+ collectionId: uuidSchema.readonly()
552
+ });
553
+ var updateEntrySchema = entrySchema.omit({
554
+ objectType: true,
555
+ created: true,
556
+ updated: true
557
+ }).extend({
558
+ projectId: uuidSchema.readonly(),
559
+ collectionId: uuidSchema.readonly()
560
+ });
561
+ var deleteEntrySchema = readEntrySchema.extend({});
562
+ var countEntriesSchema = z5.object({
563
+ projectId: uuidSchema.readonly(),
564
+ collectionId: uuidSchema.readonly()
565
+ });
566
+
567
+ // src/schema/collectionSchema.ts
568
+ var collectionFileSchema = baseFileSchema.extend({
569
+ objectType: z6.literal(objectTypeSchema.Enum.collection).readonly(),
570
+ name: z6.object({
571
+ singular: translatableStringSchema,
572
+ plural: translatableStringSchema
573
+ }),
574
+ slug: z6.object({
575
+ singular: z6.string(),
576
+ plural: z6.string()
577
+ }),
578
+ description: translatableStringSchema,
579
+ icon: supportedIconSchema,
580
+ valueDefinitions: z6.array(valueDefinitionSchema)
581
+ });
582
+ var collectionSchema = collectionFileSchema.extend({});
583
+ var collectionExportSchema = collectionSchema.extend({
584
+ entries: z6.array(entryExportSchema)
585
+ });
586
+ var createCollectionSchema = collectionSchema.omit({
587
+ id: true,
588
+ objectType: true,
589
+ created: true,
590
+ updated: true
591
+ }).extend({
592
+ projectId: uuidSchema.readonly()
593
+ });
594
+ var readCollectionSchema = z6.object({
595
+ id: uuidSchema.readonly(),
596
+ projectId: uuidSchema.readonly()
597
+ });
598
+ var updateCollectionSchema = collectionFileSchema.pick({
599
+ id: true,
600
+ name: true,
601
+ slug: true,
602
+ description: true,
603
+ icon: true,
604
+ valueDefinitions: true
605
+ }).extend({
606
+ projectId: uuidSchema.readonly()
607
+ });
608
+ var deleteCollectionSchema = readCollectionSchema.extend({});
609
+ var countCollectionsSchema = z6.object({
610
+ projectId: uuidSchema.readonly()
611
+ });
612
+
613
+ // src/schema/coreSchema.ts
614
+ import { z as z7 } from "zod";
615
+ var elekIoCoreOptionsSchema = z7.object({
616
+ /**
617
+ * The environment elek.io Core is currently running in
618
+ */
619
+ environment: environmentSchema,
620
+ /**
621
+ * The current version of elek.io Core
622
+ */
623
+ version: versionSchema,
624
+ file: z7.object({
625
+ json: z7.object({
626
+ /**
627
+ * If set, adds indentation with spaces (number) or escape character (string)
628
+ * and line break characters to saved JSON files on disk, to make them easier to read.
629
+ * Defaults to 2 spaces of indentation.
630
+ */
631
+ indentation: z7.union([z7.number(), z7.string()])
632
+ })
633
+ })
634
+ });
635
+ var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
636
+ version: true
637
+ }).partial({
638
+ environment: true,
639
+ file: true
640
+ }).optional();
641
+
642
+ // src/schema/gitSchema.ts
643
+ import { z as z8 } from "zod";
644
+ var gitRepositoryPathSchema = z8.string();
645
+ var gitSignatureSchema = z8.object({
646
+ name: z8.string(),
647
+ email: z8.string()
648
+ });
649
+ var gitCommitSchema = z8.object({
650
+ /**
651
+ * SHA-1 hash of the commit
652
+ */
653
+ hash: z8.string(),
654
+ message: z8.string(),
655
+ author: gitSignatureSchema,
656
+ timestamp: z8.number(),
657
+ tag: z8.string().nullable()
658
+ });
659
+ var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
660
+ GitCommitIconNative2["INIT"] = ":tada:";
661
+ GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
662
+ GitCommitIconNative2["UPDATE"] = ":wrench:";
663
+ GitCommitIconNative2["DELETE"] = ":fire:";
664
+ return GitCommitIconNative2;
665
+ })(GitCommitIconNative || {});
666
+ var gitCommitIconSchema = z8.nativeEnum(GitCommitIconNative);
667
+ var gitInitOptionsSchema = z8.object({
668
+ /**
669
+ * Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).
670
+ */
671
+ initialBranch: z8.string()
672
+ });
673
+ var gitCloneOptionsSchema = z8.object({
674
+ /**
675
+ * Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
676
+ */
677
+ depth: z8.number(),
678
+ /**
679
+ * Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.
680
+ */
681
+ singleBranch: z8.boolean(),
682
+ /**
683
+ * Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
684
+ */
685
+ branch: z8.string()
686
+ });
687
+ var gitSwitchOptionsSchema = z8.object({
688
+ /**
689
+ * If true, creates a new local branch and then switches to it
690
+ *
691
+ * @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
692
+ */
693
+ isNew: z8.boolean().optional()
694
+ });
695
+ var gitLogOptionsSchema = z8.object({
696
+ /**
697
+ * Limit the result to given number of commits
698
+ */
699
+ limit: z8.number().optional(),
700
+ /**
701
+ * Only list commits that are between given SHAs or tag names
702
+ *
703
+ * Note that the commits of from and to are not included in the result
704
+ */
705
+ between: z8.object({
706
+ /**
707
+ * From the oldest commit
708
+ */
709
+ from: z8.string(),
710
+ /**
711
+ * To the newest commit
712
+ *
713
+ * Defaults to the current HEAD
714
+ */
715
+ to: z8.string().optional()
716
+ })
717
+ });
718
+
719
+ // src/schema/gitTagSchema.ts
720
+ import { z as z9 } from "zod";
721
+ var gitTagSchema = z9.object({
722
+ id: uuidSchema,
723
+ message: z9.string(),
724
+ author: gitSignatureSchema,
725
+ timestamp: z9.number()
726
+ });
727
+ var createGitTagSchema = gitTagSchema.pick({
728
+ message: true
729
+ }).extend({
730
+ path: gitRepositoryPathSchema,
731
+ hash: gitCommitSchema.shape.hash.optional()
732
+ });
733
+ var readGitTagSchema = z9.object({
734
+ path: gitRepositoryPathSchema,
735
+ id: uuidSchema.readonly()
736
+ });
737
+ var deleteGitTagSchema = readGitTagSchema.extend({});
738
+ var countGitTagsSchema = z9.object({
739
+ path: gitRepositoryPathSchema
740
+ });
741
+
742
+ // src/schema/projectSchema.ts
743
+ import { z as z10 } from "zod";
744
+ var projectStatusSchema = z10.enum(["foo", "bar", "todo"]);
745
+ var projectSettingsSchema = z10.object({
746
+ language: z10.object({
747
+ default: supportedLanguageSchema,
748
+ supported: z10.array(supportedLanguageSchema)
749
+ })
750
+ });
751
+ var projectFolderSchema = z10.enum([
752
+ "assets",
753
+ "collections",
754
+ "shared-values",
755
+ "lfs"
756
+ // 'logs',
757
+ // 'public',
758
+ // 'theme',
759
+ ]);
760
+ var projectFileSchema = baseFileSchema.extend({
761
+ objectType: z10.literal(objectTypeSchema.Enum.project).readonly(),
762
+ coreVersion: versionSchema,
763
+ name: z10.string().trim().min(1, "shared.projectNameRequired"),
764
+ description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
765
+ version: versionSchema,
766
+ status: projectStatusSchema,
767
+ settings: projectSettingsSchema
768
+ });
769
+ var projectSchema = projectFileSchema.extend({});
770
+ var projectExportSchema = projectSchema.extend({
771
+ assets: z10.array(assetExportSchema),
772
+ collections: z10.array(collectionExportSchema)
773
+ });
774
+ var createProjectSchema = projectSchema.pick({
775
+ name: true,
776
+ description: true,
777
+ settings: true
778
+ }).partial({
779
+ description: true,
780
+ settings: true
781
+ });
782
+ var readProjectSchema = z10.object({
783
+ id: uuidSchema.readonly()
784
+ });
785
+ var updateProjectSchema = projectSchema.pick({
786
+ id: true,
787
+ name: true,
788
+ description: true,
789
+ settings: true
790
+ }).partial({
791
+ name: true,
792
+ description: true,
793
+ settings: true
794
+ });
795
+ var upgradeProjectSchema = z10.object({
796
+ id: uuidSchema.readonly()
797
+ });
798
+ var deleteProjectSchema = readProjectSchema.extend({});
799
+ var projectUpgradeSchema = z10.object({
800
+ /**
801
+ * The Core version the Project will be upgraded to
802
+ */
803
+ to: versionSchema.readonly(),
804
+ /**
805
+ * Function that will be executed in the process of upgrading a Project
806
+ */
807
+ run: z10.function().args(projectFileSchema).returns(z10.promise(z10.void()))
808
+ });
809
+ var cloneProjectSchema = z10.object({
810
+ url: z10.string()
811
+ });
812
+ var listBranchesProjectSchema = z10.object({
813
+ id: uuidSchema.readonly()
814
+ });
815
+ var currentBranchProjectSchema = z10.object({
816
+ id: uuidSchema.readonly()
817
+ });
818
+ var switchBranchProjectSchema = z10.object({
819
+ id: uuidSchema.readonly(),
820
+ branch: z10.string(),
821
+ options: gitSwitchOptionsSchema.optional()
822
+ });
823
+ var getRemoteOriginUrlProjectSchema = z10.object({
824
+ id: uuidSchema.readonly()
825
+ });
826
+ var setRemoteOriginUrlProjectSchema = z10.object({
827
+ id: uuidSchema.readonly(),
828
+ url: z10.string()
829
+ });
830
+ var getChangesProjectSchema = z10.object({
831
+ id: uuidSchema.readonly()
832
+ });
833
+ var synchronizeProjectSchema = z10.object({
834
+ id: uuidSchema.readonly()
835
+ });
836
+ var searchProjectSchema = z10.object({
837
+ id: uuidSchema.readonly(),
838
+ query: z10.string(),
839
+ language: supportedLanguageSchema,
840
+ type: z10.array(objectTypeSchema).optional()
841
+ });
842
+
843
+ // src/schema/serviceSchema.ts
844
+ import { z as z11 } from "zod";
845
+ var serviceTypeSchema = z11.enum([
846
+ "Git",
847
+ "GitTag",
848
+ "User",
849
+ "Project",
850
+ "Asset",
851
+ "JsonFile",
852
+ "Search",
853
+ "Collection",
854
+ "Entry",
855
+ "Value"
856
+ ]);
857
+ var listSchema = z11.object({
858
+ projectId: uuidSchema,
859
+ limit: z11.number().optional(),
860
+ offset: z11.number().optional()
861
+ });
862
+ var listCollectionsSchema = listSchema;
863
+ var listEntriesSchema = listSchema.extend({
864
+ collectionId: uuidSchema
865
+ });
866
+ var listAssetsSchema = listSchema;
867
+ var listProjectsSchema = listSchema.omit({
868
+ projectId: true
869
+ });
870
+ var listGitTagsSchema = z11.object({
871
+ path: gitRepositoryPathSchema
872
+ });
873
+
874
+ // src/schema/userSchema.ts
875
+ import z12 from "zod";
876
+ var UserTypeSchema = z12.enum(["local", "cloud"]);
877
+ var baseUserSchema = gitSignatureSchema.extend({
878
+ userType: UserTypeSchema,
879
+ language: supportedLanguageSchema
880
+ });
881
+ var localUserSchema = baseUserSchema.extend({
882
+ userType: z12.literal(UserTypeSchema.Enum.local)
883
+ });
884
+ var cloudUserSchema = baseUserSchema.extend({
885
+ userType: z12.literal(UserTypeSchema.Enum.cloud),
886
+ id: uuidSchema
887
+ });
888
+ var userFileSchema = z12.union([localUserSchema, cloudUserSchema]);
889
+ var userSchema = userFileSchema;
890
+ var setUserSchema = userSchema;
891
+
892
+ // src/util/shared.ts
893
+ import slugify from "slugify";
894
+ import { v4 as generateUuid } from "uuid";
895
+ var Slugify = slugify.default || slugify;
896
+ function uuid() {
897
+ return generateUuid();
898
+ }
899
+ function currentTimestamp() {
900
+ return Math.floor(Date.now() / 1e3);
901
+ }
902
+ function slug(string) {
903
+ return Slugify(string, {
904
+ replacement: "-",
905
+ // replace spaces with replacement character, defaults to `-`
906
+ remove: void 0,
907
+ // remove characters that match regex, defaults to `undefined`
908
+ lower: true,
909
+ // convert to lower case, defaults to `false`
910
+ strict: true
911
+ // strip special characters except replacement, defaults to `false`
912
+ });
913
+ }
914
+ export {
915
+ BooleanValueDefinitionBaseSchema,
916
+ NumberValueDefinitionBaseSchema,
917
+ ReferenceValueDefinitionBaseSchema,
918
+ StringValueDefinitionBaseSchema,
919
+ UserTypeSchema,
920
+ ValueDefinitionBaseSchema,
921
+ ValueInputTypeSchema,
922
+ ValueInputWidthSchema,
923
+ ValueTypeSchema,
924
+ assetExportSchema,
925
+ assetFileSchema,
926
+ assetSchema,
927
+ assetValueDefinitionSchema,
928
+ baseFileSchema,
929
+ baseFileWithLanguageSchema,
930
+ baseUserSchema,
931
+ cloneProjectSchema,
932
+ cloudUserSchema,
933
+ collectionExportSchema,
934
+ collectionFileSchema,
935
+ collectionSchema,
936
+ constructorElekIoCoreSchema,
937
+ countAssetsSchema,
938
+ countCollectionsSchema,
939
+ countEntriesSchema,
940
+ countGitTagsSchema,
941
+ createAssetSchema,
942
+ createCollectionSchema,
943
+ createEntrySchema,
944
+ createGitTagSchema,
945
+ createProjectSchema,
946
+ currentBranchProjectSchema,
947
+ currentTimestamp,
948
+ dateValueDefinitionSchema,
949
+ datetimeValueDefinitionSchema,
950
+ deleteAssetSchema,
951
+ deleteCollectionSchema,
952
+ deleteEntrySchema,
953
+ deleteGitTagSchema,
954
+ deleteProjectSchema,
955
+ directBooleanValueSchema,
956
+ directNumberValueSchema,
957
+ directStringValueSchema,
958
+ directValueBaseSchema,
959
+ directValueSchema,
960
+ elekIoCoreOptionsSchema,
961
+ emailValueDefinitionSchema,
962
+ entryExportSchema,
963
+ entryFileSchema,
964
+ entrySchema,
965
+ entryValueDefinitionSchema,
966
+ environmentSchema,
967
+ fileReferenceSchema,
968
+ getChangesProjectSchema,
969
+ getRemoteOriginUrlProjectSchema,
970
+ getValueContentSchemaFromDefinition,
971
+ gitCloneOptionsSchema,
972
+ gitCommitIconSchema,
973
+ gitCommitSchema,
974
+ gitInitOptionsSchema,
975
+ gitLogOptionsSchema,
976
+ gitRepositoryPathSchema,
977
+ gitSignatureSchema,
978
+ gitSwitchOptionsSchema,
979
+ gitTagSchema,
980
+ ipValueDefinitionSchema,
981
+ listAssetsSchema,
982
+ listBranchesProjectSchema,
983
+ listCollectionsSchema,
984
+ listEntriesSchema,
985
+ listGitTagsSchema,
986
+ listProjectsSchema,
987
+ localUserSchema,
988
+ numberValueDefinitionSchema,
989
+ objectTypeSchema,
990
+ projectExportSchema,
991
+ projectFileSchema,
992
+ projectFolderSchema,
993
+ projectSchema,
994
+ projectSettingsSchema,
995
+ projectStatusSchema,
996
+ projectUpgradeSchema,
997
+ rangeValueDefinitionSchema,
998
+ readAssetSchema,
999
+ readCollectionSchema,
1000
+ readEntrySchema,
1001
+ readGitTagSchema,
1002
+ readProjectSchema,
1003
+ referencedValueSchema,
1004
+ resolvedReferencedValueSchema,
1005
+ resolvedValueContentReferenceSchema,
1006
+ resolvedValueSchema,
1007
+ searchProjectSchema,
1008
+ serviceTypeSchema,
1009
+ setRemoteOriginUrlProjectSchema,
1010
+ setUserSchema,
1011
+ slug,
1012
+ stringValueDefinitionSchema,
1013
+ supportedAssetExtensionSchema,
1014
+ supportedAssetMimeTypeSchema,
1015
+ supportedAssetTypeSchema,
1016
+ supportedIconSchema,
1017
+ supportedLanguageSchema,
1018
+ switchBranchProjectSchema,
1019
+ synchronizeProjectSchema,
1020
+ telephoneValueDefinitionSchema,
1021
+ textValueDefinitionSchema,
1022
+ textareaValueDefinitionSchema,
1023
+ timeValueDefinitionSchema,
1024
+ toggleValueDefinitionSchema,
1025
+ translatableArrayOf,
1026
+ translatableBooleanSchema,
1027
+ translatableNumberSchema,
1028
+ translatableStringSchema,
1029
+ updateAssetSchema,
1030
+ updateCollectionSchema,
1031
+ updateEntrySchema,
1032
+ updateProjectSchema,
1033
+ upgradeProjectSchema,
1034
+ urlValueDefinitionSchema,
1035
+ userFileSchema,
1036
+ userSchema,
1037
+ uuid,
1038
+ uuidSchema,
1039
+ valueContentReferenceBase,
1040
+ valueContentReferenceSchema,
1041
+ valueContentReferenceToAssetSchema,
1042
+ valueContentReferenceToCollectionSchema,
1043
+ valueContentReferenceToEntrySchema,
1044
+ valueContentReferenceWithLanguageBase,
1045
+ valueDefinitionSchema,
1046
+ valueSchema,
1047
+ versionSchema
1048
+ };
1049
+ //# sourceMappingURL=index.browser.js.map