@enonic-types/lib-scheduler 0.1.1 → 7.11.0-B3
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 +13 -4
- package/package.json +35 -32
- package/scheduler.d.ts +113 -115
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# Enonic XP lib-scheduler TS types
|
|
2
2
|
|
|
3
3
|
> TypeScript definitions for `lib-scheduler` library of Enonic XP
|
|
4
|
+
|
|
4
5
|
## Install
|
|
5
6
|
|
|
6
7
|
```bash
|
|
7
|
-
npm i --save-dev @enonic/lib-scheduler
|
|
8
|
+
npm i --save-dev @enonic-types/lib-scheduler
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
## Use
|
|
@@ -12,6 +13,7 @@ npm i --save-dev @enonic/lib-scheduler
|
|
|
12
13
|
Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code.
|
|
13
14
|
|
|
14
15
|
`tsconfig.json`
|
|
16
|
+
|
|
15
17
|
```json
|
|
16
18
|
{
|
|
17
19
|
"compilerOptions": {
|
|
@@ -24,9 +26,11 @@ Add the corresponding types to your `tsconfig.json` file that is used for applic
|
|
|
24
26
|
|
|
25
27
|
### Require and custom imports
|
|
26
28
|
|
|
27
|
-
To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
29
|
+
To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
+
global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
|
|
28
31
|
|
|
29
32
|
`tsconfig.json`
|
|
33
|
+
|
|
30
34
|
```diff
|
|
31
35
|
{
|
|
32
36
|
"compilerOptions": {
|
|
@@ -39,17 +43,21 @@ To make `require` work out of box, you must install and add the `@enonic-types/g
|
|
|
39
43
|
```
|
|
40
44
|
|
|
41
45
|
`example.ts`
|
|
46
|
+
|
|
42
47
|
```ts
|
|
43
48
|
const {create, modify} = require('/lib/xp/scheduler');
|
|
44
49
|
```
|
|
45
50
|
|
|
46
|
-
More detailed explanation on how it works and how to type custom import function can be
|
|
51
|
+
More detailed explanation on how it works and how to type custom import function can be
|
|
52
|
+
found [here](https://developer.enonic.com/docs/xp/stable/api).
|
|
47
53
|
|
|
48
54
|
### ES6-style import
|
|
49
55
|
|
|
50
|
-
If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper
|
|
56
|
+
If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper
|
|
57
|
+
types mapping to your configuration.
|
|
51
58
|
|
|
52
59
|
`tsconfig.json`
|
|
60
|
+
|
|
53
61
|
```diff
|
|
54
62
|
{
|
|
55
63
|
"compilerOptions": {
|
|
@@ -65,6 +73,7 @@ If you are planning to use `import` in your code and transpile it with the defau
|
|
|
65
73
|
```
|
|
66
74
|
|
|
67
75
|
`example.ts`
|
|
76
|
+
|
|
68
77
|
```ts
|
|
69
78
|
import {create, modify} from '/lib/xp/scheduler';
|
|
70
79
|
```
|
package/package.json
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@enonic-types/lib-scheduler",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Type definitions for lib-scheduler.",
|
|
5
|
-
"types": "scheduler.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"scheduler.d.ts"
|
|
8
|
-
],
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"enonic",
|
|
15
|
-
"enonic-xp",
|
|
16
|
-
"lib-scheduler",
|
|
17
|
-
"scheduler",
|
|
18
|
-
"types",
|
|
19
|
-
"typescript"
|
|
20
|
-
],
|
|
21
|
-
"contributors": [
|
|
22
|
-
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
-
],
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
}
|
|
32
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@enonic-types/lib-scheduler",
|
|
3
|
+
"version": "7.11.0-B3",
|
|
4
|
+
"description": "Type definitions for lib-scheduler.",
|
|
5
|
+
"types": "scheduler.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"scheduler.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"enonic",
|
|
15
|
+
"enonic-xp",
|
|
16
|
+
"lib-scheduler",
|
|
17
|
+
"scheduler",
|
|
18
|
+
"types",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"contributors": [
|
|
22
|
+
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
+
],
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@enonic-types/core": "7.11.0-B3"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/scheduler.d.ts
CHANGED
|
@@ -1,115 +1,113 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scheduler functions.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* var schedulerLib = require('/lib/xp/scheduler');
|
|
6
|
-
*
|
|
7
|
-
* @module scheduler
|
|
8
|
-
*/
|
|
9
|
-
declare global {
|
|
10
|
-
interface XpLibraries {
|
|
11
|
-
'/lib/xp/scheduler': typeof import('./scheduler');
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
export interface
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
56
|
-
*
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {string} params.
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {string} params.schedule.
|
|
64
|
-
* @param {string} params.
|
|
65
|
-
* @param {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
78
|
-
*
|
|
79
|
-
* @param {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
104
|
-
*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*/
|
|
115
|
-
export declare function list(): ScheduleJob[];
|
|
1
|
+
/**
|
|
2
|
+
* Scheduler functions.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* var schedulerLib = require('/lib/xp/scheduler');
|
|
6
|
+
*
|
|
7
|
+
* @module scheduler
|
|
8
|
+
*/
|
|
9
|
+
declare global {
|
|
10
|
+
interface XpLibraries {
|
|
11
|
+
'/lib/xp/scheduler': typeof import('./scheduler');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
import type { UserKey } from '@enonic-types/core';
|
|
15
|
+
export type { PrincipalKey, UserKey, GroupKey, RoleKey } from '@enonic-types/core';
|
|
16
|
+
export declare type EditorFn<T> = (value: T) => T;
|
|
17
|
+
export interface CreateScheduledJobParams<Config extends object = Record<string, unknown>> {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
descriptor: string;
|
|
21
|
+
config?: Config;
|
|
22
|
+
schedule: OneTimeSchedule | CronSchedule;
|
|
23
|
+
user?: UserKey;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface OneTimeSchedule {
|
|
27
|
+
type: 'ONE_TIME';
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CronSchedule {
|
|
31
|
+
type: 'CRON';
|
|
32
|
+
value: string;
|
|
33
|
+
timeZone: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ScheduledJob<Config extends object = Record<string, unknown>> {
|
|
36
|
+
name: string;
|
|
37
|
+
descriptor: string;
|
|
38
|
+
description?: string | null;
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
config?: Config | null;
|
|
41
|
+
user?: UserKey | null;
|
|
42
|
+
creator: UserKey;
|
|
43
|
+
modifier: UserKey;
|
|
44
|
+
createdTime: string;
|
|
45
|
+
modifiedTime: string;
|
|
46
|
+
lastRun?: string | null;
|
|
47
|
+
lastTaskId?: string | null;
|
|
48
|
+
schedule: OneTimeSchedule | CronSchedule;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a job to be scheduled.
|
|
52
|
+
*
|
|
53
|
+
* @example-ref examples/scheduler/create.js
|
|
54
|
+
*
|
|
55
|
+
* @param {object} params JSON with the parameters.
|
|
56
|
+
* @param {string} params.name unique job name.
|
|
57
|
+
* @param {string} [params.description] job description.
|
|
58
|
+
* @param {string} params.descriptor descriptor of the task to be scheduled.
|
|
59
|
+
* @param {object} [params.config] config of the task to be scheduled.
|
|
60
|
+
* @param {object} params.schedule task time run config.
|
|
61
|
+
* @param {string} params.schedule.value schedule value according to its type.
|
|
62
|
+
* @param {string} params.schedule.type schedule type (CRON | ONE_TIME).
|
|
63
|
+
* @param {string} params.schedule.timezone time zone of cron scheduling.
|
|
64
|
+
* @param {string} [params.user] key of the user that submitted the task.
|
|
65
|
+
* @param {boolean} params.enabled job is active or not.
|
|
66
|
+
*/
|
|
67
|
+
export declare function create<Config extends object = Record<string, unknown>>(params: CreateScheduledJobParams<Config>): ScheduledJob<Config>;
|
|
68
|
+
export interface ModifyScheduledJobParams<Config extends object = Record<string, unknown>> {
|
|
69
|
+
name: string;
|
|
70
|
+
editor: EditorFn<ScheduledJob<Config>>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Modifies scheduled job.
|
|
74
|
+
*
|
|
75
|
+
* @example-ref examples/scheduler/modify.js
|
|
76
|
+
*
|
|
77
|
+
* @param {object} params JSON with the parameters.
|
|
78
|
+
* @param {string} params.name unique job name.
|
|
79
|
+
* @param {function} params.editor editor callback function, has editable existing job as a param.
|
|
80
|
+
*/
|
|
81
|
+
export declare function modify<Config extends object = Record<string, unknown>>(params: ModifyScheduledJobParams<Config>): ScheduledJob<Config>;
|
|
82
|
+
export interface DeleteScheduledJobParams {
|
|
83
|
+
name: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Removes scheduled job.
|
|
87
|
+
*
|
|
88
|
+
* @example-ref examples/scheduler/delete.js
|
|
89
|
+
*
|
|
90
|
+
* @param {object} params JSON with the parameters.
|
|
91
|
+
* @param {string} params.name job to be deleted name.
|
|
92
|
+
*/
|
|
93
|
+
declare function _delete(params: DeleteScheduledJobParams): boolean;
|
|
94
|
+
export { _delete as delete, };
|
|
95
|
+
export interface GetScheduledJobParams {
|
|
96
|
+
name: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fetches scheduled job.
|
|
100
|
+
*
|
|
101
|
+
* @example-ref examples/scheduler/get.js
|
|
102
|
+
*
|
|
103
|
+
* @param {object} params JSON with the parameters.
|
|
104
|
+
* @param {string} params.name job to be fetched name.
|
|
105
|
+
*/
|
|
106
|
+
export declare function get<Config extends object = Record<string, unknown>>(params: GetScheduledJobParams): ScheduledJob<Config> | null;
|
|
107
|
+
/**
|
|
108
|
+
* Lists scheduled jobs.
|
|
109
|
+
*
|
|
110
|
+
* @example-ref examples/scheduler/list.js
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
export declare function list<Config extends object = Record<string, unknown>>(): ScheduledJob<Config>[];
|