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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +87 -27
  2. package/dist/index.js +43 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/interceptors/redirect.js +18 -0
  5. package/dist/interceptors/redirect.js.map +1 -1
  6. package/dist/lib/batcher.js +1 -1
  7. package/dist/lib/credentials/credentials.js +1 -1
  8. package/dist/lib/credentials/token.js +1 -1
  9. package/dist/lib/services/services.js +1 -1
  10. package/dist/lib/services-v2/constants.js +17 -0
  11. package/dist/lib/services-v2/constants.js.map +1 -0
  12. package/dist/lib/services-v2/index.js +58 -0
  13. package/dist/lib/services-v2/index.js.map +1 -0
  14. package/dist/lib/services-v2/interceptors/hostmap.js +64 -0
  15. package/dist/lib/services-v2/interceptors/hostmap.js.map +1 -0
  16. package/dist/lib/services-v2/interceptors/server-error.js +77 -0
  17. package/dist/lib/services-v2/interceptors/server-error.js.map +1 -0
  18. package/dist/lib/services-v2/interceptors/service.js +137 -0
  19. package/dist/lib/services-v2/interceptors/service.js.map +1 -0
  20. package/dist/lib/services-v2/metrics.js +12 -0
  21. package/dist/lib/services-v2/metrics.js.map +1 -0
  22. package/dist/lib/services-v2/service-catalog.js +346 -0
  23. package/dist/lib/services-v2/service-catalog.js.map +1 -0
  24. package/dist/lib/services-v2/service-detail.js +94 -0
  25. package/dist/lib/services-v2/service-detail.js.map +1 -0
  26. package/dist/lib/services-v2/service-fed-ramp.js +13 -0
  27. package/dist/lib/services-v2/service-fed-ramp.js.map +1 -0
  28. package/dist/lib/services-v2/services-v2.js +985 -0
  29. package/dist/lib/services-v2/services-v2.js.map +1 -0
  30. package/dist/lib/services-v2/types.js +7 -0
  31. package/dist/lib/services-v2/types.js.map +1 -0
  32. package/dist/plugins/logger.js +1 -1
  33. package/dist/webex-core.js +2 -2
  34. package/dist/webex-core.js.map +1 -1
  35. package/package.json +13 -13
  36. package/src/index.js +10 -0
  37. package/src/interceptors/redirect.js +28 -0
  38. package/src/lib/services-v2/README.md +3 -0
  39. package/src/lib/services-v2/constants.ts +21 -0
  40. package/src/lib/services-v2/index.ts +23 -0
  41. package/src/lib/services-v2/interceptors/hostmap.js +36 -0
  42. package/src/lib/services-v2/interceptors/server-error.js +48 -0
  43. package/src/lib/services-v2/interceptors/service.js +101 -0
  44. package/src/lib/services-v2/metrics.js +4 -0
  45. package/src/lib/services-v2/service-catalog.ts +360 -0
  46. package/src/lib/services-v2/service-detail.ts +97 -0
  47. package/src/lib/services-v2/service-fed-ramp.ts +5 -0
  48. package/src/lib/services-v2/services-v2.js +988 -0
  49. package/src/lib/services-v2/types.ts +13 -0
  50. package/test/fixtures/host-catalog-v2.ts +249 -0
  51. package/test/integration/spec/services/services.js +12 -10
  52. package/test/unit/spec/interceptors/redirect.js +72 -0
  53. package/test/unit/spec/services-v2/service-catalog.ts +288 -0
  54. package/test/unit/spec/services-v2/service-detail.ts +147 -0
  55. package/test/unit/spec/services-v2/services-v2.ts +562 -0
@@ -0,0 +1,94 @@
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 _ampersandState = _interopRequireDefault(require("ampersand-state"));
10
+ /**
11
+ * @class
12
+ */
13
+ var ServiceDetail = _ampersandState.default.extend({
14
+ namespace: 'ServiceDetail',
15
+ props: {
16
+ serviceUrls: ['array', false, function () {
17
+ return [];
18
+ }],
19
+ serviceName: ['string', true, undefined],
20
+ id: ['string', true, undefined]
21
+ },
22
+ /**
23
+ * Generate a host url based on the host
24
+ * uri provided.
25
+ * @param {ServiceUrl} serviceUrl
26
+ * @returns {string}
27
+ */
28
+ _generateHostUrl: function _generateHostUrl(serviceUrl) {
29
+ var url = new URL(serviceUrl.baseUrl);
30
+
31
+ // setting url.hostname will not apply during Url.format(), set host via
32
+ // a string literal instead.
33
+ url.host = "".concat(serviceUrl.host).concat(url.port ? ":".concat(url.port) : '');
34
+ return url.href;
35
+ },
36
+ /**
37
+ * Get the current host url with the highest priority. This will only return a URL with a filtered host that has the
38
+ * `homeCluster` value set to `true`.
39
+ * @returns {string} - The priority host url.
40
+ */
41
+ _getPriorityHostUrl: function _getPriorityHostUrl() {
42
+ // format of catalog ensures that array is sorted by highest priority
43
+ var priorityServiceUrl = this._searchForValidPriorityHost();
44
+ if (!priorityServiceUrl) {
45
+ this.serviceUrls = this.serviceUrls.map(function (serviceUrl) {
46
+ serviceUrl.failed = false;
47
+ return serviceUrl;
48
+ });
49
+ priorityServiceUrl = this._searchForValidPriorityHost();
50
+ }
51
+ return priorityServiceUrl ? this._generateHostUrl(priorityServiceUrl) : '';
52
+ },
53
+ /**
54
+ * Searches for a valid service URL with a priority greater than 0 that has not failed.
55
+ * @returns {ServiceUrl | undefined} - The first valid service URL found, or undefined if none exist.
56
+ */
57
+ _searchForValidPriorityHost: function _searchForValidPriorityHost() {
58
+ return this.serviceUrls.find(function (serviceUrl) {
59
+ return serviceUrl.priority > 0 && !serviceUrl.failed;
60
+ });
61
+ },
62
+ /**
63
+ * Attempt to mark a host from this `ServiceDetail` as failed and return true
64
+ * if the provided url has a host that could be successfully marked as failed.
65
+ *
66
+ * @param {string} url
67
+ * @returns {boolean}
68
+ */
69
+ failHost: function failHost(url) {
70
+ var failedUrl = new URL(url);
71
+ var foundHost = this.serviceUrls.find(function (serviceUrl) {
72
+ return serviceUrl.host === failedUrl.host;
73
+ });
74
+ if (foundHost) {
75
+ foundHost.failed = true;
76
+ }
77
+ return foundHost !== undefined;
78
+ },
79
+ /**
80
+ * Generate a url using the host with the
81
+ * highest priority via host rendering.
82
+ *
83
+ * @returns {string} - The full service url.
84
+ */
85
+ get: function get() {
86
+ // return empty string to indicate that no service url is available
87
+ if (!this.serviceUrls || this.serviceUrls.length === 0) {
88
+ return '';
89
+ }
90
+ return this._getPriorityHostUrl();
91
+ }
92
+ });
93
+ var _default = exports.default = ServiceDetail;
94
+ //# sourceMappingURL=service-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ampersandState","_interopRequireDefault","require","ServiceDetail","AmpState","extend","namespace","props","serviceUrls","serviceName","undefined","id","_generateHostUrl","serviceUrl","url","URL","baseUrl","host","concat","port","href","_getPriorityHostUrl","priorityServiceUrl","_searchForValidPriorityHost","map","failed","find","priority","failHost","failedUrl","foundHost","get","length","_default","exports","default"],"sources":["service-detail.ts"],"sourcesContent":["import AmpState from 'ampersand-state';\nimport {ServiceUrl} from './types';\n\n/**\n * @class\n */\nconst ServiceDetail = AmpState.extend({\n namespace: 'ServiceDetail',\n\n props: {\n serviceUrls: ['array', false, () => []],\n serviceName: ['string', true, undefined],\n id: ['string', true, undefined],\n },\n\n /**\n * Generate a host url based on the host\n * uri provided.\n * @param {ServiceUrl} serviceUrl\n * @returns {string}\n */\n _generateHostUrl(serviceUrl: ServiceUrl): string {\n const url = new URL(serviceUrl.baseUrl);\n\n // setting url.hostname will not apply during Url.format(), set host via\n // a string literal instead.\n url.host = `${serviceUrl.host}${url.port ? `:${url.port}` : ''}`;\n\n return url.href;\n },\n\n /**\n * Get the current host url with the highest priority. This will only return a URL with a filtered host that has the\n * `homeCluster` value set to `true`.\n * @returns {string} - The priority host url.\n */\n _getPriorityHostUrl(): string {\n // format of catalog ensures that array is sorted by highest priority\n let priorityServiceUrl = this._searchForValidPriorityHost();\n\n if (!priorityServiceUrl) {\n this.serviceUrls = this.serviceUrls.map((serviceUrl) => {\n serviceUrl.failed = false;\n\n return serviceUrl;\n });\n\n priorityServiceUrl = this._searchForValidPriorityHost();\n }\n\n return priorityServiceUrl ? this._generateHostUrl(priorityServiceUrl) : '';\n },\n\n /**\n * Searches for a valid service URL with a priority greater than 0 that has not failed.\n * @returns {ServiceUrl | undefined} - The first valid service URL found, or undefined if none exist.\n */\n _searchForValidPriorityHost(): ServiceUrl | undefined {\n return this.serviceUrls.find((serviceUrl) => serviceUrl.priority > 0 && !serviceUrl.failed);\n },\n\n /**\n * Attempt to mark a host from this `ServiceDetail` 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: string): boolean {\n const failedUrl = new URL(url);\n\n const foundHost = this.serviceUrls.find((serviceUrl) => serviceUrl.host === failedUrl.host);\n\n if (foundHost) {\n foundHost.failed = true;\n }\n\n return foundHost !== undefined;\n },\n\n /**\n * Generate a url using the host with the\n * highest priority via host rendering.\n *\n * @returns {string} - The full service url.\n */\n get(): string {\n // return empty string to indicate that no service url is available\n if (!this.serviceUrls || this.serviceUrls.length === 0) {\n return '';\n }\n\n return this._getPriorityHostUrl();\n },\n});\n\nexport default ServiceDetail;\n"],"mappings":";;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACA,IAAMC,aAAa,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACpCC,SAAS,EAAE,eAAe;EAE1BC,KAAK,EAAE;IACLC,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE;MAAA,OAAM,EAAE;IAAA,EAAC;IACvCC,WAAW,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAEC,SAAS,CAAC;IACxCC,EAAE,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAED,SAAS;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEE,gBAAgB,WAAAA,iBAACC,UAAsB,EAAU;IAC/C,IAAMC,GAAG,GAAG,IAAIC,GAAG,CAACF,UAAU,CAACG,OAAO,CAAC;;IAEvC;IACA;IACAF,GAAG,CAACG,IAAI,MAAAC,MAAA,CAAML,UAAU,CAACI,IAAI,EAAAC,MAAA,CAAGJ,GAAG,CAACK,IAAI,OAAAD,MAAA,CAAOJ,GAAG,CAACK,IAAI,IAAK,EAAE,CA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W,IAAI,IAAI,CAACA,WAAW,CAACwB,MAAM,KAAK,CAAC,EAAE;MACtD,OAAO,EAAE;IACX;IAEA,OAAO,IAAI,CAACX,mBAAmB,CAAC,CAAC;EACnC;AACF,CAAC,CAAC;AAAC,IAAAY,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEYhC,aAAa"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ 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.ts"],"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"}