@enonic-types/lib-task 7.11.0-B1 → 7.11.0-B4
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 +11 -29
- package/package.json +4 -1
- package/task.d.ts +10 -8
package/README.md
CHANGED
|
@@ -5,38 +5,23 @@
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i --save-dev @enonic/lib-task
|
|
8
|
+
npm i --save-dev @enonic-types/lib-task
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Use
|
|
12
12
|
|
|
13
|
-
Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code.
|
|
14
|
-
|
|
15
|
-
`tsconfig.json`
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
{
|
|
19
|
-
"compilerOptions": {
|
|
20
|
-
"types": [
|
|
21
|
-
"@enonic-types/lib-task"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
13
|
### Require and custom imports
|
|
28
14
|
|
|
29
|
-
To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
-
objects, e.g. `log`, `app`, `__`, etc, requiring library by the default path will return typed object.
|
|
15
|
+
To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
16
|
+
global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
|
|
31
17
|
|
|
32
18
|
`tsconfig.json`
|
|
33
19
|
|
|
34
|
-
```
|
|
20
|
+
```json
|
|
35
21
|
{
|
|
36
22
|
"compilerOptions": {
|
|
37
23
|
"types": [
|
|
38
|
-
|
|
39
|
-
"@enonic-types/lib-task"
|
|
24
|
+
"@enonic-types/global"
|
|
40
25
|
]
|
|
41
26
|
}
|
|
42
27
|
}
|
|
@@ -49,7 +34,7 @@ const {submit, executeFunction, submitNamed, submitTask, list, get, sleep, progr
|
|
|
49
34
|
```
|
|
50
35
|
|
|
51
36
|
More detailed explanation on how it works and how to type custom import function can be
|
|
52
|
-
found [here](https://
|
|
37
|
+
found [here](https://developer.enonic.com/docs/xp/stable/api).
|
|
53
38
|
|
|
54
39
|
### ES6-style import
|
|
55
40
|
|
|
@@ -58,16 +43,13 @@ types mapping to your configuration.
|
|
|
58
43
|
|
|
59
44
|
`tsconfig.json`
|
|
60
45
|
|
|
61
|
-
```
|
|
46
|
+
```json
|
|
62
47
|
{
|
|
63
48
|
"compilerOptions": {
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
+ "paths": {
|
|
69
|
-
+ "/lib/xp/task": ["node_modules/@enonic-types/lib-task"],
|
|
70
|
-
+ }
|
|
49
|
+
"baseUrl": "./",
|
|
50
|
+
"paths": {
|
|
51
|
+
"/lib/xp/task": ["node_modules/@enonic-types/lib-task"]
|
|
52
|
+
}
|
|
71
53
|
}
|
|
72
54
|
}
|
|
73
55
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic-types/lib-task",
|
|
3
|
-
"version": "7.11.0-
|
|
3
|
+
"version": "7.11.0-B4",
|
|
4
4
|
"description": "Type definitions for lib-task.",
|
|
5
5
|
"types": "task.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"url": "https://github.com/enonic/xp/issues"
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@enonic-types/core": "7.11.0-B4"
|
|
31
|
+
},
|
|
29
32
|
"publishConfig": {
|
|
30
33
|
"access": "public"
|
|
31
34
|
}
|
package/task.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ declare global {
|
|
|
11
11
|
'/lib/xp/task': typeof import('./task');
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
import type { UserKey } from '@enonic-types/core';
|
|
15
|
+
export type { UserKey } from '@enonic-types/core';
|
|
14
16
|
export declare type CallbackFn = () => void;
|
|
15
17
|
export interface SubmitParams {
|
|
16
18
|
description: string;
|
|
@@ -23,7 +25,7 @@ export interface ExecuteFunctionParams {
|
|
|
23
25
|
/**
|
|
24
26
|
* @typedef TaskInfo
|
|
25
27
|
* @type Object
|
|
26
|
-
* @property {string} id Task
|
|
28
|
+
* @property {string} id Task ID.
|
|
27
29
|
* @property {string} name Task name.
|
|
28
30
|
* @property {string} description Task description.
|
|
29
31
|
* @property {string} state Task state. Possible values: 'WAITING' | 'RUNNING' | 'FINISHED' | 'FAILED'
|
|
@@ -65,9 +67,9 @@ export declare function submit(params: SubmitParams): string;
|
|
|
65
67
|
* @returns {string} Id of the task that will be executed.
|
|
66
68
|
*/
|
|
67
69
|
export declare function executeFunction(params: ExecuteFunctionParams): string;
|
|
68
|
-
export interface SubmitNamedTaskParams {
|
|
70
|
+
export interface SubmitNamedTaskParams<Config extends object = Record<string, unknown>> {
|
|
69
71
|
name: string;
|
|
70
|
-
config?:
|
|
72
|
+
config?: Config;
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
75
|
* @deprecated Please use {@link submitTask}.
|
|
@@ -84,10 +86,10 @@ export interface SubmitNamedTaskParams {
|
|
|
84
86
|
* The object must be valid according to the schema defined in the form of the task descriptor XML.
|
|
85
87
|
* @returns {string} Id of the task that will be executed.
|
|
86
88
|
*/
|
|
87
|
-
export declare function submitNamed(params: SubmitNamedTaskParams): string;
|
|
88
|
-
export interface SubmitTaskParams {
|
|
89
|
+
export declare function submitNamed<Config extends object = Record<string, unknown>>(params: SubmitNamedTaskParams<Config>): string;
|
|
90
|
+
export interface SubmitTaskParams<Config extends object = Record<string, unknown>> {
|
|
89
91
|
descriptor: string;
|
|
90
|
-
config?:
|
|
92
|
+
config?: Config;
|
|
91
93
|
}
|
|
92
94
|
/**
|
|
93
95
|
* Submits a task to be executed in the background and returns an id representing the task.
|
|
@@ -102,7 +104,7 @@ export interface SubmitTaskParams {
|
|
|
102
104
|
* The object must be valid according to the schema defined in the form of the task descriptor XML.
|
|
103
105
|
* @returns {string} Id of the task that will be executed.
|
|
104
106
|
*/
|
|
105
|
-
export declare function submitTask(params: SubmitTaskParams): string;
|
|
107
|
+
export declare function submitTask<Config extends object = Record<string, unknown>>(params: SubmitTaskParams<Config>): string;
|
|
106
108
|
export declare type TaskStateType = 'WAITING' | 'RUNNING' | 'FINISHED' | 'FAILED';
|
|
107
109
|
export interface ListTasksParams {
|
|
108
110
|
name?: string | null;
|
|
@@ -119,7 +121,7 @@ export interface TaskInfo {
|
|
|
119
121
|
name: string;
|
|
120
122
|
state: TaskStateType;
|
|
121
123
|
application: string;
|
|
122
|
-
user:
|
|
124
|
+
user: UserKey;
|
|
123
125
|
startTime: string;
|
|
124
126
|
progress: TaskProgress;
|
|
125
127
|
}
|