@e22m4u/js-repository 0.4.0 → 0.5.1
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/README.md +569 -80
- package/dist/cjs/index.cjs +319 -270
- 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-transformation-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/adapter/decorator/property-uniqueness-decorator.js +1 -1
- package/src/definition/datasource/datasource-definition-validator.js +3 -3
- package/src/definition/datasource/datasource-definition-validator.spec.js +3 -3
- package/src/definition/model/model-data-sanitizer.js +2 -2
- package/src/definition/model/model-data-transformer.js +71 -13
- package/src/definition/model/model-data-transformer.spec.js +2073 -407
- package/src/definition/model/model-data-validator.js +125 -37
- package/src/definition/model/model-data-validator.spec.js +2138 -440
- package/src/definition/model/model-definition-utils.js +5 -5
- package/src/definition/model/model-definition-utils.spec.js +7 -7
- package/src/definition/model/model-definition-validator.js +7 -7
- package/src/definition/model/model-definition-validator.spec.js +10 -7
- package/src/definition/model/properties/properties-definition-validator.js +129 -54
- package/src/definition/model/properties/properties-definition-validator.spec.js +85 -25
- package/src/definition/model/properties/property-definition.d.ts +3 -3
- package/src/definition/model/properties/property-transformer/builtin/index.d.ts +0 -1
- package/src/definition/model/properties/property-transformer/builtin/index.js +0 -1
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.d.ts +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.spec.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.d.ts +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.spec.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.spec.js +1 -1
- package/src/definition/model/properties/property-transformer/property-transformer-registry.js +2 -4
- package/src/definition/model/properties/property-transformer/property-transformer-registry.spec.js +2 -4
- package/src/definition/model/properties/property-transformer/property-transformer.d.ts +2 -2
- package/src/definition/model/properties/property-uniqueness-validator.js +4 -4
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +4 -4
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.d.ts +1 -1
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.spec.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.d.ts +1 -1
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.spec.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.d.ts +1 -1
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.spec.js +2 -2
- package/src/definition/model/properties/property-validator/property-validator-registry.js +2 -2
- package/src/definition/model/properties/property-validator/property-validator-registry.spec.js +2 -2
- package/src/definition/model/properties/property-validator/property-validator.d.ts +2 -2
- package/src/definition/model/relations/relation-definition.d.ts +21 -21
- package/src/definition/model/relations/relations-definition-validator.js +23 -23
- package/src/definition/model/relations/relations-definition-validator.spec.js +24 -24
- 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 +5 -5
- package/src/filter/fields-clause-tool.spec.js +16 -16
- package/src/filter/include-clause-tool.js +6 -6
- package/src/filter/include-clause-tool.spec.js +2 -2
- 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 +3 -3
- package/src/filter/order-clause-tool.spec.js +4 -4
- package/src/filter/slice-clause-tool.js +5 -5
- package/src/filter/slice-clause-tool.spec.js +5 -5
- package/src/filter/where-clause-tool.js +4 -4
- package/src/filter/where-clause-tool.spec.js +3 -3
- package/src/relations/belongs-to-resolver.js +14 -14
- package/src/relations/belongs-to-resolver.spec.js +14 -14
- package/src/relations/has-many-resolver.js +22 -22
- package/src/relations/has-many-resolver.spec.js +23 -23
- package/src/relations/has-one-resolver.js +22 -22
- package/src/relations/has-one-resolver.spec.js +23 -23
- package/src/relations/references-many-resolver.js +7 -7
- package/src/relations/references-many-resolver.spec.js +7 -7
- package/src/repository/repository-registry.js +1 -1
- package/src/utils/exclude-object-keys.js +1 -1
- package/src/utils/exclude-object-keys.spec.js +1 -1
- 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 +3 -3
- package/src/utils/select-object-keys.spec.js +3 -3
- package/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.d.ts +0 -6
- package/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.js +0 -22
- package/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.spec.js +0 -41
|
@@ -23,7 +23,7 @@ describe('regexpValidator', function () {
|
|
|
23
23
|
const error = v =>
|
|
24
24
|
format(
|
|
25
25
|
'The property validator "myValidator" requires ' +
|
|
26
|
-
'a String value, but %s given.',
|
|
26
|
+
'a String value, but %s was given.',
|
|
27
27
|
v,
|
|
28
28
|
);
|
|
29
29
|
expect(throwable(true)).to.throw(error('true'));
|
|
@@ -45,7 +45,7 @@ describe('regexpValidator', function () {
|
|
|
45
45
|
const error = v =>
|
|
46
46
|
format(
|
|
47
47
|
'The validator "myValidator" requires the "options" argument ' +
|
|
48
|
-
'as a String or RegExp, but %s given.',
|
|
48
|
+
'as a String or RegExp, but %s was given.',
|
|
49
49
|
v,
|
|
50
50
|
);
|
|
51
51
|
expect(throwable(true)).to.throw(error('true'));
|
|
@@ -30,7 +30,7 @@ export class PropertyValidatorRegistry extends Service {
|
|
|
30
30
|
if (!name || typeof name !== 'string')
|
|
31
31
|
throw new InvalidArgumentError(
|
|
32
32
|
'A name of the property validator must ' +
|
|
33
|
-
'be a non-empty String, but %v given.',
|
|
33
|
+
'be a non-empty String, but %v was given.',
|
|
34
34
|
name,
|
|
35
35
|
);
|
|
36
36
|
if (name in this._validators)
|
|
@@ -40,7 +40,7 @@ export class PropertyValidatorRegistry extends Service {
|
|
|
40
40
|
);
|
|
41
41
|
if (typeof validator !== 'function')
|
|
42
42
|
throw new InvalidArgumentError(
|
|
43
|
-
'The property validator %v must be a Function, but %v given.',
|
|
43
|
+
'The property validator %v must be a Function, but %v was given.',
|
|
44
44
|
name,
|
|
45
45
|
validator,
|
|
46
46
|
);
|
package/src/definition/model/properties/property-validator/property-validator-registry.spec.js
CHANGED
|
@@ -30,7 +30,7 @@ describe('PropertyValidatorRegistry', function () {
|
|
|
30
30
|
const error = v =>
|
|
31
31
|
format(
|
|
32
32
|
'A name of the property validator must ' +
|
|
33
|
-
'be a non-empty String, but %s given.',
|
|
33
|
+
'be a non-empty String, but %s was given.',
|
|
34
34
|
v,
|
|
35
35
|
);
|
|
36
36
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -59,7 +59,7 @@ describe('PropertyValidatorRegistry', function () {
|
|
|
59
59
|
const throwable = v => () => pvr.addValidator('test', v);
|
|
60
60
|
const error = v =>
|
|
61
61
|
format(
|
|
62
|
-
'The property validator "test" must be a Function, but %s given.',
|
|
62
|
+
'The property validator "test" must be a Function, but %s was given.',
|
|
63
63
|
v,
|
|
64
64
|
);
|
|
65
65
|
expect(throwable('str')).to.throw(error('"str"'));
|
|
@@ -35,7 +35,7 @@ export declare type RelationDefinition =
|
|
|
35
35
|
* @example Required options only.
|
|
36
36
|
* ```
|
|
37
37
|
* {
|
|
38
|
-
* type:
|
|
38
|
+
* type: 'belongsTo',
|
|
39
39
|
* model: 'model',
|
|
40
40
|
* }
|
|
41
41
|
* ```
|
|
@@ -43,14 +43,14 @@ export declare type RelationDefinition =
|
|
|
43
43
|
* @example Verbose definition.
|
|
44
44
|
* ```
|
|
45
45
|
* {
|
|
46
|
-
* type:
|
|
46
|
+
* type: 'belongsTo',
|
|
47
47
|
* model: 'model',
|
|
48
48
|
* foreignKey: 'modelId',
|
|
49
49
|
* }
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
export declare type BelongsToDefinition = {
|
|
53
|
-
type: RelationType.BELONGS_TO
|
|
53
|
+
type: `${RelationType.BELONGS_TO}`;
|
|
54
54
|
polymorphic?: false;
|
|
55
55
|
model: string;
|
|
56
56
|
foreignKey?: string;
|
|
@@ -62,7 +62,7 @@ export declare type BelongsToDefinition = {
|
|
|
62
62
|
* @example Required fields only.
|
|
63
63
|
* ```
|
|
64
64
|
* {
|
|
65
|
-
* type:
|
|
65
|
+
* type: 'belongsTo',
|
|
66
66
|
* polymorphic: true,
|
|
67
67
|
* }
|
|
68
68
|
* ```
|
|
@@ -70,7 +70,7 @@ export declare type BelongsToDefinition = {
|
|
|
70
70
|
* @example Verbose definition.
|
|
71
71
|
* ```
|
|
72
72
|
* {
|
|
73
|
-
* type:
|
|
73
|
+
* type: 'belongsTo',
|
|
74
74
|
* polymorphic: true,
|
|
75
75
|
* foreignKey: 'referenceId',
|
|
76
76
|
* discriminator: 'referenceType',
|
|
@@ -78,7 +78,7 @@ export declare type BelongsToDefinition = {
|
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
80
|
export declare type PolyBelongsToDefinition = {
|
|
81
|
-
type: RelationType.BELONGS_TO
|
|
81
|
+
type: `${RelationType.BELONGS_TO}`;
|
|
82
82
|
polymorphic: true;
|
|
83
83
|
foreignKey?: string;
|
|
84
84
|
discriminator?: string;
|
|
@@ -90,14 +90,14 @@ export declare type PolyBelongsToDefinition = {
|
|
|
90
90
|
* @example
|
|
91
91
|
* ```ts
|
|
92
92
|
* {
|
|
93
|
-
* type:
|
|
93
|
+
* type: 'hasOne',
|
|
94
94
|
* model: 'model',
|
|
95
95
|
* foreignKey: 'modelId',
|
|
96
96
|
* }
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
99
|
export declare type HasOneDefinition = {
|
|
100
|
-
type: RelationType.HAS_ONE
|
|
100
|
+
type: `${RelationType.HAS_ONE}`;
|
|
101
101
|
model: string;
|
|
102
102
|
foreignKey: string;
|
|
103
103
|
polymorphic?: false;
|
|
@@ -110,14 +110,14 @@ export declare type HasOneDefinition = {
|
|
|
110
110
|
* @example
|
|
111
111
|
* ```ts
|
|
112
112
|
* {
|
|
113
|
-
* type:
|
|
113
|
+
* type: 'hasOne',
|
|
114
114
|
* model: 'model',
|
|
115
115
|
* polymorphic: 'reference',
|
|
116
116
|
* }
|
|
117
117
|
* ```
|
|
118
118
|
*/
|
|
119
119
|
export declare type PolyHasOneDefinitionWithTargetRelationName = {
|
|
120
|
-
type: RelationType.HAS_ONE
|
|
120
|
+
type: `${RelationType.HAS_ONE}`;
|
|
121
121
|
model: string;
|
|
122
122
|
polymorphic: string;
|
|
123
123
|
foreignKey?: undefined;
|
|
@@ -130,7 +130,7 @@ export declare type PolyHasOneDefinitionWithTargetRelationName = {
|
|
|
130
130
|
* @example
|
|
131
131
|
* ```
|
|
132
132
|
* {
|
|
133
|
-
* type:
|
|
133
|
+
* type: 'hasOne',
|
|
134
134
|
* model: 'model',
|
|
135
135
|
* polymorphic: true,
|
|
136
136
|
* foreignKey: 'referenceId',
|
|
@@ -139,7 +139,7 @@ export declare type PolyHasOneDefinitionWithTargetRelationName = {
|
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
141
|
export declare type PolyHasOneDefinitionWithTargetKeys = {
|
|
142
|
-
type: RelationType.HAS_ONE
|
|
142
|
+
type: `${RelationType.HAS_ONE}`;
|
|
143
143
|
model: string;
|
|
144
144
|
polymorphic: true;
|
|
145
145
|
foreignKey: string;
|
|
@@ -152,14 +152,14 @@ export declare type PolyHasOneDefinitionWithTargetKeys = {
|
|
|
152
152
|
* @example
|
|
153
153
|
* ```ts
|
|
154
154
|
* {
|
|
155
|
-
* type:
|
|
155
|
+
* type: 'hasMany',
|
|
156
156
|
* model: 'model',
|
|
157
157
|
* foreignKey: 'modelId',
|
|
158
158
|
* }
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
161
|
export declare type HasManyDefinition = {
|
|
162
|
-
type: RelationType.HAS_MANY
|
|
162
|
+
type: `${RelationType.HAS_MANY}`;
|
|
163
163
|
model: string;
|
|
164
164
|
foreignKey: string;
|
|
165
165
|
polymorphic?: false;
|
|
@@ -172,14 +172,14 @@ export declare type HasManyDefinition = {
|
|
|
172
172
|
* @example
|
|
173
173
|
* ```ts
|
|
174
174
|
* {
|
|
175
|
-
* type:
|
|
175
|
+
* type: 'hasMany',
|
|
176
176
|
* model: 'model',
|
|
177
177
|
* polymorphic: 'reference',
|
|
178
178
|
* }
|
|
179
179
|
* ```
|
|
180
180
|
*/
|
|
181
181
|
export declare type PolyHasManyDefinitionWithTargetRelationName = {
|
|
182
|
-
type: RelationType.HAS_MANY
|
|
182
|
+
type: `${RelationType.HAS_MANY}`;
|
|
183
183
|
model: string;
|
|
184
184
|
polymorphic: string;
|
|
185
185
|
foreignKey?: undefined;
|
|
@@ -192,7 +192,7 @@ export declare type PolyHasManyDefinitionWithTargetRelationName = {
|
|
|
192
192
|
* @example
|
|
193
193
|
* ```
|
|
194
194
|
* {
|
|
195
|
-
* type:
|
|
195
|
+
* type: 'hasMany',
|
|
196
196
|
* model: 'model',
|
|
197
197
|
* polymorphic: true,
|
|
198
198
|
* foreignKey: 'referenceId',
|
|
@@ -201,7 +201,7 @@ export declare type PolyHasManyDefinitionWithTargetRelationName = {
|
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
203
|
export declare type PolyHasManyDefinitionWithTargetKeys = {
|
|
204
|
-
type: RelationType.HAS_MANY
|
|
204
|
+
type: `${RelationType.HAS_MANY}`;
|
|
205
205
|
model: string;
|
|
206
206
|
polymorphic: true;
|
|
207
207
|
foreignKey: string;
|
|
@@ -214,7 +214,7 @@ export declare type PolyHasManyDefinitionWithTargetKeys = {
|
|
|
214
214
|
* @example Required options only.
|
|
215
215
|
* ```
|
|
216
216
|
* {
|
|
217
|
-
* type:
|
|
217
|
+
* type: 'referencesMany',
|
|
218
218
|
* model: 'model',
|
|
219
219
|
* }
|
|
220
220
|
* ```
|
|
@@ -222,14 +222,14 @@ export declare type PolyHasManyDefinitionWithTargetKeys = {
|
|
|
222
222
|
* @example Verbose definition.
|
|
223
223
|
* ```
|
|
224
224
|
* {
|
|
225
|
-
* type:
|
|
225
|
+
* type: 'referencesMany',
|
|
226
226
|
* model: 'model',
|
|
227
227
|
* foreignKey: 'modelIds',
|
|
228
228
|
* }
|
|
229
229
|
* ```
|
|
230
230
|
*/
|
|
231
231
|
export declare type ReferencesManyDefinition = {
|
|
232
|
-
type: RelationType.REFERENCES_MANY
|
|
232
|
+
type: `${RelationType.REFERENCES_MANY}`;
|
|
233
233
|
model: string;
|
|
234
234
|
foreignKey?: string;
|
|
235
235
|
discriminator?: undefined;
|
|
@@ -17,13 +17,13 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
17
17
|
if (!modelName || typeof modelName !== 'string')
|
|
18
18
|
throw new InvalidArgumentError(
|
|
19
19
|
'The first argument of RelationsDefinitionValidator.validate ' +
|
|
20
|
-
'should be a non-empty String, but %v given.',
|
|
20
|
+
'should be a non-empty String, but %v was given.',
|
|
21
21
|
modelName,
|
|
22
22
|
);
|
|
23
23
|
if (!relDefs || typeof relDefs !== 'object' || Array.isArray(relDefs))
|
|
24
24
|
throw new InvalidArgumentError(
|
|
25
25
|
'The provided option "relations" of the model %v ' +
|
|
26
|
-
'should be an Object, but %v given.',
|
|
26
|
+
'should be an Object, but %v was given.',
|
|
27
27
|
modelName,
|
|
28
28
|
relDefs,
|
|
29
29
|
);
|
|
@@ -45,19 +45,19 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
45
45
|
if (!modelName || typeof modelName !== 'string')
|
|
46
46
|
throw new InvalidArgumentError(
|
|
47
47
|
'The first argument of RelationsDefinitionValidator._validateRelation ' +
|
|
48
|
-
'should be a non-empty String, but %v given.',
|
|
48
|
+
'should be a non-empty String, but %v was given.',
|
|
49
49
|
modelName,
|
|
50
50
|
);
|
|
51
51
|
if (!relName || typeof relName !== 'string')
|
|
52
52
|
throw new InvalidArgumentError(
|
|
53
53
|
'The relation name of the model %v should be ' +
|
|
54
|
-
'a non-empty String, but %v given.',
|
|
54
|
+
'a non-empty String, but %v was given.',
|
|
55
55
|
modelName,
|
|
56
56
|
relName,
|
|
57
57
|
);
|
|
58
58
|
if (!relDef || typeof relDef !== 'object' || Array.isArray(relDef))
|
|
59
59
|
throw new InvalidArgumentError(
|
|
60
|
-
'The relation %v of the model %v should be an Object, but %v given.',
|
|
60
|
+
'The relation %v of the model %v should be an Object, but %v was given.',
|
|
61
61
|
relName,
|
|
62
62
|
modelName,
|
|
63
63
|
relDef,
|
|
@@ -65,7 +65,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
65
65
|
if (!relDef.type || !Object.values(Type).includes(relDef.type))
|
|
66
66
|
throw new InvalidArgumentError(
|
|
67
67
|
'The relation %v of the model %v requires the option "type" ' +
|
|
68
|
-
'to have one of relation types: %l, but %v given.',
|
|
68
|
+
'to have one of relation types: %l, but %v was given.',
|
|
69
69
|
relName,
|
|
70
70
|
modelName,
|
|
71
71
|
Object.values(Type),
|
|
@@ -112,7 +112,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
112
112
|
throw new InvalidArgumentError(
|
|
113
113
|
'The relation %v of the model %v has the type "belongsTo", ' +
|
|
114
114
|
'so it expects the option "polymorphic" to be a Boolean, ' +
|
|
115
|
-
'but %v given.',
|
|
115
|
+
'but %v was given.',
|
|
116
116
|
relName,
|
|
117
117
|
modelName,
|
|
118
118
|
relDef.polymorphic,
|
|
@@ -121,7 +121,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
121
121
|
throw new InvalidArgumentError(
|
|
122
122
|
'The relation %v of the model %v is a polymorphic "belongsTo" relation, ' +
|
|
123
123
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
124
|
-
'but %v given.',
|
|
124
|
+
'but %v was given.',
|
|
125
125
|
relName,
|
|
126
126
|
modelName,
|
|
127
127
|
relDef.foreignKey,
|
|
@@ -130,7 +130,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
130
130
|
throw new InvalidArgumentError(
|
|
131
131
|
'The relation %v of the model %v is a polymorphic "belongsTo" relation, ' +
|
|
132
132
|
'so it expects the provided option "discriminator" to be a String, ' +
|
|
133
|
-
'but %v given.',
|
|
133
|
+
'but %v was given.',
|
|
134
134
|
relName,
|
|
135
135
|
modelName,
|
|
136
136
|
relDef.discriminator,
|
|
@@ -141,7 +141,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
141
141
|
throw new InvalidArgumentError(
|
|
142
142
|
'The relation %v of the model %v has the type "belongsTo", ' +
|
|
143
143
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
144
|
-
'but %v given.',
|
|
144
|
+
'but %v was given.',
|
|
145
145
|
relName,
|
|
146
146
|
modelName,
|
|
147
147
|
relDef.model,
|
|
@@ -150,7 +150,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
150
150
|
throw new InvalidArgumentError(
|
|
151
151
|
'The relation %v of the model %v has the type "belongsTo", ' +
|
|
152
152
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
153
|
-
'but %v given.',
|
|
153
|
+
'but %v was given.',
|
|
154
154
|
relName,
|
|
155
155
|
modelName,
|
|
156
156
|
relDef.foreignKey,
|
|
@@ -208,7 +208,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
208
208
|
throw new InvalidArgumentError(
|
|
209
209
|
'The relation %v of the model %v has the type "hasOne", ' +
|
|
210
210
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
211
|
-
'but %v given.',
|
|
211
|
+
'but %v was given.',
|
|
212
212
|
relName,
|
|
213
213
|
modelName,
|
|
214
214
|
relDef.model,
|
|
@@ -238,7 +238,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
238
238
|
throw new InvalidArgumentError(
|
|
239
239
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
240
240
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
241
|
-
'to be a non-empty String, but %v given.',
|
|
241
|
+
'to be a non-empty String, but %v was given.',
|
|
242
242
|
relName,
|
|
243
243
|
modelName,
|
|
244
244
|
relDef.foreignKey,
|
|
@@ -247,7 +247,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
247
247
|
throw new InvalidArgumentError(
|
|
248
248
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
249
249
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
250
|
-
'to be a non-empty String, but %v given.',
|
|
250
|
+
'to be a non-empty String, but %v was given.',
|
|
251
251
|
relName,
|
|
252
252
|
modelName,
|
|
253
253
|
relDef.discriminator,
|
|
@@ -256,7 +256,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
256
256
|
throw new InvalidArgumentError(
|
|
257
257
|
'The relation %v of the model %v has the type "hasOne", ' +
|
|
258
258
|
'so it expects the provided option "polymorphic" to be ' +
|
|
259
|
-
'a String or a Boolean, but %v given.',
|
|
259
|
+
'a String or a Boolean, but %v was given.',
|
|
260
260
|
relName,
|
|
261
261
|
modelName,
|
|
262
262
|
relDef.polymorphic,
|
|
@@ -268,7 +268,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
268
268
|
throw new InvalidArgumentError(
|
|
269
269
|
'The relation %v of the model %v has the type "hasOne", ' +
|
|
270
270
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
271
|
-
'but %v given.',
|
|
271
|
+
'but %v was given.',
|
|
272
272
|
relName,
|
|
273
273
|
modelName,
|
|
274
274
|
relDef.foreignKey,
|
|
@@ -326,7 +326,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
326
326
|
throw new InvalidArgumentError(
|
|
327
327
|
'The relation %v of the model %v has the type "hasMany", ' +
|
|
328
328
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
329
|
-
'but %v given.',
|
|
329
|
+
'but %v was given.',
|
|
330
330
|
relName,
|
|
331
331
|
modelName,
|
|
332
332
|
relDef.model,
|
|
@@ -356,7 +356,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
356
356
|
throw new InvalidArgumentError(
|
|
357
357
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
358
358
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
359
|
-
'to be a non-empty String, but %v given.',
|
|
359
|
+
'to be a non-empty String, but %v was given.',
|
|
360
360
|
relName,
|
|
361
361
|
modelName,
|
|
362
362
|
relDef.foreignKey,
|
|
@@ -365,7 +365,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
365
365
|
throw new InvalidArgumentError(
|
|
366
366
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
367
367
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
368
|
-
'to be a non-empty String, but %v given.',
|
|
368
|
+
'to be a non-empty String, but %v was given.',
|
|
369
369
|
relName,
|
|
370
370
|
modelName,
|
|
371
371
|
relDef.discriminator,
|
|
@@ -374,7 +374,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
374
374
|
throw new InvalidArgumentError(
|
|
375
375
|
'The relation %v of the model %v has the type "hasMany", ' +
|
|
376
376
|
'so it expects the provided option "polymorphic" to be ' +
|
|
377
|
-
'a String or a Boolean, but %v given.',
|
|
377
|
+
'a String or a Boolean, but %v was given.',
|
|
378
378
|
relName,
|
|
379
379
|
modelName,
|
|
380
380
|
relDef.polymorphic,
|
|
@@ -386,7 +386,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
386
386
|
throw new InvalidArgumentError(
|
|
387
387
|
'The relation %v of the model %v has the type "hasMany", ' +
|
|
388
388
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
389
|
-
'but %v given.',
|
|
389
|
+
'but %v was given.',
|
|
390
390
|
relName,
|
|
391
391
|
modelName,
|
|
392
392
|
relDef.foreignKey,
|
|
@@ -424,7 +424,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
424
424
|
throw new InvalidArgumentError(
|
|
425
425
|
'The relation %v of the model %v has the type "referencesMany", ' +
|
|
426
426
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
427
|
-
'but %v given.',
|
|
427
|
+
'but %v was given.',
|
|
428
428
|
relName,
|
|
429
429
|
modelName,
|
|
430
430
|
relDef.model,
|
|
@@ -433,7 +433,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
433
433
|
throw new InvalidArgumentError(
|
|
434
434
|
'The relation %v of the model %v has the type "referencesMany", ' +
|
|
435
435
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
436
|
-
'but %v given.',
|
|
436
|
+
'but %v was given.',
|
|
437
437
|
relName,
|
|
438
438
|
modelName,
|
|
439
439
|
relDef.foreignKey,
|
|
@@ -12,7 +12,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
12
12
|
const error = v =>
|
|
13
13
|
format(
|
|
14
14
|
'The first argument of RelationsDefinitionValidator.validate ' +
|
|
15
|
-
'should be a non-empty String, but %s given.',
|
|
15
|
+
'should be a non-empty String, but %s was given.',
|
|
16
16
|
v,
|
|
17
17
|
);
|
|
18
18
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -31,7 +31,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
31
31
|
const error = v =>
|
|
32
32
|
format(
|
|
33
33
|
'The provided option "relations" of the model "model" ' +
|
|
34
|
-
'should be an Object, but %s given.',
|
|
34
|
+
'should be an Object, but %s was given.',
|
|
35
35
|
v,
|
|
36
36
|
);
|
|
37
37
|
expect(validate('str')).to.throw(error('"str"'));
|
|
@@ -49,7 +49,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
49
49
|
const error = v =>
|
|
50
50
|
format(
|
|
51
51
|
'The relation name of the model "model" should be ' +
|
|
52
|
-
'a non-empty String, but %s given.',
|
|
52
|
+
'a non-empty String, but %s was given.',
|
|
53
53
|
v,
|
|
54
54
|
);
|
|
55
55
|
expect(validate({['']: {}})).to.throw(error('""'));
|
|
@@ -61,7 +61,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
61
61
|
const error = v =>
|
|
62
62
|
format(
|
|
63
63
|
'The relation "foo" of the model "model" should ' +
|
|
64
|
-
'be an Object, but %s given.',
|
|
64
|
+
'be an Object, but %s was given.',
|
|
65
65
|
v,
|
|
66
66
|
);
|
|
67
67
|
expect(validate('str')).to.throw(error('"str"'));
|
|
@@ -82,7 +82,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
82
82
|
const error = v =>
|
|
83
83
|
format(
|
|
84
84
|
'The relation "foo" of the model "model" requires the option "type" ' +
|
|
85
|
-
'to have one of relation types: %l, but %s given.',
|
|
85
|
+
'to have one of relation types: %l, but %s was given.',
|
|
86
86
|
Object.values(RelationType),
|
|
87
87
|
v,
|
|
88
88
|
);
|
|
@@ -111,7 +111,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
111
111
|
format(
|
|
112
112
|
'The relation "foo" of the model "model" has the type "belongsTo", ' +
|
|
113
113
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
114
|
-
'but %s given.',
|
|
114
|
+
'but %s was given.',
|
|
115
115
|
v,
|
|
116
116
|
);
|
|
117
117
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -138,7 +138,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
138
138
|
format(
|
|
139
139
|
'The relation "foo" of the model "model" has the type "belongsTo", ' +
|
|
140
140
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
141
|
-
'but %s given.',
|
|
141
|
+
'but %s was given.',
|
|
142
142
|
v,
|
|
143
143
|
);
|
|
144
144
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -181,7 +181,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
181
181
|
format(
|
|
182
182
|
'The relation "foo" of the model "model" has the type "belongsTo", ' +
|
|
183
183
|
'so it expects the option "polymorphic" to be a Boolean, ' +
|
|
184
|
-
'but %s given.',
|
|
184
|
+
'but %s was given.',
|
|
185
185
|
v,
|
|
186
186
|
);
|
|
187
187
|
expect(validate('str')).to.throw(error('"str"'));
|
|
@@ -204,7 +204,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
204
204
|
format(
|
|
205
205
|
'The relation "foo" of the model "model" is a polymorphic "belongsTo" relation, ' +
|
|
206
206
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
207
|
-
'but %s given.',
|
|
207
|
+
'but %s was given.',
|
|
208
208
|
v,
|
|
209
209
|
);
|
|
210
210
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -231,7 +231,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
231
231
|
format(
|
|
232
232
|
'The relation "foo" of the model "model" is a polymorphic "belongsTo" relation, ' +
|
|
233
233
|
'so it expects the provided option "discriminator" to be a String, ' +
|
|
234
|
-
'but %s given.',
|
|
234
|
+
'but %s was given.',
|
|
235
235
|
v,
|
|
236
236
|
);
|
|
237
237
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -262,7 +262,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
262
262
|
format(
|
|
263
263
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
264
264
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
265
|
-
'but %s given.',
|
|
265
|
+
'but %s was given.',
|
|
266
266
|
v,
|
|
267
267
|
);
|
|
268
268
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -289,7 +289,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
289
289
|
format(
|
|
290
290
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
291
291
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
292
|
-
'but %s given.',
|
|
292
|
+
'but %s was given.',
|
|
293
293
|
v,
|
|
294
294
|
);
|
|
295
295
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -334,7 +334,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
334
334
|
format(
|
|
335
335
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
336
336
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
337
|
-
'but %s given.',
|
|
337
|
+
'but %s was given.',
|
|
338
338
|
v,
|
|
339
339
|
);
|
|
340
340
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -399,7 +399,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
399
399
|
format(
|
|
400
400
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
401
401
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
402
|
-
'but %s given.',
|
|
402
|
+
'but %s was given.',
|
|
403
403
|
v,
|
|
404
404
|
);
|
|
405
405
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -428,7 +428,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
428
428
|
format(
|
|
429
429
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
430
430
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
431
|
-
'to be a non-empty String, but %s given.',
|
|
431
|
+
'to be a non-empty String, but %s was given.',
|
|
432
432
|
v,
|
|
433
433
|
);
|
|
434
434
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -457,7 +457,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
457
457
|
format(
|
|
458
458
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
459
459
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
460
|
-
'to be a non-empty String, but %s given.',
|
|
460
|
+
'to be a non-empty String, but %s was given.',
|
|
461
461
|
v,
|
|
462
462
|
);
|
|
463
463
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -488,7 +488,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
488
488
|
format(
|
|
489
489
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
490
490
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
491
|
-
'but %s given.',
|
|
491
|
+
'but %s was given.',
|
|
492
492
|
v,
|
|
493
493
|
);
|
|
494
494
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -515,7 +515,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
515
515
|
format(
|
|
516
516
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
517
517
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
518
|
-
'but %s given.',
|
|
518
|
+
'but %s was given.',
|
|
519
519
|
v,
|
|
520
520
|
);
|
|
521
521
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -560,7 +560,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
560
560
|
format(
|
|
561
561
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
562
562
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
563
|
-
'but %s given.',
|
|
563
|
+
'but %s was given.',
|
|
564
564
|
v,
|
|
565
565
|
);
|
|
566
566
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -625,7 +625,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
625
625
|
format(
|
|
626
626
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
627
627
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
628
|
-
'but %s given.',
|
|
628
|
+
'but %s was given.',
|
|
629
629
|
v,
|
|
630
630
|
);
|
|
631
631
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -654,7 +654,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
654
654
|
format(
|
|
655
655
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
656
656
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
657
|
-
'to be a non-empty String, but %s given.',
|
|
657
|
+
'to be a non-empty String, but %s was given.',
|
|
658
658
|
v,
|
|
659
659
|
);
|
|
660
660
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -683,7 +683,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
683
683
|
format(
|
|
684
684
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
685
685
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
686
|
-
'to be a non-empty String, but %s given.',
|
|
686
|
+
'to be a non-empty String, but %s was given.',
|
|
687
687
|
v,
|
|
688
688
|
);
|
|
689
689
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -712,7 +712,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
712
712
|
format(
|
|
713
713
|
'The relation "foo" of the model "model" has the type "referencesMany", ' +
|
|
714
714
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
715
|
-
'but %s given.',
|
|
715
|
+
'but %s was given.',
|
|
716
716
|
v,
|
|
717
717
|
);
|
|
718
718
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -739,7 +739,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
739
739
|
format(
|
|
740
740
|
'The relation "foo" of the model "model" has the type "referencesMany", ' +
|
|
741
741
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
742
|
-
'but %s given.',
|
|
742
|
+
'but %s was given.',
|
|
743
743
|
v,
|
|
744
744
|
);
|
|
745
745
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -14,7 +14,7 @@ export class InvalidOperatorValueError extends Error {
|
|
|
14
14
|
constructor(operator, expected, value) {
|
|
15
15
|
super(
|
|
16
16
|
format(
|
|
17
|
-
'Condition of {%s: ...} should have %s, but %v given.',
|
|
17
|
+
'Condition of {%s: ...} should have %s, but %v was given.',
|
|
18
18
|
operator,
|
|
19
19
|
expected,
|
|
20
20
|
value,
|
|
@@ -5,7 +5,7 @@ describe('InvalidOperatorValueError', function () {
|
|
|
5
5
|
it('sets specific message', function () {
|
|
6
6
|
const error = new InvalidOperatorValueError('exists', 'a boolean', '');
|
|
7
7
|
const message =
|
|
8
|
-
'Condition of {exists: ...} should have a boolean, but "" given.';
|
|
8
|
+
'Condition of {exists: ...} should have a boolean, but "" was given.';
|
|
9
9
|
expect(error.message).to.be.eq(message);
|
|
10
10
|
});
|
|
11
11
|
});
|