@mikro-orm/core 6.2.10-dev.8 → 6.2.10-dev.81

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 (82) hide show
  1. package/EntityManager.d.ts +1 -2
  2. package/EntityManager.js +26 -24
  3. package/decorators/Check.js +1 -2
  4. package/decorators/CreateRequestContext.js +2 -3
  5. package/decorators/Embeddable.js +1 -2
  6. package/decorators/Embedded.js +1 -2
  7. package/decorators/Entity.js +1 -2
  8. package/decorators/Enum.js +1 -2
  9. package/decorators/Filter.js +1 -2
  10. package/decorators/Formula.js +1 -2
  11. package/decorators/Indexed.d.ts +3 -3
  12. package/decorators/Indexed.js +2 -3
  13. package/decorators/ManyToMany.js +1 -2
  14. package/decorators/ManyToOne.js +1 -2
  15. package/decorators/OneToMany.js +2 -3
  16. package/decorators/OneToOne.d.ts +1 -1
  17. package/decorators/OneToOne.js +1 -2
  18. package/decorators/PrimaryKey.d.ts +3 -2
  19. package/decorators/PrimaryKey.js +2 -3
  20. package/decorators/Property.d.ts +1 -1
  21. package/decorators/Property.js +1 -2
  22. package/decorators/hooks.js +10 -11
  23. package/drivers/DatabaseDriver.js +1 -1
  24. package/drivers/IDatabaseDriver.d.ts +2 -1
  25. package/entity/ArrayCollection.d.ts +0 -1
  26. package/entity/EntityIdentifier.d.ts +1 -1
  27. package/entity/EntityLoader.js +3 -0
  28. package/entity/Reference.d.ts +0 -1
  29. package/entity/Reference.js +10 -7
  30. package/entity/WrappedEntity.d.ts +0 -1
  31. package/entity/wrap.js +2 -3
  32. package/events/TransactionEventBroadcaster.d.ts +2 -2
  33. package/index.mjs +1 -0
  34. package/metadata/MetadataDiscovery.js +6 -4
  35. package/naming-strategy/AbstractNamingStrategy.d.ts +8 -0
  36. package/naming-strategy/AbstractNamingStrategy.js +12 -0
  37. package/naming-strategy/NamingStrategy.d.ts +21 -0
  38. package/package.json +2 -2
  39. package/platforms/Platform.d.ts +5 -1
  40. package/platforms/Platform.js +12 -4
  41. package/serialization/EntitySerializer.js +2 -2
  42. package/serialization/SerializationContext.d.ts +2 -2
  43. package/types/BigIntType.d.ts +2 -2
  44. package/types/BigIntType.js +1 -1
  45. package/types/BlobType.d.ts +0 -1
  46. package/types/CharacterType.d.ts +7 -0
  47. package/types/CharacterType.js +13 -0
  48. package/types/DateTimeType.d.ts +1 -0
  49. package/types/DateTimeType.js +3 -0
  50. package/types/DateType.d.ts +1 -0
  51. package/types/DateType.js +3 -0
  52. package/types/DecimalType.d.ts +2 -2
  53. package/types/IntervalType.d.ts +1 -0
  54. package/types/IntervalType.js +3 -0
  55. package/types/StringType.d.ts +1 -0
  56. package/types/StringType.js +3 -0
  57. package/types/TimeType.d.ts +1 -0
  58. package/types/TimeType.js +3 -0
  59. package/types/Type.d.ts +16 -2
  60. package/types/Uint8ArrayType.d.ts +0 -1
  61. package/types/index.d.ts +19 -16
  62. package/types/index.js +34 -31
  63. package/typings.d.ts +19 -19
  64. package/unit-of-work/ChangeSet.d.ts +0 -1
  65. package/unit-of-work/ChangeSetPersister.d.ts +1 -1
  66. package/unit-of-work/ChangeSetPersister.js +5 -3
  67. package/unit-of-work/UnitOfWork.d.ts +1 -1
  68. package/unit-of-work/UnitOfWork.js +32 -18
  69. package/utils/Configuration.js +2 -2
  70. package/utils/ConfigurationLoader.js +1 -0
  71. package/utils/Cursor.d.ts +0 -1
  72. package/utils/DataloaderUtils.d.ts +3 -3
  73. package/utils/DataloaderUtils.js +4 -4
  74. package/utils/EntityComparator.d.ts +13 -0
  75. package/utils/EntityComparator.js +62 -34
  76. package/utils/RawQueryFragment.d.ts +1 -2
  77. package/utils/RawQueryFragment.js +4 -4
  78. package/utils/Utils.d.ts +4 -6
  79. package/utils/Utils.js +13 -10
  80. package/utils/clone.js +1 -2
  81. package/utils/upsert-utils.d.ts +3 -2
  82. package/utils/upsert-utils.js +4 -5
package/utils/Utils.js CHANGED
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Utils = exports.parseJsonSafe = exports.equals = exports.compareBuffers = exports.compareBooleans = exports.compareArrays = exports.compareObjects = exports.ObjectBindingPattern = void 0;
6
+ exports.Utils = exports.ObjectBindingPattern = void 0;
7
+ exports.compareObjects = compareObjects;
8
+ exports.compareArrays = compareArrays;
9
+ exports.compareBooleans = compareBooleans;
10
+ exports.compareBuffers = compareBuffers;
11
+ exports.equals = equals;
12
+ exports.parseJsonSafe = parseJsonSafe;
7
13
  const module_1 = require("module");
8
14
  const globby_1 = __importDefault(require("globby"));
9
15
  const path_1 = require("path");
@@ -67,7 +73,6 @@ function compareObjects(a, b) {
67
73
  }
68
74
  return true;
69
75
  }
70
- exports.compareObjects = compareObjects;
71
76
  function compareArrays(a, b) {
72
77
  const length = a.length;
73
78
  if (length !== b.length) {
@@ -81,13 +86,11 @@ function compareArrays(a, b) {
81
86
  }
82
87
  return true;
83
88
  }
84
- exports.compareArrays = compareArrays;
85
89
  function compareBooleans(a, b) {
86
90
  a = typeof a === 'number' ? Boolean(a) : a;
87
91
  b = typeof b === 'number' ? Boolean(b) : b;
88
92
  return a === b;
89
93
  }
90
- exports.compareBooleans = compareBooleans;
91
94
  function compareBuffers(a, b) {
92
95
  const length = a.length;
93
96
  if (length !== b.length) {
@@ -100,7 +103,6 @@ function compareBuffers(a, b) {
100
103
  }
101
104
  return true;
102
105
  }
103
- exports.compareBuffers = compareBuffers;
104
106
  /**
105
107
  * Checks if arguments are deeply (but not strictly) equal.
106
108
  */
@@ -119,7 +121,6 @@ function equals(a, b) {
119
121
  }
120
122
  return Number.isNaN(a) && Number.isNaN(b);
121
123
  }
122
- exports.equals = equals;
123
124
  const equalsFn = equals;
124
125
  function parseJsonSafe(value) {
125
126
  if (typeof value === 'string') {
@@ -133,7 +134,6 @@ function parseJsonSafe(value) {
133
134
  }
134
135
  return value;
135
136
  }
136
- exports.parseJsonSafe = parseJsonSafe;
137
137
  class Utils {
138
138
  static PK_SEPARATOR = '~~~';
139
139
  /* istanbul ignore next */
@@ -386,20 +386,23 @@ class Utils {
386
386
  const ret = [];
387
387
  const tokens = this.tokenize(func);
388
388
  let inside = 0;
389
+ let currentBlockStart = 0;
389
390
  for (let i = 0; i < tokens.length; i++) {
390
391
  const token = tokens[i];
391
392
  if (token.type === 'Identifier' && token.value === methodName) {
392
393
  inside = 1;
394
+ currentBlockStart = i;
393
395
  continue;
394
396
  }
395
397
  if (inside === 1 && token.type === 'Punctuator' && token.value === '(') {
396
398
  inside = 2;
399
+ currentBlockStart = i;
397
400
  continue;
398
401
  }
399
402
  if (inside === 2 && token.type === 'Punctuator' && token.value === ')') {
400
403
  break;
401
404
  }
402
- if (inside === 2 && token.type === 'Punctuator' && token.value === '{') {
405
+ if (inside === 2 && token.type === 'Punctuator' && token.value === '{' && i === currentBlockStart + 1) {
403
406
  ret.push(exports.ObjectBindingPattern);
404
407
  i = tokens.findIndex((t, idx) => idx > i + 2 && t.type === 'Punctuator' && t.value === '}');
405
408
  continue;
@@ -704,9 +707,9 @@ class Utils {
704
707
  return (0, url_1.fileURLToPath)(url);
705
708
  }
706
709
  /**
707
- * Resolves and normalizes a series of path parts relative to each preceeding part.
710
+ * Resolves and normalizes a series of path parts relative to each preceding part.
708
711
  * If any part is a `file:` URL, it is converted to a local path. If any part is an
709
- * absolute path, it replaces preceeding paths (similar to `path.resolve` in NodeJS).
712
+ * absolute path, it replaces preceding paths (similar to `path.resolve` in NodeJS).
710
713
  * Trailing directory separators are removed, and all directory separators are converted
711
714
  * to POSIX-style separators (`/`).
712
715
  */
package/utils/clone.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @internal
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.clone = void 0;
8
+ exports.clone = clone;
9
9
  const events_1 = require("events");
10
10
  const RawQueryFragment_1 = require("./RawQueryFragment");
11
11
  function clone(parent, respectCustomCloneMethod = true) {
@@ -124,4 +124,3 @@ function clone(parent, respectCustomCloneMethod = true) {
124
124
  }
125
125
  return _clone(parent);
126
126
  }
127
- exports.clone = clone;
@@ -1,6 +1,7 @@
1
1
  import type { EntityData, EntityMetadata } from '../typings';
2
2
  import type { UpsertOptions } from '../drivers/IDatabaseDriver';
3
+ import type { RawQueryFragment } from '../utils/RawQueryFragment';
3
4
  /** @internal */
4
- export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[], options: UpsertOptions<T>): (keyof T)[];
5
+ export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | RawQueryFragment, options: UpsertOptions<T>): (keyof T)[];
5
6
  /** @internal */
6
- export declare function getOnConflictReturningFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[], options: UpsertOptions<T>): (keyof T)[] | '*';
7
+ export declare function getOnConflictReturningFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | RawQueryFragment, options: UpsertOptions<T>): (keyof T)[] | '*';
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOnConflictReturningFields = exports.getOnConflictFields = void 0;
3
+ exports.getOnConflictFields = getOnConflictFields;
4
+ exports.getOnConflictReturningFields = getOnConflictReturningFields;
4
5
  /** @internal */
5
6
  function getOnConflictFields(meta, data, uniqueFields, options) {
6
7
  if (options.onConflictMergeFields) {
7
8
  return options.onConflictMergeFields;
8
9
  }
9
10
  const keys = Object.keys(data).filter(f => {
10
- return !uniqueFields.includes(f) && !meta?.properties[f]?.embeddable;
11
+ return Array.isArray(uniqueFields) && !uniqueFields.includes(f) && !meta?.properties[f]?.embeddable;
11
12
  });
12
13
  if (options.onConflictExcludeFields) {
13
14
  return keys.filter(f => !options.onConflictExcludeFields.includes(f));
14
15
  }
15
16
  return keys;
16
17
  }
17
- exports.getOnConflictFields = getOnConflictFields;
18
18
  /** @internal */
19
19
  function getOnConflictReturningFields(meta, data, uniqueFields, options) {
20
20
  if (!meta) {
21
21
  return '*';
22
22
  }
23
- const keys = meta.comparableProps.filter(p => !p.lazy && !p.embeddable && !uniqueFields.includes(p.name)).map(p => p.name);
23
+ const keys = meta.comparableProps.filter(p => !p.lazy && !p.embeddable && Array.isArray(uniqueFields) && !uniqueFields.includes(p.name)).map(p => p.name);
24
24
  if (meta.versionProperty) {
25
25
  keys.push(meta.versionProperty);
26
26
  }
@@ -35,4 +35,3 @@ function getOnConflictReturningFields(meta, data, uniqueFields, options) {
35
35
  }
36
36
  return keys.filter(key => !(key in data));
37
37
  }
38
- exports.getOnConflictReturningFields = getOnConflictReturningFields;