@e22m4u/js-repository 0.8.7 → 0.8.9
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/dist/cjs/index.cjs +452 -406
- package/package.json +7 -7
- 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.d.ts +10 -0
- package/src/definition/definition-registry.js +28 -19
- package/src/definition/definition-registry.spec.js +64 -117
- 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 +4 -6
- package/src/repository/repository-registry.spec.js +0 -19
- 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/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/like-to-regexp.js +1 -2
- package/src/utils/like-to-regexp.spec.js +5 -5
- package/src/utils/select-object-keys.js +6 -7
- package/src/utils/select-object-keys.spec.js +3 -6
- package/src/utils/model-name-to-model-key.d.ts +0 -6
- package/src/utils/model-name-to-model-key.js +0 -18
- package/src/utils/model-name-to-model-key.spec.js +0 -94
|
@@ -29,43 +29,38 @@ export class BelongsToResolver extends Service {
|
|
|
29
29
|
) {
|
|
30
30
|
if (!entities || !Array.isArray(entities)) {
|
|
31
31
|
throw new InvalidArgumentError(
|
|
32
|
-
'
|
|
33
|
-
'an Array of Object, but %v was given.',
|
|
32
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
34
33
|
entities,
|
|
35
34
|
);
|
|
36
35
|
}
|
|
37
36
|
if (!sourceName || typeof sourceName !== 'string') {
|
|
38
37
|
throw new InvalidArgumentError(
|
|
39
|
-
'
|
|
40
|
-
'a non-empty String, but %v was given.',
|
|
38
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
41
39
|
sourceName,
|
|
42
40
|
);
|
|
43
41
|
}
|
|
44
42
|
if (!targetName || typeof targetName !== 'string') {
|
|
45
43
|
throw new InvalidArgumentError(
|
|
46
|
-
'
|
|
47
|
-
'a non-empty String, but %v was given.',
|
|
44
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
48
45
|
targetName,
|
|
49
46
|
);
|
|
50
47
|
}
|
|
51
48
|
if (!relationName || typeof relationName !== 'string') {
|
|
52
49
|
throw new InvalidArgumentError(
|
|
53
|
-
'
|
|
54
|
-
'
|
|
50
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
51
|
+
'but %v was given.',
|
|
55
52
|
relationName,
|
|
56
53
|
);
|
|
57
54
|
}
|
|
58
55
|
if (foreignKey && typeof foreignKey !== 'string') {
|
|
59
56
|
throw new InvalidArgumentError(
|
|
60
|
-
'
|
|
61
|
-
'should be a String, but %v was given.',
|
|
57
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
62
58
|
foreignKey,
|
|
63
59
|
);
|
|
64
60
|
}
|
|
65
61
|
if (scope && (typeof scope !== 'object' || Array.isArray(scope))) {
|
|
66
62
|
throw new InvalidArgumentError(
|
|
67
|
-
'
|
|
68
|
-
'should be an Object, but %v was given.',
|
|
63
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
69
64
|
scope,
|
|
70
65
|
);
|
|
71
66
|
}
|
|
@@ -75,8 +70,7 @@ export class BelongsToResolver extends Service {
|
|
|
75
70
|
const targetIds = entities.reduce((acc, entity) => {
|
|
76
71
|
if (!entity || typeof entity !== 'object' || Array.isArray(entity)) {
|
|
77
72
|
throw new InvalidArgumentError(
|
|
78
|
-
'
|
|
79
|
-
'an Array of Object, but %v was given.',
|
|
73
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
80
74
|
entity,
|
|
81
75
|
);
|
|
82
76
|
}
|
|
@@ -129,43 +123,38 @@ export class BelongsToResolver extends Service {
|
|
|
129
123
|
) {
|
|
130
124
|
if (!entities || !Array.isArray(entities)) {
|
|
131
125
|
throw new InvalidArgumentError(
|
|
132
|
-
'
|
|
133
|
-
'requires an Array of Object, but %v was given.',
|
|
126
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
134
127
|
entities,
|
|
135
128
|
);
|
|
136
129
|
}
|
|
137
130
|
if (!sourceName || typeof sourceName !== 'string') {
|
|
138
131
|
throw new InvalidArgumentError(
|
|
139
|
-
'
|
|
140
|
-
'requires a non-empty String, but %v was given.',
|
|
132
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
141
133
|
sourceName,
|
|
142
134
|
);
|
|
143
135
|
}
|
|
144
136
|
if (!relationName || typeof relationName !== 'string') {
|
|
145
137
|
throw new InvalidArgumentError(
|
|
146
|
-
'
|
|
147
|
-
'
|
|
138
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
139
|
+
'but %v was given.',
|
|
148
140
|
relationName,
|
|
149
141
|
);
|
|
150
142
|
}
|
|
151
143
|
if (foreignKey && typeof foreignKey !== 'string') {
|
|
152
144
|
throw new InvalidArgumentError(
|
|
153
|
-
'
|
|
154
|
-
'should be a String, but %v was given.',
|
|
145
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
155
146
|
foreignKey,
|
|
156
147
|
);
|
|
157
148
|
}
|
|
158
149
|
if (discriminator && typeof discriminator !== 'string') {
|
|
159
150
|
throw new InvalidArgumentError(
|
|
160
|
-
'
|
|
161
|
-
'should be a String, but %v was given.',
|
|
151
|
+
'Parameter "discriminator" must be a String, but %v was given.',
|
|
162
152
|
discriminator,
|
|
163
153
|
);
|
|
164
154
|
}
|
|
165
155
|
if (scope && (typeof scope !== 'object' || Array.isArray(scope))) {
|
|
166
156
|
throw new InvalidArgumentError(
|
|
167
|
-
'
|
|
168
|
-
'should be an Object, but %v was given.',
|
|
157
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
169
158
|
scope,
|
|
170
159
|
);
|
|
171
160
|
}
|
|
@@ -181,8 +170,7 @@ export class BelongsToResolver extends Service {
|
|
|
181
170
|
entities.forEach(entity => {
|
|
182
171
|
if (!entity || typeof entity !== 'object' || Array.isArray(entity)) {
|
|
183
172
|
throw new InvalidArgumentError(
|
|
184
|
-
'
|
|
185
|
-
'an Array of Object, but %v was given.',
|
|
173
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
186
174
|
entity,
|
|
187
175
|
);
|
|
188
176
|
}
|
|
@@ -210,9 +198,9 @@ export class BelongsToResolver extends Service {
|
|
|
210
198
|
} catch (error) {
|
|
211
199
|
if (error instanceof InvalidArgumentError) {
|
|
212
200
|
if (
|
|
213
|
-
error.message === `
|
|
201
|
+
error.message === `Model "${targetName}" is not defined.` ||
|
|
214
202
|
error.message ===
|
|
215
|
-
`
|
|
203
|
+
`Model "${targetName}" does not have a specified datasource.`
|
|
216
204
|
) {
|
|
217
205
|
return;
|
|
218
206
|
}
|
|
@@ -16,8 +16,7 @@ describe('BelongsToResolver', function () {
|
|
|
16
16
|
const R = dbs.getService(BelongsToResolver);
|
|
17
17
|
const error = v =>
|
|
18
18
|
format(
|
|
19
|
-
'
|
|
20
|
-
'an Array of Object, but %s was given.',
|
|
19
|
+
'Parameter "entities" must be an Array of Object, but %s was given.',
|
|
21
20
|
v,
|
|
22
21
|
);
|
|
23
22
|
const throwable = v =>
|
|
@@ -37,8 +36,7 @@ describe('BelongsToResolver', function () {
|
|
|
37
36
|
const R = dbs.getService(BelongsToResolver);
|
|
38
37
|
const error = v =>
|
|
39
38
|
format(
|
|
40
|
-
'
|
|
41
|
-
'an Array of Object, but %s was given.',
|
|
39
|
+
'Parameter "entities" must be an Array of Object, but %s was given.',
|
|
42
40
|
v,
|
|
43
41
|
);
|
|
44
42
|
const throwable = v =>
|
|
@@ -58,8 +56,8 @@ describe('BelongsToResolver', function () {
|
|
|
58
56
|
const R = dbs.getService(BelongsToResolver);
|
|
59
57
|
const error = v =>
|
|
60
58
|
format(
|
|
61
|
-
'
|
|
62
|
-
'
|
|
59
|
+
'Parameter "sourceName" must be a non-empty String, ' +
|
|
60
|
+
'but %s was given.',
|
|
63
61
|
v,
|
|
64
62
|
);
|
|
65
63
|
const throwable = v => R.includeTo([], v, 'targetName', 'relationName');
|
|
@@ -78,8 +76,8 @@ describe('BelongsToResolver', function () {
|
|
|
78
76
|
const R = dbs.getService(BelongsToResolver);
|
|
79
77
|
const error = v =>
|
|
80
78
|
format(
|
|
81
|
-
'
|
|
82
|
-
'
|
|
79
|
+
'Parameter "targetName" must be a non-empty String, ' +
|
|
80
|
+
'but %s was given.',
|
|
83
81
|
v,
|
|
84
82
|
);
|
|
85
83
|
const throwable = v => R.includeTo([], 'sourceName', v, 'relationName');
|
|
@@ -98,8 +96,8 @@ describe('BelongsToResolver', function () {
|
|
|
98
96
|
const R = dbs.getService(BelongsToResolver);
|
|
99
97
|
const error = v =>
|
|
100
98
|
format(
|
|
101
|
-
'
|
|
102
|
-
'
|
|
99
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
100
|
+
'but %s was given.',
|
|
103
101
|
v,
|
|
104
102
|
);
|
|
105
103
|
const throwable = v => R.includeTo([], 'sourceName', 'targetName', v);
|
|
@@ -117,11 +115,7 @@ describe('BelongsToResolver', function () {
|
|
|
117
115
|
const dbs = new DatabaseSchema();
|
|
118
116
|
const R = dbs.getService(BelongsToResolver);
|
|
119
117
|
const error = v =>
|
|
120
|
-
format(
|
|
121
|
-
'The provided parameter "foreignKey" of BelongsToResolver.includeTo ' +
|
|
122
|
-
'should be a String, but %s was given.',
|
|
123
|
-
v,
|
|
124
|
-
);
|
|
118
|
+
format('Parameter "foreignKey" must be a String, but %s was given.', v);
|
|
125
119
|
const throwable = v =>
|
|
126
120
|
R.includeTo([], 'sourceName', 'targetName', 'relationName', v);
|
|
127
121
|
await expect(throwable(10)).to.be.rejectedWith(error('10'));
|
|
@@ -134,11 +128,7 @@ describe('BelongsToResolver', function () {
|
|
|
134
128
|
const dbs = new DatabaseSchema();
|
|
135
129
|
const R = dbs.getService(BelongsToResolver);
|
|
136
130
|
const error = v =>
|
|
137
|
-
format(
|
|
138
|
-
'The provided parameter "scope" of BelongsToResolver.includeTo ' +
|
|
139
|
-
'should be an Object, but %s was given.',
|
|
140
|
-
v,
|
|
141
|
-
);
|
|
131
|
+
format('Parameter "scope" must be an Object, but %s was given.', v);
|
|
142
132
|
const throwable = v =>
|
|
143
133
|
R.includeTo(
|
|
144
134
|
[],
|
|
@@ -159,9 +149,7 @@ describe('BelongsToResolver', function () {
|
|
|
159
149
|
dbs.defineModel({name: 'source'});
|
|
160
150
|
const R = dbs.getService(BelongsToResolver);
|
|
161
151
|
const promise = R.includeTo([], 'source', 'target', 'relation');
|
|
162
|
-
await expect(promise).to.be.rejectedWith(
|
|
163
|
-
'The model "target" is not defined',
|
|
164
|
-
);
|
|
152
|
+
await expect(promise).to.be.rejectedWith('Model "target" is not defined');
|
|
165
153
|
});
|
|
166
154
|
|
|
167
155
|
it('throws an error if the given target model does not have a datasource', async function () {
|
|
@@ -170,7 +158,7 @@ describe('BelongsToResolver', function () {
|
|
|
170
158
|
const R = dbs.getService(BelongsToResolver);
|
|
171
159
|
const promise = R.includeTo([], 'source', 'target', 'relation');
|
|
172
160
|
await expect(promise).to.be.rejectedWith(
|
|
173
|
-
'
|
|
161
|
+
'Model "target" does not have a specified datasource.',
|
|
174
162
|
);
|
|
175
163
|
});
|
|
176
164
|
|
|
@@ -530,8 +518,7 @@ describe('BelongsToResolver', function () {
|
|
|
530
518
|
const R = dbs.getService(BelongsToResolver);
|
|
531
519
|
const error = v =>
|
|
532
520
|
format(
|
|
533
|
-
'
|
|
534
|
-
'an Array of Object, but %s was given.',
|
|
521
|
+
'Parameter "entities" must be an Array of Object, but %s was given.',
|
|
535
522
|
v,
|
|
536
523
|
);
|
|
537
524
|
const throwable = v =>
|
|
@@ -551,8 +538,7 @@ describe('BelongsToResolver', function () {
|
|
|
551
538
|
const R = dbs.getService(BelongsToResolver);
|
|
552
539
|
const error = v =>
|
|
553
540
|
format(
|
|
554
|
-
'
|
|
555
|
-
'an Array of Object, but %s was given.',
|
|
541
|
+
'Parameter "entities" must be an Array of Object, but %s was given.',
|
|
556
542
|
v,
|
|
557
543
|
);
|
|
558
544
|
const throwable = v =>
|
|
@@ -572,8 +558,8 @@ describe('BelongsToResolver', function () {
|
|
|
572
558
|
const R = dbs.getService(BelongsToResolver);
|
|
573
559
|
const error = v =>
|
|
574
560
|
format(
|
|
575
|
-
'
|
|
576
|
-
'
|
|
561
|
+
'Parameter "sourceName" must be a non-empty String, ' +
|
|
562
|
+
'but %s was given.',
|
|
577
563
|
v,
|
|
578
564
|
);
|
|
579
565
|
const throwable = v =>
|
|
@@ -593,8 +579,8 @@ describe('BelongsToResolver', function () {
|
|
|
593
579
|
const R = dbs.getService(BelongsToResolver);
|
|
594
580
|
const error = v =>
|
|
595
581
|
format(
|
|
596
|
-
'
|
|
597
|
-
'
|
|
582
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
583
|
+
'but %s was given.',
|
|
598
584
|
v,
|
|
599
585
|
);
|
|
600
586
|
const throwable = v => R.includePolymorphicTo([], 'sourceName', v);
|
|
@@ -612,11 +598,7 @@ describe('BelongsToResolver', function () {
|
|
|
612
598
|
const dbs = new DatabaseSchema();
|
|
613
599
|
const R = dbs.getService(BelongsToResolver);
|
|
614
600
|
const error = v =>
|
|
615
|
-
format(
|
|
616
|
-
'The provided parameter "foreignKey" of BelongsToResolver.includePolymorphicTo ' +
|
|
617
|
-
'should be a String, but %s was given.',
|
|
618
|
-
v,
|
|
619
|
-
);
|
|
601
|
+
format('Parameter "foreignKey" must be a String, but %s was given.', v);
|
|
620
602
|
const throwable = v =>
|
|
621
603
|
R.includePolymorphicTo([], 'sourceName', 'relationName', v);
|
|
622
604
|
await expect(throwable(10)).to.be.rejectedWith(error('10'));
|
|
@@ -630,8 +612,7 @@ describe('BelongsToResolver', function () {
|
|
|
630
612
|
const R = dbs.getService(BelongsToResolver);
|
|
631
613
|
const error = v =>
|
|
632
614
|
format(
|
|
633
|
-
'
|
|
634
|
-
'should be a String, but %s was given.',
|
|
615
|
+
'Parameter "discriminator" must be a String, but %s was given.',
|
|
635
616
|
v,
|
|
636
617
|
);
|
|
637
618
|
const throwable = v =>
|
|
@@ -646,11 +627,7 @@ describe('BelongsToResolver', function () {
|
|
|
646
627
|
const dbs = new DatabaseSchema();
|
|
647
628
|
const R = dbs.getService(BelongsToResolver);
|
|
648
629
|
const error = v =>
|
|
649
|
-
format(
|
|
650
|
-
'The provided parameter "scope" of BelongsToResolver.includePolymorphicTo ' +
|
|
651
|
-
'should be an Object, but %s was given.',
|
|
652
|
-
v,
|
|
653
|
-
);
|
|
630
|
+
format('Parameter "scope" must be an Object, but %s was given.', v);
|
|
654
631
|
const throwable = v =>
|
|
655
632
|
R.includePolymorphicTo(
|
|
656
633
|
[],
|
|
@@ -29,43 +29,38 @@ export class HasManyResolver extends Service {
|
|
|
29
29
|
) {
|
|
30
30
|
if (!entities || !Array.isArray(entities)) {
|
|
31
31
|
throw new InvalidArgumentError(
|
|
32
|
-
'
|
|
33
|
-
'an Array of Object, but %v was given.',
|
|
32
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
34
33
|
entities,
|
|
35
34
|
);
|
|
36
35
|
}
|
|
37
36
|
if (!sourceName || typeof sourceName !== 'string') {
|
|
38
37
|
throw new InvalidArgumentError(
|
|
39
|
-
'
|
|
40
|
-
'a non-empty String, but %v was given.',
|
|
38
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
41
39
|
sourceName,
|
|
42
40
|
);
|
|
43
41
|
}
|
|
44
42
|
if (!targetName || typeof targetName !== 'string') {
|
|
45
43
|
throw new InvalidArgumentError(
|
|
46
|
-
'
|
|
47
|
-
'a non-empty String, but %v was given.',
|
|
44
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
48
45
|
targetName,
|
|
49
46
|
);
|
|
50
47
|
}
|
|
51
48
|
if (!relationName || typeof relationName !== 'string') {
|
|
52
49
|
throw new InvalidArgumentError(
|
|
53
|
-
'
|
|
54
|
-
'
|
|
50
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
51
|
+
'but %v was given.',
|
|
55
52
|
relationName,
|
|
56
53
|
);
|
|
57
54
|
}
|
|
58
55
|
if (!foreignKey || typeof foreignKey !== 'string') {
|
|
59
56
|
throw new InvalidArgumentError(
|
|
60
|
-
'
|
|
61
|
-
'a non-empty String, but %v was given.',
|
|
57
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
62
58
|
foreignKey,
|
|
63
59
|
);
|
|
64
60
|
}
|
|
65
61
|
if (scope && (typeof scope !== 'object' || Array.isArray(scope))) {
|
|
66
62
|
throw new InvalidArgumentError(
|
|
67
|
-
'
|
|
68
|
-
'should be an Object, but %v was given.',
|
|
63
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
69
64
|
scope,
|
|
70
65
|
);
|
|
71
66
|
}
|
|
@@ -78,8 +73,7 @@ export class HasManyResolver extends Service {
|
|
|
78
73
|
entities.forEach(entity => {
|
|
79
74
|
if (!entity || typeof entity !== 'object' || Array.isArray(entity)) {
|
|
80
75
|
throw new InvalidArgumentError(
|
|
81
|
-
'
|
|
82
|
-
'an Array of Object, but %v was given.',
|
|
76
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
83
77
|
entity,
|
|
84
78
|
);
|
|
85
79
|
}
|
|
@@ -141,50 +135,45 @@ export class HasManyResolver extends Service {
|
|
|
141
135
|
) {
|
|
142
136
|
if (!entities || !Array.isArray(entities)) {
|
|
143
137
|
throw new InvalidArgumentError(
|
|
144
|
-
'
|
|
145
|
-
'an Array of Object, but %v was given.',
|
|
138
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
146
139
|
entities,
|
|
147
140
|
);
|
|
148
141
|
}
|
|
149
142
|
if (!sourceName || typeof sourceName !== 'string') {
|
|
150
143
|
throw new InvalidArgumentError(
|
|
151
|
-
'
|
|
152
|
-
'a non-empty String, but %v was given.',
|
|
144
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
153
145
|
sourceName,
|
|
154
146
|
);
|
|
155
147
|
}
|
|
156
148
|
if (!targetName || typeof targetName !== 'string') {
|
|
157
149
|
throw new InvalidArgumentError(
|
|
158
|
-
'
|
|
159
|
-
'a non-empty String, but %v was given.',
|
|
150
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
160
151
|
targetName,
|
|
161
152
|
);
|
|
162
153
|
}
|
|
163
154
|
if (!relationName || typeof relationName !== 'string') {
|
|
164
155
|
throw new InvalidArgumentError(
|
|
165
|
-
'
|
|
166
|
-
'
|
|
156
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
157
|
+
'but %v was given.',
|
|
167
158
|
relationName,
|
|
168
159
|
);
|
|
169
160
|
}
|
|
170
161
|
if (!foreignKey || typeof foreignKey !== 'string') {
|
|
171
162
|
throw new InvalidArgumentError(
|
|
172
|
-
'
|
|
173
|
-
'a non-empty String, but %v was given.',
|
|
163
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
174
164
|
foreignKey,
|
|
175
165
|
);
|
|
176
166
|
}
|
|
177
167
|
if (!discriminator || typeof discriminator !== 'string') {
|
|
178
168
|
throw new InvalidArgumentError(
|
|
179
|
-
'
|
|
180
|
-
'
|
|
169
|
+
'Parameter "discriminator" must be a non-empty String, ' +
|
|
170
|
+
'but %v was given.',
|
|
181
171
|
discriminator,
|
|
182
172
|
);
|
|
183
173
|
}
|
|
184
174
|
if (scope && (typeof scope !== 'object' || Array.isArray(scope))) {
|
|
185
175
|
throw new InvalidArgumentError(
|
|
186
|
-
'
|
|
187
|
-
'should be an Object, but %v was given.',
|
|
176
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
188
177
|
scope,
|
|
189
178
|
);
|
|
190
179
|
}
|
|
@@ -197,8 +186,7 @@ export class HasManyResolver extends Service {
|
|
|
197
186
|
entities.forEach(entity => {
|
|
198
187
|
if (!entity || typeof entity !== 'object' || Array.isArray(entity)) {
|
|
199
188
|
throw new InvalidArgumentError(
|
|
200
|
-
'
|
|
201
|
-
'an Array of Object, but %v was given.',
|
|
189
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
202
190
|
entity,
|
|
203
191
|
);
|
|
204
192
|
}
|
|
@@ -261,43 +249,39 @@ export class HasManyResolver extends Service {
|
|
|
261
249
|
) {
|
|
262
250
|
if (!entities || !Array.isArray(entities)) {
|
|
263
251
|
throw new InvalidArgumentError(
|
|
264
|
-
'
|
|
265
|
-
'an Array of Object, but %v was given.',
|
|
252
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
266
253
|
entities,
|
|
267
254
|
);
|
|
268
255
|
}
|
|
269
256
|
if (!sourceName || typeof sourceName !== 'string') {
|
|
270
257
|
throw new InvalidArgumentError(
|
|
271
|
-
'
|
|
272
|
-
'a non-empty String, but %v was given.',
|
|
258
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
273
259
|
sourceName,
|
|
274
260
|
);
|
|
275
261
|
}
|
|
276
262
|
if (!targetName || typeof targetName !== 'string') {
|
|
277
263
|
throw new InvalidArgumentError(
|
|
278
|
-
'
|
|
279
|
-
'a non-empty String, but %v was given.',
|
|
264
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
280
265
|
targetName,
|
|
281
266
|
);
|
|
282
267
|
}
|
|
283
268
|
if (!relationName || typeof relationName !== 'string') {
|
|
284
269
|
throw new InvalidArgumentError(
|
|
285
|
-
'
|
|
286
|
-
'
|
|
270
|
+
'Parameter "relationName" must be a non-empty String, ' +
|
|
271
|
+
'but %v was given.',
|
|
287
272
|
relationName,
|
|
288
273
|
);
|
|
289
274
|
}
|
|
290
275
|
if (!targetRelationName || typeof targetRelationName !== 'string') {
|
|
291
276
|
throw new InvalidArgumentError(
|
|
292
|
-
'
|
|
293
|
-
'
|
|
277
|
+
'Parameter "targetRelationName" must be a non-empty String, ' +
|
|
278
|
+
'but %v was given.',
|
|
294
279
|
targetRelationName,
|
|
295
280
|
);
|
|
296
281
|
}
|
|
297
282
|
if (scope && (typeof scope !== 'object' || Array.isArray(scope))) {
|
|
298
283
|
throw new InvalidArgumentError(
|
|
299
|
-
'
|
|
300
|
-
'should be an Object, but %v was given.',
|
|
284
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
301
285
|
scope,
|
|
302
286
|
);
|
|
303
287
|
}
|
|
@@ -307,7 +291,7 @@ export class HasManyResolver extends Service {
|
|
|
307
291
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
308
292
|
if (targetRelationDef.type !== RelationType.BELONGS_TO) {
|
|
309
293
|
throw new InvalidArgumentError(
|
|
310
|
-
'
|
|
294
|
+
'Relation %v of the model %v is a polymorphic "hasMany" relation, ' +
|
|
311
295
|
'so it requires the target relation %v to be a polymorphic "belongsTo", ' +
|
|
312
296
|
'but %v type was given.',
|
|
313
297
|
relationName,
|
|
@@ -318,7 +302,7 @@ export class HasManyResolver extends Service {
|
|
|
318
302
|
}
|
|
319
303
|
if (!targetRelationDef.polymorphic) {
|
|
320
304
|
throw new InvalidArgumentError(
|
|
321
|
-
'
|
|
305
|
+
'Relation %v of the model %v is a polymorphic "hasMany" relation, ' +
|
|
322
306
|
'so it requires the target relation %v to be a polymorphic too.',
|
|
323
307
|
relationName,
|
|
324
308
|
sourceName,
|