@elek-io/core 0.4.2 → 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} +809 -817
- package/dist/node/index.node.cjs.map +1 -0
- package/dist/{index.js → node/index.node.js} +806 -814
- package/dist/node/index.node.js.map +1 -0
- package/package.json +1 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/{index.d.cts → node/index.node.d.cts} +3012 -3012
- package/dist/{index.d.ts → node/index.node.d.ts} +3012 -3012
|
@@ -4,21 +4,9 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/index.ts
|
|
7
|
+
// src/index.node.ts
|
|
8
8
|
import Fs7 from "fs-extra";
|
|
9
9
|
|
|
10
|
-
// src/service/AssetService.ts
|
|
11
|
-
import Fs3 from "fs-extra";
|
|
12
|
-
import IsSvg from "is-svg";
|
|
13
|
-
|
|
14
|
-
// src/error/RequiredParameterMissingError.ts
|
|
15
|
-
var RequiredParameterMissingError = class extends Error {
|
|
16
|
-
constructor(parameter) {
|
|
17
|
-
super(`Missing required parameter "${parameter}"`);
|
|
18
|
-
this.name = "RequiredParameterMissingError";
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
10
|
// src/schema/assetSchema.ts
|
|
23
11
|
import z3 from "zod";
|
|
24
12
|
|
|
@@ -230,156 +218,21 @@ var deleteAssetSchema = assetFileSchema.pick({
|
|
|
230
218
|
});
|
|
231
219
|
var countAssetsSchema = z3.object({ projectId: uuidSchema.readonly() });
|
|
232
220
|
|
|
233
|
-
// src/schema/serviceSchema.ts
|
|
234
|
-
import { z as z5 } from "zod";
|
|
235
|
-
|
|
236
|
-
// src/schema/gitSchema.ts
|
|
237
|
-
import { z as z4 } from "zod";
|
|
238
|
-
var gitRepositoryPathSchema = z4.string();
|
|
239
|
-
var gitSignatureSchema = z4.object({
|
|
240
|
-
name: z4.string(),
|
|
241
|
-
email: z4.string()
|
|
242
|
-
});
|
|
243
|
-
var gitCommitSchema = z4.object({
|
|
244
|
-
/**
|
|
245
|
-
* SHA-1 hash of the commit
|
|
246
|
-
*/
|
|
247
|
-
hash: z4.string(),
|
|
248
|
-
message: z4.string(),
|
|
249
|
-
author: gitSignatureSchema,
|
|
250
|
-
timestamp: z4.number(),
|
|
251
|
-
tag: z4.string().nullable()
|
|
252
|
-
});
|
|
253
|
-
var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
|
|
254
|
-
GitCommitIconNative2["INIT"] = ":tada:";
|
|
255
|
-
GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
|
|
256
|
-
GitCommitIconNative2["UPDATE"] = ":wrench:";
|
|
257
|
-
GitCommitIconNative2["DELETE"] = ":fire:";
|
|
258
|
-
return GitCommitIconNative2;
|
|
259
|
-
})(GitCommitIconNative || {});
|
|
260
|
-
var gitCommitIconSchema = z4.nativeEnum(GitCommitIconNative);
|
|
261
|
-
var gitInitOptionsSchema = z4.object({
|
|
262
|
-
/**
|
|
263
|
-
* Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).
|
|
264
|
-
*/
|
|
265
|
-
initialBranch: z4.string()
|
|
266
|
-
});
|
|
267
|
-
var gitCloneOptionsSchema = z4.object({
|
|
268
|
-
/**
|
|
269
|
-
* Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
|
|
270
|
-
*/
|
|
271
|
-
depth: z4.number(),
|
|
272
|
-
/**
|
|
273
|
-
* Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.
|
|
274
|
-
*/
|
|
275
|
-
singleBranch: z4.boolean(),
|
|
276
|
-
/**
|
|
277
|
-
* Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
|
|
278
|
-
*/
|
|
279
|
-
branch: z4.string()
|
|
280
|
-
});
|
|
281
|
-
var gitSwitchOptionsSchema = z4.object({
|
|
282
|
-
/**
|
|
283
|
-
* If true, creates a new local branch and then switches to it
|
|
284
|
-
*
|
|
285
|
-
* @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
|
|
286
|
-
*/
|
|
287
|
-
isNew: z4.boolean().optional()
|
|
288
|
-
});
|
|
289
|
-
var gitLogOptionsSchema = z4.object({
|
|
290
|
-
/**
|
|
291
|
-
* Limit the result to given number of commits
|
|
292
|
-
*/
|
|
293
|
-
limit: z4.number().optional(),
|
|
294
|
-
/**
|
|
295
|
-
* Only list commits that are between given SHAs or tag names
|
|
296
|
-
*
|
|
297
|
-
* Note that the commits of from and to are not included in the result
|
|
298
|
-
*/
|
|
299
|
-
between: z4.object({
|
|
300
|
-
/**
|
|
301
|
-
* From the oldest commit
|
|
302
|
-
*/
|
|
303
|
-
from: z4.string(),
|
|
304
|
-
/**
|
|
305
|
-
* To the newest commit
|
|
306
|
-
*
|
|
307
|
-
* Defaults to the current HEAD
|
|
308
|
-
*/
|
|
309
|
-
to: z4.string().optional()
|
|
310
|
-
})
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
// src/schema/serviceSchema.ts
|
|
314
|
-
var serviceTypeSchema = z5.enum([
|
|
315
|
-
"Git",
|
|
316
|
-
"GitTag",
|
|
317
|
-
"User",
|
|
318
|
-
"Project",
|
|
319
|
-
"Asset",
|
|
320
|
-
"JsonFile",
|
|
321
|
-
"Search",
|
|
322
|
-
"Collection",
|
|
323
|
-
"Entry",
|
|
324
|
-
"Value"
|
|
325
|
-
]);
|
|
326
|
-
var listSchema = z5.object({
|
|
327
|
-
projectId: uuidSchema,
|
|
328
|
-
limit: z5.number().optional(),
|
|
329
|
-
offset: z5.number().optional()
|
|
330
|
-
});
|
|
331
|
-
var listCollectionsSchema = listSchema;
|
|
332
|
-
var listEntriesSchema = listSchema.extend({
|
|
333
|
-
collectionId: uuidSchema
|
|
334
|
-
});
|
|
335
|
-
var listAssetsSchema = listSchema;
|
|
336
|
-
var listProjectsSchema = listSchema.omit({
|
|
337
|
-
projectId: true
|
|
338
|
-
});
|
|
339
|
-
var listGitTagsSchema = z5.object({
|
|
340
|
-
path: gitRepositoryPathSchema
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
// src/util/node.ts
|
|
344
|
-
var node_exports = {};
|
|
345
|
-
__export(node_exports, {
|
|
346
|
-
assignDefaultIfMissing: () => assignDefaultIfMissing,
|
|
347
|
-
files: () => files,
|
|
348
|
-
folders: () => folders,
|
|
349
|
-
fromPath: () => fromPath,
|
|
350
|
-
getDuplicates: () => getDuplicates,
|
|
351
|
-
getRelativePath: () => getRelativePath,
|
|
352
|
-
isNoError: () => isNoError,
|
|
353
|
-
notEmpty: () => notEmpty,
|
|
354
|
-
pathTo: () => pathTo,
|
|
355
|
-
returnResolved: () => returnResolved,
|
|
356
|
-
spawnChildProcess: () => spawnChildProcess,
|
|
357
|
-
workingDirectory: () => workingDirectory
|
|
358
|
-
});
|
|
359
|
-
import { spawn } from "child_process";
|
|
360
|
-
import Fs from "fs-extra";
|
|
361
|
-
import { filter, flatten, groupBy, uniq } from "lodash-es";
|
|
362
|
-
import Os from "os";
|
|
363
|
-
import Path from "path";
|
|
364
|
-
|
|
365
|
-
// src/schema/projectSchema.ts
|
|
366
|
-
import { z as z9 } from "zod";
|
|
367
|
-
|
|
368
221
|
// src/schema/collectionSchema.ts
|
|
369
|
-
import
|
|
222
|
+
import z6 from "zod";
|
|
370
223
|
|
|
371
224
|
// src/schema/entrySchema.ts
|
|
372
|
-
import
|
|
225
|
+
import z5 from "zod";
|
|
373
226
|
|
|
374
227
|
// src/schema/valueSchema.ts
|
|
375
|
-
import
|
|
376
|
-
var ValueTypeSchema =
|
|
228
|
+
import z4 from "zod";
|
|
229
|
+
var ValueTypeSchema = z4.enum([
|
|
377
230
|
"string",
|
|
378
231
|
"number",
|
|
379
232
|
"boolean",
|
|
380
233
|
"reference"
|
|
381
234
|
]);
|
|
382
|
-
var ValueInputTypeSchema =
|
|
235
|
+
var ValueInputTypeSchema = z4.enum([
|
|
383
236
|
// String
|
|
384
237
|
"text",
|
|
385
238
|
"textarea",
|
|
@@ -401,67 +254,67 @@ var ValueInputTypeSchema = z6.enum([
|
|
|
401
254
|
"entry"
|
|
402
255
|
// 'sharedValue', // @todo
|
|
403
256
|
]);
|
|
404
|
-
var ValueInputWidthSchema =
|
|
405
|
-
var ValueDefinitionBaseSchema =
|
|
257
|
+
var ValueInputWidthSchema = z4.enum(["12", "6", "4", "3"]);
|
|
258
|
+
var ValueDefinitionBaseSchema = z4.object({
|
|
406
259
|
id: uuidSchema.readonly(),
|
|
407
260
|
label: translatableStringSchema,
|
|
408
261
|
description: translatableStringSchema,
|
|
409
|
-
isRequired:
|
|
410
|
-
isDisabled:
|
|
411
|
-
isUnique:
|
|
262
|
+
isRequired: z4.boolean(),
|
|
263
|
+
isDisabled: z4.boolean(),
|
|
264
|
+
isUnique: z4.boolean(),
|
|
412
265
|
inputWidth: ValueInputWidthSchema
|
|
413
266
|
});
|
|
414
267
|
var StringValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
|
|
415
268
|
{
|
|
416
|
-
valueType:
|
|
417
|
-
defaultValue:
|
|
269
|
+
valueType: z4.literal(ValueTypeSchema.Enum.string),
|
|
270
|
+
defaultValue: z4.string().nullable()
|
|
418
271
|
}
|
|
419
272
|
);
|
|
420
273
|
var textValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
421
274
|
{
|
|
422
|
-
inputType:
|
|
423
|
-
min:
|
|
424
|
-
max:
|
|
275
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.text),
|
|
276
|
+
min: z4.number().nullable(),
|
|
277
|
+
max: z4.number().nullable()
|
|
425
278
|
}
|
|
426
279
|
);
|
|
427
280
|
var textareaValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
428
|
-
inputType:
|
|
429
|
-
min:
|
|
430
|
-
max:
|
|
281
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.textarea),
|
|
282
|
+
min: z4.number().nullable(),
|
|
283
|
+
max: z4.number().nullable()
|
|
431
284
|
});
|
|
432
285
|
var emailValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
433
|
-
inputType:
|
|
434
|
-
defaultValue:
|
|
286
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.email),
|
|
287
|
+
defaultValue: z4.string().email().nullable()
|
|
435
288
|
});
|
|
436
289
|
var urlValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
437
|
-
inputType:
|
|
438
|
-
defaultValue:
|
|
290
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.url),
|
|
291
|
+
defaultValue: z4.string().url().nullable()
|
|
439
292
|
});
|
|
440
293
|
var ipValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
441
|
-
inputType:
|
|
442
|
-
defaultValue:
|
|
294
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.ip),
|
|
295
|
+
defaultValue: z4.string().ip().nullable()
|
|
443
296
|
});
|
|
444
297
|
var dateValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
445
298
|
{
|
|
446
|
-
inputType:
|
|
447
|
-
defaultValue:
|
|
299
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.date),
|
|
300
|
+
defaultValue: z4.string().date().nullable()
|
|
448
301
|
}
|
|
449
302
|
);
|
|
450
303
|
var timeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend(
|
|
451
304
|
{
|
|
452
|
-
inputType:
|
|
453
|
-
defaultValue:
|
|
305
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.time),
|
|
306
|
+
defaultValue: z4.string().time().nullable()
|
|
454
307
|
}
|
|
455
308
|
);
|
|
456
309
|
var datetimeValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
457
|
-
inputType:
|
|
458
|
-
defaultValue:
|
|
310
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.datetime),
|
|
311
|
+
defaultValue: z4.string().datetime().nullable()
|
|
459
312
|
});
|
|
460
313
|
var telephoneValueDefinitionSchema = StringValueDefinitionBaseSchema.extend({
|
|
461
|
-
inputType:
|
|
314
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.telephone)
|
|
462
315
|
// defaultValue: z.string().e164(), @todo when zod v4 releases @see https://github.com/colinhacks/zod/pull/3476
|
|
463
316
|
});
|
|
464
|
-
var stringValueDefinitionSchema =
|
|
317
|
+
var stringValueDefinitionSchema = z4.union([
|
|
465
318
|
textValueDefinitionSchema,
|
|
466
319
|
textareaValueDefinitionSchema,
|
|
467
320
|
emailValueDefinitionSchema,
|
|
@@ -474,50 +327,50 @@ var stringValueDefinitionSchema = z6.union([
|
|
|
474
327
|
]);
|
|
475
328
|
var NumberValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend(
|
|
476
329
|
{
|
|
477
|
-
valueType:
|
|
478
|
-
min:
|
|
479
|
-
max:
|
|
480
|
-
isUnique:
|
|
481
|
-
defaultValue:
|
|
330
|
+
valueType: z4.literal(ValueTypeSchema.Enum.number),
|
|
331
|
+
min: z4.number().nullable(),
|
|
332
|
+
max: z4.number().nullable(),
|
|
333
|
+
isUnique: z4.literal(false),
|
|
334
|
+
defaultValue: z4.number().nullable()
|
|
482
335
|
}
|
|
483
336
|
);
|
|
484
337
|
var numberValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
|
|
485
|
-
inputType:
|
|
338
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.number)
|
|
486
339
|
});
|
|
487
340
|
var rangeValueDefinitionSchema = NumberValueDefinitionBaseSchema.extend({
|
|
488
|
-
inputType:
|
|
341
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.range),
|
|
489
342
|
// Overwrite from nullable to required because a range needs min, max and default to work and is required, since it always returns a number
|
|
490
|
-
isRequired:
|
|
491
|
-
min:
|
|
492
|
-
max:
|
|
493
|
-
defaultValue:
|
|
343
|
+
isRequired: z4.literal(true),
|
|
344
|
+
min: z4.number(),
|
|
345
|
+
max: z4.number(),
|
|
346
|
+
defaultValue: z4.number()
|
|
494
347
|
});
|
|
495
348
|
var BooleanValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
|
|
496
|
-
valueType:
|
|
349
|
+
valueType: z4.literal(ValueTypeSchema.Enum.boolean),
|
|
497
350
|
// Overwrite from nullable to required because a boolean needs a default to work and is required, since it always is either true or false
|
|
498
|
-
isRequired:
|
|
499
|
-
defaultValue:
|
|
500
|
-
isUnique:
|
|
351
|
+
isRequired: z4.literal(true),
|
|
352
|
+
defaultValue: z4.boolean(),
|
|
353
|
+
isUnique: z4.literal(false)
|
|
501
354
|
});
|
|
502
355
|
var toggleValueDefinitionSchema = BooleanValueDefinitionBaseSchema.extend({
|
|
503
|
-
inputType:
|
|
356
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.toggle)
|
|
504
357
|
});
|
|
505
358
|
var ReferenceValueDefinitionBaseSchema = ValueDefinitionBaseSchema.extend({
|
|
506
|
-
valueType:
|
|
359
|
+
valueType: z4.literal(ValueTypeSchema.Enum.reference)
|
|
507
360
|
});
|
|
508
361
|
var assetValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
|
|
509
|
-
inputType:
|
|
510
|
-
allowedMimeTypes:
|
|
511
|
-
min:
|
|
512
|
-
max:
|
|
362
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.asset),
|
|
363
|
+
allowedMimeTypes: z4.array(supportedAssetMimeTypeSchema).min(1),
|
|
364
|
+
min: z4.number().nullable(),
|
|
365
|
+
max: z4.number().nullable()
|
|
513
366
|
});
|
|
514
367
|
var entryValueDefinitionSchema = ReferenceValueDefinitionBaseSchema.extend({
|
|
515
|
-
inputType:
|
|
516
|
-
ofCollections:
|
|
517
|
-
min:
|
|
518
|
-
max:
|
|
368
|
+
inputType: z4.literal(ValueInputTypeSchema.Enum.entry),
|
|
369
|
+
ofCollections: z4.array(uuidSchema),
|
|
370
|
+
min: z4.number().nullable(),
|
|
371
|
+
max: z4.number().nullable()
|
|
519
372
|
});
|
|
520
|
-
var valueDefinitionSchema =
|
|
373
|
+
var valueDefinitionSchema = z4.union([
|
|
521
374
|
stringValueDefinitionSchema,
|
|
522
375
|
numberValueDefinitionSchema,
|
|
523
376
|
rangeValueDefinitionSchema,
|
|
@@ -526,65 +379,65 @@ var valueDefinitionSchema = z6.union([
|
|
|
526
379
|
entryValueDefinitionSchema
|
|
527
380
|
// sharedValueDefinitionSchema,
|
|
528
381
|
]);
|
|
529
|
-
var valueContentReferenceBase =
|
|
382
|
+
var valueContentReferenceBase = z4.object({
|
|
530
383
|
id: uuidSchema
|
|
531
384
|
});
|
|
532
385
|
var valueContentReferenceWithLanguageBase = valueContentReferenceBase.extend({
|
|
533
386
|
language: supportedLanguageSchema
|
|
534
387
|
});
|
|
535
388
|
var valueContentReferenceToAssetSchema = valueContentReferenceWithLanguageBase.extend({
|
|
536
|
-
objectType:
|
|
389
|
+
objectType: z4.literal(objectTypeSchema.Enum.asset)
|
|
537
390
|
});
|
|
538
391
|
var valueContentReferenceToCollectionSchema = valueContentReferenceBase.extend({
|
|
539
|
-
objectType:
|
|
392
|
+
objectType: z4.literal(objectTypeSchema.Enum.collection)
|
|
540
393
|
});
|
|
541
394
|
var valueContentReferenceToEntrySchema = valueContentReferenceBase.extend({
|
|
542
|
-
objectType:
|
|
395
|
+
objectType: z4.literal(objectTypeSchema.Enum.entry)
|
|
543
396
|
});
|
|
544
|
-
var valueContentReferenceSchema =
|
|
397
|
+
var valueContentReferenceSchema = z4.union([
|
|
545
398
|
valueContentReferenceToAssetSchema,
|
|
546
399
|
valueContentReferenceToCollectionSchema,
|
|
547
400
|
valueContentReferenceToEntrySchema
|
|
548
401
|
// valueContentReferenceToSharedValueSchema,
|
|
549
402
|
]);
|
|
550
|
-
var resolvedValueContentReferenceSchema =
|
|
403
|
+
var resolvedValueContentReferenceSchema = z4.union([
|
|
551
404
|
assetSchema,
|
|
552
|
-
|
|
405
|
+
z4.lazy(() => entrySchema)
|
|
553
406
|
// Circular dependency / recursive type @see https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types
|
|
554
407
|
// resolvedValueContentReferenceToSharedValueSchema,
|
|
555
408
|
]);
|
|
556
|
-
var directValueBaseSchema =
|
|
557
|
-
objectType:
|
|
409
|
+
var directValueBaseSchema = z4.object({
|
|
410
|
+
objectType: z4.literal(objectTypeSchema.Enum.value).readonly(),
|
|
558
411
|
definitionId: uuidSchema.readonly()
|
|
559
412
|
});
|
|
560
413
|
var directStringValueSchema = directValueBaseSchema.extend({
|
|
561
|
-
valueType:
|
|
414
|
+
valueType: z4.literal(ValueTypeSchema.Enum.string).readonly(),
|
|
562
415
|
content: translatableStringSchema
|
|
563
416
|
});
|
|
564
417
|
var directNumberValueSchema = directValueBaseSchema.extend({
|
|
565
|
-
valueType:
|
|
418
|
+
valueType: z4.literal(ValueTypeSchema.Enum.number).readonly(),
|
|
566
419
|
content: translatableNumberSchema
|
|
567
420
|
});
|
|
568
421
|
var directBooleanValueSchema = directValueBaseSchema.extend({
|
|
569
|
-
valueType:
|
|
422
|
+
valueType: z4.literal(ValueTypeSchema.Enum.boolean).readonly(),
|
|
570
423
|
content: translatableBooleanSchema
|
|
571
424
|
});
|
|
572
|
-
var directValueSchema =
|
|
425
|
+
var directValueSchema = z4.union([
|
|
573
426
|
directStringValueSchema,
|
|
574
427
|
directNumberValueSchema,
|
|
575
428
|
directBooleanValueSchema
|
|
576
429
|
]);
|
|
577
|
-
var referencedValueSchema =
|
|
578
|
-
objectType:
|
|
430
|
+
var referencedValueSchema = z4.object({
|
|
431
|
+
objectType: z4.literal(objectTypeSchema.Enum.value).readonly(),
|
|
579
432
|
definitionId: uuidSchema.readonly(),
|
|
580
|
-
valueType:
|
|
433
|
+
valueType: z4.literal(ValueTypeSchema.Enum.reference).readonly(),
|
|
581
434
|
content: translatableArrayOf(valueContentReferenceSchema)
|
|
582
435
|
});
|
|
583
|
-
var valueSchema =
|
|
436
|
+
var valueSchema = z4.union([directValueSchema, referencedValueSchema]);
|
|
584
437
|
var resolvedReferencedValueSchema = referencedValueSchema.extend({
|
|
585
438
|
content: translatableArrayOf(resolvedValueContentReferenceSchema)
|
|
586
439
|
});
|
|
587
|
-
var resolvedValueSchema =
|
|
440
|
+
var resolvedValueSchema = z4.union([
|
|
588
441
|
directValueSchema,
|
|
589
442
|
resolvedReferencedValueSchema
|
|
590
443
|
]);
|
|
@@ -606,10 +459,10 @@ function getValueContentSchemaFromDefinition(definition) {
|
|
|
606
459
|
}
|
|
607
460
|
}
|
|
608
461
|
function getBooleanValueContentSchema(definition) {
|
|
609
|
-
return
|
|
462
|
+
return z4.boolean();
|
|
610
463
|
}
|
|
611
464
|
function getNumberValueContentSchema(definition) {
|
|
612
|
-
let schema =
|
|
465
|
+
let schema = z4.number();
|
|
613
466
|
if (definition.min) {
|
|
614
467
|
schema = schema.min(definition.min);
|
|
615
468
|
}
|
|
@@ -622,7 +475,7 @@ function getNumberValueContentSchema(definition) {
|
|
|
622
475
|
return schema;
|
|
623
476
|
}
|
|
624
477
|
function getStringValueContentSchema(definition) {
|
|
625
|
-
let schema =
|
|
478
|
+
let schema = z4.string().trim();
|
|
626
479
|
if ("min" in definition && definition.min) {
|
|
627
480
|
schema = schema.min(definition.min);
|
|
628
481
|
}
|
|
@@ -661,12 +514,12 @@ function getReferenceValueContentSchema(definition) {
|
|
|
661
514
|
switch (definition.inputType) {
|
|
662
515
|
case ValueInputTypeSchema.Enum.asset:
|
|
663
516
|
{
|
|
664
|
-
schema =
|
|
517
|
+
schema = z4.array(valueContentReferenceToAssetSchema);
|
|
665
518
|
}
|
|
666
519
|
break;
|
|
667
520
|
case ValueInputTypeSchema.Enum.entry:
|
|
668
521
|
{
|
|
669
|
-
schema =
|
|
522
|
+
schema = z4.array(valueContentReferenceToEntrySchema);
|
|
670
523
|
}
|
|
671
524
|
break;
|
|
672
525
|
}
|
|
@@ -684,11 +537,11 @@ function getReferenceValueContentSchema(definition) {
|
|
|
684
537
|
|
|
685
538
|
// src/schema/entrySchema.ts
|
|
686
539
|
var entryFileSchema = baseFileSchema.extend({
|
|
687
|
-
objectType:
|
|
688
|
-
values:
|
|
540
|
+
objectType: z5.literal(objectTypeSchema.Enum.entry).readonly(),
|
|
541
|
+
values: z5.array(valueSchema)
|
|
689
542
|
});
|
|
690
543
|
var entrySchema = entryFileSchema.extend({
|
|
691
|
-
values:
|
|
544
|
+
values: z5.array(z5.lazy(() => resolvedValueSchema))
|
|
692
545
|
});
|
|
693
546
|
var entryExportSchema = entrySchema.extend({});
|
|
694
547
|
var createEntrySchema = entryFileSchema.omit({
|
|
@@ -699,9 +552,9 @@ var createEntrySchema = entryFileSchema.omit({
|
|
|
699
552
|
}).extend({
|
|
700
553
|
projectId: uuidSchema.readonly(),
|
|
701
554
|
collectionId: uuidSchema.readonly(),
|
|
702
|
-
values:
|
|
555
|
+
values: z5.array(valueSchema)
|
|
703
556
|
});
|
|
704
|
-
var readEntrySchema =
|
|
557
|
+
var readEntrySchema = z5.object({
|
|
705
558
|
id: uuidSchema.readonly(),
|
|
706
559
|
projectId: uuidSchema.readonly(),
|
|
707
560
|
collectionId: uuidSchema.readonly()
|
|
@@ -715,29 +568,29 @@ var updateEntrySchema = entrySchema.omit({
|
|
|
715
568
|
collectionId: uuidSchema.readonly()
|
|
716
569
|
});
|
|
717
570
|
var deleteEntrySchema = readEntrySchema.extend({});
|
|
718
|
-
var countEntriesSchema =
|
|
571
|
+
var countEntriesSchema = z5.object({
|
|
719
572
|
projectId: uuidSchema.readonly(),
|
|
720
573
|
collectionId: uuidSchema.readonly()
|
|
721
574
|
});
|
|
722
575
|
|
|
723
576
|
// src/schema/collectionSchema.ts
|
|
724
577
|
var collectionFileSchema = baseFileSchema.extend({
|
|
725
|
-
objectType:
|
|
726
|
-
name:
|
|
578
|
+
objectType: z6.literal(objectTypeSchema.Enum.collection).readonly(),
|
|
579
|
+
name: z6.object({
|
|
727
580
|
singular: translatableStringSchema,
|
|
728
581
|
plural: translatableStringSchema
|
|
729
582
|
}),
|
|
730
|
-
slug:
|
|
731
|
-
singular:
|
|
732
|
-
plural:
|
|
583
|
+
slug: z6.object({
|
|
584
|
+
singular: z6.string(),
|
|
585
|
+
plural: z6.string()
|
|
733
586
|
}),
|
|
734
587
|
description: translatableStringSchema,
|
|
735
588
|
icon: supportedIconSchema,
|
|
736
|
-
valueDefinitions:
|
|
589
|
+
valueDefinitions: z6.array(valueDefinitionSchema)
|
|
737
590
|
});
|
|
738
591
|
var collectionSchema = collectionFileSchema.extend({});
|
|
739
592
|
var collectionExportSchema = collectionSchema.extend({
|
|
740
|
-
entries:
|
|
593
|
+
entries: z6.array(entryExportSchema)
|
|
741
594
|
});
|
|
742
595
|
var createCollectionSchema = collectionSchema.omit({
|
|
743
596
|
id: true,
|
|
@@ -747,7 +600,7 @@ var createCollectionSchema = collectionSchema.omit({
|
|
|
747
600
|
}).extend({
|
|
748
601
|
projectId: uuidSchema.readonly()
|
|
749
602
|
});
|
|
750
|
-
var readCollectionSchema =
|
|
603
|
+
var readCollectionSchema = z6.object({
|
|
751
604
|
id: uuidSchema.readonly(),
|
|
752
605
|
projectId: uuidSchema.readonly()
|
|
753
606
|
});
|
|
@@ -762,19 +615,149 @@ var updateCollectionSchema = collectionFileSchema.pick({
|
|
|
762
615
|
projectId: uuidSchema.readonly()
|
|
763
616
|
});
|
|
764
617
|
var deleteCollectionSchema = readCollectionSchema.extend({});
|
|
765
|
-
var countCollectionsSchema =
|
|
618
|
+
var countCollectionsSchema = z6.object({
|
|
766
619
|
projectId: uuidSchema.readonly()
|
|
767
620
|
});
|
|
768
621
|
|
|
622
|
+
// src/schema/coreSchema.ts
|
|
623
|
+
import { z as z7 } from "zod";
|
|
624
|
+
var elekIoCoreOptionsSchema = z7.object({
|
|
625
|
+
/**
|
|
626
|
+
* The environment elek.io Core is currently running in
|
|
627
|
+
*/
|
|
628
|
+
environment: environmentSchema,
|
|
629
|
+
/**
|
|
630
|
+
* The current version of elek.io Core
|
|
631
|
+
*/
|
|
632
|
+
version: versionSchema,
|
|
633
|
+
file: z7.object({
|
|
634
|
+
json: z7.object({
|
|
635
|
+
/**
|
|
636
|
+
* If set, adds indentation with spaces (number) or escape character (string)
|
|
637
|
+
* and line break characters to saved JSON files on disk, to make them easier to read.
|
|
638
|
+
* Defaults to 2 spaces of indentation.
|
|
639
|
+
*/
|
|
640
|
+
indentation: z7.union([z7.number(), z7.string()])
|
|
641
|
+
})
|
|
642
|
+
})
|
|
643
|
+
});
|
|
644
|
+
var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
|
|
645
|
+
version: true
|
|
646
|
+
}).partial({
|
|
647
|
+
environment: true,
|
|
648
|
+
file: true
|
|
649
|
+
}).optional();
|
|
650
|
+
|
|
651
|
+
// src/schema/gitSchema.ts
|
|
652
|
+
import { z as z8 } from "zod";
|
|
653
|
+
var gitRepositoryPathSchema = z8.string();
|
|
654
|
+
var gitSignatureSchema = z8.object({
|
|
655
|
+
name: z8.string(),
|
|
656
|
+
email: z8.string()
|
|
657
|
+
});
|
|
658
|
+
var gitCommitSchema = z8.object({
|
|
659
|
+
/**
|
|
660
|
+
* SHA-1 hash of the commit
|
|
661
|
+
*/
|
|
662
|
+
hash: z8.string(),
|
|
663
|
+
message: z8.string(),
|
|
664
|
+
author: gitSignatureSchema,
|
|
665
|
+
timestamp: z8.number(),
|
|
666
|
+
tag: z8.string().nullable()
|
|
667
|
+
});
|
|
668
|
+
var GitCommitIconNative = /* @__PURE__ */ ((GitCommitIconNative2) => {
|
|
669
|
+
GitCommitIconNative2["INIT"] = ":tada:";
|
|
670
|
+
GitCommitIconNative2["CREATE"] = ":heavy_plus_sign:";
|
|
671
|
+
GitCommitIconNative2["UPDATE"] = ":wrench:";
|
|
672
|
+
GitCommitIconNative2["DELETE"] = ":fire:";
|
|
673
|
+
return GitCommitIconNative2;
|
|
674
|
+
})(GitCommitIconNative || {});
|
|
675
|
+
var gitCommitIconSchema = z8.nativeEnum(GitCommitIconNative);
|
|
676
|
+
var gitInitOptionsSchema = z8.object({
|
|
677
|
+
/**
|
|
678
|
+
* Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).
|
|
679
|
+
*/
|
|
680
|
+
initialBranch: z8.string()
|
|
681
|
+
});
|
|
682
|
+
var gitCloneOptionsSchema = z8.object({
|
|
683
|
+
/**
|
|
684
|
+
* Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
|
|
685
|
+
*/
|
|
686
|
+
depth: z8.number(),
|
|
687
|
+
/**
|
|
688
|
+
* Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.
|
|
689
|
+
*/
|
|
690
|
+
singleBranch: z8.boolean(),
|
|
691
|
+
/**
|
|
692
|
+
* Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
|
|
693
|
+
*/
|
|
694
|
+
branch: z8.string()
|
|
695
|
+
});
|
|
696
|
+
var gitSwitchOptionsSchema = z8.object({
|
|
697
|
+
/**
|
|
698
|
+
* If true, creates a new local branch and then switches to it
|
|
699
|
+
*
|
|
700
|
+
* @see https://git-scm.com/docs/git-switch#Documentation/git-switch.txt---createltnew-branchgt
|
|
701
|
+
*/
|
|
702
|
+
isNew: z8.boolean().optional()
|
|
703
|
+
});
|
|
704
|
+
var gitLogOptionsSchema = z8.object({
|
|
705
|
+
/**
|
|
706
|
+
* Limit the result to given number of commits
|
|
707
|
+
*/
|
|
708
|
+
limit: z8.number().optional(),
|
|
709
|
+
/**
|
|
710
|
+
* Only list commits that are between given SHAs or tag names
|
|
711
|
+
*
|
|
712
|
+
* Note that the commits of from and to are not included in the result
|
|
713
|
+
*/
|
|
714
|
+
between: z8.object({
|
|
715
|
+
/**
|
|
716
|
+
* From the oldest commit
|
|
717
|
+
*/
|
|
718
|
+
from: z8.string(),
|
|
719
|
+
/**
|
|
720
|
+
* To the newest commit
|
|
721
|
+
*
|
|
722
|
+
* Defaults to the current HEAD
|
|
723
|
+
*/
|
|
724
|
+
to: z8.string().optional()
|
|
725
|
+
})
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
// src/schema/gitTagSchema.ts
|
|
729
|
+
import { z as z9 } from "zod";
|
|
730
|
+
var gitTagSchema = z9.object({
|
|
731
|
+
id: uuidSchema,
|
|
732
|
+
message: z9.string(),
|
|
733
|
+
author: gitSignatureSchema,
|
|
734
|
+
timestamp: z9.number()
|
|
735
|
+
});
|
|
736
|
+
var createGitTagSchema = gitTagSchema.pick({
|
|
737
|
+
message: true
|
|
738
|
+
}).extend({
|
|
739
|
+
path: gitRepositoryPathSchema,
|
|
740
|
+
hash: gitCommitSchema.shape.hash.optional()
|
|
741
|
+
});
|
|
742
|
+
var readGitTagSchema = z9.object({
|
|
743
|
+
path: gitRepositoryPathSchema,
|
|
744
|
+
id: uuidSchema.readonly()
|
|
745
|
+
});
|
|
746
|
+
var deleteGitTagSchema = readGitTagSchema.extend({});
|
|
747
|
+
var countGitTagsSchema = z9.object({
|
|
748
|
+
path: gitRepositoryPathSchema
|
|
749
|
+
});
|
|
750
|
+
|
|
769
751
|
// src/schema/projectSchema.ts
|
|
770
|
-
|
|
771
|
-
var
|
|
772
|
-
|
|
752
|
+
import { z as z10 } from "zod";
|
|
753
|
+
var projectStatusSchema = z10.enum(["foo", "bar", "todo"]);
|
|
754
|
+
var projectSettingsSchema = z10.object({
|
|
755
|
+
language: z10.object({
|
|
773
756
|
default: supportedLanguageSchema,
|
|
774
|
-
supported:
|
|
757
|
+
supported: z10.array(supportedLanguageSchema)
|
|
775
758
|
})
|
|
776
759
|
});
|
|
777
|
-
var projectFolderSchema =
|
|
760
|
+
var projectFolderSchema = z10.enum([
|
|
778
761
|
"assets",
|
|
779
762
|
"collections",
|
|
780
763
|
"shared-values",
|
|
@@ -784,18 +767,18 @@ var projectFolderSchema = z9.enum([
|
|
|
784
767
|
// 'theme',
|
|
785
768
|
]);
|
|
786
769
|
var projectFileSchema = baseFileSchema.extend({
|
|
787
|
-
objectType:
|
|
770
|
+
objectType: z10.literal(objectTypeSchema.Enum.project).readonly(),
|
|
788
771
|
coreVersion: versionSchema,
|
|
789
|
-
name:
|
|
790
|
-
description:
|
|
772
|
+
name: z10.string().trim().min(1, "shared.projectNameRequired"),
|
|
773
|
+
description: z10.string().trim().min(1, "shared.projectDescriptionRequired"),
|
|
791
774
|
version: versionSchema,
|
|
792
775
|
status: projectStatusSchema,
|
|
793
776
|
settings: projectSettingsSchema
|
|
794
777
|
});
|
|
795
778
|
var projectSchema = projectFileSchema.extend({});
|
|
796
779
|
var projectExportSchema = projectSchema.extend({
|
|
797
|
-
assets:
|
|
798
|
-
collections:
|
|
780
|
+
assets: z10.array(assetExportSchema),
|
|
781
|
+
collections: z10.array(collectionExportSchema)
|
|
799
782
|
});
|
|
800
783
|
var createProjectSchema = projectSchema.pick({
|
|
801
784
|
name: true,
|
|
@@ -805,7 +788,7 @@ var createProjectSchema = projectSchema.pick({
|
|
|
805
788
|
description: true,
|
|
806
789
|
settings: true
|
|
807
790
|
});
|
|
808
|
-
var readProjectSchema =
|
|
791
|
+
var readProjectSchema = z10.object({
|
|
809
792
|
id: uuidSchema.readonly()
|
|
810
793
|
});
|
|
811
794
|
var updateProjectSchema = projectSchema.pick({
|
|
@@ -818,11 +801,11 @@ var updateProjectSchema = projectSchema.pick({
|
|
|
818
801
|
description: true,
|
|
819
802
|
settings: true
|
|
820
803
|
});
|
|
821
|
-
var upgradeProjectSchema =
|
|
804
|
+
var upgradeProjectSchema = z10.object({
|
|
822
805
|
id: uuidSchema.readonly()
|
|
823
806
|
});
|
|
824
807
|
var deleteProjectSchema = readProjectSchema.extend({});
|
|
825
|
-
var projectUpgradeSchema =
|
|
808
|
+
var projectUpgradeSchema = z10.object({
|
|
826
809
|
/**
|
|
827
810
|
* The Core version the Project will be upgraded to
|
|
828
811
|
*/
|
|
@@ -830,83 +813,184 @@ var projectUpgradeSchema = z9.object({
|
|
|
830
813
|
/**
|
|
831
814
|
* Function that will be executed in the process of upgrading a Project
|
|
832
815
|
*/
|
|
833
|
-
run:
|
|
816
|
+
run: z10.function().args(projectFileSchema).returns(z10.promise(z10.void()))
|
|
834
817
|
});
|
|
835
|
-
var cloneProjectSchema =
|
|
836
|
-
url:
|
|
818
|
+
var cloneProjectSchema = z10.object({
|
|
819
|
+
url: z10.string()
|
|
837
820
|
});
|
|
838
|
-
var listBranchesProjectSchema =
|
|
821
|
+
var listBranchesProjectSchema = z10.object({
|
|
839
822
|
id: uuidSchema.readonly()
|
|
840
823
|
});
|
|
841
|
-
var currentBranchProjectSchema =
|
|
824
|
+
var currentBranchProjectSchema = z10.object({
|
|
842
825
|
id: uuidSchema.readonly()
|
|
843
826
|
});
|
|
844
|
-
var switchBranchProjectSchema =
|
|
827
|
+
var switchBranchProjectSchema = z10.object({
|
|
845
828
|
id: uuidSchema.readonly(),
|
|
846
|
-
branch:
|
|
829
|
+
branch: z10.string(),
|
|
847
830
|
options: gitSwitchOptionsSchema.optional()
|
|
848
831
|
});
|
|
849
|
-
var getRemoteOriginUrlProjectSchema =
|
|
832
|
+
var getRemoteOriginUrlProjectSchema = z10.object({
|
|
850
833
|
id: uuidSchema.readonly()
|
|
851
834
|
});
|
|
852
|
-
var setRemoteOriginUrlProjectSchema =
|
|
835
|
+
var setRemoteOriginUrlProjectSchema = z10.object({
|
|
853
836
|
id: uuidSchema.readonly(),
|
|
854
|
-
url:
|
|
837
|
+
url: z10.string()
|
|
855
838
|
});
|
|
856
|
-
var getChangesProjectSchema =
|
|
839
|
+
var getChangesProjectSchema = z10.object({
|
|
857
840
|
id: uuidSchema.readonly()
|
|
858
841
|
});
|
|
859
|
-
var synchronizeProjectSchema =
|
|
842
|
+
var synchronizeProjectSchema = z10.object({
|
|
860
843
|
id: uuidSchema.readonly()
|
|
861
844
|
});
|
|
862
|
-
var searchProjectSchema =
|
|
845
|
+
var searchProjectSchema = z10.object({
|
|
863
846
|
id: uuidSchema.readonly(),
|
|
864
|
-
query:
|
|
847
|
+
query: z10.string(),
|
|
865
848
|
language: supportedLanguageSchema,
|
|
866
|
-
type:
|
|
849
|
+
type: z10.array(objectTypeSchema).optional()
|
|
867
850
|
});
|
|
868
851
|
|
|
869
|
-
// src/
|
|
870
|
-
|
|
871
|
-
var
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
852
|
+
// src/schema/serviceSchema.ts
|
|
853
|
+
import { z as z11 } from "zod";
|
|
854
|
+
var serviceTypeSchema = z11.enum([
|
|
855
|
+
"Git",
|
|
856
|
+
"GitTag",
|
|
857
|
+
"User",
|
|
858
|
+
"Project",
|
|
859
|
+
"Asset",
|
|
860
|
+
"JsonFile",
|
|
861
|
+
"Search",
|
|
862
|
+
"Collection",
|
|
863
|
+
"Entry",
|
|
864
|
+
"Value"
|
|
865
|
+
]);
|
|
866
|
+
var listSchema = z11.object({
|
|
867
|
+
projectId: uuidSchema,
|
|
868
|
+
limit: z11.number().optional(),
|
|
869
|
+
offset: z11.number().optional()
|
|
870
|
+
});
|
|
871
|
+
var listCollectionsSchema = listSchema;
|
|
872
|
+
var listEntriesSchema = listSchema.extend({
|
|
873
|
+
collectionId: uuidSchema
|
|
874
|
+
});
|
|
875
|
+
var listAssetsSchema = listSchema;
|
|
876
|
+
var listProjectsSchema = listSchema.omit({
|
|
877
|
+
projectId: true
|
|
878
|
+
});
|
|
879
|
+
var listGitTagsSchema = z11.object({
|
|
880
|
+
path: gitRepositoryPathSchema
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
// src/schema/userSchema.ts
|
|
884
|
+
import z12 from "zod";
|
|
885
|
+
var UserTypeSchema = z12.enum(["local", "cloud"]);
|
|
886
|
+
var baseUserSchema = gitSignatureSchema.extend({
|
|
887
|
+
userType: UserTypeSchema,
|
|
888
|
+
language: supportedLanguageSchema
|
|
889
|
+
});
|
|
890
|
+
var localUserSchema = baseUserSchema.extend({
|
|
891
|
+
userType: z12.literal(UserTypeSchema.Enum.local)
|
|
892
|
+
});
|
|
893
|
+
var cloudUserSchema = baseUserSchema.extend({
|
|
894
|
+
userType: z12.literal(UserTypeSchema.Enum.cloud),
|
|
895
|
+
id: uuidSchema
|
|
896
|
+
});
|
|
897
|
+
var userFileSchema = z12.union([localUserSchema, cloudUserSchema]);
|
|
898
|
+
var userSchema = userFileSchema;
|
|
899
|
+
var setUserSchema = userSchema;
|
|
900
|
+
|
|
901
|
+
// src/error/GitError.ts
|
|
902
|
+
var GitError = class extends Error {
|
|
903
|
+
constructor(message) {
|
|
904
|
+
super(message);
|
|
905
|
+
this.name = "GitError";
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
// src/error/NoCurrentUserError.ts
|
|
910
|
+
var NoCurrentUserError = class extends Error {
|
|
911
|
+
constructor() {
|
|
912
|
+
super("Make sure to set a User via Core before using other methods");
|
|
913
|
+
this.name = "NoCurrentUserError";
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
// src/error/ProjectUpgradeError.ts
|
|
918
|
+
var ProjectUpgradeError = class extends Error {
|
|
919
|
+
constructor(message) {
|
|
920
|
+
super(message);
|
|
921
|
+
this.name = "ProjectUpgradeError";
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
// src/error/RequiredParameterMissingError.ts
|
|
926
|
+
var RequiredParameterMissingError = class extends Error {
|
|
927
|
+
constructor(parameter) {
|
|
928
|
+
super(`Missing required parameter "${parameter}"`);
|
|
929
|
+
this.name = "RequiredParameterMissingError";
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
// src/util/node.ts
|
|
934
|
+
var node_exports = {};
|
|
935
|
+
__export(node_exports, {
|
|
936
|
+
assignDefaultIfMissing: () => assignDefaultIfMissing,
|
|
937
|
+
files: () => files,
|
|
938
|
+
folders: () => folders,
|
|
939
|
+
fromPath: () => fromPath,
|
|
940
|
+
getDuplicates: () => getDuplicates,
|
|
941
|
+
getRelativePath: () => getRelativePath,
|
|
942
|
+
isNoError: () => isNoError,
|
|
943
|
+
notEmpty: () => notEmpty,
|
|
944
|
+
pathTo: () => pathTo,
|
|
945
|
+
returnResolved: () => returnResolved,
|
|
946
|
+
spawnChildProcess: () => spawnChildProcess,
|
|
947
|
+
workingDirectory: () => workingDirectory
|
|
948
|
+
});
|
|
949
|
+
import { spawn } from "child_process";
|
|
950
|
+
import Fs from "fs-extra";
|
|
951
|
+
import { filter, flatten, groupBy, uniq } from "lodash-es";
|
|
952
|
+
import Os from "os";
|
|
953
|
+
import Path from "path";
|
|
954
|
+
var workingDirectory = Path.join(Os.homedir(), "elek.io");
|
|
955
|
+
var pathTo = {
|
|
956
|
+
tmp: Path.join(workingDirectory, "tmp"),
|
|
957
|
+
userFile: Path.join(workingDirectory, "user.json"),
|
|
958
|
+
// logs: Path.join(workingDirectory, 'logs'),
|
|
959
|
+
projects: Path.join(workingDirectory, "projects"),
|
|
960
|
+
project: (projectId) => {
|
|
961
|
+
return Path.join(pathTo.projects, projectId);
|
|
962
|
+
},
|
|
963
|
+
projectFile: (projectId) => {
|
|
964
|
+
return Path.join(pathTo.project(projectId), "project.json");
|
|
965
|
+
},
|
|
966
|
+
// projectLogs: (projectId: string): string => {
|
|
967
|
+
// return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.logs);
|
|
968
|
+
// },
|
|
969
|
+
// public: (projectId: string): string => {
|
|
970
|
+
// return Path.join(pathTo.project(projectId), 'public');
|
|
971
|
+
// },
|
|
972
|
+
lfs: (projectId) => {
|
|
973
|
+
return Path.join(pathTo.project(projectId), projectFolderSchema.Enum.lfs);
|
|
974
|
+
},
|
|
975
|
+
collections: (projectId) => {
|
|
976
|
+
return Path.join(
|
|
977
|
+
pathTo.project(projectId),
|
|
978
|
+
projectFolderSchema.Enum.collections
|
|
979
|
+
);
|
|
980
|
+
},
|
|
981
|
+
collection: (projectId, id) => {
|
|
982
|
+
return Path.join(pathTo.collections(projectId), id);
|
|
983
|
+
},
|
|
984
|
+
collectionFile: (projectId, id) => {
|
|
985
|
+
return Path.join(pathTo.collection(projectId, id), "collection.json");
|
|
986
|
+
},
|
|
987
|
+
entries: (projectId, collectionId) => {
|
|
988
|
+
return Path.join(pathTo.collection(projectId, collectionId));
|
|
989
|
+
},
|
|
990
|
+
entryFile: (projectId, collectionId, id) => {
|
|
991
|
+
return Path.join(pathTo.entries(projectId, collectionId), `${id}.json`);
|
|
992
|
+
},
|
|
993
|
+
sharedValues: (projectId) => {
|
|
910
994
|
return Path.join(pathTo.project(projectId), "shared-values");
|
|
911
995
|
},
|
|
912
996
|
sharedValueFile: (projectId, id, language) => {
|
|
@@ -1035,29 +1119,6 @@ function getDuplicates(arr, key) {
|
|
|
1035
1119
|
);
|
|
1036
1120
|
}
|
|
1037
1121
|
|
|
1038
|
-
// src/util/shared.ts
|
|
1039
|
-
import slugify from "slugify";
|
|
1040
|
-
import { v4 as generateUuid } from "uuid";
|
|
1041
|
-
var Slugify = slugify.default || slugify;
|
|
1042
|
-
function uuid() {
|
|
1043
|
-
return generateUuid();
|
|
1044
|
-
}
|
|
1045
|
-
function currentTimestamp() {
|
|
1046
|
-
return Math.floor(Date.now() / 1e3);
|
|
1047
|
-
}
|
|
1048
|
-
function slug(string) {
|
|
1049
|
-
return Slugify(string, {
|
|
1050
|
-
replacement: "-",
|
|
1051
|
-
// replace spaces with replacement character, defaults to `-`
|
|
1052
|
-
remove: void 0,
|
|
1053
|
-
// remove characters that match regex, defaults to `undefined`
|
|
1054
|
-
lower: true,
|
|
1055
|
-
// convert to lower case, defaults to `false`
|
|
1056
|
-
strict: true
|
|
1057
|
-
// strip special characters except replacement, defaults to `false`
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
1122
|
// src/service/AbstractCrudService.ts
|
|
1062
1123
|
var AbstractCrudService = class {
|
|
1063
1124
|
/**
|
|
@@ -1154,54 +1215,341 @@ var AbstractCrudService = class {
|
|
|
1154
1215
|
}
|
|
1155
1216
|
};
|
|
1156
1217
|
|
|
1157
|
-
// src/service/
|
|
1158
|
-
import
|
|
1159
|
-
import
|
|
1160
|
-
import PQueue from "p-queue";
|
|
1218
|
+
// src/service/AssetService.ts
|
|
1219
|
+
import Fs3 from "fs-extra";
|
|
1220
|
+
import IsSvg from "is-svg";
|
|
1161
1221
|
|
|
1162
|
-
// src/
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1222
|
+
// src/util/shared.ts
|
|
1223
|
+
import slugify from "slugify";
|
|
1224
|
+
import { v4 as generateUuid } from "uuid";
|
|
1225
|
+
var Slugify = slugify.default || slugify;
|
|
1226
|
+
function uuid() {
|
|
1227
|
+
return generateUuid();
|
|
1228
|
+
}
|
|
1229
|
+
function currentTimestamp() {
|
|
1230
|
+
return Math.floor(Date.now() / 1e3);
|
|
1231
|
+
}
|
|
1232
|
+
function slug(string) {
|
|
1233
|
+
return Slugify(string, {
|
|
1234
|
+
replacement: "-",
|
|
1235
|
+
// replace spaces with replacement character, defaults to `-`
|
|
1236
|
+
remove: void 0,
|
|
1237
|
+
// remove characters that match regex, defaults to `undefined`
|
|
1238
|
+
lower: true,
|
|
1239
|
+
// convert to lower case, defaults to `false`
|
|
1240
|
+
strict: true
|
|
1241
|
+
// strip special characters except replacement, defaults to `false`
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// src/service/JsonFileService.ts
|
|
1246
|
+
import Fs2 from "fs-extra";
|
|
1247
|
+
var JsonFileService = class extends AbstractCrudService {
|
|
1248
|
+
constructor(options) {
|
|
1249
|
+
super(serviceTypeSchema.Enum.JsonFile, options);
|
|
1250
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Creates a new file on disk. Fails if path already exists
|
|
1254
|
+
*
|
|
1255
|
+
* @param data Data to write into the file
|
|
1256
|
+
* @param path Path to write the file to
|
|
1257
|
+
* @param schema Schema of the file to validate against
|
|
1258
|
+
* @returns Validated content of the file from disk
|
|
1259
|
+
*/
|
|
1260
|
+
async create(data, path, schema) {
|
|
1261
|
+
const parsedData = schema.parse(data);
|
|
1262
|
+
const string = this.serialize(parsedData);
|
|
1263
|
+
await Fs2.writeFile(path, string, {
|
|
1264
|
+
flag: "wx",
|
|
1265
|
+
encoding: "utf8"
|
|
1266
|
+
});
|
|
1267
|
+
this.cache.set(path, parsedData);
|
|
1268
|
+
return parsedData;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Reads the content of a file on disk. Fails if path does not exist
|
|
1272
|
+
*
|
|
1273
|
+
* @param path Path to read the file from
|
|
1274
|
+
* @param schema Schema of the file to validate against
|
|
1275
|
+
* @returns Validated content of the file from disk
|
|
1276
|
+
*/
|
|
1277
|
+
async read(path, schema) {
|
|
1278
|
+
if (this.cache.has(path)) {
|
|
1279
|
+
return this.cache.get(path);
|
|
1280
|
+
}
|
|
1281
|
+
const data = await Fs2.readFile(path, {
|
|
1282
|
+
flag: "r",
|
|
1283
|
+
encoding: "utf8"
|
|
1284
|
+
});
|
|
1285
|
+
const json = this.deserialize(data);
|
|
1286
|
+
const parsedData = schema.parse(json);
|
|
1287
|
+
this.cache.set(path, parsedData);
|
|
1288
|
+
return parsedData;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Overwrites an existing file on disk
|
|
1292
|
+
*
|
|
1293
|
+
* @todo Check how to error out if the file does not exist already
|
|
1294
|
+
*
|
|
1295
|
+
* @param data Data to write into the file
|
|
1296
|
+
* @param path Path to the file to overwrite
|
|
1297
|
+
* @param schema Schema of the file to validate against
|
|
1298
|
+
* @returns Validated content of the file from disk
|
|
1299
|
+
*/
|
|
1300
|
+
async update(data, path, schema) {
|
|
1301
|
+
const parsedData = schema.parse(data);
|
|
1302
|
+
const string = this.serialize(parsedData);
|
|
1303
|
+
await Fs2.writeFile(path, string, {
|
|
1304
|
+
flag: "w",
|
|
1305
|
+
encoding: "utf8"
|
|
1306
|
+
});
|
|
1307
|
+
this.cache.set(path, parsedData);
|
|
1308
|
+
return parsedData;
|
|
1309
|
+
}
|
|
1310
|
+
serialize(data) {
|
|
1311
|
+
return JSON.stringify(data, null, this.options.file.json.indentation);
|
|
1312
|
+
}
|
|
1313
|
+
deserialize(data) {
|
|
1314
|
+
return JSON.parse(data);
|
|
1167
1315
|
}
|
|
1168
1316
|
};
|
|
1169
1317
|
|
|
1170
|
-
// src/
|
|
1171
|
-
var
|
|
1172
|
-
constructor() {
|
|
1173
|
-
super(
|
|
1174
|
-
this.
|
|
1318
|
+
// src/service/AssetService.ts
|
|
1319
|
+
var AssetService = class extends AbstractCrudService {
|
|
1320
|
+
constructor(options, jsonFileService, gitService) {
|
|
1321
|
+
super(serviceTypeSchema.Enum.Asset, options);
|
|
1322
|
+
this.jsonFileService = jsonFileService;
|
|
1323
|
+
this.gitService = gitService;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Creates a new Asset
|
|
1327
|
+
*/
|
|
1328
|
+
async create(props) {
|
|
1329
|
+
createAssetSchema.parse(props);
|
|
1330
|
+
const id = uuid();
|
|
1331
|
+
const projectPath = pathTo.project(props.projectId);
|
|
1332
|
+
const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
|
|
1333
|
+
const size = await this.getAssetSize(props.filePath);
|
|
1334
|
+
const assetPath = pathTo.asset(
|
|
1335
|
+
props.projectId,
|
|
1336
|
+
id,
|
|
1337
|
+
props.language,
|
|
1338
|
+
fileType.extension
|
|
1339
|
+
);
|
|
1340
|
+
const assetFilePath = pathTo.assetFile(props.projectId, id, props.language);
|
|
1341
|
+
const assetFile = {
|
|
1342
|
+
...props,
|
|
1343
|
+
objectType: "asset",
|
|
1344
|
+
id,
|
|
1345
|
+
created: currentTimestamp(),
|
|
1346
|
+
updated: null,
|
|
1347
|
+
extension: fileType.extension,
|
|
1348
|
+
mimeType: fileType.mimeType,
|
|
1349
|
+
size
|
|
1350
|
+
};
|
|
1351
|
+
try {
|
|
1352
|
+
await Fs3.copyFile(props.filePath, assetPath);
|
|
1353
|
+
await this.jsonFileService.create(
|
|
1354
|
+
assetFile,
|
|
1355
|
+
assetFilePath,
|
|
1356
|
+
assetFileSchema
|
|
1357
|
+
);
|
|
1358
|
+
} catch (error) {
|
|
1359
|
+
await this.delete({ ...assetFile, projectId: props.projectId });
|
|
1360
|
+
throw error;
|
|
1361
|
+
}
|
|
1362
|
+
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
1363
|
+
await this.gitService.commit(projectPath, this.gitMessage.create);
|
|
1364
|
+
return this.toAsset(props.projectId, assetFile);
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Returns an Asset by ID and language
|
|
1368
|
+
*/
|
|
1369
|
+
async read(props) {
|
|
1370
|
+
readAssetSchema.parse(props);
|
|
1371
|
+
const assetFile = await this.jsonFileService.read(
|
|
1372
|
+
pathTo.assetFile(props.projectId, props.id, props.language),
|
|
1373
|
+
assetFileSchema
|
|
1374
|
+
);
|
|
1375
|
+
return this.toAsset(props.projectId, assetFile);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Updates given Asset
|
|
1379
|
+
*
|
|
1380
|
+
* Use the optional "newFilePath" prop to update the Asset itself
|
|
1381
|
+
*/
|
|
1382
|
+
async update(props) {
|
|
1383
|
+
updateAssetSchema.parse(props);
|
|
1384
|
+
const projectPath = pathTo.project(props.projectId);
|
|
1385
|
+
const assetFilePath = pathTo.assetFile(
|
|
1386
|
+
props.projectId,
|
|
1387
|
+
props.id,
|
|
1388
|
+
props.language
|
|
1389
|
+
);
|
|
1390
|
+
const prevAssetFile = await this.read(props);
|
|
1391
|
+
const assetFile = {
|
|
1392
|
+
...prevAssetFile,
|
|
1393
|
+
...props,
|
|
1394
|
+
updated: currentTimestamp()
|
|
1395
|
+
};
|
|
1396
|
+
if (props.newFilePath) {
|
|
1397
|
+
const fileType = await this.getSupportedFileTypeOrThrow(
|
|
1398
|
+
props.newFilePath
|
|
1399
|
+
);
|
|
1400
|
+
const size = await this.getAssetSize(props.newFilePath);
|
|
1401
|
+
const prevAssetPath = pathTo.asset(
|
|
1402
|
+
props.projectId,
|
|
1403
|
+
props.id,
|
|
1404
|
+
props.language,
|
|
1405
|
+
prevAssetFile.extension
|
|
1406
|
+
);
|
|
1407
|
+
const assetPath = pathTo.asset(
|
|
1408
|
+
props.projectId,
|
|
1409
|
+
props.id,
|
|
1410
|
+
props.language,
|
|
1411
|
+
fileType.extension
|
|
1412
|
+
);
|
|
1413
|
+
await Fs3.remove(prevAssetPath);
|
|
1414
|
+
await Fs3.copyFile(props.newFilePath, assetPath);
|
|
1415
|
+
assetFile.extension = fileType.extension;
|
|
1416
|
+
assetFile.mimeType = fileType.mimeType;
|
|
1417
|
+
assetFile.size = size;
|
|
1418
|
+
}
|
|
1419
|
+
await this.jsonFileService.update(
|
|
1420
|
+
assetFile,
|
|
1421
|
+
assetFilePath,
|
|
1422
|
+
assetFileSchema
|
|
1423
|
+
);
|
|
1424
|
+
await this.gitService.add(projectPath, [assetFilePath]);
|
|
1425
|
+
await this.gitService.commit(projectPath, this.gitMessage.update);
|
|
1426
|
+
return this.toAsset(props.projectId, assetFile);
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Deletes given Asset
|
|
1430
|
+
*/
|
|
1431
|
+
async delete(props) {
|
|
1432
|
+
deleteAssetSchema.parse(props);
|
|
1433
|
+
const projectPath = pathTo.project(props.projectId);
|
|
1434
|
+
const assetFilePath = pathTo.assetFile(
|
|
1435
|
+
props.projectId,
|
|
1436
|
+
props.id,
|
|
1437
|
+
props.language
|
|
1438
|
+
);
|
|
1439
|
+
const assetPath = pathTo.asset(
|
|
1440
|
+
props.projectId,
|
|
1441
|
+
props.id,
|
|
1442
|
+
props.language,
|
|
1443
|
+
props.extension
|
|
1444
|
+
);
|
|
1445
|
+
await Fs3.remove(assetPath);
|
|
1446
|
+
await Fs3.remove(assetFilePath);
|
|
1447
|
+
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
1448
|
+
await this.gitService.commit(projectPath, this.gitMessage.delete);
|
|
1449
|
+
}
|
|
1450
|
+
async list(props) {
|
|
1451
|
+
listAssetsSchema.parse(props);
|
|
1452
|
+
const offset = props.offset || 0;
|
|
1453
|
+
const limit = props.limit || 15;
|
|
1454
|
+
const assetReferences = await this.listReferences(
|
|
1455
|
+
objectTypeSchema.Enum.asset,
|
|
1456
|
+
props.projectId
|
|
1457
|
+
);
|
|
1458
|
+
const partialAssetReferences = assetReferences.slice(offset, limit);
|
|
1459
|
+
const assets = await returnResolved(
|
|
1460
|
+
partialAssetReferences.map((assetReference) => {
|
|
1461
|
+
if (!assetReference.language) {
|
|
1462
|
+
throw new RequiredParameterMissingError("language");
|
|
1463
|
+
}
|
|
1464
|
+
return this.read({
|
|
1465
|
+
projectId: props.projectId,
|
|
1466
|
+
id: assetReference.id,
|
|
1467
|
+
language: assetReference.language
|
|
1468
|
+
});
|
|
1469
|
+
})
|
|
1470
|
+
);
|
|
1471
|
+
return {
|
|
1472
|
+
total: assetReferences.length,
|
|
1473
|
+
limit,
|
|
1474
|
+
offset,
|
|
1475
|
+
list: assets
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
async count(props) {
|
|
1479
|
+
countAssetsSchema.parse(props);
|
|
1480
|
+
const count = (await this.listReferences(objectTypeSchema.Enum.asset, props.projectId)).length;
|
|
1481
|
+
return count;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Checks if given object is of type Asset
|
|
1485
|
+
*/
|
|
1486
|
+
isAsset(obj) {
|
|
1487
|
+
return assetSchema.safeParse(obj).success;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Returns the size of an Asset in bytes
|
|
1491
|
+
*
|
|
1492
|
+
* @param path Path of the Asset to get the size from
|
|
1493
|
+
*/
|
|
1494
|
+
async getAssetSize(path) {
|
|
1495
|
+
return (await Fs3.stat(path)).size;
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Creates an Asset from given AssetFile
|
|
1499
|
+
*
|
|
1500
|
+
* @param projectId The project's ID
|
|
1501
|
+
* @param assetFile The AssetFile to convert
|
|
1502
|
+
*/
|
|
1503
|
+
async toAsset(projectId, assetFile) {
|
|
1504
|
+
const assetPath = pathTo.asset(
|
|
1505
|
+
projectId,
|
|
1506
|
+
assetFile.id,
|
|
1507
|
+
assetFile.language,
|
|
1508
|
+
assetFile.extension
|
|
1509
|
+
);
|
|
1510
|
+
const asset = {
|
|
1511
|
+
...assetFile,
|
|
1512
|
+
absolutePath: assetPath
|
|
1513
|
+
};
|
|
1514
|
+
return asset;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Returns the found and supported extension as well as mime type,
|
|
1518
|
+
* otherwise throws an error
|
|
1519
|
+
*
|
|
1520
|
+
* @param filePath Path to the file to check
|
|
1521
|
+
*/
|
|
1522
|
+
async getSupportedFileTypeOrThrow(filePath) {
|
|
1523
|
+
const fileSize = (await Fs3.stat(filePath)).size;
|
|
1524
|
+
if (fileSize / 1e3 <= 500) {
|
|
1525
|
+
const fileBuffer = await Fs3.readFile(filePath);
|
|
1526
|
+
if (IsSvg(fileBuffer.toString()) === true) {
|
|
1527
|
+
return {
|
|
1528
|
+
extension: supportedAssetExtensionSchema.Enum.svg,
|
|
1529
|
+
mimeType: supportedAssetMimeTypeSchema.Enum["image/svg+xml"]
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
const { fileTypeFromFile } = await import("file-type");
|
|
1534
|
+
const fileType = await fileTypeFromFile(filePath);
|
|
1535
|
+
const result = supportedAssetTypeSchema.parse({
|
|
1536
|
+
extension: fileType?.ext,
|
|
1537
|
+
mimeType: fileType?.mime
|
|
1538
|
+
});
|
|
1539
|
+
return result;
|
|
1175
1540
|
}
|
|
1176
1541
|
};
|
|
1177
1542
|
|
|
1178
|
-
// src/service/
|
|
1179
|
-
import
|
|
1543
|
+
// src/service/CollectionService.ts
|
|
1544
|
+
import Fs4 from "fs-extra";
|
|
1180
1545
|
|
|
1181
|
-
// src/
|
|
1182
|
-
import {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
message: z10.string(),
|
|
1186
|
-
author: gitSignatureSchema,
|
|
1187
|
-
timestamp: z10.number()
|
|
1188
|
-
});
|
|
1189
|
-
var createGitTagSchema = gitTagSchema.pick({
|
|
1190
|
-
message: true
|
|
1191
|
-
}).extend({
|
|
1192
|
-
path: gitRepositoryPathSchema,
|
|
1193
|
-
hash: gitCommitSchema.shape.hash.optional()
|
|
1194
|
-
});
|
|
1195
|
-
var readGitTagSchema = z10.object({
|
|
1196
|
-
path: gitRepositoryPathSchema,
|
|
1197
|
-
id: uuidSchema.readonly()
|
|
1198
|
-
});
|
|
1199
|
-
var deleteGitTagSchema = readGitTagSchema.extend({});
|
|
1200
|
-
var countGitTagsSchema = z10.object({
|
|
1201
|
-
path: gitRepositoryPathSchema
|
|
1202
|
-
});
|
|
1546
|
+
// src/service/GitService.ts
|
|
1547
|
+
import { GitProcess } from "dugite";
|
|
1548
|
+
import { EOL as EOL2 } from "os";
|
|
1549
|
+
import PQueue from "p-queue";
|
|
1203
1550
|
|
|
1204
1551
|
// src/service/GitTagService.ts
|
|
1552
|
+
import { EOL } from "os";
|
|
1205
1553
|
var GitTagService = class extends AbstractCrudService {
|
|
1206
1554
|
constructor(options, git) {
|
|
1207
1555
|
super(serviceTypeSchema.Enum.GitTag, options);
|
|
@@ -1329,97 +1677,6 @@ var GitTagService = class extends AbstractCrudService {
|
|
|
1329
1677
|
}
|
|
1330
1678
|
};
|
|
1331
1679
|
|
|
1332
|
-
// src/schema/userSchema.ts
|
|
1333
|
-
import z11 from "zod";
|
|
1334
|
-
var UserTypeSchema = z11.enum(["local", "cloud"]);
|
|
1335
|
-
var baseUserSchema = gitSignatureSchema.extend({
|
|
1336
|
-
userType: UserTypeSchema,
|
|
1337
|
-
language: supportedLanguageSchema
|
|
1338
|
-
});
|
|
1339
|
-
var localUserSchema = baseUserSchema.extend({
|
|
1340
|
-
userType: z11.literal(UserTypeSchema.Enum.local)
|
|
1341
|
-
});
|
|
1342
|
-
var cloudUserSchema = baseUserSchema.extend({
|
|
1343
|
-
userType: z11.literal(UserTypeSchema.Enum.cloud),
|
|
1344
|
-
id: uuidSchema
|
|
1345
|
-
});
|
|
1346
|
-
var userFileSchema = z11.union([localUserSchema, cloudUserSchema]);
|
|
1347
|
-
var userSchema = userFileSchema;
|
|
1348
|
-
var setUserSchema = userSchema;
|
|
1349
|
-
|
|
1350
|
-
// src/service/JsonFileService.ts
|
|
1351
|
-
import Fs2 from "fs-extra";
|
|
1352
|
-
var JsonFileService = class extends AbstractCrudService {
|
|
1353
|
-
constructor(options) {
|
|
1354
|
-
super(serviceTypeSchema.Enum.JsonFile, options);
|
|
1355
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
1356
|
-
}
|
|
1357
|
-
/**
|
|
1358
|
-
* Creates a new file on disk. Fails if path already exists
|
|
1359
|
-
*
|
|
1360
|
-
* @param data Data to write into the file
|
|
1361
|
-
* @param path Path to write the file to
|
|
1362
|
-
* @param schema Schema of the file to validate against
|
|
1363
|
-
* @returns Validated content of the file from disk
|
|
1364
|
-
*/
|
|
1365
|
-
async create(data, path, schema) {
|
|
1366
|
-
const parsedData = schema.parse(data);
|
|
1367
|
-
const string = this.serialize(parsedData);
|
|
1368
|
-
await Fs2.writeFile(path, string, {
|
|
1369
|
-
flag: "wx",
|
|
1370
|
-
encoding: "utf8"
|
|
1371
|
-
});
|
|
1372
|
-
this.cache.set(path, parsedData);
|
|
1373
|
-
return parsedData;
|
|
1374
|
-
}
|
|
1375
|
-
/**
|
|
1376
|
-
* Reads the content of a file on disk. Fails if path does not exist
|
|
1377
|
-
*
|
|
1378
|
-
* @param path Path to read the file from
|
|
1379
|
-
* @param schema Schema of the file to validate against
|
|
1380
|
-
* @returns Validated content of the file from disk
|
|
1381
|
-
*/
|
|
1382
|
-
async read(path, schema) {
|
|
1383
|
-
if (this.cache.has(path)) {
|
|
1384
|
-
return this.cache.get(path);
|
|
1385
|
-
}
|
|
1386
|
-
const data = await Fs2.readFile(path, {
|
|
1387
|
-
flag: "r",
|
|
1388
|
-
encoding: "utf8"
|
|
1389
|
-
});
|
|
1390
|
-
const json = this.deserialize(data);
|
|
1391
|
-
const parsedData = schema.parse(json);
|
|
1392
|
-
this.cache.set(path, parsedData);
|
|
1393
|
-
return parsedData;
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Overwrites an existing file on disk
|
|
1397
|
-
*
|
|
1398
|
-
* @todo Check how to error out if the file does not exist already
|
|
1399
|
-
*
|
|
1400
|
-
* @param data Data to write into the file
|
|
1401
|
-
* @param path Path to the file to overwrite
|
|
1402
|
-
* @param schema Schema of the file to validate against
|
|
1403
|
-
* @returns Validated content of the file from disk
|
|
1404
|
-
*/
|
|
1405
|
-
async update(data, path, schema) {
|
|
1406
|
-
const parsedData = schema.parse(data);
|
|
1407
|
-
const string = this.serialize(parsedData);
|
|
1408
|
-
await Fs2.writeFile(path, string, {
|
|
1409
|
-
flag: "w",
|
|
1410
|
-
encoding: "utf8"
|
|
1411
|
-
});
|
|
1412
|
-
this.cache.set(path, parsedData);
|
|
1413
|
-
return parsedData;
|
|
1414
|
-
}
|
|
1415
|
-
serialize(data) {
|
|
1416
|
-
return JSON.stringify(data, null, this.options.file.json.indentation);
|
|
1417
|
-
}
|
|
1418
|
-
deserialize(data) {
|
|
1419
|
-
return JSON.parse(data);
|
|
1420
|
-
}
|
|
1421
|
-
};
|
|
1422
|
-
|
|
1423
1680
|
// src/service/UserService.ts
|
|
1424
1681
|
var UserService = class {
|
|
1425
1682
|
constructor(jsonFileService) {
|
|
@@ -1858,343 +2115,117 @@ var GitService2 = class {
|
|
|
1858
2115
|
]);
|
|
1859
2116
|
return {
|
|
1860
2117
|
created: meta[0],
|
|
1861
|
-
updated: meta[1]
|
|
1862
|
-
};
|
|
1863
|
-
}
|
|
1864
|
-
/**
|
|
1865
|
-
* Reads the currently used version of Git
|
|
1866
|
-
*
|
|
1867
|
-
* This can help debugging
|
|
1868
|
-
*/
|
|
1869
|
-
async updateVersion() {
|
|
1870
|
-
const result = await this.git("", ["--version"]);
|
|
1871
|
-
this.version = result.stdout.replace("git version", "").trim();
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
* Reads the path to the executable of Git that is used
|
|
1875
|
-
*
|
|
1876
|
-
* This can help debugging, since dugite is shipping their own executable
|
|
1877
|
-
* but in some cases resolves another executable
|
|
1878
|
-
* @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
|
|
1879
|
-
*/
|
|
1880
|
-
async updateGitPath() {
|
|
1881
|
-
const result = await this.git("", ["--exec-path"]);
|
|
1882
|
-
this.gitPath = result.stdout.trim();
|
|
1883
|
-
}
|
|
1884
|
-
/**
|
|
1885
|
-
* A reference is used in Git to specify branches and tags.
|
|
1886
|
-
* This method checks if given name matches the required format
|
|
1887
|
-
*
|
|
1888
|
-
* @see https://git-scm.com/docs/git-check-ref-format
|
|
1889
|
-
*
|
|
1890
|
-
* @param path Path to the repository
|
|
1891
|
-
* @param name Name to check
|
|
1892
|
-
*/
|
|
1893
|
-
async checkBranchOrTagName(path, name) {
|
|
1894
|
-
await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
|
|
1895
|
-
}
|
|
1896
|
-
/**
|
|
1897
|
-
* Installs LFS support and starts tracking
|
|
1898
|
-
* all files inside the lfs folder
|
|
1899
|
-
*
|
|
1900
|
-
* @param path Path to the repository
|
|
1901
|
-
*/
|
|
1902
|
-
async installLfs(path) {
|
|
1903
|
-
await this.git(path, ["lfs", "install"]);
|
|
1904
|
-
await this.git(path, ["lfs", "track", "lfs/*"]);
|
|
1905
|
-
}
|
|
1906
|
-
/**
|
|
1907
|
-
* Sets the git config of given local repository from ElekIoCoreOptions
|
|
1908
|
-
*
|
|
1909
|
-
* @param path Path to the repository
|
|
1910
|
-
*/
|
|
1911
|
-
async setLocalConfig(path) {
|
|
1912
|
-
const user = await this.userService.get();
|
|
1913
|
-
if (!user) {
|
|
1914
|
-
throw new NoCurrentUserError();
|
|
1915
|
-
}
|
|
1916
|
-
const userNameArgs = ["config", "--local", "user.name", user.name];
|
|
1917
|
-
const userEmailArgs = ["config", "--local", "user.email", user.email];
|
|
1918
|
-
const autoSetupRemoteArgs = [
|
|
1919
|
-
"config",
|
|
1920
|
-
"--local",
|
|
1921
|
-
"push.autoSetupRemote",
|
|
1922
|
-
"true"
|
|
1923
|
-
];
|
|
1924
|
-
await this.git(path, userNameArgs);
|
|
1925
|
-
await this.git(path, userEmailArgs);
|
|
1926
|
-
await this.git(path, autoSetupRemoteArgs);
|
|
1927
|
-
}
|
|
1928
|
-
/**
|
|
1929
|
-
* Type guard for GitCommit
|
|
1930
|
-
*
|
|
1931
|
-
* @param obj The object to check
|
|
1932
|
-
*/
|
|
1933
|
-
isGitCommit(obj) {
|
|
1934
|
-
return gitCommitSchema.safeParse(obj).success;
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* Wraps the execution of any git command
|
|
1938
|
-
* to use a FIFO queue for sequential processing
|
|
1939
|
-
*
|
|
1940
|
-
* @param path Path to the repository
|
|
1941
|
-
* @param args Arguments to append after the `git` command
|
|
1942
|
-
*/
|
|
1943
|
-
async git(path, args) {
|
|
1944
|
-
const result = await this.queue.add(
|
|
1945
|
-
() => GitProcess.exec(args, path, {
|
|
1946
|
-
env: {
|
|
1947
|
-
// @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
|
|
1948
|
-
// @see https://github.com/git-lfs/git-lfs/issues/5749
|
|
1949
|
-
GIT_CLONE_PROTECTION_ACTIVE: "false"
|
|
1950
|
-
}
|
|
1951
|
-
})
|
|
1952
|
-
);
|
|
1953
|
-
if (!result) {
|
|
1954
|
-
throw new GitError(
|
|
1955
|
-
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
1956
|
-
" "
|
|
1957
|
-
)}" failed to return a result`
|
|
1958
|
-
);
|
|
1959
|
-
}
|
|
1960
|
-
if (result.exitCode !== 0) {
|
|
1961
|
-
throw new GitError(
|
|
1962
|
-
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
1963
|
-
" "
|
|
1964
|
-
)}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
|
|
1965
|
-
);
|
|
1966
|
-
}
|
|
1967
|
-
return result;
|
|
1968
|
-
}
|
|
1969
|
-
};
|
|
1970
|
-
|
|
1971
|
-
// src/service/AssetService.ts
|
|
1972
|
-
var AssetService = class extends AbstractCrudService {
|
|
1973
|
-
constructor(options, jsonFileService, gitService) {
|
|
1974
|
-
super(serviceTypeSchema.Enum.Asset, options);
|
|
1975
|
-
this.jsonFileService = jsonFileService;
|
|
1976
|
-
this.gitService = gitService;
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
* Creates a new Asset
|
|
1980
|
-
*/
|
|
1981
|
-
async create(props) {
|
|
1982
|
-
createAssetSchema.parse(props);
|
|
1983
|
-
const id = uuid();
|
|
1984
|
-
const projectPath = pathTo.project(props.projectId);
|
|
1985
|
-
const fileType = await this.getSupportedFileTypeOrThrow(props.filePath);
|
|
1986
|
-
const size = await this.getAssetSize(props.filePath);
|
|
1987
|
-
const assetPath = pathTo.asset(
|
|
1988
|
-
props.projectId,
|
|
1989
|
-
id,
|
|
1990
|
-
props.language,
|
|
1991
|
-
fileType.extension
|
|
1992
|
-
);
|
|
1993
|
-
const assetFilePath = pathTo.assetFile(props.projectId, id, props.language);
|
|
1994
|
-
const assetFile = {
|
|
1995
|
-
...props,
|
|
1996
|
-
objectType: "asset",
|
|
1997
|
-
id,
|
|
1998
|
-
created: currentTimestamp(),
|
|
1999
|
-
updated: null,
|
|
2000
|
-
extension: fileType.extension,
|
|
2001
|
-
mimeType: fileType.mimeType,
|
|
2002
|
-
size
|
|
2003
|
-
};
|
|
2004
|
-
try {
|
|
2005
|
-
await Fs3.copyFile(props.filePath, assetPath);
|
|
2006
|
-
await this.jsonFileService.create(
|
|
2007
|
-
assetFile,
|
|
2008
|
-
assetFilePath,
|
|
2009
|
-
assetFileSchema
|
|
2010
|
-
);
|
|
2011
|
-
} catch (error) {
|
|
2012
|
-
await this.delete({ ...assetFile, projectId: props.projectId });
|
|
2013
|
-
throw error;
|
|
2014
|
-
}
|
|
2015
|
-
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
2016
|
-
await this.gitService.commit(projectPath, this.gitMessage.create);
|
|
2017
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2018
|
-
}
|
|
2019
|
-
/**
|
|
2020
|
-
* Returns an Asset by ID and language
|
|
2021
|
-
*/
|
|
2022
|
-
async read(props) {
|
|
2023
|
-
readAssetSchema.parse(props);
|
|
2024
|
-
const assetFile = await this.jsonFileService.read(
|
|
2025
|
-
pathTo.assetFile(props.projectId, props.id, props.language),
|
|
2026
|
-
assetFileSchema
|
|
2027
|
-
);
|
|
2028
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2118
|
+
updated: meta[1]
|
|
2119
|
+
};
|
|
2029
2120
|
}
|
|
2030
2121
|
/**
|
|
2031
|
-
*
|
|
2122
|
+
* Reads the currently used version of Git
|
|
2032
2123
|
*
|
|
2033
|
-
*
|
|
2124
|
+
* This can help debugging
|
|
2034
2125
|
*/
|
|
2035
|
-
async
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
const assetFilePath = pathTo.assetFile(
|
|
2039
|
-
props.projectId,
|
|
2040
|
-
props.id,
|
|
2041
|
-
props.language
|
|
2042
|
-
);
|
|
2043
|
-
const prevAssetFile = await this.read(props);
|
|
2044
|
-
const assetFile = {
|
|
2045
|
-
...prevAssetFile,
|
|
2046
|
-
...props,
|
|
2047
|
-
updated: currentTimestamp()
|
|
2048
|
-
};
|
|
2049
|
-
if (props.newFilePath) {
|
|
2050
|
-
const fileType = await this.getSupportedFileTypeOrThrow(
|
|
2051
|
-
props.newFilePath
|
|
2052
|
-
);
|
|
2053
|
-
const size = await this.getAssetSize(props.newFilePath);
|
|
2054
|
-
const prevAssetPath = pathTo.asset(
|
|
2055
|
-
props.projectId,
|
|
2056
|
-
props.id,
|
|
2057
|
-
props.language,
|
|
2058
|
-
prevAssetFile.extension
|
|
2059
|
-
);
|
|
2060
|
-
const assetPath = pathTo.asset(
|
|
2061
|
-
props.projectId,
|
|
2062
|
-
props.id,
|
|
2063
|
-
props.language,
|
|
2064
|
-
fileType.extension
|
|
2065
|
-
);
|
|
2066
|
-
await Fs3.remove(prevAssetPath);
|
|
2067
|
-
await Fs3.copyFile(props.newFilePath, assetPath);
|
|
2068
|
-
assetFile.extension = fileType.extension;
|
|
2069
|
-
assetFile.mimeType = fileType.mimeType;
|
|
2070
|
-
assetFile.size = size;
|
|
2071
|
-
}
|
|
2072
|
-
await this.jsonFileService.update(
|
|
2073
|
-
assetFile,
|
|
2074
|
-
assetFilePath,
|
|
2075
|
-
assetFileSchema
|
|
2076
|
-
);
|
|
2077
|
-
await this.gitService.add(projectPath, [assetFilePath]);
|
|
2078
|
-
await this.gitService.commit(projectPath, this.gitMessage.update);
|
|
2079
|
-
return this.toAsset(props.projectId, assetFile);
|
|
2126
|
+
async updateVersion() {
|
|
2127
|
+
const result = await this.git("", ["--version"]);
|
|
2128
|
+
this.version = result.stdout.replace("git version", "").trim();
|
|
2080
2129
|
}
|
|
2081
2130
|
/**
|
|
2082
|
-
*
|
|
2131
|
+
* Reads the path to the executable of Git that is used
|
|
2132
|
+
*
|
|
2133
|
+
* This can help debugging, since dugite is shipping their own executable
|
|
2134
|
+
* but in some cases resolves another executable
|
|
2135
|
+
* @see https://github.com/desktop/dugite/blob/main/lib/git-environment.ts
|
|
2083
2136
|
*/
|
|
2084
|
-
async
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
const assetFilePath = pathTo.assetFile(
|
|
2088
|
-
props.projectId,
|
|
2089
|
-
props.id,
|
|
2090
|
-
props.language
|
|
2091
|
-
);
|
|
2092
|
-
const assetPath = pathTo.asset(
|
|
2093
|
-
props.projectId,
|
|
2094
|
-
props.id,
|
|
2095
|
-
props.language,
|
|
2096
|
-
props.extension
|
|
2097
|
-
);
|
|
2098
|
-
await Fs3.remove(assetPath);
|
|
2099
|
-
await Fs3.remove(assetFilePath);
|
|
2100
|
-
await this.gitService.add(projectPath, [assetFilePath, assetPath]);
|
|
2101
|
-
await this.gitService.commit(projectPath, this.gitMessage.delete);
|
|
2102
|
-
}
|
|
2103
|
-
async list(props) {
|
|
2104
|
-
listAssetsSchema.parse(props);
|
|
2105
|
-
const offset = props.offset || 0;
|
|
2106
|
-
const limit = props.limit || 15;
|
|
2107
|
-
const assetReferences = await this.listReferences(
|
|
2108
|
-
objectTypeSchema.Enum.asset,
|
|
2109
|
-
props.projectId
|
|
2110
|
-
);
|
|
2111
|
-
const partialAssetReferences = assetReferences.slice(offset, limit);
|
|
2112
|
-
const assets = await returnResolved(
|
|
2113
|
-
partialAssetReferences.map((assetReference) => {
|
|
2114
|
-
if (!assetReference.language) {
|
|
2115
|
-
throw new RequiredParameterMissingError("language");
|
|
2116
|
-
}
|
|
2117
|
-
return this.read({
|
|
2118
|
-
projectId: props.projectId,
|
|
2119
|
-
id: assetReference.id,
|
|
2120
|
-
language: assetReference.language
|
|
2121
|
-
});
|
|
2122
|
-
})
|
|
2123
|
-
);
|
|
2124
|
-
return {
|
|
2125
|
-
total: assetReferences.length,
|
|
2126
|
-
limit,
|
|
2127
|
-
offset,
|
|
2128
|
-
list: assets
|
|
2129
|
-
};
|
|
2137
|
+
async updateGitPath() {
|
|
2138
|
+
const result = await this.git("", ["--exec-path"]);
|
|
2139
|
+
this.gitPath = result.stdout.trim();
|
|
2130
2140
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2141
|
+
/**
|
|
2142
|
+
* A reference is used in Git to specify branches and tags.
|
|
2143
|
+
* This method checks if given name matches the required format
|
|
2144
|
+
*
|
|
2145
|
+
* @see https://git-scm.com/docs/git-check-ref-format
|
|
2146
|
+
*
|
|
2147
|
+
* @param path Path to the repository
|
|
2148
|
+
* @param name Name to check
|
|
2149
|
+
*/
|
|
2150
|
+
async checkBranchOrTagName(path, name) {
|
|
2151
|
+
await this.git(path, ["check-ref-format", "--allow-onelevel", name]);
|
|
2135
2152
|
}
|
|
2136
2153
|
/**
|
|
2137
|
-
*
|
|
2154
|
+
* Installs LFS support and starts tracking
|
|
2155
|
+
* all files inside the lfs folder
|
|
2156
|
+
*
|
|
2157
|
+
* @param path Path to the repository
|
|
2138
2158
|
*/
|
|
2139
|
-
|
|
2140
|
-
|
|
2159
|
+
async installLfs(path) {
|
|
2160
|
+
await this.git(path, ["lfs", "install"]);
|
|
2161
|
+
await this.git(path, ["lfs", "track", "lfs/*"]);
|
|
2141
2162
|
}
|
|
2142
2163
|
/**
|
|
2143
|
-
*
|
|
2164
|
+
* Sets the git config of given local repository from ElekIoCoreOptions
|
|
2144
2165
|
*
|
|
2145
|
-
* @param path Path
|
|
2166
|
+
* @param path Path to the repository
|
|
2146
2167
|
*/
|
|
2147
|
-
async
|
|
2148
|
-
|
|
2168
|
+
async setLocalConfig(path) {
|
|
2169
|
+
const user = await this.userService.get();
|
|
2170
|
+
if (!user) {
|
|
2171
|
+
throw new NoCurrentUserError();
|
|
2172
|
+
}
|
|
2173
|
+
const userNameArgs = ["config", "--local", "user.name", user.name];
|
|
2174
|
+
const userEmailArgs = ["config", "--local", "user.email", user.email];
|
|
2175
|
+
const autoSetupRemoteArgs = [
|
|
2176
|
+
"config",
|
|
2177
|
+
"--local",
|
|
2178
|
+
"push.autoSetupRemote",
|
|
2179
|
+
"true"
|
|
2180
|
+
];
|
|
2181
|
+
await this.git(path, userNameArgs);
|
|
2182
|
+
await this.git(path, userEmailArgs);
|
|
2183
|
+
await this.git(path, autoSetupRemoteArgs);
|
|
2149
2184
|
}
|
|
2150
2185
|
/**
|
|
2151
|
-
*
|
|
2186
|
+
* Type guard for GitCommit
|
|
2152
2187
|
*
|
|
2153
|
-
* @param
|
|
2154
|
-
* @param assetFile The AssetFile to convert
|
|
2188
|
+
* @param obj The object to check
|
|
2155
2189
|
*/
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
projectId,
|
|
2159
|
-
assetFile.id,
|
|
2160
|
-
assetFile.language,
|
|
2161
|
-
assetFile.extension
|
|
2162
|
-
);
|
|
2163
|
-
const asset = {
|
|
2164
|
-
...assetFile,
|
|
2165
|
-
absolutePath: assetPath
|
|
2166
|
-
};
|
|
2167
|
-
return asset;
|
|
2190
|
+
isGitCommit(obj) {
|
|
2191
|
+
return gitCommitSchema.safeParse(obj).success;
|
|
2168
2192
|
}
|
|
2169
2193
|
/**
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2194
|
+
* Wraps the execution of any git command
|
|
2195
|
+
* to use a FIFO queue for sequential processing
|
|
2172
2196
|
*
|
|
2173
|
-
* @param
|
|
2197
|
+
* @param path Path to the repository
|
|
2198
|
+
* @param args Arguments to append after the `git` command
|
|
2174
2199
|
*/
|
|
2175
|
-
async
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2200
|
+
async git(path, args) {
|
|
2201
|
+
const result = await this.queue.add(
|
|
2202
|
+
() => GitProcess.exec(args, path, {
|
|
2203
|
+
env: {
|
|
2204
|
+
// @todo Nasty stuff - remove after update to dugite with git > v2.45.2 once available
|
|
2205
|
+
// @see https://github.com/git-lfs/git-lfs/issues/5749
|
|
2206
|
+
GIT_CLONE_PROTECTION_ACTIVE: "false"
|
|
2207
|
+
}
|
|
2208
|
+
})
|
|
2209
|
+
);
|
|
2210
|
+
if (!result) {
|
|
2211
|
+
throw new GitError(
|
|
2212
|
+
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2213
|
+
" "
|
|
2214
|
+
)}" failed to return a result`
|
|
2215
|
+
);
|
|
2216
|
+
}
|
|
2217
|
+
if (result.exitCode !== 0) {
|
|
2218
|
+
throw new GitError(
|
|
2219
|
+
`Git ${this.version} (${this.gitPath}) command "git ${args.join(
|
|
2220
|
+
" "
|
|
2221
|
+
)}" failed with exit code "${result.exitCode}" and message "${result.stderr}"`
|
|
2222
|
+
);
|
|
2185
2223
|
}
|
|
2186
|
-
const { fileTypeFromFile } = await import("file-type");
|
|
2187
|
-
const fileType = await fileTypeFromFile(filePath);
|
|
2188
|
-
const result = supportedAssetTypeSchema.parse({
|
|
2189
|
-
extension: fileType?.ext,
|
|
2190
|
-
mimeType: fileType?.mime
|
|
2191
|
-
});
|
|
2192
2224
|
return result;
|
|
2193
2225
|
}
|
|
2194
2226
|
};
|
|
2195
2227
|
|
|
2196
2228
|
// src/service/CollectionService.ts
|
|
2197
|
-
import Fs4 from "fs-extra";
|
|
2198
2229
|
var CollectionService = class extends AbstractCrudService {
|
|
2199
2230
|
constructor(options, jsonFileService, gitService) {
|
|
2200
2231
|
super(serviceTypeSchema.Enum.Collection, options);
|
|
@@ -2629,16 +2660,6 @@ import Fs6 from "fs-extra";
|
|
|
2629
2660
|
import Os2 from "os";
|
|
2630
2661
|
import Path2 from "path";
|
|
2631
2662
|
import Semver from "semver";
|
|
2632
|
-
|
|
2633
|
-
// src/error/ProjectUpgradeError.ts
|
|
2634
|
-
var ProjectUpgradeError = class extends Error {
|
|
2635
|
-
constructor(message) {
|
|
2636
|
-
super(message);
|
|
2637
|
-
this.name = "ProjectUpgradeError";
|
|
2638
|
-
}
|
|
2639
|
-
};
|
|
2640
|
-
|
|
2641
|
-
// src/service/ProjectService.ts
|
|
2642
2663
|
var ProjectService = class extends AbstractCrudService {
|
|
2643
2664
|
constructor(options, jsonFileService, userService, gitService, assetService, collectionService, entryService) {
|
|
2644
2665
|
super(serviceTypeSchema.Enum.Project, options);
|
|
@@ -3021,36 +3042,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3021
3042
|
}
|
|
3022
3043
|
};
|
|
3023
3044
|
|
|
3024
|
-
// src/
|
|
3025
|
-
import { z as z12 } from "zod";
|
|
3026
|
-
var elekIoCoreOptionsSchema = z12.object({
|
|
3027
|
-
/**
|
|
3028
|
-
* The environment elek.io Core is currently running in
|
|
3029
|
-
*/
|
|
3030
|
-
environment: environmentSchema,
|
|
3031
|
-
/**
|
|
3032
|
-
* The current version of elek.io Core
|
|
3033
|
-
*/
|
|
3034
|
-
version: versionSchema,
|
|
3035
|
-
file: z12.object({
|
|
3036
|
-
json: z12.object({
|
|
3037
|
-
/**
|
|
3038
|
-
* If set, adds indentation with spaces (number) or escape character (string)
|
|
3039
|
-
* and line break characters to saved JSON files on disk, to make them easier to read.
|
|
3040
|
-
* Defaults to 2 spaces of indentation.
|
|
3041
|
-
*/
|
|
3042
|
-
indentation: z12.union([z12.number(), z12.string()])
|
|
3043
|
-
})
|
|
3044
|
-
})
|
|
3045
|
-
});
|
|
3046
|
-
var constructorElekIoCoreSchema = elekIoCoreOptionsSchema.omit({
|
|
3047
|
-
version: true
|
|
3048
|
-
}).partial({
|
|
3049
|
-
environment: true,
|
|
3050
|
-
file: true
|
|
3051
|
-
}).optional();
|
|
3052
|
-
|
|
3053
|
-
// src/index.ts
|
|
3045
|
+
// src/index.node.ts
|
|
3054
3046
|
var ElekIoCore = class {
|
|
3055
3047
|
// private readonly sharedValueService: SharedValueService;
|
|
3056
3048
|
constructor(props) {
|
|
@@ -3292,4 +3284,4 @@ export {
|
|
|
3292
3284
|
valueSchema,
|
|
3293
3285
|
versionSchema
|
|
3294
3286
|
};
|
|
3295
|
-
//# sourceMappingURL=index.js.map
|
|
3287
|
+
//# sourceMappingURL=index.node.js.map
|