@mikro-orm/core 7.0.2-dev.13 → 7.0.2-dev.15

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 (147) hide show
  1. package/EntityManager.d.ts +4 -0
  2. package/EntityManager.js +4 -0
  3. package/MikroORM.d.ts +2 -0
  4. package/MikroORM.js +2 -0
  5. package/cache/CacheAdapter.d.ts +2 -0
  6. package/cache/GeneratedCacheAdapter.d.ts +1 -0
  7. package/cache/GeneratedCacheAdapter.js +1 -0
  8. package/cache/MemoryCacheAdapter.d.ts +1 -0
  9. package/cache/MemoryCacheAdapter.js +1 -0
  10. package/cache/NullCacheAdapter.d.ts +1 -0
  11. package/cache/NullCacheAdapter.js +1 -0
  12. package/connections/Connection.d.ts +13 -0
  13. package/connections/Connection.js +9 -0
  14. package/drivers/DatabaseDriver.d.ts +12 -0
  15. package/drivers/DatabaseDriver.js +12 -0
  16. package/drivers/IDatabaseDriver.d.ts +44 -0
  17. package/drivers/IDatabaseDriver.js +1 -0
  18. package/entity/BaseEntity.d.ts +11 -0
  19. package/entity/BaseEntity.js +11 -0
  20. package/entity/Collection.d.ts +26 -0
  21. package/entity/Collection.js +15 -0
  22. package/entity/EntityAssigner.d.ts +3 -0
  23. package/entity/EntityAssigner.js +2 -0
  24. package/entity/EntityFactory.d.ts +16 -0
  25. package/entity/EntityFactory.js +19 -0
  26. package/entity/EntityLoader.d.ts +19 -0
  27. package/entity/EntityLoader.js +2 -0
  28. package/entity/EntityRepository.d.ts +2 -0
  29. package/entity/EntityRepository.js +2 -0
  30. package/entity/Reference.d.ts +20 -0
  31. package/entity/Reference.js +16 -0
  32. package/entity/WrappedEntity.d.ts +20 -0
  33. package/entity/WrappedEntity.js +21 -1
  34. package/entity/defineEntity.d.ts +10 -0
  35. package/entity/defineEntity.js +1 -0
  36. package/enums.d.ts +132 -0
  37. package/enums.js +132 -0
  38. package/errors.d.ts +6 -0
  39. package/errors.js +6 -0
  40. package/events/EventManager.d.ts +5 -0
  41. package/events/EventManager.js +5 -0
  42. package/events/EventSubscriber.d.ts +4 -0
  43. package/events/TransactionEventBroadcaster.d.ts +2 -0
  44. package/events/TransactionEventBroadcaster.js +2 -0
  45. package/hydration/Hydrator.d.ts +2 -0
  46. package/hydration/Hydrator.js +2 -0
  47. package/hydration/ObjectHydrator.d.ts +1 -0
  48. package/hydration/ObjectHydrator.js +1 -0
  49. package/logging/DefaultLogger.d.ts +3 -0
  50. package/logging/DefaultLogger.js +3 -0
  51. package/logging/Logger.d.ts +5 -0
  52. package/metadata/EntitySchema.d.ts +22 -0
  53. package/metadata/EntitySchema.js +20 -0
  54. package/metadata/MetadataDiscovery.d.ts +4 -0
  55. package/metadata/MetadataDiscovery.js +4 -0
  56. package/metadata/MetadataProvider.d.ts +8 -0
  57. package/metadata/MetadataProvider.js +8 -0
  58. package/metadata/MetadataStorage.d.ts +14 -0
  59. package/metadata/MetadataStorage.js +13 -0
  60. package/naming-strategy/AbstractNamingStrategy.d.ts +1 -0
  61. package/naming-strategy/AbstractNamingStrategy.js +1 -0
  62. package/naming-strategy/MongoNamingStrategy.d.ts +1 -0
  63. package/naming-strategy/MongoNamingStrategy.js +1 -0
  64. package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -0
  65. package/naming-strategy/UnderscoreNamingStrategy.js +1 -0
  66. package/package.json +1 -1
  67. package/platforms/ExceptionConverter.d.ts +1 -0
  68. package/platforms/ExceptionConverter.js +1 -0
  69. package/platforms/Platform.d.ts +65 -0
  70. package/platforms/Platform.js +65 -0
  71. package/serialization/EntitySerializer.d.ts +2 -0
  72. package/serialization/EntitySerializer.js +2 -0
  73. package/serialization/EntityTransformer.d.ts +2 -0
  74. package/serialization/EntityTransformer.js +2 -0
  75. package/serialization/SerializationContext.d.ts +5 -0
  76. package/serialization/SerializationContext.js +5 -0
  77. package/types/ArrayType.d.ts +1 -0
  78. package/types/ArrayType.js +1 -0
  79. package/types/BlobType.d.ts +1 -0
  80. package/types/BlobType.js +1 -0
  81. package/types/BooleanType.d.ts +1 -0
  82. package/types/BooleanType.js +1 -0
  83. package/types/CharacterType.d.ts +1 -0
  84. package/types/CharacterType.js +1 -0
  85. package/types/DateTimeType.d.ts +1 -0
  86. package/types/DateTimeType.js +1 -0
  87. package/types/DateType.d.ts +1 -0
  88. package/types/DateType.js +1 -0
  89. package/types/EnumArrayType.d.ts +1 -0
  90. package/types/EnumArrayType.js +1 -0
  91. package/types/EnumType.d.ts +1 -0
  92. package/types/EnumType.js +1 -0
  93. package/types/FloatType.d.ts +1 -0
  94. package/types/FloatType.js +1 -0
  95. package/types/IntegerType.d.ts +1 -0
  96. package/types/IntegerType.js +1 -0
  97. package/types/IntervalType.d.ts +1 -0
  98. package/types/IntervalType.js +1 -0
  99. package/types/JsonType.d.ts +1 -0
  100. package/types/JsonType.js +1 -0
  101. package/types/MediumIntType.d.ts +1 -0
  102. package/types/MediumIntType.js +1 -0
  103. package/types/SmallIntType.d.ts +1 -0
  104. package/types/SmallIntType.js +1 -0
  105. package/types/StringType.d.ts +1 -0
  106. package/types/StringType.js +1 -0
  107. package/types/TextType.d.ts +1 -0
  108. package/types/TextType.js +1 -0
  109. package/types/TimeType.d.ts +1 -0
  110. package/types/TimeType.js +1 -0
  111. package/types/TinyIntType.d.ts +1 -0
  112. package/types/TinyIntType.js +1 -0
  113. package/types/Type.d.ts +3 -0
  114. package/types/Type.js +1 -0
  115. package/types/Uint8ArrayType.d.ts +1 -0
  116. package/types/Uint8ArrayType.js +1 -0
  117. package/types/UnknownType.d.ts +1 -0
  118. package/types/UnknownType.js +1 -0
  119. package/types/UuidType.d.ts +1 -0
  120. package/types/UuidType.js +1 -0
  121. package/types/index.d.ts +2 -0
  122. package/types/index.js +2 -0
  123. package/typings.d.ts +177 -0
  124. package/typings.js +11 -0
  125. package/unit-of-work/ChangeSet.d.ts +4 -0
  126. package/unit-of-work/ChangeSet.js +4 -0
  127. package/unit-of-work/ChangeSetComputer.d.ts +2 -0
  128. package/unit-of-work/ChangeSetComputer.js +15 -2
  129. package/unit-of-work/ChangeSetPersister.d.ts +4 -0
  130. package/unit-of-work/ChangeSetPersister.js +4 -0
  131. package/unit-of-work/IdentityMap.d.ts +7 -0
  132. package/unit-of-work/IdentityMap.js +7 -0
  133. package/unit-of-work/UnitOfWork.d.ts +15 -0
  134. package/unit-of-work/UnitOfWork.js +15 -0
  135. package/utils/Configuration.d.ts +8 -0
  136. package/utils/Configuration.js +8 -0
  137. package/utils/EntityComparator.d.ts +2 -0
  138. package/utils/EntityComparator.js +2 -0
  139. package/utils/NullHighlighter.d.ts +1 -0
  140. package/utils/NullHighlighter.js +1 -0
  141. package/utils/RawQueryFragment.d.ts +10 -0
  142. package/utils/RawQueryFragment.js +9 -0
  143. package/utils/RequestContext.d.ts +1 -0
  144. package/utils/TransactionContext.d.ts +1 -0
  145. package/utils/TransactionContext.js +1 -0
  146. package/utils/Utils.d.ts +6 -0
  147. package/utils/Utils.js +7 -1
@@ -1,4 +1,5 @@
1
1
  import { Utils } from './Utils.js';
2
+ /** Represents a raw SQL fragment with optional parameters, usable as both a value and an object key via Symbol coercion. */
2
3
  export class RawQueryFragment {
3
4
  sql;
4
5
  params;
@@ -8,6 +9,7 @@ export class RawQueryFragment {
8
9
  this.sql = sql;
9
10
  this.params = params;
10
11
  }
12
+ /** Returns a unique symbol key for this fragment, creating and caching it on first access. */
11
13
  get key() {
12
14
  if (!this.#key) {
13
15
  this.#key = Symbol(this.toJSON());
@@ -15,6 +17,7 @@ export class RawQueryFragment {
15
17
  }
16
18
  return this.#key;
17
19
  }
20
+ /** Creates a new fragment with an alias appended via `as ??`. */
18
21
  as(alias) {
19
22
  return new RawQueryFragment(`${this.sql} as ??`, [...this.params, alias]);
20
23
  }
@@ -35,19 +38,23 @@ export class RawQueryFragment {
35
38
  clone() {
36
39
  return this;
37
40
  }
41
+ /** Checks whether the given value is a symbol that maps to a known raw query fragment. */
38
42
  static isKnownFragmentSymbol(key) {
39
43
  return typeof key === 'symbol' && this.#rawQueryReferences.has(key);
40
44
  }
45
+ /** Checks whether an object has any symbol keys that are known raw query fragments. */
41
46
  static hasObjectFragments(object) {
42
47
  return (Utils.isPlainObject(object) &&
43
48
  Object.getOwnPropertySymbols(object).some(symbol => this.isKnownFragmentSymbol(symbol)));
44
49
  }
50
+ /** Checks whether the given value is a RawQueryFragment instance or a known fragment symbol. */
45
51
  static isKnownFragment(key) {
46
52
  if (key instanceof RawQueryFragment) {
47
53
  return true;
48
54
  }
49
55
  return this.isKnownFragmentSymbol(key);
50
56
  }
57
+ /** Retrieves the RawQueryFragment associated with the given key (instance or symbol). */
51
58
  static getKnownFragment(key) {
52
59
  if (key instanceof RawQueryFragment) {
53
60
  return key;
@@ -70,6 +77,7 @@ export { RawQueryFragment as Raw };
70
77
  Object.defineProperties(RawQueryFragment.prototype, {
71
78
  __raw: { value: true, enumerable: false },
72
79
  });
80
+ /** Checks whether the given value is a `RawQueryFragment` instance. */
73
81
  export function isRaw(value) {
74
82
  return typeof value === 'object' && value !== null && '__raw' in value;
75
83
  }
@@ -178,6 +186,7 @@ export function raw(sql, params) {
178
186
  export function sql(sql, ...values) {
179
187
  return raw(sql.join('?'), values);
180
188
  }
189
+ /** Creates a raw SQL function expression wrapping the given key (e.g., `lower(name)`). */
181
190
  export function createSqlFunction(func, key) {
182
191
  if (typeof key === 'string') {
183
192
  return raw(`${func}(${key})`);
@@ -35,6 +35,7 @@ export declare class RequestContext {
35
35
  static getEntityManager(name?: string): EntityManager | undefined;
36
36
  private static createContext;
37
37
  }
38
+ /** Options for creating a new RequestContext, allowing schema and logger overrides. */
38
39
  export interface CreateContextOptions {
39
40
  schema?: string;
40
41
  loggerContext?: LoggingOptions;
@@ -1,4 +1,5 @@
1
1
  import type { EntityManager } from '../EntityManager.js';
2
+ /** Uses `AsyncLocalStorage` to maintain a transaction-scoped EntityManager context across async operations. */
2
3
  export declare class TransactionContext {
3
4
  readonly em: EntityManager;
4
5
  private static storage;
@@ -1,4 +1,5 @@
1
1
  import { createAsyncContext } from './AsyncContext.js';
2
+ /** Uses `AsyncLocalStorage` to maintain a transaction-scoped EntityManager context across async operations. */
2
3
  export class TransactionContext {
3
4
  em;
4
5
  static storage = createAsyncContext();
package/utils/Utils.d.ts CHANGED
@@ -3,15 +3,21 @@ import type { Collection } from '../entity/Collection.js';
3
3
  import type { Platform } from '../platforms/Platform.js';
4
4
  import { type ScalarReference } from '../entity/Reference.js';
5
5
  import { type RawQueryFragmentSymbol } from './RawQueryFragment.js';
6
+ /** Deeply compares two objects for equality, handling dates, regexes, and raw fragments. */
6
7
  export declare function compareObjects(a: any, b: any): boolean;
8
+ /** Compares two arrays element-by-element for deep equality. */
7
9
  export declare function compareArrays(a: any[] | string, b: any[] | string): boolean;
10
+ /** Compares two boolean values, treating numeric 0/1 as false/true. */
8
11
  export declare function compareBooleans(a: unknown, b: unknown): boolean;
12
+ /** Compares two byte arrays element-by-element. */
9
13
  export declare function compareBuffers(a: Uint8Array, b: Uint8Array): boolean;
10
14
  /**
11
15
  * Checks if arguments are deeply (but not strictly) equal.
12
16
  */
13
17
  export declare function equals(a: any, b: any): boolean;
18
+ /** Parses a JSON string safely, returning the original value if parsing fails. */
14
19
  export declare function parseJsonSafe<T = unknown>(value: unknown): T;
20
+ /** Collection of general-purpose utility methods used throughout the ORM. */
15
21
  export declare class Utils {
16
22
  #private;
17
23
  static readonly PK_SEPARATOR = "~~~";
package/utils/Utils.js CHANGED
@@ -14,6 +14,7 @@ function compareConstructors(a, b) {
14
14
  }
15
15
  return false;
16
16
  }
17
+ /** Deeply compares two objects for equality, handling dates, regexes, and raw fragments. */
17
18
  export function compareObjects(a, b) {
18
19
  if (a === b || (a == null && b == null)) {
19
20
  return true;
@@ -59,6 +60,7 @@ export function compareObjects(a, b) {
59
60
  }
60
61
  return true;
61
62
  }
63
+ /** Compares two arrays element-by-element for deep equality. */
62
64
  export function compareArrays(a, b) {
63
65
  const length = a.length;
64
66
  if (length !== b.length) {
@@ -72,11 +74,13 @@ export function compareArrays(a, b) {
72
74
  }
73
75
  return true;
74
76
  }
77
+ /** Compares two boolean values, treating numeric 0/1 as false/true. */
75
78
  export function compareBooleans(a, b) {
76
79
  a = typeof a === 'number' ? Boolean(a) : a;
77
80
  b = typeof b === 'number' ? Boolean(b) : b;
78
81
  return a === b;
79
82
  }
83
+ /** Compares two byte arrays element-by-element. */
80
84
  export function compareBuffers(a, b) {
81
85
  const length = a.length;
82
86
  if (length !== b.length) {
@@ -108,6 +112,7 @@ export function equals(a, b) {
108
112
  return Number.isNaN(a) && Number.isNaN(b);
109
113
  }
110
114
  const equalsFn = equals;
115
+ /** Parses a JSON string safely, returning the original value if parsing fails. */
111
116
  export function parseJsonSafe(value) {
112
117
  if (typeof value === 'string') {
113
118
  /* v8 ignore next */
@@ -121,9 +126,10 @@ export function parseJsonSafe(value) {
121
126
  }
122
127
  return value;
123
128
  }
129
+ /** Collection of general-purpose utility methods used throughout the ORM. */
124
130
  export class Utils {
125
131
  static PK_SEPARATOR = '~~~';
126
- static #ORM_VERSION = '7.0.2-dev.13';
132
+ static #ORM_VERSION = '7.0.2-dev.15';
127
133
  /**
128
134
  * Checks if the argument is instance of `Object`. Returns false for arrays.
129
135
  */