@twin.org/background-task-models 0.0.1-next.3 → 0.0.1-next.5

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.
@@ -1,5 +1,4 @@
1
1
  export * from "./factories/backgroundTaskConnectorFactory";
2
- export * from "./models/backgroundTaskHandler";
3
2
  export * from "./models/IBackgroundTask";
4
3
  export * from "./models/IBackgroundTaskConnector";
5
4
  export * from "./models/taskStatus";
@@ -1,6 +1,5 @@
1
1
  import type { IComponent } from "@twin.org/core";
2
2
  import type { SortDirection } from "@twin.org/entity";
3
- import type { BackgroundTaskHandler } from "./backgroundTaskHandler";
4
3
  import type { IBackgroundTask } from "./IBackgroundTask";
5
4
  import type { TaskStatus } from "./taskStatus";
6
5
  /**
@@ -10,10 +9,12 @@ export interface IBackgroundTaskConnector extends IComponent {
10
9
  /**
11
10
  * Register a handler for a task.
12
11
  * @param taskType The type of the task the handler can process.
13
- * @param handler The handler for the task.
12
+ * @param module The module the handler is in.
13
+ * @param method The method in the module to execute.
14
+ * @param stateChangeCallback The callback to execute when the task state is updated.
14
15
  * @returns Nothing.
15
16
  */
16
- registerHandler<T, U>(taskType: string, handler: BackgroundTaskHandler<T, U>): Promise<void>;
17
+ registerHandler<T, U>(taskType: string, module: string, method: string, stateChangeCallback?: (task: IBackgroundTask<T, U>) => Promise<void>): Promise<void>;
17
18
  /**
18
19
  * Unregister a handler for a task.
19
20
  * @param taskType The type of the task handler to remove.
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/background-task-models - Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## v0.0.1-next.5
4
4
 
5
5
  - Initial Release
@@ -7,7 +7,6 @@
7
7
 
8
8
  ## Type Aliases
9
9
 
10
- - [BackgroundTaskHandler](type-aliases/BackgroundTaskHandler.md)
11
10
  - [TaskStatus](type-aliases/TaskStatus.md)
12
11
 
13
12
  ## Variables
@@ -10,7 +10,7 @@ Interface describing a background task connector.
10
10
 
11
11
  ### registerHandler()
12
12
 
13
- > **registerHandler**\<`T`, `U`\>(`taskType`, `handler`): `Promise`\<`void`\>
13
+ > **registerHandler**\<`T`, `U`\>(`taskType`, `module`, `method`, `stateChangeCallback`?): `Promise`\<`void`\>
14
14
 
15
15
  Register a handler for a task.
16
16
 
@@ -26,9 +26,17 @@ Register a handler for a task.
26
26
 
27
27
  The type of the task the handler can process.
28
28
 
29
- • **handler**: [`BackgroundTaskHandler`](../type-aliases/BackgroundTaskHandler.md)\<`T`, `U`\>
29
+ • **module**: `string`
30
30
 
31
- The handler for the task.
31
+ The module the handler is in.
32
+
33
+ • **method**: `string`
34
+
35
+ The method in the module to execute.
36
+
37
+ • **stateChangeCallback?**
38
+
39
+ The callback to execute when the task state is updated.
32
40
 
33
41
  #### Returns
34
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/background-task-models",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "description": "Models which define the structure of the background task contracts and connectors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +0,0 @@
1
- /**
2
- * Interface describing a task handler, exceptions thrown in the handler will be caught.
3
- */
4
- export type BackgroundTaskHandler<T = any, U = any> = (payload: T) => Promise<U>;
@@ -1,19 +0,0 @@
1
- # Type Alias: BackgroundTaskHandler()\<T, U\>
2
-
3
- > **BackgroundTaskHandler**\<`T`, `U`\>: (`payload`) => `Promise`\<`U`\>
4
-
5
- Interface describing a task handler, exceptions thrown in the handler will be caught.
6
-
7
- ## Type Parameters
8
-
9
- • **T** = `any`
10
-
11
- • **U** = `any`
12
-
13
- ## Parameters
14
-
15
- • **payload**: `T`
16
-
17
- ## Returns
18
-
19
- `Promise`\<`U`\>