@ditojs/server 2.10.1 → 2.10.3
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/package.json +5 -5
- package/src/app/Application.js +15 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/server",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/server",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node >= 18"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ditojs/admin": "^2.10.
|
|
25
|
+
"@ditojs/admin": "^2.10.3",
|
|
26
26
|
"@ditojs/build": "^2.10.0",
|
|
27
27
|
"@ditojs/router": "^2.10.0",
|
|
28
28
|
"@ditojs/utils": "^2.10.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"bytes": "^3.1.2",
|
|
38
38
|
"data-uri-to-buffer": "^5.0.1",
|
|
39
39
|
"eventemitter2": "^6.4.9",
|
|
40
|
-
"file-type": "^18.
|
|
40
|
+
"file-type": "^18.5.0",
|
|
41
41
|
"koa": "^2.14.2",
|
|
42
42
|
"koa-bodyparser": "^4.4.0",
|
|
43
43
|
"koa-compose": "^4.1.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"multer": "^1.4.5-lts.1",
|
|
56
56
|
"multer-s3": "https://github.com/ditojs/multer-s3#dito",
|
|
57
57
|
"nanoid": "^4.0.2",
|
|
58
|
-
"parse-duration": "^1.0
|
|
58
|
+
"parse-duration": "^1.1.0",
|
|
59
59
|
"passport-local": "^1.0.0",
|
|
60
60
|
"passthrough-counter": "^1.0.0",
|
|
61
61
|
"picocolors": "^1.0.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"typescript": "^5.1.3"
|
|
89
89
|
},
|
|
90
90
|
"types": "types",
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "64c92430531216d8f463835bc07c4ac8e2370bf0",
|
|
92
92
|
"scripts": {
|
|
93
93
|
"types": "tsc --noEmit --esModuleInterop ./types/index.d.ts"
|
|
94
94
|
},
|
package/src/app/Application.js
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
isModule,
|
|
27
27
|
hyphenate,
|
|
28
28
|
clone,
|
|
29
|
+
groupBy,
|
|
29
30
|
assignDeeply,
|
|
30
31
|
parseDataPath,
|
|
31
32
|
normalizeDataPath,
|
|
@@ -907,11 +908,13 @@ export class Application extends Koa {
|
|
|
907
908
|
const AssetModel = this.getModel('Asset')
|
|
908
909
|
if (AssetModel) {
|
|
909
910
|
// Find missing assets (copied from another system), and add them.
|
|
911
|
+
const filesByKey = groupBy(files, file => file.key)
|
|
910
912
|
await mapConcurrently(
|
|
911
|
-
|
|
912
|
-
async
|
|
913
|
-
const asset = await AssetModel.query(trx).findOne('key',
|
|
913
|
+
Object.entries(filesByKey),
|
|
914
|
+
async ([key, files]) => {
|
|
915
|
+
const asset = await AssetModel.query(trx).findOne('key', key)
|
|
914
916
|
if (!asset) {
|
|
917
|
+
const [file] = files // Pick the first file
|
|
915
918
|
if (file.data || file.url) {
|
|
916
919
|
let { data } = file
|
|
917
920
|
if (!data) {
|
|
@@ -946,11 +949,13 @@ export class Application extends Koa {
|
|
|
946
949
|
}
|
|
947
950
|
const importedFile = await storage.addFile(file, data)
|
|
948
951
|
await this.createAssets(storage, [importedFile], 0, trx)
|
|
949
|
-
// Merge back the changed file properties into the actual files
|
|
950
|
-
// object, so that the data from the static model hook can be used
|
|
951
|
-
// directly for the actual running query.
|
|
952
|
-
Object.assign(file, importedFile)
|
|
953
952
|
importedFiles.push(importedFile)
|
|
953
|
+
// Merge back the changed file properties into the actual file
|
|
954
|
+
// objects, so that the data from the static model hook can be
|
|
955
|
+
// used directly for the actual running query.
|
|
956
|
+
for (const file of files) {
|
|
957
|
+
Object.assign(file, importedFile)
|
|
958
|
+
}
|
|
954
959
|
} else {
|
|
955
960
|
throw new AssetError(
|
|
956
961
|
`Unable to import asset from foreign source: '${
|
|
@@ -963,7 +968,9 @@ export class Application extends Koa {
|
|
|
963
968
|
} else {
|
|
964
969
|
// Asset is from a foreign source, but was already imported and can
|
|
965
970
|
// be reused. See above for an explanation of this merge.
|
|
966
|
-
|
|
971
|
+
for (const file of files) {
|
|
972
|
+
Object.assign(file, asset.file)
|
|
973
|
+
}
|
|
967
974
|
// NOTE: No need to add `file` to `importedFiles`, since it's
|
|
968
975
|
// already been imported to the storage before.
|
|
969
976
|
}
|