@e22m4u/js-repository 0.8.6 → 0.8.8
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/build-cjs.js +1 -1
- package/dist/cjs/index.cjs +560 -491
- package/package.json +8 -8
- package/src/adapter/adapter-loader.js +2 -5
- package/src/adapter/adapter-loader.spec.js +2 -2
- package/src/adapter/adapter-registry.spec.js +2 -2
- package/src/adapter/builtin/memory-adapter.js +5 -5
- package/src/adapter/builtin/memory-adapter.spec.js +12 -12
- package/src/adapter/decorator/data-sanitizing-decorator.js +1 -2
- package/src/adapter/decorator/default-values-decorator.js +1 -2
- package/src/adapter/decorator/fields-filtering-decorator.js +1 -2
- package/src/adapter/decorator/inclusion-decorator.js +1 -2
- package/src/adapter/decorator/property-uniqueness-decorator.js +1 -2
- package/src/adapter/decorator/required-property-decorator.js +1 -2
- package/src/database-schema.spec.js +3 -5
- package/src/definition/datasource/datasource-definition-validator.js +3 -3
- package/src/definition/datasource/datasource-definition-validator.spec.js +3 -6
- package/src/definition/definition-registry.js +4 -7
- package/src/definition/definition-registry.spec.js +4 -6
- package/src/definition/model/model-data-sanitizer.js +2 -4
- package/src/definition/model/model-definition-utils.js +12 -14
- package/src/definition/model/model-definition-utils.spec.js +12 -21
- package/src/definition/model/model-definition-validator.js +12 -12
- package/src/definition/model/model-definition-validator.spec.js +12 -15
- package/src/definition/model/properties/primary-keys-definition-validator.js +4 -4
- package/src/definition/model/properties/primary-keys-definition-validator.spec.js +8 -8
- package/src/definition/model/properties/properties-definition-validator.js +42 -43
- package/src/definition/model/properties/properties-definition-validator.spec.js +45 -45
- package/src/definition/model/properties/property-uniqueness-validator.js +7 -11
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +57 -60
- package/src/definition/model/properties/required-property-validator.js +1 -1
- package/src/definition/model/properties/required-property-validator.spec.js +1 -1
- package/src/definition/model/relations/relations-definition-validator.js +40 -42
- package/src/definition/model/relations/relations-definition-validator.spec.js +44 -45
- package/src/errors/invalid-operator-value-error.js +1 -1
- package/src/errors/invalid-operator-value-error.spec.js +1 -1
- package/src/filter/fields-clause-tool.js +95 -53
- package/src/filter/fields-clause-tool.spec.js +210 -387
- package/src/filter/include-clause-tool.js +9 -9
- package/src/filter/include-clause-tool.spec.js +4 -4
- package/src/filter/operator-clause-tool.js +20 -32
- package/src/filter/operator-clause-tool.spec.js +25 -49
- package/src/filter/order-clause-tool.js +55 -27
- package/src/filter/order-clause-tool.spec.js +151 -90
- package/src/filter/slice-clause-tool.js +5 -6
- package/src/filter/slice-clause-tool.spec.js +8 -24
- package/src/filter/where-clause-tool.js +18 -11
- package/src/filter/where-clause-tool.spec.js +27 -17
- package/src/relations/belongs-to-resolver.js +18 -30
- package/src/relations/belongs-to-resolver.spec.js +21 -44
- package/src/relations/has-many-resolver.js +28 -44
- package/src/relations/has-many-resolver.spec.js +44 -68
- package/src/relations/has-one-resolver.js +28 -44
- package/src/relations/has-one-resolver.spec.js +44 -68
- package/src/relations/references-many-resolver.js +8 -14
- package/src/relations/references-many-resolver.spec.js +12 -24
- package/src/repository/repository-registry.js +2 -2
- package/src/repository/repository.js +1 -1
- package/src/utils/exclude-object-keys.js +2 -2
- package/src/utils/exclude-object-keys.spec.js +2 -2
- package/src/utils/like-to-regexp.js +1 -2
- package/src/utils/like-to-regexp.spec.js +5 -5
- package/src/utils/model-name-to-model-key.js +1 -1
- package/src/utils/model-name-to-model-key.spec.js +7 -7
- package/src/utils/select-object-keys.js +6 -7
- package/src/utils/select-object-keys.spec.js +3 -6
|
@@ -10,23 +10,22 @@ import {InvalidArgumentError} from '../errors/index.js';
|
|
|
10
10
|
export function selectObjectKeys(obj, keys) {
|
|
11
11
|
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
|
|
12
12
|
throw new InvalidArgumentError(
|
|
13
|
-
'
|
|
14
|
-
'should be an Object, but %v was given.',
|
|
13
|
+
'Parameter "obj" must be an Object, but %v was given.',
|
|
15
14
|
obj,
|
|
16
15
|
);
|
|
17
16
|
}
|
|
18
17
|
if (!Array.isArray(keys)) {
|
|
19
18
|
throw new InvalidArgumentError(
|
|
20
|
-
'
|
|
21
|
-
'should be an Array of String, but %v was given.',
|
|
19
|
+
'Parameter "keys" must be an Array, but %v was given.',
|
|
22
20
|
keys,
|
|
23
21
|
);
|
|
24
22
|
}
|
|
25
|
-
keys.forEach(key => {
|
|
23
|
+
keys.forEach((key, index) => {
|
|
26
24
|
if (typeof key !== 'string') {
|
|
27
25
|
throw new InvalidArgumentError(
|
|
28
|
-
'
|
|
29
|
-
'
|
|
26
|
+
'Element %d of the parameter "keys" must be a String, ' +
|
|
27
|
+
'but %v was given.',
|
|
28
|
+
index,
|
|
30
29
|
key,
|
|
31
30
|
);
|
|
32
31
|
}
|
|
@@ -17,24 +17,21 @@ describe('selectObjectKeys', function () {
|
|
|
17
17
|
it('throws an error if a given value is not an Object', function () {
|
|
18
18
|
const throwable = () => selectObjectKeys(10, ['key']);
|
|
19
19
|
expect(throwable).to.throw(
|
|
20
|
-
'
|
|
21
|
-
'should be an Object, but 10 was given.',
|
|
20
|
+
'Parameter "obj" must be an Object, but 10 was given.',
|
|
22
21
|
);
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
it('throws an error if a given keys is not an Array', function () {
|
|
26
25
|
const throwable = () => selectObjectKeys({});
|
|
27
26
|
expect(throwable).to.throw(
|
|
28
|
-
'
|
|
29
|
-
'should be an Array of String, but undefined was given.',
|
|
27
|
+
'Parameter "keys" must be an Array, but undefined was given.',
|
|
30
28
|
);
|
|
31
29
|
});
|
|
32
30
|
|
|
33
31
|
it('throws an error if a given keys is not an String', function () {
|
|
34
32
|
const throwable = () => selectObjectKeys({}, [10]);
|
|
35
33
|
expect(throwable).to.throw(
|
|
36
|
-
'
|
|
37
|
-
'should be an Array of String, but 10 was given.',
|
|
34
|
+
'Element 0 of the parameter "keys" must be a String, but 10 was given.',
|
|
38
35
|
);
|
|
39
36
|
});
|
|
40
37
|
});
|