@twin.org/background-task-scheduler 0.0.2-next.2 → 0.0.2-next.4
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/cjs/index.cjs +9 -10
- package/dist/esm/index.mjs +9 -10
- package/dist/types/index.d.ts +1 -1
- package/dist/types/{taskScheduler.d.ts → taskSchedulerService.d.ts} +2 -6
- package/docs/changelog.md +28 -0
- package/docs/reference/classes/{TaskSchedulerComponent.md → TaskSchedulerService.md} +4 -12
- package/docs/reference/index.md +1 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -4,17 +4,13 @@ var core = require('@twin.org/core');
|
|
|
4
4
|
var loggingModels = require('@twin.org/logging-models');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Class for
|
|
7
|
+
* Class for scheduling tasks.
|
|
8
8
|
*/
|
|
9
|
-
class
|
|
10
|
-
/**
|
|
11
|
-
* The namespace supported by the task scheduler.
|
|
12
|
-
*/
|
|
13
|
-
static NAMESPACE = "task-scheduler";
|
|
9
|
+
class TaskSchedulerService {
|
|
14
10
|
/**
|
|
15
11
|
* Runtime name for the class.
|
|
16
12
|
*/
|
|
17
|
-
CLASS_NAME = "
|
|
13
|
+
CLASS_NAME = "TaskSchedulerService";
|
|
18
14
|
/**
|
|
19
15
|
* The logger for the task connector.
|
|
20
16
|
* @internal
|
|
@@ -80,7 +76,7 @@ class TaskSchedulerComponent {
|
|
|
80
76
|
id: taskId
|
|
81
77
|
}
|
|
82
78
|
});
|
|
83
|
-
this.startTimer();
|
|
79
|
+
await this.startTimer();
|
|
84
80
|
}
|
|
85
81
|
/**
|
|
86
82
|
* Remove a task from the scheduler.
|
|
@@ -143,8 +139,11 @@ class TaskSchedulerComponent {
|
|
|
143
139
|
* Start the timer for running scheduled tasks.
|
|
144
140
|
* @internal
|
|
145
141
|
*/
|
|
146
|
-
startTimer() {
|
|
142
|
+
async startTimer() {
|
|
147
143
|
if (core.Is.empty(this._timer)) {
|
|
144
|
+
// Trigger immediately to catch up on any missed tasks
|
|
145
|
+
await this.triggerScheduledTasks();
|
|
146
|
+
// Set the timer to run at the specified interval
|
|
148
147
|
this._timer = setInterval(async () => this.triggerScheduledTasks(), this._tickInterval);
|
|
149
148
|
}
|
|
150
149
|
}
|
|
@@ -209,4 +208,4 @@ class TaskSchedulerComponent {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
|
|
212
|
-
exports.
|
|
211
|
+
exports.TaskSchedulerService = TaskSchedulerService;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,17 +2,13 @@ import { Is, BaseError } from '@twin.org/core';
|
|
|
2
2
|
import { LoggingConnectorFactory } from '@twin.org/logging-models';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Class for
|
|
5
|
+
* Class for scheduling tasks.
|
|
6
6
|
*/
|
|
7
|
-
class
|
|
8
|
-
/**
|
|
9
|
-
* The namespace supported by the task scheduler.
|
|
10
|
-
*/
|
|
11
|
-
static NAMESPACE = "task-scheduler";
|
|
7
|
+
class TaskSchedulerService {
|
|
12
8
|
/**
|
|
13
9
|
* Runtime name for the class.
|
|
14
10
|
*/
|
|
15
|
-
CLASS_NAME = "
|
|
11
|
+
CLASS_NAME = "TaskSchedulerService";
|
|
16
12
|
/**
|
|
17
13
|
* The logger for the task connector.
|
|
18
14
|
* @internal
|
|
@@ -78,7 +74,7 @@ class TaskSchedulerComponent {
|
|
|
78
74
|
id: taskId
|
|
79
75
|
}
|
|
80
76
|
});
|
|
81
|
-
this.startTimer();
|
|
77
|
+
await this.startTimer();
|
|
82
78
|
}
|
|
83
79
|
/**
|
|
84
80
|
* Remove a task from the scheduler.
|
|
@@ -141,8 +137,11 @@ class TaskSchedulerComponent {
|
|
|
141
137
|
* Start the timer for running scheduled tasks.
|
|
142
138
|
* @internal
|
|
143
139
|
*/
|
|
144
|
-
startTimer() {
|
|
140
|
+
async startTimer() {
|
|
145
141
|
if (Is.empty(this._timer)) {
|
|
142
|
+
// Trigger immediately to catch up on any missed tasks
|
|
143
|
+
await this.triggerScheduledTasks();
|
|
144
|
+
// Set the timer to run at the specified interval
|
|
146
145
|
this._timer = setInterval(async () => this.triggerScheduledTasks(), this._tickInterval);
|
|
147
146
|
}
|
|
148
147
|
}
|
|
@@ -207,4 +206,4 @@ class TaskSchedulerComponent {
|
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
208
|
|
|
210
|
-
export {
|
|
209
|
+
export { TaskSchedulerService };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { IScheduledTaskInfo, IScheduledTaskTime, ITaskSchedulerComponent } from "@twin.org/background-task-models";
|
|
2
2
|
import type { ITaskSchedulerConstructorOptions } from "./models/ITaskSchedulerConstructorOptions";
|
|
3
3
|
/**
|
|
4
|
-
* Class for
|
|
4
|
+
* Class for scheduling tasks.
|
|
5
5
|
*/
|
|
6
|
-
export declare class
|
|
7
|
-
/**
|
|
8
|
-
* The namespace supported by the task scheduler.
|
|
9
|
-
*/
|
|
10
|
-
static readonly NAMESPACE: string;
|
|
6
|
+
export declare class TaskSchedulerService implements ITaskSchedulerComponent {
|
|
11
7
|
/**
|
|
12
8
|
* Runtime name for the class.
|
|
13
9
|
*/
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/background-task/compare/background-task-scheduler-v0.0.2-next.3...background-task-scheduler-v0.0.2-next.4) (2025-07-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* background tasks immediately trigger ([a0a847b](https://github.com/twinfoundation/background-task/commit/a0a847ba9686adcd0460e810540959f87dcaeab1))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/background-task-models bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
16
|
+
|
|
17
|
+
## [0.0.2-next.3](https://github.com/twinfoundation/background-task/compare/background-task-scheduler-v0.0.2-next.2...background-task-scheduler-v0.0.2-next.3) (2025-07-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* rename task scheduler component to service ([f097a98](https://github.com/twinfoundation/background-task/commit/f097a988c9ee0795aa55d74deda616365ec4ffb1))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/background-task-models bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
30
|
+
|
|
3
31
|
## [0.0.2-next.2](https://github.com/twinfoundation/background-task/compare/background-task-scheduler-v0.0.2-next.1...background-task-scheduler-v0.0.2-next.2) (2025-07-09)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Class:
|
|
1
|
+
# Class: TaskSchedulerService
|
|
2
2
|
|
|
3
|
-
Class for
|
|
3
|
+
Class for scheduling tasks.
|
|
4
4
|
|
|
5
5
|
## Implements
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ Class for performing task operations in entity storage.
|
|
|
10
10
|
|
|
11
11
|
### Constructor
|
|
12
12
|
|
|
13
|
-
> **new
|
|
13
|
+
> **new TaskSchedulerService**(`options?`): `TaskSchedulerService`
|
|
14
14
|
|
|
15
15
|
Create a new instance of TaskSchedulerComponent.
|
|
16
16
|
|
|
@@ -24,18 +24,10 @@ The options for the scheduler.
|
|
|
24
24
|
|
|
25
25
|
#### Returns
|
|
26
26
|
|
|
27
|
-
`
|
|
27
|
+
`TaskSchedulerService`
|
|
28
28
|
|
|
29
29
|
## Properties
|
|
30
30
|
|
|
31
|
-
### NAMESPACE
|
|
32
|
-
|
|
33
|
-
> `readonly` `static` **NAMESPACE**: `string` = `"task-scheduler"`
|
|
34
|
-
|
|
35
|
-
The namespace supported by the task scheduler.
|
|
36
|
-
|
|
37
|
-
***
|
|
38
|
-
|
|
39
31
|
### CLASS\_NAME
|
|
40
32
|
|
|
41
33
|
> `readonly` **CLASS\_NAME**: `string`
|
package/docs/reference/index.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/background-task-scheduler",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.4",
|
|
4
4
|
"description": "Background task scheduler",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/background-task-models": "0.0.2-next.
|
|
17
|
+
"@twin.org/background-task-models": "0.0.2-next.4",
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
19
|
"@twin.org/logging-models": "next",
|
|
20
20
|
"@twin.org/nameof": "next"
|