@mikro-orm/cli 7.1.0-dev.45 → 7.1.0-dev.47
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.
|
@@ -194,11 +194,12 @@ export class DiscoveryExportCommand {
|
|
|
194
194
|
lines.push(`import { ${names} } from '${rel}';`);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
// Bring in the driver's `EntityManager` class as a runtime value, not just
|
|
198
|
+
// a type — DI containers (NestJS, etc.) read it via `design:paramtypes`
|
|
199
|
+
// reflect-metadata, so the consumer needs the actual class reference, not
|
|
200
|
+
// an erased type alias. Aliasing keeps the local name free for our own
|
|
201
|
+
// `EntityManager` re-export.
|
|
202
|
+
lines.push(`import { EntityManager as DriverEntityManager } from '${driverPackage}';`);
|
|
202
203
|
lines.push('');
|
|
203
204
|
// entities array
|
|
204
205
|
lines.push('export const entities = [');
|
|
@@ -206,12 +207,20 @@ export class DiscoveryExportCommand {
|
|
|
206
207
|
lines.push(` ${item.exportName},`);
|
|
207
208
|
}
|
|
208
209
|
lines.push('] as const;');
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
lines.push('');
|
|
211
|
+
// The entity tuple type — usable in `MikroORM<Driver, EM, Database>`,
|
|
212
|
+
// for typed repository helpers, and anywhere entity classes/schemas are
|
|
213
|
+
// accepted as a tuple.
|
|
214
|
+
lines.push('export type Database = typeof entities;');
|
|
215
|
+
lines.push('');
|
|
216
|
+
// Typed `EntityManager` for DI / NestJS contexts. Declaration merging
|
|
217
|
+
// lets us export the same name twice: the `type` carries the entity
|
|
218
|
+
// tuple via the `'~entities'` graft (so `em.getKysely(opts)` keeps full
|
|
219
|
+
// inference), and the `const` is the driver's actual EM class — so
|
|
220
|
+
// `constructor(em: EntityManager) {}` resolves through Nest's container
|
|
221
|
+
// just like importing the class straight from the driver package.
|
|
222
|
+
lines.push("export type EntityManager = DriverEntityManager & { '~entities': Database };");
|
|
223
|
+
lines.push('export const EntityManager = DriverEntityManager;');
|
|
215
224
|
lines.push('');
|
|
216
225
|
return lines.join('\n');
|
|
217
226
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/cli",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.47",
|
|
4
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.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"copy": "node ../../scripts/copy.mjs"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
54
|
-
"mikro-orm": "7.1.0-dev.
|
|
53
|
+
"@mikro-orm/core": "7.1.0-dev.47",
|
|
54
|
+
"mikro-orm": "7.1.0-dev.47",
|
|
55
55
|
"yargs": "17.7.2"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|