@eggjs/tegg-orm-plugin 4.0.0-beta.6 → 4.0.0-beta.8

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.
Files changed (44) hide show
  1. package/dist/DataSourceManager-CyKZLZ5P.d.ts +23 -0
  2. package/dist/DataSourceManager-D8WpEJAL.js +22 -0
  3. package/dist/LeoricRegister-BYtIlnjj.d.ts +20 -0
  4. package/dist/LeoricRegister-D5XVCPFb.js +67 -0
  5. package/dist/ModelProtoHook-DUljMCzr.js +19 -0
  6. package/dist/ModelProtoManager-DNpjSdgO.d.ts +15 -0
  7. package/dist/ModelProtoManager-L7fRU1sn.js +21 -0
  8. package/dist/ORMLoadUnitHook-BVBniFwv.js +17 -0
  9. package/dist/SingletonModelObject-BUrJjvMq.js +48 -0
  10. package/dist/SingletonModelProto-CffXdtt4.d.ts +27 -0
  11. package/dist/SingletonModelProto-DM-war1a.js +41 -0
  12. package/dist/SingletonORM-CPBngV28.js +36 -0
  13. package/dist/SingletonORM-Qo7APzul.d.ts +10 -0
  14. package/dist/app-CZucRSDc.d.ts +26 -0
  15. package/dist/app-Dyi1e0rC.js +43 -0
  16. package/dist/app.d.ts +6 -25
  17. package/dist/app.js +9 -42
  18. package/dist/config/config.default.d.ts +1 -1
  19. package/dist/index.d.ts +7 -2
  20. package/dist/index.js +10 -3
  21. package/dist/lib/DataSourceManager.d.ts +1 -22
  22. package/dist/lib/DataSourceManager.js +1 -20
  23. package/dist/lib/LeoricRegister.d.ts +4 -19
  24. package/dist/lib/LeoricRegister.js +3 -66
  25. package/dist/lib/ModelProtoHook.d.ts +1 -1
  26. package/dist/lib/ModelProtoHook.js +2 -18
  27. package/dist/lib/ModelProtoManager.d.ts +1 -14
  28. package/dist/lib/ModelProtoManager.js +1 -19
  29. package/dist/lib/ORMLoadUnitHook.js +5 -15
  30. package/dist/lib/SingletonModelObject.d.ts +1 -1
  31. package/dist/lib/SingletonModelObject.js +2 -47
  32. package/dist/lib/SingletonModelProto.d.ts +1 -26
  33. package/dist/lib/SingletonModelProto.js +1 -39
  34. package/dist/lib/SingletonORM.d.ts +2 -9
  35. package/dist/lib/SingletonORM.js +4 -21
  36. package/dist/lib/types.d.ts +1 -6
  37. package/dist/types-AcnzDaZv.d.ts +8 -0
  38. package/dist/types-CLh7lniX.js +4 -0
  39. package/dist/types-dLxBJ-zQ.d.ts +7 -0
  40. package/dist/types.d.ts +7 -8
  41. package/dist/types.js +10 -3
  42. package/package.json +10 -10
  43. package/dist/_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js +0 -10
  44. package/dist/_virtual/_@oxc-project_runtime@0.93.0/helpers/decorateMetadata.js +0 -7
@@ -0,0 +1,23 @@
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 };
@@ -0,0 +1,22 @@
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 };
@@ -0,0 +1,20 @@
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 };
@@ -0,0 +1,67 @@
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 };
@@ -0,0 +1,19 @@
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 };
@@ -0,0 +1,15 @@
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 };
@@ -0,0 +1,21 @@
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 };
@@ -0,0 +1,17 @@
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 };
@@ -0,0 +1,48 @@
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 };
@@ -0,0 +1,27 @@
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 };
@@ -0,0 +1,41 @@
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 };
@@ -0,0 +1,36 @@
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 };
@@ -0,0 +1,10 @@
1
+ import { RealmType } from "./types-dLxBJ-zQ.js";
2
+
3
+ //#region src/lib/SingletonORM.d.ts
4
+ declare class Orm {
5
+ private leoricRegister;
6
+ get client(): RealmType;
7
+ getClient(datasource: string): RealmType;
8
+ }
9
+ //#endregion
10
+ export { Orm };
@@ -0,0 +1,26 @@
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 };
@@ -0,0 +1,43 @@
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 };
package/dist/app.d.ts CHANGED
@@ -1,26 +1,7 @@
1
- import { Orm } from "./lib/SingletonORM.js";
2
- import { LeoricRegister } from "./lib/LeoricRegister.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
1
+ import "./types-dLxBJ-zQ.js";
2
+ import "./SingletonORM-Qo7APzul.js";
3
+ import "./ModelProtoManager-DNpjSdgO.js";
4
+ import "./DataSourceManager-CyKZLZ5P.js";
5
+ import "./LeoricRegister-BYtIlnjj.js";
6
+ import { OrmAppBootHook } from "./app-CZucRSDc.js";
26
7
  export { OrmAppBootHook as default };
package/dist/app.js CHANGED
@@ -1,44 +1,11 @@
1
- import { ModelProtoManager } from "./lib/ModelProtoManager.js";
2
- import { DataSourceManager } from "./lib/DataSourceManager.js";
3
- import { LeoricRegister } from "./lib/LeoricRegister.js";
4
- import "./lib/SingletonORM.js";
5
- import { ModelProtoHook } from "./lib/ModelProtoHook.js";
6
- import SingletonModelProto from "./lib/SingletonModelProto.js";
7
- import { SingletonModelObject } from "./lib/SingletonModelObject.js";
8
- import { ORMLoadUnitHook } from "./lib/ORMLoadUnitHook.js";
9
- import { Application } from "egg";
10
- import { MODEL_PROTO_IMPL_TYPE } from "@eggjs/tegg-orm-decorator";
1
+ import "./ModelProtoManager-L7fRU1sn.js";
2
+ import "./DataSourceManager-D8WpEJAL.js";
3
+ import "./LeoricRegister-D5XVCPFb.js";
4
+ import "./SingletonORM-CPBngV28.js";
5
+ import "./ModelProtoHook-DUljMCzr.js";
6
+ import "./SingletonModelProto-DM-war1a.js";
7
+ import "./SingletonModelObject-BUrJjvMq.js";
8
+ import "./ORMLoadUnitHook-BVBniFwv.js";
9
+ import { OrmAppBootHook } from "./app-Dyi1e0rC.js";
11
10
 
12
- //#region src/app.ts
13
- var OrmAppBootHook = class {
14
- constructor(app) {
15
- this.app = app;
16
- this.dataSourceManager = new DataSourceManager();
17
- this.modelProtoManager = new ModelProtoManager();
18
- this.leoricRegister = new LeoricRegister(this.modelProtoManager, this.dataSourceManager);
19
- this.modelProtoHook = new ModelProtoHook(this.modelProtoManager);
20
- this.app.eggPrototypeCreatorFactory.registerPrototypeCreator(MODEL_PROTO_IMPL_TYPE, SingletonModelProto.createProto);
21
- this.app.leoricRegister = this.leoricRegister;
22
- this.ormLoadUnitHook = new ORMLoadUnitHook();
23
- }
24
- configWillLoad() {
25
- this.app.eggPrototypeLifecycleUtil.registerLifecycle(this.modelProtoHook);
26
- this.app.eggObjectFactory.registerEggObjectCreateMethod(SingletonModelProto, SingletonModelObject.createObject);
27
- this.app.loadUnitLifecycleUtil.registerLifecycle(this.ormLoadUnitHook);
28
- }
29
- configDidLoad() {
30
- const config = this.app.config.orm;
31
- if (config.datasources) for (const datasource of config.datasources) this.dataSourceManager.addConfig(datasource);
32
- else this.dataSourceManager.addDefaultConfig(config);
33
- }
34
- async didLoad() {
35
- await this.app.moduleHandler.ready();
36
- await this.leoricRegister.register();
37
- }
38
- async beforeClose() {
39
- this.app.eggPrototypeLifecycleUtil.deleteLifecycle(this.modelProtoHook);
40
- }
41
- };
42
-
43
- //#endregion
44
11
  export { OrmAppBootHook as default };
@@ -1,4 +1,4 @@
1
- import { OrmConfig } from "../lib/DataSourceManager.js";
1
+ import { OrmConfig } from "../DataSourceManager-CyKZLZ5P.js";
2
2
 
3
3
  //#region src/config/config.default.d.ts
4
4
  interface AppOrmConfig extends OrmConfig {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- import { Orm } from "./lib/SingletonORM.js";
2
- import { LeoricRegister } from "./lib/LeoricRegister.js";
1
+ import "./types-dLxBJ-zQ.js";
2
+ import { Orm } from "./SingletonORM-Qo7APzul.js";
3
+ import "./ModelProtoManager-DNpjSdgO.js";
4
+ import "./DataSourceManager-CyKZLZ5P.js";
5
+ import { LeoricRegister } from "./LeoricRegister-BYtIlnjj.js";
6
+ import "./app-CZucRSDc.js";
7
+ import "./types-AcnzDaZv.js";
3
8
  export { LeoricRegister, Orm };
package/dist/index.js CHANGED
@@ -1,5 +1,12 @@
1
- import { LeoricRegister } from "./lib/LeoricRegister.js";
2
- import { Orm } from "./lib/SingletonORM.js";
3
- import "./types.js";
1
+ import "./ModelProtoManager-L7fRU1sn.js";
2
+ import "./DataSourceManager-D8WpEJAL.js";
3
+ import { LeoricRegister } from "./LeoricRegister-D5XVCPFb.js";
4
+ import { Orm } from "./SingletonORM-CPBngV28.js";
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";
4
11
 
5
12
  export { LeoricRegister, Orm };
@@ -1,23 +1,2 @@
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
1
+ import { DataSourceManager, OrmConfig } from "../DataSourceManager-CyKZLZ5P.js";
23
2
  export { DataSourceManager, OrmConfig };
@@ -1,22 +1,3 @@
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
- };
1
+ import { DataSourceManager } from "../DataSourceManager-D8WpEJAL.js";
20
2
 
21
- //#endregion
22
3
  export { DataSourceManager };
@@ -1,20 +1,5 @@
1
- import { RealmType } from "./types.js";
2
- import { ModelProtoManager } from "./ModelProtoManager.js";
3
- import { DataSourceManager, OrmConfig } from "./DataSourceManager.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
1
+ import "../types-dLxBJ-zQ.js";
2
+ import "../ModelProtoManager-DNpjSdgO.js";
3
+ import "../DataSourceManager-CyKZLZ5P.js";
4
+ import { LeoricRegister } from "../LeoricRegister-BYtIlnjj.js";
20
5
  export { LeoricRegister };
@@ -1,68 +1,5 @@
1
- import "./ModelProtoManager.js";
2
- import { ModelMetadata, ModelMetadataUtil } from "@eggjs/tegg-orm-decorator";
3
- import { Base } from "sdk-base";
4
- import Realm from "leoric";
1
+ import "../ModelProtoManager-L7fRU1sn.js";
2
+ import "../DataSourceManager-D8WpEJAL.js";
3
+ import { LeoricRegister } from "../LeoricRegister-D5XVCPFb.js";
5
4
 
6
- //#region src/lib/LeoricRegister.ts
7
- var LeoricRegister = class extends Base {
8
- constructor(modelProtoManager, dataSourceManager) {
9
- super();
10
- this.modelProtoManager = modelProtoManager;
11
- this.dataSourceManager = dataSourceManager;
12
- this.realmMap = /* @__PURE__ */ new Map();
13
- }
14
- getConfig(datasource) {
15
- let config;
16
- if (!datasource) config = this.dataSourceManager.getDefaultConfig();
17
- else config = this.dataSourceManager.getConfig(datasource);
18
- return config;
19
- }
20
- getRealm(config) {
21
- if (!config?.database) return;
22
- return this.realmMap.get(config.database);
23
- }
24
- getOrCreateRealm(datasource) {
25
- const config = this.getConfig(datasource);
26
- let realm;
27
- if (config) {
28
- realm = this.getRealm(config);
29
- if (realm) return realm;
30
- }
31
- realm = new Realm({ ...config });
32
- this.realmMap.set(config.database, realm);
33
- return realm;
34
- }
35
- generateLeoricAttributes(metadata) {
36
- const attributes = {};
37
- for (const attribute of metadata.attributes) attributes[attribute.propertyName] = {
38
- columnName: attribute.attributeName,
39
- type: attribute.dataType,
40
- allowNull: attribute.allowNull,
41
- primaryKey: attribute.primary,
42
- unique: attribute.unique,
43
- autoIncrement: attribute.autoIncrement
44
- };
45
- return attributes;
46
- }
47
- async register() {
48
- for (const { proto, clazz } of this.modelProtoManager.getProtos()) {
49
- const metadata = ModelMetadataUtil.getModelMetadata(clazz);
50
- if (!metadata) throw new Error(`not found metadata for model ${proto.id}`);
51
- const realm = this.getOrCreateRealm(metadata.dataSource);
52
- realm.models[clazz.name] = clazz;
53
- realm[clazz.name] = clazz;
54
- const attributes = this.generateLeoricAttributes(metadata);
55
- const hooks = {};
56
- for (const hookName of Realm.hookNames) if (clazz[hookName]) hooks[hookName] = clazz[hookName];
57
- clazz.init(attributes, {
58
- tableName: metadata.tableName,
59
- hooks
60
- }, {});
61
- }
62
- await Promise.all(Array.from(this.realmMap.values()).map((realm) => realm.connect()));
63
- this.ready(true);
64
- }
65
- };
66
-
67
- //#endregion
68
5
  export { LeoricRegister };
@@ -1,4 +1,4 @@
1
- import { ModelProtoManager } from "./ModelProtoManager.js";
1
+ import { ModelProtoManager } from "../ModelProtoManager-DNpjSdgO.js";
2
2
  import { LifecycleHook } from "@eggjs/tegg";
3
3
  import { EggPrototype, EggPrototypeLifecycleContext } from "@eggjs/tegg-metadata";
4
4
 
@@ -1,20 +1,4 @@
1
- import "./ModelProtoManager.js";
2
- import { IS_MODEL, ModelMetaBuilder, ModelMetadataUtil } from "@eggjs/tegg-orm-decorator";
3
- import "@eggjs/tegg";
4
- import "@eggjs/tegg-metadata";
1
+ import "../ModelProtoManager-L7fRU1sn.js";
2
+ import { ModelProtoHook } from "../ModelProtoHook-DUljMCzr.js";
5
3
 
6
- //#region src/lib/ModelProtoHook.ts
7
- var ModelProtoHook = class {
8
- constructor(modelProtoManager) {
9
- this.modelProtoManager = modelProtoManager;
10
- }
11
- async postCreate(ctx, obj) {
12
- if (!obj.getMetaData(IS_MODEL)) return;
13
- const metadata = new ModelMetaBuilder(ctx.clazz).build();
14
- ModelMetadataUtil.setModelMetadata(ctx.clazz, metadata);
15
- this.modelProtoManager.addProto(ctx.clazz, obj);
16
- }
17
- };
18
-
19
- //#endregion
20
4
  export { ModelProtoHook };
@@ -1,15 +1,2 @@
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
1
+ import { ModelProtoManager, ModelProtoPair } from "../ModelProtoManager-DNpjSdgO.js";
15
2
  export { ModelProtoManager, ModelProtoPair };
@@ -1,21 +1,3 @@
1
- import "@eggjs/tegg";
2
- import "@eggjs/tegg-metadata";
1
+ import { ModelProtoManager } from "../ModelProtoManager-L7fRU1sn.js";
3
2
 
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
3
  export { ModelProtoManager };
@@ -1,17 +1,7 @@
1
- import { Orm } from "./SingletonORM.js";
2
- import "@eggjs/tegg";
3
- import { EggLoadUnitType, EggPrototypeCreatorFactory, EggPrototypeFactory } from "@eggjs/tegg-metadata";
1
+ import "../ModelProtoManager-L7fRU1sn.js";
2
+ import "../DataSourceManager-D8WpEJAL.js";
3
+ import "../LeoricRegister-D5XVCPFb.js";
4
+ import "../SingletonORM-CPBngV28.js";
5
+ import { ORMLoadUnitHook } from "../ORMLoadUnitHook-BVBniFwv.js";
4
6
 
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
7
  export { ORMLoadUnitHook };
@@ -1,4 +1,4 @@
1
- import SingletonModelProto from "./SingletonModelProto.js";
1
+ import { SingletonModelProto } from "../SingletonModelProto-CffXdtt4.js";
2
2
  import { EggObjectName, EggPrototypeName } from "@eggjs/tegg";
3
3
  import { Bone } from "leoric";
4
4
  import { EggPrototype } from "@eggjs/tegg-metadata";
@@ -1,49 +1,4 @@
1
- import "./SingletonModelProto.js";
2
- import "@eggjs/tegg";
3
- import { Bone } from "leoric";
4
- import "@eggjs/tegg-metadata";
5
- import { IdenticalUtil } from "@eggjs/tegg-lifecycle";
6
- import { ContextHandler, EggObjectStatus } from "@eggjs/tegg-runtime";
7
- import { EGG_CONTEXT } from "@eggjs/egg-module-common";
1
+ import "../SingletonModelProto-DM-war1a.js";
2
+ import { SingletonModelObject } from "../SingletonModelObject-BUrJjvMq.js";
8
3
 
9
- //#region src/lib/SingletonModelObject.ts
10
- var SingletonModelObject = class SingletonModelObject {
11
- constructor(name, proto) {
12
- this.status = EggObjectStatus.PENDING;
13
- this.name = name;
14
- this.proto = proto;
15
- this.id = IdenticalUtil.createObjectId(this.proto.id);
16
- }
17
- async init() {
18
- this._obj = class ContextModelClass extends this.proto.model {
19
- static get name() {
20
- return super.name;
21
- }
22
- static get ctx() {
23
- const ctx = ContextHandler.getContext();
24
- if (ctx) return ctx.get(EGG_CONTEXT);
25
- }
26
- get ctx() {
27
- return ContextModelClass.ctx;
28
- }
29
- };
30
- this.status = EggObjectStatus.READY;
31
- }
32
- injectProperty() {
33
- throw new Error("never call ModelObject#injectProperty");
34
- }
35
- get isReady() {
36
- return this.status === EggObjectStatus.READY;
37
- }
38
- get obj() {
39
- return this._obj;
40
- }
41
- static async createObject(name, proto) {
42
- const modelObject = new SingletonModelObject(name, proto);
43
- await modelObject.init();
44
- return modelObject;
45
- }
46
- };
47
-
48
- //#endregion
49
4
  export { SingletonModelObject };
@@ -1,27 +1,2 @@
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
1
+ import { SingletonModelProto } from "../SingletonModelProto-CffXdtt4.js";
27
2
  export { SingletonModelProto as default };
@@ -1,41 +1,3 @@
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";
1
+ import { SingletonModelProto } from "../SingletonModelProto-DM-war1a.js";
5
2
 
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
3
  export { SingletonModelProto as default };
@@ -1,10 +1,3 @@
1
- import { RealmType } from "./types.js";
2
-
3
- //#region src/lib/SingletonORM.d.ts
4
- declare class Orm {
5
- private leoricRegister;
6
- get client(): RealmType;
7
- getClient(datasource: string): RealmType;
8
- }
9
- //#endregion
1
+ import "../types-dLxBJ-zQ.js";
2
+ import { Orm } from "../SingletonORM-Qo7APzul.js";
10
3
  export { Orm };
@@ -1,23 +1,6 @@
1
- import { LeoricRegister } from "./LeoricRegister.js";
2
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.93.0/helpers/decorateMetadata.js";
3
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.93.0/helpers/decorate.js";
4
- import { AccessLevel, Inject, SingletonProto } from "@eggjs/tegg";
1
+ import "../ModelProtoManager-L7fRU1sn.js";
2
+ import "../DataSourceManager-D8WpEJAL.js";
3
+ import "../LeoricRegister-D5XVCPFb.js";
4
+ import { Orm } from "../SingletonORM-CPBngV28.js";
5
5
 
6
- //#region src/lib/SingletonORM.ts
7
- var _ref;
8
- let Orm = class Orm$1 {
9
- get client() {
10
- const defaultConfig = this.leoricRegister.getConfig();
11
- return this.leoricRegister.getRealm(defaultConfig);
12
- }
13
- getClient(datasource) {
14
- const config = this.leoricRegister.getConfig(datasource);
15
- if (!config) throw new Error(`not found ${datasource} datasource`);
16
- return this.leoricRegister.getOrCreateRealm(config.database);
17
- }
18
- };
19
- __decorate([Inject(), __decorateMetadata("design:type", typeof (_ref = typeof LeoricRegister !== "undefined" && LeoricRegister) === "function" ? _ref : Object)], Orm.prototype, "leoricRegister", void 0);
20
- Orm = __decorate([SingletonProto({ accessLevel: AccessLevel.PUBLIC })], Orm);
21
-
22
- //#endregion
23
6
  export { Orm };
@@ -1,7 +1,2 @@
1
- import { AbstractDriver, connect } from "leoric";
2
-
3
- //#region src/lib/types.d.ts
4
- type DataType = AbstractDriver['DataType'];
5
- type RealmType = Awaited<ReturnType<typeof connect>>;
6
- //#endregion
1
+ import { DataType, RealmType } from "../types-dLxBJ-zQ.js";
7
2
  export { DataType, RealmType };
@@ -0,0 +1,8 @@
1
+ import { DataType } from "./types-dLxBJ-zQ.js";
2
+ import { AttributeOptions } from "@eggjs/tegg-orm-decorator";
3
+ import "@eggjs/tegg-plugin/types";
4
+
5
+ //#region src/types.d.ts
6
+ declare module '@eggjs/tegg-orm-decorator' {
7
+ function Attribute(dataType: DataType, options?: AttributeOptions): (target: any, propertyKey: PropertyKey) => void;
8
+ }
@@ -0,0 +1,4 @@
1
+ import "@eggjs/tegg-orm-decorator";
2
+ import "@eggjs/tegg-plugin/types";
3
+
4
+ export { };
@@ -0,0 +1,7 @@
1
+ import { AbstractDriver, connect } from "leoric";
2
+
3
+ //#region src/lib/types.d.ts
4
+ type DataType = AbstractDriver['DataType'];
5
+ type RealmType = Awaited<ReturnType<typeof connect>>;
6
+ //#endregion
7
+ export { DataType, RealmType };
package/dist/types.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { DataType } from "./lib/types.js";
2
- import { AttributeOptions } from "@eggjs/tegg-orm-decorator";
3
- import "@eggjs/tegg-plugin/types";
4
-
5
- //#region src/types.d.ts
6
- declare module '@eggjs/tegg-orm-decorator' {
7
- function Attribute(dataType: DataType, options?: AttributeOptions): (target: any, propertyKey: PropertyKey) => void;
8
- }
1
+ import "./types-dLxBJ-zQ.js";
2
+ import "./SingletonORM-Qo7APzul.js";
3
+ import "./ModelProtoManager-DNpjSdgO.js";
4
+ import "./DataSourceManager-CyKZLZ5P.js";
5
+ import "./LeoricRegister-BYtIlnjj.js";
6
+ import "./app-CZucRSDc.js";
7
+ import "./types-AcnzDaZv.js";
package/dist/types.js CHANGED
@@ -1,5 +1,12 @@
1
- import "./app.js";
2
- import "@eggjs/tegg-orm-decorator";
3
- import "@eggjs/tegg-plugin/types";
1
+ import "./ModelProtoManager-L7fRU1sn.js";
2
+ import "./DataSourceManager-D8WpEJAL.js";
3
+ import "./LeoricRegister-D5XVCPFb.js";
4
+ import "./SingletonORM-CPBngV28.js";
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";
4
11
 
5
12
  export { };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "tegg"
7
7
  ]
8
8
  },
9
- "version": "4.0.0-beta.6",
9
+ "version": "4.0.0-beta.8",
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/tegg": "4.0.0-beta.6",
56
- "@eggjs/egg-module-common": "4.0.0-beta.6",
57
- "@eggjs/tegg-orm-decorator": "4.0.0-beta.6",
58
- "@eggjs/tegg-metadata": "4.0.0-beta.6",
59
- "@eggjs/tegg-runtime": "4.0.0-beta.6",
60
- "@eggjs/tegg-lifecycle": "4.0.0-beta.6"
55
+ "@eggjs/egg-module-common": "4.0.0-beta.8",
56
+ "@eggjs/tegg": "4.0.0-beta.8",
57
+ "@eggjs/tegg-metadata": "4.0.0-beta.8",
58
+ "@eggjs/tegg-lifecycle": "4.0.0-beta.8",
59
+ "@eggjs/tegg-orm-decorator": "4.0.0-beta.8",
60
+ "@eggjs/tegg-runtime": "4.0.0-beta.8"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "egg": "beta",
64
- "@eggjs/tegg-plugin": "4.0.0-beta.6"
64
+ "@eggjs/tegg-plugin": "4.0.0-beta.8"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@eggjs/bin": "beta",
@@ -75,9 +75,9 @@
75
75
  "typescript": "^5.9.3",
76
76
  "tsdown": "^0.15.6",
77
77
  "unplugin-unused": "^0.5.3",
78
- "@eggjs/tegg-config": "4.0.0-beta.6",
79
78
  "@eggjs/module-test-util": "4.0.0-beta.4",
80
- "@eggjs/tegg-plugin": "4.0.0-beta.6"
79
+ "@eggjs/tegg-config": "4.0.0-beta.8",
80
+ "@eggjs/tegg-plugin": "4.0.0-beta.8"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public"
@@ -1,10 +0,0 @@
1
- //#region \0@oxc-project+runtime@0.93.0/helpers/decorate.js
2
- function __decorate(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
-
9
- //#endregion
10
- export { __decorate };
@@ -1,7 +0,0 @@
1
- //#region \0@oxc-project+runtime@0.93.0/helpers/decorateMetadata.js
2
- function __decorateMetadata(k, v) {
3
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
- }
5
-
6
- //#endregion
7
- export { __decorateMetadata };