@webex/internal-plugin-scheduler 2.41.0
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/LICENSE.md +2 -0
- package/README.md +44 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/payloadTransformer/index.js +18 -0
- package/dist/payloadTransformer/index.js.map +1 -0
- package/dist/payloadTransformer/predicates.js +86 -0
- package/dist/payloadTransformer/predicates.js.map +1 -0
- package/dist/payloadTransformer/transformers.js +73 -0
- package/dist/payloadTransformer/transformers.js.map +1 -0
- package/dist/scheduler/index.js +26 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/scheduler.config.js +29 -0
- package/dist/scheduler/scheduler.config.js.map +1 -0
- package/dist/scheduler/scheduler.constants.js +15 -0
- package/dist/scheduler/scheduler.constants.js.map +1 -0
- package/dist/scheduler/scheduler.js +196 -0
- package/dist/scheduler/scheduler.js.map +1 -0
- package/package.json +43 -0
- package/src/index.js +16 -0
- package/src/payloadTransformer/index.js +9 -0
- package/src/payloadTransformer/predicates.js +68 -0
- package/src/payloadTransformer/transformers.js +65 -0
- package/src/scheduler/index.js +7 -0
- package/src/scheduler/scheduler.config.js +17 -0
- package/src/scheduler/scheduler.constants.js +8 -0
- package/src/scheduler/scheduler.js +156 -0
- package/test/integration/spec/payloadTransformer/predicates.js +44 -0
- package/test/integration/spec/payloadTransformer/transformers.js +44 -0
- package/test/integration/spec/scheduler/scheduler.js +44 -0
- package/test/unit/spec/scheduler/scheduler.js +57 -0
package/LICENSE.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @webex/internal-plugin-scheduler
|
|
2
|
+
|
|
3
|
+
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
+
|
|
5
|
+
> Plugin for scheduler management
|
|
6
|
+
|
|
7
|
+
This is an internal Cisco Webex plugin. As such, it does not strictly adhere to semantic versioning. Use at your own risk. If you're not working on one of our first party clients, please look at our [developer api](https://developer.webex.com/) and stick to our public plugins.
|
|
8
|
+
|
|
9
|
+
- [Install](#install)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Maintainers](#maintainers)
|
|
12
|
+
- [Contribute](#contribute)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save @webex/internal-plugin-scheduler
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import '@webex/internal-plugin-scheduler';
|
|
25
|
+
|
|
26
|
+
import WebexCore from '@webex/webex-core';
|
|
27
|
+
|
|
28
|
+
const webex = new WebexCore();
|
|
29
|
+
|
|
30
|
+
// Namespace.
|
|
31
|
+
webex.internal.scheduler;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Maintainers
|
|
35
|
+
|
|
36
|
+
This package is maintained by {...}.
|
|
37
|
+
|
|
38
|
+
## Contribute
|
|
39
|
+
|
|
40
|
+
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
© 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
+
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
8
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
require("@webex/internal-plugin-encryption");
|
|
13
|
+
var _webexCore = require("@webex/webex-core");
|
|
14
|
+
var _scheduler = _interopRequireWildcard(require("./scheduler"));
|
|
15
|
+
var _payloadTransformer = _interopRequireDefault(require("./payloadTransformer"));
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
+
// Import all plugins used within this plugin here, as they are singletons
|
|
19
|
+
// and must be mounted prior to any other mounting logic within this plugin.
|
|
20
|
+
|
|
21
|
+
// Mounts the plugin to `webex.internal.{NAMESPACE}` and begins initialization.
|
|
22
|
+
(0, _webexCore.registerInternalPlugin)(_scheduler.CONSTANTS.NAMESPACE, _scheduler.default, {
|
|
23
|
+
payloadTransformer: _payloadTransformer.default,
|
|
24
|
+
config: _scheduler.config
|
|
25
|
+
});
|
|
26
|
+
var _default = _scheduler.default;
|
|
27
|
+
exports.default = _default;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["registerInternalPlugin","CONSTANTS","NAMESPACE","Scheduler","payloadTransformer","config"],"sources":["index.js"],"sourcesContent":["// Import all plugins used within this plugin here, as they are singletons\n// and must be mounted prior to any other mounting logic within this plugin.\nimport '@webex/internal-plugin-encryption';\n\nimport {registerInternalPlugin} from '@webex/webex-core';\n\nimport Scheduler, {config, CONSTANTS} from './scheduler';\nimport payloadTransformer from './payloadTransformer';\n\n// Mounts the plugin to `webex.internal.{NAMESPACE}` and begins initialization.\nregisterInternalPlugin(CONSTANTS.NAMESPACE, Scheduler, {\n payloadTransformer,\n config,\n});\n\nexport default Scheduler;\n"],"mappings":";;;;;;;;;;;AAEA;AAEA;AAEA;AACA;AAAsD;AAAA;AAPtD;AACA;;AAQA;AACA,IAAAA,iCAAsB,EAACC,oBAAS,CAACC,SAAS,EAAEC,kBAAS,EAAE;EACrDC,kBAAkB,EAAlBA,2BAAkB;EAClBC,MAAM,EAANA;AACF,CAAC,CAAC;AAAC,eAEYF,kBAAS;AAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
10
|
+
var _predicates = _interopRequireDefault(require("./predicates"));
|
|
11
|
+
var _transformers = _interopRequireDefault(require("./transformers"));
|
|
12
|
+
var payloadTransformer = {
|
|
13
|
+
predicates: (0, _values.default)(_predicates.default),
|
|
14
|
+
transforms: (0, _values.default)(_transformers.default)
|
|
15
|
+
};
|
|
16
|
+
var _default = payloadTransformer;
|
|
17
|
+
exports.default = _default;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["payloadTransformer","predicates","transforms","transformers"],"sources":["index.js"],"sourcesContent":["import predicates from './predicates';\nimport transformers from './transformers';\n\nconst payloadTransformer = {\n predicates: Object.values(predicates),\n transforms: Object.values(transformers),\n};\n\nexport default payloadTransformer;\n"],"mappings":";;;;;;;;;AAAA;AACA;AAEA,IAAMA,kBAAkB,GAAG;EACzBC,UAAU,EAAE,qBAAcA,mBAAU,CAAC;EACrCC,UAAU,EAAE,qBAAcC,qBAAY;AACxC,CAAC;AAAC,eAEaH,kBAAkB;AAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
10
|
+
/**
|
|
11
|
+
* Predicates are used to validate whether or not a transformer should be
|
|
12
|
+
* triggered, and with what data.
|
|
13
|
+
*/
|
|
14
|
+
var exampleGeneralPredicate = {
|
|
15
|
+
/**
|
|
16
|
+
* Name of the transformer to be called.
|
|
17
|
+
*
|
|
18
|
+
* A predicate will `test()` if the payload is valid for the transform, and
|
|
19
|
+
* then `extract()` the necessary data to be passed into the transformer.
|
|
20
|
+
*
|
|
21
|
+
* @type {string}
|
|
22
|
+
*/
|
|
23
|
+
name: 'exampleGeneralTransformer',
|
|
24
|
+
/**
|
|
25
|
+
* Direction this predicate should process on. This allows for different
|
|
26
|
+
* predicates to be used for inbound and outbound transforms.
|
|
27
|
+
*
|
|
28
|
+
* @type {'inbound' | 'outbound' | undefined}
|
|
29
|
+
*/
|
|
30
|
+
direction: undefined,
|
|
31
|
+
/**
|
|
32
|
+
* Test is used to validate if the `extract()` method should be called to be
|
|
33
|
+
* processed by the associated `name` transformer.
|
|
34
|
+
*
|
|
35
|
+
* @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop
|
|
36
|
+
* @param {Object} data - Data from the event or request
|
|
37
|
+
* @returns {boolean} - Whether to process the `extract()` method.
|
|
38
|
+
*/
|
|
39
|
+
test: function test(ctx, data) {
|
|
40
|
+
return _promise.default.resolve(!!data.value);
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Extract a given set of data from a request or event to be processed by the
|
|
44
|
+
* associated `name` transform.
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} data - Data from the event or request
|
|
47
|
+
* @returns {any} - Data to send to the named transform.
|
|
48
|
+
*/
|
|
49
|
+
extract: function extract(data) {
|
|
50
|
+
return _promise.default.resolve(data.value);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// NOTE - additional predicate examples [start]
|
|
55
|
+
|
|
56
|
+
var exampleInboundPredicate = {
|
|
57
|
+
name: 'exampleInboundTransformer',
|
|
58
|
+
direction: 'inbound',
|
|
59
|
+
test: function test(ctx, data) {
|
|
60
|
+
return _promise.default.resolve(!!data.inboundValue);
|
|
61
|
+
},
|
|
62
|
+
extract: function extract(data) {
|
|
63
|
+
return _promise.default.resolve(data.inboundValue);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var exampleOutboundPredicate = {
|
|
67
|
+
name: 'exampleOutboundTransformer',
|
|
68
|
+
direction: 'outbound',
|
|
69
|
+
test: function test(ctx, data) {
|
|
70
|
+
return _promise.default.resolve(!!data.outboundValue);
|
|
71
|
+
},
|
|
72
|
+
extract: function extract(data) {
|
|
73
|
+
return _promise.default.resolve(data.outboundValue);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// NOTE - additional predicate examples [end]
|
|
78
|
+
|
|
79
|
+
var predicates = {
|
|
80
|
+
exampleGeneralPredicate: exampleGeneralPredicate,
|
|
81
|
+
exampleInboundPredicate: exampleInboundPredicate,
|
|
82
|
+
exampleOutboundPredicate: exampleOutboundPredicate
|
|
83
|
+
};
|
|
84
|
+
var _default = predicates;
|
|
85
|
+
exports.default = _default;
|
|
86
|
+
//# sourceMappingURL=predicates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["exampleGeneralPredicate","name","direction","undefined","test","ctx","data","resolve","value","extract","exampleInboundPredicate","inboundValue","exampleOutboundPredicate","outboundValue","predicates"],"sources":["predicates.js"],"sourcesContent":["/**\n * Predicates are used to validate whether or not a transformer should be\n * triggered, and with what data.\n */\nconst exampleGeneralPredicate = {\n /**\n * Name of the transformer to be called.\n *\n * A predicate will `test()` if the payload is valid for the transform, and\n * then `extract()` the necessary data to be passed into the transformer.\n *\n * @type {string}\n */\n name: 'exampleGeneralTransformer',\n\n /**\n * Direction this predicate should process on. This allows for different\n * predicates to be used for inbound and outbound transforms.\n *\n * @type {'inbound' | 'outbound' | undefined}\n */\n direction: undefined,\n\n /**\n * Test is used to validate if the `extract()` method should be called to be\n * processed by the associated `name` transformer.\n *\n * @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop\n * @param {Object} data - Data from the event or request\n * @returns {boolean} - Whether to process the `extract()` method.\n */\n test: (ctx, data) => Promise.resolve(!!data.value),\n\n /**\n * Extract a given set of data from a request or event to be processed by the\n * associated `name` transform.\n *\n * @param {Object} data - Data from the event or request\n * @returns {any} - Data to send to the named transform.\n */\n extract: (data) => Promise.resolve(data.value),\n};\n\n// NOTE - additional predicate examples [start]\n\nconst exampleInboundPredicate = {\n name: 'exampleInboundTransformer',\n direction: 'inbound',\n test: (ctx, data) => Promise.resolve(!!data.inboundValue),\n extract: (data) => Promise.resolve(data.inboundValue),\n};\n\nconst exampleOutboundPredicate = {\n name: 'exampleOutboundTransformer',\n direction: 'outbound',\n test: (ctx, data) => Promise.resolve(!!data.outboundValue),\n extract: (data) => Promise.resolve(data.outboundValue),\n};\n\n// NOTE - additional predicate examples [end]\n\nconst predicates = {\n exampleGeneralPredicate,\n exampleInboundPredicate,\n exampleOutboundPredicate,\n};\n\nexport default predicates;\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA,IAAMA,uBAAuB,GAAG;EAC9B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,IAAI,EAAE,2BAA2B;EAEjC;AACF;AACA;AACA;AACA;AACA;EACEC,SAAS,EAAEC,SAAS;EAEpB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,IAAI,EAAE,cAACC,GAAG,EAAEC,IAAI;IAAA,OAAK,iBAAQC,OAAO,CAAC,CAAC,CAACD,IAAI,CAACE,KAAK,CAAC;EAAA;EAElD;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,OAAO,EAAE,iBAACH,IAAI;IAAA,OAAK,iBAAQC,OAAO,CAACD,IAAI,CAACE,KAAK,CAAC;EAAA;AAChD,CAAC;;AAED;;AAEA,IAAME,uBAAuB,GAAG;EAC9BT,IAAI,EAAE,2BAA2B;EACjCC,SAAS,EAAE,SAAS;EACpBE,IAAI,EAAE,cAACC,GAAG,EAAEC,IAAI;IAAA,OAAK,iBAAQC,OAAO,CAAC,CAAC,CAACD,IAAI,CAACK,YAAY,CAAC;EAAA;EACzDF,OAAO,EAAE,iBAACH,IAAI;IAAA,OAAK,iBAAQC,OAAO,CAACD,IAAI,CAACK,YAAY,CAAC;EAAA;AACvD,CAAC;AAED,IAAMC,wBAAwB,GAAG;EAC/BX,IAAI,EAAE,4BAA4B;EAClCC,SAAS,EAAE,UAAU;EACrBE,IAAI,EAAE,cAACC,GAAG,EAAEC,IAAI;IAAA,OAAK,iBAAQC,OAAO,CAAC,CAAC,CAACD,IAAI,CAACO,aAAa,CAAC;EAAA;EAC1DJ,OAAO,EAAE,iBAACH,IAAI;IAAA,OAAK,iBAAQC,OAAO,CAACD,IAAI,CAACO,aAAa,CAAC;EAAA;AACxD,CAAC;;AAED;;AAEA,IAAMC,UAAU,GAAG;EACjBd,uBAAuB,EAAvBA,uBAAuB;EACvBU,uBAAuB,EAAvBA,uBAAuB;EACvBE,wBAAwB,EAAxBA;AACF,CAAC;AAAC,eAEaE,UAAU;AAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Transformers are used to process data from requests and events, performing
|
|
10
|
+
* actions prior to the resolution of a `request` or `event` within the calling
|
|
11
|
+
* stack.
|
|
12
|
+
*/
|
|
13
|
+
var exampleGeneralTransformer = {
|
|
14
|
+
/**
|
|
15
|
+
* Name of this transformer.
|
|
16
|
+
*
|
|
17
|
+
* The usage of this transformer can be validated via a predicate. See the
|
|
18
|
+
* `predicates.js` file for more details.
|
|
19
|
+
*
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
name: 'exampleGeneralTransformer',
|
|
23
|
+
/**
|
|
24
|
+
* Direction this transformer should process on. This allows for different
|
|
25
|
+
* directions to be handled differently when sending/receiving data.
|
|
26
|
+
*
|
|
27
|
+
* @type {'inbound' | 'outbound' | undefined}
|
|
28
|
+
*/
|
|
29
|
+
direction: undefined,
|
|
30
|
+
/**
|
|
31
|
+
* The main transformation function
|
|
32
|
+
* @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop.
|
|
33
|
+
* @param {any} data - Data from the event or request.
|
|
34
|
+
* @returns {Promise<any>} - Data after transformation.
|
|
35
|
+
*/
|
|
36
|
+
fn: function fn(ctx, data) {
|
|
37
|
+
return ctx.transform('exampleInboundTransformer', ctx, data).then(function (transformed) {
|
|
38
|
+
return ctx.webex.internal.encryption.example(transformed);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// NOTE - additional predicate examples [start]
|
|
44
|
+
|
|
45
|
+
var exampleInboundTransformer = {
|
|
46
|
+
name: 'exampleInboundTransformer',
|
|
47
|
+
direction: 'inbound',
|
|
48
|
+
fn: function fn(ctx, data) {
|
|
49
|
+
return ctx.transform('exampleGeneralTransformer', ctx, data).then(function (transformed) {
|
|
50
|
+
return ctx.webex.internal.encryption.example(transformed);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var exampleOutboundTransformer = {
|
|
55
|
+
name: 'exampleOutboundTransformer',
|
|
56
|
+
direction: 'outbound',
|
|
57
|
+
fn: function fn(ctx, data) {
|
|
58
|
+
return ctx.transform('exampleGeneralTransformer', ctx, data).then(function (transformed) {
|
|
59
|
+
return ctx.webex.internal.encryption.example(transformed);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// NOTE - additional predicate examples [end]
|
|
65
|
+
|
|
66
|
+
var transformers = {
|
|
67
|
+
exampleGeneralTransformer: exampleGeneralTransformer,
|
|
68
|
+
exampleInboundTransformer: exampleInboundTransformer,
|
|
69
|
+
exampleOutboundTransformer: exampleOutboundTransformer
|
|
70
|
+
};
|
|
71
|
+
var _default = transformers;
|
|
72
|
+
exports.default = _default;
|
|
73
|
+
//# sourceMappingURL=transformers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["exampleGeneralTransformer","name","direction","undefined","fn","ctx","data","transform","then","transformed","webex","internal","encryption","example","exampleInboundTransformer","exampleOutboundTransformer","transformers"],"sources":["transformers.js"],"sourcesContent":["/**\n * Transformers are used to process data from requests and events, performing\n * actions prior to the resolution of a `request` or `event` within the calling\n * stack.\n */\nconst exampleGeneralTransformer = {\n /**\n * Name of this transformer.\n *\n * The usage of this transformer can be validated via a predicate. See the\n * `predicates.js` file for more details.\n *\n * @type {string}\n */\n name: 'exampleGeneralTransformer',\n\n /**\n * Direction this transformer should process on. This allows for different\n * directions to be handled differently when sending/receiving data.\n *\n * @type {'inbound' | 'outbound' | undefined}\n */\n direction: undefined,\n\n /**\n * The main transformation function\n * @param {Record<'webex' | 'transform', any>} ctx - An Object containing a webex instance and transform prop.\n * @param {any} data - Data from the event or request.\n * @returns {Promise<any>} - Data after transformation.\n */\n fn: (ctx, data) =>\n ctx\n .transform('exampleInboundTransformer', ctx, data)\n .then((transformed) => ctx.webex.internal.encryption.example(transformed)),\n};\n\n// NOTE - additional predicate examples [start]\n\nconst exampleInboundTransformer = {\n name: 'exampleInboundTransformer',\n direction: 'inbound',\n fn: (ctx, data) =>\n ctx\n .transform('exampleGeneralTransformer', ctx, data)\n .then((transformed) => ctx.webex.internal.encryption.example(transformed)),\n};\n\nconst exampleOutboundTransformer = {\n name: 'exampleOutboundTransformer',\n direction: 'outbound',\n fn: (ctx, data) =>\n ctx\n .transform('exampleGeneralTransformer', ctx, data)\n .then((transformed) => ctx.webex.internal.encryption.example(transformed)),\n};\n\n// NOTE - additional predicate examples [end]\n\nconst transformers = {\n exampleGeneralTransformer,\n exampleInboundTransformer,\n exampleOutboundTransformer,\n};\n\nexport default transformers;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,IAAMA,yBAAyB,GAAG;EAChC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,IAAI,EAAE,2BAA2B;EAEjC;AACF;AACA;AACA;AACA;AACA;EACEC,SAAS,EAAEC,SAAS;EAEpB;AACF;AACA;AACA;AACA;AACA;EACEC,EAAE,EAAE,YAACC,GAAG,EAAEC,IAAI;IAAA,OACZD,GAAG,CACAE,SAAS,CAAC,2BAA2B,EAAEF,GAAG,EAAEC,IAAI,CAAC,CACjDE,IAAI,CAAC,UAACC,WAAW;MAAA,OAAKJ,GAAG,CAACK,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACC,OAAO,CAACJ,WAAW,CAAC;IAAA,EAAC;EAAA;AAChF,CAAC;;AAED;;AAEA,IAAMK,yBAAyB,GAAG;EAChCb,IAAI,EAAE,2BAA2B;EACjCC,SAAS,EAAE,SAAS;EACpBE,EAAE,EAAE,YAACC,GAAG,EAAEC,IAAI;IAAA,OACZD,GAAG,CACAE,SAAS,CAAC,2BAA2B,EAAEF,GAAG,EAAEC,IAAI,CAAC,CACjDE,IAAI,CAAC,UAACC,WAAW;MAAA,OAAKJ,GAAG,CAACK,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACC,OAAO,CAACJ,WAAW,CAAC;IAAA,EAAC;EAAA;AAChF,CAAC;AAED,IAAMM,0BAA0B,GAAG;EACjCd,IAAI,EAAE,4BAA4B;EAClCC,SAAS,EAAE,UAAU;EACrBE,EAAE,EAAE,YAACC,GAAG,EAAEC,IAAI;IAAA,OACZD,GAAG,CACAE,SAAS,CAAC,2BAA2B,EAAEF,GAAG,EAAEC,IAAI,CAAC,CACjDE,IAAI,CAAC,UAACC,WAAW;MAAA,OAAKJ,GAAG,CAACK,KAAK,CAACC,QAAQ,CAACC,UAAU,CAACC,OAAO,CAACJ,WAAW,CAAC;IAAA,EAAC;EAAA;AAChF,CAAC;;AAED;;AAEA,IAAMO,YAAY,GAAG;EACnBhB,yBAAyB,EAAzBA,yBAAyB;EACzBc,yBAAyB,EAAzBA,yBAAyB;EACzBC,0BAA0B,EAA1BA;AACF,CAAC;AAAC,eAEaC,YAAY;AAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
_Object$defineProperty(exports, "CONSTANTS", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _scheduler3.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
_Object$defineProperty(exports, "config", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _scheduler2.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.default = void 0;
|
|
21
|
+
var _scheduler = _interopRequireDefault(require("./scheduler"));
|
|
22
|
+
var _scheduler2 = _interopRequireDefault(require("./scheduler.config"));
|
|
23
|
+
var _scheduler3 = _interopRequireDefault(require("./scheduler.constants"));
|
|
24
|
+
var _default = _scheduler.default;
|
|
25
|
+
exports.default = _default;
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Scheduler"],"sources":["index.js"],"sourcesContent":["import Scheduler from './scheduler';\nimport config from './scheduler.config';\nimport CONSTANTS from './scheduler.constants';\n\nexport {config, CONSTANTS};\n\nexport default Scheduler;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAA8C,eAI/BA,kBAAS;AAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* The configuration object for this plugin.
|
|
10
|
+
*
|
|
11
|
+
* Each of the values can be retreived from `this.webex.config.scheduler.{property}.
|
|
12
|
+
* When these properties mount/update, `this.webex` object emits `change:config`.
|
|
13
|
+
*/
|
|
14
|
+
var config = {
|
|
15
|
+
scheduler: {
|
|
16
|
+
configurationBoolean: true,
|
|
17
|
+
configurationString: 'hello',
|
|
18
|
+
configurationNumber: 1234,
|
|
19
|
+
configurationArray: [1, 2, 3, 4],
|
|
20
|
+
configurationObject: {
|
|
21
|
+
a: 1,
|
|
22
|
+
b: 2,
|
|
23
|
+
c: 3
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var _default = config;
|
|
28
|
+
exports.default = _default;
|
|
29
|
+
//# sourceMappingURL=scheduler.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["config","scheduler","configurationBoolean","configurationString","configurationNumber","configurationArray","configurationObject","a","b","c"],"sources":["scheduler.config.js"],"sourcesContent":["/**\n * The configuration object for this plugin.\n *\n * Each of the values can be retreived from `this.webex.config.scheduler.{property}.\n * When these properties mount/update, `this.webex` object emits `change:config`.\n */\nconst config = {\n scheduler: {\n configurationBoolean: true,\n configurationString: 'hello',\n configurationNumber: 1234,\n configurationArray: [1, 2, 3, 4],\n configurationObject: {a: 1, b: 2, c: 3},\n },\n};\n\nexport default config;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,MAAM,GAAG;EACbC,SAAS,EAAE;IACTC,oBAAoB,EAAE,IAAI;IAC1BC,mBAAmB,EAAE,OAAO;IAC5BC,mBAAmB,EAAE,IAAI;IACzBC,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChCC,mBAAmB,EAAE;MAACC,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE;IAAC;EACxC;AACF,CAAC;AAAC,eAEaT,MAAM;AAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
// Namespace to store this plugin under within `webex` or `webex.internal`.
|
|
9
|
+
var NAMESPACE = 'scheduler';
|
|
10
|
+
var CONSTANTS = {
|
|
11
|
+
NAMESPACE: NAMESPACE
|
|
12
|
+
};
|
|
13
|
+
var _default = CONSTANTS;
|
|
14
|
+
exports.default = _default;
|
|
15
|
+
//# sourceMappingURL=scheduler.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NAMESPACE","CONSTANTS"],"sources":["scheduler.constants.js"],"sourcesContent":["// Namespace to store this plugin under within `webex` or `webex.internal`.\nconst NAMESPACE = 'scheduler';\n\nconst CONSTANTS = {\n NAMESPACE,\n};\n\nexport default CONSTANTS;\n"],"mappings":";;;;;;;AAAA;AACA,IAAMA,SAAS,GAAG,WAAW;AAE7B,IAAMC,SAAS,GAAG;EAChBD,SAAS,EAATA;AACF,CAAC;AAAC,eAEaC,SAAS;AAAA"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.default = void 0;
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
15
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
17
|
+
var _webexCore = require("@webex/webex-core");
|
|
18
|
+
var _scheduler = _interopRequireDefault(require("./scheduler.constants"));
|
|
19
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
+
/**
|
|
22
|
+
* Scheduler WebexPlugin class.
|
|
23
|
+
*/
|
|
24
|
+
var Scheduler = /*#__PURE__*/function (_WebexPlugin) {
|
|
25
|
+
(0, _inherits2.default)(Scheduler, _WebexPlugin);
|
|
26
|
+
var _super = _createSuper(Scheduler);
|
|
27
|
+
/**
|
|
28
|
+
* Namespace, or key, to register a `Scheduler` class object to within the
|
|
29
|
+
* `webex.internal` object. Note that only one instance of this class can be
|
|
30
|
+
* used against a single `webex` class instance.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {Object} args Arguments for constructing a new Scheduler instance.
|
|
35
|
+
*/
|
|
36
|
+
function Scheduler() {
|
|
37
|
+
var _this;
|
|
38
|
+
(0, _classCallCheck2.default)(this, Scheduler);
|
|
39
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
40
|
+
args[_key] = arguments[_key];
|
|
41
|
+
}
|
|
42
|
+
_this = _super.call.apply(_super, [this].concat(args)); // Required to properly mount the singleton class instance.
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The `this.request` method should now be available for usage.
|
|
46
|
+
* See `http-core` for this tooling.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The mercury connection is available for initialization
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The `this.logger` object should now be available for usage.
|
|
55
|
+
* `this.logger.log()`, `this.logger.error()`, `this.logger.warn()`, etc.
|
|
56
|
+
*/
|
|
57
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "namespace", _scheduler.default.NAMESPACE);
|
|
58
|
+
_this.logger.log('plugin example constructed'); // example, remove this.
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* WebexPlugin initialize method. This triggers once Webex has completed its
|
|
64
|
+
* initialization workflow.
|
|
65
|
+
*
|
|
66
|
+
* If the plugin is meant to perform startup actions, place them in this
|
|
67
|
+
* `initialize()` method instead of the `constructor()` method.
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
(0, _createClass2.default)(Scheduler, [{
|
|
71
|
+
key: "initialize",
|
|
72
|
+
value: function initialize() {
|
|
73
|
+
// Used to perform actions based on the provided configuration object once
|
|
74
|
+
// the configuration object is ready.
|
|
75
|
+
this.listenToOnce(this.webex, 'change:config', function () {
|
|
76
|
+
/* ...perform actions once the configuration object is mounted... */
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Used to perform actions after webex is fully qualified and ready for
|
|
80
|
+
// operation.
|
|
81
|
+
this.listenToOnce(this.webex, 'ready', function () {
|
|
82
|
+
/* ...perform actions once the webex object is fully qualified... */
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Example request usage. `this.request` returns a promise using XHR. and the
|
|
88
|
+
* `request` npm package.
|
|
89
|
+
* @returns {void}
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "exampleRequestUsage",
|
|
93
|
+
value: function exampleRequestUsage() {
|
|
94
|
+
// Simple example
|
|
95
|
+
this.request({
|
|
96
|
+
method: 'GET',
|
|
97
|
+
// method to use for this request
|
|
98
|
+
service: 'example-service',
|
|
99
|
+
// `service` is federated from U2C. See `this.webex.services.list()` at runtime.
|
|
100
|
+
resource: 'example/resource/path' // full resource path,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Complex example
|
|
104
|
+
return this.request({
|
|
105
|
+
uri: 'https://www.example.com',
|
|
106
|
+
// a URI can be used in place of service/resource.
|
|
107
|
+
method: 'POST',
|
|
108
|
+
headers: {
|
|
109
|
+
accept: 'application/json',
|
|
110
|
+
authorization: 'example-token',
|
|
111
|
+
'x-custom-header': 'x-custom-header-example-value'
|
|
112
|
+
},
|
|
113
|
+
body: {
|
|
114
|
+
'example-param-a': 'example-param-a-value',
|
|
115
|
+
'example-param-b': 'example-param-b-value',
|
|
116
|
+
'example-param-c': 'example-param-c-value'
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Example event usage. Note that an event engine is mapped to `this`
|
|
123
|
+
* upon extending the `WebexPlugin` class constructor. This includes
|
|
124
|
+
* the following methods:
|
|
125
|
+
* `this.listenTo()`, `this.stopListening()`, `this.trigger()`, `this.on()`, etc.
|
|
126
|
+
*
|
|
127
|
+
* Note that all methods provided as event handlers should be associated with
|
|
128
|
+
* a namespace so that they can be referenced/destroyed if/when necessary.
|
|
129
|
+
*
|
|
130
|
+
* @returns {void}
|
|
131
|
+
*/
|
|
132
|
+
}, {
|
|
133
|
+
key: "exampleEventUsage",
|
|
134
|
+
value: function exampleEventUsage() {
|
|
135
|
+
var _this2 = this;
|
|
136
|
+
// listen for locally scoped events [using on, internal]
|
|
137
|
+
this.on('event:scope', function (event) {
|
|
138
|
+
_this2.logger.log(event);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// stop listening for locally scoped events.
|
|
142
|
+
this.off('event:scope', function () {
|
|
143
|
+
/* use previous `on` method param namespace instead of arrow function */
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// listen for scoped events [using on, external], replace `this.webex` with `webex` namespace.
|
|
147
|
+
this.webex.internal.scheduler.on('event:scope', function (event) {
|
|
148
|
+
_this2.logger.log(event);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// stop listening for scoped events [using on, external], replace `this.webex` with `webex` namespace.
|
|
152
|
+
this.webex.internal.scheduler.off('event:scope', function () {
|
|
153
|
+
/* use previous `on` method param namespace instead of arrow function */
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// listen for scoped events [using listenTo(), plugin-to-plugin].
|
|
157
|
+
this.listenTo(this.webex.pluginName, 'event:scope', function (event) {
|
|
158
|
+
_this2.logger.log(event);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// stop listening for scoped events [using listenTo(), plugin-to-plugin].
|
|
162
|
+
this.stopListening(this.webex.pluginName, 'event:scope', function () {
|
|
163
|
+
/* use previous `listenTo` method param namespace instead of arrow function */
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Example mercury connection setup. See the above `exampleEventUsage()` for
|
|
169
|
+
* event usage definition.
|
|
170
|
+
*
|
|
171
|
+
* @returns {void}
|
|
172
|
+
*/
|
|
173
|
+
}, {
|
|
174
|
+
key: "exampleMercuryConnection",
|
|
175
|
+
value: function exampleMercuryConnection() {
|
|
176
|
+
var _this3 = this;
|
|
177
|
+
this.webex.internal.mercury.connect().then(function () {
|
|
178
|
+
// Scope this listener to a trackable namespace
|
|
179
|
+
_this3.handler = function (event) {
|
|
180
|
+
_this3.logger.log(event);
|
|
181
|
+
_this3.trigger('event:scope', event);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Start handling events.
|
|
185
|
+
_this3.listenTo(_this3.webex.internal.mercury, 'event:scope', _this3.handler);
|
|
186
|
+
|
|
187
|
+
// Stop handling events.
|
|
188
|
+
_this3.stopListening(_this3.webex.internal.mercury, 'event:scope', _this3.handler);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}]);
|
|
192
|
+
return Scheduler;
|
|
193
|
+
}(_webexCore.WebexPlugin);
|
|
194
|
+
var _default = Scheduler;
|
|
195
|
+
exports.default = _default;
|
|
196
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Scheduler","args","CONSTANTS","NAMESPACE","logger","log","listenToOnce","webex","request","method","service","resource","uri","headers","accept","authorization","body","on","event","off","internal","scheduler","listenTo","pluginName","stopListening","mercury","connect","then","handler","trigger","WebexPlugin"],"sources":["scheduler.js"],"sourcesContent":["import {WebexPlugin} from '@webex/webex-core';\n\nimport CONSTANTS from './scheduler.constants';\n\n/**\n * Scheduler WebexPlugin class.\n */\nclass Scheduler extends WebexPlugin {\n /**\n * Namespace, or key, to register a `Scheduler` class object to within the\n * `webex.internal` object. Note that only one instance of this class can be\n * used against a single `webex` class instance.\n */\n namespace = CONSTANTS.NAMESPACE;\n\n /**\n * @param {Object} args Arguments for constructing a new Scheduler instance.\n */\n constructor(...args) {\n super(...args); // Required to properly mount the singleton class instance.\n\n /**\n * The `this.request` method should now be available for usage.\n * See `http-core` for this tooling.\n */\n\n /**\n * The mercury connection is available for initialization\n */\n\n /**\n * The `this.logger` object should now be available for usage.\n * `this.logger.log()`, `this.logger.error()`, `this.logger.warn()`, etc.\n */\n this.logger.log('plugin example constructed'); // example, remove this.\n }\n\n /**\n * WebexPlugin initialize method. This triggers once Webex has completed its\n * initialization workflow.\n *\n * If the plugin is meant to perform startup actions, place them in this\n * `initialize()` method instead of the `constructor()` method.\n * @returns {void}\n */\n initialize() {\n // Used to perform actions based on the provided configuration object once\n // the configuration object is ready.\n this.listenToOnce(this.webex, 'change:config', () => {\n /* ...perform actions once the configuration object is mounted... */\n });\n\n // Used to perform actions after webex is fully qualified and ready for\n // operation.\n this.listenToOnce(this.webex, 'ready', () => {\n /* ...perform actions once the webex object is fully qualified... */\n });\n }\n\n /**\n * Example request usage. `this.request` returns a promise using XHR. and the\n * `request` npm package.\n * @returns {void}\n */\n exampleRequestUsage() {\n // Simple example\n this.request({\n method: 'GET', // method to use for this request\n service: 'example-service', // `service` is federated from U2C. See `this.webex.services.list()` at runtime.\n resource: 'example/resource/path', // full resource path,\n });\n\n // Complex example\n return this.request({\n uri: 'https://www.example.com', // a URI can be used in place of service/resource.\n method: 'POST',\n headers: {\n accept: 'application/json',\n authorization: 'example-token',\n 'x-custom-header': 'x-custom-header-example-value',\n },\n body: {\n 'example-param-a': 'example-param-a-value',\n 'example-param-b': 'example-param-b-value',\n 'example-param-c': 'example-param-c-value',\n },\n });\n }\n\n /**\n * Example event usage. Note that an event engine is mapped to `this`\n * upon extending the `WebexPlugin` class constructor. This includes\n * the following methods:\n * `this.listenTo()`, `this.stopListening()`, `this.trigger()`, `this.on()`, etc.\n *\n * Note that all methods provided as event handlers should be associated with\n * a namespace so that they can be referenced/destroyed if/when necessary.\n *\n * @returns {void}\n */\n exampleEventUsage() {\n // listen for locally scoped events [using on, internal]\n this.on('event:scope', (event) => {\n this.logger.log(event);\n });\n\n // stop listening for locally scoped events.\n this.off('event:scope', () => {\n /* use previous `on` method param namespace instead of arrow function */\n });\n\n // listen for scoped events [using on, external], replace `this.webex` with `webex` namespace.\n this.webex.internal.scheduler.on('event:scope', (event) => {\n this.logger.log(event);\n });\n\n // stop listening for scoped events [using on, external], replace `this.webex` with `webex` namespace.\n this.webex.internal.scheduler.off('event:scope', () => {\n /* use previous `on` method param namespace instead of arrow function */\n });\n\n // listen for scoped events [using listenTo(), plugin-to-plugin].\n this.listenTo(this.webex.pluginName, 'event:scope', (event) => {\n this.logger.log(event);\n });\n\n // stop listening for scoped events [using listenTo(), plugin-to-plugin].\n this.stopListening(this.webex.pluginName, 'event:scope', () => {\n /* use previous `listenTo` method param namespace instead of arrow function */\n });\n }\n\n /**\n * Example mercury connection setup. See the above `exampleEventUsage()` for\n * event usage definition.\n *\n * @returns {void}\n */\n exampleMercuryConnection() {\n this.webex.internal.mercury.connect().then(() => {\n // Scope this listener to a trackable namespace\n this.handler = (event) => {\n this.logger.log(event);\n this.trigger('event:scope', event);\n };\n\n // Start handling events.\n this.listenTo(this.webex.internal.mercury, 'event:scope', this.handler);\n\n // Stop handling events.\n this.stopListening(this.webex.internal.mercury, 'event:scope', this.handler);\n });\n }\n}\n\nexport default Scheduler;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAEA;AAA8C;AAAA;AAE9C;AACA;AACA;AAFA,IAGMA,SAAS;EAAA;EAAA;EACb;AACF;AACA;AACA;AACA;;EAGE;AACF;AACA;EACE,qBAAqB;IAAA;IAAA;IAAA,kCAANC,IAAI;MAAJA,IAAI;IAAA;IACjB,gDAASA,IAAI,GAAE,CAAC;;IAEhB;AACJ;AACA;AACA;;IAEI;AACJ;AACA;;IAEI;AACJ;AACA;AACA;IAHI,wFAjBUC,kBAAS,CAACC,SAAS;IAqB7B,MAAKC,MAAM,CAACC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;IAAA;EACjD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EAPE;IAAA;IAAA,OAQA,sBAAa;MACX;MACA;MACA,IAAI,CAACC,YAAY,CAAC,IAAI,CAACC,KAAK,EAAE,eAAe,EAAE,YAAM;QACnD;MAAA,CACD,CAAC;;MAEF;MACA;MACA,IAAI,CAACD,YAAY,CAAC,IAAI,CAACC,KAAK,EAAE,OAAO,EAAE,YAAM;QAC3C;MAAA,CACD,CAAC;IACJ;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,+BAAsB;MACpB;MACA,IAAI,CAACC,OAAO,CAAC;QACXC,MAAM,EAAE,KAAK;QAAE;QACfC,OAAO,EAAE,iBAAiB;QAAE;QAC5BC,QAAQ,EAAE,uBAAuB,CAAE;MACrC,CAAC,CAAC;;MAEF;MACA,OAAO,IAAI,CAACH,OAAO,CAAC;QAClBI,GAAG,EAAE,yBAAyB;QAAE;QAChCH,MAAM,EAAE,MAAM;QACdI,OAAO,EAAE;UACPC,MAAM,EAAE,kBAAkB;UAC1BC,aAAa,EAAE,eAAe;UAC9B,iBAAiB,EAAE;QACrB,CAAC;QACDC,IAAI,EAAE;UACJ,iBAAiB,EAAE,uBAAuB;UAC1C,iBAAiB,EAAE,uBAAuB;UAC1C,iBAAiB,EAAE;QACrB;MACF,CAAC,CAAC;IACJ;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAVE;IAAA;IAAA,OAWA,6BAAoB;MAAA;MAClB;MACA,IAAI,CAACC,EAAE,CAAC,aAAa,EAAE,UAACC,KAAK,EAAK;QAChC,MAAI,CAACd,MAAM,CAACC,GAAG,CAACa,KAAK,CAAC;MACxB,CAAC,CAAC;;MAEF;MACA,IAAI,CAACC,GAAG,CAAC,aAAa,EAAE,YAAM;QAC5B;MAAA,CACD,CAAC;;MAEF;MACA,IAAI,CAACZ,KAAK,CAACa,QAAQ,CAACC,SAAS,CAACJ,EAAE,CAAC,aAAa,EAAE,UAACC,KAAK,EAAK;QACzD,MAAI,CAACd,MAAM,CAACC,GAAG,CAACa,KAAK,CAAC;MACxB,CAAC,CAAC;;MAEF;MACA,IAAI,CAACX,KAAK,CAACa,QAAQ,CAACC,SAAS,CAACF,GAAG,CAAC,aAAa,EAAE,YAAM;QACrD;MAAA,CACD,CAAC;;MAEF;MACA,IAAI,CAACG,QAAQ,CAAC,IAAI,CAACf,KAAK,CAACgB,UAAU,EAAE,aAAa,EAAE,UAACL,KAAK,EAAK;QAC7D,MAAI,CAACd,MAAM,CAACC,GAAG,CAACa,KAAK,CAAC;MACxB,CAAC,CAAC;;MAEF;MACA,IAAI,CAACM,aAAa,CAAC,IAAI,CAACjB,KAAK,CAACgB,UAAU,EAAE,aAAa,EAAE,YAAM;QAC7D;MAAA,CACD,CAAC;IACJ;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,oCAA2B;MAAA;MACzB,IAAI,CAAChB,KAAK,CAACa,QAAQ,CAACK,OAAO,CAACC,OAAO,EAAE,CAACC,IAAI,CAAC,YAAM;QAC/C;QACA,MAAI,CAACC,OAAO,GAAG,UAACV,KAAK,EAAK;UACxB,MAAI,CAACd,MAAM,CAACC,GAAG,CAACa,KAAK,CAAC;UACtB,MAAI,CAACW,OAAO,CAAC,aAAa,EAAEX,KAAK,CAAC;QACpC,CAAC;;QAED;QACA,MAAI,CAACI,QAAQ,CAAC,MAAI,CAACf,KAAK,CAACa,QAAQ,CAACK,OAAO,EAAE,aAAa,EAAE,MAAI,CAACG,OAAO,CAAC;;QAEvE;QACA,MAAI,CAACJ,aAAa,CAAC,MAAI,CAACjB,KAAK,CAACa,QAAQ,CAACK,OAAO,EAAE,aAAa,EAAE,MAAI,CAACG,OAAO,CAAC;MAC9E,CAAC,CAAC;IACJ;EAAC;EAAA;AAAA,EAjJqBE,sBAAW;AAAA,eAoJpB9B,SAAS;AAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webex/internal-plugin-scheduler",
|
|
3
|
+
"version": "2.41.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"devMain": "src/index.js",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/webex/webex-js-sdk.git",
|
|
11
|
+
"directory": "packages/@webex/internal-plugin-scheduler"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=14"
|
|
15
|
+
},
|
|
16
|
+
"browserify": {
|
|
17
|
+
"transform": [
|
|
18
|
+
"babelify",
|
|
19
|
+
"envify"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@webex/test-helper-chai": "2.41.0",
|
|
24
|
+
"@webex/test-helper-mock-webex": "2.41.0",
|
|
25
|
+
"@webex/test-helper-test-users": "2.41.0",
|
|
26
|
+
"chai": "^4.3.4",
|
|
27
|
+
"chai-as-promised": "^7.1.1",
|
|
28
|
+
"sinon": "^9.2.4"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@webex/common": "2.41.0",
|
|
32
|
+
"@webex/common-timers": "2.41.0",
|
|
33
|
+
"@webex/http-core": "2.41.0",
|
|
34
|
+
"@webex/internal-plugin-device": "2.41.0",
|
|
35
|
+
"@webex/internal-plugin-encryption": "2.41.0",
|
|
36
|
+
"@webex/internal-plugin-mercury": "2.41.0",
|
|
37
|
+
"@webex/internal-plugin-metrics": "2.41.0",
|
|
38
|
+
"@webex/webex-core": "2.41.0",
|
|
39
|
+
"ampersand-collection": "^2.0.2",
|
|
40
|
+
"ampersand-state": "^5.0.3",
|
|
41
|
+
"lodash": "^4.17.21"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {WebexPlugin} from '@webex/webex-core';
|
|
2
|
+
|
|
3
|
+
import CONSTANTS from './scheduler.constants';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scheduler WebexPlugin class.
|
|
7
|
+
*/
|
|
8
|
+
class Scheduler extends WebexPlugin {
|
|
9
|
+
/**
|
|
10
|
+
* Namespace, or key, to register a `Scheduler` class object to within the
|
|
11
|
+
* `webex.internal` object. Note that only one instance of this class can be
|
|
12
|
+
* used against a single `webex` class instance.
|
|
13
|
+
*/
|
|
14
|
+
namespace = CONSTANTS.NAMESPACE;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {Object} args Arguments for constructing a new Scheduler instance.
|
|
18
|
+
*/
|
|
19
|
+
constructor(...args) {
|
|
20
|
+
super(...args); // Required to properly mount the singleton class instance.
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The `this.request` method should now be available for usage.
|
|
24
|
+
* See `http-core` for this tooling.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The mercury connection is available for initialization
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The `this.logger` object should now be available for usage.
|
|
33
|
+
* `this.logger.log()`, `this.logger.error()`, `this.logger.warn()`, etc.
|
|
34
|
+
*/
|
|
35
|
+
this.logger.log('plugin example constructed'); // example, remove this.
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* WebexPlugin initialize method. This triggers once Webex has completed its
|
|
40
|
+
* initialization workflow.
|
|
41
|
+
*
|
|
42
|
+
* If the plugin is meant to perform startup actions, place them in this
|
|
43
|
+
* `initialize()` method instead of the `constructor()` method.
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
initialize() {
|
|
47
|
+
// Used to perform actions based on the provided configuration object once
|
|
48
|
+
// the configuration object is ready.
|
|
49
|
+
this.listenToOnce(this.webex, 'change:config', () => {
|
|
50
|
+
/* ...perform actions once the configuration object is mounted... */
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Used to perform actions after webex is fully qualified and ready for
|
|
54
|
+
// operation.
|
|
55
|
+
this.listenToOnce(this.webex, 'ready', () => {
|
|
56
|
+
/* ...perform actions once the webex object is fully qualified... */
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Example request usage. `this.request` returns a promise using XHR. and the
|
|
62
|
+
* `request` npm package.
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
65
|
+
exampleRequestUsage() {
|
|
66
|
+
// Simple example
|
|
67
|
+
this.request({
|
|
68
|
+
method: 'GET', // method to use for this request
|
|
69
|
+
service: 'example-service', // `service` is federated from U2C. See `this.webex.services.list()` at runtime.
|
|
70
|
+
resource: 'example/resource/path', // full resource path,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Complex example
|
|
74
|
+
return this.request({
|
|
75
|
+
uri: 'https://www.example.com', // a URI can be used in place of service/resource.
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: {
|
|
78
|
+
accept: 'application/json',
|
|
79
|
+
authorization: 'example-token',
|
|
80
|
+
'x-custom-header': 'x-custom-header-example-value',
|
|
81
|
+
},
|
|
82
|
+
body: {
|
|
83
|
+
'example-param-a': 'example-param-a-value',
|
|
84
|
+
'example-param-b': 'example-param-b-value',
|
|
85
|
+
'example-param-c': 'example-param-c-value',
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Example event usage. Note that an event engine is mapped to `this`
|
|
92
|
+
* upon extending the `WebexPlugin` class constructor. This includes
|
|
93
|
+
* the following methods:
|
|
94
|
+
* `this.listenTo()`, `this.stopListening()`, `this.trigger()`, `this.on()`, etc.
|
|
95
|
+
*
|
|
96
|
+
* Note that all methods provided as event handlers should be associated with
|
|
97
|
+
* a namespace so that they can be referenced/destroyed if/when necessary.
|
|
98
|
+
*
|
|
99
|
+
* @returns {void}
|
|
100
|
+
*/
|
|
101
|
+
exampleEventUsage() {
|
|
102
|
+
// listen for locally scoped events [using on, internal]
|
|
103
|
+
this.on('event:scope', (event) => {
|
|
104
|
+
this.logger.log(event);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// stop listening for locally scoped events.
|
|
108
|
+
this.off('event:scope', () => {
|
|
109
|
+
/* use previous `on` method param namespace instead of arrow function */
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// listen for scoped events [using on, external], replace `this.webex` with `webex` namespace.
|
|
113
|
+
this.webex.internal.scheduler.on('event:scope', (event) => {
|
|
114
|
+
this.logger.log(event);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// stop listening for scoped events [using on, external], replace `this.webex` with `webex` namespace.
|
|
118
|
+
this.webex.internal.scheduler.off('event:scope', () => {
|
|
119
|
+
/* use previous `on` method param namespace instead of arrow function */
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// listen for scoped events [using listenTo(), plugin-to-plugin].
|
|
123
|
+
this.listenTo(this.webex.pluginName, 'event:scope', (event) => {
|
|
124
|
+
this.logger.log(event);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// stop listening for scoped events [using listenTo(), plugin-to-plugin].
|
|
128
|
+
this.stopListening(this.webex.pluginName, 'event:scope', () => {
|
|
129
|
+
/* use previous `listenTo` method param namespace instead of arrow function */
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Example mercury connection setup. See the above `exampleEventUsage()` for
|
|
135
|
+
* event usage definition.
|
|
136
|
+
*
|
|
137
|
+
* @returns {void}
|
|
138
|
+
*/
|
|
139
|
+
exampleMercuryConnection() {
|
|
140
|
+
this.webex.internal.mercury.connect().then(() => {
|
|
141
|
+
// Scope this listener to a trackable namespace
|
|
142
|
+
this.handler = (event) => {
|
|
143
|
+
this.logger.log(event);
|
|
144
|
+
this.trigger('event:scope', event);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Start handling events.
|
|
148
|
+
this.listenTo(this.webex.internal.mercury, 'event:scope', this.handler);
|
|
149
|
+
|
|
150
|
+
// Stop handling events.
|
|
151
|
+
this.stopListening(this.webex.internal.mercury, 'event:scope', this.handler);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export default Scheduler;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import chai from 'chai';
|
|
2
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
5
|
+
import WebexCore from '@webex/webex-core';
|
|
6
|
+
import '@webex/internal-plugin-scheduler';
|
|
7
|
+
|
|
8
|
+
const {assert} = chai;
|
|
9
|
+
|
|
10
|
+
chai.use(chaiAsPromised);
|
|
11
|
+
sinon.assert.expose(chai.assert, {prefix: ''});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Integration tests use a real webex test user against services.
|
|
15
|
+
*/
|
|
16
|
+
describe('plugin-scheduler', () => {
|
|
17
|
+
describe('predicates', () => {
|
|
18
|
+
let scheduler;
|
|
19
|
+
let user;
|
|
20
|
+
let webex;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
testUsers.create({count: 1}).then(([createdUser]) => {
|
|
24
|
+
user = createdUser;
|
|
25
|
+
|
|
26
|
+
webex = new WebexCore({
|
|
27
|
+
credentials: user.token,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
scheduler = webex.internal.scheduler;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Integration test scope, typically methods/name or event/name.
|
|
36
|
+
*/
|
|
37
|
+
describe('test scope', () => {
|
|
38
|
+
// TODO - Add integration tests.
|
|
39
|
+
it('example test', () => {
|
|
40
|
+
assert.isTrue(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import chai from 'chai';
|
|
2
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
5
|
+
import WebexCore from '@webex/webex-core';
|
|
6
|
+
import '@webex/internal-plugin-scheduler';
|
|
7
|
+
|
|
8
|
+
const {assert} = chai;
|
|
9
|
+
|
|
10
|
+
chai.use(chaiAsPromised);
|
|
11
|
+
sinon.assert.expose(chai.assert, {prefix: ''});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Integration tests use a real webex test user against services.
|
|
15
|
+
*/
|
|
16
|
+
describe('plugin-scheduler', () => {
|
|
17
|
+
describe('transformers', () => {
|
|
18
|
+
let scheduler;
|
|
19
|
+
let user;
|
|
20
|
+
let webex;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
testUsers.create({count: 1}).then(([createdUser]) => {
|
|
24
|
+
user = createdUser;
|
|
25
|
+
|
|
26
|
+
webex = new WebexCore({
|
|
27
|
+
credentials: user.token,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
scheduler = webex.internal.scheduler;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Integration test scope, typically methods/name or event/name.
|
|
36
|
+
*/
|
|
37
|
+
describe('test scope', () => {
|
|
38
|
+
// TODO - Add integration tests.
|
|
39
|
+
it('example test', () => {
|
|
40
|
+
assert.isTrue(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import chai from 'chai';
|
|
2
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
5
|
+
import WebexCore from '@webex/webex-core';
|
|
6
|
+
import '@webex/internal-plugin-scheduler';
|
|
7
|
+
|
|
8
|
+
const {assert} = chai;
|
|
9
|
+
|
|
10
|
+
chai.use(chaiAsPromised);
|
|
11
|
+
sinon.assert.expose(chai.assert, {prefix: ''});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Integration tests use a real webex test user against services.
|
|
15
|
+
*/
|
|
16
|
+
describe('plugin-scheduler', () => {
|
|
17
|
+
describe('Scheduler', () => {
|
|
18
|
+
let scheduler;
|
|
19
|
+
let user;
|
|
20
|
+
let webex;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
testUsers.create({count: 1}).then(([createdUser]) => {
|
|
24
|
+
user = createdUser;
|
|
25
|
+
|
|
26
|
+
webex = new WebexCore({
|
|
27
|
+
credentials: user.token,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
scheduler = webex.internal.scheduler;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Integration test scope, typically methods/name or event/name.
|
|
36
|
+
*/
|
|
37
|
+
describe('test scope', () => {
|
|
38
|
+
// TODO - Add integration tests.
|
|
39
|
+
it('example test', () => {
|
|
40
|
+
assert.isTrue(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {assert} from '@webex/test-helper-chai';
|
|
2
|
+
import MockWebex from '@webex/test-helper-mock-webex';
|
|
3
|
+
|
|
4
|
+
import Scheduler from '@webex/internal-plugin-scheduler';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Unit tests are not used against services.
|
|
8
|
+
*/
|
|
9
|
+
describe('plugin-scheduler', () => {
|
|
10
|
+
describe('Scheduler', () => {
|
|
11
|
+
let webex;
|
|
12
|
+
let scheduler;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
webex = new MockWebex({
|
|
16
|
+
children: {
|
|
17
|
+
scheduler: Scheduler,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
scheduler = webex.internal.scheduler;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Any expected property assignments to this scope.
|
|
26
|
+
*/
|
|
27
|
+
describe('properties', () => {
|
|
28
|
+
describe('request', () => {
|
|
29
|
+
it('should be mounted', () => {
|
|
30
|
+
assert.exists(scheduler.request);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('logger', () => {
|
|
35
|
+
it('should be mounted', () => {
|
|
36
|
+
assert.exists(scheduler.logger);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// TODO - Test additional properties.
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Any expected event workflows assigned to this scope.
|
|
45
|
+
*/
|
|
46
|
+
describe('events', () => {
|
|
47
|
+
// TODO - Add event testing.
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Any methods assigned to this scope.
|
|
52
|
+
*/
|
|
53
|
+
describe('methods', () => {
|
|
54
|
+
// TODO - Add method testing.
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|