@ditojs/server 1.10.1 → 1.12.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/package.json +12 -13
- package/src/app/Application.js +2 -7
- package/src/controllers/AdminController.js +0 -17
- package/src/errors/ResponseError.js +0 -2
- package/src/graph/expression.js +1 -1
- package/src/graph/graph.js +1 -1
- package/src/models/Model.js +2 -2
- package/src/schema/relations.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
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",
|
|
@@ -14,29 +14,28 @@
|
|
|
14
14
|
"dito": "./src/cli/index.js"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">= 18.0.0",
|
|
18
18
|
"yarn": ">= 1.0.0"
|
|
19
19
|
},
|
|
20
20
|
"browserslist": [
|
|
21
|
-
"node >=
|
|
21
|
+
"node >= 18"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/client-s3": "^3.
|
|
25
|
-
"@ditojs/admin": "^1.
|
|
26
|
-
"@ditojs/build": "^1.
|
|
27
|
-
"@ditojs/router": "^1.
|
|
28
|
-
"@ditojs/utils": "^1.
|
|
29
|
-
"@koa/cors": "^
|
|
24
|
+
"@aws-sdk/client-s3": "^3.200.0",
|
|
25
|
+
"@ditojs/admin": "^1.12.0",
|
|
26
|
+
"@ditojs/build": "^1.12.0",
|
|
27
|
+
"@ditojs/router": "^1.12.0",
|
|
28
|
+
"@ditojs/utils": "^1.12.0",
|
|
29
|
+
"@koa/cors": "^4.0.0",
|
|
30
30
|
"@koa/multer": "^3.0.0",
|
|
31
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
32
32
|
"ajv": "^8.11.0",
|
|
33
33
|
"ajv-formats": "^2.1.1",
|
|
34
|
-
"axios": "^0.27.2",
|
|
35
34
|
"bcryptjs": "^2.4.3",
|
|
36
35
|
"bytes": "^3.1.2",
|
|
37
36
|
"data-uri-to-buffer": "^4.0.0",
|
|
38
37
|
"eventemitter2": "^6.4.9",
|
|
39
|
-
"file-type": "^
|
|
38
|
+
"file-type": "^18.0.0",
|
|
40
39
|
"fs-extra": "^10.1.0",
|
|
41
40
|
"image-size": "^1.0.2",
|
|
42
41
|
"is-svg": "^4.3.2",
|
|
@@ -62,7 +61,7 @@
|
|
|
62
61
|
"picocolors": "^1.0.0",
|
|
63
62
|
"picomatch": "^2.3.1",
|
|
64
63
|
"pino": "^8.7.0",
|
|
65
|
-
"pino-pretty": "^
|
|
64
|
+
"pino-pretty": "^9.1.1",
|
|
66
65
|
"pluralize": "^8.0.0",
|
|
67
66
|
"repl": "^0.1.3",
|
|
68
67
|
"uuid": "^9.0.0",
|
|
@@ -79,5 +78,5 @@
|
|
|
79
78
|
"knex": "^2.3.0",
|
|
80
79
|
"objection": "^3.0.1"
|
|
81
80
|
},
|
|
82
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "3707045b72d84db4b5174d2efeb8cf62e2065ffa"
|
|
83
82
|
}
|
package/src/app/Application.js
CHANGED
|
@@ -5,7 +5,6 @@ import zlib from 'zlib'
|
|
|
5
5
|
import fs from 'fs-extra'
|
|
6
6
|
import Koa from 'koa'
|
|
7
7
|
import Knex from 'knex'
|
|
8
|
-
import axios from 'axios'
|
|
9
8
|
import pico from 'picocolors'
|
|
10
9
|
import pino from 'pino'
|
|
11
10
|
import parseDuration from 'parse-duration'
|
|
@@ -888,12 +887,8 @@ export class Application extends Koa {
|
|
|
888
887
|
const filepath = path.resolve(url.substring(7))
|
|
889
888
|
data = await fs.readFile(filepath)
|
|
890
889
|
} else {
|
|
891
|
-
const response = await
|
|
892
|
-
|
|
893
|
-
responseType: 'arraybuffer',
|
|
894
|
-
url
|
|
895
|
-
})
|
|
896
|
-
data = response.data
|
|
890
|
+
const response = await fetch(url)
|
|
891
|
+
data = await response.arrayBuffer()
|
|
897
892
|
}
|
|
898
893
|
}
|
|
899
894
|
const importedFile = await storage.addFile(file, data)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
|
-
import { exit } from 'process'
|
|
3
2
|
import Koa from 'koa'
|
|
4
3
|
import serve from 'koa-static'
|
|
5
4
|
import { defineConfig, createServer } from 'vite'
|
|
@@ -147,24 +146,9 @@ export class AdminController extends Controller {
|
|
|
147
146
|
|
|
148
147
|
this.closed = false
|
|
149
148
|
|
|
150
|
-
// Monkey-patch `process.exit()` to filter out the calls caused by vite's
|
|
151
|
-
// handling of SIGTERM, see: https://github.com/vitejs/vite/issues/7627
|
|
152
|
-
process.exit = code => {
|
|
153
|
-
// Filter out calls from inside vite by looking at the stack trace.
|
|
154
|
-
if (new Error().stack.includes('/vite/dist/')) {
|
|
155
|
-
// vite's own `exitProcess()` just called `process.exit(), and this
|
|
156
|
-
// means it has already called `server.close()` internally.
|
|
157
|
-
this.closed = true
|
|
158
|
-
process.exit = exit
|
|
159
|
-
} else {
|
|
160
|
-
exit(code)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
149
|
this.app.once('after:stop', () => {
|
|
165
150
|
// For good timing it seems crucial to not add more ticks with async
|
|
166
151
|
// signature, so we directly return the `server.close()` promise instead.
|
|
167
|
-
process.exit = exit
|
|
168
152
|
if (!this.closed) {
|
|
169
153
|
this.closed = true
|
|
170
154
|
return server.close()
|
|
@@ -289,7 +273,6 @@ const CORE_DEPENDENCIES = [
|
|
|
289
273
|
'vue-upload-component',
|
|
290
274
|
'vuedraggable',
|
|
291
275
|
|
|
292
|
-
'axios',
|
|
293
276
|
'core-js',
|
|
294
277
|
'lowlight',
|
|
295
278
|
'sortablejs',
|
|
@@ -9,8 +9,6 @@ export class ResponseError extends Error {
|
|
|
9
9
|
// Copy error into object so they can be merged with defaults after.
|
|
10
10
|
// First copy everything that is enumerable, unless the error is from
|
|
11
11
|
// axios, in which case we don't want to leak config information.
|
|
12
|
-
// TODO: Use `instanceof AxiosException` instead once axios is v1.0.0:
|
|
13
|
-
// https://github.com/axios/axios/pull/2014
|
|
14
12
|
...(error.isAxiosError ? null : error),
|
|
15
13
|
// Also explicitly copy message, status and code.
|
|
16
14
|
message: error.message,
|
package/src/graph/expression.js
CHANGED
|
@@ -39,7 +39,7 @@ export function expressionPathToString(path, start = 0) {
|
|
|
39
39
|
|
|
40
40
|
export function modelGraphToExpression(modelGraph, expr) {
|
|
41
41
|
if (modelGraph) {
|
|
42
|
-
expr
|
|
42
|
+
expr ||= {}
|
|
43
43
|
for (const model of asArray(modelGraph)) {
|
|
44
44
|
if (model) {
|
|
45
45
|
const relations = model.constructor.getRelations()
|
package/src/graph/graph.js
CHANGED
|
@@ -49,7 +49,7 @@ function parseRelationArray(json, relation, options) {
|
|
|
49
49
|
let changed = false
|
|
50
50
|
for (let i = 0, l = json.length; i < l; i++) {
|
|
51
51
|
const model = parseRelationObject(json[i], relation, options)
|
|
52
|
-
changed
|
|
52
|
+
changed ||= model !== json[i]
|
|
53
53
|
models[i] = model
|
|
54
54
|
}
|
|
55
55
|
return changed ? models : json
|
package/src/models/Model.js
CHANGED
|
@@ -168,7 +168,7 @@ export class Model extends objection.Model {
|
|
|
168
168
|
// extensions (async and graph for now):
|
|
169
169
|
return super.$validate(json, options)
|
|
170
170
|
}
|
|
171
|
-
json
|
|
171
|
+
json ||= this
|
|
172
172
|
const inputJson = json
|
|
173
173
|
const shallow = json.$isObjectionModel && !options.graph
|
|
174
174
|
if (shallow) {
|
|
@@ -471,7 +471,7 @@ export class Model extends objection.Model {
|
|
|
471
471
|
|
|
472
472
|
// @override
|
|
473
473
|
$setJson(json, options) {
|
|
474
|
-
options
|
|
474
|
+
options ||= {}
|
|
475
475
|
const callInitialize = (
|
|
476
476
|
// Only call initialize when:
|
|
477
477
|
// 1. we're not partially patching:
|
package/src/schema/relations.js
CHANGED
|
@@ -193,7 +193,7 @@ export function convertRelation(schema, models) {
|
|
|
193
193
|
throw new RelationError('Unsupported through join definition')
|
|
194
194
|
}
|
|
195
195
|
// Combine `modify` and `filter`. Setting both together is not supported.
|
|
196
|
-
modify
|
|
196
|
+
modify ||= filter
|
|
197
197
|
if (isObject(modify)) {
|
|
198
198
|
// Convert a find-filter object to a filter function, same as in the
|
|
199
199
|
// handling of definition.scopes, see Model.js
|