@tsed/mikro-orm 8.0.0-alpha.5 → 8.0.0-alpha.6
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 +1 -1
- package/package.json +14 -15
- package/lib/cjs/MikroOrmModule.js +0 -76
- package/lib/cjs/MikroOrmModule.js.map +0 -1
- package/lib/cjs/constants.js +0 -6
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/decorators/entityManager.js +0 -26
- package/lib/cjs/decorators/entityManager.js.map +0 -1
- package/lib/cjs/decorators/orm.js +0 -20
- package/lib/cjs/decorators/orm.js.map +0 -1
- package/lib/cjs/decorators/subscriber.js +0 -14
- package/lib/cjs/decorators/subscriber.js.map +0 -1
- package/lib/cjs/decorators/transactional.js +0 -12
- package/lib/cjs/decorators/transactional.js.map +0 -1
- package/lib/cjs/filters/OptimisticLockErrorFilter.js +0 -20
- package/lib/cjs/filters/OptimisticLockErrorFilter.js.map +0 -1
- package/lib/cjs/index.js +0 -21
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interceptors/TransactionalInterceptor.js +0 -105
- package/lib/cjs/interceptors/TransactionalInterceptor.js.map +0 -1
- package/lib/cjs/interfaces/AfterTransactionCommit.js +0 -3
- package/lib/cjs/interfaces/AfterTransactionCommit.js.map +0 -1
- package/lib/cjs/interfaces/BeforeTransactionCommit.js +0 -3
- package/lib/cjs/interfaces/BeforeTransactionCommit.js.map +0 -1
- package/lib/cjs/interfaces/RetryStrategy.js +0 -5
- package/lib/cjs/interfaces/RetryStrategy.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/services/MikroOrmContext.js +0 -34
- package/lib/cjs/services/MikroOrmContext.js.map +0 -1
- package/lib/cjs/services/MikroOrmFactory.js +0 -25
- package/lib/cjs/services/MikroOrmFactory.js.map +0 -1
- package/lib/cjs/services/MikroOrmRegistry.js +0 -56
- package/lib/cjs/services/MikroOrmRegistry.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/MikroOrmModule.d.ts +0 -29
- package/lib/types-esm/constants.d.ts +0 -2
- package/lib/types-esm/decorators/entityManager.d.ts +0 -15
- package/lib/types-esm/decorators/orm.d.ts +0 -11
- package/lib/types-esm/decorators/subscriber.d.ts +0 -8
- package/lib/types-esm/decorators/transactional.d.ts +0 -6
- package/lib/types-esm/filters/OptimisticLockErrorFilter.d.ts +0 -5
- package/lib/types-esm/index.d.ts +0 -17
- package/lib/types-esm/interceptors/TransactionalInterceptor.d.ts +0 -31
- package/lib/types-esm/interfaces/AfterTransactionCommit.d.ts +0 -4
- package/lib/types-esm/interfaces/BeforeTransactionCommit.d.ts +0 -4
- package/lib/types-esm/interfaces/RetryStrategy.d.ts +0 -4
- package/lib/types-esm/services/MikroOrmContext.d.ts +0 -9
- package/lib/types-esm/services/MikroOrmFactory.d.ts +0 -7
- package/lib/types-esm/services/MikroOrmRegistry.d.ts +0 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
-
import "./services/MikroOrmFactory
|
|
2
|
+
import "./services/MikroOrmFactory";
|
|
3
3
|
import { Constant, Inject, InjectorService, LocalsContainer, Module, ProviderScope, registerProvider } from "@tsed/di";
|
|
4
4
|
import { MikroOrmRegistry } from "./services/MikroOrmRegistry.js";
|
|
5
5
|
import { RetryStrategy } from "./interfaces/RetryStrategy.js";
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mikro-orm",
|
|
3
3
|
"description": "MikroORM package for Ts.ED framework",
|
|
4
|
-
"type": "
|
|
5
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.0.0-alpha.6",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/
|
|
7
|
+
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
9
9
|
"typings": "./lib/types/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./lib/types/index.d.ts",
|
|
13
13
|
"import": "./lib/esm/index.js",
|
|
14
|
-
"require": "./lib/cjs/index.js",
|
|
15
14
|
"default": "./lib/cjs/index.js"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
@@ -28,15 +27,15 @@
|
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@mikro-orm/core": "6.2.2",
|
|
30
29
|
"@mikro-orm/mongodb": "6.2.2",
|
|
31
|
-
"@tsed/barrels": "8.0.0-alpha.
|
|
32
|
-
"@tsed/common": "8.0.0-alpha.
|
|
33
|
-
"@tsed/core": "8.0.0-alpha.
|
|
34
|
-
"@tsed/di": "8.0.0-alpha.
|
|
35
|
-
"@tsed/json-mapper": "8.0.0-alpha.
|
|
30
|
+
"@tsed/barrels": "8.0.0-alpha.6",
|
|
31
|
+
"@tsed/common": "8.0.0-alpha.6",
|
|
32
|
+
"@tsed/core": "8.0.0-alpha.6",
|
|
33
|
+
"@tsed/di": "8.0.0-alpha.6",
|
|
34
|
+
"@tsed/json-mapper": "8.0.0-alpha.6",
|
|
36
35
|
"@tsed/logger": ">=6.7.5",
|
|
37
|
-
"@tsed/schema": "8.0.0-alpha.
|
|
38
|
-
"@tsed/testcontainers-mongo": "8.0.0-alpha.
|
|
39
|
-
"@tsed/typescript": "8.0.0-alpha.
|
|
36
|
+
"@tsed/schema": "8.0.0-alpha.6",
|
|
37
|
+
"@tsed/testcontainers-mongo": "8.0.0-alpha.6",
|
|
38
|
+
"@tsed/typescript": "8.0.0-alpha.6",
|
|
40
39
|
"cross-env": "7.0.3",
|
|
41
40
|
"eslint": "^8.57.0",
|
|
42
41
|
"ts-mockito": "^2.6.1",
|
|
@@ -45,9 +44,9 @@
|
|
|
45
44
|
},
|
|
46
45
|
"peerDependencies": {
|
|
47
46
|
"@mikro-orm/core": ">=4.5.9",
|
|
48
|
-
"@tsed/common": "8.0.0-alpha.
|
|
49
|
-
"@tsed/core": "8.0.0-alpha.
|
|
50
|
-
"@tsed/di": "8.0.0-alpha.
|
|
47
|
+
"@tsed/common": "8.0.0-alpha.6",
|
|
48
|
+
"@tsed/core": "8.0.0-alpha.6",
|
|
49
|
+
"@tsed/di": "8.0.0-alpha.6",
|
|
51
50
|
"@tsed/logger": ">=6.7.5"
|
|
52
51
|
},
|
|
53
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MikroOrmModule = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
require("./services/MikroOrmFactory");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const MikroOrmRegistry_js_1 = require("./services/MikroOrmRegistry.js");
|
|
8
|
-
const RetryStrategy_js_1 = require("./interfaces/RetryStrategy.js");
|
|
9
|
-
const OptimisticLockErrorFilter_js_1 = require("./filters/OptimisticLockErrorFilter.js");
|
|
10
|
-
const MikroOrmContext_js_1 = require("./services/MikroOrmContext.js");
|
|
11
|
-
const core_1 = require("@tsed/core");
|
|
12
|
-
const constants_js_1 = require("./constants.js");
|
|
13
|
-
let MikroOrmModule = class MikroOrmModule {
|
|
14
|
-
constructor(subscribers) {
|
|
15
|
-
this.subscribers = subscribers;
|
|
16
|
-
}
|
|
17
|
-
async $onInit() {
|
|
18
|
-
const container = new di_1.LocalsContainer();
|
|
19
|
-
await Promise.all(this.settings.map((opts) => this.registry.register({ ...opts, subscribers: this.getSubscribers(opts, container) })));
|
|
20
|
-
}
|
|
21
|
-
$onDestroy() {
|
|
22
|
-
return this.registry.clear();
|
|
23
|
-
}
|
|
24
|
-
$alterRunInContext(next) {
|
|
25
|
-
return () => this.createContext(next);
|
|
26
|
-
}
|
|
27
|
-
getSubscribers(opts, container) {
|
|
28
|
-
return [...this.getUnmanagedSubscribers(opts, container), ...this.getManagedSubscribers(opts.contextName)];
|
|
29
|
-
}
|
|
30
|
-
getUnmanagedSubscribers(opts, container) {
|
|
31
|
-
const diOpts = { scope: di_1.ProviderScope.INSTANCE };
|
|
32
|
-
return (opts.subscribers ?? []).map((subscriber) => {
|
|
33
|
-
// Starting from https://github.com/mikro-orm/mikro-orm/issues/4231 mikro-orm
|
|
34
|
-
// accept also accepts class reference, not just instances.
|
|
35
|
-
if ((0, core_1.isFunction)(subscriber)) {
|
|
36
|
-
return this.injector.invoke(subscriber, container, diOpts);
|
|
37
|
-
}
|
|
38
|
-
return subscriber;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
getManagedSubscribers(contextName = constants_js_1.DEFAULT_CONTEXT_NAME) {
|
|
42
|
-
return this.subscribers.filter((instance) => core_1.Store.from((0, core_1.classOf)(instance)).get(constants_js_1.SUBSCRIBER_INJECTION_TYPE)?.contextName === contextName);
|
|
43
|
-
}
|
|
44
|
-
createContext(next) {
|
|
45
|
-
const instances = [...this.registry.values()];
|
|
46
|
-
const managers = instances.map((orm) => orm.em);
|
|
47
|
-
return this.context.run(managers, next);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
tslib_1.__decorate([
|
|
51
|
-
(0, di_1.Constant)("mikroOrm", []),
|
|
52
|
-
tslib_1.__metadata("design:type", Array)
|
|
53
|
-
], MikroOrmModule.prototype, "settings", void 0);
|
|
54
|
-
tslib_1.__decorate([
|
|
55
|
-
(0, di_1.Inject)(),
|
|
56
|
-
tslib_1.__metadata("design:type", MikroOrmRegistry_js_1.MikroOrmRegistry)
|
|
57
|
-
], MikroOrmModule.prototype, "registry", void 0);
|
|
58
|
-
tslib_1.__decorate([
|
|
59
|
-
(0, di_1.Inject)(),
|
|
60
|
-
tslib_1.__metadata("design:type", MikroOrmContext_js_1.MikroOrmContext)
|
|
61
|
-
], MikroOrmModule.prototype, "context", void 0);
|
|
62
|
-
tslib_1.__decorate([
|
|
63
|
-
(0, di_1.Inject)(),
|
|
64
|
-
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
65
|
-
], MikroOrmModule.prototype, "injector", void 0);
|
|
66
|
-
MikroOrmModule = tslib_1.__decorate([
|
|
67
|
-
(0, di_1.Module)({
|
|
68
|
-
responseFilters: [OptimisticLockErrorFilter_js_1.OptimisticLockErrorFilter]
|
|
69
|
-
}),
|
|
70
|
-
tslib_1.__param(0, (0, di_1.Inject)(constants_js_1.SUBSCRIBER_INJECTION_TYPE)),
|
|
71
|
-
tslib_1.__metadata("design:paramtypes", [Array])
|
|
72
|
-
], MikroOrmModule);
|
|
73
|
-
exports.MikroOrmModule = MikroOrmModule;
|
|
74
|
-
// TODO: the IoC container should provide null or undefined by default until tsedio/tsed#1694 is closed
|
|
75
|
-
(0, di_1.registerProvider)({ provide: RetryStrategy_js_1.RetryStrategy, useValue: null });
|
|
76
|
-
//# sourceMappingURL=MikroOrmModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmModule.js","sourceRoot":"","sources":["../../src/MikroOrmModule.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AACpC,iCAWkB;AAElB,wEAAgE;AAChE,oEAA4D;AAC5D,yFAAiF;AACjF,sEAA8D;AAC9D,qCAAsD;AACtD,iDAA+E;AAkBxE,IAAM,cAAc,GAApB,MAAM,cAAc;IAazB,YAAuD,WAA8B;QAA9B,gBAAW,GAAX,WAAW,CAAmB;IAAG,CAAC;IAElF,KAAK,CAAC,OAAO;QAClB,MAAM,SAAS,GAAG,IAAI,oBAAe,EAAE,CAAC;QAExC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAC,GAAG,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,EAAC,CAAC,CAAC,CA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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;AAxDC;IAAC,IAAA,aAAQ,EAAC,UAAU,EAAE,EAAE,CAAC;;gDACa;AAEtC;IAAC,IAAA,WAAM,GAAE;sCACmB,sCAAgB;gDAAC;AAE7C;IAAC,IAAA,WAAM,GAAE;sCACkB,oCAAe;+CAAC;AAE3C;IAAC,IAAA,WAAM,GAAE;sCACmB,oBAAe;gDAAC;AAXjC,cAAc;IAH1B,IAAA,WAAM,EAAC;QACN,eAAe,EAAE,CAAC,wDAAyB,CAAC;KAC7C,CAAC;IAca,mBAAA,IAAA,WAAM,EAAC,wCAAyB,CAAC,CAAA;;GAbnC,cAAc,CAyD1B;AAzDY,wCAAc;AA2D3B,uGAAuG;AACvG,IAAA,qBAAgB,EAAC,EAAC,OAAO,EAAE,gCAAa,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC"}
|
package/lib/cjs/constants.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUBSCRIBER_INJECTION_TYPE = exports.DEFAULT_CONTEXT_NAME = void 0;
|
|
4
|
-
exports.DEFAULT_CONTEXT_NAME = "default";
|
|
5
|
-
exports.SUBSCRIBER_INJECTION_TYPE = Symbol("Subscriber");
|
|
6
|
-
//# sourceMappingURL=constants.js.map
|
package/lib/cjs/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,SAAS,CAAC;AACjC,QAAA,yBAAyB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Em = exports.EntityManager = exports.entityManager = void 0;
|
|
4
|
-
const di_1 = require("@tsed/di");
|
|
5
|
-
const MikroOrmRegistry_js_1 = require("../services/MikroOrmRegistry.js");
|
|
6
|
-
const orm_js_1 = require("./orm.js");
|
|
7
|
-
function entityManager(contextName) {
|
|
8
|
-
return (0, orm_js_1.orm)(contextName)?.em;
|
|
9
|
-
}
|
|
10
|
-
exports.entityManager = entityManager;
|
|
11
|
-
/**
|
|
12
|
-
* Get the entity manager for the given context name.
|
|
13
|
-
* @param {String} contextName
|
|
14
|
-
* @decorator
|
|
15
|
-
* @mikroOrm
|
|
16
|
-
*/
|
|
17
|
-
const EntityManager = (contextName) => (0, di_1.Inject)(MikroOrmRegistry_js_1.MikroOrmRegistry, { transform: (registry) => registry.get(contextName)?.em });
|
|
18
|
-
exports.EntityManager = EntityManager;
|
|
19
|
-
/**
|
|
20
|
-
* Get the entity manager for the given context name.
|
|
21
|
-
* @param {String} connectionName
|
|
22
|
-
* @decorator
|
|
23
|
-
* @mikroOrm
|
|
24
|
-
*/
|
|
25
|
-
exports.Em = exports.EntityManager;
|
|
26
|
-
//# sourceMappingURL=entityManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entityManager.js","sourceRoot":"","sources":["../../../src/decorators/entityManager.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,yEAAiE;AACjE,qCAA6B;AAE7B,SAAgB,aAAa,CAAC,WAAoB;IAChD,OAAO,IAAA,YAAG,EAAC,WAAW,CAAC,EAAE,EAAE,CAAC;AAC9B,CAAC;AAFD,sCAEC;AAED;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,WAAoB,EAAqB,EAAE,CACvE,IAAA,WAAM,EAAC,sCAAgB,EAAE,EAAC,SAAS,EAAE,CAAC,QAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,EAAC,CAAsB,CAAC;AAD/G,QAAA,aAAa,iBACkG;AAE5H;;;;;GAKG;AACU,QAAA,EAAE,GAAG,qBAAa,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Orm = exports.orm = void 0;
|
|
4
|
-
const di_1 = require("@tsed/di");
|
|
5
|
-
const MikroOrmRegistry_js_1 = require("../services/MikroOrmRegistry.js");
|
|
6
|
-
/**
|
|
7
|
-
* Get the ORM for the given context name using new inject() function.
|
|
8
|
-
* @param contextName
|
|
9
|
-
*/
|
|
10
|
-
function orm(contextName) {
|
|
11
|
-
return (0, di_1.inject)(MikroOrmRegistry_js_1.MikroOrmRegistry).get(contextName);
|
|
12
|
-
}
|
|
13
|
-
exports.orm = orm;
|
|
14
|
-
/**
|
|
15
|
-
* Get the ORM for the given context name.
|
|
16
|
-
* @param {String} contextName
|
|
17
|
-
*/
|
|
18
|
-
const Orm = (contextName) => (0, di_1.Inject)(MikroOrmRegistry_js_1.MikroOrmRegistry, { transform: (registry) => registry.get(contextName) });
|
|
19
|
-
exports.Orm = Orm;
|
|
20
|
-
//# sourceMappingURL=orm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orm.js","sourceRoot":"","sources":["../../../src/decorators/orm.ts"],"names":[],"mappings":";;;AACA,iCAAwC;AACxC,yEAAiE;AAEjE;;;GAGG;AACH,SAAgB,GAAG,CAAC,WAAoB;IACtC,OAAO,IAAA,WAAM,EAAC,sCAAgB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACnD,CAAC;AAFD,kBAEC;AAED;;;GAGG;AACI,MAAM,GAAG,GAAG,CAAC,WAAoB,EAAqB,EAAE,CAC7D,IAAA,WAAM,EAAC,sCAAgB,EAAE,EAAC,SAAS,EAAE,CAAC,QAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAC,CAAsB,CAAC;AAD3G,QAAA,GAAG,OACwG"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Subscriber = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const constants_js_1 = require("../constants.js");
|
|
7
|
-
/**
|
|
8
|
-
* Register a new subscriber for the given context name.
|
|
9
|
-
* @decorator
|
|
10
|
-
* @mikroOrm
|
|
11
|
-
*/
|
|
12
|
-
const Subscriber = (options = { contextName: constants_js_1.DEFAULT_CONTEXT_NAME }) => (0, core_1.useDecorators)((0, di_1.Injectable)({ type: constants_js_1.SUBSCRIBER_INJECTION_TYPE }), (0, core_1.StoreSet)(constants_js_1.SUBSCRIBER_INJECTION_TYPE, options));
|
|
13
|
-
exports.Subscriber = Subscriber;
|
|
14
|
-
//# sourceMappingURL=subscriber.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscriber.js","sourceRoot":"","sources":["../../../src/decorators/subscriber.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAAoC;AACpC,kDAAgF;AAEhF;;;;GAIG;AACI,MAAM,UAAU,GAAG,CAAC,UAAiC,EAAC,WAAW,EAAE,mCAAoB,EAAC,EAAE,EAAE,CACjG,IAAA,oBAAa,EAAC,IAAA,eAAU,EAAC,EAAC,IAAI,EAAE,wCAAyB,EAAC,CAAC,EAAE,IAAA,eAAQ,EAAC,wCAAyB,EAAE,OAAO,CAAC,CAAC,CAAC;AADhG,QAAA,UAAU,cACsF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Transactional = void 0;
|
|
4
|
-
const di_1 = require("@tsed/di");
|
|
5
|
-
const TransactionalInterceptor_js_1 = require("../interceptors/TransactionalInterceptor.js");
|
|
6
|
-
/**
|
|
7
|
-
* Register a new request context for your method and execute it inside the context.
|
|
8
|
-
* @param {String | TransactionOptions} contextNameOrOptions
|
|
9
|
-
*/
|
|
10
|
-
const Transactional = (contextNameOrOptions) => (0, di_1.Intercept)(TransactionalInterceptor_js_1.TransactionalInterceptor, contextNameOrOptions);
|
|
11
|
-
exports.Transactional = Transactional;
|
|
12
|
-
//# sourceMappingURL=transactional.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transactional.js","sourceRoot":"","sources":["../../../src/decorators/transactional.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,6FAAyG;AAEzG;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,oBAAkD,EAAmB,EAAE,CACnG,IAAA,cAAS,EAAC,sDAAwB,EAAE,oBAAoB,CAAC,CAAC;AAD/C,QAAA,aAAa,iBACkC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OptimisticLockErrorFilter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@tsed/common");
|
|
6
|
-
const core_1 = require("@mikro-orm/core");
|
|
7
|
-
let OptimisticLockErrorFilter = class OptimisticLockErrorFilter {
|
|
8
|
-
catch(exception, ctx) {
|
|
9
|
-
const { response, logger } = ctx;
|
|
10
|
-
logger.error({
|
|
11
|
-
exception
|
|
12
|
-
});
|
|
13
|
-
response.status(409).body(`Update refused. The resource has changed on the server. Please try again later`);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
OptimisticLockErrorFilter = tslib_1.__decorate([
|
|
17
|
-
(0, common_1.Catch)(core_1.OptimisticLockError)
|
|
18
|
-
], OptimisticLockErrorFilter);
|
|
19
|
-
exports.OptimisticLockErrorFilter = OptimisticLockErrorFilter;
|
|
20
|
-
//# sourceMappingURL=OptimisticLockErrorFilter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OptimisticLockErrorFilter.js","sourceRoot":"","sources":["../../../src/filters/OptimisticLockErrorFilter.ts"],"names":[],"mappings":";;;;AAAA,yCAA4E;AAC5E,0CAAoD;AAG7C,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,SAAS;SACV,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAC9G,CAAC;CACF,CAAA;AAVY,yBAAyB;IADrC,IAAA,cAAK,EAAC,0BAAmB,CAAC;GACd,yBAAyB,CAUrC;AAVY,8DAAyB"}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* @file Automatically generated by @tsed/barrels.
|
|
6
|
-
*/
|
|
7
|
-
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./decorators/entityManager.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./decorators/orm.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./decorators/subscriber.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./decorators/transactional.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./filters/OptimisticLockErrorFilter.js"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./interceptors/TransactionalInterceptor.js"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./interfaces/AfterTransactionCommit.js"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./interfaces/BeforeTransactionCommit.js"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./interfaces/RetryStrategy.js"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./MikroOrmModule.js"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./services/MikroOrmContext.js"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./services/MikroOrmFactory.js"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./services/MikroOrmRegistry.js"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA+B;AAC/B,wEAA8C;AAC9C,8DAAoC;AACpC,qEAA2C;AAC3C,wEAA8C;AAC9C,iFAAuD;AACvD,qFAA2D;AAC3D,iFAAuD;AACvD,kFAAwD;AACxD,wEAA8C;AAC9C,8DAAoC;AACpC,wEAA8C;AAC9C,wEAA8C;AAC9C,yEAA+C"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionalInterceptor = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const logger_1 = require("@tsed/logger");
|
|
7
|
-
const RetryStrategy_js_1 = require("../interfaces/RetryStrategy.js");
|
|
8
|
-
const MikroOrmContext_js_1 = require("../services/MikroOrmContext.js");
|
|
9
|
-
const MikroOrmRegistry_js_1 = require("../services/MikroOrmRegistry.js");
|
|
10
|
-
const constants_js_1 = require("../constants.js");
|
|
11
|
-
let TransactionalInterceptor = class TransactionalInterceptor {
|
|
12
|
-
constructor(injector, registry, context, logger, retryStrategy) {
|
|
13
|
-
this.injector = injector;
|
|
14
|
-
this.registry = registry;
|
|
15
|
-
this.context = context;
|
|
16
|
-
this.logger = logger;
|
|
17
|
-
this.retryStrategy = retryStrategy;
|
|
18
|
-
}
|
|
19
|
-
intercept(context, next) {
|
|
20
|
-
const options = this.extractContextName(context.options);
|
|
21
|
-
if (options.retry && !this.retryStrategy) {
|
|
22
|
-
this.logger.warn(`To retry a transaction you have to implement a "${RetryStrategy_js_1.RetryStrategy.description}" interface`);
|
|
23
|
-
}
|
|
24
|
-
return this.context.has(options.contextName) ? this.runWithinCtx(next, options) : this.runWithinNewCtx(next, options);
|
|
25
|
-
}
|
|
26
|
-
runWithinCtx(next, options) {
|
|
27
|
-
const callback = () => this.executeInTransaction(next, options);
|
|
28
|
-
return options.retry && this.retryStrategy ? this.retryStrategy.acquire(callback) : callback();
|
|
29
|
-
}
|
|
30
|
-
async runWithinNewCtx(next, options) {
|
|
31
|
-
const em = await this.getGlobalEntityManager(options.contextName);
|
|
32
|
-
return this.context.run([em], () => this.runWithinCtx(next, options));
|
|
33
|
-
}
|
|
34
|
-
getGlobalEntityManager(contextName = constants_js_1.DEFAULT_CONTEXT_NAME) {
|
|
35
|
-
const orm = this.registry.get(contextName);
|
|
36
|
-
if (!orm) {
|
|
37
|
-
throw new Error(`No such context: ${contextName}. Please register a corresponding MikroOrm instance using '@Configuration()' decorator.`);
|
|
38
|
-
}
|
|
39
|
-
return orm.em;
|
|
40
|
-
}
|
|
41
|
-
extractContextName(options) {
|
|
42
|
-
if (typeof options === "string") {
|
|
43
|
-
return {
|
|
44
|
-
contextName: options
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const { flushMode, isolationLevel, contextName = constants_js_1.DEFAULT_CONTEXT_NAME, retry = false, disabled = false } = options ?? {};
|
|
48
|
-
return {
|
|
49
|
-
contextName,
|
|
50
|
-
retry,
|
|
51
|
-
disabled,
|
|
52
|
-
flushMode,
|
|
53
|
-
isolationLevel
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
async executeInTransaction(next, options) {
|
|
57
|
-
const em = this.getEntityManager(options.contextName);
|
|
58
|
-
if (options.disabled) {
|
|
59
|
-
return next();
|
|
60
|
-
}
|
|
61
|
-
const result = await em.transactional(() => this.executeHandlerDelegate(next, options), {
|
|
62
|
-
flushMode: options.flushMode,
|
|
63
|
-
isolationLevel: options.isolationLevel
|
|
64
|
-
});
|
|
65
|
-
await this.afterTransactionCommit(options);
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
async executeHandlerDelegate(next, options) {
|
|
69
|
-
const result = await next();
|
|
70
|
-
await this.beforeTransactionCommit(options);
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
beforeTransactionCommit(options) {
|
|
74
|
-
return this.injector.alterAsync("$beforeTransactionCommit", this.getEntityManager(options.contextName));
|
|
75
|
-
}
|
|
76
|
-
afterTransactionCommit(options) {
|
|
77
|
-
const em = this.getGlobalEntityManager(options.contextName);
|
|
78
|
-
return this.context.run([em], () => {
|
|
79
|
-
const forkedEm = this.getEntityManager(options.contextName);
|
|
80
|
-
forkedEm.resetTransactionContext();
|
|
81
|
-
return this.injector.alterAsync("$afterTransactionCommit", forkedEm);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
getEntityManager(contextName = constants_js_1.DEFAULT_CONTEXT_NAME) {
|
|
85
|
-
const em = this.context.get(contextName);
|
|
86
|
-
if (!em) {
|
|
87
|
-
throw new Error(`No such context: ${contextName}. Please check if the async context is lost in one of the asynchronous operations.`);
|
|
88
|
-
}
|
|
89
|
-
return em;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
TransactionalInterceptor = tslib_1.__decorate([
|
|
93
|
-
(0, di_1.Interceptor)(),
|
|
94
|
-
tslib_1.__param(0, (0, di_1.Inject)()),
|
|
95
|
-
tslib_1.__param(1, (0, di_1.Inject)()),
|
|
96
|
-
tslib_1.__param(2, (0, di_1.Inject)()),
|
|
97
|
-
tslib_1.__param(3, (0, di_1.Inject)()),
|
|
98
|
-
tslib_1.__param(4, (0, di_1.Inject)(RetryStrategy_js_1.RetryStrategy)),
|
|
99
|
-
tslib_1.__metadata("design:paramtypes", [di_1.InjectorService,
|
|
100
|
-
MikroOrmRegistry_js_1.MikroOrmRegistry,
|
|
101
|
-
MikroOrmContext_js_1.MikroOrmContext,
|
|
102
|
-
logger_1.Logger, Object])
|
|
103
|
-
], TransactionalInterceptor);
|
|
104
|
-
exports.TransactionalInterceptor = TransactionalInterceptor;
|
|
105
|
-
//# sourceMappingURL=TransactionalInterceptor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionalInterceptor.js","sourceRoot":"","sources":["../../../src/interceptors/TransactionalInterceptor.ts"],"names":[],"mappings":";;;;AAAA,iCAAuH;AACvH,yCAAoC;AACpC,qEAA6D;AAC7D,uEAA+D;AAC/D,yEAAiE;AAEjE,kDAAqD;AAa9C,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,GAAP,OAAO,CAAiB;QACxB,WAAM,GAAN,MAAM,CAAQ;QAExB,kBAAa,GAAb,aAAa,CAAgB;IAC7C,CAAC;IAEG,SAAS,CAAC,OAAoC,EAAE,IAAqB;QAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEzD,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mDAAmD,gCAAa,CAAC,WAAW,aAAa,CAAC,CAAC;SAC7G;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,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GAAG,EAAE;YACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC5D,QAAQ,CAAC,uBAAuB,EAAE,CAAC;YAEnC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,gBAAgB,CAAC,cAAsB,mCAAoB;QACjE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEzC,IAAI,CAAC,EAAE,EAAE;YACP,MAAM,IAAI,KAAK,CAAC,oBAAoB,WAAW,oFAAoF,CAAC,CAAC;SACtI;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;AA7GY,wBAAwB;IADpC,IAAA,gBAAW,GAAE;IAGT,mBAAA,IAAA,WAAM,GAAE,CAAA;IACR,mBAAA,IAAA,WAAM,GAAE,CAAA;IACR,mBAAA,IAAA,WAAM,GAAE,CAAA;IACR,mBAAA,IAAA,WAAM,GAAE,CAAA;IACR,mBAAA,IAAA,WAAM,EAAC,gCAAa,CAAC,CAAA;6CAJe,oBAAe;QACf,sCAAgB;QACjB,oCAAe;QAChB,eAAM;GALhC,wBAAwB,CA6GpC;AA7GY,4DAAwB"}
|
|
@@ -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,QAAA,aAAa,GAAkB,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MikroOrmContext = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const core_1 = require("@mikro-orm/core");
|
|
7
|
-
const core_2 = require("@tsed/core");
|
|
8
|
-
/**
|
|
9
|
-
* @internal Since 2022-06-20.
|
|
10
|
-
*/
|
|
11
|
-
let MikroOrmContext = class MikroOrmContext {
|
|
12
|
-
run(managers, task) {
|
|
13
|
-
// @ts-expect-error `RequestContext.createAsync` has been removed in favour of `RequestContext.create` since mikro-orm v6.0.0
|
|
14
|
-
if ((0, core_2.isFunction)(core_1.RequestContext.createAsync)) {
|
|
15
|
-
// @ts-expect-error see above
|
|
16
|
-
return core_1.RequestContext.createAsync(managers, task);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return core_1.RequestContext.create(managers, task);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
get(contextName) {
|
|
23
|
-
return core_1.RequestContext.getEntityManager(contextName);
|
|
24
|
-
}
|
|
25
|
-
has(contextName) {
|
|
26
|
-
const manager = this.get(contextName);
|
|
27
|
-
return !!manager;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
MikroOrmContext = tslib_1.__decorate([
|
|
31
|
-
(0, di_1.Injectable)()
|
|
32
|
-
], MikroOrmContext);
|
|
33
|
-
exports.MikroOrmContext = MikroOrmContext;
|
|
34
|
-
//# sourceMappingURL=MikroOrmContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmContext.js","sourceRoot":"","sources":["../../../src/services/MikroOrmContext.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,0CAA8D;AAC9D,qCAAsC;AAEtC;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACnB,GAAG,CAAC,QAAyB,EAAE,IAAqC;QACzE,6HAA6H;QAC7H,IAAI,IAAA,iBAAU,EAAC,qBAAc,CAAC,WAAW,CAAC,EAAE;YAC1C,6BAA6B;YAC7B,OAAO,qBAAc,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM;YACL,OAAO,qBAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAqB,CAAC;SAClE;IACH,CAAC;IAEM,GAAG,CAAC,WAAoB;QAC7B,OAAO,qBAAc,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,IAAA,eAAU,GAAE;GACA,eAAe,CAoB3B;AApBY,0CAAe"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MikroOrmFactory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@mikro-orm/core");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const MikroOrmContext_js_1 = require("./MikroOrmContext.js");
|
|
8
|
-
let MikroOrmFactory = class MikroOrmFactory {
|
|
9
|
-
constructor(context) {
|
|
10
|
-
this.context = context;
|
|
11
|
-
}
|
|
12
|
-
create(options) {
|
|
13
|
-
return core_1.MikroORM.init({
|
|
14
|
-
...options,
|
|
15
|
-
context: (name) => this.context.get(name)
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
MikroOrmFactory = tslib_1.__decorate([
|
|
20
|
-
(0, di_1.Injectable)(),
|
|
21
|
-
tslib_1.__param(0, (0, di_1.Inject)()),
|
|
22
|
-
tslib_1.__metadata("design:paramtypes", [MikroOrmContext_js_1.MikroOrmContext])
|
|
23
|
-
], MikroOrmFactory);
|
|
24
|
-
exports.MikroOrmFactory = MikroOrmFactory;
|
|
25
|
-
//# sourceMappingURL=MikroOrmFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmFactory.js","sourceRoot":"","sources":["../../../src/services/MikroOrmFactory.ts"],"names":[],"mappings":";;;;AAAA,0CAAkD;AAClD,iCAA4C;AAC5C,6DAAqD;AAG9C,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAuC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAE5D,MAAM,CAAC,OAAgB;QAC5B,OAAO,eAAQ,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,IAAA,eAAU,GAAE;IAEE,mBAAA,IAAA,WAAM,GAAE,CAAA;6CAA2B,oCAAe;GADpD,eAAe,CAS3B;AATY,0CAAe"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MikroOrmRegistry = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const MikroOrmFactory_js_1 = require("./MikroOrmFactory.js");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const core_1 = require("@tsed/core");
|
|
8
|
-
const logger_1 = require("@tsed/logger");
|
|
9
|
-
let MikroOrmRegistry = class MikroOrmRegistry {
|
|
10
|
-
constructor(logger, mikroOrmFactory) {
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
this.mikroOrmFactory = mikroOrmFactory;
|
|
13
|
-
this.DEFAULT_CONTEXT_NAME = "default";
|
|
14
|
-
this.instances = new Map();
|
|
15
|
-
}
|
|
16
|
-
async register(options) {
|
|
17
|
-
const contextName = (0, core_1.getValue)(options, "contextName", this.DEFAULT_CONTEXT_NAME);
|
|
18
|
-
if (this.has(contextName)) {
|
|
19
|
-
return this.get(contextName);
|
|
20
|
-
}
|
|
21
|
-
this.logger.info(`Create connection with MikroOrm to database: %s`, contextName);
|
|
22
|
-
this.logger.debug(`options: %j`, options);
|
|
23
|
-
const instance = await this.mikroOrmFactory.create(options);
|
|
24
|
-
this.instances.set(contextName, instance);
|
|
25
|
-
this.logger.info(`Connected with MikroOrm to database: %s`, contextName);
|
|
26
|
-
return instance;
|
|
27
|
-
}
|
|
28
|
-
get(contextName) {
|
|
29
|
-
return this.instances.get(contextName ?? this.DEFAULT_CONTEXT_NAME);
|
|
30
|
-
}
|
|
31
|
-
has(contextName) {
|
|
32
|
-
return this.instances.has(contextName ?? this.DEFAULT_CONTEXT_NAME);
|
|
33
|
-
}
|
|
34
|
-
values() {
|
|
35
|
-
return this.instances.values();
|
|
36
|
-
}
|
|
37
|
-
async clear() {
|
|
38
|
-
const instances = [...this.instances.values()];
|
|
39
|
-
await Promise.all(instances.map((instance) => (0, core_1.catchAsyncError)(() => this.dispose(instance))));
|
|
40
|
-
this.instances.clear();
|
|
41
|
-
}
|
|
42
|
-
async dispose(instance) {
|
|
43
|
-
if (await instance.isConnected()) {
|
|
44
|
-
await instance.close(false);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
MikroOrmRegistry = tslib_1.__decorate([
|
|
49
|
-
(0, di_1.Injectable)(),
|
|
50
|
-
tslib_1.__param(0, (0, di_1.Inject)()),
|
|
51
|
-
tslib_1.__param(1, (0, di_1.Inject)()),
|
|
52
|
-
tslib_1.__metadata("design:paramtypes", [logger_1.Logger,
|
|
53
|
-
MikroOrmFactory_js_1.MikroOrmFactory])
|
|
54
|
-
], MikroOrmRegistry);
|
|
55
|
-
exports.MikroOrmRegistry = MikroOrmRegistry;
|
|
56
|
-
//# sourceMappingURL=MikroOrmRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmRegistry.js","sourceRoot":"","sources":["../../../src/services/MikroOrmRegistry.ts"],"names":[],"mappings":";;;;AAAA,6DAAqD;AACrD,iCAA4C;AAE5C,qCAAqD;AACrD,yCAAoC;AAG7B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAI3B,YAC6B,MAAc,EACd,eAAgC;QADhC,WAAM,GAAN,MAAM,CAAQ;QACd,oBAAe,GAAf,eAAe,CAAiB;QAL5C,yBAAoB,GAAG,SAAS,CAAC;QACjC,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAKtD,CAAC;IAEG,KAAK,CAAC,QAAQ,CAA2B,OAAmB;QACjE,MAAM,WAAW,GAAG,IAAA,eAAQ,EAAS,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAExF,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;SAC/B;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iDAAiD,EAAE,WAAW,CAAC,CAAC;QACjF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAE1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,EAAE,WAAW,CAAC,CAAC;QAEzE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,GAAG,CAAC,WAAoB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACtE,CAAC;IAEM,GAAG,CAAC,WAAoB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACtE,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IACjC,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,IAAA,sBAAe,EAAC,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;YAChC,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC7B;IACH,CAAC;CACF,CAAA;AArDY,gBAAgB;IAD5B,IAAA,eAAU,GAAE;IAMR,mBAAA,IAAA,WAAM,GAAE,CAAA;IACR,mBAAA,IAAA,WAAM,GAAE,CAAA;6CAD0B,eAAM;QACG,oCAAe;GANlD,gBAAgB,CAqD5B;AArDY,4CAAgB"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import "./services/MikroOrmFactory";
|
|
2
|
-
import { AlterRunInContext, OnDestroy, OnInit } from "@tsed/di";
|
|
3
|
-
import { EventSubscriber, Options } from "@mikro-orm/core";
|
|
4
|
-
declare global {
|
|
5
|
-
namespace TsED {
|
|
6
|
-
interface Configuration {
|
|
7
|
-
/**
|
|
8
|
-
* The ORM configuration, entity metadata.
|
|
9
|
-
* If you omit the `options` parameter, your CLI config will be used.
|
|
10
|
-
*/
|
|
11
|
-
mikroOrm?: Options[];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export declare class MikroOrmModule implements OnDestroy, OnInit, AlterRunInContext {
|
|
16
|
-
private subscribers;
|
|
17
|
-
private readonly settings;
|
|
18
|
-
private readonly registry;
|
|
19
|
-
private readonly context;
|
|
20
|
-
private readonly injector;
|
|
21
|
-
constructor(subscribers: EventSubscriber[]);
|
|
22
|
-
$onInit(): Promise<void>;
|
|
23
|
-
$onDestroy(): Promise<void>;
|
|
24
|
-
$alterRunInContext(next: (...args: unknown[]) => unknown): () => unknown | Promise<() => unknown>;
|
|
25
|
-
private getSubscribers;
|
|
26
|
-
private getUnmanagedSubscribers;
|
|
27
|
-
private getManagedSubscribers;
|
|
28
|
-
private createContext;
|
|
29
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare function entityManager(contextName?: string): import("@mikro-orm/core").EntityManager<import("@mikro-orm/core").IDatabaseDriver<import("@mikro-orm/core").Connection>> | undefined;
|
|
2
|
-
/**
|
|
3
|
-
* Get the entity manager for the given context name.
|
|
4
|
-
* @param {String} contextName
|
|
5
|
-
* @decorator
|
|
6
|
-
* @mikroOrm
|
|
7
|
-
*/
|
|
8
|
-
export declare const EntityManager: (contextName?: string) => PropertyDecorator;
|
|
9
|
-
/**
|
|
10
|
-
* Get the entity manager for the given context name.
|
|
11
|
-
* @param {String} connectionName
|
|
12
|
-
* @decorator
|
|
13
|
-
* @mikroOrm
|
|
14
|
-
*/
|
|
15
|
-
export declare const Em: (contextName?: string) => PropertyDecorator;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MikroORM } from "@mikro-orm/core";
|
|
2
|
-
/**
|
|
3
|
-
* Get the ORM for the given context name using new inject() function.
|
|
4
|
-
* @param contextName
|
|
5
|
-
*/
|
|
6
|
-
export declare function orm(contextName?: string): MikroORM | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Get the ORM for the given context name.
|
|
9
|
-
* @param {String} contextName
|
|
10
|
-
*/
|
|
11
|
-
export declare const Orm: (contextName?: string) => PropertyDecorator;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { TransactionOptions } from "../interceptors/TransactionalInterceptor.js";
|
|
2
|
-
/**
|
|
3
|
-
* Register a new request context for your method and execute it inside the context.
|
|
4
|
-
* @param {String | TransactionOptions} contextNameOrOptions
|
|
5
|
-
*/
|
|
6
|
-
export declare const Transactional: (contextNameOrOptions?: string | TransactionOptions) => MethodDecorator;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ExceptionFilterMethods, PlatformContext } from "@tsed/common";
|
|
2
|
-
import { OptimisticLockError } from "@mikro-orm/core";
|
|
3
|
-
export declare class OptimisticLockErrorFilter implements ExceptionFilterMethods<OptimisticLockError> {
|
|
4
|
-
catch(exception: OptimisticLockError, ctx: PlatformContext): void;
|
|
5
|
-
}
|
package/lib/types-esm/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Automatically generated by @tsed/barrels.
|
|
3
|
-
*/
|
|
4
|
-
export * from "./constants.js";
|
|
5
|
-
export * from "./decorators/entityManager.js";
|
|
6
|
-
export * from "./decorators/orm.js";
|
|
7
|
-
export * from "./decorators/subscriber.js";
|
|
8
|
-
export * from "./decorators/transactional.js";
|
|
9
|
-
export * from "./filters/OptimisticLockErrorFilter.js";
|
|
10
|
-
export * from "./interceptors/TransactionalInterceptor.js";
|
|
11
|
-
export * from "./interfaces/AfterTransactionCommit.js";
|
|
12
|
-
export * from "./interfaces/BeforeTransactionCommit.js";
|
|
13
|
-
export * from "./interfaces/RetryStrategy.js";
|
|
14
|
-
export * from "./MikroOrmModule.js";
|
|
15
|
-
export * from "./services/MikroOrmContext.js";
|
|
16
|
-
export * from "./services/MikroOrmFactory.js";
|
|
17
|
-
export * from "./services/MikroOrmRegistry.js";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { InjectorService, InterceptorContext, InterceptorMethods, InterceptorNext } from "@tsed/di";
|
|
2
|
-
import { Logger } from "@tsed/logger";
|
|
3
|
-
import { RetryStrategy } from "../interfaces/RetryStrategy.js";
|
|
4
|
-
import { MikroOrmContext } from "../services/MikroOrmContext.js";
|
|
5
|
-
import { MikroOrmRegistry } from "../services/MikroOrmRegistry.js";
|
|
6
|
-
import { FlushMode, IsolationLevel } from "@mikro-orm/core";
|
|
7
|
-
export interface TransactionOptions {
|
|
8
|
-
retry?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
isolationLevel?: IsolationLevel;
|
|
11
|
-
flushMode?: FlushMode;
|
|
12
|
-
contextName?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare class TransactionalInterceptor implements InterceptorMethods {
|
|
15
|
-
private readonly injector;
|
|
16
|
-
private readonly registry;
|
|
17
|
-
private readonly context;
|
|
18
|
-
private readonly logger;
|
|
19
|
-
private readonly retryStrategy?;
|
|
20
|
-
constructor(injector: InjectorService, registry: MikroOrmRegistry, context: MikroOrmContext, logger: Logger, retryStrategy?: RetryStrategy | undefined);
|
|
21
|
-
intercept(context: InterceptorContext<unknown>, next: InterceptorNext): Promise<unknown>;
|
|
22
|
-
private runWithinCtx;
|
|
23
|
-
private runWithinNewCtx;
|
|
24
|
-
private getGlobalEntityManager;
|
|
25
|
-
private extractContextName;
|
|
26
|
-
private executeInTransaction;
|
|
27
|
-
private executeHandlerDelegate;
|
|
28
|
-
private beforeTransactionCommit;
|
|
29
|
-
private afterTransactionCommit;
|
|
30
|
-
private getEntityManager;
|
|
31
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EntityManager } from "@mikro-orm/core";
|
|
2
|
-
/**
|
|
3
|
-
* @internal Since 2022-06-20.
|
|
4
|
-
*/
|
|
5
|
-
export declare class MikroOrmContext {
|
|
6
|
-
run(managers: EntityManager[], task: (...args: unknown[]) => unknown): Promise<unknown>;
|
|
7
|
-
get(contextName?: string): EntityManager | undefined;
|
|
8
|
-
has(contextName?: string): boolean;
|
|
9
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { MikroORM, Options } from "@mikro-orm/core";
|
|
2
|
-
import { MikroOrmContext } from "./MikroOrmContext.js";
|
|
3
|
-
export declare class MikroOrmFactory {
|
|
4
|
-
private readonly context;
|
|
5
|
-
constructor(context: MikroOrmContext);
|
|
6
|
-
create(options: Options): Promise<MikroORM>;
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MikroOrmFactory } from "./MikroOrmFactory.js";
|
|
2
|
-
import { IDatabaseDriver as DatabaseDriver, MikroORM, Options } from "@mikro-orm/core";
|
|
3
|
-
import { Logger } from "@tsed/logger";
|
|
4
|
-
export declare class MikroOrmRegistry {
|
|
5
|
-
private readonly logger;
|
|
6
|
-
private readonly mikroOrmFactory;
|
|
7
|
-
private readonly DEFAULT_CONTEXT_NAME;
|
|
8
|
-
private readonly instances;
|
|
9
|
-
constructor(logger: Logger, mikroOrmFactory: MikroOrmFactory);
|
|
10
|
-
register<T extends DatabaseDriver>(options: Options<T>): Promise<MikroORM>;
|
|
11
|
-
get(contextName?: string): MikroORM | undefined;
|
|
12
|
-
has(contextName?: string): boolean;
|
|
13
|
-
values(): IterableIterator<MikroORM>;
|
|
14
|
-
clear(): Promise<void>;
|
|
15
|
-
private dispose;
|
|
16
|
-
}
|