@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
@@ -1,7 +1,4 @@
1
- import {
2
- SERVICE_CATALOGS,
3
- SERVICE_CATALOGS_ENUM_TYPES
4
- } from './constants';
1
+ import {SERVICE_CATALOGS, SERVICE_CATALOGS_ENUM_TYPES} from './constants';
5
2
  import ServiceHost from './service-host';
6
3
 
7
4
  /**
@@ -68,19 +65,17 @@ export default class ServiceRegistry {
68
65
  return this.find({
69
66
  active: true,
70
67
  local: true,
71
- priority: true
72
- }).reduce(
73
- (map, host) => {
74
- // Generate a new object to assign the existing map.
75
- const hostReference = {};
76
-
77
- // Assign the key:value pair for the service and url.
78
- hostReference[host.service] = host.url;
79
-
80
- // Assign the reference to the map and return.
81
- return {...map, ...hostReference};
82
- }, {}
83
- );
68
+ priority: true,
69
+ }).reduce((map, host) => {
70
+ // Generate a new object to assign the existing map.
71
+ const hostReference = {};
72
+
73
+ // Assign the key:value pair for the service and url.
74
+ hostReference[host.service] = host.url;
75
+
76
+ // Assign the reference to the map and return.
77
+ return {...map, ...hostReference};
78
+ }, {});
84
79
  }
85
80
 
86
81
  /**
@@ -98,9 +93,7 @@ export default class ServiceRegistry {
98
93
  const removing = this.find(filter);
99
94
 
100
95
  // Remove the hosts from the array.
101
- this.hosts = this.hosts.filter(
102
- (host) => !removing.includes(host)
103
- );
96
+ this.hosts = this.hosts.filter((host) => !removing.includes(host));
104
97
 
105
98
  // Return the removed hosts.
106
99
  return removing;
@@ -121,11 +114,9 @@ export default class ServiceRegistry {
121
114
  const failing = this.find(filter);
122
115
 
123
116
  // Mark the hosts from the array as failed.
124
- failing.forEach(
125
- (host) => {
126
- host.setStatus({failed: true});
127
- }
128
- );
117
+ failing.forEach((host) => {
118
+ host.setStatus({failed: true});
119
+ });
129
120
 
130
121
  // Return the marked hosts.
131
122
  return failing;
@@ -141,9 +132,9 @@ export default class ServiceRegistry {
141
132
  */
142
133
  filterActive(active) {
143
134
  // Filter the host array if the active requirement is true.
144
- return (typeof active === 'boolean') ?
145
- this.hosts.filter((host) => host.active === active) :
146
- [...this.hosts];
135
+ return typeof active === 'boolean'
136
+ ? this.hosts.filter((host) => host.active === active)
137
+ : [...this.hosts];
147
138
  }
148
139
 
149
140
  /**
@@ -157,16 +148,18 @@ export default class ServiceRegistry {
157
148
  */
158
149
  filterCatalog(catalog = []) {
159
150
  // Generate a catalog names array based on the provided catalog param.
160
- const catalogs = (Array.isArray(catalog) ? catalog : [catalog])
161
- .map((catalogId) => ServiceRegistry.mapCatalogName({
162
- id: catalogId,
163
- type: SERVICE_CATALOGS_ENUM_TYPES.STRING
164
- }) || catalogId);
151
+ const catalogs = (Array.isArray(catalog) ? catalog : [catalog]).map(
152
+ (catalogId) =>
153
+ ServiceRegistry.mapCatalogName({
154
+ id: catalogId,
155
+ type: SERVICE_CATALOGS_ENUM_TYPES.STRING,
156
+ }) || catalogId
157
+ );
165
158
 
166
159
  // Filter the host array against the catalog names array.
167
- return (catalogs.length > 0) ?
168
- this.hosts.filter((host) => catalogs.includes(host.catalog)) :
169
- [...this.hosts];
160
+ return catalogs.length > 0
161
+ ? this.hosts.filter((host) => catalogs.includes(host.catalog))
162
+ : [...this.hosts];
170
163
  }
171
164
 
172
165
  /**
@@ -180,12 +173,12 @@ export default class ServiceRegistry {
180
173
  */
181
174
  filterCluster(cluster = []) {
182
175
  // Generate an array of clusters regardless of parameter type.
183
- const clusters = (Array.isArray(cluster) ? cluster : [cluster]);
176
+ const clusters = Array.isArray(cluster) ? cluster : [cluster];
184
177
 
185
178
  // Filter the host array against the provided clusters.
186
- return (clusters.length > 0) ?
187
- this.hosts.filter((host) => clusters.includes(host.id)) :
188
- [...this.hosts];
179
+ return clusters.length > 0
180
+ ? this.hosts.filter((host) => clusters.includes(host.id))
181
+ : [...this.hosts];
189
182
  }
190
183
 
191
184
  /**
@@ -198,9 +191,9 @@ export default class ServiceRegistry {
198
191
  * @returns {Array<ServiceHost>} - The filtered host array.
199
192
  */
200
193
  filterLocal(local) {
201
- return (typeof local === 'boolean') ?
202
- this.hosts.filter((host) => host.local === local) :
203
- [...this.hosts];
194
+ return typeof local === 'boolean'
195
+ ? this.hosts.filter((host) => host.local === local)
196
+ : [...this.hosts];
204
197
  }
205
198
 
206
199
  /**
@@ -213,9 +206,8 @@ export default class ServiceRegistry {
213
206
  * @returns {Array<ServiceHost>} - The filtered host array.
214
207
  */
215
208
  filterPriority(priority) {
216
- return (priority) ?
217
- this.hosts.reduce(
218
- (filteredHosts, currentHost) => {
209
+ return priority
210
+ ? this.hosts.reduce((filteredHosts, currentHost) => {
219
211
  // Validate that the current host is not active.
220
212
  if (!currentHost.active) {
221
213
  return filteredHosts;
@@ -223,9 +215,7 @@ export default class ServiceRegistry {
223
215
 
224
216
  // Determine if the filtered hosts array contains a host from the same
225
217
  // host group.
226
- const foundHost = filteredHosts.find(
227
- (host) => host.hostGroup === currentHost.hostGroup
228
- );
218
+ const foundHost = filteredHosts.find((host) => host.hostGroup === currentHost.hostGroup);
229
219
 
230
220
  // Validate if a host was found.
231
221
  if (!foundHost) {
@@ -237,13 +227,13 @@ export default class ServiceRegistry {
237
227
  // Map the found host's catalog to its priority value.
238
228
  const foundHostCatalogPriority = ServiceRegistry.mapCatalogName({
239
229
  id: foundHost.catalog,
240
- type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER
230
+ type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER,
241
231
  });
242
232
 
243
233
  // Map the current host's catalog to its priority value.
244
234
  const currentHostCatalogPriority = ServiceRegistry.mapCatalogName({
245
235
  id: currentHost.catalog,
246
- type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER
236
+ type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER,
247
237
  });
248
238
 
249
239
  // Validate if the found host has a lower priority than the current
@@ -257,8 +247,8 @@ export default class ServiceRegistry {
257
247
  }
258
248
 
259
249
  return filteredHosts;
260
- }, []
261
- ) : [...this.hosts];
250
+ }, [])
251
+ : [...this.hosts];
262
252
  }
263
253
 
264
254
  /**
@@ -272,12 +262,12 @@ export default class ServiceRegistry {
272
262
  */
273
263
  filterService(service = []) {
274
264
  // Generate an array of services regardless of parameter type.
275
- const services = (Array.isArray(service) ? service : [service]);
265
+ const services = Array.isArray(service) ? service : [service];
276
266
 
277
267
  // Filter the host array against the provided services.
278
- return (services.length > 0) ?
279
- this.hosts.filter((host) => services.includes(host.service)) :
280
- [...this.hosts];
268
+ return services.length > 0
269
+ ? this.hosts.filter((host) => services.includes(host.service))
270
+ : [...this.hosts];
281
271
  }
282
272
 
283
273
  /**
@@ -291,12 +281,10 @@ export default class ServiceRegistry {
291
281
  */
292
282
  filterUrl(url = []) {
293
283
  // Generate an array of URLs regardless of the parameter type.
294
- const urls = (Array.isArray(url) ? url : [url]);
284
+ const urls = Array.isArray(url) ? url : [url];
295
285
 
296
286
  // Filter the host array against the provided URLs.
297
- return (urls.length > 0) ?
298
- this.hosts.filter((host) => urls.includes(host.url)) :
299
- [...this.hosts];
287
+ return urls.length > 0 ? this.hosts.filter((host) => urls.includes(host.url)) : [...this.hosts];
300
288
  }
301
289
 
302
290
  /**
@@ -308,17 +296,9 @@ export default class ServiceRegistry {
308
296
  * @param {HostFilter} [filter] - The inclusive filter for hosts to find.
309
297
  * @returns {Array<ServiceHost>} - The filtered hosts.
310
298
  */
311
- find({
312
- active,
313
- catalog,
314
- cluster,
315
- local,
316
- priority,
317
- service,
318
- url
319
- } = {}) {
299
+ find({active, catalog, cluster, local, priority, service, url} = {}) {
320
300
  return this.hosts.filter(
321
- (host) => (
301
+ (host) =>
322
302
  this.filterActive(active).includes(host) &&
323
303
  this.filterCatalog(catalog).includes(host) &&
324
304
  this.filterCluster(cluster).includes(host) &&
@@ -326,7 +306,6 @@ export default class ServiceRegistry {
326
306
  this.filterPriority(priority).includes(host) &&
327
307
  this.filterService(service).includes(host) &&
328
308
  this.filterUrl(url).includes(host)
329
- )
330
309
  );
331
310
  }
332
311
 
@@ -342,16 +321,16 @@ export default class ServiceRegistry {
342
321
  */
343
322
  load(hosts = []) {
344
323
  // Validate that the provided hosts are eligible to be loaded.
345
- const validHosts = hosts.filter((host) => !!(
346
- ServiceRegistry.mapCatalogName({
347
- id: host.catalog,
348
- type: SERVICE_CATALOGS_ENUM_TYPES.STRING
349
- })));
324
+ const validHosts = hosts.filter(
325
+ (host) =>
326
+ !!ServiceRegistry.mapCatalogName({
327
+ id: host.catalog,
328
+ type: SERVICE_CATALOGS_ENUM_TYPES.STRING,
329
+ })
330
+ );
350
331
 
351
332
  // Load the eligible hosts.
352
- this.hosts.push(
353
- ...validHosts.map((loadableHost) => new ServiceHost(loadableHost))
354
- );
333
+ this.hosts.push(...validHosts.map((loadableHost) => new ServiceHost(loadableHost)));
355
334
 
356
335
  return this;
357
336
  }
@@ -371,11 +350,9 @@ export default class ServiceRegistry {
371
350
  const replacing = this.find(filter);
372
351
 
373
352
  // Mark the hosts from the array as replaced.
374
- replacing.forEach(
375
- (host) => {
376
- host.setStatus({replaced: true});
377
- }
378
- );
353
+ replacing.forEach((host) => {
354
+ host.setStatus({replaced: true});
355
+ });
379
356
 
380
357
  // Return the marked hosts.
381
358
  return replacing;
@@ -396,11 +373,9 @@ export default class ServiceRegistry {
396
373
  const resetting = this.find(filter);
397
374
 
398
375
  // Mark the hosts from the array as replaced.
399
- resetting.forEach(
400
- (host) => {
401
- host.setStatus({failed: false});
402
- }
403
- );
376
+ resetting.forEach((host) => {
377
+ host.setStatus({failed: false});
378
+ });
404
379
 
405
380
  // Return the marked hosts.
406
381
  return resetting;
@@ -423,7 +398,7 @@ export default class ServiceRegistry {
423
398
  if (typeof id === 'number') {
424
399
  // Validate that the desired type is a number.
425
400
  if (type === SERVICE_CATALOGS_ENUM_TYPES.NUMBER) {
426
- return (SERVICE_CATALOGS[id] !== undefined) ? id : undefined;
401
+ return SERVICE_CATALOGS[id] !== undefined ? id : undefined;
427
402
  }
428
403
 
429
404
  // Validate that the desired type is a string.
@@ -441,9 +416,7 @@ export default class ServiceRegistry {
441
416
 
442
417
  // Validate that the desired type is a number.
443
418
  if (type === SERVICE_CATALOGS_ENUM_TYPES.NUMBER) {
444
- return (SERVICE_CATALOGS.includes(id)) ?
445
- SERVICE_CATALOGS.indexOf(id) :
446
- undefined;
419
+ return SERVICE_CATALOGS.includes(id) ? SERVICE_CATALOGS.indexOf(id) : undefined;
447
420
  }
448
421
  }
449
422
 
@@ -465,7 +438,7 @@ export default class ServiceRegistry {
465
438
  // Collect the service catalog name if needed.
466
439
  const catalogIndex = ServiceRegistry.mapCatalogName({
467
440
  id: catalog,
468
- type: SERVICE_CATALOGS_ENUM_TYPES.STRING
441
+ type: SERVICE_CATALOGS_ENUM_TYPES.STRING,
469
442
  });
470
443
 
471
444
  // Validate that the target catalog exists.
@@ -482,7 +455,7 @@ export default class ServiceRegistry {
482
455
  hostGroup: key,
483
456
  id: host.id,
484
457
  priority: host.priority,
485
- uri: host.host
458
+ uri: host.host,
486
459
  }))
487
460
  );
488
461
 
@@ -22,11 +22,9 @@ export default class ServiceState {
22
22
  */
23
23
  constructor() {
24
24
  // Iterate over the possible catalog names and generate their states.
25
- SERVICE_CATALOGS.forEach(
26
- (catalog) => {
27
- this[catalog] = ServiceState.generateCatalogState();
28
- }
29
- );
25
+ SERVICE_CATALOGS.forEach((catalog) => {
26
+ this[catalog] = ServiceState.generateCatalogState();
27
+ });
30
28
  }
31
29
 
32
30
  /**
@@ -74,7 +72,7 @@ export default class ServiceState {
74
72
  static generateCatalogState() {
75
73
  return {
76
74
  collecting: false,
77
- ready: false
75
+ ready: false,
78
76
  };
79
77
  }
80
78
  }
@@ -11,8 +11,8 @@ const ServiceUrl = AmpState.extend({
11
11
 
12
12
  props: {
13
13
  defaultUrl: ['string', true, undefined],
14
- hosts: ['array', false, () => ([])],
15
- name: ['string', true, undefined]
14
+ hosts: ['array', false, () => []],
15
+ name: ['string', true, undefined],
16
16
  },
17
17
 
18
18
  /**
@@ -39,7 +39,7 @@ const ServiceUrl = AmpState.extend({
39
39
  _getHostUrls() {
40
40
  return this.hosts.map((host) => ({
41
41
  url: this._generateHostUrl(host.host),
42
- priority: host.priority
42
+ priority: host.priority,
43
43
  }));
44
44
  },
45
45
 
@@ -56,28 +56,29 @@ const ServiceUrl = AmpState.extend({
56
56
  return this.defaultUrl;
57
57
  }
58
58
 
59
- let filteredHosts = clusterId ?
60
- this.hosts.filter((host) => host.id === clusterId) :
61
- this.hosts.filter((host) => host.homeCluster);
59
+ let filteredHosts = clusterId
60
+ ? this.hosts.filter((host) => host.id === clusterId)
61
+ : this.hosts.filter((host) => host.homeCluster);
62
62
 
63
- const aliveHosts = filteredHosts.filter(
64
- (host) => !host.failed
65
- );
63
+ const aliveHosts = filteredHosts.filter((host) => !host.failed);
66
64
 
67
- filteredHosts = (aliveHosts.length === 0) ?
68
- filteredHosts.map(
69
- (host) => {
70
- /* eslint-disable-next-line no-param-reassign */
71
- host.failed = false;
65
+ filteredHosts =
66
+ aliveHosts.length === 0
67
+ ? filteredHosts.map((host) => {
68
+ /* eslint-disable-next-line no-param-reassign */
69
+ host.failed = false;
72
70
 
73
- return host;
74
- }
75
- ) : aliveHosts;
71
+ return host;
72
+ })
73
+ : aliveHosts;
76
74
 
77
- return this._generateHostUrl(filteredHosts.reduce((previous, current) => (
78
- (previous.priority > current.priority || !previous.homeCluster) ?
79
- current : previous
80
- ), {}).host);
75
+ return this._generateHostUrl(
76
+ filteredHosts.reduce(
77
+ (previous, current) =>
78
+ previous.priority > current.priority || !previous.homeCluster ? current : previous,
79
+ {}
80
+ ).host
81
+ );
81
82
  },
82
83
 
83
84
  /**
@@ -99,7 +100,7 @@ const ServiceUrl = AmpState.extend({
99
100
  foundHost.failed = true;
100
101
  }
101
102
 
102
- return (foundHost !== undefined);
103
+ return foundHost !== undefined;
103
104
  },
104
105
 
105
106
  /**
@@ -116,7 +117,7 @@ const ServiceUrl = AmpState.extend({
116
117
  }
117
118
 
118
119
  return this._getPriorityHostUrl(clusterId);
119
- }
120
+ },
120
121
  });
121
122
  /* eslint-enable no-underscore-dangle */
122
123