@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.
- 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} +1005 -1018
- package/dist/node/index.node.cjs.map +1 -0
- package/dist/{index.d.cts → node/index.node.d.cts} +3032 -3034
- package/dist/{index.d.ts → node/index.node.d.ts} +3032 -3034
- package/dist/{index.js → node/index.node.js} +1049 -1065
- package/dist/node/index.node.js.map +1 -0
- package/package.json +1 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -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,
|
|
@@ -62,6 +62,7 @@ __export(src_exports, {
|
|
|
62
62
|
createGitTagSchema: () => createGitTagSchema,
|
|
63
63
|
createProjectSchema: () => createProjectSchema,
|
|
64
64
|
currentBranchProjectSchema: () => currentBranchProjectSchema,
|
|
65
|
+
currentTimestamp: () => currentTimestamp,
|
|
65
66
|
dateValueDefinitionSchema: () => dateValueDefinitionSchema,
|
|
66
67
|
datetimeValueDefinitionSchema: () => datetimeValueDefinitionSchema,
|
|
67
68
|
default: () => ElekIoCore,
|
|
@@ -126,6 +127,7 @@ __export(src_exports, {
|
|
|
126
127
|
serviceTypeSchema: () => serviceTypeSchema,
|
|
127
128
|
setRemoteOriginUrlProjectSchema: () => setRemoteOriginUrlProjectSchema,
|
|
128
129
|
setUserSchema: () => setUserSchema,
|
|
130
|
+
slug: () => slug,
|
|
129
131
|
stringValueDefinitionSchema: () => stringValueDefinitionSchema,
|
|
130
132
|
supportedAssetExtensionSchema: () => supportedAssetExtensionSchema,
|
|
131
133
|
supportedAssetMimeTypeSchema: () => supportedAssetMimeTypeSchema,
|
|
@@ -151,6 +153,7 @@ __export(src_exports, {
|
|
|
151
153
|
urlValueDefinitionSchema: () => urlValueDefinitionSchema,
|
|
152
154
|
userFileSchema: () => userFileSchema,
|
|
153
155
|
userSchema: () => userSchema,
|
|
156
|
+
uuid: () => uuid,
|
|
154
157
|
uuidSchema: () => uuidSchema,
|
|
155
158
|
valueContentReferenceBase: () => valueContentReferenceBase,
|
|
156
159
|
valueContentReferenceSchema: () => valueContentReferenceSchema,
|
|
@@ -162,21 +165,9 @@ __export(src_exports, {
|
|
|
162
165
|
valueSchema: () => valueSchema,
|
|
163
166
|
versionSchema: () => versionSchema
|
|
164
167
|
});
|
|
165
|
-
module.exports = __toCommonJS(
|
|
168
|
+
module.exports = __toCommonJS(index_node_exports);
|
|
166
169
|
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
167
170
|
|
|
168
|
-
// src/service/AssetService.ts
|
|
169
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
170
|
-
var import_is_svg = __toESM(require("is-svg"), 1);
|
|
171
|
-
|
|
172
|
-
// src/error/RequiredParameterMissingError.ts
|
|
173
|
-
var RequiredParameterMissingError = class extends Error {
|
|
174
|
-
constructor(parameter) {
|
|
175
|
-
super(`Missing required parameter "${parameter}"`);
|
|
176
|
-
this.name = "RequiredParameterMissingError";
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
171
|
// src/schema/assetSchema.ts
|
|
181
172
|
var import_zod3 = __toESM(require("zod"), 1);
|
|
182
173
|
|
|
@@ -388,161 +379,21 @@ var deleteAssetSchema = assetFileSchema.pick({
|
|
|
388
379
|
});
|
|
389
380
|
var countAssetsSchema = import_zod3.default.object({ projectId: uuidSchema.readonly() });
|
|
390
381
|
|
|
391
|
-
// src/schema/serviceSchema.ts
|
|
392
|
-
var import_zod5 = require("zod");
|
|
393
|
-
|
|
394
|
-
// src/schema/gitSchema.ts
|
|
395
|
-
var import_zod4 = require("zod");
|
|
396
|
-
var gitRepositoryPathSchema = import_zod4.z.string();
|
|
397
|
-
var gitSignatureSchema = import_zod4.z.object({
|
|
398
|
-
name: import_zod4.z.string(),
|
|
399
|
-
email: import_zod4.z.string()
|
|
400
|
-
});
|
|
401
|
-
var gitCommitSchema = import_zod4.z.object({
|
|
402
|
-
/**
|
|
403
|
-
* SHA-1 hash of the commit
|
|
404
|
-
*/
|
|
405
|
-
hash: import_zod4.z.string(),
|
|
406
|
-
message: import_zod4.z.string(),
|
|
407
|
-
author: gitSignatureSchema,
|
|
408
|
-
timestamp: import_zod4.z.number(),
|
|
409
|
-
tag: import_zod4.z.string().nullable()
|
|
410
|
-
});
|
|
411
|
-
var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
|
|
412
|
-
GitCommitIconNative2["INIT"] = ":tada:";
|
|
413
|
-
GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
|
|
414
|
-
GitCommitIconNative2["UPDATE"] = ":wrench:";
|
|
415
|
-
GitCommitIconNative2["DELETE"] = ":fire:";
|
|
416
|
-
return GitCommitIconNative2;
|
|
417
|
-
})(GitCommitIconNative || {});
|
|
418
|
-
var gitCommitIconSchema = import_zod4.z.nativeEnum(GitCommitIconNative);
|
|
419
|
-
var gitInitOptionsSchema = import_zod4.z.object({
|
|
420
|
-
/**
|
|
421
|
-
* Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).
|
|
422
|
-
*/
|
|
423
|
-
initialBranch: import_zod4.z.string()
|
|
424
|
-
});
|
|
425
|
-
var gitCloneOptionsSchema = import_zod4.z.object({
|
|
426
|
-
/**
|
|
427
|
-
* Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
|
|
428
|
-
*/
|
|
429
|
-
depth: import_zod4.z.number(),
|
|
430
|
-
/**
|
|
431
|
-
* Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.
|
|
432
|
-
*/
|
|
433
|
-
singleBranch: import_zod4.z.boolean(),
|
|
434
|
-
/**
|
|
435
|
-
* Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
|
|
436
|
-
*/
|
|
437
|
-
branch: import_zod4.z.string()
|
|
438
|
-
});
|
|
439
|
-
var gitSwitchOptionsSchema = import_zod4.z.object({
|
|
440
|
-
/**
|
|
441
|
-
* If true, creates a new local branch and then switches to it
|
|
442
|
-
*
|
|
443
|
-
* @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
|
|
444
|
-
*/
|
|
445
|
-
isNew: import_zod4.z.boolean().optional()
|
|
446
|
-
});
|
|
447
|
-
var gitLogOptionsSchema = import_zod4.z.object({
|
|
448
|
-
/**
|
|
449
|
-
* Limit the result to given number of commits
|
|
450
|
-
*/
|
|
451
|
-
limit: import_zod4.z.number().optional(),
|
|
452
|
-
/**
|
|
453
|
-
* Only list commits that are between given SHAs or tag names
|
|
454
|
-
*
|
|
455
|
-
* Note that the commits of from and to are not included in the result
|
|
456
|
-
*/
|
|
457
|
-
between: import_zod4.z.object({
|
|
458
|
-
/**
|
|
459
|
-
* From the oldest commit
|
|
460
|
-
*/
|
|
461
|
-
from: import_zod4.z.string(),
|
|
462
|
-
/**
|
|
463
|
-
* To the newest commit
|
|
464
|
-
*
|
|
465
|
-
* Defaults to the current HEAD
|
|
466
|
-
*/
|
|
467
|
-
to: import_zod4.z.string().optional()
|
|
468
|
-
})
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
// src/schema/serviceSchema.ts
|
|
472
|
-
var serviceTypeSchema = import_zod5.z.enum([
|
|
473
|
-
"Git",
|
|
474
|
-
"GitTag",
|
|
475
|
-
"User",
|
|
476
|
-
"Project",
|
|
477
|
-
"Asset",
|
|
478
|
-
"JsonFile",
|
|
479
|
-
"Search",
|
|
480
|
-
"Collection",
|
|
481
|
-
"Entry",
|
|
482
|
-
"Value"
|
|
483
|
-
]);
|
|
484
|
-
var listSchema = import_zod5.z.object({
|
|
485
|
-
projectId: uuidSchema,
|
|
486
|
-
limit: import_zod5.z.number().optional(),
|
|
487
|
-
offset: import_zod5.z.number().optional()
|
|
488
|
-
});
|
|
489
|
-
var listCollectionsSchema = listSchema;
|
|
490
|
-
var listEntriesSchema = listSchema.extend({
|
|
491
|
-
collectionId: uuidSchema
|
|
492
|
-
});
|
|
493
|
-
var listAssetsSchema = listSchema;
|
|
494
|
-
var listProjectsSchema = listSchema.omit({
|
|
495
|
-
projectId: true
|
|
496
|
-
});
|
|
497
|
-
var listGitTagsSchema = import_zod5.z.object({
|
|
498
|
-
path: gitRepositoryPathSchema
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// src/util/index.ts
|
|
502
|
-
var util_exports = {};
|
|
503
|
-
__export(util_exports, {
|
|
504
|
-
assignDefaultIfMissing: () => assignDefaultIfMissing,
|
|
505
|
-
currentTimestamp: () => currentTimestamp,
|
|
506
|
-
files: () => files,
|
|
507
|
-
folders: () => folders,
|
|
508
|
-
fromPath: () => fromPath,
|
|
509
|
-
getDuplicates: () => getDuplicates,
|
|
510
|
-
getRelativePath: () => getRelativePath,
|
|
511
|
-
isNoError: () => isNoError,
|
|
512
|
-
notEmpty: () => notEmpty,
|
|
513
|
-
pathTo: () => pathTo,
|
|
514
|
-
returnResolved: () => returnResolved,
|
|
515
|
-
slug: () => slug,
|
|
516
|
-
spawnChildProcess: () => spawnChildProcess,
|
|
517
|
-
uuid: () => uuid,
|
|
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
|
-
var import_slugify = __toESM(require("slugify"), 1);
|
|
526
|
-
var import_uuid = require("uuid");
|
|
527
|
-
|
|
528
|
-
// src/schema/projectSchema.ts
|
|
529
|
-
var import_zod9 = require("zod");
|
|
530
|
-
|
|
531
382
|
// src/schema/collectionSchema.ts
|
|
532
|
-
var
|
|
383
|
+
var import_zod6 = __toESM(require("zod"), 1);
|
|
533
384
|
|
|
534
385
|
// src/schema/entrySchema.ts
|
|
535
|
-
var
|
|
386
|
+
var import_zod5 = __toESM(require("zod"), 1);
|
|
536
387
|
|
|
537
388
|
// src/schema/valueSchema.ts
|
|
538
|
-
var
|
|
539
|
-
var ValueTypeSchema =
|
|
389
|
+
var import_zod4 = __toESM(require("zod"), 1);
|
|
390
|
+
var ValueTypeSchema = import_zod4.default.enum([
|
|
540
391
|
"string",
|
|
541
392
|
"number",
|
|
542
393
|
"boolean",
|
|
543
394
|
"reference"
|
|
544
395
|
]);
|
|
545
|
-
var ValueInputTypeSchema =
|
|
396
|
+
var ValueInputTypeSchema = import_zod4.default.enum([
|
|
546
397
|
// String
|
|
547
398
|
"text",
|
|
548
399
|
"textarea",
|
|
@@ -564,67 +415,67 @@ var ValueInputTypeSchema = import_zod6.default.enum([
|
|
|
564
415
|
"entry"
|
|
565
416
|
// 'sharedValue', // @todo
|
|
566
417
|
]);
|
|
567
|
-
var ValueInputWidthSchema =
|
|
568
|
-
var ValueDefinitionBaseSchema =
|
|
418
|
+
var ValueInputWidthSchema = import_zod4.default.enum(["12", "6", "4", "3"]);
|
|
419
|
+
var ValueDefinitionBaseSchema = import_zod4.default.object({
|
|
569
420
|
id: uuidSchema.readonly(),
|
|
570
421
|
label: translatableStringSchema,
|
|
571
422
|
description: translatableStringSchema,
|
|
572
|
-
isRequired:
|
|
573
|
-
isDisabled:
|
|
574
|
-
isUnique:
|
|
423
|
+
isRequired: import_zod4.default.boolean(),
|
|
424
|
+
isDisabled: import_zod4.default.boolean(),
|
|
425
|
+
isUnique: import_zod4.default.boolean(),
|
|
575
426
|
inputWidth: ValueInputWidthSchema
|
|
576
427
|
});
|
|
577
428
|
var StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
|
|
578
429
|
{
|
|
579
|
-
valueType:
|
|
580
|
-
defaultValue:
|
|
430
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.string),
|
|
431
|
+
defaultValue: import_zod4.default.string().nullable()
|
|
581
432
|
}
|
|
582
433
|
);
|
|
583
434
|
var textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
584
435
|
{
|
|
585
|
-
inputType:
|
|
586
|
-
min:
|
|
587
|
-
max:
|
|
436
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.text),
|
|
437
|
+
min: import_zod4.default.number().nullable(),
|
|
438
|
+
max: import_zod4.default.number().nullable()
|
|
588
439
|
}
|
|
589
440
|
);
|
|
590
441
|
var textareaValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
591
|
-
inputType:
|
|
592
|
-
min:
|
|
593
|
-
max:
|
|
442
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.textarea),
|
|
443
|
+
min: import_zod4.default.number().nullable(),
|
|
444
|
+
max: import_zod4.default.number().nullable()
|
|
594
445
|
});
|
|
595
446
|
var emailValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
596
|
-
inputType:
|
|
597
|
-
defaultValue:
|
|
447
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.email),
|
|
448
|
+
defaultValue: import_zod4.default.string().email().nullable()
|
|
598
449
|
});
|
|
599
450
|
var urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
600
|
-
inputType:
|
|
601
|
-
defaultValue:
|
|
451
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.url),
|
|
452
|
+
defaultValue: import_zod4.default.string().url().nullable()
|
|
602
453
|
});
|
|
603
454
|
var ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
604
|
-
inputType:
|
|
605
|
-
defaultValue:
|
|
455
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.ip),
|
|
456
|
+
defaultValue: import_zod4.default.string().ip().nullable()
|
|
606
457
|
});
|
|
607
458
|
var dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
608
459
|
{
|
|
609
|
-
inputType:
|
|
610
|
-
defaultValue:
|
|
460
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.date),
|
|
461
|
+
defaultValue: import_zod4.default.string().date().nullable()
|
|
611
462
|
}
|
|
612
463
|
);
|
|
613
464
|
var timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
614
465
|
{
|
|
615
|
-
inputType:
|
|
616
|
-
defaultValue:
|
|
466
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.time),
|
|
467
|
+
defaultValue: import_zod4.default.string().time().nullable()
|
|
617
468
|
}
|
|
618
469
|
);
|
|
619
470
|
var datetimeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
620
|
-
inputType:
|
|
621
|
-
defaultValue:
|
|
471
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.datetime),
|
|
472
|
+
defaultValue: import_zod4.default.string().datetime().nullable()
|
|
622
473
|
});
|
|
623
474
|
var telephoneValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
624
|
-
inputType:
|
|
475
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.telephone)
|
|
625
476
|
// defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
|
|
626
477
|
});
|
|
627
|
-
var stringValueDefinitionSchema =
|
|
478
|
+
var stringValueDefinitionSchema = import_zod4.default.union([
|
|
628
479
|
textValueDefinitionSchema,
|
|
629
480
|
textareaValueDefinitionSchema,
|
|
630
481
|
emailValueDefinitionSchema,
|
|
@@ -637,50 +488,50 @@ var stringValueDefinitionSchema = import_zod6.default.union([
|
|
|
637
488
|
]);
|
|
638
489
|
var NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
|
|
639
490
|
{
|
|
640
|
-
valueType:
|
|
641
|
-
min:
|
|
642
|
-
max:
|
|
643
|
-
isUnique:
|
|
644
|
-
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()
|
|
645
496
|
}
|
|
646
497
|
);
|
|
647
498
|
var numberValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
|
|
648
|
-
inputType:
|
|
499
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.number)
|
|
649
500
|
});
|
|
650
501
|
var rangeValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
|
|
651
|
-
inputType:
|
|
502
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.range),
|
|
652
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
|
|
653
|
-
isRequired:
|
|
654
|
-
min:
|
|
655
|
-
max:
|
|
656
|
-
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()
|
|
657
508
|
});
|
|
658
509
|
var BooleanValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
|
|
659
|
-
valueType:
|
|
510
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.boolean),
|
|
660
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
|
|
661
|
-
isRequired:
|
|
662
|
-
defaultValue:
|
|
663
|
-
isUnique:
|
|
512
|
+
isRequired: import_zod4.default.literal(true),
|
|
513
|
+
defaultValue: import_zod4.default.boolean(),
|
|
514
|
+
isUnique: import_zod4.default.literal(false)
|
|
664
515
|
});
|
|
665
516
|
var toggleValueDefinitionSchema = BooleanValueDefinitionBaseSchema.extend({
|
|
666
|
-
inputType:
|
|
517
|
+
inputType: import_zod4.default.literal(ValueInputTypeSchema.Enum.toggle)
|
|
667
518
|
});
|
|
668
519
|
var ReferenceValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
|
|
669
|
-
valueType:
|
|
520
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.reference)
|
|
670
521
|
});
|
|
671
522
|
var assetValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
|
|
672
|
-
inputType:
|
|
673
|
-
allowedMimeTypes:
|
|
674
|
-
min:
|
|
675
|
-
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()
|
|
676
527
|
});
|
|
677
528
|
var entryValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
|
|
678
|
-
inputType:
|
|
679
|
-
ofCollections:
|
|
680
|
-
min:
|
|
681
|
-
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()
|
|
682
533
|
});
|
|
683
|
-
var valueDefinitionSchema =
|
|
534
|
+
var valueDefinitionSchema = import_zod4.default.union([
|
|
684
535
|
stringValueDefinitionSchema,
|
|
685
536
|
numberValueDefinitionSchema,
|
|
686
537
|
rangeValueDefinitionSchema,
|
|
@@ -689,65 +540,65 @@ var valueDefinitionSchema = import_zod6.default.union([
|
|
|
689
540
|
entryValueDefinitionSchema
|
|
690
541
|
// sharedValueDefinitionSchema,
|
|
691
542
|
]);
|
|
692
|
-
var valueContentReferenceBase =
|
|
543
|
+
var valueContentReferenceBase = import_zod4.default.object({
|
|
693
544
|
id: uuidSchema
|
|
694
545
|
});
|
|
695
546
|
var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
|
|
696
547
|
language: supportedLanguageSchema
|
|
697
548
|
});
|
|
698
549
|
var valueContentReferenceToAssetSchema = valueContentReferenceWithLanguageBase.extend({
|
|
699
|
-
objectType:
|
|
550
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.asset)
|
|
700
551
|
});
|
|
701
552
|
var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
|
|
702
|
-
objectType:
|
|
553
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.collection)
|
|
703
554
|
});
|
|
704
555
|
var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
|
|
705
|
-
objectType:
|
|
556
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.entry)
|
|
706
557
|
});
|
|
707
|
-
var valueContentReferenceSchema =
|
|
558
|
+
var valueContentReferenceSchema = import_zod4.default.union([
|
|
708
559
|
valueContentReferenceToAssetSchema,
|
|
709
560
|
valueContentReferenceToCollectionSchema,
|
|
710
561
|
valueContentReferenceToEntrySchema
|
|
711
562
|
// valueContentReferenceToSharedValueSchema,
|
|
712
563
|
]);
|
|
713
|
-
var resolvedValueContentReferenceSchema =
|
|
564
|
+
var resolvedValueContentReferenceSchema = import_zod4.default.union([
|
|
714
565
|
assetSchema,
|
|
715
|
-
|
|
566
|
+
import_zod4.default.lazy(() => entrySchema)
|
|
716
567
|
// Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types
|
|
717
568
|
// resolvedValueContentReferenceToSharedValueSchema,
|
|
718
569
|
]);
|
|
719
|
-
var directValueBaseSchema =
|
|
720
|
-
objectType:
|
|
570
|
+
var directValueBaseSchema = import_zod4.default.object({
|
|
571
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.value).readonly(),
|
|
721
572
|
definitionId: uuidSchema.readonly()
|
|
722
573
|
});
|
|
723
574
|
var directStringValueSchema = directValueBaseSchema.extend({
|
|
724
|
-
valueType:
|
|
575
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.string).readonly(),
|
|
725
576
|
content: translatableStringSchema
|
|
726
577
|
});
|
|
727
578
|
var directNumberValueSchema = directValueBaseSchema.extend({
|
|
728
|
-
valueType:
|
|
579
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.number).readonly(),
|
|
729
580
|
content: translatableNumberSchema
|
|
730
581
|
});
|
|
731
582
|
var directBooleanValueSchema = directValueBaseSchema.extend({
|
|
732
|
-
valueType:
|
|
583
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.boolean).readonly(),
|
|
733
584
|
content: translatableBooleanSchema
|
|
734
585
|
});
|
|
735
|
-
var directValueSchema =
|
|
586
|
+
var directValueSchema = import_zod4.default.union([
|
|
736
587
|
directStringValueSchema,
|
|
737
588
|
directNumberValueSchema,
|
|
738
589
|
directBooleanValueSchema
|
|
739
590
|
]);
|
|
740
|
-
var referencedValueSchema =
|
|
741
|
-
objectType:
|
|
591
|
+
var referencedValueSchema = import_zod4.default.object({
|
|
592
|
+
objectType: import_zod4.default.literal(objectTypeSchema.Enum.value).readonly(),
|
|
742
593
|
definitionId: uuidSchema.readonly(),
|
|
743
|
-
valueType:
|
|
594
|
+
valueType: import_zod4.default.literal(ValueTypeSchema.Enum.reference).readonly(),
|
|
744
595
|
content: translatableArrayOf(valueContentReferenceSchema)
|
|
745
596
|
});
|
|
746
|
-
var valueSchema =
|
|
597
|
+
var valueSchema = import_zod4.default.union([directValueSchema, referencedValueSchema]);
|
|
747
598
|
var resolvedReferencedValueSchema = referencedValueSchema.extend({
|
|
748
599
|
content: translatableArrayOf(resolvedValueContentReferenceSchema)
|
|
749
600
|
});
|
|
750
|
-
var resolvedValueSchema =
|
|
601
|
+
var resolvedValueSchema = import_zod4.default.union([
|
|
751
602
|
directValueSchema,
|
|
752
603
|
resolvedReferencedValueSchema
|
|
753
604
|
]);
|
|
@@ -769,10 +620,10 @@ function getValueContentSchemaFromDefinition(definition) {
|
|
|
769
620
|
}
|
|
770
621
|
}
|
|
771
622
|
function getBooleanValueContentSchema(definition) {
|
|
772
|
-
return
|
|
623
|
+
return import_zod4.default.boolean();
|
|
773
624
|
}
|
|
774
625
|
function getNumberValueContentSchema(definition) {
|
|
775
|
-
let schema =
|
|
626
|
+
let schema = import_zod4.default.number();
|
|
776
627
|
if (definition.min) {
|
|
777
628
|
schema = schema.min(definition.min);
|
|
778
629
|
}
|
|
@@ -785,7 +636,7 @@ function getNumberValueContentSchema(definition) {
|
|
|
785
636
|
return schema;
|
|
786
637
|
}
|
|
787
638
|
function getStringValueContentSchema(definition) {
|
|
788
|
-
let schema =
|
|
639
|
+
let schema = import_zod4.default.string().trim();
|
|
789
640
|
if ("min" in definition && definition.min) {
|
|
790
641
|
schema = schema.min(definition.min);
|
|
791
642
|
}
|
|
@@ -824,12 +675,12 @@ function getReferenceValueContentSchema(definition) {
|
|
|
824
675
|
switch (definition.inputType) {
|
|
825
676
|
case ValueInputTypeSchema.Enum.asset:
|
|
826
677
|
{
|
|
827
|
-
schema =
|
|
678
|
+
schema = import_zod4.default.array(valueContentReferenceToAssetSchema);
|
|
828
679
|
}
|
|
829
680
|
break;
|
|
830
681
|
case ValueInputTypeSchema.Enum.entry:
|
|
831
682
|
{
|
|
832
|
-
schema =
|
|
683
|
+
schema = import_zod4.default.array(valueContentReferenceToEntrySchema);
|
|
833
684
|
}
|
|
834
685
|
break;
|
|
835
686
|
}
|
|
@@ -847,11 +698,11 @@ function getReferenceValueContentSchema(definition) {
|
|
|
847
698
|
|
|
848
699
|
// src/schema/entrySchema.ts
|
|
849
700
|
var entryFileSchema = baseFileSchema.extend({
|
|
850
|
-
objectType:
|
|
851
|
-
values:
|
|
701
|
+
objectType: import_zod5.default.literal(objectTypeSchema.Enum.entry).readonly(),
|
|
702
|
+
values: import_zod5.default.array(valueSchema)
|
|
852
703
|
});
|
|
853
704
|
var entrySchema = entryFileSchema.extend({
|
|
854
|
-
values:
|
|
705
|
+
values: import_zod5.default.array(import_zod5.default.lazy(() => resolvedValueSchema))
|
|
855
706
|
});
|
|
856
707
|
var entryExportSchema = entrySchema.extend({});
|
|
857
708
|
var createEntrySchema = entryFileSchema.omit({
|
|
@@ -862,9 +713,9 @@ var createEntrySchema = entryFileSchema.omit({
|
|
|
862
713
|
}).extend({
|
|
863
714
|
projectId: uuidSchema.readonly(),
|
|
864
715
|
collectionId: uuidSchema.readonly(),
|
|
865
|
-
values:
|
|
716
|
+
values: import_zod5.default.array(valueSchema)
|
|
866
717
|
});
|
|
867
|
-
var readEntrySchema =
|
|
718
|
+
var readEntrySchema = import_zod5.default.object({
|
|
868
719
|
id: uuidSchema.readonly(),
|
|
869
720
|
projectId: uuidSchema.readonly(),
|
|
870
721
|
collectionId: uuidSchema.readonly()
|
|
@@ -878,29 +729,29 @@ var updateEntrySchema = entrySchema.omit({
|
|
|
878
729
|
collectionId: uuidSchema.readonly()
|
|
879
730
|
});
|
|
880
731
|
var deleteEntrySchema = readEntrySchema.extend({});
|
|
881
|
-
var countEntriesSchema =
|
|
732
|
+
var countEntriesSchema = import_zod5.default.object({
|
|
882
733
|
projectId: uuidSchema.readonly(),
|
|
883
734
|
collectionId: uuidSchema.readonly()
|
|
884
735
|
});
|
|
885
736
|
|
|
886
737
|
// src/schema/collectionSchema.ts
|
|
887
738
|
var collectionFileSchema = baseFileSchema.extend({
|
|
888
|
-
objectType:
|
|
889
|
-
name:
|
|
739
|
+
objectType: import_zod6.default.literal(objectTypeSchema.Enum.collection).readonly(),
|
|
740
|
+
name: import_zod6.default.object({
|
|
890
741
|
singular: translatableStringSchema,
|
|
891
742
|
plural: translatableStringSchema
|
|
892
743
|
}),
|
|
893
|
-
slug:
|
|
894
|
-
singular:
|
|
895
|
-
plural:
|
|
744
|
+
slug: import_zod6.default.object({
|
|
745
|
+
singular: import_zod6.default.string(),
|
|
746
|
+
plural: import_zod6.default.string()
|
|
896
747
|
}),
|
|
897
748
|
description: translatableStringSchema,
|
|
898
749
|
icon: supportedIconSchema,
|
|
899
|
-
valueDefinitions:
|
|
750
|
+
valueDefinitions: import_zod6.default.array(valueDefinitionSchema)
|
|
900
751
|
});
|
|
901
752
|
var collectionSchema = collectionFileSchema.extend({});
|
|
902
753
|
var collectionExportSchema = collectionSchema.extend({
|
|
903
|
-
entries:
|
|
754
|
+
entries: import_zod6.default.array(entryExportSchema)
|
|
904
755
|
});
|
|
905
756
|
var createCollectionSchema = collectionSchema.omit({
|
|
906
757
|
id: true,
|
|
@@ -910,7 +761,7 @@ var createCollectionSchema = collectionSchema.omit({
|
|
|
910
761
|
}).extend({
|
|
911
762
|
projectId: uuidSchema.readonly()
|
|
912
763
|
});
|
|
913
|
-
var readCollectionSchema =
|
|
764
|
+
var readCollectionSchema = import_zod6.default.object({
|
|
914
765
|
id: uuidSchema.readonly(),
|
|
915
766
|
projectId: uuidSchema.readonly()
|
|
916
767
|
});
|
|
@@ -925,19 +776,149 @@ var updateCollectionSchema = collectionFileSchema.pick({
|
|
|
925
776
|
projectId: uuidSchema.readonly()
|
|
926
777
|
});
|
|
927
778
|
var deleteCollectionSchema = readCollectionSchema.extend({});
|
|
928
|
-
var countCollectionsSchema =
|
|
779
|
+
var countCollectionsSchema = import_zod6.default.object({
|
|
929
780
|
projectId: uuidSchema.readonly()
|
|
930
781
|
});
|
|
931
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
|
+
|
|
932
912
|
// src/schema/projectSchema.ts
|
|
933
|
-
var
|
|
934
|
-
var
|
|
935
|
-
|
|
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({
|
|
936
917
|
default: supportedLanguageSchema,
|
|
937
|
-
supported:
|
|
918
|
+
supported: import_zod10.z.array(supportedLanguageSchema)
|
|
938
919
|
})
|
|
939
920
|
});
|
|
940
|
-
var projectFolderSchema =
|
|
921
|
+
var projectFolderSchema = import_zod10.z.enum([
|
|
941
922
|
"assets",
|
|
942
923
|
"collections",
|
|
943
924
|
"shared-values",
|
|
@@ -947,18 +928,18 @@ var projectFolderSchema = import_zod9.z.enum([
|
|
|
947
928
|
// 'theme',
|
|
948
929
|
]);
|
|
949
930
|
var projectFileSchema = baseFileSchema.extend({
|
|
950
|
-
objectType:
|
|
931
|
+
objectType: import_zod10.z.literal(objectTypeSchema.Enum.project).readonly(),
|
|
951
932
|
coreVersion: versionSchema,
|
|
952
|
-
name:
|
|
953
|
-
description:
|
|
933
|
+
name: import_zod10.z.string().trim().min(1, "shared.projectNameRequired"),
|
|
934
|
+
description: import_zod10.z.string().trim().min(1, "shared.projectDescriptionRequired"),
|
|
954
935
|
version: versionSchema,
|
|
955
936
|
status: projectStatusSchema,
|
|
956
937
|
settings: projectSettingsSchema
|
|
957
938
|
});
|
|
958
939
|
var projectSchema = projectFileSchema.extend({});
|
|
959
940
|
var projectExportSchema = projectSchema.extend({
|
|
960
|
-
assets:
|
|
961
|
-
collections:
|
|
941
|
+
assets: import_zod10.z.array(assetExportSchema),
|
|
942
|
+
collections: import_zod10.z.array(collectionExportSchema)
|
|
962
943
|
});
|
|
963
944
|
var createProjectSchema = projectSchema.pick({
|
|
964
945
|
name: true,
|
|
@@ -968,7 +949,7 @@ var createProjectSchema = projectSchema.pick({
|
|
|
968
949
|
description: true,
|
|
969
950
|
settings: true
|
|
970
951
|
});
|
|
971
|
-
var readProjectSchema =
|
|
952
|
+
var readProjectSchema = import_zod10.z.object({
|
|
972
953
|
id: uuidSchema.readonly()
|
|
973
954
|
});
|
|
974
955
|
var updateProjectSchema = projectSchema.pick({
|
|
@@ -981,11 +962,11 @@ var updateProjectSchema = projectSchema.pick({
|
|
|
981
962
|
description: true,
|
|
982
963
|
settings: true
|
|
983
964
|
});
|
|
984
|
-
var upgradeProjectSchema =
|
|
965
|
+
var upgradeProjectSchema = import_zod10.z.object({
|
|
985
966
|
id: uuidSchema.readonly()
|
|
986
967
|
});
|
|
987
968
|
var deleteProjectSchema = readProjectSchema.extend({});
|
|
988
|
-
var projectUpgradeSchema =
|
|
969
|
+
var projectUpgradeSchema = import_zod10.z.object({
|
|
989
970
|
/**
|
|
990
971
|
* The Core version the Project will be upgraded to
|
|
991
972
|
*/
|
|
@@ -993,79 +974,161 @@ var projectUpgradeSchema = import_zod9.z.object({
|
|
|
993
974
|
/**
|
|
994
975
|
* Function that will be executed in the process of upgrading a Project
|
|
995
976
|
*/
|
|
996
|
-
run:
|
|
977
|
+
run: import_zod10.z.function().args(projectFileSchema).returns(import_zod10.z.promise(import_zod10.z.void()))
|
|
997
978
|
});
|
|
998
|
-
var cloneProjectSchema =
|
|
999
|
-
url:
|
|
979
|
+
var cloneProjectSchema = import_zod10.z.object({
|
|
980
|
+
url: import_zod10.z.string()
|
|
1000
981
|
});
|
|
1001
|
-
var listBranchesProjectSchema =
|
|
982
|
+
var listBranchesProjectSchema = import_zod10.z.object({
|
|
1002
983
|
id: uuidSchema.readonly()
|
|
1003
984
|
});
|
|
1004
|
-
var currentBranchProjectSchema =
|
|
985
|
+
var currentBranchProjectSchema = import_zod10.z.object({
|
|
1005
986
|
id: uuidSchema.readonly()
|
|
1006
987
|
});
|
|
1007
|
-
var switchBranchProjectSchema =
|
|
988
|
+
var switchBranchProjectSchema = import_zod10.z.object({
|
|
1008
989
|
id: uuidSchema.readonly(),
|
|
1009
|
-
branch:
|
|
990
|
+
branch: import_zod10.z.string(),
|
|
1010
991
|
options: gitSwitchOptionsSchema.optional()
|
|
1011
992
|
});
|
|
1012
|
-
var getRemoteOriginUrlProjectSchema =
|
|
993
|
+
var getRemoteOriginUrlProjectSchema = import_zod10.z.object({
|
|
1013
994
|
id: uuidSchema.readonly()
|
|
1014
995
|
});
|
|
1015
|
-
var setRemoteOriginUrlProjectSchema =
|
|
996
|
+
var setRemoteOriginUrlProjectSchema = import_zod10.z.object({
|
|
1016
997
|
id: uuidSchema.readonly(),
|
|
1017
|
-
url:
|
|
998
|
+
url: import_zod10.z.string()
|
|
1018
999
|
});
|
|
1019
|
-
var getChangesProjectSchema =
|
|
1000
|
+
var getChangesProjectSchema = import_zod10.z.object({
|
|
1020
1001
|
id: uuidSchema.readonly()
|
|
1021
1002
|
});
|
|
1022
|
-
var synchronizeProjectSchema =
|
|
1003
|
+
var synchronizeProjectSchema = import_zod10.z.object({
|
|
1023
1004
|
id: uuidSchema.readonly()
|
|
1024
1005
|
});
|
|
1025
|
-
var searchProjectSchema =
|
|
1006
|
+
var searchProjectSchema = import_zod10.z.object({
|
|
1026
1007
|
id: uuidSchema.readonly(),
|
|
1027
|
-
query:
|
|
1008
|
+
query: import_zod10.z.string(),
|
|
1028
1009
|
language: supportedLanguageSchema,
|
|
1029
|
-
type:
|
|
1010
|
+
type: import_zod10.z.array(objectTypeSchema).optional()
|
|
1030
1011
|
});
|
|
1031
1012
|
|
|
1032
|
-
// src/
|
|
1033
|
-
var
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
var
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
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');
|
|
1069
1132
|
// },
|
|
1070
1133
|
lfs: (projectId) => {
|
|
1071
1134
|
return import_path.default.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
|
|
@@ -1313,269 +1376,465 @@ var AbstractCrudService = class {
|
|
|
1313
1376
|
}
|
|
1314
1377
|
};
|
|
1315
1378
|
|
|
1316
|
-
// src/service/
|
|
1317
|
-
var
|
|
1318
|
-
var
|
|
1319
|
-
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
1320
|
-
|
|
1321
|
-
// src/error/GitError.ts
|
|
1322
|
-
var GitError = class extends Error {
|
|
1323
|
-
constructor(message) {
|
|
1324
|
-
super(message);
|
|
1325
|
-
this.name = "GitError";
|
|
1326
|
-
}
|
|
1327
|
-
};
|
|
1328
|
-
|
|
1329
|
-
// src/error/NoCurrentUserError.ts
|
|
1330
|
-
var NoCurrentUserError = class extends Error {
|
|
1331
|
-
constructor() {
|
|
1332
|
-
super("Make sure to set a User via Core before using other methods");
|
|
1333
|
-
this.name = "NoCurrentUserError";
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
|
|
1337
|
-
// src/service/GitTagService.ts
|
|
1338
|
-
var import_os2 = require("os");
|
|
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);
|
|
1339
1382
|
|
|
1340
|
-
// src/
|
|
1341
|
-
var
|
|
1342
|
-
var
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
}
|
|
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
|
+
}
|
|
1362
1405
|
|
|
1363
|
-
// src/service/
|
|
1364
|
-
var
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
/**
|
|
1370
|
-
* Creates a new tag
|
|
1371
|
-
*
|
|
1372
|
-
* @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---annotate
|
|
1373
|
-
*/
|
|
1374
|
-
async create(props) {
|
|
1375
|
-
createGitTagSchema.parse(props);
|
|
1376
|
-
const id = uuid();
|
|
1377
|
-
let args = ["tag", "--annotate", id];
|
|
1378
|
-
if (props.hash) {
|
|
1379
|
-
args = [...args, props.hash];
|
|
1380
|
-
}
|
|
1381
|
-
args = [...args, "-m", props.message];
|
|
1382
|
-
await this.git(props.path, args);
|
|
1383
|
-
const tag = await this.read({ path: props.path, id });
|
|
1384
|
-
return tag;
|
|
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();
|
|
1385
1412
|
}
|
|
1386
1413
|
/**
|
|
1387
|
-
*
|
|
1414
|
+
* Creates a new file on disk. Fails if path already exists
|
|
1388
1415
|
*
|
|
1389
|
-
*
|
|
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
|
|
1390
1420
|
*/
|
|
1391
|
-
async
|
|
1392
|
-
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1395
|
-
|
|
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"
|
|
1396
1427
|
});
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
`Provided tag with UUID "${props.id}" did not match any known tags`
|
|
1400
|
-
);
|
|
1401
|
-
}
|
|
1402
|
-
return tag;
|
|
1428
|
+
this.cache.set(path, parsedData);
|
|
1429
|
+
return parsedData;
|
|
1403
1430
|
}
|
|
1404
1431
|
/**
|
|
1405
|
-
*
|
|
1406
|
-
* Please delete the old and create a new one
|
|
1432
|
+
* Reads the content of a file on disk. Fails if path does not exist
|
|
1407
1433
|
*
|
|
1408
|
-
* @
|
|
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
|
|
1409
1437
|
*/
|
|
1410
|
-
async
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
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;
|
|
1414
1450
|
}
|
|
1415
1451
|
/**
|
|
1416
|
-
*
|
|
1452
|
+
* Overwrites an existing file on disk
|
|
1417
1453
|
*
|
|
1418
|
-
* @
|
|
1454
|
+
* @todo Check how to error out if the file does not exist already
|
|
1419
1455
|
*
|
|
1420
|
-
* @param
|
|
1421
|
-
* @param
|
|
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
|
|
1422
1460
|
*/
|
|
1423
|
-
async
|
|
1424
|
-
|
|
1425
|
-
const
|
|
1426
|
-
await
|
|
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);
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
|
|
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;
|
|
1427
1485
|
}
|
|
1428
1486
|
/**
|
|
1429
|
-
*
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
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
|
|
1433
1540
|
*
|
|
1434
|
-
*
|
|
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
|
|
1435
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
|
+
}
|
|
1436
1611
|
async list(props) {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
const
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
timestamp: parseInt(lineArray[4])
|
|
1458
|
-
};
|
|
1459
|
-
});
|
|
1460
|
-
const gitTags = lineObjArr.filter(this.isGitTag.bind(this));
|
|
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
|
+
);
|
|
1461
1632
|
return {
|
|
1462
|
-
total:
|
|
1463
|
-
limit
|
|
1464
|
-
offset
|
|
1465
|
-
list:
|
|
1633
|
+
total: assetReferences.length,
|
|
1634
|
+
limit,
|
|
1635
|
+
offset,
|
|
1636
|
+
list: assets
|
|
1466
1637
|
};
|
|
1467
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
|
+
}
|
|
1468
1644
|
/**
|
|
1469
|
-
*
|
|
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
|
|
1470
1652
|
*
|
|
1471
|
-
*
|
|
1472
|
-
|
|
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
|
|
1473
1660
|
*
|
|
1474
|
-
* @param
|
|
1661
|
+
* @param projectId The project's ID
|
|
1662
|
+
* @param assetFile The AssetFile to convert
|
|
1475
1663
|
*/
|
|
1476
|
-
async
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
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;
|
|
1480
1676
|
}
|
|
1481
1677
|
/**
|
|
1482
|
-
*
|
|
1678
|
+
* Returns the found and supported extension as well as mime type,
|
|
1679
|
+
* otherwise throws an error
|
|
1483
1680
|
*
|
|
1484
|
-
* @param
|
|
1681
|
+
* @param filePath Path to the file to check
|
|
1485
1682
|
*/
|
|
1486
|
-
|
|
1487
|
-
|
|
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;
|
|
1488
1701
|
}
|
|
1489
1702
|
};
|
|
1490
1703
|
|
|
1491
|
-
// src/
|
|
1492
|
-
var
|
|
1493
|
-
var UserTypeSchema = import_zod11.default.enum(["local", "cloud"]);
|
|
1494
|
-
var baseUserSchema = gitSignatureSchema.extend({
|
|
1495
|
-
userType: UserTypeSchema,
|
|
1496
|
-
language: supportedLanguageSchema
|
|
1497
|
-
});
|
|
1498
|
-
var localUserSchema = baseUserSchema.extend({
|
|
1499
|
-
userType: import_zod11.default.literal(UserTypeSchema.Enum.local)
|
|
1500
|
-
});
|
|
1501
|
-
var cloudUserSchema = baseUserSchema.extend({
|
|
1502
|
-
userType: import_zod11.default.literal(UserTypeSchema.Enum.cloud),
|
|
1503
|
-
id: uuidSchema
|
|
1504
|
-
});
|
|
1505
|
-
var userFileSchema = import_zod11.default.union([localUserSchema, cloudUserSchema]);
|
|
1506
|
-
var userSchema = userFileSchema;
|
|
1507
|
-
var setUserSchema = userSchema;
|
|
1704
|
+
// src/service/CollectionService.ts
|
|
1705
|
+
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
1508
1706
|
|
|
1509
|
-
// src/service/
|
|
1510
|
-
var
|
|
1511
|
-
var
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
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);
|
|
1711
|
+
|
|
1712
|
+
// src/service/GitTagService.ts
|
|
1713
|
+
var import_os2 = require("os");
|
|
1714
|
+
var GitTagService = class extends AbstractCrudService {
|
|
1715
|
+
constructor(options, git) {
|
|
1716
|
+
super(serviceTypeSchema.Enum.GitTag, options);
|
|
1717
|
+
this.git = git;
|
|
1515
1718
|
}
|
|
1516
1719
|
/**
|
|
1517
|
-
* Creates a new
|
|
1720
|
+
* Creates a new tag
|
|
1518
1721
|
*
|
|
1519
|
-
* @
|
|
1520
|
-
* @param path Path to write the file to
|
|
1521
|
-
* @param schema Schema of the file to validate against
|
|
1522
|
-
* @returns Validated content of the file from disk
|
|
1722
|
+
* @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---annotate
|
|
1523
1723
|
*/
|
|
1524
|
-
async create(
|
|
1525
|
-
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1724
|
+
async create(props) {
|
|
1725
|
+
createGitTagSchema.parse(props);
|
|
1726
|
+
const id = uuid();
|
|
1727
|
+
let args = ["tag", "--annotate", id];
|
|
1728
|
+
if (props.hash) {
|
|
1729
|
+
args = [...args, props.hash];
|
|
1730
|
+
}
|
|
1731
|
+
args = [...args, "-m", props.message];
|
|
1732
|
+
await this.git(props.path, args);
|
|
1733
|
+
const tag = await this.read({ path: props.path, id });
|
|
1734
|
+
return tag;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Returns a tag by ID
|
|
1738
|
+
*
|
|
1739
|
+
* Internally uses list() but only returns the tag with matching ID.
|
|
1740
|
+
*/
|
|
1741
|
+
async read(props) {
|
|
1742
|
+
readGitTagSchema.parse(props);
|
|
1743
|
+
const tags = await this.list({ path: props.path });
|
|
1744
|
+
const tag = tags.list.find((tag2) => {
|
|
1745
|
+
return tag2.id === props.id;
|
|
1530
1746
|
});
|
|
1531
|
-
|
|
1532
|
-
|
|
1747
|
+
if (!tag) {
|
|
1748
|
+
throw new GitError(
|
|
1749
|
+
`Provided tag with UUID "${props.id}" did not match any known tags`
|
|
1750
|
+
);
|
|
1751
|
+
}
|
|
1752
|
+
return tag;
|
|
1533
1753
|
}
|
|
1534
1754
|
/**
|
|
1535
|
-
*
|
|
1755
|
+
* Updating a git tag is not supported.
|
|
1756
|
+
* Please delete the old and create a new one
|
|
1757
|
+
*
|
|
1758
|
+
* @see https://git-scm.com/docs/git-tag#_on_re_tagging
|
|
1759
|
+
*/
|
|
1760
|
+
async update() {
|
|
1761
|
+
throw new Error(
|
|
1762
|
+
"Updating a git tag is not supported. Please delete the old and create a new one"
|
|
1763
|
+
);
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Deletes a tag
|
|
1767
|
+
*
|
|
1768
|
+
* @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---delete
|
|
1769
|
+
*
|
|
1770
|
+
* @param path Path to the repository
|
|
1771
|
+
* @param id UUID of the tag to delete
|
|
1772
|
+
*/
|
|
1773
|
+
async delete(props) {
|
|
1774
|
+
deleteGitTagSchema.parse(props);
|
|
1775
|
+
const args = ["tag", "--delete", props.id];
|
|
1776
|
+
await this.git(props.path, args);
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Gets all local tags or filter them by pattern
|
|
1780
|
+
*
|
|
1781
|
+
* They are sorted by authordate of the commit, not the timestamp the tag is created.
|
|
1782
|
+
* This ensures tags are sorted correctly in the timeline of their commits.
|
|
1536
1783
|
*
|
|
1537
|
-
* @
|
|
1538
|
-
* @param schema Schema of the file to validate against
|
|
1539
|
-
* @returns Validated content of the file from disk
|
|
1784
|
+
* @see https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---list
|
|
1540
1785
|
*/
|
|
1541
|
-
async
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1786
|
+
async list(props) {
|
|
1787
|
+
listGitTagsSchema.parse(props);
|
|
1788
|
+
let args = ["tag", "--list"];
|
|
1789
|
+
args = [
|
|
1790
|
+
...args,
|
|
1791
|
+
"--sort=-*authordate",
|
|
1792
|
+
"--format=%(refname:short)|%(subject)|%(*authorname)|%(*authoremail)|%(*authordate:unix)"
|
|
1793
|
+
];
|
|
1794
|
+
const result = await this.git(props.path, args);
|
|
1795
|
+
const noEmptyLinesArr = result.stdout.split(import_os2.EOL).filter((line) => {
|
|
1796
|
+
return line.trim() !== "";
|
|
1548
1797
|
});
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1798
|
+
const lineObjArr = noEmptyLinesArr.map((line) => {
|
|
1799
|
+
const lineArray = line.split("|");
|
|
1800
|
+
return {
|
|
1801
|
+
id: lineArray[0],
|
|
1802
|
+
message: lineArray[1],
|
|
1803
|
+
author: {
|
|
1804
|
+
name: lineArray[2],
|
|
1805
|
+
email: lineArray[3]
|
|
1806
|
+
},
|
|
1807
|
+
timestamp: parseInt(lineArray[4])
|
|
1808
|
+
};
|
|
1809
|
+
});
|
|
1810
|
+
const gitTags = lineObjArr.filter(this.isGitTag.bind(this));
|
|
1811
|
+
return {
|
|
1812
|
+
total: gitTags.length,
|
|
1813
|
+
limit: 0,
|
|
1814
|
+
offset: 0,
|
|
1815
|
+
list: gitTags
|
|
1816
|
+
};
|
|
1553
1817
|
}
|
|
1554
1818
|
/**
|
|
1555
|
-
*
|
|
1819
|
+
* Returns the total number of tags inside given repository
|
|
1556
1820
|
*
|
|
1557
|
-
*
|
|
1821
|
+
* Internally uses list(), so do not use count()
|
|
1822
|
+
* in conjuncion with it to avoid multiple git calls.
|
|
1558
1823
|
*
|
|
1559
|
-
* @param
|
|
1560
|
-
* @param path Path to the file to overwrite
|
|
1561
|
-
* @param schema Schema of the file to validate against
|
|
1562
|
-
* @returns Validated content of the file from disk
|
|
1824
|
+
* @param path Path to the repository
|
|
1563
1825
|
*/
|
|
1564
|
-
async
|
|
1565
|
-
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
flag: "w",
|
|
1569
|
-
encoding: "utf8"
|
|
1570
|
-
});
|
|
1571
|
-
this.cache.set(path, parsedData);
|
|
1572
|
-
return parsedData;
|
|
1573
|
-
}
|
|
1574
|
-
serialize(data) {
|
|
1575
|
-
return JSON.stringify(data, null, this.options.file.json.indentation);
|
|
1826
|
+
async count(props) {
|
|
1827
|
+
countGitTagsSchema.parse(props);
|
|
1828
|
+
const gitTags = await this.list({ path: props.path });
|
|
1829
|
+
return gitTags.total;
|
|
1576
1830
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1831
|
+
/**
|
|
1832
|
+
* Type guard for GitTag
|
|
1833
|
+
*
|
|
1834
|
+
* @param obj The object to check
|
|
1835
|
+
*/
|
|
1836
|
+
isGitTag(obj) {
|
|
1837
|
+
return gitTagSchema.safeParse(obj).success;
|
|
1579
1838
|
}
|
|
1580
1839
|
};
|
|
1581
1840
|
|
|
@@ -1589,10 +1848,7 @@ var UserService = class {
|
|
|
1589
1848
|
*/
|
|
1590
1849
|
async get() {
|
|
1591
1850
|
try {
|
|
1592
|
-
return await this.jsonFileService.read(
|
|
1593
|
-
pathTo.userFile,
|
|
1594
|
-
userFileSchema
|
|
1595
|
-
);
|
|
1851
|
+
return await this.jsonFileService.read(pathTo.userFile, userFileSchema);
|
|
1596
1852
|
} catch (error) {
|
|
1597
1853
|
return void 0;
|
|
1598
1854
|
}
|
|
@@ -1860,507 +2116,277 @@ var GitService2 = class {
|
|
|
1860
2116
|
/**
|
|
1861
2117
|
* Download objects and refs from remote `origin`
|
|
1862
2118
|
*
|
|
1863
|
-
* @see https://www.git-scm.com/docs/git-fetch
|
|
1864
|
-
*
|
|
1865
|
-
* @param path Path to the repository
|
|
1866
|
-
*/
|
|
1867
|
-
async fetch(path) {
|
|
1868
|
-
const args = ["fetch"];
|
|
1869
|
-
await this.git(path, args);
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* Fetch from and integrate (rebase or merge) with a local branch
|
|
1873
|
-
*
|
|
1874
|
-
* @see https://git-scm.com/docs/git-pull
|
|
1875
|
-
*
|
|
1876
|
-
* @param path Path to the repository
|
|
1877
|
-
*/
|
|
1878
|
-
async pull(path) {
|
|
1879
|
-
const args = ["pull"];
|
|
1880
|
-
await this.git(path, args);
|
|
1881
|
-
}
|
|
1882
|
-
/**
|
|
1883
|
-
* Update remote refs along with associated objects to remote `origin`
|
|
1884
|
-
*
|
|
1885
|
-
* @see https://git-scm.com/docs/git-push
|
|
1886
|
-
*
|
|
1887
|
-
* @param path Path to the repository
|
|
1888
|
-
*/
|
|
1889
|
-
async push(path, options) {
|
|
1890
|
-
let args = ["push", "origin"];
|
|
1891
|
-
if (options?.all === true) {
|
|
1892
|
-
args = [...args, "--all"];
|
|
1893
|
-
}
|
|
1894
|
-
if (options?.force === true) {
|
|
1895
|
-
args = [...args, "--force"];
|
|
1896
|
-
}
|
|
1897
|
-
await this.git(path, args);
|
|
1898
|
-
}
|
|
1899
|
-
/**
|
|
1900
|
-
* Record changes to the repository
|
|
1901
|
-
*
|
|
1902
|
-
* @see https://git-scm.com/docs/git-commit
|
|
1903
|
-
*
|
|
1904
|
-
* @param path Path to the repository
|
|
1905
|
-
* @param message A message that describes the changes
|
|
1906
|
-
*/
|
|
1907
|
-
async commit(path, message) {
|
|
1908
|
-
const user = await this.userService.get();
|
|
1909
|
-
if (!user) {
|
|
1910
|
-
throw new NoCurrentUserError();
|
|
1911
|
-
}
|
|
1912
|
-
const args = [
|
|
1913
|
-
"commit",
|
|
1914
|
-
`--message=${message}`,
|
|
1915
|
-
`--author=${user.name} <${user.email}>`
|
|
1916
|
-
];
|
|
1917
|
-
await this.git(path, args);
|
|
1918
|
-
}
|
|
1919
|
-
/**
|
|
1920
|
-
* Gets local commit history
|
|
1921
|
-
*
|
|
1922
|
-
* @see https://git-scm.com/docs/git-log
|
|
1923
|
-
*
|
|
1924
|
-
* @todo Check if there is a need to trim the git commit message of chars
|
|
1925
|
-
* @todo Use this method in a service. Decide if we need a HistoryService for example
|
|
1926
|
-
*
|
|
1927
|
-
* @param path Path to the repository
|
|
1928
|
-
* @param options Options specific to the log operation
|
|
1929
|
-
*/
|
|
1930
|
-
async log(path, options) {
|
|
1931
|
-
let args = ["log"];
|
|
1932
|
-
if (options?.between?.from) {
|
|
1933
|
-
args = [
|
|
1934
|
-
...args,
|
|
1935
|
-
`${options.between.from}..${options.between.to || "HEAD"}`
|
|
1936
|
-
];
|
|
1937
|
-
}
|
|
1938
|
-
if (options?.limit) {
|
|
1939
|
-
args = [...args, `--max-count=${options.limit}`];
|
|
1940
|
-
}
|
|
1941
|
-
const result = await this.git(path, [
|
|
1942
|
-
...args,
|
|
1943
|
-
"--format=%H|%s|%an|%ae|%at|%D"
|
|
1944
|
-
]);
|
|
1945
|
-
const noEmptyLinesArr = result.stdout.split(import_os3.EOL).filter((line) => {
|
|
1946
|
-
return line.trim() !== "";
|
|
1947
|
-
});
|
|
1948
|
-
const lineObjArr = noEmptyLinesArr.map((line) => {
|
|
1949
|
-
const lineArray = line.split("|");
|
|
1950
|
-
return {
|
|
1951
|
-
hash: lineArray[0],
|
|
1952
|
-
message: lineArray[1],
|
|
1953
|
-
author: {
|
|
1954
|
-
name: lineArray[2],
|
|
1955
|
-
email: lineArray[3]
|
|
1956
|
-
},
|
|
1957
|
-
timestamp: parseInt(lineArray[4]),
|
|
1958
|
-
tag: this.refNameToTagName(lineArray[5])
|
|
1959
|
-
};
|
|
1960
|
-
});
|
|
1961
|
-
return lineObjArr.filter(this.isGitCommit.bind(this));
|
|
1962
|
-
}
|
|
1963
|
-
refNameToTagName(refName) {
|
|
1964
|
-
const tagName = refName.replace("tag: ", "").trim();
|
|
1965
|
-
if (tagName === "" || uuidSchema.safeParse(tagName).success === false) {
|
|
1966
|
-
return null;
|
|
1967
|
-
}
|
|
1968
|
-
return tagName;
|
|
1969
|
-
}
|
|
1970
|
-
/**
|
|
1971
|
-
* Returns a timestamp of given files creation
|
|
1972
|
-
*
|
|
1973
|
-
* Git only returns the timestamp the file was added,
|
|
1974
|
-
* which could be different from the file being created.
|
|
1975
|
-
* But since file operations will always be committed
|
|
1976
|
-
* immediately, this is practically the same.
|
|
1977
|
-
*
|
|
1978
|
-
* @param path Path to the repository
|
|
1979
|
-
* @param file File to get timestamp from
|
|
1980
|
-
*/
|
|
1981
|
-
async getFileCreatedTimestamp(path, file) {
|
|
1982
|
-
const result = await this.git(path, [
|
|
1983
|
-
"log",
|
|
1984
|
-
"--diff-filter=A",
|
|
1985
|
-
"--follow",
|
|
1986
|
-
"--format=%at",
|
|
1987
|
-
"--max-count=1",
|
|
1988
|
-
"--",
|
|
1989
|
-
file
|
|
1990
|
-
]);
|
|
1991
|
-
return parseInt(result.stdout);
|
|
1992
|
-
}
|
|
1993
|
-
/**
|
|
1994
|
-
* Returns a timestamp of the files last modification
|
|
1995
|
-
*
|
|
1996
|
-
* @param path Path to the repository
|
|
1997
|
-
* @param file File to get timestamp from
|
|
1998
|
-
*/
|
|
1999
|
-
async getFileLastUpdatedTimestamp(path, file) {
|
|
2000
|
-
const result = await this.git(path, [
|
|
2001
|
-
"log",
|
|
2002
|
-
"--follow",
|
|
2003
|
-
"--format=%at",
|
|
2004
|
-
"--max-count=1",
|
|
2005
|
-
"--",
|
|
2006
|
-
file
|
|
2007
|
-
]);
|
|
2008
|
-
return parseInt(result.stdout);
|
|
2009
|
-
}
|
|
2010
|
-
/**
|
|
2011
|
-
* Returns created and updated timestamps from given file
|
|
2012
|
-
*
|
|
2013
|
-
* @param path Path to the project
|
|
2014
|
-
* @param file Path to the file
|
|
2015
|
-
*/
|
|
2016
|
-
async getFileCreatedUpdatedMeta(path, file) {
|
|
2017
|
-
const meta = await Promise.all([
|
|
2018
|
-
this.getFileCreatedTimestamp(path, file),
|
|
2019
|
-
this.getFileLastUpdatedTimestamp(path, file)
|
|
2020
|
-
]);
|
|
2021
|
-
return {
|
|
2022
|
-
created: meta[0],
|
|
2023
|
-
updated: meta[1]
|
|
2024
|
-
};
|
|
2025
|
-
}
|
|
2026
|
-
/**
|
|
2027
|
-
* Reads the currently used version of Git
|
|
2028
|
-
*
|
|
2029
|
-
* This can help debugging
|
|
2030
|
-
*/
|
|
2031
|
-
async updateVersion() {
|
|
2032
|
-
const result = await this.git("", ["--version"]);
|
|
2033
|
-
this.version = result.stdout.replace("git version", "").trim();
|
|
2034
|
-
}
|
|
2035
|
-
/**
|
|
2036
|
-
* Reads the path to the executable of Git that is used
|
|
2037
|
-
*
|
|
2038
|
-
* This can help debugging, since dugite is shipping their own executable
|
|
2039
|
-
* but in some cases resolves another executable
|
|
2040
|
-
* @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
|
|
2119
|
+
* @see https://www.git-scm.com/docs/git-fetch
|
|
2120
|
+
*
|
|
2121
|
+
* @param path Path to the repository
|
|
2041
2122
|
*/
|
|
2042
|
-
async
|
|
2043
|
-
const
|
|
2044
|
-
this.
|
|
2123
|
+
async fetch(path) {
|
|
2124
|
+
const args = ["fetch"];
|
|
2125
|
+
await this.git(path, args);
|
|
2045
2126
|
}
|
|
2046
2127
|
/**
|
|
2047
|
-
*
|
|
2048
|
-
* This method checks if given name matches the required format
|
|
2128
|
+
* Fetch from and integrate (rebase or merge) with a local branch
|
|
2049
2129
|
*
|
|
2050
|
-
* @see https://git-scm.com/docs/git-
|
|
2130
|
+
* @see https://git-scm.com/docs/git-pull
|
|
2051
2131
|
*
|
|
2052
2132
|
* @param path Path to the repository
|
|
2053
|
-
* @param name Name to check
|
|
2054
2133
|
*/
|
|
2055
|
-
async
|
|
2056
|
-
|
|
2134
|
+
async pull(path) {
|
|
2135
|
+
const args = ["pull"];
|
|
2136
|
+
await this.git(path, args);
|
|
2057
2137
|
}
|
|
2058
2138
|
/**
|
|
2059
|
-
*
|
|
2060
|
-
*
|
|
2139
|
+
* Update remote refs along with associated objects to remote `origin`
|
|
2140
|
+
*
|
|
2141
|
+
* @see https://git-scm.com/docs/git-push
|
|
2061
2142
|
*
|
|
2062
2143
|
* @param path Path to the repository
|
|
2063
2144
|
*/
|
|
2064
|
-
async
|
|
2065
|
-
|
|
2066
|
-
|
|
2145
|
+
async push(path, options) {
|
|
2146
|
+
let args = ["push", "origin"];
|
|
2147
|
+
if (options?.all === true) {
|
|
2148
|
+
args = [...args, "--all"];
|
|
2149
|
+
}
|
|
2150
|
+
if (options?.force === true) {
|
|
2151
|
+
args = [...args, "--force"];
|
|
2152
|
+
}
|
|
2153
|
+
await this.git(path, args);
|
|
2067
2154
|
}
|
|
2068
2155
|
/**
|
|
2069
|
-
*
|
|
2156
|
+
* Record changes to the repository
|
|
2070
2157
|
*
|
|
2071
|
-
* @
|
|
2158
|
+
* @see https://git-scm.com/docs/git-commit
|
|
2159
|
+
*
|
|
2160
|
+
* @param path Path to the repository
|
|
2161
|
+
* @param message A message that describes the changes
|
|
2072
2162
|
*/
|
|
2073
|
-
async
|
|
2163
|
+
async commit(path, message) {
|
|
2074
2164
|
const user = await this.userService.get();
|
|
2075
2165
|
if (!user) {
|
|
2076
2166
|
throw new NoCurrentUserError();
|
|
2077
2167
|
}
|
|
2078
|
-
const
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
"--local",
|
|
2083
|
-
"push.autoSetupRemote",
|
|
2084
|
-
"true"
|
|
2168
|
+
const args = [
|
|
2169
|
+
"commit",
|
|
2170
|
+
`--message=${message}`,
|
|
2171
|
+
`--author=${user.name} <${user.email}>`
|
|
2085
2172
|
];
|
|
2086
|
-
await this.git(path,
|
|
2087
|
-
await this.git(path, userEmailArgs);
|
|
2088
|
-
await this.git(path, autoSetupRemoteArgs);
|
|
2173
|
+
await this.git(path, args);
|
|
2089
2174
|
}
|
|
2090
2175
|
/**
|
|
2091
|
-
*
|
|
2176
|
+
* Gets local commit history
|
|
2092
2177
|
*
|
|
2093
|
-
* @
|
|
2094
|
-
*/
|
|
2095
|
-
isGitCommit(obj) {
|
|
2096
|
-
return gitCommitSchema.safeParse(obj).success;
|
|
2097
|
-
}
|
|
2098
|
-
/**
|
|
2099
|
-
* Wraps the execution of any git command
|
|
2100
|
-
* to use a FIFO queue for sequential processing
|
|
2178
|
+
* @see https://git-scm.com/docs/git-log
|
|
2101
2179
|
*
|
|
2102
|
-
* @
|
|
2103
|
-
* @
|
|
2180
|
+
* @todo Check if there is a need to trim the git commit message of chars
|
|
2181
|
+
* @todo Use this method in a service. Decide if we need a HistoryService for example
|
|
2182
|
+
*
|
|
2183
|
+
* @param path Path to the repository
|
|
2184
|
+
* @param options Options specific to the log operation
|
|
2104
2185
|
*/
|
|
2105
|
-
async
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
}
|
|
2113
|
-
})
|
|
2114
|
-
);
|
|
2115
|
-
if (!result) {
|
|
2116
|
-
throw new GitError(
|
|
2117
|
-
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2118
|
-
" "
|
|
2119
|
-
)}" failed to return a result`
|
|
2120
|
-
);
|
|
2186
|
+
async log(path, options) {
|
|
2187
|
+
let args = ["log"];
|
|
2188
|
+
if (options?.between?.from) {
|
|
2189
|
+
args = [
|
|
2190
|
+
...args,
|
|
2191
|
+
`${options.between.from}..${options.between.to || "HEAD"}`
|
|
2192
|
+
];
|
|
2121
2193
|
}
|
|
2122
|
-
if (
|
|
2123
|
-
|
|
2124
|
-
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2125
|
-
" "
|
|
2126
|
-
)}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
|
|
2127
|
-
);
|
|
2194
|
+
if (options?.limit) {
|
|
2195
|
+
args = [...args, `--max-count=${options.limit}`];
|
|
2128
2196
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2197
|
+
const result = await this.git(path, [
|
|
2198
|
+
...args,
|
|
2199
|
+
"--format=%H|%s|%an|%ae|%at|%D"
|
|
2200
|
+
]);
|
|
2201
|
+
const noEmptyLinesArr = result.stdout.split(import_os3.EOL).filter((line) => {
|
|
2202
|
+
return line.trim() !== "";
|
|
2203
|
+
});
|
|
2204
|
+
const lineObjArr = noEmptyLinesArr.map((line) => {
|
|
2205
|
+
const lineArray = line.split("|");
|
|
2206
|
+
return {
|
|
2207
|
+
hash: lineArray[0],
|
|
2208
|
+
message: lineArray[1],
|
|
2209
|
+
author: {
|
|
2210
|
+
name: lineArray[2],
|
|
2211
|
+
email: lineArray[3]
|
|
2212
|
+
},
|
|
2213
|
+
timestamp: parseInt(lineArray[4]),
|
|
2214
|
+
tag: this.refNameToTagName(lineArray[5])
|
|
2215
|
+
};
|
|
2216
|
+
});
|
|
2217
|
+
return lineObjArr.filter(this.isGitCommit.bind(this));
|
|
2139
2218
|
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
createAssetSchema.parse(props);
|
|
2145
|
-
const id = uuid();
|
|
2146
|
-
const projectPath = pathTo.project(props.projectId);
|
|
2147
|
-
const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
|
|
2148
|
-
const size = await this.getAssetSize(props.filePath);
|
|
2149
|
-
const assetPath = pathTo.asset(
|
|
2150
|
-
props.projectId,
|
|
2151
|
-
id,
|
|
2152
|
-
props.language,
|
|
2153
|
-
fileType.extension
|
|
2154
|
-
);
|
|
2155
|
-
const assetFilePath = pathTo.assetFile(
|
|
2156
|
-
props.projectId,
|
|
2157
|
-
id,
|
|
2158
|
-
props.language
|
|
2159
|
-
);
|
|
2160
|
-
const assetFile = {
|
|
2161
|
-
...props,
|
|
2162
|
-
objectType: "asset",
|
|
2163
|
-
id,
|
|
2164
|
-
created: currentTimestamp(),
|
|
2165
|
-
updated: null,
|
|
2166
|
-
extension: fileType.extension,
|
|
2167
|
-
mimeType: fileType.mimeType,
|
|
2168
|
-
size
|
|
2169
|
-
};
|
|
2170
|
-
try {
|
|
2171
|
-
await import_fs_extra3.default.copyFile(props.filePath, assetPath);
|
|
2172
|
-
await this.jsonFileService.create(
|
|
2173
|
-
assetFile,
|
|
2174
|
-
assetFilePath,
|
|
2175
|
-
assetFileSchema
|
|
2176
|
-
);
|
|
2177
|
-
} catch (error) {
|
|
2178
|
-
await this.delete({ ...assetFile, projectId: props.projectId });
|
|
2179
|
-
throw error;
|
|
2219
|
+
refNameToTagName(refName) {
|
|
2220
|
+
const tagName = refName.replace("tag: ", "").trim();
|
|
2221
|
+
if (tagName === "" || uuidSchema.safeParse(tagName).success === false) {
|
|
2222
|
+
return null;
|
|
2180
2223
|
}
|
|
2181
|
-
|
|
2182
|
-
await this.gitService.commit(projectPath, this.gitMessage.create);
|
|
2183
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2184
|
-
}
|
|
2185
|
-
/**
|
|
2186
|
-
* Returns an Asset by ID and language
|
|
2187
|
-
*/
|
|
2188
|
-
async read(props) {
|
|
2189
|
-
readAssetSchema.parse(props);
|
|
2190
|
-
const assetFile = await this.jsonFileService.read(
|
|
2191
|
-
pathTo.assetFile(props.projectId, props.id, props.language),
|
|
2192
|
-
assetFileSchema
|
|
2193
|
-
);
|
|
2194
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2224
|
+
return tagName;
|
|
2195
2225
|
}
|
|
2196
2226
|
/**
|
|
2197
|
-
*
|
|
2227
|
+
* Returns a timestamp of given files creation
|
|
2198
2228
|
*
|
|
2199
|
-
*
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
);
|
|
2219
|
-
const size = await this.getAssetSize(props.newFilePath);
|
|
2220
|
-
const prevAssetPath = pathTo.asset(
|
|
2221
|
-
props.projectId,
|
|
2222
|
-
props.id,
|
|
2223
|
-
props.language,
|
|
2224
|
-
prevAssetFile.extension
|
|
2225
|
-
);
|
|
2226
|
-
const assetPath = pathTo.asset(
|
|
2227
|
-
props.projectId,
|
|
2228
|
-
props.id,
|
|
2229
|
-
props.language,
|
|
2230
|
-
fileType.extension
|
|
2231
|
-
);
|
|
2232
|
-
await import_fs_extra3.default.remove(prevAssetPath);
|
|
2233
|
-
await import_fs_extra3.default.copyFile(props.newFilePath, assetPath);
|
|
2234
|
-
assetFile.extension = fileType.extension;
|
|
2235
|
-
assetFile.mimeType = fileType.mimeType;
|
|
2236
|
-
assetFile.size = size;
|
|
2237
|
-
}
|
|
2238
|
-
await this.jsonFileService.update(
|
|
2239
|
-
assetFile,
|
|
2240
|
-
assetFilePath,
|
|
2241
|
-
assetFileSchema
|
|
2242
|
-
);
|
|
2243
|
-
await this.gitService.add(projectPath, [assetFilePath]);
|
|
2244
|
-
await this.gitService.commit(projectPath, this.gitMessage.update);
|
|
2245
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2229
|
+
* Git only returns the timestamp the file was added,
|
|
2230
|
+
* which could be different from the file being created.
|
|
2231
|
+
* But since file operations will always be committed
|
|
2232
|
+
* immediately, this is practically the same.
|
|
2233
|
+
*
|
|
2234
|
+
* @param path Path to the repository
|
|
2235
|
+
* @param file File to get timestamp from
|
|
2236
|
+
*/
|
|
2237
|
+
async getFileCreatedTimestamp(path, file) {
|
|
2238
|
+
const result = await this.git(path, [
|
|
2239
|
+
"log",
|
|
2240
|
+
"--diff-filter=A",
|
|
2241
|
+
"--follow",
|
|
2242
|
+
"--format=%at",
|
|
2243
|
+
"--max-count=1",
|
|
2244
|
+
"--",
|
|
2245
|
+
file
|
|
2246
|
+
]);
|
|
2247
|
+
return parseInt(result.stdout);
|
|
2246
2248
|
}
|
|
2247
2249
|
/**
|
|
2248
|
-
*
|
|
2250
|
+
* Returns a timestamp of the files last modification
|
|
2251
|
+
*
|
|
2252
|
+
* @param path Path to the repository
|
|
2253
|
+
* @param file File to get timestamp from
|
|
2249
2254
|
*/
|
|
2250
|
-
async
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
props.id,
|
|
2261
|
-
props.language,
|
|
2262
|
-
props.extension
|
|
2263
|
-
);
|
|
2264
|
-
await import_fs_extra3.default.remove(assetPath);
|
|
2265
|
-
await import_fs_extra3.default.remove(assetFilePath);
|
|
2266
|
-
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
2267
|
-
await this.gitService.commit(projectPath, this.gitMessage.delete);
|
|
2255
|
+
async getFileLastUpdatedTimestamp(path, file) {
|
|
2256
|
+
const result = await this.git(path, [
|
|
2257
|
+
"log",
|
|
2258
|
+
"--follow",
|
|
2259
|
+
"--format=%at",
|
|
2260
|
+
"--max-count=1",
|
|
2261
|
+
"--",
|
|
2262
|
+
file
|
|
2263
|
+
]);
|
|
2264
|
+
return parseInt(result.stdout);
|
|
2268
2265
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
if (!assetReference.language) {
|
|
2281
|
-
throw new RequiredParameterMissingError("language");
|
|
2282
|
-
}
|
|
2283
|
-
return this.read({
|
|
2284
|
-
projectId: props.projectId,
|
|
2285
|
-
id: assetReference.id,
|
|
2286
|
-
language: assetReference.language
|
|
2287
|
-
});
|
|
2288
|
-
})
|
|
2289
|
-
);
|
|
2266
|
+
/**
|
|
2267
|
+
* Returns created and updated timestamps from given file
|
|
2268
|
+
*
|
|
2269
|
+
* @param path Path to the project
|
|
2270
|
+
* @param file Path to the file
|
|
2271
|
+
*/
|
|
2272
|
+
async getFileCreatedUpdatedMeta(path, file) {
|
|
2273
|
+
const meta = await Promise.all([
|
|
2274
|
+
this.getFileCreatedTimestamp(path, file),
|
|
2275
|
+
this.getFileLastUpdatedTimestamp(path, file)
|
|
2276
|
+
]);
|
|
2290
2277
|
return {
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
offset,
|
|
2294
|
-
list: assets
|
|
2278
|
+
created: meta[0],
|
|
2279
|
+
updated: meta[1]
|
|
2295
2280
|
};
|
|
2296
2281
|
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2282
|
+
/**
|
|
2283
|
+
* Reads the currently used version of Git
|
|
2284
|
+
*
|
|
2285
|
+
* This can help debugging
|
|
2286
|
+
*/
|
|
2287
|
+
async updateVersion() {
|
|
2288
|
+
const result = await this.git("", ["--version"]);
|
|
2289
|
+
this.version = result.stdout.replace("git version", "").trim();
|
|
2301
2290
|
}
|
|
2302
2291
|
/**
|
|
2303
|
-
*
|
|
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
|
|
2304
2297
|
*/
|
|
2305
|
-
|
|
2306
|
-
|
|
2298
|
+
async updateGitPath() {
|
|
2299
|
+
const result = await this.git("", ["--exec-path"]);
|
|
2300
|
+
this.gitPath = result.stdout.trim();
|
|
2307
2301
|
}
|
|
2308
2302
|
/**
|
|
2309
|
-
*
|
|
2303
|
+
* A reference is used in Git to specify branches and tags.
|
|
2304
|
+
* This method checks if given name matches the required format
|
|
2310
2305
|
*
|
|
2311
|
-
* @
|
|
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
|
|
2312
2310
|
*/
|
|
2313
|
-
async
|
|
2314
|
-
|
|
2311
|
+
async checkBranchOrTagName(path, name) {
|
|
2312
|
+
await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
|
|
2315
2313
|
}
|
|
2316
2314
|
/**
|
|
2317
|
-
*
|
|
2315
|
+
* Installs LFS support and starts tracking
|
|
2316
|
+
* all files inside the lfs folder
|
|
2318
2317
|
*
|
|
2319
|
-
* @param
|
|
2320
|
-
* @param assetFile The AssetFile to convert
|
|
2318
|
+
* @param path Path to the repository
|
|
2321
2319
|
*/
|
|
2322
|
-
async
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
assetFile.id,
|
|
2326
|
-
assetFile.language,
|
|
2327
|
-
assetFile.extension
|
|
2328
|
-
);
|
|
2329
|
-
const asset = {
|
|
2330
|
-
...assetFile,
|
|
2331
|
-
absolutePath: assetPath
|
|
2332
|
-
};
|
|
2333
|
-
return asset;
|
|
2320
|
+
async installLfs(path) {
|
|
2321
|
+
await this.git(path, ["lfs", "install"]);
|
|
2322
|
+
await this.git(path, ["lfs", "track", "lfs/*"]);
|
|
2334
2323
|
}
|
|
2335
2324
|
/**
|
|
2336
|
-
*
|
|
2337
|
-
* otherwise throws an error
|
|
2325
|
+
* Sets the git config of given local repository from ElekIoCoreOptions
|
|
2338
2326
|
*
|
|
2339
|
-
* @param
|
|
2327
|
+
* @param path Path to the repository
|
|
2340
2328
|
*/
|
|
2341
|
-
async
|
|
2342
|
-
const
|
|
2343
|
-
if (
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
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);
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Type guard for GitCommit
|
|
2348
|
+
*
|
|
2349
|
+
* @param obj The object to check
|
|
2350
|
+
*/
|
|
2351
|
+
isGitCommit(obj) {
|
|
2352
|
+
return gitCommitSchema.safeParse(obj).success;
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Wraps the execution of any git command
|
|
2356
|
+
* to use a FIFO queue for sequential processing
|
|
2357
|
+
*
|
|
2358
|
+
* @param path Path to the repository
|
|
2359
|
+
* @param args Arguments to append after the `git` command
|
|
2360
|
+
*/
|
|
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
|
+
);
|
|
2351
2384
|
}
|
|
2352
|
-
const { fileTypeFromFile } = await import("file-type");
|
|
2353
|
-
const fileType = await fileTypeFromFile(filePath);
|
|
2354
|
-
const result = supportedAssetTypeSchema.parse({
|
|
2355
|
-
extension: fileType?.ext,
|
|
2356
|
-
mimeType: fileType?.mime
|
|
2357
|
-
});
|
|
2358
2385
|
return result;
|
|
2359
2386
|
}
|
|
2360
2387
|
};
|
|
2361
2388
|
|
|
2362
2389
|
// src/service/CollectionService.ts
|
|
2363
|
-
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
2364
2390
|
var CollectionService = class extends AbstractCrudService {
|
|
2365
2391
|
constructor(options, jsonFileService, gitService) {
|
|
2366
2392
|
super(serviceTypeSchema.Enum.Collection, options);
|
|
@@ -2421,10 +2447,7 @@ var CollectionService = class extends AbstractCrudService {
|
|
|
2421
2447
|
async update(props) {
|
|
2422
2448
|
updateCollectionSchema.parse(props);
|
|
2423
2449
|
const projectPath = pathTo.project(props.projectId);
|
|
2424
|
-
const collectionFilePath = pathTo.collectionFile(
|
|
2425
|
-
props.projectId,
|
|
2426
|
-
props.id
|
|
2427
|
-
);
|
|
2450
|
+
const collectionFilePath = pathTo.collectionFile(props.projectId, props.id);
|
|
2428
2451
|
const prevCollectionFile = await this.read(props);
|
|
2429
2452
|
const collectionFile = {
|
|
2430
2453
|
...prevCollectionFile,
|
|
@@ -2798,16 +2821,6 @@ var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
|
2798
2821
|
var import_os4 = __toESM(require("os"), 1);
|
|
2799
2822
|
var import_path2 = __toESM(require("path"), 1);
|
|
2800
2823
|
var import_semver = __toESM(require("semver"), 1);
|
|
2801
|
-
|
|
2802
|
-
// src/error/ProjectUpgradeError.ts
|
|
2803
|
-
var ProjectUpgradeError = class extends Error {
|
|
2804
|
-
constructor(message) {
|
|
2805
|
-
super(message);
|
|
2806
|
-
this.name = "ProjectUpgradeError";
|
|
2807
|
-
}
|
|
2808
|
-
};
|
|
2809
|
-
|
|
2810
|
-
// src/service/ProjectService.ts
|
|
2811
2824
|
var ProjectService = class extends AbstractCrudService {
|
|
2812
2825
|
constructor(options, jsonFileService, userService, gitService, assetService, collectionService, entryService) {
|
|
2813
2826
|
super(serviceTypeSchema.Enum.Project, options);
|
|
@@ -3190,36 +3203,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3190
3203
|
}
|
|
3191
3204
|
};
|
|
3192
3205
|
|
|
3193
|
-
// src/
|
|
3194
|
-
var import_zod12 = require("zod");
|
|
3195
|
-
var elekIoCoreOptionsSchema = import_zod12.z.object({
|
|
3196
|
-
/**
|
|
3197
|
-
* The environment elek.io Core is currently running in
|
|
3198
|
-
*/
|
|
3199
|
-
environment: environmentSchema,
|
|
3200
|
-
/**
|
|
3201
|
-
* The current version of elek.io Core
|
|
3202
|
-
*/
|
|
3203
|
-
version: versionSchema,
|
|
3204
|
-
file: import_zod12.z.object({
|
|
3205
|
-
json: import_zod12.z.object({
|
|
3206
|
-
/**
|
|
3207
|
-
* If set, adds indentation with spaces (number) or escape character (string)
|
|
3208
|
-
* and line break characters to saved JSON files on disk, to make them easier to read.
|
|
3209
|
-
* Defaults to 2 spaces of indentation.
|
|
3210
|
-
*/
|
|
3211
|
-
indentation: import_zod12.z.union([import_zod12.z.number(), import_zod12.z.string()])
|
|
3212
|
-
})
|
|
3213
|
-
})
|
|
3214
|
-
});
|
|
3215
|
-
var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
|
|
3216
|
-
version: true
|
|
3217
|
-
}).partial({
|
|
3218
|
-
environment: true,
|
|
3219
|
-
file: true
|
|
3220
|
-
}).optional();
|
|
3221
|
-
|
|
3222
|
-
// src/index.ts
|
|
3206
|
+
// src/index.node.ts
|
|
3223
3207
|
var ElekIoCore = class {
|
|
3224
3208
|
// private readonly sharedValueService: SharedValueService;
|
|
3225
3209
|
constructor(props) {
|
|
@@ -3280,7 +3264,7 @@ var ElekIoCore = class {
|
|
|
3280
3264
|
* Utility / helper functions
|
|
3281
3265
|
*/
|
|
3282
3266
|
get util() {
|
|
3283
|
-
return
|
|
3267
|
+
return node_exports;
|
|
3284
3268
|
}
|
|
3285
3269
|
/**
|
|
3286
3270
|
* Exposes git functions
|
|
@@ -3359,6 +3343,7 @@ var ElekIoCore = class {
|
|
|
3359
3343
|
createGitTagSchema,
|
|
3360
3344
|
createProjectSchema,
|
|
3361
3345
|
currentBranchProjectSchema,
|
|
3346
|
+
currentTimestamp,
|
|
3362
3347
|
dateValueDefinitionSchema,
|
|
3363
3348
|
datetimeValueDefinitionSchema,
|
|
3364
3349
|
deleteAssetSchema,
|
|
@@ -3422,6 +3407,7 @@ var ElekIoCore = class {
|
|
|
3422
3407
|
serviceTypeSchema,
|
|
3423
3408
|
setRemoteOriginUrlProjectSchema,
|
|
3424
3409
|
setUserSchema,
|
|
3410
|
+
slug,
|
|
3425
3411
|
stringValueDefinitionSchema,
|
|
3426
3412
|
supportedAssetExtensionSchema,
|
|
3427
3413
|
supportedAssetMimeTypeSchema,
|
|
@@ -3447,6 +3433,7 @@ var ElekIoCore = class {
|
|
|
3447
3433
|
urlValueDefinitionSchema,
|
|
3448
3434
|
userFileSchema,
|
|
3449
3435
|
userSchema,
|
|
3436
|
+
uuid,
|
|
3450
3437
|
uuidSchema,
|
|
3451
3438
|
valueContentReferenceBase,
|
|
3452
3439
|
valueContentReferenceSchema,
|
|
@@ -3458,4 +3445,4 @@ var ElekIoCore = class {
|
|
|
3458
3445
|
valueSchema,
|
|
3459
3446
|
versionSchema
|
|
3460
3447
|
});
|
|
3461
|
-
//# sourceMappingURL=index.cjs.map
|
|
3448
|
+
//# sourceMappingURL=index.node.cjs.map
|