@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
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
6
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
7
|
var __glob = (map) => (path) => {
|
|
11
8
|
var fn = map[path];
|
|
@@ -27,16 +24,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
24
|
}
|
|
28
25
|
return to;
|
|
29
26
|
};
|
|
30
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
-
mod
|
|
37
|
-
));
|
|
38
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
28
|
|
|
41
29
|
// src/utils/is-promise.js
|
|
42
30
|
function isPromise(value) {
|
|
@@ -207,38 +195,43 @@ var init_is_deep_equal = __esm({
|
|
|
207
195
|
});
|
|
208
196
|
|
|
209
197
|
// src/errors/not-implemented-error.js
|
|
210
|
-
var import_js_format,
|
|
198
|
+
var import_js_format, NotImplementedError;
|
|
211
199
|
var init_not_implemented_error = __esm({
|
|
212
200
|
"src/errors/not-implemented-error.js"() {
|
|
213
201
|
"use strict";
|
|
214
202
|
import_js_format = require("@e22m4u/js-format");
|
|
215
|
-
|
|
203
|
+
NotImplementedError = class extends import_js_format.Errorf {
|
|
204
|
+
static {
|
|
205
|
+
__name(this, "NotImplementedError");
|
|
206
|
+
}
|
|
216
207
|
};
|
|
217
|
-
__name(_NotImplementedError, "NotImplementedError");
|
|
218
|
-
NotImplementedError = _NotImplementedError;
|
|
219
208
|
}
|
|
220
209
|
});
|
|
221
210
|
|
|
222
211
|
// src/errors/invalid-argument-error.js
|
|
223
|
-
var import_js_format2,
|
|
212
|
+
var import_js_format2, InvalidArgumentError;
|
|
224
213
|
var init_invalid_argument_error = __esm({
|
|
225
214
|
"src/errors/invalid-argument-error.js"() {
|
|
226
215
|
"use strict";
|
|
227
216
|
import_js_format2 = require("@e22m4u/js-format");
|
|
228
|
-
|
|
217
|
+
InvalidArgumentError = class extends import_js_format2.Errorf {
|
|
218
|
+
static {
|
|
219
|
+
__name(this, "InvalidArgumentError");
|
|
220
|
+
}
|
|
229
221
|
};
|
|
230
|
-
__name(_InvalidArgumentError, "InvalidArgumentError");
|
|
231
|
-
InvalidArgumentError = _InvalidArgumentError;
|
|
232
222
|
}
|
|
233
223
|
});
|
|
234
224
|
|
|
235
225
|
// src/errors/invalid-operator-value-error.js
|
|
236
|
-
var import_js_format3,
|
|
226
|
+
var import_js_format3, InvalidOperatorValueError;
|
|
237
227
|
var init_invalid_operator_value_error = __esm({
|
|
238
228
|
"src/errors/invalid-operator-value-error.js"() {
|
|
239
229
|
"use strict";
|
|
240
230
|
import_js_format3 = require("@e22m4u/js-format");
|
|
241
|
-
|
|
231
|
+
InvalidOperatorValueError = class extends Error {
|
|
232
|
+
static {
|
|
233
|
+
__name(this, "InvalidOperatorValueError");
|
|
234
|
+
}
|
|
242
235
|
/**
|
|
243
236
|
* Constructor.
|
|
244
237
|
*
|
|
@@ -249,7 +242,7 @@ var init_invalid_operator_value_error = __esm({
|
|
|
249
242
|
constructor(operator, expected, value) {
|
|
250
243
|
super(
|
|
251
244
|
(0, import_js_format3.format)(
|
|
252
|
-
"Condition of {%s: ...}
|
|
245
|
+
"Condition of {%s: ...} must have %s, but %v was given.",
|
|
253
246
|
operator,
|
|
254
247
|
expected,
|
|
255
248
|
value
|
|
@@ -257,8 +250,6 @@ var init_invalid_operator_value_error = __esm({
|
|
|
257
250
|
);
|
|
258
251
|
}
|
|
259
252
|
};
|
|
260
|
-
__name(_InvalidOperatorValueError, "InvalidOperatorValueError");
|
|
261
|
-
InvalidOperatorValueError = _InvalidOperatorValueError;
|
|
262
253
|
}
|
|
263
254
|
});
|
|
264
255
|
|
|
@@ -276,7 +267,7 @@ var init_errors = __esm({
|
|
|
276
267
|
function likeToRegexp(pattern, isCaseInsensitive = false) {
|
|
277
268
|
if (typeof pattern !== "string") {
|
|
278
269
|
throw new InvalidArgumentError(
|
|
279
|
-
"
|
|
270
|
+
'Parameter "pattern" must be a String, but %v was given.',
|
|
280
271
|
pattern
|
|
281
272
|
);
|
|
282
273
|
}
|
|
@@ -371,20 +362,21 @@ var init_get_value_by_path = __esm({
|
|
|
371
362
|
function selectObjectKeys(obj, keys) {
|
|
372
363
|
if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
|
|
373
364
|
throw new InvalidArgumentError(
|
|
374
|
-
"
|
|
365
|
+
'Parameter "obj" must be an Object, but %v was given.',
|
|
375
366
|
obj
|
|
376
367
|
);
|
|
377
368
|
}
|
|
378
369
|
if (!Array.isArray(keys)) {
|
|
379
370
|
throw new InvalidArgumentError(
|
|
380
|
-
"
|
|
371
|
+
'Parameter "keys" must be an Array, but %v was given.',
|
|
381
372
|
keys
|
|
382
373
|
);
|
|
383
374
|
}
|
|
384
|
-
keys.forEach((key) => {
|
|
375
|
+
keys.forEach((key, index) => {
|
|
385
376
|
if (typeof key !== "string") {
|
|
386
377
|
throw new InvalidArgumentError(
|
|
387
|
-
|
|
378
|
+
'Element %d of the parameter "keys" must be a String, but %v was given.',
|
|
379
|
+
index,
|
|
388
380
|
key
|
|
389
381
|
);
|
|
390
382
|
}
|
|
@@ -408,9 +400,9 @@ var init_select_object_keys = __esm({
|
|
|
408
400
|
|
|
409
401
|
// src/utils/exclude-object-keys.js
|
|
410
402
|
function excludeObjectKeys(obj, keys) {
|
|
411
|
-
if (typeof obj !== "object" ||
|
|
403
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
|
|
412
404
|
throw new InvalidArgumentError(
|
|
413
|
-
"
|
|
405
|
+
'Parameter "obj" must be an Object, but %v was given.',
|
|
414
406
|
obj
|
|
415
407
|
);
|
|
416
408
|
}
|
|
@@ -431,7 +423,7 @@ var init_exclude_object_keys = __esm({
|
|
|
431
423
|
function modelNameToModelKey(modelName) {
|
|
432
424
|
if (!modelName || typeof modelName !== "string" || /\s/.test(modelName)) {
|
|
433
425
|
throw new InvalidArgumentError(
|
|
434
|
-
"
|
|
426
|
+
"Model name must be a non-empty String without spaces, but %v was given.",
|
|
435
427
|
modelName
|
|
436
428
|
);
|
|
437
429
|
}
|
|
@@ -465,13 +457,16 @@ var init_utils = __esm({
|
|
|
465
457
|
});
|
|
466
458
|
|
|
467
459
|
// src/filter/slice-clause-tool.js
|
|
468
|
-
var import_js_service,
|
|
460
|
+
var import_js_service, SliceClauseTool;
|
|
469
461
|
var init_slice_clause_tool = __esm({
|
|
470
462
|
"src/filter/slice-clause-tool.js"() {
|
|
471
463
|
"use strict";
|
|
472
464
|
import_js_service = require("@e22m4u/js-service");
|
|
473
465
|
init_errors();
|
|
474
|
-
|
|
466
|
+
SliceClauseTool = class extends import_js_service.Service {
|
|
467
|
+
static {
|
|
468
|
+
__name(this, "SliceClauseTool");
|
|
469
|
+
}
|
|
475
470
|
/**
|
|
476
471
|
* Slice.
|
|
477
472
|
*
|
|
@@ -483,19 +478,19 @@ var init_slice_clause_tool = __esm({
|
|
|
483
478
|
slice(entities, skip = void 0, limit = void 0) {
|
|
484
479
|
if (!Array.isArray(entities)) {
|
|
485
480
|
throw new InvalidArgumentError(
|
|
486
|
-
"
|
|
481
|
+
'Parameter "entities" must be an Array, but %v was given.',
|
|
487
482
|
entities
|
|
488
483
|
);
|
|
489
484
|
}
|
|
490
485
|
if (skip != null && typeof skip !== "number") {
|
|
491
486
|
throw new InvalidArgumentError(
|
|
492
|
-
'
|
|
487
|
+
'Option "skip" must be a Number, but %v was given.',
|
|
493
488
|
skip
|
|
494
489
|
);
|
|
495
490
|
}
|
|
496
491
|
if (limit != null && typeof limit !== "number") {
|
|
497
492
|
throw new InvalidArgumentError(
|
|
498
|
-
'
|
|
493
|
+
'Option "limit" must be a Number, but %v was given.',
|
|
499
494
|
limit
|
|
500
495
|
);
|
|
501
496
|
}
|
|
@@ -514,7 +509,7 @@ var init_slice_clause_tool = __esm({
|
|
|
514
509
|
}
|
|
515
510
|
if (typeof skip !== "number") {
|
|
516
511
|
throw new InvalidArgumentError(
|
|
517
|
-
'
|
|
512
|
+
'Option "skip" must be a Number, but %v was given.',
|
|
518
513
|
skip
|
|
519
514
|
);
|
|
520
515
|
}
|
|
@@ -530,14 +525,12 @@ var init_slice_clause_tool = __esm({
|
|
|
530
525
|
}
|
|
531
526
|
if (typeof limit !== "number") {
|
|
532
527
|
throw new InvalidArgumentError(
|
|
533
|
-
'
|
|
528
|
+
'Option "limit" must be a Number, but %v was given.',
|
|
534
529
|
limit
|
|
535
530
|
);
|
|
536
531
|
}
|
|
537
532
|
}
|
|
538
533
|
};
|
|
539
|
-
__name(_SliceClauseTool, "SliceClauseTool");
|
|
540
|
-
SliceClauseTool = _SliceClauseTool;
|
|
541
534
|
}
|
|
542
535
|
});
|
|
543
536
|
|
|
@@ -557,14 +550,17 @@ function compareFn(a, b) {
|
|
|
557
550
|
}
|
|
558
551
|
return 0;
|
|
559
552
|
}
|
|
560
|
-
var import_js_service2,
|
|
553
|
+
var import_js_service2, OrderClauseTool;
|
|
561
554
|
var init_order_clause_tool = __esm({
|
|
562
555
|
"src/filter/order-clause-tool.js"() {
|
|
563
556
|
"use strict";
|
|
564
557
|
import_js_service2 = require("@e22m4u/js-service");
|
|
565
558
|
init_utils();
|
|
566
559
|
init_errors();
|
|
567
|
-
|
|
560
|
+
OrderClauseTool = class extends import_js_service2.Service {
|
|
561
|
+
static {
|
|
562
|
+
__name(this, "OrderClauseTool");
|
|
563
|
+
}
|
|
568
564
|
/**
|
|
569
565
|
* Sort.
|
|
570
566
|
*
|
|
@@ -572,32 +568,45 @@ var init_order_clause_tool = __esm({
|
|
|
572
568
|
* @param {string|string[]|undefined} clause
|
|
573
569
|
*/
|
|
574
570
|
sort(entities, clause) {
|
|
571
|
+
if (!Array.isArray(entities)) {
|
|
572
|
+
throw new InvalidArgumentError(
|
|
573
|
+
'Parameter "entities" must be an Array, but %v was given.',
|
|
574
|
+
entities
|
|
575
|
+
);
|
|
576
|
+
}
|
|
575
577
|
if (clause == null) {
|
|
576
578
|
return;
|
|
577
579
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
+
const isArrayClause = Array.isArray(clause);
|
|
581
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
582
|
+
throw new InvalidArgumentError(
|
|
583
|
+
'Option "order" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
584
|
+
clause
|
|
585
|
+
);
|
|
580
586
|
}
|
|
581
|
-
if (!
|
|
587
|
+
if (!isArrayClause) {
|
|
588
|
+
clause = [clause];
|
|
589
|
+
} else if (!clause.length) {
|
|
582
590
|
return;
|
|
583
591
|
}
|
|
584
592
|
const mapping = [];
|
|
585
|
-
clause.forEach((
|
|
586
|
-
if (!
|
|
593
|
+
clause.forEach((element, index) => {
|
|
594
|
+
if (!element || typeof element !== "string") {
|
|
587
595
|
throw new InvalidArgumentError(
|
|
588
|
-
'
|
|
589
|
-
|
|
596
|
+
'Element %d of the option "order" must be a non-empty String, but %v was given.',
|
|
597
|
+
index,
|
|
598
|
+
element
|
|
590
599
|
);
|
|
591
600
|
}
|
|
592
601
|
let reverse = 1;
|
|
593
|
-
const matches =
|
|
602
|
+
const matches = element.match(/\s+(A|DE)SC$/i);
|
|
594
603
|
if (matches) {
|
|
595
|
-
|
|
604
|
+
element = element.replace(/\s+(A|DE)SC/i, "");
|
|
596
605
|
if (matches[1].toLowerCase() === "de") {
|
|
597
606
|
reverse = -1;
|
|
598
607
|
}
|
|
599
608
|
}
|
|
600
|
-
mapping[index] = { key, reverse };
|
|
609
|
+
mapping[index] = { key: element, reverse };
|
|
601
610
|
});
|
|
602
611
|
entities.sort(compareFn.bind(mapping));
|
|
603
612
|
}
|
|
@@ -610,17 +619,22 @@ var init_order_clause_tool = __esm({
|
|
|
610
619
|
if (clause == null) {
|
|
611
620
|
return;
|
|
612
621
|
}
|
|
613
|
-
|
|
614
|
-
|
|
622
|
+
const isArrayClause = Array.isArray(clause);
|
|
623
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
624
|
+
throw new InvalidArgumentError(
|
|
625
|
+
'Option "order" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
626
|
+
clause
|
|
627
|
+
);
|
|
615
628
|
}
|
|
616
|
-
if (!clause.length) {
|
|
629
|
+
if (!isArrayClause || !clause.length) {
|
|
617
630
|
return;
|
|
618
631
|
}
|
|
619
|
-
clause.forEach((
|
|
620
|
-
if (!
|
|
632
|
+
clause.forEach((element, index) => {
|
|
633
|
+
if (!element || typeof element !== "string") {
|
|
621
634
|
throw new InvalidArgumentError(
|
|
622
|
-
'
|
|
623
|
-
|
|
635
|
+
'Element %d of the option "order" must be a non-empty String, but %v was given.',
|
|
636
|
+
index,
|
|
637
|
+
element
|
|
624
638
|
);
|
|
625
639
|
}
|
|
626
640
|
});
|
|
@@ -635,38 +649,46 @@ var init_order_clause_tool = __esm({
|
|
|
635
649
|
if (clause == null) {
|
|
636
650
|
return;
|
|
637
651
|
}
|
|
638
|
-
|
|
639
|
-
|
|
652
|
+
const isArrayClause = Array.isArray(clause);
|
|
653
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
654
|
+
throw new InvalidArgumentError(
|
|
655
|
+
'Option "order" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
656
|
+
clause
|
|
657
|
+
);
|
|
640
658
|
}
|
|
641
|
-
if (!
|
|
659
|
+
if (!isArrayClause) {
|
|
660
|
+
return [clause];
|
|
661
|
+
} else if (!clause.length) {
|
|
642
662
|
return;
|
|
643
663
|
}
|
|
644
|
-
clause.forEach((
|
|
645
|
-
if (!
|
|
664
|
+
clause.forEach((element, index) => {
|
|
665
|
+
if (!element || typeof element !== "string") {
|
|
646
666
|
throw new InvalidArgumentError(
|
|
647
|
-
'
|
|
648
|
-
|
|
667
|
+
'Element %d of the option "order" must be a non-empty String, but %v was given.',
|
|
668
|
+
index,
|
|
669
|
+
element
|
|
649
670
|
);
|
|
650
671
|
}
|
|
651
672
|
});
|
|
652
673
|
return clause;
|
|
653
674
|
}
|
|
654
675
|
};
|
|
655
|
-
__name(_OrderClauseTool, "OrderClauseTool");
|
|
656
|
-
OrderClauseTool = _OrderClauseTool;
|
|
657
676
|
__name(compareFn, "compareFn");
|
|
658
677
|
}
|
|
659
678
|
});
|
|
660
679
|
|
|
661
680
|
// src/filter/operator-clause-tool.js
|
|
662
|
-
var import_js_service3,
|
|
681
|
+
var import_js_service3, OperatorClauseTool;
|
|
663
682
|
var init_operator_clause_tool = __esm({
|
|
664
683
|
"src/filter/operator-clause-tool.js"() {
|
|
665
684
|
"use strict";
|
|
666
685
|
import_js_service3 = require("@e22m4u/js-service");
|
|
667
686
|
init_utils();
|
|
668
687
|
init_errors();
|
|
669
|
-
|
|
688
|
+
OperatorClauseTool = class extends import_js_service3.Service {
|
|
689
|
+
static {
|
|
690
|
+
__name(this, "OperatorClauseTool");
|
|
691
|
+
}
|
|
670
692
|
/**
|
|
671
693
|
* Compare.
|
|
672
694
|
*
|
|
@@ -718,7 +740,7 @@ var init_operator_clause_tool = __esm({
|
|
|
718
740
|
testAll(clause, value) {
|
|
719
741
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
720
742
|
throw new InvalidArgumentError(
|
|
721
|
-
"
|
|
743
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
722
744
|
clause
|
|
723
745
|
);
|
|
724
746
|
}
|
|
@@ -776,9 +798,9 @@ var init_operator_clause_tool = __esm({
|
|
|
776
798
|
* @returns {boolean|undefined}
|
|
777
799
|
*/
|
|
778
800
|
testEqNeq(clause, value) {
|
|
779
|
-
if (!clause || typeof clause !== "object") {
|
|
801
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
780
802
|
throw new InvalidArgumentError(
|
|
781
|
-
"
|
|
803
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
782
804
|
clause
|
|
783
805
|
);
|
|
784
806
|
}
|
|
@@ -825,9 +847,9 @@ var init_operator_clause_tool = __esm({
|
|
|
825
847
|
* @returns {boolean|undefined}
|
|
826
848
|
*/
|
|
827
849
|
testGtLt(clause, value) {
|
|
828
|
-
if (!clause || typeof clause !== "object") {
|
|
850
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
829
851
|
throw new InvalidArgumentError(
|
|
830
|
-
"
|
|
852
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
831
853
|
clause
|
|
832
854
|
);
|
|
833
855
|
}
|
|
@@ -859,9 +881,9 @@ var init_operator_clause_tool = __esm({
|
|
|
859
881
|
* @returns {boolean|undefined}
|
|
860
882
|
*/
|
|
861
883
|
testInq(clause, value) {
|
|
862
|
-
if (!clause || typeof clause !== "object") {
|
|
884
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
863
885
|
throw new InvalidArgumentError(
|
|
864
|
-
"
|
|
886
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
865
887
|
clause
|
|
866
888
|
);
|
|
867
889
|
}
|
|
@@ -896,9 +918,9 @@ var init_operator_clause_tool = __esm({
|
|
|
896
918
|
* @returns {boolean|undefined}
|
|
897
919
|
*/
|
|
898
920
|
testNin(clause, value) {
|
|
899
|
-
if (!clause || typeof clause !== "object") {
|
|
921
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
900
922
|
throw new InvalidArgumentError(
|
|
901
|
-
"
|
|
923
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
902
924
|
clause
|
|
903
925
|
);
|
|
904
926
|
}
|
|
@@ -930,9 +952,9 @@ var init_operator_clause_tool = __esm({
|
|
|
930
952
|
* @returns {boolean|undefined}
|
|
931
953
|
*/
|
|
932
954
|
testBetween(clause, value) {
|
|
933
|
-
if (!clause || typeof clause !== "object") {
|
|
955
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
934
956
|
throw new InvalidArgumentError(
|
|
935
|
-
"
|
|
957
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
936
958
|
clause
|
|
937
959
|
);
|
|
938
960
|
}
|
|
@@ -962,9 +984,9 @@ var init_operator_clause_tool = __esm({
|
|
|
962
984
|
* @returns {boolean|undefined}
|
|
963
985
|
*/
|
|
964
986
|
testExists(clause, value) {
|
|
965
|
-
if (!clause || typeof clause !== "object") {
|
|
987
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
966
988
|
throw new InvalidArgumentError(
|
|
967
|
-
"
|
|
989
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
968
990
|
clause
|
|
969
991
|
);
|
|
970
992
|
}
|
|
@@ -996,7 +1018,7 @@ var init_operator_clause_tool = __esm({
|
|
|
996
1018
|
testLike(clause, value) {
|
|
997
1019
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
998
1020
|
throw new InvalidArgumentError(
|
|
999
|
-
"
|
|
1021
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1000
1022
|
clause
|
|
1001
1023
|
);
|
|
1002
1024
|
}
|
|
@@ -1024,7 +1046,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1024
1046
|
testNlike(clause, value) {
|
|
1025
1047
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1026
1048
|
throw new InvalidArgumentError(
|
|
1027
|
-
"
|
|
1049
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1028
1050
|
clause
|
|
1029
1051
|
);
|
|
1030
1052
|
}
|
|
@@ -1052,7 +1074,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1052
1074
|
testIlike(clause, value) {
|
|
1053
1075
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1054
1076
|
throw new InvalidArgumentError(
|
|
1055
|
-
"
|
|
1077
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1056
1078
|
clause
|
|
1057
1079
|
);
|
|
1058
1080
|
}
|
|
@@ -1080,7 +1102,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1080
1102
|
testNilike(clause, value) {
|
|
1081
1103
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1082
1104
|
throw new InvalidArgumentError(
|
|
1083
|
-
"
|
|
1105
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1084
1106
|
clause
|
|
1085
1107
|
);
|
|
1086
1108
|
}
|
|
@@ -1118,9 +1140,9 @@ var init_operator_clause_tool = __esm({
|
|
|
1118
1140
|
* @returns {boolean|undefined}
|
|
1119
1141
|
*/
|
|
1120
1142
|
testRegexp(clause, value) {
|
|
1121
|
-
if (!clause || typeof clause !== "object") {
|
|
1143
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1122
1144
|
throw new InvalidArgumentError(
|
|
1123
|
-
"
|
|
1145
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1124
1146
|
clause
|
|
1125
1147
|
);
|
|
1126
1148
|
}
|
|
@@ -1135,7 +1157,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1135
1157
|
const flags = clause.flags || void 0;
|
|
1136
1158
|
if (flags && typeof flags !== "string") {
|
|
1137
1159
|
throw new InvalidArgumentError(
|
|
1138
|
-
"RegExp flags
|
|
1160
|
+
"RegExp flags must be a String, but %v was given.",
|
|
1139
1161
|
clause.flags
|
|
1140
1162
|
);
|
|
1141
1163
|
}
|
|
@@ -1147,13 +1169,11 @@ var init_operator_clause_tool = __esm({
|
|
|
1147
1169
|
}
|
|
1148
1170
|
}
|
|
1149
1171
|
};
|
|
1150
|
-
__name(_OperatorClauseTool, "OperatorClauseTool");
|
|
1151
|
-
OperatorClauseTool = _OperatorClauseTool;
|
|
1152
1172
|
}
|
|
1153
1173
|
});
|
|
1154
1174
|
|
|
1155
1175
|
// src/filter/where-clause-tool.js
|
|
1156
|
-
var import_js_service4,
|
|
1176
|
+
var import_js_service4, WhereClauseTool;
|
|
1157
1177
|
var init_where_clause_tool = __esm({
|
|
1158
1178
|
"src/filter/where-clause-tool.js"() {
|
|
1159
1179
|
"use strict";
|
|
@@ -1161,7 +1181,10 @@ var init_where_clause_tool = __esm({
|
|
|
1161
1181
|
init_errors();
|
|
1162
1182
|
init_operator_clause_tool();
|
|
1163
1183
|
init_utils();
|
|
1164
|
-
|
|
1184
|
+
WhereClauseTool = class extends import_js_service4.Service {
|
|
1185
|
+
static {
|
|
1186
|
+
__name(this, "WhereClauseTool");
|
|
1187
|
+
}
|
|
1165
1188
|
/**
|
|
1166
1189
|
* Filter by where clause.
|
|
1167
1190
|
*
|
|
@@ -1194,7 +1217,7 @@ var init_where_clause_tool = __esm({
|
|
|
1194
1217
|
filter(entities, where = void 0) {
|
|
1195
1218
|
if (!Array.isArray(entities)) {
|
|
1196
1219
|
throw new InvalidArgumentError(
|
|
1197
|
-
"
|
|
1220
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
1198
1221
|
entities
|
|
1199
1222
|
);
|
|
1200
1223
|
}
|
|
@@ -1210,17 +1233,18 @@ var init_where_clause_tool = __esm({
|
|
|
1210
1233
|
* @returns {Function}
|
|
1211
1234
|
*/
|
|
1212
1235
|
_createFilter(whereClause) {
|
|
1213
|
-
if (typeof whereClause !== "object" || Array.isArray(whereClause)) {
|
|
1236
|
+
if (!whereClause || typeof whereClause !== "object" || Array.isArray(whereClause)) {
|
|
1214
1237
|
throw new InvalidArgumentError(
|
|
1215
|
-
'
|
|
1238
|
+
'Option "where" must be an Object, but %v was given.',
|
|
1216
1239
|
whereClause
|
|
1217
1240
|
);
|
|
1218
1241
|
}
|
|
1219
1242
|
const keys = Object.keys(whereClause);
|
|
1220
|
-
return (data) => {
|
|
1221
|
-
if (typeof data !== "object") {
|
|
1243
|
+
return (data, index) => {
|
|
1244
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
1222
1245
|
throw new InvalidArgumentError(
|
|
1223
|
-
"
|
|
1246
|
+
"Entity at index %d must be an Object, but %v was given.",
|
|
1247
|
+
index,
|
|
1224
1248
|
data
|
|
1225
1249
|
);
|
|
1226
1250
|
}
|
|
@@ -1228,12 +1252,16 @@ var init_where_clause_tool = __esm({
|
|
|
1228
1252
|
if (key === "and" && key in whereClause) {
|
|
1229
1253
|
const andClause = whereClause[key];
|
|
1230
1254
|
if (Array.isArray(andClause)) {
|
|
1231
|
-
return andClause.every(
|
|
1255
|
+
return andClause.every(
|
|
1256
|
+
(clause) => this._createFilter(clause)(data, index)
|
|
1257
|
+
);
|
|
1232
1258
|
}
|
|
1233
1259
|
} else if (key === "or" && key in whereClause) {
|
|
1234
1260
|
const orClause = whereClause[key];
|
|
1235
1261
|
if (Array.isArray(orClause)) {
|
|
1236
|
-
return orClause.some(
|
|
1262
|
+
return orClause.some(
|
|
1263
|
+
(clause) => this._createFilter(clause)(data, index)
|
|
1264
|
+
);
|
|
1237
1265
|
}
|
|
1238
1266
|
}
|
|
1239
1267
|
const value = getValueByPath(data, key);
|
|
@@ -1301,14 +1329,12 @@ var init_where_clause_tool = __esm({
|
|
|
1301
1329
|
}
|
|
1302
1330
|
if (typeof clause !== "object" || Array.isArray(clause)) {
|
|
1303
1331
|
throw new InvalidArgumentError(
|
|
1304
|
-
'
|
|
1332
|
+
'Option "where" must be an Object, but %v was given.',
|
|
1305
1333
|
clause
|
|
1306
1334
|
);
|
|
1307
1335
|
}
|
|
1308
1336
|
}
|
|
1309
1337
|
};
|
|
1310
|
-
__name(_WhereClauseTool, "WhereClauseTool");
|
|
1311
|
-
WhereClauseTool = _WhereClauseTool;
|
|
1312
1338
|
}
|
|
1313
1339
|
});
|
|
1314
1340
|
|
|
@@ -1334,14 +1360,17 @@ var init_relation_definition = __esm({
|
|
|
1334
1360
|
});
|
|
1335
1361
|
|
|
1336
1362
|
// src/definition/model/relations/relations-definition-validator.js
|
|
1337
|
-
var import_js_service5,
|
|
1363
|
+
var import_js_service5, RelationsDefinitionValidator;
|
|
1338
1364
|
var init_relations_definition_validator = __esm({
|
|
1339
1365
|
"src/definition/model/relations/relations-definition-validator.js"() {
|
|
1340
1366
|
"use strict";
|
|
1341
1367
|
import_js_service5 = require("@e22m4u/js-service");
|
|
1342
1368
|
init_relation_type();
|
|
1343
1369
|
init_errors();
|
|
1344
|
-
|
|
1370
|
+
RelationsDefinitionValidator = class extends import_js_service5.Service {
|
|
1371
|
+
static {
|
|
1372
|
+
__name(this, "RelationsDefinitionValidator");
|
|
1373
|
+
}
|
|
1345
1374
|
/**
|
|
1346
1375
|
* Validate.
|
|
1347
1376
|
*
|
|
@@ -1351,13 +1380,13 @@ var init_relations_definition_validator = __esm({
|
|
|
1351
1380
|
validate(modelName, relDefs) {
|
|
1352
1381
|
if (!modelName || typeof modelName !== "string") {
|
|
1353
1382
|
throw new InvalidArgumentError(
|
|
1354
|
-
"
|
|
1383
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
1355
1384
|
modelName
|
|
1356
1385
|
);
|
|
1357
1386
|
}
|
|
1358
1387
|
if (!relDefs || typeof relDefs !== "object" || Array.isArray(relDefs)) {
|
|
1359
1388
|
throw new InvalidArgumentError(
|
|
1360
|
-
'
|
|
1389
|
+
'Option "relations" of the model %v must be an Object, but %v was given.',
|
|
1361
1390
|
modelName,
|
|
1362
1391
|
relDefs
|
|
1363
1392
|
);
|
|
@@ -1378,20 +1407,20 @@ var init_relations_definition_validator = __esm({
|
|
|
1378
1407
|
_validateRelation(modelName, relName, relDef) {
|
|
1379
1408
|
if (!modelName || typeof modelName !== "string") {
|
|
1380
1409
|
throw new InvalidArgumentError(
|
|
1381
|
-
"
|
|
1410
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
1382
1411
|
modelName
|
|
1383
1412
|
);
|
|
1384
1413
|
}
|
|
1385
1414
|
if (!relName || typeof relName !== "string") {
|
|
1386
1415
|
throw new InvalidArgumentError(
|
|
1387
|
-
"
|
|
1416
|
+
"Relation name of the model %v must be a non-empty String, but %v was given.",
|
|
1388
1417
|
modelName,
|
|
1389
1418
|
relName
|
|
1390
1419
|
);
|
|
1391
1420
|
}
|
|
1392
1421
|
if (!relDef || typeof relDef !== "object" || Array.isArray(relDef)) {
|
|
1393
1422
|
throw new InvalidArgumentError(
|
|
1394
|
-
"
|
|
1423
|
+
"Relation %v of the model %v must be an Object, but %v was given.",
|
|
1395
1424
|
relName,
|
|
1396
1425
|
modelName,
|
|
1397
1426
|
relDef
|
|
@@ -1399,7 +1428,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1399
1428
|
}
|
|
1400
1429
|
if (!relDef.type || !Object.values(RelationType).includes(relDef.type)) {
|
|
1401
1430
|
throw new InvalidArgumentError(
|
|
1402
|
-
'
|
|
1431
|
+
'Relation %v of the model %v requires the option "type" to have one of relation types: %l, but %v was given.',
|
|
1403
1432
|
relName,
|
|
1404
1433
|
modelName,
|
|
1405
1434
|
Object.values(RelationType),
|
|
@@ -1445,7 +1474,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1445
1474
|
if (relDef.polymorphic) {
|
|
1446
1475
|
if (typeof relDef.polymorphic !== "boolean") {
|
|
1447
1476
|
throw new InvalidArgumentError(
|
|
1448
|
-
'
|
|
1477
|
+
'Relation %v of the model %v has the type "belongsTo", so it expects the option "polymorphic" to be a Boolean, but %v was given.',
|
|
1449
1478
|
relName,
|
|
1450
1479
|
modelName,
|
|
1451
1480
|
relDef.polymorphic
|
|
@@ -1453,7 +1482,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1453
1482
|
}
|
|
1454
1483
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
|
|
1455
1484
|
throw new InvalidArgumentError(
|
|
1456
|
-
'
|
|
1485
|
+
'Relation %v of the model %v is a polymorphic "belongsTo" relation, so it expects the provided option "foreignKey" to be a String, but %v was given.',
|
|
1457
1486
|
relName,
|
|
1458
1487
|
modelName,
|
|
1459
1488
|
relDef.foreignKey
|
|
@@ -1461,7 +1490,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1461
1490
|
}
|
|
1462
1491
|
if (relDef.discriminator && typeof relDef.discriminator !== "string") {
|
|
1463
1492
|
throw new InvalidArgumentError(
|
|
1464
|
-
'
|
|
1493
|
+
'Relation %v of the model %v is a polymorphic "belongsTo" relation, so it expects the provided option "discriminator" to be a String, but %v was given.',
|
|
1465
1494
|
relName,
|
|
1466
1495
|
modelName,
|
|
1467
1496
|
relDef.discriminator
|
|
@@ -1470,7 +1499,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1470
1499
|
} else {
|
|
1471
1500
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1472
1501
|
throw new InvalidArgumentError(
|
|
1473
|
-
'
|
|
1502
|
+
'Relation %v of the model %v has the type "belongsTo", so it requires the option "model" to be a non-empty String, but %v was given.',
|
|
1474
1503
|
relName,
|
|
1475
1504
|
modelName,
|
|
1476
1505
|
relDef.model
|
|
@@ -1478,7 +1507,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1478
1507
|
}
|
|
1479
1508
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
|
|
1480
1509
|
throw new InvalidArgumentError(
|
|
1481
|
-
'
|
|
1510
|
+
'Relation %v of the model %v has the type "belongsTo", so it expects the provided option "foreignKey" to be a String, but %v was given.',
|
|
1482
1511
|
relName,
|
|
1483
1512
|
modelName,
|
|
1484
1513
|
relDef.foreignKey
|
|
@@ -1486,7 +1515,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1486
1515
|
}
|
|
1487
1516
|
if (relDef.discriminator) {
|
|
1488
1517
|
throw new InvalidArgumentError(
|
|
1489
|
-
'
|
|
1518
|
+
'Relation %v of the model %v is a non-polymorphic "belongsTo" relation, so it must not have the option "discriminator" to be provided.',
|
|
1490
1519
|
relName,
|
|
1491
1520
|
modelName
|
|
1492
1521
|
);
|
|
@@ -1536,7 +1565,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1536
1565
|
}
|
|
1537
1566
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1538
1567
|
throw new InvalidArgumentError(
|
|
1539
|
-
'
|
|
1568
|
+
'Relation %v of the model %v has the type "hasOne", so it requires the option "model" to be a non-empty String, but %v was given.',
|
|
1540
1569
|
relName,
|
|
1541
1570
|
modelName,
|
|
1542
1571
|
relDef.model
|
|
@@ -1546,14 +1575,14 @@ var init_relations_definition_validator = __esm({
|
|
|
1546
1575
|
if (typeof relDef.polymorphic === "string") {
|
|
1547
1576
|
if (relDef.foreignKey) {
|
|
1548
1577
|
throw new InvalidArgumentError(
|
|
1549
|
-
'
|
|
1578
|
+
'Relation %v of the model %v has the option "polymorphic" with a String value, so it must not have the option "foreignKey" to be provided.',
|
|
1550
1579
|
relName,
|
|
1551
1580
|
modelName
|
|
1552
1581
|
);
|
|
1553
1582
|
}
|
|
1554
1583
|
if (relDef.discriminator) {
|
|
1555
1584
|
throw new InvalidArgumentError(
|
|
1556
|
-
'
|
|
1585
|
+
'Relation %v of the model %v has the option "polymorphic" with a String value, so it must not have the option "discriminator" to be provided.',
|
|
1557
1586
|
relName,
|
|
1558
1587
|
modelName
|
|
1559
1588
|
);
|
|
@@ -1561,7 +1590,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1561
1590
|
} else if (typeof relDef.polymorphic === "boolean") {
|
|
1562
1591
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1563
1592
|
throw new InvalidArgumentError(
|
|
1564
|
-
'
|
|
1593
|
+
'Relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "foreignKey" to be a non-empty String, but %v was given.',
|
|
1565
1594
|
relName,
|
|
1566
1595
|
modelName,
|
|
1567
1596
|
relDef.foreignKey
|
|
@@ -1569,7 +1598,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1569
1598
|
}
|
|
1570
1599
|
if (!relDef.discriminator || typeof relDef.discriminator !== "string") {
|
|
1571
1600
|
throw new InvalidArgumentError(
|
|
1572
|
-
'
|
|
1601
|
+
'Relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "discriminator" to be a non-empty String, but %v was given.',
|
|
1573
1602
|
relName,
|
|
1574
1603
|
modelName,
|
|
1575
1604
|
relDef.discriminator
|
|
@@ -1577,7 +1606,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1577
1606
|
}
|
|
1578
1607
|
} else {
|
|
1579
1608
|
throw new InvalidArgumentError(
|
|
1580
|
-
'
|
|
1609
|
+
'Relation %v of the model %v has the type "hasOne", so it expects the provided option "polymorphic" to be a String or a Boolean, but %v was given.',
|
|
1581
1610
|
relName,
|
|
1582
1611
|
modelName,
|
|
1583
1612
|
relDef.polymorphic
|
|
@@ -1586,7 +1615,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1586
1615
|
} else {
|
|
1587
1616
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1588
1617
|
throw new InvalidArgumentError(
|
|
1589
|
-
'
|
|
1618
|
+
'Relation %v of the model %v has the type "hasOne", so it requires the option "foreignKey" to be a non-empty String, but %v was given.',
|
|
1590
1619
|
relName,
|
|
1591
1620
|
modelName,
|
|
1592
1621
|
relDef.foreignKey
|
|
@@ -1594,7 +1623,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1594
1623
|
}
|
|
1595
1624
|
if (relDef.discriminator) {
|
|
1596
1625
|
throw new InvalidArgumentError(
|
|
1597
|
-
'
|
|
1626
|
+
'Relation %v of the model %v is a non-polymorphic "hasOne" relation, so it must not have the option "discriminator" to be provided.',
|
|
1598
1627
|
relName,
|
|
1599
1628
|
modelName
|
|
1600
1629
|
);
|
|
@@ -1644,7 +1673,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1644
1673
|
}
|
|
1645
1674
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1646
1675
|
throw new InvalidArgumentError(
|
|
1647
|
-
'
|
|
1676
|
+
'Relation %v of the model %v has the type "hasMany", so it requires the option "model" to be a non-empty String, but %v was given.',
|
|
1648
1677
|
relName,
|
|
1649
1678
|
modelName,
|
|
1650
1679
|
relDef.model
|
|
@@ -1654,14 +1683,14 @@ var init_relations_definition_validator = __esm({
|
|
|
1654
1683
|
if (typeof relDef.polymorphic === "string") {
|
|
1655
1684
|
if (relDef.foreignKey) {
|
|
1656
1685
|
throw new InvalidArgumentError(
|
|
1657
|
-
'
|
|
1686
|
+
'Relation %v of the model %v has the option "polymorphic" with a String value, so it must not have the option "foreignKey" to be provided.',
|
|
1658
1687
|
relName,
|
|
1659
1688
|
modelName
|
|
1660
1689
|
);
|
|
1661
1690
|
}
|
|
1662
1691
|
if (relDef.discriminator) {
|
|
1663
1692
|
throw new InvalidArgumentError(
|
|
1664
|
-
'
|
|
1693
|
+
'Relation %v of the model %v has the option "polymorphic" with a String value, so it must not have the option "discriminator" to be provided.',
|
|
1665
1694
|
relName,
|
|
1666
1695
|
modelName
|
|
1667
1696
|
);
|
|
@@ -1669,7 +1698,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1669
1698
|
} else if (typeof relDef.polymorphic === "boolean") {
|
|
1670
1699
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1671
1700
|
throw new InvalidArgumentError(
|
|
1672
|
-
'
|
|
1701
|
+
'Relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "foreignKey" to be a non-empty String, but %v was given.',
|
|
1673
1702
|
relName,
|
|
1674
1703
|
modelName,
|
|
1675
1704
|
relDef.foreignKey
|
|
@@ -1677,7 +1706,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1677
1706
|
}
|
|
1678
1707
|
if (!relDef.discriminator || typeof relDef.discriminator !== "string") {
|
|
1679
1708
|
throw new InvalidArgumentError(
|
|
1680
|
-
'
|
|
1709
|
+
'Relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "discriminator" to be a non-empty String, but %v was given.',
|
|
1681
1710
|
relName,
|
|
1682
1711
|
modelName,
|
|
1683
1712
|
relDef.discriminator
|
|
@@ -1685,7 +1714,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1685
1714
|
}
|
|
1686
1715
|
} else {
|
|
1687
1716
|
throw new InvalidArgumentError(
|
|
1688
|
-
'
|
|
1717
|
+
'Relation %v of the model %v has the type "hasMany", so it expects the provided option "polymorphic" to be a String or a Boolean, but %v was given.',
|
|
1689
1718
|
relName,
|
|
1690
1719
|
modelName,
|
|
1691
1720
|
relDef.polymorphic
|
|
@@ -1694,7 +1723,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1694
1723
|
} else {
|
|
1695
1724
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1696
1725
|
throw new InvalidArgumentError(
|
|
1697
|
-
'
|
|
1726
|
+
'Relation %v of the model %v has the type "hasMany", so it requires the option "foreignKey" to be a non-empty String, but %v was given.',
|
|
1698
1727
|
relName,
|
|
1699
1728
|
modelName,
|
|
1700
1729
|
relDef.foreignKey
|
|
@@ -1702,7 +1731,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1702
1731
|
}
|
|
1703
1732
|
if (relDef.discriminator) {
|
|
1704
1733
|
throw new InvalidArgumentError(
|
|
1705
|
-
'
|
|
1734
|
+
'Relation %v of the model %v is a non-polymorphic "hasMany" relation, so it must not have the option "discriminator" to be provided.',
|
|
1706
1735
|
relName,
|
|
1707
1736
|
modelName
|
|
1708
1737
|
);
|
|
@@ -1732,7 +1761,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1732
1761
|
}
|
|
1733
1762
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1734
1763
|
throw new InvalidArgumentError(
|
|
1735
|
-
'
|
|
1764
|
+
'Relation %v of the model %v has the type "referencesMany", so it requires the option "model" to be a non-empty String, but %v was given.',
|
|
1736
1765
|
relName,
|
|
1737
1766
|
modelName,
|
|
1738
1767
|
relDef.model
|
|
@@ -1740,7 +1769,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1740
1769
|
}
|
|
1741
1770
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
|
|
1742
1771
|
throw new InvalidArgumentError(
|
|
1743
|
-
'
|
|
1772
|
+
'Relation %v of the model %v has the type "referencesMany", so it expects the provided option "foreignKey" to be a String, but %v was given.',
|
|
1744
1773
|
relName,
|
|
1745
1774
|
modelName,
|
|
1746
1775
|
relDef.foreignKey
|
|
@@ -1748,15 +1777,13 @@ var init_relations_definition_validator = __esm({
|
|
|
1748
1777
|
}
|
|
1749
1778
|
if (relDef.discriminator) {
|
|
1750
1779
|
throw new InvalidArgumentError(
|
|
1751
|
-
'
|
|
1780
|
+
'Relation %v of the model %v has the type "referencesMany", so it must not have the option "discriminator" to be provided.',
|
|
1752
1781
|
relName,
|
|
1753
1782
|
modelName
|
|
1754
1783
|
);
|
|
1755
1784
|
}
|
|
1756
1785
|
}
|
|
1757
1786
|
};
|
|
1758
|
-
__name(_RelationsDefinitionValidator, "RelationsDefinitionValidator");
|
|
1759
|
-
RelationsDefinitionValidator = _RelationsDefinitionValidator;
|
|
1760
1787
|
}
|
|
1761
1788
|
});
|
|
1762
1789
|
|
|
@@ -1807,7 +1834,7 @@ var init_property_uniqueness = __esm({
|
|
|
1807
1834
|
});
|
|
1808
1835
|
|
|
1809
1836
|
// src/definition/definition-registry.js
|
|
1810
|
-
var import_js_service6,
|
|
1837
|
+
var import_js_service6, DefinitionRegistry;
|
|
1811
1838
|
var init_definition_registry = __esm({
|
|
1812
1839
|
"src/definition/definition-registry.js"() {
|
|
1813
1840
|
"use strict";
|
|
@@ -1816,7 +1843,10 @@ var init_definition_registry = __esm({
|
|
|
1816
1843
|
init_errors();
|
|
1817
1844
|
init_model();
|
|
1818
1845
|
init_definition();
|
|
1819
|
-
|
|
1846
|
+
DefinitionRegistry = class extends import_js_service6.Service {
|
|
1847
|
+
static {
|
|
1848
|
+
__name(this, "DefinitionRegistry");
|
|
1849
|
+
}
|
|
1820
1850
|
/**
|
|
1821
1851
|
* Datasources.
|
|
1822
1852
|
*
|
|
@@ -1838,10 +1868,7 @@ var init_definition_registry = __esm({
|
|
|
1838
1868
|
this.getService(DatasourceDefinitionValidator).validate(datasourceDef);
|
|
1839
1869
|
const name = datasourceDef.name;
|
|
1840
1870
|
if (name in this._datasources) {
|
|
1841
|
-
throw new InvalidArgumentError(
|
|
1842
|
-
"The datasource %v is already defined.",
|
|
1843
|
-
name
|
|
1844
|
-
);
|
|
1871
|
+
throw new InvalidArgumentError("Datasource %v is already defined.", name);
|
|
1845
1872
|
}
|
|
1846
1873
|
this._datasources[name] = datasourceDef;
|
|
1847
1874
|
}
|
|
@@ -1863,7 +1890,7 @@ var init_definition_registry = __esm({
|
|
|
1863
1890
|
getDatasource(name) {
|
|
1864
1891
|
const datasourceDef = this._datasources[name];
|
|
1865
1892
|
if (!datasourceDef) {
|
|
1866
|
-
throw new InvalidArgumentError("
|
|
1893
|
+
throw new InvalidArgumentError("Datasource %v is not defined.", name);
|
|
1867
1894
|
}
|
|
1868
1895
|
return datasourceDef;
|
|
1869
1896
|
}
|
|
@@ -1877,7 +1904,7 @@ var init_definition_registry = __esm({
|
|
|
1877
1904
|
const modelKey = modelNameToModelKey(modelDef.name);
|
|
1878
1905
|
if (modelKey in this._models) {
|
|
1879
1906
|
throw new InvalidArgumentError(
|
|
1880
|
-
"
|
|
1907
|
+
"Model %v is already defined.",
|
|
1881
1908
|
modelDef.name
|
|
1882
1909
|
);
|
|
1883
1910
|
}
|
|
@@ -1903,18 +1930,16 @@ var init_definition_registry = __esm({
|
|
|
1903
1930
|
const modelKey = modelNameToModelKey(name);
|
|
1904
1931
|
const modelDef = this._models[modelKey];
|
|
1905
1932
|
if (!modelDef) {
|
|
1906
|
-
throw new InvalidArgumentError("
|
|
1933
|
+
throw new InvalidArgumentError("Model %v is not defined.", name);
|
|
1907
1934
|
}
|
|
1908
1935
|
return modelDef;
|
|
1909
1936
|
}
|
|
1910
1937
|
};
|
|
1911
|
-
__name(_DefinitionRegistry, "DefinitionRegistry");
|
|
1912
|
-
DefinitionRegistry = _DefinitionRegistry;
|
|
1913
1938
|
}
|
|
1914
1939
|
});
|
|
1915
1940
|
|
|
1916
1941
|
// src/definition/model/model-definition-utils.js
|
|
1917
|
-
var import_js_service7, DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
1942
|
+
var import_js_service7, DEFAULT_PRIMARY_KEY_PROPERTY_NAME, ModelDefinitionUtils;
|
|
1918
1943
|
var init_model_definition_utils = __esm({
|
|
1919
1944
|
"src/definition/model/model-definition-utils.js"() {
|
|
1920
1945
|
"use strict";
|
|
@@ -1924,7 +1949,10 @@ var init_model_definition_utils = __esm({
|
|
|
1924
1949
|
init_definition_registry();
|
|
1925
1950
|
init_utils();
|
|
1926
1951
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME = "id";
|
|
1927
|
-
|
|
1952
|
+
ModelDefinitionUtils = class extends import_js_service7.Service {
|
|
1953
|
+
static {
|
|
1954
|
+
__name(this, "ModelDefinitionUtils");
|
|
1955
|
+
}
|
|
1928
1956
|
/**
|
|
1929
1957
|
* Get primary key as property name.
|
|
1930
1958
|
*
|
|
@@ -1943,7 +1971,7 @@ var init_model_definition_utils = __esm({
|
|
|
1943
1971
|
);
|
|
1944
1972
|
if (isDefaultPrimaryKeyAlreadyInUse) {
|
|
1945
1973
|
throw new InvalidArgumentError(
|
|
1946
|
-
'
|
|
1974
|
+
'Property name %v of the model %v is defined as a regular property. In this case, a primary key must be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
|
|
1947
1975
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
1948
1976
|
modelName
|
|
1949
1977
|
);
|
|
@@ -1980,9 +2008,8 @@ var init_model_definition_utils = __esm({
|
|
|
1980
2008
|
* @returns {string}
|
|
1981
2009
|
*/
|
|
1982
2010
|
getTableNameByModelName(modelName) {
|
|
1983
|
-
var _a;
|
|
1984
2011
|
const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
|
|
1985
|
-
return
|
|
2012
|
+
return modelDef.tableName ?? modelName;
|
|
1986
2013
|
}
|
|
1987
2014
|
/**
|
|
1988
2015
|
* Get column name by property name.
|
|
@@ -1992,18 +2019,17 @@ var init_model_definition_utils = __esm({
|
|
|
1992
2019
|
* @returns {string}
|
|
1993
2020
|
*/
|
|
1994
2021
|
getColumnNameByPropertyName(modelName, propertyName) {
|
|
1995
|
-
var _a;
|
|
1996
2022
|
const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
|
|
1997
2023
|
const propDef = propDefs[propertyName];
|
|
1998
2024
|
if (!propDef) {
|
|
1999
2025
|
throw new InvalidArgumentError(
|
|
2000
|
-
"
|
|
2026
|
+
"Model %v does not have the property %v.",
|
|
2001
2027
|
modelName,
|
|
2002
2028
|
propertyName
|
|
2003
2029
|
);
|
|
2004
2030
|
}
|
|
2005
2031
|
if (propDef && typeof propDef === "object") {
|
|
2006
|
-
return
|
|
2032
|
+
return propDef.columnName ?? propertyName;
|
|
2007
2033
|
}
|
|
2008
2034
|
return propertyName;
|
|
2009
2035
|
}
|
|
@@ -2019,7 +2045,7 @@ var init_model_definition_utils = __esm({
|
|
|
2019
2045
|
const propDef = propDefs[propertyName];
|
|
2020
2046
|
if (!propDef) {
|
|
2021
2047
|
throw new InvalidArgumentError(
|
|
2022
|
-
"
|
|
2048
|
+
"Model %v does not have the property %v.",
|
|
2023
2049
|
modelName,
|
|
2024
2050
|
propertyName
|
|
2025
2051
|
);
|
|
@@ -2139,7 +2165,7 @@ var init_model_definition_utils = __esm({
|
|
|
2139
2165
|
return DataType.ANY;
|
|
2140
2166
|
}
|
|
2141
2167
|
throw new InvalidArgumentError(
|
|
2142
|
-
"
|
|
2168
|
+
"Model %v does not have the property %v.",
|
|
2143
2169
|
modelName,
|
|
2144
2170
|
propertyName
|
|
2145
2171
|
);
|
|
@@ -2158,7 +2184,7 @@ var init_model_definition_utils = __esm({
|
|
|
2158
2184
|
getDataTypeFromPropertyDefinition(propDef) {
|
|
2159
2185
|
if ((!propDef || typeof propDef !== "object") && !Object.values(DataType).includes(propDef)) {
|
|
2160
2186
|
throw new InvalidArgumentError(
|
|
2161
|
-
'
|
|
2187
|
+
'Parameter "propDef" must be an Object or a DataType, but %v was given.',
|
|
2162
2188
|
propDef
|
|
2163
2189
|
);
|
|
2164
2190
|
}
|
|
@@ -2168,7 +2194,7 @@ var init_model_definition_utils = __esm({
|
|
|
2168
2194
|
const dataType = propDef.type;
|
|
2169
2195
|
if (!Object.values(DataType).includes(dataType)) {
|
|
2170
2196
|
throw new InvalidArgumentError(
|
|
2171
|
-
'
|
|
2197
|
+
'Option "type" must be one of values: %l, but %v was given.',
|
|
2172
2198
|
Object.values(DataType),
|
|
2173
2199
|
propDef.type
|
|
2174
2200
|
);
|
|
@@ -2182,9 +2208,8 @@ var init_model_definition_utils = __esm({
|
|
|
2182
2208
|
* @returns {object}
|
|
2183
2209
|
*/
|
|
2184
2210
|
getOwnPropertiesDefinitionOfPrimaryKeys(modelName) {
|
|
2185
|
-
var _a;
|
|
2186
2211
|
const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
|
|
2187
|
-
const propDefs =
|
|
2212
|
+
const propDefs = modelDef.properties ?? {};
|
|
2188
2213
|
const pkPropNames = Object.keys(propDefs).filter((propName) => {
|
|
2189
2214
|
const propDef = propDefs[propName];
|
|
2190
2215
|
return typeof propDef === "object" && propDef.primaryKey;
|
|
@@ -2198,9 +2223,8 @@ var init_model_definition_utils = __esm({
|
|
|
2198
2223
|
* @returns {object}
|
|
2199
2224
|
*/
|
|
2200
2225
|
getOwnPropertiesDefinitionWithoutPrimaryKeys(modelName) {
|
|
2201
|
-
var _a;
|
|
2202
2226
|
const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
|
|
2203
|
-
const propDefs =
|
|
2227
|
+
const propDefs = modelDef.properties ?? {};
|
|
2204
2228
|
return Object.keys(propDefs).reduce((result, propName) => {
|
|
2205
2229
|
const propDef = propDefs[propName];
|
|
2206
2230
|
if (typeof propDef === "object" && propDef.primaryKey) {
|
|
@@ -2221,7 +2245,7 @@ var init_model_definition_utils = __esm({
|
|
|
2221
2245
|
const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
|
|
2222
2246
|
if (currModelName === prevModelName) {
|
|
2223
2247
|
throw new InvalidArgumentError(
|
|
2224
|
-
"
|
|
2248
|
+
"Model %v has a circular inheritance.",
|
|
2225
2249
|
currModelName
|
|
2226
2250
|
);
|
|
2227
2251
|
}
|
|
@@ -2247,9 +2271,8 @@ var init_model_definition_utils = __esm({
|
|
|
2247
2271
|
* @returns {object}
|
|
2248
2272
|
*/
|
|
2249
2273
|
getOwnRelationsDefinition(modelName) {
|
|
2250
|
-
var _a;
|
|
2251
2274
|
const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
|
|
2252
|
-
return
|
|
2275
|
+
return modelDef.relations ?? {};
|
|
2253
2276
|
}
|
|
2254
2277
|
/**
|
|
2255
2278
|
* Get relations definition in base model hierarchy.
|
|
@@ -2260,15 +2283,14 @@ var init_model_definition_utils = __esm({
|
|
|
2260
2283
|
getRelationsDefinitionInBaseModelHierarchy(modelName) {
|
|
2261
2284
|
let result = {};
|
|
2262
2285
|
const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
|
|
2263
|
-
var _a;
|
|
2264
2286
|
if (currModelName === prevModelName) {
|
|
2265
2287
|
throw new InvalidArgumentError(
|
|
2266
|
-
"
|
|
2288
|
+
"Model %v has a circular inheritance.",
|
|
2267
2289
|
currModelName
|
|
2268
2290
|
);
|
|
2269
2291
|
}
|
|
2270
2292
|
const modelDef = this.getService(DefinitionRegistry).getModel(currModelName);
|
|
2271
|
-
const ownRelDefs =
|
|
2293
|
+
const ownRelDefs = modelDef.relations ?? {};
|
|
2272
2294
|
result = { ...ownRelDefs, ...result };
|
|
2273
2295
|
if (modelDef.base) {
|
|
2274
2296
|
recursion(modelDef.base, currModelName);
|
|
@@ -2296,7 +2318,7 @@ var init_model_definition_utils = __esm({
|
|
|
2296
2318
|
}
|
|
2297
2319
|
if (!foundDef) {
|
|
2298
2320
|
throw new InvalidArgumentError(
|
|
2299
|
-
"
|
|
2321
|
+
"Model %v does not have relation name %v.",
|
|
2300
2322
|
modelName,
|
|
2301
2323
|
relationName
|
|
2302
2324
|
);
|
|
@@ -2313,7 +2335,7 @@ var init_model_definition_utils = __esm({
|
|
|
2313
2335
|
excludeObjectKeysByRelationNames(modelName, modelData) {
|
|
2314
2336
|
if (!modelData || typeof modelData !== "object" || Array.isArray(modelData)) {
|
|
2315
2337
|
throw new InvalidArgumentError(
|
|
2316
|
-
"
|
|
2338
|
+
'Parameter "modelData" must be an Object, but %v was given.',
|
|
2317
2339
|
modelData
|
|
2318
2340
|
);
|
|
2319
2341
|
}
|
|
@@ -2357,13 +2379,11 @@ var init_model_definition_utils = __esm({
|
|
|
2357
2379
|
return void 0;
|
|
2358
2380
|
}
|
|
2359
2381
|
};
|
|
2360
|
-
__name(_ModelDefinitionUtils, "ModelDefinitionUtils");
|
|
2361
|
-
ModelDefinitionUtils = _ModelDefinitionUtils;
|
|
2362
2382
|
}
|
|
2363
2383
|
});
|
|
2364
2384
|
|
|
2365
2385
|
// src/definition/model/properties/required-property-validator.js
|
|
2366
|
-
var import_js_service8,
|
|
2386
|
+
var import_js_service8, RequiredPropertyValidator;
|
|
2367
2387
|
var init_required_property_validator = __esm({
|
|
2368
2388
|
"src/definition/model/properties/required-property-validator.js"() {
|
|
2369
2389
|
"use strict";
|
|
@@ -2371,7 +2391,10 @@ var init_required_property_validator = __esm({
|
|
|
2371
2391
|
import_js_service8 = require("@e22m4u/js-service");
|
|
2372
2392
|
init_errors();
|
|
2373
2393
|
init_model_definition_utils();
|
|
2374
|
-
|
|
2394
|
+
RequiredPropertyValidator = class extends import_js_service8.Service {
|
|
2395
|
+
static {
|
|
2396
|
+
__name(this, "RequiredPropertyValidator");
|
|
2397
|
+
}
|
|
2375
2398
|
/**
|
|
2376
2399
|
* Validate.
|
|
2377
2400
|
*
|
|
@@ -2388,7 +2411,7 @@ var init_required_property_validator = __esm({
|
|
|
2388
2411
|
}
|
|
2389
2412
|
if (!modelData || typeof modelData !== "object" || Array.isArray(modelData)) {
|
|
2390
2413
|
throw new InvalidArgumentError(
|
|
2391
|
-
"Data of the model %v
|
|
2414
|
+
"Data of the model %v must be an Object, but %v was given.",
|
|
2392
2415
|
modelName,
|
|
2393
2416
|
modelData
|
|
2394
2417
|
);
|
|
@@ -2429,13 +2452,11 @@ var init_required_property_validator = __esm({
|
|
|
2429
2452
|
}
|
|
2430
2453
|
}
|
|
2431
2454
|
};
|
|
2432
|
-
__name(_RequiredPropertyValidator, "RequiredPropertyValidator");
|
|
2433
|
-
RequiredPropertyValidator = _RequiredPropertyValidator;
|
|
2434
2455
|
}
|
|
2435
2456
|
});
|
|
2436
2457
|
|
|
2437
2458
|
// src/definition/model/properties/property-uniqueness-validator.js
|
|
2438
|
-
var import_js_service9,
|
|
2459
|
+
var import_js_service9, PropertyUniquenessValidator;
|
|
2439
2460
|
var init_property_uniqueness_validator = __esm({
|
|
2440
2461
|
"src/definition/model/properties/property-uniqueness-validator.js"() {
|
|
2441
2462
|
"use strict";
|
|
@@ -2444,7 +2465,10 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2444
2465
|
init_property_uniqueness();
|
|
2445
2466
|
init_errors();
|
|
2446
2467
|
init_model_definition_utils();
|
|
2447
|
-
|
|
2468
|
+
PropertyUniquenessValidator = class extends import_js_service9.Service {
|
|
2469
|
+
static {
|
|
2470
|
+
__name(this, "PropertyUniquenessValidator");
|
|
2471
|
+
}
|
|
2448
2472
|
/**
|
|
2449
2473
|
* Validate.
|
|
2450
2474
|
*
|
|
@@ -2458,25 +2482,25 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2458
2482
|
async validate(countMethod, methodName, modelName, modelData, modelId = void 0) {
|
|
2459
2483
|
if (typeof countMethod !== "function") {
|
|
2460
2484
|
throw new InvalidArgumentError(
|
|
2461
|
-
'
|
|
2485
|
+
'Parameter "countMethod" must be a Function, but %v was given.',
|
|
2462
2486
|
countMethod
|
|
2463
2487
|
);
|
|
2464
2488
|
}
|
|
2465
2489
|
if (!methodName || typeof methodName !== "string") {
|
|
2466
2490
|
throw new InvalidArgumentError(
|
|
2467
|
-
'
|
|
2491
|
+
'Parameter "methodName" must be a non-empty String, but %v was given.',
|
|
2468
2492
|
methodName
|
|
2469
2493
|
);
|
|
2470
2494
|
}
|
|
2471
2495
|
if (!modelName || typeof modelName !== "string") {
|
|
2472
2496
|
throw new InvalidArgumentError(
|
|
2473
|
-
'
|
|
2497
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2474
2498
|
modelName
|
|
2475
2499
|
);
|
|
2476
2500
|
}
|
|
2477
2501
|
if (!isPlainObject(modelData)) {
|
|
2478
2502
|
throw new InvalidArgumentError(
|
|
2479
|
-
"
|
|
2503
|
+
"Data of the model %v must be an Object, but %v was given.",
|
|
2480
2504
|
modelName,
|
|
2481
2505
|
modelData
|
|
2482
2506
|
);
|
|
@@ -2490,7 +2514,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2490
2514
|
modelName
|
|
2491
2515
|
);
|
|
2492
2516
|
const createError = /* @__PURE__ */ __name((propName, propValue) => new InvalidArgumentError(
|
|
2493
|
-
"
|
|
2517
|
+
"Existing document of the model %v already has the property %v with the value %v and must be unique.",
|
|
2494
2518
|
modelName,
|
|
2495
2519
|
propName,
|
|
2496
2520
|
propValue
|
|
@@ -2553,27 +2577,28 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2553
2577
|
}
|
|
2554
2578
|
} else {
|
|
2555
2579
|
throw new InvalidArgumentError(
|
|
2556
|
-
"
|
|
2580
|
+
"Adapter method %v is not supported.",
|
|
2557
2581
|
methodName
|
|
2558
2582
|
);
|
|
2559
2583
|
}
|
|
2560
2584
|
}
|
|
2561
2585
|
}
|
|
2562
2586
|
};
|
|
2563
|
-
__name(_PropertyUniquenessValidator, "PropertyUniquenessValidator");
|
|
2564
|
-
PropertyUniquenessValidator = _PropertyUniquenessValidator;
|
|
2565
2587
|
}
|
|
2566
2588
|
});
|
|
2567
2589
|
|
|
2568
2590
|
// src/definition/model/properties/primary-keys-definition-validator.js
|
|
2569
|
-
var import_js_service10,
|
|
2591
|
+
var import_js_service10, PrimaryKeysDefinitionValidator;
|
|
2570
2592
|
var init_primary_keys_definition_validator = __esm({
|
|
2571
2593
|
"src/definition/model/properties/primary-keys-definition-validator.js"() {
|
|
2572
2594
|
"use strict";
|
|
2573
2595
|
import_js_service10 = require("@e22m4u/js-service");
|
|
2574
2596
|
init_errors();
|
|
2575
2597
|
init_model_definition_utils();
|
|
2576
|
-
|
|
2598
|
+
PrimaryKeysDefinitionValidator = class extends import_js_service10.Service {
|
|
2599
|
+
static {
|
|
2600
|
+
__name(this, "PrimaryKeysDefinitionValidator");
|
|
2601
|
+
}
|
|
2577
2602
|
/**
|
|
2578
2603
|
* Validate.
|
|
2579
2604
|
*
|
|
@@ -2589,7 +2614,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2589
2614
|
const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(DEFAULT_PRIMARY_KEY_PROPERTY_NAME);
|
|
2590
2615
|
if (isDefaultPrimaryKeyAlreadyInUse) {
|
|
2591
2616
|
throw new InvalidArgumentError(
|
|
2592
|
-
'
|
|
2617
|
+
'Property name %v of the model %v is defined as a regular property. In this case, a primary key must be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
|
|
2593
2618
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
2594
2619
|
modelName
|
|
2595
2620
|
);
|
|
@@ -2598,7 +2623,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2598
2623
|
}
|
|
2599
2624
|
if (propNames.length > 1) {
|
|
2600
2625
|
throw new InvalidArgumentError(
|
|
2601
|
-
"
|
|
2626
|
+
"Model definition %v must not have multiple primary keys, but %v keys were given.",
|
|
2602
2627
|
modelName,
|
|
2603
2628
|
propNames.length
|
|
2604
2629
|
);
|
|
@@ -2614,13 +2639,11 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2614
2639
|
}
|
|
2615
2640
|
}
|
|
2616
2641
|
};
|
|
2617
|
-
__name(_PrimaryKeysDefinitionValidator, "PrimaryKeysDefinitionValidator");
|
|
2618
|
-
PrimaryKeysDefinitionValidator = _PrimaryKeysDefinitionValidator;
|
|
2619
2642
|
}
|
|
2620
2643
|
});
|
|
2621
2644
|
|
|
2622
2645
|
// src/definition/model/properties/properties-definition-validator.js
|
|
2623
|
-
var import_js_service11,
|
|
2646
|
+
var import_js_service11, PropertiesDefinitionValidator;
|
|
2624
2647
|
var init_properties_definition_validator = __esm({
|
|
2625
2648
|
"src/definition/model/properties/properties-definition-validator.js"() {
|
|
2626
2649
|
"use strict";
|
|
@@ -2630,7 +2653,10 @@ var init_properties_definition_validator = __esm({
|
|
|
2630
2653
|
init_property_uniqueness();
|
|
2631
2654
|
init_errors();
|
|
2632
2655
|
init_primary_keys_definition_validator();
|
|
2633
|
-
|
|
2656
|
+
PropertiesDefinitionValidator = class extends import_js_service11.Service {
|
|
2657
|
+
static {
|
|
2658
|
+
__name(this, "PropertiesDefinitionValidator");
|
|
2659
|
+
}
|
|
2634
2660
|
/**
|
|
2635
2661
|
* Validate.
|
|
2636
2662
|
*
|
|
@@ -2640,13 +2666,13 @@ var init_properties_definition_validator = __esm({
|
|
|
2640
2666
|
validate(modelName, propDefs) {
|
|
2641
2667
|
if (!modelName || typeof modelName !== "string") {
|
|
2642
2668
|
throw new InvalidArgumentError(
|
|
2643
|
-
"
|
|
2669
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2644
2670
|
modelName
|
|
2645
2671
|
);
|
|
2646
2672
|
}
|
|
2647
2673
|
if (!propDefs || typeof propDefs !== "object" || Array.isArray(propDefs)) {
|
|
2648
2674
|
throw new InvalidArgumentError(
|
|
2649
|
-
'
|
|
2675
|
+
'Option "properties" of the model %v must be an Object, but %v was given.',
|
|
2650
2676
|
modelName,
|
|
2651
2677
|
propDefs
|
|
2652
2678
|
);
|
|
@@ -2671,20 +2697,20 @@ var init_properties_definition_validator = __esm({
|
|
|
2671
2697
|
_validateProperty(modelName, propName, propDef) {
|
|
2672
2698
|
if (!modelName || typeof modelName !== "string") {
|
|
2673
2699
|
throw new InvalidArgumentError(
|
|
2674
|
-
"
|
|
2700
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2675
2701
|
modelName
|
|
2676
2702
|
);
|
|
2677
2703
|
}
|
|
2678
2704
|
if (!propName || typeof propName !== "string") {
|
|
2679
2705
|
throw new InvalidArgumentError(
|
|
2680
|
-
"
|
|
2706
|
+
"Property name of the model %v must be a non-empty String, but %v was given.",
|
|
2681
2707
|
modelName,
|
|
2682
2708
|
propName
|
|
2683
2709
|
);
|
|
2684
2710
|
}
|
|
2685
2711
|
if (!propDef) {
|
|
2686
2712
|
throw new InvalidArgumentError(
|
|
2687
|
-
"
|
|
2713
|
+
"Property %v of the model %v must have a property definition, but %v was given.",
|
|
2688
2714
|
propName,
|
|
2689
2715
|
modelName,
|
|
2690
2716
|
propDef
|
|
@@ -2693,7 +2719,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2693
2719
|
if (typeof propDef === "string") {
|
|
2694
2720
|
if (!Object.values(DataType).includes(propDef)) {
|
|
2695
2721
|
throw new InvalidArgumentError(
|
|
2696
|
-
"In case of a short property definition, the property %v of the model %v
|
|
2722
|
+
"In case of a short property definition, the property %v of the model %v must have one of data types: %l, but %v was given.",
|
|
2697
2723
|
propName,
|
|
2698
2724
|
modelName,
|
|
2699
2725
|
Object.values(DataType),
|
|
@@ -2704,7 +2730,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2704
2730
|
}
|
|
2705
2731
|
if (!propDef || typeof propDef !== "object" || Array.isArray(propDef)) {
|
|
2706
2732
|
throw new InvalidArgumentError(
|
|
2707
|
-
"In case of a full property definition, the property %v of the model %v
|
|
2733
|
+
"In case of a full property definition, the property %v of the model %v must be an Object, but %v was given.",
|
|
2708
2734
|
propName,
|
|
2709
2735
|
modelName,
|
|
2710
2736
|
propDef
|
|
@@ -2712,7 +2738,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2712
2738
|
}
|
|
2713
2739
|
if (!propDef.type || !Object.values(DataType).includes(propDef.type)) {
|
|
2714
2740
|
throw new InvalidArgumentError(
|
|
2715
|
-
'
|
|
2741
|
+
'Property %v of the model %v requires the option "type" to have one of data types: %l, but %v was given.',
|
|
2716
2742
|
propName,
|
|
2717
2743
|
modelName,
|
|
2718
2744
|
Object.values(DataType),
|
|
@@ -2721,7 +2747,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2721
2747
|
}
|
|
2722
2748
|
if (propDef.itemType && !Object.values(DataType).includes(propDef.itemType)) {
|
|
2723
2749
|
throw new InvalidArgumentError(
|
|
2724
|
-
'
|
|
2750
|
+
'Option "itemType" of the property %v in the model %v should have one of data types: %l, but %v was given.',
|
|
2725
2751
|
propName,
|
|
2726
2752
|
modelName,
|
|
2727
2753
|
Object.values(DataType),
|
|
@@ -2730,7 +2756,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2730
2756
|
}
|
|
2731
2757
|
if (propDef.itemModel && typeof propDef.itemModel !== "string") {
|
|
2732
2758
|
throw new InvalidArgumentError(
|
|
2733
|
-
'
|
|
2759
|
+
'Option "itemModel" of the property %v in the model %v must be a String, but %v was given.',
|
|
2734
2760
|
propName,
|
|
2735
2761
|
modelName,
|
|
2736
2762
|
propDef.itemModel
|
|
@@ -2738,7 +2764,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2738
2764
|
}
|
|
2739
2765
|
if (propDef.model && typeof propDef.model !== "string") {
|
|
2740
2766
|
throw new InvalidArgumentError(
|
|
2741
|
-
'
|
|
2767
|
+
'Option "model" of the property %v in the model %v must be a String, but %v was given.',
|
|
2742
2768
|
propName,
|
|
2743
2769
|
modelName,
|
|
2744
2770
|
propDef.model
|
|
@@ -2746,7 +2772,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2746
2772
|
}
|
|
2747
2773
|
if (propDef.primaryKey && typeof propDef.primaryKey !== "boolean") {
|
|
2748
2774
|
throw new InvalidArgumentError(
|
|
2749
|
-
'
|
|
2775
|
+
'Option "primaryKey" of the property %v in the model %v must be a Boolean, but %v was given.',
|
|
2750
2776
|
propName,
|
|
2751
2777
|
modelName,
|
|
2752
2778
|
propDef.primaryKey
|
|
@@ -2754,7 +2780,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2754
2780
|
}
|
|
2755
2781
|
if (propDef.columnName && typeof propDef.columnName !== "string") {
|
|
2756
2782
|
throw new InvalidArgumentError(
|
|
2757
|
-
'
|
|
2783
|
+
'Option "columnName" of the property %v in the model %v must be a String, but %v was given.',
|
|
2758
2784
|
propName,
|
|
2759
2785
|
modelName,
|
|
2760
2786
|
propDef.columnName
|
|
@@ -2762,7 +2788,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2762
2788
|
}
|
|
2763
2789
|
if (propDef.columnType && typeof propDef.columnType !== "string") {
|
|
2764
2790
|
throw new InvalidArgumentError(
|
|
2765
|
-
'
|
|
2791
|
+
'Option "columnType" of the property %v in the model %v must be a String, but %v was given.',
|
|
2766
2792
|
propName,
|
|
2767
2793
|
modelName,
|
|
2768
2794
|
propDef.columnType
|
|
@@ -2770,7 +2796,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2770
2796
|
}
|
|
2771
2797
|
if (propDef.required && typeof propDef.required !== "boolean") {
|
|
2772
2798
|
throw new InvalidArgumentError(
|
|
2773
|
-
'
|
|
2799
|
+
'Option "required" of the property %v in the model %v must be a Boolean, but %v was given.',
|
|
2774
2800
|
propName,
|
|
2775
2801
|
modelName,
|
|
2776
2802
|
propDef.required
|
|
@@ -2778,28 +2804,28 @@ var init_properties_definition_validator = __esm({
|
|
|
2778
2804
|
}
|
|
2779
2805
|
if (propDef.required && propDef.default !== void 0) {
|
|
2780
2806
|
throw new InvalidArgumentError(
|
|
2781
|
-
'
|
|
2807
|
+
'Property %v of the model %v is a required property, so it must not have the option "default" to be provided.',
|
|
2782
2808
|
propName,
|
|
2783
2809
|
modelName
|
|
2784
2810
|
);
|
|
2785
2811
|
}
|
|
2786
2812
|
if (propDef.primaryKey && propDef.required) {
|
|
2787
2813
|
throw new InvalidArgumentError(
|
|
2788
|
-
'
|
|
2814
|
+
'Property %v of the model %v is a primary key, so it must not have the option "required" to be provided.',
|
|
2789
2815
|
propName,
|
|
2790
2816
|
modelName
|
|
2791
2817
|
);
|
|
2792
2818
|
}
|
|
2793
2819
|
if (propDef.primaryKey && propDef.default !== void 0) {
|
|
2794
2820
|
throw new InvalidArgumentError(
|
|
2795
|
-
'
|
|
2821
|
+
'Property %v of the model %v is a primary key, so it must not have the option "default" to be provided.',
|
|
2796
2822
|
propName,
|
|
2797
2823
|
modelName
|
|
2798
2824
|
);
|
|
2799
2825
|
}
|
|
2800
2826
|
if (propDef.itemType && propDef.type !== DataType.ARRAY) {
|
|
2801
2827
|
throw new InvalidArgumentError(
|
|
2802
|
-
'
|
|
2828
|
+
'Property %v of the model %v has a non-array type, so it must not have the option "itemType" to be provided.',
|
|
2803
2829
|
propName,
|
|
2804
2830
|
modelName,
|
|
2805
2831
|
propDef.type
|
|
@@ -2807,7 +2833,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2807
2833
|
}
|
|
2808
2834
|
if (propDef.itemModel && propDef.type !== DataType.ARRAY) {
|
|
2809
2835
|
throw new InvalidArgumentError(
|
|
2810
|
-
'
|
|
2836
|
+
'Option "itemModel" is not supported for %s property type, so the property %v of the model %v must not have the option "itemModel" to be provided.',
|
|
2811
2837
|
capitalize(propDef.type),
|
|
2812
2838
|
propName,
|
|
2813
2839
|
modelName
|
|
@@ -2816,14 +2842,14 @@ var init_properties_definition_validator = __esm({
|
|
|
2816
2842
|
if (propDef.itemModel && propDef.itemType !== DataType.OBJECT) {
|
|
2817
2843
|
if (propDef.itemType) {
|
|
2818
2844
|
throw new InvalidArgumentError(
|
|
2819
|
-
'
|
|
2845
|
+
'Option "itemModel" requires the option "itemType" to be explicitly set to Object, but the property %v of the model %v has specified item type as %s.',
|
|
2820
2846
|
propName,
|
|
2821
2847
|
modelName,
|
|
2822
2848
|
capitalize(propDef.itemType)
|
|
2823
2849
|
);
|
|
2824
2850
|
} else {
|
|
2825
2851
|
throw new InvalidArgumentError(
|
|
2826
|
-
'
|
|
2852
|
+
'Option "itemModel" requires the option "itemType" to be explicitly set to Object, but the property %v of the model %v does not have specified item type.',
|
|
2827
2853
|
propName,
|
|
2828
2854
|
modelName
|
|
2829
2855
|
);
|
|
@@ -2831,7 +2857,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2831
2857
|
}
|
|
2832
2858
|
if (propDef.model && propDef.type !== DataType.OBJECT) {
|
|
2833
2859
|
throw new InvalidArgumentError(
|
|
2834
|
-
'
|
|
2860
|
+
'Option "model" is not supported for %s property type, so the property %v of the model %v must not have the option "model" to be provided.',
|
|
2835
2861
|
capitalize(propDef.type),
|
|
2836
2862
|
propName,
|
|
2837
2863
|
modelName
|
|
@@ -2840,7 +2866,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2840
2866
|
if (propDef.unique) {
|
|
2841
2867
|
if (typeof propDef.unique !== "boolean" && !Object.values(PropertyUniqueness).includes(propDef.unique)) {
|
|
2842
2868
|
throw new InvalidArgumentError(
|
|
2843
|
-
'
|
|
2869
|
+
'Option "unique" of the property %v in the model %v must be a Boolean or one of values: %l, but %v was given.',
|
|
2844
2870
|
propName,
|
|
2845
2871
|
modelName,
|
|
2846
2872
|
Object.values(PropertyUniqueness),
|
|
@@ -2850,15 +2876,13 @@ var init_properties_definition_validator = __esm({
|
|
|
2850
2876
|
}
|
|
2851
2877
|
if (propDef.unique && propDef.primaryKey) {
|
|
2852
2878
|
throw new InvalidArgumentError(
|
|
2853
|
-
'
|
|
2879
|
+
'Property %v of the model %v is a primary key, so it must not have the option "unique" to be provided.',
|
|
2854
2880
|
propName,
|
|
2855
2881
|
modelName
|
|
2856
2882
|
);
|
|
2857
2883
|
}
|
|
2858
2884
|
}
|
|
2859
2885
|
};
|
|
2860
|
-
__name(_PropertiesDefinitionValidator, "PropertiesDefinitionValidator");
|
|
2861
|
-
PropertiesDefinitionValidator = _PropertiesDefinitionValidator;
|
|
2862
2886
|
}
|
|
2863
2887
|
});
|
|
2864
2888
|
|
|
@@ -2884,14 +2908,17 @@ var init_model_definition = __esm({
|
|
|
2884
2908
|
});
|
|
2885
2909
|
|
|
2886
2910
|
// src/definition/model/model-data-sanitizer.js
|
|
2887
|
-
var import_js_service12,
|
|
2911
|
+
var import_js_service12, ModelDataSanitizer;
|
|
2888
2912
|
var init_model_data_sanitizer = __esm({
|
|
2889
2913
|
"src/definition/model/model-data-sanitizer.js"() {
|
|
2890
2914
|
"use strict";
|
|
2891
2915
|
import_js_service12 = require("@e22m4u/js-service");
|
|
2892
2916
|
init_errors();
|
|
2893
2917
|
init_model_definition_utils();
|
|
2894
|
-
|
|
2918
|
+
ModelDataSanitizer = class extends import_js_service12.Service {
|
|
2919
|
+
static {
|
|
2920
|
+
__name(this, "ModelDataSanitizer");
|
|
2921
|
+
}
|
|
2895
2922
|
/**
|
|
2896
2923
|
* Validate.
|
|
2897
2924
|
*
|
|
@@ -2902,13 +2929,13 @@ var init_model_data_sanitizer = __esm({
|
|
|
2902
2929
|
sanitize(modelName, modelData) {
|
|
2903
2930
|
if (!modelName || typeof modelName !== "string") {
|
|
2904
2931
|
throw new InvalidArgumentError(
|
|
2905
|
-
"
|
|
2932
|
+
'Parameter "modelName" must be a String, but %v was given.',
|
|
2906
2933
|
modelName
|
|
2907
2934
|
);
|
|
2908
2935
|
}
|
|
2909
2936
|
if (!modelData || typeof modelData !== "object") {
|
|
2910
2937
|
throw new InvalidArgumentError(
|
|
2911
|
-
"
|
|
2938
|
+
'Parameter "modelData" must be an Object, but %v was given.',
|
|
2912
2939
|
modelData
|
|
2913
2940
|
);
|
|
2914
2941
|
}
|
|
@@ -2917,13 +2944,11 @@ var init_model_data_sanitizer = __esm({
|
|
|
2917
2944
|
).excludeObjectKeysByRelationNames(modelName, modelData);
|
|
2918
2945
|
}
|
|
2919
2946
|
};
|
|
2920
|
-
__name(_ModelDataSanitizer, "ModelDataSanitizer");
|
|
2921
|
-
ModelDataSanitizer = _ModelDataSanitizer;
|
|
2922
2947
|
}
|
|
2923
2948
|
});
|
|
2924
2949
|
|
|
2925
2950
|
// src/definition/model/model-definition-validator.js
|
|
2926
|
-
var import_js_service13,
|
|
2951
|
+
var import_js_service13, ModelDefinitionValidator;
|
|
2927
2952
|
var init_model_definition_validator = __esm({
|
|
2928
2953
|
"src/definition/model/model-definition-validator.js"() {
|
|
2929
2954
|
"use strict";
|
|
@@ -2931,7 +2956,10 @@ var init_model_definition_validator = __esm({
|
|
|
2931
2956
|
init_errors();
|
|
2932
2957
|
init_relations();
|
|
2933
2958
|
init_properties();
|
|
2934
|
-
|
|
2959
|
+
ModelDefinitionValidator = class extends import_js_service13.Service {
|
|
2960
|
+
static {
|
|
2961
|
+
__name(this, "ModelDefinitionValidator");
|
|
2962
|
+
}
|
|
2935
2963
|
/**
|
|
2936
2964
|
* Validate.
|
|
2937
2965
|
*
|
|
@@ -2940,33 +2968,33 @@ var init_model_definition_validator = __esm({
|
|
|
2940
2968
|
validate(modelDef) {
|
|
2941
2969
|
if (!modelDef || typeof modelDef !== "object" || Array.isArray(modelDef)) {
|
|
2942
2970
|
throw new InvalidArgumentError(
|
|
2943
|
-
"
|
|
2971
|
+
"Model definition must be an Object, but %v was given.",
|
|
2944
2972
|
modelDef
|
|
2945
2973
|
);
|
|
2946
2974
|
}
|
|
2947
2975
|
if (!modelDef.name || typeof modelDef.name !== "string") {
|
|
2948
2976
|
throw new InvalidArgumentError(
|
|
2949
|
-
'
|
|
2977
|
+
'Model definition requires the option "name" as a non-empty String, but %v was given.',
|
|
2950
2978
|
modelDef.name
|
|
2951
2979
|
);
|
|
2952
2980
|
}
|
|
2953
2981
|
if (modelDef.datasource && typeof modelDef.datasource !== "string") {
|
|
2954
2982
|
throw new InvalidArgumentError(
|
|
2955
|
-
'
|
|
2983
|
+
'Option "datasource" of the model %v must be a String, but %v was given.',
|
|
2956
2984
|
modelDef.name,
|
|
2957
2985
|
modelDef.datasource
|
|
2958
2986
|
);
|
|
2959
2987
|
}
|
|
2960
2988
|
if (modelDef.base && typeof modelDef.base !== "string") {
|
|
2961
2989
|
throw new InvalidArgumentError(
|
|
2962
|
-
'
|
|
2990
|
+
'Option "base" of the model %v must be a String, but %v was given.',
|
|
2963
2991
|
modelDef.name,
|
|
2964
2992
|
modelDef.base
|
|
2965
2993
|
);
|
|
2966
2994
|
}
|
|
2967
2995
|
if (modelDef.tableName && typeof modelDef.tableName !== "string") {
|
|
2968
2996
|
throw new InvalidArgumentError(
|
|
2969
|
-
'
|
|
2997
|
+
'Option "tableName" of the model %v must be a String, but %v was given.',
|
|
2970
2998
|
modelDef.name,
|
|
2971
2999
|
modelDef.tableName
|
|
2972
3000
|
);
|
|
@@ -2974,7 +3002,7 @@ var init_model_definition_validator = __esm({
|
|
|
2974
3002
|
if (modelDef.properties) {
|
|
2975
3003
|
if (typeof modelDef.properties !== "object" || Array.isArray(modelDef.properties)) {
|
|
2976
3004
|
throw new InvalidArgumentError(
|
|
2977
|
-
'
|
|
3005
|
+
'Option "properties" of the model %v must be an Object, but %v was given.',
|
|
2978
3006
|
modelDef.name,
|
|
2979
3007
|
modelDef.properties
|
|
2980
3008
|
);
|
|
@@ -2987,7 +3015,7 @@ var init_model_definition_validator = __esm({
|
|
|
2987
3015
|
if (modelDef.relations) {
|
|
2988
3016
|
if (typeof modelDef.relations !== "object" || Array.isArray(modelDef.relations)) {
|
|
2989
3017
|
throw new InvalidArgumentError(
|
|
2990
|
-
'
|
|
3018
|
+
'Option "relations" of the model %v must be an Object, but %v was given.',
|
|
2991
3019
|
modelDef.name,
|
|
2992
3020
|
modelDef.relations
|
|
2993
3021
|
);
|
|
@@ -2999,8 +3027,6 @@ var init_model_definition_validator = __esm({
|
|
|
2999
3027
|
}
|
|
3000
3028
|
}
|
|
3001
3029
|
};
|
|
3002
|
-
__name(_ModelDefinitionValidator, "ModelDefinitionValidator");
|
|
3003
|
-
ModelDefinitionValidator = _ModelDefinitionValidator;
|
|
3004
3030
|
}
|
|
3005
3031
|
});
|
|
3006
3032
|
|
|
@@ -3018,13 +3044,16 @@ var init_model = __esm({
|
|
|
3018
3044
|
});
|
|
3019
3045
|
|
|
3020
3046
|
// src/definition/datasource/datasource-definition-validator.js
|
|
3021
|
-
var import_js_service14,
|
|
3047
|
+
var import_js_service14, DatasourceDefinitionValidator;
|
|
3022
3048
|
var init_datasource_definition_validator = __esm({
|
|
3023
3049
|
"src/definition/datasource/datasource-definition-validator.js"() {
|
|
3024
3050
|
"use strict";
|
|
3025
3051
|
import_js_service14 = require("@e22m4u/js-service");
|
|
3026
3052
|
init_errors();
|
|
3027
|
-
|
|
3053
|
+
DatasourceDefinitionValidator = class extends import_js_service14.Service {
|
|
3054
|
+
static {
|
|
3055
|
+
__name(this, "DatasourceDefinitionValidator");
|
|
3056
|
+
}
|
|
3028
3057
|
/**
|
|
3029
3058
|
* Validate.
|
|
3030
3059
|
*
|
|
@@ -3033,27 +3062,25 @@ var init_datasource_definition_validator = __esm({
|
|
|
3033
3062
|
validate(datasourceDef) {
|
|
3034
3063
|
if (!datasourceDef || typeof datasourceDef !== "object") {
|
|
3035
3064
|
throw new InvalidArgumentError(
|
|
3036
|
-
"
|
|
3065
|
+
"Datasource definition must be an Object, but %v was given.",
|
|
3037
3066
|
datasourceDef
|
|
3038
3067
|
);
|
|
3039
3068
|
}
|
|
3040
3069
|
if (!datasourceDef.name || typeof datasourceDef.name !== "string") {
|
|
3041
3070
|
throw new InvalidArgumentError(
|
|
3042
|
-
'
|
|
3071
|
+
'Datasource definition requires the option "name" as a non-empty String, but %v was given.',
|
|
3043
3072
|
datasourceDef.name
|
|
3044
3073
|
);
|
|
3045
3074
|
}
|
|
3046
3075
|
if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string") {
|
|
3047
3076
|
throw new InvalidArgumentError(
|
|
3048
|
-
'
|
|
3077
|
+
'Datasource %v requires the option "adapter" as a non-empty String, but %v was given.',
|
|
3049
3078
|
datasourceDef.name,
|
|
3050
3079
|
datasourceDef.adapter
|
|
3051
3080
|
);
|
|
3052
3081
|
}
|
|
3053
3082
|
}
|
|
3054
3083
|
};
|
|
3055
|
-
__name(_DatasourceDefinitionValidator, "DatasourceDefinitionValidator");
|
|
3056
|
-
DatasourceDefinitionValidator = _DatasourceDefinitionValidator;
|
|
3057
3084
|
}
|
|
3058
3085
|
});
|
|
3059
3086
|
|
|
@@ -3076,7 +3103,7 @@ var init_definition = __esm({
|
|
|
3076
3103
|
});
|
|
3077
3104
|
|
|
3078
3105
|
// src/filter/fields-clause-tool.js
|
|
3079
|
-
var import_js_service15,
|
|
3106
|
+
var import_js_service15, FieldsClauseTool;
|
|
3080
3107
|
var init_fields_clause_tool = __esm({
|
|
3081
3108
|
"src/filter/fields-clause-tool.js"() {
|
|
3082
3109
|
"use strict";
|
|
@@ -3084,7 +3111,10 @@ var init_fields_clause_tool = __esm({
|
|
|
3084
3111
|
init_utils();
|
|
3085
3112
|
init_errors();
|
|
3086
3113
|
init_definition();
|
|
3087
|
-
|
|
3114
|
+
FieldsClauseTool = class extends import_js_service15.Service {
|
|
3115
|
+
static {
|
|
3116
|
+
__name(this, "FieldsClauseTool");
|
|
3117
|
+
}
|
|
3088
3118
|
/**
|
|
3089
3119
|
* Filter.
|
|
3090
3120
|
*
|
|
@@ -3094,45 +3124,64 @@ var init_fields_clause_tool = __esm({
|
|
|
3094
3124
|
* @returns {object|object[]}
|
|
3095
3125
|
*/
|
|
3096
3126
|
filter(input, modelName, clause) {
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3127
|
+
if (!input || typeof input !== "object") {
|
|
3128
|
+
throw new InvalidArgumentError(
|
|
3129
|
+
'Parameter "input" must be an Object or an Array of Object, but %v was given.',
|
|
3130
|
+
input
|
|
3131
|
+
);
|
|
3132
|
+
}
|
|
3133
|
+
const isArrayInput = Array.isArray(input);
|
|
3134
|
+
if (isArrayInput) {
|
|
3135
|
+
input.forEach((entity, index) => {
|
|
3136
|
+
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
3137
|
+
throw new InvalidArgumentError(
|
|
3138
|
+
'Element %d of the parameter "input" must be an Object, but %v was given.',
|
|
3139
|
+
index,
|
|
3140
|
+
entity
|
|
3141
|
+
);
|
|
3142
|
+
}
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3107
3145
|
if (!modelName || typeof modelName !== "string") {
|
|
3108
3146
|
throw new InvalidArgumentError(
|
|
3109
|
-
"
|
|
3147
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
3110
3148
|
modelName
|
|
3111
3149
|
);
|
|
3112
3150
|
}
|
|
3113
3151
|
if (clause == null) {
|
|
3114
3152
|
return input;
|
|
3115
3153
|
}
|
|
3116
|
-
const
|
|
3117
|
-
if (!
|
|
3118
|
-
|
|
3154
|
+
const isArrayClause = Array.isArray(clause);
|
|
3155
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
3156
|
+
throw new InvalidArgumentError(
|
|
3157
|
+
'Option "fields" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3158
|
+
clause
|
|
3159
|
+
);
|
|
3119
3160
|
}
|
|
3120
|
-
|
|
3121
|
-
if (!
|
|
3122
|
-
|
|
3123
|
-
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3124
|
-
field
|
|
3125
|
-
);
|
|
3161
|
+
if (isArrayClause) {
|
|
3162
|
+
if (!clause.length) {
|
|
3163
|
+
return input;
|
|
3126
3164
|
}
|
|
3127
|
-
|
|
3165
|
+
clause.forEach((field, index) => {
|
|
3166
|
+
if (!field || typeof field !== "string") {
|
|
3167
|
+
throw new InvalidArgumentError(
|
|
3168
|
+
'Element %d of the option "fields" must be a non-empty String, but %v was given.',
|
|
3169
|
+
index,
|
|
3170
|
+
field
|
|
3171
|
+
);
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
}
|
|
3175
|
+
const fields = isArrayClause ? clause.slice() : [clause];
|
|
3128
3176
|
const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
|
|
3129
3177
|
modelName
|
|
3130
3178
|
);
|
|
3131
3179
|
if (fields.indexOf(pkPropName) === -1) {
|
|
3132
3180
|
fields.push(pkPropName);
|
|
3133
3181
|
}
|
|
3182
|
+
let entities = isArrayInput ? input : [input];
|
|
3134
3183
|
entities = entities.map((entity) => selectObjectKeys(entity, fields));
|
|
3135
|
-
return
|
|
3184
|
+
return isArrayInput ? entities : entities[0];
|
|
3136
3185
|
}
|
|
3137
3186
|
/**
|
|
3138
3187
|
* Validate fields clause.
|
|
@@ -3143,18 +3192,24 @@ var init_fields_clause_tool = __esm({
|
|
|
3143
3192
|
if (clause == null) {
|
|
3144
3193
|
return;
|
|
3145
3194
|
}
|
|
3146
|
-
const
|
|
3147
|
-
if (!
|
|
3148
|
-
|
|
3195
|
+
const isArray = Array.isArray(clause);
|
|
3196
|
+
if (!clause || typeof clause !== "string" && !isArray) {
|
|
3197
|
+
throw new InvalidArgumentError(
|
|
3198
|
+
'Option "fields" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3199
|
+
clause
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
if (isArray && clause.length > 0) {
|
|
3203
|
+
clause.forEach((field, index) => {
|
|
3204
|
+
if (!field || typeof field !== "string") {
|
|
3205
|
+
throw new InvalidArgumentError(
|
|
3206
|
+
'Element %d of the option "fields" must be a non-empty String, but %v was given.',
|
|
3207
|
+
index,
|
|
3208
|
+
field
|
|
3209
|
+
);
|
|
3210
|
+
}
|
|
3211
|
+
});
|
|
3149
3212
|
}
|
|
3150
|
-
fields.forEach((field) => {
|
|
3151
|
-
if (!field || typeof field !== "string") {
|
|
3152
|
-
throw new InvalidArgumentError(
|
|
3153
|
-
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3154
|
-
field
|
|
3155
|
-
);
|
|
3156
|
-
}
|
|
3157
|
-
});
|
|
3158
3213
|
}
|
|
3159
3214
|
/**
|
|
3160
3215
|
* Normalize fields clause.
|
|
@@ -3166,28 +3221,35 @@ var init_fields_clause_tool = __esm({
|
|
|
3166
3221
|
if (clause == null) {
|
|
3167
3222
|
return;
|
|
3168
3223
|
}
|
|
3169
|
-
const
|
|
3170
|
-
if (!
|
|
3171
|
-
|
|
3224
|
+
const isArray = Array.isArray(clause);
|
|
3225
|
+
if (!clause || typeof clause !== "string" && !isArray) {
|
|
3226
|
+
throw new InvalidArgumentError(
|
|
3227
|
+
'Option "fields" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3228
|
+
clause
|
|
3229
|
+
);
|
|
3172
3230
|
}
|
|
3173
|
-
|
|
3174
|
-
if (!
|
|
3175
|
-
|
|
3176
|
-
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3177
|
-
field
|
|
3178
|
-
);
|
|
3231
|
+
if (isArray) {
|
|
3232
|
+
if (!clause.length) {
|
|
3233
|
+
return;
|
|
3179
3234
|
}
|
|
3180
|
-
|
|
3181
|
-
|
|
3235
|
+
clause.forEach((field, index) => {
|
|
3236
|
+
if (!field || typeof field !== "string") {
|
|
3237
|
+
throw new InvalidArgumentError(
|
|
3238
|
+
'Element %d of the option "fields" must be a non-empty String, but %v was given.',
|
|
3239
|
+
index,
|
|
3240
|
+
field
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
return isArray ? clause : [clause];
|
|
3182
3246
|
}
|
|
3183
3247
|
};
|
|
3184
|
-
__name(_FieldsClauseTool, "FieldsClauseTool");
|
|
3185
|
-
FieldsClauseTool = _FieldsClauseTool;
|
|
3186
3248
|
}
|
|
3187
3249
|
});
|
|
3188
3250
|
|
|
3189
3251
|
// src/adapter/decorator/inclusion-decorator.js
|
|
3190
|
-
var import_js_service16,
|
|
3252
|
+
var import_js_service16, InclusionDecorator;
|
|
3191
3253
|
var init_inclusion_decorator = __esm({
|
|
3192
3254
|
"src/adapter/decorator/inclusion-decorator.js"() {
|
|
3193
3255
|
"use strict";
|
|
@@ -3195,7 +3257,10 @@ var init_inclusion_decorator = __esm({
|
|
|
3195
3257
|
import_js_service16 = require("@e22m4u/js-service");
|
|
3196
3258
|
init_filter();
|
|
3197
3259
|
init_errors();
|
|
3198
|
-
|
|
3260
|
+
InclusionDecorator = class extends import_js_service16.Service {
|
|
3261
|
+
static {
|
|
3262
|
+
__name(this, "InclusionDecorator");
|
|
3263
|
+
}
|
|
3199
3264
|
/**
|
|
3200
3265
|
* Decorate.
|
|
3201
3266
|
*
|
|
@@ -3204,7 +3269,7 @@ var init_inclusion_decorator = __esm({
|
|
|
3204
3269
|
decorate(adapter) {
|
|
3205
3270
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3206
3271
|
throw new InvalidArgumentError(
|
|
3207
|
-
"
|
|
3272
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3208
3273
|
adapter
|
|
3209
3274
|
);
|
|
3210
3275
|
}
|
|
@@ -3277,13 +3342,11 @@ var init_inclusion_decorator = __esm({
|
|
|
3277
3342
|
};
|
|
3278
3343
|
}
|
|
3279
3344
|
};
|
|
3280
|
-
__name(_InclusionDecorator, "InclusionDecorator");
|
|
3281
|
-
InclusionDecorator = _InclusionDecorator;
|
|
3282
3345
|
}
|
|
3283
3346
|
});
|
|
3284
3347
|
|
|
3285
3348
|
// src/adapter/decorator/default-values-decorator.js
|
|
3286
|
-
var import_js_service17,
|
|
3349
|
+
var import_js_service17, DefaultValuesDecorator;
|
|
3287
3350
|
var init_default_values_decorator = __esm({
|
|
3288
3351
|
"src/adapter/decorator/default-values-decorator.js"() {
|
|
3289
3352
|
"use strict";
|
|
@@ -3291,7 +3354,10 @@ var init_default_values_decorator = __esm({
|
|
|
3291
3354
|
import_js_service17 = require("@e22m4u/js-service");
|
|
3292
3355
|
init_errors();
|
|
3293
3356
|
init_definition();
|
|
3294
|
-
|
|
3357
|
+
DefaultValuesDecorator = class extends import_js_service17.Service {
|
|
3358
|
+
static {
|
|
3359
|
+
__name(this, "DefaultValuesDecorator");
|
|
3360
|
+
}
|
|
3295
3361
|
/**
|
|
3296
3362
|
* Decorate.
|
|
3297
3363
|
*
|
|
@@ -3300,7 +3366,7 @@ var init_default_values_decorator = __esm({
|
|
|
3300
3366
|
decorate(adapter) {
|
|
3301
3367
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3302
3368
|
throw new InvalidArgumentError(
|
|
3303
|
-
"
|
|
3369
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3304
3370
|
adapter
|
|
3305
3371
|
);
|
|
3306
3372
|
}
|
|
@@ -3343,13 +3409,11 @@ var init_default_values_decorator = __esm({
|
|
|
3343
3409
|
};
|
|
3344
3410
|
}
|
|
3345
3411
|
};
|
|
3346
|
-
__name(_DefaultValuesDecorator, "DefaultValuesDecorator");
|
|
3347
|
-
DefaultValuesDecorator = _DefaultValuesDecorator;
|
|
3348
3412
|
}
|
|
3349
3413
|
});
|
|
3350
3414
|
|
|
3351
3415
|
// src/adapter/decorator/data-sanitizing-decorator.js
|
|
3352
|
-
var import_js_service18,
|
|
3416
|
+
var import_js_service18, DataSanitizingDecorator;
|
|
3353
3417
|
var init_data_sanitizing_decorator = __esm({
|
|
3354
3418
|
"src/adapter/decorator/data-sanitizing-decorator.js"() {
|
|
3355
3419
|
"use strict";
|
|
@@ -3357,7 +3421,10 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
3357
3421
|
import_js_service18 = require("@e22m4u/js-service");
|
|
3358
3422
|
init_errors();
|
|
3359
3423
|
init_definition();
|
|
3360
|
-
|
|
3424
|
+
DataSanitizingDecorator = class extends import_js_service18.Service {
|
|
3425
|
+
static {
|
|
3426
|
+
__name(this, "DataSanitizingDecorator");
|
|
3427
|
+
}
|
|
3361
3428
|
/**
|
|
3362
3429
|
* Decorate.
|
|
3363
3430
|
*
|
|
@@ -3366,7 +3433,7 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
3366
3433
|
decorate(adapter) {
|
|
3367
3434
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3368
3435
|
throw new InvalidArgumentError(
|
|
3369
|
-
"
|
|
3436
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3370
3437
|
adapter
|
|
3371
3438
|
);
|
|
3372
3439
|
}
|
|
@@ -3399,13 +3466,11 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
3399
3466
|
};
|
|
3400
3467
|
}
|
|
3401
3468
|
};
|
|
3402
|
-
__name(_DataSanitizingDecorator, "DataSanitizingDecorator");
|
|
3403
|
-
DataSanitizingDecorator = _DataSanitizingDecorator;
|
|
3404
3469
|
}
|
|
3405
3470
|
});
|
|
3406
3471
|
|
|
3407
3472
|
// src/adapter/decorator/fields-filtering-decorator.js
|
|
3408
|
-
var import_js_service19,
|
|
3473
|
+
var import_js_service19, FieldsFilteringDecorator;
|
|
3409
3474
|
var init_fields_filtering_decorator = __esm({
|
|
3410
3475
|
"src/adapter/decorator/fields-filtering-decorator.js"() {
|
|
3411
3476
|
"use strict";
|
|
@@ -3413,7 +3478,10 @@ var init_fields_filtering_decorator = __esm({
|
|
|
3413
3478
|
import_js_service19 = require("@e22m4u/js-service");
|
|
3414
3479
|
init_filter();
|
|
3415
3480
|
init_errors();
|
|
3416
|
-
|
|
3481
|
+
FieldsFilteringDecorator = class extends import_js_service19.Service {
|
|
3482
|
+
static {
|
|
3483
|
+
__name(this, "FieldsFilteringDecorator");
|
|
3484
|
+
}
|
|
3417
3485
|
/**
|
|
3418
3486
|
* Decorate.
|
|
3419
3487
|
*
|
|
@@ -3422,7 +3490,7 @@ var init_fields_filtering_decorator = __esm({
|
|
|
3422
3490
|
decorate(adapter) {
|
|
3423
3491
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3424
3492
|
throw new InvalidArgumentError(
|
|
3425
|
-
"
|
|
3493
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3426
3494
|
adapter
|
|
3427
3495
|
);
|
|
3428
3496
|
}
|
|
@@ -3489,13 +3557,11 @@ var init_fields_filtering_decorator = __esm({
|
|
|
3489
3557
|
};
|
|
3490
3558
|
}
|
|
3491
3559
|
};
|
|
3492
|
-
__name(_FieldsFilteringDecorator, "FieldsFilteringDecorator");
|
|
3493
|
-
FieldsFilteringDecorator = _FieldsFilteringDecorator;
|
|
3494
3560
|
}
|
|
3495
3561
|
});
|
|
3496
3562
|
|
|
3497
3563
|
// src/adapter/decorator/required-property-decorator.js
|
|
3498
|
-
var import_js_service20,
|
|
3564
|
+
var import_js_service20, RequiredPropertyDecorator;
|
|
3499
3565
|
var init_required_property_decorator = __esm({
|
|
3500
3566
|
"src/adapter/decorator/required-property-decorator.js"() {
|
|
3501
3567
|
"use strict";
|
|
@@ -3503,7 +3569,10 @@ var init_required_property_decorator = __esm({
|
|
|
3503
3569
|
import_js_service20 = require("@e22m4u/js-service");
|
|
3504
3570
|
init_errors();
|
|
3505
3571
|
init_definition();
|
|
3506
|
-
|
|
3572
|
+
RequiredPropertyDecorator = class extends import_js_service20.Service {
|
|
3573
|
+
static {
|
|
3574
|
+
__name(this, "RequiredPropertyDecorator");
|
|
3575
|
+
}
|
|
3507
3576
|
/**
|
|
3508
3577
|
* Decorate.
|
|
3509
3578
|
*
|
|
@@ -3512,7 +3581,7 @@ var init_required_property_decorator = __esm({
|
|
|
3512
3581
|
decorate(adapter) {
|
|
3513
3582
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3514
3583
|
throw new InvalidArgumentError(
|
|
3515
|
-
"
|
|
3584
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3516
3585
|
adapter
|
|
3517
3586
|
);
|
|
3518
3587
|
}
|
|
@@ -3544,13 +3613,11 @@ var init_required_property_decorator = __esm({
|
|
|
3544
3613
|
};
|
|
3545
3614
|
}
|
|
3546
3615
|
};
|
|
3547
|
-
__name(_RequiredPropertyDecorator, "RequiredPropertyDecorator");
|
|
3548
|
-
RequiredPropertyDecorator = _RequiredPropertyDecorator;
|
|
3549
3616
|
}
|
|
3550
3617
|
});
|
|
3551
3618
|
|
|
3552
3619
|
// src/adapter/decorator/property-uniqueness-decorator.js
|
|
3553
|
-
var import_js_service21,
|
|
3620
|
+
var import_js_service21, PropertyUniquenessDecorator;
|
|
3554
3621
|
var init_property_uniqueness_decorator = __esm({
|
|
3555
3622
|
"src/adapter/decorator/property-uniqueness-decorator.js"() {
|
|
3556
3623
|
"use strict";
|
|
@@ -3558,7 +3625,10 @@ var init_property_uniqueness_decorator = __esm({
|
|
|
3558
3625
|
import_js_service21 = require("@e22m4u/js-service");
|
|
3559
3626
|
init_errors();
|
|
3560
3627
|
init_definition();
|
|
3561
|
-
|
|
3628
|
+
PropertyUniquenessDecorator = class extends import_js_service21.Service {
|
|
3629
|
+
static {
|
|
3630
|
+
__name(this, "PropertyUniquenessDecorator");
|
|
3631
|
+
}
|
|
3562
3632
|
/**
|
|
3563
3633
|
* Decorate.
|
|
3564
3634
|
*
|
|
@@ -3567,7 +3637,7 @@ var init_property_uniqueness_decorator = __esm({
|
|
|
3567
3637
|
decorate(adapter) {
|
|
3568
3638
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3569
3639
|
throw new InvalidArgumentError(
|
|
3570
|
-
"
|
|
3640
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3571
3641
|
adapter
|
|
3572
3642
|
);
|
|
3573
3643
|
}
|
|
@@ -3621,8 +3691,6 @@ var init_property_uniqueness_decorator = __esm({
|
|
|
3621
3691
|
};
|
|
3622
3692
|
}
|
|
3623
3693
|
};
|
|
3624
|
-
__name(_PropertyUniquenessDecorator, "PropertyUniquenessDecorator");
|
|
3625
|
-
PropertyUniquenessDecorator = _PropertyUniquenessDecorator;
|
|
3626
3694
|
}
|
|
3627
3695
|
});
|
|
3628
3696
|
|
|
@@ -3640,7 +3708,7 @@ var init_decorator = __esm({
|
|
|
3640
3708
|
});
|
|
3641
3709
|
|
|
3642
3710
|
// src/adapter/adapter.js
|
|
3643
|
-
var import_js_service22, ADAPTER_CLASS_NAME,
|
|
3711
|
+
var import_js_service22, ADAPTER_CLASS_NAME, Adapter;
|
|
3644
3712
|
var init_adapter = __esm({
|
|
3645
3713
|
"src/adapter/adapter.js"() {
|
|
3646
3714
|
"use strict";
|
|
@@ -3648,7 +3716,16 @@ var init_adapter = __esm({
|
|
|
3648
3716
|
init_errors();
|
|
3649
3717
|
init_decorator();
|
|
3650
3718
|
ADAPTER_CLASS_NAME = "Adapter";
|
|
3651
|
-
|
|
3719
|
+
Adapter = class _Adapter extends import_js_service22.Service {
|
|
3720
|
+
static {
|
|
3721
|
+
__name(this, "Adapter");
|
|
3722
|
+
}
|
|
3723
|
+
/**
|
|
3724
|
+
* Kinds.
|
|
3725
|
+
*
|
|
3726
|
+
* @type {string[]}
|
|
3727
|
+
*/
|
|
3728
|
+
static kinds = [...import_js_service22.Service.kinds, ADAPTER_CLASS_NAME];
|
|
3652
3729
|
/**
|
|
3653
3730
|
* Settings.
|
|
3654
3731
|
*
|
|
@@ -3833,14 +3910,6 @@ var init_adapter = __esm({
|
|
|
3833
3910
|
);
|
|
3834
3911
|
}
|
|
3835
3912
|
};
|
|
3836
|
-
__name(_Adapter, "Adapter");
|
|
3837
|
-
/**
|
|
3838
|
-
* Kinds.
|
|
3839
|
-
*
|
|
3840
|
-
* @type {string[]}
|
|
3841
|
-
*/
|
|
3842
|
-
__publicField(_Adapter, "kinds", [...import_js_service22.Service.kinds, ADAPTER_CLASS_NAME]);
|
|
3843
|
-
Adapter = _Adapter;
|
|
3844
3913
|
}
|
|
3845
3914
|
});
|
|
3846
3915
|
|
|
@@ -3849,7 +3918,7 @@ var memory_adapter_exports = {};
|
|
|
3849
3918
|
__export(memory_adapter_exports, {
|
|
3850
3919
|
MemoryAdapter: () => MemoryAdapter
|
|
3851
3920
|
});
|
|
3852
|
-
var
|
|
3921
|
+
var MemoryAdapter;
|
|
3853
3922
|
var init_memory_adapter = __esm({
|
|
3854
3923
|
"src/adapter/builtin/memory-adapter.js"() {
|
|
3855
3924
|
"use strict";
|
|
@@ -3858,7 +3927,10 @@ var init_memory_adapter = __esm({
|
|
|
3858
3927
|
init_utils();
|
|
3859
3928
|
init_definition();
|
|
3860
3929
|
init_filter();
|
|
3861
|
-
|
|
3930
|
+
MemoryAdapter = class extends Adapter {
|
|
3931
|
+
static {
|
|
3932
|
+
__name(this, "MemoryAdapter");
|
|
3933
|
+
}
|
|
3862
3934
|
/**
|
|
3863
3935
|
* Tables.
|
|
3864
3936
|
*
|
|
@@ -3895,12 +3967,11 @@ var init_memory_adapter = __esm({
|
|
|
3895
3967
|
* @returns {number}
|
|
3896
3968
|
*/
|
|
3897
3969
|
_genNextIdValue(modelName, propName) {
|
|
3898
|
-
var _a;
|
|
3899
3970
|
const modelUtils = this.getService(ModelDefinitionUtils);
|
|
3900
3971
|
const propType = modelUtils.getDataTypeByPropertyName(modelName, propName);
|
|
3901
3972
|
if (propType !== DataType.ANY && propType !== DataType.NUMBER) {
|
|
3902
3973
|
throw new InvalidArgumentError(
|
|
3903
|
-
"
|
|
3974
|
+
"Memory adapter is able to generate only Number identifiers, but the primary key %v of the model %v is defined as %s. Do provide your own value for the %v property, or change the type in the primary key definition to a Number that will be generated automatically.",
|
|
3904
3975
|
propName,
|
|
3905
3976
|
modelName,
|
|
3906
3977
|
capitalize(propType),
|
|
@@ -3909,7 +3980,7 @@ var init_memory_adapter = __esm({
|
|
|
3909
3980
|
}
|
|
3910
3981
|
const tableName = modelUtils.getTableNameByModelName(modelName);
|
|
3911
3982
|
const table = this._getTableOrCreate(modelName);
|
|
3912
|
-
let nextId =
|
|
3983
|
+
let nextId = this._lastIds.get(tableName) ?? 0;
|
|
3913
3984
|
do {
|
|
3914
3985
|
nextId++;
|
|
3915
3986
|
} while (table.has(nextId));
|
|
@@ -3927,9 +3998,8 @@ var init_memory_adapter = __esm({
|
|
|
3927
3998
|
* @param {number} idValue
|
|
3928
3999
|
*/
|
|
3929
4000
|
_updateLastIdValueIfNeeded(modelName, idValue) {
|
|
3930
|
-
var _a;
|
|
3931
4001
|
const tableName = this.getService(ModelDefinitionUtils).getTableNameByModelName(modelName);
|
|
3932
|
-
const currentLastId =
|
|
4002
|
+
const currentLastId = this._lastIds.get(tableName) ?? 0;
|
|
3933
4003
|
if (idValue > currentLastId) {
|
|
3934
4004
|
this._lastIds.set(tableName, idValue);
|
|
3935
4005
|
}
|
|
@@ -3956,7 +4026,7 @@ var init_memory_adapter = __esm({
|
|
|
3956
4026
|
const table = this._getTableOrCreate(modelName);
|
|
3957
4027
|
if (table.has(idValue)) {
|
|
3958
4028
|
throw new InvalidArgumentError(
|
|
3959
|
-
"
|
|
4029
|
+
"Value %v of the primary key %v already exists in the model %v.",
|
|
3960
4030
|
idValue,
|
|
3961
4031
|
pkPropName,
|
|
3962
4032
|
modelName
|
|
@@ -3990,7 +4060,7 @@ var init_memory_adapter = __esm({
|
|
|
3990
4060
|
);
|
|
3991
4061
|
if (!isExists) {
|
|
3992
4062
|
throw new InvalidArgumentError(
|
|
3993
|
-
"
|
|
4063
|
+
"Value %v of the primary key %v does not exist in the model %v.",
|
|
3994
4064
|
id,
|
|
3995
4065
|
pkPropName,
|
|
3996
4066
|
modelName
|
|
@@ -4093,7 +4163,7 @@ var init_memory_adapter = __esm({
|
|
|
4093
4163
|
);
|
|
4094
4164
|
if (existingTableData == null) {
|
|
4095
4165
|
throw new InvalidArgumentError(
|
|
4096
|
-
"
|
|
4166
|
+
"Value %v of the primary key %v does not exist in the model %v.",
|
|
4097
4167
|
id,
|
|
4098
4168
|
pkPropName,
|
|
4099
4169
|
modelName
|
|
@@ -4166,7 +4236,7 @@ var init_memory_adapter = __esm({
|
|
|
4166
4236
|
);
|
|
4167
4237
|
if (!tableData) {
|
|
4168
4238
|
throw new InvalidArgumentError(
|
|
4169
|
-
"
|
|
4239
|
+
"Value %v of the primary key %v does not exist in the model %v.",
|
|
4170
4240
|
id,
|
|
4171
4241
|
pkPropName,
|
|
4172
4242
|
modelName
|
|
@@ -4254,8 +4324,6 @@ var init_memory_adapter = __esm({
|
|
|
4254
4324
|
return modelItems.length;
|
|
4255
4325
|
}
|
|
4256
4326
|
};
|
|
4257
|
-
__name(_MemoryAdapter, "MemoryAdapter");
|
|
4258
|
-
MemoryAdapter = _MemoryAdapter;
|
|
4259
4327
|
}
|
|
4260
4328
|
});
|
|
4261
4329
|
|
|
@@ -4283,7 +4351,7 @@ function findAdapterCtorInModule(module2) {
|
|
|
4283
4351
|
}
|
|
4284
4352
|
return adapterCtor;
|
|
4285
4353
|
}
|
|
4286
|
-
var import_js_service23,
|
|
4354
|
+
var import_js_service23, AdapterLoader;
|
|
4287
4355
|
var init_adapter_loader = __esm({
|
|
4288
4356
|
"src/adapter/adapter-loader.js"() {
|
|
4289
4357
|
"use strict";
|
|
@@ -4291,7 +4359,10 @@ var init_adapter_loader = __esm({
|
|
|
4291
4359
|
init_errors();
|
|
4292
4360
|
init_adapter();
|
|
4293
4361
|
init_();
|
|
4294
|
-
|
|
4362
|
+
AdapterLoader = class extends import_js_service23.Service {
|
|
4363
|
+
static {
|
|
4364
|
+
__name(this, "AdapterLoader");
|
|
4365
|
+
}
|
|
4295
4366
|
/**
|
|
4296
4367
|
* Load by name.
|
|
4297
4368
|
*
|
|
@@ -4302,7 +4373,7 @@ var init_adapter_loader = __esm({
|
|
|
4302
4373
|
async loadByName(adapterName, settings = void 0) {
|
|
4303
4374
|
if (!adapterName || typeof adapterName !== "string") {
|
|
4304
4375
|
throw new InvalidArgumentError(
|
|
4305
|
-
"
|
|
4376
|
+
"Adapter name must be a non-empty String, but %v was given.",
|
|
4306
4377
|
adapterName
|
|
4307
4378
|
);
|
|
4308
4379
|
}
|
|
@@ -4314,28 +4385,23 @@ var init_adapter_loader = __esm({
|
|
|
4314
4385
|
}
|
|
4315
4386
|
if (!adapterCtor) {
|
|
4316
4387
|
try {
|
|
4317
|
-
const module2 = await
|
|
4388
|
+
const module2 = await import(`@e22m4u/js-repository-${adapterName}-adapter`);
|
|
4318
4389
|
adapterCtor = findAdapterCtorInModule(module2);
|
|
4319
4390
|
} catch {
|
|
4320
4391
|
}
|
|
4321
4392
|
}
|
|
4322
4393
|
if (!adapterCtor) {
|
|
4323
|
-
throw new InvalidArgumentError(
|
|
4324
|
-
"The adapter %v is not found.",
|
|
4325
|
-
adapterName
|
|
4326
|
-
);
|
|
4394
|
+
throw new InvalidArgumentError("Adapter %v is not found.", adapterName);
|
|
4327
4395
|
}
|
|
4328
4396
|
return new adapterCtor(this.container, settings);
|
|
4329
4397
|
}
|
|
4330
4398
|
};
|
|
4331
|
-
__name(_AdapterLoader, "AdapterLoader");
|
|
4332
|
-
AdapterLoader = _AdapterLoader;
|
|
4333
4399
|
__name(findAdapterCtorInModule, "findAdapterCtorInModule");
|
|
4334
4400
|
}
|
|
4335
4401
|
});
|
|
4336
4402
|
|
|
4337
4403
|
// src/adapter/adapter-registry.js
|
|
4338
|
-
var import_js_service24,
|
|
4404
|
+
var import_js_service24, AdapterRegistry;
|
|
4339
4405
|
var init_adapter_registry = __esm({
|
|
4340
4406
|
"src/adapter/adapter-registry.js"() {
|
|
4341
4407
|
"use strict";
|
|
@@ -4343,7 +4409,10 @@ var init_adapter_registry = __esm({
|
|
|
4343
4409
|
import_js_service24 = require("@e22m4u/js-service");
|
|
4344
4410
|
init_adapter_loader();
|
|
4345
4411
|
init_definition();
|
|
4346
|
-
|
|
4412
|
+
AdapterRegistry = class extends import_js_service24.Service {
|
|
4413
|
+
static {
|
|
4414
|
+
__name(this, "AdapterRegistry");
|
|
4415
|
+
}
|
|
4347
4416
|
/**
|
|
4348
4417
|
* Adapters.
|
|
4349
4418
|
*
|
|
@@ -4371,8 +4440,6 @@ var init_adapter_registry = __esm({
|
|
|
4371
4440
|
return adapter;
|
|
4372
4441
|
}
|
|
4373
4442
|
};
|
|
4374
|
-
__name(_AdapterRegistry, "AdapterRegistry");
|
|
4375
|
-
AdapterRegistry = _AdapterRegistry;
|
|
4376
4443
|
}
|
|
4377
4444
|
});
|
|
4378
4445
|
|
|
@@ -4387,7 +4454,7 @@ var init_adapter2 = __esm({
|
|
|
4387
4454
|
});
|
|
4388
4455
|
|
|
4389
4456
|
// src/repository/repository.js
|
|
4390
|
-
var import_js_service25,
|
|
4457
|
+
var import_js_service25, Repository;
|
|
4391
4458
|
var init_repository = __esm({
|
|
4392
4459
|
"src/repository/repository.js"() {
|
|
4393
4460
|
"use strict";
|
|
@@ -4395,7 +4462,10 @@ var init_repository = __esm({
|
|
|
4395
4462
|
init_errors();
|
|
4396
4463
|
init_definition();
|
|
4397
4464
|
init_adapter2();
|
|
4398
|
-
|
|
4465
|
+
Repository = class extends import_js_service25.Service {
|
|
4466
|
+
static {
|
|
4467
|
+
__name(this, "Repository");
|
|
4468
|
+
}
|
|
4399
4469
|
/**
|
|
4400
4470
|
* Model name.
|
|
4401
4471
|
*
|
|
@@ -4438,7 +4508,7 @@ var init_repository = __esm({
|
|
|
4438
4508
|
const datasourceName = modelDef.datasource;
|
|
4439
4509
|
if (!datasourceName) {
|
|
4440
4510
|
throw new InvalidArgumentError(
|
|
4441
|
-
"
|
|
4511
|
+
"Model %v does not have a specified datasource.",
|
|
4442
4512
|
modelName
|
|
4443
4513
|
);
|
|
4444
4514
|
}
|
|
@@ -4527,7 +4597,7 @@ var init_repository = __esm({
|
|
|
4527
4597
|
*/
|
|
4528
4598
|
async findOne(filter = void 0) {
|
|
4529
4599
|
const adapter = await this.getAdapter();
|
|
4530
|
-
filter = filter
|
|
4600
|
+
filter = filter ?? {};
|
|
4531
4601
|
filter.limit = 1;
|
|
4532
4602
|
const result = await adapter.find(this.modelName, filter);
|
|
4533
4603
|
return result.length ? result[0] : void 0;
|
|
@@ -4584,13 +4654,11 @@ var init_repository = __esm({
|
|
|
4584
4654
|
return adapter.count(this.modelName, where);
|
|
4585
4655
|
}
|
|
4586
4656
|
};
|
|
4587
|
-
__name(_Repository, "Repository");
|
|
4588
|
-
Repository = _Repository;
|
|
4589
4657
|
}
|
|
4590
4658
|
});
|
|
4591
4659
|
|
|
4592
4660
|
// src/repository/repository-registry.js
|
|
4593
|
-
var import_js_service26,
|
|
4661
|
+
var import_js_service26, RepositoryRegistry;
|
|
4594
4662
|
var init_repository_registry = __esm({
|
|
4595
4663
|
"src/repository/repository-registry.js"() {
|
|
4596
4664
|
"use strict";
|
|
@@ -4598,7 +4666,10 @@ var init_repository_registry = __esm({
|
|
|
4598
4666
|
init_repository();
|
|
4599
4667
|
init_utils();
|
|
4600
4668
|
init_errors();
|
|
4601
|
-
|
|
4669
|
+
RepositoryRegistry = class extends import_js_service26.Service {
|
|
4670
|
+
static {
|
|
4671
|
+
__name(this, "RepositoryRegistry");
|
|
4672
|
+
}
|
|
4602
4673
|
/**
|
|
4603
4674
|
* Repositories.
|
|
4604
4675
|
*
|
|
@@ -4620,7 +4691,7 @@ var init_repository_registry = __esm({
|
|
|
4620
4691
|
setRepositoryCtor(ctor) {
|
|
4621
4692
|
if (!ctor || typeof ctor !== "function" || !(ctor.prototype instanceof Repository)) {
|
|
4622
4693
|
throw new InvalidArgumentError(
|
|
4623
|
-
"
|
|
4694
|
+
'Parameter "ctor" must inherit from Repository class, but %v was given.',
|
|
4624
4695
|
ctor
|
|
4625
4696
|
);
|
|
4626
4697
|
}
|
|
@@ -4643,8 +4714,6 @@ var init_repository_registry = __esm({
|
|
|
4643
4714
|
return repository;
|
|
4644
4715
|
}
|
|
4645
4716
|
};
|
|
4646
|
-
__name(_RepositoryRegistry, "RepositoryRegistry");
|
|
4647
|
-
RepositoryRegistry = _RepositoryRegistry;
|
|
4648
4717
|
}
|
|
4649
4718
|
});
|
|
4650
4719
|
|
|
@@ -4658,7 +4727,7 @@ var init_repository2 = __esm({
|
|
|
4658
4727
|
});
|
|
4659
4728
|
|
|
4660
4729
|
// src/relations/has-one-resolver.js
|
|
4661
|
-
var import_js_service27,
|
|
4730
|
+
var import_js_service27, HasOneResolver;
|
|
4662
4731
|
var init_has_one_resolver = __esm({
|
|
4663
4732
|
"src/relations/has-one-resolver.js"() {
|
|
4664
4733
|
"use strict";
|
|
@@ -4667,7 +4736,10 @@ var init_has_one_resolver = __esm({
|
|
|
4667
4736
|
init_errors();
|
|
4668
4737
|
init_repository2();
|
|
4669
4738
|
init_definition();
|
|
4670
|
-
|
|
4739
|
+
HasOneResolver = class extends import_js_service27.Service {
|
|
4740
|
+
static {
|
|
4741
|
+
__name(this, "HasOneResolver");
|
|
4742
|
+
}
|
|
4671
4743
|
/**
|
|
4672
4744
|
* Include to.
|
|
4673
4745
|
*
|
|
@@ -4682,37 +4754,37 @@ var init_has_one_resolver = __esm({
|
|
|
4682
4754
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
|
|
4683
4755
|
if (!entities || !Array.isArray(entities)) {
|
|
4684
4756
|
throw new InvalidArgumentError(
|
|
4685
|
-
'
|
|
4757
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4686
4758
|
entities
|
|
4687
4759
|
);
|
|
4688
4760
|
}
|
|
4689
4761
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4690
4762
|
throw new InvalidArgumentError(
|
|
4691
|
-
'
|
|
4763
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4692
4764
|
sourceName
|
|
4693
4765
|
);
|
|
4694
4766
|
}
|
|
4695
4767
|
if (!targetName || typeof targetName !== "string") {
|
|
4696
4768
|
throw new InvalidArgumentError(
|
|
4697
|
-
'
|
|
4769
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4698
4770
|
targetName
|
|
4699
4771
|
);
|
|
4700
4772
|
}
|
|
4701
4773
|
if (!relationName || typeof relationName !== "string") {
|
|
4702
4774
|
throw new InvalidArgumentError(
|
|
4703
|
-
'
|
|
4775
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4704
4776
|
relationName
|
|
4705
4777
|
);
|
|
4706
4778
|
}
|
|
4707
4779
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
4708
4780
|
throw new InvalidArgumentError(
|
|
4709
|
-
'
|
|
4781
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
4710
4782
|
foreignKey
|
|
4711
4783
|
);
|
|
4712
4784
|
}
|
|
4713
4785
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4714
4786
|
throw new InvalidArgumentError(
|
|
4715
|
-
'
|
|
4787
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
4716
4788
|
scope
|
|
4717
4789
|
);
|
|
4718
4790
|
}
|
|
@@ -4723,7 +4795,7 @@ var init_has_one_resolver = __esm({
|
|
|
4723
4795
|
entities.forEach((entity) => {
|
|
4724
4796
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
4725
4797
|
throw new InvalidArgumentError(
|
|
4726
|
-
'
|
|
4798
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4727
4799
|
entity
|
|
4728
4800
|
);
|
|
4729
4801
|
}
|
|
@@ -4772,43 +4844,43 @@ var init_has_one_resolver = __esm({
|
|
|
4772
4844
|
async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
|
|
4773
4845
|
if (!entities || !Array.isArray(entities)) {
|
|
4774
4846
|
throw new InvalidArgumentError(
|
|
4775
|
-
'
|
|
4847
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4776
4848
|
entities
|
|
4777
4849
|
);
|
|
4778
4850
|
}
|
|
4779
4851
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4780
4852
|
throw new InvalidArgumentError(
|
|
4781
|
-
'
|
|
4853
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4782
4854
|
sourceName
|
|
4783
4855
|
);
|
|
4784
4856
|
}
|
|
4785
4857
|
if (!targetName || typeof targetName !== "string") {
|
|
4786
4858
|
throw new InvalidArgumentError(
|
|
4787
|
-
'
|
|
4859
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4788
4860
|
targetName
|
|
4789
4861
|
);
|
|
4790
4862
|
}
|
|
4791
4863
|
if (!relationName || typeof relationName !== "string") {
|
|
4792
4864
|
throw new InvalidArgumentError(
|
|
4793
|
-
'
|
|
4865
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4794
4866
|
relationName
|
|
4795
4867
|
);
|
|
4796
4868
|
}
|
|
4797
4869
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
4798
4870
|
throw new InvalidArgumentError(
|
|
4799
|
-
'
|
|
4871
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
4800
4872
|
foreignKey
|
|
4801
4873
|
);
|
|
4802
4874
|
}
|
|
4803
4875
|
if (!discriminator || typeof discriminator !== "string") {
|
|
4804
4876
|
throw new InvalidArgumentError(
|
|
4805
|
-
'
|
|
4877
|
+
'Parameter "discriminator" must be a non-empty String, but %v was given.',
|
|
4806
4878
|
discriminator
|
|
4807
4879
|
);
|
|
4808
4880
|
}
|
|
4809
4881
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4810
4882
|
throw new InvalidArgumentError(
|
|
4811
|
-
'
|
|
4883
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
4812
4884
|
scope
|
|
4813
4885
|
);
|
|
4814
4886
|
}
|
|
@@ -4819,7 +4891,7 @@ var init_has_one_resolver = __esm({
|
|
|
4819
4891
|
entities.forEach((entity) => {
|
|
4820
4892
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
4821
4893
|
throw new InvalidArgumentError(
|
|
4822
|
-
'
|
|
4894
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4823
4895
|
entity
|
|
4824
4896
|
);
|
|
4825
4897
|
}
|
|
@@ -4870,37 +4942,37 @@ var init_has_one_resolver = __esm({
|
|
|
4870
4942
|
async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
|
|
4871
4943
|
if (!entities || !Array.isArray(entities)) {
|
|
4872
4944
|
throw new InvalidArgumentError(
|
|
4873
|
-
'
|
|
4945
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4874
4946
|
entities
|
|
4875
4947
|
);
|
|
4876
4948
|
}
|
|
4877
4949
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4878
4950
|
throw new InvalidArgumentError(
|
|
4879
|
-
'
|
|
4951
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4880
4952
|
sourceName
|
|
4881
4953
|
);
|
|
4882
4954
|
}
|
|
4883
4955
|
if (!targetName || typeof targetName !== "string") {
|
|
4884
4956
|
throw new InvalidArgumentError(
|
|
4885
|
-
'
|
|
4957
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4886
4958
|
targetName
|
|
4887
4959
|
);
|
|
4888
4960
|
}
|
|
4889
4961
|
if (!relationName || typeof relationName !== "string") {
|
|
4890
4962
|
throw new InvalidArgumentError(
|
|
4891
|
-
'
|
|
4963
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4892
4964
|
relationName
|
|
4893
4965
|
);
|
|
4894
4966
|
}
|
|
4895
4967
|
if (!targetRelationName || typeof targetRelationName !== "string") {
|
|
4896
4968
|
throw new InvalidArgumentError(
|
|
4897
|
-
'
|
|
4969
|
+
'Parameter "targetRelationName" must be a non-empty String, but %v was given.',
|
|
4898
4970
|
targetRelationName
|
|
4899
4971
|
);
|
|
4900
4972
|
}
|
|
4901
4973
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4902
4974
|
throw new InvalidArgumentError(
|
|
4903
|
-
'
|
|
4975
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
4904
4976
|
scope
|
|
4905
4977
|
);
|
|
4906
4978
|
}
|
|
@@ -4909,7 +4981,7 @@ var init_has_one_resolver = __esm({
|
|
|
4909
4981
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
4910
4982
|
if (targetRelationDef.type !== RelationType.BELONGS_TO) {
|
|
4911
4983
|
throw new InvalidArgumentError(
|
|
4912
|
-
'
|
|
4984
|
+
'Relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic "belongsTo", but %v type was given.',
|
|
4913
4985
|
relationName,
|
|
4914
4986
|
sourceName,
|
|
4915
4987
|
targetRelationName,
|
|
@@ -4918,7 +4990,7 @@ var init_has_one_resolver = __esm({
|
|
|
4918
4990
|
}
|
|
4919
4991
|
if (!targetRelationDef.polymorphic) {
|
|
4920
4992
|
throw new InvalidArgumentError(
|
|
4921
|
-
'
|
|
4993
|
+
'Relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic too.',
|
|
4922
4994
|
relationName,
|
|
4923
4995
|
sourceName,
|
|
4924
4996
|
targetRelationName
|
|
@@ -4937,13 +5009,11 @@ var init_has_one_resolver = __esm({
|
|
|
4937
5009
|
);
|
|
4938
5010
|
}
|
|
4939
5011
|
};
|
|
4940
|
-
__name(_HasOneResolver, "HasOneResolver");
|
|
4941
|
-
HasOneResolver = _HasOneResolver;
|
|
4942
5012
|
}
|
|
4943
5013
|
});
|
|
4944
5014
|
|
|
4945
5015
|
// src/relations/has-many-resolver.js
|
|
4946
|
-
var import_js_service28,
|
|
5016
|
+
var import_js_service28, HasManyResolver;
|
|
4947
5017
|
var init_has_many_resolver = __esm({
|
|
4948
5018
|
"src/relations/has-many-resolver.js"() {
|
|
4949
5019
|
"use strict";
|
|
@@ -4952,7 +5022,10 @@ var init_has_many_resolver = __esm({
|
|
|
4952
5022
|
init_errors();
|
|
4953
5023
|
init_repository2();
|
|
4954
5024
|
init_definition();
|
|
4955
|
-
|
|
5025
|
+
HasManyResolver = class extends import_js_service28.Service {
|
|
5026
|
+
static {
|
|
5027
|
+
__name(this, "HasManyResolver");
|
|
5028
|
+
}
|
|
4956
5029
|
/**
|
|
4957
5030
|
* Include to.
|
|
4958
5031
|
*
|
|
@@ -4967,37 +5040,37 @@ var init_has_many_resolver = __esm({
|
|
|
4967
5040
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
|
|
4968
5041
|
if (!entities || !Array.isArray(entities)) {
|
|
4969
5042
|
throw new InvalidArgumentError(
|
|
4970
|
-
'
|
|
5043
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4971
5044
|
entities
|
|
4972
5045
|
);
|
|
4973
5046
|
}
|
|
4974
5047
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4975
5048
|
throw new InvalidArgumentError(
|
|
4976
|
-
'
|
|
5049
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4977
5050
|
sourceName
|
|
4978
5051
|
);
|
|
4979
5052
|
}
|
|
4980
5053
|
if (!targetName || typeof targetName !== "string") {
|
|
4981
5054
|
throw new InvalidArgumentError(
|
|
4982
|
-
'
|
|
5055
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4983
5056
|
targetName
|
|
4984
5057
|
);
|
|
4985
5058
|
}
|
|
4986
5059
|
if (!relationName || typeof relationName !== "string") {
|
|
4987
5060
|
throw new InvalidArgumentError(
|
|
4988
|
-
'
|
|
5061
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4989
5062
|
relationName
|
|
4990
5063
|
);
|
|
4991
5064
|
}
|
|
4992
5065
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
4993
5066
|
throw new InvalidArgumentError(
|
|
4994
|
-
'
|
|
5067
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
4995
5068
|
foreignKey
|
|
4996
5069
|
);
|
|
4997
5070
|
}
|
|
4998
5071
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4999
5072
|
throw new InvalidArgumentError(
|
|
5000
|
-
'
|
|
5073
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5001
5074
|
scope
|
|
5002
5075
|
);
|
|
5003
5076
|
}
|
|
@@ -5008,7 +5081,7 @@ var init_has_many_resolver = __esm({
|
|
|
5008
5081
|
entities.forEach((entity) => {
|
|
5009
5082
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5010
5083
|
throw new InvalidArgumentError(
|
|
5011
|
-
'
|
|
5084
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5012
5085
|
entity
|
|
5013
5086
|
);
|
|
5014
5087
|
}
|
|
@@ -5029,9 +5102,8 @@ var init_has_many_resolver = __esm({
|
|
|
5029
5102
|
};
|
|
5030
5103
|
promises.push(
|
|
5031
5104
|
targetRepository.find(filter).then((result) => {
|
|
5032
|
-
var _a;
|
|
5033
5105
|
if (result.length) {
|
|
5034
|
-
let targets =
|
|
5106
|
+
let targets = targetsBySourceId.get(sourceId) ?? [];
|
|
5035
5107
|
targets = [...targets, ...result];
|
|
5036
5108
|
targetsBySourceId.set(sourceId, targets);
|
|
5037
5109
|
}
|
|
@@ -5040,9 +5112,8 @@ var init_has_many_resolver = __esm({
|
|
|
5040
5112
|
});
|
|
5041
5113
|
await Promise.all(promises);
|
|
5042
5114
|
entities.forEach((entity) => {
|
|
5043
|
-
var _a;
|
|
5044
5115
|
const sourceId = entity[sourcePkPropName];
|
|
5045
|
-
entity[relationName] =
|
|
5116
|
+
entity[relationName] = targetsBySourceId.get(sourceId) ?? [];
|
|
5046
5117
|
});
|
|
5047
5118
|
}
|
|
5048
5119
|
/**
|
|
@@ -5060,43 +5131,43 @@ var init_has_many_resolver = __esm({
|
|
|
5060
5131
|
async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
|
|
5061
5132
|
if (!entities || !Array.isArray(entities)) {
|
|
5062
5133
|
throw new InvalidArgumentError(
|
|
5063
|
-
'
|
|
5134
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5064
5135
|
entities
|
|
5065
5136
|
);
|
|
5066
5137
|
}
|
|
5067
5138
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5068
5139
|
throw new InvalidArgumentError(
|
|
5069
|
-
'
|
|
5140
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5070
5141
|
sourceName
|
|
5071
5142
|
);
|
|
5072
5143
|
}
|
|
5073
5144
|
if (!targetName || typeof targetName !== "string") {
|
|
5074
5145
|
throw new InvalidArgumentError(
|
|
5075
|
-
'
|
|
5146
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5076
5147
|
targetName
|
|
5077
5148
|
);
|
|
5078
5149
|
}
|
|
5079
5150
|
if (!relationName || typeof relationName !== "string") {
|
|
5080
5151
|
throw new InvalidArgumentError(
|
|
5081
|
-
'
|
|
5152
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5082
5153
|
relationName
|
|
5083
5154
|
);
|
|
5084
5155
|
}
|
|
5085
5156
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
5086
5157
|
throw new InvalidArgumentError(
|
|
5087
|
-
'
|
|
5158
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
5088
5159
|
foreignKey
|
|
5089
5160
|
);
|
|
5090
5161
|
}
|
|
5091
5162
|
if (!discriminator || typeof discriminator !== "string") {
|
|
5092
5163
|
throw new InvalidArgumentError(
|
|
5093
|
-
'
|
|
5164
|
+
'Parameter "discriminator" must be a non-empty String, but %v was given.',
|
|
5094
5165
|
discriminator
|
|
5095
5166
|
);
|
|
5096
5167
|
}
|
|
5097
5168
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5098
5169
|
throw new InvalidArgumentError(
|
|
5099
|
-
'
|
|
5170
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5100
5171
|
scope
|
|
5101
5172
|
);
|
|
5102
5173
|
}
|
|
@@ -5107,7 +5178,7 @@ var init_has_many_resolver = __esm({
|
|
|
5107
5178
|
entities.forEach((entity) => {
|
|
5108
5179
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5109
5180
|
throw new InvalidArgumentError(
|
|
5110
|
-
'
|
|
5181
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5111
5182
|
entity
|
|
5112
5183
|
);
|
|
5113
5184
|
}
|
|
@@ -5131,9 +5202,8 @@ var init_has_many_resolver = __esm({
|
|
|
5131
5202
|
};
|
|
5132
5203
|
promises.push(
|
|
5133
5204
|
targetRepository.find(filter).then((result) => {
|
|
5134
|
-
var _a;
|
|
5135
5205
|
if (result.length) {
|
|
5136
|
-
let targets =
|
|
5206
|
+
let targets = targetsBySourceId.get(sourceId) ?? [];
|
|
5137
5207
|
targets = [...targets, ...result];
|
|
5138
5208
|
targetsBySourceId.set(sourceId, targets);
|
|
5139
5209
|
}
|
|
@@ -5142,9 +5212,8 @@ var init_has_many_resolver = __esm({
|
|
|
5142
5212
|
});
|
|
5143
5213
|
await Promise.all(promises);
|
|
5144
5214
|
entities.forEach((entity) => {
|
|
5145
|
-
var _a;
|
|
5146
5215
|
const sourceId = entity[sourcePkPropName];
|
|
5147
|
-
entity[relationName] =
|
|
5216
|
+
entity[relationName] = targetsBySourceId.get(sourceId) ?? [];
|
|
5148
5217
|
});
|
|
5149
5218
|
}
|
|
5150
5219
|
/**
|
|
@@ -5161,37 +5230,37 @@ var init_has_many_resolver = __esm({
|
|
|
5161
5230
|
async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
|
|
5162
5231
|
if (!entities || !Array.isArray(entities)) {
|
|
5163
5232
|
throw new InvalidArgumentError(
|
|
5164
|
-
'
|
|
5233
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5165
5234
|
entities
|
|
5166
5235
|
);
|
|
5167
5236
|
}
|
|
5168
5237
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5169
5238
|
throw new InvalidArgumentError(
|
|
5170
|
-
'
|
|
5239
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5171
5240
|
sourceName
|
|
5172
5241
|
);
|
|
5173
5242
|
}
|
|
5174
5243
|
if (!targetName || typeof targetName !== "string") {
|
|
5175
5244
|
throw new InvalidArgumentError(
|
|
5176
|
-
'
|
|
5245
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5177
5246
|
targetName
|
|
5178
5247
|
);
|
|
5179
5248
|
}
|
|
5180
5249
|
if (!relationName || typeof relationName !== "string") {
|
|
5181
5250
|
throw new InvalidArgumentError(
|
|
5182
|
-
'
|
|
5251
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5183
5252
|
relationName
|
|
5184
5253
|
);
|
|
5185
5254
|
}
|
|
5186
5255
|
if (!targetRelationName || typeof targetRelationName !== "string") {
|
|
5187
5256
|
throw new InvalidArgumentError(
|
|
5188
|
-
'
|
|
5257
|
+
'Parameter "targetRelationName" must be a non-empty String, but %v was given.',
|
|
5189
5258
|
targetRelationName
|
|
5190
5259
|
);
|
|
5191
5260
|
}
|
|
5192
5261
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5193
5262
|
throw new InvalidArgumentError(
|
|
5194
|
-
'
|
|
5263
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5195
5264
|
scope
|
|
5196
5265
|
);
|
|
5197
5266
|
}
|
|
@@ -5200,7 +5269,7 @@ var init_has_many_resolver = __esm({
|
|
|
5200
5269
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
5201
5270
|
if (targetRelationDef.type !== RelationType.BELONGS_TO) {
|
|
5202
5271
|
throw new InvalidArgumentError(
|
|
5203
|
-
'
|
|
5272
|
+
'Relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic "belongsTo", but %v type was given.',
|
|
5204
5273
|
relationName,
|
|
5205
5274
|
sourceName,
|
|
5206
5275
|
targetRelationName,
|
|
@@ -5209,7 +5278,7 @@ var init_has_many_resolver = __esm({
|
|
|
5209
5278
|
}
|
|
5210
5279
|
if (!targetRelationDef.polymorphic) {
|
|
5211
5280
|
throw new InvalidArgumentError(
|
|
5212
|
-
'
|
|
5281
|
+
'Relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic too.',
|
|
5213
5282
|
relationName,
|
|
5214
5283
|
sourceName,
|
|
5215
5284
|
targetRelationName
|
|
@@ -5228,13 +5297,11 @@ var init_has_many_resolver = __esm({
|
|
|
5228
5297
|
);
|
|
5229
5298
|
}
|
|
5230
5299
|
};
|
|
5231
|
-
__name(_HasManyResolver, "HasManyResolver");
|
|
5232
|
-
HasManyResolver = _HasManyResolver;
|
|
5233
5300
|
}
|
|
5234
5301
|
});
|
|
5235
5302
|
|
|
5236
5303
|
// src/relations/belongs-to-resolver.js
|
|
5237
|
-
var import_js_service29,
|
|
5304
|
+
var import_js_service29, BelongsToResolver;
|
|
5238
5305
|
var init_belongs_to_resolver = __esm({
|
|
5239
5306
|
"src/relations/belongs-to-resolver.js"() {
|
|
5240
5307
|
"use strict";
|
|
@@ -5243,7 +5310,10 @@ var init_belongs_to_resolver = __esm({
|
|
|
5243
5310
|
init_utils();
|
|
5244
5311
|
init_repository2();
|
|
5245
5312
|
init_definition();
|
|
5246
|
-
|
|
5313
|
+
BelongsToResolver = class extends import_js_service29.Service {
|
|
5314
|
+
static {
|
|
5315
|
+
__name(this, "BelongsToResolver");
|
|
5316
|
+
}
|
|
5247
5317
|
/**
|
|
5248
5318
|
* Include to.
|
|
5249
5319
|
*
|
|
@@ -5258,37 +5328,37 @@ var init_belongs_to_resolver = __esm({
|
|
|
5258
5328
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
|
|
5259
5329
|
if (!entities || !Array.isArray(entities)) {
|
|
5260
5330
|
throw new InvalidArgumentError(
|
|
5261
|
-
'
|
|
5331
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5262
5332
|
entities
|
|
5263
5333
|
);
|
|
5264
5334
|
}
|
|
5265
5335
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5266
5336
|
throw new InvalidArgumentError(
|
|
5267
|
-
'
|
|
5337
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5268
5338
|
sourceName
|
|
5269
5339
|
);
|
|
5270
5340
|
}
|
|
5271
5341
|
if (!targetName || typeof targetName !== "string") {
|
|
5272
5342
|
throw new InvalidArgumentError(
|
|
5273
|
-
'
|
|
5343
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5274
5344
|
targetName
|
|
5275
5345
|
);
|
|
5276
5346
|
}
|
|
5277
5347
|
if (!relationName || typeof relationName !== "string") {
|
|
5278
5348
|
throw new InvalidArgumentError(
|
|
5279
|
-
'
|
|
5349
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5280
5350
|
relationName
|
|
5281
5351
|
);
|
|
5282
5352
|
}
|
|
5283
5353
|
if (foreignKey && typeof foreignKey !== "string") {
|
|
5284
5354
|
throw new InvalidArgumentError(
|
|
5285
|
-
'
|
|
5355
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
5286
5356
|
foreignKey
|
|
5287
5357
|
);
|
|
5288
5358
|
}
|
|
5289
5359
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5290
5360
|
throw new InvalidArgumentError(
|
|
5291
|
-
'
|
|
5361
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5292
5362
|
scope
|
|
5293
5363
|
);
|
|
5294
5364
|
}
|
|
@@ -5298,7 +5368,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
5298
5368
|
const targetIds = entities.reduce((acc, entity) => {
|
|
5299
5369
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5300
5370
|
throw new InvalidArgumentError(
|
|
5301
|
-
'
|
|
5371
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5302
5372
|
entity
|
|
5303
5373
|
);
|
|
5304
5374
|
}
|
|
@@ -5341,37 +5411,37 @@ var init_belongs_to_resolver = __esm({
|
|
|
5341
5411
|
async includePolymorphicTo(entities, sourceName, relationName, foreignKey = void 0, discriminator = void 0, scope = void 0) {
|
|
5342
5412
|
if (!entities || !Array.isArray(entities)) {
|
|
5343
5413
|
throw new InvalidArgumentError(
|
|
5344
|
-
'
|
|
5414
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5345
5415
|
entities
|
|
5346
5416
|
);
|
|
5347
5417
|
}
|
|
5348
5418
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5349
5419
|
throw new InvalidArgumentError(
|
|
5350
|
-
'
|
|
5420
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5351
5421
|
sourceName
|
|
5352
5422
|
);
|
|
5353
5423
|
}
|
|
5354
5424
|
if (!relationName || typeof relationName !== "string") {
|
|
5355
5425
|
throw new InvalidArgumentError(
|
|
5356
|
-
'
|
|
5426
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5357
5427
|
relationName
|
|
5358
5428
|
);
|
|
5359
5429
|
}
|
|
5360
5430
|
if (foreignKey && typeof foreignKey !== "string") {
|
|
5361
5431
|
throw new InvalidArgumentError(
|
|
5362
|
-
'
|
|
5432
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
5363
5433
|
foreignKey
|
|
5364
5434
|
);
|
|
5365
5435
|
}
|
|
5366
5436
|
if (discriminator && typeof discriminator !== "string") {
|
|
5367
5437
|
throw new InvalidArgumentError(
|
|
5368
|
-
'
|
|
5438
|
+
'Parameter "discriminator" must be a String, but %v was given.',
|
|
5369
5439
|
discriminator
|
|
5370
5440
|
);
|
|
5371
5441
|
}
|
|
5372
5442
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5373
5443
|
throw new InvalidArgumentError(
|
|
5374
|
-
'
|
|
5444
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5375
5445
|
scope
|
|
5376
5446
|
);
|
|
5377
5447
|
}
|
|
@@ -5387,7 +5457,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
5387
5457
|
entities.forEach((entity) => {
|
|
5388
5458
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5389
5459
|
throw new InvalidArgumentError(
|
|
5390
|
-
'
|
|
5460
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5391
5461
|
entity
|
|
5392
5462
|
);
|
|
5393
5463
|
}
|
|
@@ -5413,7 +5483,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
5413
5483
|
targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
|
|
5414
5484
|
} catch (error) {
|
|
5415
5485
|
if (error instanceof InvalidArgumentError) {
|
|
5416
|
-
if (error.message === `
|
|
5486
|
+
if (error.message === `Model "${targetName}" is not defined.` || error.message === `Model "${targetName}" does not have a specified datasource.`) {
|
|
5417
5487
|
return;
|
|
5418
5488
|
}
|
|
5419
5489
|
} else {
|
|
@@ -5432,9 +5502,8 @@ var init_belongs_to_resolver = __esm({
|
|
|
5432
5502
|
]
|
|
5433
5503
|
};
|
|
5434
5504
|
const promise = targetRepository.find(targetFilter).then((result) => {
|
|
5435
|
-
var _a;
|
|
5436
5505
|
targetEntitiesByTargetNames[targetName] = [
|
|
5437
|
-
...
|
|
5506
|
+
...targetEntitiesByTargetNames[targetName] ?? [],
|
|
5438
5507
|
...result
|
|
5439
5508
|
];
|
|
5440
5509
|
});
|
|
@@ -5442,13 +5511,12 @@ var init_belongs_to_resolver = __esm({
|
|
|
5442
5511
|
});
|
|
5443
5512
|
await Promise.all(promises);
|
|
5444
5513
|
entities.forEach((entity) => {
|
|
5445
|
-
var _a;
|
|
5446
5514
|
const targetId = entity[foreignKey];
|
|
5447
5515
|
const targetName = entity[discriminator];
|
|
5448
5516
|
if (targetId == null || targetName == null || targetEntitiesByTargetNames[targetName] == null) {
|
|
5449
5517
|
return;
|
|
5450
5518
|
}
|
|
5451
|
-
const targetEntities =
|
|
5519
|
+
const targetEntities = targetEntitiesByTargetNames[targetName] ?? [];
|
|
5452
5520
|
const targetPkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
|
|
5453
5521
|
targetName
|
|
5454
5522
|
);
|
|
@@ -5459,13 +5527,11 @@ var init_belongs_to_resolver = __esm({
|
|
|
5459
5527
|
});
|
|
5460
5528
|
}
|
|
5461
5529
|
};
|
|
5462
|
-
__name(_BelongsToResolver, "BelongsToResolver");
|
|
5463
|
-
BelongsToResolver = _BelongsToResolver;
|
|
5464
5530
|
}
|
|
5465
5531
|
});
|
|
5466
5532
|
|
|
5467
5533
|
// src/relations/references-many-resolver.js
|
|
5468
|
-
var import_js_service30,
|
|
5534
|
+
var import_js_service30, ReferencesManyResolver;
|
|
5469
5535
|
var init_references_many_resolver = __esm({
|
|
5470
5536
|
"src/relations/references-many-resolver.js"() {
|
|
5471
5537
|
"use strict";
|
|
@@ -5474,7 +5540,10 @@ var init_references_many_resolver = __esm({
|
|
|
5474
5540
|
init_utils();
|
|
5475
5541
|
init_repository2();
|
|
5476
5542
|
init_definition();
|
|
5477
|
-
|
|
5543
|
+
ReferencesManyResolver = class extends import_js_service30.Service {
|
|
5544
|
+
static {
|
|
5545
|
+
__name(this, "ReferencesManyResolver");
|
|
5546
|
+
}
|
|
5478
5547
|
/**
|
|
5479
5548
|
* Include to.
|
|
5480
5549
|
*
|
|
@@ -5489,37 +5558,37 @@ var init_references_many_resolver = __esm({
|
|
|
5489
5558
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
|
|
5490
5559
|
if (!entities || !Array.isArray(entities)) {
|
|
5491
5560
|
throw new InvalidArgumentError(
|
|
5492
|
-
'
|
|
5561
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5493
5562
|
entities
|
|
5494
5563
|
);
|
|
5495
5564
|
}
|
|
5496
5565
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5497
5566
|
throw new InvalidArgumentError(
|
|
5498
|
-
'
|
|
5567
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5499
5568
|
sourceName
|
|
5500
5569
|
);
|
|
5501
5570
|
}
|
|
5502
5571
|
if (!targetName || typeof targetName !== "string") {
|
|
5503
5572
|
throw new InvalidArgumentError(
|
|
5504
|
-
'
|
|
5573
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5505
5574
|
targetName
|
|
5506
5575
|
);
|
|
5507
5576
|
}
|
|
5508
5577
|
if (!relationName || typeof relationName !== "string") {
|
|
5509
5578
|
throw new InvalidArgumentError(
|
|
5510
|
-
'
|
|
5579
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5511
5580
|
relationName
|
|
5512
5581
|
);
|
|
5513
5582
|
}
|
|
5514
5583
|
if (foreignKey && typeof foreignKey !== "string") {
|
|
5515
5584
|
throw new InvalidArgumentError(
|
|
5516
|
-
'
|
|
5585
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
5517
5586
|
foreignKey
|
|
5518
5587
|
);
|
|
5519
5588
|
}
|
|
5520
5589
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5521
5590
|
throw new InvalidArgumentError(
|
|
5522
|
-
'
|
|
5591
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5523
5592
|
scope
|
|
5524
5593
|
);
|
|
5525
5594
|
}
|
|
@@ -5530,7 +5599,7 @@ var init_references_many_resolver = __esm({
|
|
|
5530
5599
|
const targetIds = entities.reduce((acc, entity) => {
|
|
5531
5600
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5532
5601
|
throw new InvalidArgumentError(
|
|
5533
|
-
'
|
|
5602
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5534
5603
|
entity
|
|
5535
5604
|
);
|
|
5536
5605
|
}
|
|
@@ -5572,8 +5641,6 @@ var init_references_many_resolver = __esm({
|
|
|
5572
5641
|
});
|
|
5573
5642
|
}
|
|
5574
5643
|
};
|
|
5575
|
-
__name(_ReferencesManyResolver, "ReferencesManyResolver");
|
|
5576
|
-
ReferencesManyResolver = _ReferencesManyResolver;
|
|
5577
5644
|
}
|
|
5578
5645
|
});
|
|
5579
5646
|
|
|
@@ -5589,7 +5656,7 @@ var init_relations2 = __esm({
|
|
|
5589
5656
|
});
|
|
5590
5657
|
|
|
5591
5658
|
// src/filter/include-clause-tool.js
|
|
5592
|
-
var import_js_service31,
|
|
5659
|
+
var import_js_service31, IncludeClauseTool;
|
|
5593
5660
|
var init_include_clause_tool = __esm({
|
|
5594
5661
|
"src/filter/include-clause-tool.js"() {
|
|
5595
5662
|
"use strict";
|
|
@@ -5601,7 +5668,10 @@ var init_include_clause_tool = __esm({
|
|
|
5601
5668
|
init_fields_clause_tool();
|
|
5602
5669
|
init_definition();
|
|
5603
5670
|
init_relations2();
|
|
5604
|
-
|
|
5671
|
+
IncludeClauseTool = class _IncludeClauseTool extends import_js_service31.Service {
|
|
5672
|
+
static {
|
|
5673
|
+
__name(this, "IncludeClauseTool");
|
|
5674
|
+
}
|
|
5605
5675
|
/**
|
|
5606
5676
|
* Include to.
|
|
5607
5677
|
*
|
|
@@ -5734,7 +5804,7 @@ var init_include_clause_tool = __esm({
|
|
|
5734
5804
|
break;
|
|
5735
5805
|
default:
|
|
5736
5806
|
throw new InvalidArgumentError(
|
|
5737
|
-
"
|
|
5807
|
+
"Relation type %v does not have an inclusion resolver.",
|
|
5738
5808
|
relDef.type
|
|
5739
5809
|
);
|
|
5740
5810
|
}
|
|
@@ -5768,7 +5838,7 @@ var init_include_clause_tool = __esm({
|
|
|
5768
5838
|
);
|
|
5769
5839
|
if (duplicateNames.length) {
|
|
5770
5840
|
throw new InvalidArgumentError(
|
|
5771
|
-
'
|
|
5841
|
+
'Option "include" has duplicates of %v.',
|
|
5772
5842
|
duplicateNames[0]
|
|
5773
5843
|
);
|
|
5774
5844
|
}
|
|
@@ -5776,7 +5846,7 @@ var init_include_clause_tool = __esm({
|
|
|
5776
5846
|
if ("relation" in clause) {
|
|
5777
5847
|
if (!clause.relation || typeof clause.relation !== "string") {
|
|
5778
5848
|
throw new InvalidArgumentError(
|
|
5779
|
-
'
|
|
5849
|
+
'Option "relation" must be a non-empty String, but %v was given.',
|
|
5780
5850
|
clause.relation
|
|
5781
5851
|
);
|
|
5782
5852
|
}
|
|
@@ -5794,7 +5864,7 @@ var init_include_clause_tool = __esm({
|
|
|
5794
5864
|
}
|
|
5795
5865
|
} else {
|
|
5796
5866
|
throw new InvalidArgumentError(
|
|
5797
|
-
'
|
|
5867
|
+
'Option "include" must have a non-empty String, an Object or an Array, but %v was given.',
|
|
5798
5868
|
clause
|
|
5799
5869
|
);
|
|
5800
5870
|
}
|
|
@@ -5810,7 +5880,7 @@ var init_include_clause_tool = __esm({
|
|
|
5810
5880
|
}
|
|
5811
5881
|
if (typeof clause !== "object" || Array.isArray(clause)) {
|
|
5812
5882
|
throw new InvalidArgumentError(
|
|
5813
|
-
'
|
|
5883
|
+
'Option "scope" must be an Object, but %v was given.',
|
|
5814
5884
|
clause
|
|
5815
5885
|
);
|
|
5816
5886
|
}
|
|
@@ -5856,7 +5926,7 @@ var init_include_clause_tool = __esm({
|
|
|
5856
5926
|
);
|
|
5857
5927
|
if (duplicateNames.length) {
|
|
5858
5928
|
throw new InvalidArgumentError(
|
|
5859
|
-
'
|
|
5929
|
+
'Option "include" has duplicates of %v.',
|
|
5860
5930
|
duplicateNames[0]
|
|
5861
5931
|
);
|
|
5862
5932
|
}
|
|
@@ -5864,7 +5934,7 @@ var init_include_clause_tool = __esm({
|
|
|
5864
5934
|
if ("relation" in clause) {
|
|
5865
5935
|
if (!clause.relation || typeof clause.relation !== "string") {
|
|
5866
5936
|
throw new InvalidArgumentError(
|
|
5867
|
-
'
|
|
5937
|
+
'Option "relation" must be a non-empty String, but %v was given.',
|
|
5868
5938
|
clause.relation
|
|
5869
5939
|
);
|
|
5870
5940
|
}
|
|
@@ -5890,7 +5960,7 @@ var init_include_clause_tool = __esm({
|
|
|
5890
5960
|
}
|
|
5891
5961
|
} else {
|
|
5892
5962
|
throw new InvalidArgumentError(
|
|
5893
|
-
'
|
|
5963
|
+
'Option "include" must have a non-empty String, an Object or an Array, but %v was given.',
|
|
5894
5964
|
clause
|
|
5895
5965
|
);
|
|
5896
5966
|
}
|
|
@@ -5908,7 +5978,7 @@ var init_include_clause_tool = __esm({
|
|
|
5908
5978
|
}
|
|
5909
5979
|
if (typeof clause !== "object" || Array.isArray(clause)) {
|
|
5910
5980
|
throw new InvalidArgumentError(
|
|
5911
|
-
'
|
|
5981
|
+
'Option "scope" must be an Object, but %v was given.',
|
|
5912
5982
|
clause
|
|
5913
5983
|
);
|
|
5914
5984
|
}
|
|
@@ -5942,8 +6012,6 @@ var init_include_clause_tool = __esm({
|
|
|
5942
6012
|
return void 0;
|
|
5943
6013
|
}
|
|
5944
6014
|
};
|
|
5945
|
-
__name(_IncludeClauseTool, "IncludeClauseTool");
|
|
5946
|
-
IncludeClauseTool = _IncludeClauseTool;
|
|
5947
6015
|
}
|
|
5948
6016
|
});
|
|
5949
6017
|
|
|
@@ -6020,7 +6088,10 @@ init_adapter2();
|
|
|
6020
6088
|
var import_js_service32 = require("@e22m4u/js-service");
|
|
6021
6089
|
init_definition();
|
|
6022
6090
|
init_repository2();
|
|
6023
|
-
var
|
|
6091
|
+
var DatabaseSchema = class extends import_js_service32.Service {
|
|
6092
|
+
static {
|
|
6093
|
+
__name(this, "DatabaseSchema");
|
|
6094
|
+
}
|
|
6024
6095
|
/**
|
|
6025
6096
|
* Define datasource.
|
|
6026
6097
|
*
|
|
@@ -6051,8 +6122,6 @@ var _DatabaseSchema = class _DatabaseSchema extends import_js_service32.Service
|
|
|
6051
6122
|
return this.getService(RepositoryRegistry).getRepository(modelName);
|
|
6052
6123
|
}
|
|
6053
6124
|
};
|
|
6054
|
-
__name(_DatabaseSchema, "DatabaseSchema");
|
|
6055
|
-
var DatabaseSchema = _DatabaseSchema;
|
|
6056
6125
|
|
|
6057
6126
|
// src/index.js
|
|
6058
6127
|
init_relations2();
|