@e22m4u/js-repository 0.0.33 → 0.0.35
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/definition/model/properties/default-values-definition-validator.js +1 -1
- package/src/definition/model/properties/default-values-definition-validator.spec.js +1 -1
- package/src/definition/model/properties/properties-definition-validator.js +2 -2
- package/src/definition/model/properties/properties-definition-validator.spec.js +1 -1
- package/src/definition/model/relations/relations-definition-validator.js +2 -2
- package/src/definition/model/relations/relations-definition-validator.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/include-clause-tool.js +50 -42
- package/src/filter/include-clause-tool.spec.js +4391 -291
- package/src/filter/operator-clause-tool.js +13 -13
- package/src/filter/operator-clause-tool.spec.js +13 -13
- package/src/filter/order-clause-tool.js +20 -17
- package/src/filter/order-clause-tool.spec.js +621 -362
- package/src/filter/slice-clause-tool.js +5 -5
- package/src/filter/slice-clause-tool.spec.js +92 -51
- package/src/filter/where-clause-tool.js +7 -7
- package/src/filter/where-clause-tool.spec.js +79 -55
- package/src/utils/select-object-keys.js +3 -3
- package/src/utils/select-object-keys.spec.js +3 -3
|
@@ -58,7 +58,7 @@ export class OperatorClauseTool extends Service {
|
|
|
58
58
|
testAll(clause, value) {
|
|
59
59
|
if (!clause || typeof clause !== 'object' || Array.isArray(clause))
|
|
60
60
|
throw new InvalidArgumentError(
|
|
61
|
-
'
|
|
61
|
+
'The first argument of OperatorUtils.testAll ' +
|
|
62
62
|
'should be an Object, but %v given.',
|
|
63
63
|
clause,
|
|
64
64
|
);
|
|
@@ -136,7 +136,7 @@ export class OperatorClauseTool extends Service {
|
|
|
136
136
|
testEqNeq(clause, value) {
|
|
137
137
|
if (!clause || typeof clause !== 'object')
|
|
138
138
|
throw new InvalidArgumentError(
|
|
139
|
-
'
|
|
139
|
+
'The first argument of OperatorUtils.testEqNeq ' +
|
|
140
140
|
'should be an Object, but %v given.',
|
|
141
141
|
clause,
|
|
142
142
|
);
|
|
@@ -182,7 +182,7 @@ export class OperatorClauseTool extends Service {
|
|
|
182
182
|
testGtLt(clause, value) {
|
|
183
183
|
if (!clause || typeof clause !== 'object')
|
|
184
184
|
throw new InvalidArgumentError(
|
|
185
|
-
'
|
|
185
|
+
'The first argument of OperatorUtils.testGtLt ' +
|
|
186
186
|
'should be an Object, but %v given.',
|
|
187
187
|
clause,
|
|
188
188
|
);
|
|
@@ -209,7 +209,7 @@ export class OperatorClauseTool extends Service {
|
|
|
209
209
|
testInq(clause, value) {
|
|
210
210
|
if (!clause || typeof clause !== 'object')
|
|
211
211
|
throw new InvalidArgumentError(
|
|
212
|
-
'
|
|
212
|
+
'The first argument of OperatorUtils.testInq ' +
|
|
213
213
|
'should be an Object, but %v given.',
|
|
214
214
|
clause,
|
|
215
215
|
);
|
|
@@ -245,7 +245,7 @@ export class OperatorClauseTool extends Service {
|
|
|
245
245
|
testNin(clause, value) {
|
|
246
246
|
if (!clause || typeof clause !== 'object')
|
|
247
247
|
throw new InvalidArgumentError(
|
|
248
|
-
'
|
|
248
|
+
'The first argument of OperatorUtils.testNin ' +
|
|
249
249
|
'should be an Object, but %v given.',
|
|
250
250
|
clause,
|
|
251
251
|
);
|
|
@@ -281,7 +281,7 @@ export class OperatorClauseTool extends Service {
|
|
|
281
281
|
testBetween(clause, value) {
|
|
282
282
|
if (!clause || typeof clause !== 'object')
|
|
283
283
|
throw new InvalidArgumentError(
|
|
284
|
-
'
|
|
284
|
+
'The first argument of OperatorUtils.testBetween ' +
|
|
285
285
|
'should be an Object, but %v given.',
|
|
286
286
|
clause,
|
|
287
287
|
);
|
|
@@ -317,7 +317,7 @@ export class OperatorClauseTool extends Service {
|
|
|
317
317
|
testExists(clause, value) {
|
|
318
318
|
if (!clause || typeof clause !== 'object')
|
|
319
319
|
throw new InvalidArgumentError(
|
|
320
|
-
'
|
|
320
|
+
'The first argument of OperatorUtils.testExists ' +
|
|
321
321
|
'should be an Object, but %v given.',
|
|
322
322
|
clause,
|
|
323
323
|
);
|
|
@@ -350,7 +350,7 @@ export class OperatorClauseTool extends Service {
|
|
|
350
350
|
testLike(clause, value) {
|
|
351
351
|
if (!clause || typeof clause !== 'object')
|
|
352
352
|
throw new InvalidArgumentError(
|
|
353
|
-
'
|
|
353
|
+
'The first argument of OperatorUtils.testLike ' +
|
|
354
354
|
'should be an Object, but %v given.',
|
|
355
355
|
clause,
|
|
356
356
|
);
|
|
@@ -378,7 +378,7 @@ export class OperatorClauseTool extends Service {
|
|
|
378
378
|
testNlike(clause, value) {
|
|
379
379
|
if (!clause || typeof clause !== 'object')
|
|
380
380
|
throw new InvalidArgumentError(
|
|
381
|
-
'
|
|
381
|
+
'The first argument of OperatorUtils.testNlike ' +
|
|
382
382
|
'should be an Object, but %v given.',
|
|
383
383
|
clause,
|
|
384
384
|
);
|
|
@@ -410,7 +410,7 @@ export class OperatorClauseTool extends Service {
|
|
|
410
410
|
testIlike(clause, value) {
|
|
411
411
|
if (!clause || typeof clause !== 'object')
|
|
412
412
|
throw new InvalidArgumentError(
|
|
413
|
-
'
|
|
413
|
+
'The first argument of OperatorUtils.testIlike ' +
|
|
414
414
|
'should be an Object, but %v given.',
|
|
415
415
|
clause,
|
|
416
416
|
);
|
|
@@ -442,7 +442,7 @@ export class OperatorClauseTool extends Service {
|
|
|
442
442
|
testNilike(clause, value) {
|
|
443
443
|
if (!clause || typeof clause !== 'object')
|
|
444
444
|
throw new InvalidArgumentError(
|
|
445
|
-
'
|
|
445
|
+
'The first argument of OperatorUtils.testNilike ' +
|
|
446
446
|
'should be an Object, but %v given.',
|
|
447
447
|
clause,
|
|
448
448
|
);
|
|
@@ -486,7 +486,7 @@ export class OperatorClauseTool extends Service {
|
|
|
486
486
|
testRegexp(clause, value) {
|
|
487
487
|
if (!clause || typeof clause !== 'object')
|
|
488
488
|
throw new InvalidArgumentError(
|
|
489
|
-
'
|
|
489
|
+
'The first argument of OperatorUtils.testRegexp ' +
|
|
490
490
|
'should be an Object, but %v given.',
|
|
491
491
|
clause,
|
|
492
492
|
);
|
|
@@ -504,7 +504,7 @@ export class OperatorClauseTool extends Service {
|
|
|
504
504
|
const flags = clause.flags || undefined;
|
|
505
505
|
if (flags && typeof flags !== 'string')
|
|
506
506
|
throw new InvalidArgumentError(
|
|
507
|
-
'RegExp flags
|
|
507
|
+
'RegExp flags should be a String, but %v given.',
|
|
508
508
|
clause.flags,
|
|
509
509
|
);
|
|
510
510
|
if (!value || typeof value !== 'string') return false;
|
|
@@ -115,7 +115,7 @@ describe('OperatorClauseTool', function () {
|
|
|
115
115
|
it('throws an error if a first argument is not an object', function () {
|
|
116
116
|
const throwable = () => S.testAll(10);
|
|
117
117
|
expect(throwable).to.throw(
|
|
118
|
-
'
|
|
118
|
+
'The first argument of OperatorUtils.testAll ' +
|
|
119
119
|
'should be an Object, but 10 given.',
|
|
120
120
|
);
|
|
121
121
|
});
|
|
@@ -130,7 +130,7 @@ describe('OperatorClauseTool', function () {
|
|
|
130
130
|
it('throws an error if a first argument is not an object', function () {
|
|
131
131
|
const throwable = () => S.testEqNeq(10);
|
|
132
132
|
expect(throwable).to.throw(
|
|
133
|
-
'
|
|
133
|
+
'The first argument of OperatorUtils.testEqNeq ' +
|
|
134
134
|
'should be an Object, but 10 given.',
|
|
135
135
|
);
|
|
136
136
|
});
|
|
@@ -215,7 +215,7 @@ describe('OperatorClauseTool', function () {
|
|
|
215
215
|
it('throws an error if a first argument is not an object', function () {
|
|
216
216
|
const throwable = () => S.testGtLt(10);
|
|
217
217
|
expect(throwable).to.throw(
|
|
218
|
-
'
|
|
218
|
+
'The first argument of OperatorUtils.testGtLt ' +
|
|
219
219
|
'should be an Object, but 10 given.',
|
|
220
220
|
);
|
|
221
221
|
});
|
|
@@ -390,7 +390,7 @@ describe('OperatorClauseTool', function () {
|
|
|
390
390
|
it('throws an error if a first argument is not an object', function () {
|
|
391
391
|
const throwable = () => S.testInq(10);
|
|
392
392
|
expect(throwable).to.throw(
|
|
393
|
-
'
|
|
393
|
+
'The first argument of OperatorUtils.testInq ' +
|
|
394
394
|
'should be an Object, but 10 given.',
|
|
395
395
|
);
|
|
396
396
|
});
|
|
@@ -445,7 +445,7 @@ describe('OperatorClauseTool', function () {
|
|
|
445
445
|
it('throws an error if a first argument is not an object', function () {
|
|
446
446
|
const throwable = () => S.testNin(10);
|
|
447
447
|
expect(throwable).to.throw(
|
|
448
|
-
'
|
|
448
|
+
'The first argument of OperatorUtils.testNin ' +
|
|
449
449
|
'should be an Object, but 10 given.',
|
|
450
450
|
);
|
|
451
451
|
});
|
|
@@ -514,7 +514,7 @@ describe('OperatorClauseTool', function () {
|
|
|
514
514
|
it('throws an error if a first argument is not an object', function () {
|
|
515
515
|
const throwable = () => S.testBetween(10);
|
|
516
516
|
expect(throwable).to.throw(
|
|
517
|
-
'
|
|
517
|
+
'The first argument of OperatorUtils.testBetween ' +
|
|
518
518
|
'should be an Object, but 10 given.',
|
|
519
519
|
);
|
|
520
520
|
});
|
|
@@ -571,7 +571,7 @@ describe('OperatorClauseTool', function () {
|
|
|
571
571
|
it('throws an error if a first argument is not an object', function () {
|
|
572
572
|
const throwable = () => S.testExists(10);
|
|
573
573
|
expect(throwable).to.throw(
|
|
574
|
-
'
|
|
574
|
+
'The first argument of OperatorUtils.testExists ' +
|
|
575
575
|
'should be an Object, but 10 given.',
|
|
576
576
|
);
|
|
577
577
|
});
|
|
@@ -694,7 +694,7 @@ describe('OperatorClauseTool', function () {
|
|
|
694
694
|
it('throws an error if a first argument is not an object', function () {
|
|
695
695
|
const throwable = () => S.testLike(10);
|
|
696
696
|
expect(throwable).to.throw(
|
|
697
|
-
'
|
|
697
|
+
'The first argument of OperatorUtils.testLike ' +
|
|
698
698
|
'should be an Object, but 10 given.',
|
|
699
699
|
);
|
|
700
700
|
});
|
|
@@ -773,7 +773,7 @@ describe('OperatorClauseTool', function () {
|
|
|
773
773
|
it('throws an error if a first argument is not an object', function () {
|
|
774
774
|
const throwable = () => S.testNlike(10);
|
|
775
775
|
expect(throwable).to.throw(
|
|
776
|
-
'
|
|
776
|
+
'The first argument of OperatorUtils.testNlike ' +
|
|
777
777
|
'should be an Object, but 10 given.',
|
|
778
778
|
);
|
|
779
779
|
});
|
|
@@ -852,7 +852,7 @@ describe('OperatorClauseTool', function () {
|
|
|
852
852
|
it('throws an error if a first argument is not an object', function () {
|
|
853
853
|
const throwable = () => S.testIlike(10);
|
|
854
854
|
expect(throwable).to.throw(
|
|
855
|
-
'
|
|
855
|
+
'The first argument of OperatorUtils.testIlike ' +
|
|
856
856
|
'should be an Object, but 10 given.',
|
|
857
857
|
);
|
|
858
858
|
});
|
|
@@ -931,7 +931,7 @@ describe('OperatorClauseTool', function () {
|
|
|
931
931
|
it('throws an error if a first argument is not an object', function () {
|
|
932
932
|
const throwable = () => S.testNilike(10);
|
|
933
933
|
expect(throwable).to.throw(
|
|
934
|
-
'
|
|
934
|
+
'The first argument of OperatorUtils.testNilike ' +
|
|
935
935
|
'should be an Object, but 10 given.',
|
|
936
936
|
);
|
|
937
937
|
});
|
|
@@ -1022,7 +1022,7 @@ describe('OperatorClauseTool', function () {
|
|
|
1022
1022
|
it('throws an error if a first argument is not an object', function () {
|
|
1023
1023
|
const throwable = () => S.testRegexp(10);
|
|
1024
1024
|
expect(throwable).to.throw(
|
|
1025
|
-
'
|
|
1025
|
+
'The first argument of OperatorUtils.testRegexp ' +
|
|
1026
1026
|
'should be an Object, but 10 given.',
|
|
1027
1027
|
);
|
|
1028
1028
|
});
|
|
@@ -1049,7 +1049,7 @@ describe('OperatorClauseTool', function () {
|
|
|
1049
1049
|
const throwable = v => () =>
|
|
1050
1050
|
S.testRegexp({regexp: 'Val.+', flags: v}, 'val');
|
|
1051
1051
|
const error = v =>
|
|
1052
|
-
format('RegExp flags
|
|
1052
|
+
format('RegExp flags should be a String, but %s given.', v);
|
|
1053
1053
|
expect(throwable(10)).to.throw(error('10'));
|
|
1054
1054
|
expect(throwable(true)).to.throw(error('true'));
|
|
1055
1055
|
expect(throwable([])).to.throw(error('Array'));
|
|
@@ -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;
|