@webex/webex-core 3.8.0-next.21 → 3.8.0-next.23
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/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/services.js +1 -1
- package/dist/lib/services-v2/constants.js.map +1 -1
- package/dist/lib/services-v2/index.js +5 -5
- package/dist/lib/services-v2/index.js.map +1 -1
- package/dist/lib/services-v2/service-catalog.js +26 -30
- package/dist/lib/services-v2/service-catalog.js.map +1 -1
- package/dist/lib/services-v2/service-detail.js +94 -0
- package/dist/lib/services-v2/service-detail.js.map +1 -0
- package/dist/lib/services-v2/service-fed-ramp.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +70 -48
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/lib/services-v2/types.js +7 -0
- package/dist/lib/services-v2/types.js.map +1 -0
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/package.json +13 -13
- package/src/index.js +1 -1
- package/src/lib/services-v2/{index.js → index.ts} +1 -1
- package/src/lib/services-v2/{service-catalog.js → service-catalog.ts} +41 -47
- package/src/lib/services-v2/service-detail.ts +97 -0
- package/src/lib/services-v2/services-v2.js +41 -24
- package/src/lib/services-v2/types.ts +12 -0
- package/test/fixtures/host-catalog-v2.js +18 -16
- package/test/unit/spec/services-v2/service-detail.ts +147 -0
- package/test/unit/spec/services-v2/services-v2.js +12 -14
- package/dist/lib/services-v2/service-url.js +0 -119
- package/dist/lib/services-v2/service-url.js.map +0 -1
- package/src/lib/services-v2/service-url.js +0 -124
- /package/src/lib/services-v2/{constants.js → constants.ts} +0 -0
- /package/src/lib/services-v2/{service-fed-ramp.js → service-fed-ramp.ts} +0 -0
|
@@ -16,7 +16,6 @@ const waitForAsync = () =>
|
|
|
16
16
|
})
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
/* eslint-disable no-underscore-dangle */
|
|
20
19
|
describe('webex-core', () => {
|
|
21
20
|
describe('ServicesV2', () => {
|
|
22
21
|
let webex;
|
|
@@ -316,24 +315,24 @@ describe('webex-core', () => {
|
|
|
316
315
|
// });
|
|
317
316
|
// });
|
|
318
317
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
318
|
+
describe('#updateCatalog', () => {
|
|
319
|
+
it('updates the catalog', async () => {
|
|
320
|
+
const serviceGroup = 'postauth';
|
|
321
|
+
const hostmap = [{hostmap: 'hostmap'}];
|
|
323
322
|
|
|
324
|
-
|
|
323
|
+
services._formatReceivedHostmap = sinon.stub().returns([{some: 'hostmap'}]);
|
|
325
324
|
|
|
326
|
-
|
|
325
|
+
catalog.updateServiceGroups = sinon.stub().returns(Promise.resolve([{some: 'value'}]));
|
|
327
326
|
|
|
328
|
-
|
|
327
|
+
const result = await services.updateCatalog(serviceGroup, hostmap);
|
|
329
328
|
|
|
330
|
-
|
|
329
|
+
assert.calledWith(services._formatReceivedHostmap, hostmap);
|
|
331
330
|
|
|
332
|
-
|
|
331
|
+
assert.calledWith(catalog.updateServiceGroups, serviceGroup, [{some: 'hostmap'}]);
|
|
333
332
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
assert.deepEqual(result, [{some: 'value'}]);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
337
336
|
|
|
338
337
|
// describe('#_fetchNewServiceHostmap()', () => {
|
|
339
338
|
// beforeEach(() => {
|
|
@@ -561,4 +560,3 @@ describe('webex-core', () => {
|
|
|
561
560
|
// });
|
|
562
561
|
});
|
|
563
562
|
});
|
|
564
|
-
/* eslint-enable no-underscore-dangle */
|
|
@@ -1,119 +0,0 @@
|
|
|
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 _url = _interopRequireDefault(require("url"));
|
|
10
|
-
var _ampersandState = _interopRequireDefault(require("ampersand-state"));
|
|
11
|
-
/* eslint-disable no-underscore-dangle */
|
|
12
|
-
/**
|
|
13
|
-
* @class
|
|
14
|
-
*/
|
|
15
|
-
var ServiceUrl = _ampersandState.default.extend({
|
|
16
|
-
namespace: 'ServiceUrl',
|
|
17
|
-
props: {
|
|
18
|
-
defaultUrl: ['string', true, undefined],
|
|
19
|
-
hosts: ['array', false, function () {
|
|
20
|
-
return [];
|
|
21
|
-
}],
|
|
22
|
-
name: ['string', true, undefined]
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Generate a host url based on the host
|
|
26
|
-
* uri provided.
|
|
27
|
-
* @param {string} hostUri
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
_generateHostUrl: function _generateHostUrl(hostUri) {
|
|
31
|
-
var url = _url.default.parse(this.defaultUrl);
|
|
32
|
-
|
|
33
|
-
// setting url.hostname will not apply during Url.format(), set host via
|
|
34
|
-
// a string literal instead.
|
|
35
|
-
url.host = "".concat(hostUri).concat(url.port ? ":".concat(url.port) : '');
|
|
36
|
-
return _url.default.format(url);
|
|
37
|
-
},
|
|
38
|
-
/**
|
|
39
|
-
* Generate a list of urls based on this
|
|
40
|
-
* `ServiceUrl`'s known hosts.
|
|
41
|
-
* @returns {string[]}
|
|
42
|
-
*/
|
|
43
|
-
_getHostUrls: function _getHostUrls() {
|
|
44
|
-
var _this = this;
|
|
45
|
-
return this.hosts.map(function (host) {
|
|
46
|
-
return {
|
|
47
|
-
url: _this._generateHostUrl(host.host),
|
|
48
|
-
priority: host.priority
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
/**
|
|
53
|
-
* Get the current host url with the highest priority. If a clusterId is not
|
|
54
|
-
* provided, this will only return a URL with a filtered host that has the
|
|
55
|
-
* `homeCluster` value set to `true`.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} [clusterId] - The clusterId to filter for a priority host.
|
|
58
|
-
* @returns {string} - The priority host url.
|
|
59
|
-
*/
|
|
60
|
-
_getPriorityHostUrl: function _getPriorityHostUrl(clusterId) {
|
|
61
|
-
if (this.hosts.length === 0) {
|
|
62
|
-
return this.defaultUrl;
|
|
63
|
-
}
|
|
64
|
-
var filteredHosts = clusterId ? this.hosts.filter(function (host) {
|
|
65
|
-
return host.id === clusterId;
|
|
66
|
-
}) : this.hosts.filter(function (host) {
|
|
67
|
-
return host.homeCluster;
|
|
68
|
-
});
|
|
69
|
-
var aliveHosts = filteredHosts.filter(function (host) {
|
|
70
|
-
return !host.failed;
|
|
71
|
-
});
|
|
72
|
-
filteredHosts = aliveHosts.length === 0 ? filteredHosts.map(function (host) {
|
|
73
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
74
|
-
host.failed = false;
|
|
75
|
-
return host;
|
|
76
|
-
}) : aliveHosts;
|
|
77
|
-
return this._generateHostUrl(filteredHosts.reduce(function (previous, current) {
|
|
78
|
-
return previous.priority > current.priority || !previous.homeCluster ? current : previous;
|
|
79
|
-
}, {}).host);
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* Attempt to mark a host from this `ServiceUrl` as failed and return true
|
|
83
|
-
* if the provided url has a host that could be successfully marked as failed.
|
|
84
|
-
*
|
|
85
|
-
* @param {string} url
|
|
86
|
-
* @returns {boolean}
|
|
87
|
-
*/
|
|
88
|
-
failHost: function failHost(url) {
|
|
89
|
-
if (url === this.defaultUrl) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
var _Url$parse = _url.default.parse(url),
|
|
93
|
-
hostname = _Url$parse.hostname;
|
|
94
|
-
var foundHost = this.hosts.find(function (hostObj) {
|
|
95
|
-
return hostObj.host === hostname;
|
|
96
|
-
});
|
|
97
|
-
if (foundHost) {
|
|
98
|
-
foundHost.failed = true;
|
|
99
|
-
}
|
|
100
|
-
return foundHost !== undefined;
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* Get the current `defaultUrl` or generate a url using the host with the
|
|
104
|
-
* highest priority via host rendering.
|
|
105
|
-
*
|
|
106
|
-
* @param {boolean} [priorityHost] - Retrieve the priority host.
|
|
107
|
-
* @param {string} [clusterId] - Cluster to match a host against.
|
|
108
|
-
* @returns {string} - The full service url.
|
|
109
|
-
*/
|
|
110
|
-
get: function get(priorityHost, clusterId) {
|
|
111
|
-
if (!priorityHost) {
|
|
112
|
-
return this.defaultUrl;
|
|
113
|
-
}
|
|
114
|
-
return this._getPriorityHostUrl(clusterId);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
/* eslint-enable no-underscore-dangle */
|
|
118
|
-
var _default = exports.default = ServiceUrl;
|
|
119
|
-
//# sourceMappingURL=service-url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","ServiceUrl","AmpState","extend","namespace","props","defaultUrl","undefined","hosts","name","_generateHostUrl","hostUri","url","Url","parse","host","concat","port","format","_getHostUrls","_this","map","priority","_getPriorityHostUrl","clusterId","length","filteredHosts","filter","id","homeCluster","aliveHosts","failed","reduce","previous","current","failHost","_Url$parse","hostname","foundHost","find","hostObj","get","priorityHost","_default","exports","default"],"sources":["service-url.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceUrl = AmpState.extend({\n namespace: 'ServiceUrl',\n\n props: {\n defaultUrl: ['string', true, undefined],\n hosts: ['array', false, () => []],\n name: ['string', true, undefined],\n },\n\n /**\n * Generate a host url based on the host\n * uri provided.\n * @param {string} hostUri\n * @returns {string}\n */\n _generateHostUrl(hostUri) {\n const url = Url.parse(this.defaultUrl);\n\n // setting url.hostname will not apply during Url.format(), set host via\n // a string literal instead.\n url.host = `${hostUri}${url.port ? `:${url.port}` : ''}`;\n\n return Url.format(url);\n },\n\n /**\n * Generate a list of urls based on this\n * `ServiceUrl`'s known hosts.\n * @returns {string[]}\n */\n _getHostUrls() {\n return this.hosts.map((host) => ({\n url: this._generateHostUrl(host.host),\n priority: host.priority,\n }));\n },\n\n /**\n * Get the current host url with the highest priority. If a clusterId is not\n * provided, this will only return a URL with a filtered host that has the\n * `homeCluster` value set to `true`.\n *\n * @param {string} [clusterId] - The clusterId to filter for a priority host.\n * @returns {string} - The priority host url.\n */\n _getPriorityHostUrl(clusterId) {\n if (this.hosts.length === 0) {\n return this.defaultUrl;\n }\n\n let filteredHosts = clusterId\n ? this.hosts.filter((host) => host.id === clusterId)\n : this.hosts.filter((host) => host.homeCluster);\n\n const aliveHosts = filteredHosts.filter((host) => !host.failed);\n\n filteredHosts =\n aliveHosts.length === 0\n ? filteredHosts.map((host) => {\n /* eslint-disable-next-line no-param-reassign */\n host.failed = false;\n\n return host;\n })\n : aliveHosts;\n\n return this._generateHostUrl(\n filteredHosts.reduce(\n (previous, current) =>\n previous.priority > current.priority || !previous.homeCluster ? current : previous,\n {}\n ).host\n );\n },\n\n /**\n * Attempt to mark a host from this `ServiceUrl` as failed and return true\n * if the provided url has a host that could be successfully marked as failed.\n *\n * @param {string} url\n * @returns {boolean}\n */\n failHost(url) {\n if (url === this.defaultUrl) {\n return true;\n }\n\n const {hostname} = Url.parse(url);\n const foundHost = this.hosts.find((hostObj) => hostObj.host === hostname);\n\n if (foundHost) {\n foundHost.failed = true;\n }\n\n return foundHost !== undefined;\n },\n\n /**\n * Get the current `defaultUrl` or generate a url using the host with the\n * highest priority via host rendering.\n *\n * @param {boolean} [priorityHost] - Retrieve the priority host.\n * @param {string} [clusterId] - Cluster to match a host against.\n * @returns {string} - The full service url.\n */\n get(priorityHost, clusterId) {\n if (!priorityHost) {\n return this.defaultUrl;\n }\n\n return this._getPriorityHostUrl(clusterId);\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceUrl;\n"],"mappings":"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"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import Url from 'url';
|
|
2
|
-
|
|
3
|
-
import AmpState from 'ampersand-state';
|
|
4
|
-
|
|
5
|
-
/* eslint-disable no-underscore-dangle */
|
|
6
|
-
/**
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
const ServiceUrl = AmpState.extend({
|
|
10
|
-
namespace: 'ServiceUrl',
|
|
11
|
-
|
|
12
|
-
props: {
|
|
13
|
-
defaultUrl: ['string', true, undefined],
|
|
14
|
-
hosts: ['array', false, () => []],
|
|
15
|
-
name: ['string', true, undefined],
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generate a host url based on the host
|
|
20
|
-
* uri provided.
|
|
21
|
-
* @param {string} hostUri
|
|
22
|
-
* @returns {string}
|
|
23
|
-
*/
|
|
24
|
-
_generateHostUrl(hostUri) {
|
|
25
|
-
const url = Url.parse(this.defaultUrl);
|
|
26
|
-
|
|
27
|
-
// setting url.hostname will not apply during Url.format(), set host via
|
|
28
|
-
// a string literal instead.
|
|
29
|
-
url.host = `${hostUri}${url.port ? `:${url.port}` : ''}`;
|
|
30
|
-
|
|
31
|
-
return Url.format(url);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Generate a list of urls based on this
|
|
36
|
-
* `ServiceUrl`'s known hosts.
|
|
37
|
-
* @returns {string[]}
|
|
38
|
-
*/
|
|
39
|
-
_getHostUrls() {
|
|
40
|
-
return this.hosts.map((host) => ({
|
|
41
|
-
url: this._generateHostUrl(host.host),
|
|
42
|
-
priority: host.priority,
|
|
43
|
-
}));
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get the current host url with the highest priority. If a clusterId is not
|
|
48
|
-
* provided, this will only return a URL with a filtered host that has the
|
|
49
|
-
* `homeCluster` value set to `true`.
|
|
50
|
-
*
|
|
51
|
-
* @param {string} [clusterId] - The clusterId to filter for a priority host.
|
|
52
|
-
* @returns {string} - The priority host url.
|
|
53
|
-
*/
|
|
54
|
-
_getPriorityHostUrl(clusterId) {
|
|
55
|
-
if (this.hosts.length === 0) {
|
|
56
|
-
return this.defaultUrl;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let filteredHosts = clusterId
|
|
60
|
-
? this.hosts.filter((host) => host.id === clusterId)
|
|
61
|
-
: this.hosts.filter((host) => host.homeCluster);
|
|
62
|
-
|
|
63
|
-
const aliveHosts = filteredHosts.filter((host) => !host.failed);
|
|
64
|
-
|
|
65
|
-
filteredHosts =
|
|
66
|
-
aliveHosts.length === 0
|
|
67
|
-
? filteredHosts.map((host) => {
|
|
68
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
69
|
-
host.failed = false;
|
|
70
|
-
|
|
71
|
-
return host;
|
|
72
|
-
})
|
|
73
|
-
: aliveHosts;
|
|
74
|
-
|
|
75
|
-
return this._generateHostUrl(
|
|
76
|
-
filteredHosts.reduce(
|
|
77
|
-
(previous, current) =>
|
|
78
|
-
previous.priority > current.priority || !previous.homeCluster ? current : previous,
|
|
79
|
-
{}
|
|
80
|
-
).host
|
|
81
|
-
);
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Attempt to mark a host from this `ServiceUrl` as failed and return true
|
|
86
|
-
* if the provided url has a host that could be successfully marked as failed.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} url
|
|
89
|
-
* @returns {boolean}
|
|
90
|
-
*/
|
|
91
|
-
failHost(url) {
|
|
92
|
-
if (url === this.defaultUrl) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const {hostname} = Url.parse(url);
|
|
97
|
-
const foundHost = this.hosts.find((hostObj) => hostObj.host === hostname);
|
|
98
|
-
|
|
99
|
-
if (foundHost) {
|
|
100
|
-
foundHost.failed = true;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return foundHost !== undefined;
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Get the current `defaultUrl` or generate a url using the host with the
|
|
108
|
-
* highest priority via host rendering.
|
|
109
|
-
*
|
|
110
|
-
* @param {boolean} [priorityHost] - Retrieve the priority host.
|
|
111
|
-
* @param {string} [clusterId] - Cluster to match a host against.
|
|
112
|
-
* @returns {string} - The full service url.
|
|
113
|
-
*/
|
|
114
|
-
get(priorityHost, clusterId) {
|
|
115
|
-
if (!priorityHost) {
|
|
116
|
-
return this.defaultUrl;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this._getPriorityHostUrl(clusterId);
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
/* eslint-enable no-underscore-dangle */
|
|
123
|
-
|
|
124
|
-
export default ServiceUrl;
|
|
File without changes
|
|
File without changes
|