@e22m4u/js-repository 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +452 -406
- package/package.json +7 -7
- package/src/adapter/adapter-loader.js +2 -5
- package/src/adapter/adapter-loader.spec.js +2 -2
- package/src/adapter/adapter-registry.spec.js +2 -2
- package/src/adapter/builtin/memory-adapter.js +5 -5
- package/src/adapter/builtin/memory-adapter.spec.js +12 -12
- package/src/adapter/decorator/data-sanitizing-decorator.js +1 -2
- package/src/adapter/decorator/default-values-decorator.js +1 -2
- package/src/adapter/decorator/fields-filtering-decorator.js +1 -2
- package/src/adapter/decorator/inclusion-decorator.js +1 -2
- package/src/adapter/decorator/property-uniqueness-decorator.js +1 -2
- package/src/adapter/decorator/required-property-decorator.js +1 -2
- package/src/database-schema.spec.js +3 -5
- package/src/definition/datasource/datasource-definition-validator.js +3 -3
- package/src/definition/datasource/datasource-definition-validator.spec.js +3 -6
- package/src/definition/definition-registry.d.ts +10 -0
- package/src/definition/definition-registry.js +28 -19
- package/src/definition/definition-registry.spec.js +64 -117
- package/src/definition/model/model-data-sanitizer.js +2 -4
- package/src/definition/model/model-definition-utils.js +12 -14
- package/src/definition/model/model-definition-utils.spec.js +12 -21
- package/src/definition/model/model-definition-validator.js +12 -12
- package/src/definition/model/model-definition-validator.spec.js +12 -15
- package/src/definition/model/properties/primary-keys-definition-validator.js +4 -4
- package/src/definition/model/properties/primary-keys-definition-validator.spec.js +8 -8
- package/src/definition/model/properties/properties-definition-validator.js +42 -43
- package/src/definition/model/properties/properties-definition-validator.spec.js +45 -45
- package/src/definition/model/properties/property-uniqueness-validator.js +7 -11
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +57 -60
- package/src/definition/model/properties/required-property-validator.js +1 -1
- package/src/definition/model/properties/required-property-validator.spec.js +1 -1
- package/src/definition/model/relations/relations-definition-validator.js +40 -42
- package/src/definition/model/relations/relations-definition-validator.spec.js +44 -45
- package/src/errors/invalid-operator-value-error.js +1 -1
- package/src/errors/invalid-operator-value-error.spec.js +1 -1
- package/src/filter/fields-clause-tool.js +95 -53
- package/src/filter/fields-clause-tool.spec.js +210 -387
- package/src/filter/include-clause-tool.js +9 -9
- package/src/filter/include-clause-tool.spec.js +4 -4
- package/src/filter/operator-clause-tool.js +20 -32
- package/src/filter/operator-clause-tool.spec.js +25 -49
- package/src/filter/order-clause-tool.js +55 -27
- package/src/filter/order-clause-tool.spec.js +151 -90
- package/src/filter/slice-clause-tool.js +5 -6
- package/src/filter/slice-clause-tool.spec.js +8 -24
- package/src/filter/where-clause-tool.js +18 -11
- package/src/filter/where-clause-tool.spec.js +27 -17
- package/src/relations/belongs-to-resolver.js +18 -30
- package/src/relations/belongs-to-resolver.spec.js +21 -44
- package/src/relations/has-many-resolver.js +28 -44
- package/src/relations/has-many-resolver.spec.js +44 -68
- package/src/relations/has-one-resolver.js +28 -44
- package/src/relations/has-one-resolver.spec.js +44 -68
- package/src/relations/references-many-resolver.js +8 -14
- package/src/relations/references-many-resolver.spec.js +12 -24
- package/src/repository/repository-registry.js +4 -6
- package/src/repository/repository-registry.spec.js +0 -19
- package/src/repository/repository.js +1 -1
- package/src/utils/exclude-object-keys.js +2 -2
- package/src/utils/exclude-object-keys.spec.js +2 -2
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/like-to-regexp.js +1 -2
- package/src/utils/like-to-regexp.spec.js +5 -5
- package/src/utils/select-object-keys.js +6 -7
- package/src/utils/select-object-keys.spec.js +3 -6
- package/src/utils/model-name-to-model-key.d.ts +0 -6
- package/src/utils/model-name-to-model-key.js +0 -18
- package/src/utils/model-name-to-model-key.spec.js +0 -94
package/dist/cjs/index.cjs
CHANGED
|
@@ -242,7 +242,7 @@ var init_invalid_operator_value_error = __esm({
|
|
|
242
242
|
constructor(operator, expected, value) {
|
|
243
243
|
super(
|
|
244
244
|
(0, import_js_format3.format)(
|
|
245
|
-
"Condition of {%s: ...}
|
|
245
|
+
"Condition of {%s: ...} must have %s, but %v was given.",
|
|
246
246
|
operator,
|
|
247
247
|
expected,
|
|
248
248
|
value
|
|
@@ -267,7 +267,7 @@ var init_errors = __esm({
|
|
|
267
267
|
function likeToRegexp(pattern, isCaseInsensitive = false) {
|
|
268
268
|
if (typeof pattern !== "string") {
|
|
269
269
|
throw new InvalidArgumentError(
|
|
270
|
-
"
|
|
270
|
+
'Parameter "pattern" must be a String, but %v was given.',
|
|
271
271
|
pattern
|
|
272
272
|
);
|
|
273
273
|
}
|
|
@@ -362,20 +362,21 @@ var init_get_value_by_path = __esm({
|
|
|
362
362
|
function selectObjectKeys(obj, keys) {
|
|
363
363
|
if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
|
|
364
364
|
throw new InvalidArgumentError(
|
|
365
|
-
"
|
|
365
|
+
'Parameter "obj" must be an Object, but %v was given.',
|
|
366
366
|
obj
|
|
367
367
|
);
|
|
368
368
|
}
|
|
369
369
|
if (!Array.isArray(keys)) {
|
|
370
370
|
throw new InvalidArgumentError(
|
|
371
|
-
"
|
|
371
|
+
'Parameter "keys" must be an Array, but %v was given.',
|
|
372
372
|
keys
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
|
-
keys.forEach((key) => {
|
|
375
|
+
keys.forEach((key, index) => {
|
|
376
376
|
if (typeof key !== "string") {
|
|
377
377
|
throw new InvalidArgumentError(
|
|
378
|
-
|
|
378
|
+
'Element %d of the parameter "keys" must be a String, but %v was given.',
|
|
379
|
+
index,
|
|
379
380
|
key
|
|
380
381
|
);
|
|
381
382
|
}
|
|
@@ -399,9 +400,9 @@ var init_select_object_keys = __esm({
|
|
|
399
400
|
|
|
400
401
|
// src/utils/exclude-object-keys.js
|
|
401
402
|
function excludeObjectKeys(obj, keys) {
|
|
402
|
-
if (typeof obj !== "object" ||
|
|
403
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
|
|
403
404
|
throw new InvalidArgumentError(
|
|
404
|
-
"
|
|
405
|
+
'Parameter "obj" must be an Object, but %v was given.',
|
|
405
406
|
obj
|
|
406
407
|
);
|
|
407
408
|
}
|
|
@@ -418,24 +419,6 @@ var init_exclude_object_keys = __esm({
|
|
|
418
419
|
}
|
|
419
420
|
});
|
|
420
421
|
|
|
421
|
-
// src/utils/model-name-to-model-key.js
|
|
422
|
-
function modelNameToModelKey(modelName) {
|
|
423
|
-
if (!modelName || typeof modelName !== "string" || /\s/.test(modelName)) {
|
|
424
|
-
throw new InvalidArgumentError(
|
|
425
|
-
"The model name should be a non-empty String without spaces, but %v was given.",
|
|
426
|
-
modelName
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
return modelName.toLowerCase().replace(/[-_]/g, "");
|
|
430
|
-
}
|
|
431
|
-
var init_model_name_to_model_key = __esm({
|
|
432
|
-
"src/utils/model-name-to-model-key.js"() {
|
|
433
|
-
"use strict";
|
|
434
|
-
init_errors();
|
|
435
|
-
__name(modelNameToModelKey, "modelNameToModelKey");
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
|
|
439
422
|
// src/utils/index.js
|
|
440
423
|
var init_utils = __esm({
|
|
441
424
|
"src/utils/index.js"() {
|
|
@@ -451,7 +434,6 @@ var init_utils = __esm({
|
|
|
451
434
|
init_get_value_by_path();
|
|
452
435
|
init_select_object_keys();
|
|
453
436
|
init_exclude_object_keys();
|
|
454
|
-
init_model_name_to_model_key();
|
|
455
437
|
}
|
|
456
438
|
});
|
|
457
439
|
|
|
@@ -477,19 +459,19 @@ var init_slice_clause_tool = __esm({
|
|
|
477
459
|
slice(entities, skip = void 0, limit = void 0) {
|
|
478
460
|
if (!Array.isArray(entities)) {
|
|
479
461
|
throw new InvalidArgumentError(
|
|
480
|
-
"
|
|
462
|
+
'Parameter "entities" must be an Array, but %v was given.',
|
|
481
463
|
entities
|
|
482
464
|
);
|
|
483
465
|
}
|
|
484
466
|
if (skip != null && typeof skip !== "number") {
|
|
485
467
|
throw new InvalidArgumentError(
|
|
486
|
-
'
|
|
468
|
+
'Option "skip" must be a Number, but %v was given.',
|
|
487
469
|
skip
|
|
488
470
|
);
|
|
489
471
|
}
|
|
490
472
|
if (limit != null && typeof limit !== "number") {
|
|
491
473
|
throw new InvalidArgumentError(
|
|
492
|
-
'
|
|
474
|
+
'Option "limit" must be a Number, but %v was given.',
|
|
493
475
|
limit
|
|
494
476
|
);
|
|
495
477
|
}
|
|
@@ -508,7 +490,7 @@ var init_slice_clause_tool = __esm({
|
|
|
508
490
|
}
|
|
509
491
|
if (typeof skip !== "number") {
|
|
510
492
|
throw new InvalidArgumentError(
|
|
511
|
-
'
|
|
493
|
+
'Option "skip" must be a Number, but %v was given.',
|
|
512
494
|
skip
|
|
513
495
|
);
|
|
514
496
|
}
|
|
@@ -524,7 +506,7 @@ var init_slice_clause_tool = __esm({
|
|
|
524
506
|
}
|
|
525
507
|
if (typeof limit !== "number") {
|
|
526
508
|
throw new InvalidArgumentError(
|
|
527
|
-
'
|
|
509
|
+
'Option "limit" must be a Number, but %v was given.',
|
|
528
510
|
limit
|
|
529
511
|
);
|
|
530
512
|
}
|
|
@@ -567,32 +549,45 @@ var init_order_clause_tool = __esm({
|
|
|
567
549
|
* @param {string|string[]|undefined} clause
|
|
568
550
|
*/
|
|
569
551
|
sort(entities, clause) {
|
|
552
|
+
if (!Array.isArray(entities)) {
|
|
553
|
+
throw new InvalidArgumentError(
|
|
554
|
+
'Parameter "entities" must be an Array, but %v was given.',
|
|
555
|
+
entities
|
|
556
|
+
);
|
|
557
|
+
}
|
|
570
558
|
if (clause == null) {
|
|
571
559
|
return;
|
|
572
560
|
}
|
|
573
|
-
|
|
574
|
-
|
|
561
|
+
const isArrayClause = Array.isArray(clause);
|
|
562
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
563
|
+
throw new InvalidArgumentError(
|
|
564
|
+
'Option "order" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
565
|
+
clause
|
|
566
|
+
);
|
|
575
567
|
}
|
|
576
|
-
if (!
|
|
568
|
+
if (!isArrayClause) {
|
|
569
|
+
clause = [clause];
|
|
570
|
+
} else if (!clause.length) {
|
|
577
571
|
return;
|
|
578
572
|
}
|
|
579
573
|
const mapping = [];
|
|
580
|
-
clause.forEach((
|
|
581
|
-
if (!
|
|
574
|
+
clause.forEach((element, index) => {
|
|
575
|
+
if (!element || typeof element !== "string") {
|
|
582
576
|
throw new InvalidArgumentError(
|
|
583
|
-
'
|
|
584
|
-
|
|
577
|
+
'Element %d of the option "order" must be a non-empty String, but %v was given.',
|
|
578
|
+
index,
|
|
579
|
+
element
|
|
585
580
|
);
|
|
586
581
|
}
|
|
587
582
|
let reverse = 1;
|
|
588
|
-
const matches =
|
|
583
|
+
const matches = element.match(/\s+(A|DE)SC$/i);
|
|
589
584
|
if (matches) {
|
|
590
|
-
|
|
585
|
+
element = element.replace(/\s+(A|DE)SC/i, "");
|
|
591
586
|
if (matches[1].toLowerCase() === "de") {
|
|
592
587
|
reverse = -1;
|
|
593
588
|
}
|
|
594
589
|
}
|
|
595
|
-
mapping[index] = { key, reverse };
|
|
590
|
+
mapping[index] = { key: element, reverse };
|
|
596
591
|
});
|
|
597
592
|
entities.sort(compareFn.bind(mapping));
|
|
598
593
|
}
|
|
@@ -605,17 +600,22 @@ var init_order_clause_tool = __esm({
|
|
|
605
600
|
if (clause == null) {
|
|
606
601
|
return;
|
|
607
602
|
}
|
|
608
|
-
|
|
609
|
-
|
|
603
|
+
const isArrayClause = Array.isArray(clause);
|
|
604
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
605
|
+
throw new InvalidArgumentError(
|
|
606
|
+
'Option "order" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
607
|
+
clause
|
|
608
|
+
);
|
|
610
609
|
}
|
|
611
|
-
if (!clause.length) {
|
|
610
|
+
if (!isArrayClause || !clause.length) {
|
|
612
611
|
return;
|
|
613
612
|
}
|
|
614
|
-
clause.forEach((
|
|
615
|
-
if (!
|
|
613
|
+
clause.forEach((element, index) => {
|
|
614
|
+
if (!element || typeof element !== "string") {
|
|
616
615
|
throw new InvalidArgumentError(
|
|
617
|
-
'
|
|
618
|
-
|
|
616
|
+
'Element %d of the option "order" must be a non-empty String, but %v was given.',
|
|
617
|
+
index,
|
|
618
|
+
element
|
|
619
619
|
);
|
|
620
620
|
}
|
|
621
621
|
});
|
|
@@ -630,17 +630,24 @@ var init_order_clause_tool = __esm({
|
|
|
630
630
|
if (clause == null) {
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
|
|
634
|
-
|
|
633
|
+
const isArrayClause = Array.isArray(clause);
|
|
634
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
635
|
+
throw new InvalidArgumentError(
|
|
636
|
+
'Option "order" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
637
|
+
clause
|
|
638
|
+
);
|
|
635
639
|
}
|
|
636
|
-
if (!
|
|
640
|
+
if (!isArrayClause) {
|
|
641
|
+
return [clause];
|
|
642
|
+
} else if (!clause.length) {
|
|
637
643
|
return;
|
|
638
644
|
}
|
|
639
|
-
clause.forEach((
|
|
640
|
-
if (!
|
|
645
|
+
clause.forEach((element, index) => {
|
|
646
|
+
if (!element || typeof element !== "string") {
|
|
641
647
|
throw new InvalidArgumentError(
|
|
642
|
-
'
|
|
643
|
-
|
|
648
|
+
'Element %d of the option "order" must be a non-empty String, but %v was given.',
|
|
649
|
+
index,
|
|
650
|
+
element
|
|
644
651
|
);
|
|
645
652
|
}
|
|
646
653
|
});
|
|
@@ -714,7 +721,7 @@ var init_operator_clause_tool = __esm({
|
|
|
714
721
|
testAll(clause, value) {
|
|
715
722
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
716
723
|
throw new InvalidArgumentError(
|
|
717
|
-
"
|
|
724
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
718
725
|
clause
|
|
719
726
|
);
|
|
720
727
|
}
|
|
@@ -772,9 +779,9 @@ var init_operator_clause_tool = __esm({
|
|
|
772
779
|
* @returns {boolean|undefined}
|
|
773
780
|
*/
|
|
774
781
|
testEqNeq(clause, value) {
|
|
775
|
-
if (!clause || typeof clause !== "object") {
|
|
782
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
776
783
|
throw new InvalidArgumentError(
|
|
777
|
-
"
|
|
784
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
778
785
|
clause
|
|
779
786
|
);
|
|
780
787
|
}
|
|
@@ -821,9 +828,9 @@ var init_operator_clause_tool = __esm({
|
|
|
821
828
|
* @returns {boolean|undefined}
|
|
822
829
|
*/
|
|
823
830
|
testGtLt(clause, value) {
|
|
824
|
-
if (!clause || typeof clause !== "object") {
|
|
831
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
825
832
|
throw new InvalidArgumentError(
|
|
826
|
-
"
|
|
833
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
827
834
|
clause
|
|
828
835
|
);
|
|
829
836
|
}
|
|
@@ -855,9 +862,9 @@ var init_operator_clause_tool = __esm({
|
|
|
855
862
|
* @returns {boolean|undefined}
|
|
856
863
|
*/
|
|
857
864
|
testInq(clause, value) {
|
|
858
|
-
if (!clause || typeof clause !== "object") {
|
|
865
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
859
866
|
throw new InvalidArgumentError(
|
|
860
|
-
"
|
|
867
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
861
868
|
clause
|
|
862
869
|
);
|
|
863
870
|
}
|
|
@@ -892,9 +899,9 @@ var init_operator_clause_tool = __esm({
|
|
|
892
899
|
* @returns {boolean|undefined}
|
|
893
900
|
*/
|
|
894
901
|
testNin(clause, value) {
|
|
895
|
-
if (!clause || typeof clause !== "object") {
|
|
902
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
896
903
|
throw new InvalidArgumentError(
|
|
897
|
-
"
|
|
904
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
898
905
|
clause
|
|
899
906
|
);
|
|
900
907
|
}
|
|
@@ -926,9 +933,9 @@ var init_operator_clause_tool = __esm({
|
|
|
926
933
|
* @returns {boolean|undefined}
|
|
927
934
|
*/
|
|
928
935
|
testBetween(clause, value) {
|
|
929
|
-
if (!clause || typeof clause !== "object") {
|
|
936
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
930
937
|
throw new InvalidArgumentError(
|
|
931
|
-
"
|
|
938
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
932
939
|
clause
|
|
933
940
|
);
|
|
934
941
|
}
|
|
@@ -958,9 +965,9 @@ var init_operator_clause_tool = __esm({
|
|
|
958
965
|
* @returns {boolean|undefined}
|
|
959
966
|
*/
|
|
960
967
|
testExists(clause, value) {
|
|
961
|
-
if (!clause || typeof clause !== "object") {
|
|
968
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
962
969
|
throw new InvalidArgumentError(
|
|
963
|
-
"
|
|
970
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
964
971
|
clause
|
|
965
972
|
);
|
|
966
973
|
}
|
|
@@ -992,7 +999,7 @@ var init_operator_clause_tool = __esm({
|
|
|
992
999
|
testLike(clause, value) {
|
|
993
1000
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
994
1001
|
throw new InvalidArgumentError(
|
|
995
|
-
"
|
|
1002
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
996
1003
|
clause
|
|
997
1004
|
);
|
|
998
1005
|
}
|
|
@@ -1020,7 +1027,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1020
1027
|
testNlike(clause, value) {
|
|
1021
1028
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1022
1029
|
throw new InvalidArgumentError(
|
|
1023
|
-
"
|
|
1030
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1024
1031
|
clause
|
|
1025
1032
|
);
|
|
1026
1033
|
}
|
|
@@ -1048,7 +1055,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1048
1055
|
testIlike(clause, value) {
|
|
1049
1056
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1050
1057
|
throw new InvalidArgumentError(
|
|
1051
|
-
"
|
|
1058
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1052
1059
|
clause
|
|
1053
1060
|
);
|
|
1054
1061
|
}
|
|
@@ -1076,7 +1083,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1076
1083
|
testNilike(clause, value) {
|
|
1077
1084
|
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1078
1085
|
throw new InvalidArgumentError(
|
|
1079
|
-
"
|
|
1086
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1080
1087
|
clause
|
|
1081
1088
|
);
|
|
1082
1089
|
}
|
|
@@ -1114,9 +1121,9 @@ var init_operator_clause_tool = __esm({
|
|
|
1114
1121
|
* @returns {boolean|undefined}
|
|
1115
1122
|
*/
|
|
1116
1123
|
testRegexp(clause, value) {
|
|
1117
|
-
if (!clause || typeof clause !== "object") {
|
|
1124
|
+
if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
|
|
1118
1125
|
throw new InvalidArgumentError(
|
|
1119
|
-
"
|
|
1126
|
+
'Parameter "clause" must be an Object, but %v was given.',
|
|
1120
1127
|
clause
|
|
1121
1128
|
);
|
|
1122
1129
|
}
|
|
@@ -1131,7 +1138,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1131
1138
|
const flags = clause.flags || void 0;
|
|
1132
1139
|
if (flags && typeof flags !== "string") {
|
|
1133
1140
|
throw new InvalidArgumentError(
|
|
1134
|
-
"RegExp flags
|
|
1141
|
+
"RegExp flags must be a String, but %v was given.",
|
|
1135
1142
|
clause.flags
|
|
1136
1143
|
);
|
|
1137
1144
|
}
|
|
@@ -1191,7 +1198,7 @@ var init_where_clause_tool = __esm({
|
|
|
1191
1198
|
filter(entities, where = void 0) {
|
|
1192
1199
|
if (!Array.isArray(entities)) {
|
|
1193
1200
|
throw new InvalidArgumentError(
|
|
1194
|
-
"
|
|
1201
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
1195
1202
|
entities
|
|
1196
1203
|
);
|
|
1197
1204
|
}
|
|
@@ -1207,17 +1214,18 @@ var init_where_clause_tool = __esm({
|
|
|
1207
1214
|
* @returns {Function}
|
|
1208
1215
|
*/
|
|
1209
1216
|
_createFilter(whereClause) {
|
|
1210
|
-
if (typeof whereClause !== "object" || Array.isArray(whereClause)) {
|
|
1217
|
+
if (!whereClause || typeof whereClause !== "object" || Array.isArray(whereClause)) {
|
|
1211
1218
|
throw new InvalidArgumentError(
|
|
1212
|
-
'
|
|
1219
|
+
'Option "where" must be an Object, but %v was given.',
|
|
1213
1220
|
whereClause
|
|
1214
1221
|
);
|
|
1215
1222
|
}
|
|
1216
1223
|
const keys = Object.keys(whereClause);
|
|
1217
|
-
return (data) => {
|
|
1218
|
-
if (typeof data !== "object") {
|
|
1224
|
+
return (data, index) => {
|
|
1225
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
1219
1226
|
throw new InvalidArgumentError(
|
|
1220
|
-
"
|
|
1227
|
+
"Entity at index %d must be an Object, but %v was given.",
|
|
1228
|
+
index,
|
|
1221
1229
|
data
|
|
1222
1230
|
);
|
|
1223
1231
|
}
|
|
@@ -1225,12 +1233,16 @@ var init_where_clause_tool = __esm({
|
|
|
1225
1233
|
if (key === "and" && key in whereClause) {
|
|
1226
1234
|
const andClause = whereClause[key];
|
|
1227
1235
|
if (Array.isArray(andClause)) {
|
|
1228
|
-
return andClause.every(
|
|
1236
|
+
return andClause.every(
|
|
1237
|
+
(clause) => this._createFilter(clause)(data, index)
|
|
1238
|
+
);
|
|
1229
1239
|
}
|
|
1230
1240
|
} else if (key === "or" && key in whereClause) {
|
|
1231
1241
|
const orClause = whereClause[key];
|
|
1232
1242
|
if (Array.isArray(orClause)) {
|
|
1233
|
-
return orClause.some(
|
|
1243
|
+
return orClause.some(
|
|
1244
|
+
(clause) => this._createFilter(clause)(data, index)
|
|
1245
|
+
);
|
|
1234
1246
|
}
|
|
1235
1247
|
}
|
|
1236
1248
|
const value = getValueByPath(data, key);
|
|
@@ -1298,7 +1310,7 @@ var init_where_clause_tool = __esm({
|
|
|
1298
1310
|
}
|
|
1299
1311
|
if (typeof clause !== "object" || Array.isArray(clause)) {
|
|
1300
1312
|
throw new InvalidArgumentError(
|
|
1301
|
-
'
|
|
1313
|
+
'Option "where" must be an Object, but %v was given.',
|
|
1302
1314
|
clause
|
|
1303
1315
|
);
|
|
1304
1316
|
}
|
|
@@ -1349,13 +1361,13 @@ var init_relations_definition_validator = __esm({
|
|
|
1349
1361
|
validate(modelName, relDefs) {
|
|
1350
1362
|
if (!modelName || typeof modelName !== "string") {
|
|
1351
1363
|
throw new InvalidArgumentError(
|
|
1352
|
-
"
|
|
1364
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
1353
1365
|
modelName
|
|
1354
1366
|
);
|
|
1355
1367
|
}
|
|
1356
1368
|
if (!relDefs || typeof relDefs !== "object" || Array.isArray(relDefs)) {
|
|
1357
1369
|
throw new InvalidArgumentError(
|
|
1358
|
-
'
|
|
1370
|
+
'Option "relations" of the model %v must be an Object, but %v was given.',
|
|
1359
1371
|
modelName,
|
|
1360
1372
|
relDefs
|
|
1361
1373
|
);
|
|
@@ -1376,20 +1388,20 @@ var init_relations_definition_validator = __esm({
|
|
|
1376
1388
|
_validateRelation(modelName, relName, relDef) {
|
|
1377
1389
|
if (!modelName || typeof modelName !== "string") {
|
|
1378
1390
|
throw new InvalidArgumentError(
|
|
1379
|
-
"
|
|
1391
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
1380
1392
|
modelName
|
|
1381
1393
|
);
|
|
1382
1394
|
}
|
|
1383
1395
|
if (!relName || typeof relName !== "string") {
|
|
1384
1396
|
throw new InvalidArgumentError(
|
|
1385
|
-
"
|
|
1397
|
+
"Relation name of the model %v must be a non-empty String, but %v was given.",
|
|
1386
1398
|
modelName,
|
|
1387
1399
|
relName
|
|
1388
1400
|
);
|
|
1389
1401
|
}
|
|
1390
1402
|
if (!relDef || typeof relDef !== "object" || Array.isArray(relDef)) {
|
|
1391
1403
|
throw new InvalidArgumentError(
|
|
1392
|
-
"
|
|
1404
|
+
"Relation %v of the model %v must be an Object, but %v was given.",
|
|
1393
1405
|
relName,
|
|
1394
1406
|
modelName,
|
|
1395
1407
|
relDef
|
|
@@ -1397,7 +1409,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1397
1409
|
}
|
|
1398
1410
|
if (!relDef.type || !Object.values(RelationType).includes(relDef.type)) {
|
|
1399
1411
|
throw new InvalidArgumentError(
|
|
1400
|
-
'
|
|
1412
|
+
'Relation %v of the model %v requires the option "type" to have one of relation types: %l, but %v was given.',
|
|
1401
1413
|
relName,
|
|
1402
1414
|
modelName,
|
|
1403
1415
|
Object.values(RelationType),
|
|
@@ -1443,7 +1455,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1443
1455
|
if (relDef.polymorphic) {
|
|
1444
1456
|
if (typeof relDef.polymorphic !== "boolean") {
|
|
1445
1457
|
throw new InvalidArgumentError(
|
|
1446
|
-
'
|
|
1458
|
+
'Relation %v of the model %v has the type "belongsTo", so it expects the option "polymorphic" to be a Boolean, but %v was given.',
|
|
1447
1459
|
relName,
|
|
1448
1460
|
modelName,
|
|
1449
1461
|
relDef.polymorphic
|
|
@@ -1451,7 +1463,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1451
1463
|
}
|
|
1452
1464
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
|
|
1453
1465
|
throw new InvalidArgumentError(
|
|
1454
|
-
'
|
|
1466
|
+
'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.',
|
|
1455
1467
|
relName,
|
|
1456
1468
|
modelName,
|
|
1457
1469
|
relDef.foreignKey
|
|
@@ -1459,7 +1471,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1459
1471
|
}
|
|
1460
1472
|
if (relDef.discriminator && typeof relDef.discriminator !== "string") {
|
|
1461
1473
|
throw new InvalidArgumentError(
|
|
1462
|
-
'
|
|
1474
|
+
'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.',
|
|
1463
1475
|
relName,
|
|
1464
1476
|
modelName,
|
|
1465
1477
|
relDef.discriminator
|
|
@@ -1468,7 +1480,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1468
1480
|
} else {
|
|
1469
1481
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1470
1482
|
throw new InvalidArgumentError(
|
|
1471
|
-
'
|
|
1483
|
+
'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.',
|
|
1472
1484
|
relName,
|
|
1473
1485
|
modelName,
|
|
1474
1486
|
relDef.model
|
|
@@ -1476,7 +1488,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1476
1488
|
}
|
|
1477
1489
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
|
|
1478
1490
|
throw new InvalidArgumentError(
|
|
1479
|
-
'
|
|
1491
|
+
'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.',
|
|
1480
1492
|
relName,
|
|
1481
1493
|
modelName,
|
|
1482
1494
|
relDef.foreignKey
|
|
@@ -1484,7 +1496,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1484
1496
|
}
|
|
1485
1497
|
if (relDef.discriminator) {
|
|
1486
1498
|
throw new InvalidArgumentError(
|
|
1487
|
-
'
|
|
1499
|
+
'Relation %v of the model %v is a non-polymorphic "belongsTo" relation, so it must not have the option "discriminator" to be provided.',
|
|
1488
1500
|
relName,
|
|
1489
1501
|
modelName
|
|
1490
1502
|
);
|
|
@@ -1534,7 +1546,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1534
1546
|
}
|
|
1535
1547
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1536
1548
|
throw new InvalidArgumentError(
|
|
1537
|
-
'
|
|
1549
|
+
'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.',
|
|
1538
1550
|
relName,
|
|
1539
1551
|
modelName,
|
|
1540
1552
|
relDef.model
|
|
@@ -1544,14 +1556,14 @@ var init_relations_definition_validator = __esm({
|
|
|
1544
1556
|
if (typeof relDef.polymorphic === "string") {
|
|
1545
1557
|
if (relDef.foreignKey) {
|
|
1546
1558
|
throw new InvalidArgumentError(
|
|
1547
|
-
'
|
|
1559
|
+
'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.',
|
|
1548
1560
|
relName,
|
|
1549
1561
|
modelName
|
|
1550
1562
|
);
|
|
1551
1563
|
}
|
|
1552
1564
|
if (relDef.discriminator) {
|
|
1553
1565
|
throw new InvalidArgumentError(
|
|
1554
|
-
'
|
|
1566
|
+
'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.',
|
|
1555
1567
|
relName,
|
|
1556
1568
|
modelName
|
|
1557
1569
|
);
|
|
@@ -1559,7 +1571,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1559
1571
|
} else if (typeof relDef.polymorphic === "boolean") {
|
|
1560
1572
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1561
1573
|
throw new InvalidArgumentError(
|
|
1562
|
-
'
|
|
1574
|
+
'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.',
|
|
1563
1575
|
relName,
|
|
1564
1576
|
modelName,
|
|
1565
1577
|
relDef.foreignKey
|
|
@@ -1567,7 +1579,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1567
1579
|
}
|
|
1568
1580
|
if (!relDef.discriminator || typeof relDef.discriminator !== "string") {
|
|
1569
1581
|
throw new InvalidArgumentError(
|
|
1570
|
-
'
|
|
1582
|
+
'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.',
|
|
1571
1583
|
relName,
|
|
1572
1584
|
modelName,
|
|
1573
1585
|
relDef.discriminator
|
|
@@ -1575,7 +1587,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1575
1587
|
}
|
|
1576
1588
|
} else {
|
|
1577
1589
|
throw new InvalidArgumentError(
|
|
1578
|
-
'
|
|
1590
|
+
'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.',
|
|
1579
1591
|
relName,
|
|
1580
1592
|
modelName,
|
|
1581
1593
|
relDef.polymorphic
|
|
@@ -1584,7 +1596,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1584
1596
|
} else {
|
|
1585
1597
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1586
1598
|
throw new InvalidArgumentError(
|
|
1587
|
-
'
|
|
1599
|
+
'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.',
|
|
1588
1600
|
relName,
|
|
1589
1601
|
modelName,
|
|
1590
1602
|
relDef.foreignKey
|
|
@@ -1592,7 +1604,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1592
1604
|
}
|
|
1593
1605
|
if (relDef.discriminator) {
|
|
1594
1606
|
throw new InvalidArgumentError(
|
|
1595
|
-
'
|
|
1607
|
+
'Relation %v of the model %v is a non-polymorphic "hasOne" relation, so it must not have the option "discriminator" to be provided.',
|
|
1596
1608
|
relName,
|
|
1597
1609
|
modelName
|
|
1598
1610
|
);
|
|
@@ -1642,7 +1654,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1642
1654
|
}
|
|
1643
1655
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1644
1656
|
throw new InvalidArgumentError(
|
|
1645
|
-
'
|
|
1657
|
+
'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.',
|
|
1646
1658
|
relName,
|
|
1647
1659
|
modelName,
|
|
1648
1660
|
relDef.model
|
|
@@ -1652,14 +1664,14 @@ var init_relations_definition_validator = __esm({
|
|
|
1652
1664
|
if (typeof relDef.polymorphic === "string") {
|
|
1653
1665
|
if (relDef.foreignKey) {
|
|
1654
1666
|
throw new InvalidArgumentError(
|
|
1655
|
-
'
|
|
1667
|
+
'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.',
|
|
1656
1668
|
relName,
|
|
1657
1669
|
modelName
|
|
1658
1670
|
);
|
|
1659
1671
|
}
|
|
1660
1672
|
if (relDef.discriminator) {
|
|
1661
1673
|
throw new InvalidArgumentError(
|
|
1662
|
-
'
|
|
1674
|
+
'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.',
|
|
1663
1675
|
relName,
|
|
1664
1676
|
modelName
|
|
1665
1677
|
);
|
|
@@ -1667,7 +1679,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1667
1679
|
} else if (typeof relDef.polymorphic === "boolean") {
|
|
1668
1680
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1669
1681
|
throw new InvalidArgumentError(
|
|
1670
|
-
'
|
|
1682
|
+
'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.',
|
|
1671
1683
|
relName,
|
|
1672
1684
|
modelName,
|
|
1673
1685
|
relDef.foreignKey
|
|
@@ -1675,7 +1687,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1675
1687
|
}
|
|
1676
1688
|
if (!relDef.discriminator || typeof relDef.discriminator !== "string") {
|
|
1677
1689
|
throw new InvalidArgumentError(
|
|
1678
|
-
'
|
|
1690
|
+
'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.',
|
|
1679
1691
|
relName,
|
|
1680
1692
|
modelName,
|
|
1681
1693
|
relDef.discriminator
|
|
@@ -1683,7 +1695,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1683
1695
|
}
|
|
1684
1696
|
} else {
|
|
1685
1697
|
throw new InvalidArgumentError(
|
|
1686
|
-
'
|
|
1698
|
+
'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.',
|
|
1687
1699
|
relName,
|
|
1688
1700
|
modelName,
|
|
1689
1701
|
relDef.polymorphic
|
|
@@ -1692,7 +1704,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1692
1704
|
} else {
|
|
1693
1705
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
|
|
1694
1706
|
throw new InvalidArgumentError(
|
|
1695
|
-
'
|
|
1707
|
+
'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.',
|
|
1696
1708
|
relName,
|
|
1697
1709
|
modelName,
|
|
1698
1710
|
relDef.foreignKey
|
|
@@ -1700,7 +1712,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1700
1712
|
}
|
|
1701
1713
|
if (relDef.discriminator) {
|
|
1702
1714
|
throw new InvalidArgumentError(
|
|
1703
|
-
'
|
|
1715
|
+
'Relation %v of the model %v is a non-polymorphic "hasMany" relation, so it must not have the option "discriminator" to be provided.',
|
|
1704
1716
|
relName,
|
|
1705
1717
|
modelName
|
|
1706
1718
|
);
|
|
@@ -1730,7 +1742,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1730
1742
|
}
|
|
1731
1743
|
if (!relDef.model || typeof relDef.model !== "string") {
|
|
1732
1744
|
throw new InvalidArgumentError(
|
|
1733
|
-
'
|
|
1745
|
+
'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.',
|
|
1734
1746
|
relName,
|
|
1735
1747
|
modelName,
|
|
1736
1748
|
relDef.model
|
|
@@ -1738,7 +1750,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1738
1750
|
}
|
|
1739
1751
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
|
|
1740
1752
|
throw new InvalidArgumentError(
|
|
1741
|
-
'
|
|
1753
|
+
'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.',
|
|
1742
1754
|
relName,
|
|
1743
1755
|
modelName,
|
|
1744
1756
|
relDef.foreignKey
|
|
@@ -1746,7 +1758,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1746
1758
|
}
|
|
1747
1759
|
if (relDef.discriminator) {
|
|
1748
1760
|
throw new InvalidArgumentError(
|
|
1749
|
-
'
|
|
1761
|
+
'Relation %v of the model %v has the type "referencesMany", so it must not have the option "discriminator" to be provided.',
|
|
1750
1762
|
relName,
|
|
1751
1763
|
modelName
|
|
1752
1764
|
);
|
|
@@ -1802,17 +1814,65 @@ var init_property_uniqueness = __esm({
|
|
|
1802
1814
|
}
|
|
1803
1815
|
});
|
|
1804
1816
|
|
|
1817
|
+
// src/definition/datasource/datasource-definition-validator.js
|
|
1818
|
+
var import_js_service6, DatasourceDefinitionValidator;
|
|
1819
|
+
var init_datasource_definition_validator = __esm({
|
|
1820
|
+
"src/definition/datasource/datasource-definition-validator.js"() {
|
|
1821
|
+
"use strict";
|
|
1822
|
+
import_js_service6 = require("@e22m4u/js-service");
|
|
1823
|
+
init_errors();
|
|
1824
|
+
DatasourceDefinitionValidator = class extends import_js_service6.Service {
|
|
1825
|
+
static {
|
|
1826
|
+
__name(this, "DatasourceDefinitionValidator");
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Validate.
|
|
1830
|
+
*
|
|
1831
|
+
* @param {object} datasourceDef
|
|
1832
|
+
*/
|
|
1833
|
+
validate(datasourceDef) {
|
|
1834
|
+
if (!datasourceDef || typeof datasourceDef !== "object") {
|
|
1835
|
+
throw new InvalidArgumentError(
|
|
1836
|
+
"Datasource definition must be an Object, but %v was given.",
|
|
1837
|
+
datasourceDef
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
if (!datasourceDef.name || typeof datasourceDef.name !== "string") {
|
|
1841
|
+
throw new InvalidArgumentError(
|
|
1842
|
+
'Datasource definition requires the option "name" as a non-empty String, but %v was given.',
|
|
1843
|
+
datasourceDef.name
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string") {
|
|
1847
|
+
throw new InvalidArgumentError(
|
|
1848
|
+
'Datasource %v requires the option "adapter" as a non-empty String, but %v was given.',
|
|
1849
|
+
datasourceDef.name,
|
|
1850
|
+
datasourceDef.adapter
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
|
|
1858
|
+
// src/definition/datasource/index.js
|
|
1859
|
+
var init_datasource = __esm({
|
|
1860
|
+
"src/definition/datasource/index.js"() {
|
|
1861
|
+
"use strict";
|
|
1862
|
+
init_datasource_definition_validator();
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
|
|
1805
1866
|
// src/definition/definition-registry.js
|
|
1806
|
-
var
|
|
1867
|
+
var import_js_service7, DefinitionRegistry;
|
|
1807
1868
|
var init_definition_registry = __esm({
|
|
1808
1869
|
"src/definition/definition-registry.js"() {
|
|
1809
1870
|
"use strict";
|
|
1810
|
-
|
|
1811
|
-
init_utils();
|
|
1871
|
+
import_js_service7 = require("@e22m4u/js-service");
|
|
1812
1872
|
init_errors();
|
|
1813
1873
|
init_model();
|
|
1814
|
-
|
|
1815
|
-
DefinitionRegistry = class extends
|
|
1874
|
+
init_datasource();
|
|
1875
|
+
DefinitionRegistry = class extends import_js_service7.Service {
|
|
1816
1876
|
static {
|
|
1817
1877
|
__name(this, "DefinitionRegistry");
|
|
1818
1878
|
}
|
|
@@ -1837,10 +1897,7 @@ var init_definition_registry = __esm({
|
|
|
1837
1897
|
this.getService(DatasourceDefinitionValidator).validate(datasourceDef);
|
|
1838
1898
|
const name = datasourceDef.name;
|
|
1839
1899
|
if (name in this._datasources) {
|
|
1840
|
-
throw new InvalidArgumentError(
|
|
1841
|
-
"The datasource %v is already defined.",
|
|
1842
|
-
name
|
|
1843
|
-
);
|
|
1900
|
+
throw new InvalidArgumentError("Datasource %v is already defined.", name);
|
|
1844
1901
|
}
|
|
1845
1902
|
this._datasources[name] = datasourceDef;
|
|
1846
1903
|
}
|
|
@@ -1862,10 +1919,18 @@ var init_definition_registry = __esm({
|
|
|
1862
1919
|
getDatasource(name) {
|
|
1863
1920
|
const datasourceDef = this._datasources[name];
|
|
1864
1921
|
if (!datasourceDef) {
|
|
1865
|
-
throw new InvalidArgumentError("
|
|
1922
|
+
throw new InvalidArgumentError("Datasource %v is not defined.", name);
|
|
1866
1923
|
}
|
|
1867
1924
|
return datasourceDef;
|
|
1868
1925
|
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Get datasource names.
|
|
1928
|
+
*
|
|
1929
|
+
* @returns {string[]}
|
|
1930
|
+
*/
|
|
1931
|
+
getDatasourceNames() {
|
|
1932
|
+
return Object.keys(this._datasources);
|
|
1933
|
+
}
|
|
1869
1934
|
/**
|
|
1870
1935
|
* Add model.
|
|
1871
1936
|
*
|
|
@@ -1873,14 +1938,11 @@ var init_definition_registry = __esm({
|
|
|
1873
1938
|
*/
|
|
1874
1939
|
addModel(modelDef) {
|
|
1875
1940
|
this.getService(ModelDefinitionValidator).validate(modelDef);
|
|
1876
|
-
const
|
|
1877
|
-
if (
|
|
1878
|
-
throw new InvalidArgumentError(
|
|
1879
|
-
"The model %v is already defined.",
|
|
1880
|
-
modelDef.name
|
|
1881
|
-
);
|
|
1941
|
+
const name = modelDef.name;
|
|
1942
|
+
if (name in this._models) {
|
|
1943
|
+
throw new InvalidArgumentError("Model %v is already defined.", name);
|
|
1882
1944
|
}
|
|
1883
|
-
this._models[
|
|
1945
|
+
this._models[name] = modelDef;
|
|
1884
1946
|
}
|
|
1885
1947
|
/**
|
|
1886
1948
|
* Has model.
|
|
@@ -1889,8 +1951,7 @@ var init_definition_registry = __esm({
|
|
|
1889
1951
|
* @returns {boolean}
|
|
1890
1952
|
*/
|
|
1891
1953
|
hasModel(name) {
|
|
1892
|
-
|
|
1893
|
-
return Boolean(this._models[modelKey]);
|
|
1954
|
+
return Boolean(this._models[name]);
|
|
1894
1955
|
}
|
|
1895
1956
|
/**
|
|
1896
1957
|
* Get model.
|
|
@@ -1899,29 +1960,36 @@ var init_definition_registry = __esm({
|
|
|
1899
1960
|
* @returns {object}
|
|
1900
1961
|
*/
|
|
1901
1962
|
getModel(name) {
|
|
1902
|
-
const
|
|
1903
|
-
const modelDef = this._models[modelKey];
|
|
1963
|
+
const modelDef = this._models[name];
|
|
1904
1964
|
if (!modelDef) {
|
|
1905
|
-
throw new InvalidArgumentError("
|
|
1965
|
+
throw new InvalidArgumentError("Model %v is not defined.", name);
|
|
1906
1966
|
}
|
|
1907
1967
|
return modelDef;
|
|
1908
1968
|
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Get model names.
|
|
1971
|
+
*
|
|
1972
|
+
* @returns {string[]}
|
|
1973
|
+
*/
|
|
1974
|
+
getModelNames() {
|
|
1975
|
+
return Object.keys(this._models);
|
|
1976
|
+
}
|
|
1909
1977
|
};
|
|
1910
1978
|
}
|
|
1911
1979
|
});
|
|
1912
1980
|
|
|
1913
1981
|
// src/definition/model/model-definition-utils.js
|
|
1914
|
-
var
|
|
1982
|
+
var import_js_service8, DEFAULT_PRIMARY_KEY_PROPERTY_NAME, ModelDefinitionUtils;
|
|
1915
1983
|
var init_model_definition_utils = __esm({
|
|
1916
1984
|
"src/definition/model/model-definition-utils.js"() {
|
|
1917
1985
|
"use strict";
|
|
1918
|
-
|
|
1986
|
+
import_js_service8 = require("@e22m4u/js-service");
|
|
1919
1987
|
init_properties();
|
|
1920
1988
|
init_errors();
|
|
1921
1989
|
init_definition_registry();
|
|
1922
1990
|
init_utils();
|
|
1923
1991
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME = "id";
|
|
1924
|
-
ModelDefinitionUtils = class extends
|
|
1992
|
+
ModelDefinitionUtils = class extends import_js_service8.Service {
|
|
1925
1993
|
static {
|
|
1926
1994
|
__name(this, "ModelDefinitionUtils");
|
|
1927
1995
|
}
|
|
@@ -1943,7 +2011,7 @@ var init_model_definition_utils = __esm({
|
|
|
1943
2011
|
);
|
|
1944
2012
|
if (isDefaultPrimaryKeyAlreadyInUse) {
|
|
1945
2013
|
throw new InvalidArgumentError(
|
|
1946
|
-
'
|
|
2014
|
+
'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
2015
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
1948
2016
|
modelName
|
|
1949
2017
|
);
|
|
@@ -1995,7 +2063,7 @@ var init_model_definition_utils = __esm({
|
|
|
1995
2063
|
const propDef = propDefs[propertyName];
|
|
1996
2064
|
if (!propDef) {
|
|
1997
2065
|
throw new InvalidArgumentError(
|
|
1998
|
-
"
|
|
2066
|
+
"Model %v does not have the property %v.",
|
|
1999
2067
|
modelName,
|
|
2000
2068
|
propertyName
|
|
2001
2069
|
);
|
|
@@ -2017,7 +2085,7 @@ var init_model_definition_utils = __esm({
|
|
|
2017
2085
|
const propDef = propDefs[propertyName];
|
|
2018
2086
|
if (!propDef) {
|
|
2019
2087
|
throw new InvalidArgumentError(
|
|
2020
|
-
"
|
|
2088
|
+
"Model %v does not have the property %v.",
|
|
2021
2089
|
modelName,
|
|
2022
2090
|
propertyName
|
|
2023
2091
|
);
|
|
@@ -2137,7 +2205,7 @@ var init_model_definition_utils = __esm({
|
|
|
2137
2205
|
return DataType.ANY;
|
|
2138
2206
|
}
|
|
2139
2207
|
throw new InvalidArgumentError(
|
|
2140
|
-
"
|
|
2208
|
+
"Model %v does not have the property %v.",
|
|
2141
2209
|
modelName,
|
|
2142
2210
|
propertyName
|
|
2143
2211
|
);
|
|
@@ -2156,7 +2224,7 @@ var init_model_definition_utils = __esm({
|
|
|
2156
2224
|
getDataTypeFromPropertyDefinition(propDef) {
|
|
2157
2225
|
if ((!propDef || typeof propDef !== "object") && !Object.values(DataType).includes(propDef)) {
|
|
2158
2226
|
throw new InvalidArgumentError(
|
|
2159
|
-
'
|
|
2227
|
+
'Parameter "propDef" must be an Object or a DataType, but %v was given.',
|
|
2160
2228
|
propDef
|
|
2161
2229
|
);
|
|
2162
2230
|
}
|
|
@@ -2166,7 +2234,7 @@ var init_model_definition_utils = __esm({
|
|
|
2166
2234
|
const dataType = propDef.type;
|
|
2167
2235
|
if (!Object.values(DataType).includes(dataType)) {
|
|
2168
2236
|
throw new InvalidArgumentError(
|
|
2169
|
-
'
|
|
2237
|
+
'Option "type" must be one of values: %l, but %v was given.',
|
|
2170
2238
|
Object.values(DataType),
|
|
2171
2239
|
propDef.type
|
|
2172
2240
|
);
|
|
@@ -2217,7 +2285,7 @@ var init_model_definition_utils = __esm({
|
|
|
2217
2285
|
const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
|
|
2218
2286
|
if (currModelName === prevModelName) {
|
|
2219
2287
|
throw new InvalidArgumentError(
|
|
2220
|
-
"
|
|
2288
|
+
"Model %v has a circular inheritance.",
|
|
2221
2289
|
currModelName
|
|
2222
2290
|
);
|
|
2223
2291
|
}
|
|
@@ -2257,7 +2325,7 @@ var init_model_definition_utils = __esm({
|
|
|
2257
2325
|
const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
|
|
2258
2326
|
if (currModelName === prevModelName) {
|
|
2259
2327
|
throw new InvalidArgumentError(
|
|
2260
|
-
"
|
|
2328
|
+
"Model %v has a circular inheritance.",
|
|
2261
2329
|
currModelName
|
|
2262
2330
|
);
|
|
2263
2331
|
}
|
|
@@ -2290,7 +2358,7 @@ var init_model_definition_utils = __esm({
|
|
|
2290
2358
|
}
|
|
2291
2359
|
if (!foundDef) {
|
|
2292
2360
|
throw new InvalidArgumentError(
|
|
2293
|
-
"
|
|
2361
|
+
"Model %v does not have relation name %v.",
|
|
2294
2362
|
modelName,
|
|
2295
2363
|
relationName
|
|
2296
2364
|
);
|
|
@@ -2307,7 +2375,7 @@ var init_model_definition_utils = __esm({
|
|
|
2307
2375
|
excludeObjectKeysByRelationNames(modelName, modelData) {
|
|
2308
2376
|
if (!modelData || typeof modelData !== "object" || Array.isArray(modelData)) {
|
|
2309
2377
|
throw new InvalidArgumentError(
|
|
2310
|
-
"
|
|
2378
|
+
'Parameter "modelData" must be an Object, but %v was given.',
|
|
2311
2379
|
modelData
|
|
2312
2380
|
);
|
|
2313
2381
|
}
|
|
@@ -2355,15 +2423,15 @@ var init_model_definition_utils = __esm({
|
|
|
2355
2423
|
});
|
|
2356
2424
|
|
|
2357
2425
|
// src/definition/model/properties/required-property-validator.js
|
|
2358
|
-
var
|
|
2426
|
+
var import_js_service9, RequiredPropertyValidator;
|
|
2359
2427
|
var init_required_property_validator = __esm({
|
|
2360
2428
|
"src/definition/model/properties/required-property-validator.js"() {
|
|
2361
2429
|
"use strict";
|
|
2362
2430
|
init_data_type();
|
|
2363
|
-
|
|
2431
|
+
import_js_service9 = require("@e22m4u/js-service");
|
|
2364
2432
|
init_errors();
|
|
2365
2433
|
init_model_definition_utils();
|
|
2366
|
-
RequiredPropertyValidator = class extends
|
|
2434
|
+
RequiredPropertyValidator = class extends import_js_service9.Service {
|
|
2367
2435
|
static {
|
|
2368
2436
|
__name(this, "RequiredPropertyValidator");
|
|
2369
2437
|
}
|
|
@@ -2383,7 +2451,7 @@ var init_required_property_validator = __esm({
|
|
|
2383
2451
|
}
|
|
2384
2452
|
if (!modelData || typeof modelData !== "object" || Array.isArray(modelData)) {
|
|
2385
2453
|
throw new InvalidArgumentError(
|
|
2386
|
-
"Data of the model %v
|
|
2454
|
+
"Data of the model %v must be an Object, but %v was given.",
|
|
2387
2455
|
modelName,
|
|
2388
2456
|
modelData
|
|
2389
2457
|
);
|
|
@@ -2428,16 +2496,16 @@ var init_required_property_validator = __esm({
|
|
|
2428
2496
|
});
|
|
2429
2497
|
|
|
2430
2498
|
// src/definition/model/properties/property-uniqueness-validator.js
|
|
2431
|
-
var
|
|
2499
|
+
var import_js_service10, PropertyUniquenessValidator;
|
|
2432
2500
|
var init_property_uniqueness_validator = __esm({
|
|
2433
2501
|
"src/definition/model/properties/property-uniqueness-validator.js"() {
|
|
2434
2502
|
"use strict";
|
|
2435
|
-
|
|
2503
|
+
import_js_service10 = require("@e22m4u/js-service");
|
|
2436
2504
|
init_utils();
|
|
2437
2505
|
init_property_uniqueness();
|
|
2438
2506
|
init_errors();
|
|
2439
2507
|
init_model_definition_utils();
|
|
2440
|
-
PropertyUniquenessValidator = class extends
|
|
2508
|
+
PropertyUniquenessValidator = class extends import_js_service10.Service {
|
|
2441
2509
|
static {
|
|
2442
2510
|
__name(this, "PropertyUniquenessValidator");
|
|
2443
2511
|
}
|
|
@@ -2454,25 +2522,25 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2454
2522
|
async validate(countMethod, methodName, modelName, modelData, modelId = void 0) {
|
|
2455
2523
|
if (typeof countMethod !== "function") {
|
|
2456
2524
|
throw new InvalidArgumentError(
|
|
2457
|
-
'
|
|
2525
|
+
'Parameter "countMethod" must be a Function, but %v was given.',
|
|
2458
2526
|
countMethod
|
|
2459
2527
|
);
|
|
2460
2528
|
}
|
|
2461
2529
|
if (!methodName || typeof methodName !== "string") {
|
|
2462
2530
|
throw new InvalidArgumentError(
|
|
2463
|
-
'
|
|
2531
|
+
'Parameter "methodName" must be a non-empty String, but %v was given.',
|
|
2464
2532
|
methodName
|
|
2465
2533
|
);
|
|
2466
2534
|
}
|
|
2467
2535
|
if (!modelName || typeof modelName !== "string") {
|
|
2468
2536
|
throw new InvalidArgumentError(
|
|
2469
|
-
'
|
|
2537
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2470
2538
|
modelName
|
|
2471
2539
|
);
|
|
2472
2540
|
}
|
|
2473
2541
|
if (!isPlainObject(modelData)) {
|
|
2474
2542
|
throw new InvalidArgumentError(
|
|
2475
|
-
"
|
|
2543
|
+
"Data of the model %v must be an Object, but %v was given.",
|
|
2476
2544
|
modelName,
|
|
2477
2545
|
modelData
|
|
2478
2546
|
);
|
|
@@ -2486,7 +2554,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2486
2554
|
modelName
|
|
2487
2555
|
);
|
|
2488
2556
|
const createError = /* @__PURE__ */ __name((propName, propValue) => new InvalidArgumentError(
|
|
2489
|
-
"
|
|
2557
|
+
"Existing document of the model %v already has the property %v with the value %v and must be unique.",
|
|
2490
2558
|
modelName,
|
|
2491
2559
|
propName,
|
|
2492
2560
|
propValue
|
|
@@ -2549,7 +2617,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2549
2617
|
}
|
|
2550
2618
|
} else {
|
|
2551
2619
|
throw new InvalidArgumentError(
|
|
2552
|
-
"
|
|
2620
|
+
"Adapter method %v is not supported.",
|
|
2553
2621
|
methodName
|
|
2554
2622
|
);
|
|
2555
2623
|
}
|
|
@@ -2560,14 +2628,14 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2560
2628
|
});
|
|
2561
2629
|
|
|
2562
2630
|
// src/definition/model/properties/primary-keys-definition-validator.js
|
|
2563
|
-
var
|
|
2631
|
+
var import_js_service11, PrimaryKeysDefinitionValidator;
|
|
2564
2632
|
var init_primary_keys_definition_validator = __esm({
|
|
2565
2633
|
"src/definition/model/properties/primary-keys-definition-validator.js"() {
|
|
2566
2634
|
"use strict";
|
|
2567
|
-
|
|
2635
|
+
import_js_service11 = require("@e22m4u/js-service");
|
|
2568
2636
|
init_errors();
|
|
2569
2637
|
init_model_definition_utils();
|
|
2570
|
-
PrimaryKeysDefinitionValidator = class extends
|
|
2638
|
+
PrimaryKeysDefinitionValidator = class extends import_js_service11.Service {
|
|
2571
2639
|
static {
|
|
2572
2640
|
__name(this, "PrimaryKeysDefinitionValidator");
|
|
2573
2641
|
}
|
|
@@ -2586,7 +2654,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2586
2654
|
const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(DEFAULT_PRIMARY_KEY_PROPERTY_NAME);
|
|
2587
2655
|
if (isDefaultPrimaryKeyAlreadyInUse) {
|
|
2588
2656
|
throw new InvalidArgumentError(
|
|
2589
|
-
'
|
|
2657
|
+
'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.',
|
|
2590
2658
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
2591
2659
|
modelName
|
|
2592
2660
|
);
|
|
@@ -2595,7 +2663,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2595
2663
|
}
|
|
2596
2664
|
if (propNames.length > 1) {
|
|
2597
2665
|
throw new InvalidArgumentError(
|
|
2598
|
-
"
|
|
2666
|
+
"Model definition %v must not have multiple primary keys, but %v keys were given.",
|
|
2599
2667
|
modelName,
|
|
2600
2668
|
propNames.length
|
|
2601
2669
|
);
|
|
@@ -2615,17 +2683,17 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2615
2683
|
});
|
|
2616
2684
|
|
|
2617
2685
|
// src/definition/model/properties/properties-definition-validator.js
|
|
2618
|
-
var
|
|
2686
|
+
var import_js_service12, PropertiesDefinitionValidator;
|
|
2619
2687
|
var init_properties_definition_validator = __esm({
|
|
2620
2688
|
"src/definition/model/properties/properties-definition-validator.js"() {
|
|
2621
2689
|
"use strict";
|
|
2622
|
-
|
|
2690
|
+
import_js_service12 = require("@e22m4u/js-service");
|
|
2623
2691
|
init_data_type();
|
|
2624
2692
|
init_utils();
|
|
2625
2693
|
init_property_uniqueness();
|
|
2626
2694
|
init_errors();
|
|
2627
2695
|
init_primary_keys_definition_validator();
|
|
2628
|
-
PropertiesDefinitionValidator = class extends
|
|
2696
|
+
PropertiesDefinitionValidator = class extends import_js_service12.Service {
|
|
2629
2697
|
static {
|
|
2630
2698
|
__name(this, "PropertiesDefinitionValidator");
|
|
2631
2699
|
}
|
|
@@ -2638,13 +2706,13 @@ var init_properties_definition_validator = __esm({
|
|
|
2638
2706
|
validate(modelName, propDefs) {
|
|
2639
2707
|
if (!modelName || typeof modelName !== "string") {
|
|
2640
2708
|
throw new InvalidArgumentError(
|
|
2641
|
-
"
|
|
2709
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2642
2710
|
modelName
|
|
2643
2711
|
);
|
|
2644
2712
|
}
|
|
2645
2713
|
if (!propDefs || typeof propDefs !== "object" || Array.isArray(propDefs)) {
|
|
2646
2714
|
throw new InvalidArgumentError(
|
|
2647
|
-
'
|
|
2715
|
+
'Option "properties" of the model %v must be an Object, but %v was given.',
|
|
2648
2716
|
modelName,
|
|
2649
2717
|
propDefs
|
|
2650
2718
|
);
|
|
@@ -2669,20 +2737,20 @@ var init_properties_definition_validator = __esm({
|
|
|
2669
2737
|
_validateProperty(modelName, propName, propDef) {
|
|
2670
2738
|
if (!modelName || typeof modelName !== "string") {
|
|
2671
2739
|
throw new InvalidArgumentError(
|
|
2672
|
-
"
|
|
2740
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2673
2741
|
modelName
|
|
2674
2742
|
);
|
|
2675
2743
|
}
|
|
2676
2744
|
if (!propName || typeof propName !== "string") {
|
|
2677
2745
|
throw new InvalidArgumentError(
|
|
2678
|
-
"
|
|
2746
|
+
"Property name of the model %v must be a non-empty String, but %v was given.",
|
|
2679
2747
|
modelName,
|
|
2680
2748
|
propName
|
|
2681
2749
|
);
|
|
2682
2750
|
}
|
|
2683
2751
|
if (!propDef) {
|
|
2684
2752
|
throw new InvalidArgumentError(
|
|
2685
|
-
"
|
|
2753
|
+
"Property %v of the model %v must have a property definition, but %v was given.",
|
|
2686
2754
|
propName,
|
|
2687
2755
|
modelName,
|
|
2688
2756
|
propDef
|
|
@@ -2691,7 +2759,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2691
2759
|
if (typeof propDef === "string") {
|
|
2692
2760
|
if (!Object.values(DataType).includes(propDef)) {
|
|
2693
2761
|
throw new InvalidArgumentError(
|
|
2694
|
-
"In case of a short property definition, the property %v of the model %v
|
|
2762
|
+
"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.",
|
|
2695
2763
|
propName,
|
|
2696
2764
|
modelName,
|
|
2697
2765
|
Object.values(DataType),
|
|
@@ -2702,7 +2770,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2702
2770
|
}
|
|
2703
2771
|
if (!propDef || typeof propDef !== "object" || Array.isArray(propDef)) {
|
|
2704
2772
|
throw new InvalidArgumentError(
|
|
2705
|
-
"In case of a full property definition, the property %v of the model %v
|
|
2773
|
+
"In case of a full property definition, the property %v of the model %v must be an Object, but %v was given.",
|
|
2706
2774
|
propName,
|
|
2707
2775
|
modelName,
|
|
2708
2776
|
propDef
|
|
@@ -2710,7 +2778,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2710
2778
|
}
|
|
2711
2779
|
if (!propDef.type || !Object.values(DataType).includes(propDef.type)) {
|
|
2712
2780
|
throw new InvalidArgumentError(
|
|
2713
|
-
'
|
|
2781
|
+
'Property %v of the model %v requires the option "type" to have one of data types: %l, but %v was given.',
|
|
2714
2782
|
propName,
|
|
2715
2783
|
modelName,
|
|
2716
2784
|
Object.values(DataType),
|
|
@@ -2719,7 +2787,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2719
2787
|
}
|
|
2720
2788
|
if (propDef.itemType && !Object.values(DataType).includes(propDef.itemType)) {
|
|
2721
2789
|
throw new InvalidArgumentError(
|
|
2722
|
-
'
|
|
2790
|
+
'Option "itemType" of the property %v in the model %v should have one of data types: %l, but %v was given.',
|
|
2723
2791
|
propName,
|
|
2724
2792
|
modelName,
|
|
2725
2793
|
Object.values(DataType),
|
|
@@ -2728,7 +2796,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2728
2796
|
}
|
|
2729
2797
|
if (propDef.itemModel && typeof propDef.itemModel !== "string") {
|
|
2730
2798
|
throw new InvalidArgumentError(
|
|
2731
|
-
'
|
|
2799
|
+
'Option "itemModel" of the property %v in the model %v must be a String, but %v was given.',
|
|
2732
2800
|
propName,
|
|
2733
2801
|
modelName,
|
|
2734
2802
|
propDef.itemModel
|
|
@@ -2736,7 +2804,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2736
2804
|
}
|
|
2737
2805
|
if (propDef.model && typeof propDef.model !== "string") {
|
|
2738
2806
|
throw new InvalidArgumentError(
|
|
2739
|
-
'
|
|
2807
|
+
'Option "model" of the property %v in the model %v must be a String, but %v was given.',
|
|
2740
2808
|
propName,
|
|
2741
2809
|
modelName,
|
|
2742
2810
|
propDef.model
|
|
@@ -2744,7 +2812,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2744
2812
|
}
|
|
2745
2813
|
if (propDef.primaryKey && typeof propDef.primaryKey !== "boolean") {
|
|
2746
2814
|
throw new InvalidArgumentError(
|
|
2747
|
-
'
|
|
2815
|
+
'Option "primaryKey" of the property %v in the model %v must be a Boolean, but %v was given.',
|
|
2748
2816
|
propName,
|
|
2749
2817
|
modelName,
|
|
2750
2818
|
propDef.primaryKey
|
|
@@ -2752,7 +2820,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2752
2820
|
}
|
|
2753
2821
|
if (propDef.columnName && typeof propDef.columnName !== "string") {
|
|
2754
2822
|
throw new InvalidArgumentError(
|
|
2755
|
-
'
|
|
2823
|
+
'Option "columnName" of the property %v in the model %v must be a String, but %v was given.',
|
|
2756
2824
|
propName,
|
|
2757
2825
|
modelName,
|
|
2758
2826
|
propDef.columnName
|
|
@@ -2760,7 +2828,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2760
2828
|
}
|
|
2761
2829
|
if (propDef.columnType && typeof propDef.columnType !== "string") {
|
|
2762
2830
|
throw new InvalidArgumentError(
|
|
2763
|
-
'
|
|
2831
|
+
'Option "columnType" of the property %v in the model %v must be a String, but %v was given.',
|
|
2764
2832
|
propName,
|
|
2765
2833
|
modelName,
|
|
2766
2834
|
propDef.columnType
|
|
@@ -2768,7 +2836,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2768
2836
|
}
|
|
2769
2837
|
if (propDef.required && typeof propDef.required !== "boolean") {
|
|
2770
2838
|
throw new InvalidArgumentError(
|
|
2771
|
-
'
|
|
2839
|
+
'Option "required" of the property %v in the model %v must be a Boolean, but %v was given.',
|
|
2772
2840
|
propName,
|
|
2773
2841
|
modelName,
|
|
2774
2842
|
propDef.required
|
|
@@ -2776,28 +2844,28 @@ var init_properties_definition_validator = __esm({
|
|
|
2776
2844
|
}
|
|
2777
2845
|
if (propDef.required && propDef.default !== void 0) {
|
|
2778
2846
|
throw new InvalidArgumentError(
|
|
2779
|
-
'
|
|
2847
|
+
'Property %v of the model %v is a required property, so it must not have the option "default" to be provided.',
|
|
2780
2848
|
propName,
|
|
2781
2849
|
modelName
|
|
2782
2850
|
);
|
|
2783
2851
|
}
|
|
2784
2852
|
if (propDef.primaryKey && propDef.required) {
|
|
2785
2853
|
throw new InvalidArgumentError(
|
|
2786
|
-
'
|
|
2854
|
+
'Property %v of the model %v is a primary key, so it must not have the option "required" to be provided.',
|
|
2787
2855
|
propName,
|
|
2788
2856
|
modelName
|
|
2789
2857
|
);
|
|
2790
2858
|
}
|
|
2791
2859
|
if (propDef.primaryKey && propDef.default !== void 0) {
|
|
2792
2860
|
throw new InvalidArgumentError(
|
|
2793
|
-
'
|
|
2861
|
+
'Property %v of the model %v is a primary key, so it must not have the option "default" to be provided.',
|
|
2794
2862
|
propName,
|
|
2795
2863
|
modelName
|
|
2796
2864
|
);
|
|
2797
2865
|
}
|
|
2798
2866
|
if (propDef.itemType && propDef.type !== DataType.ARRAY) {
|
|
2799
2867
|
throw new InvalidArgumentError(
|
|
2800
|
-
'
|
|
2868
|
+
'Property %v of the model %v has a non-array type, so it must not have the option "itemType" to be provided.',
|
|
2801
2869
|
propName,
|
|
2802
2870
|
modelName,
|
|
2803
2871
|
propDef.type
|
|
@@ -2805,7 +2873,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2805
2873
|
}
|
|
2806
2874
|
if (propDef.itemModel && propDef.type !== DataType.ARRAY) {
|
|
2807
2875
|
throw new InvalidArgumentError(
|
|
2808
|
-
'
|
|
2876
|
+
'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.',
|
|
2809
2877
|
capitalize(propDef.type),
|
|
2810
2878
|
propName,
|
|
2811
2879
|
modelName
|
|
@@ -2814,14 +2882,14 @@ var init_properties_definition_validator = __esm({
|
|
|
2814
2882
|
if (propDef.itemModel && propDef.itemType !== DataType.OBJECT) {
|
|
2815
2883
|
if (propDef.itemType) {
|
|
2816
2884
|
throw new InvalidArgumentError(
|
|
2817
|
-
'
|
|
2885
|
+
'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.',
|
|
2818
2886
|
propName,
|
|
2819
2887
|
modelName,
|
|
2820
2888
|
capitalize(propDef.itemType)
|
|
2821
2889
|
);
|
|
2822
2890
|
} else {
|
|
2823
2891
|
throw new InvalidArgumentError(
|
|
2824
|
-
'
|
|
2892
|
+
'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.',
|
|
2825
2893
|
propName,
|
|
2826
2894
|
modelName
|
|
2827
2895
|
);
|
|
@@ -2829,7 +2897,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2829
2897
|
}
|
|
2830
2898
|
if (propDef.model && propDef.type !== DataType.OBJECT) {
|
|
2831
2899
|
throw new InvalidArgumentError(
|
|
2832
|
-
'
|
|
2900
|
+
'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.',
|
|
2833
2901
|
capitalize(propDef.type),
|
|
2834
2902
|
propName,
|
|
2835
2903
|
modelName
|
|
@@ -2838,7 +2906,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2838
2906
|
if (propDef.unique) {
|
|
2839
2907
|
if (typeof propDef.unique !== "boolean" && !Object.values(PropertyUniqueness).includes(propDef.unique)) {
|
|
2840
2908
|
throw new InvalidArgumentError(
|
|
2841
|
-
'
|
|
2909
|
+
'Option "unique" of the property %v in the model %v must be a Boolean or one of values: %l, but %v was given.',
|
|
2842
2910
|
propName,
|
|
2843
2911
|
modelName,
|
|
2844
2912
|
Object.values(PropertyUniqueness),
|
|
@@ -2848,7 +2916,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2848
2916
|
}
|
|
2849
2917
|
if (propDef.unique && propDef.primaryKey) {
|
|
2850
2918
|
throw new InvalidArgumentError(
|
|
2851
|
-
'
|
|
2919
|
+
'Property %v of the model %v is a primary key, so it must not have the option "unique" to be provided.',
|
|
2852
2920
|
propName,
|
|
2853
2921
|
modelName
|
|
2854
2922
|
);
|
|
@@ -2880,14 +2948,14 @@ var init_model_definition = __esm({
|
|
|
2880
2948
|
});
|
|
2881
2949
|
|
|
2882
2950
|
// src/definition/model/model-data-sanitizer.js
|
|
2883
|
-
var
|
|
2951
|
+
var import_js_service13, ModelDataSanitizer;
|
|
2884
2952
|
var init_model_data_sanitizer = __esm({
|
|
2885
2953
|
"src/definition/model/model-data-sanitizer.js"() {
|
|
2886
2954
|
"use strict";
|
|
2887
|
-
|
|
2955
|
+
import_js_service13 = require("@e22m4u/js-service");
|
|
2888
2956
|
init_errors();
|
|
2889
2957
|
init_model_definition_utils();
|
|
2890
|
-
ModelDataSanitizer = class extends
|
|
2958
|
+
ModelDataSanitizer = class extends import_js_service13.Service {
|
|
2891
2959
|
static {
|
|
2892
2960
|
__name(this, "ModelDataSanitizer");
|
|
2893
2961
|
}
|
|
@@ -2901,13 +2969,13 @@ var init_model_data_sanitizer = __esm({
|
|
|
2901
2969
|
sanitize(modelName, modelData) {
|
|
2902
2970
|
if (!modelName || typeof modelName !== "string") {
|
|
2903
2971
|
throw new InvalidArgumentError(
|
|
2904
|
-
"
|
|
2972
|
+
'Parameter "modelName" must be a String, but %v was given.',
|
|
2905
2973
|
modelName
|
|
2906
2974
|
);
|
|
2907
2975
|
}
|
|
2908
2976
|
if (!modelData || typeof modelData !== "object") {
|
|
2909
2977
|
throw new InvalidArgumentError(
|
|
2910
|
-
"
|
|
2978
|
+
'Parameter "modelData" must be an Object, but %v was given.',
|
|
2911
2979
|
modelData
|
|
2912
2980
|
);
|
|
2913
2981
|
}
|
|
@@ -2920,15 +2988,15 @@ var init_model_data_sanitizer = __esm({
|
|
|
2920
2988
|
});
|
|
2921
2989
|
|
|
2922
2990
|
// src/definition/model/model-definition-validator.js
|
|
2923
|
-
var
|
|
2991
|
+
var import_js_service14, ModelDefinitionValidator;
|
|
2924
2992
|
var init_model_definition_validator = __esm({
|
|
2925
2993
|
"src/definition/model/model-definition-validator.js"() {
|
|
2926
2994
|
"use strict";
|
|
2927
|
-
|
|
2995
|
+
import_js_service14 = require("@e22m4u/js-service");
|
|
2928
2996
|
init_errors();
|
|
2929
2997
|
init_relations();
|
|
2930
2998
|
init_properties();
|
|
2931
|
-
ModelDefinitionValidator = class extends
|
|
2999
|
+
ModelDefinitionValidator = class extends import_js_service14.Service {
|
|
2932
3000
|
static {
|
|
2933
3001
|
__name(this, "ModelDefinitionValidator");
|
|
2934
3002
|
}
|
|
@@ -2940,33 +3008,33 @@ var init_model_definition_validator = __esm({
|
|
|
2940
3008
|
validate(modelDef) {
|
|
2941
3009
|
if (!modelDef || typeof modelDef !== "object" || Array.isArray(modelDef)) {
|
|
2942
3010
|
throw new InvalidArgumentError(
|
|
2943
|
-
"
|
|
3011
|
+
"Model definition must be an Object, but %v was given.",
|
|
2944
3012
|
modelDef
|
|
2945
3013
|
);
|
|
2946
3014
|
}
|
|
2947
3015
|
if (!modelDef.name || typeof modelDef.name !== "string") {
|
|
2948
3016
|
throw new InvalidArgumentError(
|
|
2949
|
-
'
|
|
3017
|
+
'Model definition requires the option "name" as a non-empty String, but %v was given.',
|
|
2950
3018
|
modelDef.name
|
|
2951
3019
|
);
|
|
2952
3020
|
}
|
|
2953
3021
|
if (modelDef.datasource && typeof modelDef.datasource !== "string") {
|
|
2954
3022
|
throw new InvalidArgumentError(
|
|
2955
|
-
'
|
|
3023
|
+
'Option "datasource" of the model %v must be a String, but %v was given.',
|
|
2956
3024
|
modelDef.name,
|
|
2957
3025
|
modelDef.datasource
|
|
2958
3026
|
);
|
|
2959
3027
|
}
|
|
2960
3028
|
if (modelDef.base && typeof modelDef.base !== "string") {
|
|
2961
3029
|
throw new InvalidArgumentError(
|
|
2962
|
-
'
|
|
3030
|
+
'Option "base" of the model %v must be a String, but %v was given.',
|
|
2963
3031
|
modelDef.name,
|
|
2964
3032
|
modelDef.base
|
|
2965
3033
|
);
|
|
2966
3034
|
}
|
|
2967
3035
|
if (modelDef.tableName && typeof modelDef.tableName !== "string") {
|
|
2968
3036
|
throw new InvalidArgumentError(
|
|
2969
|
-
'
|
|
3037
|
+
'Option "tableName" of the model %v must be a String, but %v was given.',
|
|
2970
3038
|
modelDef.name,
|
|
2971
3039
|
modelDef.tableName
|
|
2972
3040
|
);
|
|
@@ -2974,7 +3042,7 @@ var init_model_definition_validator = __esm({
|
|
|
2974
3042
|
if (modelDef.properties) {
|
|
2975
3043
|
if (typeof modelDef.properties !== "object" || Array.isArray(modelDef.properties)) {
|
|
2976
3044
|
throw new InvalidArgumentError(
|
|
2977
|
-
'
|
|
3045
|
+
'Option "properties" of the model %v must be an Object, but %v was given.',
|
|
2978
3046
|
modelDef.name,
|
|
2979
3047
|
modelDef.properties
|
|
2980
3048
|
);
|
|
@@ -2987,7 +3055,7 @@ var init_model_definition_validator = __esm({
|
|
|
2987
3055
|
if (modelDef.relations) {
|
|
2988
3056
|
if (typeof modelDef.relations !== "object" || Array.isArray(modelDef.relations)) {
|
|
2989
3057
|
throw new InvalidArgumentError(
|
|
2990
|
-
'
|
|
3058
|
+
'Option "relations" of the model %v must be an Object, but %v was given.',
|
|
2991
3059
|
modelDef.name,
|
|
2992
3060
|
modelDef.relations
|
|
2993
3061
|
);
|
|
@@ -3015,55 +3083,6 @@ var init_model = __esm({
|
|
|
3015
3083
|
}
|
|
3016
3084
|
});
|
|
3017
3085
|
|
|
3018
|
-
// src/definition/datasource/datasource-definition-validator.js
|
|
3019
|
-
var import_js_service14, DatasourceDefinitionValidator;
|
|
3020
|
-
var init_datasource_definition_validator = __esm({
|
|
3021
|
-
"src/definition/datasource/datasource-definition-validator.js"() {
|
|
3022
|
-
"use strict";
|
|
3023
|
-
import_js_service14 = require("@e22m4u/js-service");
|
|
3024
|
-
init_errors();
|
|
3025
|
-
DatasourceDefinitionValidator = class extends import_js_service14.Service {
|
|
3026
|
-
static {
|
|
3027
|
-
__name(this, "DatasourceDefinitionValidator");
|
|
3028
|
-
}
|
|
3029
|
-
/**
|
|
3030
|
-
* Validate.
|
|
3031
|
-
*
|
|
3032
|
-
* @param {object} datasourceDef
|
|
3033
|
-
*/
|
|
3034
|
-
validate(datasourceDef) {
|
|
3035
|
-
if (!datasourceDef || typeof datasourceDef !== "object") {
|
|
3036
|
-
throw new InvalidArgumentError(
|
|
3037
|
-
"The datasource definition should be an Object, but %v was given.",
|
|
3038
|
-
datasourceDef
|
|
3039
|
-
);
|
|
3040
|
-
}
|
|
3041
|
-
if (!datasourceDef.name || typeof datasourceDef.name !== "string") {
|
|
3042
|
-
throw new InvalidArgumentError(
|
|
3043
|
-
'The datasource definition requires the option "name" as a non-empty String, but %v was given.',
|
|
3044
|
-
datasourceDef.name
|
|
3045
|
-
);
|
|
3046
|
-
}
|
|
3047
|
-
if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string") {
|
|
3048
|
-
throw new InvalidArgumentError(
|
|
3049
|
-
'The datasource %v requires the option "adapter" as a non-empty String, but %v was given.',
|
|
3050
|
-
datasourceDef.name,
|
|
3051
|
-
datasourceDef.adapter
|
|
3052
|
-
);
|
|
3053
|
-
}
|
|
3054
|
-
}
|
|
3055
|
-
};
|
|
3056
|
-
}
|
|
3057
|
-
});
|
|
3058
|
-
|
|
3059
|
-
// src/definition/datasource/index.js
|
|
3060
|
-
var init_datasource = __esm({
|
|
3061
|
-
"src/definition/datasource/index.js"() {
|
|
3062
|
-
"use strict";
|
|
3063
|
-
init_datasource_definition_validator();
|
|
3064
|
-
}
|
|
3065
|
-
});
|
|
3066
|
-
|
|
3067
3086
|
// src/definition/index.js
|
|
3068
3087
|
var init_definition = __esm({
|
|
3069
3088
|
"src/definition/index.js"() {
|
|
@@ -3096,45 +3115,64 @@ var init_fields_clause_tool = __esm({
|
|
|
3096
3115
|
* @returns {object|object[]}
|
|
3097
3116
|
*/
|
|
3098
3117
|
filter(input, modelName, clause) {
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3118
|
+
if (!input || typeof input !== "object") {
|
|
3119
|
+
throw new InvalidArgumentError(
|
|
3120
|
+
'Parameter "input" must be an Object or an Array of Object, but %v was given.',
|
|
3121
|
+
input
|
|
3122
|
+
);
|
|
3123
|
+
}
|
|
3124
|
+
const isArrayInput = Array.isArray(input);
|
|
3125
|
+
if (isArrayInput) {
|
|
3126
|
+
input.forEach((entity, index) => {
|
|
3127
|
+
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
3128
|
+
throw new InvalidArgumentError(
|
|
3129
|
+
'Element %d of the parameter "input" must be an Object, but %v was given.',
|
|
3130
|
+
index,
|
|
3131
|
+
entity
|
|
3132
|
+
);
|
|
3133
|
+
}
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3109
3136
|
if (!modelName || typeof modelName !== "string") {
|
|
3110
3137
|
throw new InvalidArgumentError(
|
|
3111
|
-
"
|
|
3138
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
3112
3139
|
modelName
|
|
3113
3140
|
);
|
|
3114
3141
|
}
|
|
3115
3142
|
if (clause == null) {
|
|
3116
3143
|
return input;
|
|
3117
3144
|
}
|
|
3118
|
-
const
|
|
3119
|
-
if (!
|
|
3120
|
-
|
|
3145
|
+
const isArrayClause = Array.isArray(clause);
|
|
3146
|
+
if (!clause || typeof clause !== "string" && !isArrayClause) {
|
|
3147
|
+
throw new InvalidArgumentError(
|
|
3148
|
+
'Option "fields" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3149
|
+
clause
|
|
3150
|
+
);
|
|
3121
3151
|
}
|
|
3122
|
-
|
|
3123
|
-
if (!
|
|
3124
|
-
|
|
3125
|
-
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3126
|
-
field
|
|
3127
|
-
);
|
|
3152
|
+
if (isArrayClause) {
|
|
3153
|
+
if (!clause.length) {
|
|
3154
|
+
return input;
|
|
3128
3155
|
}
|
|
3129
|
-
|
|
3156
|
+
clause.forEach((field, index) => {
|
|
3157
|
+
if (!field || typeof field !== "string") {
|
|
3158
|
+
throw new InvalidArgumentError(
|
|
3159
|
+
'Element %d of the option "fields" must be a non-empty String, but %v was given.',
|
|
3160
|
+
index,
|
|
3161
|
+
field
|
|
3162
|
+
);
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
const fields = isArrayClause ? clause.slice() : [clause];
|
|
3130
3167
|
const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
|
|
3131
3168
|
modelName
|
|
3132
3169
|
);
|
|
3133
3170
|
if (fields.indexOf(pkPropName) === -1) {
|
|
3134
3171
|
fields.push(pkPropName);
|
|
3135
3172
|
}
|
|
3173
|
+
let entities = isArrayInput ? input : [input];
|
|
3136
3174
|
entities = entities.map((entity) => selectObjectKeys(entity, fields));
|
|
3137
|
-
return
|
|
3175
|
+
return isArrayInput ? entities : entities[0];
|
|
3138
3176
|
}
|
|
3139
3177
|
/**
|
|
3140
3178
|
* Validate fields clause.
|
|
@@ -3145,18 +3183,24 @@ var init_fields_clause_tool = __esm({
|
|
|
3145
3183
|
if (clause == null) {
|
|
3146
3184
|
return;
|
|
3147
3185
|
}
|
|
3148
|
-
const
|
|
3149
|
-
if (!
|
|
3150
|
-
|
|
3186
|
+
const isArray = Array.isArray(clause);
|
|
3187
|
+
if (!clause || typeof clause !== "string" && !isArray) {
|
|
3188
|
+
throw new InvalidArgumentError(
|
|
3189
|
+
'Option "fields" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3190
|
+
clause
|
|
3191
|
+
);
|
|
3192
|
+
}
|
|
3193
|
+
if (isArray && clause.length > 0) {
|
|
3194
|
+
clause.forEach((field, index) => {
|
|
3195
|
+
if (!field || typeof field !== "string") {
|
|
3196
|
+
throw new InvalidArgumentError(
|
|
3197
|
+
'Element %d of the option "fields" must be a non-empty String, but %v was given.',
|
|
3198
|
+
index,
|
|
3199
|
+
field
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
});
|
|
3151
3203
|
}
|
|
3152
|
-
fields.forEach((field) => {
|
|
3153
|
-
if (!field || typeof field !== "string") {
|
|
3154
|
-
throw new InvalidArgumentError(
|
|
3155
|
-
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3156
|
-
field
|
|
3157
|
-
);
|
|
3158
|
-
}
|
|
3159
|
-
});
|
|
3160
3204
|
}
|
|
3161
3205
|
/**
|
|
3162
3206
|
* Normalize fields clause.
|
|
@@ -3168,19 +3212,28 @@ var init_fields_clause_tool = __esm({
|
|
|
3168
3212
|
if (clause == null) {
|
|
3169
3213
|
return;
|
|
3170
3214
|
}
|
|
3171
|
-
const
|
|
3172
|
-
if (!
|
|
3173
|
-
|
|
3215
|
+
const isArray = Array.isArray(clause);
|
|
3216
|
+
if (!clause || typeof clause !== "string" && !isArray) {
|
|
3217
|
+
throw new InvalidArgumentError(
|
|
3218
|
+
'Option "fields" must be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3219
|
+
clause
|
|
3220
|
+
);
|
|
3174
3221
|
}
|
|
3175
|
-
|
|
3176
|
-
if (!
|
|
3177
|
-
|
|
3178
|
-
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
|
|
3179
|
-
field
|
|
3180
|
-
);
|
|
3222
|
+
if (isArray) {
|
|
3223
|
+
if (!clause.length) {
|
|
3224
|
+
return;
|
|
3181
3225
|
}
|
|
3182
|
-
|
|
3183
|
-
|
|
3226
|
+
clause.forEach((field, index) => {
|
|
3227
|
+
if (!field || typeof field !== "string") {
|
|
3228
|
+
throw new InvalidArgumentError(
|
|
3229
|
+
'Element %d of the option "fields" must be a non-empty String, but %v was given.',
|
|
3230
|
+
index,
|
|
3231
|
+
field
|
|
3232
|
+
);
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3236
|
+
return isArray ? clause : [clause];
|
|
3184
3237
|
}
|
|
3185
3238
|
};
|
|
3186
3239
|
}
|
|
@@ -3207,7 +3260,7 @@ var init_inclusion_decorator = __esm({
|
|
|
3207
3260
|
decorate(adapter) {
|
|
3208
3261
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3209
3262
|
throw new InvalidArgumentError(
|
|
3210
|
-
"
|
|
3263
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3211
3264
|
adapter
|
|
3212
3265
|
);
|
|
3213
3266
|
}
|
|
@@ -3304,7 +3357,7 @@ var init_default_values_decorator = __esm({
|
|
|
3304
3357
|
decorate(adapter) {
|
|
3305
3358
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3306
3359
|
throw new InvalidArgumentError(
|
|
3307
|
-
"
|
|
3360
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3308
3361
|
adapter
|
|
3309
3362
|
);
|
|
3310
3363
|
}
|
|
@@ -3371,7 +3424,7 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
3371
3424
|
decorate(adapter) {
|
|
3372
3425
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3373
3426
|
throw new InvalidArgumentError(
|
|
3374
|
-
"
|
|
3427
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3375
3428
|
adapter
|
|
3376
3429
|
);
|
|
3377
3430
|
}
|
|
@@ -3428,7 +3481,7 @@ var init_fields_filtering_decorator = __esm({
|
|
|
3428
3481
|
decorate(adapter) {
|
|
3429
3482
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3430
3483
|
throw new InvalidArgumentError(
|
|
3431
|
-
"
|
|
3484
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3432
3485
|
adapter
|
|
3433
3486
|
);
|
|
3434
3487
|
}
|
|
@@ -3519,7 +3572,7 @@ var init_required_property_decorator = __esm({
|
|
|
3519
3572
|
decorate(adapter) {
|
|
3520
3573
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3521
3574
|
throw new InvalidArgumentError(
|
|
3522
|
-
"
|
|
3575
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3523
3576
|
adapter
|
|
3524
3577
|
);
|
|
3525
3578
|
}
|
|
@@ -3575,7 +3628,7 @@ var init_property_uniqueness_decorator = __esm({
|
|
|
3575
3628
|
decorate(adapter) {
|
|
3576
3629
|
if (!adapter || !(adapter instanceof Adapter)) {
|
|
3577
3630
|
throw new InvalidArgumentError(
|
|
3578
|
-
"
|
|
3631
|
+
'Parameter "adapter" must be an instance of Adapter, but %v was given.',
|
|
3579
3632
|
adapter
|
|
3580
3633
|
);
|
|
3581
3634
|
}
|
|
@@ -3909,7 +3962,7 @@ var init_memory_adapter = __esm({
|
|
|
3909
3962
|
const propType = modelUtils.getDataTypeByPropertyName(modelName, propName);
|
|
3910
3963
|
if (propType !== DataType.ANY && propType !== DataType.NUMBER) {
|
|
3911
3964
|
throw new InvalidArgumentError(
|
|
3912
|
-
"
|
|
3965
|
+
"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.",
|
|
3913
3966
|
propName,
|
|
3914
3967
|
modelName,
|
|
3915
3968
|
capitalize(propType),
|
|
@@ -3964,7 +4017,7 @@ var init_memory_adapter = __esm({
|
|
|
3964
4017
|
const table = this._getTableOrCreate(modelName);
|
|
3965
4018
|
if (table.has(idValue)) {
|
|
3966
4019
|
throw new InvalidArgumentError(
|
|
3967
|
-
"
|
|
4020
|
+
"Value %v of the primary key %v already exists in the model %v.",
|
|
3968
4021
|
idValue,
|
|
3969
4022
|
pkPropName,
|
|
3970
4023
|
modelName
|
|
@@ -3998,7 +4051,7 @@ var init_memory_adapter = __esm({
|
|
|
3998
4051
|
);
|
|
3999
4052
|
if (!isExists) {
|
|
4000
4053
|
throw new InvalidArgumentError(
|
|
4001
|
-
"
|
|
4054
|
+
"Value %v of the primary key %v does not exist in the model %v.",
|
|
4002
4055
|
id,
|
|
4003
4056
|
pkPropName,
|
|
4004
4057
|
modelName
|
|
@@ -4101,7 +4154,7 @@ var init_memory_adapter = __esm({
|
|
|
4101
4154
|
);
|
|
4102
4155
|
if (existingTableData == null) {
|
|
4103
4156
|
throw new InvalidArgumentError(
|
|
4104
|
-
"
|
|
4157
|
+
"Value %v of the primary key %v does not exist in the model %v.",
|
|
4105
4158
|
id,
|
|
4106
4159
|
pkPropName,
|
|
4107
4160
|
modelName
|
|
@@ -4174,7 +4227,7 @@ var init_memory_adapter = __esm({
|
|
|
4174
4227
|
);
|
|
4175
4228
|
if (!tableData) {
|
|
4176
4229
|
throw new InvalidArgumentError(
|
|
4177
|
-
"
|
|
4230
|
+
"Value %v of the primary key %v does not exist in the model %v.",
|
|
4178
4231
|
id,
|
|
4179
4232
|
pkPropName,
|
|
4180
4233
|
modelName
|
|
@@ -4311,7 +4364,7 @@ var init_adapter_loader = __esm({
|
|
|
4311
4364
|
async loadByName(adapterName, settings = void 0) {
|
|
4312
4365
|
if (!adapterName || typeof adapterName !== "string") {
|
|
4313
4366
|
throw new InvalidArgumentError(
|
|
4314
|
-
"
|
|
4367
|
+
"Adapter name must be a non-empty String, but %v was given.",
|
|
4315
4368
|
adapterName
|
|
4316
4369
|
);
|
|
4317
4370
|
}
|
|
@@ -4329,10 +4382,7 @@ var init_adapter_loader = __esm({
|
|
|
4329
4382
|
}
|
|
4330
4383
|
}
|
|
4331
4384
|
if (!adapterCtor) {
|
|
4332
|
-
throw new InvalidArgumentError(
|
|
4333
|
-
"The adapter %v is not found.",
|
|
4334
|
-
adapterName
|
|
4335
|
-
);
|
|
4385
|
+
throw new InvalidArgumentError("Adapter %v is not found.", adapterName);
|
|
4336
4386
|
}
|
|
4337
4387
|
return new adapterCtor(this.container, settings);
|
|
4338
4388
|
}
|
|
@@ -4449,7 +4499,7 @@ var init_repository = __esm({
|
|
|
4449
4499
|
const datasourceName = modelDef.datasource;
|
|
4450
4500
|
if (!datasourceName) {
|
|
4451
4501
|
throw new InvalidArgumentError(
|
|
4452
|
-
"
|
|
4502
|
+
"Model %v does not have a specified datasource.",
|
|
4453
4503
|
modelName
|
|
4454
4504
|
);
|
|
4455
4505
|
}
|
|
@@ -4605,7 +4655,6 @@ var init_repository_registry = __esm({
|
|
|
4605
4655
|
"use strict";
|
|
4606
4656
|
import_js_service26 = require("@e22m4u/js-service");
|
|
4607
4657
|
init_repository();
|
|
4608
|
-
init_utils();
|
|
4609
4658
|
init_errors();
|
|
4610
4659
|
RepositoryRegistry = class extends import_js_service26.Service {
|
|
4611
4660
|
static {
|
|
@@ -4632,7 +4681,7 @@ var init_repository_registry = __esm({
|
|
|
4632
4681
|
setRepositoryCtor(ctor) {
|
|
4633
4682
|
if (!ctor || typeof ctor !== "function" || !(ctor.prototype instanceof Repository)) {
|
|
4634
4683
|
throw new InvalidArgumentError(
|
|
4635
|
-
"
|
|
4684
|
+
'Parameter "ctor" must inherit from Repository class, but %v was given.',
|
|
4636
4685
|
ctor
|
|
4637
4686
|
);
|
|
4638
4687
|
}
|
|
@@ -4645,13 +4694,12 @@ var init_repository_registry = __esm({
|
|
|
4645
4694
|
* @returns {Repository}
|
|
4646
4695
|
*/
|
|
4647
4696
|
getRepository(modelName) {
|
|
4648
|
-
|
|
4649
|
-
let repository = this._repositories[modelKey];
|
|
4697
|
+
let repository = this._repositories[modelName];
|
|
4650
4698
|
if (repository) {
|
|
4651
4699
|
return repository;
|
|
4652
4700
|
}
|
|
4653
4701
|
repository = new this._repositoryCtor(this.container, modelName);
|
|
4654
|
-
this._repositories[
|
|
4702
|
+
this._repositories[modelName] = repository;
|
|
4655
4703
|
return repository;
|
|
4656
4704
|
}
|
|
4657
4705
|
};
|
|
@@ -4695,37 +4743,37 @@ var init_has_one_resolver = __esm({
|
|
|
4695
4743
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
|
|
4696
4744
|
if (!entities || !Array.isArray(entities)) {
|
|
4697
4745
|
throw new InvalidArgumentError(
|
|
4698
|
-
'
|
|
4746
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4699
4747
|
entities
|
|
4700
4748
|
);
|
|
4701
4749
|
}
|
|
4702
4750
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4703
4751
|
throw new InvalidArgumentError(
|
|
4704
|
-
'
|
|
4752
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4705
4753
|
sourceName
|
|
4706
4754
|
);
|
|
4707
4755
|
}
|
|
4708
4756
|
if (!targetName || typeof targetName !== "string") {
|
|
4709
4757
|
throw new InvalidArgumentError(
|
|
4710
|
-
'
|
|
4758
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4711
4759
|
targetName
|
|
4712
4760
|
);
|
|
4713
4761
|
}
|
|
4714
4762
|
if (!relationName || typeof relationName !== "string") {
|
|
4715
4763
|
throw new InvalidArgumentError(
|
|
4716
|
-
'
|
|
4764
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4717
4765
|
relationName
|
|
4718
4766
|
);
|
|
4719
4767
|
}
|
|
4720
4768
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
4721
4769
|
throw new InvalidArgumentError(
|
|
4722
|
-
'
|
|
4770
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
4723
4771
|
foreignKey
|
|
4724
4772
|
);
|
|
4725
4773
|
}
|
|
4726
4774
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4727
4775
|
throw new InvalidArgumentError(
|
|
4728
|
-
'
|
|
4776
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
4729
4777
|
scope
|
|
4730
4778
|
);
|
|
4731
4779
|
}
|
|
@@ -4736,7 +4784,7 @@ var init_has_one_resolver = __esm({
|
|
|
4736
4784
|
entities.forEach((entity) => {
|
|
4737
4785
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
4738
4786
|
throw new InvalidArgumentError(
|
|
4739
|
-
'
|
|
4787
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4740
4788
|
entity
|
|
4741
4789
|
);
|
|
4742
4790
|
}
|
|
@@ -4785,43 +4833,43 @@ var init_has_one_resolver = __esm({
|
|
|
4785
4833
|
async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
|
|
4786
4834
|
if (!entities || !Array.isArray(entities)) {
|
|
4787
4835
|
throw new InvalidArgumentError(
|
|
4788
|
-
'
|
|
4836
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4789
4837
|
entities
|
|
4790
4838
|
);
|
|
4791
4839
|
}
|
|
4792
4840
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4793
4841
|
throw new InvalidArgumentError(
|
|
4794
|
-
'
|
|
4842
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4795
4843
|
sourceName
|
|
4796
4844
|
);
|
|
4797
4845
|
}
|
|
4798
4846
|
if (!targetName || typeof targetName !== "string") {
|
|
4799
4847
|
throw new InvalidArgumentError(
|
|
4800
|
-
'
|
|
4848
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4801
4849
|
targetName
|
|
4802
4850
|
);
|
|
4803
4851
|
}
|
|
4804
4852
|
if (!relationName || typeof relationName !== "string") {
|
|
4805
4853
|
throw new InvalidArgumentError(
|
|
4806
|
-
'
|
|
4854
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4807
4855
|
relationName
|
|
4808
4856
|
);
|
|
4809
4857
|
}
|
|
4810
4858
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
4811
4859
|
throw new InvalidArgumentError(
|
|
4812
|
-
'
|
|
4860
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
4813
4861
|
foreignKey
|
|
4814
4862
|
);
|
|
4815
4863
|
}
|
|
4816
4864
|
if (!discriminator || typeof discriminator !== "string") {
|
|
4817
4865
|
throw new InvalidArgumentError(
|
|
4818
|
-
'
|
|
4866
|
+
'Parameter "discriminator" must be a non-empty String, but %v was given.',
|
|
4819
4867
|
discriminator
|
|
4820
4868
|
);
|
|
4821
4869
|
}
|
|
4822
4870
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4823
4871
|
throw new InvalidArgumentError(
|
|
4824
|
-
'
|
|
4872
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
4825
4873
|
scope
|
|
4826
4874
|
);
|
|
4827
4875
|
}
|
|
@@ -4832,7 +4880,7 @@ var init_has_one_resolver = __esm({
|
|
|
4832
4880
|
entities.forEach((entity) => {
|
|
4833
4881
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
4834
4882
|
throw new InvalidArgumentError(
|
|
4835
|
-
'
|
|
4883
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4836
4884
|
entity
|
|
4837
4885
|
);
|
|
4838
4886
|
}
|
|
@@ -4883,37 +4931,37 @@ var init_has_one_resolver = __esm({
|
|
|
4883
4931
|
async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
|
|
4884
4932
|
if (!entities || !Array.isArray(entities)) {
|
|
4885
4933
|
throw new InvalidArgumentError(
|
|
4886
|
-
'
|
|
4934
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4887
4935
|
entities
|
|
4888
4936
|
);
|
|
4889
4937
|
}
|
|
4890
4938
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4891
4939
|
throw new InvalidArgumentError(
|
|
4892
|
-
'
|
|
4940
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4893
4941
|
sourceName
|
|
4894
4942
|
);
|
|
4895
4943
|
}
|
|
4896
4944
|
if (!targetName || typeof targetName !== "string") {
|
|
4897
4945
|
throw new InvalidArgumentError(
|
|
4898
|
-
'
|
|
4946
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4899
4947
|
targetName
|
|
4900
4948
|
);
|
|
4901
4949
|
}
|
|
4902
4950
|
if (!relationName || typeof relationName !== "string") {
|
|
4903
4951
|
throw new InvalidArgumentError(
|
|
4904
|
-
'
|
|
4952
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
4905
4953
|
relationName
|
|
4906
4954
|
);
|
|
4907
4955
|
}
|
|
4908
4956
|
if (!targetRelationName || typeof targetRelationName !== "string") {
|
|
4909
4957
|
throw new InvalidArgumentError(
|
|
4910
|
-
'
|
|
4958
|
+
'Parameter "targetRelationName" must be a non-empty String, but %v was given.',
|
|
4911
4959
|
targetRelationName
|
|
4912
4960
|
);
|
|
4913
4961
|
}
|
|
4914
4962
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
4915
4963
|
throw new InvalidArgumentError(
|
|
4916
|
-
'
|
|
4964
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
4917
4965
|
scope
|
|
4918
4966
|
);
|
|
4919
4967
|
}
|
|
@@ -4922,7 +4970,7 @@ var init_has_one_resolver = __esm({
|
|
|
4922
4970
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
4923
4971
|
if (targetRelationDef.type !== RelationType.BELONGS_TO) {
|
|
4924
4972
|
throw new InvalidArgumentError(
|
|
4925
|
-
'
|
|
4973
|
+
'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.',
|
|
4926
4974
|
relationName,
|
|
4927
4975
|
sourceName,
|
|
4928
4976
|
targetRelationName,
|
|
@@ -4931,7 +4979,7 @@ var init_has_one_resolver = __esm({
|
|
|
4931
4979
|
}
|
|
4932
4980
|
if (!targetRelationDef.polymorphic) {
|
|
4933
4981
|
throw new InvalidArgumentError(
|
|
4934
|
-
'
|
|
4982
|
+
'Relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic too.',
|
|
4935
4983
|
relationName,
|
|
4936
4984
|
sourceName,
|
|
4937
4985
|
targetRelationName
|
|
@@ -4981,37 +5029,37 @@ var init_has_many_resolver = __esm({
|
|
|
4981
5029
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
|
|
4982
5030
|
if (!entities || !Array.isArray(entities)) {
|
|
4983
5031
|
throw new InvalidArgumentError(
|
|
4984
|
-
'
|
|
5032
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
4985
5033
|
entities
|
|
4986
5034
|
);
|
|
4987
5035
|
}
|
|
4988
5036
|
if (!sourceName || typeof sourceName !== "string") {
|
|
4989
5037
|
throw new InvalidArgumentError(
|
|
4990
|
-
'
|
|
5038
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
4991
5039
|
sourceName
|
|
4992
5040
|
);
|
|
4993
5041
|
}
|
|
4994
5042
|
if (!targetName || typeof targetName !== "string") {
|
|
4995
5043
|
throw new InvalidArgumentError(
|
|
4996
|
-
'
|
|
5044
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
4997
5045
|
targetName
|
|
4998
5046
|
);
|
|
4999
5047
|
}
|
|
5000
5048
|
if (!relationName || typeof relationName !== "string") {
|
|
5001
5049
|
throw new InvalidArgumentError(
|
|
5002
|
-
'
|
|
5050
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5003
5051
|
relationName
|
|
5004
5052
|
);
|
|
5005
5053
|
}
|
|
5006
5054
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
5007
5055
|
throw new InvalidArgumentError(
|
|
5008
|
-
'
|
|
5056
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
5009
5057
|
foreignKey
|
|
5010
5058
|
);
|
|
5011
5059
|
}
|
|
5012
5060
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5013
5061
|
throw new InvalidArgumentError(
|
|
5014
|
-
'
|
|
5062
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5015
5063
|
scope
|
|
5016
5064
|
);
|
|
5017
5065
|
}
|
|
@@ -5022,7 +5070,7 @@ var init_has_many_resolver = __esm({
|
|
|
5022
5070
|
entities.forEach((entity) => {
|
|
5023
5071
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5024
5072
|
throw new InvalidArgumentError(
|
|
5025
|
-
'
|
|
5073
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5026
5074
|
entity
|
|
5027
5075
|
);
|
|
5028
5076
|
}
|
|
@@ -5072,43 +5120,43 @@ var init_has_many_resolver = __esm({
|
|
|
5072
5120
|
async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
|
|
5073
5121
|
if (!entities || !Array.isArray(entities)) {
|
|
5074
5122
|
throw new InvalidArgumentError(
|
|
5075
|
-
'
|
|
5123
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5076
5124
|
entities
|
|
5077
5125
|
);
|
|
5078
5126
|
}
|
|
5079
5127
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5080
5128
|
throw new InvalidArgumentError(
|
|
5081
|
-
'
|
|
5129
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5082
5130
|
sourceName
|
|
5083
5131
|
);
|
|
5084
5132
|
}
|
|
5085
5133
|
if (!targetName || typeof targetName !== "string") {
|
|
5086
5134
|
throw new InvalidArgumentError(
|
|
5087
|
-
'
|
|
5135
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5088
5136
|
targetName
|
|
5089
5137
|
);
|
|
5090
5138
|
}
|
|
5091
5139
|
if (!relationName || typeof relationName !== "string") {
|
|
5092
5140
|
throw new InvalidArgumentError(
|
|
5093
|
-
'
|
|
5141
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5094
5142
|
relationName
|
|
5095
5143
|
);
|
|
5096
5144
|
}
|
|
5097
5145
|
if (!foreignKey || typeof foreignKey !== "string") {
|
|
5098
5146
|
throw new InvalidArgumentError(
|
|
5099
|
-
'
|
|
5147
|
+
'Parameter "foreignKey" must be a non-empty String, but %v was given.',
|
|
5100
5148
|
foreignKey
|
|
5101
5149
|
);
|
|
5102
5150
|
}
|
|
5103
5151
|
if (!discriminator || typeof discriminator !== "string") {
|
|
5104
5152
|
throw new InvalidArgumentError(
|
|
5105
|
-
'
|
|
5153
|
+
'Parameter "discriminator" must be a non-empty String, but %v was given.',
|
|
5106
5154
|
discriminator
|
|
5107
5155
|
);
|
|
5108
5156
|
}
|
|
5109
5157
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5110
5158
|
throw new InvalidArgumentError(
|
|
5111
|
-
'
|
|
5159
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5112
5160
|
scope
|
|
5113
5161
|
);
|
|
5114
5162
|
}
|
|
@@ -5119,7 +5167,7 @@ var init_has_many_resolver = __esm({
|
|
|
5119
5167
|
entities.forEach((entity) => {
|
|
5120
5168
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5121
5169
|
throw new InvalidArgumentError(
|
|
5122
|
-
'
|
|
5170
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5123
5171
|
entity
|
|
5124
5172
|
);
|
|
5125
5173
|
}
|
|
@@ -5171,37 +5219,37 @@ var init_has_many_resolver = __esm({
|
|
|
5171
5219
|
async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
|
|
5172
5220
|
if (!entities || !Array.isArray(entities)) {
|
|
5173
5221
|
throw new InvalidArgumentError(
|
|
5174
|
-
'
|
|
5222
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5175
5223
|
entities
|
|
5176
5224
|
);
|
|
5177
5225
|
}
|
|
5178
5226
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5179
5227
|
throw new InvalidArgumentError(
|
|
5180
|
-
'
|
|
5228
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5181
5229
|
sourceName
|
|
5182
5230
|
);
|
|
5183
5231
|
}
|
|
5184
5232
|
if (!targetName || typeof targetName !== "string") {
|
|
5185
5233
|
throw new InvalidArgumentError(
|
|
5186
|
-
'
|
|
5234
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5187
5235
|
targetName
|
|
5188
5236
|
);
|
|
5189
5237
|
}
|
|
5190
5238
|
if (!relationName || typeof relationName !== "string") {
|
|
5191
5239
|
throw new InvalidArgumentError(
|
|
5192
|
-
'
|
|
5240
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5193
5241
|
relationName
|
|
5194
5242
|
);
|
|
5195
5243
|
}
|
|
5196
5244
|
if (!targetRelationName || typeof targetRelationName !== "string") {
|
|
5197
5245
|
throw new InvalidArgumentError(
|
|
5198
|
-
'
|
|
5246
|
+
'Parameter "targetRelationName" must be a non-empty String, but %v was given.',
|
|
5199
5247
|
targetRelationName
|
|
5200
5248
|
);
|
|
5201
5249
|
}
|
|
5202
5250
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5203
5251
|
throw new InvalidArgumentError(
|
|
5204
|
-
'
|
|
5252
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5205
5253
|
scope
|
|
5206
5254
|
);
|
|
5207
5255
|
}
|
|
@@ -5210,7 +5258,7 @@ var init_has_many_resolver = __esm({
|
|
|
5210
5258
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
5211
5259
|
if (targetRelationDef.type !== RelationType.BELONGS_TO) {
|
|
5212
5260
|
throw new InvalidArgumentError(
|
|
5213
|
-
'
|
|
5261
|
+
'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.',
|
|
5214
5262
|
relationName,
|
|
5215
5263
|
sourceName,
|
|
5216
5264
|
targetRelationName,
|
|
@@ -5219,7 +5267,7 @@ var init_has_many_resolver = __esm({
|
|
|
5219
5267
|
}
|
|
5220
5268
|
if (!targetRelationDef.polymorphic) {
|
|
5221
5269
|
throw new InvalidArgumentError(
|
|
5222
|
-
'
|
|
5270
|
+
'Relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic too.',
|
|
5223
5271
|
relationName,
|
|
5224
5272
|
sourceName,
|
|
5225
5273
|
targetRelationName
|
|
@@ -5269,37 +5317,37 @@ var init_belongs_to_resolver = __esm({
|
|
|
5269
5317
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
|
|
5270
5318
|
if (!entities || !Array.isArray(entities)) {
|
|
5271
5319
|
throw new InvalidArgumentError(
|
|
5272
|
-
'
|
|
5320
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5273
5321
|
entities
|
|
5274
5322
|
);
|
|
5275
5323
|
}
|
|
5276
5324
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5277
5325
|
throw new InvalidArgumentError(
|
|
5278
|
-
'
|
|
5326
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5279
5327
|
sourceName
|
|
5280
5328
|
);
|
|
5281
5329
|
}
|
|
5282
5330
|
if (!targetName || typeof targetName !== "string") {
|
|
5283
5331
|
throw new InvalidArgumentError(
|
|
5284
|
-
'
|
|
5332
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5285
5333
|
targetName
|
|
5286
5334
|
);
|
|
5287
5335
|
}
|
|
5288
5336
|
if (!relationName || typeof relationName !== "string") {
|
|
5289
5337
|
throw new InvalidArgumentError(
|
|
5290
|
-
'
|
|
5338
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5291
5339
|
relationName
|
|
5292
5340
|
);
|
|
5293
5341
|
}
|
|
5294
5342
|
if (foreignKey && typeof foreignKey !== "string") {
|
|
5295
5343
|
throw new InvalidArgumentError(
|
|
5296
|
-
'
|
|
5344
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
5297
5345
|
foreignKey
|
|
5298
5346
|
);
|
|
5299
5347
|
}
|
|
5300
5348
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5301
5349
|
throw new InvalidArgumentError(
|
|
5302
|
-
'
|
|
5350
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5303
5351
|
scope
|
|
5304
5352
|
);
|
|
5305
5353
|
}
|
|
@@ -5309,7 +5357,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
5309
5357
|
const targetIds = entities.reduce((acc, entity) => {
|
|
5310
5358
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5311
5359
|
throw new InvalidArgumentError(
|
|
5312
|
-
'
|
|
5360
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5313
5361
|
entity
|
|
5314
5362
|
);
|
|
5315
5363
|
}
|
|
@@ -5352,37 +5400,37 @@ var init_belongs_to_resolver = __esm({
|
|
|
5352
5400
|
async includePolymorphicTo(entities, sourceName, relationName, foreignKey = void 0, discriminator = void 0, scope = void 0) {
|
|
5353
5401
|
if (!entities || !Array.isArray(entities)) {
|
|
5354
5402
|
throw new InvalidArgumentError(
|
|
5355
|
-
'
|
|
5403
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5356
5404
|
entities
|
|
5357
5405
|
);
|
|
5358
5406
|
}
|
|
5359
5407
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5360
5408
|
throw new InvalidArgumentError(
|
|
5361
|
-
'
|
|
5409
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5362
5410
|
sourceName
|
|
5363
5411
|
);
|
|
5364
5412
|
}
|
|
5365
5413
|
if (!relationName || typeof relationName !== "string") {
|
|
5366
5414
|
throw new InvalidArgumentError(
|
|
5367
|
-
'
|
|
5415
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5368
5416
|
relationName
|
|
5369
5417
|
);
|
|
5370
5418
|
}
|
|
5371
5419
|
if (foreignKey && typeof foreignKey !== "string") {
|
|
5372
5420
|
throw new InvalidArgumentError(
|
|
5373
|
-
'
|
|
5421
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
5374
5422
|
foreignKey
|
|
5375
5423
|
);
|
|
5376
5424
|
}
|
|
5377
5425
|
if (discriminator && typeof discriminator !== "string") {
|
|
5378
5426
|
throw new InvalidArgumentError(
|
|
5379
|
-
'
|
|
5427
|
+
'Parameter "discriminator" must be a String, but %v was given.',
|
|
5380
5428
|
discriminator
|
|
5381
5429
|
);
|
|
5382
5430
|
}
|
|
5383
5431
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5384
5432
|
throw new InvalidArgumentError(
|
|
5385
|
-
'
|
|
5433
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5386
5434
|
scope
|
|
5387
5435
|
);
|
|
5388
5436
|
}
|
|
@@ -5398,7 +5446,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
5398
5446
|
entities.forEach((entity) => {
|
|
5399
5447
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5400
5448
|
throw new InvalidArgumentError(
|
|
5401
|
-
'
|
|
5449
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5402
5450
|
entity
|
|
5403
5451
|
);
|
|
5404
5452
|
}
|
|
@@ -5424,7 +5472,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
5424
5472
|
targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
|
|
5425
5473
|
} catch (error) {
|
|
5426
5474
|
if (error instanceof InvalidArgumentError) {
|
|
5427
|
-
if (error.message === `
|
|
5475
|
+
if (error.message === `Model "${targetName}" is not defined.` || error.message === `Model "${targetName}" does not have a specified datasource.`) {
|
|
5428
5476
|
return;
|
|
5429
5477
|
}
|
|
5430
5478
|
} else {
|
|
@@ -5499,37 +5547,37 @@ var init_references_many_resolver = __esm({
|
|
|
5499
5547
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
|
|
5500
5548
|
if (!entities || !Array.isArray(entities)) {
|
|
5501
5549
|
throw new InvalidArgumentError(
|
|
5502
|
-
'
|
|
5550
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5503
5551
|
entities
|
|
5504
5552
|
);
|
|
5505
5553
|
}
|
|
5506
5554
|
if (!sourceName || typeof sourceName !== "string") {
|
|
5507
5555
|
throw new InvalidArgumentError(
|
|
5508
|
-
'
|
|
5556
|
+
'Parameter "sourceName" must be a non-empty String, but %v was given.',
|
|
5509
5557
|
sourceName
|
|
5510
5558
|
);
|
|
5511
5559
|
}
|
|
5512
5560
|
if (!targetName || typeof targetName !== "string") {
|
|
5513
5561
|
throw new InvalidArgumentError(
|
|
5514
|
-
'
|
|
5562
|
+
'Parameter "targetName" must be a non-empty String, but %v was given.',
|
|
5515
5563
|
targetName
|
|
5516
5564
|
);
|
|
5517
5565
|
}
|
|
5518
5566
|
if (!relationName || typeof relationName !== "string") {
|
|
5519
5567
|
throw new InvalidArgumentError(
|
|
5520
|
-
'
|
|
5568
|
+
'Parameter "relationName" must be a non-empty String, but %v was given.',
|
|
5521
5569
|
relationName
|
|
5522
5570
|
);
|
|
5523
5571
|
}
|
|
5524
5572
|
if (foreignKey && typeof foreignKey !== "string") {
|
|
5525
5573
|
throw new InvalidArgumentError(
|
|
5526
|
-
'
|
|
5574
|
+
'Parameter "foreignKey" must be a String, but %v was given.',
|
|
5527
5575
|
foreignKey
|
|
5528
5576
|
);
|
|
5529
5577
|
}
|
|
5530
5578
|
if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
|
|
5531
5579
|
throw new InvalidArgumentError(
|
|
5532
|
-
'
|
|
5580
|
+
'Parameter "scope" must be an Object, but %v was given.',
|
|
5533
5581
|
scope
|
|
5534
5582
|
);
|
|
5535
5583
|
}
|
|
@@ -5540,7 +5588,7 @@ var init_references_many_resolver = __esm({
|
|
|
5540
5588
|
const targetIds = entities.reduce((acc, entity) => {
|
|
5541
5589
|
if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
|
|
5542
5590
|
throw new InvalidArgumentError(
|
|
5543
|
-
'
|
|
5591
|
+
'Parameter "entities" must be an Array of Object, but %v was given.',
|
|
5544
5592
|
entity
|
|
5545
5593
|
);
|
|
5546
5594
|
}
|
|
@@ -5745,7 +5793,7 @@ var init_include_clause_tool = __esm({
|
|
|
5745
5793
|
break;
|
|
5746
5794
|
default:
|
|
5747
5795
|
throw new InvalidArgumentError(
|
|
5748
|
-
"
|
|
5796
|
+
"Relation type %v does not have an inclusion resolver.",
|
|
5749
5797
|
relDef.type
|
|
5750
5798
|
);
|
|
5751
5799
|
}
|
|
@@ -5779,7 +5827,7 @@ var init_include_clause_tool = __esm({
|
|
|
5779
5827
|
);
|
|
5780
5828
|
if (duplicateNames.length) {
|
|
5781
5829
|
throw new InvalidArgumentError(
|
|
5782
|
-
'
|
|
5830
|
+
'Option "include" has duplicates of %v.',
|
|
5783
5831
|
duplicateNames[0]
|
|
5784
5832
|
);
|
|
5785
5833
|
}
|
|
@@ -5787,7 +5835,7 @@ var init_include_clause_tool = __esm({
|
|
|
5787
5835
|
if ("relation" in clause) {
|
|
5788
5836
|
if (!clause.relation || typeof clause.relation !== "string") {
|
|
5789
5837
|
throw new InvalidArgumentError(
|
|
5790
|
-
'
|
|
5838
|
+
'Option "relation" must be a non-empty String, but %v was given.',
|
|
5791
5839
|
clause.relation
|
|
5792
5840
|
);
|
|
5793
5841
|
}
|
|
@@ -5805,7 +5853,7 @@ var init_include_clause_tool = __esm({
|
|
|
5805
5853
|
}
|
|
5806
5854
|
} else {
|
|
5807
5855
|
throw new InvalidArgumentError(
|
|
5808
|
-
'
|
|
5856
|
+
'Option "include" must have a non-empty String, an Object or an Array, but %v was given.',
|
|
5809
5857
|
clause
|
|
5810
5858
|
);
|
|
5811
5859
|
}
|
|
@@ -5821,7 +5869,7 @@ var init_include_clause_tool = __esm({
|
|
|
5821
5869
|
}
|
|
5822
5870
|
if (typeof clause !== "object" || Array.isArray(clause)) {
|
|
5823
5871
|
throw new InvalidArgumentError(
|
|
5824
|
-
'
|
|
5872
|
+
'Option "scope" must be an Object, but %v was given.',
|
|
5825
5873
|
clause
|
|
5826
5874
|
);
|
|
5827
5875
|
}
|
|
@@ -5867,7 +5915,7 @@ var init_include_clause_tool = __esm({
|
|
|
5867
5915
|
);
|
|
5868
5916
|
if (duplicateNames.length) {
|
|
5869
5917
|
throw new InvalidArgumentError(
|
|
5870
|
-
'
|
|
5918
|
+
'Option "include" has duplicates of %v.',
|
|
5871
5919
|
duplicateNames[0]
|
|
5872
5920
|
);
|
|
5873
5921
|
}
|
|
@@ -5875,7 +5923,7 @@ var init_include_clause_tool = __esm({
|
|
|
5875
5923
|
if ("relation" in clause) {
|
|
5876
5924
|
if (!clause.relation || typeof clause.relation !== "string") {
|
|
5877
5925
|
throw new InvalidArgumentError(
|
|
5878
|
-
'
|
|
5926
|
+
'Option "relation" must be a non-empty String, but %v was given.',
|
|
5879
5927
|
clause.relation
|
|
5880
5928
|
);
|
|
5881
5929
|
}
|
|
@@ -5901,7 +5949,7 @@ var init_include_clause_tool = __esm({
|
|
|
5901
5949
|
}
|
|
5902
5950
|
} else {
|
|
5903
5951
|
throw new InvalidArgumentError(
|
|
5904
|
-
'
|
|
5952
|
+
'Option "include" must have a non-empty String, an Object or an Array, but %v was given.',
|
|
5905
5953
|
clause
|
|
5906
5954
|
);
|
|
5907
5955
|
}
|
|
@@ -5919,7 +5967,7 @@ var init_include_clause_tool = __esm({
|
|
|
5919
5967
|
}
|
|
5920
5968
|
if (typeof clause !== "object" || Array.isArray(clause)) {
|
|
5921
5969
|
throw new InvalidArgumentError(
|
|
5922
|
-
'
|
|
5970
|
+
'Option "scope" must be an Object, but %v was given.',
|
|
5923
5971
|
clause
|
|
5924
5972
|
);
|
|
5925
5973
|
}
|
|
@@ -6014,7 +6062,6 @@ __export(index_exports, {
|
|
|
6014
6062
|
isPlainObject: () => isPlainObject,
|
|
6015
6063
|
isPromise: () => isPromise,
|
|
6016
6064
|
likeToRegexp: () => likeToRegexp,
|
|
6017
|
-
modelNameToModelKey: () => modelNameToModelKey,
|
|
6018
6065
|
selectObjectKeys: () => selectObjectKeys,
|
|
6019
6066
|
singularize: () => singularize,
|
|
6020
6067
|
stringToRegexp: () => stringToRegexp
|
|
@@ -6112,7 +6159,6 @@ init_repository2();
|
|
|
6112
6159
|
isPlainObject,
|
|
6113
6160
|
isPromise,
|
|
6114
6161
|
likeToRegexp,
|
|
6115
|
-
modelNameToModelKey,
|
|
6116
6162
|
selectObjectKeys,
|
|
6117
6163
|
singularize,
|
|
6118
6164
|
stringToRegexp
|