@webex/webex-core 3.0.0-beta.2 → 3.0.0-beta.21

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.
Files changed (184) hide show
  1. package/dist/config.js +1 -11
  2. package/dist/config.js.map +1 -1
  3. package/dist/credentials-config.js +44 -64
  4. package/dist/credentials-config.js.map +1 -1
  5. package/dist/index.js +0 -76
  6. package/dist/index.js.map +1 -1
  7. package/dist/interceptors/auth.js +22 -55
  8. package/dist/interceptors/auth.js.map +1 -1
  9. package/dist/interceptors/default-options.js +0 -20
  10. package/dist/interceptors/default-options.js.map +1 -1
  11. package/dist/interceptors/embargo.js +0 -21
  12. package/dist/interceptors/embargo.js.map +1 -1
  13. package/dist/interceptors/network-timing.js +2 -21
  14. package/dist/interceptors/network-timing.js.map +1 -1
  15. package/dist/interceptors/payload-transformer.js +2 -22
  16. package/dist/interceptors/payload-transformer.js.map +1 -1
  17. package/dist/interceptors/rate-limit.js +25 -57
  18. package/dist/interceptors/rate-limit.js.map +1 -1
  19. package/dist/interceptors/redirect.js +4 -33
  20. package/dist/interceptors/redirect.js.map +1 -1
  21. package/dist/interceptors/request-event.js +3 -30
  22. package/dist/interceptors/request-event.js.map +1 -1
  23. package/dist/interceptors/request-logger.js +1 -30
  24. package/dist/interceptors/request-logger.js.map +1 -1
  25. package/dist/interceptors/request-timing.js +3 -22
  26. package/dist/interceptors/request-timing.js.map +1 -1
  27. package/dist/interceptors/response-logger.js +2 -31
  28. package/dist/interceptors/response-logger.js.map +1 -1
  29. package/dist/interceptors/user-agent.js +2 -29
  30. package/dist/interceptors/user-agent.js.map +1 -1
  31. package/dist/interceptors/webex-tracking-id.js +5 -28
  32. package/dist/interceptors/webex-tracking-id.js.map +1 -1
  33. package/dist/interceptors/webex-user-agent.js +5 -38
  34. package/dist/interceptors/webex-user-agent.js.map +1 -1
  35. package/dist/lib/batcher.js +3 -51
  36. package/dist/lib/batcher.js.map +1 -1
  37. package/dist/lib/credentials/credentials.js +39 -119
  38. package/dist/lib/credentials/credentials.js.map +1 -1
  39. package/dist/lib/credentials/grant-errors.js +0 -49
  40. package/dist/lib/credentials/grant-errors.js.map +1 -1
  41. package/dist/lib/credentials/index.js +1 -13
  42. package/dist/lib/credentials/index.js.map +1 -1
  43. package/dist/lib/credentials/scope.js +1 -7
  44. package/dist/lib/credentials/scope.js.map +1 -1
  45. package/dist/lib/credentials/token-collection.js +1 -7
  46. package/dist/lib/credentials/token-collection.js.map +1 -1
  47. package/dist/lib/credentials/token.js +39 -118
  48. package/dist/lib/credentials/token.js.map +1 -1
  49. package/dist/lib/page.js +13 -26
  50. package/dist/lib/page.js.map +1 -1
  51. package/dist/lib/services/constants.js +0 -2
  52. package/dist/lib/services/constants.js.map +1 -1
  53. package/dist/lib/services/index.js +1 -28
  54. package/dist/lib/services/index.js.map +1 -1
  55. package/dist/lib/services/interceptors/server-error.js +2 -23
  56. package/dist/lib/services/interceptors/server-error.js.map +1 -1
  57. package/dist/lib/services/interceptors/service.js +12 -34
  58. package/dist/lib/services/interceptors/service.js.map +1 -1
  59. package/dist/lib/services/metrics.js +0 -2
  60. package/dist/lib/services/metrics.js.map +1 -1
  61. package/dist/lib/services/service-catalog.js +10 -90
  62. package/dist/lib/services/service-catalog.js.map +1 -1
  63. package/dist/lib/services/service-fed-ramp.js +0 -2
  64. package/dist/lib/services/service-fed-ramp.js.map +1 -1
  65. package/dist/lib/services/service-host.js +47 -62
  66. package/dist/lib/services/service-host.js.map +1 -1
  67. package/dist/lib/services/service-registry.js +78 -90
  68. package/dist/lib/services/service-registry.js.map +1 -1
  69. package/dist/lib/services/service-state.js +3 -15
  70. package/dist/lib/services/service-state.js.map +1 -1
  71. package/dist/lib/services/service-url.js +4 -25
  72. package/dist/lib/services/service-url.js.map +1 -1
  73. package/dist/lib/services/services.js +122 -238
  74. package/dist/lib/services/services.js.map +1 -1
  75. package/dist/lib/stateless-webex-plugin.js +5 -28
  76. package/dist/lib/stateless-webex-plugin.js.map +1 -1
  77. package/dist/lib/storage/decorators.js +19 -62
  78. package/dist/lib/storage/decorators.js.map +1 -1
  79. package/dist/lib/storage/errors.js +0 -23
  80. package/dist/lib/storage/errors.js.map +1 -1
  81. package/dist/lib/storage/index.js +2 -16
  82. package/dist/lib/storage/index.js.map +1 -1
  83. package/dist/lib/storage/make-webex-plugin-store.js +11 -41
  84. package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
  85. package/dist/lib/storage/make-webex-store.js +8 -30
  86. package/dist/lib/storage/make-webex-store.js.map +1 -1
  87. package/dist/lib/storage/memory-store-adapter.js +1 -19
  88. package/dist/lib/storage/memory-store-adapter.js.map +1 -1
  89. package/dist/lib/webex-core-plugin-mixin.js +9 -29
  90. package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
  91. package/dist/lib/webex-http-error.js +1 -31
  92. package/dist/lib/webex-http-error.js.map +1 -1
  93. package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
  94. package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
  95. package/dist/lib/webex-plugin.js +6 -40
  96. package/dist/lib/webex-plugin.js.map +1 -1
  97. package/dist/plugins/logger.js +3 -17
  98. package/dist/plugins/logger.js.map +1 -1
  99. package/dist/webex-core.js +79 -203
  100. package/dist/webex-core.js.map +1 -1
  101. package/dist/webex-internal-core.js +0 -10
  102. package/dist/webex-internal-core.js.map +1 -1
  103. package/package.json +14 -14
  104. package/src/config.js +9 -11
  105. package/src/credentials-config.js +110 -72
  106. package/src/index.js +4 -14
  107. package/src/interceptors/auth.js +36 -37
  108. package/src/interceptors/default-options.js +0 -1
  109. package/src/interceptors/embargo.js +1 -1
  110. package/src/interceptors/payload-transformer.js +1 -2
  111. package/src/interceptors/rate-limit.js +8 -5
  112. package/src/interceptors/redirect.js +14 -8
  113. package/src/interceptors/request-event.js +4 -8
  114. package/src/interceptors/request-logger.js +8 -5
  115. package/src/interceptors/response-logger.js +11 -8
  116. package/src/interceptors/user-agent.js +1 -2
  117. package/src/interceptors/webex-user-agent.js +3 -9
  118. package/src/lib/batcher.js +70 -69
  119. package/src/lib/credentials/credentials.js +112 -122
  120. package/src/lib/credentials/grant-errors.js +6 -7
  121. package/src/lib/credentials/index.js +1 -4
  122. package/src/lib/credentials/scope.js +1 -4
  123. package/src/lib/credentials/token-collection.js +1 -1
  124. package/src/lib/credentials/token.js +86 -80
  125. package/src/lib/page.js +10 -11
  126. package/src/lib/services/constants.js +3 -13
  127. package/src/lib/services/index.js +2 -2
  128. package/src/lib/services/interceptors/server-error.js +12 -7
  129. package/src/lib/services/interceptors/service.js +6 -5
  130. package/src/lib/services/metrics.js +1 -1
  131. package/src/lib/services/service-catalog.js +110 -100
  132. package/src/lib/services/service-fed-ramp.js +1 -2
  133. package/src/lib/services/service-host.js +10 -17
  134. package/src/lib/services/service-registry.js +69 -96
  135. package/src/lib/services/service-state.js +4 -6
  136. package/src/lib/services/service-url.js +24 -23
  137. package/src/lib/services/services.js +260 -251
  138. package/src/lib/stateless-webex-plugin.js +4 -2
  139. package/src/lib/storage/decorators.js +68 -66
  140. package/src/lib/storage/index.js +4 -6
  141. package/src/lib/storage/make-webex-plugin-store.js +34 -21
  142. package/src/lib/storage/make-webex-store.js +6 -7
  143. package/src/lib/storage/memory-store-adapter.js +3 -3
  144. package/src/lib/webex-core-plugin-mixin.js +10 -7
  145. package/src/lib/webex-http-error.js +7 -8
  146. package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
  147. package/src/lib/webex-plugin.js +41 -34
  148. package/src/plugins/logger.js +8 -3
  149. package/src/webex-core.js +185 -116
  150. package/src/webex-internal-core.js +15 -9
  151. package/test/integration/spec/credentials/credentials.js +26 -30
  152. package/test/integration/spec/credentials/token.js +36 -33
  153. package/test/integration/spec/services/service-catalog.js +177 -156
  154. package/test/integration/spec/services/services.js +313 -304
  155. package/test/integration/spec/webex-core.js +98 -86
  156. package/test/unit/spec/_setup.js +26 -18
  157. package/test/unit/spec/credentials/credentials.js +189 -154
  158. package/test/unit/spec/credentials/token.js +94 -76
  159. package/test/unit/spec/interceptors/auth.js +291 -243
  160. package/test/unit/spec/interceptors/default-options.js +36 -24
  161. package/test/unit/spec/interceptors/embargo.js +32 -27
  162. package/test/unit/spec/interceptors/network-timing.js +2 -2
  163. package/test/unit/spec/interceptors/payload-transformer.js +61 -52
  164. package/test/unit/spec/interceptors/rate-limit.js +104 -75
  165. package/test/unit/spec/interceptors/redirect.js +22 -20
  166. package/test/unit/spec/interceptors/request-timing.js +18 -22
  167. package/test/unit/spec/interceptors/user-agent.js +28 -16
  168. package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
  169. package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
  170. package/test/unit/spec/lib/batcher.js +36 -32
  171. package/test/unit/spec/lib/page.js +36 -32
  172. package/test/unit/spec/lib/webex-plugin.js +1 -1
  173. package/test/unit/spec/services/interceptors/server-error.js +67 -90
  174. package/test/unit/spec/services/interceptors/service.js +17 -28
  175. package/test/unit/spec/services/service-catalog.js +19 -27
  176. package/test/unit/spec/services/service-host.js +29 -26
  177. package/test/unit/spec/services/service-registry.js +128 -170
  178. package/test/unit/spec/services/service-state.js +13 -22
  179. package/test/unit/spec/services/service-url.js +24 -43
  180. package/test/unit/spec/services/services.js +85 -41
  181. package/test/unit/spec/storage/persist.js +6 -9
  182. package/test/unit/spec/storage/wait-for-value.js +22 -21
  183. package/test/unit/spec/webex-core.js +78 -57
  184. package/test/unit/spec/webex-internal-core.js +56 -31
@@ -50,7 +50,7 @@ export default class StatelessWebexPlugin {
50
50
  * @private
51
51
  * @type {boolean}
52
52
  */
53
- ready = true;
53
+ ready = true;
54
54
 
55
55
  /**
56
56
  * Constructor. One of attrs.webex or options.parent is required
@@ -63,7 +63,9 @@ export default class StatelessWebexPlugin {
63
63
  let webex = attrs.webex || options.parent;
64
64
 
65
65
  if (!webex) {
66
- throw new Error('One of `attrs.webex` or `options.parent` must be supplied when initializing a StatelessWebexPlugin');
66
+ throw new Error(
67
+ 'One of `attrs.webex` or `options.parent` must be supplied when initializing a StatelessWebexPlugin'
68
+ );
67
69
  }
68
70
 
69
71
  while (webex.parent || webex.collection) {
@@ -4,13 +4,7 @@
4
4
 
5
5
  /* eslint no-invalid-this: [0] */
6
6
 
7
- import {
8
- curry,
9
- debounce,
10
- identity,
11
- result,
12
- wrap
13
- } from 'lodash';
7
+ import {curry, debounce, identity, result, wrap} from 'lodash';
14
8
  import {make} from '@webex/common';
15
9
 
16
10
  import {NotFoundError} from './errors';
@@ -32,7 +26,9 @@ export function persist(...args) {
32
26
  if (prop !== 'initialize') {
33
27
  // Once we have class-based alternative to AmpersandState, it should be
34
28
  // detected here.
35
- throw new TypeError('@persist can only currently be applied to AmpersandState objects or their derivatives and must be applied to the initialize method');
29
+ throw new TypeError(
30
+ '@persist can only currently be applied to AmpersandState objects or their derivatives and must be applied to the initialize method'
31
+ );
36
32
  }
37
33
 
38
34
  descriptor.value = wrap(descriptor.value, function persistExecutor(fn, ...initializeArgs) {
@@ -44,20 +40,23 @@ export function persist(...args) {
44
40
  // a debounce of zero, we're effectively coalescing all the changes
45
41
  // triggered by a single call to set() and commiting them on the next tick
46
42
  // eslint-disable-next-line no-invalid-this
47
- this.on(changeEvent, debounce(() => {
48
- const shouldPersist = !decider || Reflect.apply(decider, this, ...initializeArgs);
43
+ this.on(
44
+ changeEvent,
45
+ debounce(() => {
46
+ const shouldPersist = !decider || Reflect.apply(decider, this, ...initializeArgs);
49
47
 
50
- if (!shouldPersist) {
51
- return Promise.resolve();
52
- }
53
- if (key === '@') {
54
- // eslint-disable-next-line no-invalid-this
55
- return this.boundedStorage.put(key, this);
56
- }
48
+ if (!shouldPersist) {
49
+ return Promise.resolve();
50
+ }
51
+ if (key === '@') {
52
+ // eslint-disable-next-line no-invalid-this
53
+ return this.boundedStorage.put(key, this);
54
+ }
57
55
 
58
- // eslint-disable-next-line no-invalid-this
59
- return this.boundedStorage.put(key, this[key]);
60
- }, 0));
56
+ // eslint-disable-next-line no-invalid-this
57
+ return this.boundedStorage.put(key, this[key]);
58
+ }, 0)
59
+ );
61
60
 
62
61
  return ret;
63
62
  });
@@ -88,8 +87,9 @@ export function waitForValue(key) {
88
87
  descriptor.value = wrap(descriptor.value, function waitForValueExecutor(fn, ...args) {
89
88
  const keys = blockingKeys.get(target, prop);
90
89
 
91
- return Promise.all([...keys].map((k) => this.boundedStorage.waitFor(k)))
92
- .then(() => Reflect.apply(fn, this, args));
90
+ return Promise.all([...keys].map((k) => this.boundedStorage.waitFor(k))).then(() =>
91
+ Reflect.apply(fn, this, args)
92
+ );
93
93
  });
94
94
 
95
95
  // This *should* make decorators compatible with AmpersandState class
@@ -159,60 +159,62 @@ function prepareInitialize(target, prop) {
159
159
  const self = this;
160
160
  const namespace = this.getNamespace();
161
161
 
162
- this.webex.initialize = wrap(this.webex.initialize || identity, function applyInit(fn, ...args) {
163
- // Call webex's initalize method first
164
- // Reminder: in order for MockWebex to accept initial storage data, the
165
- // wrapped initialize() must be invoked before attempting to load data.
166
- // Reminder: context here is `webex`, not `self`.
167
- stack.add(namespace);
168
- Reflect.apply(fn, this, args);
169
-
170
- // Then prepare a function for setting values retrieved from storage
171
- const set = curry((key, value) => {
172
- this.logger.debug(`storage:(${namespace}): got \`${key}\` for first time`);
173
- if (key === '@') {
174
- self.parent.set({
175
- [namespace.toLowerCase()]: value
176
- });
177
- }
178
- else if (result(self[key], 'isState')) {
179
- self[key].set(value);
180
- }
181
- else {
182
- self.set(key, value);
183
- }
184
- this.logger.debug(`storage:(${namespace}): set \`${key}\` for first time`);
185
- });
162
+ this.webex.initialize = wrap(
163
+ this.webex.initialize || identity,
164
+ function applyInit(fn, ...args) {
165
+ // Call webex's initalize method first
166
+ // Reminder: in order for MockWebex to accept initial storage data, the
167
+ // wrapped initialize() must be invoked before attempting to load data.
168
+ // Reminder: context here is `webex`, not `self`.
169
+ stack.add(namespace);
170
+ Reflect.apply(fn, this, args);
171
+
172
+ // Then prepare a function for setting values retrieved from storage
173
+ const set = curry((key, value) => {
174
+ this.logger.debug(`storage:(${namespace}): got \`${key}\` for first time`);
175
+ if (key === '@') {
176
+ self.parent.set({
177
+ [namespace.toLowerCase()]: value,
178
+ });
179
+ } else if (result(self[key], 'isState')) {
180
+ self[key].set(value);
181
+ } else {
182
+ self.set(key, value);
183
+ }
184
+ this.logger.debug(`storage:(${namespace}): set \`${key}\` for first time`);
185
+ });
186
186
 
187
- // And prepare an error handler for when those keys can't be found
188
- const handle = curry((key, reason) => {
189
- if (reason instanceof NotFoundError || process.env.NODE_ENV !== 'production' && reason.toString().includes('MockNotFoundError')) {
190
- this.logger.debug(`storage(${namespace}): no data for \`${key}\`, continuing`);
187
+ // And prepare an error handler for when those keys can't be found
188
+ const handle = curry((key, reason) => {
189
+ if (
190
+ reason instanceof NotFoundError ||
191
+ (process.env.NODE_ENV !== 'production' &&
192
+ reason.toString().includes('MockNotFoundError'))
193
+ ) {
194
+ this.logger.debug(`storage(${namespace}): no data for \`${key}\`, continuing`);
191
195
 
192
- return Promise.resolve();
193
- }
194
- this.logger.error(`storage(${namespace}): failed to init \`${key}\``, reason);
196
+ return Promise.resolve();
197
+ }
198
+ this.logger.error(`storage(${namespace}): failed to init \`${key}\``, reason);
195
199
 
196
- return Promise.reject(reason);
197
- });
200
+ return Promise.reject(reason);
201
+ });
198
202
 
199
- // Iterate over the list of keys marked as blocking via `@waitForValue`
200
- const keys = blockingKeys.get(target, prop);
201
- const promises = [];
203
+ // Iterate over the list of keys marked as blocking via `@waitForValue`
204
+ const keys = blockingKeys.get(target, prop);
205
+ const promises = [];
202
206
 
203
- keys.forEach((key) => {
204
- promises.push(this.boundedStorage.get(namespace, key)
205
- .then(set(key))
206
- .catch(handle(key)));
207
- });
207
+ keys.forEach((key) => {
208
+ promises.push(this.boundedStorage.get(namespace, key).then(set(key)).catch(handle(key)));
209
+ });
208
210
 
209
- Promise.all(promises)
210
- .then(() => {
211
+ Promise.all(promises).then(() => {
211
212
  stack.delete(namespace);
212
213
  if (stack.size === 0) {
213
214
  this.loaded = true;
214
215
  }
215
216
  });
216
- });
217
+ }
218
+ );
217
219
  }
218
220
  }
@@ -2,11 +2,9 @@
2
2
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
 
5
- export {
6
- persist,
7
- waitForValue
8
- } from './decorators';
9
- export {default as makeWebexStore} from './make-webex-store.js';
10
- export {default as makeWebexPluginStore} from './make-webex-plugin-store.js';
5
+ export {persist, waitForValue} from './decorators';
6
+ export {default as makeWebexStore} from './make-webex-store';
7
+ export {default as makeWebexPluginStore} from './make-webex-plugin-store';
8
+
11
9
  export {default as MemoryStoreAdapter} from './memory-store-adapter';
12
10
  export {StorageError, NotFoundError} from './errors';
@@ -28,12 +28,10 @@ function serialize(value) {
28
28
  if (isArray(val)) {
29
29
  if (val.length === 0) {
30
30
  serialized[key] = undefined;
31
- }
32
- else {
31
+ } else {
33
32
  serialized[key] = val.map(serialize);
34
33
  }
35
- }
36
- else if (isObject(val)) {
34
+ } else if (isObject(val)) {
37
35
  Object.keys(val).forEach((k) => {
38
36
  val[k] = serialize(val[k]);
39
37
  });
@@ -102,12 +100,11 @@ export default function makeWebexPluginStorage(type, context) {
102
100
  defers.get(this).set(key, defer);
103
101
  }
104
102
 
105
- return context.webex[`${type}Storage`].get(context.getNamespace(), key)
106
- .then((res) => {
107
- defer.resolve();
103
+ return context.webex[`${type}Storage`].get(context.getNamespace(), key).then((res) => {
104
+ defer.resolve();
108
105
 
109
- return res;
110
- });
106
+ return res;
107
+ });
111
108
  }
112
109
 
113
110
  /**
@@ -129,11 +126,15 @@ export default function makeWebexPluginStorage(type, context) {
129
126
  * @returns {Promise}
130
127
  */
131
128
  waitFor(key) {
132
- context.logger.debug(`plugin-storage(${context.getNamespace()}): waiting to init key \`${key}\``);
129
+ context.logger.debug(
130
+ `plugin-storage(${context.getNamespace()}): waiting to init key \`${key}\``
131
+ );
133
132
  const defer = defers.get(this).get(key);
134
133
 
135
134
  if (defer) {
136
- context.logger.debug(`plugin-storage(${context.getNamespace()}): already inited \`${key}\``);
135
+ context.logger.debug(
136
+ `plugin-storage(${context.getNamespace()}): already inited \`${key}\``
137
+ );
137
138
 
138
139
  return defer.promise;
139
140
  }
@@ -160,19 +161,22 @@ export default function makeWebexPluginStorage(type, context) {
160
161
 
161
162
  // Intentionally bypasses this.get so we don't resolve the promise until
162
163
  // after the parent value is set.
163
- context.webex[`${type}Storage`].get(context.getNamespace(), key)
164
+ context.webex[`${type}Storage`]
165
+ .get(context.getNamespace(), key)
164
166
  .then((value) => {
165
- context.logger.debug(`plugin-storage(${context.getNamespace()}): got \`${key}\` for first time`);
167
+ context.logger.debug(
168
+ `plugin-storage(${context.getNamespace()}): got \`${key}\` for first time`
169
+ );
166
170
  if (key === '@') {
167
171
  context.parent.set(value);
168
- }
169
- else if (result(context[key], 'isState')) {
172
+ } else if (result(context[key], 'isState')) {
170
173
  context[key].set(value);
171
- }
172
- else {
174
+ } else {
173
175
  context.set(key, value);
174
176
  }
175
- context.logger.debug(`plugin-storage(${context.getNamespace()}): set \`${key}\` for first time`);
177
+ context.logger.debug(
178
+ `plugin-storage(${context.getNamespace()}): set \`${key}\` for first time`
179
+ );
176
180
  defer.resolve();
177
181
  context.logger.debug(`plugin-storage(${context.getNamespace()}): inited \`${key}\``);
178
182
  })
@@ -180,12 +184,21 @@ export default function makeWebexPluginStorage(type, context) {
180
184
  // The next conditional is a bit of an unfortunate solution to deal
181
185
  // with circular dependencies in unit tests. It should not effect
182
186
  // integration tests or production code.
183
- if (reason instanceof NotFoundError || process.env.NODE_ENV !== 'production' && reason.toString().includes('MockNotFoundError')) {
184
- context.logger.debug(`plugin-storage(${context.getNamespace()}): no data for \`${key}\`, continuing`);
187
+ if (
188
+ reason instanceof NotFoundError ||
189
+ (process.env.NODE_ENV !== 'production' &&
190
+ reason.toString().includes('MockNotFoundError'))
191
+ ) {
192
+ context.logger.debug(
193
+ `plugin-storage(${context.getNamespace()}): no data for \`${key}\`, continuing`
194
+ );
185
195
 
186
196
  return defer.resolve();
187
197
  }
188
- context.logger.warn(`plugin-storage(${context.getNamespace()}): failed to init \`${key}\``, reason);
198
+ context.logger.warn(
199
+ `plugin-storage(${context.getNamespace()}): failed to init \`${key}\``,
200
+ reason
201
+ );
189
202
 
190
203
  return defer.reject(reason);
191
204
  });
@@ -67,8 +67,7 @@ export default function makeWebexStore(type, webex) {
67
67
  del(namespace, key) {
68
68
  webex.logger.debug(`webex-store: removing ${namespace}:${key}`);
69
69
 
70
- return this._getBinding(namespace)
71
- .then((binding) => binding.del(key));
70
+ return this._getBinding(namespace).then((binding) => binding.del(key));
72
71
  }
73
72
 
74
73
  /**
@@ -81,8 +80,7 @@ export default function makeWebexStore(type, webex) {
81
80
  get(namespace, key) {
82
81
  webex.logger.debug(`webex-store: retrieving ${namespace}:${key}`);
83
82
 
84
- return this._getBinding(namespace)
85
- .then((binding) => binding.get(key));
83
+ return this._getBinding(namespace).then((binding) => binding.get(key));
86
84
  }
87
85
 
88
86
  /**
@@ -124,13 +122,14 @@ export default function makeWebexStore(type, webex) {
124
122
  return resolve(binding);
125
123
  }
126
124
 
127
- return resolve(this.adapter.bind(namespace, {logger: webex.logger})
128
- .then((_binding) => {
125
+ return resolve(
126
+ this.adapter.bind(namespace, {logger: webex.logger}).then((_binding) => {
129
127
  webex.logger.debug(`storage: made binding for \`${namespace}\``);
130
128
  this.bindings.set(namespace, _binding);
131
129
 
132
130
  return _binding;
133
- }));
131
+ })
132
+ );
134
133
  });
135
134
  }
136
135
  }
@@ -59,7 +59,7 @@ function _bind(namespace, options = {}) {
59
59
  logger.debug(`memory-store-adapter: writing \`${key}\``);
60
60
 
61
61
  return Promise.resolve(map.set(key, value));
62
- }
62
+ },
63
63
  });
64
64
  }
65
65
 
@@ -73,7 +73,7 @@ export default {
73
73
  }
74
74
 
75
75
  return _bind(namespace, options);
76
- }
76
+ },
77
77
  };
78
- }
78
+ },
79
79
  };
@@ -26,7 +26,7 @@ export default function mixinWebexCorePlugins(State, config, interceptors) {
26
26
  deps: [`${name}.${key}`],
27
27
  fn() {
28
28
  return this[name][key];
29
- }
29
+ },
30
30
  });
31
31
  });
32
32
  }
@@ -55,13 +55,16 @@ export default function mixinWebexCorePlugins(State, config, interceptors) {
55
55
 
56
56
  if (options.onBeforeLogout) {
57
57
  config.onBeforeLogout = config.onBeforeLogout || [];
58
- const onBeforeLogout = isArray(options.onBeforeLogout) ? options.onBeforeLogout : [options.onBeforeLogout];
58
+ const onBeforeLogout = isArray(options.onBeforeLogout)
59
+ ? options.onBeforeLogout
60
+ : [options.onBeforeLogout];
59
61
 
60
62
  onBeforeLogout.forEach((fn) =>
61
63
  config.onBeforeLogout.push({
62
64
  plugin: name,
63
- fn
64
- }));
65
+ fn,
66
+ })
67
+ );
65
68
  }
66
69
 
67
70
  // Only mess with the plugin's derived properties if it's an amp-state plugin
@@ -69,7 +72,7 @@ export default function mixinWebexCorePlugins(State, config, interceptors) {
69
72
  const {fn, depList} = State.prototype._derived.ready;
70
73
  const def = {
71
74
  deps: depList.concat(`${name}.ready`),
72
- fn
75
+ fn,
73
76
  };
74
77
 
75
78
  createDerivedProperty(State.prototype, 'ready', def);
@@ -91,7 +94,7 @@ function createDerivedProperty(modelProto, name, definition) {
91
94
  const def = (modelProto._derived[name] = {
92
95
  fn: isFunction(definition) ? definition : definition.fn,
93
96
  cache: definition.cache !== false,
94
- depList: definition.deps || []
97
+ depList: definition.deps || [],
95
98
  });
96
99
 
97
100
  // add to our shared dependency list
@@ -106,6 +109,6 @@ function createDerivedProperty(modelProto, name, definition) {
106
109
  },
107
110
  set() {
108
111
  throw new TypeError(`\`${name}\` is a derived property, it can't be set directly.`);
109
- }
112
+ },
110
113
  });
111
114
  }
@@ -19,17 +19,17 @@ export default class WebexHttpError extends HttpError {
19
19
 
20
20
  Reflect.defineProperty(this, 'options', {
21
21
  enumerable: false,
22
- value: res.options
22
+ value: res.options,
23
23
  });
24
24
 
25
25
  if (this.options.url) {
26
26
  message += `\n${this.options.method} ${this.options.url}`;
27
- }
28
- else if (this.options.uri) {
27
+ } else if (this.options.uri) {
29
28
  message += `\n${this.options.method} ${this.options.uri}`;
30
- }
31
- else {
32
- message += `\n${this.options.method} ${this.options.service.toUpperCase()}/${this.options.resource}`;
29
+ } else {
30
+ message += `\n${this.options.method} ${this.options.service.toUpperCase()}/${
31
+ this.options.resource
32
+ }`;
33
33
  }
34
34
  message += `\nWEBEX_TRACKING_ID: ${this.options.headers.trackingid}`;
35
35
  if (this.options.headers && this.options.headers['x-trans-id']) {
@@ -39,7 +39,7 @@ export default class WebexHttpError extends HttpError {
39
39
  Reflect.defineProperty(this, 'retryAfter', {
40
40
  enumerable: true,
41
41
  value: this.headers['retry-after'],
42
- writeable: false
42
+ writeable: false,
43
43
  });
44
44
 
45
45
  message += `\nRETRY-AFTER: ${this.retryAfter}`;
@@ -52,7 +52,6 @@ export default class WebexHttpError extends HttpError {
52
52
 
53
53
  HttpError.makeSubTypes(WebexHttpError);
54
54
 
55
-
56
55
  /**
57
56
  * TooManyRequests
58
57
  */
@@ -48,13 +48,16 @@ export default function mixinWebexInternalCorePlugins(State, config, interceptor
48
48
 
49
49
  if (options.onBeforeLogout) {
50
50
  config.onBeforeLogout = config.onBeforeLogout || [];
51
- const onBeforeLogout = isArray(options.onBeforeLogout) ? options.onBeforeLogout : [options.onBeforeLogout];
51
+ const onBeforeLogout = isArray(options.onBeforeLogout)
52
+ ? options.onBeforeLogout
53
+ : [options.onBeforeLogout];
52
54
 
53
55
  onBeforeLogout.forEach((fn) =>
54
56
  config.onBeforeLogout.push({
55
57
  plugin: name,
56
- fn
57
- }));
58
+ fn,
59
+ })
60
+ );
58
61
  }
59
62
 
60
63
  // Only mess with the plugin's derived properties if it's an amp-state plugin
@@ -62,7 +65,7 @@ export default function mixinWebexInternalCorePlugins(State, config, interceptor
62
65
  const {fn, depList} = State.prototype._derived.ready;
63
66
  const def = {
64
67
  deps: depList.concat(`${name}.ready`),
65
- fn
68
+ fn,
66
69
  };
67
70
 
68
71
  createDerivedProperty(State.prototype, 'ready', def);
@@ -84,7 +87,7 @@ function createDerivedProperty(modelProto, name, definition) {
84
87
  const def = (modelProto._derived[name] = {
85
88
  fn: isFunction(definition) ? definition : definition.fn,
86
89
  cache: definition.cache !== false,
87
- depList: definition.deps || []
90
+ depList: definition.deps || [],
88
91
  });
89
92
 
90
93
  // add to our shared dependency list
@@ -99,6 +102,6 @@ function createDerivedProperty(modelProto, name, definition) {
99
102
  },
100
103
  set() {
101
104
  throw new TypeError(`\`${name}\` is a derived property, it can't be set directly.`);
102
- }
105
+ },
103
106
  });
104
107
  }
@@ -5,11 +5,7 @@
5
5
  import util from 'util';
6
6
 
7
7
  import AmpState from 'ampersand-state';
8
- import {
9
- cloneDeep,
10
- isObject,
11
- omit
12
- } from 'lodash';
8
+ import {cloneDeep, isObject, omit} from 'lodash';
13
9
 
14
10
  import {makeWebexPluginStore} from './storage';
15
11
 
@@ -22,22 +18,19 @@ const WebexPlugin = AmpState.extend({
22
18
  deps: [],
23
19
  fn() {
24
20
  return makeWebexPluginStore('bounded', this);
25
- }
21
+ },
26
22
  },
27
23
  unboundedStorage: {
28
24
  deps: [],
29
25
  fn() {
30
26
  return makeWebexPluginStore('unbounded', this);
31
- }
27
+ },
32
28
  },
33
29
  config: {
34
- // figure out why caching config breaks the refresh integration test
35
- // but not the refresh automation test.
30
+ // figure out why caching config breaks the refresh integration test
31
+ // but not the refresh automation test.
36
32
  cache: false,
37
- deps: [
38
- 'webex',
39
- 'webex.config'
40
- ],
33
+ deps: ['webex', 'webex.config'],
41
34
  fn() {
42
35
  if (this.webex && this.webex.config) {
43
36
  const namespace = this.getNamespace();
@@ -50,24 +43,23 @@ const WebexPlugin = AmpState.extend({
50
43
  }
51
44
 
52
45
  return {};
53
- }
46
+ },
54
47
  },
55
48
 
56
49
  logger: {
57
- deps: [
58
- 'webex',
59
- 'webex.logger'
60
- ],
50
+ deps: ['webex', 'webex.logger'],
61
51
  fn() {
62
52
  return this.webex.logger || console;
63
- }
53
+ },
64
54
  },
65
55
 
66
56
  webex: {
67
57
  deps: ['parent'],
68
58
  fn() {
69
59
  if (!this.parent && !this.collection) {
70
- throw new Error('Cannot determine `this.webex` without `this.parent` or `this.collection`. Please initialize `this` via `children` or `collection` or set `this.parent` manually');
60
+ throw new Error(
61
+ 'Cannot determine `this.webex` without `this.parent` or `this.collection`. Please initialize `this` via `children` or `collection` or set `this.parent` manually'
62
+ );
71
63
  }
72
64
 
73
65
  /* eslint consistent-this: [0] */
@@ -78,13 +70,13 @@ const WebexPlugin = AmpState.extend({
78
70
  }
79
71
 
80
72
  return parent;
81
- }
82
- }
73
+ },
74
+ },
83
75
  },
84
76
 
85
77
  session: {
86
78
  parent: {
87
- type: 'any'
79
+ type: 'any',
88
80
  },
89
81
  /**
90
82
  * Indicates this plugin is ready to be used. Defaults to true but can be
@@ -95,8 +87,8 @@ const WebexPlugin = AmpState.extend({
95
87
  */
96
88
  ready: {
97
89
  default: true,
98
- type: 'boolean'
99
- }
90
+ type: 'boolean',
91
+ },
100
92
  },
101
93
 
102
94
  /**
@@ -148,7 +140,12 @@ const WebexPlugin = AmpState.extend({
148
140
  // Propagate change:[attribute] events from children
149
141
  this.on('change', (model, options) => {
150
142
  if (this.parent) {
151
- this.parent.trigger(`change:${this.getNamespace().toLowerCase()}`, this.parent, this, options);
143
+ this.parent.trigger(
144
+ `change:${this.getNamespace().toLowerCase()}`,
145
+ this.parent,
146
+ this,
147
+ options
148
+ );
152
149
  }
153
150
  });
154
151
  },
@@ -161,11 +158,22 @@ const WebexPlugin = AmpState.extend({
161
158
  * @returns {Object}
162
159
  */
163
160
  inspect(depth) {
164
- return util.inspect(omit(this.serialize({
165
- props: true,
166
- session: true,
167
- derived: true
168
- }), 'boundedStorage', 'unboundedStorage', 'config', 'logger', 'webex', 'parent'), {depth});
161
+ return util.inspect(
162
+ omit(
163
+ this.serialize({
164
+ props: true,
165
+ session: true,
166
+ derived: true,
167
+ }),
168
+ 'boundedStorage',
169
+ 'unboundedStorage',
170
+ 'config',
171
+ 'logger',
172
+ 'webex',
173
+ 'parent'
174
+ ),
175
+ {depth}
176
+ );
169
177
  },
170
178
 
171
179
  request(...args) {
@@ -200,8 +208,7 @@ const WebexPlugin = AmpState.extend({
200
208
  if (isObject(key) || key === null) {
201
209
  attrs = key;
202
210
  options = value;
203
- }
204
- else {
211
+ } else {
205
212
  attrs = {};
206
213
  attrs[key] = value;
207
214
  }
@@ -209,7 +216,7 @@ const WebexPlugin = AmpState.extend({
209
216
  options = options || {};
210
217
 
211
218
  return [attrs, options];
212
- }
219
+ },
213
220
  });
214
221
 
215
222
  export default WebexPlugin;