@e22m4u/js-repository 0.8.5 → 0.8.6

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.
Files changed (44) hide show
  1. package/README.md +27 -23
  2. package/dist/cjs/index.cjs +746 -325
  3. package/eslint.config.js +1 -0
  4. package/package.json +14 -13
  5. package/src/adapter/adapter-loader.js +9 -4
  6. package/src/adapter/adapter-registry.js +3 -1
  7. package/src/adapter/builtin/memory-adapter.js +29 -13
  8. package/src/adapter/decorator/data-sanitizing-decorator.js +2 -1
  9. package/src/adapter/decorator/default-values-decorator.js +2 -1
  10. package/src/adapter/decorator/fields-filtering-decorator.js +14 -7
  11. package/src/adapter/decorator/inclusion-decorator.js +14 -7
  12. package/src/adapter/decorator/property-uniqueness-decorator.js +2 -1
  13. package/src/adapter/decorator/required-property-decorator.js +2 -1
  14. package/src/definition/datasource/datasource-definition-validator.js +6 -3
  15. package/src/definition/definition-registry.js +8 -4
  16. package/src/definition/model/model-data-sanitizer.js +4 -2
  17. package/src/definition/model/model-definition-utils.js +68 -26
  18. package/src/definition/model/model-definition-validator.js +10 -5
  19. package/src/definition/model/properties/primary-keys-definition-validator.js +4 -2
  20. package/src/definition/model/properties/properties-definition-validator.js +36 -18
  21. package/src/definition/model/properties/property-uniqueness-validator.js +26 -10
  22. package/src/definition/model/properties/property-uniqueness-validator.spec.js +500 -38
  23. package/src/definition/model/relations/relations-definition-validator.js +70 -33
  24. package/src/filter/fields-clause-tool.js +31 -12
  25. package/src/filter/include-clause-tool.js +38 -15
  26. package/src/filter/operator-clause-tool.js +55 -23
  27. package/src/filter/order-clause-tool.js +36 -13
  28. package/src/filter/slice-clause-tool.js +16 -7
  29. package/src/filter/where-clause-tool.js +24 -10
  30. package/src/relations/belongs-to-resolver.js +44 -20
  31. package/src/relations/has-many-resolver.js +52 -25
  32. package/src/relations/has-one-resolver.js +58 -27
  33. package/src/relations/references-many-resolver.js +24 -11
  34. package/src/repository/repository-registry.js +3 -1
  35. package/src/repository/repository.js +2 -1
  36. package/src/utils/capitalize.js +3 -1
  37. package/src/utils/clone-deep.js +6 -2
  38. package/src/utils/exclude-object-keys.js +2 -1
  39. package/src/utils/get-value-by-path.js +6 -2
  40. package/src/utils/is-deep-equal.js +21 -7
  41. package/src/utils/is-promise.js +6 -2
  42. package/src/utils/model-name-to-model-key.js +2 -1
  43. package/src/utils/select-object-keys.js +9 -4
  44. package/src/utils/singularize.js +3 -1
@@ -40,8 +40,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
40
40
 
41
41
  // src/utils/is-promise.js
42
42
  function isPromise(value) {
43
- if (!value) return false;
44
- if (typeof value !== "object") return false;
43
+ if (!value) {
44
+ return false;
45
+ }
46
+ if (typeof value !== "object") {
47
+ return false;
48
+ }
45
49
  return typeof value.then === "function";
46
50
  }
47
51
  var init_is_promise = __esm({
@@ -53,7 +57,9 @@ var init_is_promise = __esm({
53
57
 
54
58
  // src/utils/capitalize.js
55
59
  function capitalize(string) {
56
- if (!string || typeof string !== "string") return string;
60
+ if (!string || typeof string !== "string") {
61
+ return string;
62
+ }
57
63
  return string.charAt(0).toUpperCase() + string.slice(1);
58
64
  }
59
65
  var init_capitalize = __esm({
@@ -65,11 +71,15 @@ var init_capitalize = __esm({
65
71
 
66
72
  // src/utils/clone-deep.js
67
73
  function cloneDeep(value) {
68
- if (!value) return value;
74
+ if (!value) {
75
+ return value;
76
+ }
69
77
  const types = [Number, String, Boolean];
70
78
  let result;
71
79
  types.forEach((type) => {
72
- if (value instanceof type) result = type(value);
80
+ if (value instanceof type) {
81
+ result = type(value);
82
+ }
73
83
  });
74
84
  if (result === void 0) {
75
85
  if (Array.isArray(value)) {
@@ -109,7 +119,9 @@ var init_clone_deep = __esm({
109
119
 
110
120
  // src/utils/singularize.js
111
121
  function singularize(noun) {
112
- if (!noun || typeof noun !== "string") return noun;
122
+ if (!noun || typeof noun !== "string") {
123
+ return noun;
124
+ }
113
125
  const endings = {
114
126
  ves: "fe",
115
127
  ies: "y",
@@ -135,17 +147,27 @@ var init_singularize = __esm({
135
147
  function isDeepEqual(firstValue, secondValue) {
136
148
  const cached = /* @__PURE__ */ new WeakMap();
137
149
  const compare = /* @__PURE__ */ __name((a, b) => {
138
- if (a === null || b === null) return a === b;
139
- if (typeof a !== "object" || typeof b !== "object") return a === b;
150
+ if (a === null || b === null) {
151
+ return a === b;
152
+ }
153
+ if (typeof a !== "object" || typeof b !== "object") {
154
+ return a === b;
155
+ }
140
156
  const dataTypeA = Array.isArray(a) ? "array" : "object";
141
157
  const dataTypeB = Array.isArray(b) ? "array" : "object";
142
- if (dataTypeA !== dataTypeB) return false;
158
+ if (dataTypeA !== dataTypeB) {
159
+ return false;
160
+ }
143
161
  const keysA = Object.keys(a);
144
162
  const keysB = Object.keys(b);
145
- if (keysA.length !== keysB.length) return false;
163
+ if (keysA.length !== keysB.length) {
164
+ return false;
165
+ }
146
166
  const symbolsA = Object.getOwnPropertySymbols(a);
147
167
  const symbolsB = Object.getOwnPropertySymbols(b);
148
- if (symbolsA.length !== symbolsB.length) return false;
168
+ if (symbolsA.length !== symbolsB.length) {
169
+ return false;
170
+ }
149
171
  let setForA = cached.get(a);
150
172
  if (setForA == null) {
151
173
  setForA = /* @__PURE__ */ new Set();
@@ -164,10 +186,14 @@ function isDeepEqual(firstValue, secondValue) {
164
186
  setForB.add(a);
165
187
  const propertyNamesA = [...keysA, ...symbolsA];
166
188
  for (const propertyNameA of propertyNamesA) {
167
- if (!Object.prototype.hasOwnProperty.call(b, propertyNameA)) return false;
189
+ if (!Object.prototype.hasOwnProperty.call(b, propertyNameA)) {
190
+ return false;
191
+ }
168
192
  const propertyValueA = a[propertyNameA];
169
193
  const propertyValueB = b[propertyNameA];
170
- if (!compare(propertyValueA, propertyValueB)) return false;
194
+ if (!compare(propertyValueA, propertyValueB)) {
195
+ return false;
196
+ }
171
197
  }
172
198
  return true;
173
199
  }, "compare");
@@ -316,8 +342,12 @@ var init_string_to_regexp = __esm({
316
342
 
317
343
  // src/utils/get-value-by-path.js
318
344
  function getValueByPath(obj, path, orElse = void 0) {
319
- if (!obj || typeof obj !== "object") return orElse;
320
- if (!path || typeof path !== "string") return orElse;
345
+ if (!obj || typeof obj !== "object") {
346
+ return orElse;
347
+ }
348
+ if (!path || typeof path !== "string") {
349
+ return orElse;
350
+ }
321
351
  const keys = path.split(".");
322
352
  let value = obj;
323
353
  for (const key of keys) {
@@ -339,27 +369,32 @@ var init_get_value_by_path = __esm({
339
369
 
340
370
  // src/utils/select-object-keys.js
341
371
  function selectObjectKeys(obj, keys) {
342
- if (!obj || typeof obj !== "object" || Array.isArray(obj))
372
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
343
373
  throw new InvalidArgumentError(
344
374
  "The first argument of selectObjectKeys should be an Object, but %v was given.",
345
375
  obj
346
376
  );
347
- if (!Array.isArray(keys))
377
+ }
378
+ if (!Array.isArray(keys)) {
348
379
  throw new InvalidArgumentError(
349
380
  "The second argument of selectObjectKeys should be an Array of String, but %v was given.",
350
381
  keys
351
382
  );
383
+ }
352
384
  keys.forEach((key) => {
353
- if (typeof key !== "string")
385
+ if (typeof key !== "string") {
354
386
  throw new InvalidArgumentError(
355
387
  "The second argument of selectObjectKeys should be an Array of String, but %v was given.",
356
388
  key
357
389
  );
390
+ }
358
391
  });
359
392
  const result = {};
360
393
  const allKeys = Object.keys(obj);
361
394
  allKeys.forEach((key) => {
362
- if (keys.includes(key)) result[key] = obj[key];
395
+ if (keys.includes(key)) {
396
+ result[key] = obj[key];
397
+ }
363
398
  });
364
399
  return result;
365
400
  }
@@ -373,11 +408,12 @@ var init_select_object_keys = __esm({
373
408
 
374
409
  // src/utils/exclude-object-keys.js
375
410
  function excludeObjectKeys(obj, keys) {
376
- if (typeof obj !== "object" || !obj || Array.isArray(obj))
411
+ if (typeof obj !== "object" || !obj || Array.isArray(obj)) {
377
412
  throw new InvalidArgumentError(
378
413
  "Cannot exclude keys from a non-Object value, %v was given.",
379
414
  obj
380
415
  );
416
+ }
381
417
  const result = { ...obj };
382
418
  keys = Array.isArray(keys) ? keys : [keys];
383
419
  keys.forEach((key) => delete result[key]);
@@ -393,11 +429,12 @@ var init_exclude_object_keys = __esm({
393
429
 
394
430
  // src/utils/model-name-to-model-key.js
395
431
  function modelNameToModelKey(modelName) {
396
- if (!modelName || typeof modelName !== "string" || /\s/.test(modelName))
432
+ if (!modelName || typeof modelName !== "string" || /\s/.test(modelName)) {
397
433
  throw new InvalidArgumentError(
398
434
  "The model name should be a non-empty String without spaces, but %v was given.",
399
435
  modelName
400
436
  );
437
+ }
401
438
  return modelName.toLowerCase().replace(/[-_]/g, "");
402
439
  }
403
440
  var init_model_name_to_model_key = __esm({
@@ -444,21 +481,24 @@ var init_slice_clause_tool = __esm({
444
481
  * @returns {object[]}
445
482
  */
446
483
  slice(entities, skip = void 0, limit = void 0) {
447
- if (!Array.isArray(entities))
484
+ if (!Array.isArray(entities)) {
448
485
  throw new InvalidArgumentError(
449
486
  "The first argument of SliceClauseTool.slice should be an Array, but %v was given.",
450
487
  entities
451
488
  );
452
- if (skip != null && typeof skip !== "number")
489
+ }
490
+ if (skip != null && typeof skip !== "number") {
453
491
  throw new InvalidArgumentError(
454
492
  'The provided option "skip" should be a Number, but %v was given.',
455
493
  skip
456
494
  );
457
- if (limit != null && typeof limit !== "number")
495
+ }
496
+ if (limit != null && typeof limit !== "number") {
458
497
  throw new InvalidArgumentError(
459
498
  'The provided option "limit" should be a Number, but %v was given.',
460
499
  limit
461
500
  );
501
+ }
462
502
  skip = skip || 0;
463
503
  limit = limit || entities.length;
464
504
  return entities.slice(skip, skip + limit);
@@ -469,12 +509,15 @@ var init_slice_clause_tool = __esm({
469
509
  * @param {number|undefined} skip
470
510
  */
471
511
  static validateSkipClause(skip) {
472
- if (skip == null) return;
473
- if (typeof skip !== "number")
512
+ if (skip == null) {
513
+ return;
514
+ }
515
+ if (typeof skip !== "number") {
474
516
  throw new InvalidArgumentError(
475
517
  'The provided option "skip" should be a Number, but %v was given.',
476
518
  skip
477
519
  );
520
+ }
478
521
  }
479
522
  /**
480
523
  * Validate limit clause.
@@ -482,12 +525,15 @@ var init_slice_clause_tool = __esm({
482
525
  * @param {number|undefined} limit
483
526
  */
484
527
  static validateLimitClause(limit) {
485
- if (limit == null) return;
486
- if (typeof limit !== "number")
528
+ if (limit == null) {
529
+ return;
530
+ }
531
+ if (typeof limit !== "number") {
487
532
  throw new InvalidArgumentError(
488
533
  'The provided option "limit" should be a Number, but %v was given.',
489
534
  limit
490
535
  );
536
+ }
491
537
  }
492
538
  };
493
539
  __name(_SliceClauseTool, "SliceClauseTool");
@@ -526,21 +572,30 @@ var init_order_clause_tool = __esm({
526
572
  * @param {string|string[]|undefined} clause
527
573
  */
528
574
  sort(entities, clause) {
529
- if (clause == null) return;
530
- if (Array.isArray(clause) === false) clause = [clause];
531
- if (!clause.length) return;
575
+ if (clause == null) {
576
+ return;
577
+ }
578
+ if (Array.isArray(clause) === false) {
579
+ clause = [clause];
580
+ }
581
+ if (!clause.length) {
582
+ return;
583
+ }
532
584
  const mapping = [];
533
585
  clause.forEach((key, index) => {
534
- if (!key || typeof key !== "string")
586
+ if (!key || typeof key !== "string") {
535
587
  throw new InvalidArgumentError(
536
588
  'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v was given.',
537
589
  key
538
590
  );
591
+ }
539
592
  let reverse = 1;
540
593
  const matches = key.match(/\s+(A|DE)SC$/i);
541
594
  if (matches) {
542
595
  key = key.replace(/\s+(A|DE)SC/i, "");
543
- if (matches[1].toLowerCase() === "de") reverse = -1;
596
+ if (matches[1].toLowerCase() === "de") {
597
+ reverse = -1;
598
+ }
544
599
  }
545
600
  mapping[index] = { key, reverse };
546
601
  });
@@ -552,15 +607,22 @@ var init_order_clause_tool = __esm({
552
607
  * @param {string|string[]|undefined} clause
553
608
  */
554
609
  static validateOrderClause(clause) {
555
- if (clause == null) return;
556
- if (Array.isArray(clause) === false) clause = [clause];
557
- if (!clause.length) return;
610
+ if (clause == null) {
611
+ return;
612
+ }
613
+ if (Array.isArray(clause) === false) {
614
+ clause = [clause];
615
+ }
616
+ if (!clause.length) {
617
+ return;
618
+ }
558
619
  clause.forEach((field) => {
559
- if (!field || typeof field !== "string")
620
+ if (!field || typeof field !== "string") {
560
621
  throw new InvalidArgumentError(
561
622
  'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v was given.',
562
623
  field
563
624
  );
625
+ }
564
626
  });
565
627
  }
566
628
  /**
@@ -570,15 +632,22 @@ var init_order_clause_tool = __esm({
570
632
  * @returns {string[]|undefined}
571
633
  */
572
634
  static normalizeOrderClause(clause) {
573
- if (clause == null) return;
574
- if (Array.isArray(clause) === false) clause = [clause];
575
- if (!clause.length) return;
635
+ if (clause == null) {
636
+ return;
637
+ }
638
+ if (Array.isArray(clause) === false) {
639
+ clause = [clause];
640
+ }
641
+ if (!clause.length) {
642
+ return;
643
+ }
576
644
  clause.forEach((field) => {
577
- if (!field || typeof field !== "string")
645
+ if (!field || typeof field !== "string") {
578
646
  throw new InvalidArgumentError(
579
647
  'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v was given.',
580
648
  field
581
649
  );
650
+ }
582
651
  });
583
652
  return clause;
584
653
  }
@@ -629,8 +698,12 @@ var init_operator_clause_tool = __esm({
629
698
  }
630
699
  }
631
700
  if (type1 === "string" && type2 === "string") {
632
- if (val1 > val2) return 1;
633
- if (val1 < val2) return -1;
701
+ if (val1 > val2) {
702
+ return 1;
703
+ }
704
+ if (val1 < val2) {
705
+ return -1;
706
+ }
634
707
  return 0;
635
708
  }
636
709
  return NaN;
@@ -643,11 +716,12 @@ var init_operator_clause_tool = __esm({
643
716
  * @returns {boolean|undefined}
644
717
  */
645
718
  testAll(clause, value) {
646
- if (!clause || typeof clause !== "object" || Array.isArray(clause))
719
+ if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
647
720
  throw new InvalidArgumentError(
648
721
  "The first argument of OperatorUtils.testAll should be an Object, but %v was given.",
649
722
  clause
650
723
  );
724
+ }
651
725
  const operatorMap = {
652
726
  eq: this.testEqNeq,
653
727
  neq: this.testEqNeq,
@@ -702,13 +776,18 @@ var init_operator_clause_tool = __esm({
702
776
  * @returns {boolean|undefined}
703
777
  */
704
778
  testEqNeq(clause, value) {
705
- if (!clause || typeof clause !== "object")
779
+ if (!clause || typeof clause !== "object") {
706
780
  throw new InvalidArgumentError(
707
781
  "The first argument of OperatorUtils.testEqNeq should be an Object, but %v was given.",
708
782
  clause
709
783
  );
710
- if ("eq" in clause) return this.compare(clause.eq, value, true) === 0;
711
- if ("neq" in clause) return this.compare(clause.neq, value, true) !== 0;
784
+ }
785
+ if ("eq" in clause) {
786
+ return this.compare(clause.eq, value, true) === 0;
787
+ }
788
+ if ("neq" in clause) {
789
+ return this.compare(clause.neq, value, true) !== 0;
790
+ }
712
791
  }
713
792
  /**
714
793
  * Test lt/gt/lte/gte operator.
@@ -746,15 +825,24 @@ var init_operator_clause_tool = __esm({
746
825
  * @returns {boolean|undefined}
747
826
  */
748
827
  testGtLt(clause, value) {
749
- if (!clause || typeof clause !== "object")
828
+ if (!clause || typeof clause !== "object") {
750
829
  throw new InvalidArgumentError(
751
830
  "The first argument of OperatorUtils.testGtLt should be an Object, but %v was given.",
752
831
  clause
753
832
  );
754
- if ("gt" in clause) return this.compare(value, clause.gt) > 0;
755
- if ("gte" in clause) return this.compare(value, clause.gte) >= 0;
756
- if ("lt" in clause) return this.compare(value, clause.lt) < 0;
757
- if ("lte" in clause) return this.compare(value, clause.lte) <= 0;
833
+ }
834
+ if ("gt" in clause) {
835
+ return this.compare(value, clause.gt) > 0;
836
+ }
837
+ if ("gte" in clause) {
838
+ return this.compare(value, clause.gte) >= 0;
839
+ }
840
+ if ("lt" in clause) {
841
+ return this.compare(value, clause.lt) < 0;
842
+ }
843
+ if ("lte" in clause) {
844
+ return this.compare(value, clause.lte) <= 0;
845
+ }
758
846
  }
759
847
  /**
760
848
  * Test inc operator.
@@ -771,11 +859,12 @@ var init_operator_clause_tool = __esm({
771
859
  * @returns {boolean|undefined}
772
860
  */
773
861
  testInq(clause, value) {
774
- if (!clause || typeof clause !== "object")
862
+ if (!clause || typeof clause !== "object") {
775
863
  throw new InvalidArgumentError(
776
864
  "The first argument of OperatorUtils.testInq should be an Object, but %v was given.",
777
865
  clause
778
866
  );
867
+ }
779
868
  if ("inq" in clause && clause.inq !== void 0) {
780
869
  if (!clause.inq || !Array.isArray(clause.inq)) {
781
870
  throw new InvalidOperatorValueError(
@@ -807,11 +896,12 @@ var init_operator_clause_tool = __esm({
807
896
  * @returns {boolean|undefined}
808
897
  */
809
898
  testNin(clause, value) {
810
- if (!clause || typeof clause !== "object")
899
+ if (!clause || typeof clause !== "object") {
811
900
  throw new InvalidArgumentError(
812
901
  "The first argument of OperatorUtils.testNin should be an Object, but %v was given.",
813
902
  clause
814
903
  );
904
+ }
815
905
  if ("nin" in clause && clause.nin !== void 0) {
816
906
  if (!clause.nin || !Array.isArray(clause.nin)) {
817
907
  throw new InvalidOperatorValueError(
@@ -840,11 +930,12 @@ var init_operator_clause_tool = __esm({
840
930
  * @returns {boolean|undefined}
841
931
  */
842
932
  testBetween(clause, value) {
843
- if (!clause || typeof clause !== "object")
933
+ if (!clause || typeof clause !== "object") {
844
934
  throw new InvalidArgumentError(
845
935
  "The first argument of OperatorUtils.testBetween should be an Object, but %v was given.",
846
936
  clause
847
937
  );
938
+ }
848
939
  if ("between" in clause && clause.between !== void 0) {
849
940
  if (!Array.isArray(clause.between) || clause.between.length !== 2) {
850
941
  throw new InvalidOperatorValueError(
@@ -871,11 +962,12 @@ var init_operator_clause_tool = __esm({
871
962
  * @returns {boolean|undefined}
872
963
  */
873
964
  testExists(clause, value) {
874
- if (!clause || typeof clause !== "object")
965
+ if (!clause || typeof clause !== "object") {
875
966
  throw new InvalidArgumentError(
876
967
  "The first argument of OperatorUtils.testExists should be an Object, but %v was given.",
877
968
  clause
878
969
  );
970
+ }
879
971
  if ("exists" in clause && clause.exists !== void 0) {
880
972
  if (typeof clause.exists !== "boolean") {
881
973
  throw new InvalidOperatorValueError(
@@ -902,14 +994,16 @@ var init_operator_clause_tool = __esm({
902
994
  * @returns {boolean|undefined}
903
995
  */
904
996
  testLike(clause, value) {
905
- if (!clause || typeof clause !== "object" || Array.isArray(clause))
997
+ if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
906
998
  throw new InvalidArgumentError(
907
999
  "The first argument of OperatorUtils.testLike should be an Object, but %v was given.",
908
1000
  clause
909
1001
  );
1002
+ }
910
1003
  if ("like" in clause && clause.like !== void 0) {
911
- if (typeof clause.like !== "string")
1004
+ if (typeof clause.like !== "string") {
912
1005
  throw new InvalidOperatorValueError("like", "a String", clause.like);
1006
+ }
913
1007
  return likeToRegexp(clause.like).test(value);
914
1008
  }
915
1009
  }
@@ -928,11 +1022,12 @@ var init_operator_clause_tool = __esm({
928
1022
  * @returns {boolean|undefined}
929
1023
  */
930
1024
  testNlike(clause, value) {
931
- if (!clause || typeof clause !== "object" || Array.isArray(clause))
1025
+ if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
932
1026
  throw new InvalidArgumentError(
933
1027
  "The first argument of OperatorUtils.testNlike should be an Object, but %v was given.",
934
1028
  clause
935
1029
  );
1030
+ }
936
1031
  if ("nlike" in clause && clause.nlike !== void 0) {
937
1032
  if (typeof clause.nlike !== "string") {
938
1033
  throw new InvalidOperatorValueError("nlike", "a String", clause.nlike);
@@ -955,11 +1050,12 @@ var init_operator_clause_tool = __esm({
955
1050
  * @returns {boolean|undefined}
956
1051
  */
957
1052
  testIlike(clause, value) {
958
- if (!clause || typeof clause !== "object" || Array.isArray(clause))
1053
+ if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
959
1054
  throw new InvalidArgumentError(
960
1055
  "The first argument of OperatorUtils.testIlike should be an Object, but %v was given.",
961
1056
  clause
962
1057
  );
1058
+ }
963
1059
  if ("ilike" in clause && clause.ilike !== void 0) {
964
1060
  if (typeof clause.ilike !== "string") {
965
1061
  throw new InvalidOperatorValueError("ilike", "a String", clause.ilike);
@@ -982,11 +1078,12 @@ var init_operator_clause_tool = __esm({
982
1078
  * @returns {boolean|undefined}
983
1079
  */
984
1080
  testNilike(clause, value) {
985
- if (!clause || typeof clause !== "object" || Array.isArray(clause))
1081
+ if (!clause || typeof clause !== "object" || Array.isArray(clause)) {
986
1082
  throw new InvalidArgumentError(
987
1083
  "The first argument of OperatorUtils.testNilike should be an Object, but %v was given.",
988
1084
  clause
989
1085
  );
1086
+ }
990
1087
  if ("nilike" in clause && clause.nilike !== void 0) {
991
1088
  if (typeof clause.nilike !== "string") {
992
1089
  throw new InvalidOperatorValueError(
@@ -1021,11 +1118,12 @@ var init_operator_clause_tool = __esm({
1021
1118
  * @returns {boolean|undefined}
1022
1119
  */
1023
1120
  testRegexp(clause, value) {
1024
- if (!clause || typeof clause !== "object")
1121
+ if (!clause || typeof clause !== "object") {
1025
1122
  throw new InvalidArgumentError(
1026
1123
  "The first argument of OperatorUtils.testRegexp should be an Object, but %v was given.",
1027
1124
  clause
1028
1125
  );
1126
+ }
1029
1127
  if ("regexp" in clause && clause.regexp !== void 0) {
1030
1128
  if (typeof clause.regexp !== "string" && !(clause.regexp instanceof RegExp)) {
1031
1129
  throw new InvalidOperatorValueError(
@@ -1035,12 +1133,15 @@ var init_operator_clause_tool = __esm({
1035
1133
  );
1036
1134
  }
1037
1135
  const flags = clause.flags || void 0;
1038
- if (flags && typeof flags !== "string")
1136
+ if (flags && typeof flags !== "string") {
1039
1137
  throw new InvalidArgumentError(
1040
1138
  "RegExp flags should be a String, but %v was given.",
1041
1139
  clause.flags
1042
1140
  );
1043
- if (!value || typeof value !== "string") return false;
1141
+ }
1142
+ if (!value || typeof value !== "string") {
1143
+ return false;
1144
+ }
1044
1145
  const regExp = stringToRegexp(clause.regexp, flags);
1045
1146
  return !!value.match(regExp);
1046
1147
  }
@@ -1091,12 +1192,15 @@ var init_where_clause_tool = __esm({
1091
1192
  * @returns {object[]}
1092
1193
  */
1093
1194
  filter(entities, where = void 0) {
1094
- if (!Array.isArray(entities))
1195
+ if (!Array.isArray(entities)) {
1095
1196
  throw new InvalidArgumentError(
1096
1197
  "The first argument of WhereClauseTool.filter should be an Array of Object, but %v was given.",
1097
1198
  entities
1098
1199
  );
1099
- if (where == null) return entities;
1200
+ }
1201
+ if (where == null) {
1202
+ return entities;
1203
+ }
1100
1204
  return entities.filter(this._createFilter(where));
1101
1205
  }
1102
1206
  /**
@@ -1106,31 +1210,37 @@ var init_where_clause_tool = __esm({
1106
1210
  * @returns {Function}
1107
1211
  */
1108
1212
  _createFilter(whereClause) {
1109
- if (typeof whereClause !== "object" || Array.isArray(whereClause))
1213
+ if (typeof whereClause !== "object" || Array.isArray(whereClause)) {
1110
1214
  throw new InvalidArgumentError(
1111
1215
  'The provided option "where" should be an Object, but %v was given.',
1112
1216
  whereClause
1113
1217
  );
1218
+ }
1114
1219
  const keys = Object.keys(whereClause);
1115
1220
  return (data) => {
1116
- if (typeof data !== "object")
1221
+ if (typeof data !== "object") {
1117
1222
  throw new InvalidArgumentError(
1118
1223
  "The first argument of WhereClauseTool.filter should be an Array of Object, but %v was given.",
1119
1224
  data
1120
1225
  );
1226
+ }
1121
1227
  return keys.every((key) => {
1122
1228
  if (key === "and" && key in whereClause) {
1123
1229
  const andClause = whereClause[key];
1124
- if (Array.isArray(andClause))
1230
+ if (Array.isArray(andClause)) {
1125
1231
  return andClause.every((clause) => this._createFilter(clause)(data));
1232
+ }
1126
1233
  } else if (key === "or" && key in whereClause) {
1127
1234
  const orClause = whereClause[key];
1128
- if (Array.isArray(orClause))
1235
+ if (Array.isArray(orClause)) {
1129
1236
  return orClause.some((clause) => this._createFilter(clause)(data));
1237
+ }
1130
1238
  }
1131
1239
  const value = getValueByPath(data, key);
1132
1240
  const matcher = whereClause[key];
1133
- if (this._test(matcher, value)) return true;
1241
+ if (this._test(matcher, value)) {
1242
+ return true;
1243
+ }
1134
1244
  });
1135
1245
  };
1136
1246
  }
@@ -1174,7 +1284,9 @@ var init_where_clause_tool = __esm({
1174
1284
  }
1175
1285
  if (Array.isArray(value)) {
1176
1286
  const isElementMatched = value.some((el) => isDeepEqual(el, example));
1177
- if (isElementMatched) return true;
1287
+ if (isElementMatched) {
1288
+ return true;
1289
+ }
1178
1290
  }
1179
1291
  return isDeepEqual(example, value);
1180
1292
  }
@@ -1184,12 +1296,15 @@ var init_where_clause_tool = __esm({
1184
1296
  * @param {WhereClause|undefined} clause
1185
1297
  */
1186
1298
  static validateWhereClause(clause) {
1187
- if (clause == null || typeof clause === "function") return;
1188
- if (typeof clause !== "object" || Array.isArray(clause))
1299
+ if (clause == null || typeof clause === "function") {
1300
+ return;
1301
+ }
1302
+ if (typeof clause !== "object" || Array.isArray(clause)) {
1189
1303
  throw new InvalidArgumentError(
1190
1304
  'The provided option "where" should be an Object, but %v was given.',
1191
1305
  clause
1192
1306
  );
1307
+ }
1193
1308
  }
1194
1309
  };
1195
1310
  __name(_WhereClauseTool, "WhereClauseTool");
@@ -1234,17 +1349,19 @@ var init_relations_definition_validator = __esm({
1234
1349
  * @param {object} relDefs
1235
1350
  */
1236
1351
  validate(modelName, relDefs) {
1237
- if (!modelName || typeof modelName !== "string")
1352
+ if (!modelName || typeof modelName !== "string") {
1238
1353
  throw new InvalidArgumentError(
1239
1354
  "The first argument of RelationsDefinitionValidator.validate should be a non-empty String, but %v was given.",
1240
1355
  modelName
1241
1356
  );
1242
- if (!relDefs || typeof relDefs !== "object" || Array.isArray(relDefs))
1357
+ }
1358
+ if (!relDefs || typeof relDefs !== "object" || Array.isArray(relDefs)) {
1243
1359
  throw new InvalidArgumentError(
1244
1360
  'The provided option "relations" of the model %v should be an Object, but %v was given.',
1245
1361
  modelName,
1246
1362
  relDefs
1247
1363
  );
1364
+ }
1248
1365
  const relNames = Object.keys(relDefs);
1249
1366
  relNames.forEach((relName) => {
1250
1367
  const relDef = relDefs[relName];
@@ -1259,25 +1376,28 @@ var init_relations_definition_validator = __esm({
1259
1376
  * @param {object} relDef
1260
1377
  */
1261
1378
  _validateRelation(modelName, relName, relDef) {
1262
- if (!modelName || typeof modelName !== "string")
1379
+ if (!modelName || typeof modelName !== "string") {
1263
1380
  throw new InvalidArgumentError(
1264
1381
  "The first argument of RelationsDefinitionValidator._validateRelation should be a non-empty String, but %v was given.",
1265
1382
  modelName
1266
1383
  );
1267
- if (!relName || typeof relName !== "string")
1384
+ }
1385
+ if (!relName || typeof relName !== "string") {
1268
1386
  throw new InvalidArgumentError(
1269
1387
  "The relation name of the model %v should be a non-empty String, but %v was given.",
1270
1388
  modelName,
1271
1389
  relName
1272
1390
  );
1273
- if (!relDef || typeof relDef !== "object" || Array.isArray(relDef))
1391
+ }
1392
+ if (!relDef || typeof relDef !== "object" || Array.isArray(relDef)) {
1274
1393
  throw new InvalidArgumentError(
1275
1394
  "The relation %v of the model %v should be an Object, but %v was given.",
1276
1395
  relName,
1277
1396
  modelName,
1278
1397
  relDef
1279
1398
  );
1280
- if (!relDef.type || !Object.values(RelationType).includes(relDef.type))
1399
+ }
1400
+ if (!relDef.type || !Object.values(RelationType).includes(relDef.type)) {
1281
1401
  throw new InvalidArgumentError(
1282
1402
  'The relation %v of the model %v requires the option "type" to have one of relation types: %l, but %v was given.',
1283
1403
  relName,
@@ -1285,6 +1405,7 @@ var init_relations_definition_validator = __esm({
1285
1405
  Object.values(RelationType),
1286
1406
  relDef.type
1287
1407
  );
1408
+ }
1288
1409
  this._validateBelongsTo(modelName, relName, relDef);
1289
1410
  this._validateHasOne(modelName, relName, relDef);
1290
1411
  this._validateHasMany(modelName, relName, relDef);
@@ -1318,50 +1439,58 @@ var init_relations_definition_validator = __esm({
1318
1439
  * @private
1319
1440
  */
1320
1441
  _validateBelongsTo(modelName, relName, relDef) {
1321
- if (relDef.type !== RelationType.BELONGS_TO) return;
1442
+ if (relDef.type !== RelationType.BELONGS_TO) {
1443
+ return;
1444
+ }
1322
1445
  if (relDef.polymorphic) {
1323
- if (typeof relDef.polymorphic !== "boolean")
1446
+ if (typeof relDef.polymorphic !== "boolean") {
1324
1447
  throw new InvalidArgumentError(
1325
1448
  'The relation %v of the model %v has the type "belongsTo", so it expects the option "polymorphic" to be a Boolean, but %v was given.',
1326
1449
  relName,
1327
1450
  modelName,
1328
1451
  relDef.polymorphic
1329
1452
  );
1330
- if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
1453
+ }
1454
+ if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
1331
1455
  throw new InvalidArgumentError(
1332
1456
  'The 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.',
1333
1457
  relName,
1334
1458
  modelName,
1335
1459
  relDef.foreignKey
1336
1460
  );
1337
- if (relDef.discriminator && typeof relDef.discriminator !== "string")
1461
+ }
1462
+ if (relDef.discriminator && typeof relDef.discriminator !== "string") {
1338
1463
  throw new InvalidArgumentError(
1339
1464
  'The 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.',
1340
1465
  relName,
1341
1466
  modelName,
1342
1467
  relDef.discriminator
1343
1468
  );
1469
+ }
1344
1470
  } else {
1345
- if (!relDef.model || typeof relDef.model !== "string")
1471
+ if (!relDef.model || typeof relDef.model !== "string") {
1346
1472
  throw new InvalidArgumentError(
1347
1473
  'The 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.',
1348
1474
  relName,
1349
1475
  modelName,
1350
1476
  relDef.model
1351
1477
  );
1352
- if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
1478
+ }
1479
+ if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
1353
1480
  throw new InvalidArgumentError(
1354
1481
  'The 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.',
1355
1482
  relName,
1356
1483
  modelName,
1357
1484
  relDef.foreignKey
1358
1485
  );
1359
- if (relDef.discriminator)
1486
+ }
1487
+ if (relDef.discriminator) {
1360
1488
  throw new InvalidArgumentError(
1361
1489
  'The relation %v of the model %v is a non-polymorphic "belongsTo" relation, so it should not have the option "discriminator" to be provided.',
1362
1490
  relName,
1363
1491
  modelName
1364
1492
  );
1493
+ }
1365
1494
  }
1366
1495
  }
1367
1496
  /**
@@ -1402,43 +1531,50 @@ var init_relations_definition_validator = __esm({
1402
1531
  * @private
1403
1532
  */
1404
1533
  _validateHasOne(modelName, relName, relDef) {
1405
- if (relDef.type !== RelationType.HAS_ONE) return;
1406
- if (!relDef.model || typeof relDef.model !== "string")
1534
+ if (relDef.type !== RelationType.HAS_ONE) {
1535
+ return;
1536
+ }
1537
+ if (!relDef.model || typeof relDef.model !== "string") {
1407
1538
  throw new InvalidArgumentError(
1408
1539
  'The 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.',
1409
1540
  relName,
1410
1541
  modelName,
1411
1542
  relDef.model
1412
1543
  );
1544
+ }
1413
1545
  if (relDef.polymorphic) {
1414
1546
  if (typeof relDef.polymorphic === "string") {
1415
- if (relDef.foreignKey)
1547
+ if (relDef.foreignKey) {
1416
1548
  throw new InvalidArgumentError(
1417
1549
  'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "foreignKey" to be provided.',
1418
1550
  relName,
1419
1551
  modelName
1420
1552
  );
1421
- if (relDef.discriminator)
1553
+ }
1554
+ if (relDef.discriminator) {
1422
1555
  throw new InvalidArgumentError(
1423
1556
  'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "discriminator" to be provided.',
1424
1557
  relName,
1425
1558
  modelName
1426
1559
  );
1560
+ }
1427
1561
  } else if (typeof relDef.polymorphic === "boolean") {
1428
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
1562
+ if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
1429
1563
  throw new InvalidArgumentError(
1430
1564
  'The 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.',
1431
1565
  relName,
1432
1566
  modelName,
1433
1567
  relDef.foreignKey
1434
1568
  );
1435
- if (!relDef.discriminator || typeof relDef.discriminator !== "string")
1569
+ }
1570
+ if (!relDef.discriminator || typeof relDef.discriminator !== "string") {
1436
1571
  throw new InvalidArgumentError(
1437
1572
  'The 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.',
1438
1573
  relName,
1439
1574
  modelName,
1440
1575
  relDef.discriminator
1441
1576
  );
1577
+ }
1442
1578
  } else {
1443
1579
  throw new InvalidArgumentError(
1444
1580
  'The 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.',
@@ -1448,19 +1584,21 @@ var init_relations_definition_validator = __esm({
1448
1584
  );
1449
1585
  }
1450
1586
  } else {
1451
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
1587
+ if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
1452
1588
  throw new InvalidArgumentError(
1453
1589
  'The 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.',
1454
1590
  relName,
1455
1591
  modelName,
1456
1592
  relDef.foreignKey
1457
1593
  );
1458
- if (relDef.discriminator)
1594
+ }
1595
+ if (relDef.discriminator) {
1459
1596
  throw new InvalidArgumentError(
1460
1597
  'The relation %v of the model %v is a non-polymorphic "hasOne" relation, so it should not have the option "discriminator" to be provided.',
1461
1598
  relName,
1462
1599
  modelName
1463
1600
  );
1601
+ }
1464
1602
  }
1465
1603
  }
1466
1604
  /**
@@ -1501,43 +1639,50 @@ var init_relations_definition_validator = __esm({
1501
1639
  * @private
1502
1640
  */
1503
1641
  _validateHasMany(modelName, relName, relDef) {
1504
- if (relDef.type !== RelationType.HAS_MANY) return;
1505
- if (!relDef.model || typeof relDef.model !== "string")
1642
+ if (relDef.type !== RelationType.HAS_MANY) {
1643
+ return;
1644
+ }
1645
+ if (!relDef.model || typeof relDef.model !== "string") {
1506
1646
  throw new InvalidArgumentError(
1507
1647
  'The 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.',
1508
1648
  relName,
1509
1649
  modelName,
1510
1650
  relDef.model
1511
1651
  );
1652
+ }
1512
1653
  if (relDef.polymorphic) {
1513
1654
  if (typeof relDef.polymorphic === "string") {
1514
- if (relDef.foreignKey)
1655
+ if (relDef.foreignKey) {
1515
1656
  throw new InvalidArgumentError(
1516
1657
  'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "foreignKey" to be provided.',
1517
1658
  relName,
1518
1659
  modelName
1519
1660
  );
1520
- if (relDef.discriminator)
1661
+ }
1662
+ if (relDef.discriminator) {
1521
1663
  throw new InvalidArgumentError(
1522
1664
  'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "discriminator" to be provided.',
1523
1665
  relName,
1524
1666
  modelName
1525
1667
  );
1668
+ }
1526
1669
  } else if (typeof relDef.polymorphic === "boolean") {
1527
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
1670
+ if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
1528
1671
  throw new InvalidArgumentError(
1529
1672
  'The 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.',
1530
1673
  relName,
1531
1674
  modelName,
1532
1675
  relDef.foreignKey
1533
1676
  );
1534
- if (!relDef.discriminator || typeof relDef.discriminator !== "string")
1677
+ }
1678
+ if (!relDef.discriminator || typeof relDef.discriminator !== "string") {
1535
1679
  throw new InvalidArgumentError(
1536
1680
  'The 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.',
1537
1681
  relName,
1538
1682
  modelName,
1539
1683
  relDef.discriminator
1540
1684
  );
1685
+ }
1541
1686
  } else {
1542
1687
  throw new InvalidArgumentError(
1543
1688
  'The 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.',
@@ -1547,19 +1692,21 @@ var init_relations_definition_validator = __esm({
1547
1692
  );
1548
1693
  }
1549
1694
  } else {
1550
- if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
1695
+ if (!relDef.foreignKey || typeof relDef.foreignKey !== "string") {
1551
1696
  throw new InvalidArgumentError(
1552
1697
  'The 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.',
1553
1698
  relName,
1554
1699
  modelName,
1555
1700
  relDef.foreignKey
1556
1701
  );
1557
- if (relDef.discriminator)
1702
+ }
1703
+ if (relDef.discriminator) {
1558
1704
  throw new InvalidArgumentError(
1559
1705
  'The relation %v of the model %v is a non-polymorphic "hasMany" relation, so it should not have the option "discriminator" to be provided.',
1560
1706
  relName,
1561
1707
  modelName
1562
1708
  );
1709
+ }
1563
1710
  }
1564
1711
  }
1565
1712
  /**
@@ -1580,27 +1727,32 @@ var init_relations_definition_validator = __esm({
1580
1727
  * @private
1581
1728
  */
1582
1729
  _validateReferencesMany(modelName, relName, relDef) {
1583
- if (relDef.type !== RelationType.REFERENCES_MANY) return;
1584
- if (!relDef.model || typeof relDef.model !== "string")
1730
+ if (relDef.type !== RelationType.REFERENCES_MANY) {
1731
+ return;
1732
+ }
1733
+ if (!relDef.model || typeof relDef.model !== "string") {
1585
1734
  throw new InvalidArgumentError(
1586
1735
  'The 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.',
1587
1736
  relName,
1588
1737
  modelName,
1589
1738
  relDef.model
1590
1739
  );
1591
- if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
1740
+ }
1741
+ if (relDef.foreignKey && typeof relDef.foreignKey !== "string") {
1592
1742
  throw new InvalidArgumentError(
1593
1743
  'The 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.',
1594
1744
  relName,
1595
1745
  modelName,
1596
1746
  relDef.foreignKey
1597
1747
  );
1598
- if (relDef.discriminator)
1748
+ }
1749
+ if (relDef.discriminator) {
1599
1750
  throw new InvalidArgumentError(
1600
1751
  'The relation %v of the model %v has the type "referencesMany", so it should not have the option "discriminator" to be provided.',
1601
1752
  relName,
1602
1753
  modelName
1603
1754
  );
1755
+ }
1604
1756
  }
1605
1757
  };
1606
1758
  __name(_RelationsDefinitionValidator, "RelationsDefinitionValidator");
@@ -1685,11 +1837,12 @@ var init_definition_registry = __esm({
1685
1837
  addDatasource(datasourceDef) {
1686
1838
  this.getService(DatasourceDefinitionValidator).validate(datasourceDef);
1687
1839
  const name = datasourceDef.name;
1688
- if (name in this._datasources)
1840
+ if (name in this._datasources) {
1689
1841
  throw new InvalidArgumentError(
1690
1842
  "The datasource %v is already defined.",
1691
1843
  name
1692
1844
  );
1845
+ }
1693
1846
  this._datasources[name] = datasourceDef;
1694
1847
  }
1695
1848
  /**
@@ -1709,8 +1862,9 @@ var init_definition_registry = __esm({
1709
1862
  */
1710
1863
  getDatasource(name) {
1711
1864
  const datasourceDef = this._datasources[name];
1712
- if (!datasourceDef)
1865
+ if (!datasourceDef) {
1713
1866
  throw new InvalidArgumentError("The datasource %v is not defined.", name);
1867
+ }
1714
1868
  return datasourceDef;
1715
1869
  }
1716
1870
  /**
@@ -1721,11 +1875,12 @@ var init_definition_registry = __esm({
1721
1875
  addModel(modelDef) {
1722
1876
  this.getService(ModelDefinitionValidator).validate(modelDef);
1723
1877
  const modelKey = modelNameToModelKey(modelDef.name);
1724
- if (modelKey in this._models)
1878
+ if (modelKey in this._models) {
1725
1879
  throw new InvalidArgumentError(
1726
1880
  "The model %v is already defined.",
1727
1881
  modelDef.name
1728
1882
  );
1883
+ }
1729
1884
  this._models[modelKey] = modelDef;
1730
1885
  }
1731
1886
  /**
@@ -1747,8 +1902,9 @@ var init_definition_registry = __esm({
1747
1902
  getModel(name) {
1748
1903
  const modelKey = modelNameToModelKey(name);
1749
1904
  const modelDef = this._models[modelKey];
1750
- if (!modelDef)
1905
+ if (!modelDef) {
1751
1906
  throw new InvalidArgumentError("The model %v is not defined.", name);
1907
+ }
1752
1908
  return modelDef;
1753
1909
  }
1754
1910
  };
@@ -1785,12 +1941,13 @@ var init_model_definition_utils = __esm({
1785
1941
  const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(
1786
1942
  DEFAULT_PRIMARY_KEY_PROPERTY_NAME
1787
1943
  );
1788
- if (isDefaultPrimaryKeyAlreadyInUse)
1944
+ if (isDefaultPrimaryKeyAlreadyInUse) {
1789
1945
  throw new InvalidArgumentError(
1790
1946
  'The property name %v of the model %v is defined as a regular property. In this case, a primary key should be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
1791
1947
  DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
1792
1948
  modelName
1793
1949
  );
1950
+ }
1794
1951
  return DEFAULT_PRIMARY_KEY_PROPERTY_NAME;
1795
1952
  }
1796
1953
  return propNames[0];
@@ -1807,9 +1964,13 @@ var init_model_definition_utils = __esm({
1807
1964
  try {
1808
1965
  pkColName = this.getColumnNameByPropertyName(modelName, pkPropName);
1809
1966
  } catch (error) {
1810
- if (!(error instanceof InvalidArgumentError)) throw error;
1967
+ if (!(error instanceof InvalidArgumentError)) {
1968
+ throw error;
1969
+ }
1970
+ }
1971
+ if (pkColName === void 0) {
1972
+ return pkPropName;
1811
1973
  }
1812
- if (pkColName === void 0) return pkPropName;
1813
1974
  return pkColName;
1814
1975
  }
1815
1976
  /**
@@ -1834,14 +1995,16 @@ var init_model_definition_utils = __esm({
1834
1995
  var _a;
1835
1996
  const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
1836
1997
  const propDef = propDefs[propertyName];
1837
- if (!propDef)
1998
+ if (!propDef) {
1838
1999
  throw new InvalidArgumentError(
1839
2000
  "The model %v does not have the property %v.",
1840
2001
  modelName,
1841
2002
  propertyName
1842
2003
  );
1843
- if (propDef && typeof propDef === "object")
2004
+ }
2005
+ if (propDef && typeof propDef === "object") {
1844
2006
  return (_a = propDef.columnName) != null ? _a : propertyName;
2007
+ }
1845
2008
  return propertyName;
1846
2009
  }
1847
2010
  /**
@@ -1854,14 +2017,16 @@ var init_model_definition_utils = __esm({
1854
2017
  getDefaultPropertyValue(modelName, propertyName) {
1855
2018
  const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
1856
2019
  const propDef = propDefs[propertyName];
1857
- if (!propDef)
2020
+ if (!propDef) {
1858
2021
  throw new InvalidArgumentError(
1859
2022
  "The model %v does not have the property %v.",
1860
2023
  modelName,
1861
2024
  propertyName
1862
2025
  );
1863
- if (propDef && typeof propDef === "object")
2026
+ }
2027
+ if (propDef && typeof propDef === "object") {
1864
2028
  return propDef.default instanceof Function ? propDef.default() : propDef.default;
2029
+ }
1865
2030
  }
1866
2031
  /**
1867
2032
  * Set default values to empty properties.
@@ -1902,7 +2067,9 @@ var init_model_definition_utils = __esm({
1902
2067
  const propNames = Object.keys(propDefs);
1903
2068
  const convertedData = cloneDeep(modelData);
1904
2069
  propNames.forEach((propName) => {
1905
- if (!(propName in convertedData)) return;
2070
+ if (!(propName in convertedData)) {
2071
+ return;
2072
+ }
1906
2073
  const colName = this.getColumnNameByPropertyName(modelName, propName);
1907
2074
  let propValue = convertedData[propName];
1908
2075
  const propDef = propDefs[propName];
@@ -1935,7 +2102,9 @@ var init_model_definition_utils = __esm({
1935
2102
  const convertedData = cloneDeep(tableData);
1936
2103
  propNames.forEach((propName) => {
1937
2104
  const colName = this.getColumnNameByPropertyName(modelName, propName);
1938
- if (!(colName in convertedData)) return;
2105
+ if (!(colName in convertedData)) {
2106
+ return;
2107
+ }
1939
2108
  let colValue = convertedData[colName];
1940
2109
  const propDef = propDefs[propName];
1941
2110
  if (colValue !== null && typeof colValue === "object" && !Array.isArray(colValue) && propDef !== null && typeof propDef === "object" && propDef.type === DataType.OBJECT && propDef.model) {
@@ -1966,14 +2135,18 @@ var init_model_definition_utils = __esm({
1966
2135
  const propDef = propDefs[propertyName];
1967
2136
  if (!propDef) {
1968
2137
  const pkPropName = this.getPrimaryKeyAsPropertyName(modelName);
1969
- if (pkPropName === propertyName) return DataType.ANY;
2138
+ if (pkPropName === propertyName) {
2139
+ return DataType.ANY;
2140
+ }
1970
2141
  throw new InvalidArgumentError(
1971
2142
  "The model %v does not have the property %v.",
1972
2143
  modelName,
1973
2144
  propertyName
1974
2145
  );
1975
2146
  }
1976
- if (typeof propDef === "string") return propDef;
2147
+ if (typeof propDef === "string") {
2148
+ return propDef;
2149
+ }
1977
2150
  return propDef.type;
1978
2151
  }
1979
2152
  /**
@@ -1989,14 +2162,17 @@ var init_model_definition_utils = __esm({
1989
2162
  propDef
1990
2163
  );
1991
2164
  }
1992
- if (typeof propDef === "string") return propDef;
2165
+ if (typeof propDef === "string") {
2166
+ return propDef;
2167
+ }
1993
2168
  const dataType = propDef.type;
1994
- if (!Object.values(DataType).includes(dataType))
2169
+ if (!Object.values(DataType).includes(dataType)) {
1995
2170
  throw new InvalidArgumentError(
1996
2171
  'The given Object to the ModelDefinitionUtils.getDataTypeFromPropertyDefinition should have the "type" property with one of values: %l, but %v was given.',
1997
2172
  Object.values(DataType),
1998
2173
  propDef.type
1999
2174
  );
2175
+ }
2000
2176
  return dataType;
2001
2177
  }
2002
2178
  /**
@@ -2027,7 +2203,9 @@ var init_model_definition_utils = __esm({
2027
2203
  const propDefs = (_a = modelDef.properties) != null ? _a : {};
2028
2204
  return Object.keys(propDefs).reduce((result, propName) => {
2029
2205
  const propDef = propDefs[propName];
2030
- if (typeof propDef === "object" && propDef.primaryKey) return result;
2206
+ if (typeof propDef === "object" && propDef.primaryKey) {
2207
+ return result;
2208
+ }
2031
2209
  return { ...result, [propName]: propDef };
2032
2210
  }, {});
2033
2211
  }
@@ -2041,19 +2219,23 @@ var init_model_definition_utils = __esm({
2041
2219
  let pkPropDefs = {};
2042
2220
  let regularPropDefs = {};
2043
2221
  const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
2044
- if (currModelName === prevModelName)
2222
+ if (currModelName === prevModelName) {
2045
2223
  throw new InvalidArgumentError(
2046
2224
  "The model %v has a circular inheritance.",
2047
2225
  currModelName
2048
2226
  );
2049
- if (Object.keys(pkPropDefs).length === 0)
2227
+ }
2228
+ if (Object.keys(pkPropDefs).length === 0) {
2050
2229
  pkPropDefs = this.getOwnPropertiesDefinitionOfPrimaryKeys(currModelName);
2230
+ }
2051
2231
  regularPropDefs = {
2052
2232
  ...this.getOwnPropertiesDefinitionWithoutPrimaryKeys(currModelName),
2053
2233
  ...regularPropDefs
2054
2234
  };
2055
2235
  const modelDef = this.getService(DefinitionRegistry).getModel(currModelName);
2056
- if (modelDef.base) recursion(modelDef.base, currModelName);
2236
+ if (modelDef.base) {
2237
+ recursion(modelDef.base, currModelName);
2238
+ }
2057
2239
  }, "recursion");
2058
2240
  recursion(modelName);
2059
2241
  return { ...pkPropDefs, ...regularPropDefs };
@@ -2079,15 +2261,18 @@ var init_model_definition_utils = __esm({
2079
2261
  let result = {};
2080
2262
  const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
2081
2263
  var _a;
2082
- if (currModelName === prevModelName)
2264
+ if (currModelName === prevModelName) {
2083
2265
  throw new InvalidArgumentError(
2084
2266
  "The model %v has a circular inheritance.",
2085
2267
  currModelName
2086
2268
  );
2269
+ }
2087
2270
  const modelDef = this.getService(DefinitionRegistry).getModel(currModelName);
2088
2271
  const ownRelDefs = (_a = modelDef.relations) != null ? _a : {};
2089
2272
  result = { ...ownRelDefs, ...result };
2090
- if (modelDef.base) recursion(modelDef.base, currModelName);
2273
+ if (modelDef.base) {
2274
+ recursion(modelDef.base, currModelName);
2275
+ }
2091
2276
  }, "recursion");
2092
2277
  recursion(modelName);
2093
2278
  return result;
@@ -2109,12 +2294,13 @@ var init_model_definition_utils = __esm({
2109
2294
  break;
2110
2295
  }
2111
2296
  }
2112
- if (!foundDef)
2297
+ if (!foundDef) {
2113
2298
  throw new InvalidArgumentError(
2114
2299
  "The model %v does not have relation name %v.",
2115
2300
  modelName,
2116
2301
  relationName
2117
2302
  );
2303
+ }
2118
2304
  return foundDef;
2119
2305
  }
2120
2306
  /**
@@ -2125,11 +2311,12 @@ var init_model_definition_utils = __esm({
2125
2311
  * @returns {object}
2126
2312
  */
2127
2313
  excludeObjectKeysByRelationNames(modelName, modelData) {
2128
- if (!modelData || typeof modelData !== "object" || Array.isArray(modelData))
2314
+ if (!modelData || typeof modelData !== "object" || Array.isArray(modelData)) {
2129
2315
  throw new InvalidArgumentError(
2130
2316
  "The second argument of ModelDefinitionUtils.excludeObjectKeysByRelationNames should be an Object, but %v was given.",
2131
2317
  modelData
2132
2318
  );
2319
+ }
2133
2320
  const relDefs = this.getRelationsDefinitionInBaseModelHierarchy(modelName);
2134
2321
  const relNames = Object.keys(relDefs);
2135
2322
  return excludeObjectKeys(modelData, relNames);
@@ -2142,23 +2329,30 @@ var init_model_definition_utils = __esm({
2142
2329
  * @returns {string|undefined}
2143
2330
  */
2144
2331
  getModelNameOfPropertyValueIfDefined(modelName, propertyName) {
2145
- if (!modelName || typeof modelName !== "string")
2332
+ if (!modelName || typeof modelName !== "string") {
2146
2333
  throw new InvalidArgumentError(
2147
2334
  'Parameter "modelName" of ModelDefinitionUtils.getModelNameOfPropertyValueIfDefined requires a non-empty String, but %v was given.',
2148
2335
  modelName
2149
2336
  );
2150
- if (!propertyName || typeof propertyName !== "string")
2337
+ }
2338
+ if (!propertyName || typeof propertyName !== "string") {
2151
2339
  throw new InvalidArgumentError(
2152
2340
  'Parameter "propertyName" of ModelDefinitionUtils.getModelNameOfPropertyValueIfDefined requires a non-empty String, but %v was given.',
2153
2341
  propertyName
2154
2342
  );
2343
+ }
2155
2344
  const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
2156
2345
  const propDef = propDefs[propertyName];
2157
- if (!propDef) return void 0;
2346
+ if (!propDef) {
2347
+ return void 0;
2348
+ }
2158
2349
  if (propDef && typeof propDef === "object") {
2159
- if (propDef.type === DataType.OBJECT) return propDef.model || void 0;
2160
- if (propDef.type === DataType.ARRAY)
2350
+ if (propDef.type === DataType.OBJECT) {
2351
+ return propDef.model || void 0;
2352
+ }
2353
+ if (propDef.type === DataType.ARRAY) {
2161
2354
  return propDef.itemModel || void 0;
2355
+ }
2162
2356
  }
2163
2357
  return void 0;
2164
2358
  }
@@ -2262,27 +2456,31 @@ var init_property_uniqueness_validator = __esm({
2262
2456
  * @returns {Promise<undefined>}
2263
2457
  */
2264
2458
  async validate(countMethod, methodName, modelName, modelData, modelId = void 0) {
2265
- if (typeof countMethod !== "function")
2459
+ if (typeof countMethod !== "function") {
2266
2460
  throw new InvalidArgumentError(
2267
2461
  'The parameter "countMethod" of the PropertyUniquenessValidator must be a Function, but %v was given.',
2268
2462
  countMethod
2269
2463
  );
2270
- if (!methodName || typeof methodName !== "string")
2464
+ }
2465
+ if (!methodName || typeof methodName !== "string") {
2271
2466
  throw new InvalidArgumentError(
2272
2467
  'The parameter "methodName" of the PropertyUniquenessValidator must be a non-empty String, but %v was given.',
2273
2468
  methodName
2274
2469
  );
2275
- if (!modelName || typeof modelName !== "string")
2470
+ }
2471
+ if (!modelName || typeof modelName !== "string") {
2276
2472
  throw new InvalidArgumentError(
2277
2473
  'The parameter "modelName" of the PropertyUniquenessValidator must be a non-empty String, but %v was given.',
2278
2474
  modelName
2279
2475
  );
2280
- if (!isPlainObject(modelData))
2476
+ }
2477
+ if (!isPlainObject(modelData)) {
2281
2478
  throw new InvalidArgumentError(
2282
2479
  "The data of the model %v should be an Object, but %v was given.",
2283
2480
  modelName,
2284
2481
  modelData
2285
2482
  );
2483
+ }
2286
2484
  const propDefs = this.getService(
2287
2485
  ModelDefinitionUtils
2288
2486
  ).getPropertiesDefinitionInBaseModelHierarchy(modelName);
@@ -2309,13 +2507,17 @@ var init_property_uniqueness_validator = __esm({
2309
2507
  }
2310
2508
  if (methodName === "create") {
2311
2509
  const count = await countMethod({ [propName]: propValue });
2312
- if (count > 0) throw createError(propName, propValue);
2510
+ if (count > 0) {
2511
+ throw createError(propName, propValue);
2512
+ }
2313
2513
  } else if (methodName === "replaceById") {
2314
2514
  const count = await countMethod({
2315
2515
  [idProp]: { neq: modelId },
2316
2516
  [propName]: propValue
2317
2517
  });
2318
- if (count > 0) throw createError(propName, propValue);
2518
+ if (count > 0) {
2519
+ throw createError(propName, propValue);
2520
+ }
2319
2521
  } else if (methodName === "replaceOrCreate") {
2320
2522
  const idFromData = modelData[idProp];
2321
2523
  if (willBeReplaced == null && idFromData != null) {
@@ -2327,20 +2529,28 @@ var init_property_uniqueness_validator = __esm({
2327
2529
  [idProp]: { neq: idFromData },
2328
2530
  [propName]: propValue
2329
2531
  });
2330
- if (count > 0) throw createError(propName, propValue);
2532
+ if (count > 0) {
2533
+ throw createError(propName, propValue);
2534
+ }
2331
2535
  } else {
2332
2536
  const count = await countMethod({ [propName]: propValue });
2333
- if (count > 0) throw createError(propName, propValue);
2537
+ if (count > 0) {
2538
+ throw createError(propName, propValue);
2539
+ }
2334
2540
  }
2335
2541
  } else if (methodName === "patch") {
2336
2542
  const count = await countMethod({ [propName]: propValue });
2337
- if (count > 0) throw createError(propName, propValue);
2543
+ if (count > 0) {
2544
+ throw createError(propName, propValue);
2545
+ }
2338
2546
  } else if (methodName === "patchById") {
2339
2547
  const count = await countMethod({
2340
2548
  [idProp]: { neq: modelId },
2341
2549
  [propName]: propValue
2342
2550
  });
2343
- if (count > 0) throw createError(propName, propValue);
2551
+ if (count > 0) {
2552
+ throw createError(propName, propValue);
2553
+ }
2344
2554
  } else {
2345
2555
  throw new InvalidArgumentError(
2346
2556
  "The PropertyUniquenessValidator does not support the adapter method %v.",
@@ -2377,20 +2587,22 @@ var init_primary_keys_definition_validator = __esm({
2377
2587
  });
2378
2588
  if (propNames.length < 1) {
2379
2589
  const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(DEFAULT_PRIMARY_KEY_PROPERTY_NAME);
2380
- if (isDefaultPrimaryKeyAlreadyInUse)
2590
+ if (isDefaultPrimaryKeyAlreadyInUse) {
2381
2591
  throw new InvalidArgumentError(
2382
2592
  'The property name %v of the model %v is defined as a regular property. In this case, a primary key should be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
2383
2593
  DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
2384
2594
  modelName
2385
2595
  );
2596
+ }
2386
2597
  return;
2387
2598
  }
2388
- if (propNames.length > 1)
2599
+ if (propNames.length > 1) {
2389
2600
  throw new InvalidArgumentError(
2390
2601
  "The model definition %v should not have multiple primary keys, but %v keys given.",
2391
2602
  modelName,
2392
2603
  propNames.length
2393
2604
  );
2605
+ }
2394
2606
  const pkPropName = propNames[0];
2395
2607
  const pkPropDef = propDefs[pkPropName];
2396
2608
  if (pkPropDef && typeof pkPropDef === "object" && pkPropDef.default !== void 0) {
@@ -2426,11 +2638,12 @@ var init_properties_definition_validator = __esm({
2426
2638
  * @param {object} propDefs
2427
2639
  */
2428
2640
  validate(modelName, propDefs) {
2429
- if (!modelName || typeof modelName !== "string")
2641
+ if (!modelName || typeof modelName !== "string") {
2430
2642
  throw new InvalidArgumentError(
2431
2643
  "The first argument of PropertiesDefinitionValidator.validate should be a non-empty String, but %v was given.",
2432
2644
  modelName
2433
2645
  );
2646
+ }
2434
2647
  if (!propDefs || typeof propDefs !== "object" || Array.isArray(propDefs)) {
2435
2648
  throw new InvalidArgumentError(
2436
2649
  'The provided option "properties" of the model %v should be an Object, but %v was given.',
@@ -2456,26 +2669,29 @@ var init_properties_definition_validator = __esm({
2456
2669
  * @param {object} propDef
2457
2670
  */
2458
2671
  _validateProperty(modelName, propName, propDef) {
2459
- if (!modelName || typeof modelName !== "string")
2672
+ if (!modelName || typeof modelName !== "string") {
2460
2673
  throw new InvalidArgumentError(
2461
2674
  "The first argument of PropertiesDefinitionValidator._validateProperty should be a non-empty String, but %v was given.",
2462
2675
  modelName
2463
2676
  );
2464
- if (!propName || typeof propName !== "string")
2677
+ }
2678
+ if (!propName || typeof propName !== "string") {
2465
2679
  throw new InvalidArgumentError(
2466
2680
  "The property name of the model %v should be a non-empty String, but %v was given.",
2467
2681
  modelName,
2468
2682
  propName
2469
2683
  );
2470
- if (!propDef)
2684
+ }
2685
+ if (!propDef) {
2471
2686
  throw new InvalidArgumentError(
2472
2687
  "The property %v of the model %v should have a property definition, but %v was given.",
2473
2688
  propName,
2474
2689
  modelName,
2475
2690
  propDef
2476
2691
  );
2692
+ }
2477
2693
  if (typeof propDef === "string") {
2478
- if (!Object.values(DataType).includes(propDef))
2694
+ if (!Object.values(DataType).includes(propDef)) {
2479
2695
  throw new InvalidArgumentError(
2480
2696
  "In case of a short property definition, the property %v of the model %v should have one of data types: %l, but %v was given.",
2481
2697
  propName,
@@ -2483,6 +2699,7 @@ var init_properties_definition_validator = __esm({
2483
2699
  Object.values(DataType),
2484
2700
  propDef
2485
2701
  );
2702
+ }
2486
2703
  return;
2487
2704
  }
2488
2705
  if (!propDef || typeof propDef !== "object" || Array.isArray(propDef)) {
@@ -2493,7 +2710,7 @@ var init_properties_definition_validator = __esm({
2493
2710
  propDef
2494
2711
  );
2495
2712
  }
2496
- if (!propDef.type || !Object.values(DataType).includes(propDef.type))
2713
+ if (!propDef.type || !Object.values(DataType).includes(propDef.type)) {
2497
2714
  throw new InvalidArgumentError(
2498
2715
  'The property %v of the model %v requires the option "type" to have one of data types: %l, but %v was given.',
2499
2716
  propName,
@@ -2501,6 +2718,7 @@ var init_properties_definition_validator = __esm({
2501
2718
  Object.values(DataType),
2502
2719
  propDef.type
2503
2720
  );
2721
+ }
2504
2722
  if (propDef.itemType && !Object.values(DataType).includes(propDef.itemType)) {
2505
2723
  throw new InvalidArgumentError(
2506
2724
  'The provided option "itemType" of the property %v in the model %v should have one of data types: %l, but %v was given.',
@@ -2518,73 +2736,83 @@ var init_properties_definition_validator = __esm({
2518
2736
  propDef.itemModel
2519
2737
  );
2520
2738
  }
2521
- if (propDef.model && typeof propDef.model !== "string")
2739
+ if (propDef.model && typeof propDef.model !== "string") {
2522
2740
  throw new InvalidArgumentError(
2523
2741
  'The provided option "model" of the property %v in the model %v should be a String, but %v was given.',
2524
2742
  propName,
2525
2743
  modelName,
2526
2744
  propDef.model
2527
2745
  );
2528
- if (propDef.primaryKey && typeof propDef.primaryKey !== "boolean")
2746
+ }
2747
+ if (propDef.primaryKey && typeof propDef.primaryKey !== "boolean") {
2529
2748
  throw new InvalidArgumentError(
2530
2749
  'The provided option "primaryKey" of the property %v in the model %v should be a Boolean, but %v was given.',
2531
2750
  propName,
2532
2751
  modelName,
2533
2752
  propDef.primaryKey
2534
2753
  );
2535
- if (propDef.columnName && typeof propDef.columnName !== "string")
2754
+ }
2755
+ if (propDef.columnName && typeof propDef.columnName !== "string") {
2536
2756
  throw new InvalidArgumentError(
2537
2757
  'The provided option "columnName" of the property %v in the model %v should be a String, but %v was given.',
2538
2758
  propName,
2539
2759
  modelName,
2540
2760
  propDef.columnName
2541
2761
  );
2542
- if (propDef.columnType && typeof propDef.columnType !== "string")
2762
+ }
2763
+ if (propDef.columnType && typeof propDef.columnType !== "string") {
2543
2764
  throw new InvalidArgumentError(
2544
2765
  'The provided option "columnType" of the property %v in the model %v should be a String, but %v was given.',
2545
2766
  propName,
2546
2767
  modelName,
2547
2768
  propDef.columnType
2548
2769
  );
2549
- if (propDef.required && typeof propDef.required !== "boolean")
2770
+ }
2771
+ if (propDef.required && typeof propDef.required !== "boolean") {
2550
2772
  throw new InvalidArgumentError(
2551
2773
  'The provided option "required" of the property %v in the model %v should be a Boolean, but %v was given.',
2552
2774
  propName,
2553
2775
  modelName,
2554
2776
  propDef.required
2555
2777
  );
2556
- if (propDef.required && propDef.default !== void 0)
2778
+ }
2779
+ if (propDef.required && propDef.default !== void 0) {
2557
2780
  throw new InvalidArgumentError(
2558
2781
  'The property %v of the model %v is a required property, so it should not have the option "default" to be provided.',
2559
2782
  propName,
2560
2783
  modelName
2561
2784
  );
2562
- if (propDef.primaryKey && propDef.required)
2785
+ }
2786
+ if (propDef.primaryKey && propDef.required) {
2563
2787
  throw new InvalidArgumentError(
2564
2788
  'The property %v of the model %v is a primary key, so it should not have the option "required" to be provided.',
2565
2789
  propName,
2566
2790
  modelName
2567
2791
  );
2568
- if (propDef.primaryKey && propDef.default !== void 0)
2792
+ }
2793
+ if (propDef.primaryKey && propDef.default !== void 0) {
2569
2794
  throw new InvalidArgumentError(
2570
2795
  'The property %v of the model %v is a primary key, so it should not have the option "default" to be provided.',
2571
2796
  propName,
2572
2797
  modelName
2573
2798
  );
2574
- if (propDef.itemType && propDef.type !== DataType.ARRAY)
2799
+ }
2800
+ if (propDef.itemType && propDef.type !== DataType.ARRAY) {
2575
2801
  throw new InvalidArgumentError(
2576
2802
  'The property %v of the model %v has a non-array type, so it should not have the option "itemType" to be provided.',
2577
2803
  propName,
2578
2804
  modelName,
2579
2805
  propDef.type
2580
2806
  );
2581
- if (propDef.itemModel && propDef.type !== DataType.ARRAY)
2807
+ }
2808
+ if (propDef.itemModel && propDef.type !== DataType.ARRAY) {
2582
2809
  throw new InvalidArgumentError(
2583
2810
  'The option "itemModel" is not supported for %s property type, so the property %v of the model %v should not have the option "itemModel" to be provided.',
2584
2811
  capitalize(propDef.type),
2585
2812
  propName,
2586
2813
  modelName
2587
2814
  );
2815
+ }
2588
2816
  if (propDef.itemModel && propDef.itemType !== DataType.OBJECT) {
2589
2817
  if (propDef.itemType) {
2590
2818
  throw new InvalidArgumentError(
@@ -2601,13 +2829,14 @@ var init_properties_definition_validator = __esm({
2601
2829
  );
2602
2830
  }
2603
2831
  }
2604
- if (propDef.model && propDef.type !== DataType.OBJECT)
2832
+ if (propDef.model && propDef.type !== DataType.OBJECT) {
2605
2833
  throw new InvalidArgumentError(
2606
2834
  'The option "model" is not supported for %s property type, so the property %v of the model %v should not have the option "model" to be provided.',
2607
2835
  capitalize(propDef.type),
2608
2836
  propName,
2609
2837
  modelName
2610
2838
  );
2839
+ }
2611
2840
  if (propDef.unique) {
2612
2841
  if (typeof propDef.unique !== "boolean" && !Object.values(PropertyUniqueness).includes(propDef.unique)) {
2613
2842
  throw new InvalidArgumentError(
@@ -2619,12 +2848,13 @@ var init_properties_definition_validator = __esm({
2619
2848
  );
2620
2849
  }
2621
2850
  }
2622
- if (propDef.unique && propDef.primaryKey)
2851
+ if (propDef.unique && propDef.primaryKey) {
2623
2852
  throw new InvalidArgumentError(
2624
2853
  'The property %v of the model %v is a primary key, so it should not have the option "unique" to be provided.',
2625
2854
  propName,
2626
2855
  modelName
2627
2856
  );
2857
+ }
2628
2858
  }
2629
2859
  };
2630
2860
  __name(_PropertiesDefinitionValidator, "PropertiesDefinitionValidator");
@@ -2670,16 +2900,18 @@ var init_model_data_sanitizer = __esm({
2670
2900
  * @returns {object}
2671
2901
  */
2672
2902
  sanitize(modelName, modelData) {
2673
- if (!modelName || typeof modelName !== "string")
2903
+ if (!modelName || typeof modelName !== "string") {
2674
2904
  throw new InvalidArgumentError(
2675
2905
  "The first argument of ModelDataSanitizer.sanitize should be a string, but %v was given.",
2676
2906
  modelName
2677
2907
  );
2678
- if (!modelData || typeof modelData !== "object")
2908
+ }
2909
+ if (!modelData || typeof modelData !== "object") {
2679
2910
  throw new InvalidArgumentError(
2680
2911
  "The second argument of ModelDataSanitizer.sanitize should be an Object, but %v was given.",
2681
2912
  modelData
2682
2913
  );
2914
+ }
2683
2915
  return this.getService(
2684
2916
  ModelDefinitionUtils
2685
2917
  ).excludeObjectKeysByRelationNames(modelName, modelData);
@@ -2706,34 +2938,39 @@ var init_model_definition_validator = __esm({
2706
2938
  * @param {object} modelDef
2707
2939
  */
2708
2940
  validate(modelDef) {
2709
- if (!modelDef || typeof modelDef !== "object" || Array.isArray(modelDef))
2941
+ if (!modelDef || typeof modelDef !== "object" || Array.isArray(modelDef)) {
2710
2942
  throw new InvalidArgumentError(
2711
2943
  "The model definition should be an Object, but %v was given.",
2712
2944
  modelDef
2713
2945
  );
2714
- if (!modelDef.name || typeof modelDef.name !== "string")
2946
+ }
2947
+ if (!modelDef.name || typeof modelDef.name !== "string") {
2715
2948
  throw new InvalidArgumentError(
2716
2949
  'The model definition requires the option "name" as a non-empty String, but %v was given.',
2717
2950
  modelDef.name
2718
2951
  );
2719
- if (modelDef.datasource && typeof modelDef.datasource !== "string")
2952
+ }
2953
+ if (modelDef.datasource && typeof modelDef.datasource !== "string") {
2720
2954
  throw new InvalidArgumentError(
2721
2955
  'The provided option "datasource" of the model %v should be a String, but %v was given.',
2722
2956
  modelDef.name,
2723
2957
  modelDef.datasource
2724
2958
  );
2725
- if (modelDef.base && typeof modelDef.base !== "string")
2959
+ }
2960
+ if (modelDef.base && typeof modelDef.base !== "string") {
2726
2961
  throw new InvalidArgumentError(
2727
2962
  'The provided option "base" of the model %v should be a String, but %v was given.',
2728
2963
  modelDef.name,
2729
2964
  modelDef.base
2730
2965
  );
2731
- if (modelDef.tableName && typeof modelDef.tableName !== "string")
2966
+ }
2967
+ if (modelDef.tableName && typeof modelDef.tableName !== "string") {
2732
2968
  throw new InvalidArgumentError(
2733
2969
  'The provided option "tableName" of the model %v should be a String, but %v was given.',
2734
2970
  modelDef.name,
2735
2971
  modelDef.tableName
2736
2972
  );
2973
+ }
2737
2974
  if (modelDef.properties) {
2738
2975
  if (typeof modelDef.properties !== "object" || Array.isArray(modelDef.properties)) {
2739
2976
  throw new InvalidArgumentError(
@@ -2794,22 +3031,25 @@ var init_datasource_definition_validator = __esm({
2794
3031
  * @param {object} datasourceDef
2795
3032
  */
2796
3033
  validate(datasourceDef) {
2797
- if (!datasourceDef || typeof datasourceDef !== "object")
3034
+ if (!datasourceDef || typeof datasourceDef !== "object") {
2798
3035
  throw new InvalidArgumentError(
2799
3036
  "The datasource definition should be an Object, but %v was given.",
2800
3037
  datasourceDef
2801
3038
  );
2802
- if (!datasourceDef.name || typeof datasourceDef.name !== "string")
3039
+ }
3040
+ if (!datasourceDef.name || typeof datasourceDef.name !== "string") {
2803
3041
  throw new InvalidArgumentError(
2804
3042
  'The datasource definition requires the option "name" as a non-empty String, but %v was given.',
2805
3043
  datasourceDef.name
2806
3044
  );
2807
- if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string")
3045
+ }
3046
+ if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string") {
2808
3047
  throw new InvalidArgumentError(
2809
3048
  'The datasource %v requires the option "adapter" as a non-empty String, but %v was given.',
2810
3049
  datasourceDef.name,
2811
3050
  datasourceDef.adapter
2812
3051
  );
3052
+ }
2813
3053
  }
2814
3054
  };
2815
3055
  __name(_DatasourceDefinitionValidator, "DatasourceDefinitionValidator");
@@ -2857,31 +3097,40 @@ var init_fields_clause_tool = __esm({
2857
3097
  const isArray = Array.isArray(input);
2858
3098
  let entities = isArray ? input : [input];
2859
3099
  entities.forEach((entity) => {
2860
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
3100
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
2861
3101
  throw new InvalidArgumentError(
2862
3102
  "The first argument of FieldsClauseTool.filter should be an Object or an Array of Object, but %v was given.",
2863
3103
  entity
2864
3104
  );
3105
+ }
2865
3106
  });
2866
- if (!modelName || typeof modelName !== "string")
3107
+ if (!modelName || typeof modelName !== "string") {
2867
3108
  throw new InvalidArgumentError(
2868
3109
  "The second argument of FieldsClauseTool.filter should be a non-empty String, but %v was given.",
2869
3110
  modelName
2870
3111
  );
2871
- if (clause == null) return input;
3112
+ }
3113
+ if (clause == null) {
3114
+ return input;
3115
+ }
2872
3116
  const fields = Array.isArray(clause) ? clause.slice() : [clause];
2873
- if (!fields.length) return input;
3117
+ if (!fields.length) {
3118
+ return input;
3119
+ }
2874
3120
  fields.forEach((field) => {
2875
- if (!field || typeof field !== "string")
3121
+ if (!field || typeof field !== "string") {
2876
3122
  throw new InvalidArgumentError(
2877
3123
  'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
2878
3124
  field
2879
3125
  );
3126
+ }
2880
3127
  });
2881
3128
  const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
2882
3129
  modelName
2883
3130
  );
2884
- if (fields.indexOf(pkPropName) === -1) fields.push(pkPropName);
3131
+ if (fields.indexOf(pkPropName) === -1) {
3132
+ fields.push(pkPropName);
3133
+ }
2885
3134
  entities = entities.map((entity) => selectObjectKeys(entity, fields));
2886
3135
  return isArray ? entities : entities[0];
2887
3136
  }
@@ -2891,15 +3140,20 @@ var init_fields_clause_tool = __esm({
2891
3140
  * @param {string|string[]|undefined} clause
2892
3141
  */
2893
3142
  static validateFieldsClause(clause) {
2894
- if (clause == null) return;
3143
+ if (clause == null) {
3144
+ return;
3145
+ }
2895
3146
  const fields = Array.isArray(clause) ? clause : [clause];
2896
- if (!fields.length) return;
3147
+ if (!fields.length) {
3148
+ return;
3149
+ }
2897
3150
  fields.forEach((field) => {
2898
- if (!field || typeof field !== "string")
3151
+ if (!field || typeof field !== "string") {
2899
3152
  throw new InvalidArgumentError(
2900
3153
  'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
2901
3154
  field
2902
3155
  );
3156
+ }
2903
3157
  });
2904
3158
  }
2905
3159
  /**
@@ -2909,15 +3163,20 @@ var init_fields_clause_tool = __esm({
2909
3163
  * @returns {string[]|undefined}
2910
3164
  */
2911
3165
  static normalizeFieldsClause(clause) {
2912
- if (clause == null) return;
3166
+ if (clause == null) {
3167
+ return;
3168
+ }
2913
3169
  const fields = Array.isArray(clause) ? clause : [clause];
2914
- if (!fields.length) return;
3170
+ if (!fields.length) {
3171
+ return;
3172
+ }
2915
3173
  fields.forEach((field) => {
2916
- if (!field || typeof field !== "string")
3174
+ if (!field || typeof field !== "string") {
2917
3175
  throw new InvalidArgumentError(
2918
3176
  'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v was given.',
2919
3177
  field
2920
3178
  );
3179
+ }
2921
3180
  });
2922
3181
  return fields;
2923
3182
  }
@@ -2943,18 +3202,20 @@ var init_inclusion_decorator = __esm({
2943
3202
  * @param {Adapter} adapter
2944
3203
  */
2945
3204
  decorate(adapter) {
2946
- if (!adapter || !(adapter instanceof Adapter))
3205
+ if (!adapter || !(adapter instanceof Adapter)) {
2947
3206
  throw new InvalidArgumentError(
2948
3207
  "The first argument of InclusionDecorator.decorate should be an Adapter instance, but %v was given.",
2949
3208
  adapter
2950
3209
  );
3210
+ }
2951
3211
  const tool = adapter.getService(IncludeClauseTool);
2952
3212
  const includeTo = /* @__PURE__ */ __name((...args) => tool.includeTo(...args), "includeTo");
2953
3213
  const create = adapter.create;
2954
3214
  adapter.create = async function(modelName, modelData, filter) {
2955
3215
  const retvalData = await create.call(this, modelName, modelData, filter);
2956
- if (filter && typeof filter === "object" && filter.include)
3216
+ if (filter && typeof filter === "object" && filter.include) {
2957
3217
  await includeTo([retvalData], modelName, filter.include);
3218
+ }
2958
3219
  return retvalData;
2959
3220
  };
2960
3221
  const replaceById = adapter.replaceById;
@@ -2966,8 +3227,9 @@ var init_inclusion_decorator = __esm({
2966
3227
  modelData,
2967
3228
  filter
2968
3229
  );
2969
- if (filter && typeof filter === "object" && filter.include)
3230
+ if (filter && typeof filter === "object" && filter.include) {
2970
3231
  await includeTo([retvalData], modelName, filter.include);
3232
+ }
2971
3233
  return retvalData;
2972
3234
  };
2973
3235
  const replaceOrCreate = adapter.replaceOrCreate;
@@ -2978,8 +3240,9 @@ var init_inclusion_decorator = __esm({
2978
3240
  modelData,
2979
3241
  filter
2980
3242
  );
2981
- if (filter && typeof filter === "object" && filter.include)
3243
+ if (filter && typeof filter === "object" && filter.include) {
2982
3244
  await includeTo([retvalData], modelName, filter.include);
3245
+ }
2983
3246
  return retvalData;
2984
3247
  };
2985
3248
  const patchById = adapter.patchById;
@@ -2991,22 +3254,25 @@ var init_inclusion_decorator = __esm({
2991
3254
  modelData,
2992
3255
  filter
2993
3256
  );
2994
- if (filter && typeof filter === "object" && filter.include)
3257
+ if (filter && typeof filter === "object" && filter.include) {
2995
3258
  await includeTo([retvalData], modelName, filter.include);
3259
+ }
2996
3260
  return retvalData;
2997
3261
  };
2998
3262
  const find = adapter.find;
2999
3263
  adapter.find = async function(modelName, filter) {
3000
3264
  const modelItems = await find.call(this, modelName, filter);
3001
- if (filter && typeof filter === "object" && filter.include)
3265
+ if (filter && typeof filter === "object" && filter.include) {
3002
3266
  await includeTo(modelItems, modelName, filter.include);
3267
+ }
3003
3268
  return modelItems;
3004
3269
  };
3005
3270
  const findById = adapter.findById;
3006
3271
  adapter.findById = async function(modelName, id, filter) {
3007
3272
  const retvalData = await findById.call(this, modelName, id, filter);
3008
- if (filter && typeof filter === "object" && filter.include)
3273
+ if (filter && typeof filter === "object" && filter.include) {
3009
3274
  await includeTo([retvalData], modelName, filter.include);
3275
+ }
3010
3276
  return retvalData;
3011
3277
  };
3012
3278
  }
@@ -3032,11 +3298,12 @@ var init_default_values_decorator = __esm({
3032
3298
  * @param {Adapter} adapter
3033
3299
  */
3034
3300
  decorate(adapter) {
3035
- if (!adapter || !(adapter instanceof Adapter))
3301
+ if (!adapter || !(adapter instanceof Adapter)) {
3036
3302
  throw new InvalidArgumentError(
3037
3303
  "The first argument of DefaultValuesDecorator.decorate should be an Adapter instance, but %v was given.",
3038
3304
  adapter
3039
3305
  );
3306
+ }
3040
3307
  const utils = adapter.getService(ModelDefinitionUtils);
3041
3308
  const setDefaults = /* @__PURE__ */ __name((...args) => utils.setDefaultValuesToEmptyProperties(...args), "setDefaults");
3042
3309
  const create = adapter.create;
@@ -3097,11 +3364,12 @@ var init_data_sanitizing_decorator = __esm({
3097
3364
  * @param {Adapter} adapter
3098
3365
  */
3099
3366
  decorate(adapter) {
3100
- if (!adapter || !(adapter instanceof Adapter))
3367
+ if (!adapter || !(adapter instanceof Adapter)) {
3101
3368
  throw new InvalidArgumentError(
3102
3369
  "The first argument of DataSanitizingDecorator.decorate should be an Adapter instance, but %v was given.",
3103
3370
  adapter
3104
3371
  );
3372
+ }
3105
3373
  const sanitizer = adapter.getService(ModelDataSanitizer);
3106
3374
  const sanitize = /* @__PURE__ */ __name((...args) => sanitizer.sanitize(...args), "sanitize");
3107
3375
  const create = adapter.create;
@@ -3152,18 +3420,20 @@ var init_fields_filtering_decorator = __esm({
3152
3420
  * @param {Adapter} adapter
3153
3421
  */
3154
3422
  decorate(adapter) {
3155
- if (!adapter || !(adapter instanceof Adapter))
3423
+ if (!adapter || !(adapter instanceof Adapter)) {
3156
3424
  throw new InvalidArgumentError(
3157
3425
  "The first argument of FieldsFilteringDecorator.decorate should be an Adapter instance, but %v was given.",
3158
3426
  adapter
3159
3427
  );
3428
+ }
3160
3429
  const tool = adapter.getService(FieldsClauseTool);
3161
3430
  const selectFields = /* @__PURE__ */ __name((...args) => tool.filter(...args), "selectFields");
3162
3431
  const create = adapter.create;
3163
3432
  adapter.create = async function(modelName, modelData, filter) {
3164
3433
  let result = await create.call(this, modelName, modelData, filter);
3165
- if (filter && typeof filter === "object" && filter.fields)
3434
+ if (filter && typeof filter === "object" && filter.fields) {
3166
3435
  result = selectFields(result, modelName, filter.fields);
3436
+ }
3167
3437
  return result;
3168
3438
  };
3169
3439
  const replaceById = adapter.replaceById;
@@ -3175,8 +3445,9 @@ var init_fields_filtering_decorator = __esm({
3175
3445
  modelData,
3176
3446
  filter
3177
3447
  );
3178
- if (filter && typeof filter === "object" && filter.fields)
3448
+ if (filter && typeof filter === "object" && filter.fields) {
3179
3449
  result = selectFields(result, modelName, filter.fields);
3450
+ }
3180
3451
  return result;
3181
3452
  };
3182
3453
  const replaceOrCreate = adapter.replaceOrCreate;
@@ -3187,29 +3458,33 @@ var init_fields_filtering_decorator = __esm({
3187
3458
  modelData,
3188
3459
  filter
3189
3460
  );
3190
- if (filter && typeof filter === "object" && filter.fields)
3461
+ if (filter && typeof filter === "object" && filter.fields) {
3191
3462
  result = selectFields(result, modelName, filter.fields);
3463
+ }
3192
3464
  return result;
3193
3465
  };
3194
3466
  const patchById = adapter.patchById;
3195
3467
  adapter.patchById = async function(modelName, id, modelData, filter) {
3196
3468
  let result = await patchById.call(this, modelName, id, modelData, filter);
3197
- if (filter && typeof filter === "object" && filter.fields)
3469
+ if (filter && typeof filter === "object" && filter.fields) {
3198
3470
  result = selectFields(result, modelName, filter.fields);
3471
+ }
3199
3472
  return result;
3200
3473
  };
3201
3474
  const find = adapter.find;
3202
3475
  adapter.find = async function(modelName, filter) {
3203
3476
  let result = await find.call(this, modelName, filter);
3204
- if (filter && typeof filter === "object" && filter.fields)
3477
+ if (filter && typeof filter === "object" && filter.fields) {
3205
3478
  result = selectFields(result, modelName, filter.fields);
3479
+ }
3206
3480
  return result;
3207
3481
  };
3208
3482
  const findById = adapter.findById;
3209
3483
  adapter.findById = async function(modelName, id, filter) {
3210
3484
  let result = await findById.call(this, modelName, id, filter);
3211
- if (filter && typeof filter === "object" && filter.fields)
3485
+ if (filter && typeof filter === "object" && filter.fields) {
3212
3486
  result = selectFields(result, modelName, filter.fields);
3487
+ }
3213
3488
  return result;
3214
3489
  };
3215
3490
  }
@@ -3235,11 +3510,12 @@ var init_required_property_decorator = __esm({
3235
3510
  * @param {Adapter} adapter
3236
3511
  */
3237
3512
  decorate(adapter) {
3238
- if (!adapter || !(adapter instanceof Adapter))
3513
+ if (!adapter || !(adapter instanceof Adapter)) {
3239
3514
  throw new InvalidArgumentError(
3240
3515
  "The first argument of RequiredPropertyDecorator.decorate should be an Adapter instance, but %v was given.",
3241
3516
  adapter
3242
3517
  );
3518
+ }
3243
3519
  const validator = this.getService(RequiredPropertyValidator);
3244
3520
  const create = adapter.create;
3245
3521
  adapter.create = async function(modelName, modelData, filter) {
@@ -3289,11 +3565,12 @@ var init_property_uniqueness_decorator = __esm({
3289
3565
  * @param {Adapter} adapter
3290
3566
  */
3291
3567
  decorate(adapter) {
3292
- if (!adapter || !(adapter instanceof Adapter))
3568
+ if (!adapter || !(adapter instanceof Adapter)) {
3293
3569
  throw new InvalidArgumentError(
3294
3570
  "The first argument of PropertyUniquenessDecorator.decorate should be an Adapter instance, but %v was given.",
3295
3571
  adapter
3296
3572
  );
3573
+ }
3297
3574
  const validator = this.getService(PropertyUniquenessValidator);
3298
3575
  const create = adapter.create;
3299
3576
  adapter.create = async function(modelName, modelData, filter) {
@@ -3603,7 +3880,9 @@ var init_memory_adapter = __esm({
3603
3880
  _getTableOrCreate(modelName) {
3604
3881
  const tableName = this.getService(ModelDefinitionUtils).getTableNameByModelName(modelName);
3605
3882
  let table = this._tables.get(tableName);
3606
- if (table) return table;
3883
+ if (table) {
3884
+ return table;
3885
+ }
3607
3886
  table = /* @__PURE__ */ new Map();
3608
3887
  this._tables.set(tableName, table);
3609
3888
  return table;
@@ -3675,13 +3954,14 @@ var init_memory_adapter = __esm({
3675
3954
  this._updateLastIdValueIfNeeded(modelName, idValue);
3676
3955
  }
3677
3956
  const table = this._getTableOrCreate(modelName);
3678
- if (table.has(idValue))
3957
+ if (table.has(idValue)) {
3679
3958
  throw new InvalidArgumentError(
3680
3959
  "The value %v of the primary key %v already exists in the model %v.",
3681
3960
  idValue,
3682
3961
  pkPropName,
3683
3962
  modelName
3684
3963
  );
3964
+ }
3685
3965
  modelData = cloneDeep(modelData);
3686
3966
  modelData[pkPropName] = idValue;
3687
3967
  const tableData = this.getService(
@@ -3708,13 +3988,14 @@ var init_memory_adapter = __esm({
3708
3988
  const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
3709
3989
  modelName
3710
3990
  );
3711
- if (!isExists)
3991
+ if (!isExists) {
3712
3992
  throw new InvalidArgumentError(
3713
3993
  "The value %v of the primary key %v does not exist in the model %v.",
3714
3994
  id,
3715
3995
  pkPropName,
3716
3996
  modelName
3717
3997
  );
3998
+ }
3718
3999
  modelData = cloneDeep(modelData);
3719
4000
  modelData[pkPropName] = id;
3720
4001
  const tableData = this.getService(
@@ -3766,15 +4047,18 @@ var init_memory_adapter = __esm({
3766
4047
  async patch(modelName, modelData, where = void 0) {
3767
4048
  const table = this._getTableOrCreate(modelName);
3768
4049
  const tableItems = Array.from(table.values());
3769
- if (!tableItems.length) return 0;
4050
+ if (!tableItems.length) {
4051
+ return 0;
4052
+ }
3770
4053
  let modelItems = tableItems.map(
3771
4054
  (tableItem) => this.getService(ModelDefinitionUtils).convertColumnNamesToPropertyNames(
3772
4055
  modelName,
3773
4056
  tableItem
3774
4057
  )
3775
4058
  );
3776
- if (where && typeof where === "object")
4059
+ if (where && typeof where === "object") {
3777
4060
  modelItems = this.getService(WhereClauseTool).filter(modelItems, where);
4061
+ }
3778
4062
  const size = modelItems.length;
3779
4063
  const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
3780
4064
  modelName
@@ -3807,13 +4091,14 @@ var init_memory_adapter = __esm({
3807
4091
  const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
3808
4092
  modelName
3809
4093
  );
3810
- if (existingTableData == null)
4094
+ if (existingTableData == null) {
3811
4095
  throw new InvalidArgumentError(
3812
4096
  "The value %v of the primary key %v does not exist in the model %v.",
3813
4097
  id,
3814
4098
  pkPropName,
3815
4099
  modelName
3816
4100
  );
4101
+ }
3817
4102
  modelData = cloneDeep(modelData);
3818
4103
  delete modelData[pkPropName];
3819
4104
  const existingModelData = this.getService(
@@ -3845,19 +4130,22 @@ var init_memory_adapter = __esm({
3845
4130
  )
3846
4131
  );
3847
4132
  if (filter && typeof filter === "object") {
3848
- if (filter.where)
4133
+ if (filter.where) {
3849
4134
  modelItems = this.getService(WhereClauseTool).filter(
3850
4135
  modelItems,
3851
4136
  filter.where
3852
4137
  );
3853
- if (filter.skip || filter.limit)
4138
+ }
4139
+ if (filter.skip || filter.limit) {
3854
4140
  modelItems = this.getService(SliceClauseTool).slice(
3855
4141
  modelItems,
3856
4142
  filter.skip,
3857
4143
  filter.limit
3858
4144
  );
3859
- if (filter.order)
4145
+ }
4146
+ if (filter.order) {
3860
4147
  this.getService(OrderClauseTool).sort(modelItems, filter.order);
4148
+ }
3861
4149
  }
3862
4150
  return modelItems;
3863
4151
  }
@@ -3876,13 +4164,14 @@ var init_memory_adapter = __esm({
3876
4164
  const pkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
3877
4165
  modelName
3878
4166
  );
3879
- if (!tableData)
4167
+ if (!tableData) {
3880
4168
  throw new InvalidArgumentError(
3881
4169
  "The value %v of the primary key %v does not exist in the model %v.",
3882
4170
  id,
3883
4171
  pkPropName,
3884
4172
  modelName
3885
4173
  );
4174
+ }
3886
4175
  return this.getService(
3887
4176
  ModelDefinitionUtils
3888
4177
  ).convertColumnNamesToPropertyNames(modelName, tableData);
@@ -3897,15 +4186,18 @@ var init_memory_adapter = __esm({
3897
4186
  async delete(modelName, where = void 0) {
3898
4187
  const table = this._getTableOrCreate(modelName);
3899
4188
  const tableItems = Array.from(table.values());
3900
- if (!tableItems.length) return 0;
4189
+ if (!tableItems.length) {
4190
+ return 0;
4191
+ }
3901
4192
  let modelItems = tableItems.map(
3902
4193
  (tableItem) => this.getService(ModelDefinitionUtils).convertColumnNamesToPropertyNames(
3903
4194
  modelName,
3904
4195
  tableItem
3905
4196
  )
3906
4197
  );
3907
- if (where && typeof where === "object")
4198
+ if (where && typeof where === "object") {
3908
4199
  modelItems = this.getService(WhereClauseTool).filter(modelItems, where);
4200
+ }
3909
4201
  const size = modelItems.length;
3910
4202
  const idPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
3911
4203
  modelName
@@ -3956,8 +4248,9 @@ var init_memory_adapter = __esm({
3956
4248
  tableItem
3957
4249
  )
3958
4250
  );
3959
- if (where && typeof where === "object")
4251
+ if (where && typeof where === "object") {
3960
4252
  modelItems = this.getService(WhereClauseTool).filter(modelItems, where);
4253
+ }
3961
4254
  return modelItems.length;
3962
4255
  }
3963
4256
  };
@@ -3979,7 +4272,9 @@ var init_ = __esm({
3979
4272
  // src/adapter/adapter-loader.js
3980
4273
  function findAdapterCtorInModule(module2) {
3981
4274
  let adapterCtor;
3982
- if (!module2 || typeof module2 !== "object" || Array.isArray(module2)) return;
4275
+ if (!module2 || typeof module2 !== "object" || Array.isArray(module2)) {
4276
+ return;
4277
+ }
3983
4278
  for (const ctor of Object.values(module2)) {
3984
4279
  if (typeof ctor === "function" && Array.isArray(ctor.kinds) && Adapter.kinds.includes(ADAPTER_CLASS_NAME)) {
3985
4280
  adapterCtor = ctor;
@@ -4005,28 +4300,31 @@ var init_adapter_loader = __esm({
4005
4300
  * @returns {Promise<Adapter>}
4006
4301
  */
4007
4302
  async loadByName(adapterName, settings = void 0) {
4008
- if (!adapterName || typeof adapterName !== "string")
4303
+ if (!adapterName || typeof adapterName !== "string") {
4009
4304
  throw new InvalidArgumentError(
4010
4305
  "The adapter name should be a non-empty String, but %v was given.",
4011
4306
  adapterName
4012
4307
  );
4308
+ }
4013
4309
  let adapterCtor;
4014
4310
  try {
4015
4311
  const module2 = await globImport_builtin_adapter_js(`./builtin/${adapterName}-adapter.js`);
4016
4312
  adapterCtor = findAdapterCtorInModule(module2);
4017
4313
  } catch {
4018
4314
  }
4019
- if (!adapterCtor)
4315
+ if (!adapterCtor) {
4020
4316
  try {
4021
4317
  const module2 = await Promise.resolve().then(() => __toESM(require(`@e22m4u/js-repository-${adapterName}-adapter`)));
4022
4318
  adapterCtor = findAdapterCtorInModule(module2);
4023
4319
  } catch {
4024
4320
  }
4025
- if (!adapterCtor)
4321
+ }
4322
+ if (!adapterCtor) {
4026
4323
  throw new InvalidArgumentError(
4027
4324
  "The adapter %v is not found.",
4028
4325
  adapterName
4029
4326
  );
4327
+ }
4030
4328
  return new adapterCtor(this.container, settings);
4031
4329
  }
4032
4330
  };
@@ -4060,7 +4358,9 @@ var init_adapter_registry = __esm({
4060
4358
  */
4061
4359
  async getAdapter(datasourceName) {
4062
4360
  let adapter = this._adapters[datasourceName];
4063
- if (adapter) return adapter;
4361
+ if (adapter) {
4362
+ return adapter;
4363
+ }
4064
4364
  const datasource = this.getService(DefinitionRegistry).getDatasource(datasourceName);
4065
4365
  const adapterName = datasource.adapter;
4066
4366
  adapter = await this.getService(AdapterLoader).loadByName(
@@ -4136,11 +4436,12 @@ var init_repository = __esm({
4136
4436
  this._modelName = modelName;
4137
4437
  const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
4138
4438
  const datasourceName = modelDef.datasource;
4139
- if (!datasourceName)
4439
+ if (!datasourceName) {
4140
4440
  throw new InvalidArgumentError(
4141
4441
  "The model %v does not have a specified datasource.",
4142
4442
  modelName
4143
4443
  );
4444
+ }
4144
4445
  this._datasourceName = datasourceName;
4145
4446
  }
4146
4447
  /**
@@ -4334,7 +4635,9 @@ var init_repository_registry = __esm({
4334
4635
  getRepository(modelName) {
4335
4636
  const modelKey = modelNameToModelKey(modelName);
4336
4637
  let repository = this._repositories[modelKey];
4337
- if (repository) return repository;
4638
+ if (repository) {
4639
+ return repository;
4640
+ }
4338
4641
  repository = new this._repositoryCtor(this.container, modelName);
4339
4642
  this._repositories[modelKey] = repository;
4340
4643
  return repository;
@@ -4377,48 +4680,57 @@ var init_has_one_resolver = __esm({
4377
4680
  * @returns {Promise<void>}
4378
4681
  */
4379
4682
  async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
4380
- if (!entities || !Array.isArray(entities))
4683
+ if (!entities || !Array.isArray(entities)) {
4381
4684
  throw new InvalidArgumentError(
4382
4685
  'The parameter "entities" of HasOneResolver.includeTo requires an Array of Object, but %v was given.',
4383
4686
  entities
4384
4687
  );
4385
- if (!sourceName || typeof sourceName !== "string")
4688
+ }
4689
+ if (!sourceName || typeof sourceName !== "string") {
4386
4690
  throw new InvalidArgumentError(
4387
4691
  'The parameter "sourceName" of HasOneResolver.includeTo requires a non-empty String, but %v was given.',
4388
4692
  sourceName
4389
4693
  );
4390
- if (!targetName || typeof targetName !== "string")
4694
+ }
4695
+ if (!targetName || typeof targetName !== "string") {
4391
4696
  throw new InvalidArgumentError(
4392
4697
  'The parameter "targetName" of HasOneResolver.includeTo requires a non-empty String, but %v was given.',
4393
4698
  targetName
4394
4699
  );
4395
- if (!relationName || typeof relationName !== "string")
4700
+ }
4701
+ if (!relationName || typeof relationName !== "string") {
4396
4702
  throw new InvalidArgumentError(
4397
4703
  'The parameter "relationName" of HasOneResolver.includeTo requires a non-empty String, but %v was given.',
4398
4704
  relationName
4399
4705
  );
4400
- if (!foreignKey || typeof foreignKey !== "string")
4706
+ }
4707
+ if (!foreignKey || typeof foreignKey !== "string") {
4401
4708
  throw new InvalidArgumentError(
4402
4709
  'The parameter "foreignKey" of HasOneResolver.includeTo requires a non-empty String, but %v was given.',
4403
4710
  foreignKey
4404
4711
  );
4405
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
4712
+ }
4713
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4406
4714
  throw new InvalidArgumentError(
4407
4715
  'The provided parameter "scope" of HasOneResolver.includeTo should be an Object, but %v was given.',
4408
4716
  scope
4409
4717
  );
4718
+ }
4410
4719
  const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
4411
4720
  sourceName
4412
4721
  );
4413
4722
  const sourceIds = [];
4414
4723
  entities.forEach((entity) => {
4415
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
4724
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
4416
4725
  throw new InvalidArgumentError(
4417
4726
  'The parameter "entities" of HasOneResolver.includeTo requires an Array of Object, but %v was given.',
4418
4727
  entity
4419
4728
  );
4729
+ }
4420
4730
  const sourceId = entity[sourcePkPropName];
4421
- if (sourceIds.includes(sourceId)) return;
4731
+ if (sourceIds.includes(sourceId)) {
4732
+ return;
4733
+ }
4422
4734
  sourceIds.push(sourceId);
4423
4735
  });
4424
4736
  const promises = [];
@@ -4433,7 +4745,9 @@ var init_has_one_resolver = __esm({
4433
4745
  filter.limit = 1;
4434
4746
  promises.push(
4435
4747
  targetRepository.find(filter).then((result) => {
4436
- if (result.length) targetBySourceId.set(sourceId, result[0]);
4748
+ if (result.length) {
4749
+ targetBySourceId.set(sourceId, result[0]);
4750
+ }
4437
4751
  })
4438
4752
  );
4439
4753
  });
@@ -4456,53 +4770,63 @@ var init_has_one_resolver = __esm({
4456
4770
  * @returns {Promise<void>}
4457
4771
  */
4458
4772
  async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
4459
- if (!entities || !Array.isArray(entities))
4773
+ if (!entities || !Array.isArray(entities)) {
4460
4774
  throw new InvalidArgumentError(
4461
4775
  'The parameter "entities" of HasOneResolver.includePolymorphicTo requires an Array of Object, but %v was given.',
4462
4776
  entities
4463
4777
  );
4464
- if (!sourceName || typeof sourceName !== "string")
4778
+ }
4779
+ if (!sourceName || typeof sourceName !== "string") {
4465
4780
  throw new InvalidArgumentError(
4466
4781
  'The parameter "sourceName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4467
4782
  sourceName
4468
4783
  );
4469
- if (!targetName || typeof targetName !== "string")
4784
+ }
4785
+ if (!targetName || typeof targetName !== "string") {
4470
4786
  throw new InvalidArgumentError(
4471
4787
  'The parameter "targetName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4472
4788
  targetName
4473
4789
  );
4474
- if (!relationName || typeof relationName !== "string")
4790
+ }
4791
+ if (!relationName || typeof relationName !== "string") {
4475
4792
  throw new InvalidArgumentError(
4476
4793
  'The parameter "relationName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4477
4794
  relationName
4478
4795
  );
4479
- if (!foreignKey || typeof foreignKey !== "string")
4796
+ }
4797
+ if (!foreignKey || typeof foreignKey !== "string") {
4480
4798
  throw new InvalidArgumentError(
4481
4799
  'The parameter "foreignKey" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4482
4800
  foreignKey
4483
4801
  );
4484
- if (!discriminator || typeof discriminator !== "string")
4802
+ }
4803
+ if (!discriminator || typeof discriminator !== "string") {
4485
4804
  throw new InvalidArgumentError(
4486
4805
  'The parameter "discriminator" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4487
4806
  discriminator
4488
4807
  );
4489
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
4808
+ }
4809
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4490
4810
  throw new InvalidArgumentError(
4491
4811
  'The provided parameter "scope" of HasOneResolver.includePolymorphicTo should be an Object, but %v was given.',
4492
4812
  scope
4493
4813
  );
4814
+ }
4494
4815
  const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
4495
4816
  sourceName
4496
4817
  );
4497
4818
  const sourceIds = [];
4498
4819
  entities.forEach((entity) => {
4499
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
4820
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
4500
4821
  throw new InvalidArgumentError(
4501
4822
  'The parameter "entities" of HasOneResolver.includePolymorphicTo requires an Array of Object, but %v was given.',
4502
4823
  entity
4503
4824
  );
4825
+ }
4504
4826
  const sourceId = entity[sourcePkPropName];
4505
- if (sourceIds.includes(sourceId)) return;
4827
+ if (sourceIds.includes(sourceId)) {
4828
+ return;
4829
+ }
4506
4830
  sourceIds.push(sourceId);
4507
4831
  });
4508
4832
  const promises = [];
@@ -4520,7 +4844,9 @@ var init_has_one_resolver = __esm({
4520
4844
  filter.limit = 1;
4521
4845
  promises.push(
4522
4846
  targetRepository.find(filter).then((result) => {
4523
- if (result.length) targetBySourceId.set(sourceId, result[0]);
4847
+ if (result.length) {
4848
+ targetBySourceId.set(sourceId, result[0]);
4849
+ }
4524
4850
  })
4525
4851
  );
4526
4852
  });
@@ -4542,40 +4868,46 @@ var init_has_one_resolver = __esm({
4542
4868
  * @returns {Promise<void>}
4543
4869
  */
4544
4870
  async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
4545
- if (!entities || !Array.isArray(entities))
4871
+ if (!entities || !Array.isArray(entities)) {
4546
4872
  throw new InvalidArgumentError(
4547
4873
  'The parameter "entities" of HasOneResolver.includePolymorphicByRelationName requires an Array of Object, but %v was given.',
4548
4874
  entities
4549
4875
  );
4550
- if (!sourceName || typeof sourceName !== "string")
4876
+ }
4877
+ if (!sourceName || typeof sourceName !== "string") {
4551
4878
  throw new InvalidArgumentError(
4552
4879
  'The parameter "sourceName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4553
4880
  sourceName
4554
4881
  );
4555
- if (!targetName || typeof targetName !== "string")
4882
+ }
4883
+ if (!targetName || typeof targetName !== "string") {
4556
4884
  throw new InvalidArgumentError(
4557
4885
  'The parameter "targetName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4558
4886
  targetName
4559
4887
  );
4560
- if (!relationName || typeof relationName !== "string")
4888
+ }
4889
+ if (!relationName || typeof relationName !== "string") {
4561
4890
  throw new InvalidArgumentError(
4562
4891
  'The parameter "relationName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4563
4892
  relationName
4564
4893
  );
4565
- if (!targetRelationName || typeof targetRelationName !== "string")
4894
+ }
4895
+ if (!targetRelationName || typeof targetRelationName !== "string") {
4566
4896
  throw new InvalidArgumentError(
4567
4897
  'The parameter "targetRelationName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4568
4898
  targetRelationName
4569
4899
  );
4570
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
4900
+ }
4901
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4571
4902
  throw new InvalidArgumentError(
4572
4903
  'The provided parameter "scope" of HasOneResolver.includePolymorphicByRelationName should be an Object, but %v was given.',
4573
4904
  scope
4574
4905
  );
4906
+ }
4575
4907
  const targetRelationDef = this.getService(
4576
4908
  ModelDefinitionUtils
4577
4909
  ).getRelationDefinitionByName(targetName, targetRelationName);
4578
- if (targetRelationDef.type !== RelationType.BELONGS_TO)
4910
+ if (targetRelationDef.type !== RelationType.BELONGS_TO) {
4579
4911
  throw new InvalidArgumentError(
4580
4912
  'The 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.',
4581
4913
  relationName,
@@ -4583,13 +4915,15 @@ var init_has_one_resolver = __esm({
4583
4915
  targetRelationName,
4584
4916
  targetRelationDef.type
4585
4917
  );
4586
- if (!targetRelationDef.polymorphic)
4918
+ }
4919
+ if (!targetRelationDef.polymorphic) {
4587
4920
  throw new InvalidArgumentError(
4588
4921
  'The relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic too.',
4589
4922
  relationName,
4590
4923
  sourceName,
4591
4924
  targetRelationName
4592
4925
  );
4926
+ }
4593
4927
  const foreignKey = targetRelationDef.foreignKey || `${targetRelationName}Id`;
4594
4928
  const discriminator = targetRelationDef.discriminator || `${targetRelationName}Type`;
4595
4929
  return this.includePolymorphicTo(
@@ -4631,48 +4965,57 @@ var init_has_many_resolver = __esm({
4631
4965
  * @returns {Promise<void>}
4632
4966
  */
4633
4967
  async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
4634
- if (!entities || !Array.isArray(entities))
4968
+ if (!entities || !Array.isArray(entities)) {
4635
4969
  throw new InvalidArgumentError(
4636
4970
  'The parameter "entities" of HasManyResolver.includeTo requires an Array of Object, but %v was given.',
4637
4971
  entities
4638
4972
  );
4639
- if (!sourceName || typeof sourceName !== "string")
4973
+ }
4974
+ if (!sourceName || typeof sourceName !== "string") {
4640
4975
  throw new InvalidArgumentError(
4641
4976
  'The parameter "sourceName" of HasManyResolver.includeTo requires a non-empty String, but %v was given.',
4642
4977
  sourceName
4643
4978
  );
4644
- if (!targetName || typeof targetName !== "string")
4979
+ }
4980
+ if (!targetName || typeof targetName !== "string") {
4645
4981
  throw new InvalidArgumentError(
4646
4982
  'The parameter "targetName" of HasManyResolver.includeTo requires a non-empty String, but %v was given.',
4647
4983
  targetName
4648
4984
  );
4649
- if (!relationName || typeof relationName !== "string")
4985
+ }
4986
+ if (!relationName || typeof relationName !== "string") {
4650
4987
  throw new InvalidArgumentError(
4651
4988
  'The parameter "relationName" of HasManyResolver.includeTo requires a non-empty String, but %v was given.',
4652
4989
  relationName
4653
4990
  );
4654
- if (!foreignKey || typeof foreignKey !== "string")
4991
+ }
4992
+ if (!foreignKey || typeof foreignKey !== "string") {
4655
4993
  throw new InvalidArgumentError(
4656
4994
  'The parameter "foreignKey" of HasManyResolver.includeTo requires a non-empty String, but %v was given.',
4657
4995
  foreignKey
4658
4996
  );
4659
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
4997
+ }
4998
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4660
4999
  throw new InvalidArgumentError(
4661
5000
  'The provided parameter "scope" of HasManyResolver.includeTo should be an Object, but %v was given.',
4662
5001
  scope
4663
5002
  );
5003
+ }
4664
5004
  const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
4665
5005
  sourceName
4666
5006
  );
4667
5007
  const sourceIds = [];
4668
5008
  entities.forEach((entity) => {
4669
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
5009
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
4670
5010
  throw new InvalidArgumentError(
4671
5011
  'The parameter "entities" of HasManyResolver.includeTo requires an Array of Object, but %v was given.',
4672
5012
  entity
4673
5013
  );
5014
+ }
4674
5015
  const sourceId = entity[sourcePkPropName];
4675
- if (sourceIds.includes(sourceId)) return;
5016
+ if (sourceIds.includes(sourceId)) {
5017
+ return;
5018
+ }
4676
5019
  sourceIds.push(sourceId);
4677
5020
  });
4678
5021
  const promises = [];
@@ -4715,53 +5058,63 @@ var init_has_many_resolver = __esm({
4715
5058
  * @returns {Promise<void>}
4716
5059
  */
4717
5060
  async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
4718
- if (!entities || !Array.isArray(entities))
5061
+ if (!entities || !Array.isArray(entities)) {
4719
5062
  throw new InvalidArgumentError(
4720
5063
  'The parameter "entities" of HasManyResolver.includePolymorphicTo requires an Array of Object, but %v was given.',
4721
5064
  entities
4722
5065
  );
4723
- if (!sourceName || typeof sourceName !== "string")
5066
+ }
5067
+ if (!sourceName || typeof sourceName !== "string") {
4724
5068
  throw new InvalidArgumentError(
4725
5069
  'The parameter "sourceName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4726
5070
  sourceName
4727
5071
  );
4728
- if (!targetName || typeof targetName !== "string")
5072
+ }
5073
+ if (!targetName || typeof targetName !== "string") {
4729
5074
  throw new InvalidArgumentError(
4730
5075
  'The parameter "targetName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4731
5076
  targetName
4732
5077
  );
4733
- if (!relationName || typeof relationName !== "string")
5078
+ }
5079
+ if (!relationName || typeof relationName !== "string") {
4734
5080
  throw new InvalidArgumentError(
4735
5081
  'The parameter "relationName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4736
5082
  relationName
4737
5083
  );
4738
- if (!foreignKey || typeof foreignKey !== "string")
5084
+ }
5085
+ if (!foreignKey || typeof foreignKey !== "string") {
4739
5086
  throw new InvalidArgumentError(
4740
5087
  'The parameter "foreignKey" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4741
5088
  foreignKey
4742
5089
  );
4743
- if (!discriminator || typeof discriminator !== "string")
5090
+ }
5091
+ if (!discriminator || typeof discriminator !== "string") {
4744
5092
  throw new InvalidArgumentError(
4745
5093
  'The parameter "discriminator" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4746
5094
  discriminator
4747
5095
  );
4748
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
5096
+ }
5097
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4749
5098
  throw new InvalidArgumentError(
4750
5099
  'The provided parameter "scope" of HasManyResolver.includePolymorphicTo should be an Object, but %v was given.',
4751
5100
  scope
4752
5101
  );
5102
+ }
4753
5103
  const sourcePkPropName = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
4754
5104
  sourceName
4755
5105
  );
4756
5106
  const sourceIds = [];
4757
5107
  entities.forEach((entity) => {
4758
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
5108
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
4759
5109
  throw new InvalidArgumentError(
4760
5110
  'The parameter "entities" of HasManyResolver.includePolymorphicTo requires an Array of Object, but %v was given.',
4761
5111
  entity
4762
5112
  );
5113
+ }
4763
5114
  const sourceId = entity[sourcePkPropName];
4764
- if (sourceIds.includes(sourceId)) return;
5115
+ if (sourceIds.includes(sourceId)) {
5116
+ return;
5117
+ }
4765
5118
  sourceIds.push(sourceId);
4766
5119
  });
4767
5120
  const promises = [];
@@ -4806,40 +5159,46 @@ var init_has_many_resolver = __esm({
4806
5159
  * @returns {Promise<void>}
4807
5160
  */
4808
5161
  async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
4809
- if (!entities || !Array.isArray(entities))
5162
+ if (!entities || !Array.isArray(entities)) {
4810
5163
  throw new InvalidArgumentError(
4811
5164
  'The parameter "entities" of HasManyResolver.includePolymorphicByRelationName requires an Array of Object, but %v was given.',
4812
5165
  entities
4813
5166
  );
4814
- if (!sourceName || typeof sourceName !== "string")
5167
+ }
5168
+ if (!sourceName || typeof sourceName !== "string") {
4815
5169
  throw new InvalidArgumentError(
4816
5170
  'The parameter "sourceName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4817
5171
  sourceName
4818
5172
  );
4819
- if (!targetName || typeof targetName !== "string")
5173
+ }
5174
+ if (!targetName || typeof targetName !== "string") {
4820
5175
  throw new InvalidArgumentError(
4821
5176
  'The parameter "targetName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4822
5177
  targetName
4823
5178
  );
4824
- if (!relationName || typeof relationName !== "string")
5179
+ }
5180
+ if (!relationName || typeof relationName !== "string") {
4825
5181
  throw new InvalidArgumentError(
4826
5182
  'The parameter "relationName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4827
5183
  relationName
4828
5184
  );
4829
- if (!targetRelationName || typeof targetRelationName !== "string")
5185
+ }
5186
+ if (!targetRelationName || typeof targetRelationName !== "string") {
4830
5187
  throw new InvalidArgumentError(
4831
5188
  'The parameter "targetRelationName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v was given.',
4832
5189
  targetRelationName
4833
5190
  );
4834
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
5191
+ }
5192
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4835
5193
  throw new InvalidArgumentError(
4836
5194
  'The provided parameter "scope" of HasManyResolver.includePolymorphicByRelationName should be an Object, but %v was given.',
4837
5195
  scope
4838
5196
  );
5197
+ }
4839
5198
  const targetRelationDef = this.getService(
4840
5199
  ModelDefinitionUtils
4841
5200
  ).getRelationDefinitionByName(targetName, targetRelationName);
4842
- if (targetRelationDef.type !== RelationType.BELONGS_TO)
5201
+ if (targetRelationDef.type !== RelationType.BELONGS_TO) {
4843
5202
  throw new InvalidArgumentError(
4844
5203
  'The 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.',
4845
5204
  relationName,
@@ -4847,13 +5206,15 @@ var init_has_many_resolver = __esm({
4847
5206
  targetRelationName,
4848
5207
  targetRelationDef.type
4849
5208
  );
4850
- if (!targetRelationDef.polymorphic)
5209
+ }
5210
+ if (!targetRelationDef.polymorphic) {
4851
5211
  throw new InvalidArgumentError(
4852
5212
  'The relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic too.',
4853
5213
  relationName,
4854
5214
  sourceName,
4855
5215
  targetRelationName
4856
5216
  );
5217
+ }
4857
5218
  const foreignKey = targetRelationDef.foreignKey || `${targetRelationName}Id`;
4858
5219
  const discriminator = targetRelationDef.discriminator || `${targetRelationName}Type`;
4859
5220
  return this.includePolymorphicTo(
@@ -4895,43 +5256,52 @@ var init_belongs_to_resolver = __esm({
4895
5256
  * @returns {Promise<void>}
4896
5257
  */
4897
5258
  async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
4898
- if (!entities || !Array.isArray(entities))
5259
+ if (!entities || !Array.isArray(entities)) {
4899
5260
  throw new InvalidArgumentError(
4900
5261
  'The parameter "entities" of BelongsToResolver.includeTo requires an Array of Object, but %v was given.',
4901
5262
  entities
4902
5263
  );
4903
- if (!sourceName || typeof sourceName !== "string")
5264
+ }
5265
+ if (!sourceName || typeof sourceName !== "string") {
4904
5266
  throw new InvalidArgumentError(
4905
5267
  'The parameter "sourceName" of BelongsToResolver.includeTo requires a non-empty String, but %v was given.',
4906
5268
  sourceName
4907
5269
  );
4908
- if (!targetName || typeof targetName !== "string")
5270
+ }
5271
+ if (!targetName || typeof targetName !== "string") {
4909
5272
  throw new InvalidArgumentError(
4910
5273
  'The parameter "targetName" of BelongsToResolver.includeTo requires a non-empty String, but %v was given.',
4911
5274
  targetName
4912
5275
  );
4913
- if (!relationName || typeof relationName !== "string")
5276
+ }
5277
+ if (!relationName || typeof relationName !== "string") {
4914
5278
  throw new InvalidArgumentError(
4915
5279
  'The parameter "relationName" of BelongsToResolver.includeTo requires a non-empty String, but %v was given.',
4916
5280
  relationName
4917
5281
  );
4918
- if (foreignKey && typeof foreignKey !== "string")
5282
+ }
5283
+ if (foreignKey && typeof foreignKey !== "string") {
4919
5284
  throw new InvalidArgumentError(
4920
5285
  'The provided parameter "foreignKey" of BelongsToResolver.includeTo should be a String, but %v was given.',
4921
5286
  foreignKey
4922
5287
  );
4923
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
5288
+ }
5289
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4924
5290
  throw new InvalidArgumentError(
4925
5291
  'The provided parameter "scope" of BelongsToResolver.includeTo should be an Object, but %v was given.',
4926
5292
  scope
4927
5293
  );
4928
- if (foreignKey == null) foreignKey = `${relationName}Id`;
5294
+ }
5295
+ if (foreignKey == null) {
5296
+ foreignKey = `${relationName}Id`;
5297
+ }
4929
5298
  const targetIds = entities.reduce((acc, entity) => {
4930
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
5299
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
4931
5300
  throw new InvalidArgumentError(
4932
5301
  'The parameter "entities" of BelongsToResolver.includeTo requires an Array of Object, but %v was given.',
4933
5302
  entity
4934
5303
  );
5304
+ }
4935
5305
  const targetId = entity[foreignKey];
4936
5306
  return targetId != null ? [...acc, targetId] : acc;
4937
5307
  }, []);
@@ -4952,7 +5322,9 @@ var init_belongs_to_resolver = __esm({
4952
5322
  const target = targets.find(
4953
5323
  (e) => e[targetPkPropName] === entity[foreignKey]
4954
5324
  );
4955
- if (target) entity[relationName] = target;
5325
+ if (target) {
5326
+ entity[relationName] = target;
5327
+ }
4956
5328
  });
4957
5329
  }
4958
5330
  /**
@@ -4967,36 +5339,42 @@ var init_belongs_to_resolver = __esm({
4967
5339
  * @returns {Promise<void>}
4968
5340
  */
4969
5341
  async includePolymorphicTo(entities, sourceName, relationName, foreignKey = void 0, discriminator = void 0, scope = void 0) {
4970
- if (!entities || !Array.isArray(entities))
5342
+ if (!entities || !Array.isArray(entities)) {
4971
5343
  throw new InvalidArgumentError(
4972
5344
  'The parameter "entities" of BelongsToResolver.includePolymorphicTo requires an Array of Object, but %v was given.',
4973
5345
  entities
4974
5346
  );
4975
- if (!sourceName || typeof sourceName !== "string")
5347
+ }
5348
+ if (!sourceName || typeof sourceName !== "string") {
4976
5349
  throw new InvalidArgumentError(
4977
5350
  'The parameter "sourceName" of BelongsToResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4978
5351
  sourceName
4979
5352
  );
4980
- if (!relationName || typeof relationName !== "string")
5353
+ }
5354
+ if (!relationName || typeof relationName !== "string") {
4981
5355
  throw new InvalidArgumentError(
4982
5356
  'The parameter "relationName" of BelongsToResolver.includePolymorphicTo requires a non-empty String, but %v was given.',
4983
5357
  relationName
4984
5358
  );
4985
- if (foreignKey && typeof foreignKey !== "string")
5359
+ }
5360
+ if (foreignKey && typeof foreignKey !== "string") {
4986
5361
  throw new InvalidArgumentError(
4987
5362
  'The provided parameter "foreignKey" of BelongsToResolver.includePolymorphicTo should be a String, but %v was given.',
4988
5363
  foreignKey
4989
5364
  );
4990
- if (discriminator && typeof discriminator !== "string")
5365
+ }
5366
+ if (discriminator && typeof discriminator !== "string") {
4991
5367
  throw new InvalidArgumentError(
4992
5368
  'The provided parameter "discriminator" of BelongsToResolver.includePolymorphicTo should be a String, but %v was given.',
4993
5369
  discriminator
4994
5370
  );
4995
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
5371
+ }
5372
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
4996
5373
  throw new InvalidArgumentError(
4997
5374
  'The provided parameter "scope" of BelongsToResolver.includePolymorphicTo should be an Object, but %v was given.',
4998
5375
  scope
4999
5376
  );
5377
+ }
5000
5378
  if (foreignKey == null) {
5001
5379
  const singularRelationName = singularize(relationName);
5002
5380
  foreignKey = `${singularRelationName}Id`;
@@ -5007,18 +5385,23 @@ var init_belongs_to_resolver = __esm({
5007
5385
  }
5008
5386
  const targetIdsByTargetName = {};
5009
5387
  entities.forEach((entity) => {
5010
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
5388
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
5011
5389
  throw new InvalidArgumentError(
5012
5390
  'The parameter "entities" of BelongsToResolver.includePolymorphicTo requires an Array of Object, but %v was given.',
5013
5391
  entity
5014
5392
  );
5393
+ }
5015
5394
  const targetId = entity[foreignKey];
5016
5395
  const targetName = entity[discriminator];
5017
- if (targetId == null || targetName == null) return;
5018
- if (targetIdsByTargetName[targetName] == null)
5396
+ if (targetId == null || targetName == null) {
5397
+ return;
5398
+ }
5399
+ if (targetIdsByTargetName[targetName] == null) {
5019
5400
  targetIdsByTargetName[targetName] = [];
5020
- if (!targetIdsByTargetName[targetName].includes(targetId))
5401
+ }
5402
+ if (!targetIdsByTargetName[targetName].includes(targetId)) {
5021
5403
  targetIdsByTargetName[targetName].push(targetId);
5404
+ }
5022
5405
  });
5023
5406
  const promises = [];
5024
5407
  const targetNames = Object.keys(targetIdsByTargetName);
@@ -5070,7 +5453,9 @@ var init_belongs_to_resolver = __esm({
5070
5453
  targetName
5071
5454
  );
5072
5455
  const target = targetEntities.find((e) => e[targetPkPropName] === targetId);
5073
- if (target) entity[relationName] = target;
5456
+ if (target) {
5457
+ entity[relationName] = target;
5458
+ }
5074
5459
  });
5075
5460
  }
5076
5461
  };
@@ -5102,52 +5487,62 @@ var init_references_many_resolver = __esm({
5102
5487
  * @returns {Promise<void>}
5103
5488
  */
5104
5489
  async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
5105
- if (!entities || !Array.isArray(entities))
5490
+ if (!entities || !Array.isArray(entities)) {
5106
5491
  throw new InvalidArgumentError(
5107
5492
  'The parameter "entities" of ReferencesManyResolver.includeTo requires an Array of Object, but %v was given.',
5108
5493
  entities
5109
5494
  );
5110
- if (!sourceName || typeof sourceName !== "string")
5495
+ }
5496
+ if (!sourceName || typeof sourceName !== "string") {
5111
5497
  throw new InvalidArgumentError(
5112
5498
  'The parameter "sourceName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v was given.',
5113
5499
  sourceName
5114
5500
  );
5115
- if (!targetName || typeof targetName !== "string")
5501
+ }
5502
+ if (!targetName || typeof targetName !== "string") {
5116
5503
  throw new InvalidArgumentError(
5117
5504
  'The parameter "targetName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v was given.',
5118
5505
  targetName
5119
5506
  );
5120
- if (!relationName || typeof relationName !== "string")
5507
+ }
5508
+ if (!relationName || typeof relationName !== "string") {
5121
5509
  throw new InvalidArgumentError(
5122
5510
  'The parameter "relationName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v was given.',
5123
5511
  relationName
5124
5512
  );
5125
- if (foreignKey && typeof foreignKey !== "string")
5513
+ }
5514
+ if (foreignKey && typeof foreignKey !== "string") {
5126
5515
  throw new InvalidArgumentError(
5127
5516
  'The provided parameter "foreignKey" of ReferencesManyResolver.includeTo should be a String, but %v was given.',
5128
5517
  foreignKey
5129
5518
  );
5130
- if (scope && (typeof scope !== "object" || Array.isArray(scope)))
5519
+ }
5520
+ if (scope && (typeof scope !== "object" || Array.isArray(scope))) {
5131
5521
  throw new InvalidArgumentError(
5132
5522
  'The provided parameter "scope" of ReferencesManyResolver.includeTo should be an Object, but %v was given.',
5133
5523
  scope
5134
5524
  );
5525
+ }
5135
5526
  if (foreignKey == null) {
5136
5527
  const singularRelationName = singularize(relationName);
5137
5528
  foreignKey = `${singularRelationName}Ids`;
5138
5529
  }
5139
5530
  const targetIds = entities.reduce((acc, entity) => {
5140
- if (!entity || typeof entity !== "object" || Array.isArray(entity))
5531
+ if (!entity || typeof entity !== "object" || Array.isArray(entity)) {
5141
5532
  throw new InvalidArgumentError(
5142
5533
  'The parameter "entities" of ReferencesManyResolver.includeTo requires an Array of Object, but %v was given.',
5143
5534
  entity
5144
5535
  );
5536
+ }
5145
5537
  const ids = entity[foreignKey];
5146
- if (Array.isArray(ids))
5538
+ if (Array.isArray(ids)) {
5147
5539
  ids.forEach((id) => {
5148
- if (id == null || acc.includes(id)) return;
5540
+ if (id == null || acc.includes(id)) {
5541
+ return;
5542
+ }
5149
5543
  acc.push(id);
5150
5544
  });
5545
+ }
5151
5546
  return acc;
5152
5547
  }, []);
5153
5548
  const targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
@@ -5166,11 +5561,14 @@ var init_references_many_resolver = __esm({
5166
5561
  entities.forEach((entity) => {
5167
5562
  const ids = entity[foreignKey];
5168
5563
  entity[relationName] = [];
5169
- if (Array.isArray(ids))
5564
+ if (Array.isArray(ids)) {
5170
5565
  targets.forEach((target) => {
5171
5566
  const targetId = target[targetPkPropName];
5172
- if (ids.includes(targetId)) entity[relationName].push(target);
5567
+ if (ids.includes(targetId)) {
5568
+ entity[relationName].push(target);
5569
+ }
5173
5570
  });
5571
+ }
5174
5572
  });
5175
5573
  }
5176
5574
  };
@@ -5359,30 +5757,37 @@ var init_include_clause_tool = __esm({
5359
5757
  relNames.push(el);
5360
5758
  } else if (typeof el === "object") {
5361
5759
  Object.keys(el).forEach((key) => {
5362
- if (Object.prototype.hasOwnProperty.call(el, key))
5760
+ if (Object.prototype.hasOwnProperty.call(el, key)) {
5363
5761
  relNames.push(key);
5762
+ }
5364
5763
  });
5365
5764
  }
5366
5765
  });
5367
5766
  const duplicateNames = relNames.filter(
5368
5767
  (name, i) => relNames.indexOf(name) !== i
5369
5768
  );
5370
- if (duplicateNames.length)
5769
+ if (duplicateNames.length) {
5371
5770
  throw new InvalidArgumentError(
5372
5771
  'The provided option "include" has duplicates of %v.',
5373
5772
  duplicateNames[0]
5374
5773
  );
5774
+ }
5375
5775
  } else if (typeof clause === "object") {
5376
5776
  if ("relation" in clause) {
5377
- if (!clause.relation || typeof clause.relation !== "string")
5777
+ if (!clause.relation || typeof clause.relation !== "string") {
5378
5778
  throw new InvalidArgumentError(
5379
5779
  'The provided option "relation" should be a non-empty String, but %v was given.',
5380
5780
  clause.relation
5381
5781
  );
5382
- if ("scope" in clause && clause) this.validateScopeClause(clause.scope);
5782
+ }
5783
+ if ("scope" in clause && clause) {
5784
+ this.validateScopeClause(clause.scope);
5785
+ }
5383
5786
  } else {
5384
5787
  Object.keys(clause).forEach((key) => {
5385
- if (!Object.prototype.hasOwnProperty.call(clause, key)) return;
5788
+ if (!Object.prototype.hasOwnProperty.call(clause, key)) {
5789
+ return;
5790
+ }
5386
5791
  this.validateIncludeClause(key);
5387
5792
  this.validateIncludeClause(clause[key]);
5388
5793
  });
@@ -5400,12 +5805,15 @@ var init_include_clause_tool = __esm({
5400
5805
  * @param {object|undefined} clause
5401
5806
  */
5402
5807
  static validateScopeClause(clause) {
5403
- if (clause == null) return;
5404
- if (typeof clause !== "object" || Array.isArray(clause))
5808
+ if (clause == null) {
5809
+ return;
5810
+ }
5811
+ if (typeof clause !== "object" || Array.isArray(clause)) {
5405
5812
  throw new InvalidArgumentError(
5406
5813
  'The provided option "scope" should be an Object, but %v was given.',
5407
5814
  clause
5408
5815
  );
5816
+ }
5409
5817
  if (clause.where != null) {
5410
5818
  WhereClauseTool.validateWhereClause(clause.where);
5411
5819
  }
@@ -5446,29 +5854,37 @@ var init_include_clause_tool = __esm({
5446
5854
  const duplicateNames = relNames.filter(
5447
5855
  (name, i) => relNames.indexOf(name) !== i
5448
5856
  );
5449
- if (duplicateNames.length)
5857
+ if (duplicateNames.length) {
5450
5858
  throw new InvalidArgumentError(
5451
5859
  'The provided option "include" has duplicates of %v.',
5452
5860
  duplicateNames[0]
5453
5861
  );
5862
+ }
5454
5863
  } else if (typeof clause === "object") {
5455
5864
  if ("relation" in clause) {
5456
- if (!clause.relation || typeof clause.relation !== "string")
5865
+ if (!clause.relation || typeof clause.relation !== "string") {
5457
5866
  throw new InvalidArgumentError(
5458
5867
  'The provided option "relation" should be a non-empty String, but %v was given.',
5459
5868
  clause.relation
5460
5869
  );
5870
+ }
5461
5871
  const normalized = { relation: clause.relation };
5462
5872
  const scope = this.normalizeScopeClause(clause.scope);
5463
- if (scope) normalized.scope = scope;
5873
+ if (scope) {
5874
+ normalized.scope = scope;
5875
+ }
5464
5876
  result.push(normalized);
5465
5877
  } else {
5466
5878
  Object.keys(clause).forEach((key) => {
5467
- if (!Object.prototype.hasOwnProperty.call(clause, key)) return;
5879
+ if (!Object.prototype.hasOwnProperty.call(clause, key)) {
5880
+ return;
5881
+ }
5468
5882
  this.validateIncludeClause(key);
5469
5883
  const normalized = { relation: key };
5470
5884
  const include = this.normalizeIncludeClause(clause[key]);
5471
- if (include.length) normalized.scope = { include };
5885
+ if (include.length) {
5886
+ normalized.scope = { include };
5887
+ }
5472
5888
  result.push(normalized);
5473
5889
  });
5474
5890
  }
@@ -5487,12 +5903,15 @@ var init_include_clause_tool = __esm({
5487
5903
  * @returns {object|undefined}
5488
5904
  */
5489
5905
  static normalizeScopeClause(clause) {
5490
- if (clause == null) return;
5491
- if (typeof clause !== "object" || Array.isArray(clause))
5906
+ if (clause == null) {
5907
+ return;
5908
+ }
5909
+ if (typeof clause !== "object" || Array.isArray(clause)) {
5492
5910
  throw new InvalidArgumentError(
5493
5911
  'The provided option "scope" should be an Object, but %v was given.',
5494
5912
  clause
5495
5913
  );
5914
+ }
5496
5915
  const result = {};
5497
5916
  if (clause.where != null) {
5498
5917
  WhereClauseTool.validateWhereClause(clause.where);
@@ -5517,7 +5936,9 @@ var init_include_clause_tool = __esm({
5517
5936
  if (clause.include != null) {
5518
5937
  result.include = this.normalizeIncludeClause(clause.include);
5519
5938
  }
5520
- if (Object.keys(result).length) return result;
5939
+ if (Object.keys(result).length) {
5940
+ return result;
5941
+ }
5521
5942
  return void 0;
5522
5943
  }
5523
5944
  };