@webex/internal-plugin-scheduler 2.59.2 → 2.59.3-next.1
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/.eslintrc.js +6 -6
- package/LICENSE.md +1 -1
- package/README.md +44 -44
- package/babel.config.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/payloadTransformer/index.js.map +1 -1
- package/dist/payloadTransformer/predicates.js +28 -28
- package/dist/payloadTransformer/predicates.js.map +1 -1
- package/dist/payloadTransformer/transformers.js +21 -21
- package/dist/payloadTransformer/transformers.js.map +1 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/scheduler.config.js +5 -5
- package/dist/scheduler/scheduler.config.js.map +1 -1
- package/dist/scheduler/scheduler.constants.js.map +1 -1
- package/dist/scheduler/scheduler.js +42 -42
- package/dist/scheduler/scheduler.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +20 -19
- package/process +1 -1
- package/src/index.js +16 -16
- package/src/payloadTransformer/index.js +9 -9
- package/src/payloadTransformer/predicates.js +68 -68
- package/src/payloadTransformer/transformers.js +65 -65
- package/src/scheduler/index.js +7 -7
- package/src/scheduler/scheduler.config.js +17 -17
- package/src/scheduler/scheduler.constants.js +8 -8
- package/src/scheduler/scheduler.js +156 -156
- package/test/integration/spec/payloadTransformer/predicates.js +44 -44
- package/test/integration/spec/payloadTransformer/transformers.js +44 -44
- package/test/integration/spec/scheduler/scheduler.js +44 -44
- package/test/unit/spec/scheduler/scheduler.js +57 -57
package/src/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// Import all plugins used within this plugin here, as they are singletons
|
|
2
|
-
// and must be mounted prior to any other mounting logic within this plugin.
|
|
3
|
-
import '@webex/internal-plugin-encryption';
|
|
4
|
-
|
|
5
|
-
import {registerInternalPlugin} from '@webex/webex-core';
|
|
6
|
-
|
|
7
|
-
import Scheduler, {config, CONSTANTS} from './scheduler';
|
|
8
|
-
import payloadTransformer from './payloadTransformer';
|
|
9
|
-
|
|
10
|
-
// Mounts the plugin to `webex.internal.{NAMESPACE}` and begins initialization.
|
|
11
|
-
registerInternalPlugin(CONSTANTS.NAMESPACE, Scheduler, {
|
|
12
|
-
payloadTransformer,
|
|
13
|
-
config,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export default Scheduler;
|
|
1
|
+
// Import all plugins used within this plugin here, as they are singletons
|
|
2
|
+
// and must be mounted prior to any other mounting logic within this plugin.
|
|
3
|
+
import '@webex/internal-plugin-encryption';
|
|
4
|
+
|
|
5
|
+
import {registerInternalPlugin} from '@webex/webex-core';
|
|
6
|
+
|
|
7
|
+
import Scheduler, {config, CONSTANTS} from './scheduler';
|
|
8
|
+
import payloadTransformer from './payloadTransformer';
|
|
9
|
+
|
|
10
|
+
// Mounts the plugin to `webex.internal.{NAMESPACE}` and begins initialization.
|
|
11
|
+
registerInternalPlugin(CONSTANTS.NAMESPACE, Scheduler, {
|
|
12
|
+
payloadTransformer,
|
|
13
|
+
config,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default Scheduler;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import predicates from './predicates';
|
|
2
|
-
import transformers from './transformers';
|
|
3
|
-
|
|
4
|
-
const payloadTransformer = {
|
|
5
|
-
predicates: Object.values(predicates),
|
|
6
|
-
transforms: Object.values(transformers),
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default payloadTransformer;
|
|
1
|
+
import predicates from './predicates';
|
|
2
|
+
import transformers from './transformers';
|
|
3
|
+
|
|
4
|
+
const payloadTransformer = {
|
|
5
|
+
predicates: Object.values(predicates),
|
|
6
|
+
transforms: Object.values(transformers),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default payloadTransformer;
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Predicates are used to validate whether or not a transformer should be
|
|
3
|
-
* triggered, and with what data.
|
|
4
|
-
*/
|
|
5
|
-
const exampleGeneralPredicate = {
|
|
6
|
-
/**
|
|
7
|
-
* Name of the transformer to be called.
|
|
8
|
-
*
|
|
9
|
-
* A predicate will `test()` if the payload is valid for the transform, and
|
|
10
|
-
* then `extract()` the necessary data to be passed into the transformer.
|
|
11
|
-
*
|
|
12
|
-
* @type {string}
|
|
13
|
-
*/
|
|
14
|
-
name: 'exampleGeneralTransformer',
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Direction this predicate should process on. This allows for different
|
|
18
|
-
* predicates to be used for inbound and outbound transforms.
|
|
19
|
-
*
|
|
20
|
-
* @type {'inbound' | 'outbound' | undefined}
|
|
21
|
-
*/
|
|
22
|
-
direction: undefined,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Test is used to validate if the `extract()` method should be called to be
|
|
26
|
-
* processed by the associated `name` transformer.
|
|
27
|
-
*
|
|
28
|
-
* @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop
|
|
29
|
-
* @param {Object} data - Data from the event or request
|
|
30
|
-
* @returns {boolean} - Whether to process the `extract()` method.
|
|
31
|
-
*/
|
|
32
|
-
test: (ctx, data) => Promise.resolve(!!data.value),
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Extract a given set of data from a request or event to be processed by the
|
|
36
|
-
* associated `name` transform.
|
|
37
|
-
*
|
|
38
|
-
* @param {Object} data - Data from the event or request
|
|
39
|
-
* @returns {any} - Data to send to the named transform.
|
|
40
|
-
*/
|
|
41
|
-
extract: (data) => Promise.resolve(data.value),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// NOTE - additional predicate examples [start]
|
|
45
|
-
|
|
46
|
-
const exampleInboundPredicate = {
|
|
47
|
-
name: 'exampleInboundTransformer',
|
|
48
|
-
direction: 'inbound',
|
|
49
|
-
test: (ctx, data) => Promise.resolve(!!data.inboundValue),
|
|
50
|
-
extract: (data) => Promise.resolve(data.inboundValue),
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const exampleOutboundPredicate = {
|
|
54
|
-
name: 'exampleOutboundTransformer',
|
|
55
|
-
direction: 'outbound',
|
|
56
|
-
test: (ctx, data) => Promise.resolve(!!data.outboundValue),
|
|
57
|
-
extract: (data) => Promise.resolve(data.outboundValue),
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// NOTE - additional predicate examples [end]
|
|
61
|
-
|
|
62
|
-
const predicates = {
|
|
63
|
-
exampleGeneralPredicate,
|
|
64
|
-
exampleInboundPredicate,
|
|
65
|
-
exampleOutboundPredicate,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default predicates;
|
|
1
|
+
/**
|
|
2
|
+
* Predicates are used to validate whether or not a transformer should be
|
|
3
|
+
* triggered, and with what data.
|
|
4
|
+
*/
|
|
5
|
+
const exampleGeneralPredicate = {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the transformer to be called.
|
|
8
|
+
*
|
|
9
|
+
* A predicate will `test()` if the payload is valid for the transform, and
|
|
10
|
+
* then `extract()` the necessary data to be passed into the transformer.
|
|
11
|
+
*
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
name: 'exampleGeneralTransformer',
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Direction this predicate should process on. This allows for different
|
|
18
|
+
* predicates to be used for inbound and outbound transforms.
|
|
19
|
+
*
|
|
20
|
+
* @type {'inbound' | 'outbound' | undefined}
|
|
21
|
+
*/
|
|
22
|
+
direction: undefined,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Test is used to validate if the `extract()` method should be called to be
|
|
26
|
+
* processed by the associated `name` transformer.
|
|
27
|
+
*
|
|
28
|
+
* @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop
|
|
29
|
+
* @param {Object} data - Data from the event or request
|
|
30
|
+
* @returns {boolean} - Whether to process the `extract()` method.
|
|
31
|
+
*/
|
|
32
|
+
test: (ctx, data) => Promise.resolve(!!data.value),
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Extract a given set of data from a request or event to be processed by the
|
|
36
|
+
* associated `name` transform.
|
|
37
|
+
*
|
|
38
|
+
* @param {Object} data - Data from the event or request
|
|
39
|
+
* @returns {any} - Data to send to the named transform.
|
|
40
|
+
*/
|
|
41
|
+
extract: (data) => Promise.resolve(data.value),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// NOTE - additional predicate examples [start]
|
|
45
|
+
|
|
46
|
+
const exampleInboundPredicate = {
|
|
47
|
+
name: 'exampleInboundTransformer',
|
|
48
|
+
direction: 'inbound',
|
|
49
|
+
test: (ctx, data) => Promise.resolve(!!data.inboundValue),
|
|
50
|
+
extract: (data) => Promise.resolve(data.inboundValue),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const exampleOutboundPredicate = {
|
|
54
|
+
name: 'exampleOutboundTransformer',
|
|
55
|
+
direction: 'outbound',
|
|
56
|
+
test: (ctx, data) => Promise.resolve(!!data.outboundValue),
|
|
57
|
+
extract: (data) => Promise.resolve(data.outboundValue),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// NOTE - additional predicate examples [end]
|
|
61
|
+
|
|
62
|
+
const predicates = {
|
|
63
|
+
exampleGeneralPredicate,
|
|
64
|
+
exampleInboundPredicate,
|
|
65
|
+
exampleOutboundPredicate,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default predicates;
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transformers are used to process data from requests and events, performing
|
|
3
|
-
* actions prior to the resolution of a `request` or `event` within the calling
|
|
4
|
-
* stack.
|
|
5
|
-
*/
|
|
6
|
-
const exampleGeneralTransformer = {
|
|
7
|
-
/**
|
|
8
|
-
* Name of this transformer.
|
|
9
|
-
*
|
|
10
|
-
* The usage of this transformer can be validated via a predicate. See the
|
|
11
|
-
* `predicates.js` file for more details.
|
|
12
|
-
*
|
|
13
|
-
* @type {string}
|
|
14
|
-
*/
|
|
15
|
-
name: 'exampleGeneralTransformer',
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Direction this transformer should process on. This allows for different
|
|
19
|
-
* directions to be handled differently when sending/receiving data.
|
|
20
|
-
*
|
|
21
|
-
* @type {'inbound' | 'outbound' | undefined}
|
|
22
|
-
*/
|
|
23
|
-
direction: undefined,
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The main transformation function
|
|
27
|
-
* @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop.
|
|
28
|
-
* @param {any} data - Data from the event or request.
|
|
29
|
-
* @returns {Promise<any>} - Data after transformation.
|
|
30
|
-
*/
|
|
31
|
-
fn: (ctx, data) =>
|
|
32
|
-
ctx
|
|
33
|
-
.transform('exampleInboundTransformer', ctx, data)
|
|
34
|
-
.then((transformed) => ctx.webex.internal.encryption.example(transformed)),
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// NOTE - additional predicate examples [start]
|
|
38
|
-
|
|
39
|
-
const exampleInboundTransformer = {
|
|
40
|
-
name: 'exampleInboundTransformer',
|
|
41
|
-
direction: 'inbound',
|
|
42
|
-
fn: (ctx, data) =>
|
|
43
|
-
ctx
|
|
44
|
-
.transform('exampleGeneralTransformer', ctx, data)
|
|
45
|
-
.then((transformed) => ctx.webex.internal.encryption.example(transformed)),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const exampleOutboundTransformer = {
|
|
49
|
-
name: 'exampleOutboundTransformer',
|
|
50
|
-
direction: 'outbound',
|
|
51
|
-
fn: (ctx, data) =>
|
|
52
|
-
ctx
|
|
53
|
-
.transform('exampleGeneralTransformer', ctx, data)
|
|
54
|
-
.then((transformed) => ctx.webex.internal.encryption.example(transformed)),
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// NOTE - additional predicate examples [end]
|
|
58
|
-
|
|
59
|
-
const transformers = {
|
|
60
|
-
exampleGeneralTransformer,
|
|
61
|
-
exampleInboundTransformer,
|
|
62
|
-
exampleOutboundTransformer,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default transformers;
|
|
1
|
+
/**
|
|
2
|
+
* Transformers are used to process data from requests and events, performing
|
|
3
|
+
* actions prior to the resolution of a `request` or `event` within the calling
|
|
4
|
+
* stack.
|
|
5
|
+
*/
|
|
6
|
+
const exampleGeneralTransformer = {
|
|
7
|
+
/**
|
|
8
|
+
* Name of this transformer.
|
|
9
|
+
*
|
|
10
|
+
* The usage of this transformer can be validated via a predicate. See the
|
|
11
|
+
* `predicates.js` file for more details.
|
|
12
|
+
*
|
|
13
|
+
* @type {string}
|
|
14
|
+
*/
|
|
15
|
+
name: 'exampleGeneralTransformer',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Direction this transformer should process on. This allows for different
|
|
19
|
+
* directions to be handled differently when sending/receiving data.
|
|
20
|
+
*
|
|
21
|
+
* @type {'inbound' | 'outbound' | undefined}
|
|
22
|
+
*/
|
|
23
|
+
direction: undefined,
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The main transformation function
|
|
27
|
+
* @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop.
|
|
28
|
+
* @param {any} data - Data from the event or request.
|
|
29
|
+
* @returns {Promise<any>} - Data after transformation.
|
|
30
|
+
*/
|
|
31
|
+
fn: (ctx, data) =>
|
|
32
|
+
ctx
|
|
33
|
+
.transform('exampleInboundTransformer', ctx, data)
|
|
34
|
+
.then((transformed) => ctx.webex.internal.encryption.example(transformed)),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// NOTE - additional predicate examples [start]
|
|
38
|
+
|
|
39
|
+
const exampleInboundTransformer = {
|
|
40
|
+
name: 'exampleInboundTransformer',
|
|
41
|
+
direction: 'inbound',
|
|
42
|
+
fn: (ctx, data) =>
|
|
43
|
+
ctx
|
|
44
|
+
.transform('exampleGeneralTransformer', ctx, data)
|
|
45
|
+
.then((transformed) => ctx.webex.internal.encryption.example(transformed)),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const exampleOutboundTransformer = {
|
|
49
|
+
name: 'exampleOutboundTransformer',
|
|
50
|
+
direction: 'outbound',
|
|
51
|
+
fn: (ctx, data) =>
|
|
52
|
+
ctx
|
|
53
|
+
.transform('exampleGeneralTransformer', ctx, data)
|
|
54
|
+
.then((transformed) => ctx.webex.internal.encryption.example(transformed)),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// NOTE - additional predicate examples [end]
|
|
58
|
+
|
|
59
|
+
const transformers = {
|
|
60
|
+
exampleGeneralTransformer,
|
|
61
|
+
exampleInboundTransformer,
|
|
62
|
+
exampleOutboundTransformer,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default transformers;
|
package/src/scheduler/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Scheduler from './scheduler';
|
|
2
|
-
import config from './scheduler.config';
|
|
3
|
-
import CONSTANTS from './scheduler.constants';
|
|
4
|
-
|
|
5
|
-
export {config, CONSTANTS};
|
|
6
|
-
|
|
7
|
-
export default Scheduler;
|
|
1
|
+
import Scheduler from './scheduler';
|
|
2
|
+
import config from './scheduler.config';
|
|
3
|
+
import CONSTANTS from './scheduler.constants';
|
|
4
|
+
|
|
5
|
+
export {config, CONSTANTS};
|
|
6
|
+
|
|
7
|
+
export default Scheduler;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The configuration object for this plugin.
|
|
3
|
-
*
|
|
4
|
-
* Each of the values can be retreived from `this.webex.config.scheduler.{property}.
|
|
5
|
-
* When these properties mount/update, `this.webex` object emits `change:config`.
|
|
6
|
-
*/
|
|
7
|
-
const config = {
|
|
8
|
-
scheduler: {
|
|
9
|
-
configurationBoolean: true,
|
|
10
|
-
configurationString: 'hello',
|
|
11
|
-
configurationNumber: 1234,
|
|
12
|
-
configurationArray: [1, 2, 3, 4],
|
|
13
|
-
configurationObject: {a: 1, b: 2, c: 3},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default config;
|
|
1
|
+
/**
|
|
2
|
+
* The configuration object for this plugin.
|
|
3
|
+
*
|
|
4
|
+
* Each of the values can be retreived from `this.webex.config.scheduler.{property}.
|
|
5
|
+
* When these properties mount/update, `this.webex` object emits `change:config`.
|
|
6
|
+
*/
|
|
7
|
+
const config = {
|
|
8
|
+
scheduler: {
|
|
9
|
+
configurationBoolean: true,
|
|
10
|
+
configurationString: 'hello',
|
|
11
|
+
configurationNumber: 1234,
|
|
12
|
+
configurationArray: [1, 2, 3, 4],
|
|
13
|
+
configurationObject: {a: 1, b: 2, c: 3},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default config;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// Namespace to store this plugin under within `webex` or `webex.internal`.
|
|
2
|
-
const NAMESPACE = 'scheduler';
|
|
3
|
-
|
|
4
|
-
const CONSTANTS = {
|
|
5
|
-
NAMESPACE,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default CONSTANTS;
|
|
1
|
+
// Namespace to store this plugin under within `webex` or `webex.internal`.
|
|
2
|
+
const NAMESPACE = 'scheduler';
|
|
3
|
+
|
|
4
|
+
const CONSTANTS = {
|
|
5
|
+
NAMESPACE,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default CONSTANTS;
|