@ldsg/schedule 0.3.25

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,8 @@
1
+ import { HandlerSpecificResourceSettings } from '@ldsg/handler';
2
+ import { ResourceDefinitionSpecificResourceSettings } from '@ldsg/resource-definition';
3
+ import { GeneralResourceSettings } from '@ldsg/types';
4
+ export declare const INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
5
+ export declare const INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS: HandlerSpecificResourceSettings;
6
+ export declare const RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
7
+ export declare const RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS: ResourceDefinitionSpecificResourceSettings;
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF,eAAO,MAAM,uDAAuD,EAAE,+BAOrE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAE5D,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
4
+ exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
5
+ title: '定时任务实例化资源处理程序',
6
+ description: ''
7
+ };
8
+ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
9
+ code: `export * from "@ldsg/schedule";`,
10
+ dependencies: [
11
+ {
12
+ name: '@ldsg/schedule'
13
+ }
14
+ ]
15
+ };
16
+ exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
17
+ title: '定时任务资源定义',
18
+ description: ''
19
+ };
20
+ exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
21
+ kind: 'schedule'
22
+ };
@@ -0,0 +1,6 @@
1
+ import { Handler } from '@ldsg/handler';
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
+ import { ScheduleResource } from './resource';
4
+ import { ScheduleSpecificResourceSettings } from './types';
5
+ export declare const handler: Handler<InstantiateResourceParams<ScheduleSpecificResourceSettings>, InstantiateResourceRes<ScheduleResource>>;
6
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B,yBAAyB,CAAC,gCAAgC,CAAC,EAC3D,sBAAsB,CAAC,gBAAgB,CAAC,CACnB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const instantiate_resource_1 = require("./instantiate-resource");
5
+ exports.handler = instantiate_resource_1.instantiateResource;
@@ -0,0 +1,6 @@
1
+ export * from './constants';
2
+ export * from './handler';
3
+ export * from './instantiate-resource';
4
+ export * from './resource';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./handler"), exports);
19
+ __exportStar(require("./instantiate-resource"), exports);
20
+ __exportStar(require("./resource"), exports);
21
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,5 @@
1
+ import { InstantiateResource } from '@ldsg/resource';
2
+ import { ScheduleResource } from './resource';
3
+ import { ScheduleSpecificResourceSettings } from './types';
4
+ export declare const instantiateResource: InstantiateResource<ScheduleSpecificResourceSettings, ScheduleResource>;
5
+ //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instantiate-resource.d.ts","sourceRoot":"","sources":["../src/instantiate-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CAAC,gCAAgC,EAAE,gBAAgB,CAYvG,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.instantiateResource = void 0;
4
+ const resource_1 = require("./resource");
5
+ const instantiateResource = (params) => {
6
+ const { resourceConstructorParams } = params;
7
+ const resource = new resource_1.ScheduleResource(resourceConstructorParams);
8
+ const res = {
9
+ resource
10
+ };
11
+ return res;
12
+ };
13
+ exports.instantiateResource = instantiateResource;
@@ -0,0 +1,17 @@
1
+ import { Resource } from '@ldsg/resource';
2
+ import { ScheduleSpecificResourceSettings } from './types';
3
+ export declare class ScheduleResource extends Resource<ScheduleSpecificResourceSettings> {
4
+ getScheduleInfo: () => {
5
+ scheduleInfo: {
6
+ [x: string]: any;
7
+ triggerType: "now" | "once" | "every";
8
+ workflowResourceId: string;
9
+ id: string;
10
+ workflowVariables?: Record<string, unknown> | undefined;
11
+ delay?: number | undefined;
12
+ scheduledAt?: number | undefined;
13
+ cron?: string | undefined;
14
+ };
15
+ };
16
+ }
17
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gCAAgC,EAAgB,MAAM,SAAS,CAAC;AAEzE,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,gCAAgC,CAAC;IAC9E,eAAe;;;;;;;;;;;MAiBb;CACH"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduleResource = void 0;
4
+ const resource_1 = require("@ldsg/resource");
5
+ class ScheduleResource extends resource_1.Resource {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.getScheduleInfo = () => {
9
+ const { settings: { triggerType, workflowResourceId, workflowVariables, delay, scheduledAt, cron }, id } = this;
10
+ const scheduleInfo = {
11
+ id,
12
+ triggerType,
13
+ workflowResourceId,
14
+ workflowVariables,
15
+ delay,
16
+ scheduledAt,
17
+ cron
18
+ };
19
+ return { scheduleInfo };
20
+ };
21
+ }
22
+ }
23
+ exports.ScheduleResource = ScheduleResource;
@@ -0,0 +1,2 @@
1
+ export * from './specific-resource-settings';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./specific-resource-settings"), exports);
@@ -0,0 +1,8 @@
1
+ import { ResourceExtendedHandler } from '@ldsg/handler';
2
+ interface ScheduleResourceExtendedHandlerParams {
3
+ triggeredAt: string;
4
+ jobData?: Record<string, unknown>;
5
+ }
6
+ export type ScheduleResourceExtendedHandler = ResourceExtendedHandler<ScheduleResourceExtendedHandlerParams, void>;
7
+ export {};
8
+ //# sourceMappingURL=resource-extended-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-extended-handler.d.ts","sourceRoot":"","sources":["../../src/types/resource-extended-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,UAAU,qCAAqC;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,+BAA+B,GAAG,uBAAuB,CACnE,qCAAqC,EACrC,IAAI,CACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ /** 触发类型:now-立即,once-单次,every-周期 */
3
+ export declare const TriggerTypeSchema: z.ZodEnum<{
4
+ now: "now";
5
+ once: "once";
6
+ every: "every";
7
+ }>;
8
+ export type TriggerType = z.infer<typeof TriggerTypeSchema>;
9
+ export declare const ScheduleSpecificResourceSettingsSchema: z.ZodObject<{
10
+ triggerType: z.ZodEnum<{
11
+ now: "now";
12
+ once: "once";
13
+ every: "every";
14
+ }>;
15
+ workflowResourceId: z.ZodString;
16
+ workflowVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
17
+ delay: z.ZodOptional<z.ZodNumber>;
18
+ scheduledAt: z.ZodOptional<z.ZodNumber>;
19
+ cron: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$catchall<z.ZodAny>>;
21
+ export declare const SpecificResourceSettingsSchema: z.ZodObject<{
22
+ triggerType: z.ZodEnum<{
23
+ now: "now";
24
+ once: "once";
25
+ every: "every";
26
+ }>;
27
+ workflowResourceId: z.ZodString;
28
+ workflowVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
29
+ delay: z.ZodOptional<z.ZodNumber>;
30
+ scheduledAt: z.ZodOptional<z.ZodNumber>;
31
+ cron: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$catchall<z.ZodAny>>;
33
+ export type ScheduleSpecificResourceSettings = z.infer<typeof ScheduleSpecificResourceSettingsSchema>;
34
+ export declare const ScheduleInfoSchema: z.ZodObject<{
35
+ triggerType: z.ZodEnum<{
36
+ now: "now";
37
+ once: "once";
38
+ every: "every";
39
+ }>;
40
+ workflowResourceId: z.ZodString;
41
+ workflowVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
42
+ delay: z.ZodOptional<z.ZodNumber>;
43
+ scheduledAt: z.ZodOptional<z.ZodNumber>;
44
+ cron: z.ZodOptional<z.ZodString>;
45
+ id: z.ZodString;
46
+ }, z.core.$catchall<z.ZodAny>>;
47
+ export type ScheduleInfo = z.infer<typeof ScheduleInfoSchema>;
48
+ export interface GetScheduleInfo {
49
+ (): {
50
+ scheduleInfo: ScheduleInfo;
51
+ };
52
+ }
53
+ //# sourceMappingURL=specific-resource-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,mCAAmC;AACnC,eAAO,MAAM,iBAAiB;;;;EAAmC,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,sCAAsC;;;;;;;;;;;8BAe/B,CAAC;AAErB,eAAO,MAAM,8BAA8B;;;;;;;;;;;8BAAyC,CAAC;AACrF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAC;AAEtG,eAAO,MAAM,kBAAkB;;;;;;;;;;;;8BAE7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,IAAI;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,CAAC;CACpC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduleInfoSchema = exports.SpecificResourceSettingsSchema = exports.ScheduleSpecificResourceSettingsSchema = exports.TriggerTypeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /** 触发类型:now-立即,once-单次,every-周期 */
6
+ exports.TriggerTypeSchema = zod_1.z.enum(['now', 'once', 'every']);
7
+ exports.ScheduleSpecificResourceSettingsSchema = zod_1.z
8
+ .object({
9
+ /** 触发类型 */
10
+ triggerType: exports.TriggerTypeSchema,
11
+ /** 关联的工作流资源ID */
12
+ workflowResourceId: zod_1.z.string(),
13
+ /** 工作流变量 */
14
+ workflowVariables: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
15
+ /** 延迟时长(毫秒),从现在起倒计时(与 scheduledAt 二选一,scheduledAt 优先) */
16
+ delay: zod_1.z.number().optional(),
17
+ /** 计划执行时间(毫秒时间戳),优先生效 */
18
+ scheduledAt: zod_1.z.number().optional(),
19
+ /** cron 表达式,仅 every 类型下使用 */
20
+ cron: zod_1.z.string().optional()
21
+ })
22
+ .catchall(zod_1.z.any());
23
+ exports.SpecificResourceSettingsSchema = exports.ScheduleSpecificResourceSettingsSchema;
24
+ exports.ScheduleInfoSchema = exports.ScheduleSpecificResourceSettingsSchema.extend({
25
+ id: zod_1.z.string()
26
+ });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@ldsg/schedule",
3
+ "version": "0.3.25",
4
+ "description": "",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "author": "wanxger",
8
+ "main": "dist/index.js",
9
+ "types": "dist",
10
+ "files": [
11
+ "dist/"
12
+ ],
13
+ "dependencies": {
14
+ "zod": "^4.1.11",
15
+ "@ldsg/resource-definition": "0.3.25",
16
+ "@ldsg/resource": "0.3.25",
17
+ "@ldsg/handler": "0.3.25"
18
+ },
19
+ "devDependencies": {
20
+ "@types/jest": "^29.5.2",
21
+ "@types/node": "^20.13.0",
22
+ "jest": "^29.5.0",
23
+ "ts-jest": "^29.1.5",
24
+ "ts-node": "^10.9.2",
25
+ "typescript": "^5.8.3",
26
+ "@ldsg/types": "0.3.25",
27
+ "@ldsg/application": "0.3.25"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc --project tsconfig.build.json",
34
+ "clean": "rm -rf dist",
35
+ "test": "jest"
36
+ }
37
+ }