@radio-garden/ditojs-server 2.91.0-2.566eca6ca → 2.92.0-1.79f40ebcd
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 +11 -11
- package/src/app/Application.js +1 -1
- package/src/controllers/AdminController.js +5 -2
- package/src/models/Model.js +15 -43
- package/types/index.d.ts +14 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radio-garden/ditojs-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.92.0-1.79f40ebcd",
|
|
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/main/packages/server",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"bytes": "^3.1.2",
|
|
33
33
|
"data-uri-to-buffer": "^7.0.0",
|
|
34
34
|
"eventemitter2": "^6.4.9",
|
|
35
|
-
"file-type": "^21.3.
|
|
35
|
+
"file-type": "^21.3.3",
|
|
36
36
|
"helmet": "^8.1.0",
|
|
37
37
|
"koa": "^3.1.2",
|
|
38
38
|
"koa-bodyparser": "^4.4.1",
|
|
39
39
|
"koa-compose": "^4.1.0",
|
|
40
|
-
"koa-compress": "^5.2.
|
|
40
|
+
"koa-compress": "^5.2.1",
|
|
41
41
|
"koa-conditional-get": "^3.0.0",
|
|
42
42
|
"koa-helmet": "^9.0.0",
|
|
43
43
|
"koa-mount": "^4.2.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"mime-types": "^3.0.2",
|
|
50
50
|
"multer": "^2.1.1",
|
|
51
51
|
"multer-s3": "github:ditojs/multer-s3#dito",
|
|
52
|
-
"nanoid": "^5.1.
|
|
52
|
+
"nanoid": "^5.1.7",
|
|
53
53
|
"parse-duration": "^2.1.5",
|
|
54
54
|
"passport-local": "^1.0.0",
|
|
55
55
|
"passthrough-counter": "^1.0.0",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"repl": "^0.1.3",
|
|
62
62
|
"type-fest": "^5.4.4",
|
|
63
63
|
"uuid": "^13.0.0",
|
|
64
|
-
"@ditojs/admin": "
|
|
65
|
-
"@ditojs/build": "
|
|
66
|
-
"@ditojs/utils": "
|
|
67
|
-
"@ditojs/router": "
|
|
64
|
+
"@ditojs/admin": "^2.92.0",
|
|
65
|
+
"@ditojs/build": "^2.92.0",
|
|
66
|
+
"@ditojs/utils": "^2.92.0",
|
|
67
|
+
"@ditojs/router": "^2.92.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@aws-sdk/client-s3": "^3.0.0",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"@types/koa-static": "^4.0.4",
|
|
83
83
|
"@types/koa__cors": "^5.0.1",
|
|
84
84
|
"@types/koa__multer": "^2.0.8",
|
|
85
|
-
"@types/node": "^25.
|
|
85
|
+
"@types/node": "^25.5.0",
|
|
86
86
|
"knex": "^3.1.0",
|
|
87
87
|
"objection": "^3.1.5",
|
|
88
88
|
"typescript": "^5.9.3"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
91
|
-
"gitBranch": "
|
|
90
|
+
"gitHead": "79f40ebcd",
|
|
91
|
+
"gitBranch": "rg",
|
|
92
92
|
"scripts": {
|
|
93
93
|
"types": "tsc --noEmit --esModuleInterop ./types/index.d.ts"
|
|
94
94
|
}
|
package/src/app/Application.js
CHANGED
|
@@ -177,7 +177,7 @@ export class Application extends Koa {
|
|
|
177
177
|
if (
|
|
178
178
|
module &&
|
|
179
179
|
module.name !== key &&
|
|
180
|
-
module.name?.replace(/^_
|
|
180
|
+
module.name?.replace(/^_|\$?\d+$/g, '') === key
|
|
181
181
|
) {
|
|
182
182
|
Object.defineProperty(module, 'name', {
|
|
183
183
|
value: key,
|
|
@@ -205,9 +205,12 @@ export class AdminController extends Controller {
|
|
|
205
205
|
rollupOptions: {
|
|
206
206
|
output: {
|
|
207
207
|
manualChunks: id => {
|
|
208
|
-
|
|
208
|
+
// Strip Rollup's \0 prefix used for virtual modules
|
|
209
|
+
// (e.g. CJS interop modules like ?commonjs-module)
|
|
210
|
+
const cleanId = id.replace(/^\0/, '')
|
|
211
|
+
if (cleanId.startsWith(views)) {
|
|
209
212
|
return 'views'
|
|
210
|
-
} else if (
|
|
213
|
+
} else if (cleanId.startsWith(this.app.basePath)) {
|
|
211
214
|
return 'common'
|
|
212
215
|
} else {
|
|
213
216
|
const module = id.match(
|
package/src/models/Model.js
CHANGED
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
isPromise,
|
|
8
8
|
asArray,
|
|
9
9
|
clone,
|
|
10
|
-
equals,
|
|
11
10
|
flatten,
|
|
11
|
+
equals,
|
|
12
12
|
parseDataPath,
|
|
13
13
|
normalizeDataPath,
|
|
14
14
|
getValueAtDataPath,
|
|
15
|
+
getEntriesAtDataPath,
|
|
15
16
|
setValueAtDataPath,
|
|
16
17
|
mapConcurrently,
|
|
17
18
|
assignDeeply,
|
|
@@ -624,8 +625,9 @@ export class Model extends objection.Model {
|
|
|
624
625
|
}
|
|
625
626
|
// Convert plain asset files objects to AssetFile instances with references
|
|
626
627
|
// to the linked storage.
|
|
627
|
-
this.constructor.
|
|
628
|
+
this.constructor._mapAssetFiles(json, (file, storage) => {
|
|
628
629
|
storage.convertAssetFile(file, { trusted })
|
|
630
|
+
return file
|
|
629
631
|
})
|
|
630
632
|
return json
|
|
631
633
|
}
|
|
@@ -1002,30 +1004,21 @@ export class Model extends objection.Model {
|
|
|
1002
1004
|
|
|
1003
1005
|
// Assets handling
|
|
1004
1006
|
|
|
1005
|
-
static _forEachAssetFile(json, callback) {
|
|
1006
|
-
const { assets } = this.definition
|
|
1007
|
-
if (assets) {
|
|
1008
|
-
for (const dataPath in assets) {
|
|
1009
|
-
const data = getValueAtDataPath(json, dataPath, noop)
|
|
1010
|
-
if (!data) continue
|
|
1011
|
-
const storage = this.app.getStorage(assets[dataPath].storage)
|
|
1012
|
-
forEachAssetFile(data, storage, callback)
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
1007
|
static _mapAssetFiles(json, callback) {
|
|
1018
1008
|
const { assets } = this.definition
|
|
1019
1009
|
if (assets) {
|
|
1020
1010
|
for (const dataPath in assets) {
|
|
1021
|
-
const data = getValueAtDataPath(json, dataPath, noop)
|
|
1022
|
-
if (!data) continue
|
|
1023
1011
|
const storage = this.app.getStorage(assets[dataPath].storage)
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1012
|
+
const map = file => callback(file, storage)
|
|
1013
|
+
const entries = getEntriesAtDataPath(json, dataPath, noop)
|
|
1014
|
+
for (const [path, data] of Object.entries(entries)) {
|
|
1015
|
+
if (!data) continue
|
|
1016
|
+
setValueAtDataPath(
|
|
1017
|
+
json,
|
|
1018
|
+
path,
|
|
1019
|
+
isArray(data) ? data.map(map) : map(data)
|
|
1020
|
+
)
|
|
1021
|
+
}
|
|
1029
1022
|
}
|
|
1030
1023
|
}
|
|
1031
1024
|
}
|
|
@@ -1197,33 +1190,12 @@ function loadAssetDataPaths(query, dataPaths) {
|
|
|
1197
1190
|
|
|
1198
1191
|
const noop = () => {}
|
|
1199
1192
|
|
|
1200
|
-
function forEachAssetFile(data, storage, callback) {
|
|
1201
|
-
if (isArray(data)) {
|
|
1202
|
-
for (const item of data) {
|
|
1203
|
-
forEachAssetFile(item, storage, callback)
|
|
1204
|
-
}
|
|
1205
|
-
} else if (data) {
|
|
1206
|
-
callback(data, storage)
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
function mapAssetFiles(data, storage, callback) {
|
|
1211
|
-
if (isArray(data)) {
|
|
1212
|
-
return data.map(item => mapAssetFiles(item, storage, callback))
|
|
1213
|
-
}
|
|
1214
|
-
return data ? callback(data, storage) : data
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
function getValueAtAssetDataPath(item, path) {
|
|
1218
|
-
return getValueAtDataPath(item, path, noop)
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
1193
|
function getFilesPerAssetDataPath(items, dataPaths) {
|
|
1222
1194
|
return dataPaths.reduce(
|
|
1223
1195
|
(allFiles, dataPath) => {
|
|
1224
1196
|
allFiles[dataPath] = asArray(items).reduce(
|
|
1225
1197
|
(files, item) => {
|
|
1226
|
-
const data = asArray(
|
|
1198
|
+
const data = asArray(getValueAtDataPath(item, dataPath, noop))
|
|
1227
1199
|
// Use flatten() as dataPath may contain wildcards, resulting in
|
|
1228
1200
|
// nested files arrays.
|
|
1229
1201
|
files.push(...flatten(data).filter(file => !!file))
|
package/types/index.d.ts
CHANGED
|
@@ -1924,7 +1924,7 @@ export type ActionParameter = Schema & { name: string }
|
|
|
1924
1924
|
* is bound to the controller instance.
|
|
1925
1925
|
*/
|
|
1926
1926
|
export type ModelControllerActionHandler<
|
|
1927
|
-
$ModelController
|
|
1927
|
+
$ModelController = any
|
|
1928
1928
|
> = (this: $ModelController, ctx: KoaContext, ...args: any[]) => any
|
|
1929
1929
|
|
|
1930
1930
|
/**
|
|
@@ -2034,7 +2034,7 @@ export type ControllerActionOptions<
|
|
|
2034
2034
|
}
|
|
2035
2035
|
|
|
2036
2036
|
export type ModelControllerActionOptions<
|
|
2037
|
-
$ModelController
|
|
2037
|
+
$ModelController = any
|
|
2038
2038
|
> = BaseControllerActionOptions & {
|
|
2039
2039
|
/** The function to be called when the action route is requested. */
|
|
2040
2040
|
handler: ModelControllerActionHandler<$ModelController>
|
|
@@ -2068,7 +2068,7 @@ export type MemberActionParameter<$Model extends Model = Model> =
|
|
|
2068
2068
|
* `handler` or a bare handler function.
|
|
2069
2069
|
*/
|
|
2070
2070
|
export type ModelControllerAction<
|
|
2071
|
-
$ModelController
|
|
2071
|
+
$ModelController = any
|
|
2072
2072
|
> =
|
|
2073
2073
|
| ModelControllerActionOptions<$ModelController>
|
|
2074
2074
|
| ModelControllerActionHandler<$ModelController>
|
|
@@ -2079,7 +2079,7 @@ export type ModelControllerAction<
|
|
|
2079
2079
|
* `'post'`, `'post login'`).
|
|
2080
2080
|
*/
|
|
2081
2081
|
export type ModelControllerActions<
|
|
2082
|
-
$ModelController
|
|
2082
|
+
$ModelController = any
|
|
2083
2083
|
> = {
|
|
2084
2084
|
[name: ControllerActionName]: ModelControllerAction<$ModelController>
|
|
2085
2085
|
allow?: OrReadOnly<ControllerActionName[]>
|
|
@@ -2087,7 +2087,7 @@ export type ModelControllerActions<
|
|
|
2087
2087
|
}
|
|
2088
2088
|
|
|
2089
2089
|
type ModelControllerMemberAction<
|
|
2090
|
-
$ModelController
|
|
2090
|
+
$ModelController = any
|
|
2091
2091
|
> =
|
|
2092
2092
|
| (Omit<ModelControllerActionOptions<$ModelController>, 'parameters'> & {
|
|
2093
2093
|
parameters?: {
|
|
@@ -2105,7 +2105,7 @@ type ModelControllerMemberAction<
|
|
|
2105
2105
|
* parameters to receive the resolved member model.
|
|
2106
2106
|
*/
|
|
2107
2107
|
export type ModelControllerMemberActions<
|
|
2108
|
-
$ModelController
|
|
2108
|
+
$ModelController = any
|
|
2109
2109
|
> = {
|
|
2110
2110
|
[name: ControllerActionName]: ModelControllerMemberAction<$ModelController>
|
|
2111
2111
|
allow?: OrReadOnly<ControllerActionName[]>
|
|
@@ -2177,7 +2177,7 @@ type ModelControllerHookKeys<
|
|
|
2177
2177
|
| '*'
|
|
2178
2178
|
}`
|
|
2179
2179
|
type ModelControllerHook<
|
|
2180
|
-
$ModelController
|
|
2180
|
+
$ModelController = any
|
|
2181
2181
|
> = (
|
|
2182
2182
|
ctx: KoaContext,
|
|
2183
2183
|
result: objection.Page<ModelFromModelController<$ModelController>>
|
|
@@ -2215,7 +2215,7 @@ type HandlerFromHookKey<
|
|
|
2215
2215
|
: never
|
|
2216
2216
|
|
|
2217
2217
|
type ModelControllerHooks<
|
|
2218
|
-
$ModelController
|
|
2218
|
+
$ModelController = any
|
|
2219
2219
|
> = {
|
|
2220
2220
|
[$Key in HookKeysFromController<$ModelController>]?: HandlerFromHookKey<
|
|
2221
2221
|
$ModelController,
|
|
@@ -2271,12 +2271,12 @@ export class CollectionController<
|
|
|
2271
2271
|
* The controller's collection actions with built-in CRUD
|
|
2272
2272
|
* defaults.
|
|
2273
2273
|
*/
|
|
2274
|
-
collection?: ModelControllerActions
|
|
2274
|
+
collection?: ModelControllerActions
|
|
2275
2275
|
/**
|
|
2276
2276
|
* The controller's member actions with built-in CRUD
|
|
2277
2277
|
* defaults.
|
|
2278
2278
|
*/
|
|
2279
|
-
member?: ModelControllerMemberActions
|
|
2279
|
+
member?: ModelControllerMemberActions
|
|
2280
2280
|
|
|
2281
2281
|
/** Creates a query builder for this controller's model. */
|
|
2282
2282
|
query(trx?: objection.Transaction): QueryBuilder<$Model>
|
|
@@ -2397,12 +2397,12 @@ export class ModelController<
|
|
|
2397
2397
|
* The controller's collection actions. Wrap actions in
|
|
2398
2398
|
* this object to assign them to the collection.
|
|
2399
2399
|
*/
|
|
2400
|
-
collection?: ModelControllerActions
|
|
2400
|
+
collection?: ModelControllerActions
|
|
2401
2401
|
/**
|
|
2402
2402
|
* The controller's member actions. Wrap actions in this
|
|
2403
2403
|
* object to assign them to the member.
|
|
2404
2404
|
*/
|
|
2405
|
-
member?: ModelControllerMemberActions
|
|
2405
|
+
member?: ModelControllerMemberActions
|
|
2406
2406
|
assets?:
|
|
2407
2407
|
| boolean
|
|
2408
2408
|
| {
|
|
@@ -3527,8 +3527,8 @@ type OrReadOnly<T> = Readonly<T> | T
|
|
|
3527
3527
|
|
|
3528
3528
|
type OrPromiseOf<T> = Promise<T> | T
|
|
3529
3529
|
|
|
3530
|
-
type ModelFromModelController<$ModelController
|
|
3531
|
-
|
|
3530
|
+
type ModelFromModelController<$ModelController> =
|
|
3531
|
+
$ModelController extends ModelController<infer $Model> ? $Model : Model
|
|
3532
3532
|
|
|
3533
3533
|
type SerializeModelPropertyValue<T> = T extends (infer U)[]
|
|
3534
3534
|
? SerializeModelPropertyValue<U>[]
|