@midwayjs/sequelize 3.20.5 → 4.0.0-beta.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/dist/configuration.js +3 -16
- package/dist/dataSourceManager.d.ts +0 -1
- package/dist/dataSourceManager.js +5 -10
- package/dist/decorator.d.ts +1 -8
- package/dist/decorator.js +3 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/interface.d.ts +1 -5
- package/package.json +8 -9
package/dist/configuration.js
CHANGED
|
@@ -36,6 +36,7 @@ let SequelizeConfiguration = class SequelizeConfiguration {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
+
exports.SequelizeConfiguration = SequelizeConfiguration;
|
|
39
40
|
__decorate([
|
|
40
41
|
(0, core_1.Config)('sequelize'),
|
|
41
42
|
__metadata("design:type", Object)
|
|
@@ -50,30 +51,16 @@ __decorate([
|
|
|
50
51
|
__metadata("design:paramtypes", []),
|
|
51
52
|
__metadata("design:returntype", Promise)
|
|
52
53
|
], SequelizeConfiguration.prototype, "init", null);
|
|
53
|
-
SequelizeConfiguration = __decorate([
|
|
54
|
+
exports.SequelizeConfiguration = SequelizeConfiguration = __decorate([
|
|
54
55
|
(0, core_1.Configuration)({
|
|
55
56
|
namespace: 'sequelize',
|
|
56
57
|
importConfigs: [
|
|
57
58
|
{
|
|
58
59
|
default: {
|
|
59
|
-
sequelize: {
|
|
60
|
-
validateConnection: true,
|
|
61
|
-
},
|
|
60
|
+
sequelize: {},
|
|
62
61
|
},
|
|
63
62
|
},
|
|
64
63
|
],
|
|
65
|
-
importConfigFilter: config => {
|
|
66
|
-
if (config['sequelize'] && config['sequelize']['options']) {
|
|
67
|
-
config['sequelize'].options.sync = config['sequelize'].sync || false;
|
|
68
|
-
const legacyDataSourceConfig = config['sequelize'].options;
|
|
69
|
-
delete config['sequelize']['options'];
|
|
70
|
-
config['sequelize'].dataSource = {
|
|
71
|
-
default: legacyDataSourceConfig,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return config;
|
|
75
|
-
},
|
|
76
64
|
})
|
|
77
65
|
], SequelizeConfiguration);
|
|
78
|
-
exports.SequelizeConfiguration = SequelizeConfiguration;
|
|
79
66
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -3,7 +3,6 @@ import { Sequelize } from 'sequelize-typescript';
|
|
|
3
3
|
export declare class SequelizeDataSourceManager extends DataSourceManager<Sequelize> {
|
|
4
4
|
sequelizeConfig: any;
|
|
5
5
|
coreLogger: ILogger;
|
|
6
|
-
baseDir: string;
|
|
7
6
|
init(): Promise<void>;
|
|
8
7
|
getName(): string;
|
|
9
8
|
protected createDataSource(config: any, dataSourceName: string): Promise<Sequelize>;
|
|
@@ -14,7 +14,9 @@ const core_1 = require("@midwayjs/core");
|
|
|
14
14
|
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
15
15
|
let SequelizeDataSourceManager = class SequelizeDataSourceManager extends core_1.DataSourceManager {
|
|
16
16
|
async init() {
|
|
17
|
-
await this.initDataSource(this.sequelizeConfig,
|
|
17
|
+
await this.initDataSource(this.sequelizeConfig, {
|
|
18
|
+
concurrent: true,
|
|
19
|
+
});
|
|
18
20
|
}
|
|
19
21
|
getName() {
|
|
20
22
|
return 'sequelize';
|
|
@@ -25,9 +27,6 @@ let SequelizeDataSourceManager = class SequelizeDataSourceManager extends core_1
|
|
|
25
27
|
if (entities && entities.length > 0) {
|
|
26
28
|
client.addModels(entities);
|
|
27
29
|
}
|
|
28
|
-
// 兼容老写法,但是这里可能有问题,会添加到所有的数据源之中
|
|
29
|
-
const listEntities = (0, core_1.listModule)('sequelize:core');
|
|
30
|
-
client.addModels(listEntities);
|
|
31
30
|
const isConnected = await this.checkConnected(client);
|
|
32
31
|
if (isConnected && config.sync) {
|
|
33
32
|
await client.sync(config.syncOptions);
|
|
@@ -51,6 +50,7 @@ let SequelizeDataSourceManager = class SequelizeDataSourceManager extends core_1
|
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
};
|
|
53
|
+
exports.SequelizeDataSourceManager = SequelizeDataSourceManager;
|
|
54
54
|
__decorate([
|
|
55
55
|
(0, core_1.Config)('sequelize'),
|
|
56
56
|
__metadata("design:type", Object)
|
|
@@ -59,19 +59,14 @@ __decorate([
|
|
|
59
59
|
(0, core_1.Logger)('coreLogger'),
|
|
60
60
|
__metadata("design:type", Object)
|
|
61
61
|
], SequelizeDataSourceManager.prototype, "coreLogger", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
(0, core_1.Inject)(),
|
|
64
|
-
__metadata("design:type", String)
|
|
65
|
-
], SequelizeDataSourceManager.prototype, "baseDir", void 0);
|
|
66
62
|
__decorate([
|
|
67
63
|
(0, core_1.Init)(),
|
|
68
64
|
__metadata("design:type", Function),
|
|
69
65
|
__metadata("design:paramtypes", []),
|
|
70
66
|
__metadata("design:returntype", Promise)
|
|
71
67
|
], SequelizeDataSourceManager.prototype, "init", null);
|
|
72
|
-
SequelizeDataSourceManager = __decorate([
|
|
68
|
+
exports.SequelizeDataSourceManager = SequelizeDataSourceManager = __decorate([
|
|
73
69
|
(0, core_1.Provide)(),
|
|
74
70
|
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
75
71
|
], SequelizeDataSourceManager);
|
|
76
|
-
exports.SequelizeDataSourceManager = SequelizeDataSourceManager;
|
|
77
72
|
//# sourceMappingURL=dataSourceManager.js.map
|
package/dist/decorator.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { Model
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated
|
|
4
|
-
* @param options
|
|
5
|
-
* @constructor
|
|
6
|
-
*/
|
|
7
|
-
export declare function BaseTable<M extends Model = Model>(options: TableOptions<M>): any;
|
|
8
|
-
export declare function BaseTable(target: any): void;
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
9
2
|
export declare const ENTITY_MODEL_KEY = "sequelize:entity_model_key";
|
|
10
3
|
export declare const DATA_SOURCE_KEY = "sequelize:data_source_key";
|
|
11
4
|
export declare function InjectRepository(modelKey: {
|
package/dist/decorator.js
CHANGED
|
@@ -1,37 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InjectDataSource = exports.InjectRepository = exports.DATA_SOURCE_KEY = exports.ENTITY_MODEL_KEY =
|
|
3
|
+
exports.InjectDataSource = exports.InjectRepository = exports.DATA_SOURCE_KEY = exports.ENTITY_MODEL_KEY = void 0;
|
|
4
4
|
const core_1 = require("@midwayjs/core");
|
|
5
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
6
|
-
function BaseTable(arg) {
|
|
7
|
-
if (typeof arg === 'function') {
|
|
8
|
-
(0, core_1.saveModule)('sequelize:core', arg);
|
|
9
|
-
annotate(arg);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
const options = Object.assign({}, arg);
|
|
13
|
-
return target => {
|
|
14
|
-
(0, core_1.saveModule)('sequelize:core', target);
|
|
15
|
-
annotate(target, options);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.BaseTable = BaseTable;
|
|
20
|
-
function annotate(target, options = {}) {
|
|
21
|
-
(0, sequelize_typescript_1.setModelName)(target.prototype, options.modelName || target.name);
|
|
22
|
-
(0, sequelize_typescript_1.addOptions)(target.prototype, options);
|
|
23
|
-
}
|
|
24
5
|
exports.ENTITY_MODEL_KEY = 'sequelize:entity_model_key';
|
|
25
6
|
exports.DATA_SOURCE_KEY = 'sequelize:data_source_key';
|
|
26
7
|
function InjectRepository(modelKey, connectionName) {
|
|
27
|
-
return
|
|
8
|
+
return core_1.DecoratorManager.createCustomPropertyDecorator(exports.ENTITY_MODEL_KEY, {
|
|
28
9
|
modelKey,
|
|
29
10
|
connectionName,
|
|
30
11
|
});
|
|
31
12
|
}
|
|
32
13
|
exports.InjectRepository = InjectRepository;
|
|
33
14
|
function InjectDataSource(dataSourceName) {
|
|
34
|
-
return
|
|
15
|
+
return core_1.DecoratorManager.createCustomPropertyDecorator(exports.DATA_SOURCE_KEY, {
|
|
35
16
|
dataSourceName,
|
|
36
17
|
});
|
|
37
18
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { SequelizeConfiguration as Configuration } from './configuration';
|
|
2
|
-
export {
|
|
2
|
+
export { InjectRepository, InjectDataSource } from './decorator';
|
|
3
3
|
export * from './interface';
|
|
4
4
|
export * from './dataSourceManager';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.InjectDataSource = exports.InjectRepository = exports.
|
|
17
|
+
exports.InjectDataSource = exports.InjectRepository = exports.Configuration = void 0;
|
|
18
18
|
var configuration_1 = require("./configuration");
|
|
19
19
|
Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.SequelizeConfiguration; } });
|
|
20
20
|
var decorator_1 = require("./decorator");
|
|
21
|
-
Object.defineProperty(exports, "BaseTable", { enumerable: true, get: function () { return decorator_1.BaseTable; } });
|
|
22
21
|
Object.defineProperty(exports, "InjectRepository", { enumerable: true, get: function () { return decorator_1.InjectRepository; } });
|
|
23
22
|
Object.defineProperty(exports, "InjectDataSource", { enumerable: true, get: function () { return decorator_1.InjectDataSource; } });
|
|
24
23
|
__exportStar(require("./interface"), exports);
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { DataSourceManagerConfigOption } from '@midwayjs/core';
|
|
2
2
|
import { SequelizeOptions } from 'sequelize-typescript';
|
|
3
|
-
|
|
4
|
-
export type SequelizeConfigOptions = DataSourceManagerConfigOption<SequelizeOptions & {
|
|
5
|
-
sync?: boolean;
|
|
6
|
-
syncOptions?: SyncOptions;
|
|
7
|
-
}>;
|
|
3
|
+
export type SequelizeConfigOptions = DataSourceManagerConfigOption<SequelizeOptions>;
|
|
8
4
|
//# sourceMappingURL=interface.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/sequelize",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
"index.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/core": "^
|
|
13
|
-
"@midwayjs/
|
|
14
|
-
"@midwayjs/mock": "^3.20.4",
|
|
12
|
+
"@midwayjs/core": "^4.0.0-beta.1",
|
|
13
|
+
"@midwayjs/mock": "^4.0.0-beta.1",
|
|
15
14
|
"sequelize": "6.37.5",
|
|
16
15
|
"sequelize-typescript": "2.1.6",
|
|
17
16
|
"sqlite3": "5.1.7"
|
|
@@ -22,14 +21,14 @@
|
|
|
22
21
|
"sequelize"
|
|
23
22
|
],
|
|
24
23
|
"author": {
|
|
25
|
-
"name": "
|
|
26
|
-
"email": "
|
|
24
|
+
"name": "czy88840616",
|
|
25
|
+
"email": "czy88840616@gmail.com"
|
|
27
26
|
},
|
|
28
27
|
"license": "MIT",
|
|
29
28
|
"scripts": {
|
|
30
29
|
"build": "tsc",
|
|
31
|
-
"test": "NODE_ENV=development node
|
|
32
|
-
"cov": "node
|
|
30
|
+
"test": "NODE_ENV=development node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
31
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit"
|
|
33
32
|
},
|
|
34
33
|
"engines": {
|
|
35
34
|
"node": ">=12"
|
|
@@ -38,5 +37,5 @@
|
|
|
38
37
|
"type": "git",
|
|
39
38
|
"url": "https://github.com/midwayjs/midway.git"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
|
|
42
41
|
}
|