@eggjs/tegg-orm-plugin 4.0.0-beta.8 → 4.0.0-beta.9
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/app.d.ts +22 -7
- package/dist/app.js +46 -11
- package/dist/config/config.default.d.ts +11 -14
- package/dist/config/config.default.js +4 -5
- package/dist/index.d.ts +4 -8
- package/dist/index.js +5 -12
- package/dist/lib/DataSourceManager.d.ts +20 -2
- package/dist/lib/DataSourceManager.js +21 -3
- package/dist/lib/LeoricRegister.d.ts +16 -5
- package/dist/lib/LeoricRegister.js +82 -5
- package/dist/lib/ModelProtoHook.d.ts +7 -11
- package/dist/lib/ModelProtoHook.js +19 -4
- package/dist/lib/ModelProtoManager.d.ts +11 -2
- package/dist/lib/ModelProtoManager.js +14 -3
- package/dist/lib/ORMLoadUnitHook.d.ts +4 -8
- package/dist/lib/ORMLoadUnitHook.js +19 -7
- package/dist/lib/SingletonModelObject.d.ts +18 -22
- package/dist/lib/SingletonModelObject.js +50 -4
- package/dist/lib/SingletonModelProto.d.ts +23 -2
- package/dist/lib/SingletonModelProto.js +42 -3
- package/dist/lib/SingletonORM.d.ts +6 -3
- package/dist/lib/SingletonORM.js +36 -6
- package/dist/lib/types.d.ts +3 -2
- package/dist/lib/types.js +2 -3
- package/dist/types.d.ts +7 -7
- package/dist/types.js +4 -12
- package/package.json +11 -11
- package/dist/DataSourceManager-CyKZLZ5P.d.ts +0 -23
- package/dist/DataSourceManager-D8WpEJAL.js +0 -22
- package/dist/LeoricRegister-BYtIlnjj.d.ts +0 -20
- package/dist/LeoricRegister-D5XVCPFb.js +0 -67
- package/dist/ModelProtoHook-DUljMCzr.js +0 -19
- package/dist/ModelProtoManager-DNpjSdgO.d.ts +0 -15
- package/dist/ModelProtoManager-L7fRU1sn.js +0 -21
- package/dist/ORMLoadUnitHook-BVBniFwv.js +0 -17
- package/dist/SingletonModelObject-BUrJjvMq.js +0 -48
- package/dist/SingletonModelProto-CffXdtt4.d.ts +0 -27
- package/dist/SingletonModelProto-DM-war1a.js +0 -41
- package/dist/SingletonORM-CPBngV28.js +0 -36
- package/dist/SingletonORM-Qo7APzul.d.ts +0 -10
- package/dist/app-CZucRSDc.d.ts +0 -26
- package/dist/app-Dyi1e0rC.js +0 -43
- package/dist/types-AcnzDaZv.d.ts +0 -8
- package/dist/types-CLh7lniX.js +0 -4
- package/dist/types-dLxBJ-zQ.d.ts +0 -7
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {} from '@eggjs/tegg-metadata';
|
|
2
|
+
import { AccessLevel, ObjectInitType, QualifierUtil, MetadataUtil, } from '@eggjs/tegg';
|
|
3
|
+
import { IdenticalUtil } from '@eggjs/tegg-lifecycle';
|
|
4
|
+
import { Bone } from 'leoric';
|
|
5
|
+
export default class SingletonModelProto {
|
|
6
|
+
constructor(loadUnit, model) {
|
|
7
|
+
this.accessLevel = AccessLevel.PUBLIC;
|
|
8
|
+
this.initType = ObjectInitType.SINGLETON;
|
|
9
|
+
this.injectObjects = [];
|
|
10
|
+
this.model = model;
|
|
11
|
+
this.id = IdenticalUtil.createProtoId(loadUnit.id, `leoric:${model.name}`);
|
|
12
|
+
this.loadUnitId = loadUnit.id;
|
|
13
|
+
this.moduleName = loadUnit.name;
|
|
14
|
+
this.name = model.name;
|
|
15
|
+
this.qualifiers = QualifierUtil.getProtoQualifiers(model);
|
|
16
|
+
}
|
|
17
|
+
constructEggObject() {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
getMetaData(metadataKey) {
|
|
21
|
+
return MetadataUtil.getMetaData(metadataKey, this.model);
|
|
22
|
+
}
|
|
23
|
+
verifyQualifier(qualifier) {
|
|
24
|
+
const selfQualifiers = this.qualifiers.find(t => t.attribute === qualifier.attribute);
|
|
25
|
+
return selfQualifiers?.value === qualifier.value;
|
|
26
|
+
}
|
|
27
|
+
verifyQualifiers(qualifiers) {
|
|
28
|
+
for (const qualifier of qualifiers) {
|
|
29
|
+
if (!this.verifyQualifier(qualifier)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
getQualifier(attribute) {
|
|
36
|
+
return this.qualifiers.find(t => t.attribute === attribute)?.value;
|
|
37
|
+
}
|
|
38
|
+
static createProto(ctx) {
|
|
39
|
+
return new SingletonModelProto(ctx.loadUnit, ctx.clazz);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2luZ2xldG9uTW9kZWxQcm90by5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvU2luZ2xldG9uTW9kZWxQcm90by50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQTRILE1BQU0sc0JBQXNCLENBQUM7QUFDaEssT0FBTyxFQUNMLFdBQVcsRUFFWCxjQUFjLEVBRWQsYUFBYSxFQUNiLFlBQVksR0FFYixNQUFNLGFBQWEsQ0FBQztBQUNyQixPQUFPLEVBQVcsYUFBYSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDL0QsT0FBTyxFQUFFLElBQUksRUFBRSxNQUFNLFFBQVEsQ0FBQztBQUU5QixNQUFNLENBQUMsT0FBTyxPQUFPLG1CQUFtQjtJQVl0QyxZQUFZLFFBQWtCLEVBQUUsS0FBa0I7UUFUekMsZ0JBQVcsR0FBRyxXQUFXLENBQUMsTUFBTSxDQUFDO1FBRWpDLGFBQVEsR0FBRyxjQUFjLENBQUMsU0FBUyxDQUFDO1FBQ3BDLGtCQUFhLEdBQW1ELEVBQUUsQ0FBQztRQU8xRSxJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQztRQUNuQixJQUFJLENBQUMsRUFBRSxHQUFHLGFBQWEsQ0FBQyxhQUFhLENBQUMsUUFBUSxDQUFDLEVBQUUsRUFBRSxVQUFVLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDO1FBQzNFLElBQUksQ0FBQyxVQUFVLEdBQUcsUUFBUSxDQUFDLEVBQUUsQ0FBQztRQUM5QixJQUFJLENBQUMsVUFBVSxHQUFHLFFBQVEsQ0FBQyxJQUFJLENBQUM7UUFDaEMsSUFBSSxDQUFDLElBQUksR0FBRyxLQUFLLENBQUMsSUFBSSxDQUFDO1FBQ3ZCLElBQUksQ0FBQyxVQUFVLEdBQUcsYUFBYSxDQUFDLGtCQUFrQixDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQzVELENBQUM7SUFFRCxrQkFBa0I7UUFDaEIsT0FBTyxFQUFFLENBQUM7SUFDWixDQUFDO0lBRUQsV0FBVyxDQUFJLFdBQXdCO1FBQ3JDLE9BQU8sWUFBWSxDQUFDLFdBQVcsQ0FBQyxXQUFXLEVBQUUsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQzNELENBQUM7SUFFRCxlQUFlLENBQUMsU0FBd0I7UUFDdEMsTUFBTSxjQUFjLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsU0FBUyxLQUFLLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUN0RixPQUFPLGNBQWMsRUFBRSxLQUFLLEtBQUssU0FBUyxDQUFDLEtBQUssQ0FBQztJQUNuRCxDQUFDO0lBRUQsZ0JBQWdCLENBQUMsVUFBMkI7UUFDMUMsS0FBSyxNQUFNLFNBQVMsSUFBSSxVQUFVLEVBQUUsQ0FBQztZQUNuQyxJQUFJLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDO2dCQUNyQyxPQUFPLEtBQUssQ0FBQztZQUNmLENBQUM7UUFDSCxDQUFDO1FBQ0QsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBRUQsWUFBWSxDQUFDLFNBQTZCO1FBQ3hDLE9BQU8sSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsU0FBUyxLQUFLLFNBQVMsQ0FBQyxFQUFFLEtBQUssQ0FBQztJQUNyRSxDQUFDO0lBRUQsTUFBTSxDQUFDLFdBQVcsQ0FBQyxHQUFpQztRQUNsRCxPQUFPLElBQUksbUJBQW1CLENBQUMsR0FBRyxDQUFDLFFBQVEsRUFBRSxHQUFHLENBQUMsS0FBb0IsQ0FBQyxDQUFDO0lBQ3pFLENBQUM7Q0FDRiJ9
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { RealmType } from './types.ts';
|
|
2
|
+
export declare class Orm {
|
|
3
|
+
private leoricRegister;
|
|
4
|
+
get client(): RealmType;
|
|
5
|
+
getClient(datasource: string): RealmType;
|
|
6
|
+
}
|
package/dist/lib/SingletonORM.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 { AccessLevel, Inject, SingletonProto, } from '@eggjs/tegg';
|
|
11
|
+
import { LeoricRegister } from "./LeoricRegister.js";
|
|
12
|
+
let Orm = class Orm {
|
|
13
|
+
// default dataSource
|
|
14
|
+
get client() {
|
|
15
|
+
const defaultConfig = this.leoricRegister.getConfig();
|
|
16
|
+
return this.leoricRegister.getRealm(defaultConfig);
|
|
17
|
+
}
|
|
18
|
+
getClient(datasource) {
|
|
19
|
+
const config = this.leoricRegister.getConfig(datasource);
|
|
20
|
+
if (!config) {
|
|
21
|
+
throw new Error(`not found ${datasource} datasource`);
|
|
22
|
+
}
|
|
23
|
+
return this.leoricRegister.getOrCreateRealm(config.database);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
__decorate([
|
|
27
|
+
Inject(),
|
|
28
|
+
__metadata("design:type", LeoricRegister)
|
|
29
|
+
], Orm.prototype, "leoricRegister", void 0);
|
|
30
|
+
Orm = __decorate([
|
|
31
|
+
SingletonProto({
|
|
32
|
+
accessLevel: AccessLevel.PUBLIC,
|
|
33
|
+
})
|
|
34
|
+
], Orm);
|
|
35
|
+
export { Orm };
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2luZ2xldG9uT1JNLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9TaW5nbGV0b25PUk0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxFQUNMLFdBQVcsRUFDWCxNQUFNLEVBQ04sY0FBYyxHQUNmLE1BQU0sYUFBYSxDQUFDO0FBRXJCLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQU05QyxJQUFNLEdBQUcsR0FBVCxNQUFNLEdBQUc7SUFJZCxxQkFBcUI7SUFDckIsSUFBSSxNQUFNO1FBQ1IsTUFBTSxhQUFhLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUN0RCxPQUFPLElBQUksQ0FBQyxjQUFjLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBRSxDQUFDO0lBQ3RELENBQUM7SUFFRCxTQUFTLENBQUMsVUFBa0I7UUFDMUIsTUFBTSxNQUFNLEdBQUcsSUFBSSxDQUFDLGNBQWMsQ0FBQyxTQUFTLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDekQsSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDO1lBQ1osTUFBTSxJQUFJLEtBQUssQ0FBQyxhQUFhLFVBQVUsYUFBYSxDQUFDLENBQUM7UUFDeEQsQ0FBQztRQUNELE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQyxnQkFBZ0IsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFFLENBQUM7SUFDaEUsQ0FBQztDQUVGLENBQUE7QUFoQlM7SUFEUCxNQUFNLEVBQUU7OEJBQ2UsY0FBYzsyQ0FBQztBQUY1QixHQUFHO0lBSGYsY0FBYyxDQUFDO1FBQ2QsV0FBVyxFQUFFLFdBQVcsQ0FBQyxNQUFNO0tBQ2hDLENBQUM7R0FDVyxHQUFHLENBa0JmIn0=
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { AbstractDriver, connect } from 'leoric';
|
|
2
|
+
export type DataType = AbstractDriver['DataType'];
|
|
3
|
+
export type RealmType = Awaited<ReturnType<typeof connect>>;
|
package/dist/lib/types.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { AbstractDriver, connect } from
|
|
2
|
-
|
|
3
|
-
export { };
|
|
1
|
+
import { AbstractDriver, connect } from 'leoric';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxjQUFjLEVBQUUsT0FBTyxFQUFFLE1BQU0sUUFBUSxDQUFDIn0=
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import '@eggjs/tegg-plugin/types';
|
|
2
|
+
import './app.ts';
|
|
3
|
+
import { type AttributeOptions } from '@eggjs/tegg-orm-decorator';
|
|
4
|
+
import type { DataType } from './lib/types.ts';
|
|
5
|
+
declare module '@eggjs/tegg-orm-decorator' {
|
|
6
|
+
function Attribute(dataType: DataType, options?: AttributeOptions): (target: any, propertyKey: PropertyKey) => void;
|
|
7
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import "./ModelProtoHook-DUljMCzr.js";
|
|
6
|
-
import "./SingletonModelProto-DM-war1a.js";
|
|
7
|
-
import "./SingletonModelObject-BUrJjvMq.js";
|
|
8
|
-
import "./ORMLoadUnitHook-BVBniFwv.js";
|
|
9
|
-
import "./app-Dyi1e0rC.js";
|
|
10
|
-
import "./types-CLh7lniX.js";
|
|
11
|
-
|
|
12
|
-
export { };
|
|
1
|
+
import '@eggjs/tegg-plugin/types';
|
|
2
|
+
import "./app.js";
|
|
3
|
+
import {} from '@eggjs/tegg-orm-decorator';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTywwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLFVBQVUsQ0FBQztBQUVsQixPQUFPLEVBQXlCLE1BQU0sMkJBQTJCLENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"tegg"
|
|
7
7
|
]
|
|
8
8
|
},
|
|
9
|
-
"version": "4.0.0-beta.
|
|
9
|
+
"version": "4.0.0-beta.9",
|
|
10
10
|
"description": "orm decorator for egg",
|
|
11
11
|
"keywords": [
|
|
12
12
|
"egg",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"leoric": "^2.12.2",
|
|
54
54
|
"sdk-base": "^5.0.1",
|
|
55
|
-
"@eggjs/egg-module-common": "4.0.0-beta.
|
|
56
|
-
"@eggjs/tegg": "4.0.0-beta.
|
|
57
|
-
"@eggjs/tegg
|
|
58
|
-
"@eggjs/tegg-
|
|
59
|
-
"@eggjs/tegg-orm-decorator": "4.0.0-beta.
|
|
60
|
-
"@eggjs/tegg-runtime": "4.0.0-beta.
|
|
55
|
+
"@eggjs/egg-module-common": "4.0.0-beta.9",
|
|
56
|
+
"@eggjs/tegg-lifecycle": "4.0.0-beta.9",
|
|
57
|
+
"@eggjs/tegg": "4.0.0-beta.9",
|
|
58
|
+
"@eggjs/tegg-metadata": "4.0.0-beta.9",
|
|
59
|
+
"@eggjs/tegg-orm-decorator": "4.0.0-beta.9",
|
|
60
|
+
"@eggjs/tegg-runtime": "4.0.0-beta.9"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"egg": "beta",
|
|
64
|
-
"@eggjs/tegg-plugin": "4.0.0-beta.
|
|
64
|
+
"@eggjs/tegg-plugin": "4.0.0-beta.9"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@eggjs/bin": "beta",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"tsdown": "^0.15.6",
|
|
77
77
|
"unplugin-unused": "^0.5.3",
|
|
78
78
|
"@eggjs/module-test-util": "4.0.0-beta.4",
|
|
79
|
-
"@eggjs/tegg-
|
|
80
|
-
"@eggjs/tegg-
|
|
79
|
+
"@eggjs/tegg-plugin": "4.0.0-beta.9",
|
|
80
|
+
"@eggjs/tegg-config": "4.0.0-beta.9"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"test:mocha:skip": "npm run prepare-test && egg-bin test",
|
|
90
90
|
"cov:mocha:skip": "npm run prepare-test && egg-bin cov",
|
|
91
91
|
"clean": "rimraf dist",
|
|
92
|
-
"build": "tsdown",
|
|
92
|
+
"build": "tsdown && rimraf dist && tsc -b --clean && tsc",
|
|
93
93
|
"typecheck": "tsc --noEmit",
|
|
94
94
|
"prepare-test": "node ./test/fixtures/prepare.js"
|
|
95
95
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/lib/DataSourceManager.d.ts
|
|
2
|
-
interface OrmConfig {
|
|
3
|
-
client: string;
|
|
4
|
-
database: string;
|
|
5
|
-
host: string;
|
|
6
|
-
port: number;
|
|
7
|
-
user: string;
|
|
8
|
-
define: object;
|
|
9
|
-
options: object;
|
|
10
|
-
charset: string;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}
|
|
13
|
-
declare class DataSourceManager {
|
|
14
|
-
private readonly dataSourceConfigs;
|
|
15
|
-
private defaultDataSourceConfig?;
|
|
16
|
-
constructor();
|
|
17
|
-
addDefaultConfig(config: OrmConfig): void;
|
|
18
|
-
getDefaultConfig(): OrmConfig | undefined;
|
|
19
|
-
addConfig(config: OrmConfig): void;
|
|
20
|
-
getConfig(name: string): OrmConfig | undefined;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { DataSourceManager, OrmConfig };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/lib/DataSourceManager.ts
|
|
2
|
-
var DataSourceManager = class {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.dataSourceConfigs = [];
|
|
5
|
-
}
|
|
6
|
-
addDefaultConfig(config) {
|
|
7
|
-
this.defaultDataSourceConfig = config;
|
|
8
|
-
}
|
|
9
|
-
getDefaultConfig() {
|
|
10
|
-
return this.defaultDataSourceConfig;
|
|
11
|
-
}
|
|
12
|
-
addConfig(config) {
|
|
13
|
-
this.dataSourceConfigs.push(config);
|
|
14
|
-
}
|
|
15
|
-
getConfig(name) {
|
|
16
|
-
if (this.defaultDataSourceConfig?.database === name) return this.defaultDataSourceConfig;
|
|
17
|
-
return this.dataSourceConfigs.find((t) => t.database === name);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { DataSourceManager };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RealmType } from "./types-dLxBJ-zQ.js";
|
|
2
|
-
import { ModelProtoManager } from "./ModelProtoManager-DNpjSdgO.js";
|
|
3
|
-
import { DataSourceManager, OrmConfig } from "./DataSourceManager-CyKZLZ5P.js";
|
|
4
|
-
import { ModelMetadata } from "@eggjs/tegg-orm-decorator";
|
|
5
|
-
import { Base } from "sdk-base";
|
|
6
|
-
|
|
7
|
-
//#region src/lib/LeoricRegister.d.ts
|
|
8
|
-
declare class LeoricRegister extends Base {
|
|
9
|
-
private readonly modelProtoManager;
|
|
10
|
-
private readonly dataSourceManager;
|
|
11
|
-
readonly realmMap: Map<string, RealmType>;
|
|
12
|
-
constructor(modelProtoManager: ModelProtoManager, dataSourceManager: DataSourceManager);
|
|
13
|
-
getConfig(datasource?: string): OrmConfig;
|
|
14
|
-
getRealm(config: OrmConfig | undefined): RealmType | undefined;
|
|
15
|
-
getOrCreateRealm(datasource: string | undefined): any;
|
|
16
|
-
generateLeoricAttributes(metadata: ModelMetadata): Record<string, any>;
|
|
17
|
-
register(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { LeoricRegister };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { ModelMetadata, ModelMetadataUtil } from "@eggjs/tegg-orm-decorator";
|
|
2
|
-
import { Base } from "sdk-base";
|
|
3
|
-
import Realm from "leoric";
|
|
4
|
-
|
|
5
|
-
//#region src/lib/LeoricRegister.ts
|
|
6
|
-
var LeoricRegister = class extends Base {
|
|
7
|
-
constructor(modelProtoManager, dataSourceManager) {
|
|
8
|
-
super();
|
|
9
|
-
this.modelProtoManager = modelProtoManager;
|
|
10
|
-
this.dataSourceManager = dataSourceManager;
|
|
11
|
-
this.realmMap = /* @__PURE__ */ new Map();
|
|
12
|
-
}
|
|
13
|
-
getConfig(datasource) {
|
|
14
|
-
let config;
|
|
15
|
-
if (!datasource) config = this.dataSourceManager.getDefaultConfig();
|
|
16
|
-
else config = this.dataSourceManager.getConfig(datasource);
|
|
17
|
-
return config;
|
|
18
|
-
}
|
|
19
|
-
getRealm(config) {
|
|
20
|
-
if (!config?.database) return;
|
|
21
|
-
return this.realmMap.get(config.database);
|
|
22
|
-
}
|
|
23
|
-
getOrCreateRealm(datasource) {
|
|
24
|
-
const config = this.getConfig(datasource);
|
|
25
|
-
let realm;
|
|
26
|
-
if (config) {
|
|
27
|
-
realm = this.getRealm(config);
|
|
28
|
-
if (realm) return realm;
|
|
29
|
-
}
|
|
30
|
-
realm = new Realm({ ...config });
|
|
31
|
-
this.realmMap.set(config.database, realm);
|
|
32
|
-
return realm;
|
|
33
|
-
}
|
|
34
|
-
generateLeoricAttributes(metadata) {
|
|
35
|
-
const attributes = {};
|
|
36
|
-
for (const attribute of metadata.attributes) attributes[attribute.propertyName] = {
|
|
37
|
-
columnName: attribute.attributeName,
|
|
38
|
-
type: attribute.dataType,
|
|
39
|
-
allowNull: attribute.allowNull,
|
|
40
|
-
primaryKey: attribute.primary,
|
|
41
|
-
unique: attribute.unique,
|
|
42
|
-
autoIncrement: attribute.autoIncrement
|
|
43
|
-
};
|
|
44
|
-
return attributes;
|
|
45
|
-
}
|
|
46
|
-
async register() {
|
|
47
|
-
for (const { proto, clazz } of this.modelProtoManager.getProtos()) {
|
|
48
|
-
const metadata = ModelMetadataUtil.getModelMetadata(clazz);
|
|
49
|
-
if (!metadata) throw new Error(`not found metadata for model ${proto.id}`);
|
|
50
|
-
const realm = this.getOrCreateRealm(metadata.dataSource);
|
|
51
|
-
realm.models[clazz.name] = clazz;
|
|
52
|
-
realm[clazz.name] = clazz;
|
|
53
|
-
const attributes = this.generateLeoricAttributes(metadata);
|
|
54
|
-
const hooks = {};
|
|
55
|
-
for (const hookName of Realm.hookNames) if (clazz[hookName]) hooks[hookName] = clazz[hookName];
|
|
56
|
-
clazz.init(attributes, {
|
|
57
|
-
tableName: metadata.tableName,
|
|
58
|
-
hooks
|
|
59
|
-
}, {});
|
|
60
|
-
}
|
|
61
|
-
await Promise.all(Array.from(this.realmMap.values()).map((realm) => realm.connect()));
|
|
62
|
-
this.ready(true);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
export { LeoricRegister };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IS_MODEL, ModelMetaBuilder, ModelMetadataUtil } from "@eggjs/tegg-orm-decorator";
|
|
2
|
-
import "@eggjs/tegg";
|
|
3
|
-
import "@eggjs/tegg-metadata";
|
|
4
|
-
|
|
5
|
-
//#region src/lib/ModelProtoHook.ts
|
|
6
|
-
var ModelProtoHook = class {
|
|
7
|
-
constructor(modelProtoManager) {
|
|
8
|
-
this.modelProtoManager = modelProtoManager;
|
|
9
|
-
}
|
|
10
|
-
async postCreate(ctx, obj) {
|
|
11
|
-
if (!obj.getMetaData(IS_MODEL)) return;
|
|
12
|
-
const metadata = new ModelMetaBuilder(ctx.clazz).build();
|
|
13
|
-
ModelMetadataUtil.setModelMetadata(ctx.clazz, metadata);
|
|
14
|
-
this.modelProtoManager.addProto(ctx.clazz, obj);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { ModelProtoHook };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EggProtoImplClass } from "@eggjs/tegg";
|
|
2
|
-
import { EggPrototype } from "@eggjs/tegg-metadata";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/ModelProtoManager.d.ts
|
|
5
|
-
interface ModelProtoPair {
|
|
6
|
-
proto: EggPrototype;
|
|
7
|
-
clazz: EggProtoImplClass;
|
|
8
|
-
}
|
|
9
|
-
declare class ModelProtoManager {
|
|
10
|
-
private readonly protos;
|
|
11
|
-
addProto(clazz: EggProtoImplClass, proto: EggPrototype): void;
|
|
12
|
-
getProtos(): Array<ModelProtoPair>;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { ModelProtoManager, ModelProtoPair };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import "@eggjs/tegg";
|
|
2
|
-
import "@eggjs/tegg-metadata";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/ModelProtoManager.ts
|
|
5
|
-
var ModelProtoManager = class {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.protos = [];
|
|
8
|
-
}
|
|
9
|
-
addProto(clazz, proto) {
|
|
10
|
-
this.protos.push({
|
|
11
|
-
proto,
|
|
12
|
-
clazz
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
getProtos() {
|
|
16
|
-
return this.protos.slice();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ModelProtoManager };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Orm } from "./SingletonORM-CPBngV28.js";
|
|
2
|
-
import "@eggjs/tegg";
|
|
3
|
-
import { EggLoadUnitType, EggPrototypeCreatorFactory, EggPrototypeFactory } from "@eggjs/tegg-metadata";
|
|
4
|
-
|
|
5
|
-
//#region src/lib/ORMLoadUnitHook.ts
|
|
6
|
-
const REGISTER_CLAZZ = [Orm];
|
|
7
|
-
var ORMLoadUnitHook = class {
|
|
8
|
-
async postCreate(_ctx, loadUnit) {
|
|
9
|
-
if (loadUnit.type === EggLoadUnitType.APP) for (const clazz of REGISTER_CLAZZ) {
|
|
10
|
-
const protos = await EggPrototypeCreatorFactory.createProto(clazz, loadUnit);
|
|
11
|
-
for (const proto of protos) EggPrototypeFactory.instance.registerPrototype(proto, loadUnit);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { ORMLoadUnitHook };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import "@eggjs/tegg";
|
|
2
|
-
import { Bone } from "leoric";
|
|
3
|
-
import "@eggjs/tegg-metadata";
|
|
4
|
-
import { IdenticalUtil } from "@eggjs/tegg-lifecycle";
|
|
5
|
-
import { ContextHandler, EggObjectStatus } from "@eggjs/tegg-runtime";
|
|
6
|
-
import { EGG_CONTEXT } from "@eggjs/egg-module-common";
|
|
7
|
-
|
|
8
|
-
//#region src/lib/SingletonModelObject.ts
|
|
9
|
-
var SingletonModelObject = class SingletonModelObject {
|
|
10
|
-
constructor(name, proto) {
|
|
11
|
-
this.status = EggObjectStatus.PENDING;
|
|
12
|
-
this.name = name;
|
|
13
|
-
this.proto = proto;
|
|
14
|
-
this.id = IdenticalUtil.createObjectId(this.proto.id);
|
|
15
|
-
}
|
|
16
|
-
async init() {
|
|
17
|
-
this._obj = class ContextModelClass extends this.proto.model {
|
|
18
|
-
static get name() {
|
|
19
|
-
return super.name;
|
|
20
|
-
}
|
|
21
|
-
static get ctx() {
|
|
22
|
-
const ctx = ContextHandler.getContext();
|
|
23
|
-
if (ctx) return ctx.get(EGG_CONTEXT);
|
|
24
|
-
}
|
|
25
|
-
get ctx() {
|
|
26
|
-
return ContextModelClass.ctx;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
this.status = EggObjectStatus.READY;
|
|
30
|
-
}
|
|
31
|
-
injectProperty() {
|
|
32
|
-
throw new Error("never call ModelObject#injectProperty");
|
|
33
|
-
}
|
|
34
|
-
get isReady() {
|
|
35
|
-
return this.status === EggObjectStatus.READY;
|
|
36
|
-
}
|
|
37
|
-
get obj() {
|
|
38
|
-
return this._obj;
|
|
39
|
-
}
|
|
40
|
-
static async createObject(name, proto) {
|
|
41
|
-
const modelObject = new SingletonModelObject(name, proto);
|
|
42
|
-
await modelObject.init();
|
|
43
|
-
return modelObject;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { SingletonModelObject };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AccessLevel, EggPrototypeName, MetaDataKey, ObjectInitType, QualifierAttribute, QualifierInfo, QualifierValue } from "@eggjs/tegg";
|
|
2
|
-
import { Bone } from "leoric";
|
|
3
|
-
import { EggPrototype, EggPrototypeLifecycleContext, InjectConstructorProto, InjectObjectProto, LoadUnit } from "@eggjs/tegg-metadata";
|
|
4
|
-
import { Id } from "@eggjs/tegg-lifecycle";
|
|
5
|
-
|
|
6
|
-
//#region src/lib/SingletonModelProto.d.ts
|
|
7
|
-
declare class SingletonModelProto implements EggPrototype {
|
|
8
|
-
[key: symbol]: PropertyDescriptor;
|
|
9
|
-
private readonly qualifiers;
|
|
10
|
-
readonly accessLevel = AccessLevel.PUBLIC;
|
|
11
|
-
id: Id;
|
|
12
|
-
readonly initType = ObjectInitType.SINGLETON;
|
|
13
|
-
readonly injectObjects: (InjectObjectProto | InjectConstructorProto)[];
|
|
14
|
-
readonly loadUnitId: string;
|
|
15
|
-
readonly moduleName: string;
|
|
16
|
-
readonly name: EggPrototypeName;
|
|
17
|
-
readonly model: typeof Bone;
|
|
18
|
-
constructor(loadUnit: LoadUnit, model: typeof Bone);
|
|
19
|
-
constructEggObject(): object;
|
|
20
|
-
getMetaData<T>(metadataKey: MetaDataKey): T | undefined;
|
|
21
|
-
verifyQualifier(qualifier: QualifierInfo): boolean;
|
|
22
|
-
verifyQualifiers(qualifiers: QualifierInfo[]): boolean;
|
|
23
|
-
getQualifier(attribute: QualifierAttribute): QualifierValue | undefined;
|
|
24
|
-
static createProto(ctx: EggPrototypeLifecycleContext): SingletonModelProto;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { SingletonModelProto };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { AccessLevel, MetadataUtil, ObjectInitType, QualifierUtil } from "@eggjs/tegg";
|
|
2
|
-
import { Bone } from "leoric";
|
|
3
|
-
import "@eggjs/tegg-metadata";
|
|
4
|
-
import { IdenticalUtil } from "@eggjs/tegg-lifecycle";
|
|
5
|
-
|
|
6
|
-
//#region src/lib/SingletonModelProto.ts
|
|
7
|
-
var SingletonModelProto = class SingletonModelProto {
|
|
8
|
-
constructor(loadUnit, model) {
|
|
9
|
-
this.accessLevel = AccessLevel.PUBLIC;
|
|
10
|
-
this.initType = ObjectInitType.SINGLETON;
|
|
11
|
-
this.injectObjects = [];
|
|
12
|
-
this.model = model;
|
|
13
|
-
this.id = IdenticalUtil.createProtoId(loadUnit.id, `leoric:${model.name}`);
|
|
14
|
-
this.loadUnitId = loadUnit.id;
|
|
15
|
-
this.moduleName = loadUnit.name;
|
|
16
|
-
this.name = model.name;
|
|
17
|
-
this.qualifiers = QualifierUtil.getProtoQualifiers(model);
|
|
18
|
-
}
|
|
19
|
-
constructEggObject() {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
getMetaData(metadataKey) {
|
|
23
|
-
return MetadataUtil.getMetaData(metadataKey, this.model);
|
|
24
|
-
}
|
|
25
|
-
verifyQualifier(qualifier) {
|
|
26
|
-
return this.qualifiers.find((t) => t.attribute === qualifier.attribute)?.value === qualifier.value;
|
|
27
|
-
}
|
|
28
|
-
verifyQualifiers(qualifiers) {
|
|
29
|
-
for (const qualifier of qualifiers) if (!this.verifyQualifier(qualifier)) return false;
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
getQualifier(attribute) {
|
|
33
|
-
return this.qualifiers.find((t) => t.attribute === attribute)?.value;
|
|
34
|
-
}
|
|
35
|
-
static createProto(ctx) {
|
|
36
|
-
return new SingletonModelProto(ctx.loadUnit, ctx.clazz);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { SingletonModelProto };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { LeoricRegister } from "./LeoricRegister-D5XVCPFb.js";
|
|
2
|
-
import { AccessLevel, Inject, SingletonProto } from "@eggjs/tegg";
|
|
3
|
-
|
|
4
|
-
//#region \0@oxc-project+runtime@0.93.0/helpers/decorateMetadata.js
|
|
5
|
-
function __decorateMetadata(k, v) {
|
|
6
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region \0@oxc-project+runtime@0.93.0/helpers/decorate.js
|
|
11
|
-
function __decorate(decorators, target, key, desc) {
|
|
12
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
-
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;
|
|
15
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/lib/SingletonORM.ts
|
|
20
|
-
var _ref;
|
|
21
|
-
let Orm = class Orm$1 {
|
|
22
|
-
get client() {
|
|
23
|
-
const defaultConfig = this.leoricRegister.getConfig();
|
|
24
|
-
return this.leoricRegister.getRealm(defaultConfig);
|
|
25
|
-
}
|
|
26
|
-
getClient(datasource) {
|
|
27
|
-
const config = this.leoricRegister.getConfig(datasource);
|
|
28
|
-
if (!config) throw new Error(`not found ${datasource} datasource`);
|
|
29
|
-
return this.leoricRegister.getOrCreateRealm(config.database);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
__decorate([Inject(), __decorateMetadata("design:type", typeof (_ref = typeof LeoricRegister !== "undefined" && LeoricRegister) === "function" ? _ref : Object)], Orm.prototype, "leoricRegister", void 0);
|
|
33
|
-
Orm = __decorate([SingletonProto({ accessLevel: AccessLevel.PUBLIC })], Orm);
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { Orm };
|
package/dist/app-CZucRSDc.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Orm } from "./SingletonORM-Qo7APzul.js";
|
|
2
|
-
import { LeoricRegister } from "./LeoricRegister-BYtIlnjj.js";
|
|
3
|
-
import { Application } from "egg";
|
|
4
|
-
|
|
5
|
-
//#region src/app.d.ts
|
|
6
|
-
declare class OrmAppBootHook {
|
|
7
|
-
private readonly app;
|
|
8
|
-
private readonly dataSourceManager;
|
|
9
|
-
private readonly leoricRegister;
|
|
10
|
-
private readonly modelProtoManager;
|
|
11
|
-
private readonly modelProtoHook;
|
|
12
|
-
private readonly ormLoadUnitHook;
|
|
13
|
-
constructor(app: Application);
|
|
14
|
-
configWillLoad(): void;
|
|
15
|
-
configDidLoad(): void;
|
|
16
|
-
didLoad(): Promise<void>;
|
|
17
|
-
beforeClose(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
declare module 'egg' {
|
|
20
|
-
interface Application {
|
|
21
|
-
leoricRegister: LeoricRegister;
|
|
22
|
-
orm: Orm;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { OrmAppBootHook };
|
package/dist/app-Dyi1e0rC.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ModelProtoManager } from "./ModelProtoManager-L7fRU1sn.js";
|
|
2
|
-
import { DataSourceManager } from "./DataSourceManager-D8WpEJAL.js";
|
|
3
|
-
import { LeoricRegister } from "./LeoricRegister-D5XVCPFb.js";
|
|
4
|
-
import { ModelProtoHook } from "./ModelProtoHook-DUljMCzr.js";
|
|
5
|
-
import { SingletonModelProto } from "./SingletonModelProto-DM-war1a.js";
|
|
6
|
-
import { SingletonModelObject } from "./SingletonModelObject-BUrJjvMq.js";
|
|
7
|
-
import { ORMLoadUnitHook } from "./ORMLoadUnitHook-BVBniFwv.js";
|
|
8
|
-
import { Application } from "egg";
|
|
9
|
-
import { MODEL_PROTO_IMPL_TYPE } from "@eggjs/tegg-orm-decorator";
|
|
10
|
-
|
|
11
|
-
//#region src/app.ts
|
|
12
|
-
var OrmAppBootHook = class {
|
|
13
|
-
constructor(app) {
|
|
14
|
-
this.app = app;
|
|
15
|
-
this.dataSourceManager = new DataSourceManager();
|
|
16
|
-
this.modelProtoManager = new ModelProtoManager();
|
|
17
|
-
this.leoricRegister = new LeoricRegister(this.modelProtoManager, this.dataSourceManager);
|
|
18
|
-
this.modelProtoHook = new ModelProtoHook(this.modelProtoManager);
|
|
19
|
-
this.app.eggPrototypeCreatorFactory.registerPrototypeCreator(MODEL_PROTO_IMPL_TYPE, SingletonModelProto.createProto);
|
|
20
|
-
this.app.leoricRegister = this.leoricRegister;
|
|
21
|
-
this.ormLoadUnitHook = new ORMLoadUnitHook();
|
|
22
|
-
}
|
|
23
|
-
configWillLoad() {
|
|
24
|
-
this.app.eggPrototypeLifecycleUtil.registerLifecycle(this.modelProtoHook);
|
|
25
|
-
this.app.eggObjectFactory.registerEggObjectCreateMethod(SingletonModelProto, SingletonModelObject.createObject);
|
|
26
|
-
this.app.loadUnitLifecycleUtil.registerLifecycle(this.ormLoadUnitHook);
|
|
27
|
-
}
|
|
28
|
-
configDidLoad() {
|
|
29
|
-
const config = this.app.config.orm;
|
|
30
|
-
if (config.datasources) for (const datasource of config.datasources) this.dataSourceManager.addConfig(datasource);
|
|
31
|
-
else this.dataSourceManager.addDefaultConfig(config);
|
|
32
|
-
}
|
|
33
|
-
async didLoad() {
|
|
34
|
-
await this.app.moduleHandler.ready();
|
|
35
|
-
await this.leoricRegister.register();
|
|
36
|
-
}
|
|
37
|
-
async beforeClose() {
|
|
38
|
-
this.app.eggPrototypeLifecycleUtil.deleteLifecycle(this.modelProtoHook);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
export { OrmAppBootHook };
|