@elek-io/core 0.3.1 → 0.4.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/index.cjs CHANGED
@@ -30,14 +30,142 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- default: () => ElekIoCore
33
+ BooleanValueDefinitionBaseSchema: () => BooleanValueDefinitionBaseSchema,
34
+ NumberValueDefinitionBaseSchema: () => NumberValueDefinitionBaseSchema,
35
+ ReferenceValueDefinitionBaseSchema: () => ReferenceValueDefinitionBaseSchema,
36
+ StringValueDefinitionBaseSchema: () => StringValueDefinitionBaseSchema,
37
+ UserTypeSchema: () => UserTypeSchema,
38
+ ValueDefinitionBaseSchema: () => ValueDefinitionBaseSchema,
39
+ ValueInputTypeSchema: () => ValueInputTypeSchema,
40
+ ValueInputWidthSchema: () => ValueInputWidthSchema,
41
+ ValueTypeSchema: () => ValueTypeSchema,
42
+ assetExportSchema: () => assetExportSchema,
43
+ assetFileSchema: () => assetFileSchema,
44
+ assetSchema: () => assetSchema,
45
+ assetValueDefinitionSchema: () => assetValueDefinitionSchema,
46
+ baseFileSchema: () => baseFileSchema,
47
+ baseFileWithLanguageSchema: () => baseFileWithLanguageSchema,
48
+ baseUserSchema: () => baseUserSchema,
49
+ cloneProjectSchema: () => cloneProjectSchema,
50
+ cloudUserSchema: () => cloudUserSchema,
51
+ collectionExportSchema: () => collectionExportSchema,
52
+ collectionFileSchema: () => collectionFileSchema,
53
+ collectionSchema: () => collectionSchema,
54
+ constructorElekIoCoreSchema: () => constructorElekIoCoreSchema,
55
+ countAssetsSchema: () => countAssetsSchema,
56
+ countCollectionsSchema: () => countCollectionsSchema,
57
+ countEntriesSchema: () => countEntriesSchema,
58
+ countGitTagsSchema: () => countGitTagsSchema,
59
+ createAssetSchema: () => createAssetSchema,
60
+ createCollectionSchema: () => createCollectionSchema,
61
+ createEntrySchema: () => createEntrySchema,
62
+ createGitTagSchema: () => createGitTagSchema,
63
+ createProjectSchema: () => createProjectSchema,
64
+ currentBranchProjectSchema: () => currentBranchProjectSchema,
65
+ dateValueDefinitionSchema: () => dateValueDefinitionSchema,
66
+ datetimeValueDefinitionSchema: () => datetimeValueDefinitionSchema,
67
+ default: () => ElekIoCore,
68
+ deleteAssetSchema: () => deleteAssetSchema,
69
+ deleteCollectionSchema: () => deleteCollectionSchema,
70
+ deleteEntrySchema: () => deleteEntrySchema,
71
+ deleteGitTagSchema: () => deleteGitTagSchema,
72
+ deleteProjectSchema: () => deleteProjectSchema,
73
+ directBooleanValueSchema: () => directBooleanValueSchema,
74
+ directNumberValueSchema: () => directNumberValueSchema,
75
+ directStringValueSchema: () => directStringValueSchema,
76
+ directValueBaseSchema: () => directValueBaseSchema,
77
+ directValueSchema: () => directValueSchema,
78
+ elekIoCoreOptionsSchema: () => elekIoCoreOptionsSchema,
79
+ emailValueDefinitionSchema: () => emailValueDefinitionSchema,
80
+ entryExportSchema: () => entryExportSchema,
81
+ entryFileSchema: () => entryFileSchema,
82
+ entrySchema: () => entrySchema,
83
+ entryValueDefinitionSchema: () => entryValueDefinitionSchema,
84
+ environmentSchema: () => environmentSchema,
85
+ fileReferenceSchema: () => fileReferenceSchema,
86
+ getChangesProjectSchema: () => getChangesProjectSchema,
87
+ getRemoteOriginUrlProjectSchema: () => getRemoteOriginUrlProjectSchema,
88
+ getValueContentSchemaFromDefinition: () => getValueContentSchemaFromDefinition,
89
+ gitCloneOptionsSchema: () => gitCloneOptionsSchema,
90
+ gitCommitIconSchema: () => gitCommitIconSchema,
91
+ gitCommitSchema: () => gitCommitSchema,
92
+ gitInitOptionsSchema: () => gitInitOptionsSchema,
93
+ gitLogOptionsSchema: () => gitLogOptionsSchema,
94
+ gitRepositoryPathSchema: () => gitRepositoryPathSchema,
95
+ gitSignatureSchema: () => gitSignatureSchema,
96
+ gitSwitchOptionsSchema: () => gitSwitchOptionsSchema,
97
+ gitTagSchema: () => gitTagSchema,
98
+ ipValueDefinitionSchema: () => ipValueDefinitionSchema,
99
+ listAssetsSchema: () => listAssetsSchema,
100
+ listBranchesProjectSchema: () => listBranchesProjectSchema,
101
+ listCollectionsSchema: () => listCollectionsSchema,
102
+ listEntriesSchema: () => listEntriesSchema,
103
+ listGitTagsSchema: () => listGitTagsSchema,
104
+ listProjectsSchema: () => listProjectsSchema,
105
+ localUserSchema: () => localUserSchema,
106
+ numberValueDefinitionSchema: () => numberValueDefinitionSchema,
107
+ objectTypeSchema: () => objectTypeSchema,
108
+ projectExportSchema: () => projectExportSchema,
109
+ projectFileSchema: () => projectFileSchema,
110
+ projectFolderSchema: () => projectFolderSchema,
111
+ projectSchema: () => projectSchema,
112
+ projectSettingsSchema: () => projectSettingsSchema,
113
+ projectStatusSchema: () => projectStatusSchema,
114
+ projectUpgradeSchema: () => projectUpgradeSchema,
115
+ rangeValueDefinitionSchema: () => rangeValueDefinitionSchema,
116
+ readAssetSchema: () => readAssetSchema,
117
+ readCollectionSchema: () => readCollectionSchema,
118
+ readEntrySchema: () => readEntrySchema,
119
+ readGitTagSchema: () => readGitTagSchema,
120
+ readProjectSchema: () => readProjectSchema,
121
+ referencedValueSchema: () => referencedValueSchema,
122
+ resolvedReferencedValueSchema: () => resolvedReferencedValueSchema,
123
+ resolvedValueContentReferenceSchema: () => resolvedValueContentReferenceSchema,
124
+ resolvedValueSchema: () => resolvedValueSchema,
125
+ searchProjectSchema: () => searchProjectSchema,
126
+ serviceTypeSchema: () => serviceTypeSchema,
127
+ setRemoteOriginUrlProjectSchema: () => setRemoteOriginUrlProjectSchema,
128
+ setUserSchema: () => setUserSchema,
129
+ stringValueDefinitionSchema: () => stringValueDefinitionSchema,
130
+ supportedAssetExtensionSchema: () => supportedAssetExtensionSchema,
131
+ supportedAssetMimeTypeSchema: () => supportedAssetMimeTypeSchema,
132
+ supportedAssetTypeSchema: () => supportedAssetTypeSchema,
133
+ supportedIconSchema: () => supportedIconSchema,
134
+ supportedLanguageSchema: () => supportedLanguageSchema,
135
+ switchBranchProjectSchema: () => switchBranchProjectSchema,
136
+ synchronizeProjectSchema: () => synchronizeProjectSchema,
137
+ telephoneValueDefinitionSchema: () => telephoneValueDefinitionSchema,
138
+ textValueDefinitionSchema: () => textValueDefinitionSchema,
139
+ textareaValueDefinitionSchema: () => textareaValueDefinitionSchema,
140
+ timeValueDefinitionSchema: () => timeValueDefinitionSchema,
141
+ toggleValueDefinitionSchema: () => toggleValueDefinitionSchema,
142
+ translatableArrayOf: () => translatableArrayOf,
143
+ translatableBooleanSchema: () => translatableBooleanSchema,
144
+ translatableNumberSchema: () => translatableNumberSchema,
145
+ translatableStringSchema: () => translatableStringSchema,
146
+ updateAssetSchema: () => updateAssetSchema,
147
+ updateCollectionSchema: () => updateCollectionSchema,
148
+ updateEntrySchema: () => updateEntrySchema,
149
+ updateProjectSchema: () => updateProjectSchema,
150
+ upgradeProjectSchema: () => upgradeProjectSchema,
151
+ urlValueDefinitionSchema: () => urlValueDefinitionSchema,
152
+ userFileSchema: () => userFileSchema,
153
+ userSchema: () => userSchema,
154
+ uuidSchema: () => uuidSchema,
155
+ valueContentReferenceBase: () => valueContentReferenceBase,
156
+ valueContentReferenceSchema: () => valueContentReferenceSchema,
157
+ valueContentReferenceToAssetSchema: () => valueContentReferenceToAssetSchema,
158
+ valueContentReferenceToCollectionSchema: () => valueContentReferenceToCollectionSchema,
159
+ valueContentReferenceToEntrySchema: () => valueContentReferenceToEntrySchema,
160
+ valueContentReferenceWithLanguageBase: () => valueContentReferenceWithLanguageBase,
161
+ valueDefinitionSchema: () => valueDefinitionSchema,
162
+ valueSchema: () => valueSchema,
163
+ versionSchema: () => versionSchema
34
164
  });
35
165
  module.exports = __toCommonJS(src_exports);
36
- var import_shared12 = require("@elek-io/shared");
37
166
  var import_fs_extra7 = __toESM(require("fs-extra"), 1);
38
167
 
39
168
  // src/service/AssetService.ts
40
- var import_shared7 = require("@elek-io/shared");
41
169
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
42
170
  var import_is_svg = __toESM(require("is-svg"), 1);
43
171
 
@@ -49,10 +177,332 @@ var RequiredParameterMissingError = class extends Error {
49
177
  }
50
178
  };
51
179
 
180
+ // src/schema/assetSchema.ts
181
+ var import_zod3 = __toESM(require("zod"), 1);
182
+
183
+ // src/schema/baseSchema.ts
184
+ var import_zod = __toESM(require("zod"), 1);
185
+ var environmentSchema = import_zod.default.enum(["production", "development", "test"]);
186
+ var supportedLanguageSchema = import_zod.default.enum([
187
+ /**
188
+ * Bulgarian
189
+ */
190
+ "bg",
191
+ //
192
+ "cs",
193
+ // Czech
194
+ "da",
195
+ // Danish
196
+ "de",
197
+ // German
198
+ "el",
199
+ // Greek
200
+ "en",
201
+ // (US) English
202
+ "es",
203
+ // Spanish
204
+ "et",
205
+ // Estonian
206
+ "fi",
207
+ // Finnish
208
+ "fr",
209
+ // French
210
+ "hu",
211
+ // Hungarian
212
+ "it",
213
+ // Italian
214
+ "ja",
215
+ // Japanese
216
+ "lt",
217
+ // Lithuanian
218
+ "lv",
219
+ // Latvian
220
+ "nl",
221
+ // Dutch
222
+ "pl",
223
+ // Polish
224
+ "pt",
225
+ // Portuguese
226
+ "ro",
227
+ // Romanian
228
+ "ru",
229
+ // Russian
230
+ "sk",
231
+ // Slovak
232
+ "sl",
233
+ // Slovenian
234
+ "sv",
235
+ // Swedish
236
+ "zh"
237
+ // (Simplified) Chinese
238
+ ]);
239
+ var supportedIconSchema = import_zod.default.enum(["home", "plus", "foobar"]);
240
+ var supportedAssetMimeTypeSchema = import_zod.default.enum([
241
+ "image/avif",
242
+ "image/gif",
243
+ "image/jpeg",
244
+ "image/png",
245
+ "image/svg+xml",
246
+ "image/webp",
247
+ "application/pdf",
248
+ "application/zip",
249
+ "video/mp4",
250
+ "video/webm",
251
+ "audio/webm",
252
+ "audio/flac"
253
+ ]);
254
+ var supportedAssetExtensionSchema = import_zod.default.enum([
255
+ "avif",
256
+ "gif",
257
+ "jpg",
258
+ "jpeg",
259
+ "png",
260
+ "svg",
261
+ "webp",
262
+ "pdf",
263
+ "zip",
264
+ "mp4",
265
+ "webm",
266
+ "flac",
267
+ "json"
268
+ ]);
269
+ var supportedAssetTypeSchema = import_zod.default.object({
270
+ extension: supportedAssetExtensionSchema,
271
+ mimeType: supportedAssetMimeTypeSchema
272
+ });
273
+ var objectTypeSchema = import_zod.default.enum([
274
+ "project",
275
+ "asset",
276
+ "collection",
277
+ "entry",
278
+ "value",
279
+ "sharedValue"
280
+ ]);
281
+ var versionSchema = import_zod.default.string();
282
+ var uuidSchema = import_zod.default.string().uuid("shared.invalidUuid");
283
+ var translatableStringSchema = import_zod.default.record(
284
+ supportedLanguageSchema,
285
+ import_zod.default.string().trim().min(1, "shared.translatableStringRequired")
286
+ );
287
+ var translatableNumberSchema = import_zod.default.record(
288
+ supportedLanguageSchema,
289
+ import_zod.default.number({ required_error: "shared.translatableNumberRequired" })
290
+ );
291
+ var translatableBooleanSchema = import_zod.default.record(
292
+ supportedLanguageSchema,
293
+ import_zod.default.boolean({ required_error: "shared.translatableBooleanRequired" })
294
+ );
295
+ function translatableArrayOf(schema) {
296
+ return import_zod.default.record(supportedLanguageSchema, import_zod.default.array(schema));
297
+ }
298
+
299
+ // src/schema/fileSchema.ts
300
+ var import_zod2 = __toESM(require("zod"), 1);
301
+ var baseFileSchema = import_zod2.default.object({
302
+ /**
303
+ * The ID of the file
304
+ *
305
+ * The ID is part of the files name.
306
+ */
307
+ id: uuidSchema.readonly(),
308
+ /**
309
+ * The timestamp of the file being created is set by the service of "objectType" while creating it
310
+ */
311
+ created: import_zod2.default.number().readonly(),
312
+ /**
313
+ * The timestamp of the file being updated is set by the service of "objectType" while updating it
314
+ */
315
+ updated: import_zod2.default.number().nullable()
316
+ });
317
+ var baseFileWithLanguageSchema = baseFileSchema.extend({
318
+ /**
319
+ * The language of the file
320
+ *
321
+ * The language is part of the files name and together with it's ID the only unique identifier.
322
+ * That's why the language cannot be changed after creating the file.
323
+ *
324
+ * @todo Maybe remove the above restriction by implementing logic to handle changing the files language inside all services
325
+ */
326
+ language: supportedLanguageSchema.readonly()
327
+ });
328
+ var fileReferenceSchema = import_zod2.default.object({
329
+ id: uuidSchema,
330
+ language: supportedLanguageSchema.optional(),
331
+ extension: supportedAssetExtensionSchema.optional()
332
+ });
333
+
334
+ // src/schema/assetSchema.ts
335
+ var assetFileSchema = baseFileWithLanguageSchema.extend({
336
+ objectType: import_zod3.default.literal(objectTypeSchema.Enum.asset).readonly(),
337
+ name: import_zod3.default.string(),
338
+ description: import_zod3.default.string(),
339
+ extension: supportedAssetExtensionSchema.readonly(),
340
+ mimeType: supportedAssetMimeTypeSchema.readonly(),
341
+ /**
342
+ * Total size in bytes
343
+ */
344
+ size: import_zod3.default.number().readonly()
345
+ });
346
+ var assetSchema = assetFileSchema.extend({
347
+ /**
348
+ * Absolute path on this filesystem
349
+ */
350
+ absolutePath: import_zod3.default.string().readonly()
351
+ });
352
+ var assetExportSchema = assetSchema.extend({});
353
+ var createAssetSchema = assetFileSchema.pick({
354
+ name: true,
355
+ description: true,
356
+ language: true
357
+ }).extend({
358
+ projectId: uuidSchema.readonly(),
359
+ /**
360
+ * Path of the file to add as a new Asset
361
+ */
362
+ filePath: import_zod3.default.string().readonly()
363
+ });
364
+ var readAssetSchema = assetFileSchema.pick({
365
+ id: true,
366
+ language: true
367
+ }).extend({
368
+ projectId: uuidSchema.readonly()
369
+ });
370
+ var updateAssetSchema = assetFileSchema.pick({
371
+ id: true,
372
+ name: true,
373
+ description: true,
374
+ language: true
375
+ }).extend({
376
+ projectId: uuidSchema.readonly(),
377
+ /**
378
+ * Path of the new file to update the Asset with
379
+ */
380
+ newFilePath: import_zod3.default.string().readonly().optional()
381
+ });
382
+ var deleteAssetSchema = assetFileSchema.pick({
383
+ id: true,
384
+ language: true,
385
+ extension: true
386
+ }).extend({
387
+ projectId: uuidSchema.readonly()
388
+ });
389
+ var countAssetsSchema = import_zod3.default.object({ projectId: uuidSchema.readonly() });
390
+
391
+ // src/schema/serviceSchema.ts
392
+ var import_zod5 = require("zod");
393
+
394
+ // src/schema/gitSchema.ts
395
+ var import_zod4 = require("zod");
396
+ var gitRepositoryPathSchema = import_zod4.z.string();
397
+ var gitSignatureSchema = import_zod4.z.object({
398
+ name: import_zod4.z.string(),
399
+ email: import_zod4.z.string()
400
+ });
401
+ var gitCommitSchema = import_zod4.z.object({
402
+ /**
403
+ * SHA-1 hash of the commit
404
+ */
405
+ hash: import_zod4.z.string(),
406
+ message: import_zod4.z.string(),
407
+ author: gitSignatureSchema,
408
+ timestamp: import_zod4.z.number(),
409
+ tag: import_zod4.z.string().nullable()
410
+ });
411
+ var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
412
+ GitCommitIconNative2["INIT"] = ":tada:";
413
+ GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
414
+ GitCommitIconNative2["UPDATE"] = ":wrench:";
415
+ GitCommitIconNative2["DELETE"] = ":fire:";
416
+ return GitCommitIconNative2;
417
+ })(GitCommitIconNative || {});
418
+ var gitCommitIconSchema = import_zod4.z.nativeEnum(GitCommitIconNative);
419
+ var gitInitOptionsSchema = import_zod4.z.object({
420
+ /**
421
+ * 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).
422
+ */
423
+ initialBranch: import_zod4.z.string()
424
+ });
425
+ var gitCloneOptionsSchema = import_zod4.z.object({
426
+ /**
427
+ * 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.
428
+ */
429
+ depth: import_zod4.z.number(),
430
+ /**
431
+ * 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.
432
+ */
433
+ singleBranch: import_zod4.z.boolean(),
434
+ /**
435
+ * 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.
436
+ */
437
+ branch: import_zod4.z.string()
438
+ });
439
+ var gitSwitchOptionsSchema = import_zod4.z.object({
440
+ /**
441
+ * If true, creates a new local branch and then switches to it
442
+ *
443
+ * @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
444
+ */
445
+ isNew: import_zod4.z.boolean().optional()
446
+ });
447
+ var gitLogOptionsSchema = import_zod4.z.object({
448
+ /**
449
+ * Limit the result to given number of commits
450
+ */
451
+ limit: import_zod4.z.number().optional(),
452
+ /**
453
+ * Only list commits that are between given SHAs or tag names
454
+ *
455
+ * Note that the commits of from and to are not included in the result
456
+ */
457
+ between: import_zod4.z.object({
458
+ /**
459
+ * From the oldest commit
460
+ */
461
+ from: import_zod4.z.string(),
462
+ /**
463
+ * To the newest commit
464
+ *
465
+ * Defaults to the current HEAD
466
+ */
467
+ to: import_zod4.z.string().optional()
468
+ })
469
+ });
470
+
471
+ // src/schema/serviceSchema.ts
472
+ var serviceTypeSchema = import_zod5.z.enum([
473
+ "Git",
474
+ "GitTag",
475
+ "User",
476
+ "Project",
477
+ "Asset",
478
+ "JsonFile",
479
+ "Search",
480
+ "Collection",
481
+ "Entry",
482
+ "Value"
483
+ ]);
484
+ var listSchema = import_zod5.z.object({
485
+ projectId: uuidSchema,
486
+ limit: import_zod5.z.number().optional(),
487
+ offset: import_zod5.z.number().optional()
488
+ });
489
+ var listCollectionsSchema = listSchema;
490
+ var listEntriesSchema = listSchema.extend({
491
+ collectionId: uuidSchema
492
+ });
493
+ var listAssetsSchema = listSchema;
494
+ var listProjectsSchema = listSchema.omit({
495
+ projectId: true
496
+ });
497
+ var listGitTagsSchema = import_zod5.z.object({
498
+ path: gitRepositoryPathSchema
499
+ });
500
+
52
501
  // src/util/index.ts
53
502
  var util_exports = {};
54
503
  __export(util_exports, {
55
504
  assignDefaultIfMissing: () => assignDefaultIfMissing,
505
+ currentTimestamp: () => currentTimestamp,
56
506
  files: () => files,
57
507
  folders: () => folders,
58
508
  fromPath: () => fromPath,
@@ -62,15 +512,543 @@ __export(util_exports, {
62
512
  notEmpty: () => notEmpty,
63
513
  pathTo: () => pathTo,
64
514
  returnResolved: () => returnResolved,
515
+ slug: () => slug,
65
516
  spawnChildProcess: () => spawnChildProcess,
517
+ uuid: () => uuid,
66
518
  workingDirectory: () => workingDirectory
67
519
  });
68
- var import_shared = require("@elek-io/shared");
69
520
  var import_child_process = require("child_process");
70
521
  var import_fs_extra = __toESM(require("fs-extra"), 1);
71
522
  var import_lodash_es = require("lodash-es");
72
523
  var import_os = __toESM(require("os"), 1);
73
524
  var import_path = __toESM(require("path"), 1);
525
+ var import_slugify = __toESM(require("slugify"), 1);
526
+ var import_uuid = require("uuid");
527
+
528
+ // src/schema/projectSchema.ts
529
+ var import_zod9 = require("zod");
530
+
531
+ // src/schema/collectionSchema.ts
532
+ var import_zod8 = __toESM(require("zod"), 1);
533
+
534
+ // src/schema/entrySchema.ts
535
+ var import_zod7 = __toESM(require("zod"), 1);
536
+
537
+ // src/schema/valueSchema.ts
538
+ var import_zod6 = __toESM(require("zod"), 1);
539
+ var ValueTypeSchema = import_zod6.default.enum([
540
+ "string",
541
+ "number",
542
+ "boolean",
543
+ "reference"
544
+ ]);
545
+ var ValueInputTypeSchema = import_zod6.default.enum([
546
+ // String
547
+ "text",
548
+ "textarea",
549
+ "email",
550
+ // 'password', @todo maybe if there is a usecase
551
+ "url",
552
+ "ip",
553
+ "date",
554
+ "time",
555
+ "datetime",
556
+ "telephone",
557
+ // Number
558
+ "number",
559
+ "range",
560
+ // Boolean
561
+ "toggle",
562
+ // Reference
563
+ "asset",
564
+ "entry"
565
+ // 'sharedValue', // @todo
566
+ ]);
567
+ var ValueInputWidthSchema = import_zod6.default.enum(["12", "6", "4", "3"]);
568
+ var ValueDefinitionBaseSchema = import_zod6.default.object({
569
+ id: uuidSchema.readonly(),
570
+ label: translatableStringSchema,
571
+ description: translatableStringSchema,
572
+ isRequired: import_zod6.default.boolean(),
573
+ isDisabled: import_zod6.default.boolean(),
574
+ isUnique: import_zod6.default.boolean(),
575
+ inputWidth: ValueInputWidthSchema
576
+ });
577
+ var StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
578
+ {
579
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.string),
580
+ defaultValue: import_zod6.default.string().nullable()
581
+ }
582
+ );
583
+ var textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
584
+ {
585
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.text),
586
+ min: import_zod6.default.number().nullable(),
587
+ max: import_zod6.default.number().nullable()
588
+ }
589
+ );
590
+ var textareaValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
591
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.textarea),
592
+ min: import_zod6.default.number().nullable(),
593
+ max: import_zod6.default.number().nullable()
594
+ });
595
+ var emailValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
596
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.email),
597
+ defaultValue: import_zod6.default.string().email().nullable()
598
+ });
599
+ var urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
600
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.url),
601
+ defaultValue: import_zod6.default.string().url().nullable()
602
+ });
603
+ var ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
604
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.ip),
605
+ defaultValue: import_zod6.default.string().ip().nullable()
606
+ });
607
+ var dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
608
+ {
609
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.date),
610
+ defaultValue: import_zod6.default.string().date().nullable()
611
+ }
612
+ );
613
+ var timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
614
+ {
615
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.time),
616
+ defaultValue: import_zod6.default.string().time().nullable()
617
+ }
618
+ );
619
+ var datetimeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
620
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.datetime),
621
+ defaultValue: import_zod6.default.string().datetime().nullable()
622
+ });
623
+ var telephoneValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
624
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.telephone)
625
+ // defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
626
+ });
627
+ var stringValueDefinitionSchema = import_zod6.default.union([
628
+ textValueDefinitionSchema,
629
+ textareaValueDefinitionSchema,
630
+ emailValueDefinitionSchema,
631
+ urlValueDefinitionSchema,
632
+ ipValueDefinitionSchema,
633
+ dateValueDefinitionSchema,
634
+ timeValueDefinitionSchema,
635
+ datetimeValueDefinitionSchema,
636
+ telephoneValueDefinitionSchema
637
+ ]);
638
+ var NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
639
+ {
640
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.number),
641
+ min: import_zod6.default.number().nullable(),
642
+ max: import_zod6.default.number().nullable(),
643
+ isUnique: import_zod6.default.literal(false),
644
+ defaultValue: import_zod6.default.number().nullable()
645
+ }
646
+ );
647
+ var numberValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
648
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.number)
649
+ });
650
+ var rangeValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
651
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.range),
652
+ // Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
653
+ isRequired: import_zod6.default.literal(true),
654
+ min: import_zod6.default.number(),
655
+ max: import_zod6.default.number(),
656
+ defaultValue: import_zod6.default.number()
657
+ });
658
+ var BooleanValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
659
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.boolean),
660
+ // Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
661
+ isRequired: import_zod6.default.literal(true),
662
+ defaultValue: import_zod6.default.boolean(),
663
+ isUnique: import_zod6.default.literal(false)
664
+ });
665
+ var toggleValueDefinitionSchema = BooleanValueDefinitionBaseSchema.extend({
666
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.toggle)
667
+ });
668
+ var ReferenceValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
669
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.reference)
670
+ });
671
+ var assetValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
672
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.asset),
673
+ allowedMimeTypes: import_zod6.default.array(supportedAssetMimeTypeSchema).min(1),
674
+ min: import_zod6.default.number().nullable(),
675
+ max: import_zod6.default.number().nullable()
676
+ });
677
+ var entryValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
678
+ inputType: import_zod6.default.literal(ValueInputTypeSchema.Enum.entry),
679
+ ofCollections: import_zod6.default.array(uuidSchema),
680
+ min: import_zod6.default.number().nullable(),
681
+ max: import_zod6.default.number().nullable()
682
+ });
683
+ var valueDefinitionSchema = import_zod6.default.union([
684
+ stringValueDefinitionSchema,
685
+ numberValueDefinitionSchema,
686
+ rangeValueDefinitionSchema,
687
+ toggleValueDefinitionSchema,
688
+ assetValueDefinitionSchema,
689
+ entryValueDefinitionSchema
690
+ // sharedValueDefinitionSchema,
691
+ ]);
692
+ var valueContentReferenceBase = import_zod6.default.object({
693
+ id: uuidSchema
694
+ });
695
+ var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
696
+ language: supportedLanguageSchema
697
+ });
698
+ var valueContentReferenceToAssetSchema = valueContentReferenceWithLanguageBase.extend({
699
+ objectType: import_zod6.default.literal(objectTypeSchema.Enum.asset)
700
+ });
701
+ var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
702
+ objectType: import_zod6.default.literal(objectTypeSchema.Enum.collection)
703
+ });
704
+ var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
705
+ objectType: import_zod6.default.literal(objectTypeSchema.Enum.entry)
706
+ });
707
+ var valueContentReferenceSchema = import_zod6.default.union([
708
+ valueContentReferenceToAssetSchema,
709
+ valueContentReferenceToCollectionSchema,
710
+ valueContentReferenceToEntrySchema
711
+ // valueContentReferenceToSharedValueSchema,
712
+ ]);
713
+ var resolvedValueContentReferenceSchema = import_zod6.default.union([
714
+ assetSchema,
715
+ import_zod6.default.lazy(() => entrySchema)
716
+ // Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types
717
+ // resolvedValueContentReferenceToSharedValueSchema,
718
+ ]);
719
+ var directValueBaseSchema = import_zod6.default.object({
720
+ objectType: import_zod6.default.literal(objectTypeSchema.Enum.value).readonly(),
721
+ definitionId: uuidSchema.readonly()
722
+ });
723
+ var directStringValueSchema = directValueBaseSchema.extend({
724
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.string).readonly(),
725
+ content: translatableStringSchema
726
+ });
727
+ var directNumberValueSchema = directValueBaseSchema.extend({
728
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.number).readonly(),
729
+ content: translatableNumberSchema
730
+ });
731
+ var directBooleanValueSchema = directValueBaseSchema.extend({
732
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.boolean).readonly(),
733
+ content: translatableBooleanSchema
734
+ });
735
+ var directValueSchema = import_zod6.default.union([
736
+ directStringValueSchema,
737
+ directNumberValueSchema,
738
+ directBooleanValueSchema
739
+ ]);
740
+ var referencedValueSchema = import_zod6.default.object({
741
+ objectType: import_zod6.default.literal(objectTypeSchema.Enum.value).readonly(),
742
+ definitionId: uuidSchema.readonly(),
743
+ valueType: import_zod6.default.literal(ValueTypeSchema.Enum.reference).readonly(),
744
+ content: translatableArrayOf(valueContentReferenceSchema)
745
+ });
746
+ var valueSchema = import_zod6.default.union([directValueSchema, referencedValueSchema]);
747
+ var resolvedReferencedValueSchema = referencedValueSchema.extend({
748
+ content: translatableArrayOf(resolvedValueContentReferenceSchema)
749
+ });
750
+ var resolvedValueSchema = import_zod6.default.union([
751
+ directValueSchema,
752
+ resolvedReferencedValueSchema
753
+ ]);
754
+ function getValueContentSchemaFromDefinition(definition) {
755
+ switch (definition.valueType) {
756
+ case ValueTypeSchema.Enum.boolean:
757
+ return getBooleanValueContentSchema(definition);
758
+ case ValueTypeSchema.Enum.number:
759
+ return getNumberValueContentSchema(definition);
760
+ case ValueTypeSchema.Enum.string:
761
+ return getStringValueContentSchema(definition);
762
+ case ValueTypeSchema.Enum.reference:
763
+ return getReferenceValueContentSchema(definition);
764
+ default:
765
+ throw new Error(
766
+ // @ts-expect-error
767
+ `Error generating schema for unsupported ValueType "${definition.valueType}"`
768
+ );
769
+ }
770
+ }
771
+ function getBooleanValueContentSchema(definition) {
772
+ return import_zod6.default.boolean();
773
+ }
774
+ function getNumberValueContentSchema(definition) {
775
+ let schema = import_zod6.default.number();
776
+ if (definition.min) {
777
+ schema = schema.min(definition.min);
778
+ }
779
+ if (definition.max) {
780
+ schema = schema.max(definition.max);
781
+ }
782
+ if (definition.isRequired === false) {
783
+ return schema.nullable();
784
+ }
785
+ return schema;
786
+ }
787
+ function getStringValueContentSchema(definition) {
788
+ let schema = import_zod6.default.string().trim();
789
+ if ("min" in definition && definition.min) {
790
+ schema = schema.min(definition.min);
791
+ }
792
+ if ("max" in definition && definition.max) {
793
+ schema = schema.max(definition.max);
794
+ }
795
+ switch (definition.inputType) {
796
+ case ValueInputTypeSchema.Enum.email:
797
+ schema = schema.email();
798
+ break;
799
+ case ValueInputTypeSchema.Enum.url:
800
+ schema = schema.url();
801
+ break;
802
+ case ValueInputTypeSchema.Enum.ip:
803
+ schema = schema.ip();
804
+ break;
805
+ case ValueInputTypeSchema.Enum.date:
806
+ schema = schema.date();
807
+ break;
808
+ case ValueInputTypeSchema.Enum.time:
809
+ schema = schema.time();
810
+ break;
811
+ case ValueInputTypeSchema.Enum.datetime:
812
+ schema = schema.datetime();
813
+ break;
814
+ case ValueInputTypeSchema.Enum.telephone:
815
+ break;
816
+ }
817
+ if (definition.isRequired === false) {
818
+ return schema.nullable();
819
+ }
820
+ return schema.min(1, "shared.stringValueRequired");
821
+ }
822
+ function getReferenceValueContentSchema(definition) {
823
+ let schema;
824
+ switch (definition.inputType) {
825
+ case ValueInputTypeSchema.Enum.asset:
826
+ {
827
+ schema = import_zod6.default.array(valueContentReferenceToAssetSchema);
828
+ }
829
+ break;
830
+ case ValueInputTypeSchema.Enum.entry:
831
+ {
832
+ schema = import_zod6.default.array(valueContentReferenceToEntrySchema);
833
+ }
834
+ break;
835
+ }
836
+ if (definition.isRequired) {
837
+ schema = schema.min(1, "shared.referenceRequired");
838
+ }
839
+ if (definition.min) {
840
+ schema = schema.min(definition.min);
841
+ }
842
+ if (definition.max) {
843
+ schema = schema.max(definition.max);
844
+ }
845
+ return schema;
846
+ }
847
+
848
+ // src/schema/entrySchema.ts
849
+ var entryFileSchema = baseFileSchema.extend({
850
+ objectType: import_zod7.default.literal(objectTypeSchema.Enum.entry).readonly(),
851
+ values: import_zod7.default.array(valueSchema)
852
+ });
853
+ var entrySchema = entryFileSchema.extend({
854
+ values: import_zod7.default.array(import_zod7.default.lazy(() => resolvedValueSchema))
855
+ });
856
+ var entryExportSchema = entrySchema.extend({});
857
+ var createEntrySchema = entryFileSchema.omit({
858
+ id: true,
859
+ objectType: true,
860
+ created: true,
861
+ updated: true
862
+ }).extend({
863
+ projectId: uuidSchema.readonly(),
864
+ collectionId: uuidSchema.readonly(),
865
+ values: import_zod7.default.array(valueSchema)
866
+ });
867
+ var readEntrySchema = import_zod7.default.object({
868
+ id: uuidSchema.readonly(),
869
+ projectId: uuidSchema.readonly(),
870
+ collectionId: uuidSchema.readonly()
871
+ });
872
+ var updateEntrySchema = entrySchema.omit({
873
+ objectType: true,
874
+ created: true,
875
+ updated: true
876
+ }).extend({
877
+ projectId: uuidSchema.readonly(),
878
+ collectionId: uuidSchema.readonly()
879
+ });
880
+ var deleteEntrySchema = readEntrySchema.extend({});
881
+ var countEntriesSchema = import_zod7.default.object({
882
+ projectId: uuidSchema.readonly(),
883
+ collectionId: uuidSchema.readonly()
884
+ });
885
+
886
+ // src/schema/collectionSchema.ts
887
+ var collectionFileSchema = baseFileSchema.extend({
888
+ objectType: import_zod8.default.literal(objectTypeSchema.Enum.collection).readonly(),
889
+ name: import_zod8.default.object({
890
+ singular: translatableStringSchema,
891
+ plural: translatableStringSchema
892
+ }),
893
+ slug: import_zod8.default.object({
894
+ singular: import_zod8.default.string(),
895
+ plural: import_zod8.default.string()
896
+ }),
897
+ description: translatableStringSchema,
898
+ icon: supportedIconSchema,
899
+ valueDefinitions: import_zod8.default.array(valueDefinitionSchema)
900
+ });
901
+ var collectionSchema = collectionFileSchema.extend({});
902
+ var collectionExportSchema = collectionSchema.extend({
903
+ entries: import_zod8.default.array(entryExportSchema)
904
+ });
905
+ var createCollectionSchema = collectionSchema.omit({
906
+ id: true,
907
+ objectType: true,
908
+ created: true,
909
+ updated: true
910
+ }).extend({
911
+ projectId: uuidSchema.readonly()
912
+ });
913
+ var readCollectionSchema = import_zod8.default.object({
914
+ id: uuidSchema.readonly(),
915
+ projectId: uuidSchema.readonly()
916
+ });
917
+ var updateCollectionSchema = collectionFileSchema.pick({
918
+ id: true,
919
+ name: true,
920
+ slug: true,
921
+ description: true,
922
+ icon: true,
923
+ valueDefinitions: true
924
+ }).extend({
925
+ projectId: uuidSchema.readonly()
926
+ });
927
+ var deleteCollectionSchema = readCollectionSchema.extend({});
928
+ var countCollectionsSchema = import_zod8.default.object({
929
+ projectId: uuidSchema.readonly()
930
+ });
931
+
932
+ // src/schema/projectSchema.ts
933
+ var projectStatusSchema = import_zod9.z.enum(["foo", "bar", "todo"]);
934
+ var projectSettingsSchema = import_zod9.z.object({
935
+ language: import_zod9.z.object({
936
+ default: supportedLanguageSchema,
937
+ supported: import_zod9.z.array(supportedLanguageSchema)
938
+ })
939
+ });
940
+ var projectFolderSchema = import_zod9.z.enum([
941
+ "assets",
942
+ "collections",
943
+ "shared-values",
944
+ "lfs"
945
+ // 'logs',
946
+ // 'public',
947
+ // 'theme',
948
+ ]);
949
+ var projectFileSchema = baseFileSchema.extend({
950
+ objectType: import_zod9.z.literal(objectTypeSchema.Enum.project).readonly(),
951
+ coreVersion: versionSchema,
952
+ name: import_zod9.z.string().trim().min(1, "shared.projectNameRequired"),
953
+ description: import_zod9.z.string().trim().min(1, "shared.projectDescriptionRequired"),
954
+ version: versionSchema,
955
+ status: projectStatusSchema,
956
+ settings: projectSettingsSchema
957
+ });
958
+ var projectSchema = projectFileSchema.extend({});
959
+ var projectExportSchema = projectSchema.extend({
960
+ assets: import_zod9.z.array(assetExportSchema),
961
+ collections: import_zod9.z.array(collectionExportSchema)
962
+ });
963
+ var createProjectSchema = projectSchema.pick({
964
+ name: true,
965
+ description: true,
966
+ settings: true
967
+ }).partial({
968
+ description: true,
969
+ settings: true
970
+ });
971
+ var readProjectSchema = import_zod9.z.object({
972
+ id: uuidSchema.readonly()
973
+ });
974
+ var updateProjectSchema = projectSchema.pick({
975
+ id: true,
976
+ name: true,
977
+ description: true,
978
+ settings: true
979
+ }).partial({
980
+ name: true,
981
+ description: true,
982
+ settings: true
983
+ });
984
+ var upgradeProjectSchema = import_zod9.z.object({
985
+ id: uuidSchema.readonly()
986
+ });
987
+ var deleteProjectSchema = readProjectSchema.extend({});
988
+ var projectUpgradeSchema = import_zod9.z.object({
989
+ /**
990
+ * The Core version the Project will be upgraded to
991
+ */
992
+ to: versionSchema.readonly(),
993
+ /**
994
+ * Function that will be executed in the process of upgrading a Project
995
+ */
996
+ run: import_zod9.z.function().args(projectFileSchema).returns(import_zod9.z.promise(import_zod9.z.void()))
997
+ });
998
+ var cloneProjectSchema = import_zod9.z.object({
999
+ url: import_zod9.z.string()
1000
+ });
1001
+ var listBranchesProjectSchema = import_zod9.z.object({
1002
+ id: uuidSchema.readonly()
1003
+ });
1004
+ var currentBranchProjectSchema = import_zod9.z.object({
1005
+ id: uuidSchema.readonly()
1006
+ });
1007
+ var switchBranchProjectSchema = import_zod9.z.object({
1008
+ id: uuidSchema.readonly(),
1009
+ branch: import_zod9.z.string(),
1010
+ options: gitSwitchOptionsSchema.optional()
1011
+ });
1012
+ var getRemoteOriginUrlProjectSchema = import_zod9.z.object({
1013
+ id: uuidSchema.readonly()
1014
+ });
1015
+ var setRemoteOriginUrlProjectSchema = import_zod9.z.object({
1016
+ id: uuidSchema.readonly(),
1017
+ url: import_zod9.z.string()
1018
+ });
1019
+ var getChangesProjectSchema = import_zod9.z.object({
1020
+ id: uuidSchema.readonly()
1021
+ });
1022
+ var synchronizeProjectSchema = import_zod9.z.object({
1023
+ id: uuidSchema.readonly()
1024
+ });
1025
+ var searchProjectSchema = import_zod9.z.object({
1026
+ id: uuidSchema.readonly(),
1027
+ query: import_zod9.z.string(),
1028
+ language: supportedLanguageSchema,
1029
+ type: import_zod9.z.array(objectTypeSchema).optional()
1030
+ });
1031
+
1032
+ // src/util/index.ts
1033
+ var Slugify = import_slugify.default.default || import_slugify.default;
1034
+ function uuid() {
1035
+ return (0, import_uuid.v4)();
1036
+ }
1037
+ function currentTimestamp() {
1038
+ return Math.floor(Date.now() / 1e3);
1039
+ }
1040
+ function slug(string) {
1041
+ return Slugify(string, {
1042
+ replacement: "-",
1043
+ // replace spaces with replacement character, defaults to `-`
1044
+ remove: void 0,
1045
+ // remove characters that match regex, defaults to `undefined`
1046
+ lower: true,
1047
+ // convert to lower case, defaults to `false`
1048
+ strict: true
1049
+ // strip special characters except replacement, defaults to `false`
1050
+ });
1051
+ }
74
1052
  var workingDirectory = import_path.default.join(import_os.default.homedir(), "elek.io");
75
1053
  var pathTo = {
76
1054
  tmp: import_path.default.join(workingDirectory, "tmp"),
@@ -90,12 +1068,12 @@ var pathTo = {
90
1068
  // return Path.join(pathTo.project(projectId), 'public');
91
1069
  // },
92
1070
  lfs: (projectId) => {
93
- return import_path.default.join(pathTo.project(projectId), import_shared.projectFolderSchema.Enum.lfs);
1071
+ return import_path.default.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
94
1072
  },
95
1073
  collections: (projectId) => {
96
1074
  return import_path.default.join(
97
1075
  pathTo.project(projectId),
98
- import_shared.projectFolderSchema.Enum.collections
1076
+ projectFolderSchema.Enum.collections
99
1077
  );
100
1078
  },
101
1079
  collection: (projectId, id) => {
@@ -119,7 +1097,7 @@ var pathTo = {
119
1097
  assets: (projectId) => {
120
1098
  return import_path.default.join(
121
1099
  pathTo.project(projectId),
122
- import_shared.projectFolderSchema.Enum.assets
1100
+ projectFolderSchema.Enum.assets
123
1101
  );
124
1102
  },
125
1103
  assetFile: (projectId, id, language) => {
@@ -139,7 +1117,7 @@ var fromPath = {
139
1117
  }
140
1118
  const end = path.indexOf(endsWith, start);
141
1119
  const result = path.substring(start, end === -1 ? path.length : end);
142
- if (result && import_shared.uuidSchema.safeParse(result).success) {
1120
+ if (result && uuidSchema.safeParse(result).success) {
143
1121
  return result;
144
1122
  }
145
1123
  return void 0;
@@ -240,8 +1218,6 @@ function getDuplicates(arr, key) {
240
1218
  }
241
1219
 
242
1220
  // src/service/AbstractCrudService.ts
243
- var import_shared2 = require("@elek-io/shared");
244
- var import_lodash_es2 = require("lodash-es");
245
1221
  var AbstractCrudService = class {
246
1222
  /**
247
1223
  * Do not instantiate directly as this is an abstract class
@@ -250,56 +1226,9 @@ var AbstractCrudService = class {
250
1226
  this.type = type;
251
1227
  this.options = options;
252
1228
  this.gitMessage = {
253
- create: `${import_shared2.gitCommitIconSchema.enum.CREATE} Created ${this.type}`,
254
- update: `${import_shared2.gitCommitIconSchema.enum.UPDATE} Updated ${this.type}`,
255
- delete: `${import_shared2.gitCommitIconSchema.enum.DELETE} Deleted ${this.type}`
256
- };
257
- }
258
- /**
259
- * Returns the filtered, sorted and paginated version of given list
260
- *
261
- * @todo Sorting and filtering requires all models to be loaded
262
- * from disk. This results in a huge memory spike before the
263
- * filtering and pagination takes effect - removing most of it again.
264
- * This approach is still better than returning everything and
265
- * letting the frontend handle it, since the memory usage would then be constant.
266
- * But this still could fill the memory limit of node.js (default 1,4 GB).
267
- *
268
- * @param list Array to filter, sort and paginate
269
- * @param sort Array of sort objects containing information about what to sort and how
270
- * @param filter Filter all object values of `list` by this string
271
- * @param limit Limit the result to this amount. If 0 is given, no limit is applied
272
- * @param offset Start at this index instead of 0
273
- */
274
- async paginate(list, sort = [], filter2 = "", limit = 15, offset = 0) {
275
- let result = list;
276
- const total = list.length;
277
- const normalizedFilter = filter2.trim().toLowerCase();
278
- if (normalizedFilter !== "") {
279
- (0, import_lodash_es2.remove)(result, (model) => {
280
- let key;
281
- for (key in model) {
282
- const value = model[key];
283
- if (String(value).toLowerCase().includes(normalizedFilter)) {
284
- return false;
285
- }
286
- }
287
- return true;
288
- });
289
- }
290
- if (sort.length !== 0) {
291
- const keys = sort.map((value) => value.by);
292
- const orders = sort.map((value) => value.order);
293
- result = (0, import_lodash_es2.orderBy)(result, keys, orders);
294
- }
295
- if (limit !== 0) {
296
- result = result.slice(offset, offset + limit);
297
- }
298
- return {
299
- total,
300
- limit,
301
- offset,
302
- list: result
1229
+ create: `${gitCommitIconSchema.enum.CREATE} Created ${this.type}`,
1230
+ update: `${gitCommitIconSchema.enum.UPDATE} Updated ${this.type}`,
1231
+ delete: `${gitCommitIconSchema.enum.DELETE} Deleted ${this.type}`
303
1232
  };
304
1233
  }
305
1234
  /**
@@ -311,19 +1240,19 @@ var AbstractCrudService = class {
311
1240
  */
312
1241
  async listReferences(type, projectId, collectionId) {
313
1242
  switch (type) {
314
- case import_shared2.objectTypeSchema.Enum.asset:
1243
+ case objectTypeSchema.Enum.asset:
315
1244
  if (!projectId) {
316
1245
  throw new RequiredParameterMissingError("projectId");
317
1246
  }
318
1247
  return this.getFileReferences(pathTo.lfs(projectId));
319
- case import_shared2.objectTypeSchema.Enum.project:
1248
+ case objectTypeSchema.Enum.project:
320
1249
  return this.getFolderReferences(pathTo.projects);
321
- case import_shared2.objectTypeSchema.Enum.collection:
1250
+ case objectTypeSchema.Enum.collection:
322
1251
  if (!projectId) {
323
1252
  throw new RequiredParameterMissingError("projectId");
324
1253
  }
325
1254
  return this.getFolderReferences(pathTo.collections(projectId));
326
- case import_shared2.objectTypeSchema.Enum.entry:
1255
+ case objectTypeSchema.Enum.entry:
327
1256
  if (!projectId) {
328
1257
  throw new RequiredParameterMissingError("projectId");
329
1258
  }
@@ -333,7 +1262,7 @@ var AbstractCrudService = class {
333
1262
  return this.getFileReferences(
334
1263
  pathTo.collection(projectId, collectionId)
335
1264
  );
336
- case import_shared2.objectTypeSchema.Enum.sharedValue:
1265
+ case objectTypeSchema.Enum.sharedValue:
337
1266
  if (!projectId) {
338
1267
  throw new RequiredParameterMissingError("projectId");
339
1268
  }
@@ -349,7 +1278,7 @@ var AbstractCrudService = class {
349
1278
  id: possibleFolder.name
350
1279
  };
351
1280
  try {
352
- return import_shared2.fileReferenceSchema.parse(folderReference);
1281
+ return fileReferenceSchema.parse(folderReference);
353
1282
  } catch (error) {
354
1283
  return null;
355
1284
  }
@@ -374,7 +1303,7 @@ var AbstractCrudService = class {
374
1303
  extension: fileNameArray.length === 2 ? fileNameArray[1] : fileNameArray[2]
375
1304
  };
376
1305
  try {
377
- return import_shared2.fileReferenceSchema.parse(fileReference);
1306
+ return fileReferenceSchema.parse(fileReference);
378
1307
  } catch (error) {
379
1308
  return null;
380
1309
  }
@@ -385,8 +1314,8 @@ var AbstractCrudService = class {
385
1314
  };
386
1315
 
387
1316
  // src/service/GitService.ts
388
- var import_shared6 = require("@elek-io/shared");
389
1317
  var import_dugite = require("dugite");
1318
+ var import_os3 = require("os");
390
1319
  var import_p_queue = __toESM(require("p-queue"), 1);
391
1320
 
392
1321
  // src/error/GitError.ts
@@ -406,10 +1335,35 @@ var NoCurrentUserError = class extends Error {
406
1335
  };
407
1336
 
408
1337
  // src/service/GitTagService.ts
409
- var import_shared3 = require("@elek-io/shared");
1338
+ var import_os2 = require("os");
1339
+
1340
+ // src/schema/gitTagSchema.ts
1341
+ var import_zod10 = require("zod");
1342
+ var gitTagSchema = import_zod10.z.object({
1343
+ id: uuidSchema,
1344
+ message: import_zod10.z.string(),
1345
+ author: gitSignatureSchema,
1346
+ timestamp: import_zod10.z.number()
1347
+ });
1348
+ var createGitTagSchema = gitTagSchema.pick({
1349
+ message: true
1350
+ }).extend({
1351
+ path: gitRepositoryPathSchema,
1352
+ hash: gitCommitSchema.shape.hash.optional()
1353
+ });
1354
+ var readGitTagSchema = import_zod10.z.object({
1355
+ path: gitRepositoryPathSchema,
1356
+ id: uuidSchema.readonly()
1357
+ });
1358
+ var deleteGitTagSchema = readGitTagSchema.extend({});
1359
+ var countGitTagsSchema = import_zod10.z.object({
1360
+ path: gitRepositoryPathSchema
1361
+ });
1362
+
1363
+ // src/service/GitTagService.ts
410
1364
  var GitTagService = class extends AbstractCrudService {
411
1365
  constructor(options, git) {
412
- super(import_shared3.serviceTypeSchema.Enum.GitTag, options);
1366
+ super(serviceTypeSchema.Enum.GitTag, options);
413
1367
  this.git = git;
414
1368
  }
415
1369
  /**
@@ -418,8 +1372,8 @@ var GitTagService = class extends AbstractCrudService {
418
1372
  * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---annotate
419
1373
  */
420
1374
  async create(props) {
421
- import_shared3.createGitTagSchema.parse(props);
422
- const id = (0, import_shared3.uuid)();
1375
+ createGitTagSchema.parse(props);
1376
+ const id = uuid();
423
1377
  let args = ["tag", "--annotate", id];
424
1378
  if (props.hash) {
425
1379
  args = [...args, props.hash];
@@ -432,22 +1386,20 @@ var GitTagService = class extends AbstractCrudService {
432
1386
  /**
433
1387
  * Returns a tag by ID
434
1388
  *
435
- * Internally uses list() with id as pattern.
1389
+ * Internally uses list() but only returns the tag with matching ID.
436
1390
  */
437
1391
  async read(props) {
438
- import_shared3.readGitTagSchema.parse(props);
439
- const tags = await this.list({ path: props.path, filter: props.id });
440
- if (tags.total === 0) {
1392
+ readGitTagSchema.parse(props);
1393
+ const tags = await this.list({ path: props.path });
1394
+ const tag = tags.list.find((tag2) => {
1395
+ return tag2.id === props.id;
1396
+ });
1397
+ if (!tag) {
441
1398
  throw new GitError(
442
1399
  `Provided tag with UUID "${props.id}" did not match any known tags`
443
1400
  );
444
1401
  }
445
- if (tags.total > 1) {
446
- throw new GitError(
447
- `Provided tag with UUID "${props.id}" matched multiple known tags`
448
- );
449
- }
450
- return tags.list[0];
1402
+ return tag;
451
1403
  }
452
1404
  /**
453
1405
  * Updating a git tag is not supported.
@@ -469,7 +1421,7 @@ var GitTagService = class extends AbstractCrudService {
469
1421
  * @param id UUID of the tag to delete
470
1422
  */
471
1423
  async delete(props) {
472
- import_shared3.deleteGitTagSchema.parse(props);
1424
+ deleteGitTagSchema.parse(props);
473
1425
  const args = ["tag", "--delete", props.id];
474
1426
  await this.git(props.path, args);
475
1427
  }
@@ -482,7 +1434,7 @@ var GitTagService = class extends AbstractCrudService {
482
1434
  * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---list
483
1435
  */
484
1436
  async list(props) {
485
- import_shared3.listGitTagsSchema.parse(props);
1437
+ listGitTagsSchema.parse(props);
486
1438
  let args = ["tag", "--list"];
487
1439
  args = [
488
1440
  ...args,
@@ -490,8 +1442,8 @@ var GitTagService = class extends AbstractCrudService {
490
1442
  "--format=%(refname:short)|%(subject)|%(*authorname)|%(*authoremail)|%(*authordate:unix)"
491
1443
  ];
492
1444
  const result = await this.git(props.path, args);
493
- const noEmptyLinesArr = result.stdout.split("\n").filter((line) => {
494
- return line !== "";
1445
+ const noEmptyLinesArr = result.stdout.split(import_os2.EOL).filter((line) => {
1446
+ return line.trim() !== "";
495
1447
  });
496
1448
  const lineObjArr = noEmptyLinesArr.map((line) => {
497
1449
  const lineArray = line.split("|");
@@ -502,17 +1454,16 @@ var GitTagService = class extends AbstractCrudService {
502
1454
  name: lineArray[2],
503
1455
  email: lineArray[3]
504
1456
  },
505
- timestamp: typeof lineArray[4] === "string" ? parseInt(lineArray[4]) : void 0
1457
+ timestamp: parseInt(lineArray[4])
506
1458
  };
507
1459
  });
508
1460
  const gitTags = lineObjArr.filter(this.isGitTag.bind(this));
509
- return this.paginate(
510
- gitTags,
511
- props?.sort,
512
- props?.filter,
513
- props?.limit,
514
- props?.offset
515
- );
1461
+ return {
1462
+ total: gitTags.length,
1463
+ limit: 0,
1464
+ offset: 0,
1465
+ list: gitTags
1466
+ };
516
1467
  }
517
1468
  /**
518
1469
  * Returns the total number of tags inside given repository
@@ -523,7 +1474,7 @@ var GitTagService = class extends AbstractCrudService {
523
1474
  * @param path Path to the repository
524
1475
  */
525
1476
  async count(props) {
526
- import_shared3.countGitTagsSchema.parse(props);
1477
+ countGitTagsSchema.parse(props);
527
1478
  const gitTags = await this.list({ path: props.path });
528
1479
  return gitTags.total;
529
1480
  }
@@ -533,19 +1484,33 @@ var GitTagService = class extends AbstractCrudService {
533
1484
  * @param obj The object to check
534
1485
  */
535
1486
  isGitTag(obj) {
536
- return import_shared3.gitTagSchema.safeParse(obj).success;
1487
+ return gitTagSchema.safeParse(obj).success;
537
1488
  }
538
1489
  };
539
1490
 
540
- // src/service/UserService.ts
541
- var import_shared5 = require("@elek-io/shared");
1491
+ // src/schema/userSchema.ts
1492
+ var import_zod11 = __toESM(require("zod"), 1);
1493
+ var UserTypeSchema = import_zod11.default.enum(["local", "cloud"]);
1494
+ var baseUserSchema = gitSignatureSchema.extend({
1495
+ userType: UserTypeSchema,
1496
+ language: supportedLanguageSchema
1497
+ });
1498
+ var localUserSchema = baseUserSchema.extend({
1499
+ userType: import_zod11.default.literal(UserTypeSchema.Enum.local)
1500
+ });
1501
+ var cloudUserSchema = baseUserSchema.extend({
1502
+ userType: import_zod11.default.literal(UserTypeSchema.Enum.cloud),
1503
+ id: uuidSchema
1504
+ });
1505
+ var userFileSchema = import_zod11.default.union([localUserSchema, cloudUserSchema]);
1506
+ var userSchema = userFileSchema;
1507
+ var setUserSchema = userSchema;
542
1508
 
543
1509
  // src/service/JsonFileService.ts
544
- var import_shared4 = require("@elek-io/shared");
545
1510
  var import_fs_extra2 = __toESM(require("fs-extra"), 1);
546
1511
  var JsonFileService = class extends AbstractCrudService {
547
1512
  constructor(options) {
548
- super(import_shared4.serviceTypeSchema.Enum.JsonFile, options);
1513
+ super(serviceTypeSchema.Enum.JsonFile, options);
549
1514
  this.cache = /* @__PURE__ */ new Map();
550
1515
  }
551
1516
  /**
@@ -626,7 +1591,7 @@ var UserService = class {
626
1591
  try {
627
1592
  return await this.jsonFileService.read(
628
1593
  pathTo.userFile,
629
- import_shared5.userFileSchema
1594
+ userFileSchema
630
1595
  );
631
1596
  } catch (error) {
632
1597
  return void 0;
@@ -638,14 +1603,14 @@ var UserService = class {
638
1603
  * By doing so all git operations are done with the signature of this User
639
1604
  */
640
1605
  async set(props) {
641
- import_shared5.setUserSchema.parse(props);
1606
+ setUserSchema.parse(props);
642
1607
  const userFilePath = pathTo.userFile;
643
1608
  const userFile = {
644
1609
  ...props
645
1610
  };
646
- if (userFile.userType === import_shared5.UserTypeSchema.Enum.cloud) {
1611
+ if (userFile.userType === UserTypeSchema.Enum.cloud) {
647
1612
  }
648
- await this.jsonFileService.update(userFile, userFilePath, import_shared5.userFileSchema);
1613
+ await this.jsonFileService.update(userFile, userFilePath, userFileSchema);
649
1614
  return userFile;
650
1615
  }
651
1616
  };
@@ -653,13 +1618,147 @@ var UserService = class {
653
1618
  // src/service/GitService.ts
654
1619
  var GitService2 = class {
655
1620
  constructor(options, userService) {
656
- this.version = void 0;
1621
+ this.branches = {
1622
+ /**
1623
+ * List branches
1624
+ *
1625
+ * @see https://www.git-scm.com/docs/git-branch
1626
+ *
1627
+ * @param path Path to the repository
1628
+ */
1629
+ list: async (path) => {
1630
+ const args = ["branch", "--list", "--all"];
1631
+ const result = await this.git(path, args);
1632
+ const normalizedLinesArr = result.stdout.split(import_os3.EOL).filter((line) => {
1633
+ return line.trim() !== "";
1634
+ }).map((line) => {
1635
+ return line.trim().replace("* ", "");
1636
+ });
1637
+ const local = [];
1638
+ const remote = [];
1639
+ normalizedLinesArr.forEach((line) => {
1640
+ if (line.startsWith("remotes/")) {
1641
+ remote.push(line.replace("remotes/", ""));
1642
+ } else {
1643
+ local.push(line);
1644
+ }
1645
+ });
1646
+ return {
1647
+ local,
1648
+ remote
1649
+ };
1650
+ },
1651
+ /**
1652
+ * Returns the name of the current branch. In detached HEAD state, an empty string is returned.
1653
+ *
1654
+ * @see https://www.git-scm.com/docs/git-branch#Documentation/git-branch.txt---show-current
1655
+ *
1656
+ * @param path Path to the repository
1657
+ */
1658
+ current: async (path) => {
1659
+ const args = ["branch", "--show-current"];
1660
+ const result = await this.git(path, args);
1661
+ return result.stdout.trim();
1662
+ },
1663
+ /**
1664
+ * Switch branches
1665
+ *
1666
+ * @see https://git-scm.com/docs/git-switch/
1667
+ *
1668
+ * @param path Path to the repository
1669
+ * @param branch Name of the branch to switch to
1670
+ * @param options Options specific to the switch operation
1671
+ */
1672
+ switch: async (path, branch, options) => {
1673
+ await this.checkBranchOrTagName(path, branch);
1674
+ let args = ["switch"];
1675
+ if (options?.isNew === true) {
1676
+ args = [...args, "--create", branch];
1677
+ } else {
1678
+ args = [...args, branch];
1679
+ }
1680
+ await this.git(path, args);
1681
+ }
1682
+ };
1683
+ this.remotes = {
1684
+ /**
1685
+ * Returns a list of currently tracked remotes
1686
+ *
1687
+ * @see https://git-scm.com/docs/git-remote
1688
+ *
1689
+ * @param path Path to the repository
1690
+ */
1691
+ list: async (path) => {
1692
+ const args = ["remote"];
1693
+ const result = await this.git(path, args);
1694
+ const normalizedLinesArr = result.stdout.split(import_os3.EOL).filter((line) => {
1695
+ return line.trim() !== "";
1696
+ });
1697
+ return normalizedLinesArr;
1698
+ },
1699
+ /**
1700
+ * Returns true if the `origin` remote exists, otherwise false
1701
+ *
1702
+ * @param path Path to the repository
1703
+ */
1704
+ hasOrigin: async (path) => {
1705
+ const remotes = await this.remotes.list(path);
1706
+ if (remotes.includes("origin")) {
1707
+ return true;
1708
+ }
1709
+ return false;
1710
+ },
1711
+ /**
1712
+ * Adds the `origin` remote with given URL
1713
+ *
1714
+ * Throws if `origin` remote is added already.
1715
+ *
1716
+ * @see https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emaddem
1717
+ *
1718
+ * @param path Path to the repository
1719
+ */
1720
+ addOrigin: async (path, url) => {
1721
+ const args = ["remote", "add", "origin", url];
1722
+ await this.git(path, args);
1723
+ },
1724
+ /**
1725
+ * Returns the current `origin` remote URL
1726
+ *
1727
+ * Throws if no `origin` remote is added yet.
1728
+ *
1729
+ * @see https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emget-urlem
1730
+ *
1731
+ * @param path Path to the repository
1732
+ */
1733
+ getOriginUrl: async (path) => {
1734
+ const args = ["remote", "get-url", "origin"];
1735
+ const result = (await this.git(path, args)).stdout.trim();
1736
+ return result.length === 0 ? null : result;
1737
+ },
1738
+ /**
1739
+ * Sets the current `origin` remote URL
1740
+ *
1741
+ * Throws if no `origin` remote is added yet.
1742
+ *
1743
+ * @see https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emset-urlem
1744
+ *
1745
+ * @param path Path to the repository
1746
+ */
1747
+ setOriginUrl: async (path, url) => {
1748
+ const args = ["remote", "set-url", "origin", url];
1749
+ await this.git(path, args);
1750
+ }
1751
+ };
1752
+ this.version = null;
1753
+ this.gitPath = null;
657
1754
  this.queue = new import_p_queue.default({
658
1755
  concurrency: 1
659
1756
  // No concurrency because git operations are sequencial
660
1757
  });
661
1758
  this.gitTagService = new GitTagService(options, this.git);
662
1759
  this.userService = userService;
1760
+ this.updateVersion();
1761
+ this.updateGitPath();
663
1762
  }
664
1763
  /**
665
1764
  * CRUD methods to work with git tags
@@ -667,13 +1766,6 @@ var GitService2 = class {
667
1766
  get tags() {
668
1767
  return this.gitTagService;
669
1768
  }
670
- /**
671
- * Reads the currently used version of Git
672
- */
673
- async getVersion() {
674
- const result = await this.git("", ["--version"]);
675
- this.version = result.stdout.replace("git version", "").trim();
676
- }
677
1769
  /**
678
1770
  * Create an empty Git repository or reinitialize an existing one
679
1771
  *
@@ -714,7 +1806,7 @@ var GitService2 = class {
714
1806
  if (options?.singleBranch === true) {
715
1807
  args = [...args, "--single-branch"];
716
1808
  }
717
- await this.git(path, [...args, url, "."]);
1809
+ await this.git("", [...args, url, path]);
718
1810
  await this.setLocalConfig(path);
719
1811
  }
720
1812
  /**
@@ -729,25 +1821,6 @@ var GitService2 = class {
729
1821
  const args = ["add", "--", ...files2];
730
1822
  await this.git(path, args);
731
1823
  }
732
- /**
733
- * Switch branches
734
- *
735
- * @see https://git-scm.com/docs/git-switch/
736
- *
737
- * @param path Path to the repository
738
- * @param name Name of the branch to switch to
739
- * @param options Options specific to the switch operation
740
- */
741
- async switch(path, name, options) {
742
- await this.checkBranchOrTagName(path, name);
743
- let args = ["switch"];
744
- if (options?.isNew === true) {
745
- args = [...args, "--create", name];
746
- } else {
747
- args = [...args, name];
748
- }
749
- await this.git(path, args);
750
- }
751
1824
  /**
752
1825
  * Reset current HEAD to the specified state
753
1826
  *
@@ -785,7 +1858,18 @@ var GitService2 = class {
785
1858
  // await this.git(path, args);
786
1859
  // }
787
1860
  /**
788
- * Fetch from and integrate with another repository or a local branch
1861
+ * Download objects and refs from remote `origin`
1862
+ *
1863
+ * @see https://www.git-scm.com/docs/git-fetch
1864
+ *
1865
+ * @param path Path to the repository
1866
+ */
1867
+ async fetch(path) {
1868
+ const args = ["fetch"];
1869
+ await this.git(path, args);
1870
+ }
1871
+ /**
1872
+ * Fetch from and integrate (rebase or merge) with a local branch
789
1873
  *
790
1874
  * @see https://git-scm.com/docs/git-pull
791
1875
  *
@@ -795,6 +1879,23 @@ var GitService2 = class {
795
1879
  const args = ["pull"];
796
1880
  await this.git(path, args);
797
1881
  }
1882
+ /**
1883
+ * Update remote refs along with associated objects to remote `origin`
1884
+ *
1885
+ * @see https://git-scm.com/docs/git-push
1886
+ *
1887
+ * @param path Path to the repository
1888
+ */
1889
+ async push(path, options) {
1890
+ let args = ["push", "origin"];
1891
+ if (options?.all === true) {
1892
+ args = [...args, "--all"];
1893
+ }
1894
+ if (options?.force === true) {
1895
+ args = [...args, "--force"];
1896
+ }
1897
+ await this.git(path, args);
1898
+ }
798
1899
  /**
799
1900
  * Record changes to the repository
800
1901
  *
@@ -831,7 +1932,7 @@ var GitService2 = class {
831
1932
  if (options?.between?.from) {
832
1933
  args = [
833
1934
  ...args,
834
- `${options.between.from}...${options.between.to || "HEAD"}`
1935
+ `${options.between.from}..${options.between.to || "HEAD"}`
835
1936
  ];
836
1937
  }
837
1938
  if (options?.limit) {
@@ -841,8 +1942,8 @@ var GitService2 = class {
841
1942
  ...args,
842
1943
  "--format=%H|%s|%an|%ae|%at|%D"
843
1944
  ]);
844
- const noEmptyLinesArr = result.stdout.split("\n").filter((line) => {
845
- return line !== "";
1945
+ const noEmptyLinesArr = result.stdout.split(import_os3.EOL).filter((line) => {
1946
+ return line.trim() !== "";
846
1947
  });
847
1948
  const lineObjArr = noEmptyLinesArr.map((line) => {
848
1949
  const lineArray = line.split("|");
@@ -860,10 +1961,9 @@ var GitService2 = class {
860
1961
  return lineObjArr.filter(this.isGitCommit.bind(this));
861
1962
  }
862
1963
  refNameToTagName(refName) {
863
- let tagName = "";
864
- tagName = refName.replace("tag: ", "");
865
- if (tagName.trim() === "" || import_shared6.uuidSchema.safeParse(tagName).success === false) {
866
- tagName = void 0;
1964
+ const tagName = refName.replace("tag: ", "").trim();
1965
+ if (tagName === "" || uuidSchema.safeParse(tagName).success === false) {
1966
+ return null;
867
1967
  }
868
1968
  return tagName;
869
1969
  }
@@ -923,6 +2023,26 @@ var GitService2 = class {
923
2023
  updated: meta[1]
924
2024
  };
925
2025
  }
2026
+ /**
2027
+ * Reads the currently used version of Git
2028
+ *
2029
+ * This can help debugging
2030
+ */
2031
+ async updateVersion() {
2032
+ const result = await this.git("", ["--version"]);
2033
+ this.version = result.stdout.replace("git version", "").trim();
2034
+ }
2035
+ /**
2036
+ * Reads the path to the executable of Git that is used
2037
+ *
2038
+ * This can help debugging, since dugite is shipping their own executable
2039
+ * but in some cases resolves another executable
2040
+ * @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
2041
+ */
2042
+ async updateGitPath() {
2043
+ const result = await this.git("", ["--exec-path"]);
2044
+ this.gitPath = result.stdout.trim();
2045
+ }
926
2046
  /**
927
2047
  * A reference is used in Git to specify branches and tags.
928
2048
  * This method checks if given name matches the required format
@@ -957,8 +2077,15 @@ var GitService2 = class {
957
2077
  }
958
2078
  const userNameArgs = ["config", "--local", "user.name", user.name];
959
2079
  const userEmailArgs = ["config", "--local", "user.email", user.email];
2080
+ const autoSetupRemoteArgs = [
2081
+ "config",
2082
+ "--local",
2083
+ "push.autoSetupRemote",
2084
+ "true"
2085
+ ];
960
2086
  await this.git(path, userNameArgs);
961
2087
  await this.git(path, userEmailArgs);
2088
+ await this.git(path, autoSetupRemoteArgs);
962
2089
  }
963
2090
  /**
964
2091
  * Type guard for GitCommit
@@ -966,7 +2093,7 @@ var GitService2 = class {
966
2093
  * @param obj The object to check
967
2094
  */
968
2095
  isGitCommit(obj) {
969
- return import_shared6.gitCommitSchema.safeParse(obj).success;
2096
+ return gitCommitSchema.safeParse(obj).success;
970
2097
  }
971
2098
  /**
972
2099
  * Wraps the execution of any git command
@@ -976,14 +2103,29 @@ var GitService2 = class {
976
2103
  * @param args Arguments to append after the `git` command
977
2104
  */
978
2105
  async git(path, args) {
979
- const result = await this.queue.add(() => import_dugite.GitProcess.exec(args, path));
2106
+ const result = await this.queue.add(
2107
+ () => import_dugite.GitProcess.exec(args, path, {
2108
+ env: {
2109
+ // @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
2110
+ // @see https://github.com/git-lfs/git-lfs/issues/5749
2111
+ GIT_CLONE_PROTECTION_ACTIVE: "false"
2112
+ }
2113
+ })
2114
+ );
980
2115
  if (!result) {
981
2116
  throw new GitError(
982
- `Git (${this.version}) command "git ${args.join(
2117
+ `Git ${this.version} (${this.gitPath}) command "git ${args.join(
983
2118
  " "
984
2119
  )}" failed to return a result`
985
2120
  );
986
2121
  }
2122
+ if (result.exitCode !== 0) {
2123
+ throw new GitError(
2124
+ `Git ${this.version} (${this.gitPath}) command "git ${args.join(
2125
+ " "
2126
+ )}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
2127
+ );
2128
+ }
987
2129
  return result;
988
2130
  }
989
2131
  };
@@ -991,7 +2133,7 @@ var GitService2 = class {
991
2133
  // src/service/AssetService.ts
992
2134
  var AssetService = class extends AbstractCrudService {
993
2135
  constructor(options, jsonFileService, gitService) {
994
- super(import_shared7.serviceTypeSchema.Enum.Asset, options);
2136
+ super(serviceTypeSchema.Enum.Asset, options);
995
2137
  this.jsonFileService = jsonFileService;
996
2138
  this.gitService = gitService;
997
2139
  }
@@ -999,8 +2141,8 @@ var AssetService = class extends AbstractCrudService {
999
2141
  * Creates a new Asset
1000
2142
  */
1001
2143
  async create(props) {
1002
- import_shared7.createAssetSchema.parse(props);
1003
- const id = (0, import_shared7.uuid)();
2144
+ createAssetSchema.parse(props);
2145
+ const id = uuid();
1004
2146
  const projectPath = pathTo.project(props.projectId);
1005
2147
  const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
1006
2148
  const size = await this.getAssetSize(props.filePath);
@@ -1019,7 +2161,8 @@ var AssetService = class extends AbstractCrudService {
1019
2161
  ...props,
1020
2162
  objectType: "asset",
1021
2163
  id,
1022
- created: (0, import_shared7.currentTimestamp)(),
2164
+ created: currentTimestamp(),
2165
+ updated: null,
1023
2166
  extension: fileType.extension,
1024
2167
  mimeType: fileType.mimeType,
1025
2168
  size
@@ -1029,7 +2172,7 @@ var AssetService = class extends AbstractCrudService {
1029
2172
  await this.jsonFileService.create(
1030
2173
  assetFile,
1031
2174
  assetFilePath,
1032
- import_shared7.assetFileSchema
2175
+ assetFileSchema
1033
2176
  );
1034
2177
  } catch (error) {
1035
2178
  await this.delete({ ...assetFile, projectId: props.projectId });
@@ -1043,10 +2186,10 @@ var AssetService = class extends AbstractCrudService {
1043
2186
  * Returns an Asset by ID and language
1044
2187
  */
1045
2188
  async read(props) {
1046
- import_shared7.readAssetSchema.parse(props);
2189
+ readAssetSchema.parse(props);
1047
2190
  const assetFile = await this.jsonFileService.read(
1048
2191
  pathTo.assetFile(props.projectId, props.id, props.language),
1049
- import_shared7.assetFileSchema
2192
+ assetFileSchema
1050
2193
  );
1051
2194
  return this.toAsset(props.projectId, assetFile);
1052
2195
  }
@@ -1056,7 +2199,7 @@ var AssetService = class extends AbstractCrudService {
1056
2199
  * Use the optional "newFilePath" prop to update the Asset itself
1057
2200
  */
1058
2201
  async update(props) {
1059
- import_shared7.updateAssetSchema.parse(props);
2202
+ updateAssetSchema.parse(props);
1060
2203
  const projectPath = pathTo.project(props.projectId);
1061
2204
  const assetFilePath = pathTo.assetFile(
1062
2205
  props.projectId,
@@ -1067,7 +2210,7 @@ var AssetService = class extends AbstractCrudService {
1067
2210
  const assetFile = {
1068
2211
  ...prevAssetFile,
1069
2212
  ...props,
1070
- updated: (0, import_shared7.currentTimestamp)()
2213
+ updated: currentTimestamp()
1071
2214
  };
1072
2215
  if (props.newFilePath) {
1073
2216
  const fileType = await this.getSupportedFileTypeOrThrow(
@@ -1095,7 +2238,7 @@ var AssetService = class extends AbstractCrudService {
1095
2238
  await this.jsonFileService.update(
1096
2239
  assetFile,
1097
2240
  assetFilePath,
1098
- import_shared7.assetFileSchema
2241
+ assetFileSchema
1099
2242
  );
1100
2243
  await this.gitService.add(projectPath, [assetFilePath]);
1101
2244
  await this.gitService.commit(projectPath, this.gitMessage.update);
@@ -1105,7 +2248,7 @@ var AssetService = class extends AbstractCrudService {
1105
2248
  * Deletes given Asset
1106
2249
  */
1107
2250
  async delete(props) {
1108
- import_shared7.deleteAssetSchema.parse(props);
2251
+ deleteAssetSchema.parse(props);
1109
2252
  const projectPath = pathTo.project(props.projectId);
1110
2253
  const assetFilePath = pathTo.assetFile(
1111
2254
  props.projectId,
@@ -1124,13 +2267,16 @@ var AssetService = class extends AbstractCrudService {
1124
2267
  await this.gitService.commit(projectPath, this.gitMessage.delete);
1125
2268
  }
1126
2269
  async list(props) {
1127
- import_shared7.listAssetsSchema.parse(props);
2270
+ listAssetsSchema.parse(props);
2271
+ const offset = props.offset || 0;
2272
+ const limit = props.limit || 15;
1128
2273
  const assetReferences = await this.listReferences(
1129
- import_shared7.objectTypeSchema.Enum.asset,
2274
+ objectTypeSchema.Enum.asset,
1130
2275
  props.projectId
1131
2276
  );
1132
- const list = await returnResolved(
1133
- assetReferences.map((assetReference) => {
2277
+ const partialAssetReferences = assetReferences.slice(offset, limit);
2278
+ const assets = await returnResolved(
2279
+ partialAssetReferences.map((assetReference) => {
1134
2280
  if (!assetReference.language) {
1135
2281
  throw new RequiredParameterMissingError("language");
1136
2282
  }
@@ -1141,25 +2287,23 @@ var AssetService = class extends AbstractCrudService {
1141
2287
  });
1142
2288
  })
1143
2289
  );
1144
- const paginatedResult = this.paginate(
1145
- list,
1146
- props.sort,
1147
- props.filter,
1148
- props.limit,
1149
- props.offset
1150
- );
1151
- return paginatedResult;
2290
+ return {
2291
+ total: assetReferences.length,
2292
+ limit,
2293
+ offset,
2294
+ list: assets
2295
+ };
1152
2296
  }
1153
2297
  async count(props) {
1154
- import_shared7.countAssetsSchema.parse(props);
1155
- const count = (await this.listReferences(import_shared7.objectTypeSchema.Enum.asset, props.projectId)).length;
2298
+ countAssetsSchema.parse(props);
2299
+ const count = (await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)).length;
1156
2300
  return count;
1157
2301
  }
1158
2302
  /**
1159
2303
  * Checks if given object is of type Asset
1160
2304
  */
1161
2305
  isAsset(obj) {
1162
- return import_shared7.assetSchema.safeParse(obj).success;
2306
+ return assetSchema.safeParse(obj).success;
1163
2307
  }
1164
2308
  /**
1165
2309
  * Returns the size of an Asset in bytes
@@ -1200,14 +2344,14 @@ var AssetService = class extends AbstractCrudService {
1200
2344
  const fileBuffer = await import_fs_extra3.default.readFile(filePath);
1201
2345
  if ((0, import_is_svg.default)(fileBuffer.toString()) === true) {
1202
2346
  return {
1203
- extension: import_shared7.supportedAssetExtensionSchema.Enum.svg,
1204
- mimeType: import_shared7.supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
2347
+ extension: supportedAssetExtensionSchema.Enum.svg,
2348
+ mimeType: supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
1205
2349
  };
1206
2350
  }
1207
2351
  }
1208
2352
  const { fileTypeFromFile } = await import("file-type");
1209
2353
  const fileType = await fileTypeFromFile(filePath);
1210
- const result = import_shared7.supportedAssetTypeSchema.parse({
2354
+ const result = supportedAssetTypeSchema.parse({
1211
2355
  extension: fileType?.ext,
1212
2356
  mimeType: fileType?.mime
1213
2357
  });
@@ -1216,11 +2360,10 @@ var AssetService = class extends AbstractCrudService {
1216
2360
  };
1217
2361
 
1218
2362
  // src/service/CollectionService.ts
1219
- var import_shared8 = require("@elek-io/shared");
1220
2363
  var import_fs_extra4 = __toESM(require("fs-extra"), 1);
1221
2364
  var CollectionService = class extends AbstractCrudService {
1222
2365
  constructor(options, jsonFileService, gitService) {
1223
- super(import_shared8.serviceTypeSchema.Enum.Collection, options);
2366
+ super(serviceTypeSchema.Enum.Collection, options);
1224
2367
  this.jsonFileService = jsonFileService;
1225
2368
  this.gitService = gitService;
1226
2369
  }
@@ -1228,29 +2371,27 @@ var CollectionService = class extends AbstractCrudService {
1228
2371
  * Creates a new Collection
1229
2372
  */
1230
2373
  async create(props) {
1231
- import_shared8.createCollectionSchema.parse(props);
1232
- const id = (0, import_shared8.uuid)();
2374
+ createCollectionSchema.parse(props);
2375
+ const id = uuid();
1233
2376
  const projectPath = pathTo.project(props.projectId);
1234
2377
  const collectionPath = pathTo.collection(props.projectId, id);
1235
- const collectionFilePath = pathTo.collectionFile(
1236
- props.projectId,
1237
- id
1238
- );
2378
+ const collectionFilePath = pathTo.collectionFile(props.projectId, id);
1239
2379
  const collectionFile = {
1240
2380
  ...props,
1241
2381
  objectType: "collection",
1242
2382
  id,
1243
2383
  slug: {
1244
- singular: (0, import_shared8.slug)(props.slug.singular),
1245
- plural: (0, import_shared8.slug)(props.slug.plural)
2384
+ singular: slug(props.slug.singular),
2385
+ plural: slug(props.slug.plural)
1246
2386
  },
1247
- created: (0, import_shared8.currentTimestamp)()
2387
+ created: currentTimestamp(),
2388
+ updated: null
1248
2389
  };
1249
2390
  await import_fs_extra4.default.ensureDir(collectionPath);
1250
2391
  await this.jsonFileService.create(
1251
2392
  collectionFile,
1252
2393
  collectionFilePath,
1253
- import_shared8.collectionFileSchema
2394
+ collectionFileSchema
1254
2395
  );
1255
2396
  await this.gitService.add(projectPath, [collectionFilePath]);
1256
2397
  await this.gitService.commit(projectPath, this.gitMessage.create);
@@ -1260,10 +2401,10 @@ var CollectionService = class extends AbstractCrudService {
1260
2401
  * Returns a Collection by ID
1261
2402
  */
1262
2403
  async read(props) {
1263
- import_shared8.readCollectionSchema.parse(props);
2404
+ readCollectionSchema.parse(props);
1264
2405
  const collection = await this.jsonFileService.read(
1265
2406
  pathTo.collectionFile(props.projectId, props.id),
1266
- import_shared8.collectionFileSchema
2407
+ collectionFileSchema
1267
2408
  );
1268
2409
  return collection;
1269
2410
  }
@@ -1278,7 +2419,7 @@ var CollectionService = class extends AbstractCrudService {
1278
2419
  * before given update can be executed or void if the update was executed successfully
1279
2420
  */
1280
2421
  async update(props) {
1281
- import_shared8.updateCollectionSchema.parse(props);
2422
+ updateCollectionSchema.parse(props);
1282
2423
  const projectPath = pathTo.project(props.projectId);
1283
2424
  const collectionFilePath = pathTo.collectionFile(
1284
2425
  props.projectId,
@@ -1288,12 +2429,12 @@ var CollectionService = class extends AbstractCrudService {
1288
2429
  const collectionFile = {
1289
2430
  ...prevCollectionFile,
1290
2431
  ...props,
1291
- updated: (0, import_shared8.currentTimestamp)()
2432
+ updated: currentTimestamp()
1292
2433
  };
1293
2434
  await this.jsonFileService.update(
1294
2435
  collectionFile,
1295
2436
  collectionFilePath,
1296
- import_shared8.collectionFileSchema
2437
+ collectionFileSchema
1297
2438
  );
1298
2439
  await this.gitService.add(projectPath, [collectionFilePath]);
1299
2440
  await this.gitService.commit(projectPath, this.gitMessage.update);
@@ -1305,42 +2446,44 @@ var CollectionService = class extends AbstractCrudService {
1305
2446
  * The Fields that Collection used are not deleted.
1306
2447
  */
1307
2448
  async delete(props) {
1308
- import_shared8.deleteCollectionSchema.parse(props);
2449
+ deleteCollectionSchema.parse(props);
1309
2450
  const projectPath = pathTo.project(props.projectId);
1310
- const collectionPath = pathTo.collection(
1311
- props.projectId,
1312
- props.id
1313
- );
2451
+ const collectionPath = pathTo.collection(props.projectId, props.id);
1314
2452
  await import_fs_extra4.default.remove(collectionPath);
1315
2453
  await this.gitService.add(projectPath, [collectionPath]);
1316
2454
  await this.gitService.commit(projectPath, this.gitMessage.delete);
1317
2455
  }
1318
2456
  async list(props) {
1319
- import_shared8.listCollectionsSchema.parse(props);
1320
- const references = await this.listReferences(
1321
- import_shared8.objectTypeSchema.Enum.collection,
2457
+ listCollectionsSchema.parse(props);
2458
+ const offset = props.offset || 0;
2459
+ const limit = props.limit || 15;
2460
+ const collectionReferences = await this.listReferences(
2461
+ objectTypeSchema.Enum.collection,
1322
2462
  props.projectId
1323
2463
  );
1324
- const list = await returnResolved(
1325
- references.map((reference) => {
2464
+ const partialCollectionReferences = collectionReferences.slice(
2465
+ offset,
2466
+ limit
2467
+ );
2468
+ const collections = await returnResolved(
2469
+ partialCollectionReferences.map((reference) => {
1326
2470
  return this.read({
1327
2471
  projectId: props.projectId,
1328
2472
  id: reference.id
1329
2473
  });
1330
2474
  })
1331
2475
  );
1332
- return this.paginate(
1333
- list,
1334
- props.sort,
1335
- props.filter,
1336
- props.limit,
1337
- props.offset
1338
- );
2476
+ return {
2477
+ total: collectionReferences.length,
2478
+ limit,
2479
+ offset,
2480
+ list: collections
2481
+ };
1339
2482
  }
1340
2483
  async count(props) {
1341
- import_shared8.countCollectionsSchema.parse(props);
2484
+ countCollectionsSchema.parse(props);
1342
2485
  const count = (await this.listReferences(
1343
- import_shared8.objectTypeSchema.Enum.collection,
2486
+ objectTypeSchema.Enum.collection,
1344
2487
  props.projectId
1345
2488
  )).length;
1346
2489
  return count;
@@ -1349,17 +2492,16 @@ var CollectionService = class extends AbstractCrudService {
1349
2492
  * Checks if given object is of type Collection
1350
2493
  */
1351
2494
  isCollection(obj) {
1352
- return import_shared8.collectionFileSchema.safeParse(obj).success;
2495
+ return collectionFileSchema.safeParse(obj).success;
1353
2496
  }
1354
2497
  };
1355
2498
 
1356
2499
  // src/service/EntryService.ts
1357
- var import_shared9 = require("@elek-io/shared");
1358
2500
  var import_fs_extra5 = __toESM(require("fs-extra"), 1);
1359
2501
  var EntryService = class extends AbstractCrudService {
1360
2502
  // private sharedValueService: SharedValueService;
1361
2503
  constructor(options, jsonFileService, gitService, collectionService, assetService) {
1362
- super(import_shared9.serviceTypeSchema.Enum.Entry, options);
2504
+ super(serviceTypeSchema.Enum.Entry, options);
1363
2505
  this.jsonFileService = jsonFileService;
1364
2506
  this.gitService = gitService;
1365
2507
  this.collectionService = collectionService;
@@ -1369,8 +2511,8 @@ var EntryService = class extends AbstractCrudService {
1369
2511
  * Creates a new Entry for given Collection
1370
2512
  */
1371
2513
  async create(props) {
1372
- import_shared9.createEntrySchema.parse(props);
1373
- const id = (0, import_shared9.uuid)();
2514
+ createEntrySchema.parse(props);
2515
+ const id = uuid();
1374
2516
  const projectPath = pathTo.project(props.projectId);
1375
2517
  const entryFilePath = pathTo.entryFile(
1376
2518
  props.projectId,
@@ -1385,7 +2527,8 @@ var EntryService = class extends AbstractCrudService {
1385
2527
  objectType: "entry",
1386
2528
  id,
1387
2529
  values: props.values,
1388
- created: (0, import_shared9.currentTimestamp)()
2530
+ created: currentTimestamp(),
2531
+ updated: null
1389
2532
  };
1390
2533
  const entry = await this.toEntry({
1391
2534
  projectId: props.projectId,
@@ -1400,7 +2543,7 @@ var EntryService = class extends AbstractCrudService {
1400
2543
  await this.jsonFileService.create(
1401
2544
  entryFile,
1402
2545
  entryFilePath,
1403
- import_shared9.entryFileSchema
2546
+ entryFileSchema
1404
2547
  );
1405
2548
  await this.gitService.add(projectPath, [entryFilePath]);
1406
2549
  await this.gitService.commit(projectPath, this.gitMessage.create);
@@ -1410,10 +2553,10 @@ var EntryService = class extends AbstractCrudService {
1410
2553
  * Returns an Entry from given Collection by ID and language
1411
2554
  */
1412
2555
  async read(props) {
1413
- import_shared9.readEntrySchema.parse(props);
2556
+ readEntrySchema.parse(props);
1414
2557
  const entryFile = await this.jsonFileService.read(
1415
2558
  pathTo.entryFile(props.projectId, props.collectionId, props.id),
1416
- import_shared9.entryFileSchema
2559
+ entryFileSchema
1417
2560
  );
1418
2561
  return await this.toEntry({
1419
2562
  projectId: props.projectId,
@@ -1425,7 +2568,7 @@ var EntryService = class extends AbstractCrudService {
1425
2568
  * Updates an Entry of given Collection with new Values and shared Values
1426
2569
  */
1427
2570
  async update(props) {
1428
- import_shared9.updateEntrySchema.parse(props);
2571
+ updateEntrySchema.parse(props);
1429
2572
  const projectPath = pathTo.project(props.projectId);
1430
2573
  const entryFilePath = pathTo.entryFile(
1431
2574
  props.projectId,
@@ -1444,7 +2587,7 @@ var EntryService = class extends AbstractCrudService {
1444
2587
  const entryFile = {
1445
2588
  ...prevEntryFile,
1446
2589
  values: props.values,
1447
- updated: (0, import_shared9.currentTimestamp)()
2590
+ updated: currentTimestamp()
1448
2591
  };
1449
2592
  const entry = await this.toEntry({
1450
2593
  projectId: props.projectId,
@@ -1459,7 +2602,7 @@ var EntryService = class extends AbstractCrudService {
1459
2602
  await this.jsonFileService.update(
1460
2603
  entryFile,
1461
2604
  entryFilePath,
1462
- import_shared9.entryFileSchema
2605
+ entryFileSchema
1463
2606
  );
1464
2607
  await this.gitService.add(projectPath, [entryFilePath]);
1465
2608
  await this.gitService.commit(projectPath, this.gitMessage.update);
@@ -1469,7 +2612,7 @@ var EntryService = class extends AbstractCrudService {
1469
2612
  * Deletes given Entry from it's Collection
1470
2613
  */
1471
2614
  async delete(props) {
1472
- import_shared9.deleteEntrySchema.parse(props);
2615
+ deleteEntrySchema.parse(props);
1473
2616
  const projectPath = pathTo.project(props.projectId);
1474
2617
  const entryFilePath = pathTo.entryFile(
1475
2618
  props.projectId,
@@ -1481,14 +2624,17 @@ var EntryService = class extends AbstractCrudService {
1481
2624
  await this.gitService.commit(projectPath, this.gitMessage.delete);
1482
2625
  }
1483
2626
  async list(props) {
1484
- import_shared9.listEntriesSchema.parse(props);
1485
- const references = await this.listReferences(
1486
- import_shared9.objectTypeSchema.Enum.entry,
2627
+ listEntriesSchema.parse(props);
2628
+ const offset = props.offset || 0;
2629
+ const limit = props.limit || 15;
2630
+ const entryReferences = await this.listReferences(
2631
+ objectTypeSchema.Enum.entry,
1487
2632
  props.projectId,
1488
2633
  props.collectionId
1489
2634
  );
1490
- const list = await returnResolved(
1491
- references.map((reference) => {
2635
+ const partialEntryReferences = entryReferences.slice(offset, limit);
2636
+ const entries = await returnResolved(
2637
+ partialEntryReferences.map((reference) => {
1492
2638
  return this.read({
1493
2639
  projectId: props.projectId,
1494
2640
  collectionId: props.collectionId,
@@ -1496,18 +2642,17 @@ var EntryService = class extends AbstractCrudService {
1496
2642
  });
1497
2643
  })
1498
2644
  );
1499
- return this.paginate(
1500
- list,
1501
- props.sort,
1502
- props.filter,
1503
- props.limit,
1504
- props.offset
1505
- );
2645
+ return {
2646
+ total: entryReferences.length,
2647
+ limit,
2648
+ offset,
2649
+ list: entries
2650
+ };
1506
2651
  }
1507
2652
  async count(props) {
1508
- import_shared9.countEntriesSchema.parse(props);
2653
+ countEntriesSchema.parse(props);
1509
2654
  return (await this.listReferences(
1510
- import_shared9.objectTypeSchema.Enum.entry,
2655
+ objectTypeSchema.Enum.entry,
1511
2656
  props.projectId,
1512
2657
  props.collectionId
1513
2658
  )).length;
@@ -1516,7 +2661,7 @@ var EntryService = class extends AbstractCrudService {
1516
2661
  * Checks if given object is of type Entry
1517
2662
  */
1518
2663
  isEntry(obj) {
1519
- return import_shared9.entrySchema.safeParse(obj).success;
2664
+ return entrySchema.safeParse(obj).success;
1520
2665
  }
1521
2666
  /**
1522
2667
  * Returns a Value definition by ID
@@ -1545,14 +2690,10 @@ var EntryService = class extends AbstractCrudService {
1545
2690
  valueDefinitions: props.valueDefinitions,
1546
2691
  id: value.definitionId
1547
2692
  });
1548
- const schema = (0, import_shared9.getValueContentSchemaFromDefinition)(definition);
2693
+ const schema = getValueContentSchemaFromDefinition(definition);
1549
2694
  try {
1550
- if (value.valueType === "reference") {
1551
- schema.parse(value.content);
1552
- } else {
1553
- for (const [language, content] of Object.entries(value.content)) {
1554
- schema.parse(content);
1555
- }
2695
+ for (const [language, content] of Object.entries(value.content)) {
2696
+ schema.parse(content);
1556
2697
  }
1557
2698
  } catch (error) {
1558
2699
  console.log("Definition:", definition);
@@ -1580,17 +2721,18 @@ var EntryService = class extends AbstractCrudService {
1580
2721
  // });
1581
2722
  // }
1582
2723
  async resolveValueContentReference(props) {
1583
- switch (props.valueContentReference.referenceObjectType) {
1584
- case import_shared9.objectTypeSchema.Enum.asset:
1585
- return this.resolveValueContentReferenceToAsset({
2724
+ switch (props.valueContentReference.objectType) {
2725
+ case objectTypeSchema.Enum.asset:
2726
+ return await this.assetService.read({
1586
2727
  projectId: props.projectId,
1587
- valueContentReferenceToAsset: props.valueContentReference
2728
+ id: props.valueContentReference.id,
2729
+ language: props.valueContentReference.language
1588
2730
  });
1589
- case import_shared9.objectTypeSchema.Enum.entry:
1590
- return this.resolveValueContentReferenceToEntry({
2731
+ case objectTypeSchema.Enum.entry:
2732
+ return await this.read({
1591
2733
  projectId: props.projectId,
1592
2734
  collectionId: props.collectionId,
1593
- valueContentReferenceToEntry: props.valueContentReference
2735
+ id: props.valueContentReference.id
1594
2736
  });
1595
2737
  default:
1596
2738
  throw new Error(
@@ -1599,86 +2741,61 @@ var EntryService = class extends AbstractCrudService {
1599
2741
  );
1600
2742
  }
1601
2743
  }
1602
- async resolveValueContentReferenceToAsset(props) {
1603
- const resolvedReferences = await Promise.all(
1604
- props.valueContentReferenceToAsset.references.map(async (reference) => {
1605
- const resolvedAsset = await this.assetService.read({
1606
- projectId: props.projectId,
1607
- id: reference.id,
1608
- language: reference.language
1609
- });
1610
- return resolvedAsset;
1611
- })
1612
- );
1613
- return {
1614
- ...props.valueContentReferenceToAsset,
1615
- references: resolvedReferences
1616
- };
1617
- }
1618
- async resolveValueContentReferenceToEntry(props) {
1619
- const resolvedReferences = await Promise.all(
1620
- props.valueContentReferenceToEntry.references.map(async (reference) => {
1621
- const resolvedEntry = await this.read({
1622
- projectId: props.projectId,
1623
- collectionId: props.collectionId,
1624
- id: reference.id
1625
- });
1626
- return resolvedEntry;
1627
- })
1628
- );
1629
- return {
1630
- ...props.valueContentReferenceToEntry,
1631
- references: resolvedReferences
1632
- };
2744
+ async resolveValueContentReferences(props) {
2745
+ let resolvedContent = {};
2746
+ for (const language in props.valueReference.content) {
2747
+ const referencesOfLanguage = props.valueReference.content[language];
2748
+ if (!referencesOfLanguage) {
2749
+ throw new Error(
2750
+ `Trying to access content references by language "${language}" failed`
2751
+ );
2752
+ }
2753
+ const resolvedReferencesOfLanguage = await Promise.all(
2754
+ referencesOfLanguage.map(async (reference) => {
2755
+ return await this.resolveValueContentReference({
2756
+ projectId: props.projectId,
2757
+ collectionId: props.collectionId,
2758
+ valueContentReference: reference
2759
+ });
2760
+ })
2761
+ );
2762
+ resolvedContent = {
2763
+ ...resolvedContent,
2764
+ [language]: resolvedReferencesOfLanguage
2765
+ };
2766
+ }
2767
+ return resolvedContent;
1633
2768
  }
1634
- // private async resolveValueContentReferenceToSharedValue(props: {
1635
- // projectId: string;
1636
- // valueContentReferenceToSharedValue: ValueContentReferenceToSharedValue;
1637
- // }): Promise<ResolvedValueContentReferenceToSharedValue> {
1638
- // const resolvedSharedValue = await this.sharedValueService.read({
1639
- // projectId: props.projectId,
1640
- // id: props.valueContentReferenceToSharedValue.references.id,
1641
- // language: props.valueContentReferenceToSharedValue.references.language,
1642
- // });
1643
- // return {
1644
- // ...props.valueContentReferenceToSharedValue,
1645
- // references: {
1646
- // ...props.valueContentReferenceToSharedValue.references,
1647
- // resolved: resolvedSharedValue,
1648
- // },
1649
- // };
1650
- // }
1651
2769
  /**
1652
2770
  * Creates an Entry from given EntryFile by resolving it's Values
1653
2771
  */
1654
2772
  async toEntry(props) {
1655
- const entry = {
2773
+ return {
1656
2774
  ...props.entryFile,
2775
+ // @ts-ignore @todo fixme - I have no idea why this happens. The types seem to be compatible to me and they work
1657
2776
  values: await Promise.all(
1658
2777
  props.entryFile.values.map(async (value) => {
1659
- if (value.valueType === import_shared9.ValueTypeSchema.Enum.reference) {
1660
- const resolvedValueContentReference = await this.resolveValueContentReference({
2778
+ if (value.valueType === ValueTypeSchema.Enum.reference) {
2779
+ const resolvedContentReferences = await this.resolveValueContentReferences({
1661
2780
  projectId: props.projectId,
1662
2781
  collectionId: props.collectionId,
1663
- valueContentReference: value.content
2782
+ valueReference: value
1664
2783
  });
1665
2784
  return {
1666
2785
  ...value,
1667
- content: resolvedValueContentReference
2786
+ content: resolvedContentReferences
1668
2787
  };
1669
2788
  }
1670
2789
  return value;
1671
2790
  })
1672
2791
  )
1673
2792
  };
1674
- return entry;
1675
2793
  }
1676
2794
  };
1677
2795
 
1678
2796
  // src/service/ProjectService.ts
1679
- var import_shared11 = require("@elek-io/shared");
1680
2797
  var import_fs_extra6 = __toESM(require("fs-extra"), 1);
1681
- var import_os2 = __toESM(require("os"), 1);
2798
+ var import_os4 = __toESM(require("os"), 1);
1682
2799
  var import_path2 = __toESM(require("path"), 1);
1683
2800
  var import_semver = __toESM(require("semver"), 1);
1684
2801
 
@@ -1690,81 +2807,52 @@ var ProjectUpgradeError = class extends Error {
1690
2807
  }
1691
2808
  };
1692
2809
 
1693
- // src/service/SearchService.ts
1694
- var import_shared10 = require("@elek-io/shared");
1695
- var SearchService = class extends AbstractCrudService {
1696
- constructor(options, assetService, collectionService) {
1697
- super(import_shared10.serviceTypeSchema.enum.Search, options);
1698
- this.assetService = assetService;
1699
- this.collectionService = collectionService;
1700
- }
1701
- /**
1702
- * Search all models inside the project for given query
1703
- *
1704
- * @todo Implement SearchOptions parameter
1705
- *
1706
- * @param project Project to search in
1707
- * @param query Query to search for
1708
- */
1709
- async search(projectId, query, objectType) {
1710
- const results = [];
1711
- const normalizedQuery = query.trim();
1712
- if (normalizedQuery === "") {
1713
- return results;
1714
- }
1715
- const paginatedLists = (await Promise.all([this.assetService.list({ projectId, filter: query })])).flat();
1716
- paginatedLists.forEach((paginatedList) => {
1717
- paginatedList.list.flat().forEach((file) => {
1718
- const result = {
1719
- id: file.id,
1720
- language: file.language,
1721
- name: file.name,
1722
- type: file.objectType,
1723
- matches: []
1724
- };
1725
- for (const [key, value] of Object.entries(file)) {
1726
- const valueString = String(value);
1727
- if (valueString.toLowerCase().includes(normalizedQuery.toLowerCase())) {
1728
- const matchStart = valueString.toLowerCase().indexOf(normalizedQuery.toLowerCase());
1729
- const matchEnd = matchStart + normalizedQuery.length;
1730
- result.matches.push({
1731
- key,
1732
- prefix: this.truncate(
1733
- valueString.substring(0, matchStart),
1734
- "start"
1735
- ),
1736
- match: valueString.substring(matchStart, matchEnd),
1737
- suffix: this.truncate(
1738
- valueString.substring(matchEnd, valueString.length),
1739
- "end"
1740
- )
1741
- });
1742
- }
1743
- }
1744
- if (result.matches.length > 0) {
1745
- results.push(result);
1746
- }
1747
- });
1748
- });
1749
- return results;
1750
- }
1751
- truncate(value, at, limit = 15) {
1752
- if (at === "start") {
1753
- return `${value.substring(value.length - limit, value.length)}`;
1754
- } else {
1755
- return `${value.substring(0, limit)}`;
1756
- }
1757
- }
1758
- };
1759
-
1760
2810
  // src/service/ProjectService.ts
1761
2811
  var ProjectService = class extends AbstractCrudService {
1762
- constructor(options, jsonFileService, userService, gitService, searchService, assetService, collectionService, entryService) {
1763
- super(import_shared11.serviceTypeSchema.Enum.Project, options);
2812
+ constructor(options, jsonFileService, userService, gitService, assetService, collectionService, entryService) {
2813
+ super(serviceTypeSchema.Enum.Project, options);
2814
+ this.branches = {
2815
+ list: async (props) => {
2816
+ listBranchesProjectSchema.parse(props);
2817
+ const projectPath = pathTo.project(props.id);
2818
+ await this.gitService.fetch(projectPath);
2819
+ return await this.gitService.branches.list(projectPath);
2820
+ },
2821
+ current: async (props) => {
2822
+ currentBranchProjectSchema.parse(props);
2823
+ const projectPath = pathTo.project(props.id);
2824
+ return await this.gitService.branches.current(projectPath);
2825
+ },
2826
+ switch: async (props) => {
2827
+ switchBranchProjectSchema.parse(props);
2828
+ const projectPath = pathTo.project(props.id);
2829
+ return await this.gitService.branches.switch(
2830
+ projectPath,
2831
+ props.branch,
2832
+ props.options
2833
+ );
2834
+ }
2835
+ };
2836
+ this.remotes = {
2837
+ getOriginUrl: async (props) => {
2838
+ getRemoteOriginUrlProjectSchema.parse(props);
2839
+ const projectPath = pathTo.project(props.id);
2840
+ return await this.gitService.remotes.getOriginUrl(projectPath);
2841
+ },
2842
+ setOriginUrl: async (props) => {
2843
+ setRemoteOriginUrlProjectSchema.parse(props);
2844
+ const projectPath = pathTo.project(props.id);
2845
+ const hasOrigin = await this.gitService.remotes.hasOrigin(projectPath);
2846
+ if (!hasOrigin) {
2847
+ await this.gitService.remotes.addOrigin(projectPath, props.url);
2848
+ } else {
2849
+ await this.gitService.remotes.setOriginUrl(projectPath, props.url);
2850
+ }
2851
+ }
2852
+ };
1764
2853
  this.jsonFileService = jsonFileService;
1765
2854
  this.userService = userService;
1766
2855
  this.gitService = gitService;
1767
- this.searchService = searchService;
1768
2856
  this.assetService = assetService;
1769
2857
  this.collectionService = collectionService;
1770
2858
  this.entryService = entryService;
@@ -1773,12 +2861,12 @@ var ProjectService = class extends AbstractCrudService {
1773
2861
  * Creates a new Project
1774
2862
  */
1775
2863
  async create(props) {
1776
- import_shared11.createProjectSchema.parse(props);
2864
+ createProjectSchema.parse(props);
1777
2865
  const user = await this.userService.get();
1778
2866
  if (!user) {
1779
2867
  throw new NoCurrentUserError();
1780
2868
  }
1781
- const id = (0, import_shared11.uuid)();
2869
+ const id = uuid();
1782
2870
  const defaultSettings = {
1783
2871
  language: {
1784
2872
  default: user.language,
@@ -1791,7 +2879,8 @@ var ProjectService = class extends AbstractCrudService {
1791
2879
  id,
1792
2880
  description: props.description || "",
1793
2881
  settings: Object.assign({}, defaultSettings, props.settings),
1794
- created: (0, import_shared11.currentTimestamp)(),
2882
+ created: currentTimestamp(),
2883
+ updated: null,
1795
2884
  coreVersion: this.options.version,
1796
2885
  // @todo should be read from package.json to avoid duplicates
1797
2886
  status: "todo",
@@ -1806,50 +2895,83 @@ var ProjectService = class extends AbstractCrudService {
1806
2895
  await this.jsonFileService.create(
1807
2896
  projectFile,
1808
2897
  pathTo.projectFile(id),
1809
- import_shared11.projectFileSchema
2898
+ projectFileSchema
1810
2899
  );
1811
2900
  await this.gitService.add(projectPath, ["."]);
1812
2901
  await this.gitService.commit(
1813
2902
  projectPath,
1814
- `${import_shared11.gitCommitIconSchema.enum.INIT} Created this new elek.io project`
2903
+ `${gitCommitIconSchema.enum.INIT} Created this new elek.io project`
1815
2904
  );
1816
- await this.gitService.switch(projectPath, "stage", { isNew: true });
2905
+ await this.gitService.branches.switch(projectPath, "stage", {
2906
+ isNew: true
2907
+ });
1817
2908
  } catch (error) {
1818
2909
  await this.delete({
1819
2910
  id
1820
2911
  });
1821
2912
  throw error;
1822
2913
  }
1823
- return projectFile;
2914
+ return await this.toProject({
2915
+ projectFile
2916
+ });
2917
+ }
2918
+ /**
2919
+ * Clones a Project by URL
2920
+ */
2921
+ async clone(props) {
2922
+ cloneProjectSchema.parse(props);
2923
+ const tmpId = uuid();
2924
+ const tmpProjectPath = import_path2.default.join(pathTo.tmp, tmpId);
2925
+ await this.gitService.clone(props.url, tmpProjectPath);
2926
+ const projectFile = await this.jsonFileService.read(
2927
+ import_path2.default.join(tmpProjectPath, "project.json"),
2928
+ projectFileSchema
2929
+ );
2930
+ const projectPath = pathTo.project(projectFile.id);
2931
+ const alreadyExists = await import_fs_extra6.default.pathExists(projectPath);
2932
+ if (alreadyExists) {
2933
+ throw new Error(
2934
+ `Tried to clone Project "${projectFile.id}" from "${props.url}" - but the Project already exists locally`
2935
+ );
2936
+ }
2937
+ await import_fs_extra6.default.copy(tmpProjectPath, projectPath);
2938
+ await import_fs_extra6.default.remove(tmpProjectPath);
2939
+ return await this.toProject({
2940
+ projectFile
2941
+ });
1824
2942
  }
1825
2943
  /**
1826
2944
  * Returns a Project by ID
1827
2945
  */
1828
2946
  async read(props) {
1829
- import_shared11.readProjectSchema.parse(props);
2947
+ readProjectSchema.parse(props);
1830
2948
  const projectFile = await this.jsonFileService.read(
1831
2949
  pathTo.projectFile(props.id),
1832
- import_shared11.projectFileSchema
2950
+ projectFileSchema
1833
2951
  );
1834
- return projectFile;
2952
+ return await this.toProject({
2953
+ projectFile
2954
+ });
1835
2955
  }
1836
2956
  /**
1837
2957
  * Updates given Project
1838
2958
  */
1839
2959
  async update(props) {
1840
- import_shared11.updateProjectSchema.parse(props);
2960
+ updateProjectSchema.parse(props);
1841
2961
  const projectPath = pathTo.project(props.id);
1842
2962
  const filePath = pathTo.projectFile(props.id);
1843
2963
  const prevProjectFile = await this.read(props);
1844
2964
  const projectFile = {
1845
2965
  ...prevProjectFile,
1846
2966
  ...props,
1847
- updated: (0, import_shared11.currentTimestamp)()
2967
+ updated: currentTimestamp()
1848
2968
  };
1849
- await this.jsonFileService.update(projectFile, filePath, import_shared11.projectFileSchema);
2969
+ await this.jsonFileService.update(projectFile, filePath, projectFileSchema);
1850
2970
  await this.gitService.add(projectPath, [filePath]);
1851
2971
  await this.gitService.commit(projectPath, this.gitMessage.update);
1852
- return projectFile;
2972
+ return await this.toProject({
2973
+ projectFile
2974
+ });
1853
2975
  }
1854
2976
  /**
1855
2977
  * Upgrades given Project to the latest version of this client
@@ -1859,7 +2981,7 @@ var ProjectService = class extends AbstractCrudService {
1859
2981
  * @todo Find out why using this.snapshotService is throwing isObjWithKeyAndValueOfString of undefined error in gitService (maybe binding issue)
1860
2982
  */
1861
2983
  async upgrade(props) {
1862
- import_shared11.upgradeProjectSchema.parse(props);
2984
+ upgradeProjectSchema.parse(props);
1863
2985
  const project = await this.read(props);
1864
2986
  const projectPath = pathTo.project(project.id);
1865
2987
  if (import_semver.default.gt(project.coreVersion, this.options.version)) {
@@ -1917,6 +3039,39 @@ var ProjectService = class extends AbstractCrudService {
1917
3039
  }
1918
3040
  }
1919
3041
  }
3042
+ /**
3043
+ * Returns the differences of the given Projects current branch
3044
+ * between the local and remote `origin` (commits ahead & behind)
3045
+ *
3046
+ * - `behind` contains a list of commits on the current branch that are available on the remote `origin` but not yet locally
3047
+ * - `ahead` contains a list of commits on the current branch that are available locally but not yet on the remote `origin`
3048
+ */
3049
+ async getChanges(props) {
3050
+ getChangesProjectSchema.parse(props);
3051
+ const projectPath = pathTo.project(props.id);
3052
+ const currentBranch = await this.gitService.branches.current(projectPath);
3053
+ await this.gitService.fetch(projectPath);
3054
+ const behind = await this.gitService.log(projectPath, {
3055
+ between: { from: currentBranch, to: `origin/${currentBranch}` }
3056
+ });
3057
+ const ahead = await this.gitService.log(projectPath, {
3058
+ between: { from: `origin/${currentBranch}`, to: currentBranch }
3059
+ });
3060
+ return {
3061
+ behind,
3062
+ ahead
3063
+ };
3064
+ }
3065
+ /**
3066
+ * Pulls remote changes of `origin` down to the local repository
3067
+ * and then pushes local commits to the upstream branch
3068
+ */
3069
+ async synchronize(props) {
3070
+ synchronizeProjectSchema.parse(props);
3071
+ const projectPath = pathTo.project(props.id);
3072
+ await this.gitService.pull(projectPath);
3073
+ await this.gitService.push(projectPath);
3074
+ }
1920
3075
  /**
1921
3076
  * Deletes given Project
1922
3077
  *
@@ -1925,45 +3080,39 @@ var ProjectService = class extends AbstractCrudService {
1925
3080
  * Or changes that are not pushed to a remote yet, will be lost too.
1926
3081
  */
1927
3082
  async delete(props) {
1928
- import_shared11.deleteProjectSchema.parse(props);
3083
+ deleteProjectSchema.parse(props);
1929
3084
  await import_fs_extra6.default.remove(pathTo.project(props.id));
1930
3085
  }
1931
3086
  async list(props) {
1932
3087
  if (props) {
1933
- import_shared11.listProjectsSchema.parse(props);
3088
+ listProjectsSchema.parse(props);
1934
3089
  }
1935
- const references = await this.listReferences(import_shared11.objectTypeSchema.Enum.project);
1936
- const list = await returnResolved(
1937
- references.map((reference) => {
3090
+ const offset = props?.offset || 0;
3091
+ const limit = props?.limit || 15;
3092
+ const projectReferences = await this.listReferences(
3093
+ objectTypeSchema.Enum.project
3094
+ );
3095
+ const partialProjectReferences = projectReferences.slice(offset, limit);
3096
+ const projects = await returnResolved(
3097
+ partialProjectReferences.map((reference) => {
1938
3098
  return this.read({ id: reference.id });
1939
3099
  })
1940
3100
  );
1941
- return this.paginate(
1942
- list,
1943
- props?.sort,
1944
- props?.filter,
1945
- props?.limit,
1946
- props?.offset
1947
- );
3101
+ return {
3102
+ total: projectReferences.length,
3103
+ limit,
3104
+ offset,
3105
+ list: projects
3106
+ };
1948
3107
  }
1949
3108
  async count() {
1950
- return (await this.listReferences(import_shared11.objectTypeSchema.Enum.project)).length;
1951
- }
1952
- /**
1953
- * Search all models inside the project for given query
1954
- *
1955
- * @param projectId Project ID to search in
1956
- * @param query Query to search for
1957
- * @param type (Optional) specify the type to search for
1958
- */
1959
- async search(projectId, query, type) {
1960
- return this.searchService.search(projectId, query, type);
3109
+ return (await this.listReferences(objectTypeSchema.Enum.project)).length;
1961
3110
  }
1962
3111
  /**
1963
3112
  * Checks if given object is of type Project
1964
3113
  */
1965
3114
  isProject(obj) {
1966
- return import_shared11.projectFileSchema.safeParse(obj).success;
3115
+ return projectFileSchema.safeParse(obj).success;
1967
3116
  }
1968
3117
  /**
1969
3118
  * Exports given Project to JSON
@@ -1995,13 +3144,21 @@ var ProjectService = class extends AbstractCrudService {
1995
3144
  collections: collectionExport
1996
3145
  };
1997
3146
  }
3147
+ /**
3148
+ * Creates a Project from given ProjectFile by adding git information
3149
+ */
3150
+ async toProject(props) {
3151
+ return {
3152
+ ...props.projectFile
3153
+ };
3154
+ }
1998
3155
  /**
1999
3156
  * Creates the projects folder structure and makes sure to
2000
3157
  * write empty .gitkeep files inside them to ensure they are
2001
3158
  * committed
2002
3159
  */
2003
3160
  async createFolderStructure(path) {
2004
- const folders2 = Object.values(import_shared11.projectFolderSchema.Values);
3161
+ const folders2 = Object.values(projectFolderSchema.Values);
2005
3162
  await Promise.all(
2006
3163
  folders2.map(async (folder) => {
2007
3164
  await import_fs_extra6.default.mkdirp(import_path2.default.join(path, folder));
@@ -2029,15 +3186,44 @@ var ProjectService = class extends AbstractCrudService {
2029
3186
  // projectFolderSchema.Enum.public + '/',
2030
3187
  // projectFolderSchema.Enum.logs + '/',
2031
3188
  ];
2032
- await import_fs_extra6.default.writeFile(import_path2.default.join(path, ".gitignore"), lines.join(import_os2.default.EOL));
3189
+ await import_fs_extra6.default.writeFile(import_path2.default.join(path, ".gitignore"), lines.join(import_os4.default.EOL));
2033
3190
  }
2034
3191
  };
2035
3192
 
3193
+ // src/schema/coreSchema.ts
3194
+ var import_zod12 = require("zod");
3195
+ var elekIoCoreOptionsSchema = import_zod12.z.object({
3196
+ /**
3197
+ * The environment elek.io Core is currently running in
3198
+ */
3199
+ environment: environmentSchema,
3200
+ /**
3201
+ * The current version of elek.io Core
3202
+ */
3203
+ version: versionSchema,
3204
+ file: import_zod12.z.object({
3205
+ json: import_zod12.z.object({
3206
+ /**
3207
+ * If set, adds indentation with spaces (number) or escape character (string)
3208
+ * and line break characters to saved JSON files on disk, to make them easier to read.
3209
+ * Defaults to 2 spaces of indentation.
3210
+ */
3211
+ indentation: import_zod12.z.union([import_zod12.z.number(), import_zod12.z.string()])
3212
+ })
3213
+ })
3214
+ });
3215
+ var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
3216
+ version: true
3217
+ }).partial({
3218
+ environment: true,
3219
+ file: true
3220
+ }).optional();
3221
+
2036
3222
  // src/index.ts
2037
3223
  var ElekIoCore = class {
2038
3224
  // private readonly sharedValueService: SharedValueService;
2039
3225
  constructor(props) {
2040
- const parsedProps = import_shared12.constructorElekIoCoreSchema.parse(props);
3226
+ const parsedProps = constructorElekIoCoreSchema.parse(props);
2041
3227
  const defaults = {
2042
3228
  environment: "production",
2043
3229
  version: "0.0.0",
@@ -2069,17 +3255,11 @@ var ElekIoCore = class {
2069
3255
  this.assetService
2070
3256
  // this.sharedValueService
2071
3257
  );
2072
- this.searchService = new SearchService(
2073
- this.options,
2074
- this.assetService,
2075
- this.collectionService
2076
- );
2077
3258
  this.projectService = new ProjectService(
2078
3259
  this.options,
2079
3260
  this.jsonFileService,
2080
3261
  this.userService,
2081
3262
  this.gitService,
2082
- this.searchService,
2083
3263
  this.assetService,
2084
3264
  this.collectionService,
2085
3265
  this.entryService
@@ -2103,7 +3283,13 @@ var ElekIoCore = class {
2103
3283
  return util_exports;
2104
3284
  }
2105
3285
  /**
2106
- *
3286
+ * Exposes git functions
3287
+ */
3288
+ get git() {
3289
+ return this.gitService;
3290
+ }
3291
+ /**
3292
+ * Getter and setter methods for the User currently working with Core
2107
3293
  */
2108
3294
  get user() {
2109
3295
  return this.userService;
@@ -2139,4 +3325,137 @@ var ElekIoCore = class {
2139
3325
  // return this.sharedValueService;
2140
3326
  // }
2141
3327
  };
3328
+ // Annotate the CommonJS export names for ESM import in node:
3329
+ 0 && (module.exports = {
3330
+ BooleanValueDefinitionBaseSchema,
3331
+ NumberValueDefinitionBaseSchema,
3332
+ ReferenceValueDefinitionBaseSchema,
3333
+ StringValueDefinitionBaseSchema,
3334
+ UserTypeSchema,
3335
+ ValueDefinitionBaseSchema,
3336
+ ValueInputTypeSchema,
3337
+ ValueInputWidthSchema,
3338
+ ValueTypeSchema,
3339
+ assetExportSchema,
3340
+ assetFileSchema,
3341
+ assetSchema,
3342
+ assetValueDefinitionSchema,
3343
+ baseFileSchema,
3344
+ baseFileWithLanguageSchema,
3345
+ baseUserSchema,
3346
+ cloneProjectSchema,
3347
+ cloudUserSchema,
3348
+ collectionExportSchema,
3349
+ collectionFileSchema,
3350
+ collectionSchema,
3351
+ constructorElekIoCoreSchema,
3352
+ countAssetsSchema,
3353
+ countCollectionsSchema,
3354
+ countEntriesSchema,
3355
+ countGitTagsSchema,
3356
+ createAssetSchema,
3357
+ createCollectionSchema,
3358
+ createEntrySchema,
3359
+ createGitTagSchema,
3360
+ createProjectSchema,
3361
+ currentBranchProjectSchema,
3362
+ dateValueDefinitionSchema,
3363
+ datetimeValueDefinitionSchema,
3364
+ deleteAssetSchema,
3365
+ deleteCollectionSchema,
3366
+ deleteEntrySchema,
3367
+ deleteGitTagSchema,
3368
+ deleteProjectSchema,
3369
+ directBooleanValueSchema,
3370
+ directNumberValueSchema,
3371
+ directStringValueSchema,
3372
+ directValueBaseSchema,
3373
+ directValueSchema,
3374
+ elekIoCoreOptionsSchema,
3375
+ emailValueDefinitionSchema,
3376
+ entryExportSchema,
3377
+ entryFileSchema,
3378
+ entrySchema,
3379
+ entryValueDefinitionSchema,
3380
+ environmentSchema,
3381
+ fileReferenceSchema,
3382
+ getChangesProjectSchema,
3383
+ getRemoteOriginUrlProjectSchema,
3384
+ getValueContentSchemaFromDefinition,
3385
+ gitCloneOptionsSchema,
3386
+ gitCommitIconSchema,
3387
+ gitCommitSchema,
3388
+ gitInitOptionsSchema,
3389
+ gitLogOptionsSchema,
3390
+ gitRepositoryPathSchema,
3391
+ gitSignatureSchema,
3392
+ gitSwitchOptionsSchema,
3393
+ gitTagSchema,
3394
+ ipValueDefinitionSchema,
3395
+ listAssetsSchema,
3396
+ listBranchesProjectSchema,
3397
+ listCollectionsSchema,
3398
+ listEntriesSchema,
3399
+ listGitTagsSchema,
3400
+ listProjectsSchema,
3401
+ localUserSchema,
3402
+ numberValueDefinitionSchema,
3403
+ objectTypeSchema,
3404
+ projectExportSchema,
3405
+ projectFileSchema,
3406
+ projectFolderSchema,
3407
+ projectSchema,
3408
+ projectSettingsSchema,
3409
+ projectStatusSchema,
3410
+ projectUpgradeSchema,
3411
+ rangeValueDefinitionSchema,
3412
+ readAssetSchema,
3413
+ readCollectionSchema,
3414
+ readEntrySchema,
3415
+ readGitTagSchema,
3416
+ readProjectSchema,
3417
+ referencedValueSchema,
3418
+ resolvedReferencedValueSchema,
3419
+ resolvedValueContentReferenceSchema,
3420
+ resolvedValueSchema,
3421
+ searchProjectSchema,
3422
+ serviceTypeSchema,
3423
+ setRemoteOriginUrlProjectSchema,
3424
+ setUserSchema,
3425
+ stringValueDefinitionSchema,
3426
+ supportedAssetExtensionSchema,
3427
+ supportedAssetMimeTypeSchema,
3428
+ supportedAssetTypeSchema,
3429
+ supportedIconSchema,
3430
+ supportedLanguageSchema,
3431
+ switchBranchProjectSchema,
3432
+ synchronizeProjectSchema,
3433
+ telephoneValueDefinitionSchema,
3434
+ textValueDefinitionSchema,
3435
+ textareaValueDefinitionSchema,
3436
+ timeValueDefinitionSchema,
3437
+ toggleValueDefinitionSchema,
3438
+ translatableArrayOf,
3439
+ translatableBooleanSchema,
3440
+ translatableNumberSchema,
3441
+ translatableStringSchema,
3442
+ updateAssetSchema,
3443
+ updateCollectionSchema,
3444
+ updateEntrySchema,
3445
+ updateProjectSchema,
3446
+ upgradeProjectSchema,
3447
+ urlValueDefinitionSchema,
3448
+ userFileSchema,
3449
+ userSchema,
3450
+ uuidSchema,
3451
+ valueContentReferenceBase,
3452
+ valueContentReferenceSchema,
3453
+ valueContentReferenceToAssetSchema,
3454
+ valueContentReferenceToCollectionSchema,
3455
+ valueContentReferenceToEntrySchema,
3456
+ valueContentReferenceWithLanguageBase,
3457
+ valueDefinitionSchema,
3458
+ valueSchema,
3459
+ versionSchema
3460
+ });
2142
3461
  //# sourceMappingURL=index.cjs.map