@eggjs/tegg-schedule-plugin 4.0.0-beta.7 → 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.
@@ -0,0 +1,19 @@
1
+ import { Context } from "egg";
2
+ import "@eggjs/tegg-metadata";
3
+ import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
4
+ import { ROOT_PROTO } from "@eggjs/egg-module-common";
5
+ import { EggContainerFactory } from "@eggjs/tegg-runtime";
6
+
7
+ //#region src/lib/EggScheduleAdapter.ts
8
+ function eggScheduleAdapterFactory(proto, metaData) {
9
+ return async function(ctx, data) {
10
+ ctx[ROOT_PROTO] = proto;
11
+ await ctx.beginModuleScope(async () => {
12
+ if (metaData.disable) return;
13
+ await (await EggContainerFactory.getOrCreateEggObject(proto, proto.name)).obj.subscribe(data);
14
+ });
15
+ };
16
+ }
17
+
18
+ //#endregion
19
+ export { eggScheduleAdapterFactory };
@@ -0,0 +1,17 @@
1
+ import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
2
+
3
+ //#region src/lib/EggScheduleMetadataConvertor.ts
4
+ var EggScheduleMetadataConvertor = class {
5
+ static convertToEggSchedule(metadata) {
6
+ return {
7
+ ...metadata.scheduleData,
8
+ type: metadata.type,
9
+ env: metadata.env,
10
+ disable: metadata.disable,
11
+ immediate: metadata.immediate
12
+ };
13
+ }
14
+ };
15
+
16
+ //#endregion
17
+ export { EggScheduleMetadataConvertor };
@@ -0,0 +1,15 @@
1
+ import "@eggjs/tegg-metadata";
2
+ import { ScheduleInfoUtil, ScheduleMetaBuilder, ScheduleMetadataUtil } from "@eggjs/tegg-schedule-decorator";
3
+ import "@eggjs/tegg-lifecycle";
4
+
5
+ //#region src/lib/SchedulePrototypeHook.ts
6
+ var SchedulePrototypeHook = class {
7
+ async postCreate(ctx) {
8
+ if (!ScheduleInfoUtil.isSchedule(ctx.clazz)) return;
9
+ const metadata = new ScheduleMetaBuilder(ctx.clazz).build();
10
+ if (metadata) ScheduleMetadataUtil.setScheduleMetadata(ctx.clazz, metadata);
11
+ }
12
+ };
13
+
14
+ //#endregion
15
+ export { SchedulePrototypeHook };
@@ -0,0 +1,24 @@
1
+ import { EggScheduleMetadataConvertor } from "./EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import "egg";
3
+ import { PrototypeUtil } from "@eggjs/tegg";
4
+ import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
5
+
6
+ //#region src/lib/ScheduleSubscriberRegister.ts
7
+ var ScheduleSubscriberRegister = class {
8
+ agent;
9
+ constructor(agent) {
10
+ this.agent = agent;
11
+ }
12
+ register(clazz, metadata) {
13
+ const schedule = EggScheduleMetadataConvertor.convertToEggSchedule(metadata);
14
+ const path = PrototypeUtil.getFilePath(clazz);
15
+ if (!metadata.disable) this.agent.logger.info("[@eggjs/tegg-schedule-plugin]: register schedule %s", path);
16
+ this.agent.schedule.registerSchedule({
17
+ schedule,
18
+ key: path
19
+ });
20
+ }
21
+ };
22
+
23
+ //#endregion
24
+ export { ScheduleSubscriberRegister };
@@ -0,0 +1,23 @@
1
+ import "@eggjs/tegg-metadata";
2
+ import "@eggjs/tegg";
3
+ import { IS_SCHEDULE, SCHEDULE_METADATA, ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
4
+
5
+ //#region src/lib/ScheduleWorkerLoadUnitHook.ts
6
+ var ScheduleWorkerLoadUnitHook = class {
7
+ scheduleWorkerRegister;
8
+ constructor(scheduleWorkerRegister) {
9
+ this.scheduleWorkerRegister = scheduleWorkerRegister;
10
+ }
11
+ async postCreate(_, obj) {
12
+ const iterator = obj.iterateEggPrototype();
13
+ for (const proto of iterator) {
14
+ if (!proto.getMetaData(IS_SCHEDULE)) continue;
15
+ const metadata = proto.getMetaData(SCHEDULE_METADATA);
16
+ if (!metadata) continue;
17
+ this.scheduleWorkerRegister.register(proto, metadata);
18
+ }
19
+ }
20
+ };
21
+
22
+ //#endregion
23
+ export { ScheduleWorkerLoadUnitHook };
@@ -0,0 +1,27 @@
1
+ import { EggScheduleMetadataConvertor } from "./EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import { eggScheduleAdapterFactory } from "./EggScheduleAdapter-DEn6ulTC.js";
3
+ import { Application } from "egg";
4
+ import "@eggjs/tegg-metadata";
5
+ import { PrototypeUtil } from "@eggjs/tegg";
6
+ import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
7
+
8
+ //#region src/lib/ScheduleWorkerRegister.ts
9
+ var ScheduleWorkerRegister = class {
10
+ app;
11
+ constructor(app) {
12
+ this.app = app;
13
+ }
14
+ register(proto, metadata) {
15
+ const task = eggScheduleAdapterFactory(proto, metadata);
16
+ const schedule = EggScheduleMetadataConvertor.convertToEggSchedule(metadata);
17
+ const path = proto.getMetaData(PrototypeUtil.FILE_PATH);
18
+ this.app.scheduleWorker.registerSchedule({
19
+ schedule,
20
+ task,
21
+ key: path
22
+ });
23
+ }
24
+ };
25
+
26
+ //#endregion
27
+ export { ScheduleWorkerRegister };
@@ -0,0 +1,12 @@
1
+ import { Application } from "egg";
2
+ import { EggPrototype } from "@eggjs/tegg-metadata";
3
+ import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
4
+
5
+ //#region src/lib/ScheduleWorkerRegister.d.ts
6
+ declare class ScheduleWorkerRegister {
7
+ private readonly app;
8
+ constructor(app: Application);
9
+ register(proto: EggPrototype, metadata: ScheduleMetadata<object>): void;
10
+ }
11
+ //#endregion
12
+ export { ScheduleWorkerRegister };
package/dist/agent.js CHANGED
@@ -1,4 +1,5 @@
1
- import { ScheduleSubscriberRegister } from "./lib/ScheduleSubscriberRegister.js";
1
+ import "./EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import { ScheduleSubscriberRegister } from "./ScheduleSubscriberRegister-CyQ8hJH8.js";
2
3
  import { Agent } from "egg";
3
4
  import { LoaderFactory } from "@eggjs/tegg-loader";
4
5
  import { EggLoadUnitType } from "@eggjs/tegg-metadata";
package/dist/app.js CHANGED
@@ -1,6 +1,8 @@
1
- import { ScheduleWorkerRegister } from "./lib/ScheduleWorkerRegister.js";
2
- import { ScheduleWorkerLoadUnitHook } from "./lib/ScheduleWorkerLoadUnitHook.js";
3
- import { SchedulePrototypeHook } from "./lib/SchedulePrototypeHook.js";
1
+ import "./EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import "./EggScheduleAdapter-DEn6ulTC.js";
3
+ import { ScheduleWorkerRegister } from "./ScheduleWorkerRegister-BEkNg0Wq.js";
4
+ import { ScheduleWorkerLoadUnitHook } from "./ScheduleWorkerLoadUnitHook-9c6e0LVf.js";
5
+ import { SchedulePrototypeHook } from "./SchedulePrototypeHook-Bijq9pON.js";
4
6
 
5
7
  //#region src/app.ts
6
8
  var ScheduleAppBootHook = class {
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ import "./types-64z8ustY.js";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./types.js";
1
+ import "./types-DoWCKYJQ.js";
2
2
 
3
3
  export { };
@@ -1,19 +1,3 @@
1
- import { Context } from "egg";
2
- import "@eggjs/tegg-metadata";
3
- import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
4
- import { ROOT_PROTO } from "@eggjs/egg-module-common";
5
- import { EggContainerFactory } from "@eggjs/tegg-runtime";
1
+ import { eggScheduleAdapterFactory } from "../EggScheduleAdapter-DEn6ulTC.js";
6
2
 
7
- //#region src/lib/EggScheduleAdapter.ts
8
- function eggScheduleAdapterFactory(proto, metaData) {
9
- return async function(ctx, data) {
10
- ctx[ROOT_PROTO] = proto;
11
- await ctx.beginModuleScope(async () => {
12
- if (metaData.disable) return;
13
- await (await EggContainerFactory.getOrCreateEggObject(proto, proto.name)).obj.subscribe(data);
14
- });
15
- };
16
- }
17
-
18
- //#endregion
19
3
  export { eggScheduleAdapterFactory };
@@ -1,17 +1,3 @@
1
- import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
1
+ import { EggScheduleMetadataConvertor } from "../EggScheduleMetadataConvertor-DztYwrQw.js";
2
2
 
3
- //#region src/lib/EggScheduleMetadataConvertor.ts
4
- var EggScheduleMetadataConvertor = class {
5
- static convertToEggSchedule(metadata) {
6
- return {
7
- ...metadata.scheduleData,
8
- type: metadata.type,
9
- env: metadata.env,
10
- disable: metadata.disable,
11
- immediate: metadata.immediate
12
- };
13
- }
14
- };
15
-
16
- //#endregion
17
3
  export { EggScheduleMetadataConvertor };
@@ -1,15 +1,3 @@
1
- import "@eggjs/tegg-metadata";
2
- import { ScheduleInfoUtil, ScheduleMetaBuilder, ScheduleMetadataUtil } from "@eggjs/tegg-schedule-decorator";
3
- import "@eggjs/tegg-lifecycle";
1
+ import { SchedulePrototypeHook } from "../SchedulePrototypeHook-Bijq9pON.js";
4
2
 
5
- //#region src/lib/SchedulePrototypeHook.ts
6
- var SchedulePrototypeHook = class {
7
- async postCreate(ctx) {
8
- if (!ScheduleInfoUtil.isSchedule(ctx.clazz)) return;
9
- const metadata = new ScheduleMetaBuilder(ctx.clazz).build();
10
- if (metadata) ScheduleMetadataUtil.setScheduleMetadata(ctx.clazz, metadata);
11
- }
12
- };
13
-
14
- //#endregion
15
3
  export { SchedulePrototypeHook };
@@ -1,24 +1,4 @@
1
- import { EggScheduleMetadataConvertor } from "./EggScheduleMetadataConvertor.js";
2
- import "egg";
3
- import { PrototypeUtil } from "@eggjs/tegg";
4
- import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
1
+ import "../EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import { ScheduleSubscriberRegister } from "../ScheduleSubscriberRegister-CyQ8hJH8.js";
5
3
 
6
- //#region src/lib/ScheduleSubscriberRegister.ts
7
- var ScheduleSubscriberRegister = class {
8
- agent;
9
- constructor(agent) {
10
- this.agent = agent;
11
- }
12
- register(clazz, metadata) {
13
- const schedule = EggScheduleMetadataConvertor.convertToEggSchedule(metadata);
14
- const path = PrototypeUtil.getFilePath(clazz);
15
- if (!metadata.disable) this.agent.logger.info("[@eggjs/tegg-schedule-plugin]: register schedule %s", path);
16
- this.agent.schedule.registerSchedule({
17
- schedule,
18
- key: path
19
- });
20
- }
21
- };
22
-
23
- //#endregion
24
4
  export { ScheduleSubscriberRegister };
@@ -1,4 +1,4 @@
1
- import { ScheduleWorkerRegister } from "./ScheduleWorkerRegister.js";
1
+ import { ScheduleWorkerRegister } from "../ScheduleWorkerRegister-D_HpfSei.js";
2
2
  import { LoadUnit, LoadUnitLifecycleContext } from "@eggjs/tegg-metadata";
3
3
  import { LifecycleHook } from "@eggjs/tegg";
4
4
 
@@ -1,24 +1,6 @@
1
- import "./ScheduleWorkerRegister.js";
2
- import "@eggjs/tegg-metadata";
3
- import "@eggjs/tegg";
4
- import { IS_SCHEDULE, SCHEDULE_METADATA, ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
1
+ import "../EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import "../EggScheduleAdapter-DEn6ulTC.js";
3
+ import "../ScheduleWorkerRegister-BEkNg0Wq.js";
4
+ import { ScheduleWorkerLoadUnitHook } from "../ScheduleWorkerLoadUnitHook-9c6e0LVf.js";
5
5
 
6
- //#region src/lib/ScheduleWorkerLoadUnitHook.ts
7
- var ScheduleWorkerLoadUnitHook = class {
8
- scheduleWorkerRegister;
9
- constructor(scheduleWorkerRegister) {
10
- this.scheduleWorkerRegister = scheduleWorkerRegister;
11
- }
12
- async postCreate(_, obj) {
13
- const iterator = obj.iterateEggPrototype();
14
- for (const proto of iterator) {
15
- if (!proto.getMetaData(IS_SCHEDULE)) continue;
16
- const metadata = proto.getMetaData(SCHEDULE_METADATA);
17
- if (!metadata) continue;
18
- this.scheduleWorkerRegister.register(proto, metadata);
19
- }
20
- }
21
- };
22
-
23
- //#endregion
24
6
  export { ScheduleWorkerLoadUnitHook };
@@ -1,12 +1,2 @@
1
- import { Application } from "egg";
2
- import { EggPrototype } from "@eggjs/tegg-metadata";
3
- import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
4
-
5
- //#region src/lib/ScheduleWorkerRegister.d.ts
6
- declare class ScheduleWorkerRegister {
7
- private readonly app;
8
- constructor(app: Application);
9
- register(proto: EggPrototype, metadata: ScheduleMetadata<object>): void;
10
- }
11
- //#endregion
1
+ import { ScheduleWorkerRegister } from "../ScheduleWorkerRegister-D_HpfSei.js";
12
2
  export { ScheduleWorkerRegister };
@@ -1,27 +1,5 @@
1
- import { EggScheduleMetadataConvertor } from "./EggScheduleMetadataConvertor.js";
2
- import { eggScheduleAdapterFactory } from "./EggScheduleAdapter.js";
3
- import { Application } from "egg";
4
- import "@eggjs/tegg-metadata";
5
- import { PrototypeUtil } from "@eggjs/tegg";
6
- import { ScheduleMetadata } from "@eggjs/tegg-schedule-decorator";
1
+ import "../EggScheduleMetadataConvertor-DztYwrQw.js";
2
+ import "../EggScheduleAdapter-DEn6ulTC.js";
3
+ import { ScheduleWorkerRegister } from "../ScheduleWorkerRegister-BEkNg0Wq.js";
7
4
 
8
- //#region src/lib/ScheduleWorkerRegister.ts
9
- var ScheduleWorkerRegister = class {
10
- app;
11
- constructor(app) {
12
- this.app = app;
13
- }
14
- register(proto, metadata) {
15
- const task = eggScheduleAdapterFactory(proto, metadata);
16
- const schedule = EggScheduleMetadataConvertor.convertToEggSchedule(metadata);
17
- const path = proto.getMetaData(PrototypeUtil.FILE_PATH);
18
- this.app.scheduleWorker.registerSchedule({
19
- schedule,
20
- task,
21
- key: path
22
- });
23
- }
24
- };
25
-
26
- //#endregion
27
5
  export { ScheduleWorkerRegister };
@@ -0,0 +1 @@
1
+ import "@eggjs/tegg-plugin";
@@ -0,0 +1,3 @@
1
+ import "@eggjs/tegg-plugin";
2
+
3
+ export { };
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- import "@eggjs/tegg-plugin";
1
+ import "./types-64z8ustY.js";
package/dist/types.js CHANGED
@@ -1,3 +1,3 @@
1
- import "@eggjs/tegg-plugin";
1
+ import "./types-DoWCKYJQ.js";
2
2
 
3
3
  export { };
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "schedule"
8
8
  ]
9
9
  },
10
- "version": "4.0.0-beta.7",
10
+ "version": "4.0.0-beta.8",
11
11
  "description": "schedule decorator for egg",
12
12
  "keywords": [
13
13
  "egg",
@@ -47,17 +47,17 @@
47
47
  "node": ">=22.18.0"
48
48
  },
49
49
  "dependencies": {
50
- "@eggjs/egg-module-common": "4.0.0-beta.7",
51
- "@eggjs/tegg": "4.0.0-beta.7",
52
- "@eggjs/tegg-lifecycle": "4.0.0-beta.7",
53
- "@eggjs/tegg-metadata": "4.0.0-beta.7",
54
- "@eggjs/tegg-runtime": "4.0.0-beta.7",
55
- "@eggjs/tegg-loader": "4.0.0-beta.7",
56
- "@eggjs/tegg-schedule-decorator": "4.0.0-beta.7"
50
+ "@eggjs/egg-module-common": "4.0.0-beta.8",
51
+ "@eggjs/tegg": "4.0.0-beta.8",
52
+ "@eggjs/tegg-lifecycle": "4.0.0-beta.8",
53
+ "@eggjs/tegg-loader": "4.0.0-beta.8",
54
+ "@eggjs/tegg-metadata": "4.0.0-beta.8",
55
+ "@eggjs/tegg-schedule-decorator": "4.0.0-beta.8",
56
+ "@eggjs/tegg-runtime": "4.0.0-beta.8"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "egg": "beta",
60
- "@eggjs/tegg-plugin": "4.0.0-beta.7"
60
+ "@eggjs/tegg-plugin": "4.0.0-beta.8"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@eggjs/bin": "beta",
@@ -69,10 +69,10 @@
69
69
  "typescript": "^5.9.3",
70
70
  "tsdown": "^0.15.6",
71
71
  "unplugin-unused": "^0.5.3",
72
- "@eggjs/tegg-common-util": "4.0.0-beta.7",
73
72
  "@eggjs/module-test-util": "4.0.0-beta.4",
74
- "@eggjs/tegg-config": "4.0.0-beta.7",
75
- "@eggjs/tegg-plugin": "4.0.0-beta.7"
73
+ "@eggjs/tegg-common-util": "4.0.0-beta.8",
74
+ "@eggjs/tegg-config": "4.0.0-beta.8",
75
+ "@eggjs/tegg-plugin": "4.0.0-beta.8"
76
76
  },
77
77
  "publishConfig": {
78
78
  "access": "public"