@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.
@@ -1,156 +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;
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;
@@ -1,44 +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
- });
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
+ });
@@ -1,44 +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
- });
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
+ });
@@ -1,44 +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
- });
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
+ });