@webex/webex-core 2.59.2 → 2.59.3-next.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/.eslintrc.js +6 -6
- package/README.md +79 -79
- package/babel.config.js +3 -3
- package/dist/config.js +24 -24
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +56 -56
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js +28 -28
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js +24 -24
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js +9 -9
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/network-timing.js +19 -19
- package/dist/interceptors/network-timing.js.map +1 -1
- package/dist/interceptors/payload-transformer.js +19 -19
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +40 -40
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js +13 -13
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js +23 -23
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js +13 -13
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/request-timing.js +23 -23
- package/dist/interceptors/request-timing.js.map +1 -1
- package/dist/interceptors/response-logger.js +19 -19
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js +29 -29
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-tracking-id.js +15 -15
- package/dist/interceptors/webex-tracking-id.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js +13 -13
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +83 -83
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +103 -103
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js +17 -17
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js +2 -2
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js +11 -11
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js +2 -2
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +145 -145
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +49 -49
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js +2 -2
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +9 -9
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +24 -24
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js +104 -104
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +134 -134
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js +175 -175
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js +38 -38
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js +31 -31
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +245 -245
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js +28 -28
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js +27 -27
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/errors.js +4 -4
- package/dist/lib/storage/errors.js.map +1 -1
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js +44 -44
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js +40 -40
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js +9 -9
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js +13 -13
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js +9 -9
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js +13 -13
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js +36 -36
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +9 -9
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +104 -104
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js +12 -12
- package/dist/webex-internal-core.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +20 -19
- package/process +1 -1
- package/src/config.js +90 -90
- package/src/credentials-config.js +212 -212
- package/src/index.js +62 -62
- package/src/interceptors/auth.js +186 -186
- package/src/interceptors/default-options.js +55 -55
- package/src/interceptors/embargo.js +43 -43
- package/src/interceptors/network-timing.js +54 -54
- package/src/interceptors/payload-transformer.js +55 -55
- package/src/interceptors/rate-limit.js +169 -169
- package/src/interceptors/redirect.js +106 -106
- package/src/interceptors/request-event.js +93 -93
- package/src/interceptors/request-logger.js +78 -78
- package/src/interceptors/request-timing.js +65 -65
- package/src/interceptors/response-logger.js +98 -98
- package/src/interceptors/user-agent.js +77 -77
- package/src/interceptors/webex-tracking-id.js +73 -73
- package/src/interceptors/webex-user-agent.js +79 -79
- package/src/lib/batcher.js +307 -307
- package/src/lib/credentials/credentials.js +552 -552
- package/src/lib/credentials/grant-errors.js +92 -92
- package/src/lib/credentials/index.js +16 -16
- package/src/lib/credentials/scope.js +34 -34
- package/src/lib/credentials/token-collection.js +17 -17
- package/src/lib/credentials/token.js +559 -559
- package/src/lib/page.js +159 -159
- package/src/lib/services/constants.js +9 -9
- package/src/lib/services/index.js +26 -26
- package/src/lib/services/interceptors/server-error.js +48 -48
- package/src/lib/services/interceptors/service.js +101 -101
- package/src/lib/services/metrics.js +4 -4
- package/src/lib/services/service-catalog.js +435 -435
- package/src/lib/services/service-fed-ramp.js +4 -4
- package/src/lib/services/service-host.js +267 -267
- package/src/lib/services/service-registry.js +465 -465
- package/src/lib/services/service-state.js +78 -78
- package/src/lib/services/service-url.js +124 -124
- package/src/lib/services/services.js +1018 -1018
- package/src/lib/stateless-webex-plugin.js +98 -98
- package/src/lib/storage/decorators.js +220 -220
- package/src/lib/storage/errors.js +15 -15
- package/src/lib/storage/index.js +10 -10
- package/src/lib/storage/make-webex-plugin-store.js +211 -211
- package/src/lib/storage/make-webex-store.js +140 -140
- package/src/lib/storage/memory-store-adapter.js +79 -79
- package/src/lib/webex-core-plugin-mixin.js +114 -114
- package/src/lib/webex-http-error.js +61 -61
- package/src/lib/webex-internal-core-plugin-mixin.js +107 -107
- package/src/lib/webex-plugin.js +222 -222
- package/src/plugins/logger.js +60 -60
- package/src/webex-core.js +745 -745
- package/src/webex-internal-core.js +46 -46
- package/test/integration/spec/credentials/credentials.js +139 -139
- package/test/integration/spec/credentials/token.js +102 -102
- package/test/integration/spec/services/service-catalog.js +838 -838
- package/test/integration/spec/services/services.js +1221 -1221
- package/test/integration/spec/webex-core.js +178 -178
- package/test/unit/spec/_setup.js +44 -44
- package/test/unit/spec/credentials/credentials.js +1017 -1017
- package/test/unit/spec/credentials/token.js +441 -441
- package/test/unit/spec/interceptors/auth.js +521 -521
- package/test/unit/spec/interceptors/default-options.js +84 -84
- package/test/unit/spec/interceptors/embargo.js +144 -144
- package/test/unit/spec/interceptors/network-timing.js +49 -49
- package/test/unit/spec/interceptors/payload-transformer.js +155 -155
- package/test/unit/spec/interceptors/rate-limit.js +302 -302
- package/test/unit/spec/interceptors/redirect.js +102 -102
- package/test/unit/spec/interceptors/request-timing.js +92 -92
- package/test/unit/spec/interceptors/user-agent.js +76 -76
- package/test/unit/spec/interceptors/webex-tracking-id.js +76 -76
- package/test/unit/spec/interceptors/webex-user-agent.js +159 -159
- package/test/unit/spec/lib/batcher.js +330 -330
- package/test/unit/spec/lib/page.js +148 -148
- package/test/unit/spec/lib/webex-plugin.js +48 -48
- package/test/unit/spec/services/interceptors/server-error.js +204 -204
- package/test/unit/spec/services/interceptors/service.js +188 -188
- package/test/unit/spec/services/service-catalog.js +194 -194
- package/test/unit/spec/services/service-host.js +260 -260
- package/test/unit/spec/services/service-registry.js +747 -747
- package/test/unit/spec/services/service-state.js +60 -60
- package/test/unit/spec/services/service-url.js +258 -258
- package/test/unit/spec/services/services.js +348 -348
- package/test/unit/spec/storage/persist.js +50 -50
- package/test/unit/spec/storage/storage-adapter.js +12 -12
- package/test/unit/spec/storage/wait-for-value.js +81 -81
- package/test/unit/spec/webex-core.js +253 -253
- package/test/unit/spec/webex-internal-core.js +91 -91
|
@@ -10,37 +10,37 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/he
|
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
11
11
|
var _url = _interopRequireDefault(require("url"));
|
|
12
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.
|
|
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
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.
|
|
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
31
|
*/
|
|
32
|
-
/**
|
|
33
|
-
* @class
|
|
34
|
-
* @classdesc - Manages a single service host and its associated data.
|
|
32
|
+
/**
|
|
33
|
+
* @class
|
|
34
|
+
* @classdesc - Manages a single service host and its associated data.
|
|
35
35
|
*/
|
|
36
36
|
var ServiceHost = /*#__PURE__*/function () {
|
|
37
|
-
/**
|
|
38
|
-
* Generate a new {@link ServiceHost}.
|
|
39
|
-
*
|
|
40
|
-
* @public
|
|
41
|
-
* @constructor
|
|
42
|
-
* @memberof ServiceHost
|
|
43
|
-
* @param {ServiceHostConstructorPTO} pto
|
|
37
|
+
/**
|
|
38
|
+
* Generate a new {@link ServiceHost}.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
* @constructor
|
|
42
|
+
* @memberof ServiceHost
|
|
43
|
+
* @param {ServiceHostConstructorPTO} pto
|
|
44
44
|
*/
|
|
45
45
|
function ServiceHost(pto) {
|
|
46
46
|
(0, _classCallCheck2.default)(this, ServiceHost);
|
|
@@ -48,95 +48,95 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
48
48
|
ServiceHost.validate(pto);
|
|
49
49
|
|
|
50
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
|
|
51
|
+
/**
|
|
52
|
+
* The catalog name that the {@link ServiceHost} is associated with.
|
|
53
|
+
*
|
|
54
|
+
* @instance
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @public
|
|
57
|
+
* @memberof ServiceHost
|
|
58
58
|
*/
|
|
59
59
|
this.catalog = pto.catalog;
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
* The default URI for the {@link ServiceHost}.
|
|
63
|
-
*
|
|
64
|
-
* @instance
|
|
65
|
-
* @type {string}
|
|
66
|
-
* @public
|
|
67
|
-
* @memberof ServiceHost
|
|
61
|
+
/**
|
|
62
|
+
* The default URI for the {@link ServiceHost}.
|
|
63
|
+
*
|
|
64
|
+
* @instance
|
|
65
|
+
* @type {string}
|
|
66
|
+
* @public
|
|
67
|
+
* @memberof ServiceHost
|
|
68
68
|
*/
|
|
69
69
|
this.default = pto.defaultUri;
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* The host group that the {@link ServiceHost} is associated with.
|
|
73
|
-
*
|
|
74
|
-
* @instance
|
|
75
|
-
* @type {string}
|
|
76
|
-
* @public
|
|
77
|
-
* @memberof ServiceHost
|
|
71
|
+
/**
|
|
72
|
+
* The host group that the {@link ServiceHost} is associated with.
|
|
73
|
+
*
|
|
74
|
+
* @instance
|
|
75
|
+
* @type {string}
|
|
76
|
+
* @public
|
|
77
|
+
* @memberof ServiceHost
|
|
78
78
|
*/
|
|
79
79
|
this.hostGroup = pto.hostGroup;
|
|
80
80
|
|
|
81
|
-
/**
|
|
82
|
-
* The cluster ID of the {@link ServiceHost}.
|
|
83
|
-
*
|
|
84
|
-
* @instance
|
|
85
|
-
* @type {string}
|
|
86
|
-
* @public
|
|
87
|
-
* @memberof ServiceHost
|
|
81
|
+
/**
|
|
82
|
+
* The cluster ID of the {@link ServiceHost}.
|
|
83
|
+
*
|
|
84
|
+
* @instance
|
|
85
|
+
* @type {string}
|
|
86
|
+
* @public
|
|
87
|
+
* @memberof ServiceHost
|
|
88
88
|
*/
|
|
89
89
|
this.id = pto.id;
|
|
90
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
|
|
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
99
|
*/
|
|
100
100
|
this.priority = pto.priority;
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* The host uri of the {@link ServiceHost}.
|
|
104
|
-
*
|
|
105
|
-
* @instance
|
|
106
|
-
* @type {string}
|
|
107
|
-
* @public
|
|
108
|
-
* @memberof ServiceHost
|
|
102
|
+
/**
|
|
103
|
+
* The host uri of the {@link ServiceHost}.
|
|
104
|
+
*
|
|
105
|
+
* @instance
|
|
106
|
+
* @type {string}
|
|
107
|
+
* @public
|
|
108
|
+
* @memberof ServiceHost
|
|
109
109
|
*/
|
|
110
110
|
this.uri = pto.uri;
|
|
111
111
|
|
|
112
112
|
// Generate flags.
|
|
113
|
-
/**
|
|
114
|
-
* If the {@link ServiceHost} is marked as failed.
|
|
115
|
-
*
|
|
116
|
-
* @instance
|
|
117
|
-
* @type {boolean}
|
|
118
|
-
* @protected
|
|
119
|
-
* @memberof ServiceHost
|
|
113
|
+
/**
|
|
114
|
+
* If the {@link ServiceHost} is marked as failed.
|
|
115
|
+
*
|
|
116
|
+
* @instance
|
|
117
|
+
* @type {boolean}
|
|
118
|
+
* @protected
|
|
119
|
+
* @memberof ServiceHost
|
|
120
120
|
*/
|
|
121
121
|
this.failed = false;
|
|
122
122
|
|
|
123
|
-
/**
|
|
124
|
-
* If the {@link ServiceHost} is marked as replaced.
|
|
125
|
-
*
|
|
126
|
-
* @instance
|
|
127
|
-
* @type {boolean}
|
|
128
|
-
* @protected
|
|
129
|
-
* @memberof ServiceHost
|
|
123
|
+
/**
|
|
124
|
+
* If the {@link ServiceHost} is marked as replaced.
|
|
125
|
+
*
|
|
126
|
+
* @instance
|
|
127
|
+
* @type {boolean}
|
|
128
|
+
* @protected
|
|
129
|
+
* @memberof ServiceHost
|
|
130
130
|
*/
|
|
131
131
|
this.replaced = false;
|
|
132
132
|
}
|
|
133
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.
|
|
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
140
|
*/
|
|
141
141
|
(0, _createClass2.default)(ServiceHost, [{
|
|
142
142
|
key: "active",
|
|
@@ -145,12 +145,12 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
145
145
|
return !this.failed && !this.replaced;
|
|
146
146
|
}
|
|
147
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.
|
|
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
154
|
*/
|
|
155
155
|
}, {
|
|
156
156
|
key: "local",
|
|
@@ -158,12 +158,12 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
158
158
|
return this.default.includes(this.hostGroup);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
/**
|
|
162
|
-
* The service value.
|
|
163
|
-
*
|
|
164
|
-
* @public
|
|
165
|
-
* @memberof ServiceHost
|
|
166
|
-
* @type {string} - The service value.
|
|
161
|
+
/**
|
|
162
|
+
* The service value.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
* @memberof ServiceHost
|
|
166
|
+
* @type {string} - The service value.
|
|
167
167
|
*/
|
|
168
168
|
}, {
|
|
169
169
|
key: "service",
|
|
@@ -171,12 +171,12 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
171
171
|
return this.id.split(':')[3];
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
/**
|
|
175
|
-
* The formatted url for the host.
|
|
176
|
-
*
|
|
177
|
-
* @public
|
|
178
|
-
* @memberof ServiceHost
|
|
179
|
-
* @type {string} - The service url.
|
|
174
|
+
/**
|
|
175
|
+
* The formatted url for the host.
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
* @memberof ServiceHost
|
|
179
|
+
* @type {string} - The service url.
|
|
180
180
|
*/
|
|
181
181
|
}, {
|
|
182
182
|
key: "url",
|
|
@@ -191,15 +191,15 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
191
191
|
return _url.default.format(urlObj);
|
|
192
192
|
}
|
|
193
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}
|
|
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
203
|
*/
|
|
204
204
|
}, {
|
|
205
205
|
key: "setStatus",
|
|
@@ -215,14 +215,14 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
215
215
|
return this;
|
|
216
216
|
}
|
|
217
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.
|
|
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
226
|
*/
|
|
227
227
|
}], [{
|
|
228
228
|
key: "polyGenerate",
|
|
@@ -240,15 +240,15 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
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}
|
|
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
252
|
*/
|
|
253
253
|
}, {
|
|
254
254
|
key: "validate",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_url","_interopRequireDefault","require","_constants","ServiceHost","pto","_classCallCheck2","default","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","exports"],"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;EAC9B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,SAAAA,YAAYC,GAAG,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAH,WAAA;IACf;IACAA,WAAW,CAACI,QAAQ,CAACH,GAAG,CAAC;;IAEzB;IACA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACI,OAAO,GAAGJ,GAAG,CAACI,OAAO;;IAE1B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACF,OAAO,GAAGF,GAAG,CAACK,UAAU;;IAE7B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,SAAS,GAAGN,GAAG,CAAC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ants","ServiceHost","pto","_classCallCheck2","default","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","exports"],"sources":["service-host.js"],"sourcesContent":["import Url from 'url';\r\n\r\nimport {SERVICE_CATALOGS} from './constants';\r\n\r\n/**\r\n * The parameter transfer object for {@link ServiceHost#constructor}.\r\n *\r\n * @typedef {Object} ServiceHostConstructorPTO\r\n * @property {string} ServiceHostConstructorPTO.catalog - The host's catalog.\r\n * @property {string} ServiceHostConstructorPTO.defaultUri - The host's default.\r\n * @property {string} ServiceHostConstructorPTO.hostGroup - The host's group.\r\n * @property {string} ServiceHostConstructorPTO.id - The host's clusterId.\r\n * @property {number} ServiceHostConstructorPTO.priority - The host's priority.\r\n * @property {string} ServiceHostConstructorPTO.uri - The host's uri.\r\n */\r\n\r\n/**\r\n * The parameter transfer object for {@link ServiceHost#polyGenerate}.\r\n *\r\n * @typedef {Object} ServiceHostPolyGeneratePTO\r\n * @property {string} ServiceHostPolyGeneratePTO.catalog - The target catalog.\r\n * @property {string} ServiceHostPolyGeneratePTO.name - The service name.\r\n * @property {string} ServiceHostPolyGeneratePTO.url - The service url.\r\n */\r\n\r\n/**\r\n * @class\r\n * @classdesc - Manages a single service host and its associated data.\r\n */\r\nexport default class ServiceHost {\r\n /**\r\n * Generate a new {@link ServiceHost}.\r\n *\r\n * @public\r\n * @constructor\r\n * @memberof ServiceHost\r\n * @param {ServiceHostConstructorPTO} pto\r\n */\r\n constructor(pto) {\r\n // Validate the parameter transfer object.\r\n ServiceHost.validate(pto);\r\n\r\n // Map the parameter transfer object to the class object.\r\n /**\r\n * The catalog name that the {@link ServiceHost} is associated with.\r\n *\r\n * @instance\r\n * @type {string}\r\n * @public\r\n * @memberof ServiceHost\r\n */\r\n this.catalog = pto.catalog;\r\n\r\n /**\r\n * The default URI for the {@link ServiceHost}.\r\n *\r\n * @instance\r\n * @type {string}\r\n * @public\r\n * @memberof ServiceHost\r\n */\r\n this.default = pto.defaultUri;\r\n\r\n /**\r\n * The host group that the {@link ServiceHost} is associated with.\r\n *\r\n * @instance\r\n * @type {string}\r\n * @public\r\n * @memberof ServiceHost\r\n */\r\n this.hostGroup = pto.hostGroup;\r\n\r\n /**\r\n * The cluster ID of the {@link ServiceHost}.\r\n *\r\n * @instance\r\n * @type {string}\r\n * @public\r\n * @memberof ServiceHost\r\n */\r\n this.id = pto.id;\r\n\r\n /**\r\n * The priority value of the {@link ServiceHost}. The lower the number, the\r\n * higher the priority.\r\n *\r\n * @instance\r\n * @type {number}\r\n * @public\r\n * @memberof ServiceHost\r\n */\r\n this.priority = pto.priority;\r\n\r\n /**\r\n * The host uri of the {@link ServiceHost}.\r\n *\r\n * @instance\r\n * @type {string}\r\n * @public\r\n * @memberof ServiceHost\r\n */\r\n this.uri = pto.uri;\r\n\r\n // Generate flags.\r\n /**\r\n * If the {@link ServiceHost} is marked as failed.\r\n *\r\n * @instance\r\n * @type {boolean}\r\n * @protected\r\n * @memberof ServiceHost\r\n */\r\n this.failed = false;\r\n\r\n /**\r\n * If the {@link ServiceHost} is marked as replaced.\r\n *\r\n * @instance\r\n * @type {boolean}\r\n * @protected\r\n * @memberof ServiceHost\r\n */\r\n this.replaced = false;\r\n }\r\n\r\n /**\r\n * If the {@link ServiceHost} is in an active state.\r\n *\r\n * @public\r\n * @memberof ServiceHost\r\n * @type {boolean} - `true` if the service is active and usable.\r\n */\r\n get active() {\r\n // Validate that the `ServiceHost` was not marked as failed or replaced.\r\n return !this.failed && !this.replaced;\r\n }\r\n\r\n /**\r\n * If the host is local to the user's cluster.\r\n *\r\n * @public\r\n * @memberof ServiceHost\r\n * @type {boolean} - If the host is local.\r\n */\r\n get local() {\r\n return this.default.includes(this.hostGroup);\r\n }\r\n\r\n /**\r\n * The service value.\r\n *\r\n * @public\r\n * @memberof ServiceHost\r\n * @type {string} - The service value.\r\n */\r\n get service() {\r\n return this.id.split(':')[3];\r\n }\r\n\r\n /**\r\n * The formatted url for the host.\r\n *\r\n * @public\r\n * @memberof ServiceHost\r\n * @type {string} - The service url.\r\n */\r\n get url() {\r\n // Generate a url object from the default url.\r\n const urlObj = Url.parse(this.default);\r\n\r\n // Format the host of the generated url object.\r\n urlObj.host = `${this.uri}${urlObj.port ? `:${urlObj.port}` : ''}`;\r\n\r\n // Assign the formatted url to this.\r\n return Url.format(urlObj);\r\n }\r\n\r\n /**\r\n * Set one or more of the status properties of the class object.\r\n *\r\n * @public\r\n * @memberof ServiceHost\r\n * @param {Object} pto - The parameter transfer object.\r\n * @property {boolean} [pto.failed] - The failed status to set.\r\n * @property {boolean} [pto.replaced] - the replaced status to set.\r\n * @returns {this}\r\n */\r\n setStatus({failed, replaced}) {\r\n if (failed !== undefined) {\r\n this.failed = failed;\r\n }\r\n\r\n if (replaced !== undefined) {\r\n this.replaced = replaced;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Generate a service host using only a catalog, name, and URL.\r\n *\r\n * @public\r\n * @static\r\n * @memberof ServiceHost\r\n * @param {ServiceHostPolyGeneratePTO} pto\r\n * @returns {ServiceHost} - The generated service host.\r\n */\r\n static polyGenerate({catalog, name, url}) {\r\n return new ServiceHost({\r\n catalog,\r\n defaultUri: url,\r\n hostGroup: Url.parse(url).host,\r\n id: name ? `poly-head:poly-group:poly-cluster:${name}` : undefined,\r\n priority: 1,\r\n uri: Url.parse(url).host,\r\n });\r\n }\r\n\r\n /**\r\n * Validate that a constructor parameter transfer object is valid.\r\n *\r\n * @public\r\n * @static\r\n * @memberof ServiceHost\r\n * @param {ServiceHostConstructorPTO} pto\r\n * @throws - If the parameter transfer object is not valid.\r\n * @returns {undefined}\r\n */\r\n static validate({catalog, defaultUri, hostGroup, id, priority, uri}) {\r\n // Generate error-throwing method.\r\n const throwError = (msg) => {\r\n throw new Error(`service-host: invalid constructor parameters, ${msg}`);\r\n };\r\n\r\n // Validate the catalog property.\r\n if (!SERVICE_CATALOGS.includes(catalog)) {\r\n throwError(\"'catalog' must be a string\");\r\n }\r\n\r\n // Validate the `defaultUri` property.\r\n if (typeof defaultUri !== 'string') {\r\n throwError(\"'defaultUri' must be a string\");\r\n }\r\n\r\n // Validate the `hostGroup` property.\r\n if (typeof hostGroup !== 'string') {\r\n throwError(\"'hostGroup' must be a string\");\r\n }\r\n\r\n // Validate the `id` property.\r\n if (typeof id !== 'string' || id.split(':').length !== 4) {\r\n throwError(\"'id' must be a string that contains 3 ':' characters\");\r\n }\r\n\r\n // Validate the `priority` property.\r\n if (typeof priority !== 'number') {\r\n throwError(\"'priority' must be a number\");\r\n }\r\n\r\n // Validate the `uri` property.\r\n if (typeof uri !== 'string') {\r\n throwError(\"'uri' must be a string\");\r\n }\r\n }\r\n}\r\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;EAC9B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,SAAAA,YAAYC,GAAG,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAH,WAAA;IACf;IACAA,WAAW,CAACI,QAAQ,CAACH,GAAG,CAAC;;IAEzB;IACA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACI,OAAO,GAAGJ,GAAG,CAACI,OAAO;;IAE1B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACF,OAAO,GAAGF,GAAG,CAACK,UAAU;;IAE7B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,IAAI,CAACC,SAAS,GAAGN,GAAG,CAACM,SAAS;;IAE9B;AACJ;AACA;AACA;AACA;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