@elek-io/core 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,21 +4,9 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // src/index.ts
7
+ // src/index.node.ts
8
8
  import Fs7 from "fs-extra";
9
9
 
10
- // src/service/AssetService.ts
11
- import Fs3 from "fs-extra";
12
- import IsSvg from "is-svg";
13
-
14
- // src/error/RequiredParameterMissingError.ts
15
- var RequiredParameterMissingError = class extends Error {
16
- constructor(parameter) {
17
- super(`Missing required parameter "${parameter}"`);
18
- this.name = "RequiredParameterMissingError";
19
- }
20
- };
21
-
22
10
  // src/schema/assetSchema.ts
23
11
  import z3 from "zod";
24
12
 
@@ -230,161 +218,21 @@ var deleteAssetSchema = assetFileSchema.pick({
230
218
  });
231
219
  var countAssetsSchema = z3.object({ projectId: uuidSchema.readonly() });
232
220
 
233
- // src/schema/serviceSchema.ts
234
- import { z as z5 } from "zod";
235
-
236
- // src/schema/gitSchema.ts
237
- import { z as z4 } from "zod";
238
- var gitRepositoryPathSchema = z4.string();
239
- var gitSignatureSchema = z4.object({
240
- name: z4.string(),
241
- email: z4.string()
242
- });
243
- var gitCommitSchema = z4.object({
244
- /**
245
- * SHA-1 hash of the commit
246
- */
247
- hash: z4.string(),
248
- message: z4.string(),
249
- author: gitSignatureSchema,
250
- timestamp: z4.number(),
251
- tag: z4.string().nullable()
252
- });
253
- var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
254
- GitCommitIconNative2["INIT"] = ":tada:";
255
- GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
256
- GitCommitIconNative2["UPDATE"] = ":wrench:";
257
- GitCommitIconNative2["DELETE"] = ":fire:";
258
- return GitCommitIconNative2;
259
- })(GitCommitIconNative || {});
260
- var gitCommitIconSchema = z4.nativeEnum(GitCommitIconNative);
261
- var gitInitOptionsSchema = z4.object({
262
- /**
263
- * 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).
264
- */
265
- initialBranch: z4.string()
266
- });
267
- var gitCloneOptionsSchema = z4.object({
268
- /**
269
- * 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.
270
- */
271
- depth: z4.number(),
272
- /**
273
- * 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.
274
- */
275
- singleBranch: z4.boolean(),
276
- /**
277
- * 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.
278
- */
279
- branch: z4.string()
280
- });
281
- var gitSwitchOptionsSchema = z4.object({
282
- /**
283
- * If true, creates a new local branch and then switches to it
284
- *
285
- * @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
286
- */
287
- isNew: z4.boolean().optional()
288
- });
289
- var gitLogOptionsSchema = z4.object({
290
- /**
291
- * Limit the result to given number of commits
292
- */
293
- limit: z4.number().optional(),
294
- /**
295
- * Only list commits that are between given SHAs or tag names
296
- *
297
- * Note that the commits of from and to are not included in the result
298
- */
299
- between: z4.object({
300
- /**
301
- * From the oldest commit
302
- */
303
- from: z4.string(),
304
- /**
305
- * To the newest commit
306
- *
307
- * Defaults to the current HEAD
308
- */
309
- to: z4.string().optional()
310
- })
311
- });
312
-
313
- // src/schema/serviceSchema.ts
314
- var serviceTypeSchema = z5.enum([
315
- "Git",
316
- "GitTag",
317
- "User",
318
- "Project",
319
- "Asset",
320
- "JsonFile",
321
- "Search",
322
- "Collection",
323
- "Entry",
324
- "Value"
325
- ]);
326
- var listSchema = z5.object({
327
- projectId: uuidSchema,
328
- limit: z5.number().optional(),
329
- offset: z5.number().optional()
330
- });
331
- var listCollectionsSchema = listSchema;
332
- var listEntriesSchema = listSchema.extend({
333
- collectionId: uuidSchema
334
- });
335
- var listAssetsSchema = listSchema;
336
- var listProjectsSchema = listSchema.omit({
337
- projectId: true
338
- });
339
- var listGitTagsSchema = z5.object({
340
- path: gitRepositoryPathSchema
341
- });
342
-
343
- // src/util/index.ts
344
- var util_exports = {};
345
- __export(util_exports, {
346
- assignDefaultIfMissing: () => assignDefaultIfMissing,
347
- currentTimestamp: () => currentTimestamp,
348
- files: () => files,
349
- folders: () => folders,
350
- fromPath: () => fromPath,
351
- getDuplicates: () => getDuplicates,
352
- getRelativePath: () => getRelativePath,
353
- isNoError: () => isNoError,
354
- notEmpty: () => notEmpty,
355
- pathTo: () => pathTo,
356
- returnResolved: () => returnResolved,
357
- slug: () => slug,
358
- spawnChildProcess: () => spawnChildProcess,
359
- uuid: () => uuid,
360
- workingDirectory: () => workingDirectory
361
- });
362
- import { spawn } from "child_process";
363
- import Fs from "fs-extra";
364
- import { filter, flatten, groupBy, uniq } from "lodash-es";
365
- import Os from "os";
366
- import Path from "path";
367
- import slugify from "slugify";
368
- import { v4 as generateUuid } from "uuid";
369
-
370
- // src/schema/projectSchema.ts
371
- import { z as z9 } from "zod";
372
-
373
221
  // src/schema/collectionSchema.ts
374
- import z8 from "zod";
222
+ import z6 from "zod";
375
223
 
376
224
  // src/schema/entrySchema.ts
377
- import z7 from "zod";
225
+ import z5 from "zod";
378
226
 
379
227
  // src/schema/valueSchema.ts
380
- import z6 from "zod";
381
- var ValueTypeSchema = z6.enum([
228
+ import z4 from "zod";
229
+ var ValueTypeSchema = z4.enum([
382
230
  "string",
383
231
  "number",
384
232
  "boolean",
385
233
  "reference"
386
234
  ]);
387
- var ValueInputTypeSchema = z6.enum([
235
+ var ValueInputTypeSchema = z4.enum([
388
236
  // String
389
237
  "text",
390
238
  "textarea",
@@ -406,67 +254,67 @@ var ValueInputTypeSchema = z6.enum([
406
254
  "entry"
407
255
  // 'sharedValue', // @todo
408
256
  ]);
409
- var ValueInputWidthSchema = z6.enum(["12", "6", "4", "3"]);
410
- var ValueDefinitionBaseSchema = z6.object({
257
+ var ValueInputWidthSchema = z4.enum(["12", "6", "4", "3"]);
258
+ var ValueDefinitionBaseSchema = z4.object({
411
259
  id: uuidSchema.readonly(),
412
260
  label: translatableStringSchema,
413
261
  description: translatableStringSchema,
414
- isRequired: z6.boolean(),
415
- isDisabled: z6.boolean(),
416
- isUnique: z6.boolean(),
262
+ isRequired: z4.boolean(),
263
+ isDisabled: z4.boolean(),
264
+ isUnique: z4.boolean(),
417
265
  inputWidth: ValueInputWidthSchema
418
266
  });
419
267
  var StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
420
268
  {
421
- valueType: z6.literal(ValueTypeSchema.Enum.string),
422
- defaultValue: z6.string().nullable()
269
+ valueType: z4.literal(ValueTypeSchema.Enum.string),
270
+ defaultValue: z4.string().nullable()
423
271
  }
424
272
  );
425
273
  var textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
426
274
  {
427
- inputType: z6.literal(ValueInputTypeSchema.Enum.text),
428
- min: z6.number().nullable(),
429
- max: z6.number().nullable()
275
+ inputType: z4.literal(ValueInputTypeSchema.Enum.text),
276
+ min: z4.number().nullable(),
277
+ max: z4.number().nullable()
430
278
  }
431
279
  );
432
280
  var textareaValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
433
- inputType: z6.literal(ValueInputTypeSchema.Enum.textarea),
434
- min: z6.number().nullable(),
435
- max: z6.number().nullable()
281
+ inputType: z4.literal(ValueInputTypeSchema.Enum.textarea),
282
+ min: z4.number().nullable(),
283
+ max: z4.number().nullable()
436
284
  });
437
285
  var emailValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
438
- inputType: z6.literal(ValueInputTypeSchema.Enum.email),
439
- defaultValue: z6.string().email().nullable()
286
+ inputType: z4.literal(ValueInputTypeSchema.Enum.email),
287
+ defaultValue: z4.string().email().nullable()
440
288
  });
441
289
  var urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
442
- inputType: z6.literal(ValueInputTypeSchema.Enum.url),
443
- defaultValue: z6.string().url().nullable()
290
+ inputType: z4.literal(ValueInputTypeSchema.Enum.url),
291
+ defaultValue: z4.string().url().nullable()
444
292
  });
445
293
  var ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
446
- inputType: z6.literal(ValueInputTypeSchema.Enum.ip),
447
- defaultValue: z6.string().ip().nullable()
294
+ inputType: z4.literal(ValueInputTypeSchema.Enum.ip),
295
+ defaultValue: z4.string().ip().nullable()
448
296
  });
449
297
  var dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
450
298
  {
451
- inputType: z6.literal(ValueInputTypeSchema.Enum.date),
452
- defaultValue: z6.string().date().nullable()
299
+ inputType: z4.literal(ValueInputTypeSchema.Enum.date),
300
+ defaultValue: z4.string().date().nullable()
453
301
  }
454
302
  );
455
303
  var timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
456
304
  {
457
- inputType: z6.literal(ValueInputTypeSchema.Enum.time),
458
- defaultValue: z6.string().time().nullable()
305
+ inputType: z4.literal(ValueInputTypeSchema.Enum.time),
306
+ defaultValue: z4.string().time().nullable()
459
307
  }
460
308
  );
461
309
  var datetimeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
462
- inputType: z6.literal(ValueInputTypeSchema.Enum.datetime),
463
- defaultValue: z6.string().datetime().nullable()
310
+ inputType: z4.literal(ValueInputTypeSchema.Enum.datetime),
311
+ defaultValue: z4.string().datetime().nullable()
464
312
  });
465
313
  var telephoneValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
466
- inputType: z6.literal(ValueInputTypeSchema.Enum.telephone)
314
+ inputType: z4.literal(ValueInputTypeSchema.Enum.telephone)
467
315
  // defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
468
316
  });
469
- var stringValueDefinitionSchema = z6.union([
317
+ var stringValueDefinitionSchema = z4.union([
470
318
  textValueDefinitionSchema,
471
319
  textareaValueDefinitionSchema,
472
320
  emailValueDefinitionSchema,
@@ -479,50 +327,50 @@ var stringValueDefinitionSchema = z6.union([
479
327
  ]);
480
328
  var NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
481
329
  {
482
- valueType: z6.literal(ValueTypeSchema.Enum.number),
483
- min: z6.number().nullable(),
484
- max: z6.number().nullable(),
485
- isUnique: z6.literal(false),
486
- defaultValue: z6.number().nullable()
330
+ valueType: z4.literal(ValueTypeSchema.Enum.number),
331
+ min: z4.number().nullable(),
332
+ max: z4.number().nullable(),
333
+ isUnique: z4.literal(false),
334
+ defaultValue: z4.number().nullable()
487
335
  }
488
336
  );
489
337
  var numberValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
490
- inputType: z6.literal(ValueInputTypeSchema.Enum.number)
338
+ inputType: z4.literal(ValueInputTypeSchema.Enum.number)
491
339
  });
492
340
  var rangeValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
493
- inputType: z6.literal(ValueInputTypeSchema.Enum.range),
341
+ inputType: z4.literal(ValueInputTypeSchema.Enum.range),
494
342
  // Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
495
- isRequired: z6.literal(true),
496
- min: z6.number(),
497
- max: z6.number(),
498
- defaultValue: z6.number()
343
+ isRequired: z4.literal(true),
344
+ min: z4.number(),
345
+ max: z4.number(),
346
+ defaultValue: z4.number()
499
347
  });
500
348
  var BooleanValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
501
- valueType: z6.literal(ValueTypeSchema.Enum.boolean),
349
+ valueType: z4.literal(ValueTypeSchema.Enum.boolean),
502
350
  // Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
503
- isRequired: z6.literal(true),
504
- defaultValue: z6.boolean(),
505
- isUnique: z6.literal(false)
351
+ isRequired: z4.literal(true),
352
+ defaultValue: z4.boolean(),
353
+ isUnique: z4.literal(false)
506
354
  });
507
355
  var toggleValueDefinitionSchema = BooleanValueDefinitionBaseSchema.extend({
508
- inputType: z6.literal(ValueInputTypeSchema.Enum.toggle)
356
+ inputType: z4.literal(ValueInputTypeSchema.Enum.toggle)
509
357
  });
510
358
  var ReferenceValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
511
- valueType: z6.literal(ValueTypeSchema.Enum.reference)
359
+ valueType: z4.literal(ValueTypeSchema.Enum.reference)
512
360
  });
513
361
  var assetValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
514
- inputType: z6.literal(ValueInputTypeSchema.Enum.asset),
515
- allowedMimeTypes: z6.array(supportedAssetMimeTypeSchema).min(1),
516
- min: z6.number().nullable(),
517
- max: z6.number().nullable()
362
+ inputType: z4.literal(ValueInputTypeSchema.Enum.asset),
363
+ allowedMimeTypes: z4.array(supportedAssetMimeTypeSchema).min(1),
364
+ min: z4.number().nullable(),
365
+ max: z4.number().nullable()
518
366
  });
519
367
  var entryValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
520
- inputType: z6.literal(ValueInputTypeSchema.Enum.entry),
521
- ofCollections: z6.array(uuidSchema),
522
- min: z6.number().nullable(),
523
- max: z6.number().nullable()
368
+ inputType: z4.literal(ValueInputTypeSchema.Enum.entry),
369
+ ofCollections: z4.array(uuidSchema),
370
+ min: z4.number().nullable(),
371
+ max: z4.number().nullable()
524
372
  });
525
- var valueDefinitionSchema = z6.union([
373
+ var valueDefinitionSchema = z4.union([
526
374
  stringValueDefinitionSchema,
527
375
  numberValueDefinitionSchema,
528
376
  rangeValueDefinitionSchema,
@@ -531,65 +379,65 @@ var valueDefinitionSchema = z6.union([
531
379
  entryValueDefinitionSchema
532
380
  // sharedValueDefinitionSchema,
533
381
  ]);
534
- var valueContentReferenceBase = z6.object({
382
+ var valueContentReferenceBase = z4.object({
535
383
  id: uuidSchema
536
384
  });
537
385
  var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
538
386
  language: supportedLanguageSchema
539
387
  });
540
388
  var valueContentReferenceToAssetSchema = valueContentReferenceWithLanguageBase.extend({
541
- objectType: z6.literal(objectTypeSchema.Enum.asset)
389
+ objectType: z4.literal(objectTypeSchema.Enum.asset)
542
390
  });
543
391
  var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
544
- objectType: z6.literal(objectTypeSchema.Enum.collection)
392
+ objectType: z4.literal(objectTypeSchema.Enum.collection)
545
393
  });
546
394
  var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
547
- objectType: z6.literal(objectTypeSchema.Enum.entry)
395
+ objectType: z4.literal(objectTypeSchema.Enum.entry)
548
396
  });
549
- var valueContentReferenceSchema = z6.union([
397
+ var valueContentReferenceSchema = z4.union([
550
398
  valueContentReferenceToAssetSchema,
551
399
  valueContentReferenceToCollectionSchema,
552
400
  valueContentReferenceToEntrySchema
553
401
  // valueContentReferenceToSharedValueSchema,
554
402
  ]);
555
- var resolvedValueContentReferenceSchema = z6.union([
403
+ var resolvedValueContentReferenceSchema = z4.union([
556
404
  assetSchema,
557
- z6.lazy(() => entrySchema)
405
+ z4.lazy(() => entrySchema)
558
406
  // Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types
559
407
  // resolvedValueContentReferenceToSharedValueSchema,
560
408
  ]);
561
- var directValueBaseSchema = z6.object({
562
- objectType: z6.literal(objectTypeSchema.Enum.value).readonly(),
409
+ var directValueBaseSchema = z4.object({
410
+ objectType: z4.literal(objectTypeSchema.Enum.value).readonly(),
563
411
  definitionId: uuidSchema.readonly()
564
412
  });
565
413
  var directStringValueSchema = directValueBaseSchema.extend({
566
- valueType: z6.literal(ValueTypeSchema.Enum.string).readonly(),
414
+ valueType: z4.literal(ValueTypeSchema.Enum.string).readonly(),
567
415
  content: translatableStringSchema
568
416
  });
569
417
  var directNumberValueSchema = directValueBaseSchema.extend({
570
- valueType: z6.literal(ValueTypeSchema.Enum.number).readonly(),
418
+ valueType: z4.literal(ValueTypeSchema.Enum.number).readonly(),
571
419
  content: translatableNumberSchema
572
420
  });
573
421
  var directBooleanValueSchema = directValueBaseSchema.extend({
574
- valueType: z6.literal(ValueTypeSchema.Enum.boolean).readonly(),
422
+ valueType: z4.literal(ValueTypeSchema.Enum.boolean).readonly(),
575
423
  content: translatableBooleanSchema
576
424
  });
577
- var directValueSchema = z6.union([
425
+ var directValueSchema = z4.union([
578
426
  directStringValueSchema,
579
427
  directNumberValueSchema,
580
428
  directBooleanValueSchema
581
429
  ]);
582
- var referencedValueSchema = z6.object({
583
- objectType: z6.literal(objectTypeSchema.Enum.value).readonly(),
430
+ var referencedValueSchema = z4.object({
431
+ objectType: z4.literal(objectTypeSchema.Enum.value).readonly(),
584
432
  definitionId: uuidSchema.readonly(),
585
- valueType: z6.literal(ValueTypeSchema.Enum.reference).readonly(),
433
+ valueType: z4.literal(ValueTypeSchema.Enum.reference).readonly(),
586
434
  content: translatableArrayOf(valueContentReferenceSchema)
587
435
  });
588
- var valueSchema = z6.union([directValueSchema, referencedValueSchema]);
436
+ var valueSchema = z4.union([directValueSchema, referencedValueSchema]);
589
437
  var resolvedReferencedValueSchema = referencedValueSchema.extend({
590
438
  content: translatableArrayOf(resolvedValueContentReferenceSchema)
591
439
  });
592
- var resolvedValueSchema = z6.union([
440
+ var resolvedValueSchema = z4.union([
593
441
  directValueSchema,
594
442
  resolvedReferencedValueSchema
595
443
  ]);
@@ -611,10 +459,10 @@ function getValueContentSchemaFromDefinition(definition) {
611
459
  }
612
460
  }
613
461
  function getBooleanValueContentSchema(definition) {
614
- return z6.boolean();
462
+ return z4.boolean();
615
463
  }
616
464
  function getNumberValueContentSchema(definition) {
617
- let schema = z6.number();
465
+ let schema = z4.number();
618
466
  if (definition.min) {
619
467
  schema = schema.min(definition.min);
620
468
  }
@@ -627,7 +475,7 @@ function getNumberValueContentSchema(definition) {
627
475
  return schema;
628
476
  }
629
477
  function getStringValueContentSchema(definition) {
630
- let schema = z6.string().trim();
478
+ let schema = z4.string().trim();
631
479
  if ("min" in definition && definition.min) {
632
480
  schema = schema.min(definition.min);
633
481
  }
@@ -666,12 +514,12 @@ function getReferenceValueContentSchema(definition) {
666
514
  switch (definition.inputType) {
667
515
  case ValueInputTypeSchema.Enum.asset:
668
516
  {
669
- schema = z6.array(valueContentReferenceToAssetSchema);
517
+ schema = z4.array(valueContentReferenceToAssetSchema);
670
518
  }
671
519
  break;
672
520
  case ValueInputTypeSchema.Enum.entry:
673
521
  {
674
- schema = z6.array(valueContentReferenceToEntrySchema);
522
+ schema = z4.array(valueContentReferenceToEntrySchema);
675
523
  }
676
524
  break;
677
525
  }
@@ -689,11 +537,11 @@ function getReferenceValueContentSchema(definition) {
689
537
 
690
538
  // src/schema/entrySchema.ts
691
539
  var entryFileSchema = baseFileSchema.extend({
692
- objectType: z7.literal(objectTypeSchema.Enum.entry).readonly(),
693
- values: z7.array(valueSchema)
540
+ objectType: z5.literal(objectTypeSchema.Enum.entry).readonly(),
541
+ values: z5.array(valueSchema)
694
542
  });
695
543
  var entrySchema = entryFileSchema.extend({
696
- values: z7.array(z7.lazy(() => resolvedValueSchema))
544
+ values: z5.array(z5.lazy(() => resolvedValueSchema))
697
545
  });
698
546
  var entryExportSchema = entrySchema.extend({});
699
547
  var createEntrySchema = entryFileSchema.omit({
@@ -704,9 +552,9 @@ var createEntrySchema = entryFileSchema.omit({
704
552
  }).extend({
705
553
  projectId: uuidSchema.readonly(),
706
554
  collectionId: uuidSchema.readonly(),
707
- values: z7.array(valueSchema)
555
+ values: z5.array(valueSchema)
708
556
  });
709
- var readEntrySchema = z7.object({
557
+ var readEntrySchema = z5.object({
710
558
  id: uuidSchema.readonly(),
711
559
  projectId: uuidSchema.readonly(),
712
560
  collectionId: uuidSchema.readonly()
@@ -720,29 +568,29 @@ var updateEntrySchema = entrySchema.omit({
720
568
  collectionId: uuidSchema.readonly()
721
569
  });
722
570
  var deleteEntrySchema = readEntrySchema.extend({});
723
- var countEntriesSchema = z7.object({
571
+ var countEntriesSchema = z5.object({
724
572
  projectId: uuidSchema.readonly(),
725
573
  collectionId: uuidSchema.readonly()
726
574
  });
727
575
 
728
576
  // src/schema/collectionSchema.ts
729
577
  var collectionFileSchema = baseFileSchema.extend({
730
- objectType: z8.literal(objectTypeSchema.Enum.collection).readonly(),
731
- name: z8.object({
578
+ objectType: z6.literal(objectTypeSchema.Enum.collection).readonly(),
579
+ name: z6.object({
732
580
  singular: translatableStringSchema,
733
581
  plural: translatableStringSchema
734
582
  }),
735
- slug: z8.object({
736
- singular: z8.string(),
737
- plural: z8.string()
583
+ slug: z6.object({
584
+ singular: z6.string(),
585
+ plural: z6.string()
738
586
  }),
739
587
  description: translatableStringSchema,
740
588
  icon: supportedIconSchema,
741
- valueDefinitions: z8.array(valueDefinitionSchema)
589
+ valueDefinitions: z6.array(valueDefinitionSchema)
742
590
  });
743
591
  var collectionSchema = collectionFileSchema.extend({});
744
592
  var collectionExportSchema = collectionSchema.extend({
745
- entries: z8.array(entryExportSchema)
593
+ entries: z6.array(entryExportSchema)
746
594
  });
747
595
  var createCollectionSchema = collectionSchema.omit({
748
596
  id: true,
@@ -752,7 +600,7 @@ var createCollectionSchema = collectionSchema.omit({
752
600
  }).extend({
753
601
  projectId: uuidSchema.readonly()
754
602
  });
755
- var readCollectionSchema = z8.object({
603
+ var readCollectionSchema = z6.object({
756
604
  id: uuidSchema.readonly(),
757
605
  projectId: uuidSchema.readonly()
758
606
  });
@@ -767,19 +615,149 @@ var updateCollectionSchema = collectionFileSchema.pick({
767
615
  projectId: uuidSchema.readonly()
768
616
  });
769
617
  var deleteCollectionSchema = readCollectionSchema.extend({});
770
- var countCollectionsSchema = z8.object({
618
+ var countCollectionsSchema = z6.object({
771
619
  projectId: uuidSchema.readonly()
772
620
  });
773
621
 
622
+ // src/schema/coreSchema.ts
623
+ import { z as z7 } from "zod";
624
+ var elekIoCoreOptionsSchema = z7.object({
625
+ /**
626
+ * The environment elek.io Core is currently running in
627
+ */
628
+ environment: environmentSchema,
629
+ /**
630
+ * The current version of elek.io Core
631
+ */
632
+ version: versionSchema,
633
+ file: z7.object({
634
+ json: z7.object({
635
+ /**
636
+ * If set, adds indentation with spaces (number) or escape character (string)
637
+ * and line break characters to saved JSON files on disk, to make them easier to read.
638
+ * Defaults to 2 spaces of indentation.
639
+ */
640
+ indentation: z7.union([z7.number(), z7.string()])
641
+ })
642
+ })
643
+ });
644
+ var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
645
+ version: true
646
+ }).partial({
647
+ environment: true,
648
+ file: true
649
+ }).optional();
650
+
651
+ // src/schema/gitSchema.ts
652
+ import { z as z8 } from "zod";
653
+ var gitRepositoryPathSchema = z8.string();
654
+ var gitSignatureSchema = z8.object({
655
+ name: z8.string(),
656
+ email: z8.string()
657
+ });
658
+ var gitCommitSchema = z8.object({
659
+ /**
660
+ * SHA-1 hash of the commit
661
+ */
662
+ hash: z8.string(),
663
+ message: z8.string(),
664
+ author: gitSignatureSchema,
665
+ timestamp: z8.number(),
666
+ tag: z8.string().nullable()
667
+ });
668
+ var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
669
+ GitCommitIconNative2["INIT"] = ":tada:";
670
+ GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
671
+ GitCommitIconNative2["UPDATE"] = ":wrench:";
672
+ GitCommitIconNative2["DELETE"] = ":fire:";
673
+ return GitCommitIconNative2;
674
+ })(GitCommitIconNative || {});
675
+ var gitCommitIconSchema = z8.nativeEnum(GitCommitIconNative);
676
+ var gitInitOptionsSchema = z8.object({
677
+ /**
678
+ * 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).
679
+ */
680
+ initialBranch: z8.string()
681
+ });
682
+ var gitCloneOptionsSchema = z8.object({
683
+ /**
684
+ * 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.
685
+ */
686
+ depth: z8.number(),
687
+ /**
688
+ * 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.
689
+ */
690
+ singleBranch: z8.boolean(),
691
+ /**
692
+ * 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.
693
+ */
694
+ branch: z8.string()
695
+ });
696
+ var gitSwitchOptionsSchema = z8.object({
697
+ /**
698
+ * If true, creates a new local branch and then switches to it
699
+ *
700
+ * @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
701
+ */
702
+ isNew: z8.boolean().optional()
703
+ });
704
+ var gitLogOptionsSchema = z8.object({
705
+ /**
706
+ * Limit the result to given number of commits
707
+ */
708
+ limit: z8.number().optional(),
709
+ /**
710
+ * Only list commits that are between given SHAs or tag names
711
+ *
712
+ * Note that the commits of from and to are not included in the result
713
+ */
714
+ between: z8.object({
715
+ /**
716
+ * From the oldest commit
717
+ */
718
+ from: z8.string(),
719
+ /**
720
+ * To the newest commit
721
+ *
722
+ * Defaults to the current HEAD
723
+ */
724
+ to: z8.string().optional()
725
+ })
726
+ });
727
+
728
+ // src/schema/gitTagSchema.ts
729
+ import { z as z9 } from "zod";
730
+ var gitTagSchema = z9.object({
731
+ id: uuidSchema,
732
+ message: z9.string(),
733
+ author: gitSignatureSchema,
734
+ timestamp: z9.number()
735
+ });
736
+ var createGitTagSchema = gitTagSchema.pick({
737
+ message: true
738
+ }).extend({
739
+ path: gitRepositoryPathSchema,
740
+ hash: gitCommitSchema.shape.hash.optional()
741
+ });
742
+ var readGitTagSchema = z9.object({
743
+ path: gitRepositoryPathSchema,
744
+ id: uuidSchema.readonly()
745
+ });
746
+ var deleteGitTagSchema = readGitTagSchema.extend({});
747
+ var countGitTagsSchema = z9.object({
748
+ path: gitRepositoryPathSchema
749
+ });
750
+
774
751
  // src/schema/projectSchema.ts
775
- var projectStatusSchema = z9.enum(["foo", "bar", "todo"]);
776
- var projectSettingsSchema = z9.object({
777
- language: z9.object({
752
+ import { z as z10 } from "zod";
753
+ var projectStatusSchema = z10.enum(["foo", "bar", "todo"]);
754
+ var projectSettingsSchema = z10.object({
755
+ language: z10.object({
778
756
  default: supportedLanguageSchema,
779
- supported: z9.array(supportedLanguageSchema)
757
+ supported: z10.array(supportedLanguageSchema)
780
758
  })
781
759
  });
782
- var projectFolderSchema = z9.enum([
760
+ var projectFolderSchema = z10.enum([
783
761
  "assets",
784
762
  "collections",
785
763
  "shared-values",
@@ -789,18 +767,18 @@ var projectFolderSchema = z9.enum([
789
767
  // 'theme',
790
768
  ]);
791
769
  var projectFileSchema = baseFileSchema.extend({
792
- objectType: z9.literal(objectTypeSchema.Enum.project).readonly(),
770
+ objectType: z10.literal(objectTypeSchema.Enum.project).readonly(),
793
771
  coreVersion: versionSchema,
794
- name: z9.string().trim().min(1, "shared.projectNameRequired"),
795
- description: z9.string().trim().min(1, "shared.projectDescriptionRequired"),
772
+ name: z10.string().trim().min(1, "shared.projectNameRequired"),
773
+ description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
796
774
  version: versionSchema,
797
775
  status: projectStatusSchema,
798
776
  settings: projectSettingsSchema
799
777
  });
800
778
  var projectSchema = projectFileSchema.extend({});
801
779
  var projectExportSchema = projectSchema.extend({
802
- assets: z9.array(assetExportSchema),
803
- collections: z9.array(collectionExportSchema)
780
+ assets: z10.array(assetExportSchema),
781
+ collections: z10.array(collectionExportSchema)
804
782
  });
805
783
  var createProjectSchema = projectSchema.pick({
806
784
  name: true,
@@ -810,7 +788,7 @@ var createProjectSchema = projectSchema.pick({
810
788
  description: true,
811
789
  settings: true
812
790
  });
813
- var readProjectSchema = z9.object({
791
+ var readProjectSchema = z10.object({
814
792
  id: uuidSchema.readonly()
815
793
  });
816
794
  var updateProjectSchema = projectSchema.pick({
@@ -823,11 +801,11 @@ var updateProjectSchema = projectSchema.pick({
823
801
  description: true,
824
802
  settings: true
825
803
  });
826
- var upgradeProjectSchema = z9.object({
804
+ var upgradeProjectSchema = z10.object({
827
805
  id: uuidSchema.readonly()
828
806
  });
829
807
  var deleteProjectSchema = readProjectSchema.extend({});
830
- var projectUpgradeSchema = z9.object({
808
+ var projectUpgradeSchema = z10.object({
831
809
  /**
832
810
  * The Core version the Project will be upgraded to
833
811
  */
@@ -835,85 +813,167 @@ var projectUpgradeSchema = z9.object({
835
813
  /**
836
814
  * Function that will be executed in the process of upgrading a Project
837
815
  */
838
- run: z9.function().args(projectFileSchema).returns(z9.promise(z9.void()))
816
+ run: z10.function().args(projectFileSchema).returns(z10.promise(z10.void()))
839
817
  });
840
- var cloneProjectSchema = z9.object({
841
- url: z9.string()
818
+ var cloneProjectSchema = z10.object({
819
+ url: z10.string()
842
820
  });
843
- var listBranchesProjectSchema = z9.object({
821
+ var listBranchesProjectSchema = z10.object({
844
822
  id: uuidSchema.readonly()
845
823
  });
846
- var currentBranchProjectSchema = z9.object({
824
+ var currentBranchProjectSchema = z10.object({
847
825
  id: uuidSchema.readonly()
848
826
  });
849
- var switchBranchProjectSchema = z9.object({
827
+ var switchBranchProjectSchema = z10.object({
850
828
  id: uuidSchema.readonly(),
851
- branch: z9.string(),
829
+ branch: z10.string(),
852
830
  options: gitSwitchOptionsSchema.optional()
853
831
  });
854
- var getRemoteOriginUrlProjectSchema = z9.object({
832
+ var getRemoteOriginUrlProjectSchema = z10.object({
855
833
  id: uuidSchema.readonly()
856
834
  });
857
- var setRemoteOriginUrlProjectSchema = z9.object({
835
+ var setRemoteOriginUrlProjectSchema = z10.object({
858
836
  id: uuidSchema.readonly(),
859
- url: z9.string()
837
+ url: z10.string()
860
838
  });
861
- var getChangesProjectSchema = z9.object({
839
+ var getChangesProjectSchema = z10.object({
862
840
  id: uuidSchema.readonly()
863
841
  });
864
- var synchronizeProjectSchema = z9.object({
842
+ var synchronizeProjectSchema = z10.object({
865
843
  id: uuidSchema.readonly()
866
844
  });
867
- var searchProjectSchema = z9.object({
845
+ var searchProjectSchema = z10.object({
868
846
  id: uuidSchema.readonly(),
869
- query: z9.string(),
847
+ query: z10.string(),
870
848
  language: supportedLanguageSchema,
871
- type: z9.array(objectTypeSchema).optional()
849
+ type: z10.array(objectTypeSchema).optional()
872
850
  });
873
851
 
874
- // src/util/index.ts
875
- var Slugify = slugify.default || slugify;
876
- function uuid() {
877
- return generateUuid();
878
- }
879
- function currentTimestamp() {
880
- return Math.floor(Date.now() / 1e3);
881
- }
882
- function slug(string) {
883
- return Slugify(string, {
884
- replacement: "-",
885
- // replace spaces with replacement character, defaults to `-`
886
- remove: void 0,
887
- // remove characters that match regex, defaults to `undefined`
888
- lower: true,
889
- // convert to lower case, defaults to `false`
890
- strict: true
891
- // strip special characters except replacement, defaults to `false`
892
- });
893
- }
894
- var workingDirectory = Path.join(Os.homedir(), "elek.io");
895
- var pathTo = {
896
- tmp: Path.join(workingDirectory, "tmp"),
897
- userFile: Path.join(workingDirectory, "user.json"),
898
- // logs: Path.join(workingDirectory, 'logs'),
899
- projects: Path.join(workingDirectory, "projects"),
900
- project: (projectId) => {
901
- return Path.join(pathTo.projects, projectId);
902
- },
903
- projectFile: (projectId) => {
904
- return Path.join(pathTo.project(projectId), "project.json");
905
- },
906
- // projectLogs: (projectId: string): string => {
907
- // return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.logs);
908
- // },
909
- // public: (projectId: string): string => {
910
- // return Path.join(pathTo.project(projectId), 'public');
911
- // },
912
- lfs: (projectId) => {
913
- return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
914
- },
915
- collections: (projectId) => {
916
- return Path.join(
852
+ // src/schema/serviceSchema.ts
853
+ import { z as z11 } from "zod";
854
+ var serviceTypeSchema = z11.enum([
855
+ "Git",
856
+ "GitTag",
857
+ "User",
858
+ "Project",
859
+ "Asset",
860
+ "JsonFile",
861
+ "Search",
862
+ "Collection",
863
+ "Entry",
864
+ "Value"
865
+ ]);
866
+ var listSchema = z11.object({
867
+ projectId: uuidSchema,
868
+ limit: z11.number().optional(),
869
+ offset: z11.number().optional()
870
+ });
871
+ var listCollectionsSchema = listSchema;
872
+ var listEntriesSchema = listSchema.extend({
873
+ collectionId: uuidSchema
874
+ });
875
+ var listAssetsSchema = listSchema;
876
+ var listProjectsSchema = listSchema.omit({
877
+ projectId: true
878
+ });
879
+ var listGitTagsSchema = z11.object({
880
+ path: gitRepositoryPathSchema
881
+ });
882
+
883
+ // src/schema/userSchema.ts
884
+ import z12 from "zod";
885
+ var UserTypeSchema = z12.enum(["local", "cloud"]);
886
+ var baseUserSchema = gitSignatureSchema.extend({
887
+ userType: UserTypeSchema,
888
+ language: supportedLanguageSchema
889
+ });
890
+ var localUserSchema = baseUserSchema.extend({
891
+ userType: z12.literal(UserTypeSchema.Enum.local)
892
+ });
893
+ var cloudUserSchema = baseUserSchema.extend({
894
+ userType: z12.literal(UserTypeSchema.Enum.cloud),
895
+ id: uuidSchema
896
+ });
897
+ var userFileSchema = z12.union([localUserSchema, cloudUserSchema]);
898
+ var userSchema = userFileSchema;
899
+ var setUserSchema = userSchema;
900
+
901
+ // src/error/GitError.ts
902
+ var GitError = class extends Error {
903
+ constructor(message) {
904
+ super(message);
905
+ this.name = "GitError";
906
+ }
907
+ };
908
+
909
+ // src/error/NoCurrentUserError.ts
910
+ var NoCurrentUserError = class extends Error {
911
+ constructor() {
912
+ super("Make sure to set a User via Core before using other methods");
913
+ this.name = "NoCurrentUserError";
914
+ }
915
+ };
916
+
917
+ // src/error/ProjectUpgradeError.ts
918
+ var ProjectUpgradeError = class extends Error {
919
+ constructor(message) {
920
+ super(message);
921
+ this.name = "ProjectUpgradeError";
922
+ }
923
+ };
924
+
925
+ // src/error/RequiredParameterMissingError.ts
926
+ var RequiredParameterMissingError = class extends Error {
927
+ constructor(parameter) {
928
+ super(`Missing required parameter "${parameter}"`);
929
+ this.name = "RequiredParameterMissingError";
930
+ }
931
+ };
932
+
933
+ // src/util/node.ts
934
+ var node_exports = {};
935
+ __export(node_exports, {
936
+ assignDefaultIfMissing: () => assignDefaultIfMissing,
937
+ files: () => files,
938
+ folders: () => folders,
939
+ fromPath: () => fromPath,
940
+ getDuplicates: () => getDuplicates,
941
+ getRelativePath: () => getRelativePath,
942
+ isNoError: () => isNoError,
943
+ notEmpty: () => notEmpty,
944
+ pathTo: () => pathTo,
945
+ returnResolved: () => returnResolved,
946
+ spawnChildProcess: () => spawnChildProcess,
947
+ workingDirectory: () => workingDirectory
948
+ });
949
+ import { spawn } from "child_process";
950
+ import Fs from "fs-extra";
951
+ import { filter, flatten, groupBy, uniq } from "lodash-es";
952
+ import Os from "os";
953
+ import Path from "path";
954
+ var workingDirectory = Path.join(Os.homedir(), "elek.io");
955
+ var pathTo = {
956
+ tmp: Path.join(workingDirectory, "tmp"),
957
+ userFile: Path.join(workingDirectory, "user.json"),
958
+ // logs: Path.join(workingDirectory, 'logs'),
959
+ projects: Path.join(workingDirectory, "projects"),
960
+ project: (projectId) => {
961
+ return Path.join(pathTo.projects, projectId);
962
+ },
963
+ projectFile: (projectId) => {
964
+ return Path.join(pathTo.project(projectId), "project.json");
965
+ },
966
+ // projectLogs: (projectId: string): string => {
967
+ // return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.logs);
968
+ // },
969
+ // public: (projectId: string): string => {
970
+ // return Path.join(pathTo.project(projectId), 'public');
971
+ // },
972
+ lfs: (projectId) => {
973
+ return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
974
+ },
975
+ collections: (projectId) => {
976
+ return Path.join(
917
977
  pathTo.project(projectId),
918
978
  projectFolderSchema.Enum.collections
919
979
  );
@@ -1155,248 +1215,82 @@ var AbstractCrudService = class {
1155
1215
  }
1156
1216
  };
1157
1217
 
1158
- // src/service/GitService.ts
1159
- import { GitProcess } from "dugite";
1160
- import { EOL as EOL2 } from "os";
1161
- import PQueue from "p-queue";
1162
-
1163
- // src/error/GitError.ts
1164
- var GitError = class extends Error {
1165
- constructor(message) {
1166
- super(message);
1167
- this.name = "GitError";
1168
- }
1169
- };
1170
-
1171
- // src/error/NoCurrentUserError.ts
1172
- var NoCurrentUserError = class extends Error {
1173
- constructor() {
1174
- super("Make sure to set a User via Core before using other methods");
1175
- this.name = "NoCurrentUserError";
1176
- }
1177
- };
1178
-
1179
- // src/service/GitTagService.ts
1180
- import { EOL } from "os";
1218
+ // src/service/AssetService.ts
1219
+ import Fs3 from "fs-extra";
1220
+ import IsSvg from "is-svg";
1181
1221
 
1182
- // src/schema/gitTagSchema.ts
1183
- import { z as z10 } from "zod";
1184
- var gitTagSchema = z10.object({
1185
- id: uuidSchema,
1186
- message: z10.string(),
1187
- author: gitSignatureSchema,
1188
- timestamp: z10.number()
1189
- });
1190
- var createGitTagSchema = gitTagSchema.pick({
1191
- message: true
1192
- }).extend({
1193
- path: gitRepositoryPathSchema,
1194
- hash: gitCommitSchema.shape.hash.optional()
1195
- });
1196
- var readGitTagSchema = z10.object({
1197
- path: gitRepositoryPathSchema,
1198
- id: uuidSchema.readonly()
1199
- });
1200
- var deleteGitTagSchema = readGitTagSchema.extend({});
1201
- var countGitTagsSchema = z10.object({
1202
- path: gitRepositoryPathSchema
1203
- });
1222
+ // src/util/shared.ts
1223
+ import slugify from "slugify";
1224
+ import { v4 as generateUuid } from "uuid";
1225
+ var Slugify = slugify.default || slugify;
1226
+ function uuid() {
1227
+ return generateUuid();
1228
+ }
1229
+ function currentTimestamp() {
1230
+ return Math.floor(Date.now() / 1e3);
1231
+ }
1232
+ function slug(string) {
1233
+ return Slugify(string, {
1234
+ replacement: "-",
1235
+ // replace spaces with replacement character, defaults to `-`
1236
+ remove: void 0,
1237
+ // remove characters that match regex, defaults to `undefined`
1238
+ lower: true,
1239
+ // convert to lower case, defaults to `false`
1240
+ strict: true
1241
+ // strip special characters except replacement, defaults to `false`
1242
+ });
1243
+ }
1204
1244
 
1205
- // src/service/GitTagService.ts
1206
- var GitTagService = class extends AbstractCrudService {
1207
- constructor(options, git) {
1208
- super(serviceTypeSchema.Enum.GitTag, options);
1209
- this.git = git;
1210
- }
1211
- /**
1212
- * Creates a new tag
1213
- *
1214
- * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---annotate
1215
- */
1216
- async create(props) {
1217
- createGitTagSchema.parse(props);
1218
- const id = uuid();
1219
- let args = ["tag", "--annotate", id];
1220
- if (props.hash) {
1221
- args = [...args, props.hash];
1222
- }
1223
- args = [...args, "-m", props.message];
1224
- await this.git(props.path, args);
1225
- const tag = await this.read({ path: props.path, id });
1226
- return tag;
1245
+ // src/service/JsonFileService.ts
1246
+ import Fs2 from "fs-extra";
1247
+ var JsonFileService = class extends AbstractCrudService {
1248
+ constructor(options) {
1249
+ super(serviceTypeSchema.Enum.JsonFile, options);
1250
+ this.cache = /* @__PURE__ */ new Map();
1227
1251
  }
1228
1252
  /**
1229
- * Returns a tag by ID
1253
+ * Creates a new file on disk. Fails if path already exists
1230
1254
  *
1231
- * Internally uses list() but only returns the tag with matching ID.
1255
+ * @param data Data to write into the file
1256
+ * @param path Path to write the file to
1257
+ * @param schema Schema of the file to validate against
1258
+ * @returns Validated content of the file from disk
1232
1259
  */
1233
- async read(props) {
1234
- readGitTagSchema.parse(props);
1235
- const tags = await this.list({ path: props.path });
1236
- const tag = tags.list.find((tag2) => {
1237
- return tag2.id === props.id;
1260
+ async create(data, path, schema) {
1261
+ const parsedData = schema.parse(data);
1262
+ const string = this.serialize(parsedData);
1263
+ await Fs2.writeFile(path, string, {
1264
+ flag: "wx",
1265
+ encoding: "utf8"
1238
1266
  });
1239
- if (!tag) {
1240
- throw new GitError(
1241
- `Provided tag with UUID "${props.id}" did not match any known tags`
1242
- );
1243
- }
1244
- return tag;
1267
+ this.cache.set(path, parsedData);
1268
+ return parsedData;
1245
1269
  }
1246
1270
  /**
1247
- * Updating a git tag is not supported.
1248
- * Please delete the old and create a new one
1271
+ * Reads the content of a file on disk. Fails if path does not exist
1249
1272
  *
1250
- * @see https://git-scm.com/docs/git-tag#_on_re_tagging
1273
+ * @param path Path to read the file from
1274
+ * @param schema Schema of the file to validate against
1275
+ * @returns Validated content of the file from disk
1251
1276
  */
1252
- async update() {
1253
- throw new Error(
1254
- "Updating a git tag is not supported. Please delete the old and create a new one"
1255
- );
1277
+ async read(path, schema) {
1278
+ if (this.cache.has(path)) {
1279
+ return this.cache.get(path);
1280
+ }
1281
+ const data = await Fs2.readFile(path, {
1282
+ flag: "r",
1283
+ encoding: "utf8"
1284
+ });
1285
+ const json = this.deserialize(data);
1286
+ const parsedData = schema.parse(json);
1287
+ this.cache.set(path, parsedData);
1288
+ return parsedData;
1256
1289
  }
1257
1290
  /**
1258
- * Deletes a tag
1291
+ * Overwrites an existing file on disk
1259
1292
  *
1260
- * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---delete
1261
- *
1262
- * @param path Path to the repository
1263
- * @param id UUID of the tag to delete
1264
- */
1265
- async delete(props) {
1266
- deleteGitTagSchema.parse(props);
1267
- const args = ["tag", "--delete", props.id];
1268
- await this.git(props.path, args);
1269
- }
1270
- /**
1271
- * Gets all local tags or filter them by pattern
1272
- *
1273
- * They are sorted by authordate of the commit, not the timestamp the tag is created.
1274
- * This ensures tags are sorted correctly in the timeline of their commits.
1275
- *
1276
- * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---list
1277
- */
1278
- async list(props) {
1279
- listGitTagsSchema.parse(props);
1280
- let args = ["tag", "--list"];
1281
- args = [
1282
- ...args,
1283
- "--sort=-*authordate",
1284
- "--format=%(refname:short)|%(subject)|%(*authorname)|%(*authoremail)|%(*authordate:unix)"
1285
- ];
1286
- const result = await this.git(props.path, args);
1287
- const noEmptyLinesArr = result.stdout.split(EOL).filter((line) => {
1288
- return line.trim() !== "";
1289
- });
1290
- const lineObjArr = noEmptyLinesArr.map((line) => {
1291
- const lineArray = line.split("|");
1292
- return {
1293
- id: lineArray[0],
1294
- message: lineArray[1],
1295
- author: {
1296
- name: lineArray[2],
1297
- email: lineArray[3]
1298
- },
1299
- timestamp: parseInt(lineArray[4])
1300
- };
1301
- });
1302
- const gitTags = lineObjArr.filter(this.isGitTag.bind(this));
1303
- return {
1304
- total: gitTags.length,
1305
- limit: 0,
1306
- offset: 0,
1307
- list: gitTags
1308
- };
1309
- }
1310
- /**
1311
- * Returns the total number of tags inside given repository
1312
- *
1313
- * Internally uses list(), so do not use count()
1314
- * in conjuncion with it to avoid multiple git calls.
1315
- *
1316
- * @param path Path to the repository
1317
- */
1318
- async count(props) {
1319
- countGitTagsSchema.parse(props);
1320
- const gitTags = await this.list({ path: props.path });
1321
- return gitTags.total;
1322
- }
1323
- /**
1324
- * Type guard for GitTag
1325
- *
1326
- * @param obj The object to check
1327
- */
1328
- isGitTag(obj) {
1329
- return gitTagSchema.safeParse(obj).success;
1330
- }
1331
- };
1332
-
1333
- // src/schema/userSchema.ts
1334
- import z11 from "zod";
1335
- var UserTypeSchema = z11.enum(["local", "cloud"]);
1336
- var baseUserSchema = gitSignatureSchema.extend({
1337
- userType: UserTypeSchema,
1338
- language: supportedLanguageSchema
1339
- });
1340
- var localUserSchema = baseUserSchema.extend({
1341
- userType: z11.literal(UserTypeSchema.Enum.local)
1342
- });
1343
- var cloudUserSchema = baseUserSchema.extend({
1344
- userType: z11.literal(UserTypeSchema.Enum.cloud),
1345
- id: uuidSchema
1346
- });
1347
- var userFileSchema = z11.union([localUserSchema, cloudUserSchema]);
1348
- var userSchema = userFileSchema;
1349
- var setUserSchema = userSchema;
1350
-
1351
- // src/service/JsonFileService.ts
1352
- import Fs2 from "fs-extra";
1353
- var JsonFileService = class extends AbstractCrudService {
1354
- constructor(options) {
1355
- super(serviceTypeSchema.Enum.JsonFile, options);
1356
- this.cache = /* @__PURE__ */ new Map();
1357
- }
1358
- /**
1359
- * Creates a new file on disk. Fails if path already exists
1360
- *
1361
- * @param data Data to write into the file
1362
- * @param path Path to write the file to
1363
- * @param schema Schema of the file to validate against
1364
- * @returns Validated content of the file from disk
1365
- */
1366
- async create(data, path, schema) {
1367
- const parsedData = schema.parse(data);
1368
- const string = this.serialize(parsedData);
1369
- await Fs2.writeFile(path, string, {
1370
- flag: "wx",
1371
- encoding: "utf8"
1372
- });
1373
- this.cache.set(path, parsedData);
1374
- return parsedData;
1375
- }
1376
- /**
1377
- * Reads the content of a file on disk. Fails if path does not exist
1378
- *
1379
- * @param path Path to read the file from
1380
- * @param schema Schema of the file to validate against
1381
- * @returns Validated content of the file from disk
1382
- */
1383
- async read(path, schema) {
1384
- if (this.cache.has(path)) {
1385
- return this.cache.get(path);
1386
- }
1387
- const data = await Fs2.readFile(path, {
1388
- flag: "r",
1389
- encoding: "utf8"
1390
- });
1391
- const json = this.deserialize(data);
1392
- const parsedData = schema.parse(json);
1393
- this.cache.set(path, parsedData);
1394
- return parsedData;
1395
- }
1396
- /**
1397
- * Overwrites an existing file on disk
1398
- *
1399
- * @todo Check how to error out if the file does not exist already
1293
+ * @todo Check how to error out if the file does not exist already
1400
1294
  *
1401
1295
  * @param data Data to write into the file
1402
1296
  * @param path Path to the file to overwrite
@@ -1421,52 +1315,411 @@ var JsonFileService = class extends AbstractCrudService {
1421
1315
  }
1422
1316
  };
1423
1317
 
1424
- // src/service/UserService.ts
1425
- var UserService = class {
1426
- constructor(jsonFileService) {
1318
+ // src/service/AssetService.ts
1319
+ var AssetService = class extends AbstractCrudService {
1320
+ constructor(options, jsonFileService, gitService) {
1321
+ super(serviceTypeSchema.Enum.Asset, options);
1427
1322
  this.jsonFileService = jsonFileService;
1323
+ this.gitService = gitService;
1428
1324
  }
1429
1325
  /**
1430
- * Returns the User currently working with Core
1326
+ * Creates a new Asset
1431
1327
  */
1432
- async get() {
1328
+ async create(props) {
1329
+ createAssetSchema.parse(props);
1330
+ const id = uuid();
1331
+ const projectPath = pathTo.project(props.projectId);
1332
+ const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
1333
+ const size = await this.getAssetSize(props.filePath);
1334
+ const assetPath = pathTo.asset(
1335
+ props.projectId,
1336
+ id,
1337
+ props.language,
1338
+ fileType.extension
1339
+ );
1340
+ const assetFilePath = pathTo.assetFile(props.projectId, id, props.language);
1341
+ const assetFile = {
1342
+ ...props,
1343
+ objectType: "asset",
1344
+ id,
1345
+ created: currentTimestamp(),
1346
+ updated: null,
1347
+ extension: fileType.extension,
1348
+ mimeType: fileType.mimeType,
1349
+ size
1350
+ };
1433
1351
  try {
1434
- return await this.jsonFileService.read(
1435
- pathTo.userFile,
1436
- userFileSchema
1352
+ await Fs3.copyFile(props.filePath, assetPath);
1353
+ await this.jsonFileService.create(
1354
+ assetFile,
1355
+ assetFilePath,
1356
+ assetFileSchema
1437
1357
  );
1438
1358
  } catch (error) {
1439
- return void 0;
1359
+ await this.delete({ ...assetFile, projectId: props.projectId });
1360
+ throw error;
1440
1361
  }
1362
+ await this.gitService.add(projectPath, [assetFilePath, assetPath]);
1363
+ await this.gitService.commit(projectPath, this.gitMessage.create);
1364
+ return this.toAsset(props.projectId, assetFile);
1441
1365
  }
1442
1366
  /**
1443
- * Sets the User currently working with Core
1367
+ * Returns an Asset by ID and language
1368
+ */
1369
+ async read(props) {
1370
+ readAssetSchema.parse(props);
1371
+ const assetFile = await this.jsonFileService.read(
1372
+ pathTo.assetFile(props.projectId, props.id, props.language),
1373
+ assetFileSchema
1374
+ );
1375
+ return this.toAsset(props.projectId, assetFile);
1376
+ }
1377
+ /**
1378
+ * Updates given Asset
1444
1379
  *
1445
- * By doing so all git operations are done with the signature of this User
1380
+ * Use the optional "newFilePath" prop to update the Asset itself
1446
1381
  */
1447
- async set(props) {
1448
- setUserSchema.parse(props);
1449
- const userFilePath = pathTo.userFile;
1450
- const userFile = {
1451
- ...props
1382
+ async update(props) {
1383
+ updateAssetSchema.parse(props);
1384
+ const projectPath = pathTo.project(props.projectId);
1385
+ const assetFilePath = pathTo.assetFile(
1386
+ props.projectId,
1387
+ props.id,
1388
+ props.language
1389
+ );
1390
+ const prevAssetFile = await this.read(props);
1391
+ const assetFile = {
1392
+ ...prevAssetFile,
1393
+ ...props,
1394
+ updated: currentTimestamp()
1452
1395
  };
1453
- if (userFile.userType === UserTypeSchema.Enum.cloud) {
1396
+ if (props.newFilePath) {
1397
+ const fileType = await this.getSupportedFileTypeOrThrow(
1398
+ props.newFilePath
1399
+ );
1400
+ const size = await this.getAssetSize(props.newFilePath);
1401
+ const prevAssetPath = pathTo.asset(
1402
+ props.projectId,
1403
+ props.id,
1404
+ props.language,
1405
+ prevAssetFile.extension
1406
+ );
1407
+ const assetPath = pathTo.asset(
1408
+ props.projectId,
1409
+ props.id,
1410
+ props.language,
1411
+ fileType.extension
1412
+ );
1413
+ await Fs3.remove(prevAssetPath);
1414
+ await Fs3.copyFile(props.newFilePath, assetPath);
1415
+ assetFile.extension = fileType.extension;
1416
+ assetFile.mimeType = fileType.mimeType;
1417
+ assetFile.size = size;
1454
1418
  }
1455
- await this.jsonFileService.update(userFile, userFilePath, userFileSchema);
1456
- return userFile;
1419
+ await this.jsonFileService.update(
1420
+ assetFile,
1421
+ assetFilePath,
1422
+ assetFileSchema
1423
+ );
1424
+ await this.gitService.add(projectPath, [assetFilePath]);
1425
+ await this.gitService.commit(projectPath, this.gitMessage.update);
1426
+ return this.toAsset(props.projectId, assetFile);
1457
1427
  }
1458
- };
1459
-
1460
- // src/service/GitService.ts
1461
- var GitService2 = class {
1462
- constructor(options, userService) {
1463
- this.branches = {
1464
- /**
1465
- * List branches
1466
- *
1467
- * @see https://www.git-scm.com/docs/git-branch
1468
- *
1469
- * @param path Path to the repository
1428
+ /**
1429
+ * Deletes given Asset
1430
+ */
1431
+ async delete(props) {
1432
+ deleteAssetSchema.parse(props);
1433
+ const projectPath = pathTo.project(props.projectId);
1434
+ const assetFilePath = pathTo.assetFile(
1435
+ props.projectId,
1436
+ props.id,
1437
+ props.language
1438
+ );
1439
+ const assetPath = pathTo.asset(
1440
+ props.projectId,
1441
+ props.id,
1442
+ props.language,
1443
+ props.extension
1444
+ );
1445
+ await Fs3.remove(assetPath);
1446
+ await Fs3.remove(assetFilePath);
1447
+ await this.gitService.add(projectPath, [assetFilePath, assetPath]);
1448
+ await this.gitService.commit(projectPath, this.gitMessage.delete);
1449
+ }
1450
+ async list(props) {
1451
+ listAssetsSchema.parse(props);
1452
+ const offset = props.offset || 0;
1453
+ const limit = props.limit || 15;
1454
+ const assetReferences = await this.listReferences(
1455
+ objectTypeSchema.Enum.asset,
1456
+ props.projectId
1457
+ );
1458
+ const partialAssetReferences = assetReferences.slice(offset, limit);
1459
+ const assets = await returnResolved(
1460
+ partialAssetReferences.map((assetReference) => {
1461
+ if (!assetReference.language) {
1462
+ throw new RequiredParameterMissingError("language");
1463
+ }
1464
+ return this.read({
1465
+ projectId: props.projectId,
1466
+ id: assetReference.id,
1467
+ language: assetReference.language
1468
+ });
1469
+ })
1470
+ );
1471
+ return {
1472
+ total: assetReferences.length,
1473
+ limit,
1474
+ offset,
1475
+ list: assets
1476
+ };
1477
+ }
1478
+ async count(props) {
1479
+ countAssetsSchema.parse(props);
1480
+ const count = (await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)).length;
1481
+ return count;
1482
+ }
1483
+ /**
1484
+ * Checks if given object is of type Asset
1485
+ */
1486
+ isAsset(obj) {
1487
+ return assetSchema.safeParse(obj).success;
1488
+ }
1489
+ /**
1490
+ * Returns the size of an Asset in bytes
1491
+ *
1492
+ * @param path Path of the Asset to get the size from
1493
+ */
1494
+ async getAssetSize(path) {
1495
+ return (await Fs3.stat(path)).size;
1496
+ }
1497
+ /**
1498
+ * Creates an Asset from given AssetFile
1499
+ *
1500
+ * @param projectId The project's ID
1501
+ * @param assetFile The AssetFile to convert
1502
+ */
1503
+ async toAsset(projectId, assetFile) {
1504
+ const assetPath = pathTo.asset(
1505
+ projectId,
1506
+ assetFile.id,
1507
+ assetFile.language,
1508
+ assetFile.extension
1509
+ );
1510
+ const asset = {
1511
+ ...assetFile,
1512
+ absolutePath: assetPath
1513
+ };
1514
+ return asset;
1515
+ }
1516
+ /**
1517
+ * Returns the found and supported extension as well as mime type,
1518
+ * otherwise throws an error
1519
+ *
1520
+ * @param filePath Path to the file to check
1521
+ */
1522
+ async getSupportedFileTypeOrThrow(filePath) {
1523
+ const fileSize = (await Fs3.stat(filePath)).size;
1524
+ if (fileSize / 1e3 <= 500) {
1525
+ const fileBuffer = await Fs3.readFile(filePath);
1526
+ if (IsSvg(fileBuffer.toString()) === true) {
1527
+ return {
1528
+ extension: supportedAssetExtensionSchema.Enum.svg,
1529
+ mimeType: supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
1530
+ };
1531
+ }
1532
+ }
1533
+ const { fileTypeFromFile } = await import("file-type");
1534
+ const fileType = await fileTypeFromFile(filePath);
1535
+ const result = supportedAssetTypeSchema.parse({
1536
+ extension: fileType?.ext,
1537
+ mimeType: fileType?.mime
1538
+ });
1539
+ return result;
1540
+ }
1541
+ };
1542
+
1543
+ // src/service/CollectionService.ts
1544
+ import Fs4 from "fs-extra";
1545
+
1546
+ // src/service/GitService.ts
1547
+ import { GitProcess } from "dugite";
1548
+ import { EOL as EOL2 } from "os";
1549
+ import PQueue from "p-queue";
1550
+
1551
+ // src/service/GitTagService.ts
1552
+ import { EOL } from "os";
1553
+ var GitTagService = class extends AbstractCrudService {
1554
+ constructor(options, git) {
1555
+ super(serviceTypeSchema.Enum.GitTag, options);
1556
+ this.git = git;
1557
+ }
1558
+ /**
1559
+ * Creates a new tag
1560
+ *
1561
+ * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---annotate
1562
+ */
1563
+ async create(props) {
1564
+ createGitTagSchema.parse(props);
1565
+ const id = uuid();
1566
+ let args = ["tag", "--annotate", id];
1567
+ if (props.hash) {
1568
+ args = [...args, props.hash];
1569
+ }
1570
+ args = [...args, "-m", props.message];
1571
+ await this.git(props.path, args);
1572
+ const tag = await this.read({ path: props.path, id });
1573
+ return tag;
1574
+ }
1575
+ /**
1576
+ * Returns a tag by ID
1577
+ *
1578
+ * Internally uses list() but only returns the tag with matching ID.
1579
+ */
1580
+ async read(props) {
1581
+ readGitTagSchema.parse(props);
1582
+ const tags = await this.list({ path: props.path });
1583
+ const tag = tags.list.find((tag2) => {
1584
+ return tag2.id === props.id;
1585
+ });
1586
+ if (!tag) {
1587
+ throw new GitError(
1588
+ `Provided tag with UUID "${props.id}" did not match any known tags`
1589
+ );
1590
+ }
1591
+ return tag;
1592
+ }
1593
+ /**
1594
+ * Updating a git tag is not supported.
1595
+ * Please delete the old and create a new one
1596
+ *
1597
+ * @see https://git-scm.com/docs/git-tag#_on_re_tagging
1598
+ */
1599
+ async update() {
1600
+ throw new Error(
1601
+ "Updating a git tag is not supported. Please delete the old and create a new one"
1602
+ );
1603
+ }
1604
+ /**
1605
+ * Deletes a tag
1606
+ *
1607
+ * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---delete
1608
+ *
1609
+ * @param path Path to the repository
1610
+ * @param id UUID of the tag to delete
1611
+ */
1612
+ async delete(props) {
1613
+ deleteGitTagSchema.parse(props);
1614
+ const args = ["tag", "--delete", props.id];
1615
+ await this.git(props.path, args);
1616
+ }
1617
+ /**
1618
+ * Gets all local tags or filter them by pattern
1619
+ *
1620
+ * They are sorted by authordate of the commit, not the timestamp the tag is created.
1621
+ * This ensures tags are sorted correctly in the timeline of their commits.
1622
+ *
1623
+ * @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---list
1624
+ */
1625
+ async list(props) {
1626
+ listGitTagsSchema.parse(props);
1627
+ let args = ["tag", "--list"];
1628
+ args = [
1629
+ ...args,
1630
+ "--sort=-*authordate",
1631
+ "--format=%(refname:short)|%(subject)|%(*authorname)|%(*authoremail)|%(*authordate:unix)"
1632
+ ];
1633
+ const result = await this.git(props.path, args);
1634
+ const noEmptyLinesArr = result.stdout.split(EOL).filter((line) => {
1635
+ return line.trim() !== "";
1636
+ });
1637
+ const lineObjArr = noEmptyLinesArr.map((line) => {
1638
+ const lineArray = line.split("|");
1639
+ return {
1640
+ id: lineArray[0],
1641
+ message: lineArray[1],
1642
+ author: {
1643
+ name: lineArray[2],
1644
+ email: lineArray[3]
1645
+ },
1646
+ timestamp: parseInt(lineArray[4])
1647
+ };
1648
+ });
1649
+ const gitTags = lineObjArr.filter(this.isGitTag.bind(this));
1650
+ return {
1651
+ total: gitTags.length,
1652
+ limit: 0,
1653
+ offset: 0,
1654
+ list: gitTags
1655
+ };
1656
+ }
1657
+ /**
1658
+ * Returns the total number of tags inside given repository
1659
+ *
1660
+ * Internally uses list(), so do not use count()
1661
+ * in conjuncion with it to avoid multiple git calls.
1662
+ *
1663
+ * @param path Path to the repository
1664
+ */
1665
+ async count(props) {
1666
+ countGitTagsSchema.parse(props);
1667
+ const gitTags = await this.list({ path: props.path });
1668
+ return gitTags.total;
1669
+ }
1670
+ /**
1671
+ * Type guard for GitTag
1672
+ *
1673
+ * @param obj The object to check
1674
+ */
1675
+ isGitTag(obj) {
1676
+ return gitTagSchema.safeParse(obj).success;
1677
+ }
1678
+ };
1679
+
1680
+ // src/service/UserService.ts
1681
+ var UserService = class {
1682
+ constructor(jsonFileService) {
1683
+ this.jsonFileService = jsonFileService;
1684
+ }
1685
+ /**
1686
+ * Returns the User currently working with Core
1687
+ */
1688
+ async get() {
1689
+ try {
1690
+ return await this.jsonFileService.read(pathTo.userFile, userFileSchema);
1691
+ } catch (error) {
1692
+ return void 0;
1693
+ }
1694
+ }
1695
+ /**
1696
+ * Sets the User currently working with Core
1697
+ *
1698
+ * By doing so all git operations are done with the signature of this User
1699
+ */
1700
+ async set(props) {
1701
+ setUserSchema.parse(props);
1702
+ const userFilePath = pathTo.userFile;
1703
+ const userFile = {
1704
+ ...props
1705
+ };
1706
+ if (userFile.userType === UserTypeSchema.Enum.cloud) {
1707
+ }
1708
+ await this.jsonFileService.update(userFile, userFilePath, userFileSchema);
1709
+ return userFile;
1710
+ }
1711
+ };
1712
+
1713
+ // src/service/GitService.ts
1714
+ var GitService2 = class {
1715
+ constructor(options, userService) {
1716
+ this.branches = {
1717
+ /**
1718
+ * List branches
1719
+ *
1720
+ * @see https://www.git-scm.com/docs/git-branch
1721
+ *
1722
+ * @param path Path to the repository
1470
1723
  */
1471
1724
  list: async (path) => {
1472
1725
  const args = ["branch", "--list", "--all"];
@@ -1702,507 +1955,277 @@ var GitService2 = class {
1702
1955
  /**
1703
1956
  * Download objects and refs from remote `origin`
1704
1957
  *
1705
- * @see https://www.git-scm.com/docs/git-fetch
1706
- *
1707
- * @param path Path to the repository
1708
- */
1709
- async fetch(path) {
1710
- const args = ["fetch"];
1711
- await this.git(path, args);
1712
- }
1713
- /**
1714
- * Fetch from and integrate (rebase or merge) with a local branch
1715
- *
1716
- * @see https://git-scm.com/docs/git-pull
1717
- *
1718
- * @param path Path to the repository
1719
- */
1720
- async pull(path) {
1721
- const args = ["pull"];
1722
- await this.git(path, args);
1723
- }
1724
- /**
1725
- * Update remote refs along with associated objects to remote `origin`
1726
- *
1727
- * @see https://git-scm.com/docs/git-push
1728
- *
1729
- * @param path Path to the repository
1730
- */
1731
- async push(path, options) {
1732
- let args = ["push", "origin"];
1733
- if (options?.all === true) {
1734
- args = [...args, "--all"];
1735
- }
1736
- if (options?.force === true) {
1737
- args = [...args, "--force"];
1738
- }
1739
- await this.git(path, args);
1740
- }
1741
- /**
1742
- * Record changes to the repository
1743
- *
1744
- * @see https://git-scm.com/docs/git-commit
1745
- *
1746
- * @param path Path to the repository
1747
- * @param message A message that describes the changes
1748
- */
1749
- async commit(path, message) {
1750
- const user = await this.userService.get();
1751
- if (!user) {
1752
- throw new NoCurrentUserError();
1753
- }
1754
- const args = [
1755
- "commit",
1756
- `--message=${message}`,
1757
- `--author=${user.name} <${user.email}>`
1758
- ];
1759
- await this.git(path, args);
1760
- }
1761
- /**
1762
- * Gets local commit history
1763
- *
1764
- * @see https://git-scm.com/docs/git-log
1765
- *
1766
- * @todo Check if there is a need to trim the git commit message of chars
1767
- * @todo Use this method in a service. Decide if we need a HistoryService for example
1768
- *
1769
- * @param path Path to the repository
1770
- * @param options Options specific to the log operation
1771
- */
1772
- async log(path, options) {
1773
- let args = ["log"];
1774
- if (options?.between?.from) {
1775
- args = [
1776
- ...args,
1777
- `${options.between.from}..${options.between.to || "HEAD"}`
1778
- ];
1779
- }
1780
- if (options?.limit) {
1781
- args = [...args, `--max-count=${options.limit}`];
1782
- }
1783
- const result = await this.git(path, [
1784
- ...args,
1785
- "--format=%H|%s|%an|%ae|%at|%D"
1786
- ]);
1787
- const noEmptyLinesArr = result.stdout.split(EOL2).filter((line) => {
1788
- return line.trim() !== "";
1789
- });
1790
- const lineObjArr = noEmptyLinesArr.map((line) => {
1791
- const lineArray = line.split("|");
1792
- return {
1793
- hash: lineArray[0],
1794
- message: lineArray[1],
1795
- author: {
1796
- name: lineArray[2],
1797
- email: lineArray[3]
1798
- },
1799
- timestamp: parseInt(lineArray[4]),
1800
- tag: this.refNameToTagName(lineArray[5])
1801
- };
1802
- });
1803
- return lineObjArr.filter(this.isGitCommit.bind(this));
1804
- }
1805
- refNameToTagName(refName) {
1806
- const tagName = refName.replace("tag: ", "").trim();
1807
- if (tagName === "" || uuidSchema.safeParse(tagName).success === false) {
1808
- return null;
1809
- }
1810
- return tagName;
1811
- }
1812
- /**
1813
- * Returns a timestamp of given files creation
1814
- *
1815
- * Git only returns the timestamp the file was added,
1816
- * which could be different from the file being created.
1817
- * But since file operations will always be committed
1818
- * immediately, this is practically the same.
1819
- *
1820
- * @param path Path to the repository
1821
- * @param file File to get timestamp from
1822
- */
1823
- async getFileCreatedTimestamp(path, file) {
1824
- const result = await this.git(path, [
1825
- "log",
1826
- "--diff-filter=A",
1827
- "--follow",
1828
- "--format=%at",
1829
- "--max-count=1",
1830
- "--",
1831
- file
1832
- ]);
1833
- return parseInt(result.stdout);
1834
- }
1835
- /**
1836
- * Returns a timestamp of the files last modification
1837
- *
1838
- * @param path Path to the repository
1839
- * @param file File to get timestamp from
1840
- */
1841
- async getFileLastUpdatedTimestamp(path, file) {
1842
- const result = await this.git(path, [
1843
- "log",
1844
- "--follow",
1845
- "--format=%at",
1846
- "--max-count=1",
1847
- "--",
1848
- file
1849
- ]);
1850
- return parseInt(result.stdout);
1851
- }
1852
- /**
1853
- * Returns created and updated timestamps from given file
1854
- *
1855
- * @param path Path to the project
1856
- * @param file Path to the file
1857
- */
1858
- async getFileCreatedUpdatedMeta(path, file) {
1859
- const meta = await Promise.all([
1860
- this.getFileCreatedTimestamp(path, file),
1861
- this.getFileLastUpdatedTimestamp(path, file)
1862
- ]);
1863
- return {
1864
- created: meta[0],
1865
- updated: meta[1]
1866
- };
1867
- }
1868
- /**
1869
- * Reads the currently used version of Git
1870
- *
1871
- * This can help debugging
1872
- */
1873
- async updateVersion() {
1874
- const result = await this.git("", ["--version"]);
1875
- this.version = result.stdout.replace("git version", "").trim();
1876
- }
1877
- /**
1878
- * Reads the path to the executable of Git that is used
1879
- *
1880
- * This can help debugging, since dugite is shipping their own executable
1881
- * but in some cases resolves another executable
1882
- * @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
1958
+ * @see https://www.git-scm.com/docs/git-fetch
1959
+ *
1960
+ * @param path Path to the repository
1883
1961
  */
1884
- async updateGitPath() {
1885
- const result = await this.git("", ["--exec-path"]);
1886
- this.gitPath = result.stdout.trim();
1962
+ async fetch(path) {
1963
+ const args = ["fetch"];
1964
+ await this.git(path, args);
1887
1965
  }
1888
1966
  /**
1889
- * A reference is used in Git to specify branches and tags.
1890
- * This method checks if given name matches the required format
1967
+ * Fetch from and integrate (rebase or merge) with a local branch
1891
1968
  *
1892
- * @see https://git-scm.com/docs/git-check-ref-format
1969
+ * @see https://git-scm.com/docs/git-pull
1893
1970
  *
1894
1971
  * @param path Path to the repository
1895
- * @param name Name to check
1896
1972
  */
1897
- async checkBranchOrTagName(path, name) {
1898
- await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
1973
+ async pull(path) {
1974
+ const args = ["pull"];
1975
+ await this.git(path, args);
1899
1976
  }
1900
1977
  /**
1901
- * Installs LFS support and starts tracking
1902
- * all files inside the lfs folder
1978
+ * Update remote refs along with associated objects to remote `origin`
1979
+ *
1980
+ * @see https://git-scm.com/docs/git-push
1903
1981
  *
1904
1982
  * @param path Path to the repository
1905
1983
  */
1906
- async installLfs(path) {
1907
- await this.git(path, ["lfs", "install"]);
1908
- await this.git(path, ["lfs", "track", "lfs/*"]);
1984
+ async push(path, options) {
1985
+ let args = ["push", "origin"];
1986
+ if (options?.all === true) {
1987
+ args = [...args, "--all"];
1988
+ }
1989
+ if (options?.force === true) {
1990
+ args = [...args, "--force"];
1991
+ }
1992
+ await this.git(path, args);
1909
1993
  }
1910
1994
  /**
1911
- * Sets the git config of given local repository from ElekIoCoreOptions
1995
+ * Record changes to the repository
1912
1996
  *
1913
- * @param path Path to the repository
1997
+ * @see https://git-scm.com/docs/git-commit
1998
+ *
1999
+ * @param path Path to the repository
2000
+ * @param message A message that describes the changes
1914
2001
  */
1915
- async setLocalConfig(path) {
2002
+ async commit(path, message) {
1916
2003
  const user = await this.userService.get();
1917
2004
  if (!user) {
1918
2005
  throw new NoCurrentUserError();
1919
2006
  }
1920
- const userNameArgs = ["config", "--local", "user.name", user.name];
1921
- const userEmailArgs = ["config", "--local", "user.email", user.email];
1922
- const autoSetupRemoteArgs = [
1923
- "config",
1924
- "--local",
1925
- "push.autoSetupRemote",
1926
- "true"
2007
+ const args = [
2008
+ "commit",
2009
+ `--message=${message}`,
2010
+ `--author=${user.name} <${user.email}>`
1927
2011
  ];
1928
- await this.git(path, userNameArgs);
1929
- await this.git(path, userEmailArgs);
1930
- await this.git(path, autoSetupRemoteArgs);
2012
+ await this.git(path, args);
1931
2013
  }
1932
2014
  /**
1933
- * Type guard for GitCommit
2015
+ * Gets local commit history
1934
2016
  *
1935
- * @param obj The object to check
1936
- */
1937
- isGitCommit(obj) {
1938
- return gitCommitSchema.safeParse(obj).success;
1939
- }
1940
- /**
1941
- * Wraps the execution of any git command
1942
- * to use a FIFO queue for sequential processing
2017
+ * @see https://git-scm.com/docs/git-log
1943
2018
  *
1944
- * @param path Path to the repository
1945
- * @param args Arguments to append after the `git` command
2019
+ * @todo Check if there is a need to trim the git commit message of chars
2020
+ * @todo Use this method in a service. Decide if we need a HistoryService for example
2021
+ *
2022
+ * @param path Path to the repository
2023
+ * @param options Options specific to the log operation
1946
2024
  */
1947
- async git(path, args) {
1948
- const result = await this.queue.add(
1949
- () => GitProcess.exec(args, path, {
1950
- env: {
1951
- // @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
1952
- // @see https://github.com/git-lfs/git-lfs/issues/5749
1953
- GIT_CLONE_PROTECTION_ACTIVE: "false"
1954
- }
1955
- })
1956
- );
1957
- if (!result) {
1958
- throw new GitError(
1959
- `Git ${this.version} (${this.gitPath}) command "git ${args.join(
1960
- " "
1961
- )}" failed to return a result`
1962
- );
2025
+ async log(path, options) {
2026
+ let args = ["log"];
2027
+ if (options?.between?.from) {
2028
+ args = [
2029
+ ...args,
2030
+ `${options.between.from}..${options.between.to || "HEAD"}`
2031
+ ];
1963
2032
  }
1964
- if (result.exitCode !== 0) {
1965
- throw new GitError(
1966
- `Git ${this.version} (${this.gitPath}) command "git ${args.join(
1967
- " "
1968
- )}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
1969
- );
2033
+ if (options?.limit) {
2034
+ args = [...args, `--max-count=${options.limit}`];
1970
2035
  }
1971
- return result;
1972
- }
1973
- };
1974
-
1975
- // src/service/AssetService.ts
1976
- var AssetService = class extends AbstractCrudService {
1977
- constructor(options, jsonFileService, gitService) {
1978
- super(serviceTypeSchema.Enum.Asset, options);
1979
- this.jsonFileService = jsonFileService;
1980
- this.gitService = gitService;
2036
+ const result = await this.git(path, [
2037
+ ...args,
2038
+ "--format=%H|%s|%an|%ae|%at|%D"
2039
+ ]);
2040
+ const noEmptyLinesArr = result.stdout.split(EOL2).filter((line) => {
2041
+ return line.trim() !== "";
2042
+ });
2043
+ const lineObjArr = noEmptyLinesArr.map((line) => {
2044
+ const lineArray = line.split("|");
2045
+ return {
2046
+ hash: lineArray[0],
2047
+ message: lineArray[1],
2048
+ author: {
2049
+ name: lineArray[2],
2050
+ email: lineArray[3]
2051
+ },
2052
+ timestamp: parseInt(lineArray[4]),
2053
+ tag: this.refNameToTagName(lineArray[5])
2054
+ };
2055
+ });
2056
+ return lineObjArr.filter(this.isGitCommit.bind(this));
1981
2057
  }
1982
- /**
1983
- * Creates a new Asset
1984
- */
1985
- async create(props) {
1986
- createAssetSchema.parse(props);
1987
- const id = uuid();
1988
- const projectPath = pathTo.project(props.projectId);
1989
- const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
1990
- const size = await this.getAssetSize(props.filePath);
1991
- const assetPath = pathTo.asset(
1992
- props.projectId,
1993
- id,
1994
- props.language,
1995
- fileType.extension
1996
- );
1997
- const assetFilePath = pathTo.assetFile(
1998
- props.projectId,
1999
- id,
2000
- props.language
2001
- );
2002
- const assetFile = {
2003
- ...props,
2004
- objectType: "asset",
2005
- id,
2006
- created: currentTimestamp(),
2007
- updated: null,
2008
- extension: fileType.extension,
2009
- mimeType: fileType.mimeType,
2010
- size
2011
- };
2012
- try {
2013
- await Fs3.copyFile(props.filePath, assetPath);
2014
- await this.jsonFileService.create(
2015
- assetFile,
2016
- assetFilePath,
2017
- assetFileSchema
2018
- );
2019
- } catch (error) {
2020
- await this.delete({ ...assetFile, projectId: props.projectId });
2021
- throw error;
2058
+ refNameToTagName(refName) {
2059
+ const tagName = refName.replace("tag: ", "").trim();
2060
+ if (tagName === "" || uuidSchema.safeParse(tagName).success === false) {
2061
+ return null;
2022
2062
  }
2023
- await this.gitService.add(projectPath, [assetFilePath, assetPath]);
2024
- await this.gitService.commit(projectPath, this.gitMessage.create);
2025
- return this.toAsset(props.projectId, assetFile);
2026
- }
2027
- /**
2028
- * Returns an Asset by ID and language
2029
- */
2030
- async read(props) {
2031
- readAssetSchema.parse(props);
2032
- const assetFile = await this.jsonFileService.read(
2033
- pathTo.assetFile(props.projectId, props.id, props.language),
2034
- assetFileSchema
2035
- );
2036
- return this.toAsset(props.projectId, assetFile);
2063
+ return tagName;
2037
2064
  }
2038
2065
  /**
2039
- * Updates given Asset
2066
+ * Returns a timestamp of given files creation
2040
2067
  *
2041
- * Use the optional "newFilePath" prop to update the Asset itself
2042
- */
2043
- async update(props) {
2044
- updateAssetSchema.parse(props);
2045
- const projectPath = pathTo.project(props.projectId);
2046
- const assetFilePath = pathTo.assetFile(
2047
- props.projectId,
2048
- props.id,
2049
- props.language
2050
- );
2051
- const prevAssetFile = await this.read(props);
2052
- const assetFile = {
2053
- ...prevAssetFile,
2054
- ...props,
2055
- updated: currentTimestamp()
2056
- };
2057
- if (props.newFilePath) {
2058
- const fileType = await this.getSupportedFileTypeOrThrow(
2059
- props.newFilePath
2060
- );
2061
- const size = await this.getAssetSize(props.newFilePath);
2062
- const prevAssetPath = pathTo.asset(
2063
- props.projectId,
2064
- props.id,
2065
- props.language,
2066
- prevAssetFile.extension
2067
- );
2068
- const assetPath = pathTo.asset(
2069
- props.projectId,
2070
- props.id,
2071
- props.language,
2072
- fileType.extension
2073
- );
2074
- await Fs3.remove(prevAssetPath);
2075
- await Fs3.copyFile(props.newFilePath, assetPath);
2076
- assetFile.extension = fileType.extension;
2077
- assetFile.mimeType = fileType.mimeType;
2078
- assetFile.size = size;
2079
- }
2080
- await this.jsonFileService.update(
2081
- assetFile,
2082
- assetFilePath,
2083
- assetFileSchema
2084
- );
2085
- await this.gitService.add(projectPath, [assetFilePath]);
2086
- await this.gitService.commit(projectPath, this.gitMessage.update);
2087
- return this.toAsset(props.projectId, assetFile);
2068
+ * Git only returns the timestamp the file was added,
2069
+ * which could be different from the file being created.
2070
+ * But since file operations will always be committed
2071
+ * immediately, this is practically the same.
2072
+ *
2073
+ * @param path Path to the repository
2074
+ * @param file File to get timestamp from
2075
+ */
2076
+ async getFileCreatedTimestamp(path, file) {
2077
+ const result = await this.git(path, [
2078
+ "log",
2079
+ "--diff-filter=A",
2080
+ "--follow",
2081
+ "--format=%at",
2082
+ "--max-count=1",
2083
+ "--",
2084
+ file
2085
+ ]);
2086
+ return parseInt(result.stdout);
2088
2087
  }
2089
2088
  /**
2090
- * Deletes given Asset
2089
+ * Returns a timestamp of the files last modification
2090
+ *
2091
+ * @param path Path to the repository
2092
+ * @param file File to get timestamp from
2091
2093
  */
2092
- async delete(props) {
2093
- deleteAssetSchema.parse(props);
2094
- const projectPath = pathTo.project(props.projectId);
2095
- const assetFilePath = pathTo.assetFile(
2096
- props.projectId,
2097
- props.id,
2098
- props.language
2099
- );
2100
- const assetPath = pathTo.asset(
2101
- props.projectId,
2102
- props.id,
2103
- props.language,
2104
- props.extension
2105
- );
2106
- await Fs3.remove(assetPath);
2107
- await Fs3.remove(assetFilePath);
2108
- await this.gitService.add(projectPath, [assetFilePath, assetPath]);
2109
- await this.gitService.commit(projectPath, this.gitMessage.delete);
2094
+ async getFileLastUpdatedTimestamp(path, file) {
2095
+ const result = await this.git(path, [
2096
+ "log",
2097
+ "--follow",
2098
+ "--format=%at",
2099
+ "--max-count=1",
2100
+ "--",
2101
+ file
2102
+ ]);
2103
+ return parseInt(result.stdout);
2110
2104
  }
2111
- async list(props) {
2112
- listAssetsSchema.parse(props);
2113
- const offset = props.offset || 0;
2114
- const limit = props.limit || 15;
2115
- const assetReferences = await this.listReferences(
2116
- objectTypeSchema.Enum.asset,
2117
- props.projectId
2118
- );
2119
- const partialAssetReferences = assetReferences.slice(offset, limit);
2120
- const assets = await returnResolved(
2121
- partialAssetReferences.map((assetReference) => {
2122
- if (!assetReference.language) {
2123
- throw new RequiredParameterMissingError("language");
2124
- }
2125
- return this.read({
2126
- projectId: props.projectId,
2127
- id: assetReference.id,
2128
- language: assetReference.language
2129
- });
2130
- })
2131
- );
2105
+ /**
2106
+ * Returns created and updated timestamps from given file
2107
+ *
2108
+ * @param path Path to the project
2109
+ * @param file Path to the file
2110
+ */
2111
+ async getFileCreatedUpdatedMeta(path, file) {
2112
+ const meta = await Promise.all([
2113
+ this.getFileCreatedTimestamp(path, file),
2114
+ this.getFileLastUpdatedTimestamp(path, file)
2115
+ ]);
2132
2116
  return {
2133
- total: assetReferences.length,
2134
- limit,
2135
- offset,
2136
- list: assets
2117
+ created: meta[0],
2118
+ updated: meta[1]
2137
2119
  };
2138
2120
  }
2139
- async count(props) {
2140
- countAssetsSchema.parse(props);
2141
- const count = (await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)).length;
2142
- return count;
2121
+ /**
2122
+ * Reads the currently used version of Git
2123
+ *
2124
+ * This can help debugging
2125
+ */
2126
+ async updateVersion() {
2127
+ const result = await this.git("", ["--version"]);
2128
+ this.version = result.stdout.replace("git version", "").trim();
2143
2129
  }
2144
2130
  /**
2145
- * Checks if given object is of type Asset
2131
+ * Reads the path to the executable of Git that is used
2132
+ *
2133
+ * This can help debugging, since dugite is shipping their own executable
2134
+ * but in some cases resolves another executable
2135
+ * @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
2146
2136
  */
2147
- isAsset(obj) {
2148
- return assetSchema.safeParse(obj).success;
2137
+ async updateGitPath() {
2138
+ const result = await this.git("", ["--exec-path"]);
2139
+ this.gitPath = result.stdout.trim();
2149
2140
  }
2150
2141
  /**
2151
- * Returns the size of an Asset in bytes
2142
+ * A reference is used in Git to specify branches and tags.
2143
+ * This method checks if given name matches the required format
2152
2144
  *
2153
- * @param path Path of the Asset to get the size from
2145
+ * @see https://git-scm.com/docs/git-check-ref-format
2146
+ *
2147
+ * @param path Path to the repository
2148
+ * @param name Name to check
2154
2149
  */
2155
- async getAssetSize(path) {
2156
- return (await Fs3.stat(path)).size;
2150
+ async checkBranchOrTagName(path, name) {
2151
+ await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
2157
2152
  }
2158
2153
  /**
2159
- * Creates an Asset from given AssetFile
2154
+ * Installs LFS support and starts tracking
2155
+ * all files inside the lfs folder
2160
2156
  *
2161
- * @param projectId The project's ID
2162
- * @param assetFile The AssetFile to convert
2157
+ * @param path Path to the repository
2163
2158
  */
2164
- async toAsset(projectId, assetFile) {
2165
- const assetPath = pathTo.asset(
2166
- projectId,
2167
- assetFile.id,
2168
- assetFile.language,
2169
- assetFile.extension
2170
- );
2171
- const asset = {
2172
- ...assetFile,
2173
- absolutePath: assetPath
2174
- };
2175
- return asset;
2159
+ async installLfs(path) {
2160
+ await this.git(path, ["lfs", "install"]);
2161
+ await this.git(path, ["lfs", "track", "lfs/*"]);
2176
2162
  }
2177
2163
  /**
2178
- * Returns the found and supported extension as well as mime type,
2179
- * otherwise throws an error
2164
+ * Sets the git config of given local repository from ElekIoCoreOptions
2180
2165
  *
2181
- * @param filePath Path to the file to check
2166
+ * @param path Path to the repository
2182
2167
  */
2183
- async getSupportedFileTypeOrThrow(filePath) {
2184
- const fileSize = (await Fs3.stat(filePath)).size;
2185
- if (fileSize / 1e3 <= 500) {
2186
- const fileBuffer = await Fs3.readFile(filePath);
2187
- if (IsSvg(fileBuffer.toString()) === true) {
2188
- return {
2189
- extension: supportedAssetExtensionSchema.Enum.svg,
2190
- mimeType: supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
2191
- };
2192
- }
2168
+ async setLocalConfig(path) {
2169
+ const user = await this.userService.get();
2170
+ if (!user) {
2171
+ throw new NoCurrentUserError();
2172
+ }
2173
+ const userNameArgs = ["config", "--local", "user.name", user.name];
2174
+ const userEmailArgs = ["config", "--local", "user.email", user.email];
2175
+ const autoSetupRemoteArgs = [
2176
+ "config",
2177
+ "--local",
2178
+ "push.autoSetupRemote",
2179
+ "true"
2180
+ ];
2181
+ await this.git(path, userNameArgs);
2182
+ await this.git(path, userEmailArgs);
2183
+ await this.git(path, autoSetupRemoteArgs);
2184
+ }
2185
+ /**
2186
+ * Type guard for GitCommit
2187
+ *
2188
+ * @param obj The object to check
2189
+ */
2190
+ isGitCommit(obj) {
2191
+ return gitCommitSchema.safeParse(obj).success;
2192
+ }
2193
+ /**
2194
+ * Wraps the execution of any git command
2195
+ * to use a FIFO queue for sequential processing
2196
+ *
2197
+ * @param path Path to the repository
2198
+ * @param args Arguments to append after the `git` command
2199
+ */
2200
+ async git(path, args) {
2201
+ const result = await this.queue.add(
2202
+ () => GitProcess.exec(args, path, {
2203
+ env: {
2204
+ // @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
2205
+ // @see https://github.com/git-lfs/git-lfs/issues/5749
2206
+ GIT_CLONE_PROTECTION_ACTIVE: "false"
2207
+ }
2208
+ })
2209
+ );
2210
+ if (!result) {
2211
+ throw new GitError(
2212
+ `Git ${this.version} (${this.gitPath}) command "git ${args.join(
2213
+ " "
2214
+ )}" failed to return a result`
2215
+ );
2216
+ }
2217
+ if (result.exitCode !== 0) {
2218
+ throw new GitError(
2219
+ `Git ${this.version} (${this.gitPath}) command "git ${args.join(
2220
+ " "
2221
+ )}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
2222
+ );
2193
2223
  }
2194
- const { fileTypeFromFile } = await import("file-type");
2195
- const fileType = await fileTypeFromFile(filePath);
2196
- const result = supportedAssetTypeSchema.parse({
2197
- extension: fileType?.ext,
2198
- mimeType: fileType?.mime
2199
- });
2200
2224
  return result;
2201
2225
  }
2202
2226
  };
2203
2227
 
2204
2228
  // src/service/CollectionService.ts
2205
- import Fs4 from "fs-extra";
2206
2229
  var CollectionService = class extends AbstractCrudService {
2207
2230
  constructor(options, jsonFileService, gitService) {
2208
2231
  super(serviceTypeSchema.Enum.Collection, options);
@@ -2263,10 +2286,7 @@ var CollectionService = class extends AbstractCrudService {
2263
2286
  async update(props) {
2264
2287
  updateCollectionSchema.parse(props);
2265
2288
  const projectPath = pathTo.project(props.projectId);
2266
- const collectionFilePath = pathTo.collectionFile(
2267
- props.projectId,
2268
- props.id
2269
- );
2289
+ const collectionFilePath = pathTo.collectionFile(props.projectId, props.id);
2270
2290
  const prevCollectionFile = await this.read(props);
2271
2291
  const collectionFile = {
2272
2292
  ...prevCollectionFile,
@@ -2640,16 +2660,6 @@ import Fs6 from "fs-extra";
2640
2660
  import Os2 from "os";
2641
2661
  import Path2 from "path";
2642
2662
  import Semver from "semver";
2643
-
2644
- // src/error/ProjectUpgradeError.ts
2645
- var ProjectUpgradeError = class extends Error {
2646
- constructor(message) {
2647
- super(message);
2648
- this.name = "ProjectUpgradeError";
2649
- }
2650
- };
2651
-
2652
- // src/service/ProjectService.ts
2653
2663
  var ProjectService = class extends AbstractCrudService {
2654
2664
  constructor(options, jsonFileService, userService, gitService, assetService, collectionService, entryService) {
2655
2665
  super(serviceTypeSchema.Enum.Project, options);
@@ -3032,36 +3042,7 @@ var ProjectService = class extends AbstractCrudService {
3032
3042
  }
3033
3043
  };
3034
3044
 
3035
- // src/schema/coreSchema.ts
3036
- import { z as z12 } from "zod";
3037
- var elekIoCoreOptionsSchema = z12.object({
3038
- /**
3039
- * The environment elek.io Core is currently running in
3040
- */
3041
- environment: environmentSchema,
3042
- /**
3043
- * The current version of elek.io Core
3044
- */
3045
- version: versionSchema,
3046
- file: z12.object({
3047
- json: z12.object({
3048
- /**
3049
- * If set, adds indentation with spaces (number) or escape character (string)
3050
- * and line break characters to saved JSON files on disk, to make them easier to read.
3051
- * Defaults to 2 spaces of indentation.
3052
- */
3053
- indentation: z12.union([z12.number(), z12.string()])
3054
- })
3055
- })
3056
- });
3057
- var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
3058
- version: true
3059
- }).partial({
3060
- environment: true,
3061
- file: true
3062
- }).optional();
3063
-
3064
- // src/index.ts
3045
+ // src/index.node.ts
3065
3046
  var ElekIoCore = class {
3066
3047
  // private readonly sharedValueService: SharedValueService;
3067
3048
  constructor(props) {
@@ -3122,7 +3103,7 @@ var ElekIoCore = class {
3122
3103
  * Utility / helper functions
3123
3104
  */
3124
3105
  get util() {
3125
- return util_exports;
3106
+ return node_exports;
3126
3107
  }
3127
3108
  /**
3128
3109
  * Exposes git functions
@@ -3200,6 +3181,7 @@ export {
3200
3181
  createGitTagSchema,
3201
3182
  createProjectSchema,
3202
3183
  currentBranchProjectSchema,
3184
+ currentTimestamp,
3203
3185
  dateValueDefinitionSchema,
3204
3186
  datetimeValueDefinitionSchema,
3205
3187
  ElekIoCore as default,
@@ -3264,6 +3246,7 @@ export {
3264
3246
  serviceTypeSchema,
3265
3247
  setRemoteOriginUrlProjectSchema,
3266
3248
  setUserSchema,
3249
+ slug,
3267
3250
  stringValueDefinitionSchema,
3268
3251
  supportedAssetExtensionSchema,
3269
3252
  supportedAssetMimeTypeSchema,
@@ -3289,6 +3272,7 @@ export {
3289
3272
  urlValueDefinitionSchema,
3290
3273
  userFileSchema,
3291
3274
  userSchema,
3275
+ uuid,
3292
3276
  uuidSchema,
3293
3277
  valueContentReferenceBase,
3294
3278
  valueContentReferenceSchema,
@@ -3300,4 +3284,4 @@ export {
3300
3284
  valueSchema,
3301
3285
  versionSchema
3302
3286
  };
3303
- //# sourceMappingURL=index.js.map
3287
+ //# sourceMappingURL=index.node.js.map