@elek-io/core 0.4.2 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.browser.cjs +1082 -0
- package/dist/browser/index.browser.cjs.map +1 -0
- package/dist/browser/index.browser.d.cts +12551 -0
- package/dist/browser/index.browser.d.ts +12551 -0
- package/dist/browser/index.browser.js +1049 -0
- package/dist/browser/index.browser.js.map +1 -0
- package/dist/{index.cjs → node/index.node.cjs} +809 -817
- package/dist/node/index.node.cjs.map +1 -0
- package/dist/{index.js → node/index.node.js} +806 -814
- package/dist/node/index.node.js.map +1 -0
- package/package.json +15 -9
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/{index.d.cts → node/index.node.d.cts} +3012 -3012
- package/dist/{index.d.ts → node/index.node.d.ts} +3012 -3012
|
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
30
|
+
// src/index.node.ts
|
|
31
|
+
var index_node_exports = {};
|
|
32
|
+
__export(index_node_exports, {
|
|
33
33
|
BooleanValueDefinitionBaseSchema: () => BooleanValueDefinitionBaseSchema,
|
|
34
34
|
NumberValueDefinitionBaseSchema: () => NumberValueDefinitionBaseSchema,
|
|
35
35
|
ReferenceValueDefinitionBaseSchema: () => ReferenceValueDefinitionBaseSchema,
|
|
@@ -165,21 +165,9 @@ __export(src_exports, {
|
|
|
165
165
|
valueSchema: () => valueSchema,
|
|
166
166
|
versionSchema: () => versionSchema
|
|
167
167
|
});
|
|
168
|
-
module.exports = __toCommonJS(
|
|
168
|
+
module.exports = __toCommonJS(index_node_exports);
|
|
169
169
|
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
170
170
|
|
|
171
|
-
// src/service/AssetService.ts
|
|
172
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
173
|
-
var import_is_svg = __toESM(require("is-svg"), 1);
|
|
174
|
-
|
|
175
|
-
// src/error/RequiredParameterMissingError.ts
|
|
176
|
-
var RequiredParameterMissingError = class extends Error {
|
|
177
|
-
constructor(parameter) {
|
|
178
|
-
super(`Missing required parameter "${parameter}"`);
|
|
179
|
-
this.name = "RequiredParameterMissingError";
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
171
|
// src/schema/assetSchema.ts
|
|
184
172
|
var import_zod3 = __toESM(require("zod"), 1);
|
|
185
173
|
|
|
@@ -391,156 +379,21 @@ var deleteAssetSchema = assetFileSchema.pick({
|
|
|
391
379
|
});
|
|
392
380
|
var countAssetsSchema = import_zod3.default.object({ projectId: uuidSchema.readonly() });
|
|
393
381
|
|
|
394
|
-
// src/schema/serviceSchema.ts
|
|
395
|
-
var import_zod5 = require("zod");
|
|
396
|
-
|
|
397
|
-
// src/schema/gitSchema.ts
|
|
398
|
-
var import_zod4 = require("zod");
|
|
399
|
-
var gitRepositoryPathSchema = import_zod4.z.string();
|
|
400
|
-
var gitSignatureSchema = import_zod4.z.object({
|
|
401
|
-
name: import_zod4.z.string(),
|
|
402
|
-
email: import_zod4.z.string()
|
|
403
|
-
});
|
|
404
|
-
var gitCommitSchema = import_zod4.z.object({
|
|
405
|
-
/**
|
|
406
|
-
* SHA-1 hash of the commit
|
|
407
|
-
*/
|
|
408
|
-
hash: import_zod4.z.string(),
|
|
409
|
-
message: import_zod4.z.string(),
|
|
410
|
-
author: gitSignatureSchema,
|
|
411
|
-
timestamp: import_zod4.z.number(),
|
|
412
|
-
tag: import_zod4.z.string().nullable()
|
|
413
|
-
});
|
|
414
|
-
var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
|
|
415
|
-
GitCommitIconNative2["INIT"] = ":tada:";
|
|
416
|
-
GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
|
|
417
|
-
GitCommitIconNative2["UPDATE"] = ":wrench:";
|
|
418
|
-
GitCommitIconNative2["DELETE"] = ":fire:";
|
|
419
|
-
return GitCommitIconNative2;
|
|
420
|
-
})(GitCommitIconNative || {});
|
|
421
|
-
var gitCommitIconSchema = import_zod4.z.nativeEnum(GitCommitIconNative);
|
|
422
|
-
var gitInitOptionsSchema = import_zod4.z.object({
|
|
423
|
-
/**
|
|
424
|
-
* 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).
|
|
425
|
-
*/
|
|
426
|
-
initialBranch: import_zod4.z.string()
|
|
427
|
-
});
|
|
428
|
-
var gitCloneOptionsSchema = import_zod4.z.object({
|
|
429
|
-
/**
|
|
430
|
-
* 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.
|
|
431
|
-
*/
|
|
432
|
-
depth: import_zod4.z.number(),
|
|
433
|
-
/**
|
|
434
|
-
* 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.
|
|
435
|
-
*/
|
|
436
|
-
singleBranch: import_zod4.z.boolean(),
|
|
437
|
-
/**
|
|
438
|
-
* 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.
|
|
439
|
-
*/
|
|
440
|
-
branch: import_zod4.z.string()
|
|
441
|
-
});
|
|
442
|
-
var gitSwitchOptionsSchema = import_zod4.z.object({
|
|
443
|
-
/**
|
|
444
|
-
* If true, creates a new local branch and then switches to it
|
|
445
|
-
*
|
|
446
|
-
* @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
|
|
447
|
-
*/
|
|
448
|
-
isNew: import_zod4.z.boolean().optional()
|
|
449
|
-
});
|
|
450
|
-
var gitLogOptionsSchema = import_zod4.z.object({
|
|
451
|
-
/**
|
|
452
|
-
* Limit the result to given number of commits
|
|
453
|
-
*/
|
|
454
|
-
limit: import_zod4.z.number().optional(),
|
|
455
|
-
/**
|
|
456
|
-
* Only list commits that are between given SHAs or tag names
|
|
457
|
-
*
|
|
458
|
-
* Note that the commits of from and to are not included in the result
|
|
459
|
-
*/
|
|
460
|
-
between: import_zod4.z.object({
|
|
461
|
-
/**
|
|
462
|
-
* From the oldest commit
|
|
463
|
-
*/
|
|
464
|
-
from: import_zod4.z.string(),
|
|
465
|
-
/**
|
|
466
|
-
* To the newest commit
|
|
467
|
-
*
|
|
468
|
-
* Defaults to the current HEAD
|
|
469
|
-
*/
|
|
470
|
-
to: import_zod4.z.string().optional()
|
|
471
|
-
})
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
// src/schema/serviceSchema.ts
|
|
475
|
-
var serviceTypeSchema = import_zod5.z.enum([
|
|
476
|
-
"Git",
|
|
477
|
-
"GitTag",
|
|
478
|
-
"User",
|
|
479
|
-
"Project",
|
|
480
|
-
"Asset",
|
|
481
|
-
"JsonFile",
|
|
482
|
-
"Search",
|
|
483
|
-
"Collection",
|
|
484
|
-
"Entry",
|
|
485
|
-
"Value"
|
|
486
|
-
]);
|
|
487
|
-
var listSchema = import_zod5.z.object({
|
|
488
|
-
projectId: uuidSchema,
|
|
489
|
-
limit: import_zod5.z.number().optional(),
|
|
490
|
-
offset: import_zod5.z.number().optional()
|
|
491
|
-
});
|
|
492
|
-
var listCollectionsSchema = listSchema;
|
|
493
|
-
var listEntriesSchema = listSchema.extend({
|
|
494
|
-
collectionId: uuidSchema
|
|
495
|
-
});
|
|
496
|
-
var listAssetsSchema = listSchema;
|
|
497
|
-
var listProjectsSchema = listSchema.omit({
|
|
498
|
-
projectId: true
|
|
499
|
-
});
|
|
500
|
-
var listGitTagsSchema = import_zod5.z.object({
|
|
501
|
-
path: gitRepositoryPathSchema
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
// src/util/node.ts
|
|
505
|
-
var node_exports = {};
|
|
506
|
-
__export(node_exports, {
|
|
507
|
-
assignDefaultIfMissing: () => assignDefaultIfMissing,
|
|
508
|
-
files: () => files,
|
|
509
|
-
folders: () => folders,
|
|
510
|
-
fromPath: () => fromPath,
|
|
511
|
-
getDuplicates: () => getDuplicates,
|
|
512
|
-
getRelativePath: () => getRelativePath,
|
|
513
|
-
isNoError: () => isNoError,
|
|
514
|
-
notEmpty: () => notEmpty,
|
|
515
|
-
pathTo: () => pathTo,
|
|
516
|
-
returnResolved: () => returnResolved,
|
|
517
|
-
spawnChildProcess: () => spawnChildProcess,
|
|
518
|
-
workingDirectory: () => workingDirectory
|
|
519
|
-
});
|
|
520
|
-
var import_child_process = require("child_process");
|
|
521
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
522
|
-
var import_lodash_es = require("lodash-es");
|
|
523
|
-
var import_os = __toESM(require("os"), 1);
|
|
524
|
-
var import_path = __toESM(require("path"), 1);
|
|
525
|
-
|
|
526
|
-
// src/schema/projectSchema.ts
|
|
527
|
-
var import_zod9 = require("zod");
|
|
528
|
-
|
|
529
382
|
// src/schema/collectionSchema.ts
|
|
530
|
-
var
|
|
383
|
+
var import_zod6 = __toESM(require("zod"), 1);
|
|
531
384
|
|
|
532
385
|
// src/schema/entrySchema.ts
|
|
533
|
-
var
|
|
386
|
+
var import_zod5 = __toESM(require("zod"), 1);
|
|
534
387
|
|
|
535
388
|
// src/schema/valueSchema.ts
|
|
536
|
-
var
|
|
537
|
-
var ValueTypeSchema =
|
|
389
|
+
var import_zod4 = __toESM(require("zod"), 1);
|
|
390
|
+
var ValueTypeSchema = import_zod4.default.enum([
|
|
538
391
|
"string",
|
|
539
392
|
"number",
|
|
540
393
|
"boolean",
|
|
541
394
|
"reference"
|
|
542
395
|
]);
|
|
543
|
-
var ValueInputTypeSchema =
|
|
396
|
+
var ValueInputTypeSchema = import_zod4.default.enum([
|
|
544
397
|
// String
|
|
545
398
|
"text",
|
|
546
399
|
"textarea",
|
|
@@ -562,67 +415,67 @@ var ValueInputTypeSchema = import_zod6.default.enum([
|
|
|
562
415
|
"entry"
|
|
563
416
|
// 'sharedValue', // @todo
|
|
564
417
|
]);
|
|
565
|
-
var ValueInputWidthSchema =
|
|
566
|
-
var ValueDefinitionBaseSchema =
|
|
418
|
+
var ValueInputWidthSchema = import_zod4.default.enum(["12", "6", "4", "3"]);
|
|
419
|
+
var ValueDefinitionBaseSchema = import_zod4.default.object({
|
|
567
420
|
id: uuidSchema.readonly(),
|
|
568
421
|
label: translatableStringSchema,
|
|
569
422
|
description: translatableStringSchema,
|
|
570
|
-
isRequired:
|
|
571
|
-
isDisabled:
|
|
572
|
-
isUnique:
|
|
423
|
+
isRequired: import_zod4.default.boolean(),
|
|
424
|
+
isDisabled: import_zod4.default.boolean(),
|
|
425
|
+
isUnique: import_zod4.default.boolean(),
|
|
573
426
|
inputWidth: ValueInputWidthSchema
|
|
574
427
|
});
|
|
575
428
|
var StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
|
|
576
429
|
{
|
|
577
|
-
valueType:
|
|
578
|
-
defaultValue:
|
|
430
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.string),
|
|
431
|
+
defaultValue: import_zod4.default.string().nullable()
|
|
579
432
|
}
|
|
580
433
|
);
|
|
581
434
|
var textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
582
435
|
{
|
|
583
|
-
inputType:
|
|
584
|
-
min:
|
|
585
|
-
max:
|
|
436
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.text),
|
|
437
|
+
min: import_zod4.default.number().nullable(),
|
|
438
|
+
max: import_zod4.default.number().nullable()
|
|
586
439
|
}
|
|
587
440
|
);
|
|
588
441
|
var textareaValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
589
|
-
inputType:
|
|
590
|
-
min:
|
|
591
|
-
max:
|
|
442
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.textarea),
|
|
443
|
+
min: import_zod4.default.number().nullable(),
|
|
444
|
+
max: import_zod4.default.number().nullable()
|
|
592
445
|
});
|
|
593
446
|
var emailValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
594
|
-
inputType:
|
|
595
|
-
defaultValue:
|
|
447
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.email),
|
|
448
|
+
defaultValue: import_zod4.default.string().email().nullable()
|
|
596
449
|
});
|
|
597
450
|
var urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
598
|
-
inputType:
|
|
599
|
-
defaultValue:
|
|
451
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.url),
|
|
452
|
+
defaultValue: import_zod4.default.string().url().nullable()
|
|
600
453
|
});
|
|
601
454
|
var ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
602
|
-
inputType:
|
|
603
|
-
defaultValue:
|
|
455
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.ip),
|
|
456
|
+
defaultValue: import_zod4.default.string().ip().nullable()
|
|
604
457
|
});
|
|
605
458
|
var dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
606
459
|
{
|
|
607
|
-
inputType:
|
|
608
|
-
defaultValue:
|
|
460
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.date),
|
|
461
|
+
defaultValue: import_zod4.default.string().date().nullable()
|
|
609
462
|
}
|
|
610
463
|
);
|
|
611
464
|
var timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
612
465
|
{
|
|
613
|
-
inputType:
|
|
614
|
-
defaultValue:
|
|
466
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.time),
|
|
467
|
+
defaultValue: import_zod4.default.string().time().nullable()
|
|
615
468
|
}
|
|
616
469
|
);
|
|
617
470
|
var datetimeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
618
|
-
inputType:
|
|
619
|
-
defaultValue:
|
|
471
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.datetime),
|
|
472
|
+
defaultValue: import_zod4.default.string().datetime().nullable()
|
|
620
473
|
});
|
|
621
474
|
var telephoneValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
622
|
-
inputType:
|
|
475
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.telephone)
|
|
623
476
|
// defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
|
|
624
477
|
});
|
|
625
|
-
var stringValueDefinitionSchema =
|
|
478
|
+
var stringValueDefinitionSchema = import_zod4.default.union([
|
|
626
479
|
textValueDefinitionSchema,
|
|
627
480
|
textareaValueDefinitionSchema,
|
|
628
481
|
emailValueDefinitionSchema,
|
|
@@ -635,50 +488,50 @@ var stringValueDefinitionSchema = import_zod6.default.union([
|
|
|
635
488
|
]);
|
|
636
489
|
var NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
|
|
637
490
|
{
|
|
638
|
-
valueType:
|
|
639
|
-
min:
|
|
640
|
-
max:
|
|
641
|
-
isUnique:
|
|
642
|
-
defaultValue:
|
|
491
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.number),
|
|
492
|
+
min: import_zod4.default.number().nullable(),
|
|
493
|
+
max: import_zod4.default.number().nullable(),
|
|
494
|
+
isUnique: import_zod4.default.literal(false),
|
|
495
|
+
defaultValue: import_zod4.default.number().nullable()
|
|
643
496
|
}
|
|
644
497
|
);
|
|
645
498
|
var numberValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
|
|
646
|
-
inputType:
|
|
499
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.number)
|
|
647
500
|
});
|
|
648
501
|
var rangeValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
|
|
649
|
-
inputType:
|
|
502
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.range),
|
|
650
503
|
// Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
|
|
651
|
-
isRequired:
|
|
652
|
-
min:
|
|
653
|
-
max:
|
|
654
|
-
defaultValue:
|
|
504
|
+
isRequired: import_zod4.default.literal(true),
|
|
505
|
+
min: import_zod4.default.number(),
|
|
506
|
+
max: import_zod4.default.number(),
|
|
507
|
+
defaultValue: import_zod4.default.number()
|
|
655
508
|
});
|
|
656
509
|
var BooleanValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
|
|
657
|
-
valueType:
|
|
510
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.boolean),
|
|
658
511
|
// Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
|
|
659
|
-
isRequired:
|
|
660
|
-
defaultValue:
|
|
661
|
-
isUnique:
|
|
512
|
+
isRequired: import_zod4.default.literal(true),
|
|
513
|
+
defaultValue: import_zod4.default.boolean(),
|
|
514
|
+
isUnique: import_zod4.default.literal(false)
|
|
662
515
|
});
|
|
663
516
|
var toggleValueDefinitionSchema = BooleanValueDefinitionBaseSchema.extend({
|
|
664
|
-
inputType:
|
|
517
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.toggle)
|
|
665
518
|
});
|
|
666
519
|
var ReferenceValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
|
|
667
|
-
valueType:
|
|
520
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.reference)
|
|
668
521
|
});
|
|
669
522
|
var assetValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
|
|
670
|
-
inputType:
|
|
671
|
-
allowedMimeTypes:
|
|
672
|
-
min:
|
|
673
|
-
max:
|
|
523
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.asset),
|
|
524
|
+
allowedMimeTypes: import_zod4.default.array(supportedAssetMimeTypeSchema).min(1),
|
|
525
|
+
min: import_zod4.default.number().nullable(),
|
|
526
|
+
max: import_zod4.default.number().nullable()
|
|
674
527
|
});
|
|
675
528
|
var entryValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
|
|
676
|
-
inputType:
|
|
677
|
-
ofCollections:
|
|
678
|
-
min:
|
|
679
|
-
max:
|
|
529
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.entry),
|
|
530
|
+
ofCollections: import_zod4.default.array(uuidSchema),
|
|
531
|
+
min: import_zod4.default.number().nullable(),
|
|
532
|
+
max: import_zod4.default.number().nullable()
|
|
680
533
|
});
|
|
681
|
-
var valueDefinitionSchema =
|
|
534
|
+
var valueDefinitionSchema = import_zod4.default.union([
|
|
682
535
|
stringValueDefinitionSchema,
|
|
683
536
|
numberValueDefinitionSchema,
|
|
684
537
|
rangeValueDefinitionSchema,
|
|
@@ -687,65 +540,65 @@ var valueDefinitionSchema = import_zod6.default.union([
|
|
|
687
540
|
entryValueDefinitionSchema
|
|
688
541
|
// sharedValueDefinitionSchema,
|
|
689
542
|
]);
|
|
690
|
-
var valueContentReferenceBase =
|
|
543
|
+
var valueContentReferenceBase = import_zod4.default.object({
|
|
691
544
|
id: uuidSchema
|
|
692
545
|
});
|
|
693
546
|
var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
|
|
694
547
|
language: supportedLanguageSchema
|
|
695
548
|
});
|
|
696
549
|
var valueContentReferenceToAssetSchema = valueContentReferenceWithLanguageBase.extend({
|
|
697
|
-
objectType:
|
|
550
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.asset)
|
|
698
551
|
});
|
|
699
552
|
var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
|
|
700
|
-
objectType:
|
|
553
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.collection)
|
|
701
554
|
});
|
|
702
555
|
var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
|
|
703
|
-
objectType:
|
|
556
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.entry)
|
|
704
557
|
});
|
|
705
|
-
var valueContentReferenceSchema =
|
|
558
|
+
var valueContentReferenceSchema = import_zod4.default.union([
|
|
706
559
|
valueContentReferenceToAssetSchema,
|
|
707
560
|
valueContentReferenceToCollectionSchema,
|
|
708
561
|
valueContentReferenceToEntrySchema
|
|
709
562
|
// valueContentReferenceToSharedValueSchema,
|
|
710
563
|
]);
|
|
711
|
-
var resolvedValueContentReferenceSchema =
|
|
564
|
+
var resolvedValueContentReferenceSchema = import_zod4.default.union([
|
|
712
565
|
assetSchema,
|
|
713
|
-
|
|
566
|
+
import_zod4.default.lazy(() => entrySchema)
|
|
714
567
|
// Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types
|
|
715
568
|
// resolvedValueContentReferenceToSharedValueSchema,
|
|
716
569
|
]);
|
|
717
|
-
var directValueBaseSchema =
|
|
718
|
-
objectType:
|
|
570
|
+
var directValueBaseSchema = import_zod4.default.object({
|
|
571
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.value).readonly(),
|
|
719
572
|
definitionId: uuidSchema.readonly()
|
|
720
573
|
});
|
|
721
574
|
var directStringValueSchema = directValueBaseSchema.extend({
|
|
722
|
-
valueType:
|
|
575
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.string).readonly(),
|
|
723
576
|
content: translatableStringSchema
|
|
724
577
|
});
|
|
725
578
|
var directNumberValueSchema = directValueBaseSchema.extend({
|
|
726
|
-
valueType:
|
|
579
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.number).readonly(),
|
|
727
580
|
content: translatableNumberSchema
|
|
728
581
|
});
|
|
729
582
|
var directBooleanValueSchema = directValueBaseSchema.extend({
|
|
730
|
-
valueType:
|
|
583
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.boolean).readonly(),
|
|
731
584
|
content: translatableBooleanSchema
|
|
732
585
|
});
|
|
733
|
-
var directValueSchema =
|
|
586
|
+
var directValueSchema = import_zod4.default.union([
|
|
734
587
|
directStringValueSchema,
|
|
735
588
|
directNumberValueSchema,
|
|
736
589
|
directBooleanValueSchema
|
|
737
590
|
]);
|
|
738
|
-
var referencedValueSchema =
|
|
739
|
-
objectType:
|
|
591
|
+
var referencedValueSchema = import_zod4.default.object({
|
|
592
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.value).readonly(),
|
|
740
593
|
definitionId: uuidSchema.readonly(),
|
|
741
|
-
valueType:
|
|
594
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.reference).readonly(),
|
|
742
595
|
content: translatableArrayOf(valueContentReferenceSchema)
|
|
743
596
|
});
|
|
744
|
-
var valueSchema =
|
|
597
|
+
var valueSchema = import_zod4.default.union([directValueSchema, referencedValueSchema]);
|
|
745
598
|
var resolvedReferencedValueSchema = referencedValueSchema.extend({
|
|
746
599
|
content: translatableArrayOf(resolvedValueContentReferenceSchema)
|
|
747
600
|
});
|
|
748
|
-
var resolvedValueSchema =
|
|
601
|
+
var resolvedValueSchema = import_zod4.default.union([
|
|
749
602
|
directValueSchema,
|
|
750
603
|
resolvedReferencedValueSchema
|
|
751
604
|
]);
|
|
@@ -767,10 +620,10 @@ function getValueContentSchemaFromDefinition(definition) {
|
|
|
767
620
|
}
|
|
768
621
|
}
|
|
769
622
|
function getBooleanValueContentSchema(definition) {
|
|
770
|
-
return
|
|
623
|
+
return import_zod4.default.boolean();
|
|
771
624
|
}
|
|
772
625
|
function getNumberValueContentSchema(definition) {
|
|
773
|
-
let schema =
|
|
626
|
+
let schema = import_zod4.default.number();
|
|
774
627
|
if (definition.min) {
|
|
775
628
|
schema = schema.min(definition.min);
|
|
776
629
|
}
|
|
@@ -783,7 +636,7 @@ function getNumberValueContentSchema(definition) {
|
|
|
783
636
|
return schema;
|
|
784
637
|
}
|
|
785
638
|
function getStringValueContentSchema(definition) {
|
|
786
|
-
let schema =
|
|
639
|
+
let schema = import_zod4.default.string().trim();
|
|
787
640
|
if ("min" in definition && definition.min) {
|
|
788
641
|
schema = schema.min(definition.min);
|
|
789
642
|
}
|
|
@@ -822,12 +675,12 @@ function getReferenceValueContentSchema(definition) {
|
|
|
822
675
|
switch (definition.inputType) {
|
|
823
676
|
case ValueInputTypeSchema.Enum.asset:
|
|
824
677
|
{
|
|
825
|
-
schema =
|
|
678
|
+
schema = import_zod4.default.array(valueContentReferenceToAssetSchema);
|
|
826
679
|
}
|
|
827
680
|
break;
|
|
828
681
|
case ValueInputTypeSchema.Enum.entry:
|
|
829
682
|
{
|
|
830
|
-
schema =
|
|
683
|
+
schema = import_zod4.default.array(valueContentReferenceToEntrySchema);
|
|
831
684
|
}
|
|
832
685
|
break;
|
|
833
686
|
}
|
|
@@ -845,11 +698,11 @@ function getReferenceValueContentSchema(definition) {
|
|
|
845
698
|
|
|
846
699
|
// src/schema/entrySchema.ts
|
|
847
700
|
var entryFileSchema = baseFileSchema.extend({
|
|
848
|
-
objectType:
|
|
849
|
-
values:
|
|
701
|
+
objectType: import_zod5.default.literal(objectTypeSchema.Enum.entry).readonly(),
|
|
702
|
+
values: import_zod5.default.array(valueSchema)
|
|
850
703
|
});
|
|
851
704
|
var entrySchema = entryFileSchema.extend({
|
|
852
|
-
values:
|
|
705
|
+
values: import_zod5.default.array(import_zod5.default.lazy(() => resolvedValueSchema))
|
|
853
706
|
});
|
|
854
707
|
var entryExportSchema = entrySchema.extend({});
|
|
855
708
|
var createEntrySchema = entryFileSchema.omit({
|
|
@@ -860,9 +713,9 @@ var createEntrySchema = entryFileSchema.omit({
|
|
|
860
713
|
}).extend({
|
|
861
714
|
projectId: uuidSchema.readonly(),
|
|
862
715
|
collectionId: uuidSchema.readonly(),
|
|
863
|
-
values:
|
|
716
|
+
values: import_zod5.default.array(valueSchema)
|
|
864
717
|
});
|
|
865
|
-
var readEntrySchema =
|
|
718
|
+
var readEntrySchema = import_zod5.default.object({
|
|
866
719
|
id: uuidSchema.readonly(),
|
|
867
720
|
projectId: uuidSchema.readonly(),
|
|
868
721
|
collectionId: uuidSchema.readonly()
|
|
@@ -876,29 +729,29 @@ var updateEntrySchema = entrySchema.omit({
|
|
|
876
729
|
collectionId: uuidSchema.readonly()
|
|
877
730
|
});
|
|
878
731
|
var deleteEntrySchema = readEntrySchema.extend({});
|
|
879
|
-
var countEntriesSchema =
|
|
732
|
+
var countEntriesSchema = import_zod5.default.object({
|
|
880
733
|
projectId: uuidSchema.readonly(),
|
|
881
734
|
collectionId: uuidSchema.readonly()
|
|
882
735
|
});
|
|
883
736
|
|
|
884
737
|
// src/schema/collectionSchema.ts
|
|
885
738
|
var collectionFileSchema = baseFileSchema.extend({
|
|
886
|
-
objectType:
|
|
887
|
-
name:
|
|
739
|
+
objectType: import_zod6.default.literal(objectTypeSchema.Enum.collection).readonly(),
|
|
740
|
+
name: import_zod6.default.object({
|
|
888
741
|
singular: translatableStringSchema,
|
|
889
742
|
plural: translatableStringSchema
|
|
890
743
|
}),
|
|
891
|
-
slug:
|
|
892
|
-
singular:
|
|
893
|
-
plural:
|
|
744
|
+
slug: import_zod6.default.object({
|
|
745
|
+
singular: import_zod6.default.string(),
|
|
746
|
+
plural: import_zod6.default.string()
|
|
894
747
|
}),
|
|
895
748
|
description: translatableStringSchema,
|
|
896
749
|
icon: supportedIconSchema,
|
|
897
|
-
valueDefinitions:
|
|
750
|
+
valueDefinitions: import_zod6.default.array(valueDefinitionSchema)
|
|
898
751
|
});
|
|
899
752
|
var collectionSchema = collectionFileSchema.extend({});
|
|
900
753
|
var collectionExportSchema = collectionSchema.extend({
|
|
901
|
-
entries:
|
|
754
|
+
entries: import_zod6.default.array(entryExportSchema)
|
|
902
755
|
});
|
|
903
756
|
var createCollectionSchema = collectionSchema.omit({
|
|
904
757
|
id: true,
|
|
@@ -908,7 +761,7 @@ var createCollectionSchema = collectionSchema.omit({
|
|
|
908
761
|
}).extend({
|
|
909
762
|
projectId: uuidSchema.readonly()
|
|
910
763
|
});
|
|
911
|
-
var readCollectionSchema =
|
|
764
|
+
var readCollectionSchema = import_zod6.default.object({
|
|
912
765
|
id: uuidSchema.readonly(),
|
|
913
766
|
projectId: uuidSchema.readonly()
|
|
914
767
|
});
|
|
@@ -923,19 +776,149 @@ var updateCollectionSchema = collectionFileSchema.pick({
|
|
|
923
776
|
projectId: uuidSchema.readonly()
|
|
924
777
|
});
|
|
925
778
|
var deleteCollectionSchema = readCollectionSchema.extend({});
|
|
926
|
-
var countCollectionsSchema =
|
|
779
|
+
var countCollectionsSchema = import_zod6.default.object({
|
|
927
780
|
projectId: uuidSchema.readonly()
|
|
928
781
|
});
|
|
929
782
|
|
|
783
|
+
// src/schema/coreSchema.ts
|
|
784
|
+
var import_zod7 = require("zod");
|
|
785
|
+
var elekIoCoreOptionsSchema = import_zod7.z.object({
|
|
786
|
+
/**
|
|
787
|
+
* The environment elek.io Core is currently running in
|
|
788
|
+
*/
|
|
789
|
+
environment: environmentSchema,
|
|
790
|
+
/**
|
|
791
|
+
* The current version of elek.io Core
|
|
792
|
+
*/
|
|
793
|
+
version: versionSchema,
|
|
794
|
+
file: import_zod7.z.object({
|
|
795
|
+
json: import_zod7.z.object({
|
|
796
|
+
/**
|
|
797
|
+
* If set, adds indentation with spaces (number) or escape character (string)
|
|
798
|
+
* and line break characters to saved JSON files on disk, to make them easier to read.
|
|
799
|
+
* Defaults to 2 spaces of indentation.
|
|
800
|
+
*/
|
|
801
|
+
indentation: import_zod7.z.union([import_zod7.z.number(), import_zod7.z.string()])
|
|
802
|
+
})
|
|
803
|
+
})
|
|
804
|
+
});
|
|
805
|
+
var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
|
|
806
|
+
version: true
|
|
807
|
+
}).partial({
|
|
808
|
+
environment: true,
|
|
809
|
+
file: true
|
|
810
|
+
}).optional();
|
|
811
|
+
|
|
812
|
+
// src/schema/gitSchema.ts
|
|
813
|
+
var import_zod8 = require("zod");
|
|
814
|
+
var gitRepositoryPathSchema = import_zod8.z.string();
|
|
815
|
+
var gitSignatureSchema = import_zod8.z.object({
|
|
816
|
+
name: import_zod8.z.string(),
|
|
817
|
+
email: import_zod8.z.string()
|
|
818
|
+
});
|
|
819
|
+
var gitCommitSchema = import_zod8.z.object({
|
|
820
|
+
/**
|
|
821
|
+
* SHA-1 hash of the commit
|
|
822
|
+
*/
|
|
823
|
+
hash: import_zod8.z.string(),
|
|
824
|
+
message: import_zod8.z.string(),
|
|
825
|
+
author: gitSignatureSchema,
|
|
826
|
+
timestamp: import_zod8.z.number(),
|
|
827
|
+
tag: import_zod8.z.string().nullable()
|
|
828
|
+
});
|
|
829
|
+
var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
|
|
830
|
+
GitCommitIconNative2["INIT"] = ":tada:";
|
|
831
|
+
GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
|
|
832
|
+
GitCommitIconNative2["UPDATE"] = ":wrench:";
|
|
833
|
+
GitCommitIconNative2["DELETE"] = ":fire:";
|
|
834
|
+
return GitCommitIconNative2;
|
|
835
|
+
})(GitCommitIconNative || {});
|
|
836
|
+
var gitCommitIconSchema = import_zod8.z.nativeEnum(GitCommitIconNative);
|
|
837
|
+
var gitInitOptionsSchema = import_zod8.z.object({
|
|
838
|
+
/**
|
|
839
|
+
* 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).
|
|
840
|
+
*/
|
|
841
|
+
initialBranch: import_zod8.z.string()
|
|
842
|
+
});
|
|
843
|
+
var gitCloneOptionsSchema = import_zod8.z.object({
|
|
844
|
+
/**
|
|
845
|
+
* 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.
|
|
846
|
+
*/
|
|
847
|
+
depth: import_zod8.z.number(),
|
|
848
|
+
/**
|
|
849
|
+
* 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.
|
|
850
|
+
*/
|
|
851
|
+
singleBranch: import_zod8.z.boolean(),
|
|
852
|
+
/**
|
|
853
|
+
* 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.
|
|
854
|
+
*/
|
|
855
|
+
branch: import_zod8.z.string()
|
|
856
|
+
});
|
|
857
|
+
var gitSwitchOptionsSchema = import_zod8.z.object({
|
|
858
|
+
/**
|
|
859
|
+
* If true, creates a new local branch and then switches to it
|
|
860
|
+
*
|
|
861
|
+
* @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
|
|
862
|
+
*/
|
|
863
|
+
isNew: import_zod8.z.boolean().optional()
|
|
864
|
+
});
|
|
865
|
+
var gitLogOptionsSchema = import_zod8.z.object({
|
|
866
|
+
/**
|
|
867
|
+
* Limit the result to given number of commits
|
|
868
|
+
*/
|
|
869
|
+
limit: import_zod8.z.number().optional(),
|
|
870
|
+
/**
|
|
871
|
+
* Only list commits that are between given SHAs or tag names
|
|
872
|
+
*
|
|
873
|
+
* Note that the commits of from and to are not included in the result
|
|
874
|
+
*/
|
|
875
|
+
between: import_zod8.z.object({
|
|
876
|
+
/**
|
|
877
|
+
* From the oldest commit
|
|
878
|
+
*/
|
|
879
|
+
from: import_zod8.z.string(),
|
|
880
|
+
/**
|
|
881
|
+
* To the newest commit
|
|
882
|
+
*
|
|
883
|
+
* Defaults to the current HEAD
|
|
884
|
+
*/
|
|
885
|
+
to: import_zod8.z.string().optional()
|
|
886
|
+
})
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
// src/schema/gitTagSchema.ts
|
|
890
|
+
var import_zod9 = require("zod");
|
|
891
|
+
var gitTagSchema = import_zod9.z.object({
|
|
892
|
+
id: uuidSchema,
|
|
893
|
+
message: import_zod9.z.string(),
|
|
894
|
+
author: gitSignatureSchema,
|
|
895
|
+
timestamp: import_zod9.z.number()
|
|
896
|
+
});
|
|
897
|
+
var createGitTagSchema = gitTagSchema.pick({
|
|
898
|
+
message: true
|
|
899
|
+
}).extend({
|
|
900
|
+
path: gitRepositoryPathSchema,
|
|
901
|
+
hash: gitCommitSchema.shape.hash.optional()
|
|
902
|
+
});
|
|
903
|
+
var readGitTagSchema = import_zod9.z.object({
|
|
904
|
+
path: gitRepositoryPathSchema,
|
|
905
|
+
id: uuidSchema.readonly()
|
|
906
|
+
});
|
|
907
|
+
var deleteGitTagSchema = readGitTagSchema.extend({});
|
|
908
|
+
var countGitTagsSchema = import_zod9.z.object({
|
|
909
|
+
path: gitRepositoryPathSchema
|
|
910
|
+
});
|
|
911
|
+
|
|
930
912
|
// src/schema/projectSchema.ts
|
|
931
|
-
var
|
|
932
|
-
var
|
|
933
|
-
|
|
913
|
+
var import_zod10 = require("zod");
|
|
914
|
+
var projectStatusSchema = import_zod10.z.enum(["foo", "bar", "todo"]);
|
|
915
|
+
var projectSettingsSchema = import_zod10.z.object({
|
|
916
|
+
language: import_zod10.z.object({
|
|
934
917
|
default: supportedLanguageSchema,
|
|
935
|
-
supported:
|
|
918
|
+
supported: import_zod10.z.array(supportedLanguageSchema)
|
|
936
919
|
})
|
|
937
920
|
});
|
|
938
|
-
var projectFolderSchema =
|
|
921
|
+
var projectFolderSchema = import_zod10.z.enum([
|
|
939
922
|
"assets",
|
|
940
923
|
"collections",
|
|
941
924
|
"shared-values",
|
|
@@ -945,18 +928,18 @@ var projectFolderSchema = import_zod9.z.enum([
|
|
|
945
928
|
// 'theme',
|
|
946
929
|
]);
|
|
947
930
|
var projectFileSchema = baseFileSchema.extend({
|
|
948
|
-
objectType:
|
|
931
|
+
objectType: import_zod10.z.literal(objectTypeSchema.Enum.project).readonly(),
|
|
949
932
|
coreVersion: versionSchema,
|
|
950
|
-
name:
|
|
951
|
-
description:
|
|
933
|
+
name: import_zod10.z.string().trim().min(1, "shared.projectNameRequired"),
|
|
934
|
+
description: import_zod10.z.string().trim().min(1, "shared.projectDescriptionRequired"),
|
|
952
935
|
version: versionSchema,
|
|
953
936
|
status: projectStatusSchema,
|
|
954
937
|
settings: projectSettingsSchema
|
|
955
938
|
});
|
|
956
939
|
var projectSchema = projectFileSchema.extend({});
|
|
957
940
|
var projectExportSchema = projectSchema.extend({
|
|
958
|
-
assets:
|
|
959
|
-
collections:
|
|
941
|
+
assets: import_zod10.z.array(assetExportSchema),
|
|
942
|
+
collections: import_zod10.z.array(collectionExportSchema)
|
|
960
943
|
});
|
|
961
944
|
var createProjectSchema = projectSchema.pick({
|
|
962
945
|
name: true,
|
|
@@ -966,7 +949,7 @@ var createProjectSchema = projectSchema.pick({
|
|
|
966
949
|
description: true,
|
|
967
950
|
settings: true
|
|
968
951
|
});
|
|
969
|
-
var readProjectSchema =
|
|
952
|
+
var readProjectSchema = import_zod10.z.object({
|
|
970
953
|
id: uuidSchema.readonly()
|
|
971
954
|
});
|
|
972
955
|
var updateProjectSchema = projectSchema.pick({
|
|
@@ -979,11 +962,11 @@ var updateProjectSchema = projectSchema.pick({
|
|
|
979
962
|
description: true,
|
|
980
963
|
settings: true
|
|
981
964
|
});
|
|
982
|
-
var upgradeProjectSchema =
|
|
965
|
+
var upgradeProjectSchema = import_zod10.z.object({
|
|
983
966
|
id: uuidSchema.readonly()
|
|
984
967
|
});
|
|
985
968
|
var deleteProjectSchema = readProjectSchema.extend({});
|
|
986
|
-
var projectUpgradeSchema =
|
|
969
|
+
var projectUpgradeSchema = import_zod10.z.object({
|
|
987
970
|
/**
|
|
988
971
|
* The Core version the Project will be upgraded to
|
|
989
972
|
*/
|
|
@@ -991,83 +974,184 @@ var projectUpgradeSchema = import_zod9.z.object({
|
|
|
991
974
|
/**
|
|
992
975
|
* Function that will be executed in the process of upgrading a Project
|
|
993
976
|
*/
|
|
994
|
-
run:
|
|
977
|
+
run: import_zod10.z.function().args(projectFileSchema).returns(import_zod10.z.promise(import_zod10.z.void()))
|
|
995
978
|
});
|
|
996
|
-
var cloneProjectSchema =
|
|
997
|
-
url:
|
|
979
|
+
var cloneProjectSchema = import_zod10.z.object({
|
|
980
|
+
url: import_zod10.z.string()
|
|
998
981
|
});
|
|
999
|
-
var listBranchesProjectSchema =
|
|
982
|
+
var listBranchesProjectSchema = import_zod10.z.object({
|
|
1000
983
|
id: uuidSchema.readonly()
|
|
1001
984
|
});
|
|
1002
|
-
var currentBranchProjectSchema =
|
|
985
|
+
var currentBranchProjectSchema = import_zod10.z.object({
|
|
1003
986
|
id: uuidSchema.readonly()
|
|
1004
987
|
});
|
|
1005
|
-
var switchBranchProjectSchema =
|
|
988
|
+
var switchBranchProjectSchema = import_zod10.z.object({
|
|
1006
989
|
id: uuidSchema.readonly(),
|
|
1007
|
-
branch:
|
|
990
|
+
branch: import_zod10.z.string(),
|
|
1008
991
|
options: gitSwitchOptionsSchema.optional()
|
|
1009
992
|
});
|
|
1010
|
-
var getRemoteOriginUrlProjectSchema =
|
|
993
|
+
var getRemoteOriginUrlProjectSchema = import_zod10.z.object({
|
|
1011
994
|
id: uuidSchema.readonly()
|
|
1012
995
|
});
|
|
1013
|
-
var setRemoteOriginUrlProjectSchema =
|
|
996
|
+
var setRemoteOriginUrlProjectSchema = import_zod10.z.object({
|
|
1014
997
|
id: uuidSchema.readonly(),
|
|
1015
|
-
url:
|
|
998
|
+
url: import_zod10.z.string()
|
|
1016
999
|
});
|
|
1017
|
-
var getChangesProjectSchema =
|
|
1000
|
+
var getChangesProjectSchema = import_zod10.z.object({
|
|
1018
1001
|
id: uuidSchema.readonly()
|
|
1019
1002
|
});
|
|
1020
|
-
var synchronizeProjectSchema =
|
|
1003
|
+
var synchronizeProjectSchema = import_zod10.z.object({
|
|
1021
1004
|
id: uuidSchema.readonly()
|
|
1022
1005
|
});
|
|
1023
|
-
var searchProjectSchema =
|
|
1006
|
+
var searchProjectSchema = import_zod10.z.object({
|
|
1024
1007
|
id: uuidSchema.readonly(),
|
|
1025
|
-
query:
|
|
1008
|
+
query: import_zod10.z.string(),
|
|
1026
1009
|
language: supportedLanguageSchema,
|
|
1027
|
-
type:
|
|
1010
|
+
type: import_zod10.z.array(objectTypeSchema).optional()
|
|
1028
1011
|
});
|
|
1029
1012
|
|
|
1030
|
-
// src/
|
|
1031
|
-
var
|
|
1032
|
-
var
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1013
|
+
// src/schema/serviceSchema.ts
|
|
1014
|
+
var import_zod11 = require("zod");
|
|
1015
|
+
var serviceTypeSchema = import_zod11.z.enum([
|
|
1016
|
+
"Git",
|
|
1017
|
+
"GitTag",
|
|
1018
|
+
"User",
|
|
1019
|
+
"Project",
|
|
1020
|
+
"Asset",
|
|
1021
|
+
"JsonFile",
|
|
1022
|
+
"Search",
|
|
1023
|
+
"Collection",
|
|
1024
|
+
"Entry",
|
|
1025
|
+
"Value"
|
|
1026
|
+
]);
|
|
1027
|
+
var listSchema = import_zod11.z.object({
|
|
1028
|
+
projectId: uuidSchema,
|
|
1029
|
+
limit: import_zod11.z.number().optional(),
|
|
1030
|
+
offset: import_zod11.z.number().optional()
|
|
1031
|
+
});
|
|
1032
|
+
var listCollectionsSchema = listSchema;
|
|
1033
|
+
var listEntriesSchema = listSchema.extend({
|
|
1034
|
+
collectionId: uuidSchema
|
|
1035
|
+
});
|
|
1036
|
+
var listAssetsSchema = listSchema;
|
|
1037
|
+
var listProjectsSchema = listSchema.omit({
|
|
1038
|
+
projectId: true
|
|
1039
|
+
});
|
|
1040
|
+
var listGitTagsSchema = import_zod11.z.object({
|
|
1041
|
+
path: gitRepositoryPathSchema
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
// src/schema/userSchema.ts
|
|
1045
|
+
var import_zod12 = __toESM(require("zod"), 1);
|
|
1046
|
+
var UserTypeSchema = import_zod12.default.enum(["local", "cloud"]);
|
|
1047
|
+
var baseUserSchema = gitSignatureSchema.extend({
|
|
1048
|
+
userType: UserTypeSchema,
|
|
1049
|
+
language: supportedLanguageSchema
|
|
1050
|
+
});
|
|
1051
|
+
var localUserSchema = baseUserSchema.extend({
|
|
1052
|
+
userType: import_zod12.default.literal(UserTypeSchema.Enum.local)
|
|
1053
|
+
});
|
|
1054
|
+
var cloudUserSchema = baseUserSchema.extend({
|
|
1055
|
+
userType: import_zod12.default.literal(UserTypeSchema.Enum.cloud),
|
|
1056
|
+
id: uuidSchema
|
|
1057
|
+
});
|
|
1058
|
+
var userFileSchema = import_zod12.default.union([localUserSchema, cloudUserSchema]);
|
|
1059
|
+
var userSchema = userFileSchema;
|
|
1060
|
+
var setUserSchema = userSchema;
|
|
1061
|
+
|
|
1062
|
+
// src/error/GitError.ts
|
|
1063
|
+
var GitError = class extends Error {
|
|
1064
|
+
constructor(message) {
|
|
1065
|
+
super(message);
|
|
1066
|
+
this.name = "GitError";
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
// src/error/NoCurrentUserError.ts
|
|
1071
|
+
var NoCurrentUserError = class extends Error {
|
|
1072
|
+
constructor() {
|
|
1073
|
+
super("Make sure to set a User via Core before using other methods");
|
|
1074
|
+
this.name = "NoCurrentUserError";
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
// src/error/ProjectUpgradeError.ts
|
|
1079
|
+
var ProjectUpgradeError = class extends Error {
|
|
1080
|
+
constructor(message) {
|
|
1081
|
+
super(message);
|
|
1082
|
+
this.name = "ProjectUpgradeError";
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
// src/error/RequiredParameterMissingError.ts
|
|
1087
|
+
var RequiredParameterMissingError = class extends Error {
|
|
1088
|
+
constructor(parameter) {
|
|
1089
|
+
super(`Missing required parameter "${parameter}"`);
|
|
1090
|
+
this.name = "RequiredParameterMissingError";
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
// src/util/node.ts
|
|
1095
|
+
var node_exports = {};
|
|
1096
|
+
__export(node_exports, {
|
|
1097
|
+
assignDefaultIfMissing: () => assignDefaultIfMissing,
|
|
1098
|
+
files: () => files,
|
|
1099
|
+
folders: () => folders,
|
|
1100
|
+
fromPath: () => fromPath,
|
|
1101
|
+
getDuplicates: () => getDuplicates,
|
|
1102
|
+
getRelativePath: () => getRelativePath,
|
|
1103
|
+
isNoError: () => isNoError,
|
|
1104
|
+
notEmpty: () => notEmpty,
|
|
1105
|
+
pathTo: () => pathTo,
|
|
1106
|
+
returnResolved: () => returnResolved,
|
|
1107
|
+
spawnChildProcess: () => spawnChildProcess,
|
|
1108
|
+
workingDirectory: () => workingDirectory
|
|
1109
|
+
});
|
|
1110
|
+
var import_child_process = require("child_process");
|
|
1111
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
1112
|
+
var import_lodash_es = require("lodash-es");
|
|
1113
|
+
var import_os = __toESM(require("os"), 1);
|
|
1114
|
+
var import_path = __toESM(require("path"), 1);
|
|
1115
|
+
var workingDirectory = import_path.default.join(import_os.default.homedir(), "elek.io");
|
|
1116
|
+
var pathTo = {
|
|
1117
|
+
tmp: import_path.default.join(workingDirectory, "tmp"),
|
|
1118
|
+
userFile: import_path.default.join(workingDirectory, "user.json"),
|
|
1119
|
+
// logs: Path.join(workingDirectory, 'logs'),
|
|
1120
|
+
projects: import_path.default.join(workingDirectory, "projects"),
|
|
1121
|
+
project: (projectId) => {
|
|
1122
|
+
return import_path.default.join(pathTo.projects, projectId);
|
|
1123
|
+
},
|
|
1124
|
+
projectFile: (projectId) => {
|
|
1125
|
+
return import_path.default.join(pathTo.project(projectId), "project.json");
|
|
1126
|
+
},
|
|
1127
|
+
// projectLogs: (projectId: string): string => {
|
|
1128
|
+
// return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.logs);
|
|
1129
|
+
// },
|
|
1130
|
+
// public: (projectId: string): string => {
|
|
1131
|
+
// return Path.join(pathTo.project(projectId), 'public');
|
|
1132
|
+
// },
|
|
1133
|
+
lfs: (projectId) => {
|
|
1134
|
+
return import_path.default.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
|
|
1135
|
+
},
|
|
1136
|
+
collections: (projectId) => {
|
|
1137
|
+
return import_path.default.join(
|
|
1138
|
+
pathTo.project(projectId),
|
|
1139
|
+
projectFolderSchema.Enum.collections
|
|
1140
|
+
);
|
|
1141
|
+
},
|
|
1142
|
+
collection: (projectId, id) => {
|
|
1143
|
+
return import_path.default.join(pathTo.collections(projectId), id);
|
|
1144
|
+
},
|
|
1145
|
+
collectionFile: (projectId, id) => {
|
|
1146
|
+
return import_path.default.join(pathTo.collection(projectId, id), "collection.json");
|
|
1147
|
+
},
|
|
1148
|
+
entries: (projectId, collectionId) => {
|
|
1149
|
+
return import_path.default.join(pathTo.collection(projectId, collectionId));
|
|
1150
|
+
},
|
|
1151
|
+
entryFile: (projectId, collectionId, id) => {
|
|
1152
|
+
return import_path.default.join(pathTo.entries(projectId, collectionId), `${id}.json`);
|
|
1153
|
+
},
|
|
1154
|
+
sharedValues: (projectId) => {
|
|
1071
1155
|
return import_path.default.join(pathTo.project(projectId), "shared-values");
|
|
1072
1156
|
},
|
|
1073
1157
|
sharedValueFile: (projectId, id, language) => {
|
|
@@ -1196,29 +1280,6 @@ function getDuplicates(arr, key) {
|
|
|
1196
1280
|
);
|
|
1197
1281
|
}
|
|
1198
1282
|
|
|
1199
|
-
// src/util/shared.ts
|
|
1200
|
-
var import_slugify = __toESM(require("slugify"), 1);
|
|
1201
|
-
var import_uuid = require("uuid");
|
|
1202
|
-
var Slugify = import_slugify.default.default || import_slugify.default;
|
|
1203
|
-
function uuid() {
|
|
1204
|
-
return (0, import_uuid.v4)();
|
|
1205
|
-
}
|
|
1206
|
-
function currentTimestamp() {
|
|
1207
|
-
return Math.floor(Date.now() / 1e3);
|
|
1208
|
-
}
|
|
1209
|
-
function slug(string) {
|
|
1210
|
-
return Slugify(string, {
|
|
1211
|
-
replacement: "-",
|
|
1212
|
-
// replace spaces with replacement character, defaults to `-`
|
|
1213
|
-
remove: void 0,
|
|
1214
|
-
// remove characters that match regex, defaults to `undefined`
|
|
1215
|
-
lower: true,
|
|
1216
|
-
// convert to lower case, defaults to `false`
|
|
1217
|
-
strict: true
|
|
1218
|
-
// strip special characters except replacement, defaults to `false`
|
|
1219
|
-
});
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
1283
|
// src/service/AbstractCrudService.ts
|
|
1223
1284
|
var AbstractCrudService = class {
|
|
1224
1285
|
/**
|
|
@@ -1315,54 +1376,341 @@ var AbstractCrudService = class {
|
|
|
1315
1376
|
}
|
|
1316
1377
|
};
|
|
1317
1378
|
|
|
1318
|
-
// src/service/
|
|
1319
|
-
var
|
|
1320
|
-
var
|
|
1321
|
-
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
1379
|
+
// src/service/AssetService.ts
|
|
1380
|
+
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
1381
|
+
var import_is_svg = __toESM(require("is-svg"), 1);
|
|
1322
1382
|
|
|
1323
|
-
// src/
|
|
1324
|
-
var
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1383
|
+
// src/util/shared.ts
|
|
1384
|
+
var import_slugify = __toESM(require("slugify"), 1);
|
|
1385
|
+
var import_uuid = require("uuid");
|
|
1386
|
+
var Slugify = import_slugify.default.default || import_slugify.default;
|
|
1387
|
+
function uuid() {
|
|
1388
|
+
return (0, import_uuid.v4)();
|
|
1389
|
+
}
|
|
1390
|
+
function currentTimestamp() {
|
|
1391
|
+
return Math.floor(Date.now() / 1e3);
|
|
1392
|
+
}
|
|
1393
|
+
function slug(string) {
|
|
1394
|
+
return Slugify(string, {
|
|
1395
|
+
replacement: "-",
|
|
1396
|
+
// replace spaces with replacement character, defaults to `-`
|
|
1397
|
+
remove: void 0,
|
|
1398
|
+
// remove characters that match regex, defaults to `undefined`
|
|
1399
|
+
lower: true,
|
|
1400
|
+
// convert to lower case, defaults to `false`
|
|
1401
|
+
strict: true
|
|
1402
|
+
// strip special characters except replacement, defaults to `false`
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// src/service/JsonFileService.ts
|
|
1407
|
+
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
1408
|
+
var JsonFileService = class extends AbstractCrudService {
|
|
1409
|
+
constructor(options) {
|
|
1410
|
+
super(serviceTypeSchema.Enum.JsonFile, options);
|
|
1411
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Creates a new file on disk. Fails if path already exists
|
|
1415
|
+
*
|
|
1416
|
+
* @param data Data to write into the file
|
|
1417
|
+
* @param path Path to write the file to
|
|
1418
|
+
* @param schema Schema of the file to validate against
|
|
1419
|
+
* @returns Validated content of the file from disk
|
|
1420
|
+
*/
|
|
1421
|
+
async create(data, path, schema) {
|
|
1422
|
+
const parsedData = schema.parse(data);
|
|
1423
|
+
const string = this.serialize(parsedData);
|
|
1424
|
+
await import_fs_extra2.default.writeFile(path, string, {
|
|
1425
|
+
flag: "wx",
|
|
1426
|
+
encoding: "utf8"
|
|
1427
|
+
});
|
|
1428
|
+
this.cache.set(path, parsedData);
|
|
1429
|
+
return parsedData;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Reads the content of a file on disk. Fails if path does not exist
|
|
1433
|
+
*
|
|
1434
|
+
* @param path Path to read the file from
|
|
1435
|
+
* @param schema Schema of the file to validate against
|
|
1436
|
+
* @returns Validated content of the file from disk
|
|
1437
|
+
*/
|
|
1438
|
+
async read(path, schema) {
|
|
1439
|
+
if (this.cache.has(path)) {
|
|
1440
|
+
return this.cache.get(path);
|
|
1441
|
+
}
|
|
1442
|
+
const data = await import_fs_extra2.default.readFile(path, {
|
|
1443
|
+
flag: "r",
|
|
1444
|
+
encoding: "utf8"
|
|
1445
|
+
});
|
|
1446
|
+
const json = this.deserialize(data);
|
|
1447
|
+
const parsedData = schema.parse(json);
|
|
1448
|
+
this.cache.set(path, parsedData);
|
|
1449
|
+
return parsedData;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Overwrites an existing file on disk
|
|
1453
|
+
*
|
|
1454
|
+
* @todo Check how to error out if the file does not exist already
|
|
1455
|
+
*
|
|
1456
|
+
* @param data Data to write into the file
|
|
1457
|
+
* @param path Path to the file to overwrite
|
|
1458
|
+
* @param schema Schema of the file to validate against
|
|
1459
|
+
* @returns Validated content of the file from disk
|
|
1460
|
+
*/
|
|
1461
|
+
async update(data, path, schema) {
|
|
1462
|
+
const parsedData = schema.parse(data);
|
|
1463
|
+
const string = this.serialize(parsedData);
|
|
1464
|
+
await import_fs_extra2.default.writeFile(path, string, {
|
|
1465
|
+
flag: "w",
|
|
1466
|
+
encoding: "utf8"
|
|
1467
|
+
});
|
|
1468
|
+
this.cache.set(path, parsedData);
|
|
1469
|
+
return parsedData;
|
|
1470
|
+
}
|
|
1471
|
+
serialize(data) {
|
|
1472
|
+
return JSON.stringify(data, null, this.options.file.json.indentation);
|
|
1473
|
+
}
|
|
1474
|
+
deserialize(data) {
|
|
1475
|
+
return JSON.parse(data);
|
|
1328
1476
|
}
|
|
1329
1477
|
};
|
|
1330
1478
|
|
|
1331
|
-
// src/
|
|
1332
|
-
var
|
|
1333
|
-
constructor() {
|
|
1334
|
-
super(
|
|
1335
|
-
this.
|
|
1479
|
+
// src/service/AssetService.ts
|
|
1480
|
+
var AssetService = class extends AbstractCrudService {
|
|
1481
|
+
constructor(options, jsonFileService, gitService) {
|
|
1482
|
+
super(serviceTypeSchema.Enum.Asset, options);
|
|
1483
|
+
this.jsonFileService = jsonFileService;
|
|
1484
|
+
this.gitService = gitService;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Creates a new Asset
|
|
1488
|
+
*/
|
|
1489
|
+
async create(props) {
|
|
1490
|
+
createAssetSchema.parse(props);
|
|
1491
|
+
const id = uuid();
|
|
1492
|
+
const projectPath = pathTo.project(props.projectId);
|
|
1493
|
+
const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
|
|
1494
|
+
const size = await this.getAssetSize(props.filePath);
|
|
1495
|
+
const assetPath = pathTo.asset(
|
|
1496
|
+
props.projectId,
|
|
1497
|
+
id,
|
|
1498
|
+
props.language,
|
|
1499
|
+
fileType.extension
|
|
1500
|
+
);
|
|
1501
|
+
const assetFilePath = pathTo.assetFile(props.projectId, id, props.language);
|
|
1502
|
+
const assetFile = {
|
|
1503
|
+
...props,
|
|
1504
|
+
objectType: "asset",
|
|
1505
|
+
id,
|
|
1506
|
+
created: currentTimestamp(),
|
|
1507
|
+
updated: null,
|
|
1508
|
+
extension: fileType.extension,
|
|
1509
|
+
mimeType: fileType.mimeType,
|
|
1510
|
+
size
|
|
1511
|
+
};
|
|
1512
|
+
try {
|
|
1513
|
+
await import_fs_extra3.default.copyFile(props.filePath, assetPath);
|
|
1514
|
+
await this.jsonFileService.create(
|
|
1515
|
+
assetFile,
|
|
1516
|
+
assetFilePath,
|
|
1517
|
+
assetFileSchema
|
|
1518
|
+
);
|
|
1519
|
+
} catch (error) {
|
|
1520
|
+
await this.delete({ ...assetFile, projectId: props.projectId });
|
|
1521
|
+
throw error;
|
|
1522
|
+
}
|
|
1523
|
+
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
1524
|
+
await this.gitService.commit(projectPath, this.gitMessage.create);
|
|
1525
|
+
return this.toAsset(props.projectId, assetFile);
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Returns an Asset by ID and language
|
|
1529
|
+
*/
|
|
1530
|
+
async read(props) {
|
|
1531
|
+
readAssetSchema.parse(props);
|
|
1532
|
+
const assetFile = await this.jsonFileService.read(
|
|
1533
|
+
pathTo.assetFile(props.projectId, props.id, props.language),
|
|
1534
|
+
assetFileSchema
|
|
1535
|
+
);
|
|
1536
|
+
return this.toAsset(props.projectId, assetFile);
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Updates given Asset
|
|
1540
|
+
*
|
|
1541
|
+
* Use the optional "newFilePath" prop to update the Asset itself
|
|
1542
|
+
*/
|
|
1543
|
+
async update(props) {
|
|
1544
|
+
updateAssetSchema.parse(props);
|
|
1545
|
+
const projectPath = pathTo.project(props.projectId);
|
|
1546
|
+
const assetFilePath = pathTo.assetFile(
|
|
1547
|
+
props.projectId,
|
|
1548
|
+
props.id,
|
|
1549
|
+
props.language
|
|
1550
|
+
);
|
|
1551
|
+
const prevAssetFile = await this.read(props);
|
|
1552
|
+
const assetFile = {
|
|
1553
|
+
...prevAssetFile,
|
|
1554
|
+
...props,
|
|
1555
|
+
updated: currentTimestamp()
|
|
1556
|
+
};
|
|
1557
|
+
if (props.newFilePath) {
|
|
1558
|
+
const fileType = await this.getSupportedFileTypeOrThrow(
|
|
1559
|
+
props.newFilePath
|
|
1560
|
+
);
|
|
1561
|
+
const size = await this.getAssetSize(props.newFilePath);
|
|
1562
|
+
const prevAssetPath = pathTo.asset(
|
|
1563
|
+
props.projectId,
|
|
1564
|
+
props.id,
|
|
1565
|
+
props.language,
|
|
1566
|
+
prevAssetFile.extension
|
|
1567
|
+
);
|
|
1568
|
+
const assetPath = pathTo.asset(
|
|
1569
|
+
props.projectId,
|
|
1570
|
+
props.id,
|
|
1571
|
+
props.language,
|
|
1572
|
+
fileType.extension
|
|
1573
|
+
);
|
|
1574
|
+
await import_fs_extra3.default.remove(prevAssetPath);
|
|
1575
|
+
await import_fs_extra3.default.copyFile(props.newFilePath, assetPath);
|
|
1576
|
+
assetFile.extension = fileType.extension;
|
|
1577
|
+
assetFile.mimeType = fileType.mimeType;
|
|
1578
|
+
assetFile.size = size;
|
|
1579
|
+
}
|
|
1580
|
+
await this.jsonFileService.update(
|
|
1581
|
+
assetFile,
|
|
1582
|
+
assetFilePath,
|
|
1583
|
+
assetFileSchema
|
|
1584
|
+
);
|
|
1585
|
+
await this.gitService.add(projectPath, [assetFilePath]);
|
|
1586
|
+
await this.gitService.commit(projectPath, this.gitMessage.update);
|
|
1587
|
+
return this.toAsset(props.projectId, assetFile);
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Deletes given Asset
|
|
1591
|
+
*/
|
|
1592
|
+
async delete(props) {
|
|
1593
|
+
deleteAssetSchema.parse(props);
|
|
1594
|
+
const projectPath = pathTo.project(props.projectId);
|
|
1595
|
+
const assetFilePath = pathTo.assetFile(
|
|
1596
|
+
props.projectId,
|
|
1597
|
+
props.id,
|
|
1598
|
+
props.language
|
|
1599
|
+
);
|
|
1600
|
+
const assetPath = pathTo.asset(
|
|
1601
|
+
props.projectId,
|
|
1602
|
+
props.id,
|
|
1603
|
+
props.language,
|
|
1604
|
+
props.extension
|
|
1605
|
+
);
|
|
1606
|
+
await import_fs_extra3.default.remove(assetPath);
|
|
1607
|
+
await import_fs_extra3.default.remove(assetFilePath);
|
|
1608
|
+
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
1609
|
+
await this.gitService.commit(projectPath, this.gitMessage.delete);
|
|
1610
|
+
}
|
|
1611
|
+
async list(props) {
|
|
1612
|
+
listAssetsSchema.parse(props);
|
|
1613
|
+
const offset = props.offset || 0;
|
|
1614
|
+
const limit = props.limit || 15;
|
|
1615
|
+
const assetReferences = await this.listReferences(
|
|
1616
|
+
objectTypeSchema.Enum.asset,
|
|
1617
|
+
props.projectId
|
|
1618
|
+
);
|
|
1619
|
+
const partialAssetReferences = assetReferences.slice(offset, limit);
|
|
1620
|
+
const assets = await returnResolved(
|
|
1621
|
+
partialAssetReferences.map((assetReference) => {
|
|
1622
|
+
if (!assetReference.language) {
|
|
1623
|
+
throw new RequiredParameterMissingError("language");
|
|
1624
|
+
}
|
|
1625
|
+
return this.read({
|
|
1626
|
+
projectId: props.projectId,
|
|
1627
|
+
id: assetReference.id,
|
|
1628
|
+
language: assetReference.language
|
|
1629
|
+
});
|
|
1630
|
+
})
|
|
1631
|
+
);
|
|
1632
|
+
return {
|
|
1633
|
+
total: assetReferences.length,
|
|
1634
|
+
limit,
|
|
1635
|
+
offset,
|
|
1636
|
+
list: assets
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
async count(props) {
|
|
1640
|
+
countAssetsSchema.parse(props);
|
|
1641
|
+
const count = (await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)).length;
|
|
1642
|
+
return count;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Checks if given object is of type Asset
|
|
1646
|
+
*/
|
|
1647
|
+
isAsset(obj) {
|
|
1648
|
+
return assetSchema.safeParse(obj).success;
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Returns the size of an Asset in bytes
|
|
1652
|
+
*
|
|
1653
|
+
* @param path Path of the Asset to get the size from
|
|
1654
|
+
*/
|
|
1655
|
+
async getAssetSize(path) {
|
|
1656
|
+
return (await import_fs_extra3.default.stat(path)).size;
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Creates an Asset from given AssetFile
|
|
1660
|
+
*
|
|
1661
|
+
* @param projectId The project's ID
|
|
1662
|
+
* @param assetFile The AssetFile to convert
|
|
1663
|
+
*/
|
|
1664
|
+
async toAsset(projectId, assetFile) {
|
|
1665
|
+
const assetPath = pathTo.asset(
|
|
1666
|
+
projectId,
|
|
1667
|
+
assetFile.id,
|
|
1668
|
+
assetFile.language,
|
|
1669
|
+
assetFile.extension
|
|
1670
|
+
);
|
|
1671
|
+
const asset = {
|
|
1672
|
+
...assetFile,
|
|
1673
|
+
absolutePath: assetPath
|
|
1674
|
+
};
|
|
1675
|
+
return asset;
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Returns the found and supported extension as well as mime type,
|
|
1679
|
+
* otherwise throws an error
|
|
1680
|
+
*
|
|
1681
|
+
* @param filePath Path to the file to check
|
|
1682
|
+
*/
|
|
1683
|
+
async getSupportedFileTypeOrThrow(filePath) {
|
|
1684
|
+
const fileSize = (await import_fs_extra3.default.stat(filePath)).size;
|
|
1685
|
+
if (fileSize / 1e3 <= 500) {
|
|
1686
|
+
const fileBuffer = await import_fs_extra3.default.readFile(filePath);
|
|
1687
|
+
if ((0, import_is_svg.default)(fileBuffer.toString()) === true) {
|
|
1688
|
+
return {
|
|
1689
|
+
extension: supportedAssetExtensionSchema.Enum.svg,
|
|
1690
|
+
mimeType: supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
const { fileTypeFromFile } = await import("file-type");
|
|
1695
|
+
const fileType = await fileTypeFromFile(filePath);
|
|
1696
|
+
const result = supportedAssetTypeSchema.parse({
|
|
1697
|
+
extension: fileType?.ext,
|
|
1698
|
+
mimeType: fileType?.mime
|
|
1699
|
+
});
|
|
1700
|
+
return result;
|
|
1336
1701
|
}
|
|
1337
1702
|
};
|
|
1338
1703
|
|
|
1339
|
-
// src/service/
|
|
1340
|
-
var
|
|
1704
|
+
// src/service/CollectionService.ts
|
|
1705
|
+
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
1341
1706
|
|
|
1342
|
-
// src/
|
|
1343
|
-
var
|
|
1344
|
-
var
|
|
1345
|
-
|
|
1346
|
-
message: import_zod10.z.string(),
|
|
1347
|
-
author: gitSignatureSchema,
|
|
1348
|
-
timestamp: import_zod10.z.number()
|
|
1349
|
-
});
|
|
1350
|
-
var createGitTagSchema = gitTagSchema.pick({
|
|
1351
|
-
message: true
|
|
1352
|
-
}).extend({
|
|
1353
|
-
path: gitRepositoryPathSchema,
|
|
1354
|
-
hash: gitCommitSchema.shape.hash.optional()
|
|
1355
|
-
});
|
|
1356
|
-
var readGitTagSchema = import_zod10.z.object({
|
|
1357
|
-
path: gitRepositoryPathSchema,
|
|
1358
|
-
id: uuidSchema.readonly()
|
|
1359
|
-
});
|
|
1360
|
-
var deleteGitTagSchema = readGitTagSchema.extend({});
|
|
1361
|
-
var countGitTagsSchema = import_zod10.z.object({
|
|
1362
|
-
path: gitRepositoryPathSchema
|
|
1363
|
-
});
|
|
1707
|
+
// src/service/GitService.ts
|
|
1708
|
+
var import_dugite = require("dugite");
|
|
1709
|
+
var import_os3 = require("os");
|
|
1710
|
+
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
1364
1711
|
|
|
1365
1712
|
// src/service/GitTagService.ts
|
|
1713
|
+
var import_os2 = require("os");
|
|
1366
1714
|
var GitTagService = class extends AbstractCrudService {
|
|
1367
1715
|
constructor(options, git) {
|
|
1368
1716
|
super(serviceTypeSchema.Enum.GitTag, options);
|
|
@@ -1490,97 +1838,6 @@ var GitTagService = class extends AbstractCrudService {
|
|
|
1490
1838
|
}
|
|
1491
1839
|
};
|
|
1492
1840
|
|
|
1493
|
-
// src/schema/userSchema.ts
|
|
1494
|
-
var import_zod11 = __toESM(require("zod"), 1);
|
|
1495
|
-
var UserTypeSchema = import_zod11.default.enum(["local", "cloud"]);
|
|
1496
|
-
var baseUserSchema = gitSignatureSchema.extend({
|
|
1497
|
-
userType: UserTypeSchema,
|
|
1498
|
-
language: supportedLanguageSchema
|
|
1499
|
-
});
|
|
1500
|
-
var localUserSchema = baseUserSchema.extend({
|
|
1501
|
-
userType: import_zod11.default.literal(UserTypeSchema.Enum.local)
|
|
1502
|
-
});
|
|
1503
|
-
var cloudUserSchema = baseUserSchema.extend({
|
|
1504
|
-
userType: import_zod11.default.literal(UserTypeSchema.Enum.cloud),
|
|
1505
|
-
id: uuidSchema
|
|
1506
|
-
});
|
|
1507
|
-
var userFileSchema = import_zod11.default.union([localUserSchema, cloudUserSchema]);
|
|
1508
|
-
var userSchema = userFileSchema;
|
|
1509
|
-
var setUserSchema = userSchema;
|
|
1510
|
-
|
|
1511
|
-
// src/service/JsonFileService.ts
|
|
1512
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
1513
|
-
var JsonFileService = class extends AbstractCrudService {
|
|
1514
|
-
constructor(options) {
|
|
1515
|
-
super(serviceTypeSchema.Enum.JsonFile, options);
|
|
1516
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
1517
|
-
}
|
|
1518
|
-
/**
|
|
1519
|
-
* Creates a new file on disk. Fails if path already exists
|
|
1520
|
-
*
|
|
1521
|
-
* @param data Data to write into the file
|
|
1522
|
-
* @param path Path to write the file to
|
|
1523
|
-
* @param schema Schema of the file to validate against
|
|
1524
|
-
* @returns Validated content of the file from disk
|
|
1525
|
-
*/
|
|
1526
|
-
async create(data, path, schema) {
|
|
1527
|
-
const parsedData = schema.parse(data);
|
|
1528
|
-
const string = this.serialize(parsedData);
|
|
1529
|
-
await import_fs_extra2.default.writeFile(path, string, {
|
|
1530
|
-
flag: "wx",
|
|
1531
|
-
encoding: "utf8"
|
|
1532
|
-
});
|
|
1533
|
-
this.cache.set(path, parsedData);
|
|
1534
|
-
return parsedData;
|
|
1535
|
-
}
|
|
1536
|
-
/**
|
|
1537
|
-
* Reads the content of a file on disk. Fails if path does not exist
|
|
1538
|
-
*
|
|
1539
|
-
* @param path Path to read the file from
|
|
1540
|
-
* @param schema Schema of the file to validate against
|
|
1541
|
-
* @returns Validated content of the file from disk
|
|
1542
|
-
*/
|
|
1543
|
-
async read(path, schema) {
|
|
1544
|
-
if (this.cache.has(path)) {
|
|
1545
|
-
return this.cache.get(path);
|
|
1546
|
-
}
|
|
1547
|
-
const data = await import_fs_extra2.default.readFile(path, {
|
|
1548
|
-
flag: "r",
|
|
1549
|
-
encoding: "utf8"
|
|
1550
|
-
});
|
|
1551
|
-
const json = this.deserialize(data);
|
|
1552
|
-
const parsedData = schema.parse(json);
|
|
1553
|
-
this.cache.set(path, parsedData);
|
|
1554
|
-
return parsedData;
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* Overwrites an existing file on disk
|
|
1558
|
-
*
|
|
1559
|
-
* @todo Check how to error out if the file does not exist already
|
|
1560
|
-
*
|
|
1561
|
-
* @param data Data to write into the file
|
|
1562
|
-
* @param path Path to the file to overwrite
|
|
1563
|
-
* @param schema Schema of the file to validate against
|
|
1564
|
-
* @returns Validated content of the file from disk
|
|
1565
|
-
*/
|
|
1566
|
-
async update(data, path, schema) {
|
|
1567
|
-
const parsedData = schema.parse(data);
|
|
1568
|
-
const string = this.serialize(parsedData);
|
|
1569
|
-
await import_fs_extra2.default.writeFile(path, string, {
|
|
1570
|
-
flag: "w",
|
|
1571
|
-
encoding: "utf8"
|
|
1572
|
-
});
|
|
1573
|
-
this.cache.set(path, parsedData);
|
|
1574
|
-
return parsedData;
|
|
1575
|
-
}
|
|
1576
|
-
serialize(data) {
|
|
1577
|
-
return JSON.stringify(data, null, this.options.file.json.indentation);
|
|
1578
|
-
}
|
|
1579
|
-
deserialize(data) {
|
|
1580
|
-
return JSON.parse(data);
|
|
1581
|
-
}
|
|
1582
|
-
};
|
|
1583
|
-
|
|
1584
1841
|
// src/service/UserService.ts
|
|
1585
1842
|
var UserService = class {
|
|
1586
1843
|
constructor(jsonFileService) {
|
|
@@ -2019,343 +2276,117 @@ var GitService2 = class {
|
|
|
2019
2276
|
]);
|
|
2020
2277
|
return {
|
|
2021
2278
|
created: meta[0],
|
|
2022
|
-
updated: meta[1]
|
|
2023
|
-
};
|
|
2024
|
-
}
|
|
2025
|
-
/**
|
|
2026
|
-
* Reads the currently used version of Git
|
|
2027
|
-
*
|
|
2028
|
-
* This can help debugging
|
|
2029
|
-
*/
|
|
2030
|
-
async updateVersion() {
|
|
2031
|
-
const result = await this.git("", ["--version"]);
|
|
2032
|
-
this.version = result.stdout.replace("git version", "").trim();
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* Reads the path to the executable of Git that is used
|
|
2036
|
-
*
|
|
2037
|
-
* This can help debugging, since dugite is shipping their own executable
|
|
2038
|
-
* but in some cases resolves another executable
|
|
2039
|
-
* @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
|
|
2040
|
-
*/
|
|
2041
|
-
async updateGitPath() {
|
|
2042
|
-
const result = await this.git("", ["--exec-path"]);
|
|
2043
|
-
this.gitPath = result.stdout.trim();
|
|
2044
|
-
}
|
|
2045
|
-
/**
|
|
2046
|
-
* A reference is used in Git to specify branches and tags.
|
|
2047
|
-
* This method checks if given name matches the required format
|
|
2048
|
-
*
|
|
2049
|
-
* @see https://git-scm.com/docs/git-check-ref-format
|
|
2050
|
-
*
|
|
2051
|
-
* @param path Path to the repository
|
|
2052
|
-
* @param name Name to check
|
|
2053
|
-
*/
|
|
2054
|
-
async checkBranchOrTagName(path, name) {
|
|
2055
|
-
await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
|
|
2056
|
-
}
|
|
2057
|
-
/**
|
|
2058
|
-
* Installs LFS support and starts tracking
|
|
2059
|
-
* all files inside the lfs folder
|
|
2060
|
-
*
|
|
2061
|
-
* @param path Path to the repository
|
|
2062
|
-
*/
|
|
2063
|
-
async installLfs(path) {
|
|
2064
|
-
await this.git(path, ["lfs", "install"]);
|
|
2065
|
-
await this.git(path, ["lfs", "track", "lfs/*"]);
|
|
2066
|
-
}
|
|
2067
|
-
/**
|
|
2068
|
-
* Sets the git config of given local repository from ElekIoCoreOptions
|
|
2069
|
-
*
|
|
2070
|
-
* @param path Path to the repository
|
|
2071
|
-
*/
|
|
2072
|
-
async setLocalConfig(path) {
|
|
2073
|
-
const user = await this.userService.get();
|
|
2074
|
-
if (!user) {
|
|
2075
|
-
throw new NoCurrentUserError();
|
|
2076
|
-
}
|
|
2077
|
-
const userNameArgs = ["config", "--local", "user.name", user.name];
|
|
2078
|
-
const userEmailArgs = ["config", "--local", "user.email", user.email];
|
|
2079
|
-
const autoSetupRemoteArgs = [
|
|
2080
|
-
"config",
|
|
2081
|
-
"--local",
|
|
2082
|
-
"push.autoSetupRemote",
|
|
2083
|
-
"true"
|
|
2084
|
-
];
|
|
2085
|
-
await this.git(path, userNameArgs);
|
|
2086
|
-
await this.git(path, userEmailArgs);
|
|
2087
|
-
await this.git(path, autoSetupRemoteArgs);
|
|
2088
|
-
}
|
|
2089
|
-
/**
|
|
2090
|
-
* Type guard for GitCommit
|
|
2091
|
-
*
|
|
2092
|
-
* @param obj The object to check
|
|
2093
|
-
*/
|
|
2094
|
-
isGitCommit(obj) {
|
|
2095
|
-
return gitCommitSchema.safeParse(obj).success;
|
|
2096
|
-
}
|
|
2097
|
-
/**
|
|
2098
|
-
* Wraps the execution of any git command
|
|
2099
|
-
* to use a FIFO queue for sequential processing
|
|
2100
|
-
*
|
|
2101
|
-
* @param path Path to the repository
|
|
2102
|
-
* @param args Arguments to append after the `git` command
|
|
2103
|
-
*/
|
|
2104
|
-
async git(path, args) {
|
|
2105
|
-
const result = await this.queue.add(
|
|
2106
|
-
() => import_dugite.GitProcess.exec(args, path, {
|
|
2107
|
-
env: {
|
|
2108
|
-
// @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
|
|
2109
|
-
// @see https://github.com/git-lfs/git-lfs/issues/5749
|
|
2110
|
-
GIT_CLONE_PROTECTION_ACTIVE: "false"
|
|
2111
|
-
}
|
|
2112
|
-
})
|
|
2113
|
-
);
|
|
2114
|
-
if (!result) {
|
|
2115
|
-
throw new GitError(
|
|
2116
|
-
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2117
|
-
" "
|
|
2118
|
-
)}" failed to return a result`
|
|
2119
|
-
);
|
|
2120
|
-
}
|
|
2121
|
-
if (result.exitCode !== 0) {
|
|
2122
|
-
throw new GitError(
|
|
2123
|
-
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2124
|
-
" "
|
|
2125
|
-
)}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
|
|
2126
|
-
);
|
|
2127
|
-
}
|
|
2128
|
-
return result;
|
|
2129
|
-
}
|
|
2130
|
-
};
|
|
2131
|
-
|
|
2132
|
-
// src/service/AssetService.ts
|
|
2133
|
-
var AssetService = class extends AbstractCrudService {
|
|
2134
|
-
constructor(options, jsonFileService, gitService) {
|
|
2135
|
-
super(serviceTypeSchema.Enum.Asset, options);
|
|
2136
|
-
this.jsonFileService = jsonFileService;
|
|
2137
|
-
this.gitService = gitService;
|
|
2138
|
-
}
|
|
2139
|
-
/**
|
|
2140
|
-
* Creates a new Asset
|
|
2141
|
-
*/
|
|
2142
|
-
async create(props) {
|
|
2143
|
-
createAssetSchema.parse(props);
|
|
2144
|
-
const id = uuid();
|
|
2145
|
-
const projectPath = pathTo.project(props.projectId);
|
|
2146
|
-
const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
|
|
2147
|
-
const size = await this.getAssetSize(props.filePath);
|
|
2148
|
-
const assetPath = pathTo.asset(
|
|
2149
|
-
props.projectId,
|
|
2150
|
-
id,
|
|
2151
|
-
props.language,
|
|
2152
|
-
fileType.extension
|
|
2153
|
-
);
|
|
2154
|
-
const assetFilePath = pathTo.assetFile(props.projectId, id, props.language);
|
|
2155
|
-
const assetFile = {
|
|
2156
|
-
...props,
|
|
2157
|
-
objectType: "asset",
|
|
2158
|
-
id,
|
|
2159
|
-
created: currentTimestamp(),
|
|
2160
|
-
updated: null,
|
|
2161
|
-
extension: fileType.extension,
|
|
2162
|
-
mimeType: fileType.mimeType,
|
|
2163
|
-
size
|
|
2164
|
-
};
|
|
2165
|
-
try {
|
|
2166
|
-
await import_fs_extra3.default.copyFile(props.filePath, assetPath);
|
|
2167
|
-
await this.jsonFileService.create(
|
|
2168
|
-
assetFile,
|
|
2169
|
-
assetFilePath,
|
|
2170
|
-
assetFileSchema
|
|
2171
|
-
);
|
|
2172
|
-
} catch (error) {
|
|
2173
|
-
await this.delete({ ...assetFile, projectId: props.projectId });
|
|
2174
|
-
throw error;
|
|
2175
|
-
}
|
|
2176
|
-
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
2177
|
-
await this.gitService.commit(projectPath, this.gitMessage.create);
|
|
2178
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2179
|
-
}
|
|
2180
|
-
/**
|
|
2181
|
-
* Returns an Asset by ID and language
|
|
2182
|
-
*/
|
|
2183
|
-
async read(props) {
|
|
2184
|
-
readAssetSchema.parse(props);
|
|
2185
|
-
const assetFile = await this.jsonFileService.read(
|
|
2186
|
-
pathTo.assetFile(props.projectId, props.id, props.language),
|
|
2187
|
-
assetFileSchema
|
|
2188
|
-
);
|
|
2189
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2279
|
+
updated: meta[1]
|
|
2280
|
+
};
|
|
2190
2281
|
}
|
|
2191
2282
|
/**
|
|
2192
|
-
*
|
|
2283
|
+
* Reads the currently used version of Git
|
|
2193
2284
|
*
|
|
2194
|
-
*
|
|
2285
|
+
* This can help debugging
|
|
2195
2286
|
*/
|
|
2196
|
-
async
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
const assetFilePath = pathTo.assetFile(
|
|
2200
|
-
props.projectId,
|
|
2201
|
-
props.id,
|
|
2202
|
-
props.language
|
|
2203
|
-
);
|
|
2204
|
-
const prevAssetFile = await this.read(props);
|
|
2205
|
-
const assetFile = {
|
|
2206
|
-
...prevAssetFile,
|
|
2207
|
-
...props,
|
|
2208
|
-
updated: currentTimestamp()
|
|
2209
|
-
};
|
|
2210
|
-
if (props.newFilePath) {
|
|
2211
|
-
const fileType = await this.getSupportedFileTypeOrThrow(
|
|
2212
|
-
props.newFilePath
|
|
2213
|
-
);
|
|
2214
|
-
const size = await this.getAssetSize(props.newFilePath);
|
|
2215
|
-
const prevAssetPath = pathTo.asset(
|
|
2216
|
-
props.projectId,
|
|
2217
|
-
props.id,
|
|
2218
|
-
props.language,
|
|
2219
|
-
prevAssetFile.extension
|
|
2220
|
-
);
|
|
2221
|
-
const assetPath = pathTo.asset(
|
|
2222
|
-
props.projectId,
|
|
2223
|
-
props.id,
|
|
2224
|
-
props.language,
|
|
2225
|
-
fileType.extension
|
|
2226
|
-
);
|
|
2227
|
-
await import_fs_extra3.default.remove(prevAssetPath);
|
|
2228
|
-
await import_fs_extra3.default.copyFile(props.newFilePath, assetPath);
|
|
2229
|
-
assetFile.extension = fileType.extension;
|
|
2230
|
-
assetFile.mimeType = fileType.mimeType;
|
|
2231
|
-
assetFile.size = size;
|
|
2232
|
-
}
|
|
2233
|
-
await this.jsonFileService.update(
|
|
2234
|
-
assetFile,
|
|
2235
|
-
assetFilePath,
|
|
2236
|
-
assetFileSchema
|
|
2237
|
-
);
|
|
2238
|
-
await this.gitService.add(projectPath, [assetFilePath]);
|
|
2239
|
-
await this.gitService.commit(projectPath, this.gitMessage.update);
|
|
2240
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2287
|
+
async updateVersion() {
|
|
2288
|
+
const result = await this.git("", ["--version"]);
|
|
2289
|
+
this.version = result.stdout.replace("git version", "").trim();
|
|
2241
2290
|
}
|
|
2242
2291
|
/**
|
|
2243
|
-
*
|
|
2292
|
+
* Reads the path to the executable of Git that is used
|
|
2293
|
+
*
|
|
2294
|
+
* This can help debugging, since dugite is shipping their own executable
|
|
2295
|
+
* but in some cases resolves another executable
|
|
2296
|
+
* @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
|
|
2244
2297
|
*/
|
|
2245
|
-
async
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
const assetFilePath = pathTo.assetFile(
|
|
2249
|
-
props.projectId,
|
|
2250
|
-
props.id,
|
|
2251
|
-
props.language
|
|
2252
|
-
);
|
|
2253
|
-
const assetPath = pathTo.asset(
|
|
2254
|
-
props.projectId,
|
|
2255
|
-
props.id,
|
|
2256
|
-
props.language,
|
|
2257
|
-
props.extension
|
|
2258
|
-
);
|
|
2259
|
-
await import_fs_extra3.default.remove(assetPath);
|
|
2260
|
-
await import_fs_extra3.default.remove(assetFilePath);
|
|
2261
|
-
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
2262
|
-
await this.gitService.commit(projectPath, this.gitMessage.delete);
|
|
2263
|
-
}
|
|
2264
|
-
async list(props) {
|
|
2265
|
-
listAssetsSchema.parse(props);
|
|
2266
|
-
const offset = props.offset || 0;
|
|
2267
|
-
const limit = props.limit || 15;
|
|
2268
|
-
const assetReferences = await this.listReferences(
|
|
2269
|
-
objectTypeSchema.Enum.asset,
|
|
2270
|
-
props.projectId
|
|
2271
|
-
);
|
|
2272
|
-
const partialAssetReferences = assetReferences.slice(offset, limit);
|
|
2273
|
-
const assets = await returnResolved(
|
|
2274
|
-
partialAssetReferences.map((assetReference) => {
|
|
2275
|
-
if (!assetReference.language) {
|
|
2276
|
-
throw new RequiredParameterMissingError("language");
|
|
2277
|
-
}
|
|
2278
|
-
return this.read({
|
|
2279
|
-
projectId: props.projectId,
|
|
2280
|
-
id: assetReference.id,
|
|
2281
|
-
language: assetReference.language
|
|
2282
|
-
});
|
|
2283
|
-
})
|
|
2284
|
-
);
|
|
2285
|
-
return {
|
|
2286
|
-
total: assetReferences.length,
|
|
2287
|
-
limit,
|
|
2288
|
-
offset,
|
|
2289
|
-
list: assets
|
|
2290
|
-
};
|
|
2298
|
+
async updateGitPath() {
|
|
2299
|
+
const result = await this.git("", ["--exec-path"]);
|
|
2300
|
+
this.gitPath = result.stdout.trim();
|
|
2291
2301
|
}
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2302
|
+
/**
|
|
2303
|
+
* A reference is used in Git to specify branches and tags.
|
|
2304
|
+
* This method checks if given name matches the required format
|
|
2305
|
+
*
|
|
2306
|
+
* @see https://git-scm.com/docs/git-check-ref-format
|
|
2307
|
+
*
|
|
2308
|
+
* @param path Path to the repository
|
|
2309
|
+
* @param name Name to check
|
|
2310
|
+
*/
|
|
2311
|
+
async checkBranchOrTagName(path, name) {
|
|
2312
|
+
await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
|
|
2296
2313
|
}
|
|
2297
2314
|
/**
|
|
2298
|
-
*
|
|
2315
|
+
* Installs LFS support and starts tracking
|
|
2316
|
+
* all files inside the lfs folder
|
|
2317
|
+
*
|
|
2318
|
+
* @param path Path to the repository
|
|
2299
2319
|
*/
|
|
2300
|
-
|
|
2301
|
-
|
|
2320
|
+
async installLfs(path) {
|
|
2321
|
+
await this.git(path, ["lfs", "install"]);
|
|
2322
|
+
await this.git(path, ["lfs", "track", "lfs/*"]);
|
|
2302
2323
|
}
|
|
2303
2324
|
/**
|
|
2304
|
-
*
|
|
2325
|
+
* Sets the git config of given local repository from ElekIoCoreOptions
|
|
2305
2326
|
*
|
|
2306
|
-
* @param path Path
|
|
2327
|
+
* @param path Path to the repository
|
|
2307
2328
|
*/
|
|
2308
|
-
async
|
|
2309
|
-
|
|
2329
|
+
async setLocalConfig(path) {
|
|
2330
|
+
const user = await this.userService.get();
|
|
2331
|
+
if (!user) {
|
|
2332
|
+
throw new NoCurrentUserError();
|
|
2333
|
+
}
|
|
2334
|
+
const userNameArgs = ["config", "--local", "user.name", user.name];
|
|
2335
|
+
const userEmailArgs = ["config", "--local", "user.email", user.email];
|
|
2336
|
+
const autoSetupRemoteArgs = [
|
|
2337
|
+
"config",
|
|
2338
|
+
"--local",
|
|
2339
|
+
"push.autoSetupRemote",
|
|
2340
|
+
"true"
|
|
2341
|
+
];
|
|
2342
|
+
await this.git(path, userNameArgs);
|
|
2343
|
+
await this.git(path, userEmailArgs);
|
|
2344
|
+
await this.git(path, autoSetupRemoteArgs);
|
|
2310
2345
|
}
|
|
2311
2346
|
/**
|
|
2312
|
-
*
|
|
2347
|
+
* Type guard for GitCommit
|
|
2313
2348
|
*
|
|
2314
|
-
* @param
|
|
2315
|
-
* @param assetFile The AssetFile to convert
|
|
2349
|
+
* @param obj The object to check
|
|
2316
2350
|
*/
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
projectId,
|
|
2320
|
-
assetFile.id,
|
|
2321
|
-
assetFile.language,
|
|
2322
|
-
assetFile.extension
|
|
2323
|
-
);
|
|
2324
|
-
const asset = {
|
|
2325
|
-
...assetFile,
|
|
2326
|
-
absolutePath: assetPath
|
|
2327
|
-
};
|
|
2328
|
-
return asset;
|
|
2351
|
+
isGitCommit(obj) {
|
|
2352
|
+
return gitCommitSchema.safeParse(obj).success;
|
|
2329
2353
|
}
|
|
2330
2354
|
/**
|
|
2331
|
-
*
|
|
2332
|
-
*
|
|
2355
|
+
* Wraps the execution of any git command
|
|
2356
|
+
* to use a FIFO queue for sequential processing
|
|
2333
2357
|
*
|
|
2334
|
-
* @param
|
|
2358
|
+
* @param path Path to the repository
|
|
2359
|
+
* @param args Arguments to append after the `git` command
|
|
2335
2360
|
*/
|
|
2336
|
-
async
|
|
2337
|
-
const
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2361
|
+
async git(path, args) {
|
|
2362
|
+
const result = await this.queue.add(
|
|
2363
|
+
() => import_dugite.GitProcess.exec(args, path, {
|
|
2364
|
+
env: {
|
|
2365
|
+
// @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
|
|
2366
|
+
// @see https://github.com/git-lfs/git-lfs/issues/5749
|
|
2367
|
+
GIT_CLONE_PROTECTION_ACTIVE: "false"
|
|
2368
|
+
}
|
|
2369
|
+
})
|
|
2370
|
+
);
|
|
2371
|
+
if (!result) {
|
|
2372
|
+
throw new GitError(
|
|
2373
|
+
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2374
|
+
" "
|
|
2375
|
+
)}" failed to return a result`
|
|
2376
|
+
);
|
|
2377
|
+
}
|
|
2378
|
+
if (result.exitCode !== 0) {
|
|
2379
|
+
throw new GitError(
|
|
2380
|
+
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2381
|
+
" "
|
|
2382
|
+
)}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
|
|
2383
|
+
);
|
|
2346
2384
|
}
|
|
2347
|
-
const { fileTypeFromFile } = await import("file-type");
|
|
2348
|
-
const fileType = await fileTypeFromFile(filePath);
|
|
2349
|
-
const result = supportedAssetTypeSchema.parse({
|
|
2350
|
-
extension: fileType?.ext,
|
|
2351
|
-
mimeType: fileType?.mime
|
|
2352
|
-
});
|
|
2353
2385
|
return result;
|
|
2354
2386
|
}
|
|
2355
2387
|
};
|
|
2356
2388
|
|
|
2357
2389
|
// src/service/CollectionService.ts
|
|
2358
|
-
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
2359
2390
|
var CollectionService = class extends AbstractCrudService {
|
|
2360
2391
|
constructor(options, jsonFileService, gitService) {
|
|
2361
2392
|
super(serviceTypeSchema.Enum.Collection, options);
|
|
@@ -2790,16 +2821,6 @@ var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
|
2790
2821
|
var import_os4 = __toESM(require("os"), 1);
|
|
2791
2822
|
var import_path2 = __toESM(require("path"), 1);
|
|
2792
2823
|
var import_semver = __toESM(require("semver"), 1);
|
|
2793
|
-
|
|
2794
|
-
// src/error/ProjectUpgradeError.ts
|
|
2795
|
-
var ProjectUpgradeError = class extends Error {
|
|
2796
|
-
constructor(message) {
|
|
2797
|
-
super(message);
|
|
2798
|
-
this.name = "ProjectUpgradeError";
|
|
2799
|
-
}
|
|
2800
|
-
};
|
|
2801
|
-
|
|
2802
|
-
// src/service/ProjectService.ts
|
|
2803
2824
|
var ProjectService = class extends AbstractCrudService {
|
|
2804
2825
|
constructor(options, jsonFileService, userService, gitService, assetService, collectionService, entryService) {
|
|
2805
2826
|
super(serviceTypeSchema.Enum.Project, options);
|
|
@@ -3182,36 +3203,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3182
3203
|
}
|
|
3183
3204
|
};
|
|
3184
3205
|
|
|
3185
|
-
// src/
|
|
3186
|
-
var import_zod12 = require("zod");
|
|
3187
|
-
var elekIoCoreOptionsSchema = import_zod12.z.object({
|
|
3188
|
-
/**
|
|
3189
|
-
* The environment elek.io Core is currently running in
|
|
3190
|
-
*/
|
|
3191
|
-
environment: environmentSchema,
|
|
3192
|
-
/**
|
|
3193
|
-
* The current version of elek.io Core
|
|
3194
|
-
*/
|
|
3195
|
-
version: versionSchema,
|
|
3196
|
-
file: import_zod12.z.object({
|
|
3197
|
-
json: import_zod12.z.object({
|
|
3198
|
-
/**
|
|
3199
|
-
* If set, adds indentation with spaces (number) or escape character (string)
|
|
3200
|
-
* and line break characters to saved JSON files on disk, to make them easier to read.
|
|
3201
|
-
* Defaults to 2 spaces of indentation.
|
|
3202
|
-
*/
|
|
3203
|
-
indentation: import_zod12.z.union([import_zod12.z.number(), import_zod12.z.string()])
|
|
3204
|
-
})
|
|
3205
|
-
})
|
|
3206
|
-
});
|
|
3207
|
-
var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
|
|
3208
|
-
version: true
|
|
3209
|
-
}).partial({
|
|
3210
|
-
environment: true,
|
|
3211
|
-
file: true
|
|
3212
|
-
}).optional();
|
|
3213
|
-
|
|
3214
|
-
// src/index.ts
|
|
3206
|
+
// src/index.node.ts
|
|
3215
3207
|
var ElekIoCore = class {
|
|
3216
3208
|
// private readonly sharedValueService: SharedValueService;
|
|
3217
3209
|
constructor(props) {
|
|
@@ -3453,4 +3445,4 @@ var ElekIoCore = class {
|
|
|
3453
3445
|
valueSchema,
|
|
3454
3446
|
versionSchema
|
|
3455
3447
|
});
|
|
3456
|
-
//# sourceMappingURL=index.cjs.map
|
|
3448
|
+
//# sourceMappingURL=index.node.cjs.map
|