@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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/adapter/adapter-loader.js +1 -1
  3. package/src/adapter/adapter-loader.spec.js +1 -1
  4. package/src/adapter/decorator/data-sanitizing-decorator.js +1 -1
  5. package/src/adapter/decorator/data-validation-decorator.js +1 -1
  6. package/src/adapter/decorator/default-values-decorator.js +1 -1
  7. package/src/adapter/decorator/fields-filtering-decorator.js +1 -1
  8. package/src/adapter/decorator/inclusion-decorator.js +1 -1
  9. package/src/definition/model/model-data-sanitizer.js +2 -2
  10. package/src/definition/model/model-data-validator.js +1 -1
  11. package/src/definition/model/model-data-validator.spec.js +1 -1
  12. package/src/definition/model/model-definition-utils.js +1 -1
  13. package/src/definition/model/model-definition-utils.spec.js +1 -1
  14. package/src/definition/model/properties/default-values-definition-validator.js +1 -1
  15. package/src/definition/model/properties/default-values-definition-validator.spec.js +1 -1
  16. package/src/definition/model/properties/properties-definition-validator.js +2 -2
  17. package/src/definition/model/properties/properties-definition-validator.spec.js +1 -1
  18. package/src/definition/model/relations/relations-definition-validator.js +2 -2
  19. package/src/definition/model/relations/relations-definition-validator.spec.js +1 -1
  20. package/src/filter/fields-clause-tool.d.ts +2 -2
  21. package/src/filter/fields-clause-tool.js +32 -21
  22. package/src/filter/fields-clause-tool.spec.js +479 -100
  23. package/src/filter/include-clause-tool.js +50 -42
  24. package/src/filter/include-clause-tool.spec.js +4391 -291
  25. package/src/filter/operator-clause-tool.js +13 -13
  26. package/src/filter/operator-clause-tool.spec.js +13 -13
  27. package/src/filter/order-clause-tool.js +20 -17
  28. package/src/filter/order-clause-tool.spec.js +621 -362
  29. package/src/filter/slice-clause-tool.js +5 -5
  30. package/src/filter/slice-clause-tool.spec.js +92 -51
  31. package/src/filter/where-clause-tool.js +7 -7
  32. package/src/filter/where-clause-tool.spec.js +79 -55
  33. package/src/utils/select-object-keys.js +3 -3
  34. 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
- 'A first argument of OperatorUtils.testAll ' +
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
- 'A first argument of OperatorUtils.testEqNeq ' +
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
- 'A first argument of OperatorUtils.testGtLt ' +
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
- 'A first argument of OperatorUtils.testInq ' +
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
- 'A first argument of OperatorUtils.testNin ' +
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
- 'A first argument of OperatorUtils.testBetween ' +
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
- 'A first argument of OperatorUtils.testExists ' +
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
- 'A first argument of OperatorUtils.testLike ' +
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
- 'A first argument of OperatorUtils.testNlike ' +
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
- 'A first argument of OperatorUtils.testIlike ' +
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
- 'A first argument of OperatorUtils.testNilike ' +
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
- 'A first argument of OperatorUtils.testRegexp ' +
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 must be a String, but %v given.',
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
- 'A first argument of OperatorUtils.testAll ' +
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
- 'A first argument of OperatorUtils.testEqNeq ' +
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
- 'A first argument of OperatorUtils.testGtLt ' +
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
- 'A first argument of OperatorUtils.testInq ' +
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
- 'A first argument of OperatorUtils.testNin ' +
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
- 'A first argument of OperatorUtils.testBetween ' +
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
- 'A first argument of OperatorUtils.testExists ' +
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
- 'A first argument of OperatorUtils.testLike ' +
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
- 'A first argument of OperatorUtils.testNlike ' +
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
- 'A first argument of OperatorUtils.testIlike ' +
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
- 'A first argument of OperatorUtils.testNilike ' +
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
- 'A first argument of OperatorUtils.testRegexp ' +
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 must be a String, but %s given.', v);
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 (!clause) return;
17
- if (!Array.isArray(clause)) clause = [clause];
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 (!clause) return;
44
- const tempClause = Array.isArray(clause) ? clause : [clause];
45
- tempClause.forEach(key => {
46
- if (!key || typeof key !== 'string')
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
- key,
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 (!clause) return;
63
- clause = Array.isArray(clause) ? clause : [clause];
64
- clause.forEach(key => {
65
- if (!key || typeof key !== 'string')
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
- key,
71
+ 'or an Array of non-empty String, but %v given.',
72
+ field,
70
73
  );
71
74
  });
72
75
  return clause;