@tsed/mikro-orm 7.31.0-rc.2 → 7.32.0
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.
- package/jest.config.js +4 -4
- package/lib/cjs/MikroOrmModule.js +34 -3
- package/lib/cjs/MikroOrmModule.js.map +1 -1
- package/lib/cjs/constants.js +6 -0
- package/lib/cjs/constants.js.map +1 -0
- package/lib/cjs/decorators/subscriber.js +14 -0
- package/lib/cjs/decorators/subscriber.js.map +1 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/MikroOrmModule.js +36 -5
- package/lib/esm/MikroOrmModule.js.map +1 -1
- package/lib/esm/constants.js +3 -0
- package/lib/esm/constants.js.map +1 -0
- package/lib/esm/decorators/subscriber.js +10 -0
- package/lib/esm/decorators/subscriber.js.map +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/MikroOrmModule.d.ts +8 -2
- package/lib/types/constants.d.ts +2 -0
- package/lib/types/decorators/subscriber.d.ts +8 -0
- package/lib/types/index.d.ts +2 -0
- package/package.json +13 -16
- package/readme.md +28 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./services/MikroOrmFactory";
|
|
2
2
|
import { AlterRunInContext, OnDestroy, OnInit } from "@tsed/di";
|
|
3
|
-
import { Options } from "@mikro-orm/core";
|
|
3
|
+
import { EventSubscriber, Options } from "@mikro-orm/core";
|
|
4
4
|
declare global {
|
|
5
5
|
namespace TsED {
|
|
6
6
|
interface Configuration {
|
|
7
7
|
/**
|
|
8
|
-
* The
|
|
8
|
+
* The ORM configuration, entity metadata.
|
|
9
9
|
* If you omit the `options` parameter, your CLI config will be used.
|
|
10
10
|
*/
|
|
11
11
|
mikroOrm?: Options[];
|
|
@@ -13,11 +13,17 @@ declare global {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export declare class MikroOrmModule implements OnDestroy, OnInit, AlterRunInContext {
|
|
16
|
+
private subscribers;
|
|
16
17
|
private readonly settings;
|
|
17
18
|
private readonly registry;
|
|
18
19
|
private readonly context;
|
|
20
|
+
private readonly injector;
|
|
21
|
+
constructor(subscribers: EventSubscriber[]);
|
|
19
22
|
$onInit(): Promise<void>;
|
|
20
23
|
$onDestroy(): Promise<void>;
|
|
21
24
|
$alterRunInContext(next: (...args: unknown[]) => unknown): () => unknown | Promise<() => unknown>;
|
|
25
|
+
private getSubscribers;
|
|
26
|
+
private getUnmanagedSubscribers;
|
|
27
|
+
private getManagedSubscribers;
|
|
22
28
|
private createContext;
|
|
23
29
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* @file Automatically generated by barrelsby.
|
|
3
3
|
*/
|
|
4
4
|
export * from "./MikroOrmModule";
|
|
5
|
+
export * from "./constants";
|
|
5
6
|
export * from "./decorators/entityManager";
|
|
6
7
|
export * from "./decorators/orm";
|
|
8
|
+
export * from "./decorators/subscriber";
|
|
7
9
|
export * from "./decorators/transactional";
|
|
8
10
|
export * from "./filters/OptimisticLockErrorFilter";
|
|
9
11
|
export * from "./interceptors/TransactionalInterceptor";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mikro-orm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.32.0",
|
|
4
4
|
"description": "MikroORM package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -27,23 +27,23 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@mikro-orm/core": "^5.2.2",
|
|
29
29
|
"@mikro-orm/mongodb": "^5.2.2",
|
|
30
|
-
"@tsed/common": "7.
|
|
31
|
-
"@tsed/core": "7.
|
|
32
|
-
"@tsed/di": "7.
|
|
33
|
-
"@tsed/eslint": "7.
|
|
34
|
-
"@tsed/json-mapper": "7.
|
|
30
|
+
"@tsed/common": "7.32.0",
|
|
31
|
+
"@tsed/core": "7.32.0",
|
|
32
|
+
"@tsed/di": "7.32.0",
|
|
33
|
+
"@tsed/eslint": "7.32.0",
|
|
34
|
+
"@tsed/json-mapper": "7.32.0",
|
|
35
35
|
"@tsed/logger": ">=6.1.1",
|
|
36
|
-
"@tsed/schema": "7.
|
|
37
|
-
"@tsed/testing-mongoose": "7.
|
|
38
|
-
"@tsed/typescript": "7.
|
|
36
|
+
"@tsed/schema": "7.32.0",
|
|
37
|
+
"@tsed/testing-mongoose": "7.32.0",
|
|
38
|
+
"@tsed/typescript": "7.32.0",
|
|
39
39
|
"eslint": "^8.12.0",
|
|
40
40
|
"ts-mockito": "^2.6.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@mikro-orm/core": ">=4.5.9",
|
|
44
|
-
"@tsed/common": "^7.
|
|
45
|
-
"@tsed/core": "^7.
|
|
46
|
-
"@tsed/di": "^7.
|
|
44
|
+
"@tsed/common": "^7.32.0",
|
|
45
|
+
"@tsed/core": "^7.32.0",
|
|
46
|
+
"@tsed/di": "^7.32.0",
|
|
47
47
|
"@tsed/logger": ">=6.2.2"
|
|
48
48
|
},
|
|
49
49
|
"repository": "https://github.com/tsedio/tsed",
|
|
@@ -52,8 +52,5 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/orm/mikro-orm",
|
|
54
54
|
"author": "Romain Lenzotti",
|
|
55
|
-
"license": "MIT"
|
|
56
|
-
"publishConfig": {
|
|
57
|
-
"tag": "rc"
|
|
58
|
-
}
|
|
55
|
+
"license": "MIT"
|
|
59
56
|
}
|
package/readme.md
CHANGED
|
@@ -389,6 +389,34 @@ export class UsersCtrl {
|
|
|
389
389
|
}
|
|
390
390
|
```
|
|
391
391
|
|
|
392
|
+
## Managing Lifecycle of Subscribers
|
|
393
|
+
|
|
394
|
+
With Ts.ED, managing the lifecycle of subscribers registered with Mikro-ORM using the IoC container is simple. To automatically resolve a subscriber's dependencies, you can use the `@Subscriber` decorator as follows:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
import {EventSubscriber} from "@mikro-orm/core";
|
|
398
|
+
import {Subscriber} from "@tsed/mikro-orm";
|
|
399
|
+
|
|
400
|
+
@Subscriber()
|
|
401
|
+
export class SomeSubscriber implements EventSubscriber {
|
|
402
|
+
// ...
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
In this example, we register the `SomeSubscriber` subscriber, which is automatically instantiated by the module using the IoC container, allowing you to easily manage the dependencies of your subscribers.
|
|
407
|
+
|
|
408
|
+
You can also specify the context name for a subscriber to tie it to a particular instance of the ORM:
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
import {EventSubscriber} from "@mikro-orm/core";
|
|
412
|
+
import {Subscriber} from "@tsed/mikro-orm";
|
|
413
|
+
|
|
414
|
+
@Subscriber({contextName: "mongodb"})
|
|
415
|
+
export class SomeSubscriber implements EventSubscriber {
|
|
416
|
+
// ...
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
392
420
|
## Contributors
|
|
393
421
|
|
|
394
422
|
Please read [contributing guidelines here](https://tsed.io/contributing.html)
|