@ldsg/schedules 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.
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +22 -0
- package/dist/handler.d.ts +6 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/instantiate-resource.d.ts +5 -0
- package/dist/instantiate-resource.d.ts.map +1 -0
- package/dist/instantiate-resource.js +13 -0
- package/dist/resource.d.ts +25 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +126 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/job-params.d.ts +14 -0
- package/dist/types/job-params.d.ts.map +1 -0
- package/dist/types/job-params.js +2 -0
- package/dist/types/resource-extended-handler.d.ts +8 -0
- package/dist/types/resource-extended-handler.d.ts.map +1 -0
- package/dist/types/resource-extended-handler.js +2 -0
- package/dist/types/specific-resource-settings.d.ts +11 -0
- package/dist/types/specific-resource-settings.d.ts.map +1 -0
- package/dist/types/specific-resource-settings.js +12 -0
- package/package.json +43 -0
|
@@ -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/schedules";`,
|
|
10
|
+
dependencies: [
|
|
11
|
+
{
|
|
12
|
+
name: '@ldsg/schedules'
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
|
|
17
|
+
title: '定时任务组资源定义',
|
|
18
|
+
description: ''
|
|
19
|
+
};
|
|
20
|
+
exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
|
|
21
|
+
kind: 'schedules'
|
|
22
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Handler } from '@ldsg/handler';
|
|
2
|
+
import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
|
|
3
|
+
import { SchedulesResource } from './resource';
|
|
4
|
+
import { SchedulesSpecificResourceSettings } from './types';
|
|
5
|
+
export declare const handler: Handler<InstantiateResourceParams<SchedulesSpecificResourceSettings>, InstantiateResourceRes<SchedulesResource>>;
|
|
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,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAE5D,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B,yBAAyB,CAAC,iCAAiC,CAAC,EAC5D,sBAAsB,CAAC,iBAAiB,CAAC,CACpB,CAAC"}
|
package/dist/handler.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -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 { SchedulesResource } from './resource';
|
|
3
|
+
import { SchedulesSpecificResourceSettings } from './types';
|
|
4
|
+
export declare const instantiateResource: InstantiateResource<SchedulesSpecificResourceSettings, SchedulesResource>;
|
|
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,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAE5D,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CACnD,iCAAiC,EACjC,iBAAiB,CAWlB,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.SchedulesResource(resourceConstructorParams);
|
|
8
|
+
const res = {
|
|
9
|
+
resource
|
|
10
|
+
};
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
exports.instantiateResource = instantiateResource;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExtendExpressApp } from '@ldsg/application';
|
|
2
|
+
import { Resource } from '@ldsg/resource';
|
|
3
|
+
import { ScheduleInfo } from '@ldsg/schedule';
|
|
4
|
+
import { Agenda, Job } from 'agenda';
|
|
5
|
+
import { CancelJobParams, ScheduleJobParams, SchedulesSpecificResourceSettings } from './types';
|
|
6
|
+
interface JobData {
|
|
7
|
+
_static?: boolean;
|
|
8
|
+
workflowResourceId: string;
|
|
9
|
+
workflowVariables?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
interface GetScheduleInfoListRes {
|
|
12
|
+
scheduleInfoList: ScheduleInfo[];
|
|
13
|
+
}
|
|
14
|
+
type GetScheduleInfoList = () => GetScheduleInfoListRes;
|
|
15
|
+
export declare class SchedulesResource extends Resource<SchedulesSpecificResourceSettings> {
|
|
16
|
+
agenda: Agenda;
|
|
17
|
+
getScheduleInfoList: GetScheduleInfoList;
|
|
18
|
+
executeWorkflow: (params: JobData) => Promise<void>;
|
|
19
|
+
extendExpressApp: ExtendExpressApp;
|
|
20
|
+
scheduleJob: (params: ScheduleJobParams) => Promise<Job>;
|
|
21
|
+
cancelJob: (params: CancelJobParams) => Promise<void>;
|
|
22
|
+
stopSchedules: () => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# 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,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEhG,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,UAAU,sBAAsB;IAC9B,gBAAgB,EAAE,YAAY,EAAE,CAAC;CAClC;AAED,KAAK,mBAAmB,GAAG,MAAM,sBAAsB,CAAC;AAIxD,qBAAa,iBAAkB,SAAQ,QAAQ,CAAC,iCAAiC,CAAC;IAChF,MAAM,EAAG,MAAM,CAAC;IAEhB,mBAAmB,EAAE,mBAAmB,CAsBtC;IAEF,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAiBjD;IAEF,gBAAgB,EAAE,gBAAgB,CAuDhC;IAEF,WAAW,GAAU,QAAQ,iBAAiB,KAAG,OAAO,CAAC,GAAG,CAAC,CA8B3D;IAEF,SAAS,GAAU,QAAQ,eAAe,mBAOxC;IAEF,aAAa,sBAEX;CACH"}
|
package/dist/resource.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SchedulesResource = void 0;
|
|
7
|
+
const resource_1 = require("@ldsg/resource");
|
|
8
|
+
const agenda_1 = require("agenda");
|
|
9
|
+
const mongo_backend_1 = require("@agendajs/mongo-backend");
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
11
|
+
const JOB_NAME = 'executeWorkflow';
|
|
12
|
+
class SchedulesResource extends resource_1.Resource {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.getScheduleInfoList = () => {
|
|
16
|
+
const { id, getFilteredResources } = this;
|
|
17
|
+
const { resources } = getFilteredResources({
|
|
18
|
+
parentId: id
|
|
19
|
+
});
|
|
20
|
+
const mapRes = resources.map((resource) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return (_a = resource.getScheduleInfo) === null || _a === void 0 ? void 0 : _a.call(resource);
|
|
23
|
+
});
|
|
24
|
+
const filterRes = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
|
|
25
|
+
const scheduleInfoList = lodash_1.default.map(filterRes, 'scheduleInfo');
|
|
26
|
+
const res = {
|
|
27
|
+
scheduleInfoList
|
|
28
|
+
};
|
|
29
|
+
return res;
|
|
30
|
+
};
|
|
31
|
+
this.executeWorkflow = async (params) => {
|
|
32
|
+
const { workflowResourceId, workflowVariables } = params;
|
|
33
|
+
const { resource: workflowResource } = this.getFilteredResource({
|
|
34
|
+
id: workflowResourceId
|
|
35
|
+
});
|
|
36
|
+
const wr = workflowResource;
|
|
37
|
+
if (!(wr === null || wr === void 0 ? void 0 : wr.execute)) {
|
|
38
|
+
throw new Error(`workflow not found or invalid: ${workflowResourceId}`);
|
|
39
|
+
}
|
|
40
|
+
await wr.execute({
|
|
41
|
+
context: {},
|
|
42
|
+
variables: workflowVariables || {}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
this.extendExpressApp = async (params) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const { getFilteredResource, getResourcesFromSettings, settings: { processEvery } } = this;
|
|
48
|
+
const databaseResourceFromSettings = getResourcesFromSettings().databaseResource;
|
|
49
|
+
const databaseResource = databaseResourceFromSettings !== null && databaseResourceFromSettings !== void 0 ? databaseResourceFromSettings : getFilteredResource({
|
|
50
|
+
kind: 'database'
|
|
51
|
+
}).resource;
|
|
52
|
+
const databaseInfo = (_a = databaseResource === null || databaseResource === void 0 ? void 0 : databaseResource.getDatabaseInfo) === null || _a === void 0 ? void 0 : _a.call(databaseResource);
|
|
53
|
+
if (!(databaseInfo === null || databaseInfo === void 0 ? void 0 : databaseInfo.uri)) {
|
|
54
|
+
throw new Error('database uri not available');
|
|
55
|
+
}
|
|
56
|
+
this.agenda = new agenda_1.Agenda({
|
|
57
|
+
backend: new mongo_backend_1.MongoBackend({ address: databaseInfo.uri }),
|
|
58
|
+
processEvery
|
|
59
|
+
});
|
|
60
|
+
this.agenda.on('error', (error) => {
|
|
61
|
+
console.error('Agenda error:', error);
|
|
62
|
+
});
|
|
63
|
+
this.agenda.define(JOB_NAME, async (job) => {
|
|
64
|
+
await this.executeWorkflow(job.attrs.data);
|
|
65
|
+
});
|
|
66
|
+
await this.agenda.start();
|
|
67
|
+
const { scheduleInfoList } = this.getScheduleInfoList();
|
|
68
|
+
const hasEvery = scheduleInfoList.some((info) => info.triggerType === 'every');
|
|
69
|
+
if (hasEvery) {
|
|
70
|
+
await this.agenda.cancel({ name: JOB_NAME });
|
|
71
|
+
}
|
|
72
|
+
for (const scheduleInfo of scheduleInfoList) {
|
|
73
|
+
await this.scheduleJob({
|
|
74
|
+
_static: true,
|
|
75
|
+
workflowResourceId: scheduleInfo.workflowResourceId,
|
|
76
|
+
workflowVariables: scheduleInfo.workflowVariables,
|
|
77
|
+
triggerType: scheduleInfo.triggerType,
|
|
78
|
+
delay: scheduleInfo.delay,
|
|
79
|
+
scheduledAt: scheduleInfo.scheduledAt,
|
|
80
|
+
cron: scheduleInfo.cron
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
this.scheduleJob = async (params) => {
|
|
85
|
+
if (!this.agenda) {
|
|
86
|
+
throw new Error('agenda not initialized');
|
|
87
|
+
}
|
|
88
|
+
const { workflowResourceId, workflowVariables, triggerType, delay, scheduledAt, cron, _static } = params;
|
|
89
|
+
const jobData = { _static, workflowResourceId, workflowVariables };
|
|
90
|
+
if (triggerType === 'now') {
|
|
91
|
+
return this.agenda.now(JOB_NAME, jobData);
|
|
92
|
+
}
|
|
93
|
+
const job = this.agenda.create(JOB_NAME, jobData);
|
|
94
|
+
if (triggerType === 'once') {
|
|
95
|
+
if (scheduledAt) {
|
|
96
|
+
job.schedule(new Date(scheduledAt));
|
|
97
|
+
}
|
|
98
|
+
else if (delay) {
|
|
99
|
+
job.schedule(new Date(Date.now() + delay));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new Error('invalid scheduling parameters: delay or scheduledAt required');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (triggerType === 'every' && cron) {
|
|
106
|
+
job.repeatEvery(cron);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw new Error('invalid scheduling parameters');
|
|
110
|
+
}
|
|
111
|
+
return job.save();
|
|
112
|
+
};
|
|
113
|
+
this.cancelJob = async (params) => {
|
|
114
|
+
if (!this.agenda) {
|
|
115
|
+
throw new Error('agenda not initialized');
|
|
116
|
+
}
|
|
117
|
+
const { jobId } = params;
|
|
118
|
+
await this.agenda.cancel({ id: jobId });
|
|
119
|
+
};
|
|
120
|
+
this.stopSchedules = async () => {
|
|
121
|
+
var _a;
|
|
122
|
+
await ((_a = this.agenda) === null || _a === void 0 ? void 0 : _a.stop());
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.SchedulesResource = SchedulesResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./job-params"), exports);
|
|
18
|
+
__exportStar(require("./specific-resource-settings"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TriggerType } from '@ldsg/schedule';
|
|
2
|
+
export interface ScheduleJobParams {
|
|
3
|
+
workflowResourceId: string;
|
|
4
|
+
workflowVariables?: Record<string, unknown>;
|
|
5
|
+
triggerType: TriggerType;
|
|
6
|
+
delay?: number;
|
|
7
|
+
scheduledAt?: number;
|
|
8
|
+
cron?: string;
|
|
9
|
+
_static?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface CancelJobParams {
|
|
12
|
+
jobId: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=job-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-params.d.ts","sourceRoot":"","sources":["../../src/types/job-params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResourceExtendedHandler } from '@ldsg/handler';
|
|
2
|
+
interface SchedulesResourceExtendedHandlerParams {
|
|
3
|
+
triggeredAt: string;
|
|
4
|
+
jobData?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export type SchedulesResourceExtendedHandler = ResourceExtendedHandler<SchedulesResourceExtendedHandlerParams, 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,sCAAsC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,gCAAgC,GAAG,uBAAuB,CACpE,sCAAsC,EACtC,IAAI,CACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SchedulesSpecificResourceSettingsSchema: z.ZodObject<{
|
|
3
|
+
databaseResourceId: z.ZodOptional<z.ZodString>;
|
|
4
|
+
processEvery: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
}, z.core.$catchall<z.ZodAny>>;
|
|
6
|
+
export declare const SpecificResourceSettingsSchema: z.ZodObject<{
|
|
7
|
+
databaseResourceId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
processEvery: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, z.core.$catchall<z.ZodAny>>;
|
|
10
|
+
export type SchedulesSpecificResourceSettings = z.infer<typeof SchedulesSpecificResourceSettingsSchema>;
|
|
11
|
+
//# 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,eAAO,MAAM,uCAAuC;;;8BAMhC,CAAC;AAErB,eAAO,MAAM,8BAA8B;;;8BAA0C,CAAC;AACtF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uCAAuC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpecificResourceSettingsSchema = exports.SchedulesSpecificResourceSettingsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.SchedulesSpecificResourceSettingsSchema = zod_1.z
|
|
6
|
+
.object({
|
|
7
|
+
databaseResourceId: zod_1.z.string().optional(),
|
|
8
|
+
/** 轮询间隔(毫秒),默认 1000 */
|
|
9
|
+
processEvery: zod_1.z.number().optional()
|
|
10
|
+
})
|
|
11
|
+
.catchall(zod_1.z.any());
|
|
12
|
+
exports.SpecificResourceSettingsSchema = exports.SchedulesSpecificResourceSettingsSchema;
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ldsg/schedules",
|
|
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
|
+
"@agendajs/mongo-backend": "^4.0.2",
|
|
15
|
+
"agenda": "^6.2.5",
|
|
16
|
+
"lodash": "^4.17.21",
|
|
17
|
+
"zod": "^4.1.11",
|
|
18
|
+
"@ldsg/database": "0.3.25",
|
|
19
|
+
"@ldsg/resource": "0.3.25",
|
|
20
|
+
"@ldsg/handler": "0.3.25",
|
|
21
|
+
"@ldsg/resource-definition": "0.3.25",
|
|
22
|
+
"@ldsg/schedule": "0.3.25"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/jest": "^29.5.2",
|
|
26
|
+
"@types/lodash": "^4.14.202",
|
|
27
|
+
"@types/node": "^20.13.0",
|
|
28
|
+
"jest": "^29.5.0",
|
|
29
|
+
"ts-jest": "^29.1.5",
|
|
30
|
+
"ts-node": "^10.9.2",
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"@ldsg/types": "0.3.25",
|
|
33
|
+
"@ldsg/application": "0.3.25"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc --project tsconfig.build.json",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
}
|
|
43
|
+
}
|