@tsed/mikro-orm 7.79.4 → 7.80.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/lib/esm/MikroOrmModule.js +1 -1
- package/lib/types-esm/MikroOrmModule.d.ts +29 -0
- package/lib/types-esm/constants.d.ts +2 -0
- package/lib/types-esm/decorators/entityManager.d.ts +14 -0
- package/lib/types-esm/decorators/orm.d.ts +5 -0
- package/lib/types-esm/decorators/subscriber.d.ts +8 -0
- package/lib/types-esm/decorators/transactional.d.ts +6 -0
- package/lib/types-esm/filters/OptimisticLockErrorFilter.d.ts +5 -0
- package/lib/types-esm/index.d.ts +17 -0
- package/lib/types-esm/interceptors/TransactionalInterceptor.d.ts +31 -0
- package/lib/types-esm/interfaces/AfterTransactionCommit.d.ts +4 -0
- package/lib/types-esm/interfaces/BeforeTransactionCommit.d.ts +4 -0
- package/lib/types-esm/interfaces/RetryStrategy.d.ts +4 -0
- package/lib/types-esm/services/MikroOrmContext.d.ts +9 -0
- package/lib/types-esm/services/MikroOrmFactory.d.ts +7 -0
- package/lib/types-esm/services/MikroOrmRegistry.d.ts +16 -0
- package/package.json +24 -20
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -15
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -48
|
@@ -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";
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the entity manager for the given context name.
|
|
3
|
+
* @param {String} contextName
|
|
4
|
+
* @decorator
|
|
5
|
+
* @mikroOrm
|
|
6
|
+
*/
|
|
7
|
+
export declare const EntityManager: (contextName?: string) => PropertyDecorator;
|
|
8
|
+
/**
|
|
9
|
+
* Get the entity manager for the given context name.
|
|
10
|
+
* @param {String} connectionName
|
|
11
|
+
* @decorator
|
|
12
|
+
* @mikroOrm
|
|
13
|
+
*/
|
|
14
|
+
export declare const Em: (contextName?: string) => PropertyDecorator;
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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";
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mikro-orm",
|
|
3
|
-
"version": "7.79.4",
|
|
4
3
|
"description": "MikroORM package for Ts.ED framework",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"version": "7.80.0",
|
|
5
6
|
"source": "./src/index.ts",
|
|
6
7
|
"main": "./lib/cjs/index.js",
|
|
7
8
|
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./lib/types/index.d.ts",
|
|
13
|
+
"import": "./lib/esm/index.js",
|
|
14
|
+
"default": "./lib/cjs/index.js"
|
|
15
|
+
}
|
|
14
16
|
},
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "yarn barrels && yarn build:ts",
|
|
17
19
|
"barrels": "barrels",
|
|
18
|
-
"test": "
|
|
19
|
-
"build:ts": "tsc --build tsconfig.json
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"build:ts": "tsc --build tsconfig.json",
|
|
22
|
+
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"tslib": "2.6.1"
|
|
@@ -24,25 +27,26 @@
|
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@mikro-orm/core": "6.2.2",
|
|
26
29
|
"@mikro-orm/mongodb": "6.2.2",
|
|
27
|
-
"@tsed/barrels": "7.
|
|
28
|
-
"@tsed/common": "7.
|
|
29
|
-
"@tsed/core": "7.
|
|
30
|
-
"@tsed/di": "7.
|
|
31
|
-
"@tsed/json-mapper": "7.
|
|
30
|
+
"@tsed/barrels": "7.80.0",
|
|
31
|
+
"@tsed/common": "7.80.0",
|
|
32
|
+
"@tsed/core": "7.80.0",
|
|
33
|
+
"@tsed/di": "7.80.0",
|
|
34
|
+
"@tsed/json-mapper": "7.80.0",
|
|
32
35
|
"@tsed/logger": ">=6.7.5",
|
|
33
|
-
"@tsed/schema": "7.
|
|
34
|
-
"@tsed/testing-mongoose": "7.
|
|
35
|
-
"@tsed/typescript": "7.
|
|
36
|
+
"@tsed/schema": "7.80.0",
|
|
37
|
+
"@tsed/testing-mongoose": "7.80.0",
|
|
38
|
+
"@tsed/typescript": "7.80.0",
|
|
36
39
|
"cross-env": "7.0.3",
|
|
37
40
|
"eslint": "^8.57.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
41
|
+
"ts-mockito": "^2.6.1",
|
|
42
|
+
"typescript": "4.9.5",
|
|
43
|
+
"vitest": "2.0.4"
|
|
40
44
|
},
|
|
41
45
|
"peerDependencies": {
|
|
42
46
|
"@mikro-orm/core": ">=4.5.9",
|
|
43
|
-
"@tsed/common": "7.
|
|
44
|
-
"@tsed/core": "7.
|
|
45
|
-
"@tsed/di": "7.
|
|
47
|
+
"@tsed/common": "7.80.0",
|
|
48
|
+
"@tsed/core": "7.80.0",
|
|
49
|
+
"@tsed/di": "7.80.0",
|
|
46
50
|
"@tsed/logger": ">=6.7.5"
|
|
47
51
|
},
|
|
48
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import {presets} from "@tsed/vitest/presets";
|
|
3
|
+
import {defineConfig} from "vitest/config";
|
|
4
|
+
|
|
5
|
+
export default defineConfig(
|
|
6
|
+
{
|
|
7
|
+
...presets,
|
|
8
|
+
test: {
|
|
9
|
+
...presets.test,
|
|
10
|
+
coverage: {
|
|
11
|
+
...presets.test.coverage,
|
|
12
|
+
thresholds: {
|
|
13
|
+
statements: 0,
|
|
14
|
+
branches: 0,
|
|
15
|
+
functions: 0,
|
|
16
|
+
lines: 0
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
);
|
package/jest.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
-
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
...require("@tsed/jest-config"),
|
|
6
|
-
roots: ["<rootDir>/src", "<rootDir>/test"],
|
|
7
|
-
coverageThreshold: {
|
|
8
|
-
global: {
|
|
9
|
-
branches: 0,
|
|
10
|
-
functions: 0,
|
|
11
|
-
lines: 0,
|
|
12
|
-
statements: 0
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
package/lib/cjs/package.json
DELETED
package/lib/esm/package.json
DELETED
package/tsconfig.esm.json
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsed/typescript/tsconfig.node.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"module": "ES2020",
|
|
6
|
-
"rootDir": "src",
|
|
7
|
-
"outDir": "./lib/esm",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationDir": "./lib/types",
|
|
10
|
-
"composite": true,
|
|
11
|
-
"noEmit": false
|
|
12
|
-
},
|
|
13
|
-
"include": ["src", "src/**/*.json"],
|
|
14
|
-
"exclude": [
|
|
15
|
-
"node_modules",
|
|
16
|
-
"test",
|
|
17
|
-
"lib",
|
|
18
|
-
"benchmark",
|
|
19
|
-
"coverage",
|
|
20
|
-
"spec",
|
|
21
|
-
"**/*.benchmark.ts",
|
|
22
|
-
"**/*.spec.ts",
|
|
23
|
-
"keys",
|
|
24
|
-
"jest.config.js",
|
|
25
|
-
"**/__mock__/**",
|
|
26
|
-
"webpack.config.js"
|
|
27
|
-
],
|
|
28
|
-
"references": [
|
|
29
|
-
{
|
|
30
|
-
"path": "../../platform/common"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"path": "../../core"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "../../di"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"path": "../../specs/json-mapper"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "../../specs/schema"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"path": "../testing-mongoose"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
}
|