@ditojs/server 2.10.4 → 2.10.6
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 +8 -8
- package/src/app/Application.js +25 -1
- package/src/errors/DatabaseError.js +2 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/server",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.6",
|
|
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,10 +22,10 @@
|
|
|
22
22
|
"node >= 18"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ditojs/admin": "^2.10.
|
|
25
|
+
"@ditojs/admin": "^2.10.5",
|
|
26
26
|
"@ditojs/build": "^2.10.0",
|
|
27
|
-
"@ditojs/router": "^2.10.
|
|
28
|
-
"@ditojs/utils": "^2.10.
|
|
27
|
+
"@ditojs/router": "^2.10.5",
|
|
28
|
+
"@ditojs/utils": "^2.10.5",
|
|
29
29
|
"@koa/cors": "^4.0.0",
|
|
30
30
|
"@koa/multer": "^3.0.2",
|
|
31
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"@types/koa-session": "^6.4.1",
|
|
83
83
|
"@types/koa-static": "^4.0.2",
|
|
84
84
|
"@types/koa__cors": "^4.0.0",
|
|
85
|
-
"@types/node": "^20.3.
|
|
85
|
+
"@types/node": "^20.3.3",
|
|
86
86
|
"knex": "^2.4.2",
|
|
87
|
-
"objection": "^3.0.
|
|
88
|
-
"typescript": "^5.1.
|
|
87
|
+
"objection": "^3.0.4",
|
|
88
|
+
"typescript": "^5.1.6"
|
|
89
89
|
},
|
|
90
90
|
"types": "types",
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "6a68994a0ecfef1729d1c2e0b29c276eab1dd0ba",
|
|
92
92
|
"scripts": {
|
|
93
93
|
"types": "tsc --noEmit --esModuleInterop ./types/index.d.ts"
|
|
94
94
|
},
|
package/src/app/Application.js
CHANGED
|
@@ -667,9 +667,33 @@ export class Application extends Koa {
|
|
|
667
667
|
knex.typeParsers &&
|
|
668
668
|
this.knex.client.driver
|
|
669
669
|
) {
|
|
670
|
+
const { types } = this.knex.client.driver
|
|
671
|
+
// Support type parser mappings defined in user-land.
|
|
670
672
|
for (const [type, parser] of Object.entries(knex.typeParsers)) {
|
|
671
|
-
|
|
673
|
+
types.setTypeParser(type, parser)
|
|
672
674
|
}
|
|
675
|
+
// Automatically setup array type parsers for numeric and int8.
|
|
676
|
+
const setupArrayParser = (valueType, arrayType) => {
|
|
677
|
+
if (
|
|
678
|
+
valueType in knex.typeParsers &&
|
|
679
|
+
!(arrayType in knex.typeParsers)
|
|
680
|
+
) {
|
|
681
|
+
const parseValue = types.getTypeParser(valueType)
|
|
682
|
+
const parseArray = types.getTypeParser(arrayType)
|
|
683
|
+
types.setTypeParser(arrayType, text =>
|
|
684
|
+
parseArray(text).map(value =>
|
|
685
|
+
value === null ? value : parseValue(value)
|
|
686
|
+
)
|
|
687
|
+
)
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
setupArrayParser(1700, 1231) // numeric
|
|
692
|
+
setupArrayParser(20, 1016) // int8
|
|
693
|
+
// setupArrayParser(21, 1005) // int2
|
|
694
|
+
// setupArrayParser(23, 1007) // int4
|
|
695
|
+
// setupArrayParser(700, 1021) // float4
|
|
696
|
+
// setupArrayParser(701, 1022) // float8
|
|
673
697
|
}
|
|
674
698
|
if (log.sql) {
|
|
675
699
|
this.setupKnexLogging()
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { ResponseError } from './ResponseError.js'
|
|
2
|
-
|
|
3
|
-
// import {
|
|
4
|
-
// DBError,
|
|
5
|
-
// DataError,
|
|
6
|
-
// CheckViolationError,
|
|
7
|
-
// NotNullViolationError,
|
|
8
|
-
// ConstraintViolationError
|
|
9
|
-
// } from 'objection'
|
|
10
|
-
import objection from 'objection'
|
|
11
|
-
const {
|
|
2
|
+
import {
|
|
12
3
|
DBError,
|
|
13
4
|
DataError,
|
|
14
5
|
CheckViolationError,
|
|
15
6
|
NotNullViolationError,
|
|
16
7
|
ConstraintViolationError
|
|
17
|
-
}
|
|
8
|
+
} from 'objection'
|
|
18
9
|
|
|
19
10
|
export class DatabaseError extends ResponseError {
|
|
20
11
|
constructor(error, overrides) {
|