@tsed/mikro-orm 8.11.0 → 8.11.2-rc.1
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/lib/esm/MikroOrmModule.js +0 -1
- package/lib/esm/constants.js +0 -1
- package/lib/esm/decorators/entityManager.js +0 -1
- package/lib/esm/decorators/orm.js +0 -1
- package/lib/esm/decorators/subscriber.js +0 -1
- package/lib/esm/decorators/transactional.js +0 -1
- package/lib/esm/filters/OptimisticLockErrorFilter.js +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/interceptors/TransactionalInterceptor.js +0 -1
- package/lib/esm/interfaces/AfterTransactionCommit.js +0 -1
- package/lib/esm/interfaces/BeforeTransactionCommit.js +0 -1
- package/lib/esm/interfaces/RetryStrategy.js +0 -1
- package/lib/esm/services/MikroOrmContext.js +0 -1
- package/lib/esm/services/MikroOrmFactory.js +0 -1
- package/lib/esm/services/MikroOrmRegistry.js +0 -1
- package/package.json +13 -10
- package/lib/esm/MikroOrmModule.js.map +0 -1
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/decorators/entityManager.js.map +0 -1
- package/lib/esm/decorators/orm.js.map +0 -1
- package/lib/esm/decorators/subscriber.js.map +0 -1
- package/lib/esm/decorators/transactional.js.map +0 -1
- package/lib/esm/filters/OptimisticLockErrorFilter.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/interceptors/TransactionalInterceptor.js.map +0 -1
- package/lib/esm/interfaces/AfterTransactionCommit.js.map +0 -1
- package/lib/esm/interfaces/BeforeTransactionCommit.js.map +0 -1
- package/lib/esm/interfaces/RetryStrategy.js.map +0 -1
- package/lib/esm/services/MikroOrmContext.js.map +0 -1
- package/lib/esm/services/MikroOrmFactory.js.map +0 -1
- package/lib/esm/services/MikroOrmRegistry.js.map +0 -1
- package/src/MikroOrmModule.spec.ts +0 -110
- package/src/MikroOrmModule.ts +0 -104
- package/src/constants.ts +0 -2
- package/src/decorators/entityManager.spec.ts +0 -98
- package/src/decorators/entityManager.ts +0 -25
- package/src/decorators/orm.spec.ts +0 -97
- package/src/decorators/orm.ts +0 -19
- package/src/decorators/subscriber.spec.ts +0 -27
- package/src/decorators/subscriber.ts +0 -12
- package/src/decorators/transactional.spec.ts +0 -34
- package/src/decorators/transactional.ts +0 -10
- package/src/filters/OptimisticLockErrorFilter.spec.ts +0 -33
- package/src/filters/OptimisticLockErrorFilter.ts +0 -19
- package/src/index.ts +0 -17
- package/src/interceptors/TransactionalInterceptor.spec.ts +0 -248
- package/src/interceptors/TransactionalInterceptor.ts +0 -130
- package/src/interfaces/AfterTransactionCommit.ts +0 -5
- package/src/interfaces/BeforeTransactionCommit.ts +0 -5
- package/src/interfaces/RetryStrategy.ts +0 -5
- package/src/services/MikroOrmContext.spec.ts +0 -95
- package/src/services/MikroOrmContext.ts +0 -29
- package/src/services/MikroOrmFactory.ts +0 -16
- package/src/services/MikroOrmRegistry.spec.ts +0 -121
- package/src/services/MikroOrmRegistry.ts +0 -62
- package/vitest.config.mts +0 -25
|
@@ -72,4 +72,3 @@ MikroOrmModule = __decorate([
|
|
|
72
72
|
export { MikroOrmModule };
|
|
73
73
|
// TODO: the IoC container should provide null or undefined by default until tsedio/tsed#1694 is closed
|
|
74
74
|
registerProvider({ token: RetryStrategy, useValue: null });
|
|
75
|
-
//# sourceMappingURL=MikroOrmModule.js.map
|
package/lib/esm/constants.js
CHANGED
|
@@ -7,4 +7,3 @@ import { DEFAULT_CONTEXT_NAME, SUBSCRIBER_INJECTION_TYPE } from "../constants.js
|
|
|
7
7
|
* @mikroOrm
|
|
8
8
|
*/
|
|
9
9
|
export const Subscriber = (options = { contextName: DEFAULT_CONTEXT_NAME }) => useDecorators(Injectable({ type: SUBSCRIBER_INJECTION_TYPE }), StoreSet(SUBSCRIBER_INJECTION_TYPE, options));
|
|
10
|
-
//# sourceMappingURL=subscriber.js.map
|
|
@@ -5,4 +5,3 @@ import { TransactionalInterceptor } from "../interceptors/TransactionalIntercept
|
|
|
5
5
|
* @param {String | TransactionOptions} contextNameOrOptions
|
|
6
6
|
*/
|
|
7
7
|
export const Transactional = (contextNameOrOptions) => Intercept(TransactionalInterceptor, contextNameOrOptions);
|
|
8
|
-
//# sourceMappingURL=transactional.js.map
|
package/lib/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/mikro-orm",
|
|
3
3
|
"description": "MikroORM package for Ts.ED framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.11.
|
|
5
|
+
"version": "8.11.2-rc.1",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@mikro-orm/core": "6.3.12",
|
|
30
30
|
"@mikro-orm/mongodb": "6.3.12",
|
|
31
|
-
"@tsed/barrels": "8.11.
|
|
32
|
-
"@tsed/core": "8.11.
|
|
33
|
-
"@tsed/di": "8.11.
|
|
34
|
-
"@tsed/json-mapper": "8.11.
|
|
31
|
+
"@tsed/barrels": "8.11.2-rc.1",
|
|
32
|
+
"@tsed/core": "8.11.2-rc.1",
|
|
33
|
+
"@tsed/di": "8.11.2-rc.1",
|
|
34
|
+
"@tsed/json-mapper": "8.11.2-rc.1",
|
|
35
35
|
"@tsed/logger": "^7.0.1",
|
|
36
|
-
"@tsed/platform-http": "8.11.
|
|
37
|
-
"@tsed/schema": "8.11.
|
|
38
|
-
"@tsed/testcontainers-mongo": "8.11.
|
|
39
|
-
"@tsed/typescript": "8.11.
|
|
36
|
+
"@tsed/platform-http": "8.11.2-rc.1",
|
|
37
|
+
"@tsed/schema": "8.11.2-rc.1",
|
|
38
|
+
"@tsed/testcontainers-mongo": "8.11.2-rc.1",
|
|
39
|
+
"@tsed/typescript": "8.11.2-rc.1",
|
|
40
40
|
"cross-env": "7.0.3",
|
|
41
41
|
"eslint": "9.12.0",
|
|
42
42
|
"ts-mockito": "^2.6.1",
|
|
@@ -56,5 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/orm/mikro-orm",
|
|
58
58
|
"author": "Romain Lenzotti",
|
|
59
|
-
"license": "MIT"
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"tag": "rc"
|
|
62
|
+
}
|
|
60
63
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmModule.js","sourceRoot":"","sources":["../../src/MikroOrmModule.ts"],"names":[],"mappings":";AAAA,OAAO,+BAA+B,CAAC;AAGvC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAEL,QAAQ,EACR,MAAM,EACN,eAAe,EACf,eAAe,EACf,MAAM,EAIN,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAC,oBAAoB,EAAE,yBAAyB,EAAC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAC,yBAAyB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAiBzD,IAAM,cAAc,GAApB,MAAM,cAAc;IAazB,YAAuD,WAA8B;QAA9B,gBAAW,GAAX,WAAW,CAAmB;IAAG,CAAC;IAElF,KAAK,CAAC,OAAO;QAClB,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;QAExC,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACzB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACrB,GAAG,IAA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C,MAAM,EAAE,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEhD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AA5DkB;IADhB,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC;;gDACa;AAGrB;IADhB,MAAM,EAAE;8BACmB,gBAAgB;gDAAC;AAG5B;IADhB,MAAM,EAAE;8BACkB,eAAe;+CAAC;AAG1B;IADhB,MAAM,EAAE;8BACmB,eAAe;gDAAC;AAXjC,cAAc;IAH1B,MAAM,CAAC;QACN,eAAe,EAAE,CAAC,yBAAyB,CAAC;KAC7C,CAAC;IAca,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;;GAbnC,cAAc,CA8D1B;;AAED,uGAAuG;AACvG,gBAAgB,CAAC,EAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC"}
|
package/lib/esm/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entityManager.js","sourceRoot":"","sources":["../../../src/decorators/entityManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,WAAoB;IAChD,OAAO,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAoB,EAAqB,EAAE,CACvE,MAAM,CAAC,gBAAgB,EAAE,EAAC,SAAS,EAAE,CAAC,QAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,EAAC,CAAsB,CAAC;AAE5H;;;;;GAKG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orm.js","sourceRoot":"","sources":["../../../src/decorators/orm.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAExC,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,WAAoB;IACtC,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,WAAoB,EAAqB,EAAE,CAC7D,MAAM,CAAC,gBAAgB,EAAE,EAAC,SAAS,EAAE,CAAC,QAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAC,CAAsB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscriber.js","sourceRoot":"","sources":["../../../src/decorators/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,oBAAoB,EAAE,yBAAyB,EAAC,MAAM,iBAAiB,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAiC,EAAC,WAAW,EAAE,oBAAoB,EAAC,EAAE,EAAE,CACjG,aAAa,CAAC,UAAU,CAAC,EAAC,IAAI,EAAE,yBAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transactional.js","sourceRoot":"","sources":["../../../src/decorators/transactional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAC,wBAAwB,EAAqB,MAAM,6CAA6C,CAAC;AAEzG;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,oBAAkD,EAAmB,EAAE,CACnG,SAAS,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OptimisticLockErrorFilter.js","sourceRoot":"","sources":["../../../src/filters/OptimisticLockErrorFilter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,KAAK,EAA8B,MAAM,2BAA2B,CAAC;AAItE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAC7B,KAAK,CAAC,SAA8B,EAAE,GAAoB;QAC/D,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,GAAG,CAAC;QAE/B,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,iCAAiC;YACxC,UAAU,EAAE,SAAS,CAAC,IAAI;YAC1B,aAAa,EAAE,SAAS,CAAC,OAAO;YAChC,KAAK,EAAE,SAAS,CAAC,KAAK;SACvB,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAC9G,CAAC;CACF,CAAA;AAbY,yBAAyB;IADrC,KAAK,CAAC,mBAAmB,CAAC;GACd,yBAAyB,CAarC"}
|
package/lib/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionalInterceptor.js","sourceRoot":"","sources":["../../../src/interceptors/TransactionalInterceptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAA0D,MAAM,UAAU,CAAC;AACvH,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAa1D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YAC6B,QAAyB,EACzB,QAA0B,EAC1B,OAAwB,EACxB,MAAc,EAExB,aAA6B;QALnB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,aAAQ,GAAR,QAAQ,CAAkB;QAC1B,YAAO,G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ACjB,eAAe;QAChB,MAAM;GALhC,wBAAwB,CA6GpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AfterTransactionCommit.js","sourceRoot":"","sources":["../../../src/interfaces/AfterTransactionCommit.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BeforeTransactionCommit.js","sourceRoot":"","sources":["../../../src/interfaces/BeforeTransactionCommit.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RetryStrategy.js","sourceRoot":"","sources":["../../../src/interfaces/RetryStrategy.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmContext.js","sourceRoot":"","sources":["../../../src/services/MikroOrmContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgB,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACnB,GAAG,CAAC,QAAyB,EAAE,IAAqC;QACzE,6HAA6H;QAC7H,IAAI,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3C,6BAA6B;YAC7B,OAAO,cAAc,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,OAAO,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAqB,CAAC;QACnE,CAAC;IACH,CAAC;IAEM,GAAG,CAAC,WAAoB;QAC7B,OAAO,cAAc,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC;IAEM,GAAG,CAAC,WAAoB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEtC,OAAO,CAAC,CAAC,OAAO,CAAC;IACnB,CAAC;CACF,CAAA;AApBY,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAoB3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmFactory.js","sourceRoot":"","sources":["../../../src/services/MikroOrmFactory.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAU,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAG9C,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAuC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAE5D,MAAM,CAAC,OAAgB;QAC5B,OAAO,QAAQ,CAAC,IAAI,CAAC;YACnB,GAAG,OAAO;YACV,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AATY,eAAe;IAD3B,UAAU,EAAE;IAEE,WAAA,MAAM,EAAE,CAAA;qCAA2B,eAAe;GADpD,eAAe,CAS3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmRegistry.js","sourceRoot":"","sources":["../../../src/services/MikroOrmRegistry.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAG9C,IAAM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,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAE/C,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAExG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,QAAkB;QACtC,IAAI,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;YACjC,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF,CAAA;AArDY,gBAAgB;IAD5B,UAAU,EAAE;IAMR,WAAA,MAAM,EAAE,CAAA;IACR,WAAA,MAAM,EAAE,CAAA;qCAD0B,MAAM;QACG,eAAe;GANlD,gBAAgB,CAqD5B"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {EntityManager, EventSubscriber, MikroORM, Options} from "@mikro-orm/core";
|
|
2
|
-
import {PlatformTest} from "@tsed/platform-http/testing";
|
|
3
|
-
import {anyOfClass, anything, deepEqual, instance, mock, reset, verify, when} from "ts-mockito";
|
|
4
|
-
|
|
5
|
-
import {Subscriber} from "./decorators/subscriber.js";
|
|
6
|
-
import {MikroOrmModule} from "./MikroOrmModule.js";
|
|
7
|
-
import {MikroOrmContext} from "./services/MikroOrmContext.js";
|
|
8
|
-
import {MikroOrmRegistry} from "./services/MikroOrmRegistry.js";
|
|
9
|
-
|
|
10
|
-
class Subscriber1 implements EventSubscriber {}
|
|
11
|
-
|
|
12
|
-
@Subscriber()
|
|
13
|
-
class Subscriber2 implements EventSubscriber {}
|
|
14
|
-
|
|
15
|
-
describe("MikroOrmModule", () => {
|
|
16
|
-
const config: Options = {
|
|
17
|
-
type: "mongo",
|
|
18
|
-
entities: [],
|
|
19
|
-
clientUrl: "mongo://localhost",
|
|
20
|
-
subscribers: [new Subscriber1()]
|
|
21
|
-
} as never;
|
|
22
|
-
const mockedMikroOrmRegistry = mock<MikroOrmRegistry>();
|
|
23
|
-
const mockedMikroOrmContext = mock<MikroOrmContext>();
|
|
24
|
-
const mockedMikroORM = mock<MikroORM>();
|
|
25
|
-
const mockedEntityManager = mock<EntityManager>();
|
|
26
|
-
|
|
27
|
-
let mikroOrmModule!: MikroOrmModule;
|
|
28
|
-
|
|
29
|
-
beforeEach(async () => {
|
|
30
|
-
await PlatformTest.create({
|
|
31
|
-
mikroOrm: [config],
|
|
32
|
-
imports: [
|
|
33
|
-
{
|
|
34
|
-
token: MikroOrmContext,
|
|
35
|
-
use: instance(mockedMikroOrmContext)
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
token: MikroOrmRegistry,
|
|
39
|
-
use: instance(mockedMikroOrmRegistry)
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
mikroOrmModule = PlatformTest.get<MikroOrmModule>(MikroOrmModule);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
vi.resetAllMocks();
|
|
49
|
-
|
|
50
|
-
reset<MikroOrmRegistry | EntityManager | MikroORM | MikroOrmContext>(
|
|
51
|
-
mockedMikroOrmRegistry,
|
|
52
|
-
mockedMikroOrmContext,
|
|
53
|
-
mockedMikroORM,
|
|
54
|
-
mockedEntityManager
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return PlatformTest.reset();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe("$onInit", () => {
|
|
61
|
-
it("should register the subscribers", async () => {
|
|
62
|
-
// act
|
|
63
|
-
await mikroOrmModule.$onInit();
|
|
64
|
-
|
|
65
|
-
// assert
|
|
66
|
-
verify(
|
|
67
|
-
mockedMikroOrmRegistry.register(deepEqual({...config, subscribers: [anyOfClass(Subscriber1), anyOfClass(Subscriber2)]}))
|
|
68
|
-
).called();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("$onDestroy", () => {
|
|
73
|
-
it("should destroy the corresponding instances", async () => {
|
|
74
|
-
// act
|
|
75
|
-
await mikroOrmModule.$onDestroy();
|
|
76
|
-
|
|
77
|
-
// assert
|
|
78
|
-
verify(mockedMikroOrmRegistry.clear()).called();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe("$alterRunInContext", () => {
|
|
83
|
-
it("should return a function", () => {
|
|
84
|
-
// arrange
|
|
85
|
-
const next = vi.fn();
|
|
86
|
-
|
|
87
|
-
// act
|
|
88
|
-
const result = mikroOrmModule.$alterRunInContext(next);
|
|
89
|
-
|
|
90
|
-
// assert
|
|
91
|
-
expect(result).toBeInstanceOf(Function);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("should make a function create a context", () => {
|
|
95
|
-
// arrange
|
|
96
|
-
const next = vi.fn();
|
|
97
|
-
const manager = instance(mockedEntityManager);
|
|
98
|
-
|
|
99
|
-
when(mockedMikroOrmRegistry.values()).thenReturn([instance(mockedMikroORM)] as unknown as IterableIterator<MikroORM>);
|
|
100
|
-
when(mockedMikroORM.em).thenReturn(manager);
|
|
101
|
-
when(mockedMikroOrmContext.run(anything(), anything())).thenReturn();
|
|
102
|
-
|
|
103
|
-
// act
|
|
104
|
-
mikroOrmModule.$alterRunInContext(next)();
|
|
105
|
-
|
|
106
|
-
// assert
|
|
107
|
-
verify(mockedMikroOrmContext.run(deepEqual([manager]), next)).once();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
package/src/MikroOrmModule.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import "./services/MikroOrmFactory.js";
|
|
2
|
-
|
|
3
|
-
import {EventSubscriber, Options} from "@mikro-orm/core";
|
|
4
|
-
import {classOf, isFunction, Store} from "@tsed/core";
|
|
5
|
-
import {
|
|
6
|
-
AlterRunInContext,
|
|
7
|
-
Constant,
|
|
8
|
-
Inject,
|
|
9
|
-
InjectorService,
|
|
10
|
-
LocalsContainer,
|
|
11
|
-
Module,
|
|
12
|
-
OnDestroy,
|
|
13
|
-
OnInit,
|
|
14
|
-
ProviderScope,
|
|
15
|
-
registerProvider
|
|
16
|
-
} from "@tsed/di";
|
|
17
|
-
|
|
18
|
-
import {DEFAULT_CONTEXT_NAME, SUBSCRIBER_INJECTION_TYPE} from "./constants.js";
|
|
19
|
-
import {OptimisticLockErrorFilter} from "./filters/OptimisticLockErrorFilter.js";
|
|
20
|
-
import {RetryStrategy} from "./interfaces/RetryStrategy.js";
|
|
21
|
-
import {MikroOrmContext} from "./services/MikroOrmContext.js";
|
|
22
|
-
import {MikroOrmRegistry} from "./services/MikroOrmRegistry.js";
|
|
23
|
-
|
|
24
|
-
declare global {
|
|
25
|
-
namespace TsED {
|
|
26
|
-
interface Configuration {
|
|
27
|
-
/**
|
|
28
|
-
* The ORM configuration, entity metadata.
|
|
29
|
-
* If you omit the `options` parameter, your CLI config will be used.
|
|
30
|
-
*/
|
|
31
|
-
mikroOrm?: Options[];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@Module({
|
|
37
|
-
responseFilters: [OptimisticLockErrorFilter]
|
|
38
|
-
})
|
|
39
|
-
export class MikroOrmModule implements OnDestroy, OnInit, AlterRunInContext {
|
|
40
|
-
@Constant("mikroOrm", [])
|
|
41
|
-
private readonly settings!: Options[];
|
|
42
|
-
|
|
43
|
-
@Inject()
|
|
44
|
-
private readonly registry!: MikroOrmRegistry;
|
|
45
|
-
|
|
46
|
-
@Inject()
|
|
47
|
-
private readonly context!: MikroOrmContext;
|
|
48
|
-
|
|
49
|
-
@Inject()
|
|
50
|
-
private readonly injector!: InjectorService;
|
|
51
|
-
|
|
52
|
-
constructor(@Inject(SUBSCRIBER_INJECTION_TYPE) private subscribers: EventSubscriber[]) {}
|
|
53
|
-
|
|
54
|
-
public async $onInit(): Promise<void> {
|
|
55
|
-
const container = new LocalsContainer();
|
|
56
|
-
|
|
57
|
-
await Promise.all(
|
|
58
|
-
this.settings.map((opts) =>
|
|
59
|
-
this.registry.register({
|
|
60
|
-
...opts,
|
|
61
|
-
subscribers: this.getSubscribers(opts, container)
|
|
62
|
-
})
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public $onDestroy(): Promise<void> {
|
|
68
|
-
return this.registry.clear();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public $alterRunInContext(next: (...args: unknown[]) => unknown): () => unknown | Promise<() => unknown> {
|
|
72
|
-
return () => this.createContext(next);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private getSubscribers(opts: Pick<Options, "subscribers" | "contextName">, container: LocalsContainer) {
|
|
76
|
-
return [...this.getUnmanagedSubscribers(opts, container), ...this.getManagedSubscribers(opts.contextName)];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private getUnmanagedSubscribers(opts: Pick<Options, "subscribers">, container: LocalsContainer) {
|
|
80
|
-
return (opts.subscribers ?? []).map((subscriber) => {
|
|
81
|
-
// Starting from https://github.com/mikro-orm/mikro-orm/issues/4231 mikro-orm
|
|
82
|
-
// accept also accepts class reference, not just instances.
|
|
83
|
-
if (isFunction(subscriber)) {
|
|
84
|
-
return this.injector.invoke(subscriber, {locals: container});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return subscriber;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private getManagedSubscribers(contextName: string = DEFAULT_CONTEXT_NAME): EventSubscriber[] {
|
|
92
|
-
return this.subscribers.filter((instance) => Store.from(classOf(instance)).get(SUBSCRIBER_INJECTION_TYPE)?.contextName === contextName);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private createContext(next: (...args: unknown[]) => unknown): unknown {
|
|
96
|
-
const instances = [...this.registry.values()];
|
|
97
|
-
const managers = instances.map((orm) => orm.em);
|
|
98
|
-
|
|
99
|
-
return this.context.run(managers, next);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// TODO: the IoC container should provide null or undefined by default until tsedio/tsed#1694 is closed
|
|
104
|
-
registerProvider({token: RetryStrategy, useValue: null});
|
package/src/constants.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {MikroORM} from "@mikro-orm/core";
|
|
2
|
-
import {MongoEntityManager} from "@mikro-orm/mongodb";
|
|
3
|
-
import {DITest, Injectable} from "@tsed/di";
|
|
4
|
-
import {afterEach, beforeEach} from "vitest";
|
|
5
|
-
|
|
6
|
-
import {MikroOrmRegistry} from "../services/MikroOrmRegistry.js";
|
|
7
|
-
import {Em, EntityManager, entityManager} from "./entityManager.js";
|
|
8
|
-
|
|
9
|
-
describe("@EntityManager()", () => {
|
|
10
|
-
beforeEach(() => DITest.create());
|
|
11
|
-
afterEach(() => DITest.reset());
|
|
12
|
-
|
|
13
|
-
describe("decorator", () => {
|
|
14
|
-
it("should decorate property (without context)", async () => {
|
|
15
|
-
@Injectable()
|
|
16
|
-
class UsersService {
|
|
17
|
-
@Em()
|
|
18
|
-
public readonly em!: MongoEntityManager;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const ormRegistry = {
|
|
22
|
-
get: vi.fn().mockReturnValue({em: {id: "id"}} as never)
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
26
|
-
{
|
|
27
|
-
token: MikroOrmRegistry,
|
|
28
|
-
use: ormRegistry
|
|
29
|
-
}
|
|
30
|
-
]);
|
|
31
|
-
expect(ormRegistry.get).toHaveBeenCalledWith(undefined);
|
|
32
|
-
expect(usersService.em).toEqual({id: "id"});
|
|
33
|
-
});
|
|
34
|
-
it("should decorate property (with context)", async () => {
|
|
35
|
-
@Injectable()
|
|
36
|
-
class UsersService {
|
|
37
|
-
@EntityManager("context")
|
|
38
|
-
public readonly orm!: MikroORM;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const ormRegistry = {
|
|
42
|
-
get: vi.fn().mockReturnValue({em: {id: "id"}} as never)
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
46
|
-
{
|
|
47
|
-
token: MikroOrmRegistry,
|
|
48
|
-
use: ormRegistry
|
|
49
|
-
}
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
expect(ormRegistry.get).toHaveBeenCalledWith("context");
|
|
53
|
-
expect(usersService.orm).toEqual({id: "id"});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("prop function", () => {
|
|
58
|
-
it("should inject property (without context)", async () => {
|
|
59
|
-
@Injectable()
|
|
60
|
-
class UsersService {
|
|
61
|
-
public readonly em = entityManager();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const ormRegistry = {
|
|
65
|
-
get: vi.fn().mockReturnValue({em: {id: "id"}} as never)
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
69
|
-
{
|
|
70
|
-
token: MikroOrmRegistry,
|
|
71
|
-
use: ormRegistry
|
|
72
|
-
}
|
|
73
|
-
]);
|
|
74
|
-
expect(ormRegistry.get).toHaveBeenCalledWith(undefined);
|
|
75
|
-
expect(usersService.em).toEqual({id: "id"});
|
|
76
|
-
});
|
|
77
|
-
it("should inject property (with context)", async () => {
|
|
78
|
-
@Injectable()
|
|
79
|
-
class UsersService {
|
|
80
|
-
public readonly em = entityManager("context");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const ormRegistry = {
|
|
84
|
-
get: vi.fn().mockReturnValue({em: {id: "id"}} as never)
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
88
|
-
{
|
|
89
|
-
token: MikroOrmRegistry,
|
|
90
|
-
use: ormRegistry
|
|
91
|
-
}
|
|
92
|
-
]);
|
|
93
|
-
|
|
94
|
-
expect(ormRegistry.get).toHaveBeenCalledWith("context");
|
|
95
|
-
expect(usersService.em).toEqual({id: "id"});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {Inject} from "@tsed/di";
|
|
2
|
-
|
|
3
|
-
import {MikroOrmRegistry} from "../services/MikroOrmRegistry.js";
|
|
4
|
-
import {orm} from "./orm.js";
|
|
5
|
-
|
|
6
|
-
export function entityManager(contextName?: string) {
|
|
7
|
-
return orm(contextName)?.em;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Get the entity manager for the given context name.
|
|
12
|
-
* @param {String} contextName
|
|
13
|
-
* @decorator
|
|
14
|
-
* @mikroOrm
|
|
15
|
-
*/
|
|
16
|
-
export const EntityManager = (contextName?: string): PropertyDecorator =>
|
|
17
|
-
Inject(MikroOrmRegistry, {transform: (registry: MikroOrmRegistry) => registry.get(contextName)?.em}) as PropertyDecorator;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get the entity manager for the given context name.
|
|
21
|
-
* @param {String} connectionName
|
|
22
|
-
* @decorator
|
|
23
|
-
* @mikroOrm
|
|
24
|
-
*/
|
|
25
|
-
export const Em = EntityManager;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {MikroORM} from "@mikro-orm/core";
|
|
2
|
-
import {DITest, Injectable} from "@tsed/di";
|
|
3
|
-
import {afterEach, beforeEach} from "vitest";
|
|
4
|
-
|
|
5
|
-
import {MikroOrmRegistry} from "../services/MikroOrmRegistry.js";
|
|
6
|
-
import {Orm, orm} from "./orm.js";
|
|
7
|
-
|
|
8
|
-
describe("@Orm()", () => {
|
|
9
|
-
beforeEach(() => DITest.create());
|
|
10
|
-
afterEach(() => DITest.reset());
|
|
11
|
-
|
|
12
|
-
describe("decorator", () => {
|
|
13
|
-
it("should decorate property (without context)", async () => {
|
|
14
|
-
@Injectable()
|
|
15
|
-
class UsersService {
|
|
16
|
-
@Orm()
|
|
17
|
-
public readonly orm!: MikroORM;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const ormRegistry = {
|
|
21
|
-
get: vi.fn().mockReturnValue({id: "id"} as never)
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
25
|
-
{
|
|
26
|
-
token: MikroOrmRegistry,
|
|
27
|
-
use: ormRegistry
|
|
28
|
-
}
|
|
29
|
-
]);
|
|
30
|
-
expect(ormRegistry.get).toHaveBeenCalledWith(undefined);
|
|
31
|
-
expect(usersService.orm).toEqual({id: "id"});
|
|
32
|
-
});
|
|
33
|
-
it("should decorate property (with context)", async () => {
|
|
34
|
-
@Injectable()
|
|
35
|
-
class UsersService {
|
|
36
|
-
@Orm("context")
|
|
37
|
-
public readonly orm!: MikroORM;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const ormRegistry = {
|
|
41
|
-
get: vi.fn().mockReturnValue({id: "id"} as never)
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
45
|
-
{
|
|
46
|
-
token: MikroOrmRegistry,
|
|
47
|
-
use: ormRegistry
|
|
48
|
-
}
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
expect(ormRegistry.get).toHaveBeenCalledWith("context");
|
|
52
|
-
expect(usersService.orm).toEqual({id: "id"});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("prop function", () => {
|
|
57
|
-
it("should inject property (without context)", async () => {
|
|
58
|
-
@Injectable()
|
|
59
|
-
class UsersService {
|
|
60
|
-
public readonly orm = orm();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const ormRegistry = {
|
|
64
|
-
get: vi.fn().mockReturnValue({id: "id"} as never)
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
68
|
-
{
|
|
69
|
-
token: MikroOrmRegistry,
|
|
70
|
-
use: ormRegistry
|
|
71
|
-
}
|
|
72
|
-
]);
|
|
73
|
-
expect(ormRegistry.get).toHaveBeenCalledWith(undefined);
|
|
74
|
-
expect(usersService.orm).toEqual({id: "id"});
|
|
75
|
-
});
|
|
76
|
-
it("should inject property (with context)", async () => {
|
|
77
|
-
@Injectable()
|
|
78
|
-
class UsersService {
|
|
79
|
-
public readonly orm = orm("context");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const ormRegistry = {
|
|
83
|
-
get: vi.fn().mockReturnValue({id: "id"} as never)
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const usersService = await DITest.invoke<UsersService>(UsersService, [
|
|
87
|
-
{
|
|
88
|
-
token: MikroOrmRegistry,
|
|
89
|
-
use: ormRegistry
|
|
90
|
-
}
|
|
91
|
-
]);
|
|
92
|
-
|
|
93
|
-
expect(ormRegistry.get).toHaveBeenCalledWith("context");
|
|
94
|
-
expect(usersService.orm).toEqual({id: "id"});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|