@mikro-orm/core 7.1.0-dev.1 → 7.1.0-dev.10

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 (46) hide show
  1. package/EntityManager.d.ts +63 -11
  2. package/EntityManager.js +163 -18
  3. package/drivers/DatabaseDriver.d.ts +1 -0
  4. package/drivers/DatabaseDriver.js +3 -0
  5. package/drivers/IDatabaseDriver.d.ts +30 -1
  6. package/entity/BaseEntity.d.ts +2 -2
  7. package/entity/Collection.d.ts +6 -3
  8. package/entity/Collection.js +15 -4
  9. package/entity/EntityFactory.js +20 -1
  10. package/entity/EntityLoader.d.ts +3 -1
  11. package/entity/EntityLoader.js +39 -16
  12. package/entity/EntityRepository.d.ts +27 -9
  13. package/entity/EntityRepository.js +12 -0
  14. package/entity/WrappedEntity.d.ts +2 -2
  15. package/entity/defineEntity.d.ts +40 -9
  16. package/entity/defineEntity.js +0 -6
  17. package/entity/utils.js +4 -5
  18. package/errors.d.ts +2 -0
  19. package/errors.js +4 -0
  20. package/index.d.ts +2 -2
  21. package/index.js +1 -1
  22. package/metadata/MetadataDiscovery.d.ts +11 -0
  23. package/metadata/MetadataDiscovery.js +127 -9
  24. package/metadata/MetadataValidator.js +9 -0
  25. package/metadata/types.d.ts +10 -2
  26. package/naming-strategy/AbstractNamingStrategy.d.ts +1 -1
  27. package/naming-strategy/NamingStrategy.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/platforms/Platform.d.ts +5 -0
  30. package/platforms/Platform.js +7 -0
  31. package/serialization/EntitySerializer.d.ts +18 -6
  32. package/serialization/EntitySerializer.js +31 -5
  33. package/typings.d.ts +108 -6
  34. package/typings.js +19 -2
  35. package/utils/AbstractMigrator.d.ts +11 -1
  36. package/utils/AbstractMigrator.js +203 -0
  37. package/utils/Configuration.d.ts +7 -0
  38. package/utils/Configuration.js +1 -0
  39. package/utils/DataloaderUtils.d.ts +10 -1
  40. package/utils/DataloaderUtils.js +78 -0
  41. package/utils/QueryHelper.d.ts +16 -0
  42. package/utils/QueryHelper.js +15 -0
  43. package/utils/Utils.d.ts +1 -1
  44. package/utils/Utils.js +1 -1
  45. package/utils/fs-utils.d.ts +2 -0
  46. package/utils/fs-utils.js +7 -1
@@ -7,6 +7,21 @@ import { isRaw, Raw } from './RawQueryFragment.js';
7
7
  /** @internal */
8
8
  export class QueryHelper {
9
9
  static SUPPORTED_OPERATORS = ['>', '<', '<=', '>=', '!', '!='];
10
+ /**
11
+ * True when the property has multiple polymorph target types. Covers two structurally-equivalent
12
+ * shapes routed through the same loading path:
13
+ * 1. Union-target owner side — `Post.attachments: Collection<Image | Video>` (one owner, many
14
+ * target types, shared pivot with target-side discriminator).
15
+ * 2. Merged inverse of Rails-style polymorphic M:N — `Tag.owners: Collection<Post | Video>`
16
+ * (many owner types pointing at one target, viewed from the target where "owners" looks
17
+ * like a union of multiple types).
18
+ *
19
+ * Both cases are loaded via `loadFromUnionTargetPolymorphicPivotTable`, which buckets pivot rows
20
+ * by discriminator and hydrates each target class separately.
21
+ */
22
+ static isUnionTargetPolymorphic(prop) {
23
+ return !!prop.polymorphic && (prop.polymorphTargets?.length ?? 0) > 1;
24
+ }
10
25
  /**
11
26
  * Finds the discriminator value (key) for a given entity class in a discriminator map.
12
27
  * Walks up the prototype chain so TPT subclasses resolve to their root's key.
package/utils/Utils.d.ts CHANGED
@@ -117,7 +117,7 @@ export declare class Utils {
117
117
  * Gets string name of given class.
118
118
  */
119
119
  static className<T>(classOrName: string | EntityName<T>): string;
120
- static extractChildElements(items: string[], prefix: string, allSymbol?: string): string[];
120
+ static extractChildElements(items: readonly string[], prefix: string, allSymbol?: string): string[];
121
121
  /**
122
122
  * Tries to detect TypeScript support.
123
123
  */
package/utils/Utils.js CHANGED
@@ -141,7 +141,7 @@ export function parseJsonSafe(value) {
141
141
  /** Collection of general-purpose utility methods used throughout the ORM. */
142
142
  export class Utils {
143
143
  static PK_SEPARATOR = '~~~';
144
- static #ORM_VERSION = '7.1.0-dev.1';
144
+ static #ORM_VERSION = '7.1.0-dev.10';
145
145
  /**
146
146
  * Checks if the argument is instance of `Object`. Returns false for arrays.
147
147
  */
@@ -13,7 +13,9 @@ export interface FsUtils {
13
13
  normalizePath(...parts: string[]): string;
14
14
  relativePath(path: string, relativeTo: string): string;
15
15
  absolutePath(path: string, baseDir?: string): string;
16
+ readFile(path: string): Promise<string>;
16
17
  writeFile(path: string, data: string, options?: Record<string, any>): Promise<void>;
18
+ unlink(path: string): Promise<void>;
17
19
  dynamicImport<T = any>(id: string): Promise<T>;
18
20
  }
19
21
  export declare const fs: FsUtils;
package/utils/fs-utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync, globSync as nodeGlobSync, mkdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
2
- import { writeFile as nodeWriteFile } from 'node:fs/promises';
2
+ import { readFile as nodeReadFile, unlink as nodeUnlink, writeFile as nodeWriteFile } from 'node:fs/promises';
3
3
  import { isAbsolute, join, normalize, relative } from 'node:path';
4
4
  import { fileURLToPath, pathToFileURL } from 'node:url';
5
5
  import { Utils } from './Utils.js';
@@ -181,9 +181,15 @@ export const fs = {
181
181
  }
182
182
  return this.normalizePath(path);
183
183
  },
184
+ async readFile(path) {
185
+ return nodeReadFile(path, 'utf-8');
186
+ },
184
187
  async writeFile(path, data, options) {
185
188
  await nodeWriteFile(path, data, options);
186
189
  },
190
+ async unlink(path) {
191
+ await nodeUnlink(path);
192
+ },
187
193
  async dynamicImport(id) {
188
194
  /* v8 ignore next */
189
195
  const specifier = id.startsWith('file://') ? id : pathToFileURL(id).href;