@mikro-orm/core 7.0.0-dev.33 → 7.0.0-dev.331

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 (218) hide show
  1. package/EntityManager.d.ts +70 -75
  2. package/EntityManager.js +487 -402
  3. package/MikroORM.d.ts +45 -38
  4. package/MikroORM.js +123 -156
  5. package/README.md +7 -4
  6. package/cache/FileCacheAdapter.d.ts +2 -7
  7. package/cache/FileCacheAdapter.js +35 -30
  8. package/cache/GeneratedCacheAdapter.d.ts +1 -2
  9. package/cache/GeneratedCacheAdapter.js +6 -8
  10. package/cache/MemoryCacheAdapter.d.ts +1 -2
  11. package/cache/MemoryCacheAdapter.js +8 -8
  12. package/cache/index.d.ts +1 -2
  13. package/cache/index.js +0 -2
  14. package/connections/Connection.d.ts +12 -5
  15. package/connections/Connection.js +37 -15
  16. package/drivers/DatabaseDriver.d.ts +25 -18
  17. package/drivers/DatabaseDriver.js +144 -45
  18. package/drivers/IDatabaseDriver.d.ts +118 -23
  19. package/entity/BaseEntity.d.ts +63 -4
  20. package/entity/BaseEntity.js +0 -3
  21. package/entity/Collection.d.ts +95 -31
  22. package/entity/Collection.js +487 -139
  23. package/entity/EntityAssigner.js +37 -25
  24. package/entity/EntityFactory.d.ts +8 -9
  25. package/entity/EntityFactory.js +152 -100
  26. package/entity/EntityHelper.d.ts +2 -2
  27. package/entity/EntityHelper.js +69 -27
  28. package/entity/EntityLoader.d.ts +12 -13
  29. package/entity/EntityLoader.js +286 -125
  30. package/entity/EntityRepository.d.ts +28 -8
  31. package/entity/EntityRepository.js +8 -2
  32. package/entity/PolymorphicRef.d.ts +12 -0
  33. package/entity/PolymorphicRef.js +18 -0
  34. package/entity/Reference.d.ts +3 -8
  35. package/entity/Reference.js +62 -29
  36. package/entity/WrappedEntity.d.ts +7 -10
  37. package/entity/WrappedEntity.js +6 -7
  38. package/entity/defineEntity.d.ts +472 -313
  39. package/entity/defineEntity.js +134 -290
  40. package/entity/index.d.ts +2 -2
  41. package/entity/index.js +2 -2
  42. package/entity/utils.d.ts +6 -1
  43. package/entity/utils.js +46 -11
  44. package/entity/validators.d.ts +11 -0
  45. package/entity/validators.js +66 -0
  46. package/enums.d.ts +8 -6
  47. package/enums.js +13 -17
  48. package/errors.d.ts +26 -16
  49. package/errors.js +63 -31
  50. package/events/EventManager.d.ts +3 -5
  51. package/events/EventManager.js +37 -26
  52. package/events/index.d.ts +1 -1
  53. package/events/index.js +0 -1
  54. package/exceptions.js +9 -2
  55. package/hydration/Hydrator.js +1 -2
  56. package/hydration/ObjectHydrator.d.ts +5 -6
  57. package/hydration/ObjectHydrator.js +109 -50
  58. package/index.d.ts +2 -2
  59. package/index.js +1 -2
  60. package/logging/DefaultLogger.d.ts +1 -1
  61. package/logging/DefaultLogger.js +3 -4
  62. package/logging/SimpleLogger.d.ts +1 -1
  63. package/logging/colors.d.ts +1 -1
  64. package/logging/colors.js +4 -6
  65. package/logging/index.d.ts +2 -1
  66. package/logging/index.js +1 -1
  67. package/logging/inspect.d.ts +2 -0
  68. package/logging/inspect.js +11 -0
  69. package/metadata/EntitySchema.d.ts +47 -23
  70. package/metadata/EntitySchema.js +103 -34
  71. package/metadata/MetadataDiscovery.d.ts +65 -18
  72. package/metadata/MetadataDiscovery.js +940 -424
  73. package/metadata/MetadataProvider.d.ts +11 -2
  74. package/metadata/MetadataProvider.js +71 -2
  75. package/metadata/MetadataStorage.d.ts +11 -13
  76. package/metadata/MetadataStorage.js +79 -48
  77. package/metadata/MetadataValidator.d.ts +32 -9
  78. package/metadata/MetadataValidator.js +214 -44
  79. package/metadata/discover-entities.d.ts +5 -0
  80. package/metadata/discover-entities.js +40 -0
  81. package/metadata/index.d.ts +1 -1
  82. package/metadata/index.js +0 -1
  83. package/metadata/types.d.ts +577 -0
  84. package/metadata/types.js +1 -0
  85. package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
  86. package/naming-strategy/AbstractNamingStrategy.js +26 -5
  87. package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
  88. package/naming-strategy/EntityCaseNamingStrategy.js +7 -6
  89. package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
  90. package/naming-strategy/MongoNamingStrategy.js +6 -6
  91. package/naming-strategy/NamingStrategy.d.ts +28 -4
  92. package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
  93. package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
  94. package/naming-strategy/index.d.ts +1 -1
  95. package/naming-strategy/index.js +0 -1
  96. package/not-supported.d.ts +2 -0
  97. package/not-supported.js +8 -0
  98. package/package.json +47 -36
  99. package/platforms/ExceptionConverter.js +1 -1
  100. package/platforms/Platform.d.ts +33 -15
  101. package/platforms/Platform.js +125 -69
  102. package/serialization/EntitySerializer.d.ts +6 -3
  103. package/serialization/EntitySerializer.js +54 -30
  104. package/serialization/EntityTransformer.js +37 -22
  105. package/serialization/SerializationContext.d.ts +10 -14
  106. package/serialization/SerializationContext.js +24 -19
  107. package/types/ArrayType.d.ts +1 -1
  108. package/types/ArrayType.js +2 -3
  109. package/types/BigIntType.js +1 -1
  110. package/types/BlobType.d.ts +0 -1
  111. package/types/BlobType.js +0 -3
  112. package/types/BooleanType.d.ts +1 -0
  113. package/types/BooleanType.js +3 -0
  114. package/types/DecimalType.js +2 -2
  115. package/types/DoubleType.js +1 -1
  116. package/types/EnumArrayType.js +1 -2
  117. package/types/JsonType.d.ts +1 -1
  118. package/types/JsonType.js +7 -2
  119. package/types/TinyIntType.js +1 -1
  120. package/types/Type.d.ts +2 -4
  121. package/types/Type.js +3 -3
  122. package/types/Uint8ArrayType.d.ts +0 -1
  123. package/types/Uint8ArrayType.js +1 -4
  124. package/types/UuidType.d.ts +2 -0
  125. package/types/UuidType.js +14 -2
  126. package/types/index.d.ts +3 -2
  127. package/typings.d.ts +427 -170
  128. package/typings.js +100 -45
  129. package/unit-of-work/ChangeSet.d.ts +4 -6
  130. package/unit-of-work/ChangeSet.js +8 -9
  131. package/unit-of-work/ChangeSetComputer.d.ts +2 -12
  132. package/unit-of-work/ChangeSetComputer.js +61 -38
  133. package/unit-of-work/ChangeSetPersister.d.ts +10 -17
  134. package/unit-of-work/ChangeSetPersister.js +136 -73
  135. package/unit-of-work/CommitOrderCalculator.d.ts +13 -14
  136. package/unit-of-work/CommitOrderCalculator.js +22 -20
  137. package/unit-of-work/IdentityMap.d.ts +12 -3
  138. package/unit-of-work/IdentityMap.js +51 -13
  139. package/unit-of-work/UnitOfWork.d.ts +39 -23
  140. package/unit-of-work/UnitOfWork.js +441 -246
  141. package/utils/AbstractMigrator.d.ts +101 -0
  142. package/utils/AbstractMigrator.js +303 -0
  143. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  144. package/utils/AbstractSchemaGenerator.js +30 -18
  145. package/utils/AsyncContext.d.ts +6 -0
  146. package/utils/AsyncContext.js +42 -0
  147. package/utils/Configuration.d.ts +647 -185
  148. package/utils/Configuration.js +215 -252
  149. package/utils/ConfigurationLoader.d.ts +1 -52
  150. package/utils/ConfigurationLoader.js +1 -330
  151. package/utils/Cursor.d.ts +3 -6
  152. package/utils/Cursor.js +32 -17
  153. package/utils/DataloaderUtils.d.ts +10 -5
  154. package/utils/DataloaderUtils.js +42 -22
  155. package/utils/EntityComparator.d.ts +21 -21
  156. package/utils/EntityComparator.js +224 -118
  157. package/utils/QueryHelper.d.ts +34 -7
  158. package/utils/QueryHelper.js +183 -72
  159. package/utils/RawQueryFragment.d.ts +28 -34
  160. package/utils/RawQueryFragment.js +37 -72
  161. package/utils/RequestContext.js +2 -2
  162. package/utils/TransactionContext.js +2 -2
  163. package/utils/TransactionManager.js +11 -8
  164. package/utils/Utils.d.ts +16 -127
  165. package/utils/Utils.js +104 -402
  166. package/utils/clone.js +13 -23
  167. package/utils/env-vars.d.ts +7 -0
  168. package/utils/env-vars.js +98 -0
  169. package/utils/fs-utils.d.ts +20 -0
  170. package/utils/fs-utils.js +193 -0
  171. package/utils/index.d.ts +1 -3
  172. package/utils/index.js +1 -3
  173. package/utils/upsert-utils.d.ts +9 -4
  174. package/utils/upsert-utils.js +51 -5
  175. package/decorators/Check.d.ts +0 -3
  176. package/decorators/Check.js +0 -13
  177. package/decorators/CreateRequestContext.d.ts +0 -3
  178. package/decorators/CreateRequestContext.js +0 -32
  179. package/decorators/Embeddable.d.ts +0 -8
  180. package/decorators/Embeddable.js +0 -11
  181. package/decorators/Embedded.d.ts +0 -12
  182. package/decorators/Embedded.js +0 -18
  183. package/decorators/Entity.d.ts +0 -33
  184. package/decorators/Entity.js +0 -12
  185. package/decorators/Enum.d.ts +0 -9
  186. package/decorators/Enum.js +0 -16
  187. package/decorators/Filter.d.ts +0 -2
  188. package/decorators/Filter.js +0 -8
  189. package/decorators/Formula.d.ts +0 -4
  190. package/decorators/Formula.js +0 -15
  191. package/decorators/Indexed.d.ts +0 -19
  192. package/decorators/Indexed.js +0 -20
  193. package/decorators/ManyToMany.d.ts +0 -42
  194. package/decorators/ManyToMany.js +0 -14
  195. package/decorators/ManyToOne.d.ts +0 -34
  196. package/decorators/ManyToOne.js +0 -14
  197. package/decorators/OneToMany.d.ts +0 -28
  198. package/decorators/OneToMany.js +0 -17
  199. package/decorators/OneToOne.d.ts +0 -28
  200. package/decorators/OneToOne.js +0 -7
  201. package/decorators/PrimaryKey.d.ts +0 -8
  202. package/decorators/PrimaryKey.js +0 -20
  203. package/decorators/Property.d.ts +0 -250
  204. package/decorators/Property.js +0 -32
  205. package/decorators/Transactional.d.ts +0 -14
  206. package/decorators/Transactional.js +0 -28
  207. package/decorators/hooks.d.ts +0 -16
  208. package/decorators/hooks.js +0 -47
  209. package/decorators/index.d.ts +0 -17
  210. package/decorators/index.js +0 -17
  211. package/entity/ArrayCollection.d.ts +0 -118
  212. package/entity/ArrayCollection.js +0 -407
  213. package/entity/EntityValidator.d.ts +0 -19
  214. package/entity/EntityValidator.js +0 -150
  215. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  216. package/metadata/ReflectMetadataProvider.js +0 -44
  217. package/utils/resolveContextProvider.d.ts +0 -10
  218. package/utils/resolveContextProvider.js +0 -28
@@ -14,7 +14,7 @@ export class AbstractNamingStrategy {
14
14
  return migrationName;
15
15
  }
16
16
  indexName(tableName, columns, type) {
17
- /* v8 ignore next 3 */
17
+ /* v8 ignore next */
18
18
  if (tableName.includes('.')) {
19
19
  tableName = tableName.substring(tableName.indexOf('.') + 1);
20
20
  }
@@ -34,11 +34,14 @@ export class AbstractNamingStrategy {
34
34
  * @inheritDoc
35
35
  */
36
36
  getEntityName(tableName, schemaName) {
37
- const name = tableName.match(/^[^$_\p{ID_Start}]/u) ? `E_${tableName}` : tableName;
38
- return this.getClassName(name.replaceAll(/[^\u200C\u200D\p{ID_Continue}]+/ug, r => r.split('').map(c => `$${c.codePointAt(0)}`).join('')), '_');
37
+ const name = /^[^$_\p{ID_Start}]/u.exec(tableName) ? `E_${tableName}` : tableName;
38
+ return this.getClassName(name.replaceAll(/[^\u200C\u200D\p{ID_Continue}]+/gu, r => r
39
+ .split('')
40
+ .map(c => `$${c.codePointAt(0)}`)
41
+ .join('')), '_');
39
42
  }
40
43
  columnNameToProperty(columnName) {
41
- const propName = columnName.replace(/[_\- ]+(\w)/ug, (_, p1) => p1.toUpperCase());
44
+ const propName = columnName.replace(/[_\- ]+(\w)/gu, (_, p1) => p1.toUpperCase());
42
45
  if (populatePathMembers.includes(propName.replace(/^\${2,}/u, '$$').replace(/^\$\*$/u, '*'))) {
43
46
  return `$${propName}`;
44
47
  }
@@ -48,7 +51,13 @@ export class AbstractNamingStrategy {
48
51
  * @inheritDoc
49
52
  */
50
53
  getEnumClassName(columnName, tableName, schemaName) {
51
- return this.getEntityName(`${tableName}_${columnName}`, schemaName);
54
+ return this.getEntityName(tableName ? `${tableName}_${columnName}` : columnName, schemaName);
55
+ }
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ getEnumTypeName(columnName, tableName, schemaName) {
60
+ return 'T' + this.getEnumClassName(columnName, tableName, schemaName);
52
61
  }
53
62
  /**
54
63
  * @inheritDoc
@@ -73,4 +82,16 @@ export class AbstractNamingStrategy {
73
82
  }
74
83
  return entityName[0].toLowerCase() + entityName.substring(1) + suffix;
75
84
  }
85
+ /**
86
+ * @inheritDoc
87
+ */
88
+ manyToManyPropertyName(ownerEntityName, targetEntityName, pivotTableName, ownerTableName, schemaName) {
89
+ return this.columnNameToProperty(pivotTableName.replace(new RegExp('^' + ownerTableName + '_'), ''));
90
+ }
91
+ /**
92
+ * @inheritDoc
93
+ */
94
+ discriminatorColumnName(baseName) {
95
+ return this.propertyToColumnName(baseName + 'Type');
96
+ }
76
97
  }
@@ -3,10 +3,10 @@ import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
3
3
  * This strategy keeps original entity/property names for table/column.
4
4
  */
5
5
  export declare class EntityCaseNamingStrategy extends AbstractNamingStrategy {
6
- classToTableName(entityName: string): string;
6
+ classToTableName(entityName: string, tableName?: string): string;
7
7
  joinColumnName(propertyName: string): string;
8
- joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean): string;
9
- joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
8
+ joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
9
+ joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
10
10
  propertyToColumnName(propertyName: string): string;
11
11
  referenceColumnName(): string;
12
12
  }
@@ -3,21 +3,22 @@ import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
3
3
  * This strategy keeps original entity/property names for table/column.
4
4
  */
5
5
  export class EntityCaseNamingStrategy extends AbstractNamingStrategy {
6
- classToTableName(entityName) {
7
- return entityName;
6
+ classToTableName(entityName, tableName) {
7
+ return tableName ?? entityName;
8
8
  }
9
9
  joinColumnName(propertyName) {
10
10
  return propertyName;
11
11
  }
12
- joinKeyColumnName(entityName, referencedColumnName, composite = false) {
13
- const name = entityName.substr(0, 1).toLowerCase() + entityName.substr(1);
12
+ joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
13
+ entityName = this.classToTableName(entityName, tableName);
14
+ const name = entityName.substring(0, 1).toLowerCase() + entityName.substring(1);
14
15
  if (composite && referencedColumnName) {
15
16
  return name + '_' + referencedColumnName;
16
17
  }
17
18
  return name;
18
19
  }
19
- joinTableName(sourceEntity, targetEntity, propertyName) {
20
- return this.classToTableName(sourceEntity) + '_' + this.propertyToColumnName(propertyName);
20
+ joinTableName(sourceEntity, targetEntity, propertyName, tableName) {
21
+ return this.classToTableName(sourceEntity, tableName) + '_' + this.propertyToColumnName(propertyName);
21
22
  }
22
23
  propertyToColumnName(propertyName) {
23
24
  return propertyName;
@@ -1,9 +1,9 @@
1
1
  import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
2
2
  export declare class MongoNamingStrategy extends AbstractNamingStrategy {
3
- classToTableName(entityName: string): string;
3
+ classToTableName(entityName: string, tableName?: string): string;
4
4
  joinColumnName(propertyName: string): string;
5
- joinKeyColumnName(entityName: string, referencedColumnName?: string): string;
6
- joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
5
+ joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
6
+ joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
7
7
  propertyToColumnName(propertyName: string): string;
8
8
  referenceColumnName(): string;
9
9
  }
@@ -1,16 +1,16 @@
1
1
  import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
2
2
  export class MongoNamingStrategy extends AbstractNamingStrategy {
3
- classToTableName(entityName) {
4
- return entityName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
3
+ classToTableName(entityName, tableName) {
4
+ return tableName ?? entityName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
5
5
  }
6
6
  joinColumnName(propertyName) {
7
7
  return propertyName;
8
8
  }
9
- joinKeyColumnName(entityName, referencedColumnName) {
10
- return entityName;
9
+ joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
10
+ return tableName ?? entityName;
11
11
  }
12
- joinTableName(sourceEntity, targetEntity, propertyName) {
13
- return this.classToTableName(sourceEntity) + '_' + this.propertyToColumnName(propertyName);
12
+ joinTableName(sourceEntity, targetEntity, propertyName, tableName) {
13
+ return this.classToTableName(sourceEntity, tableName) + '_' + this.propertyToColumnName(propertyName);
14
14
  }
15
15
  propertyToColumnName(propertyName) {
16
16
  return propertyName;
@@ -7,7 +7,7 @@ export interface NamingStrategy {
7
7
  /**
8
8
  * Return a table name for an entity class
9
9
  */
10
- classToTableName(entityName: string): string;
10
+ classToTableName(entityName: string, tableName?: string): string;
11
11
  /**
12
12
  * Return a migration name. This name should allow ordering.
13
13
  */
@@ -25,7 +25,17 @@ export interface NamingStrategy {
25
25
  *
26
26
  * @return A new class name that will be used for the enum.
27
27
  */
28
- getEnumClassName(columnName: string, tableName: string, schemaName?: string): string;
28
+ getEnumClassName(columnName: string, tableName: string | undefined, schemaName?: string): string;
29
+ /**
30
+ * Get an enum type name. Used with `enumType: 'dictionary'` and `enumType: 'union-type'` entity generator option.
31
+ *
32
+ * @param columnName The column name which has the enum.
33
+ * @param tableName The table name of the column.
34
+ * @param schemaName The schema name of the column.
35
+ *
36
+ * @return A new type name that will be used for the enum.
37
+ */
38
+ getEnumTypeName(columnName: string, tableName: string | undefined, schemaName?: string): string;
29
39
  /**
30
40
  * Get an enum option name for a given enum value.
31
41
  *
@@ -57,11 +67,11 @@ export interface NamingStrategy {
57
67
  /**
58
68
  * Return a join table name
59
69
  */
60
- joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
70
+ joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
61
71
  /**
62
72
  * Return the foreign key column name for the given parameters
63
73
  */
64
- joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean): string;
74
+ joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
65
75
  /**
66
76
  * Returns key/constraint name for the given type. Some drivers might not support all the types (e.g. mysql and sqlite enforce the PK name).
67
77
  */
@@ -75,4 +85,18 @@ export interface NamingStrategy {
75
85
  * Returns the name of the inverse side property. Used in the `EntityGenerator` with `bidirectionalRelations` option.
76
86
  */
77
87
  inverseSideName(entityName: string, propertyName: string, kind: ReferenceKind): string;
88
+ /**
89
+ * Return a property name for a many-to-many relation (used in `EntityGenerator`).
90
+ *
91
+ * @param ownerEntityName - The owner entity class name
92
+ * @param targetEntityName - The target entity class name
93
+ * @param pivotTableName - The pivot table name
94
+ * @param ownerTableName - The owner table name
95
+ * @param schemaName - The schema name (if any)
96
+ */
97
+ manyToManyPropertyName(ownerEntityName: string, targetEntityName: string, pivotTableName: string, ownerTableName: string, schemaName?: string): string;
98
+ /**
99
+ * Returns the discriminator column name for polymorphic relations.
100
+ */
101
+ discriminatorColumnName(baseName: string): string;
78
102
  }
@@ -1,9 +1,9 @@
1
1
  import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
2
2
  export declare class UnderscoreNamingStrategy extends AbstractNamingStrategy {
3
- classToTableName(entityName: string): string;
3
+ classToTableName(entityName: string, tableName?: string): string;
4
4
  joinColumnName(propertyName: string): string;
5
- joinKeyColumnName(entityName: string, referencedColumnName?: string): string;
6
- joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
5
+ joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
6
+ joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
7
7
  propertyToColumnName(propertyName: string, object?: boolean): string;
8
8
  referenceColumnName(): string;
9
9
  private underscore;
@@ -1,16 +1,16 @@
1
1
  import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
2
2
  export class UnderscoreNamingStrategy extends AbstractNamingStrategy {
3
- classToTableName(entityName) {
4
- return this.underscore(entityName);
3
+ classToTableName(entityName, tableName) {
4
+ return tableName ?? this.underscore(entityName);
5
5
  }
6
6
  joinColumnName(propertyName) {
7
7
  return this.underscore(propertyName) + '_' + this.referenceColumnName();
8
8
  }
9
- joinKeyColumnName(entityName, referencedColumnName) {
10
- return this.classToTableName(entityName) + '_' + (referencedColumnName || this.referenceColumnName());
9
+ joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
10
+ return this.classToTableName(entityName, tableName) + '_' + (referencedColumnName || this.referenceColumnName());
11
11
  }
12
- joinTableName(sourceEntity, targetEntity, propertyName) {
13
- return this.classToTableName(sourceEntity) + '_' + this.classToTableName(propertyName);
12
+ joinTableName(sourceEntity, targetEntity, propertyName, tableName) {
13
+ return this.classToTableName(sourceEntity, tableName) + '_' + this.classToTableName(propertyName);
14
14
  }
15
15
  propertyToColumnName(propertyName, object) {
16
16
  return this.underscore(propertyName);
@@ -1,4 +1,4 @@
1
- export * from './NamingStrategy.js';
1
+ export type * from './NamingStrategy.js';
2
2
  export * from './AbstractNamingStrategy.js';
3
3
  export * from './MongoNamingStrategy.js';
4
4
  export * from './UnderscoreNamingStrategy.js';
@@ -1,4 +1,3 @@
1
- export * from './NamingStrategy.js';
2
1
  export * from './AbstractNamingStrategy.js';
3
2
  export * from './MongoNamingStrategy.js';
4
3
  export * from './UnderscoreNamingStrategy.js';
@@ -0,0 +1,2 @@
1
+ export declare function discoverEntities(): void;
2
+ export declare const fs: {};
@@ -0,0 +1,8 @@
1
+ export function discoverEntities() {
2
+ throw new Error('Folder-based discovery is not supported in this environment.');
3
+ }
4
+ export const fs = new Proxy({}, {
5
+ get: () => {
6
+ throw new Error('File system is not supported in this environment.');
7
+ },
8
+ });
package/package.json CHANGED
@@ -1,61 +1,72 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "type": "module",
4
- "version": "7.0.0-dev.33",
3
+ "version": "7.0.0-dev.331",
5
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
- "exports": {
7
- "./package.json": "./package.json",
8
- ".": "./index.js"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
13
- },
14
- "funding": "https://github.com/sponsors/b4nan",
15
5
  "keywords": [
16
- "orm",
6
+ "data-mapper",
7
+ "ddd",
8
+ "entity",
9
+ "identity-map",
10
+ "javascript",
11
+ "js",
12
+ "mariadb",
13
+ "mikro-orm",
17
14
  "mongo",
18
15
  "mongodb",
19
16
  "mysql",
20
- "mariadb",
17
+ "orm",
21
18
  "postgresql",
22
19
  "sqlite",
23
20
  "sqlite3",
24
21
  "ts",
25
22
  "typescript",
26
- "js",
27
- "javascript",
28
- "entity",
29
- "ddd",
30
- "mikro-orm",
31
- "unit-of-work",
32
- "data-mapper",
33
- "identity-map"
23
+ "unit-of-work"
34
24
  ],
35
- "author": "Martin Adámek",
36
- "license": "MIT",
25
+ "homepage": "https://mikro-orm.io",
37
26
  "bugs": {
38
27
  "url": "https://github.com/mikro-orm/mikro-orm/issues"
39
28
  },
40
- "homepage": "https://mikro-orm.io",
41
- "engines": {
42
- "node": ">= 22.11.0"
29
+ "license": "MIT",
30
+ "author": "Martin Adámek",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
34
+ },
35
+ "funding": "https://github.com/sponsors/b4nan",
36
+ "type": "module",
37
+ "exports": {
38
+ "./package.json": "./package.json",
39
+ ".": "./index.js",
40
+ "./file-discovery": {
41
+ "node": "./metadata/discover-entities.js",
42
+ "browser": "./not-supported.js"
43
+ },
44
+ "./fs-utils": {
45
+ "node": "./utils/fs-utils.js",
46
+ "browser": "./not-supported.js"
47
+ },
48
+ "./migrations": "./utils/AbstractMigrator.js",
49
+ "./schema": "./utils/AbstractSchemaGenerator.js",
50
+ "./dataloader": "./utils/DataloaderUtils.js"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
43
54
  },
44
55
  "scripts": {
45
- "build": "yarn clean && yarn compile && yarn copy",
56
+ "build": "yarn compile && yarn copy",
46
57
  "clean": "yarn run -T rimraf ./dist",
47
58
  "compile": "yarn run -T tsc -p tsconfig.build.json",
48
59
  "copy": "node ../../scripts/copy.mjs"
49
60
  },
50
- "publishConfig": {
51
- "access": "public"
61
+ "peerDependencies": {
62
+ "dataloader": "2.2.3"
52
63
  },
53
- "dependencies": {
54
- "dataloader": "2.2.3",
55
- "dotenv": "17.2.3",
56
- "esprima": "4.0.1",
57
- "mikro-orm": "7.0.0-dev.33",
58
- "reflect-metadata": "0.2.2",
59
- "tinyglobby": "0.2.13"
64
+ "peerDependenciesMeta": {
65
+ "dataloader": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "engines": {
70
+ "node": ">= 22.17.0"
60
71
  }
61
72
  }
@@ -1,6 +1,6 @@
1
1
  import { DriverException } from '../exceptions.js';
2
2
  export class ExceptionConverter {
3
- /* v8 ignore next 3 */
3
+ /* v8 ignore next */
4
4
  convertException(exception) {
5
5
  return new DriverException(exception);
6
6
  }
@@ -1,7 +1,6 @@
1
- import { inspect } from 'node:util';
2
1
  import { EntityRepository } from '../entity/EntityRepository.js';
3
2
  import { type NamingStrategy } from '../naming-strategy/NamingStrategy.js';
4
- import type { Constructor, EntityProperty, IPrimaryKey, ISchemaGenerator, PopulateOptions, Primary, EntityMetadata, SimpleColumnMeta } from '../typings.js';
3
+ import type { Constructor, EntityMetadata, EntityProperty, IPrimaryKey, ISchemaGenerator, PopulateOptions, Primary, SimpleColumnMeta, FilterQuery, EntityValue, EntityKey } from '../typings.js';
5
4
  import { ExceptionConverter } from './ExceptionConverter.js';
6
5
  import type { EntityManager } from '../EntityManager.js';
7
6
  import type { Configuration } from '../utils/Configuration.js';
@@ -9,6 +8,7 @@ import type { IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
9
8
  import { Type } from '../types/index.js';
10
9
  import type { MikroORM } from '../MikroORM.js';
11
10
  import type { TransformContext } from '../types/Type.js';
11
+ import { Raw } from '../utils/RawQueryFragment.js';
12
12
  export declare const JsonProperty: unique symbol;
13
13
  export declare abstract class Platform {
14
14
  protected readonly exceptionConverter: ExceptionConverter;
@@ -28,9 +28,9 @@ export declare abstract class Platform {
28
28
  supportsNativeEnums(): boolean;
29
29
  /** for postgres text enums (default) */
30
30
  usesEnumCheckConstraints(): boolean;
31
+ supportsMaterializedViews(): boolean;
31
32
  getSchemaHelper(): unknown;
32
33
  indexForeignKeys(): boolean;
33
- allowsMultiInsert(): boolean;
34
34
  /**
35
35
  * Whether or not the driver supports retuning list of created PKs back when multi-inserting
36
36
  */
@@ -48,11 +48,6 @@ export declare abstract class Platform {
48
48
  * Converts scalar primary key representation to native driver wrapper (e.g. string to mongodb's ObjectId)
49
49
  */
50
50
  denormalizePrimaryKey(data: IPrimaryKey): IPrimaryKey;
51
- /**
52
- * Used when serializing via toObject and toJSON methods, allows to use different PK field name (like `id` instead of `_id`)
53
- */
54
- getSerializedPrimaryKeyField(field: string): string;
55
- usesDifferentSerializedPrimaryKey(): boolean;
56
51
  /**
57
52
  * Returns the SQL specific for the platform to get the current timestamp
58
53
  */
@@ -66,12 +61,21 @@ export declare abstract class Platform {
66
61
  getDateTypeDeclarationSQL(length?: number): string;
67
62
  getTimeTypeDeclarationSQL(length?: number): string;
68
63
  getRegExpOperator(val?: unknown, flags?: string): string;
64
+ mapRegExpCondition(mappedKey: string, value: {
65
+ $re: string;
66
+ $flags?: string;
67
+ }): {
68
+ sql: string;
69
+ params: unknown[];
70
+ };
69
71
  getRegExpValue(val: RegExp): {
70
72
  $re: string;
71
73
  $flags?: string;
72
74
  };
73
75
  isAllowedTopLevelOperator(operator: string): boolean;
74
- quoteVersionValue(value: Date | number, prop: EntityProperty): Date | string | number;
76
+ convertVersionValue(value: Date | number, prop: EntityProperty): Date | string | number | {
77
+ $in: (string | number)[];
78
+ };
75
79
  getDefaultVersionLength(): number;
76
80
  allowsComparingTuples(): boolean;
77
81
  isBigIntProperty(prop: EntityProperty): boolean;
@@ -142,14 +146,22 @@ export declare abstract class Platform {
142
146
  getMappedType(type: string): Type<unknown>;
143
147
  getDefaultMappedType(type: string): Type<unknown>;
144
148
  supportsMultipleCascadePaths(): boolean;
149
+ /**
150
+ * Returns true if the platform supports ON UPDATE foreign key rules.
151
+ * Oracle doesn't support ON UPDATE rules.
152
+ */
153
+ supportsOnUpdate(): boolean;
145
154
  supportsMultipleStatements(): boolean;
155
+ supportsUnionWhere(): boolean;
146
156
  getArrayDeclarationSQL(): string;
147
157
  marshallArray(values: string[]): string;
148
158
  unmarshallArray(value: string): string[];
149
159
  getBlobDeclarationSQL(): string;
150
160
  getJsonDeclarationSQL(): string;
151
- getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string;
152
- getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string;
161
+ getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string | Raw;
162
+ getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | Raw;
163
+ processJsonCondition<T extends object>(o: FilterQuery<T>, value: EntityValue<T>, path: EntityKey<T>[], alias: boolean): FilterQuery<T>;
164
+ protected getJsonValueType(value: unknown): string;
153
165
  getJsonIndexDefinition(index: {
154
166
  columnNames: string[];
155
167
  }): string[];
@@ -158,10 +170,18 @@ export declare abstract class Platform {
158
170
  getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
159
171
  convertsJsonAutomatically(): boolean;
160
172
  convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
161
- convertJsonToJSValue(value: unknown, prop: EntityProperty): unknown;
173
+ convertJsonToJSValue(value: unknown, context?: TransformContext): unknown;
162
174
  convertDateToJSValue(value: string | Date): string;
163
175
  convertIntervalToJSValue(value: string): unknown;
164
176
  convertIntervalToDatabaseValue(value: unknown): unknown;
177
+ usesAsKeyword(): boolean;
178
+ /**
179
+ * Determines how UUID values are compared in the change set tracking.
180
+ * Return `'string'` for inline string comparison (fast), or `'any'` for deep comparison via type methods.
181
+ */
182
+ compareUuids(): string;
183
+ convertUuidToJSValue(value: unknown): unknown;
184
+ convertUuidToDatabaseValue(value: unknown): unknown;
165
185
  parseDate(value: string | number): Date;
166
186
  getRepositoryClass<T extends object>(): Constructor<EntityRepository<T>>;
167
187
  getDefaultCharset(): string;
@@ -195,7 +215,7 @@ export declare abstract class Platform {
195
215
  getDefaultPrimaryName(tableName: string, columns: string[]): string;
196
216
  supportsCustomPrimaryKeyNames(): boolean;
197
217
  isPopulated<T>(key: string, populate: readonly PopulateOptions<T>[] | boolean): boolean;
198
- shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean): boolean;
218
+ shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean, ignoreInlineEmbeddables?: boolean): boolean;
199
219
  /**
200
220
  * Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
201
221
  */
@@ -227,6 +247,4 @@ export declare abstract class Platform {
227
247
  * @internal
228
248
  */
229
249
  clone(): this;
230
- /** @ignore */
231
- [inspect.custom](): string;
232
250
  }