@webex/webex-core 3.8.1-next.2 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,50 +1,28 @@
1
1
  # @webex/webex-core
2
2
 
3
- Core library for the Cisco Webex JS SDK.
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
4
 
5
- ## Install
6
-
7
- ```bash
8
- npm install --save @webex/webex-core
9
- ```
5
+ > Core library for the Cisco Webex JS SDK.
10
6
 
11
- ## What it Does
7
+ Defines the plugin system, storage system, common http behaviors, credentials, services, and basic logging.
12
8
 
13
- The webex-core package provides the foundational architecture for the Webex JavaScript SDK, including:
14
-
15
- - Plugin system for loading and managing SDK plugins
16
- - Storage system for data persistence across environments
17
- - HTTP core for common request handling
18
- - Credentials management for token handling
19
- - Service discovery for dynamic endpoint resolution
20
- - Logging framework for debugging
21
-
22
- ## Basic Usage
23
-
24
- ```js
25
- import WebexCore from '@webex/webex-core';
9
+ - [Install](#install)
10
+ - [Usage](#usage)
11
+ - [Contribute](#contribute)
12
+ - [Maintainers](#maintainers)
13
+ - [License](#license)
26
14
 
27
- // Create a basic Webex instance
28
- const webex = new WebexCore({
29
- credentials: {
30
- access_token: 'your-access-token'
31
- }
32
- });
15
+ ## Install
33
16
 
34
- // Use core functionality
35
- webex.request({
36
- method: 'GET',
37
- uri: 'https://webexapis.com/v1/people/me'
38
- }).then(response => {
39
- console.log('User info:', response.body);
40
- });
17
+ ```bash
18
+ npm install --save @webex/webex-core
41
19
  ```
42
20
 
43
- ## Configuration
21
+ ## Usage
44
22
 
45
23
  ### Client Scope Requirements
46
24
 
47
- To utilize the basic functionality of the services plugin, the following scopes must be present in the client's scopes:
25
+ To utilize the basic functionality of the `services` plugin that is bound to the `webex-core` plugin upon initialization, the following scopes must be present in the provided client's scopes:
48
26
 
49
27
  - `spark:all`
50
28
 
@@ -52,82 +30,44 @@ To utilize the basic functionality of the services plugin, the following scopes
52
30
 
53
31
  The following environment variables are used by this plugin:
54
32
 
55
- - `HYDRA_SERVICE_URL` - Stores the public hydra api url for managing Webex resources
56
- - `U2C_SERVICE_URL` - Stores the service catalog collecting url, typically the U2C service
33
+ - `HYDRA_SERVICE_URL` - Stores the public hydra api url for managing Webex resources.
34
+ - `U2C_SERVICE_URL` - Stores the service catalog collecting url, typically the **U2C** service.
57
35
  - `SQDISCOVERY_SERVICE_URL` - Stores the URL for client region information, such as country code and timezone
58
36
 
59
- ### Advanced Configuration
37
+ ### Configuration
60
38
 
61
- The services plugin supports the ability to inject discovery urls via the constructor:
39
+ The `services` plugin that is bound to the `webex-core` plugin upon initialization supports the ability to inject discovery urls via the constructor:
62
40
 
63
41
  ```js
64
- const webex = new WebexCore({
42
+ const webex = new Webex({
65
43
  config: {
66
44
  services: {
67
- // Services that are available before catalog retrieval
45
+ // Services that are available before catalog retrieval.
68
46
  discovery: {
69
47
  hydra: 'https://api.ciscospark.com/v1',
70
48
  sqdiscovery: 'https://ds.ciscospark.com/v1/region'
71
49
  },
72
50
 
73
- // Services that have a persistent host, typically for testing
51
+ // Services that have a persistant host, typically for testing.
74
52
  override: {
75
53
  serviceName: 'https://api.service.com/v1'
76
- },
54
+ }
77
55
 
78
- // Validate domains against the allowed domains
56
+ // Validate domains against the allowed domains.
79
57
  validateDomains: true,
80
58
 
81
- // The allowed domains to validate domains against
59
+ // The allowed domains to validate domains against.
82
60
  allowedDomains: ['allowed-domain']
83
61
  }
84
62
  }
85
63
  });
86
64
  ```
87
65
 
88
- ### Default Service URLs
89
-
90
66
  The default configuration includes the following service urls:
91
67
 
92
- - `U2C_SERVICE_URL` [U2C] - `https://u2c.wbx2.com/u2c/api/v1`
93
- - `HYDRA_SERVICE_URL` [Hydra] - `https://webexapis.com/v1`
94
- - `SQDISCOVERY_SERVICE_URL` [SQDISCOVERY] - `https://ds.ciscospark.com/v1/region`
95
-
96
- ## Plugin System
97
-
98
- WebexCore provides a plugin architecture that allows extending functionality:
99
-
100
- ```js
101
- import WebexCore from '@webex/webex-core';
102
- import MyPlugin from './my-plugin';
103
-
104
- // Register a plugin
105
- WebexCore.registerPlugin('myPlugin', MyPlugin);
106
-
107
- const webex = new WebexCore();
108
- // Plugin is now available at webex.myPlugin
109
- ```
110
-
111
- ## Storage System
112
-
113
- WebexCore includes a unified storage interface:
114
-
115
- ```js
116
- // Configure storage adapter
117
- const webex = new WebexCore({
118
- config: {
119
- storage: {
120
- adapter: 'localStorage' // or 'memory', 'indexedDB', etc.
121
- }
122
- }
123
- });
124
-
125
- // Use storage
126
- webex.storage.put('key', 'value');
127
- webex.storage.get('key').then(value => console.log(value));
128
- ```
129
-
130
- This package is the foundation for all Webex SDK functionality and is required for most other Webex SDK packages.
68
+ - `U2C_SERVICE_URL` [ **U2C** ] - `https://u2c.wbx2.com/u2c/api/v1`
69
+ - `HYDRA_SERVICE_URL` [ **Hydra** ] - `https://api.ciscospark.com/v1`
70
+ - `SQDISCOVERY_SERVICE_URL` [ **SQDISCOVERY** ] - `https://ds.ciscospark.com/v1/region`
131
71
 
132
72
  ## Maintainers
133
73
 
@@ -139,4 +79,4 @@ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/web
139
79
 
140
80
  ## License
141
81
 
142
- © 2016-2025 Cisco and/or its affiliates. All Rights Reserved.
82
+ © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
@@ -286,7 +286,7 @@ var Batcher = _webexPlugin.default.extend({
286
286
  fingerprintResponse: function fingerprintResponse(item) {
287
287
  throw new Error('fingerprintResponse() must be implemented');
288
288
  },
289
- version: "3.8.1-next.2"
289
+ version: "3.8.1"
290
290
  });
291
291
  var _default2 = exports.default = Batcher;
292
292
  //# sourceMappingURL=batcher.js.map
@@ -558,7 +558,7 @@ var Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
558
558
  this.refresh();
559
559
  }
560
560
  },
561
- version: "3.8.1-next.2"
561
+ version: "3.8.1"
562
562
  }, ((0, _applyDecoratedDescriptor2.default)(_obj, "getUserToken", [_dec, _dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "getUserToken"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "initialize", [_dec3], (0, _getOwnPropertyDescriptor.default)(_obj, "initialize"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "invalidate", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, "invalidate"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight, _dec5, _dec6], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj)), _obj)));
563
563
  var _default = exports.default = Credentials;
564
564
  //# sourceMappingURL=credentials.js.map
@@ -532,7 +532,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
532
532
  return res.body;
533
533
  });
534
534
  },
535
- version: "3.8.1-next.2"
535
+ version: "3.8.1"
536
536
  }, ((0, _applyDecoratedDescriptor2.default)(_obj, "downscope", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "downscope"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "revoke", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "revoke"), _obj)), _obj)));
537
537
  var _default = exports.default = Token;
538
538
  //# sourceMappingURL=token.js.map
@@ -1067,7 +1067,7 @@ var Services = _webexPlugin.default.extend({
1067
1067
  }
1068
1068
  });
1069
1069
  },
1070
- version: "3.8.1-next.2"
1070
+ version: "3.8.1"
1071
1071
  });
1072
1072
  /* eslint-enable no-underscore-dangle */
1073
1073
  var _default = exports.default = Services;
@@ -0,0 +1,300 @@
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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
11
+ var _url = _interopRequireDefault(require("url"));
12
+ var _constants = require("./constants");
13
+ /**
14
+ * The parameter transfer object for {@link ServiceHost#constructor}.
15
+ *
16
+ * @typedef {Object} ServiceHostConstructorPTO
17
+ * @property {string} ServiceHostConstructorPTO.catalog - The host's catalog.
18
+ * @property {string} ServiceHostConstructorPTO.defaultUri - The host's default.
19
+ * @property {string} ServiceHostConstructorPTO.hostGroup - The host's group.
20
+ * @property {string} ServiceHostConstructorPTO.id - The host's clusterId.
21
+ * @property {number} ServiceHostConstructorPTO.priority - The host's priority.
22
+ * @property {string} ServiceHostConstructorPTO.uri - The host's uri.
23
+ */
24
+ /**
25
+ * The parameter transfer object for {@link ServiceHost#polyGenerate}.
26
+ *
27
+ * @typedef {Object} ServiceHostPolyGeneratePTO
28
+ * @property {string} ServiceHostPolyGeneratePTO.catalog - The target catalog.
29
+ * @property {string} ServiceHostPolyGeneratePTO.name - The service name.
30
+ * @property {string} ServiceHostPolyGeneratePTO.url - The service url.
31
+ */
32
+ /**
33
+ * @class
34
+ * @classdesc - Manages a single service host and its associated data.
35
+ */
36
+ var ServiceHost = exports.default = /*#__PURE__*/function () {
37
+ /**
38
+ * Generate a new {@link ServiceHost}.
39
+ *
40
+ * @public
41
+ * @constructor
42
+ * @memberof ServiceHost
43
+ * @param {ServiceHostConstructorPTO} pto
44
+ */
45
+ function ServiceHost(pto) {
46
+ (0, _classCallCheck2.default)(this, ServiceHost);
47
+ // Validate the parameter transfer object.
48
+ ServiceHost.validate(pto);
49
+
50
+ // Map the parameter transfer object to the class object.
51
+ /**
52
+ * The catalog name that the {@link ServiceHost} is associated with.
53
+ *
54
+ * @instance
55
+ * @type {string}
56
+ * @public
57
+ * @memberof ServiceHost
58
+ */
59
+ this.catalog = pto.catalog;
60
+
61
+ /**
62
+ * The default URI for the {@link ServiceHost}.
63
+ *
64
+ * @instance
65
+ * @type {string}
66
+ * @public
67
+ * @memberof ServiceHost
68
+ */
69
+ this.default = pto.defaultUri;
70
+
71
+ /**
72
+ * The host group that the {@link ServiceHost} is associated with.
73
+ *
74
+ * @instance
75
+ * @type {string}
76
+ * @public
77
+ * @memberof ServiceHost
78
+ */
79
+ this.hostGroup = pto.hostGroup;
80
+
81
+ /**
82
+ * The cluster ID of the {@link ServiceHost}.
83
+ *
84
+ * @instance
85
+ * @type {string}
86
+ * @public
87
+ * @memberof ServiceHost
88
+ */
89
+ this.id = pto.id;
90
+
91
+ /**
92
+ * The priority value of the {@link ServiceHost}. The lower the number, the
93
+ * higher the priority.
94
+ *
95
+ * @instance
96
+ * @type {number}
97
+ * @public
98
+ * @memberof ServiceHost
99
+ */
100
+ this.priority = pto.priority;
101
+
102
+ /**
103
+ * The host uri of the {@link ServiceHost}.
104
+ *
105
+ * @instance
106
+ * @type {string}
107
+ * @public
108
+ * @memberof ServiceHost
109
+ */
110
+ this.uri = pto.uri;
111
+
112
+ // Generate flags.
113
+ /**
114
+ * If the {@link ServiceHost} is marked as failed.
115
+ *
116
+ * @instance
117
+ * @type {boolean}
118
+ * @protected
119
+ * @memberof ServiceHost
120
+ */
121
+ this.failed = false;
122
+
123
+ /**
124
+ * If the {@link ServiceHost} is marked as replaced.
125
+ *
126
+ * @instance
127
+ * @type {boolean}
128
+ * @protected
129
+ * @memberof ServiceHost
130
+ */
131
+ this.replaced = false;
132
+ }
133
+
134
+ /**
135
+ * If the {@link ServiceHost} is in an active state.
136
+ *
137
+ * @public
138
+ * @memberof ServiceHost
139
+ * @type {boolean} - `true` if the service is active and usable.
140
+ */
141
+ (0, _createClass2.default)(ServiceHost, [{
142
+ key: "active",
143
+ get: function get() {
144
+ // Validate that the `ServiceHost` was not marked as failed or replaced.
145
+ return !this.failed && !this.replaced;
146
+ }
147
+
148
+ /**
149
+ * If the host is local to the user's cluster.
150
+ *
151
+ * @public
152
+ * @memberof ServiceHost
153
+ * @type {boolean} - If the host is local.
154
+ */
155
+ }, {
156
+ key: "local",
157
+ get: function get() {
158
+ return this.default.includes(this.hostGroup);
159
+ }
160
+
161
+ /**
162
+ * The service value.
163
+ *
164
+ * @public
165
+ * @memberof ServiceHost
166
+ * @type {string} - The service value.
167
+ */
168
+ }, {
169
+ key: "service",
170
+ get: function get() {
171
+ return this.id.split(':')[3];
172
+ }
173
+
174
+ /**
175
+ * The formatted url for the host.
176
+ *
177
+ * @public
178
+ * @memberof ServiceHost
179
+ * @type {string} - The service url.
180
+ */
181
+ }, {
182
+ key: "url",
183
+ get: function get() {
184
+ // Generate a url object from the default url.
185
+ var urlObj = _url.default.parse(this.default);
186
+
187
+ // Format the host of the generated url object.
188
+ urlObj.host = "".concat(this.uri).concat(urlObj.port ? ":".concat(urlObj.port) : '');
189
+
190
+ // Assign the formatted url to this.
191
+ return _url.default.format(urlObj);
192
+ }
193
+
194
+ /**
195
+ * Set one or more of the status properties of the class object.
196
+ *
197
+ * @public
198
+ * @memberof ServiceHost
199
+ * @param {Object} pto - The parameter transfer object.
200
+ * @property {boolean} [pto.failed] - The failed status to set.
201
+ * @property {boolean} [pto.replaced] - the replaced status to set.
202
+ * @returns {this}
203
+ */
204
+ }, {
205
+ key: "setStatus",
206
+ value: function setStatus(_ref) {
207
+ var failed = _ref.failed,
208
+ replaced = _ref.replaced;
209
+ if (failed !== undefined) {
210
+ this.failed = failed;
211
+ }
212
+ if (replaced !== undefined) {
213
+ this.replaced = replaced;
214
+ }
215
+ return this;
216
+ }
217
+
218
+ /**
219
+ * Generate a service host using only a catalog, name, and URL.
220
+ *
221
+ * @public
222
+ * @static
223
+ * @memberof ServiceHost
224
+ * @param {ServiceHostPolyGeneratePTO} pto
225
+ * @returns {ServiceHost} - The generated service host.
226
+ */
227
+ }], [{
228
+ key: "polyGenerate",
229
+ value: function polyGenerate(_ref2) {
230
+ var catalog = _ref2.catalog,
231
+ name = _ref2.name,
232
+ url = _ref2.url;
233
+ return new ServiceHost({
234
+ catalog: catalog,
235
+ defaultUri: url,
236
+ hostGroup: _url.default.parse(url).host,
237
+ id: name ? "poly-head:poly-group:poly-cluster:".concat(name) : undefined,
238
+ priority: 1,
239
+ uri: _url.default.parse(url).host
240
+ });
241
+ }
242
+
243
+ /**
244
+ * Validate that a constructor parameter transfer object is valid.
245
+ *
246
+ * @public
247
+ * @static
248
+ * @memberof ServiceHost
249
+ * @param {ServiceHostConstructorPTO} pto
250
+ * @throws - If the parameter transfer object is not valid.
251
+ * @returns {undefined}
252
+ */
253
+ }, {
254
+ key: "validate",
255
+ value: function validate(_ref3) {
256
+ var catalog = _ref3.catalog,
257
+ defaultUri = _ref3.defaultUri,
258
+ hostGroup = _ref3.hostGroup,
259
+ id = _ref3.id,
260
+ priority = _ref3.priority,
261
+ uri = _ref3.uri;
262
+ // Generate error-throwing method.
263
+ var throwError = function throwError(msg) {
264
+ throw new Error("service-host: invalid constructor parameters, ".concat(msg));
265
+ };
266
+
267
+ // Validate the catalog property.
268
+ if (!_constants.SERVICE_CATALOGS.includes(catalog)) {
269
+ throwError("'catalog' must be a string");
270
+ }
271
+
272
+ // Validate the `defaultUri` property.
273
+ if (typeof defaultUri !== 'string') {
274
+ throwError("'defaultUri' must be a string");
275
+ }
276
+
277
+ // Validate the `hostGroup` property.
278
+ if (typeof hostGroup !== 'string') {
279
+ throwError("'hostGroup' must be a string");
280
+ }
281
+
282
+ // Validate the `id` property.
283
+ if (typeof id !== 'string' || id.split(':').length !== 4) {
284
+ throwError("'id' must be a string that contains 3 ':' characters");
285
+ }
286
+
287
+ // Validate the `priority` property.
288
+ if (typeof priority !== 'number') {
289
+ throwError("'priority' must be a number");
290
+ }
291
+
292
+ // Validate the `uri` property.
293
+ if (typeof uri !== 'string') {
294
+ throwError("'uri' must be a string");
295
+ }
296
+ }
297
+ }]);
298
+ return ServiceHost;
299
+ }();
300
+ //# sourceMappingURL=service-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_url","_interopRequireDefault","require","_constants","ServiceHost","exports","default","pto","_classCallCheck2","validate","catalog","defaultUri","hostGroup","id","priority","uri","failed","replaced","_createClass2","key","get","includes","split","urlObj","Url","parse","host","concat","port","format","value","setStatus","_ref","undefined","polyGenerate","_ref2","name","url","_ref3","throwError","msg","Error","SERVICE_CATALOGS","length"],"sources":["service-host.js"],"sourcesContent":["import Url from 'url';\n\nimport {SERVICE_CATALOGS} from './constants';\n\n/**\n * The parameter transfer object for {@link ServiceHost#constructor}.\n *\n * @typedef {Object} ServiceHostConstructorPTO\n * @property {string} ServiceHostConstructorPTO.catalog - The host's catalog.\n * @property {string} ServiceHostConstructorPTO.defaultUri - The host's default.\n * @property {string} ServiceHostConstructorPTO.hostGroup - The host's group.\n * @property {string} ServiceHostConstructorPTO.id - The host's clusterId.\n * @property {number} ServiceHostConstructorPTO.priority - The host's priority.\n * @property {string} ServiceHostConstructorPTO.uri - The host's uri.\n */\n\n/**\n * The parameter transfer object for {@link ServiceHost#polyGenerate}.\n *\n * @typedef {Object} ServiceHostPolyGeneratePTO\n * @property {string} ServiceHostPolyGeneratePTO.catalog - The target catalog.\n * @property {string} ServiceHostPolyGeneratePTO.name - The service name.\n * @property {string} ServiceHostPolyGeneratePTO.url - The service url.\n */\n\n/**\n * @class\n * @classdesc - Manages a single service host and its associated data.\n */\nexport default class ServiceHost {\n /**\n * Generate a new {@link ServiceHost}.\n *\n * @public\n * @constructor\n * @memberof ServiceHost\n * @param {ServiceHostConstructorPTO} pto\n */\n constructor(pto) {\n // Validate the parameter transfer object.\n ServiceHost.validate(pto);\n\n // Map the parameter transfer object to the class object.\n /**\n * The catalog name that the {@link ServiceHost} is associated with.\n *\n * @instance\n * @type {string}\n * @public\n * @memberof ServiceHost\n */\n this.catalog = pto.catalog;\n\n /**\n * The default URI for the {@link ServiceHost}.\n *\n * @instance\n * @type {string}\n * @public\n * @memberof ServiceHost\n */\n this.default = pto.defaultUri;\n\n /**\n * The host group that the {@link ServiceHost} is associated with.\n *\n * @instance\n * @type {string}\n * @public\n * @memberof ServiceHost\n */\n this.hostGroup = pto.hostGroup;\n\n /**\n * The cluster ID of the {@link ServiceHost}.\n *\n * @instance\n * @type {string}\n * @public\n * @memberof ServiceHost\n */\n this.id = pto.id;\n\n /**\n * The priority value of the {@link ServiceHost}. The lower the number, the\n * higher the priority.\n *\n * @instance\n * @type {number}\n * @public\n * @memberof ServiceHost\n */\n this.priority = pto.priority;\n\n /**\n * The host uri of the {@link ServiceHost}.\n *\n * @instance\n * @type {string}\n * @public\n * @memberof ServiceHost\n */\n this.uri = pto.uri;\n\n // Generate flags.\n /**\n * If the {@link ServiceHost} is marked as failed.\n *\n * @instance\n * @type {boolean}\n * @protected\n * @memberof ServiceHost\n */\n this.failed = false;\n\n /**\n * If the {@link ServiceHost} is marked as replaced.\n *\n * @instance\n * @type {boolean}\n * @protected\n * @memberof ServiceHost\n */\n this.replaced = false;\n }\n\n /**\n * If the {@link ServiceHost} is in an active state.\n *\n * @public\n * @memberof ServiceHost\n * @type {boolean} - `true` if the service is active and usable.\n */\n get active() {\n // Validate that the `ServiceHost` was not marked as failed or replaced.\n return !this.failed && !this.replaced;\n }\n\n /**\n * If the host is local to the user's cluster.\n *\n * @public\n * @memberof ServiceHost\n * @type {boolean} - If the host is local.\n */\n get local() {\n return this.default.includes(this.hostGroup);\n }\n\n /**\n * The service value.\n *\n * @public\n * @memberof ServiceHost\n * @type {string} - The service value.\n */\n get service() {\n return this.id.split(':')[3];\n }\n\n /**\n * The formatted url for the host.\n *\n * @public\n * @memberof ServiceHost\n * @type {string} - The service url.\n */\n get url() {\n // Generate a url object from the default url.\n const urlObj = Url.parse(this.default);\n\n // Format the host of the generated url object.\n urlObj.host = `${this.uri}${urlObj.port ? `:${urlObj.port}` : ''}`;\n\n // Assign the formatted url to this.\n return Url.format(urlObj);\n }\n\n /**\n * Set one or more of the status properties of the class object.\n *\n * @public\n * @memberof ServiceHost\n * @param {Object} pto - The parameter transfer object.\n * @property {boolean} [pto.failed] - The failed status to set.\n * @property {boolean} [pto.replaced] - the replaced status to set.\n * @returns {this}\n */\n setStatus({failed, replaced}) {\n if (failed !== undefined) {\n this.failed = failed;\n }\n\n if (replaced !== undefined) {\n this.replaced = replaced;\n }\n\n return this;\n }\n\n /**\n * Generate a service host using only a catalog, name, and URL.\n *\n * @public\n * @static\n * @memberof ServiceHost\n * @param {ServiceHostPolyGeneratePTO} pto\n * @returns {ServiceHost} - The generated service host.\n */\n static polyGenerate({catalog, name, url}) {\n return new ServiceHost({\n catalog,\n defaultUri: url,\n hostGroup: Url.parse(url).host,\n id: name ? `poly-head:poly-group:poly-cluster:${name}` : undefined,\n priority: 1,\n uri: Url.parse(url).host,\n });\n }\n\n /**\n * Validate that a constructor parameter transfer object is valid.\n *\n * @public\n * @static\n * @memberof ServiceHost\n * @param {ServiceHostConstructorPTO} pto\n * @throws - If the parameter transfer object is not valid.\n * @returns {undefined}\n */\n static validate({catalog, defaultUri, hostGroup, id, priority, uri}) {\n // Generate error-throwing method.\n const throwError = (msg) => {\n throw new Error(`service-host: invalid constructor parameters, ${msg}`);\n };\n\n // Validate the catalog property.\n if (!SERVICE_CATALOGS.includes(catalog)) {\n throwError(\"'catalog' must be a string\");\n }\n\n // Validate the `defaultUri` property.\n if (typeof defaultUri !== 'string') {\n throwError(\"'defaultUri' must be a string\");\n }\n\n // Validate the `hostGroup` property.\n if (typeof hostGroup !== 'string') {\n throwError(\"'hostGroup' must be a string\");\n }\n\n // Validate the `id` property.\n if (typeof id !== 'string' || id.split(':').length !== 4) {\n throwError(\"'id' must be a string that contains 3 ':' characters\");\n }\n\n // Validate the `priority` property.\n if (typeof priority !== 'number') {\n throwError(\"'priority' must be a number\");\n }\n\n // Validate the `uri` property.\n if (typeof uri !== 'string') {\n throwError(\"'uri' must be a string\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAHA,IAIqBE,WAAW,GAAAC,OAAA,CAAAC,OAAA;EAC9B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,SAAAF,YAAYG,GAAG,EAAE;IAAA,IAAAC,gBAAA,CAAAF,OAAA,QAAAF,WAAA;IACf;IACAA,WAAW,CAACK,QAAQ,CAACF,GAAG,CAAC;;IAEzB;IACA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACG,OAAO,GAAGH,GAAG,CAACG,OAAO;;IAE1B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACJ,OAAO,GAAGC,GAAG,CAACI,UAAU;;IAE7B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,SAAS,GAAGL,GAAG,CAACK,SAAS;;IAE9B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,EAAE,GAAGN,GAAG,CAACM,EAAE;;IAEhB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,QAAQ,GAAGP,GAAG,CAACO,QAAQ;;IAE5B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,GAAG,GAAGR,GAAG,CAACQ,GAAG;;IAElB;IACA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,MAAM,GAAG,KAAK;;IAEnB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE,IAAAC,aAAA,CAAAZ,OAAA,EAAAF,WAAA;IAA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