@joktec/mysql 0.0.29 → 0.0.30

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/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './mysql.module';
2
- export * from './mysql.client';
3
- export * from './mysql.service';
4
- export * from './mysql.config';
5
- export * from './mysql.utils';
6
- export * from './mysql.repo';
7
- export * from './mysql.exception';
8
- export * from './models';
9
- export * from 'sequelize-typescript';
10
- export { Op } from 'sequelize';
1
+ export * from './mysql.module';
2
+ export * from './mysql.client';
3
+ export * from './mysql.service';
4
+ export * from './mysql.config';
5
+ export * from './mysql.utils';
6
+ export * from './mysql.repo';
7
+ export * from './mysql.exception';
8
+ export * from './models';
9
+ export * from 'sequelize-typescript';
10
+ export { Op } from 'sequelize';
11
11
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,29 +1,29 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Op = void 0;
18
- __exportStar(require("./mysql.module"), exports);
19
- __exportStar(require("./mysql.client"), exports);
20
- __exportStar(require("./mysql.service"), exports);
21
- __exportStar(require("./mysql.config"), exports);
22
- __exportStar(require("./mysql.utils"), exports);
23
- __exportStar(require("./mysql.repo"), exports);
24
- __exportStar(require("./mysql.exception"), exports);
25
- __exportStar(require("./models"), exports);
26
- __exportStar(require("sequelize-typescript"), exports);
27
- var sequelize_1 = require("sequelize");
28
- Object.defineProperty(exports, "Op", { enumerable: true, get: function () { return sequelize_1.Op; } });
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Op = void 0;
18
+ __exportStar(require("./mysql.module"), exports);
19
+ __exportStar(require("./mysql.client"), exports);
20
+ __exportStar(require("./mysql.service"), exports);
21
+ __exportStar(require("./mysql.config"), exports);
22
+ __exportStar(require("./mysql.utils"), exports);
23
+ __exportStar(require("./mysql.repo"), exports);
24
+ __exportStar(require("./mysql.exception"), exports);
25
+ __exportStar(require("./models"), exports);
26
+ __exportStar(require("sequelize-typescript"), exports);
27
+ var sequelize_1 = require("sequelize");
28
+ Object.defineProperty(exports, "Op", { enumerable: true, get: function () { return sequelize_1.Op; } });
29
29
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export * from './mysql.model';
2
- export * from './mysql.request';
3
- export * from './mysql.response';
1
+ export * from './mysql.model';
2
+ export * from './mysql.request';
3
+ export * from './mysql.response';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,20 +1,20 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./mysql.model"), exports);
18
- __exportStar(require("./mysql.request"), exports);
19
- __exportStar(require("./mysql.response"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mysql.model"), exports);
18
+ __exportStar(require("./mysql.request"), exports);
19
+ __exportStar(require("./mysql.response"), exports);
20
20
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
- import { Model } from 'sequelize-typescript';
2
- export declare abstract class MysqlModel<T> extends Model<T> {
3
- createdAt?: Date;
4
- updatedAt?: Date;
5
- deletedAt?: Date;
6
- }
1
+ import { Model } from 'sequelize-typescript';
2
+ export declare abstract class MysqlModel<T> extends Model<T> {
3
+ createdAt?: Date;
4
+ updatedAt?: Date;
5
+ deletedAt?: Date;
6
+ }
7
7
  //# sourceMappingURL=mysql.model.d.ts.map
@@ -1,36 +1,36 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MysqlModel = void 0;
13
- const sequelize_typescript_1 = require("sequelize-typescript");
14
- const core_1 = require("@joktec/core");
15
- class MysqlModel extends sequelize_typescript_1.Model {
16
- }
17
- __decorate([
18
- sequelize_typescript_1.CreatedAt,
19
- (0, core_1.ApiProperty)({ type: Date }),
20
- (0, core_1.Field)(() => Date, { nullable: true }),
21
- __metadata("design:type", Date)
22
- ], MysqlModel.prototype, "createdAt", void 0);
23
- __decorate([
24
- sequelize_typescript_1.UpdatedAt,
25
- (0, core_1.ApiProperty)({ type: Date }),
26
- (0, core_1.Field)(() => Date, { nullable: true }),
27
- __metadata("design:type", Date)
28
- ], MysqlModel.prototype, "updatedAt", void 0);
29
- __decorate([
30
- sequelize_typescript_1.DeletedAt,
31
- (0, core_1.ApiProperty)({ type: Date }),
32
- (0, core_1.Field)(() => Date, { nullable: true }),
33
- __metadata("design:type", Date)
34
- ], MysqlModel.prototype, "deletedAt", void 0);
35
- exports.MysqlModel = MysqlModel;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MysqlModel = void 0;
13
+ const sequelize_typescript_1 = require("sequelize-typescript");
14
+ const core_1 = require("@joktec/core");
15
+ class MysqlModel extends sequelize_typescript_1.Model {
16
+ }
17
+ __decorate([
18
+ sequelize_typescript_1.CreatedAt,
19
+ (0, core_1.ApiProperty)({ type: Date }),
20
+ (0, core_1.Field)(() => Date, { nullable: true }),
21
+ __metadata("design:type", Date)
22
+ ], MysqlModel.prototype, "createdAt", void 0);
23
+ __decorate([
24
+ sequelize_typescript_1.UpdatedAt,
25
+ (0, core_1.ApiProperty)({ type: Date }),
26
+ (0, core_1.Field)(() => Date, { nullable: true }),
27
+ __metadata("design:type", Date)
28
+ ], MysqlModel.prototype, "updatedAt", void 0);
29
+ __decorate([
30
+ sequelize_typescript_1.DeletedAt,
31
+ (0, core_1.ApiProperty)({ type: Date }),
32
+ (0, core_1.Field)(() => Date, { nullable: true }),
33
+ __metadata("design:type", Date)
34
+ ], MysqlModel.prototype, "deletedAt", void 0);
35
+ exports.MysqlModel = MysqlModel;
36
36
  //# sourceMappingURL=mysql.model.js.map
@@ -1,10 +1,10 @@
1
- import { IDataType, IBaseRequest } from '@joktec/core';
2
- export declare type MysqlId = string | number | bigint;
3
- export declare type ArrayBinding = Array<IDataType>;
4
- export declare type DictBinding = {
5
- [key: string]: IDataType;
6
- };
7
- export declare type RawBinding = ArrayBinding | DictBinding;
8
- export interface IMysqlRequest extends IBaseRequest {
9
- }
1
+ import { IDataType, IBaseRequest } from '@joktec/core';
2
+ export declare type MysqlId = string | number | bigint;
3
+ export declare type ArrayBinding = Array<IDataType>;
4
+ export declare type DictBinding = {
5
+ [key: string]: IDataType;
6
+ };
7
+ export declare type RawBinding = ArrayBinding | DictBinding;
8
+ export interface IMysqlRequest extends IBaseRequest {
9
+ }
10
10
  //# sourceMappingURL=mysql.request.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=mysql.request.js.map
@@ -1,4 +1,4 @@
1
- import { IListResponseDto } from '@joktec/core';
2
- export interface IMysqlResponse<T> extends IListResponseDto<T> {
3
- }
1
+ import { IListResponseDto } from '@joktec/core';
2
+ export interface IMysqlResponse<T> extends IListResponseDto<T> {
3
+ }
4
4
  //# sourceMappingURL=mysql.response.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=mysql.response.js.map
@@ -1,9 +1,9 @@
1
- import { BaseRepository, Client, ICondition } from '@joktec/core';
2
- import { MysqlConfig } from './mysql.config';
3
- import { Sequelize } from 'sequelize-typescript';
4
- export interface MysqlClient extends Client<MysqlConfig, Sequelize> {
5
- }
6
- export interface IMysqlRepository<T, ID> extends BaseRepository<T, ID> {
7
- upsert(condition: ICondition, body: Partial<T>): Promise<T>;
8
- }
1
+ import { BaseRepository, Client, ICondition } from '@joktec/core';
2
+ import { MysqlConfig } from './mysql.config';
3
+ import { Sequelize } from 'sequelize-typescript';
4
+ export interface MysqlClient extends Client<MysqlConfig, Sequelize> {
5
+ }
6
+ export interface IMysqlRepository<T, ID> extends BaseRepository<T, ID> {
7
+ upsert(condition: ICondition, body: Partial<T>): Promise<T>;
8
+ }
9
9
  //# sourceMappingURL=mysql.client.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=mysql.client.js.map
@@ -1,35 +1,35 @@
1
- import { ClientConfig } from '@joktec/core';
2
- import { SequelizeOptions } from 'sequelize-typescript/dist/sequelize/sequelize/sequelize-options';
3
- import { ConnectionOptions } from 'sequelize/types/sequelize';
4
- export declare class MysqlSlaveConfig implements ConnectionOptions {
5
- host: string;
6
- port: number;
7
- username: string;
8
- password: string;
9
- database: string;
10
- constructor(props: MysqlSlaveConfig);
11
- }
12
- export declare enum Dialect {
13
- MYSQL = "mysql",
14
- POSTGRES = "postgres",
15
- SQLITE = "sqlite",
16
- MARIADB = "mariadb",
17
- MSSQL = "mssql",
18
- DB2 = "db2",
19
- SNOWFLAKE = "snowflake",
20
- ORACLE = "oracle"
21
- }
22
- export declare class MysqlConfig extends ClientConfig implements SequelizeOptions {
23
- dialect: Dialect;
24
- host: string;
25
- port: number;
26
- username: string;
27
- password: string;
28
- database: string;
29
- charset?: string;
30
- timezone?: string;
31
- connectTimeout?: number;
32
- slaves?: MysqlSlaveConfig[];
33
- constructor(props: MysqlConfig);
34
- }
1
+ import { ClientConfig } from '@joktec/core';
2
+ import { SequelizeOptions } from 'sequelize-typescript/dist/sequelize/sequelize/sequelize-options';
3
+ import { ConnectionOptions } from 'sequelize/types/sequelize';
4
+ export declare class MysqlSlaveConfig implements ConnectionOptions {
5
+ host: string;
6
+ port: number;
7
+ username: string;
8
+ password: string;
9
+ database: string;
10
+ constructor(props: MysqlSlaveConfig);
11
+ }
12
+ export declare enum Dialect {
13
+ MYSQL = "mysql",
14
+ POSTGRES = "postgres",
15
+ SQLITE = "sqlite",
16
+ MARIADB = "mariadb",
17
+ MSSQL = "mssql",
18
+ DB2 = "db2",
19
+ SNOWFLAKE = "snowflake",
20
+ ORACLE = "oracle"
21
+ }
22
+ export declare class MysqlConfig extends ClientConfig implements SequelizeOptions {
23
+ dialect: Dialect;
24
+ host: string;
25
+ port: number;
26
+ username: string;
27
+ password: string;
28
+ database: string;
29
+ charset?: string;
30
+ timezone?: string;
31
+ connectTimeout?: number;
32
+ slaves?: MysqlSlaveConfig[];
33
+ constructor(props: MysqlConfig);
34
+ }
35
35
  //# sourceMappingURL=mysql.config.d.ts.map
@@ -1,120 +1,120 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MysqlConfig = exports.Dialect = exports.MysqlSlaveConfig = void 0;
13
- const core_1 = require("@joktec/core");
14
- const lodash_1 = require("lodash");
15
- class MysqlSlaveConfig {
16
- constructor(props) {
17
- Object.assign(this, Object.assign({}, props));
18
- }
19
- }
20
- __decorate([
21
- (0, core_1.IsString)(),
22
- (0, core_1.IsNotEmpty)(),
23
- __metadata("design:type", String)
24
- ], MysqlSlaveConfig.prototype, "host", void 0);
25
- __decorate([
26
- (0, core_1.IsInt)(),
27
- (0, core_1.IsNotEmpty)(),
28
- __metadata("design:type", Number)
29
- ], MysqlSlaveConfig.prototype, "port", void 0);
30
- __decorate([
31
- (0, core_1.IsString)(),
32
- (0, core_1.IsNotEmpty)(),
33
- __metadata("design:type", String)
34
- ], MysqlSlaveConfig.prototype, "username", void 0);
35
- __decorate([
36
- (0, core_1.IsString)(),
37
- (0, core_1.IsNotEmpty)(),
38
- __metadata("design:type", String)
39
- ], MysqlSlaveConfig.prototype, "password", void 0);
40
- __decorate([
41
- (0, core_1.IsString)(),
42
- (0, core_1.IsNotEmpty)(),
43
- __metadata("design:type", String)
44
- ], MysqlSlaveConfig.prototype, "database", void 0);
45
- exports.MysqlSlaveConfig = MysqlSlaveConfig;
46
- var Dialect;
47
- (function (Dialect) {
48
- Dialect["MYSQL"] = "mysql";
49
- Dialect["POSTGRES"] = "postgres";
50
- Dialect["SQLITE"] = "sqlite";
51
- Dialect["MARIADB"] = "mariadb";
52
- Dialect["MSSQL"] = "mssql";
53
- Dialect["DB2"] = "db2";
54
- Dialect["SNOWFLAKE"] = "snowflake";
55
- Dialect["ORACLE"] = "oracle";
56
- })(Dialect = exports.Dialect || (exports.Dialect = {}));
57
- class MysqlConfig extends core_1.ClientConfig {
58
- constructor(props) {
59
- var _a;
60
- super(props);
61
- Object.assign(this, Object.assign(Object.assign({}, props), { dialect: (props === null || props === void 0 ? void 0 : props.dialect) || Dialect.MYSQL, host: (props === null || props === void 0 ? void 0 : props.host) || 'localhost', port: (0, core_1.toInt)(props === null || props === void 0 ? void 0 : props.port, 3306), connectTimeout: (0, core_1.toInt)(props === null || props === void 0 ? void 0 : props.connectTimeout, 20000), slaves: [] }));
62
- if ((_a = props === null || props === void 0 ? void 0 : props.slaves) === null || _a === void 0 ? void 0 : _a.length) {
63
- const masterConfig = (0, lodash_1.pick)(props, ['host', 'port', 'username', 'password', 'database']);
64
- this.slaves = props.slaves.map(slave => new MysqlSlaveConfig(Object.assign(Object.assign({}, masterConfig), slave)));
65
- }
66
- }
67
- }
68
- __decorate([
69
- (0, core_1.IsString)(),
70
- (0, core_1.IsNotEmpty)(),
71
- __metadata("design:type", String)
72
- ], MysqlConfig.prototype, "dialect", void 0);
73
- __decorate([
74
- (0, core_1.IsString)(),
75
- (0, core_1.IsNotEmpty)(),
76
- __metadata("design:type", String)
77
- ], MysqlConfig.prototype, "host", void 0);
78
- __decorate([
79
- (0, core_1.IsInt)(),
80
- (0, core_1.IsNotEmpty)(),
81
- __metadata("design:type", Number)
82
- ], MysqlConfig.prototype, "port", void 0);
83
- __decorate([
84
- (0, core_1.IsString)(),
85
- (0, core_1.IsNotEmpty)(),
86
- __metadata("design:type", String)
87
- ], MysqlConfig.prototype, "username", void 0);
88
- __decorate([
89
- (0, core_1.IsString)(),
90
- (0, core_1.IsNotEmpty)(),
91
- __metadata("design:type", String)
92
- ], MysqlConfig.prototype, "password", void 0);
93
- __decorate([
94
- (0, core_1.IsString)(),
95
- (0, core_1.IsNotEmpty)(),
96
- __metadata("design:type", String)
97
- ], MysqlConfig.prototype, "database", void 0);
98
- __decorate([
99
- (0, core_1.IsString)(),
100
- (0, core_1.IsOptional)(),
101
- __metadata("design:type", String)
102
- ], MysqlConfig.prototype, "charset", void 0);
103
- __decorate([
104
- (0, core_1.IsString)(),
105
- (0, core_1.IsOptional)(),
106
- __metadata("design:type", String)
107
- ], MysqlConfig.prototype, "timezone", void 0);
108
- __decorate([
109
- (0, core_1.IsInt)(),
110
- (0, core_1.IsOptional)(),
111
- __metadata("design:type", Number)
112
- ], MysqlConfig.prototype, "connectTimeout", void 0);
113
- __decorate([
114
- (0, core_1.IsArray)(),
115
- (0, core_1.IsTypes)([MysqlSlaveConfig], { each: true }),
116
- (0, core_1.IsOptional)(),
117
- __metadata("design:type", Array)
118
- ], MysqlConfig.prototype, "slaves", void 0);
119
- exports.MysqlConfig = MysqlConfig;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MysqlConfig = exports.Dialect = exports.MysqlSlaveConfig = void 0;
13
+ const core_1 = require("@joktec/core");
14
+ const lodash_1 = require("lodash");
15
+ class MysqlSlaveConfig {
16
+ constructor(props) {
17
+ Object.assign(this, Object.assign({}, props));
18
+ }
19
+ }
20
+ __decorate([
21
+ (0, core_1.IsString)(),
22
+ (0, core_1.IsNotEmpty)(),
23
+ __metadata("design:type", String)
24
+ ], MysqlSlaveConfig.prototype, "host", void 0);
25
+ __decorate([
26
+ (0, core_1.IsInt)(),
27
+ (0, core_1.IsNotEmpty)(),
28
+ __metadata("design:type", Number)
29
+ ], MysqlSlaveConfig.prototype, "port", void 0);
30
+ __decorate([
31
+ (0, core_1.IsString)(),
32
+ (0, core_1.IsNotEmpty)(),
33
+ __metadata("design:type", String)
34
+ ], MysqlSlaveConfig.prototype, "username", void 0);
35
+ __decorate([
36
+ (0, core_1.IsString)(),
37
+ (0, core_1.IsNotEmpty)(),
38
+ __metadata("design:type", String)
39
+ ], MysqlSlaveConfig.prototype, "password", void 0);
40
+ __decorate([
41
+ (0, core_1.IsString)(),
42
+ (0, core_1.IsNotEmpty)(),
43
+ __metadata("design:type", String)
44
+ ], MysqlSlaveConfig.prototype, "database", void 0);
45
+ exports.MysqlSlaveConfig = MysqlSlaveConfig;
46
+ var Dialect;
47
+ (function (Dialect) {
48
+ Dialect["MYSQL"] = "mysql";
49
+ Dialect["POSTGRES"] = "postgres";
50
+ Dialect["SQLITE"] = "sqlite";
51
+ Dialect["MARIADB"] = "mariadb";
52
+ Dialect["MSSQL"] = "mssql";
53
+ Dialect["DB2"] = "db2";
54
+ Dialect["SNOWFLAKE"] = "snowflake";
55
+ Dialect["ORACLE"] = "oracle";
56
+ })(Dialect = exports.Dialect || (exports.Dialect = {}));
57
+ class MysqlConfig extends core_1.ClientConfig {
58
+ constructor(props) {
59
+ var _a;
60
+ super(props);
61
+ Object.assign(this, Object.assign(Object.assign({}, props), { dialect: (props === null || props === void 0 ? void 0 : props.dialect) || Dialect.MYSQL, host: (props === null || props === void 0 ? void 0 : props.host) || 'localhost', port: (0, core_1.toInt)(props === null || props === void 0 ? void 0 : props.port, 3306), connectTimeout: (0, core_1.toInt)(props === null || props === void 0 ? void 0 : props.connectTimeout, 20000), slaves: [] }));
62
+ if ((_a = props === null || props === void 0 ? void 0 : props.slaves) === null || _a === void 0 ? void 0 : _a.length) {
63
+ const masterConfig = (0, lodash_1.pick)(props, ['host', 'port', 'username', 'password', 'database']);
64
+ this.slaves = props.slaves.map(slave => new MysqlSlaveConfig(Object.assign(Object.assign({}, masterConfig), slave)));
65
+ }
66
+ }
67
+ }
68
+ __decorate([
69
+ (0, core_1.IsString)(),
70
+ (0, core_1.IsNotEmpty)(),
71
+ __metadata("design:type", String)
72
+ ], MysqlConfig.prototype, "dialect", void 0);
73
+ __decorate([
74
+ (0, core_1.IsString)(),
75
+ (0, core_1.IsNotEmpty)(),
76
+ __metadata("design:type", String)
77
+ ], MysqlConfig.prototype, "host", void 0);
78
+ __decorate([
79
+ (0, core_1.IsInt)(),
80
+ (0, core_1.IsNotEmpty)(),
81
+ __metadata("design:type", Number)
82
+ ], MysqlConfig.prototype, "port", void 0);
83
+ __decorate([
84
+ (0, core_1.IsString)(),
85
+ (0, core_1.IsNotEmpty)(),
86
+ __metadata("design:type", String)
87
+ ], MysqlConfig.prototype, "username", void 0);
88
+ __decorate([
89
+ (0, core_1.IsString)(),
90
+ (0, core_1.IsNotEmpty)(),
91
+ __metadata("design:type", String)
92
+ ], MysqlConfig.prototype, "password", void 0);
93
+ __decorate([
94
+ (0, core_1.IsString)(),
95
+ (0, core_1.IsNotEmpty)(),
96
+ __metadata("design:type", String)
97
+ ], MysqlConfig.prototype, "database", void 0);
98
+ __decorate([
99
+ (0, core_1.IsString)(),
100
+ (0, core_1.IsOptional)(),
101
+ __metadata("design:type", String)
102
+ ], MysqlConfig.prototype, "charset", void 0);
103
+ __decorate([
104
+ (0, core_1.IsString)(),
105
+ (0, core_1.IsOptional)(),
106
+ __metadata("design:type", String)
107
+ ], MysqlConfig.prototype, "timezone", void 0);
108
+ __decorate([
109
+ (0, core_1.IsInt)(),
110
+ (0, core_1.IsOptional)(),
111
+ __metadata("design:type", Number)
112
+ ], MysqlConfig.prototype, "connectTimeout", void 0);
113
+ __decorate([
114
+ (0, core_1.IsArray)(),
115
+ (0, core_1.IsTypes)([MysqlSlaveConfig], { each: true }),
116
+ (0, core_1.IsOptional)(),
117
+ __metadata("design:type", Array)
118
+ ], MysqlConfig.prototype, "slaves", void 0);
119
+ exports.MysqlConfig = MysqlConfig;
120
120
  //# sourceMappingURL=mysql.config.js.map
@@ -1,6 +1,6 @@
1
- import { InternalServerException } from '@joktec/core';
2
- export declare class MysqlException extends InternalServerException {
3
- constructor(msg: string, error: any);
4
- }
5
- export declare const MysqlCatch: MethodDecorator;
1
+ import { InternalServerException } from '@joktec/core';
2
+ export declare class MysqlException extends InternalServerException {
3
+ constructor(msg: string, error: any);
4
+ }
5
+ export declare const MysqlCatch: MethodDecorator;
6
6
  //# sourceMappingURL=mysql.exception.d.ts.map