@twin.org/background-task-models 0.0.1-next.18 → 0.0.1-next.19
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/types/index.d.ts +3 -0
- package/dist/types/models/IScheduledTaskInfo.d.ts +12 -0
- package/dist/types/models/IScheduledTaskTime.d.ts +21 -0
- package/dist/types/models/ITaskSchedulerComponent.d.ts +27 -0
- package/docs/changelog.md +7 -0
- package/docs/reference/index.md +3 -0
- package/docs/reference/interfaces/IScheduledTaskInfo.md +15 -0
- package/docs/reference/interfaces/IScheduledTaskTime.md +35 -0
- package/docs/reference/interfaces/ITaskSchedulerComponent.md +77 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from "./factories/backgroundTaskConnectorFactory";
|
|
2
2
|
export * from "./models/IBackgroundTask";
|
|
3
3
|
export * from "./models/IBackgroundTaskConnector";
|
|
4
|
+
export * from "./models/IScheduledTaskInfo";
|
|
5
|
+
export * from "./models/IScheduledTaskTime";
|
|
6
|
+
export * from "./models/ITaskSchedulerComponent";
|
|
4
7
|
export * from "./models/taskStatus";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IScheduledTaskTime } from "./IScheduledTaskTime";
|
|
2
|
+
/**
|
|
3
|
+
* Interface describing a scheduled task information.
|
|
4
|
+
*/
|
|
5
|
+
export interface IScheduledTaskInfo {
|
|
6
|
+
/**
|
|
7
|
+
* The information for the tasks.
|
|
8
|
+
*/
|
|
9
|
+
tasks: {
|
|
10
|
+
[id: string]: IScheduledTaskTime[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface describing a scheduled task time.
|
|
3
|
+
*/
|
|
4
|
+
export interface IScheduledTaskTime {
|
|
5
|
+
/**
|
|
6
|
+
* The date/time to start the task, if not provided defaults to first interval from now.
|
|
7
|
+
*/
|
|
8
|
+
nextTriggerTime?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The interval in days to repeat the task, if no intervals are set the task will not repeat.
|
|
11
|
+
*/
|
|
12
|
+
intervalDays?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The interval in hours to repeat the task, if no intervals are set the task will not repeat.
|
|
15
|
+
*/
|
|
16
|
+
intervalHours?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The interval in minutes to repeat the task, if no intervals are set the task will not repeat.
|
|
19
|
+
*/
|
|
20
|
+
intervalMinutes?: number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IScheduledTaskInfo } from "./IScheduledTaskInfo";
|
|
3
|
+
import type { IScheduledTaskTime } from "./IScheduledTaskTime";
|
|
4
|
+
/**
|
|
5
|
+
* Interface describing a task scheduler.
|
|
6
|
+
*/
|
|
7
|
+
export interface ITaskSchedulerComponent extends IComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Add a task to the scheduler.
|
|
10
|
+
* @param taskId The id of the task to add.
|
|
11
|
+
* @param times The times at which the task should be scheduled.
|
|
12
|
+
* @param taskCallback The callback to execute when the task is scheduled.
|
|
13
|
+
* @returns Nothing.
|
|
14
|
+
*/
|
|
15
|
+
addTask(taskId: string, times: IScheduledTaskTime[], taskCallback: () => Promise<void>): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Remove a task from the scheduler.
|
|
18
|
+
* @param taskId The id of the task to remove.
|
|
19
|
+
* @returns Nothing.
|
|
20
|
+
*/
|
|
21
|
+
removeTask(taskId: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the information about the tasks.
|
|
24
|
+
* @returns The tasks information.
|
|
25
|
+
*/
|
|
26
|
+
tasksInfo(): Promise<IScheduledTaskInfo>;
|
|
27
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @twin.org/background-task-models - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.19](https://github.com/twinfoundation/background-task/compare/background-task-models-v0.0.1-next.18...background-task-models-v0.0.1-next.19) (2025-06-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add task scheduler ([754d973](https://github.com/twinfoundation/background-task/commit/754d973e7c8483e5e54e887c157661867d5a0375))
|
|
9
|
+
|
|
3
10
|
## [0.0.1-next.18](https://github.com/twinfoundation/background-task/compare/background-task-models-v0.0.1-next.17...background-task-models-v0.0.1-next.18) (2025-06-19)
|
|
4
11
|
|
|
5
12
|
|
package/docs/reference/index.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
- [IBackgroundTask](interfaces/IBackgroundTask.md)
|
|
6
6
|
- [IBackgroundTaskConnector](interfaces/IBackgroundTaskConnector.md)
|
|
7
|
+
- [IScheduledTaskInfo](interfaces/IScheduledTaskInfo.md)
|
|
8
|
+
- [IScheduledTaskTime](interfaces/IScheduledTaskTime.md)
|
|
9
|
+
- [ITaskSchedulerComponent](interfaces/ITaskSchedulerComponent.md)
|
|
7
10
|
|
|
8
11
|
## Type Aliases
|
|
9
12
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Interface: IScheduledTaskInfo
|
|
2
|
+
|
|
3
|
+
Interface describing a scheduled task information.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### tasks
|
|
8
|
+
|
|
9
|
+
> **tasks**: `object`
|
|
10
|
+
|
|
11
|
+
The information for the tasks.
|
|
12
|
+
|
|
13
|
+
#### Index Signature
|
|
14
|
+
|
|
15
|
+
\[`id`: `string`\]: [`IScheduledTaskTime`](IScheduledTaskTime.md)[]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Interface: IScheduledTaskTime
|
|
2
|
+
|
|
3
|
+
Interface describing a scheduled task time.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### nextTriggerTime?
|
|
8
|
+
|
|
9
|
+
> `optional` **nextTriggerTime**: `number`
|
|
10
|
+
|
|
11
|
+
The date/time to start the task, if not provided defaults to first interval from now.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### intervalDays?
|
|
16
|
+
|
|
17
|
+
> `optional` **intervalDays**: `number`
|
|
18
|
+
|
|
19
|
+
The interval in days to repeat the task, if no intervals are set the task will not repeat.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### intervalHours?
|
|
24
|
+
|
|
25
|
+
> `optional` **intervalHours**: `number`
|
|
26
|
+
|
|
27
|
+
The interval in hours to repeat the task, if no intervals are set the task will not repeat.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### intervalMinutes?
|
|
32
|
+
|
|
33
|
+
> `optional` **intervalMinutes**: `number`
|
|
34
|
+
|
|
35
|
+
The interval in minutes to repeat the task, if no intervals are set the task will not repeat.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Interface: ITaskSchedulerComponent
|
|
2
|
+
|
|
3
|
+
Interface describing a task scheduler.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### addTask()
|
|
12
|
+
|
|
13
|
+
> **addTask**(`taskId`, `times`, `taskCallback`): `Promise`\<`void`\>
|
|
14
|
+
|
|
15
|
+
Add a task to the scheduler.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### taskId
|
|
20
|
+
|
|
21
|
+
`string`
|
|
22
|
+
|
|
23
|
+
The id of the task to add.
|
|
24
|
+
|
|
25
|
+
##### times
|
|
26
|
+
|
|
27
|
+
[`IScheduledTaskTime`](IScheduledTaskTime.md)[]
|
|
28
|
+
|
|
29
|
+
The times at which the task should be scheduled.
|
|
30
|
+
|
|
31
|
+
##### taskCallback
|
|
32
|
+
|
|
33
|
+
() => `Promise`\<`void`\>
|
|
34
|
+
|
|
35
|
+
The callback to execute when the task is scheduled.
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
`Promise`\<`void`\>
|
|
40
|
+
|
|
41
|
+
Nothing.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### removeTask()
|
|
46
|
+
|
|
47
|
+
> **removeTask**(`taskId`): `Promise`\<`void`\>
|
|
48
|
+
|
|
49
|
+
Remove a task from the scheduler.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
##### taskId
|
|
54
|
+
|
|
55
|
+
`string`
|
|
56
|
+
|
|
57
|
+
The id of the task to remove.
|
|
58
|
+
|
|
59
|
+
#### Returns
|
|
60
|
+
|
|
61
|
+
`Promise`\<`void`\>
|
|
62
|
+
|
|
63
|
+
Nothing.
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### tasksInfo()
|
|
68
|
+
|
|
69
|
+
> **tasksInfo**(): `Promise`\<[`IScheduledTaskInfo`](IScheduledTaskInfo.md)\>
|
|
70
|
+
|
|
71
|
+
Get the information about the tasks.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`Promise`\<[`IScheduledTaskInfo`](IScheduledTaskInfo.md)\>
|
|
76
|
+
|
|
77
|
+
The tasks information.
|
package/package.json
CHANGED