@ditojs/server 2.0.5 → 2.1.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 +11 -13
- package/src/app/Application.js +226 -179
- package/src/app/Validator.js +53 -43
- package/src/cli/console.js +6 -4
- package/src/cli/db/createMigration.js +59 -30
- package/src/cli/db/migrate.js +6 -4
- package/src/cli/db/reset.js +8 -5
- package/src/cli/db/rollback.js +6 -4
- package/src/cli/db/seed.js +2 -1
- package/src/cli/index.js +1 -1
- package/src/controllers/AdminController.js +98 -84
- package/src/controllers/CollectionController.js +37 -30
- package/src/controllers/Controller.js +83 -43
- package/src/controllers/ControllerAction.js +27 -15
- package/src/controllers/ModelController.js +4 -1
- package/src/controllers/RelationController.js +19 -21
- package/src/controllers/UsersController.js +3 -4
- package/src/decorators/parameters.js +3 -1
- package/src/decorators/scope.js +1 -1
- package/src/errors/ControllerError.js +2 -1
- package/src/errors/DatabaseError.js +20 -11
- package/src/graph/DitoGraphProcessor.js +48 -40
- package/src/graph/expression.js +6 -8
- package/src/graph/graph.js +20 -11
- package/src/lib/EventEmitter.js +12 -12
- package/src/middleware/handleConnectMiddleware.js +16 -10
- package/src/middleware/handleError.js +6 -5
- package/src/middleware/handleSession.js +33 -29
- package/src/middleware/handleUser.js +2 -2
- package/src/middleware/index.js +1 -0
- package/src/middleware/logRequests.js +3 -3
- package/src/middleware/setupRequestStorage.js +14 -0
- package/src/mixins/AssetMixin.js +62 -58
- package/src/mixins/SessionMixin.js +13 -10
- package/src/mixins/TimeStampedMixin.js +33 -29
- package/src/mixins/UserMixin.js +130 -116
- package/src/models/Model.js +245 -194
- package/src/models/definitions/filters.js +14 -13
- package/src/query/QueryBuilder.js +252 -195
- package/src/query/QueryFilters.js +3 -3
- package/src/query/QueryParameters.js +2 -2
- package/src/query/Registry.js +8 -10
- package/src/schema/keywords/_validate.js +10 -8
- package/src/schema/properties.test.js +247 -206
- package/src/schema/relations.js +42 -20
- package/src/schema/relations.test.js +36 -19
- package/src/services/Service.js +8 -14
- package/src/storage/S3Storage.js +5 -3
- package/src/storage/Storage.js +16 -14
- package/src/utils/function.js +7 -4
- package/src/utils/function.test.js +30 -6
- package/src/utils/object.test.js +5 -1
- package/types/index.d.ts +244 -257
|
@@ -30,8 +30,8 @@ QueryFilters.register({
|
|
|
30
30
|
query.where(property, 'ILIKE', operand)
|
|
31
31
|
} else {
|
|
32
32
|
query.whereRaw(
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
`LOWER(??) LIKE ?`,
|
|
34
|
+
[property, operand.toLowerCase()]
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -59,7 +59,7 @@ QueryFilters.register({
|
|
|
59
59
|
} else if (to) {
|
|
60
60
|
query.where(property, '<=', new Date(to))
|
|
61
61
|
} else {
|
|
62
|
-
|
|
62
|
+
// TODO: Can we get validation to catch the case where both are empty?
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/query/Registry.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { isObject } from '@ditojs/utils'
|
|
2
2
|
|
|
3
3
|
export default class Registry {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this._allowed = Object.create(null)
|
|
7
|
-
}
|
|
4
|
+
#registry = Object.create(null)
|
|
5
|
+
#allowed = Object.create(null)
|
|
8
6
|
|
|
9
7
|
get(name) {
|
|
10
|
-
return this
|
|
8
|
+
return this.#registry[name]
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
has(name) {
|
|
14
|
-
return name in this
|
|
12
|
+
return name in this.#registry
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
register(name, handler) {
|
|
@@ -20,12 +18,12 @@ export default class Registry {
|
|
|
20
18
|
this.register(key, name[key])
|
|
21
19
|
}
|
|
22
20
|
} else {
|
|
23
|
-
this
|
|
24
|
-
this
|
|
21
|
+
this.#registry[name] = handler
|
|
22
|
+
this.#allowed[name] = true
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
return this
|
|
26
|
+
getAllowed() {
|
|
27
|
+
return this.#allowed
|
|
30
28
|
}
|
|
31
29
|
}
|
|
@@ -58,14 +58,16 @@ function getParams(ctx, data, parentSchema, dataCtx) {
|
|
|
58
58
|
|
|
59
59
|
function getErrors(error, { validator, instancePath }) {
|
|
60
60
|
const errors = isArray(error.errors)
|
|
61
|
-
// Ajv errors array:
|
|
62
|
-
|
|
63
|
-
// Convert string error message to errors array:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
? // Ajv errors array:
|
|
62
|
+
error.errors
|
|
63
|
+
: // Convert string error message to errors array:
|
|
64
|
+
[
|
|
65
|
+
{
|
|
66
|
+
keyword: 'validate',
|
|
67
|
+
message: error.message || error.toString(),
|
|
68
|
+
params: {}
|
|
69
|
+
}
|
|
70
|
+
]
|
|
69
71
|
// Return errors prefixed with the current instancePath:
|
|
70
72
|
return validator.prefixInstancePaths(errors, instancePath)
|
|
71
73
|
}
|