@e22m4u/js-repository 0.0.33 → 0.0.34
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 +1 -1
- package/src/adapter/adapter-loader.js +1 -1
- package/src/adapter/adapter-loader.spec.js +1 -1
- package/src/adapter/decorator/data-sanitizing-decorator.js +1 -1
- package/src/adapter/decorator/data-validation-decorator.js +1 -1
- package/src/adapter/decorator/default-values-decorator.js +1 -1
- package/src/adapter/decorator/fields-filtering-decorator.js +1 -1
- package/src/adapter/decorator/inclusion-decorator.js +1 -1
- package/src/definition/model/model-data-sanitizer.js +2 -2
- package/src/definition/model/model-data-validator.js +1 -1
- package/src/definition/model/model-data-validator.spec.js +1 -1
- package/src/definition/model/model-definition-utils.js +1 -1
- package/src/definition/model/model-definition-utils.spec.js +1 -1
- package/src/filter/fields-clause-tool.d.ts +2 -2
- package/src/filter/fields-clause-tool.js +32 -21
- package/src/filter/fields-clause-tool.spec.js +479 -100
- package/src/filter/operator-clause-tool.js +1 -1
- package/src/filter/operator-clause-tool.spec.js +1 -1
- package/src/filter/order-clause-tool.js +20 -17
- package/src/filter/order-clause-tool.spec.js +621 -362
|
@@ -13,14 +13,15 @@ export class OrderClauseTool extends Service {
|
|
|
13
13
|
* @param {string|string[]|undefined} clause
|
|
14
14
|
*/
|
|
15
15
|
sort(entities, clause) {
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
16
|
+
if (clause == null) return;
|
|
17
|
+
if (Array.isArray(clause) === false) clause = [clause];
|
|
18
|
+
if (!clause.length) return;
|
|
18
19
|
const mapping = [];
|
|
19
20
|
clause.forEach((key, index) => {
|
|
20
|
-
if (typeof key !== 'string')
|
|
21
|
+
if (!key || typeof key !== 'string')
|
|
21
22
|
throw new InvalidArgumentError(
|
|
22
|
-
'The provided option "order" should be a String ' +
|
|
23
|
-
'or an Array of String, but %v given.',
|
|
23
|
+
'The provided option "order" should be a non-empty String ' +
|
|
24
|
+
'or an Array of non-empty String, but %v given.',
|
|
24
25
|
key,
|
|
25
26
|
);
|
|
26
27
|
let reverse = 1;
|
|
@@ -40,14 +41,15 @@ export class OrderClauseTool extends Service {
|
|
|
40
41
|
* @param {string|string[]|undefined} clause
|
|
41
42
|
*/
|
|
42
43
|
static validateOrderClause(clause) {
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (clause == null) return;
|
|
45
|
+
if (Array.isArray(clause) === false) clause = [clause];
|
|
46
|
+
if (!clause.length) return;
|
|
47
|
+
clause.forEach(field => {
|
|
48
|
+
if (!field || typeof field !== 'string')
|
|
47
49
|
throw new InvalidArgumentError(
|
|
48
50
|
'The provided option "order" should be a non-empty String ' +
|
|
49
|
-
'or an Array of String, but %v given.',
|
|
50
|
-
|
|
51
|
+
'or an Array of non-empty String, but %v given.',
|
|
52
|
+
field,
|
|
51
53
|
);
|
|
52
54
|
});
|
|
53
55
|
}
|
|
@@ -59,14 +61,15 @@ export class OrderClauseTool extends Service {
|
|
|
59
61
|
* @returns {string[]|undefined}
|
|
60
62
|
*/
|
|
61
63
|
static normalizeOrderClause(clause) {
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
clause.
|
|
65
|
-
|
|
64
|
+
if (clause == null) return;
|
|
65
|
+
if (Array.isArray(clause) === false) clause = [clause];
|
|
66
|
+
if (!clause.length) return;
|
|
67
|
+
clause.forEach(field => {
|
|
68
|
+
if (!field || typeof field !== 'string')
|
|
66
69
|
throw new InvalidArgumentError(
|
|
67
70
|
'The provided option "order" should be a non-empty String ' +
|
|
68
|
-
'or an Array of String, but %v given.',
|
|
69
|
-
|
|
71
|
+
'or an Array of non-empty String, but %v given.',
|
|
72
|
+
field,
|
|
70
73
|
);
|
|
71
74
|
});
|
|
72
75
|
return clause;
|