@elek-io/core 0.15.2 → 0.16.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/astro/index.astro.d.mts +60 -0
- package/dist/astro/index.astro.mjs +3864 -0
- package/dist/astro/index.astro.mjs.map +1 -0
- package/dist/browser/index.browser.d.ts +172 -61
- package/dist/browser/index.browser.js +1 -1
- package/dist/browser/index.browser.js.map +1 -1
- package/dist/cli/{index.cli.js → index.cli.mjs} +304 -184
- package/dist/node/chunk-DQk6qfdC.mjs +18 -0
- package/dist/node/{index.node.d.ts → index.node.d.mts} +161 -50
- package/dist/node/{index.node.js → index.node.mjs} +134 -134
- package/dist/node/index.node.mjs.map +1 -0
- package/package.json +44 -30
- package/dist/node/chunk-Bp6m_JJh.js +0 -13
- package/dist/node/index.node.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
|
|
2
2
|
import Fs from "fs-extra";
|
|
3
3
|
import { serve } from "@hono/node-server";
|
|
4
4
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
@@ -8,13 +8,13 @@ import { cors } from "hono/cors";
|
|
|
8
8
|
import { trimTrailingSlash } from "hono/trailing-slash";
|
|
9
9
|
import { z as z$1 } from "zod";
|
|
10
10
|
import { Scalar } from "@scalar/hono-api-reference";
|
|
11
|
-
import Os from "os";
|
|
12
|
-
import Path from "path";
|
|
13
|
-
import { execFile } from "child_process";
|
|
11
|
+
import Os from "node:os";
|
|
12
|
+
import Path from "node:path";
|
|
13
|
+
import { execFile } from "node:child_process";
|
|
14
14
|
import mime from "mime";
|
|
15
15
|
import slugify from "@sindresorhus/slugify";
|
|
16
16
|
import { v4 } from "uuid";
|
|
17
|
-
import {
|
|
17
|
+
import { exec } from "dugite";
|
|
18
18
|
import PQueue from "p-queue";
|
|
19
19
|
import { createLogger, format, transports } from "winston";
|
|
20
20
|
import DailyRotateFile from "winston-daily-rotate-file";
|
|
@@ -23,24 +23,34 @@ import Semver from "semver";
|
|
|
23
23
|
//#region package.json
|
|
24
24
|
var package_default = {
|
|
25
25
|
name: "@elek-io/core",
|
|
26
|
-
version: "0.
|
|
26
|
+
version: "0.16.0",
|
|
27
27
|
description: "Handles core functionality of elek.io Projects like file IO and version control.",
|
|
28
28
|
homepage: "https://elek.io",
|
|
29
29
|
repository: "https://github.com/elek-io/core",
|
|
30
30
|
bugs: { "url": "https://github.com/elek-io/core/issues" },
|
|
31
31
|
type: "module",
|
|
32
|
-
bin: { "elek": "./dist/cli/index.cli.
|
|
33
|
-
files: [
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
bin: { "elek": "./dist/cli/index.cli.mjs" },
|
|
33
|
+
files: [
|
|
34
|
+
"dist/node",
|
|
35
|
+
"dist/browser",
|
|
36
|
+
"dist/astro"
|
|
37
|
+
],
|
|
38
|
+
exports: {
|
|
39
|
+
".": {
|
|
40
|
+
"node": { "import": {
|
|
41
|
+
"types": "./dist/node/index.node.d.mts",
|
|
42
|
+
"default": "./dist/node/index.node.mjs"
|
|
43
|
+
} },
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/browser/index.browser.d.ts",
|
|
46
|
+
"default": "./dist/browser/index.browser.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"./astro": { "import": {
|
|
50
|
+
"types": "./dist/astro/index.astro.d.mts",
|
|
51
|
+
"default": "./dist/astro/index.astro.mjs"
|
|
52
|
+
} }
|
|
53
|
+
},
|
|
44
54
|
pnpm: { "overrides": {} },
|
|
45
55
|
scripts: {
|
|
46
56
|
"lint": "eslint",
|
|
@@ -55,44 +65,49 @@ var package_default = {
|
|
|
55
65
|
},
|
|
56
66
|
dependencies: {
|
|
57
67
|
"@commander-js/extra-typings": "14.0.0",
|
|
58
|
-
"@hono/node-server": "1.19.
|
|
59
|
-
"@hono/zod-openapi": "1.
|
|
60
|
-
"@scalar/hono-api-reference": "0.
|
|
68
|
+
"@hono/node-server": "1.19.11",
|
|
69
|
+
"@hono/zod-openapi": "1.2.2",
|
|
70
|
+
"@scalar/hono-api-reference": "0.10.0",
|
|
61
71
|
"@sindresorhus/slugify": "3.0.0",
|
|
62
|
-
"chokidar": "
|
|
72
|
+
"chokidar": "5.0.0",
|
|
63
73
|
"code-block-writer": "13.0.3",
|
|
64
|
-
"commander": "14.0.
|
|
65
|
-
"fs-extra": "11.3.
|
|
66
|
-
"hono": "4.
|
|
74
|
+
"commander": "14.0.3",
|
|
75
|
+
"fs-extra": "11.3.4",
|
|
76
|
+
"hono": "4.12.5",
|
|
67
77
|
"mime": "4.1.0",
|
|
68
|
-
"p-queue": "9.
|
|
69
|
-
"semver": "7.7.
|
|
70
|
-
"tsdown": "0.
|
|
78
|
+
"p-queue": "9.1.0",
|
|
79
|
+
"semver": "7.7.4",
|
|
80
|
+
"tsdown": "0.21.0",
|
|
71
81
|
"uuid": "13.0.0",
|
|
72
|
-
"winston": "3.
|
|
82
|
+
"winston": "3.19.0",
|
|
73
83
|
"winston-daily-rotate-file": "5.0.0",
|
|
74
|
-
"zod": "4.
|
|
84
|
+
"zod": "4.3.6"
|
|
75
85
|
},
|
|
76
86
|
devDependencies: {
|
|
77
|
-
"@changesets/cli": "2.
|
|
78
|
-
"@eslint/js": "
|
|
79
|
-
"@faker-js/faker": "10.
|
|
80
|
-
"@tsconfig/
|
|
81
|
-
"@tsconfig/strictest": "2.0.
|
|
87
|
+
"@changesets/cli": "2.30.0",
|
|
88
|
+
"@eslint/js": "10.0.1",
|
|
89
|
+
"@faker-js/faker": "10.3.0",
|
|
90
|
+
"@tsconfig/node24": "24.0.4",
|
|
91
|
+
"@tsconfig/strictest": "2.0.8",
|
|
82
92
|
"@types/fs-extra": "11.0.4",
|
|
83
|
-
"@types/node": "
|
|
93
|
+
"@types/node": "24.12.0",
|
|
84
94
|
"@types/semver": "7.7.1",
|
|
85
|
-
"@vitest/coverage-v8": "4.0.
|
|
86
|
-
"
|
|
95
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
96
|
+
"astro": "5.18.0",
|
|
97
|
+
"eslint": "10.0.3",
|
|
87
98
|
"eslint-config-prettier": "10.1.8",
|
|
88
|
-
"globals": "
|
|
99
|
+
"globals": "17.4.0",
|
|
89
100
|
"jiti": "2.6.1",
|
|
90
|
-
"prettier": "3.
|
|
101
|
+
"prettier": "3.8.1",
|
|
91
102
|
"typescript": "5.9.3",
|
|
92
|
-
"typescript-eslint": "8.
|
|
93
|
-
"vitest": "4.0.
|
|
103
|
+
"typescript-eslint": "8.56.1",
|
|
104
|
+
"vitest": "4.0.18"
|
|
105
|
+
},
|
|
106
|
+
peerDependencies: {
|
|
107
|
+
"astro": ">=5.0.0",
|
|
108
|
+
"dugite": "3.2.0"
|
|
94
109
|
},
|
|
95
|
-
|
|
110
|
+
peerDependenciesMeta: { "astro": { "optional": true } }
|
|
96
111
|
};
|
|
97
112
|
|
|
98
113
|
//#endregion
|
|
@@ -102,10 +117,10 @@ var package_default = {
|
|
|
102
117
|
*/
|
|
103
118
|
const requestResponseLogger = createMiddleware(async (c, next) => {
|
|
104
119
|
const { method, url } = c.req;
|
|
105
|
-
const requestId
|
|
120
|
+
const requestId = c.get("requestId");
|
|
106
121
|
c.var.logService.info({
|
|
107
122
|
source: "core",
|
|
108
|
-
message: `Recieved API request "${method} ${url}" with requestId ${requestId
|
|
123
|
+
message: `Recieved API request "${method} ${url}" with requestId ${requestId}`
|
|
109
124
|
});
|
|
110
125
|
const start = Date.now();
|
|
111
126
|
await next();
|
|
@@ -113,7 +128,7 @@ const requestResponseLogger = createMiddleware(async (c, next) => {
|
|
|
113
128
|
const statusCode = c.res.status.toString();
|
|
114
129
|
const resultLog = {
|
|
115
130
|
source: "core",
|
|
116
|
-
message: `Response for API request "${method} ${url}" with requestId ${requestId
|
|
131
|
+
message: `Response for API request "${method} ${url}" with requestId ${requestId} and status code ${statusCode} in ${durationMs}ms`
|
|
117
132
|
};
|
|
118
133
|
if (statusCode.startsWith("2")) c.var.logService.info(resultLog);
|
|
119
134
|
else if (statusCode.startsWith("3")) c.var.logService.warn(resultLog);
|
|
@@ -223,19 +238,19 @@ const logLevelSchema = z.enum([
|
|
|
223
238
|
"debug"
|
|
224
239
|
]);
|
|
225
240
|
const versionSchema = z.string();
|
|
226
|
-
const uuidSchema = z.uuid(
|
|
241
|
+
const uuidSchema = z.uuid();
|
|
227
242
|
/**
|
|
228
243
|
* A record that can be used to translate a string value into all supported languages
|
|
229
244
|
*/
|
|
230
|
-
const translatableStringSchema = z.partialRecord(supportedLanguageSchema, z.string().trim().min(1
|
|
245
|
+
const translatableStringSchema = z.partialRecord(supportedLanguageSchema, z.string().trim().min(1));
|
|
231
246
|
/**
|
|
232
247
|
* A record that can be used to translate a number value into all supported languages
|
|
233
248
|
*/
|
|
234
|
-
const translatableNumberSchema = z.partialRecord(supportedLanguageSchema, z.number(
|
|
249
|
+
const translatableNumberSchema = z.partialRecord(supportedLanguageSchema, z.number());
|
|
235
250
|
/**
|
|
236
251
|
* A record that can be used to translate a boolean value into all supported languages
|
|
237
252
|
*/
|
|
238
|
-
const translatableBooleanSchema = z.partialRecord(supportedLanguageSchema, z.boolean(
|
|
253
|
+
const translatableBooleanSchema = z.partialRecord(supportedLanguageSchema, z.boolean());
|
|
239
254
|
function translatableArrayOf(schema) {
|
|
240
255
|
return z.partialRecord(supportedLanguageSchema, z.array(schema));
|
|
241
256
|
}
|
|
@@ -670,8 +685,8 @@ const projectBranchSchema = z.enum(["production", "work"]);
|
|
|
670
685
|
const projectFileSchema = baseFileSchema.extend({
|
|
671
686
|
objectType: z.literal(objectTypeSchema.enum.project).readonly(),
|
|
672
687
|
coreVersion: versionSchema,
|
|
673
|
-
name: z.string().trim().min(1
|
|
674
|
-
description: z.string().trim().min(1
|
|
688
|
+
name: z.string().trim().min(1),
|
|
689
|
+
description: z.string().trim().min(1),
|
|
675
690
|
version: versionSchema,
|
|
676
691
|
status: projectStatusSchema,
|
|
677
692
|
settings: projectSettingsSchema
|
|
@@ -681,11 +696,10 @@ const projectSchema = projectFileSchema.extend({
|
|
|
681
696
|
history: z.array(gitCommitSchema).openapi({ description: "Commit history of this Project" }),
|
|
682
697
|
fullHistory: z.array(gitCommitSchema).openapi({ description: "Full commit history of this Project including all Assets, Collections, Entries and other files" })
|
|
683
698
|
}).openapi("Project");
|
|
684
|
-
const
|
|
699
|
+
const migrateProjectSchema = projectFileSchema.pick({
|
|
685
700
|
id: true,
|
|
686
|
-
name: true,
|
|
687
701
|
coreVersion: true
|
|
688
|
-
});
|
|
702
|
+
}).loose();
|
|
689
703
|
const projectExportSchema = projectSchema.extend({
|
|
690
704
|
assets: z.array(assetExportSchema),
|
|
691
705
|
collections: z.array(collectionExportSchema)
|
|
@@ -694,9 +708,6 @@ const createProjectSchema = projectSchema.pick({
|
|
|
694
708
|
name: true,
|
|
695
709
|
description: true,
|
|
696
710
|
settings: true
|
|
697
|
-
}).partial({
|
|
698
|
-
description: true,
|
|
699
|
-
settings: true
|
|
700
711
|
});
|
|
701
712
|
const readProjectSchema = z.object({
|
|
702
713
|
id: uuidSchema.readonly(),
|
|
@@ -707,10 +718,6 @@ const updateProjectSchema = projectSchema.pick({
|
|
|
707
718
|
name: true,
|
|
708
719
|
description: true,
|
|
709
720
|
settings: true
|
|
710
|
-
}).partial({
|
|
711
|
-
name: true,
|
|
712
|
-
description: true,
|
|
713
|
-
settings: true
|
|
714
721
|
});
|
|
715
722
|
const upgradeProjectSchema = z.object({
|
|
716
723
|
id: uuidSchema.readonly(),
|
|
@@ -749,6 +756,12 @@ const searchProjectSchema = z.object({
|
|
|
749
756
|
//#endregion
|
|
750
757
|
//#region src/schema/schemaFromFieldDefinition.ts
|
|
751
758
|
/**
|
|
759
|
+
* Dynamic zod schema generation
|
|
760
|
+
*
|
|
761
|
+
* Altough everything is already strictly typed, a type of string might not be an email or text of a certain length.
|
|
762
|
+
* To validate this, we need to generate zod schemas based on Field definitions the user created.
|
|
763
|
+
*/
|
|
764
|
+
/**
|
|
752
765
|
* Boolean Values are always either true or false, so we don't need the Field definition here
|
|
753
766
|
*/
|
|
754
767
|
function getBooleanValueContentSchemaFromFieldDefinition() {
|
|
@@ -800,7 +813,7 @@ function getStringValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
|
800
813
|
if ("min" in fieldDefinition && fieldDefinition.min) schema = schema.min(fieldDefinition.min);
|
|
801
814
|
if ("max" in fieldDefinition && fieldDefinition.max) schema = schema.max(fieldDefinition.max);
|
|
802
815
|
if (fieldDefinition.isRequired === false) return schema.nullable();
|
|
803
|
-
return schema.min(1
|
|
816
|
+
return schema.min(1);
|
|
804
817
|
}
|
|
805
818
|
/**
|
|
806
819
|
* Reference Values can reference either Assets or Entries (or Shared Values in the future)
|
|
@@ -816,7 +829,7 @@ function getReferenceValueContentSchemaFromFieldDefinition(fieldDefinition) {
|
|
|
816
829
|
schema = z.array(valueContentReferenceToEntrySchema);
|
|
817
830
|
break;
|
|
818
831
|
}
|
|
819
|
-
if (fieldDefinition.isRequired) schema = schema.min(1
|
|
832
|
+
if (fieldDefinition.isRequired) schema = schema.min(1);
|
|
820
833
|
if (fieldDefinition.min) schema = schema.min(fieldDefinition.min);
|
|
821
834
|
if (fieldDefinition.max) schema = schema.max(fieldDefinition.max);
|
|
822
835
|
return schema;
|
|
@@ -961,7 +974,7 @@ const projectsSchema = z$1.string().default("all").transform((value) => {
|
|
|
961
974
|
return value.split(",").map((v) => uuidSchema.parse(v.trim()));
|
|
962
975
|
});
|
|
963
976
|
const generateApiClientOptionsSchema = z$1.object({ watch: z$1.boolean().default(false) });
|
|
964
|
-
const exportProjectsOptionsSchema = generateApiClientOptionsSchema.extend({
|
|
977
|
+
const exportProjectsOptionsSchema = generateApiClientOptionsSchema.extend({ watch: z$1.boolean().default(false) });
|
|
965
978
|
const generateApiClientSchema = z$1.object({
|
|
966
979
|
outDir: outDirSchema,
|
|
967
980
|
language: languageSchema,
|
|
@@ -985,6 +998,7 @@ const apiStartSchema = z$1.object({ port: portSchema });
|
|
|
985
998
|
const exportSchema = z$1.object({
|
|
986
999
|
outDir: outDirSchema,
|
|
987
1000
|
projects: projectsSchema,
|
|
1001
|
+
template: z$1.enum(["nested", "separate"]).default("nested"),
|
|
988
1002
|
options: exportProjectsOptionsSchema
|
|
989
1003
|
});
|
|
990
1004
|
|
|
@@ -1063,7 +1077,6 @@ const router$6 = createRouter().openapi(createRoute({
|
|
|
1063
1077
|
const project = await c.var.projectService.read({ id: projectId });
|
|
1064
1078
|
return c.json(project, 200);
|
|
1065
1079
|
});
|
|
1066
|
-
var projects_default = router$6;
|
|
1067
1080
|
|
|
1068
1081
|
//#endregion
|
|
1069
1082
|
//#region src/api/routes/content/v1/collections.ts
|
|
@@ -1149,7 +1162,6 @@ const router$5 = createRouter().openapi(createRoute({
|
|
|
1149
1162
|
});
|
|
1150
1163
|
return c.json(collection, 200);
|
|
1151
1164
|
});
|
|
1152
|
-
var collections_default = router$5;
|
|
1153
1165
|
|
|
1154
1166
|
//#endregion
|
|
1155
1167
|
//#region src/api/routes/content/v1/entries.ts
|
|
@@ -1256,7 +1268,6 @@ const router$4 = createRouter().openapi(createRoute({
|
|
|
1256
1268
|
});
|
|
1257
1269
|
return c.json(entry, 200);
|
|
1258
1270
|
});
|
|
1259
|
-
var entries_default = router$4;
|
|
1260
1271
|
|
|
1261
1272
|
//#endregion
|
|
1262
1273
|
//#region src/api/routes/content/v1/assets.ts
|
|
@@ -1342,22 +1353,18 @@ const router$3 = createRouter().openapi(createRoute({
|
|
|
1342
1353
|
});
|
|
1343
1354
|
return c.json(asset, 200);
|
|
1344
1355
|
});
|
|
1345
|
-
var assets_default = router$3;
|
|
1346
1356
|
|
|
1347
1357
|
//#endregion
|
|
1348
1358
|
//#region src/api/routes/content/v1/index.ts
|
|
1349
|
-
const router$2 = createRouter().route("/projects",
|
|
1350
|
-
var v1_default = router$2;
|
|
1359
|
+
const router$2 = createRouter().route("/projects", router$6).route("/projects", router$5).route("/projects", router$4).route("/projects", router$3);
|
|
1351
1360
|
|
|
1352
1361
|
//#endregion
|
|
1353
1362
|
//#region src/api/routes/content/index.ts
|
|
1354
|
-
const router$1 = createRouter().route("/v1",
|
|
1355
|
-
var content_default = router$1;
|
|
1363
|
+
const router$1 = createRouter().route("/v1", router$2);
|
|
1356
1364
|
|
|
1357
1365
|
//#endregion
|
|
1358
1366
|
//#region src/api/routes/index.ts
|
|
1359
|
-
const router = createRouter().route("/content",
|
|
1360
|
-
var routes_default = router;
|
|
1367
|
+
const router = createRouter().route("/content", router$1);
|
|
1361
1368
|
|
|
1362
1369
|
//#endregion
|
|
1363
1370
|
//#region src/api/index.ts
|
|
@@ -1375,7 +1382,7 @@ var LocalApi = class {
|
|
|
1375
1382
|
this.collectionService = collectionService;
|
|
1376
1383
|
this.entryService = entryService;
|
|
1377
1384
|
this.assetService = assetService;
|
|
1378
|
-
this.api = createApi(this.logService, this.projectService, this.collectionService, this.entryService, this.assetService).route("/",
|
|
1385
|
+
this.api = createApi(this.logService, this.projectService, this.collectionService, this.entryService, this.assetService).route("/", router).doc("/openapi.json", {
|
|
1379
1386
|
openapi: "3.0.0",
|
|
1380
1387
|
externalDocs: { url: "https://elek.io/docs" },
|
|
1381
1388
|
info: {
|
|
@@ -1479,7 +1486,7 @@ var RequiredParameterMissingError = class extends Error {
|
|
|
1479
1486
|
|
|
1480
1487
|
//#endregion
|
|
1481
1488
|
//#region src/util/node.ts
|
|
1482
|
-
var node_exports = /* @__PURE__ */
|
|
1489
|
+
var node_exports = /* @__PURE__ */ __exportAll({
|
|
1483
1490
|
execCommand: () => execCommand,
|
|
1484
1491
|
files: () => files,
|
|
1485
1492
|
folders: () => folders,
|
|
@@ -1646,8 +1653,8 @@ var AbstractCrudService = class {
|
|
|
1646
1653
|
/**
|
|
1647
1654
|
* Do not instantiate directly as this is an abstract class
|
|
1648
1655
|
*/
|
|
1649
|
-
constructor(type
|
|
1650
|
-
this.type = type
|
|
1656
|
+
constructor(type, options, logService) {
|
|
1657
|
+
this.type = type;
|
|
1651
1658
|
this.options = options;
|
|
1652
1659
|
this.logService = logService;
|
|
1653
1660
|
}
|
|
@@ -1683,8 +1690,8 @@ var AbstractCrudService = class {
|
|
|
1683
1690
|
* @param projectId Project to get all asset references from
|
|
1684
1691
|
* @param collectionId Only needed when requesting files of type "Entry"
|
|
1685
1692
|
*/
|
|
1686
|
-
async listReferences(type
|
|
1687
|
-
switch (type
|
|
1693
|
+
async listReferences(type, projectId, collectionId) {
|
|
1694
|
+
switch (type) {
|
|
1688
1695
|
case objectTypeSchema.enum.asset:
|
|
1689
1696
|
if (!projectId) throw new RequiredParameterMissingError("projectId");
|
|
1690
1697
|
return this.getFileReferences(pathTo.lfs(projectId));
|
|
@@ -1699,7 +1706,7 @@ var AbstractCrudService = class {
|
|
|
1699
1706
|
case objectTypeSchema.enum.sharedValue:
|
|
1700
1707
|
if (!projectId) throw new RequiredParameterMissingError("projectId");
|
|
1701
1708
|
return this.getFileReferences(pathTo.sharedValues(projectId));
|
|
1702
|
-
default: throw new Error(`Trying to list files of unsupported type "${type
|
|
1709
|
+
default: throw new Error(`Trying to list files of unsupported type "${type}"`);
|
|
1703
1710
|
}
|
|
1704
1711
|
}
|
|
1705
1712
|
async getFolderReferences(path) {
|
|
@@ -1919,9 +1926,9 @@ var AssetService = class extends AbstractCrudService {
|
|
|
1919
1926
|
async list(props) {
|
|
1920
1927
|
listAssetsSchema.parse(props);
|
|
1921
1928
|
const offset = props.offset || 0;
|
|
1922
|
-
const limit = props.limit
|
|
1929
|
+
const limit = props.limit ?? 15;
|
|
1923
1930
|
const assetReferences = await this.listReferences(objectTypeSchema.enum.asset, props.projectId);
|
|
1924
|
-
const partialAssetReferences = assetReferences.slice(offset, limit);
|
|
1931
|
+
const partialAssetReferences = limit === 0 ? assetReferences.slice(offset) : assetReferences.slice(offset, offset + limit);
|
|
1925
1932
|
const assets = await this.returnResolved(partialAssetReferences.map((assetReference) => {
|
|
1926
1933
|
return this.read({
|
|
1927
1934
|
projectId: props.projectId,
|
|
@@ -2104,9 +2111,9 @@ var CollectionService = class extends AbstractCrudService {
|
|
|
2104
2111
|
async list(props) {
|
|
2105
2112
|
listCollectionsSchema.parse(props);
|
|
2106
2113
|
const offset = props.offset || 0;
|
|
2107
|
-
const limit = props.limit
|
|
2114
|
+
const limit = props.limit ?? 15;
|
|
2108
2115
|
const collectionReferences = await this.listReferences(objectTypeSchema.enum.collection, props.projectId);
|
|
2109
|
-
const partialCollectionReferences = collectionReferences.slice(offset, limit);
|
|
2116
|
+
const partialCollectionReferences = limit === 0 ? collectionReferences.slice(offset) : collectionReferences.slice(offset, offset + limit);
|
|
2110
2117
|
const collections = await this.returnResolved(partialCollectionReferences.map((reference) => {
|
|
2111
2118
|
return this.read({
|
|
2112
2119
|
projectId: props.projectId,
|
|
@@ -2269,9 +2276,9 @@ var EntryService = class extends AbstractCrudService {
|
|
|
2269
2276
|
async list(props) {
|
|
2270
2277
|
listEntriesSchema.parse(props);
|
|
2271
2278
|
const offset = props.offset || 0;
|
|
2272
|
-
const limit = props.limit
|
|
2279
|
+
const limit = props.limit ?? 15;
|
|
2273
2280
|
const entryReferences = await this.listReferences(objectTypeSchema.enum.entry, props.projectId, props.collectionId);
|
|
2274
|
-
const partialEntryReferences = entryReferences.slice(offset, limit);
|
|
2281
|
+
const partialEntryReferences = limit === 0 ? entryReferences.slice(offset) : entryReferences.slice(offset, offset + limit);
|
|
2275
2282
|
const entries = await this.returnResolved(partialEntryReferences.map((reference) => {
|
|
2276
2283
|
return this.read({
|
|
2277
2284
|
projectId: props.projectId,
|
|
@@ -2357,8 +2364,8 @@ var GitTagService = class extends AbstractCrudService {
|
|
|
2357
2364
|
*/
|
|
2358
2365
|
async read(props) {
|
|
2359
2366
|
readGitTagSchema.parse(props);
|
|
2360
|
-
const tag = (await this.list({ path: props.path })).list.find((tag
|
|
2361
|
-
return tag
|
|
2367
|
+
const tag = (await this.list({ path: props.path })).list.find((tag) => {
|
|
2368
|
+
return tag.id === props.id;
|
|
2362
2369
|
});
|
|
2363
2370
|
if (!tag) throw new GitError(`Provided tag with UUID "${props.id}" did not match any known tags`);
|
|
2364
2371
|
return tag;
|
|
@@ -2549,11 +2556,11 @@ var GitService = class {
|
|
|
2549
2556
|
* @param path Path to the repository
|
|
2550
2557
|
* @param files Files to add
|
|
2551
2558
|
*/
|
|
2552
|
-
async add(path, files
|
|
2559
|
+
async add(path, files) {
|
|
2553
2560
|
const args = [
|
|
2554
2561
|
"add",
|
|
2555
2562
|
"--",
|
|
2556
|
-
...files
|
|
2563
|
+
...files.map((filePath) => {
|
|
2557
2564
|
return filePath.replace(`${path}${Path.sep}`, "");
|
|
2558
2565
|
})
|
|
2559
2566
|
];
|
|
@@ -2827,11 +2834,11 @@ var GitService = class {
|
|
|
2827
2834
|
* @param path Path to the repository
|
|
2828
2835
|
* @param name Name to check
|
|
2829
2836
|
*/
|
|
2830
|
-
async checkBranchOrTagName(path, name
|
|
2837
|
+
async checkBranchOrTagName(path, name) {
|
|
2831
2838
|
await this.git(path, [
|
|
2832
2839
|
"check-ref-format",
|
|
2833
2840
|
"--allow-onelevel",
|
|
2834
|
-
name
|
|
2841
|
+
name
|
|
2835
2842
|
]);
|
|
2836
2843
|
}
|
|
2837
2844
|
/**
|
|
@@ -2890,7 +2897,7 @@ var GitService = class {
|
|
|
2890
2897
|
const result = await this.queue.add(async () => {
|
|
2891
2898
|
const start = Date.now();
|
|
2892
2899
|
return {
|
|
2893
|
-
gitResult: await
|
|
2900
|
+
gitResult: await exec(args, path, options),
|
|
2894
2901
|
durationMs: Date.now() - start
|
|
2895
2902
|
};
|
|
2896
2903
|
});
|
|
@@ -2902,8 +2909,12 @@ var GitService = class {
|
|
|
2902
2909
|
};
|
|
2903
2910
|
if (result.durationMs >= 100) this.logService.warn(gitLog);
|
|
2904
2911
|
else this.logService.debug(gitLog);
|
|
2905
|
-
if (result.gitResult.exitCode !== 0) throw new GitError(`Git ${this.version} (${this.gitPath}) command "git ${args.join(" ")}" executed for "${path}" failed with exit code "${result.gitResult.exitCode}" and message "${result.gitResult.stderr.trim() || result.gitResult.stdout.trim()}"`);
|
|
2906
|
-
return
|
|
2912
|
+
if (result.gitResult.exitCode !== 0) throw new GitError(`Git ${this.version} (${this.gitPath}) command "git ${args.join(" ")}" executed for "${path}" failed with exit code "${result.gitResult.exitCode}" and message "${result.gitResult.stderr.toString().trim() || result.gitResult.stdout.toString().trim()}"`);
|
|
2913
|
+
return {
|
|
2914
|
+
...result.gitResult,
|
|
2915
|
+
stdout: result.gitResult.stdout.toString(),
|
|
2916
|
+
stderr: result.gitResult.stderr.toString()
|
|
2917
|
+
};
|
|
2907
2918
|
}
|
|
2908
2919
|
};
|
|
2909
2920
|
|
|
@@ -2952,8 +2963,8 @@ var JsonFileService = class extends AbstractCrudService {
|
|
|
2952
2963
|
source: "core",
|
|
2953
2964
|
message: `Cache hit reading file "${path}"`
|
|
2954
2965
|
});
|
|
2955
|
-
const json
|
|
2956
|
-
return schema.parse(json
|
|
2966
|
+
const json = this.cache.get(path);
|
|
2967
|
+
return schema.parse(json);
|
|
2957
2968
|
}
|
|
2958
2969
|
this.logService.debug({
|
|
2959
2970
|
source: "core",
|
|
@@ -3058,13 +3069,18 @@ var LogService = class {
|
|
|
3058
3069
|
handleExceptions: true,
|
|
3059
3070
|
handleRejections: true,
|
|
3060
3071
|
format: format.combine(format.colorize(), format.timestamp({ format: "HH:mm:ss" }), format.printf((props) => {
|
|
3061
|
-
const
|
|
3062
|
-
|
|
3072
|
+
const splatArgs = props[Symbol.for("splat")];
|
|
3073
|
+
const result = logConsoleTransportSchema.safeParse({
|
|
3074
|
+
...splatArgs?.[0] ?? {},
|
|
3063
3075
|
timestamp: props["timestamp"],
|
|
3064
3076
|
level: props.level,
|
|
3065
3077
|
message: props.message
|
|
3066
3078
|
});
|
|
3067
|
-
|
|
3079
|
+
if (result.success) {
|
|
3080
|
+
const { timestamp, level, source, message } = result.data;
|
|
3081
|
+
return `${timestamp} [${source}] ${level}: ${message}`;
|
|
3082
|
+
}
|
|
3083
|
+
return `${String(props["timestamp"])} ${props.level}: ${String(props.message)}`;
|
|
3068
3084
|
}))
|
|
3069
3085
|
});
|
|
3070
3086
|
this.logger = createLogger({
|
|
@@ -3128,16 +3144,14 @@ var SynchronizeLocalChangesError = class extends Error {
|
|
|
3128
3144
|
var ProjectService = class extends AbstractCrudService {
|
|
3129
3145
|
coreVersion;
|
|
3130
3146
|
jsonFileService;
|
|
3131
|
-
userService;
|
|
3132
3147
|
gitService;
|
|
3133
3148
|
assetService;
|
|
3134
3149
|
collectionService;
|
|
3135
3150
|
entryService;
|
|
3136
|
-
constructor(coreVersion, options, logService, jsonFileService,
|
|
3151
|
+
constructor(coreVersion, options, logService, jsonFileService, gitService, assetService, collectionService, entryService) {
|
|
3137
3152
|
super(serviceTypeSchema.enum.Project, options, logService);
|
|
3138
3153
|
this.coreVersion = coreVersion;
|
|
3139
3154
|
this.jsonFileService = jsonFileService;
|
|
3140
|
-
this.userService = userService;
|
|
3141
3155
|
this.gitService = gitService;
|
|
3142
3156
|
this.assetService = assetService;
|
|
3143
3157
|
this.collectionService = collectionService;
|
|
@@ -3148,19 +3162,11 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3148
3162
|
*/
|
|
3149
3163
|
async create(props) {
|
|
3150
3164
|
createProjectSchema.parse(props);
|
|
3151
|
-
const user = await this.userService.get();
|
|
3152
|
-
if (!user) throw new NoCurrentUserError();
|
|
3153
3165
|
const id = uuid();
|
|
3154
|
-
const defaultSettings = { language: {
|
|
3155
|
-
default: user.language,
|
|
3156
|
-
supported: [user.language]
|
|
3157
|
-
} };
|
|
3158
3166
|
const projectFile = {
|
|
3159
3167
|
...props,
|
|
3160
3168
|
objectType: "project",
|
|
3161
3169
|
id,
|
|
3162
|
-
description: props.description || "",
|
|
3163
|
-
settings: Object.assign({}, defaultSettings, props.settings),
|
|
3164
3170
|
created: datetime(),
|
|
3165
3171
|
updated: null,
|
|
3166
3172
|
coreVersion: this.coreVersion,
|
|
@@ -3218,7 +3224,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3218
3224
|
const projectFile = await this.jsonFileService.read(pathTo.projectFile(props.id), projectFileSchema);
|
|
3219
3225
|
return await this.toProject(projectFile);
|
|
3220
3226
|
} else {
|
|
3221
|
-
const projectFile = this.migrate(JSON.parse(await this.gitService.getFileContentAtCommit(pathTo.project(props.id), pathTo.projectFile(props.id), props.commitHash)));
|
|
3227
|
+
const projectFile = this.migrate(migrateProjectSchema.parse(JSON.parse(await this.gitService.getFileContentAtCommit(pathTo.project(props.id), pathTo.projectFile(props.id), props.commitHash))));
|
|
3222
3228
|
return await this.toProject(projectFile);
|
|
3223
3229
|
}
|
|
3224
3230
|
}
|
|
@@ -3229,16 +3235,9 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3229
3235
|
updateProjectSchema.parse(props);
|
|
3230
3236
|
const projectPath = pathTo.project(props.id);
|
|
3231
3237
|
const filePath = pathTo.projectFile(props.id);
|
|
3232
|
-
const prevProjectFile = await this.read(props);
|
|
3233
3238
|
const projectFile = {
|
|
3234
|
-
...
|
|
3235
|
-
|
|
3236
|
-
description: props.description || prevProjectFile.description,
|
|
3237
|
-
coreVersion: this.coreVersion,
|
|
3238
|
-
settings: { language: {
|
|
3239
|
-
supported: props.settings?.language.supported || prevProjectFile.settings.language.supported,
|
|
3240
|
-
default: props.settings?.language.default || prevProjectFile.settings.language.default
|
|
3241
|
-
} },
|
|
3239
|
+
...await this.read(props),
|
|
3240
|
+
...props,
|
|
3242
3241
|
updated: datetime()
|
|
3243
3242
|
};
|
|
3244
3243
|
await this.jsonFileService.update(projectFile, filePath, projectFileSchema);
|
|
@@ -3262,7 +3261,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3262
3261
|
const projectPath = pathTo.project(props.id);
|
|
3263
3262
|
const projectFilePath = pathTo.projectFile(props.id);
|
|
3264
3263
|
if (await this.gitService.branches.current(projectPath) !== projectBranchSchema.enum.work) await this.gitService.branches.switch(projectPath, projectBranchSchema.enum.work);
|
|
3265
|
-
const currentProjectFile =
|
|
3264
|
+
const currentProjectFile = migrateProjectSchema.parse(await this.jsonFileService.unsafeRead(projectFilePath));
|
|
3266
3265
|
if (Semver.gt(currentProjectFile.coreVersion, this.coreVersion)) throw new ProjectUpgradeError(`The Projects Core version "${currentProjectFile.coreVersion}" is higher than the current Core version "${this.coreVersion}".`);
|
|
3267
3266
|
if (Semver.eq(currentProjectFile.coreVersion, this.coreVersion) && props.force !== true) throw new ProjectUpgradeError(`The Projects Core version "${currentProjectFile.coreVersion}" is already up to date.`);
|
|
3268
3267
|
const assetReferences = await this.listReferences("asset", props.id);
|
|
@@ -3404,7 +3403,7 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3404
3403
|
const projectReferences = await this.listReferences(objectTypeSchema.enum.project);
|
|
3405
3404
|
return (await Promise.all(projectReferences.map(async (reference) => {
|
|
3406
3405
|
const json = await this.jsonFileService.unsafeRead(pathTo.projectFile(reference.id));
|
|
3407
|
-
const projectFile =
|
|
3406
|
+
const projectFile = migrateProjectSchema.parse(json);
|
|
3408
3407
|
if (projectFile.coreVersion !== this.coreVersion) return projectFile;
|
|
3409
3408
|
return null;
|
|
3410
3409
|
}))).filter(isNotEmpty);
|
|
@@ -3412,9 +3411,9 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3412
3411
|
async list(props) {
|
|
3413
3412
|
if (props) listProjectsSchema.parse(props);
|
|
3414
3413
|
const offset = props?.offset || 0;
|
|
3415
|
-
const limit = props?.limit
|
|
3414
|
+
const limit = props?.limit ?? 15;
|
|
3416
3415
|
const projectReferences = await this.listReferences(objectTypeSchema.enum.project);
|
|
3417
|
-
const partialProjectReferences = projectReferences.slice(offset, limit);
|
|
3416
|
+
const partialProjectReferences = limit === 0 ? projectReferences.slice(offset) : projectReferences.slice(offset, offset + limit);
|
|
3418
3417
|
const projects = await this.returnResolved(partialProjectReferences.map((reference) => {
|
|
3419
3418
|
return this.read({ id: reference.id });
|
|
3420
3419
|
}));
|
|
@@ -3437,8 +3436,9 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3437
3436
|
/**
|
|
3438
3437
|
* Migrates an potentially outdated Project file to the current schema
|
|
3439
3438
|
*/
|
|
3440
|
-
migrate(
|
|
3441
|
-
|
|
3439
|
+
migrate(props) {
|
|
3440
|
+
props.coreVersion = this.coreVersion;
|
|
3441
|
+
return projectFileSchema.parse(props);
|
|
3442
3442
|
}
|
|
3443
3443
|
/**
|
|
3444
3444
|
* Creates a Project from given ProjectFile
|
|
@@ -3462,8 +3462,8 @@ var ProjectService = class extends AbstractCrudService {
|
|
|
3462
3462
|
* committed
|
|
3463
3463
|
*/
|
|
3464
3464
|
async createFolderStructure(path) {
|
|
3465
|
-
const folders
|
|
3466
|
-
await Promise.all(folders
|
|
3465
|
+
const folders = Object.values(projectFolderSchema.enum);
|
|
3466
|
+
await Promise.all(folders.map(async (folder) => {
|
|
3467
3467
|
await Fs.mkdirp(Path.join(path, folder));
|
|
3468
3468
|
await Fs.writeFile(Path.join(path, folder, ".gitkeep"), "");
|
|
3469
3469
|
}));
|
|
@@ -3627,7 +3627,7 @@ var ElekIoCore = class {
|
|
|
3627
3627
|
this.assetService = new AssetService(this.options, this.logService, this.jsonFileService, this.gitService);
|
|
3628
3628
|
this.collectionService = new CollectionService(this.options, this.logService, this.jsonFileService, this.gitService);
|
|
3629
3629
|
this.entryService = new EntryService(this.options, this.logService, this.jsonFileService, this.gitService, this.collectionService);
|
|
3630
|
-
this.projectService = new ProjectService(this.coreVersion, this.options, this.logService, this.jsonFileService, this.
|
|
3630
|
+
this.projectService = new ProjectService(this.coreVersion, this.options, this.logService, this.jsonFileService, this.gitService, this.assetService, this.collectionService, this.entryService);
|
|
3631
3631
|
this.localApi = new LocalApi(this.logService, this.projectService, this.collectionService, this.entryService, this.assetService);
|
|
3632
3632
|
this.logService.info({
|
|
3633
3633
|
source: "core",
|
|
@@ -3696,5 +3696,5 @@ var ElekIoCore = class {
|
|
|
3696
3696
|
};
|
|
3697
3697
|
|
|
3698
3698
|
//#endregion
|
|
3699
|
-
export { BooleanFieldDefinitionBaseSchema, FieldDefinitionBaseSchema, FieldTypeSchema, FieldWidthSchema, NumberFieldDefinitionBaseSchema, ReferenceFieldDefinitionBaseSchema, StringFieldDefinitionBaseSchema, UserTypeSchema, ValueTypeSchema, apiStartSchema, assetExportSchema, assetFieldDefinitionSchema, assetFileSchema, assetSchema, baseFileSchema, baseUserSchema, cloneProjectSchema, cloudUserSchema, collectionExportSchema, collectionFileSchema, collectionSchema, constructorElekIoCoreSchema, countAssetsSchema, countCollectionsSchema, countEntriesSchema, countGitTagsSchema, createAssetSchema, createCollectionSchema, createEntrySchema, createGitTagSchema, createProjectSchema, currentBranchProjectSchema, dateFieldDefinitionSchema, datetime, datetimeFieldDefinitionSchema, ElekIoCore as default, deleteAssetSchema, deleteCollectionSchema, deleteEntrySchema, deleteGitTagSchema, deleteProjectSchema, directBooleanValueSchema, directNumberValueSchema, directStringValueSchema, directValueBaseSchema, directValueSchema, elekIoCoreOptionsSchema, emailFieldDefinitionSchema, entryExportSchema, entryFieldDefinitionSchema, entryFileSchema, entrySchema, exportSchema, fieldDefinitionSchema, fileReferenceSchema, generateApiClientSchema, getChangesProjectSchema, getCreateEntrySchemaFromFieldDefinitions, getEntrySchemaFromFieldDefinitions, getRemoteOriginUrlProjectSchema, getUpdateEntrySchemaFromFieldDefinitions, getValueSchemaFromFieldDefinition, gitCloneOptionsSchema, gitCommitSchema, gitInitOptionsSchema, gitLogOptionsSchema, gitMergeOptionsSchema, gitMessageSchema, gitSignatureSchema, gitSwitchOptionsSchema, gitTagSchema, ipv4FieldDefinitionSchema, listAssetsSchema, listBranchesProjectSchema, listCollectionsSchema, listEntriesSchema, listGitTagsSchema, listProjectsSchema, localUserSchema, logConsoleTransportSchema, logLevelSchema, logSchema, logSourceSchema, numberFieldDefinitionSchema, objectTypeSchema,
|
|
3700
|
-
//# sourceMappingURL=index.node.
|
|
3699
|
+
export { BooleanFieldDefinitionBaseSchema, FieldDefinitionBaseSchema, FieldTypeSchema, FieldWidthSchema, NumberFieldDefinitionBaseSchema, ReferenceFieldDefinitionBaseSchema, StringFieldDefinitionBaseSchema, UserTypeSchema, ValueTypeSchema, apiStartSchema, assetExportSchema, assetFieldDefinitionSchema, assetFileSchema, assetSchema, baseFileSchema, baseUserSchema, cloneProjectSchema, cloudUserSchema, collectionExportSchema, collectionFileSchema, collectionSchema, constructorElekIoCoreSchema, countAssetsSchema, countCollectionsSchema, countEntriesSchema, countGitTagsSchema, createAssetSchema, createCollectionSchema, createEntrySchema, createGitTagSchema, createProjectSchema, currentBranchProjectSchema, dateFieldDefinitionSchema, datetime, datetimeFieldDefinitionSchema, ElekIoCore as default, deleteAssetSchema, deleteCollectionSchema, deleteEntrySchema, deleteGitTagSchema, deleteProjectSchema, directBooleanValueSchema, directNumberValueSchema, directStringValueSchema, directValueBaseSchema, directValueSchema, elekIoCoreOptionsSchema, emailFieldDefinitionSchema, entryExportSchema, entryFieldDefinitionSchema, entryFileSchema, entrySchema, exportSchema, fieldDefinitionSchema, fileReferenceSchema, generateApiClientSchema, getChangesProjectSchema, getCreateEntrySchemaFromFieldDefinitions, getEntrySchemaFromFieldDefinitions, getRemoteOriginUrlProjectSchema, getTranslatableBooleanValueContentSchemaFromFieldDefinition, getTranslatableNumberValueContentSchemaFromFieldDefinition, getTranslatableReferenceValueContentSchemaFromFieldDefinition, getTranslatableStringValueContentSchemaFromFieldDefinition, getUpdateEntrySchemaFromFieldDefinitions, getValueSchemaFromFieldDefinition, gitCloneOptionsSchema, gitCommitSchema, gitInitOptionsSchema, gitLogOptionsSchema, gitMergeOptionsSchema, gitMessageSchema, gitSignatureSchema, gitSwitchOptionsSchema, gitTagSchema, ipv4FieldDefinitionSchema, listAssetsSchema, listBranchesProjectSchema, listCollectionsSchema, listEntriesSchema, listGitTagsSchema, listProjectsSchema, localUserSchema, logConsoleTransportSchema, logLevelSchema, logSchema, logSourceSchema, migrateProjectSchema, numberFieldDefinitionSchema, objectTypeSchema, paginatedListOf, projectBranchSchema, projectExportSchema, projectFileSchema, projectFolderSchema, projectSchema, projectSettingsSchema, projectStatusSchema, projectUpgradeSchema, rangeFieldDefinitionSchema, readAssetSchema, readCollectionSchema, readEntrySchema, readGitTagSchema, readProjectSchema, referencedValueSchema, saveAssetSchema, searchProjectSchema, serviceTypeSchema, setRemoteOriginUrlProjectSchema, setUserSchema, slug, stringFieldDefinitionSchema, supportedIconSchema, supportedLanguageSchema, switchBranchProjectSchema, synchronizeProjectSchema, telephoneFieldDefinitionSchema, textFieldDefinitionSchema, textareaFieldDefinitionSchema, timeFieldDefinitionSchema, toggleFieldDefinitionSchema, translatableArrayOf, translatableBooleanSchema, translatableNumberSchema, translatableStringSchema, updateAssetSchema, updateCollectionSchema, updateEntrySchema, updateProjectSchema, upgradeProjectSchema, urlFieldDefinitionSchema, userFileSchema, userSchema, uuid, uuidSchema, valueContentReferenceBase, valueContentReferenceSchema, valueContentReferenceToAssetSchema, valueContentReferenceToCollectionSchema, valueContentReferenceToEntrySchema, valueSchema, versionSchema };
|
|
3700
|
+
//# sourceMappingURL=index.node.mjs.map
|