@webex/webex-core 3.8.0-next.2 → 3.8.0-next.20
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 +43 -0
- 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/service-catalog.js +23 -68
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +1 -1
- package/dist/lib/services-v2/constants.js +17 -0
- package/dist/lib/services-v2/constants.js.map +1 -0
- package/dist/lib/services-v2/index.js +58 -0
- package/dist/lib/services-v2/index.js.map +1 -0
- package/dist/lib/services-v2/interceptors/hostmap.js +64 -0
- package/dist/lib/services-v2/interceptors/hostmap.js.map +1 -0
- package/dist/lib/services-v2/interceptors/server-error.js +77 -0
- package/dist/lib/services-v2/interceptors/server-error.js.map +1 -0
- package/dist/lib/services-v2/interceptors/service.js +137 -0
- package/dist/lib/services-v2/interceptors/service.js.map +1 -0
- package/dist/lib/services-v2/metrics.js +12 -0
- package/dist/lib/services-v2/metrics.js.map +1 -0
- package/dist/lib/services-v2/service-catalog.js +433 -0
- package/dist/lib/services-v2/service-catalog.js.map +1 -0
- package/dist/lib/services-v2/service-fed-ramp.js +13 -0
- package/dist/lib/services-v2/service-fed-ramp.js.map +1 -0
- package/dist/lib/services-v2/service-url.js +119 -0
- package/dist/lib/services-v2/service-url.js.map +1 -0
- package/dist/lib/services-v2/services-v2.js +963 -0
- package/dist/lib/services-v2/services-v2.js.map +1 -0
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/dist/webex-core.js.map +1 -1
- package/package.json +13 -13
- package/src/index.js +10 -0
- package/src/lib/services/service-catalog.js +14 -54
- package/src/lib/services-v2/README.md +3 -0
- package/src/lib/services-v2/constants.js +21 -0
- package/src/lib/services-v2/index.js +23 -0
- package/src/lib/services-v2/interceptors/hostmap.js +36 -0
- package/src/lib/services-v2/interceptors/server-error.js +48 -0
- package/src/lib/services-v2/interceptors/service.js +101 -0
- package/src/lib/services-v2/metrics.js +4 -0
- package/src/lib/services-v2/service-catalog.js +455 -0
- package/src/lib/services-v2/service-fed-ramp.js +5 -0
- package/src/lib/services-v2/service-url.js +124 -0
- package/src/lib/services-v2/services-v2.js +971 -0
- package/test/fixtures/host-catalog-v2.js +247 -0
- package/test/unit/spec/services/service-catalog.js +30 -90
- package/test/unit/spec/services-v2/services-v2.js +564 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
|
|
4
|
+
var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
|
|
5
|
+
var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
|
|
6
|
+
var _Array$isArray = require("@babel/runtime-corejs2/core-js/array/is-array");
|
|
7
|
+
var _Object$keys3 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
8
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
9
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
10
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
11
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
12
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
14
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
exports.default = void 0;
|
|
18
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
19
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
21
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
22
|
+
var _url = _interopRequireDefault(require("url"));
|
|
23
|
+
var _ampersandState = _interopRequireDefault(require("ampersand-state"));
|
|
24
|
+
var _lodash = require("lodash");
|
|
25
|
+
var _serviceUrl = _interopRequireDefault(require("./service-url"));
|
|
26
|
+
function ownKeys(e, r) { var t = _Object$keys3(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
27
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && o[_Symbol$iterator] || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
29
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
30
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
31
|
+
/* eslint-disable no-underscore-dangle */
|
|
32
|
+
/**
|
|
33
|
+
* @class
|
|
34
|
+
*/
|
|
35
|
+
var ServiceCatalog = _ampersandState.default.extend({
|
|
36
|
+
namespace: 'ServiceCatalog',
|
|
37
|
+
props: {
|
|
38
|
+
serviceGroups: ['object', true, function () {
|
|
39
|
+
return {
|
|
40
|
+
discovery: [],
|
|
41
|
+
override: [],
|
|
42
|
+
preauth: [],
|
|
43
|
+
postauth: [],
|
|
44
|
+
signin: []
|
|
45
|
+
};
|
|
46
|
+
}],
|
|
47
|
+
status: ['object', true, function () {
|
|
48
|
+
return {
|
|
49
|
+
discovery: {
|
|
50
|
+
ready: false,
|
|
51
|
+
collecting: false
|
|
52
|
+
},
|
|
53
|
+
override: {
|
|
54
|
+
ready: false,
|
|
55
|
+
collecting: false
|
|
56
|
+
},
|
|
57
|
+
preauth: {
|
|
58
|
+
ready: false,
|
|
59
|
+
collecting: false
|
|
60
|
+
},
|
|
61
|
+
postauth: {
|
|
62
|
+
ready: false,
|
|
63
|
+
collecting: false
|
|
64
|
+
},
|
|
65
|
+
signin: {
|
|
66
|
+
ready: false,
|
|
67
|
+
collecting: false
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}],
|
|
71
|
+
isReady: ['boolean', false, false],
|
|
72
|
+
allowedDomains: ['array', false, function () {
|
|
73
|
+
return [];
|
|
74
|
+
}]
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* @private
|
|
78
|
+
* Search the service url array to locate a `ServiceUrl`
|
|
79
|
+
* class object based on its name.
|
|
80
|
+
* @param {string} name
|
|
81
|
+
* @param {string} [serviceGroup]
|
|
82
|
+
* @returns {ServiceUrl}
|
|
83
|
+
*/
|
|
84
|
+
_getUrl: function _getUrl(name, serviceGroup) {
|
|
85
|
+
var serviceUrls = typeof serviceGroup === 'string' ? this.serviceGroups[serviceGroup] || [] : [].concat((0, _toConsumableArray2.default)(this.serviceGroups.override), (0, _toConsumableArray2.default)(this.serviceGroups.postauth), (0, _toConsumableArray2.default)(this.serviceGroups.signin), (0, _toConsumableArray2.default)(this.serviceGroups.preauth), (0, _toConsumableArray2.default)(this.serviceGroups.discovery));
|
|
86
|
+
return serviceUrls.find(function (serviceUrl) {
|
|
87
|
+
return serviceUrl.name === name;
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* @private
|
|
92
|
+
* Generate an array of `ServiceUrl`s that is organized from highest auth
|
|
93
|
+
* level to lowest auth level.
|
|
94
|
+
* @returns {Array<ServiceUrl>} - array of `ServiceUrl`s
|
|
95
|
+
*/
|
|
96
|
+
_listServiceUrls: function _listServiceUrls() {
|
|
97
|
+
return [].concat((0, _toConsumableArray2.default)(this.serviceGroups.override), (0, _toConsumableArray2.default)(this.serviceGroups.postauth), (0, _toConsumableArray2.default)(this.serviceGroups.signin), (0, _toConsumableArray2.default)(this.serviceGroups.preauth), (0, _toConsumableArray2.default)(this.serviceGroups.discovery));
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* @private
|
|
101
|
+
* Safely load one or more `ServiceUrl`s into this `Services` instance.
|
|
102
|
+
* @param {string} serviceGroup
|
|
103
|
+
* @param {Array<ServiceUrl>} services
|
|
104
|
+
* @returns {Services}
|
|
105
|
+
*/
|
|
106
|
+
_loadServiceUrls: function _loadServiceUrls(serviceGroup, services) {
|
|
107
|
+
var _this = this;
|
|
108
|
+
// declare namespaces outside of loop
|
|
109
|
+
var existingService;
|
|
110
|
+
services.forEach(function (service) {
|
|
111
|
+
existingService = _this._getUrl(service.name, serviceGroup);
|
|
112
|
+
if (!existingService) {
|
|
113
|
+
_this.serviceGroups[serviceGroup].push(service);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return this;
|
|
117
|
+
},
|
|
118
|
+
/**
|
|
119
|
+
* @private
|
|
120
|
+
* Safely unload one or more `ServiceUrl`s into this `Services` instance
|
|
121
|
+
* @param {string} serviceGroup
|
|
122
|
+
* @param {Array<ServiceUrl>} services
|
|
123
|
+
* @returns {Services}
|
|
124
|
+
*/
|
|
125
|
+
_unloadServiceUrls: function _unloadServiceUrls(serviceGroup, services) {
|
|
126
|
+
var _this2 = this;
|
|
127
|
+
// declare namespaces outside of loop
|
|
128
|
+
var existingService;
|
|
129
|
+
services.forEach(function (service) {
|
|
130
|
+
existingService = _this2._getUrl(service.name, serviceGroup);
|
|
131
|
+
if (existingService) {
|
|
132
|
+
_this2.serviceGroups[serviceGroup].splice(_this2.serviceGroups[serviceGroup].indexOf(existingService), 1);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return this;
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Clear all collected catalog data and reset catalog status.
|
|
139
|
+
*
|
|
140
|
+
* @returns {void}
|
|
141
|
+
*/
|
|
142
|
+
clean: function clean() {
|
|
143
|
+
this.serviceGroups.preauth.length = 0;
|
|
144
|
+
this.serviceGroups.signin.length = 0;
|
|
145
|
+
this.serviceGroups.postauth.length = 0;
|
|
146
|
+
this.status.preauth = {
|
|
147
|
+
ready: false
|
|
148
|
+
};
|
|
149
|
+
this.status.signin = {
|
|
150
|
+
ready: false
|
|
151
|
+
};
|
|
152
|
+
this.status.postauth = {
|
|
153
|
+
ready: false
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* Search over all service groups to find a cluster id based
|
|
158
|
+
* on a given url.
|
|
159
|
+
* @param {string} url - Must be parsable by `Url`
|
|
160
|
+
* @returns {string} - ClusterId of a given url
|
|
161
|
+
*/
|
|
162
|
+
findClusterId: function findClusterId(url) {
|
|
163
|
+
var incomingUrlObj = _url.default.parse(url);
|
|
164
|
+
var serviceUrlObj;
|
|
165
|
+
for (var _i = 0, _Object$keys = (0, _keys.default)(this.serviceGroups); _i < _Object$keys.length; _i++) {
|
|
166
|
+
var key = _Object$keys[_i];
|
|
167
|
+
var _iterator = _createForOfIteratorHelper(this.serviceGroups[key]),
|
|
168
|
+
_step;
|
|
169
|
+
try {
|
|
170
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
171
|
+
var service = _step.value;
|
|
172
|
+
serviceUrlObj = _url.default.parse(service.defaultUrl);
|
|
173
|
+
var _iterator2 = _createForOfIteratorHelper(service.hosts),
|
|
174
|
+
_step2;
|
|
175
|
+
try {
|
|
176
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
177
|
+
var _host = _step2.value;
|
|
178
|
+
if (incomingUrlObj.hostname === _host.host && _host.id) {
|
|
179
|
+
return _host.id;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
} catch (err) {
|
|
183
|
+
_iterator2.e(err);
|
|
184
|
+
} finally {
|
|
185
|
+
_iterator2.f();
|
|
186
|
+
}
|
|
187
|
+
if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {
|
|
188
|
+
// no exact match, so try to grab the first home cluster
|
|
189
|
+
var _iterator3 = _createForOfIteratorHelper(service.hosts),
|
|
190
|
+
_step3;
|
|
191
|
+
try {
|
|
192
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
193
|
+
var host = _step3.value;
|
|
194
|
+
if (host.homeCluster) {
|
|
195
|
+
return host.id;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// no match found still, so return the first entry
|
|
200
|
+
} catch (err) {
|
|
201
|
+
_iterator3.e(err);
|
|
202
|
+
} finally {
|
|
203
|
+
_iterator3.f();
|
|
204
|
+
}
|
|
205
|
+
return service.hosts[0].id;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} catch (err) {
|
|
209
|
+
_iterator.e(err);
|
|
210
|
+
} finally {
|
|
211
|
+
_iterator.f();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return undefined;
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* Search over all service groups and return a service value from a provided
|
|
218
|
+
* clusterId. Currently, this method will return either a service name, or a
|
|
219
|
+
* service url depending on the `value` parameter. If the `value` parameter
|
|
220
|
+
* is set to `name`, it will return a service name to be utilized within the
|
|
221
|
+
* Services plugin methods.
|
|
222
|
+
* @param {object} params
|
|
223
|
+
* @param {string} params.clusterId - clusterId of found service
|
|
224
|
+
* @param {boolean} [params.priorityHost = true] - returns priority host url if true
|
|
225
|
+
* @param {string} [params.serviceGroup] - specify service group
|
|
226
|
+
* @returns {object} service
|
|
227
|
+
* @returns {string} service.name
|
|
228
|
+
* @returns {string} service.url
|
|
229
|
+
*/
|
|
230
|
+
findServiceFromClusterId: function findServiceFromClusterId() {
|
|
231
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
232
|
+
clusterId = _ref.clusterId,
|
|
233
|
+
_ref$priorityHost = _ref.priorityHost,
|
|
234
|
+
priorityHost = _ref$priorityHost === void 0 ? true : _ref$priorityHost,
|
|
235
|
+
serviceGroup = _ref.serviceGroup;
|
|
236
|
+
var serviceUrls = typeof serviceGroup === 'string' ? this.serviceGroups[serviceGroup] || [] : [].concat((0, _toConsumableArray2.default)(this.serviceGroups.override), (0, _toConsumableArray2.default)(this.serviceGroups.postauth), (0, _toConsumableArray2.default)(this.serviceGroups.signin), (0, _toConsumableArray2.default)(this.serviceGroups.preauth), (0, _toConsumableArray2.default)(this.serviceGroups.discovery));
|
|
237
|
+
var identifiedServiceUrl = serviceUrls.find(function (serviceUrl) {
|
|
238
|
+
return serviceUrl.hosts.find(function (host) {
|
|
239
|
+
return host.id === clusterId;
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
if (identifiedServiceUrl) {
|
|
243
|
+
return {
|
|
244
|
+
name: identifiedServiceUrl.name,
|
|
245
|
+
url: identifiedServiceUrl.get(priorityHost, clusterId)
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return undefined;
|
|
249
|
+
},
|
|
250
|
+
/**
|
|
251
|
+
* Find a service based on the provided url.
|
|
252
|
+
* @param {string} url - Must be parsable by `Url`
|
|
253
|
+
* @returns {serviceUrl} - ServiceUrl assocated with provided url
|
|
254
|
+
*/
|
|
255
|
+
findServiceUrlFromUrl: function findServiceUrlFromUrl(url) {
|
|
256
|
+
var serviceUrls = [].concat((0, _toConsumableArray2.default)(this.serviceGroups.discovery), (0, _toConsumableArray2.default)(this.serviceGroups.preauth), (0, _toConsumableArray2.default)(this.serviceGroups.signin), (0, _toConsumableArray2.default)(this.serviceGroups.postauth), (0, _toConsumableArray2.default)(this.serviceGroups.override));
|
|
257
|
+
return serviceUrls.find(function (serviceUrl) {
|
|
258
|
+
// Check to see if the URL we are checking starts with the default URL
|
|
259
|
+
if (url.startsWith(serviceUrl.defaultUrl)) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// If not, we check to see if the alternate URLs match
|
|
264
|
+
// These are made by swapping the host of the default URL
|
|
265
|
+
// with that of an alternate host
|
|
266
|
+
var _iterator4 = _createForOfIteratorHelper(serviceUrl.hosts),
|
|
267
|
+
_step4;
|
|
268
|
+
try {
|
|
269
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
270
|
+
var host = _step4.value;
|
|
271
|
+
var alternateUrl = new URL(serviceUrl.defaultUrl);
|
|
272
|
+
alternateUrl.host = host.host;
|
|
273
|
+
if (url.startsWith(alternateUrl.toString())) {
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
} catch (err) {
|
|
278
|
+
_iterator4.e(err);
|
|
279
|
+
} finally {
|
|
280
|
+
_iterator4.f();
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
});
|
|
284
|
+
},
|
|
285
|
+
/**
|
|
286
|
+
* Finds an allowed domain that matches a specific url.
|
|
287
|
+
*
|
|
288
|
+
* @param {string} url - The url to match the allowed domains against.
|
|
289
|
+
* @returns {string} - The matching allowed domain.
|
|
290
|
+
*/
|
|
291
|
+
findAllowedDomain: function findAllowedDomain(url) {
|
|
292
|
+
var urlObj = _url.default.parse(url);
|
|
293
|
+
if (!urlObj.host) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
return this.allowedDomains.find(function (allowedDomain) {
|
|
297
|
+
return urlObj.host.includes(allowedDomain);
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Get a service url from the current services list by name.
|
|
302
|
+
* @param {string} name
|
|
303
|
+
* @param {boolean} priorityHost
|
|
304
|
+
* @param {string} serviceGroup
|
|
305
|
+
* @returns {string}
|
|
306
|
+
*/
|
|
307
|
+
get: function get(name, priorityHost, serviceGroup) {
|
|
308
|
+
var serviceUrl = this._getUrl(name, serviceGroup);
|
|
309
|
+
return serviceUrl ? serviceUrl.get(priorityHost) : undefined;
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* Get the current allowed domains list.
|
|
313
|
+
*
|
|
314
|
+
* @returns {Array<string>} - the current allowed domains list.
|
|
315
|
+
*/
|
|
316
|
+
getAllowedDomains: function getAllowedDomains() {
|
|
317
|
+
return (0, _toConsumableArray2.default)(this.allowedDomains);
|
|
318
|
+
},
|
|
319
|
+
/**
|
|
320
|
+
* Creates an object where the keys are the service names
|
|
321
|
+
* and the values are the service urls.
|
|
322
|
+
* @param {boolean} priorityHost - use the highest priority if set to `true`
|
|
323
|
+
* @param {string} [serviceGroup]
|
|
324
|
+
* @returns {Record<string, string>}
|
|
325
|
+
*/
|
|
326
|
+
list: function list(priorityHost, serviceGroup) {
|
|
327
|
+
var output = {};
|
|
328
|
+
var serviceUrls = typeof serviceGroup === 'string' ? this.serviceGroups[serviceGroup] || [] : [].concat((0, _toConsumableArray2.default)(this.serviceGroups.discovery), (0, _toConsumableArray2.default)(this.serviceGroups.preauth), (0, _toConsumableArray2.default)(this.serviceGroups.signin), (0, _toConsumableArray2.default)(this.serviceGroups.postauth), (0, _toConsumableArray2.default)(this.serviceGroups.override));
|
|
329
|
+
if (serviceUrls) {
|
|
330
|
+
serviceUrls.forEach(function (serviceUrl) {
|
|
331
|
+
output[serviceUrl.name] = serviceUrl.get(priorityHost);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return output;
|
|
335
|
+
},
|
|
336
|
+
/**
|
|
337
|
+
* Mark a priority host service url as failed.
|
|
338
|
+
* This will mark the host associated with the
|
|
339
|
+
* `ServiceUrl` to be removed from the its
|
|
340
|
+
* respective host array, and then return the next
|
|
341
|
+
* viable host from the `ServiceUrls` host array,
|
|
342
|
+
* or the `ServiceUrls` default url if no other priority
|
|
343
|
+
* hosts are available, or if `noPriorityHosts` is set to
|
|
344
|
+
* `true`.
|
|
345
|
+
* @param {string} url
|
|
346
|
+
* @param {boolean} noPriorityHosts
|
|
347
|
+
* @returns {string}
|
|
348
|
+
*/
|
|
349
|
+
markFailedUrl: function markFailedUrl(url, noPriorityHosts) {
|
|
350
|
+
var _this3 = this;
|
|
351
|
+
var serviceUrl = this._getUrl((0, _keys.default)(this.list()).find(function (key) {
|
|
352
|
+
return _this3._getUrl(key).failHost(url);
|
|
353
|
+
}));
|
|
354
|
+
if (!serviceUrl) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);
|
|
358
|
+
},
|
|
359
|
+
/**
|
|
360
|
+
* Set the allowed domains for the catalog.
|
|
361
|
+
*
|
|
362
|
+
* @param {Array<string>} allowedDomains - allowed domains to be assigned.
|
|
363
|
+
* @returns {void}
|
|
364
|
+
*/
|
|
365
|
+
setAllowedDomains: function setAllowedDomains(allowedDomains) {
|
|
366
|
+
this.allowedDomains = (0, _toConsumableArray2.default)(allowedDomains);
|
|
367
|
+
},
|
|
368
|
+
/**
|
|
369
|
+
*
|
|
370
|
+
* @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains
|
|
371
|
+
* @returns {void}
|
|
372
|
+
*/
|
|
373
|
+
addAllowedDomains: function addAllowedDomains(newAllowedDomains) {
|
|
374
|
+
this.allowedDomains = (0, _lodash.union)(this.allowedDomains, newAllowedDomains);
|
|
375
|
+
},
|
|
376
|
+
/**
|
|
377
|
+
* Update the current list of `ServiceUrl`s against a provided
|
|
378
|
+
* service hostmap.
|
|
379
|
+
* @emits ServiceCatalog#preauthorized
|
|
380
|
+
* @emits ServiceCatalog#postauthorized
|
|
381
|
+
* @param {string} serviceGroup
|
|
382
|
+
* @param {object} serviceHostmap
|
|
383
|
+
* @returns {Services}
|
|
384
|
+
*/
|
|
385
|
+
updateServiceUrls: function updateServiceUrls(serviceGroup, serviceHostmap) {
|
|
386
|
+
var _this4 = this;
|
|
387
|
+
var currentServiceUrls = this.serviceGroups[serviceGroup];
|
|
388
|
+
var unusedUrls = currentServiceUrls.filter(function (serviceUrl) {
|
|
389
|
+
return serviceHostmap.every(function (item) {
|
|
390
|
+
return item.name !== serviceUrl.name;
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
this._unloadServiceUrls(serviceGroup, unusedUrls);
|
|
394
|
+
serviceHostmap.forEach(function (serviceObj) {
|
|
395
|
+
var service = _this4._getUrl(serviceObj.name, serviceGroup);
|
|
396
|
+
if (service) {
|
|
397
|
+
service.defaultUrl = serviceObj.defaultUrl;
|
|
398
|
+
service.hosts = serviceObj.hosts || [];
|
|
399
|
+
} else {
|
|
400
|
+
_this4._loadServiceUrls(serviceGroup, [new _serviceUrl.default(_objectSpread({}, serviceObj))]);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
this.status[serviceGroup].ready = true;
|
|
404
|
+
this.trigger(serviceGroup);
|
|
405
|
+
return this;
|
|
406
|
+
},
|
|
407
|
+
/**
|
|
408
|
+
* Wait until the service catalog is available,
|
|
409
|
+
* or reject after a timeout of 60 seconds.
|
|
410
|
+
* @param {string} serviceGroup
|
|
411
|
+
* @param {number} [timeout] - in seconds
|
|
412
|
+
* @returns {Promise<void>}
|
|
413
|
+
*/
|
|
414
|
+
waitForCatalog: function waitForCatalog(serviceGroup, timeout) {
|
|
415
|
+
var _this5 = this;
|
|
416
|
+
return new _promise.default(function (resolve, reject) {
|
|
417
|
+
if (_this5.status[serviceGroup].ready) {
|
|
418
|
+
resolve();
|
|
419
|
+
}
|
|
420
|
+
var validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;
|
|
421
|
+
var timeoutTimer = setTimeout(function () {
|
|
422
|
+
return reject(new Error("services: timeout occured while waiting for '".concat(serviceGroup, "' catalog to populate")));
|
|
423
|
+
}, validatedTimeout * 1000);
|
|
424
|
+
_this5.once(serviceGroup, function () {
|
|
425
|
+
clearTimeout(timeoutTimer);
|
|
426
|
+
resolve();
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
/* eslint-enable no-underscore-dangle */
|
|
432
|
+
var _default = exports.default = ServiceCatalog;
|
|
433
|
+
//# sourceMappingURL=service-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","_lodash","_serviceUrl","ownKeys","e","r","t","_Object$keys3","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_createForOfIteratorHelper","allowArrayLike","it","_Symbol","_Symbol$iterator","_Array$isArray","_unsupportedIterableToArray","i","F","s","n","done","value","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","prototype","toString","slice","constructor","name","_Array$from","test","arr","len","arr2","Array","ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","serviceGroup","serviceUrls","concat","_toConsumableArray2","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","_this","existingService","service","_unloadServiceUrls","_this2","splice","indexOf","clean","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","_i","_Object$keys","_keys","key","_iterator","_step","defaultUrl","_iterator2","hosts","_step2","host","hostname","id","_iterator3","_step3","homeCluster","undefined","findServiceFromClusterId","_ref","clusterId","_ref$priorityHost","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","startsWith","_iterator4","_step4","alternateUrl","URL","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","_this3","failHost","setAllowedDomains","addAllowedDomains","newAllowedDomains","union","updateServiceUrls","serviceHostmap","_this4","currentServiceUrls","unusedUrls","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","_this5","_promise","resolve","reject","validatedTimeout","timeoutTimer","setTimeout","Error","once","clearTimeout","_default","exports"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport {union} from 'lodash';\nimport ServiceUrl from './service-url';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceCatalog = AmpState.extend({\n namespace: 'ServiceCatalog',\n\n props: {\n serviceGroups: [\n 'object',\n true,\n () => ({\n discovery: [],\n override: [],\n preauth: [],\n postauth: [],\n signin: [],\n }),\n ],\n status: [\n 'object',\n true,\n () => ({\n discovery: {\n ready: false,\n collecting: false,\n },\n override: {\n ready: false,\n collecting: false,\n },\n preauth: {\n ready: false,\n collecting: false,\n },\n postauth: {\n ready: false,\n collecting: false,\n },\n signin: {\n ready: false,\n collecting: false,\n },\n }),\n ],\n isReady: ['boolean', false, false],\n allowedDomains: ['array', false, () => []],\n },\n\n /**\n * @private\n * Search the service url array to locate a `ServiceUrl`\n * class object based on its name.\n * @param {string} name\n * @param {string} [serviceGroup]\n * @returns {ServiceUrl}\n */\n _getUrl(name, serviceGroup) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n return serviceUrls.find((serviceUrl) => serviceUrl.name === name);\n },\n\n /**\n * @private\n * Generate an array of `ServiceUrl`s that is organized from highest auth\n * level to lowest auth level.\n * @returns {Array<ServiceUrl>} - array of `ServiceUrl`s\n */\n _listServiceUrls() {\n return [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n },\n\n /**\n * @private\n * Safely load one or more `ServiceUrl`s into this `Services` instance.\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _loadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (!existingService) {\n this.serviceGroups[serviceGroup].push(service);\n }\n });\n\n return this;\n },\n\n /**\n * @private\n * Safely unload one or more `ServiceUrl`s into this `Services` instance\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _unloadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (existingService) {\n this.serviceGroups[serviceGroup].splice(\n this.serviceGroups[serviceGroup].indexOf(existingService),\n 1\n );\n }\n });\n\n return this;\n },\n\n /**\n * Clear all collected catalog data and reset catalog status.\n *\n * @returns {void}\n */\n clean() {\n this.serviceGroups.preauth.length = 0;\n this.serviceGroups.signin.length = 0;\n this.serviceGroups.postauth.length = 0;\n this.status.preauth = {ready: false};\n this.status.signin = {ready: false};\n this.status.postauth = {ready: false};\n },\n\n /**\n * Search over all service groups to find a cluster id based\n * on a given url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {string} - ClusterId of a given url\n */\n findClusterId(url) {\n const incomingUrlObj = Url.parse(url);\n let serviceUrlObj;\n\n for (const key of Object.keys(this.serviceGroups)) {\n for (const service of this.serviceGroups[key]) {\n serviceUrlObj = Url.parse(service.defaultUrl);\n\n for (const host of service.hosts) {\n if (incomingUrlObj.hostname === host.host && host.id) {\n return host.id;\n }\n }\n\n if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {\n // no exact match, so try to grab the first home cluster\n for (const host of service.hosts) {\n if (host.homeCluster) {\n return host.id;\n }\n }\n\n // no match found still, so return the first entry\n return service.hosts[0].id;\n }\n }\n }\n\n return undefined;\n },\n\n /**\n * Search over all service groups and return a service value from a provided\n * clusterId. Currently, this method will return either a service name, or a\n * service url depending on the `value` parameter. If the `value` parameter\n * is set to `name`, it will return a service name to be utilized within the\n * Services plugin methods.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost = true] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n const identifiedServiceUrl = serviceUrls.find((serviceUrl) =>\n serviceUrl.hosts.find((host) => host.id === clusterId)\n );\n\n if (identifiedServiceUrl) {\n return {\n name: identifiedServiceUrl.name,\n url: identifiedServiceUrl.get(priorityHost, clusterId),\n };\n }\n\n return undefined;\n },\n\n /**\n * Find a service based on the provided url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {serviceUrl} - ServiceUrl assocated with provided url\n */\n findServiceUrlFromUrl(url) {\n const serviceUrls = [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n return serviceUrls.find((serviceUrl) => {\n // Check to see if the URL we are checking starts with the default URL\n if (url.startsWith(serviceUrl.defaultUrl)) {\n return true;\n }\n\n // If not, we check to see if the alternate URLs match\n // These are made by swapping the host of the default URL\n // with that of an alternate host\n for (const host of serviceUrl.hosts) {\n const alternateUrl = new URL(serviceUrl.defaultUrl);\n alternateUrl.host = host.host;\n\n if (url.startsWith(alternateUrl.toString())) {\n return true;\n }\n }\n\n return false;\n });\n },\n\n /**\n * Finds an allowed domain that matches a specific url.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @returns {string} - The matching allowed domain.\n */\n findAllowedDomain(url) {\n const urlObj = Url.parse(url);\n\n if (!urlObj.host) {\n return undefined;\n }\n\n return this.allowedDomains.find((allowedDomain) => urlObj.host.includes(allowedDomain));\n },\n\n /**\n * Get a service url from the current services list by name.\n * @param {string} name\n * @param {boolean} priorityHost\n * @param {string} serviceGroup\n * @returns {string}\n */\n get(name, priorityHost, serviceGroup) {\n const serviceUrl = this._getUrl(name, serviceGroup);\n\n return serviceUrl ? serviceUrl.get(priorityHost) : undefined;\n },\n\n /**\n * Get the current allowed domains list.\n *\n * @returns {Array<string>} - the current allowed domains list.\n */\n getAllowedDomains() {\n return [...this.allowedDomains];\n },\n\n /**\n * Creates an object where the keys are the service names\n * and the values are the service urls.\n * @param {boolean} priorityHost - use the highest priority if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list(priorityHost, serviceGroup) {\n const output = {};\n\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n if (serviceUrls) {\n serviceUrls.forEach((serviceUrl) => {\n output[serviceUrl.name] = serviceUrl.get(priorityHost);\n });\n }\n\n return output;\n },\n\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl(url, noPriorityHosts) {\n const serviceUrl = this._getUrl(\n Object.keys(this.list()).find((key) => this._getUrl(key).failHost(url))\n );\n\n if (!serviceUrl) {\n return undefined;\n }\n\n return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);\n },\n\n /**\n * Set the allowed domains for the catalog.\n *\n * @param {Array<string>} allowedDomains - allowed domains to be assigned.\n * @returns {void}\n */\n setAllowedDomains(allowedDomains) {\n this.allowedDomains = [...allowedDomains];\n },\n\n /**\n *\n * @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains\n * @returns {void}\n */\n addAllowedDomains(newAllowedDomains) {\n this.allowedDomains = union(this.allowedDomains, newAllowedDomains);\n },\n\n /**\n * Update the current list of `ServiceUrl`s against a provided\n * service hostmap.\n * @emits ServiceCatalog#preauthorized\n * @emits ServiceCatalog#postauthorized\n * @param {string} serviceGroup\n * @param {object} serviceHostmap\n * @returns {Services}\n */\n updateServiceUrls(serviceGroup, serviceHostmap) {\n const currentServiceUrls = this.serviceGroups[serviceGroup];\n\n const unusedUrls = currentServiceUrls.filter((serviceUrl) =>\n serviceHostmap.every((item) => item.name !== serviceUrl.name)\n );\n\n this._unloadServiceUrls(serviceGroup, unusedUrls);\n\n serviceHostmap.forEach((serviceObj) => {\n const service = this._getUrl(serviceObj.name, serviceGroup);\n\n if (service) {\n service.defaultUrl = serviceObj.defaultUrl;\n service.hosts = serviceObj.hosts || [];\n } else {\n this._loadServiceUrls(serviceGroup, [\n new ServiceUrl({\n ...serviceObj,\n }),\n ]);\n }\n });\n\n this.status[serviceGroup].ready = true;\n this.trigger(serviceGroup);\n\n return this;\n },\n\n /**\n * Wait until the service catalog is available,\n * or reject after a timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog(serviceGroup, timeout) {\n return new Promise((resolve, reject) => {\n if (this.status[serviceGroup].ready) {\n resolve();\n }\n\n const validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;\n\n const timeoutTimer = setTimeout(\n () =>\n reject(\n new Error(\n `services: timeout occured while waiting for '${serviceGroup}' catalog to populate`\n )\n ),\n validatedTimeout * 1000\n );\n\n this.once(serviceGroup, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceCatalog;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAuC,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,aAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAA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
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _default = exports.default = {
|
|
9
|
+
hydra: 'https://api-usgov.webex.com/v1',
|
|
10
|
+
u2c: 'https://u2c.gov.ciscospark.com/u2c/api/v1',
|
|
11
|
+
sqdiscovery: 'https://ds.ciscospark.com/v1/region' // TODO: fedramp load balanced URL? this has been here for years as of now but now explicitly done
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=service-fed-ramp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hydra","u2c","sqdiscovery"],"sources":["service-fed-ramp.js"],"sourcesContent":["export default {\n hydra: 'https://api-usgov.webex.com/v1',\n u2c: 'https://u2c.gov.ciscospark.com/u2c/api/v1',\n sqdiscovery: 'https://ds.ciscospark.com/v1/region', // TODO: fedramp load balanced URL? this has been here for years as of now but now explicitly done\n};\n"],"mappings":";;;;;;;iCAAe;EACbA,KAAK,EAAE,gCAAgC;EACvCC,GAAG,EAAE,2CAA2C;EAChDC,WAAW,EAAE,qCAAqC,CAAE;AACtD,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA,IAAME,UAAU,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACjCC,SAAS,EAAE,YAAY;EAEvBC,KAAK,EAAE;IACLC,UAAU,EA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