@robinpath/scheduler 0.1.0
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/README.md +94 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/scheduler.d.ts +140 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +350 -0
- package/dist/scheduler.js.map +1 -0
- package/package.json +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @robinpath/scheduler
|
|
2
|
+
|
|
3
|
+
> Schedule and run recurring or one-time tasks with cron expressions, pause/resume support, and execution history
|
|
4
|
+
|
|
5
|
+
   
|
|
6
|
+
|
|
7
|
+
## Why use this module?
|
|
8
|
+
|
|
9
|
+
The `scheduler` module lets you:
|
|
10
|
+
|
|
11
|
+
- Schedule a recurring task using a cron expression
|
|
12
|
+
- Schedule a one-time task at a specific date/time or after a delay in ms
|
|
13
|
+
- Cancel a scheduled task by id
|
|
14
|
+
- Cancel all scheduled tasks
|
|
15
|
+
- List all scheduled tasks with their next run times
|
|
16
|
+
|
|
17
|
+
All functions are callable directly from RobinPath scripts with a simple, consistent API.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @robinpath/scheduler
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
No credentials needed — start using it right away:
|
|
28
|
+
|
|
29
|
+
```robinpath
|
|
30
|
+
scheduler.once "sendEmail" "2025-12-31T23:59:00Z" { action: "sendNewYearEmail" }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available Functions
|
|
34
|
+
|
|
35
|
+
| Function | Description |
|
|
36
|
+
|----------|-------------|
|
|
37
|
+
| `scheduler.schedule` | Schedule a recurring task using a cron expression |
|
|
38
|
+
| `scheduler.once` | Schedule a one-time task at a specific date/time or after a delay in ms |
|
|
39
|
+
| `scheduler.cancel` | Cancel a scheduled task by id |
|
|
40
|
+
| `scheduler.cancelAll` | Cancel all scheduled tasks |
|
|
41
|
+
| `scheduler.list` | List all scheduled tasks with their next run times |
|
|
42
|
+
| `scheduler.get` | Get info about a specific scheduled task |
|
|
43
|
+
| `scheduler.pause` | Pause a scheduled task (keeps it but stops execution) |
|
|
44
|
+
| `scheduler.resume` | Resume a paused task |
|
|
45
|
+
| `scheduler.isRunning` | Check if a task is currently active (not paused and scheduled) |
|
|
46
|
+
| `scheduler.nextRun` | Get the next run time for a scheduled task |
|
|
47
|
+
| `scheduler.history` | Get execution history for a task |
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
### Schedule a one-time task at a specific date/time or after a delay in ms
|
|
52
|
+
|
|
53
|
+
```robinpath
|
|
54
|
+
scheduler.once "sendEmail" "2025-12-31T23:59:00Z" { action: "sendNewYearEmail" }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Cancel a scheduled task by id
|
|
58
|
+
|
|
59
|
+
```robinpath
|
|
60
|
+
scheduler.cancel "cleanup"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Cancel all scheduled tasks
|
|
64
|
+
|
|
65
|
+
```robinpath
|
|
66
|
+
scheduler.cancelAll
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Integration with RobinPath
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { RobinPath } from "@wiredwp/robinpath";
|
|
73
|
+
import Module from "@robinpath/scheduler";
|
|
74
|
+
|
|
75
|
+
const rp = new RobinPath();
|
|
76
|
+
rp.registerModule(Module.name, Module.functions);
|
|
77
|
+
rp.registerModuleMeta(Module.name, Module.functionMetadata);
|
|
78
|
+
|
|
79
|
+
const result = await rp.executeScript(`
|
|
80
|
+
scheduler.once "sendEmail" "2025-12-31T23:59:00Z" { action: "sendNewYearEmail" }
|
|
81
|
+
`);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Full API Reference
|
|
85
|
+
|
|
86
|
+
See [MODULE.md](./MODULE.md) for complete documentation including all parameters, return types, error handling, and advanced examples.
|
|
87
|
+
|
|
88
|
+
## Related Modules
|
|
89
|
+
|
|
90
|
+
- [`@robinpath/json`](../json) — JSON module for complementary functionality
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleAdapter } from "@wiredwp/robinpath";
|
|
2
|
+
declare const SchedulerModule: ModuleAdapter;
|
|
3
|
+
export default SchedulerModule;
|
|
4
|
+
export { SchedulerModule };
|
|
5
|
+
export { SchedulerFunctions, SchedulerFunctionMetadata, SchedulerModuleMetadata } from "./scheduler.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,QAAA,MAAM,eAAe,EAAE,aAMtB,CAAC;AAEF,eAAe,eAAe,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SchedulerFunctions, SchedulerFunctionMetadata, SchedulerModuleMetadata } from "./scheduler.js";
|
|
2
|
+
const SchedulerModule = {
|
|
3
|
+
name: "scheduler",
|
|
4
|
+
functions: SchedulerFunctions,
|
|
5
|
+
functionMetadata: SchedulerFunctionMetadata,
|
|
6
|
+
moduleMetadata: SchedulerModuleMetadata,
|
|
7
|
+
global: false,
|
|
8
|
+
}; // as ModuleAdapter
|
|
9
|
+
export default SchedulerModule;
|
|
10
|
+
export { SchedulerModule };
|
|
11
|
+
export { SchedulerFunctions, SchedulerFunctionMetadata, SchedulerModuleMetadata } from "./scheduler.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAExG,MAAM,eAAe,GAAkB;IACrC,IAAI,EAAE,WAAW;IACjB,SAAS,EAAE,kBAAkB;IAC7B,gBAAgB,EAAE,yBAAgC;IAClD,cAAc,EAAE,uBAA8B;IAC9C,MAAM,EAAE,KAAK;CACd,CAAC,CAAC,mBAAmB;AAEtB,eAAe,eAAe,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { BuiltinHandler } from "@wiredwp/robinpath";
|
|
2
|
+
export declare const SchedulerFunctions: Record<string, BuiltinHandler>;
|
|
3
|
+
export declare const SchedulerFunctionMetadata: {
|
|
4
|
+
schedule: {
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
name: string;
|
|
8
|
+
dataType: string;
|
|
9
|
+
description: string;
|
|
10
|
+
formInputType: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
returnType: string;
|
|
14
|
+
returnDescription: string;
|
|
15
|
+
example: string;
|
|
16
|
+
};
|
|
17
|
+
once: {
|
|
18
|
+
description: string;
|
|
19
|
+
parameters: {
|
|
20
|
+
name: string;
|
|
21
|
+
dataType: string;
|
|
22
|
+
description: string;
|
|
23
|
+
formInputType: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
returnType: string;
|
|
27
|
+
returnDescription: string;
|
|
28
|
+
example: string;
|
|
29
|
+
};
|
|
30
|
+
cancel: {
|
|
31
|
+
description: string;
|
|
32
|
+
parameters: {
|
|
33
|
+
name: string;
|
|
34
|
+
dataType: string;
|
|
35
|
+
description: string;
|
|
36
|
+
formInputType: string;
|
|
37
|
+
required: boolean;
|
|
38
|
+
}[];
|
|
39
|
+
returnType: string;
|
|
40
|
+
returnDescription: string;
|
|
41
|
+
example: string;
|
|
42
|
+
};
|
|
43
|
+
cancelAll: {
|
|
44
|
+
description: string;
|
|
45
|
+
parameters: never[];
|
|
46
|
+
returnType: string;
|
|
47
|
+
returnDescription: string;
|
|
48
|
+
example: string;
|
|
49
|
+
};
|
|
50
|
+
list: {
|
|
51
|
+
description: string;
|
|
52
|
+
parameters: never[];
|
|
53
|
+
returnType: string;
|
|
54
|
+
returnDescription: string;
|
|
55
|
+
example: string;
|
|
56
|
+
};
|
|
57
|
+
get: {
|
|
58
|
+
description: string;
|
|
59
|
+
parameters: {
|
|
60
|
+
name: string;
|
|
61
|
+
dataType: string;
|
|
62
|
+
description: string;
|
|
63
|
+
formInputType: string;
|
|
64
|
+
required: boolean;
|
|
65
|
+
}[];
|
|
66
|
+
returnType: string;
|
|
67
|
+
returnDescription: string;
|
|
68
|
+
example: string;
|
|
69
|
+
};
|
|
70
|
+
pause: {
|
|
71
|
+
description: string;
|
|
72
|
+
parameters: {
|
|
73
|
+
name: string;
|
|
74
|
+
dataType: string;
|
|
75
|
+
description: string;
|
|
76
|
+
formInputType: string;
|
|
77
|
+
required: boolean;
|
|
78
|
+
}[];
|
|
79
|
+
returnType: string;
|
|
80
|
+
returnDescription: string;
|
|
81
|
+
example: string;
|
|
82
|
+
};
|
|
83
|
+
resume: {
|
|
84
|
+
description: string;
|
|
85
|
+
parameters: {
|
|
86
|
+
name: string;
|
|
87
|
+
dataType: string;
|
|
88
|
+
description: string;
|
|
89
|
+
formInputType: string;
|
|
90
|
+
required: boolean;
|
|
91
|
+
}[];
|
|
92
|
+
returnType: string;
|
|
93
|
+
returnDescription: string;
|
|
94
|
+
example: string;
|
|
95
|
+
};
|
|
96
|
+
isRunning: {
|
|
97
|
+
description: string;
|
|
98
|
+
parameters: {
|
|
99
|
+
name: string;
|
|
100
|
+
dataType: string;
|
|
101
|
+
description: string;
|
|
102
|
+
formInputType: string;
|
|
103
|
+
required: boolean;
|
|
104
|
+
}[];
|
|
105
|
+
returnType: string;
|
|
106
|
+
returnDescription: string;
|
|
107
|
+
example: string;
|
|
108
|
+
};
|
|
109
|
+
nextRun: {
|
|
110
|
+
description: string;
|
|
111
|
+
parameters: {
|
|
112
|
+
name: string;
|
|
113
|
+
dataType: string;
|
|
114
|
+
description: string;
|
|
115
|
+
formInputType: string;
|
|
116
|
+
required: boolean;
|
|
117
|
+
}[];
|
|
118
|
+
returnType: string;
|
|
119
|
+
returnDescription: string;
|
|
120
|
+
example: string;
|
|
121
|
+
};
|
|
122
|
+
history: {
|
|
123
|
+
description: string;
|
|
124
|
+
parameters: {
|
|
125
|
+
name: string;
|
|
126
|
+
dataType: string;
|
|
127
|
+
description: string;
|
|
128
|
+
formInputType: string;
|
|
129
|
+
required: boolean;
|
|
130
|
+
}[];
|
|
131
|
+
returnType: string;
|
|
132
|
+
returnDescription: string;
|
|
133
|
+
example: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export declare const SchedulerModuleMetadata: {
|
|
137
|
+
description: string;
|
|
138
|
+
methods: string[];
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2C,MAAM,oBAAoB,CAAC;AAkQlG,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAE7D,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGrC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;CAGnC,CAAC"}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Internal cron parser (5-field: minute hour day-of-month month day-of-week)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
function expandField(field, min, max) {
|
|
5
|
+
const values = new Set();
|
|
6
|
+
for (const part of field.split(",")) {
|
|
7
|
+
const stepMatch = part.match(/^(.+)\/(\d+)$/);
|
|
8
|
+
let range, step;
|
|
9
|
+
if (stepMatch) {
|
|
10
|
+
range = stepMatch[1];
|
|
11
|
+
step = Number(stepMatch[2]);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
range = part;
|
|
15
|
+
step = 1;
|
|
16
|
+
}
|
|
17
|
+
if (range === "*") {
|
|
18
|
+
for (let i = min; i <= max; i += step)
|
|
19
|
+
values.add(i);
|
|
20
|
+
}
|
|
21
|
+
else if (range.includes("-")) {
|
|
22
|
+
const [start, end] = range.split("-").map(Number);
|
|
23
|
+
for (let i = start; i <= end; i += step)
|
|
24
|
+
values.add(i);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
values.add(Number(range));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return [...values].sort((a, b) => a - b);
|
|
31
|
+
}
|
|
32
|
+
function parseCron(expr) {
|
|
33
|
+
const parts = expr.trim().split(/\s+/);
|
|
34
|
+
if (parts.length !== 5)
|
|
35
|
+
return null;
|
|
36
|
+
try {
|
|
37
|
+
return {
|
|
38
|
+
minute: expandField(parts[0], 0, 59),
|
|
39
|
+
hour: expandField(parts[1], 0, 23),
|
|
40
|
+
dayOfMonth: expandField(parts[2], 1, 31),
|
|
41
|
+
month: expandField(parts[3], 1, 12),
|
|
42
|
+
dayOfWeek: expandField(parts[4], 0, 6),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function matchesCron(parsed, date) {
|
|
50
|
+
return parsed.minute.includes(date.getMinutes()) &&
|
|
51
|
+
parsed.hour.includes(date.getHours()) &&
|
|
52
|
+
parsed.dayOfMonth.includes(date.getDate()) &&
|
|
53
|
+
parsed.month.includes(date.getMonth() + 1) &&
|
|
54
|
+
parsed.dayOfWeek.includes(date.getDay());
|
|
55
|
+
}
|
|
56
|
+
function findNextCronDate(parsed, from) {
|
|
57
|
+
const d = new Date(from);
|
|
58
|
+
d.setSeconds(0, 0);
|
|
59
|
+
d.setMinutes(d.getMinutes() + 1);
|
|
60
|
+
for (let i = 0; i < 525960; i++) { // up to ~1 year of minutes
|
|
61
|
+
if (matchesCron(parsed, d))
|
|
62
|
+
return d;
|
|
63
|
+
d.setMinutes(d.getMinutes() + 1);
|
|
64
|
+
}
|
|
65
|
+
throw new Error("No matching cron date found within 1 year");
|
|
66
|
+
}
|
|
67
|
+
const jobs = new Map();
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Internal helpers
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
function scheduleNextTick(job) {
|
|
72
|
+
if (job.interval !== null) {
|
|
73
|
+
clearTimeout(job.interval);
|
|
74
|
+
job.interval = null;
|
|
75
|
+
}
|
|
76
|
+
if (job.paused)
|
|
77
|
+
return;
|
|
78
|
+
const now = new Date();
|
|
79
|
+
const delay = Math.max(job.nextRun.getTime() - now.getTime(), 0);
|
|
80
|
+
job.interval = setTimeout(() => {
|
|
81
|
+
// Record execution
|
|
82
|
+
job.history.push({ ran: new Date().toISOString(), status: "executed" });
|
|
83
|
+
// Keep history bounded
|
|
84
|
+
if (job.history.length > 200)
|
|
85
|
+
job.history.splice(0, job.history.length - 200);
|
|
86
|
+
if (job.type === "recurring" && job.cron) {
|
|
87
|
+
const parsed = parseCron(job.cron);
|
|
88
|
+
if (parsed) {
|
|
89
|
+
job.nextRun = findNextCronDate(parsed, new Date());
|
|
90
|
+
scheduleNextTick(job);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// one-time job: clean up after execution
|
|
95
|
+
job.interval = null;
|
|
96
|
+
jobs.delete(job.id);
|
|
97
|
+
}
|
|
98
|
+
}, delay);
|
|
99
|
+
}
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Handlers
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
const schedule = (args) => {
|
|
104
|
+
const id = String(args[0] ?? "");
|
|
105
|
+
const cronExpression = String(args[1] ?? "");
|
|
106
|
+
const action = args[2] ?? null;
|
|
107
|
+
if (!id)
|
|
108
|
+
throw new Error("Task id is required");
|
|
109
|
+
const parsed = parseCron(cronExpression);
|
|
110
|
+
if (!parsed)
|
|
111
|
+
throw new Error("Invalid cron expression: " + cronExpression);
|
|
112
|
+
// Cancel existing job with same id if present
|
|
113
|
+
if (jobs.has(id)) {
|
|
114
|
+
const existing = jobs.get(id);
|
|
115
|
+
if (existing.interval !== null)
|
|
116
|
+
clearTimeout(existing.interval);
|
|
117
|
+
}
|
|
118
|
+
const nextRun = findNextCronDate(parsed, new Date());
|
|
119
|
+
const job = { id, cron: cronExpression, nextRun, interval: null, paused: false, type: "recurring", action, history: [] };
|
|
120
|
+
jobs.set(id, job);
|
|
121
|
+
scheduleNextTick(job);
|
|
122
|
+
return { id, nextRun: nextRun.toISOString(), type: "recurring", cron: cronExpression };
|
|
123
|
+
};
|
|
124
|
+
const once = (args) => {
|
|
125
|
+
const id = String(args[0] ?? "");
|
|
126
|
+
const dateOrDelay = args[1];
|
|
127
|
+
const action = args[2] ?? null;
|
|
128
|
+
if (!id)
|
|
129
|
+
throw new Error("Task id is required");
|
|
130
|
+
if (dateOrDelay === undefined || dateOrDelay === null)
|
|
131
|
+
throw new Error("dateOrDelay is required (ISO string or milliseconds)");
|
|
132
|
+
// Cancel existing job with same id if present
|
|
133
|
+
if (jobs.has(id)) {
|
|
134
|
+
const existing = jobs.get(id);
|
|
135
|
+
if (existing.interval !== null)
|
|
136
|
+
clearTimeout(existing.interval);
|
|
137
|
+
}
|
|
138
|
+
let nextRun;
|
|
139
|
+
if (typeof dateOrDelay === "number") {
|
|
140
|
+
nextRun = new Date(Date.now() + dateOrDelay);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
nextRun = new Date(String(dateOrDelay));
|
|
144
|
+
if (isNaN(nextRun.getTime()))
|
|
145
|
+
throw new Error("Invalid date: " + String(dateOrDelay));
|
|
146
|
+
}
|
|
147
|
+
const job = { id, cron: null, nextRun, interval: null, paused: false, type: "once", action, history: [] };
|
|
148
|
+
jobs.set(id, job);
|
|
149
|
+
scheduleNextTick(job);
|
|
150
|
+
return { id, nextRun: nextRun.toISOString(), type: "once" };
|
|
151
|
+
};
|
|
152
|
+
const cancel = (args) => {
|
|
153
|
+
const id = String(args[0] ?? "");
|
|
154
|
+
const job = jobs.get(id);
|
|
155
|
+
if (!job)
|
|
156
|
+
return { cancelled: false, reason: "Task not found" };
|
|
157
|
+
if (job.interval !== null)
|
|
158
|
+
clearTimeout(job.interval);
|
|
159
|
+
jobs.delete(id);
|
|
160
|
+
return { cancelled: true, id };
|
|
161
|
+
};
|
|
162
|
+
const cancelAll = () => {
|
|
163
|
+
let count = 0;
|
|
164
|
+
for (const [, job] of jobs) {
|
|
165
|
+
if (job.interval !== null)
|
|
166
|
+
clearTimeout(job.interval);
|
|
167
|
+
count++;
|
|
168
|
+
}
|
|
169
|
+
jobs.clear();
|
|
170
|
+
return { cancelled: count };
|
|
171
|
+
};
|
|
172
|
+
const list = () => {
|
|
173
|
+
const entries = [];
|
|
174
|
+
for (const [, job] of jobs) {
|
|
175
|
+
entries.push({ id: job.id, type: job.type, cron: job.cron, nextRun: job.nextRun.toISOString(), paused: job.paused });
|
|
176
|
+
}
|
|
177
|
+
return entries;
|
|
178
|
+
};
|
|
179
|
+
const get = (args) => {
|
|
180
|
+
const id = String(args[0] ?? "");
|
|
181
|
+
const job = jobs.get(id);
|
|
182
|
+
if (!job)
|
|
183
|
+
return null;
|
|
184
|
+
return { id: job.id, type: job.type, cron: job.cron, nextRun: job.nextRun.toISOString(), paused: job.paused, action: job.action, historyCount: job.history.length };
|
|
185
|
+
};
|
|
186
|
+
const pause = (args) => {
|
|
187
|
+
const id = String(args[0] ?? "");
|
|
188
|
+
const job = jobs.get(id);
|
|
189
|
+
if (!job)
|
|
190
|
+
throw new Error("Task not found: " + id);
|
|
191
|
+
if (job.paused)
|
|
192
|
+
return { id, paused: true, message: "Already paused" };
|
|
193
|
+
job.paused = true;
|
|
194
|
+
if (job.interval !== null) {
|
|
195
|
+
clearTimeout(job.interval);
|
|
196
|
+
job.interval = null;
|
|
197
|
+
}
|
|
198
|
+
return { id, paused: true };
|
|
199
|
+
};
|
|
200
|
+
const resume = (args) => {
|
|
201
|
+
const id = String(args[0] ?? "");
|
|
202
|
+
const job = jobs.get(id);
|
|
203
|
+
if (!job)
|
|
204
|
+
throw new Error("Task not found: " + id);
|
|
205
|
+
if (!job.paused)
|
|
206
|
+
return { id, paused: false, message: "Already running" };
|
|
207
|
+
job.paused = false;
|
|
208
|
+
// Recalculate next run for recurring tasks in case time has passed
|
|
209
|
+
if (job.type === "recurring" && job.cron) {
|
|
210
|
+
const parsed = parseCron(job.cron);
|
|
211
|
+
if (parsed) {
|
|
212
|
+
job.nextRun = findNextCronDate(parsed, new Date());
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
scheduleNextTick(job);
|
|
216
|
+
return { id, paused: false, nextRun: job.nextRun.toISOString() };
|
|
217
|
+
};
|
|
218
|
+
const isRunning = (args) => {
|
|
219
|
+
const id = String(args[0] ?? "");
|
|
220
|
+
const job = jobs.get(id);
|
|
221
|
+
if (!job)
|
|
222
|
+
return false;
|
|
223
|
+
return !job.paused && job.interval !== null;
|
|
224
|
+
};
|
|
225
|
+
const nextRun = (args) => {
|
|
226
|
+
const id = String(args[0] ?? "");
|
|
227
|
+
const job = jobs.get(id);
|
|
228
|
+
if (!job)
|
|
229
|
+
throw new Error("Task not found: " + id);
|
|
230
|
+
return job.nextRun.toISOString();
|
|
231
|
+
};
|
|
232
|
+
const history = (args) => {
|
|
233
|
+
const id = String(args[0] ?? "");
|
|
234
|
+
const job = jobs.get(id);
|
|
235
|
+
if (!job)
|
|
236
|
+
throw new Error("Task not found: " + id);
|
|
237
|
+
return [...job.history];
|
|
238
|
+
};
|
|
239
|
+
// ---------------------------------------------------------------------------
|
|
240
|
+
// Exports
|
|
241
|
+
// ---------------------------------------------------------------------------
|
|
242
|
+
export const SchedulerFunctions = {
|
|
243
|
+
schedule, once, cancel, cancelAll, list, get, pause, resume, isRunning, nextRun, history,
|
|
244
|
+
};
|
|
245
|
+
export const SchedulerFunctionMetadata = {
|
|
246
|
+
schedule: {
|
|
247
|
+
description: "Schedule a recurring task using a cron expression",
|
|
248
|
+
parameters: [
|
|
249
|
+
{ name: "id", dataType: "string", description: "Unique task identifier", formInputType: "text", required: true },
|
|
250
|
+
{ name: "cronExpression", dataType: "string", description: "Standard 5-field cron expression", formInputType: "text", required: true },
|
|
251
|
+
{ name: "action", dataType: "object", description: "Callback info object with action name", formInputType: "text", required: true },
|
|
252
|
+
],
|
|
253
|
+
returnType: "object",
|
|
254
|
+
returnDescription: "{ id, nextRun, type, cron }",
|
|
255
|
+
example: 'scheduler.schedule "cleanup" "*/5 * * * *" { action: "runCleanup" }',
|
|
256
|
+
},
|
|
257
|
+
once: {
|
|
258
|
+
description: "Schedule a one-time task at a specific date/time or after a delay in ms",
|
|
259
|
+
parameters: [
|
|
260
|
+
{ name: "id", dataType: "string", description: "Unique task identifier", formInputType: "text", required: true },
|
|
261
|
+
{ name: "dateOrDelay", dataType: "string", description: "ISO date string or delay in milliseconds", formInputType: "text", required: true },
|
|
262
|
+
{ name: "action", dataType: "object", description: "Callback info object with action name", formInputType: "text", required: false },
|
|
263
|
+
],
|
|
264
|
+
returnType: "object",
|
|
265
|
+
returnDescription: "{ id, nextRun, type }",
|
|
266
|
+
example: 'scheduler.once "sendEmail" "2025-12-31T23:59:00Z" { action: "sendNewYearEmail" }',
|
|
267
|
+
},
|
|
268
|
+
cancel: {
|
|
269
|
+
description: "Cancel a scheduled task by id",
|
|
270
|
+
parameters: [
|
|
271
|
+
{ name: "id", dataType: "string", description: "Task identifier to cancel", formInputType: "text", required: true },
|
|
272
|
+
],
|
|
273
|
+
returnType: "object",
|
|
274
|
+
returnDescription: "{ cancelled, id } or { cancelled: false, reason }",
|
|
275
|
+
example: 'scheduler.cancel "cleanup"',
|
|
276
|
+
},
|
|
277
|
+
cancelAll: {
|
|
278
|
+
description: "Cancel all scheduled tasks",
|
|
279
|
+
parameters: [],
|
|
280
|
+
returnType: "object",
|
|
281
|
+
returnDescription: "{ cancelled: <count> }",
|
|
282
|
+
example: "scheduler.cancelAll",
|
|
283
|
+
},
|
|
284
|
+
list: {
|
|
285
|
+
description: "List all scheduled tasks with their next run times",
|
|
286
|
+
parameters: [],
|
|
287
|
+
returnType: "array",
|
|
288
|
+
returnDescription: "Array of { id, type, cron, nextRun, paused }",
|
|
289
|
+
example: "scheduler.list",
|
|
290
|
+
},
|
|
291
|
+
get: {
|
|
292
|
+
description: "Get info about a specific scheduled task",
|
|
293
|
+
parameters: [
|
|
294
|
+
{ name: "id", dataType: "string", description: "Task identifier", formInputType: "text", required: true },
|
|
295
|
+
],
|
|
296
|
+
returnType: "object",
|
|
297
|
+
returnDescription: "Task details or null if not found",
|
|
298
|
+
example: 'scheduler.get "cleanup"',
|
|
299
|
+
},
|
|
300
|
+
pause: {
|
|
301
|
+
description: "Pause a scheduled task (keeps it but stops execution)",
|
|
302
|
+
parameters: [
|
|
303
|
+
{ name: "id", dataType: "string", description: "Task identifier to pause", formInputType: "text", required: true },
|
|
304
|
+
],
|
|
305
|
+
returnType: "object",
|
|
306
|
+
returnDescription: "{ id, paused: true }",
|
|
307
|
+
example: 'scheduler.pause "cleanup"',
|
|
308
|
+
},
|
|
309
|
+
resume: {
|
|
310
|
+
description: "Resume a paused task",
|
|
311
|
+
parameters: [
|
|
312
|
+
{ name: "id", dataType: "string", description: "Task identifier to resume", formInputType: "text", required: true },
|
|
313
|
+
],
|
|
314
|
+
returnType: "object",
|
|
315
|
+
returnDescription: "{ id, paused: false, nextRun }",
|
|
316
|
+
example: 'scheduler.resume "cleanup"',
|
|
317
|
+
},
|
|
318
|
+
isRunning: {
|
|
319
|
+
description: "Check if a task is currently active (not paused and scheduled)",
|
|
320
|
+
parameters: [
|
|
321
|
+
{ name: "id", dataType: "string", description: "Task identifier", formInputType: "text", required: true },
|
|
322
|
+
],
|
|
323
|
+
returnType: "boolean",
|
|
324
|
+
returnDescription: "True if the task is active",
|
|
325
|
+
example: 'scheduler.isRunning "cleanup"',
|
|
326
|
+
},
|
|
327
|
+
nextRun: {
|
|
328
|
+
description: "Get the next run time for a scheduled task",
|
|
329
|
+
parameters: [
|
|
330
|
+
{ name: "id", dataType: "string", description: "Task identifier", formInputType: "text", required: true },
|
|
331
|
+
],
|
|
332
|
+
returnType: "string",
|
|
333
|
+
returnDescription: "ISO date string of the next run",
|
|
334
|
+
example: 'scheduler.nextRun "cleanup"',
|
|
335
|
+
},
|
|
336
|
+
history: {
|
|
337
|
+
description: "Get execution history for a task",
|
|
338
|
+
parameters: [
|
|
339
|
+
{ name: "id", dataType: "string", description: "Task identifier", formInputType: "text", required: true },
|
|
340
|
+
],
|
|
341
|
+
returnType: "array",
|
|
342
|
+
returnDescription: "Array of { ran, status } entries",
|
|
343
|
+
example: 'scheduler.history "cleanup"',
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
export const SchedulerModuleMetadata = {
|
|
347
|
+
description: "Schedule and run recurring or one-time tasks with cron expressions, pause/resume support, and execution history",
|
|
348
|
+
methods: ["schedule", "once", "cancel", "cancelAll", "list", "get", "pause", "resume", "isRunning", "nextRun", "history"],
|
|
349
|
+
};
|
|
350
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAE9E,SAAS,WAAW,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC1D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9C,IAAI,KAAa,EAAE,IAAY,CAAC;QAChC,IAAI,SAAS,EAAE,CAAC;YAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAE,CAAC;YAAC,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;aACjE,CAAC;YAAC,KAAK,GAAG,IAAI,CAAC;YAAC,IAAI,GAAG,CAAC,CAAC;QAAC,CAAC;QAEhC,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAClB,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,IAAI;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAClD,KAAK,IAAI,CAAC,GAAG,KAAM,EAAE,CAAC,IAA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E,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;CAC1H,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@robinpath/scheduler",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": { "access": "public" },
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": { ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" } },
|
|
9
|
+
"files": ["dist"],
|
|
10
|
+
"scripts": { "build": "tsc", "test": "node --import tsx --test tests/*.test.ts" },
|
|
11
|
+
"peerDependencies": { "@wiredwp/robinpath": ">=0.20.0" },
|
|
12
|
+
"devDependencies": { "@wiredwp/robinpath": "^0.30.1", "tsx": "^4.19.0", "typescript": "^5.6.0" }
|
|
13
|
+
}
|