@elek-io/core 0.15.0 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1151 +1,2 @@
1
- // src/schema/assetSchema.ts
2
- import { z as z4 } from "@hono/zod-openapi";
3
-
4
- // src/schema/baseSchema.ts
5
- import z from "zod";
6
- var supportedLanguageSchema = z.enum([
7
- /**
8
- * Bulgarian
9
- */
10
- "bg",
11
- //
12
- "cs",
13
- // Czech
14
- "da",
15
- // Danish
16
- "de",
17
- // German
18
- "el",
19
- // Greek
20
- "en",
21
- // (US) English
22
- "es",
23
- // Spanish
24
- "et",
25
- // Estonian
26
- "fi",
27
- // Finnish
28
- "fr",
29
- // French
30
- "hu",
31
- // Hungarian
32
- "it",
33
- // Italian
34
- "ja",
35
- // Japanese
36
- "lt",
37
- // Lithuanian
38
- "lv",
39
- // Latvian
40
- "nl",
41
- // Dutch
42
- "pl",
43
- // Polish
44
- "pt",
45
- // Portuguese
46
- "ro",
47
- // Romanian
48
- "ru",
49
- // Russian
50
- "sk",
51
- // Slovak
52
- "sl",
53
- // Slovenian
54
- "sv",
55
- // Swedish
56
- "zh"
57
- // (Simplified) Chinese
58
- ]);
59
- var supportedIconSchema = z.enum(["home", "plus", "foobar"]);
60
- var objectTypeSchema = z.enum([
61
- "project",
62
- "asset",
63
- "collection",
64
- "entry",
65
- "value",
66
- "sharedValue"
67
- ]);
68
- var logLevelSchema = z.enum(["error", "warn", "info", "debug"]);
69
- var versionSchema = z.string();
70
- var uuidSchema = z.uuid("shared.invalidUuid");
71
- var translatableStringSchema = z.partialRecord(
72
- supportedLanguageSchema,
73
- z.string().trim().min(1, "shared.translatableStringRequired")
74
- );
75
- var translatableNumberSchema = z.partialRecord(
76
- supportedLanguageSchema,
77
- z.number({
78
- error: (error) => error.input === void 0 ? "shared.translatableNumberRequired" : "shared.translatableNumberNotANumber"
79
- })
80
- );
81
- var translatableBooleanSchema = z.partialRecord(
82
- supportedLanguageSchema,
83
- z.boolean({
84
- error: (error) => error.input === void 0 ? "shared.translatableBooleanRequired" : "shared.translatableBooleanNotABoolean"
85
- })
86
- );
87
- function translatableArrayOf(schema) {
88
- return z.partialRecord(supportedLanguageSchema, z.array(schema));
89
- }
90
-
91
- // src/schema/fileSchema.ts
92
- import z2 from "zod";
93
- var baseFileSchema = z2.object({
94
- /**
95
- * The object type of the file
96
- */
97
- objectType: objectTypeSchema.readonly(),
98
- /**
99
- * The ID of the file
100
- *
101
- * The ID is part of the files name.
102
- */
103
- id: uuidSchema.readonly(),
104
- /**
105
- * The datetime of the file being created is set by the service of "objectType" while creating it
106
- */
107
- created: z2.string().datetime().readonly(),
108
- /**
109
- * The datetime of the file being updated is set by the service of "objectType" while updating it
110
- */
111
- updated: z2.string().datetime().nullable()
112
- });
113
- var fileReferenceSchema = z2.object({
114
- id: uuidSchema,
115
- extension: z2.string().optional()
116
- });
117
-
118
- // src/schema/gitSchema.ts
119
- import { z as z3 } from "zod";
120
- var gitSignatureSchema = z3.object({
121
- name: z3.string(),
122
- email: z3.string().email()
123
- });
124
- var gitMessageSchema = z3.object({
125
- method: z3.enum(["create", "update", "delete", "upgrade"]),
126
- reference: z3.object({
127
- objectType: objectTypeSchema,
128
- /**
129
- * ID of the objectType
130
- */
131
- id: uuidSchema,
132
- /**
133
- * Only present if the objectType is of "entry"
134
- */
135
- collectionId: uuidSchema.optional()
136
- })
137
- });
138
- var gitTagSchema = z3.object({
139
- id: uuidSchema,
140
- message: z3.string(),
141
- author: gitSignatureSchema,
142
- datetime: z3.string().datetime()
143
- });
144
- var gitCommitSchema = z3.object({
145
- /**
146
- * SHA-1 hash of the commit
147
- */
148
- hash: z3.string(),
149
- message: gitMessageSchema,
150
- author: gitSignatureSchema,
151
- datetime: z3.string().datetime(),
152
- tag: gitTagSchema.nullable()
153
- });
154
- var gitInitOptionsSchema = z3.object({
155
- /**
156
- * 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).
157
- */
158
- initialBranch: z3.string()
159
- });
160
- var gitCloneOptionsSchema = z3.object({
161
- /**
162
- * 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.
163
- */
164
- depth: z3.number(),
165
- /**
166
- * 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.
167
- */
168
- singleBranch: z3.boolean(),
169
- /**
170
- * 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.
171
- */
172
- branch: z3.string(),
173
- /**
174
- * Make a bare Git repository. That is, instead of creating <directory> and placing the administrative files in <directory>`/.git`, make the <directory> itself the $GIT_DIR.
175
- * Used primarily to copy an existing local repository to a server, where you want to set up the repository as a central point to work with others.
176
- *
177
- * The destination path for the cloned repository should end with a .git by convention.
178
- *
179
- * @see https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server
180
- */
181
- bare: z3.boolean()
182
- });
183
- var gitMergeOptionsSchema = z3.object({
184
- squash: z3.boolean()
185
- });
186
- var gitSwitchOptionsSchema = z3.object({
187
- /**
188
- * If true, creates a new local branch and then switches to it
189
- *
190
- * @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
191
- */
192
- isNew: z3.boolean().optional()
193
- });
194
- var gitLogOptionsSchema = z3.object({
195
- /**
196
- * Limit the result to given number of commits
197
- */
198
- limit: z3.number().optional(),
199
- /**
200
- * Only list commits that are between given SHAs or tag names
201
- *
202
- * Note that the commits of from and to are not included in the result
203
- */
204
- between: z3.object({
205
- /**
206
- * From the oldest commit
207
- */
208
- from: z3.string(),
209
- /**
210
- * To the newest commit
211
- *
212
- * Defaults to the current HEAD
213
- */
214
- to: z3.string().optional()
215
- }),
216
- /**
217
- * Only shows commits of given file
218
- */
219
- filePath: z3.string().optional()
220
- });
221
- var createGitTagSchema = gitTagSchema.pick({
222
- message: true
223
- }).extend({
224
- path: z3.string(),
225
- hash: z3.string().optional()
226
- });
227
- var readGitTagSchema = z3.object({
228
- path: z3.string(),
229
- id: uuidSchema.readonly()
230
- });
231
- var deleteGitTagSchema = readGitTagSchema.extend({});
232
- var countGitTagsSchema = z3.object({
233
- path: z3.string()
234
- });
235
-
236
- // src/schema/assetSchema.ts
237
- var assetFileSchema = baseFileSchema.extend({
238
- objectType: z4.literal(objectTypeSchema.enum.asset).readonly(),
239
- name: z4.string(),
240
- description: z4.string(),
241
- extension: z4.string().readonly(),
242
- mimeType: z4.string().readonly(),
243
- /**
244
- * Total size in bytes
245
- */
246
- size: z4.number().readonly()
247
- });
248
- var assetSchema = assetFileSchema.extend({
249
- /**
250
- * Absolute path on this filesystem
251
- */
252
- absolutePath: z4.string().readonly(),
253
- /**
254
- * Commit history of this Asset
255
- */
256
- history: z4.array(gitCommitSchema)
257
- }).openapi("Asset");
258
- var assetExportSchema = assetSchema.extend({});
259
- var createAssetSchema = assetFileSchema.pick({
260
- name: true,
261
- description: true
262
- }).extend({
263
- projectId: uuidSchema.readonly(),
264
- /**
265
- * Path of the file to add as a new Asset
266
- */
267
- filePath: z4.string().readonly()
268
- });
269
- var readAssetSchema = assetFileSchema.pick({
270
- id: true
271
- }).extend({
272
- projectId: uuidSchema.readonly(),
273
- commitHash: z4.string().optional().readonly()
274
- });
275
- var saveAssetSchema = assetFileSchema.pick({
276
- id: true
277
- }).extend({
278
- projectId: uuidSchema.readonly(),
279
- filePath: z4.string().readonly(),
280
- commitHash: z4.string().optional().readonly()
281
- });
282
- var updateAssetSchema = assetFileSchema.pick({
283
- id: true,
284
- name: true,
285
- description: true
286
- }).extend({
287
- projectId: uuidSchema.readonly(),
288
- /**
289
- * Path of the new file to update the Asset with
290
- */
291
- newFilePath: z4.string().readonly().optional()
292
- });
293
- var deleteAssetSchema = assetFileSchema.pick({
294
- id: true,
295
- extension: true
296
- }).extend({
297
- projectId: uuidSchema.readonly()
298
- });
299
- var countAssetsSchema = z4.object({ projectId: uuidSchema.readonly() });
300
-
301
- // src/schema/collectionSchema.ts
302
- import { z as z8 } from "@hono/zod-openapi";
303
-
304
- // src/schema/entrySchema.ts
305
- import { z as z6 } from "@hono/zod-openapi";
306
-
307
- // src/schema/valueSchema.ts
308
- import z5 from "zod";
309
- var ValueTypeSchema = z5.enum([
310
- "string",
311
- "number",
312
- "boolean",
313
- "reference"
314
- ]);
315
- var valueContentReferenceBase = z5.object({
316
- id: uuidSchema
317
- });
318
- var valueContentReferenceToAssetSchema = valueContentReferenceBase.extend({
319
- objectType: z5.literal(objectTypeSchema.enum.asset)
320
- });
321
- var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
322
- objectType: z5.literal(objectTypeSchema.enum.collection)
323
- });
324
- var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
325
- objectType: z5.literal(objectTypeSchema.enum.entry)
326
- });
327
- var valueContentReferenceSchema = z5.union([
328
- valueContentReferenceToAssetSchema,
329
- valueContentReferenceToCollectionSchema,
330
- valueContentReferenceToEntrySchema
331
- // valueContentReferenceToSharedValueSchema,
332
- ]);
333
- var directValueBaseSchema = z5.object({
334
- objectType: z5.literal(objectTypeSchema.enum.value).readonly(),
335
- fieldDefinitionId: uuidSchema.readonly()
336
- });
337
- var directStringValueSchema = directValueBaseSchema.extend({
338
- valueType: z5.literal(ValueTypeSchema.enum.string).readonly(),
339
- content: translatableStringSchema
340
- });
341
- var directNumberValueSchema = directValueBaseSchema.extend({
342
- valueType: z5.literal(ValueTypeSchema.enum.number).readonly(),
343
- content: translatableNumberSchema
344
- });
345
- var directBooleanValueSchema = directValueBaseSchema.extend({
346
- valueType: z5.literal(ValueTypeSchema.enum.boolean).readonly(),
347
- content: translatableBooleanSchema
348
- });
349
- var directValueSchema = z5.union([
350
- directStringValueSchema,
351
- directNumberValueSchema,
352
- directBooleanValueSchema
353
- ]);
354
- var referencedValueSchema = z5.object({
355
- objectType: z5.literal(objectTypeSchema.enum.value).readonly(),
356
- fieldDefinitionId: uuidSchema.readonly(),
357
- valueType: z5.literal(ValueTypeSchema.enum.reference).readonly(),
358
- content: translatableArrayOf(valueContentReferenceSchema)
359
- });
360
- var valueSchema = z5.union([directValueSchema, referencedValueSchema]);
361
-
362
- // src/schema/entrySchema.ts
363
- var entryFileSchema = baseFileSchema.extend({
364
- objectType: z6.literal(objectTypeSchema.enum.entry).readonly(),
365
- values: z6.array(valueSchema)
366
- });
367
- var entrySchema = entryFileSchema.extend({
368
- /**
369
- * Commit history of this Entry
370
- */
371
- history: z6.array(gitCommitSchema)
372
- }).openapi("Entry");
373
- var entryExportSchema = entrySchema.extend({});
374
- var createEntrySchema = entryFileSchema.omit({
375
- id: true,
376
- objectType: true,
377
- created: true,
378
- updated: true
379
- }).extend({
380
- projectId: uuidSchema.readonly(),
381
- collectionId: uuidSchema.readonly(),
382
- values: z6.array(valueSchema)
383
- });
384
- var readEntrySchema = z6.object({
385
- id: uuidSchema.readonly(),
386
- projectId: uuidSchema.readonly(),
387
- collectionId: uuidSchema.readonly(),
388
- commitHash: z6.string().optional().readonly()
389
- });
390
- var updateEntrySchema = entryFileSchema.omit({
391
- objectType: true,
392
- created: true,
393
- updated: true
394
- }).extend({
395
- projectId: uuidSchema.readonly(),
396
- collectionId: uuidSchema.readonly()
397
- });
398
- var deleteEntrySchema = readEntrySchema.extend({});
399
- var countEntriesSchema = z6.object({
400
- projectId: uuidSchema.readonly(),
401
- collectionId: uuidSchema.readonly()
402
- });
403
-
404
- // src/schema/fieldSchema.ts
405
- import { z as z7 } from "zod";
406
- var FieldTypeSchema = z7.enum([
407
- // String Values
408
- "text",
409
- "textarea",
410
- "email",
411
- // 'password', @todo maybe if there is a usecase
412
- "url",
413
- "ipv4",
414
- "date",
415
- "time",
416
- "datetime",
417
- "telephone",
418
- // Number Values
419
- "number",
420
- "range",
421
- // Boolean Values
422
- "toggle",
423
- // Reference Values
424
- "asset",
425
- "entry"
426
- // 'sharedValue', // @todo
427
- ]);
428
- var FieldWidthSchema = z7.enum(["12", "6", "4", "3"]);
429
- var FieldDefinitionBaseSchema = z7.object({
430
- id: uuidSchema.readonly(),
431
- label: translatableStringSchema,
432
- description: translatableStringSchema.nullable(),
433
- isRequired: z7.boolean(),
434
- isDisabled: z7.boolean(),
435
- isUnique: z7.boolean(),
436
- inputWidth: FieldWidthSchema
437
- });
438
- var StringFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
439
- {
440
- valueType: z7.literal(ValueTypeSchema.enum.string),
441
- defaultValue: z7.string().nullable()
442
- }
443
- );
444
- var textFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
445
- {
446
- fieldType: z7.literal(FieldTypeSchema.enum.text),
447
- min: z7.number().nullable(),
448
- max: z7.number().nullable()
449
- }
450
- );
451
- var textareaFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
452
- fieldType: z7.literal(FieldTypeSchema.enum.textarea),
453
- min: z7.number().nullable(),
454
- max: z7.number().nullable()
455
- });
456
- var emailFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
457
- fieldType: z7.literal(FieldTypeSchema.enum.email),
458
- defaultValue: z7.email().nullable()
459
- });
460
- var urlFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
461
- fieldType: z7.literal(FieldTypeSchema.enum.url),
462
- defaultValue: z7.url().nullable()
463
- });
464
- var ipv4FieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
465
- {
466
- fieldType: z7.literal(FieldTypeSchema.enum.ipv4),
467
- defaultValue: z7.ipv4().nullable()
468
- }
469
- );
470
- var dateFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
471
- {
472
- fieldType: z7.literal(FieldTypeSchema.enum.date),
473
- defaultValue: z7.iso.date().nullable()
474
- }
475
- );
476
- var timeFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend(
477
- {
478
- fieldType: z7.literal(FieldTypeSchema.enum.time),
479
- defaultValue: z7.iso.time().nullable()
480
- }
481
- );
482
- var datetimeFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
483
- fieldType: z7.literal(FieldTypeSchema.enum.datetime),
484
- defaultValue: z7.iso.datetime().nullable()
485
- });
486
- var telephoneFieldDefinitionSchema = StringFieldDefinitionBaseSchema.extend({
487
- fieldType: z7.literal(FieldTypeSchema.enum.telephone),
488
- defaultValue: z7.e164().nullable()
489
- });
490
- var stringFieldDefinitionSchema = z7.union([
491
- textFieldDefinitionSchema,
492
- textareaFieldDefinitionSchema,
493
- emailFieldDefinitionSchema,
494
- urlFieldDefinitionSchema,
495
- ipv4FieldDefinitionSchema,
496
- dateFieldDefinitionSchema,
497
- timeFieldDefinitionSchema,
498
- datetimeFieldDefinitionSchema,
499
- telephoneFieldDefinitionSchema
500
- ]);
501
- var NumberFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend(
502
- {
503
- valueType: z7.literal(ValueTypeSchema.enum.number),
504
- min: z7.number().nullable(),
505
- max: z7.number().nullable(),
506
- isUnique: z7.literal(false),
507
- defaultValue: z7.number().nullable()
508
- }
509
- );
510
- var numberFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
511
- fieldType: z7.literal(FieldTypeSchema.enum.number)
512
- });
513
- var rangeFieldDefinitionSchema = NumberFieldDefinitionBaseSchema.extend({
514
- fieldType: z7.literal(FieldTypeSchema.enum.range),
515
- // Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
516
- isRequired: z7.literal(true),
517
- min: z7.number(),
518
- max: z7.number(),
519
- defaultValue: z7.number()
520
- });
521
- var BooleanFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
522
- valueType: z7.literal(ValueTypeSchema.enum.boolean),
523
- // Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
524
- isRequired: z7.literal(true),
525
- defaultValue: z7.boolean(),
526
- isUnique: z7.literal(false)
527
- });
528
- var toggleFieldDefinitionSchema = BooleanFieldDefinitionBaseSchema.extend({
529
- fieldType: z7.literal(FieldTypeSchema.enum.toggle)
530
- });
531
- var ReferenceFieldDefinitionBaseSchema = FieldDefinitionBaseSchema.extend({
532
- valueType: z7.literal(ValueTypeSchema.enum.reference)
533
- });
534
- var assetFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
535
- fieldType: z7.literal(FieldTypeSchema.enum.asset),
536
- min: z7.number().nullable(),
537
- max: z7.number().nullable()
538
- });
539
- var entryFieldDefinitionSchema = ReferenceFieldDefinitionBaseSchema.extend({
540
- fieldType: z7.literal(FieldTypeSchema.enum.entry),
541
- ofCollections: z7.array(uuidSchema),
542
- min: z7.number().nullable(),
543
- max: z7.number().nullable()
544
- });
545
- var fieldDefinitionSchema = z7.union([
546
- stringFieldDefinitionSchema,
547
- numberFieldDefinitionSchema,
548
- rangeFieldDefinitionSchema,
549
- toggleFieldDefinitionSchema,
550
- assetFieldDefinitionSchema,
551
- entryFieldDefinitionSchema
552
- // sharedValueDefinitionSchema,
553
- ]);
554
-
555
- // src/schema/collectionSchema.ts
556
- var collectionFileSchema = baseFileSchema.extend({
557
- objectType: z8.literal(objectTypeSchema.enum.collection).readonly(),
558
- name: z8.object({
559
- singular: translatableStringSchema,
560
- plural: translatableStringSchema
561
- }),
562
- slug: z8.object({
563
- singular: z8.string(),
564
- plural: z8.string()
565
- }),
566
- description: translatableStringSchema,
567
- icon: supportedIconSchema,
568
- fieldDefinitions: z8.array(fieldDefinitionSchema)
569
- });
570
- var collectionSchema = collectionFileSchema.extend({
571
- /**
572
- * Commit history of this Collection
573
- */
574
- history: z8.array(gitCommitSchema)
575
- }).openapi("Collection");
576
- var collectionExportSchema = collectionSchema.extend({
577
- entries: z8.array(entryExportSchema)
578
- });
579
- var createCollectionSchema = collectionFileSchema.omit({
580
- id: true,
581
- objectType: true,
582
- created: true,
583
- updated: true
584
- }).extend({
585
- projectId: uuidSchema.readonly()
586
- });
587
- var readCollectionSchema = z8.object({
588
- id: uuidSchema.readonly(),
589
- projectId: uuidSchema.readonly(),
590
- commitHash: z8.string().optional().readonly()
591
- });
592
- var updateCollectionSchema = collectionFileSchema.pick({
593
- id: true,
594
- name: true,
595
- slug: true,
596
- description: true,
597
- icon: true,
598
- fieldDefinitions: true
599
- }).extend({
600
- projectId: uuidSchema.readonly()
601
- });
602
- var deleteCollectionSchema = readCollectionSchema.extend({});
603
- var countCollectionsSchema = z8.object({
604
- projectId: uuidSchema.readonly()
605
- });
606
-
607
- // src/schema/coreSchema.ts
608
- import { z as z9 } from "zod";
609
- var elekIoCoreOptionsSchema = z9.object({
610
- log: z9.object({
611
- /**
612
- * The lowest level that should be logged
613
- *
614
- * @default 'info'
615
- */
616
- level: logLevelSchema
617
- }),
618
- file: z9.object({
619
- /**
620
- * If set to true, caches files in memory to speed up access
621
- *
622
- * @default true
623
- */
624
- cache: z9.boolean()
625
- })
626
- });
627
- var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.partial({
628
- log: true,
629
- file: true
630
- }).optional();
631
-
632
- // src/schema/projectSchema.ts
633
- import { z as z10 } from "@hono/zod-openapi";
634
- var projectStatusSchema = z10.enum(["foo", "bar", "todo"]);
635
- var projectSettingsSchema = z10.object({
636
- language: z10.object({
637
- default: supportedLanguageSchema,
638
- supported: z10.array(supportedLanguageSchema)
639
- })
640
- });
641
- var projectFolderSchema = z10.enum([
642
- "assets",
643
- "collections",
644
- "shared-values",
645
- "lfs"
646
- // 'logs',
647
- // 'public',
648
- // 'theme',
649
- ]);
650
- var projectBranchSchema = z10.enum(["production", "work"]);
651
- var projectFileSchema = baseFileSchema.extend({
652
- objectType: z10.literal(objectTypeSchema.enum.project).readonly(),
653
- coreVersion: versionSchema,
654
- name: z10.string().trim().min(1, "shared.projectNameRequired"),
655
- description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
656
- version: versionSchema,
657
- status: projectStatusSchema,
658
- settings: projectSettingsSchema
659
- });
660
- var projectSchema = projectFileSchema.extend({
661
- remoteOriginUrl: z10.string().nullable().openapi({
662
- description: "URL of the remote Git repository"
663
- }),
664
- history: z10.array(gitCommitSchema).openapi({
665
- description: "Commit history of this Project"
666
- }),
667
- fullHistory: z10.array(gitCommitSchema).openapi({
668
- description: "Full commit history of this Project including all Assets, Collections, Entries and other files"
669
- })
670
- }).openapi("Project");
671
- var outdatedProjectSchema = projectFileSchema.pick({
672
- id: true,
673
- name: true,
674
- coreVersion: true
675
- });
676
- var projectExportSchema = projectSchema.extend({
677
- assets: z10.array(assetExportSchema),
678
- collections: z10.array(collectionExportSchema)
679
- });
680
- var createProjectSchema = projectSchema.pick({
681
- name: true,
682
- description: true,
683
- settings: true
684
- }).partial({
685
- description: true,
686
- settings: true
687
- });
688
- var readProjectSchema = z10.object({
689
- id: uuidSchema.readonly(),
690
- commitHash: z10.string().optional().readonly()
691
- });
692
- var updateProjectSchema = projectSchema.pick({
693
- id: true,
694
- name: true,
695
- description: true,
696
- settings: true
697
- }).partial({
698
- name: true,
699
- description: true,
700
- settings: true
701
- });
702
- var upgradeProjectSchema = z10.object({
703
- id: uuidSchema.readonly(),
704
- /**
705
- * Force the upgrade even if the Project is up-to-date
706
- */
707
- force: z10.boolean().optional()
708
- });
709
- var deleteProjectSchema = readProjectSchema.extend({
710
- force: z10.boolean().optional()
711
- });
712
- var projectUpgradeSchema = z10.object({
713
- /**
714
- * The Core version the Project will be upgraded to
715
- */
716
- to: versionSchema.readonly(),
717
- /**
718
- * Function that will be executed in the process of upgrading a Project
719
- */
720
- run: z10.function({
721
- input: [projectFileSchema],
722
- output: z10.promise(z10.void())
723
- })
724
- });
725
- var cloneProjectSchema = z10.object({
726
- url: z10.string()
727
- });
728
- var listBranchesProjectSchema = z10.object({
729
- id: uuidSchema.readonly()
730
- });
731
- var currentBranchProjectSchema = z10.object({
732
- id: uuidSchema.readonly()
733
- });
734
- var switchBranchProjectSchema = z10.object({
735
- id: uuidSchema.readonly(),
736
- branch: z10.string(),
737
- options: gitSwitchOptionsSchema.optional()
738
- });
739
- var getRemoteOriginUrlProjectSchema = z10.object({
740
- id: uuidSchema.readonly()
741
- });
742
- var setRemoteOriginUrlProjectSchema = z10.object({
743
- id: uuidSchema.readonly(),
744
- url: z10.string()
745
- });
746
- var getChangesProjectSchema = z10.object({
747
- id: uuidSchema.readonly()
748
- });
749
- var synchronizeProjectSchema = z10.object({
750
- id: uuidSchema.readonly()
751
- });
752
- var searchProjectSchema = z10.object({
753
- id: uuidSchema.readonly(),
754
- query: z10.string(),
755
- language: supportedLanguageSchema,
756
- type: z10.array(objectTypeSchema).optional()
757
- });
758
-
759
- // src/schema/schemaFromFieldDefinition.ts
760
- import z11 from "zod";
761
- function getBooleanValueContentSchemaFromFieldDefinition() {
762
- return z11.boolean();
763
- }
764
- function getNumberValueContentSchemaFromFieldDefinition(fieldDefinition) {
765
- let schema = z11.number();
766
- if (fieldDefinition.min) {
767
- schema = schema.min(fieldDefinition.min);
768
- }
769
- if (fieldDefinition.max) {
770
- schema = schema.max(fieldDefinition.max);
771
- }
772
- if (fieldDefinition.isRequired === false) {
773
- return schema.nullable();
774
- }
775
- return schema;
776
- }
777
- function getStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
778
- let schema = null;
779
- switch (fieldDefinition.fieldType) {
780
- case FieldTypeSchema.enum.email:
781
- schema = z11.email();
782
- break;
783
- case FieldTypeSchema.enum.url:
784
- schema = z11.url();
785
- break;
786
- case FieldTypeSchema.enum.ipv4:
787
- schema = z11.ipv4();
788
- break;
789
- case FieldTypeSchema.enum.date:
790
- schema = z11.iso.date();
791
- break;
792
- case FieldTypeSchema.enum.time:
793
- schema = z11.iso.time();
794
- break;
795
- case FieldTypeSchema.enum.datetime:
796
- schema = z11.iso.datetime();
797
- break;
798
- case FieldTypeSchema.enum.telephone:
799
- schema = z11.e164();
800
- break;
801
- case FieldTypeSchema.enum.text:
802
- case FieldTypeSchema.enum.textarea:
803
- schema = z11.string().trim();
804
- break;
805
- }
806
- if ("min" in fieldDefinition && fieldDefinition.min) {
807
- schema = schema.min(fieldDefinition.min);
808
- }
809
- if ("max" in fieldDefinition && fieldDefinition.max) {
810
- schema = schema.max(fieldDefinition.max);
811
- }
812
- if (fieldDefinition.isRequired === false) {
813
- return schema.nullable();
814
- }
815
- return schema.min(1, "shared.stringValueRequired");
816
- }
817
- function getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
818
- let schema;
819
- switch (fieldDefinition.fieldType) {
820
- case FieldTypeSchema.enum.asset:
821
- {
822
- schema = z11.array(valueContentReferenceToAssetSchema);
823
- }
824
- break;
825
- case FieldTypeSchema.enum.entry:
826
- {
827
- schema = z11.array(valueContentReferenceToEntrySchema);
828
- }
829
- break;
830
- }
831
- if (fieldDefinition.isRequired) {
832
- schema = schema.min(1, "shared.referenceRequired");
833
- }
834
- if (fieldDefinition.min) {
835
- schema = schema.min(fieldDefinition.min);
836
- }
837
- if (fieldDefinition.max) {
838
- schema = schema.max(fieldDefinition.max);
839
- }
840
- return schema;
841
- }
842
- function getTranslatableStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
843
- return z11.partialRecord(
844
- supportedLanguageSchema,
845
- getStringValueContentSchemaFromFieldDefinition(fieldDefinition)
846
- );
847
- }
848
- function getTranslatableNumberValueContentSchemaFromFieldDefinition(fieldDefinition) {
849
- return z11.partialRecord(
850
- supportedLanguageSchema,
851
- getNumberValueContentSchemaFromFieldDefinition(fieldDefinition)
852
- );
853
- }
854
- function getTranslatableBooleanValueContentSchemaFromFieldDefinition() {
855
- return z11.partialRecord(
856
- supportedLanguageSchema,
857
- getBooleanValueContentSchemaFromFieldDefinition()
858
- );
859
- }
860
- function getTranslatableReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
861
- return z11.partialRecord(
862
- supportedLanguageSchema,
863
- getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition)
864
- );
865
- }
866
- function getValueSchemaFromFieldDefinition(fieldDefinition) {
867
- switch (fieldDefinition.valueType) {
868
- case ValueTypeSchema.enum.boolean:
869
- return directBooleanValueSchema.extend({
870
- content: getTranslatableBooleanValueContentSchemaFromFieldDefinition()
871
- });
872
- case ValueTypeSchema.enum.number:
873
- return directNumberValueSchema.extend({
874
- content: getTranslatableNumberValueContentSchemaFromFieldDefinition(
875
- fieldDefinition
876
- )
877
- });
878
- case ValueTypeSchema.enum.string:
879
- return directStringValueSchema.extend({
880
- content: getTranslatableStringValueContentSchemaFromFieldDefinition(
881
- fieldDefinition
882
- )
883
- });
884
- case ValueTypeSchema.enum.reference:
885
- return referencedValueSchema.extend({
886
- content: getTranslatableReferenceValueContentSchemaFromFieldDefinition(
887
- fieldDefinition
888
- )
889
- });
890
- default:
891
- throw new Error(
892
- // @ts-expect-error Code cannot be reached, but if we add a new ValueType and forget to update this function, we want to be notified about it
893
- `Error generating schema for unsupported ValueType "${fieldDefinition.valueType}"`
894
- );
895
- }
896
- }
897
- function getCreateEntrySchemaFromFieldDefinitions(fieldDefinitions, values) {
898
- const schema = {
899
- ...createEntrySchema,
900
- values: values.map((value) => {
901
- const fieldDefinition = fieldDefinitions.find(
902
- (fieldDefinition2) => fieldDefinition2.id === value.fieldDefinitionId
903
- );
904
- if (!fieldDefinition) {
905
- throw new Error(
906
- `Field definition with ID "${value.fieldDefinitionId}" not found`
907
- );
908
- }
909
- return getValueSchemaFromFieldDefinition(fieldDefinition);
910
- })
911
- };
912
- return schema;
913
- }
914
- function getUpdateEntrySchemaFromFieldDefinitions(fieldDefinitions, values) {
915
- const schema = {
916
- ...updateEntrySchema,
917
- values: values.map((value) => {
918
- const fieldDefinition = fieldDefinitions.find(
919
- (fieldDefinition2) => fieldDefinition2.id === value.fieldDefinitionId
920
- );
921
- if (!fieldDefinition) {
922
- throw new Error(
923
- `Field definition with ID "${value.fieldDefinitionId}" not found`
924
- );
925
- }
926
- return getValueSchemaFromFieldDefinition(fieldDefinition);
927
- })
928
- };
929
- return schema;
930
- }
931
-
932
- // src/schema/serviceSchema.ts
933
- import { z as z12 } from "zod";
934
- var serviceTypeSchema = z12.enum([
935
- "Git",
936
- "GitTag",
937
- "User",
938
- "Project",
939
- "Asset",
940
- "JsonFile",
941
- "Search",
942
- "Collection",
943
- "Entry",
944
- "Value"
945
- ]);
946
- function paginatedListOf(schema) {
947
- return z12.object({
948
- total: z12.number(),
949
- limit: z12.number(),
950
- offset: z12.number(),
951
- list: z12.array(schema)
952
- });
953
- }
954
- var listSchema = z12.object({
955
- projectId: uuidSchema,
956
- limit: z12.number().optional(),
957
- offset: z12.number().optional()
958
- });
959
- var listCollectionsSchema = listSchema;
960
- var listEntriesSchema = listSchema.extend({
961
- collectionId: uuidSchema
962
- });
963
- var listAssetsSchema = listSchema;
964
- var listProjectsSchema = listSchema.omit({
965
- projectId: true
966
- });
967
- var listGitTagsSchema = z12.object({
968
- path: z12.string()
969
- });
970
-
971
- // src/schema/userSchema.ts
972
- import z13 from "zod";
973
- var UserTypeSchema = z13.enum(["local", "cloud"]);
974
- var baseUserSchema = gitSignatureSchema.extend({
975
- userType: UserTypeSchema,
976
- language: supportedLanguageSchema,
977
- localApi: z13.object({
978
- /**
979
- * If set to true the local API is started whenever Core is initialized
980
- */
981
- isEnabled: z13.boolean(),
982
- /**
983
- * The port the local API uses
984
- */
985
- port: z13.number()
986
- })
987
- });
988
- var localUserSchema = baseUserSchema.extend({
989
- userType: z13.literal(UserTypeSchema.enum.local)
990
- });
991
- var cloudUserSchema = baseUserSchema.extend({
992
- userType: z13.literal(UserTypeSchema.enum.cloud),
993
- id: uuidSchema
994
- });
995
- var userFileSchema = z13.union([localUserSchema, cloudUserSchema]);
996
- var userSchema = userFileSchema;
997
- var setUserSchema = userSchema;
998
-
999
- // src/util/shared.ts
1000
- import slugify from "@sindresorhus/slugify";
1001
- import { v4 as generateUuid } from "uuid";
1002
- function uuid() {
1003
- return generateUuid();
1004
- }
1005
- function datetime(value) {
1006
- if (!value) {
1007
- return (/* @__PURE__ */ new Date()).toISOString();
1008
- }
1009
- return new Date(value).toISOString();
1010
- }
1011
- function slug(string) {
1012
- return slugify(string, {
1013
- separator: "-",
1014
- lowercase: true,
1015
- decamelize: true
1016
- });
1017
- }
1018
- export {
1019
- BooleanFieldDefinitionBaseSchema,
1020
- FieldDefinitionBaseSchema,
1021
- FieldTypeSchema,
1022
- FieldWidthSchema,
1023
- NumberFieldDefinitionBaseSchema,
1024
- ReferenceFieldDefinitionBaseSchema,
1025
- StringFieldDefinitionBaseSchema,
1026
- UserTypeSchema,
1027
- ValueTypeSchema,
1028
- assetExportSchema,
1029
- assetFieldDefinitionSchema,
1030
- assetFileSchema,
1031
- assetSchema,
1032
- baseFileSchema,
1033
- baseUserSchema,
1034
- cloneProjectSchema,
1035
- cloudUserSchema,
1036
- collectionExportSchema,
1037
- collectionFileSchema,
1038
- collectionSchema,
1039
- constructorElekIoCoreSchema,
1040
- countAssetsSchema,
1041
- countCollectionsSchema,
1042
- countEntriesSchema,
1043
- countGitTagsSchema,
1044
- createAssetSchema,
1045
- createCollectionSchema,
1046
- createEntrySchema,
1047
- createGitTagSchema,
1048
- createProjectSchema,
1049
- currentBranchProjectSchema,
1050
- dateFieldDefinitionSchema,
1051
- datetime,
1052
- datetimeFieldDefinitionSchema,
1053
- deleteAssetSchema,
1054
- deleteCollectionSchema,
1055
- deleteEntrySchema,
1056
- deleteGitTagSchema,
1057
- deleteProjectSchema,
1058
- directBooleanValueSchema,
1059
- directNumberValueSchema,
1060
- directStringValueSchema,
1061
- directValueBaseSchema,
1062
- directValueSchema,
1063
- elekIoCoreOptionsSchema,
1064
- emailFieldDefinitionSchema,
1065
- entryExportSchema,
1066
- entryFieldDefinitionSchema,
1067
- entryFileSchema,
1068
- entrySchema,
1069
- fieldDefinitionSchema,
1070
- fileReferenceSchema,
1071
- getChangesProjectSchema,
1072
- getCreateEntrySchemaFromFieldDefinitions,
1073
- getRemoteOriginUrlProjectSchema,
1074
- getUpdateEntrySchemaFromFieldDefinitions,
1075
- getValueSchemaFromFieldDefinition,
1076
- gitCloneOptionsSchema,
1077
- gitCommitSchema,
1078
- gitInitOptionsSchema,
1079
- gitLogOptionsSchema,
1080
- gitMergeOptionsSchema,
1081
- gitMessageSchema,
1082
- gitSignatureSchema,
1083
- gitSwitchOptionsSchema,
1084
- gitTagSchema,
1085
- ipv4FieldDefinitionSchema,
1086
- listAssetsSchema,
1087
- listBranchesProjectSchema,
1088
- listCollectionsSchema,
1089
- listEntriesSchema,
1090
- listGitTagsSchema,
1091
- listProjectsSchema,
1092
- localUserSchema,
1093
- logLevelSchema,
1094
- numberFieldDefinitionSchema,
1095
- objectTypeSchema,
1096
- outdatedProjectSchema,
1097
- paginatedListOf,
1098
- projectBranchSchema,
1099
- projectExportSchema,
1100
- projectFileSchema,
1101
- projectFolderSchema,
1102
- projectSchema,
1103
- projectSettingsSchema,
1104
- projectStatusSchema,
1105
- projectUpgradeSchema,
1106
- rangeFieldDefinitionSchema,
1107
- readAssetSchema,
1108
- readCollectionSchema,
1109
- readEntrySchema,
1110
- readGitTagSchema,
1111
- readProjectSchema,
1112
- referencedValueSchema,
1113
- saveAssetSchema,
1114
- searchProjectSchema,
1115
- serviceTypeSchema,
1116
- setRemoteOriginUrlProjectSchema,
1117
- setUserSchema,
1118
- slug,
1119
- stringFieldDefinitionSchema,
1120
- supportedIconSchema,
1121
- supportedLanguageSchema,
1122
- switchBranchProjectSchema,
1123
- synchronizeProjectSchema,
1124
- telephoneFieldDefinitionSchema,
1125
- textFieldDefinitionSchema,
1126
- textareaFieldDefinitionSchema,
1127
- timeFieldDefinitionSchema,
1128
- toggleFieldDefinitionSchema,
1129
- translatableArrayOf,
1130
- translatableBooleanSchema,
1131
- translatableNumberSchema,
1132
- translatableStringSchema,
1133
- updateAssetSchema,
1134
- updateCollectionSchema,
1135
- updateEntrySchema,
1136
- updateProjectSchema,
1137
- upgradeProjectSchema,
1138
- urlFieldDefinitionSchema,
1139
- userFileSchema,
1140
- userSchema,
1141
- uuid,
1142
- uuidSchema,
1143
- valueContentReferenceBase,
1144
- valueContentReferenceSchema,
1145
- valueContentReferenceToAssetSchema,
1146
- valueContentReferenceToCollectionSchema,
1147
- valueContentReferenceToEntrySchema,
1148
- valueSchema,
1149
- versionSchema
1150
- };
1
+ import{z as e}from"@hono/zod-openapi";import{z as t}from"zod";import n from"@sindresorhus/slugify";import{v4 as ee}from"uuid";const r=e.enum([`bg`,`cs`,`da`,`de`,`el`,`en`,`es`,`et`,`fi`,`fr`,`hu`,`it`,`ja`,`lt`,`lv`,`nl`,`pl`,`pt`,`ro`,`ru`,`sk`,`sl`,`sv`,`zh`]),te=e.enum([`home`,`plus`,`foobar`]),i=e.enum([`project`,`asset`,`collection`,`entry`,`value`,`sharedValue`]),a=e.enum([`error`,`warn`,`info`,`debug`]),o=e.string(),s=e.uuid(`shared.invalidUuid`),c=e.partialRecord(r,e.string().trim().min(1,`shared.translatableStringRequired`)),l=e.partialRecord(r,e.number({error:e=>e.input===void 0?`shared.translatableNumberRequired`:`shared.translatableNumberNotANumber`})),ne=e.partialRecord(r,e.boolean({error:e=>e.input===void 0?`shared.translatableBooleanRequired`:`shared.translatableBooleanNotABoolean`}));function re(t){return e.partialRecord(r,e.array(t))}const u=e.object({objectType:i.readonly(),id:s.readonly(),created:e.string().datetime().readonly(),updated:e.string().datetime().nullable()}),ie=e.object({id:s,extension:e.string().optional()}),d=e.object({name:e.string(),email:e.string().email()}),f=e.object({method:e.enum([`create`,`update`,`delete`,`upgrade`]),reference:e.object({objectType:i,id:s,collectionId:s.optional()})}),p=e.object({id:s,message:e.string(),author:d,datetime:e.string().datetime()}),m=e.object({hash:e.string(),message:f,author:d,datetime:e.string().datetime(),tag:p.nullable()}),ae=e.object({initialBranch:e.string()}),oe=e.object({depth:e.number(),singleBranch:e.boolean(),branch:e.string(),bare:e.boolean()}),se=e.object({squash:e.boolean()}),h=e.object({isNew:e.boolean().optional()}),ce=e.object({limit:e.number().optional(),between:e.object({from:e.string(),to:e.string().optional()}),filePath:e.string().optional()}),le=p.pick({message:!0}).extend({path:e.string(),hash:e.string().optional()}),g=e.object({path:e.string(),id:s.readonly()}),ue=g.extend({}),de=e.object({path:e.string()}),_=u.extend({objectType:e.literal(i.enum.asset).readonly(),name:e.string(),description:e.string(),extension:e.string().readonly(),mimeType:e.string().readonly(),size:e.number().readonly()}),fe=_.extend({absolutePath:e.string().readonly(),history:e.array(m)}).openapi(`Asset`),pe=fe.extend({}),me=_.pick({name:!0,description:!0}).extend({projectId:s.readonly(),filePath:e.string().readonly()}),he=_.pick({id:!0}).extend({projectId:s.readonly(),commitHash:e.string().optional().readonly()}),ge=_.pick({id:!0}).extend({projectId:s.readonly(),filePath:e.string().readonly(),commitHash:e.string().optional().readonly()}),_e=_.pick({id:!0,name:!0,description:!0}).extend({projectId:s.readonly(),newFilePath:e.string().readonly().optional()}),ve=_.pick({id:!0,extension:!0}).extend({projectId:s.readonly()}),ye=e.object({projectId:s.readonly()}),v=e.enum([`string`,`number`,`boolean`,`reference`]),y=e.object({id:s}),b=y.extend({objectType:e.literal(i.enum.asset)}),x=y.extend({objectType:e.literal(i.enum.collection)}),S=y.extend({objectType:e.literal(i.enum.entry)}),C=e.union([b,x,S]),w=e.object({objectType:e.literal(i.enum.value).readonly(),fieldDefinitionId:s.readonly()}),T=w.extend({valueType:e.literal(v.enum.string).readonly(),content:c}),E=w.extend({valueType:e.literal(v.enum.number).readonly(),content:l}),D=w.extend({valueType:e.literal(v.enum.boolean).readonly(),content:ne}),O=e.union([T,E,D]),k=e.object({objectType:e.literal(i.enum.value).readonly(),fieldDefinitionId:s.readonly(),valueType:e.literal(v.enum.reference).readonly(),content:re(C)}),A=e.union([O,k]),j=u.extend({objectType:e.literal(i.enum.entry).readonly(),values:e.array(A)}),M=j.extend({history:e.array(m)}).openapi(`Entry`),N=M.extend({}),P=j.omit({id:!0,objectType:!0,created:!0,updated:!0}).extend({projectId:s.readonly(),collectionId:s.readonly(),values:e.array(A)}),F=e.object({id:s.readonly(),projectId:s.readonly(),collectionId:s.readonly(),commitHash:e.string().optional().readonly()}),I=j.omit({objectType:!0,created:!0,updated:!0}).extend({projectId:s.readonly(),collectionId:s.readonly()}),be=F.extend({}),xe=e.object({projectId:s.readonly(),collectionId:s.readonly()}),L=e.enum([`text`,`textarea`,`email`,`url`,`ipv4`,`date`,`time`,`datetime`,`telephone`,`number`,`range`,`toggle`,`asset`,`entry`]),R=e.enum([`12`,`6`,`4`,`3`]),z=e.object({id:s.readonly(),label:c,description:c.nullable(),isRequired:e.boolean(),isDisabled:e.boolean(),isUnique:e.boolean(),inputWidth:R}),B=z.extend({valueType:e.literal(v.enum.string),defaultValue:e.string().nullable()}),V=B.extend({fieldType:e.literal(L.enum.text),min:e.number().nullable(),max:e.number().nullable()}),H=B.extend({fieldType:e.literal(L.enum.textarea),min:e.number().nullable(),max:e.number().nullable()}),U=B.extend({fieldType:e.literal(L.enum.email),defaultValue:e.email().nullable()}),Se=B.extend({fieldType:e.literal(L.enum.url),defaultValue:e.url().nullable()}),Ce=B.extend({fieldType:e.literal(L.enum.ipv4),defaultValue:e.ipv4().nullable()}),we=B.extend({fieldType:e.literal(L.enum.date),defaultValue:e.iso.date().nullable()}),Te=B.extend({fieldType:e.literal(L.enum.time),defaultValue:e.iso.time().nullable()}),Ee=B.extend({fieldType:e.literal(L.enum.datetime),defaultValue:e.iso.datetime().nullable()}),De=B.extend({fieldType:e.literal(L.enum.telephone),defaultValue:e.e164().nullable()}),Oe=e.union([V,H,U,Se,Ce,we,Te,Ee,De]),W=z.extend({valueType:e.literal(v.enum.number),min:e.number().nullable(),max:e.number().nullable(),isUnique:e.literal(!1),defaultValue:e.number().nullable()}),ke=W.extend({fieldType:e.literal(L.enum.number)}),Ae=W.extend({fieldType:e.literal(L.enum.range),isRequired:e.literal(!0),min:e.number(),max:e.number(),defaultValue:e.number()}),je=z.extend({valueType:e.literal(v.enum.boolean),isRequired:e.literal(!0),defaultValue:e.boolean(),isUnique:e.literal(!1)}),Me=je.extend({fieldType:e.literal(L.enum.toggle)}),G=z.extend({valueType:e.literal(v.enum.reference)}),Ne=G.extend({fieldType:e.literal(L.enum.asset),min:e.number().nullable(),max:e.number().nullable()}),Pe=G.extend({fieldType:e.literal(L.enum.entry),ofCollections:e.array(s),min:e.number().nullable(),max:e.number().nullable()}),Fe=e.union([Oe,ke,Ae,Me,Ne,Pe]),K=u.extend({objectType:e.literal(i.enum.collection).readonly(),name:e.object({singular:c,plural:c}),slug:e.object({singular:e.string(),plural:e.string()}),description:c,icon:te,fieldDefinitions:e.array(Fe)}),Ie=K.extend({history:e.array(m)}).openapi(`Collection`),q=Ie.extend({entries:e.array(N)}),Le=K.omit({id:!0,objectType:!0,created:!0,updated:!0}).extend({projectId:s.readonly()}),Re=e.object({id:s.readonly(),projectId:s.readonly(),commitHash:e.string().optional().readonly()}),ze=K.pick({id:!0,name:!0,slug:!0,description:!0,icon:!0,fieldDefinitions:!0}).extend({projectId:s.readonly()}),Be=Re.extend({}),Ve=e.object({projectId:s.readonly()}),He=e.object({log:e.object({level:a}),file:e.object({cache:e.boolean()})}),Ue=He.partial({log:!0,file:!0}).optional(),We=e.enum([`foo`,`bar`,`todo`]),Ge=e.object({language:e.object({default:r,supported:e.array(r)})}),Ke=e.enum([`assets`,`collections`,`shared-values`,`lfs`]),qe=e.enum([`production`,`work`]),J=u.extend({objectType:e.literal(i.enum.project).readonly(),coreVersion:o,name:e.string().trim().min(1,`shared.projectNameRequired`),description:e.string().trim().min(1,`shared.projectDescriptionRequired`),version:o,status:We,settings:Ge}),Y=J.extend({remoteOriginUrl:e.string().nullable().openapi({description:`URL of the remote Git repository`}),history:e.array(m).openapi({description:`Commit history of this Project`}),fullHistory:e.array(m).openapi({description:`Full commit history of this Project including all Assets, Collections, Entries and other files`})}).openapi(`Project`),Je=J.pick({id:!0,name:!0,coreVersion:!0}),Ye=Y.extend({assets:e.array(pe),collections:e.array(q)}),Xe=Y.pick({name:!0,description:!0,settings:!0}).partial({description:!0,settings:!0}),Ze=e.object({id:s.readonly(),commitHash:e.string().optional().readonly()}),Qe=Y.pick({id:!0,name:!0,description:!0,settings:!0}).partial({name:!0,description:!0,settings:!0}),$e=e.object({id:s.readonly(),force:e.boolean().optional()}),et=Ze.extend({force:e.boolean().optional()}),tt=e.object({to:o.readonly(),run:e.function({input:[J],output:e.promise(e.void())})}),nt=e.object({url:e.string()}),rt=e.object({id:s.readonly()}),it=e.object({id:s.readonly()}),at=e.object({id:s.readonly(),branch:e.string(),options:h.optional()}),ot=e.object({id:s.readonly()}),st=e.object({id:s.readonly(),url:e.string()}),ct=e.object({id:s.readonly()}),lt=e.object({id:s.readonly()}),ut=e.object({id:s.readonly(),query:e.string(),language:r,type:e.array(i).optional()});function dt(){return e.boolean()}function ft(t){let n=e.number();return t.min&&(n=n.min(t.min)),t.max&&(n=n.max(t.max)),t.isRequired===!1?n.nullable():n}function pt(t){let n=null;switch(t.fieldType){case L.enum.email:n=e.email();break;case L.enum.url:n=e.url();break;case L.enum.ipv4:n=e.ipv4();break;case L.enum.date:n=e.iso.date();break;case L.enum.time:n=e.iso.time();break;case L.enum.datetime:n=e.iso.datetime();break;case L.enum.telephone:n=e.e164();break;case L.enum.text:case L.enum.textarea:n=e.string().trim();break}return`min`in t&&t.min&&(n=n.min(t.min)),`max`in t&&t.max&&(n=n.max(t.max)),t.isRequired===!1?n.nullable():n.min(1,`shared.stringValueRequired`)}function mt(t){let n;switch(t.fieldType){case L.enum.asset:n=e.array(b);break;case L.enum.entry:n=e.array(S);break}return t.isRequired&&(n=n.min(1,`shared.referenceRequired`)),t.min&&(n=n.min(t.min)),t.max&&(n=n.max(t.max)),n}function ht(t){return e.partialRecord(r,pt(t))}function gt(t){return e.partialRecord(r,ft(t))}function _t(){return e.partialRecord(r,dt())}function vt(t){return e.partialRecord(r,mt(t))}function X(e){switch(e.valueType){case v.enum.boolean:return D.extend({content:_t()});case v.enum.number:return E.extend({content:gt(e)});case v.enum.string:return T.extend({content:ht(e)});case v.enum.reference:return k.extend({content:vt(e)});default:throw Error(`Error generating schema for unsupported ValueType "${e.valueType}"`)}}function yt(t){let n=t.map(e=>X(e));return e.object({...M.shape,values:e.tuple(n)})}function bt(t){let n=t.map(e=>X(e));return e.object({...P.shape,values:e.tuple(n)})}function xt(t){let n=t.map(e=>X(e));return e.object({...I.shape,values:e.tuple(n)})}const St=e.enum([`Git`,`GitTag`,`User`,`Project`,`Asset`,`JsonFile`,`Search`,`Collection`,`Entry`,`Value`]);function Ct(t){return e.object({total:e.number(),limit:e.number(),offset:e.number(),list:e.array(t)})}const Z=e.object({projectId:s,limit:e.number().optional(),offset:e.number().optional()}),wt=Z,Tt=Z.extend({collectionId:s}),Et=Z,Dt=Z.omit({projectId:!0}),Ot=e.object({path:e.string()}),Q=e.enum([`local`,`cloud`]),$=d.extend({userType:Q,language:r,localApi:e.object({isEnabled:e.boolean(),port:e.number()})}),kt=$.extend({userType:e.literal(Q.enum.local)}),At=$.extend({userType:e.literal(Q.enum.cloud),id:s}),jt=e.union([kt,At]),Mt=jt,Nt=Mt,Pt=t.string().default(`./.elek.io`),Ft=t.enum([`ts`,`js`]).default(`ts`),It=t.enum([`esm`,`cjs`]).default(`esm`),Lt=t.enum([`es3`,`es5`,`es6`,`es2015`,`es2016`,`es2017`,`es2018`,`es2019`,`es2020`,`es2021`,`es2022`,`es2023`,`es2024`,`esnext`]).default(`es2020`),Rt=t.string().default(`all`).transform(e=>e===`all`?`all`:e.split(`,`).map(e=>s.parse(e.trim()))),zt=t.object({watch:t.boolean().default(!1)}),Bt=zt.extend({separate:t.boolean().default(!1)}),Vt=t.object({outDir:Pt,language:Ft,format:It,target:Lt,options:zt}),Ht=t.string().default(`31310`).transform((e,n)=>{try{return parseInt(e)}catch{return n.addIssue({code:`custom`,message:`Invalid port number`,input:e}),t.NEVER}}),Ut=t.object({port:Ht}),Wt=t.object({outDir:Pt,projects:Rt,options:Bt}),Gt=e.enum([`core`,`desktop`]),Kt=e.object({source:Gt,message:e.string(),meta:e.record(e.string(),e.unknown()).optional()}),qt=Kt.extend({timestamp:e.string(),level:e.string()});function Jt(){return ee()}function Yt(e){return e?new Date(e).toISOString():new Date().toISOString()}function Xt(e){return n(e,{separator:`-`,lowercase:!0,decamelize:!0})}export{je as BooleanFieldDefinitionBaseSchema,z as FieldDefinitionBaseSchema,L as FieldTypeSchema,R as FieldWidthSchema,W as NumberFieldDefinitionBaseSchema,G as ReferenceFieldDefinitionBaseSchema,B as StringFieldDefinitionBaseSchema,Q as UserTypeSchema,v as ValueTypeSchema,Ut as apiStartSchema,pe as assetExportSchema,Ne as assetFieldDefinitionSchema,_ as assetFileSchema,fe as assetSchema,u as baseFileSchema,$ as baseUserSchema,nt as cloneProjectSchema,At as cloudUserSchema,q as collectionExportSchema,K as collectionFileSchema,Ie as collectionSchema,Ue as constructorElekIoCoreSchema,ye as countAssetsSchema,Ve as countCollectionsSchema,xe as countEntriesSchema,de as countGitTagsSchema,me as createAssetSchema,Le as createCollectionSchema,P as createEntrySchema,le as createGitTagSchema,Xe as createProjectSchema,it as currentBranchProjectSchema,we as dateFieldDefinitionSchema,Yt as datetime,Ee as datetimeFieldDefinitionSchema,ve as deleteAssetSchema,Be as deleteCollectionSchema,be as deleteEntrySchema,ue as deleteGitTagSchema,et as deleteProjectSchema,D as directBooleanValueSchema,E as directNumberValueSchema,T as directStringValueSchema,w as directValueBaseSchema,O as directValueSchema,He as elekIoCoreOptionsSchema,U as emailFieldDefinitionSchema,N as entryExportSchema,Pe as entryFieldDefinitionSchema,j as entryFileSchema,M as entrySchema,Wt as exportSchema,Fe as fieldDefinitionSchema,ie as fileReferenceSchema,Vt as generateApiClientSchema,ct as getChangesProjectSchema,bt as getCreateEntrySchemaFromFieldDefinitions,yt as getEntrySchemaFromFieldDefinitions,ot as getRemoteOriginUrlProjectSchema,xt as getUpdateEntrySchemaFromFieldDefinitions,X as getValueSchemaFromFieldDefinition,oe as gitCloneOptionsSchema,m as gitCommitSchema,ae as gitInitOptionsSchema,ce as gitLogOptionsSchema,se as gitMergeOptionsSchema,f as gitMessageSchema,d as gitSignatureSchema,h as gitSwitchOptionsSchema,p as gitTagSchema,Ce as ipv4FieldDefinitionSchema,Et as listAssetsSchema,rt as listBranchesProjectSchema,wt as listCollectionsSchema,Tt as listEntriesSchema,Ot as listGitTagsSchema,Dt as listProjectsSchema,kt as localUserSchema,qt as logConsoleTransportSchema,a as logLevelSchema,Kt as logSchema,Gt as logSourceSchema,ke as numberFieldDefinitionSchema,i as objectTypeSchema,Je as outdatedProjectSchema,Ct as paginatedListOf,qe as projectBranchSchema,Ye as projectExportSchema,J as projectFileSchema,Ke as projectFolderSchema,Y as projectSchema,Ge as projectSettingsSchema,We as projectStatusSchema,tt as projectUpgradeSchema,Ae as rangeFieldDefinitionSchema,he as readAssetSchema,Re as readCollectionSchema,F as readEntrySchema,g as readGitTagSchema,Ze as readProjectSchema,k as referencedValueSchema,ge as saveAssetSchema,ut as searchProjectSchema,St as serviceTypeSchema,st as setRemoteOriginUrlProjectSchema,Nt as setUserSchema,Xt as slug,Oe as stringFieldDefinitionSchema,te as supportedIconSchema,r as supportedLanguageSchema,at as switchBranchProjectSchema,lt as synchronizeProjectSchema,De as telephoneFieldDefinitionSchema,V as textFieldDefinitionSchema,H as textareaFieldDefinitionSchema,Te as timeFieldDefinitionSchema,Me as toggleFieldDefinitionSchema,re as translatableArrayOf,ne as translatableBooleanSchema,l as translatableNumberSchema,c as translatableStringSchema,_e as updateAssetSchema,ze as updateCollectionSchema,I as updateEntrySchema,Qe as updateProjectSchema,$e as upgradeProjectSchema,Se as urlFieldDefinitionSchema,jt as userFileSchema,Mt as userSchema,Jt as uuid,s as uuidSchema,y as valueContentReferenceBase,C as valueContentReferenceSchema,b as valueContentReferenceToAssetSchema,x as valueContentReferenceToCollectionSchema,S as valueContentReferenceToEntrySchema,A as valueSchema,o as versionSchema};
1151
2
  //# sourceMappingURL=index.browser.js.map