@eggjs/dal-decorator 4.0.0-beta.8 → 4.0.1-beta.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/README.md +1 -1
- package/dist/decorator/Column.d.ts +6 -0
- package/dist/decorator/Column.js +17 -0
- package/dist/decorator/Dao.d.ts +6 -0
- package/dist/decorator/Dao.js +20 -0
- package/dist/decorator/DataSourceQualifier.d.ts +4 -0
- package/dist/decorator/DataSourceQualifier.js +12 -0
- package/dist/decorator/Table.d.ts +6 -0
- package/dist/decorator/Table.js +21 -0
- package/dist/decorator/TableIndex.d.ts +6 -0
- package/dist/decorator/TableIndex.js +12 -0
- package/dist/decorator/index.d.ts +5 -0
- package/dist/decorator/index.js +7 -0
- package/dist/index.d.ts +19 -175
- package/dist/index.js +17 -358
- package/dist/model/ColumnModel.d.ts +38 -0
- package/dist/model/ColumnModel.js +59 -0
- package/dist/model/IndexModel.d.ts +32 -0
- package/dist/model/IndexModel.js +51 -0
- package/dist/model/TableModel.d.ts +55 -0
- package/dist/model/TableModel.js +116 -0
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.js +5 -0
- package/dist/type/MySql.d.ts +2 -0
- package/dist/type/Spatial.d.ts +14 -0
- package/dist/type/Spatial.js +31 -0
- package/dist/type/index.d.ts +2 -0
- package/dist/type/index.js +3 -0
- package/dist/util/ColumnInfoUtil.d.ts +13 -0
- package/dist/util/ColumnInfoUtil.js +21 -0
- package/dist/util/DaoInfoUtil.d.ts +9 -0
- package/dist/util/DaoInfoUtil.js +15 -0
- package/dist/util/IndexInfoUtil.d.ts +9 -0
- package/dist/util/IndexInfoUtil.js +15 -0
- package/dist/util/TableInfoUtil.d.ts +13 -0
- package/dist/util/TableInfoUtil.js +26 -0
- package/dist/util/index.d.ts +4 -0
- package/dist/util/index.js +6 -0
- package/package.json +32 -35
package/README.md
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnInfoUtil } from "../util/ColumnInfoUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import assert from "node:assert";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/Column.ts
|
|
6
|
+
function Column(type, params) {
|
|
7
|
+
return function(target, propertyKey) {
|
|
8
|
+
assert(typeof propertyKey === "string", `[Column/${target.name}] expect column name be typeof string, but now is ${String(propertyKey)}`);
|
|
9
|
+
const tableClazz = target.constructor;
|
|
10
|
+
const columnName = propertyKey;
|
|
11
|
+
ColumnInfoUtil.addColumnType(tableClazz, columnName, type);
|
|
12
|
+
if (params) ColumnInfoUtil.addColumnInfo(tableClazz, columnName, params);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Column };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DaoInfoUtil } from "../util/DaoInfoUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { Prototype, PrototypeUtil } from "@eggjs/core-decorator";
|
|
4
|
+
import { AccessLevel, ObjectInitType } from "@eggjs/tegg-types";
|
|
5
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
6
|
+
|
|
7
|
+
//#region src/decorator/Dao.ts
|
|
8
|
+
function Dao() {
|
|
9
|
+
return function(constructor) {
|
|
10
|
+
DaoInfoUtil.setIsDao(constructor);
|
|
11
|
+
Prototype({
|
|
12
|
+
accessLevel: AccessLevel.PUBLIC,
|
|
13
|
+
initType: ObjectInitType.SINGLETON
|
|
14
|
+
})(constructor);
|
|
15
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Dao };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QualifierUtil } from "@eggjs/core-decorator";
|
|
2
|
+
import { DataSourceQualifierAttribute } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/DataSourceQualifier.ts
|
|
5
|
+
function DataSourceQualifier(dataSourceName) {
|
|
6
|
+
return function(target, propertyKey, parameterIndex) {
|
|
7
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, DataSourceQualifierAttribute, dataSourceName);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { DataSourceQualifier };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TableInfoUtil } from "../util/TableInfoUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { Prototype, PrototypeUtil } from "@eggjs/core-decorator";
|
|
4
|
+
import { AccessLevel, ObjectInitType } from "@eggjs/tegg-types";
|
|
5
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
6
|
+
|
|
7
|
+
//#region src/decorator/Table.ts
|
|
8
|
+
function Table(params) {
|
|
9
|
+
return function(constructor) {
|
|
10
|
+
TableInfoUtil.setIsTable(constructor);
|
|
11
|
+
if (params) TableInfoUtil.setTableParams(constructor, params);
|
|
12
|
+
Prototype({
|
|
13
|
+
accessLevel: AccessLevel.PUBLIC,
|
|
14
|
+
initType: ObjectInitType.ALWAYS_NEW
|
|
15
|
+
})(constructor);
|
|
16
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Table };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IndexInfoUtil } from "../util/IndexInfoUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/TableIndex.ts
|
|
5
|
+
function Index(params) {
|
|
6
|
+
return function(constructor) {
|
|
7
|
+
IndexInfoUtil.addIndex(constructor, params);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Index };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,176 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Column } from "./decorator/Column.js";
|
|
2
|
+
import { Dao } from "./decorator/Dao.js";
|
|
3
|
+
import { DataSourceQualifier } from "./decorator/DataSourceQualifier.js";
|
|
4
|
+
import { Table } from "./decorator/Table.js";
|
|
5
|
+
import { Index } from "./decorator/TableIndex.js";
|
|
6
|
+
import "./decorator/index.js";
|
|
7
|
+
import { ColumnModel } from "./model/ColumnModel.js";
|
|
8
|
+
import { IndexKey, IndexModel } from "./model/IndexModel.js";
|
|
9
|
+
import { TableModel } from "./model/TableModel.js";
|
|
10
|
+
import "./model/index.js";
|
|
11
|
+
import { DeleteResult, InsertResult, UpdateResult } from "./type/MySql.js";
|
|
12
|
+
import { SpatialHelper } from "./type/Spatial.js";
|
|
13
|
+
import "./type/index.js";
|
|
14
|
+
import { ColumnInfoMap, ColumnInfoUtil, ColumnTypeMap } from "./util/ColumnInfoUtil.js";
|
|
15
|
+
import { DaoInfoUtil } from "./util/DaoInfoUtil.js";
|
|
16
|
+
import { IndexInfoUtil } from "./util/IndexInfoUtil.js";
|
|
17
|
+
import { TABLE_CLAZZ_LIST, TableInfoUtil } from "./util/TableInfoUtil.js";
|
|
18
|
+
import "./util/index.js";
|
|
3
19
|
export * from "@eggjs/tegg-types/dal";
|
|
4
|
-
|
|
5
|
-
//#region src/decorator/Column.d.ts
|
|
6
|
-
declare function Column(type: ColumnTypeParams, params?: ColumnParams): (target: any, propertyKey: PropertyKey) => void;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/decorator/Dao.d.ts
|
|
9
|
-
declare function Dao(): (constructor: EggProtoImplClass) => void;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/decorator/DataSourceQualifier.d.ts
|
|
12
|
-
declare function DataSourceQualifier(dataSourceName: string): (target: any, propertyKey: PropertyKey, parameterIndex?: number) => void;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/decorator/Table.d.ts
|
|
15
|
-
declare function Table(params?: TableParams): (constructor: EggProtoImplClass) => void;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/decorator/TableIndex.d.ts
|
|
18
|
-
declare function Index(params: IndexParams): (constructor: EggProtoImplClass) => void;
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/model/ColumnModel.d.ts
|
|
21
|
-
declare class ColumnModel {
|
|
22
|
-
columnName: string;
|
|
23
|
-
propertyName: string;
|
|
24
|
-
type: ColumnTypeParams;
|
|
25
|
-
canNull: boolean;
|
|
26
|
-
default?: string;
|
|
27
|
-
comment?: string;
|
|
28
|
-
visible?: boolean;
|
|
29
|
-
autoIncrement?: boolean;
|
|
30
|
-
uniqueKey?: boolean;
|
|
31
|
-
primaryKey?: boolean;
|
|
32
|
-
collate?: string;
|
|
33
|
-
columnFormat?: ColumnFormat;
|
|
34
|
-
engineAttribute?: string;
|
|
35
|
-
secondaryEngineAttribute?: string;
|
|
36
|
-
constructor(params: {
|
|
37
|
-
columnName: string;
|
|
38
|
-
propertyName: string;
|
|
39
|
-
type: ColumnTypeParams;
|
|
40
|
-
canNull: boolean;
|
|
41
|
-
default?: string;
|
|
42
|
-
comment?: string;
|
|
43
|
-
visible?: boolean;
|
|
44
|
-
autoIncrement?: boolean;
|
|
45
|
-
uniqueKey?: boolean;
|
|
46
|
-
primaryKey?: boolean;
|
|
47
|
-
collate?: string;
|
|
48
|
-
columnFormat?: ColumnFormat;
|
|
49
|
-
engineAttribute?: string;
|
|
50
|
-
secondaryEngineAttribute?: string;
|
|
51
|
-
});
|
|
52
|
-
static build(property: string, type: ColumnTypeParams, params?: ColumnParams): ColumnModel;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/model/IndexModel.d.ts
|
|
56
|
-
interface IndexKey {
|
|
57
|
-
columnName: string;
|
|
58
|
-
propertyName: string;
|
|
59
|
-
}
|
|
60
|
-
declare class IndexModel {
|
|
61
|
-
name: string;
|
|
62
|
-
keys: IndexKey[];
|
|
63
|
-
type: IndexType;
|
|
64
|
-
storeType?: IndexStoreType;
|
|
65
|
-
comment?: string;
|
|
66
|
-
engineAttribute?: string;
|
|
67
|
-
secondaryEngineAttribute?: string;
|
|
68
|
-
parser?: string;
|
|
69
|
-
constructor(params: {
|
|
70
|
-
name: string;
|
|
71
|
-
keys: IndexKey[];
|
|
72
|
-
type: IndexType;
|
|
73
|
-
storeType?: IndexStoreType;
|
|
74
|
-
comment?: string;
|
|
75
|
-
engineAttribute?: string;
|
|
76
|
-
secondaryEngineAttribute?: string;
|
|
77
|
-
parser?: string;
|
|
78
|
-
});
|
|
79
|
-
static buildIndexName(keys: string[], type: IndexType): string;
|
|
80
|
-
static build(params: IndexParams, columns: ColumnModel[], clazz: EggProtoImplClass<unknown>): IndexModel;
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/model/TableModel.d.ts
|
|
84
|
-
declare class TableModel<T = object> {
|
|
85
|
-
clazz: EggProtoImplClass<T>;
|
|
86
|
-
name: string;
|
|
87
|
-
columns: Array<ColumnModel>;
|
|
88
|
-
indices: Array<IndexModel>;
|
|
89
|
-
dataSourceName: string;
|
|
90
|
-
comment?: string;
|
|
91
|
-
autoExtendSize?: number;
|
|
92
|
-
autoIncrement?: number;
|
|
93
|
-
avgRowLength?: number;
|
|
94
|
-
characterSet?: string;
|
|
95
|
-
collate?: string;
|
|
96
|
-
compression?: CompressionType;
|
|
97
|
-
encryption?: boolean;
|
|
98
|
-
engine?: string;
|
|
99
|
-
engineAttribute?: string;
|
|
100
|
-
insertMethod?: InsertMethod;
|
|
101
|
-
keyBlockSize?: number;
|
|
102
|
-
maxRows?: number;
|
|
103
|
-
minRows?: number;
|
|
104
|
-
rowFormat?: RowFormat;
|
|
105
|
-
secondaryEngineAttribute?: string;
|
|
106
|
-
constructor(params: {
|
|
107
|
-
clazz: EggProtoImplClass<T>;
|
|
108
|
-
name: string;
|
|
109
|
-
dataSourceName: string;
|
|
110
|
-
columns: Array<ColumnModel>;
|
|
111
|
-
indices: Array<IndexModel>;
|
|
112
|
-
comment?: string;
|
|
113
|
-
autoExtendSize?: number;
|
|
114
|
-
autoIncrement?: number;
|
|
115
|
-
avgRowLength?: number;
|
|
116
|
-
characterSet?: string;
|
|
117
|
-
collate?: string;
|
|
118
|
-
compression?: CompressionType;
|
|
119
|
-
encryption?: boolean;
|
|
120
|
-
engine?: string;
|
|
121
|
-
engineAttribute?: string;
|
|
122
|
-
insertMethod?: InsertMethod;
|
|
123
|
-
keyBlockSize?: number;
|
|
124
|
-
maxRows?: number;
|
|
125
|
-
minRows?: number;
|
|
126
|
-
rowFormat?: RowFormat;
|
|
127
|
-
secondaryEngineAttribute?: string;
|
|
128
|
-
});
|
|
129
|
-
getPrimary(): IndexModel | undefined;
|
|
130
|
-
static build<T>(clazz: EggProtoImplClass<T>): TableModel<T>;
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/type/Spatial.d.ts
|
|
134
|
-
declare class SpatialHelper {
|
|
135
|
-
static isPoint(t: Geometry): boolean;
|
|
136
|
-
static isLine(t: Geometry): boolean;
|
|
137
|
-
static isPolygon(t: Geometry): boolean;
|
|
138
|
-
static getGeometryType(t: Geometry): ColumnType.POINT | ColumnType.LINESTRING | ColumnType.POLYGON;
|
|
139
|
-
static isMultiPoint(t: GeometryCollection): boolean;
|
|
140
|
-
static isMultiLine(t: GeometryCollection): boolean;
|
|
141
|
-
static isMultiPolygon(t: GeometryCollection): boolean;
|
|
142
|
-
}
|
|
143
|
-
//#endregion
|
|
144
|
-
//#region src/util/ColumnInfoUtil.d.ts
|
|
145
|
-
type ColumnInfoMap = Map<string, ColumnParams>;
|
|
146
|
-
type ColumnTypeMap = Map<string, ColumnTypeParams>;
|
|
147
|
-
declare class ColumnInfoUtil {
|
|
148
|
-
static addColumnInfo(clazz: EggProtoImplClass, property: string, column: ColumnInfoUtil): void;
|
|
149
|
-
static addColumnType(clazz: EggProtoImplClass, property: string, type: ColumnTypeParams): void;
|
|
150
|
-
static getColumnInfoMap(clazz: EggProtoImplClass): ColumnInfoMap | undefined;
|
|
151
|
-
static getColumnTypeMap(clazz: EggProtoImplClass): ColumnTypeMap | undefined;
|
|
152
|
-
}
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/util/DaoInfoUtil.d.ts
|
|
155
|
-
declare class DaoInfoUtil {
|
|
156
|
-
static setIsDao(clazz: EggProtoImplClass): void;
|
|
157
|
-
static getIsDao(clazz: EggProtoImplClass): clazz is BaseDaoType;
|
|
158
|
-
}
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/util/IndexInfoUtil.d.ts
|
|
161
|
-
declare class IndexInfoUtil {
|
|
162
|
-
static addIndex(clazz: EggProtoImplClass, index: IndexParams): void;
|
|
163
|
-
static getIndexList(clazz: EggProtoImplClass): Array<IndexParams>;
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/util/TableInfoUtil.d.ts
|
|
167
|
-
declare const TABLE_CLAZZ_LIST: Array<EggProtoImplClass>;
|
|
168
|
-
declare class TableInfoUtil {
|
|
169
|
-
static setIsTable(clazz: EggProtoImplClass): void;
|
|
170
|
-
static getClazzList(): EggProtoImplClass[];
|
|
171
|
-
static getIsTable(clazz: EggProtoImplClass): boolean;
|
|
172
|
-
static setTableParams(clazz: EggProtoImplClass, params: TableParams): void;
|
|
173
|
-
static getTableParams(clazz: EggProtoImplClass): TableParams | undefined;
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
export { Column, ColumnInfoMap, ColumnInfoUtil, ColumnModel, ColumnTypeMap, Dao, DaoInfoUtil, DataSourceQualifier, type DeleteResult, Index, IndexInfoUtil, IndexKey, IndexModel, type InsertResult, SpatialHelper, TABLE_CLAZZ_LIST, Table, TableInfoUtil, TableModel, type UpdateResult };
|
|
20
|
+
export { Column, ColumnInfoMap, ColumnInfoUtil, ColumnModel, ColumnTypeMap, Dao, DaoInfoUtil, DataSourceQualifier, DeleteResult, Index, IndexInfoUtil, IndexKey, IndexModel, InsertResult, SpatialHelper, TABLE_CLAZZ_LIST, Table, TableInfoUtil, TableModel, UpdateResult };
|