@celljs/typeorm 3.8.0 → 3.9.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/esm/browser/module.d.ts +2 -0
- package/esm/browser/module.js +3 -0
- package/esm/browser/module.js.map +1 -0
- package/esm/common/constants.d.ts +1 -0
- package/esm/common/constants.js +2 -0
- package/esm/common/constants.js.map +1 -0
- package/esm/common/data-source-manager.d.ts +33 -0
- package/esm/common/data-source-manager.js +73 -0
- package/esm/common/data-source-manager.js.map +1 -0
- package/esm/common/entity-provider.d.ts +4 -0
- package/esm/common/entity-provider.js +21 -0
- package/esm/common/entity-provider.js.map +1 -0
- package/esm/common/errors.d.ts +13 -0
- package/esm/common/errors.js +19 -0
- package/esm/common/errors.js.map +1 -0
- package/esm/common/index.d.ts +6 -0
- package/esm/common/index.js +7 -0
- package/esm/common/index.js.map +1 -0
- package/esm/common/typeorm-initializer.d.ts +9 -0
- package/esm/common/typeorm-initializer.js +56 -0
- package/esm/common/typeorm-initializer.js.map +1 -0
- package/esm/common/utils.d.ts +3 -0
- package/esm/common/utils.js +20 -0
- package/esm/common/utils.js.map +1 -0
- package/esm/node/annotation/index.d.ts +1 -0
- package/esm/node/annotation/index.js +2 -0
- package/esm/node/annotation/index.js.map +1 -0
- package/esm/node/annotation/transactional.d.ts +19 -0
- package/esm/node/annotation/transactional.js +85 -0
- package/esm/node/annotation/transactional.js.map +1 -0
- package/esm/node/context/context-protocol.d.ts +10 -0
- package/esm/node/context/context-protocol.js +52 -0
- package/esm/node/context/context-protocol.js.map +1 -0
- package/esm/node/context/index.d.ts +1 -0
- package/esm/node/context/index.js +2 -0
- package/esm/node/context/index.js.map +1 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +3 -0
- package/esm/node/index.js.map +1 -0
- package/esm/node/module.d.ts +3 -0
- package/esm/node/module.js +4 -0
- package/esm/node/module.js.map +1 -0
- package/esm/package.json +3 -0
- package/lib/node/annotation/transactional.d.ts +1 -1
- package/lib/node/annotation/transactional.d.ts.map +1 -1
- package/package.json +45 -5
- package/src/node/annotation/transactional.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/browser/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,eAAe,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_CONNECTION_NAME = "default";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DataSource, DataSourceOptions } from 'typeorm';
|
|
2
|
+
/**
|
|
3
|
+
* DataSourceManager is used to store and manage multiple orm dataSources.
|
|
4
|
+
* It also provides useful factory methods to simplify dataSource creation.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare class DataSourceManager {
|
|
8
|
+
/**
|
|
9
|
+
* List of dataSources registered in this dataSource manager.
|
|
10
|
+
*/
|
|
11
|
+
get dataSources(): DataSource[];
|
|
12
|
+
/**
|
|
13
|
+
* Internal lookup to quickly get from a dataSource name to the DataSource object.
|
|
14
|
+
*/
|
|
15
|
+
private readonly dataSourceMap;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if dataSource with the given name exist in the manager.
|
|
18
|
+
*/
|
|
19
|
+
has(name: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Gets registered dataSource with the given name.
|
|
22
|
+
* If dataSource name is not given then it will get a default dataSource.
|
|
23
|
+
* Throws error if dataSource with the given name was not found.
|
|
24
|
+
*/
|
|
25
|
+
get(name?: string): DataSource;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new dataSource based on the given dataSource options and registers it in the manager.
|
|
28
|
+
* DataSource won't be established, you'll need to manually call connect method to establish dataSource.
|
|
29
|
+
*/
|
|
30
|
+
create(options: DataSourceOptions & {
|
|
31
|
+
name?: string;
|
|
32
|
+
}): DataSource;
|
|
33
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Component } from '@celljs/core';
|
|
8
|
+
import { DataSource } from 'typeorm';
|
|
9
|
+
import { DataSourceNotFoundError, AlreadyHasActiveDataSourceError } from './errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* DataSourceManager is used to store and manage multiple orm dataSources.
|
|
12
|
+
* It also provides useful factory methods to simplify dataSource creation.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
let DataSourceManager = class DataSourceManager {
|
|
16
|
+
constructor() {
|
|
17
|
+
/**
|
|
18
|
+
* Internal lookup to quickly get from a dataSource name to the DataSource object.
|
|
19
|
+
*/
|
|
20
|
+
this.dataSourceMap = new Map();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* List of dataSources registered in this dataSource manager.
|
|
24
|
+
*/
|
|
25
|
+
get dataSources() {
|
|
26
|
+
return Array.from(this.dataSourceMap.values());
|
|
27
|
+
}
|
|
28
|
+
// -------------------------------------------------------------------------
|
|
29
|
+
// Public Methods
|
|
30
|
+
// -------------------------------------------------------------------------
|
|
31
|
+
/**
|
|
32
|
+
* Checks if dataSource with the given name exist in the manager.
|
|
33
|
+
*/
|
|
34
|
+
has(name) {
|
|
35
|
+
return this.dataSourceMap.has(name);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets registered dataSource with the given name.
|
|
39
|
+
* If dataSource name is not given then it will get a default dataSource.
|
|
40
|
+
* Throws error if dataSource with the given name was not found.
|
|
41
|
+
*/
|
|
42
|
+
get(name = 'default') {
|
|
43
|
+
const dataSource = this.dataSourceMap.get(name);
|
|
44
|
+
if (!dataSource) {
|
|
45
|
+
throw new DataSourceNotFoundError(name);
|
|
46
|
+
}
|
|
47
|
+
return dataSource;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new dataSource based on the given dataSource options and registers it in the manager.
|
|
51
|
+
* DataSource won't be established, you'll need to manually call connect method to establish dataSource.
|
|
52
|
+
*/
|
|
53
|
+
create(options) {
|
|
54
|
+
const name = options.name || 'default';
|
|
55
|
+
// check if such dataSource is already registered
|
|
56
|
+
const existDataSource = this.dataSourceMap.get(name);
|
|
57
|
+
if (existDataSource) {
|
|
58
|
+
// if dataSource is registered and its not closed then throw an error
|
|
59
|
+
if (existDataSource.isInitialized) {
|
|
60
|
+
throw new AlreadyHasActiveDataSourceError(name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// create a new dataSource
|
|
64
|
+
const dataSource = new DataSource({ ...options, name });
|
|
65
|
+
this.dataSourceMap.set(name, dataSource);
|
|
66
|
+
return dataSource;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
DataSourceManager = __decorate([
|
|
70
|
+
Component()
|
|
71
|
+
], DataSourceManager);
|
|
72
|
+
export { DataSourceManager };
|
|
73
|
+
//# sourceMappingURL=data-source-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-source-manager.js","sourceRoot":"","sources":["../../src/common/data-source-manager.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC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,EAAC,CAAC,CAAC;QACvD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACzC,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ,CAAA;AA3DY,iBAAiB;IAD7B,SAAS,EAAE;GACC,iBAAiB,CA2D7B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEFAULT_CONNECTION_NAME } from './constants.js';
|
|
2
|
+
const _entitiyMap = new Map();
|
|
3
|
+
export function autoBindEntities(entities, name = DEFAULT_CONNECTION_NAME) {
|
|
4
|
+
let _entities = entities;
|
|
5
|
+
if (!Array.isArray(entities)) {
|
|
6
|
+
_entities = [];
|
|
7
|
+
for (const key of Object.keys(entities)) {
|
|
8
|
+
_entities.push(entities[key]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const current = _entitiyMap.get(name) || [];
|
|
12
|
+
_entitiyMap.set(name, [...current, ..._entities]);
|
|
13
|
+
}
|
|
14
|
+
export var EntityProvider;
|
|
15
|
+
(function (EntityProvider) {
|
|
16
|
+
function getEntities(name = DEFAULT_CONNECTION_NAME) {
|
|
17
|
+
return _entitiyMap.get(name);
|
|
18
|
+
}
|
|
19
|
+
EntityProvider.getEntities = getEntities;
|
|
20
|
+
})(EntityProvider || (EntityProvider = {}));
|
|
21
|
+
//# sourceMappingURL=entity-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-provider.js","sourceRoot":"","sources":["../../src/common/entity-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,QAAa,EAAE,IAAI,GAAG,uBAAuB;IAC1E,IAAI,SAAS,GAAG,QAAQ,CAAC;IACzB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,SAAS,GAAG,EAAE,CAAC;QACf,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAE5C,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,CAAE,GAAG,OAAO,EAAE,GAAG,SAAS,CAAE,CAAC,CAAC;AAExD,CAAC;AAED,MAAM,KAAW,cAAc,CAI9B;AAJD,WAAiB,cAAc;IAC3B,SAAgB,WAAW,CAAC,IAAI,GAAG,uBAAuB;QACtD,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAFe,eAAA,WAAW,cAE1B,CAAA;AACL,CAAC,EAJgB,cAAc,KAAd,cAAc,QAI9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TypeORMError } from 'typeorm';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when consumer tries to get datasource that does not exist.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DataSourceNotFoundError extends TypeORMError {
|
|
6
|
+
constructor(name: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when consumer tries to recreate datasource with the same name, but previous datasource was not closed yet.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AlreadyHasActiveDataSourceError extends TypeORMError {
|
|
12
|
+
constructor(DataSourceName: string);
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TypeORMError } from 'typeorm';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when consumer tries to get datasource that does not exist.
|
|
4
|
+
*/
|
|
5
|
+
export class DataSourceNotFoundError extends TypeORMError {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
super(`DataSource "${name}" was not found.`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Thrown when consumer tries to recreate datasource with the same name, but previous datasource was not closed yet.
|
|
12
|
+
*/
|
|
13
|
+
export class AlreadyHasActiveDataSourceError extends TypeORMError {
|
|
14
|
+
constructor(DataSourceName) {
|
|
15
|
+
super(`Cannot create a new DataSource named "${DataSourceName}", because DataSource with such name ` +
|
|
16
|
+
'already exist and it now has an active DataSource session.');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IACrD,YAAY,IAAY;QACpB,KAAK,CAAC,eAAe,IAAI,kBAAkB,CAAC,CAAC;IACjD,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,YAAY;IAC7D,YAAY,cAAsB;QAC9B,KAAK,CACD,yCAAyC,cAAc,uCAAuC;YAC1F,4DAA4D,CACnE,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ApplicationLifecycle, Application, Deferred } from '@celljs/core';
|
|
2
|
+
import { DataSourceManager } from './data-source-manager.js';
|
|
3
|
+
export declare class TypeOrmInitializer implements ApplicationLifecycle<Application> {
|
|
4
|
+
readonly initialized: Deferred<void>;
|
|
5
|
+
protected readonly options: any;
|
|
6
|
+
protected readonly dataSourceManager: DataSourceManager;
|
|
7
|
+
onStart(app: Application): Promise<void>;
|
|
8
|
+
onStop(app: Application): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, ApplicationLifecycle, Value, Autowired, Deferred } from '@celljs/core';
|
|
11
|
+
import { DEFAULT_CONNECTION_NAME } from './constants.js';
|
|
12
|
+
import { DataSourceManager } from './data-source-manager.js';
|
|
13
|
+
import { EntityProvider } from './entity-provider.js';
|
|
14
|
+
import { createDataSources } from './utils.js';
|
|
15
|
+
let TypeOrmInitializer = class TypeOrmInitializer {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.initialized = new Deferred();
|
|
18
|
+
}
|
|
19
|
+
async onStart(app) {
|
|
20
|
+
const { ormConfig } = this.options;
|
|
21
|
+
let configs;
|
|
22
|
+
if (Array.isArray(ormConfig)) {
|
|
23
|
+
configs = ormConfig;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
ormConfig.name = DEFAULT_CONNECTION_NAME;
|
|
27
|
+
configs = [ormConfig];
|
|
28
|
+
}
|
|
29
|
+
for (const config of configs) {
|
|
30
|
+
config.entities = EntityProvider.getEntities(config.name) || [];
|
|
31
|
+
}
|
|
32
|
+
await createDataSources(configs);
|
|
33
|
+
this.initialized.resolve();
|
|
34
|
+
}
|
|
35
|
+
onStop(app) {
|
|
36
|
+
const dataSources = this.dataSourceManager.dataSources;
|
|
37
|
+
for (const dataSource of dataSources) {
|
|
38
|
+
if (dataSource.isInitialized) {
|
|
39
|
+
dataSource.destroy();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
__decorate([
|
|
45
|
+
Value('cell.typeorm'),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], TypeOrmInitializer.prototype, "options", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
Autowired(DataSourceManager),
|
|
50
|
+
__metadata("design:type", DataSourceManager)
|
|
51
|
+
], TypeOrmInitializer.prototype, "dataSourceManager", void 0);
|
|
52
|
+
TypeOrmInitializer = __decorate([
|
|
53
|
+
Component(ApplicationLifecycle)
|
|
54
|
+
], TypeOrmInitializer);
|
|
55
|
+
export { TypeOrmInitializer };
|
|
56
|
+
//# sourceMappingURL=typeorm-initializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-initializer.js","sourceRoot":"","sources":["../../src/common/typeorm-initializer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAe,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxG,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAAxB;QAEM,gBAAW,GAAG,IAAI,QAAQ,EAAQ,CAAC;IAmChD,CAAC;IA3BG,KAAK,CAAC,OAAO,CAAC,GAAgB;QAC1B,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACnC,IAAI,OAAc,CAAC;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO,GAAG,SAAS,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,SAAS,CAAC,IAAI,GAAG,uBAAuB,CAAC;YACzC,OAAO,GAAG,CAAE,SAAS,CAAE,CAAC;QAC5B,CAAC;QAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpE,CAAC;QAED,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,GAAgB;QACnB,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC;QACvD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACnC,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC;gBAC3B,UAAU,CAAC,OAAO,EAAE,CAAC;YACzB,CAAC;QACL,CAAC;IACL,CAAC;CAEJ,CAAA;AAhCsB;IADlB,KAAK,CAAC,cAAc,CAAC;;mDACU;AAGb;IADlB,SAAS,CAAC,iBAAiB,CAAC;8BACS,iBAAiB;6DAAC;AAR/C,kBAAkB;IAD9B,SAAS,CAAC,oBAAoB,CAAC;GACnB,kBAAkB,CAqC9B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContainerUtil } from '@celljs/core';
|
|
2
|
+
import { DataSourceManager } from '../common/index.js';
|
|
3
|
+
export async function getDataSource(name) {
|
|
4
|
+
const dataSourceManager = ContainerUtil.get(DataSourceManager);
|
|
5
|
+
const dataSource = dataSourceManager.get(name);
|
|
6
|
+
if (!dataSource.isInitialized) {
|
|
7
|
+
await dataSource.initialize();
|
|
8
|
+
}
|
|
9
|
+
return dataSource;
|
|
10
|
+
}
|
|
11
|
+
export async function createDataSources(options) {
|
|
12
|
+
const dataSourceManager = ContainerUtil.get(DataSourceManager);
|
|
13
|
+
const dataSources = options.map(option => dataSourceManager.create(option));
|
|
14
|
+
// Do not use Promise.all or test 8522 will produce a dangling sqlite connection
|
|
15
|
+
for (const dataSource of dataSources) {
|
|
16
|
+
await dataSource.initialize();
|
|
17
|
+
}
|
|
18
|
+
return dataSources;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAa;IAC7C,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAC5B,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA4B;IAChE,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5E,gFAAgF;IAChF,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IACD,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './transactional.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/annotation/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IsolationLevel } from 'typeorm/driver/types/IsolationLevel.js';
|
|
2
|
+
export declare enum Propagation {
|
|
3
|
+
Required = 0,
|
|
4
|
+
RequiresNew = 1
|
|
5
|
+
}
|
|
6
|
+
export interface TransactionalOption {
|
|
7
|
+
name?: string;
|
|
8
|
+
isolation?: IsolationLevel;
|
|
9
|
+
propagation?: Propagation;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare namespace TransactionalOption {
|
|
13
|
+
function is(option: any): option is TransactionalOption;
|
|
14
|
+
}
|
|
15
|
+
export interface TransactionalDecorator {
|
|
16
|
+
(nameOrTransactionalOption?: string | TransactionalOption): MethodDecorator;
|
|
17
|
+
}
|
|
18
|
+
export declare const Transactional: TransactionalDecorator;
|
|
19
|
+
export declare function getTransactionalOption(nameOrTransactionalOption?: string | TransactionalOption): TransactionalOption;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { DEFAULT_CONNECTION_NAME, getDataSource } from '../../common/index.js';
|
|
2
|
+
import { OrmContext } from '../context/index.js';
|
|
3
|
+
import { Context } from '@celljs/core/lib/node';
|
|
4
|
+
export var Propagation;
|
|
5
|
+
(function (Propagation) {
|
|
6
|
+
Propagation[Propagation["Required"] = 0] = "Required";
|
|
7
|
+
Propagation[Propagation["RequiresNew"] = 1] = "RequiresNew";
|
|
8
|
+
})(Propagation || (Propagation = {}));
|
|
9
|
+
export var TransactionalOption;
|
|
10
|
+
(function (TransactionalOption) {
|
|
11
|
+
function is(option) {
|
|
12
|
+
return option && (option.name !== undefined || option.isolation !== undefined || option.readOnly !== undefined);
|
|
13
|
+
}
|
|
14
|
+
TransactionalOption.is = is;
|
|
15
|
+
})(TransactionalOption || (TransactionalOption = {}));
|
|
16
|
+
export const Transactional = function (nameOrTransactionalOption) {
|
|
17
|
+
const { name, isolation, propagation, readOnly } = getTransactionalOption(nameOrTransactionalOption);
|
|
18
|
+
return (target, methodName, descriptor) => {
|
|
19
|
+
const originalMethod = descriptor.value;
|
|
20
|
+
descriptor.value = async function (...args) {
|
|
21
|
+
if (propagation === Propagation.Required) {
|
|
22
|
+
const em = OrmContext.getEntityManager(name);
|
|
23
|
+
if (em && em.queryRunner && (em.queryRunner.isTransactionActive || readOnly)) {
|
|
24
|
+
return originalMethod.apply(this, args);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const callback = async (entityManager) => {
|
|
28
|
+
OrmContext.pushEntityManager(name, entityManager);
|
|
29
|
+
try {
|
|
30
|
+
return await originalMethod.apply(this, args);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
OrmContext.popEntityManager(name);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const dataSource = await getDataSource(name);
|
|
37
|
+
const manager = dataSource.manager;
|
|
38
|
+
if (readOnly) {
|
|
39
|
+
return callback(manager);
|
|
40
|
+
}
|
|
41
|
+
else if (isolation) {
|
|
42
|
+
return manager.transaction(isolation, callback);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return manager.transaction(callback);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const originalMethod2 = descriptor.value;
|
|
49
|
+
descriptor.value = async function (...args) {
|
|
50
|
+
if (!Context.getCurrent()) {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
Context.run(async () => {
|
|
53
|
+
Context.setCurrent(new Context());
|
|
54
|
+
try {
|
|
55
|
+
resolve(originalMethod2.apply(this, args));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return originalMethod2.apply(this, args);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export function getTransactionalOption(nameOrTransactionalOption) {
|
|
71
|
+
const defaultOption = {
|
|
72
|
+
name: DEFAULT_CONNECTION_NAME,
|
|
73
|
+
propagation: Propagation.Required,
|
|
74
|
+
readOnly: false
|
|
75
|
+
};
|
|
76
|
+
let option = defaultOption;
|
|
77
|
+
if (TransactionalOption.is(nameOrTransactionalOption)) {
|
|
78
|
+
option = { ...defaultOption, ...nameOrTransactionalOption };
|
|
79
|
+
}
|
|
80
|
+
else if (nameOrTransactionalOption) {
|
|
81
|
+
option = { ...defaultOption, name: nameOrTransactionalOption };
|
|
82
|
+
}
|
|
83
|
+
return option;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=transactional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactional.js","sourceRoot":"","sources":["../../../src/node/annotation/transactional.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,MAAM,CAAN,IAAY,WAEX;AAFD,WAAY,WAAW;IACnB,qDAAQ,CAAA;IAAE,2DAAW,CAAA;AACzB,CAAC,EAFW,WAAW,KAAX,WAAW,QAEtB;AAQD,MAAM,KAAW,mBAAmB,CAInC;AAJD,WAAiB,mBAAmB;IAChC,SAAgB,EAAE,CAAC,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AClB,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,WAAW,CAAC,QAAQ;QACjC,QAAQ,EAAE,KAAK;KAClB,CAAC;IACF,IAAI,MAAM,GAAwB,aAAa,CAAC;IAChD,IAAI,mBAAmB,CAAC,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,yBAAyB,EAAE,CAAC;IAChE,CAAC;SAAM,IAAI,yBAAyB,EAAE,CAAC;QACnC,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC;IACnE,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EntityManager, ObjectType, EntitySchema, Repository, TreeRepository, MongoRepository, ObjectLiteral } from 'typeorm';
|
|
2
|
+
export declare const CURRENT_ORM_CONTEXT_REQUEST_KEY = "CurrentOrmContextRequest";
|
|
3
|
+
export declare namespace OrmContext {
|
|
4
|
+
function getEntityManager(name?: string): EntityManager;
|
|
5
|
+
function getRepository<Entity extends ObjectLiteral>(target: ObjectType<Entity> | EntitySchema<Entity> | string, name?: string): Repository<Entity>;
|
|
6
|
+
function getTreeRepository<Entity extends ObjectLiteral>(target: ObjectType<Entity> | EntitySchema<Entity> | string, name?: string): TreeRepository<Entity>;
|
|
7
|
+
function getMongoRepository<Entity extends ObjectLiteral>(target: ObjectType<Entity> | EntitySchema<Entity> | string, name?: string): MongoRepository<Entity>;
|
|
8
|
+
function pushEntityManager(name: string, entityManager: EntityManager): void;
|
|
9
|
+
function popEntityManager(name: string): EntityManager | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Context, AttributeScope } from '@celljs/core/lib/node';
|
|
2
|
+
import { DEFAULT_CONNECTION_NAME } from '../../common/index.js';
|
|
3
|
+
export const CURRENT_ORM_CONTEXT_REQUEST_KEY = 'CurrentOrmContextRequest';
|
|
4
|
+
export var OrmContext;
|
|
5
|
+
(function (OrmContext) {
|
|
6
|
+
function getEntityManager(name = DEFAULT_CONNECTION_NAME) {
|
|
7
|
+
const entityManagerMap = Context.getAttr(CURRENT_ORM_CONTEXT_REQUEST_KEY, AttributeScope.Request);
|
|
8
|
+
if (entityManagerMap) {
|
|
9
|
+
const entityManagers = entityManagerMap.get(name);
|
|
10
|
+
if (entityManagers && entityManagers.length > 0) {
|
|
11
|
+
return entityManagers[entityManagers.length - 1];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
OrmContext.getEntityManager = getEntityManager;
|
|
17
|
+
function getRepository(target, name) {
|
|
18
|
+
return getEntityManager(name).getRepository(target);
|
|
19
|
+
}
|
|
20
|
+
OrmContext.getRepository = getRepository;
|
|
21
|
+
function getTreeRepository(target, name) {
|
|
22
|
+
return getEntityManager(name).getTreeRepository(target);
|
|
23
|
+
}
|
|
24
|
+
OrmContext.getTreeRepository = getTreeRepository;
|
|
25
|
+
function getMongoRepository(target, name) {
|
|
26
|
+
return getEntityManager(name).getMongoRepository(target);
|
|
27
|
+
}
|
|
28
|
+
OrmContext.getMongoRepository = getMongoRepository;
|
|
29
|
+
function pushEntityManager(name, entityManager) {
|
|
30
|
+
let entityManagerMap = Context.getAttr(CURRENT_ORM_CONTEXT_REQUEST_KEY, AttributeScope.Request);
|
|
31
|
+
if (!entityManagerMap) {
|
|
32
|
+
entityManagerMap = new Map();
|
|
33
|
+
Context.setAttr(CURRENT_ORM_CONTEXT_REQUEST_KEY, entityManagerMap);
|
|
34
|
+
}
|
|
35
|
+
if (!entityManagerMap.get(name)) {
|
|
36
|
+
entityManagerMap.set(name, []);
|
|
37
|
+
}
|
|
38
|
+
entityManagerMap.get(name).push(entityManager);
|
|
39
|
+
}
|
|
40
|
+
OrmContext.pushEntityManager = pushEntityManager;
|
|
41
|
+
function popEntityManager(name) {
|
|
42
|
+
const entityManagerMap = Context.getAttr(CURRENT_ORM_CONTEXT_REQUEST_KEY, AttributeScope.Request);
|
|
43
|
+
if (entityManagerMap) {
|
|
44
|
+
const entityManagers = entityManagerMap.get(name);
|
|
45
|
+
if (entityManagers && entityManagers.length > 0) {
|
|
46
|
+
return entityManagers.pop();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
OrmContext.popEntityManager = popEntityManager;
|
|
51
|
+
})(OrmContext || (OrmContext = {}));
|
|
52
|
+
//# sourceMappingURL=context-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-protocol.js","sourceRoot":"","sources":["../../../src/node/context/context-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,CAAC,MAAM,+BAA+B,GAAG,0BAA0B,CAAC;AAE1E,MAAM,KAAW,UAAU,CA+C1B;AA/CD,WAAiB,UAAU;IAEvB,SAAgB,gBAAgB,CAAC,IAAI,GAAG,uBAAuB;QAC3D,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAA+B,+BAA+B,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAChI,IAAI,gBAAgB,EAAE,CAAC;YACnB,MAAM,cAAc,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClD,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9C,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACrD,CAAC;QACL,CAAC;QACD,OAA+B,SAAS,CAAC;IAC7C,CAAC;IATe,WAAA,gBAAgB,mBAS/B,CAAA;IAED,SAAgB,aAAa,CAA+B,MAAsD,EAAE,IAAa;QAC7H,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,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cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9C,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC;YAChC,CAAC;QACL,CAAC;IACL,CAAC;IARe,WAAA,gBAAgB,mBAQ/B,CAAA;AAEL,CAAC,EA/CgB,UAAU,KAAV,UAAU,QA+C1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './context-protocol.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,cAAc,WAAW,CAAC;AAE1B,eAAe,QAAQ,EAAE,CAAC"}
|
package/esm/package.json
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactional.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/transactional.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"transactional.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/transactional.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAM7E,oBAAY,WAAW;IACnB,QAAQ,IAAA;IAAE,WAAW,IAAA;CACxB;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,yBAAiB,mBAAmB,CAAC;IACjC,SAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,mBAAmB,CAE7D;CACJ;AAED,MAAM,WAAW,sBAAsB;IACnC,CAAC,yBAAyB,CAAC,EAAE,MAAM,GAAG,mBAAmB,GAAG,eAAe,CAAC;CAC/E;AAED,eAAO,MAAM,aAAa,EAAI,sBAqD7B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,yBAAyB,CAAC,EAAE,MAAM,GAAG,mBAAmB,uBAc9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/typeorm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -18,26 +18,66 @@
|
|
|
18
18
|
"typings": "lib/common/index.d.ts",
|
|
19
19
|
"files": [
|
|
20
20
|
"lib",
|
|
21
|
+
"esm",
|
|
21
22
|
"src",
|
|
22
23
|
"cell.yml",
|
|
23
24
|
"cell-fc.yml"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
|
-
"build": "tsc -b",
|
|
27
|
-
"clean": "rm -rf lib *.tsbuildinfo",
|
|
27
|
+
"build": "tsc -b && bun ../../scripts/build-esm.ts",
|
|
28
|
+
"clean": "rm -rf lib esm *.tsbuildinfo",
|
|
28
29
|
"test": "bun test --preload reflect-metadata ./lib",
|
|
29
30
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@celljs/core": "3.
|
|
33
|
+
"@celljs/core": "3.9.0",
|
|
33
34
|
"mysql2": "^2.3.3",
|
|
34
35
|
"tslib": "^2.8.0",
|
|
35
36
|
"typeorm": "^0.3.7"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@celljs/cli-service": "3.
|
|
39
|
+
"@celljs/cli-service": "3.9.0"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"webpack": "./lib/common/index.js",
|
|
47
|
+
"import": "./esm/common/index.js",
|
|
48
|
+
"default": "./lib/common/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./package.json": "./package.json",
|
|
51
|
+
"./lib/common": {
|
|
52
|
+
"webpack": "./lib/common/index.js",
|
|
53
|
+
"import": "./esm/common/index.js",
|
|
54
|
+
"default": "./lib/common/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./lib/node": {
|
|
57
|
+
"webpack": "./lib/node/index.js",
|
|
58
|
+
"import": "./esm/node/index.js",
|
|
59
|
+
"default": "./lib/node/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./lib/node/annotation": {
|
|
62
|
+
"webpack": "./lib/node/annotation/index.js",
|
|
63
|
+
"import": "./esm/node/annotation/index.js",
|
|
64
|
+
"default": "./lib/node/annotation/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./lib/node/context": {
|
|
67
|
+
"webpack": "./lib/node/context/index.js",
|
|
68
|
+
"import": "./esm/node/context/index.js",
|
|
69
|
+
"default": "./lib/node/context/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./lib/*.js": {
|
|
72
|
+
"webpack": "./lib/*.js",
|
|
73
|
+
"import": "./esm/*.js",
|
|
74
|
+
"default": "./lib/*.js"
|
|
75
|
+
},
|
|
76
|
+
"./lib/*": {
|
|
77
|
+
"webpack": "./lib/*.js",
|
|
78
|
+
"import": "./esm/*.js",
|
|
79
|
+
"default": "./lib/*.js"
|
|
80
|
+
},
|
|
81
|
+
"./*": "./*"
|
|
42
82
|
}
|
|
43
83
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsolationLevel } from 'typeorm/driver/types/IsolationLevel';
|
|
1
|
+
import type { IsolationLevel } from 'typeorm/driver/types/IsolationLevel.js';
|
|
2
2
|
import { DEFAULT_CONNECTION_NAME, getDataSource } from '../../common';
|
|
3
3
|
import { EntityManager } from 'typeorm';
|
|
4
4
|
import { OrmContext } from '../context';
|