@webex/webex-core 3.0.0-beta.13 → 3.0.0-beta.15
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/config.js.map +1 -1
- package/dist/credentials-config.js +44 -44
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +4 -4
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +21 -6
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +19 -5
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +2 -0
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +2 -2
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +1 -1
- 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.map +1 -1
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +6 -6
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +9 -7
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/index.js +2 -2
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +2 -2
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
- package/src/config.js +9 -11
- package/src/credentials-config.js +110 -72
- package/src/index.js +4 -14
- package/src/interceptors/auth.js +36 -37
- package/src/interceptors/default-options.js +0 -1
- package/src/interceptors/embargo.js +1 -1
- package/src/interceptors/payload-transformer.js +1 -2
- package/src/interceptors/rate-limit.js +8 -5
- package/src/interceptors/redirect.js +14 -8
- package/src/interceptors/request-event.js +4 -8
- package/src/interceptors/request-logger.js +8 -5
- package/src/interceptors/response-logger.js +11 -8
- package/src/interceptors/user-agent.js +1 -2
- package/src/interceptors/webex-user-agent.js +3 -9
- package/src/lib/batcher.js +70 -69
- package/src/lib/credentials/credentials.js +112 -122
- package/src/lib/credentials/grant-errors.js +6 -7
- package/src/lib/credentials/index.js +1 -4
- package/src/lib/credentials/scope.js +1 -4
- package/src/lib/credentials/token-collection.js +1 -1
- package/src/lib/credentials/token.js +86 -80
- package/src/lib/page.js +10 -11
- package/src/lib/services/constants.js +3 -13
- package/src/lib/services/index.js +2 -2
- package/src/lib/services/interceptors/server-error.js +12 -7
- package/src/lib/services/interceptors/service.js +6 -5
- package/src/lib/services/metrics.js +1 -1
- package/src/lib/services/service-catalog.js +110 -100
- package/src/lib/services/service-fed-ramp.js +1 -2
- package/src/lib/services/service-host.js +10 -17
- package/src/lib/services/service-registry.js +69 -96
- package/src/lib/services/service-state.js +4 -6
- package/src/lib/services/service-url.js +24 -23
- package/src/lib/services/services.js +260 -251
- package/src/lib/stateless-webex-plugin.js +4 -2
- package/src/lib/storage/decorators.js +68 -66
- package/src/lib/storage/index.js +4 -6
- package/src/lib/storage/make-webex-plugin-store.js +34 -21
- package/src/lib/storage/make-webex-store.js +6 -7
- package/src/lib/storage/memory-store-adapter.js +3 -3
- package/src/lib/webex-core-plugin-mixin.js +10 -7
- package/src/lib/webex-http-error.js +7 -8
- package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
- package/src/lib/webex-plugin.js +41 -34
- package/src/plugins/logger.js +8 -3
- package/src/webex-core.js +185 -116
- package/src/webex-internal-core.js +15 -9
- package/test/integration/spec/credentials/credentials.js +26 -30
- package/test/integration/spec/credentials/token.js +36 -33
- package/test/integration/spec/services/service-catalog.js +177 -156
- package/test/integration/spec/services/services.js +313 -304
- package/test/integration/spec/webex-core.js +98 -86
- package/test/unit/spec/_setup.js +26 -18
- package/test/unit/spec/credentials/credentials.js +189 -154
- package/test/unit/spec/credentials/token.js +94 -76
- package/test/unit/spec/interceptors/auth.js +291 -243
- package/test/unit/spec/interceptors/default-options.js +36 -24
- package/test/unit/spec/interceptors/embargo.js +32 -27
- package/test/unit/spec/interceptors/network-timing.js +2 -2
- package/test/unit/spec/interceptors/payload-transformer.js +61 -52
- package/test/unit/spec/interceptors/rate-limit.js +104 -75
- package/test/unit/spec/interceptors/redirect.js +22 -20
- package/test/unit/spec/interceptors/request-timing.js +18 -22
- package/test/unit/spec/interceptors/user-agent.js +28 -16
- package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
- package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
- package/test/unit/spec/lib/batcher.js +36 -32
- package/test/unit/spec/lib/page.js +36 -32
- package/test/unit/spec/lib/webex-plugin.js +1 -1
- package/test/unit/spec/services/interceptors/server-error.js +67 -90
- package/test/unit/spec/services/interceptors/service.js +17 -28
- package/test/unit/spec/services/service-catalog.js +19 -27
- package/test/unit/spec/services/service-host.js +29 -26
- package/test/unit/spec/services/service-registry.js +128 -170
- package/test/unit/spec/services/service-state.js +13 -22
- package/test/unit/spec/services/service-url.js +24 -43
- package/test/unit/spec/services/services.js +85 -41
- package/test/unit/spec/storage/persist.js +6 -9
- package/test/unit/spec/storage/wait-for-value.js +22 -21
- package/test/unit/spec/webex-core.js +78 -57
- package/test/unit/spec/webex-internal-core.js +56 -31
package/dist/lib/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["itemsMap","linksMap","webexsMap","Page","res","webex","set","body","items","parseLinkHeaders","headers","link","get","length","getLink","hasLink","request","uri","links","then","Boolean","i","next","value","done","linkHeaders","reduce","linkHeader","split","replace","rel"],"sources":["page.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nconst itemsMap = new WeakMap();\nconst linksMap = new WeakMap();\nconst webexsMap = new WeakMap();\n\n/**\n * @class Page\n */\nexport default class Page {\n /**\n * @type {Array}\n */\n get items() {\n return itemsMap.get(this);\n }\n\n /**\n * @type {number}\n */\n get length() {\n return this.items.length;\n }\n\n /**\n * @private\n * @type {Object}\n */\n get links() {\n return linksMap.get(this);\n }\n\n /**\n * @private\n * @type {ProxyWebex}\n */\n get webex() {\n return webexsMap.get(this);\n }\n\n /**\n * @constructs {Page}\n * @param {HttpResponse} res\n * @param {ProxyWebex} webex\n * @returns {Page}\n */\n constructor(res, webex) {\n itemsMap.set(this, res.body.items);\n linksMap.set(this, Page.parseLinkHeaders(res.headers.link));\n webexsMap.set(this, webex);\n\n return this;\n }\n\n /**\n * Separate a single link header string into an actionable object\n * @param {string} linkHeaders\n * @private\n * @returns {Object}\n */\n static parseLinkHeaders(linkHeaders) {\n if (!linkHeaders) {\n return {};\n }\n\n linkHeaders = Array.isArray(linkHeaders) ? linkHeaders : [linkHeaders];\n\n return linkHeaders.reduce((links, linkHeader) => {\n linkHeader = linkHeader.split(';');\n const link = linkHeader[0]
|
|
1
|
+
{"version":3,"names":["itemsMap","linksMap","webexsMap","Page","res","webex","set","body","items","parseLinkHeaders","headers","link","get","length","getLink","hasLink","request","uri","links","then","Boolean","i","next","value","done","linkHeaders","reduce","linkHeader","split","replace","rel"],"sources":["page.js"],"sourcesContent":["/* eslint-disable no-constructor-return */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nconst itemsMap = new WeakMap();\nconst linksMap = new WeakMap();\nconst webexsMap = new WeakMap();\n\n/**\n * @class Page\n */\nexport default class Page {\n /**\n * @type {Array}\n */\n get items() {\n return itemsMap.get(this);\n }\n\n /**\n * @type {number}\n */\n get length() {\n return this.items.length;\n }\n\n /**\n * @private\n * @type {Object}\n */\n get links() {\n return linksMap.get(this);\n }\n\n /**\n * @private\n * @type {ProxyWebex}\n */\n get webex() {\n return webexsMap.get(this);\n }\n\n /**\n * @constructs {Page}\n * @param {HttpResponse} res\n * @param {ProxyWebex} webex\n * @returns {Page}\n */\n constructor(res, webex) {\n itemsMap.set(this, res.body.items);\n linksMap.set(this, Page.parseLinkHeaders(res.headers.link));\n webexsMap.set(this, webex);\n\n return this;\n }\n\n /**\n * Separate a single link header string into an actionable object\n * @param {string} linkHeaders\n * @private\n * @returns {Object}\n */\n static parseLinkHeaders(linkHeaders) {\n if (!linkHeaders) {\n return {};\n }\n\n linkHeaders = Array.isArray(linkHeaders) ? linkHeaders : [linkHeaders];\n\n return linkHeaders.reduce((links, linkHeader) => {\n linkHeader = linkHeader.split(';');\n const link = linkHeader[0].replace('<', '').replace('>', '');\n const rel = linkHeader[1].split('=')[1].replace(/\"/g, '');\n\n links[rel] = link;\n\n return links;\n }, {});\n }\n\n /**\n * Get next page\n * @returns {Function}\n */\n next() {\n return this.getLink('next');\n }\n\n /**\n * Indicates if there's another page\n * @returns {Boolean}\n */\n hasNext() {\n return this.hasLink('next');\n }\n\n /**\n * Get previous page\n * @returns {Page}\n */\n previous() {\n return this.getLink('previous');\n }\n\n /**\n * Indicates if there is a previous Page\n * @returns {Boolean}\n */\n hasPrevious() {\n return this.hasLink('previous');\n }\n\n /**\n * Retrieves the `Page` at url specified by `link`\n * @param {string} link Specifies which link header to return\n * @private\n * @returns {Promise<Page>}\n */\n getLink(link) {\n return this.webex\n .request({\n uri: this.links[link],\n })\n .then((res) => new Page(res, this.webex));\n }\n\n /**\n * Indicates if the specified link is in the link header\n * @param {string} link\n * @private\n * @returns {Boolean}\n */\n hasLink(link) {\n return Boolean(this.links[link]);\n }\n\n /**\n * Iterator\n * @returns {Object}\n */\n [Symbol.iterator]() {\n let i = -1;\n\n return {\n next: () => {\n i += 1;\n if (i < this.length) {\n return {\n value: this.items[i],\n };\n }\n\n return {done: true};\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AAEA,IAAMA,QAAQ,GAAG,sBAAjB;AACA,IAAMC,QAAQ,GAAG,sBAAjB;AACA,IAAMC,SAAS,GAAG,sBAAlB;AAEA;AACA;AACA;;IACqBC,I;EA+BnB;AACF;AACA;AACA;AACA;AACA;EACE,cAAYC,GAAZ,EAAiBC,KAAjB,EAAwB;IAAA;IACtBL,QAAQ,CAACM,GAAT,CAAa,IAAb,EAAmBF,GAAG,CAACG,IAAJ,CAASC,KAA5B;IACAP,QAAQ,CAACK,GAAT,CAAa,IAAb,EAAmBH,IAAI,CAACM,gBAAL,CAAsBL,GAAG,CAACM,OAAJ,CAAYC,IAAlC,CAAnB;IACAT,SAAS,CAACI,GAAV,CAAc,IAAd,EAAoBD,KAApB;IAEA,OAAO,IAAP;EAC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ACVD,CAAC,IAAI,CAAL;;UACA,IAAIA,CAAC,GAAG,MAAI,CAACR,MAAb,EAAqB;YACnB,OAAO;cACLU,KAAK,EAAE,MAAI,CAACf,KAAL,CAAWa,CAAX;YADF,CAAP;UAGD;;UAED,OAAO;YAACG,IAAI,EAAE;UAAP,CAAP;QACD;MAVI,CAAP;IAYD;;;WA7FD,0BAAwBC,WAAxB,EAAqC;MACnC,IAAI,CAACA,WAAL,EAAkB;QAChB,OAAO,EAAP;MACD;;MAEDA,WAAW,GAAG,sBAAcA,WAAd,IAA6BA,WAA7B,GAA2C,CAACA,WAAD,CAAzD;MAEA,OAAOA,WAAW,CAACC,MAAZ,CAAmB,UAACR,KAAD,EAAQS,UAAR,EAAuB;QAC/CA,UAAU,GAAGA,UAAU,CAACC,KAAX,CAAiB,GAAjB,CAAb;QACA,IAAMjB,IAAI,GAAGgB,UAAU,CAAC,CAAD,CAAV,CAAcE,OAAd,CAAsB,GAAtB,EAA2B,EAA3B,EAA+BA,OAA/B,CAAuC,GAAvC,EAA4C,EAA5C,CAAb;QACA,IAAMC,GAAG,GAAGH,UAAU,CAAC,CAAD,CAAV,CAAcC,KAAd,CAAoB,GAApB,EAAyB,CAAzB,EAA4BC,OAA5B,CAAoC,IAApC,EAA0C,EAA1C,CAAZ;QAEAX,KAAK,CAACY,GAAD,CAAL,GAAanB,IAAb;QAEA,OAAOO,KAAP;MACD,CARM,EAQJ,EARI,CAAP;IASD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NAMESPACE","SERVICE_CATALOGS","SERVICE_CATALOGS_ENUM_TYPES","STRING","NUMBER"],"sources":["constants.js"],"sourcesContent":["const NAMESPACE = 'services';\nconst SERVICE_CATALOGS = [
|
|
1
|
+
{"version":3,"names":["NAMESPACE","SERVICE_CATALOGS","SERVICE_CATALOGS_ENUM_TYPES","STRING","NUMBER"],"sources":["constants.js"],"sourcesContent":["const NAMESPACE = 'services';\nconst SERVICE_CATALOGS = ['discovery', 'limited', 'signin', 'postauth', 'custom'];\n\nconst SERVICE_CATALOGS_ENUM_TYPES = {\n STRING: 'SERVICE_CATALOGS_ENUM_TYPES_STRING',\n NUMBER: 'SERVICE_CATALOGS_ENUM_TYPES_NUMBER',\n};\n\nexport {SERVICE_CATALOGS_ENUM_TYPES, NAMESPACE, SERVICE_CATALOGS};\n"],"mappings":";;;;;;;;;AAAA,IAAMA,SAAS,GAAG,UAAlB;;AACA,IAAMC,gBAAgB,GAAG,CAAC,WAAD,EAAc,SAAd,EAAyB,QAAzB,EAAmC,UAAnC,EAA+C,QAA/C,CAAzB;;AAEA,IAAMC,2BAA2B,GAAG;EAClCC,MAAM,EAAE,oCAD0B;EAElCC,MAAM,EAAE;AAF0B,CAApC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerInternalPlugin","Services","interceptors","ServiceInterceptor","create","ServerErrorInterceptor"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nimport {registerInternalPlugin} from '../../webex-core';\n\nimport * as constants from './constants';\nimport Services from './services';\nimport ServerErrorInterceptor from './interceptors/server-error';\nimport ServiceInterceptor from './interceptors/service';\n\nregisterInternalPlugin('services', Services, {\n interceptors: {\n ServiceInterceptor: ServiceInterceptor.create,\n ServerErrorInterceptor: ServerErrorInterceptor.create
|
|
1
|
+
{"version":3,"names":["registerInternalPlugin","Services","interceptors","ServiceInterceptor","create","ServerErrorInterceptor"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nimport {registerInternalPlugin} from '../../webex-core';\n\nimport * as constants from './constants';\nimport Services from './services';\nimport ServerErrorInterceptor from './interceptors/server-error';\nimport ServiceInterceptor from './interceptors/service';\n\nregisterInternalPlugin('services', Services, {\n interceptors: {\n ServiceInterceptor: ServiceInterceptor.create,\n ServerErrorInterceptor: ServerErrorInterceptor.create,\n },\n});\n\nexport {constants};\nexport {default as ServiceInterceptor} from './interceptors/service';\nexport {default as ServerErrorInterceptor} from './interceptors/server-error';\nexport {default as Services} from './services';\nexport {default as ServiceCatalog} from './service-catalog';\nexport {default as ServiceRegistry} from './service-registry';\nexport {default as ServiceState} from './service-state';\nexport {default as ServiceHost} from './service-host';\nexport {default as ServiceUrl} from './service-url';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAEA;;;;AACA;;AACA;;AACA;;AAaA;;AACA;;AACA;;AACA;;AACA;;;;;;AAzBA;AACA;AACA;AAQA,IAAAA,iCAAA,EAAuB,UAAvB,EAAmCC,iBAAnC,EAA6C;EAC3CC,YAAY,EAAE;IACZC,kBAAkB,EAAEA,gBAAA,CAAmBC,MAD3B;IAEZC,sBAAsB,EAAEA,oBAAA,CAAuBD;EAFnC;AAD6B,CAA7C"}
|
|
@@ -81,8 +81,8 @@ var ServerErrorInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
|
81
81
|
key: "create",
|
|
82
82
|
value:
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
* @returns {HAMessagingInterceptor}
|
|
85
|
+
*/
|
|
86
86
|
function create() {
|
|
87
87
|
// eslint-disable-next-line no-invalid-this
|
|
88
88
|
return new ServerErrorInterceptor({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServerErrorInterceptor","options","reason","WebexHttpError","InternalServerError","BadGateway","ServiceUnavailable","uri","feature","webex","internal","device","features","developer","get","value","metrics","submitClientMetrics","fields","success","tags","action","error","message","url","resolve","services","markFailedUrl","then","reject","Interceptor"],"sources":["server-error.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\nimport {WebexHttpError} from '@webex/webex-core';\n/**\n * Changes server url when it fails\n */\nexport default class ServerErrorInterceptor extends Interceptor {\n /**\n
|
|
1
|
+
{"version":3,"names":["ServerErrorInterceptor","options","reason","WebexHttpError","InternalServerError","BadGateway","ServiceUnavailable","uri","feature","webex","internal","device","features","developer","get","value","metrics","submitClientMetrics","fields","success","tags","action","error","message","url","resolve","services","markFailedUrl","then","reject","Interceptor"],"sources":["server-error.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\nimport {WebexHttpError} from '@webex/webex-core';\n/**\n * Changes server url when it fails\n */\nexport default class ServerErrorInterceptor extends Interceptor {\n /**\n * @returns {HAMessagingInterceptor}\n */\n static create() {\n // eslint-disable-next-line no-invalid-this\n return new ServerErrorInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onResponseError\n * @param {Object} options\n * @param {Object} reason\n * @returns {Object}\n */\n onResponseError(options, reason) {\n if (\n (reason instanceof WebexHttpError.InternalServerError ||\n reason instanceof WebexHttpError.BadGateway ||\n reason instanceof WebexHttpError.ServiceUnavailable) &&\n options.uri\n ) {\n const feature = this.webex.internal.device.features.developer.get('web-high-availability');\n\n if (feature && feature.value) {\n this.webex.internal.metrics.submitClientMetrics('web-ha', {\n fields: {success: false},\n tags: {action: 'failed', error: reason.message, url: options.uri},\n });\n\n return Promise.resolve(this.webex.internal.services.markFailedUrl(options.uri)).then(() =>\n Promise.reject(reason)\n );\n }\n }\n\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;;;;;AACA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;IASnB;AACF;AACA;AACA;AACA;AACA;IACE,yBAAgBC,OAAhB,EAAyBC,MAAzB,EAAiC;MAC/B,IACE,CAACA,MAAM,YAAYC,yBAAA,CAAeC,mBAAjC,IACCF,MAAM,YAAYC,yBAAA,CAAeE,UADlC,IAECH,MAAM,YAAYC,yBAAA,CAAeG,kBAFnC,KAGAL,OAAO,CAACM,GAJV,EAKE;QACA,IAAMC,OAAO,GAAG,KAAKC,KAAL,CAAWC,QAAX,CAAoBC,MAApB,CAA2BC,QAA3B,CAAoCC,SAApC,CAA8CC,GAA9C,CAAkD,uBAAlD,CAAhB;;QAEA,IAAIN,OAAO,IAAIA,OAAO,CAACO,KAAvB,EAA8B;UAC5B,KAAKN,KAAL,CAAWC,QAAX,CAAoBM,OAApB,CAA4BC,mBAA5B,CAAgD,QAAhD,EAA0D;YACxDC,MAAM,EAAE;cAACC,OAAO,EAAE;YAAV,CADgD;YAExDC,IAAI,EAAE;cAACC,MAAM,EAAE,QAAT;cAAmBC,KAAK,EAAEpB,MAAM,CAACqB,OAAjC;cAA0CC,GAAG,EAAEvB,OAAO,CAACM;YAAvD;UAFkD,CAA1D;UAKA,OAAO,iBAAQkB,OAAR,CAAgB,KAAKhB,KAAL,CAAWC,QAAX,CAAoBgB,QAApB,CAA6BC,aAA7B,CAA2C1B,OAAO,CAACM,GAAnD,CAAhB,EAAyEqB,IAAzE,CAA8E;YAAA,OACnF,iBAAQC,MAAR,CAAe3B,MAAf,CADmF;UAAA,CAA9E,CAAP;QAGD;MACF;;MAED,OAAO,iBAAQ2B,MAAR,CAAe3B,MAAf,CAAP;IACD;;;;IApCD;AACF;AACA;IACE,kBAAgB;MACd;MACA,OAAO,IAAIF,sBAAJ,CAA2B;QAACS,KAAK,EAAE;MAAR,CAA3B,CAAP;IACD;;;EAPiDqB,qB"}
|
|
@@ -131,7 +131,7 @@ var ServiceInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
if (!options.service) {
|
|
134
|
-
throw new Error(
|
|
134
|
+
throw new Error("a valid 'service' parameter is required");
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
/* eslint-enable class-methods-use-this, no-param-reassign */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["trailingSlashes","ServiceInterceptor","options","uri","normalizeOptions","validateOptions","services","webex","internal","service","resource","waitForService","name","then","serviceUrl","generateUri","catch","reject","Error","formattedService","replace","formattedResource","api","Interceptor"],"sources":["service.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nconst trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n/**\n * @class\n */\nexport default class ServiceInterceptor extends Interceptor {\n /**\n * @returns {ServiceInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new ServiceInterceptor({webex: this});\n }\n\n /* eslint-disable no-param-reassign */\n /**\n * @see Interceptor#onRequest\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n onRequest(options) {\n // Validate that the PTO includes a uri property.\n if (options.uri) {\n return options;\n }\n\n // Normalize and validate the PTO.\n this.normalizeOptions(options);\n this.validateOptions(options);\n\n // Destructure commonly referenced namespaces.\n const {services} = this.webex.internal;\n const {service, resource} = options;\n\n // Attempt to collect the service url.\n return services.waitForService({name: service})\n .then((serviceUrl) => {\n // Generate the combined service url and resource.\n options.uri = this.generateUri(serviceUrl, resource);\n\n return options;\n })\n .catch(()
|
|
1
|
+
{"version":3,"names":["trailingSlashes","ServiceInterceptor","options","uri","normalizeOptions","validateOptions","services","webex","internal","service","resource","waitForService","name","then","serviceUrl","generateUri","catch","reject","Error","formattedService","replace","formattedResource","api","Interceptor"],"sources":["service.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nconst trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n/**\n * @class\n */\nexport default class ServiceInterceptor extends Interceptor {\n /**\n * @returns {ServiceInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new ServiceInterceptor({webex: this});\n }\n\n /* eslint-disable no-param-reassign */\n /**\n * @see Interceptor#onRequest\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n onRequest(options) {\n // Validate that the PTO includes a uri property.\n if (options.uri) {\n return options;\n }\n\n // Normalize and validate the PTO.\n this.normalizeOptions(options);\n this.validateOptions(options);\n\n // Destructure commonly referenced namespaces.\n const {services} = this.webex.internal;\n const {service, resource} = options;\n\n // Attempt to collect the service url.\n return services\n .waitForService({name: service})\n .then((serviceUrl) => {\n // Generate the combined service url and resource.\n options.uri = this.generateUri(serviceUrl, resource);\n\n return options;\n })\n .catch(() =>\n Promise.reject(new Error(`service-interceptor: '${service}' is not a known service`))\n );\n }\n\n /* eslint-disable class-methods-use-this */\n /**\n * Generate a usable request uri string from a service url and a resouce.\n *\n * @param {string} serviceUrl - The service url.\n * @param {string} [resource] - The resouce to be appended to the service url.\n * @returns {string} - The combined service url and resource.\n */\n generateUri(serviceUrl, resource = '') {\n const formattedService = serviceUrl.replace(trailingSlashes, '');\n const formattedResource = resource.replace(trailingSlashes, '');\n\n return `${formattedService}/${formattedResource}`;\n }\n\n /**\n * Normalizes request options relative to service identification.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n normalizeOptions(options) {\n // Validate if the api property is used.\n if (options.api) {\n // Assign the service property the value of the api property if necessary.\n options.service = options.service || options.api;\n delete options.api;\n }\n }\n\n /**\n * Validates that the appropriate options for this interceptor are present.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n validateOptions(options) {\n if (!options.resource) {\n throw new Error('a `resource` parameter is required');\n }\n\n if (!options.service) {\n throw new Error(\"a valid 'service' parameter is required\");\n }\n }\n /* eslint-enable class-methods-use-this, no-param-reassign */\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAEA,IAAMA,eAAe,GAAG,iBAAxB;AAEA;AACA;AACA;;IACqBC,kB;;;;;;;;;;;;;IASnB;;IACA;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MAAA;;MACjB;MACA,IAAIA,O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ED;AACF;AACA;AACA;AACA;AACA;;;;WACE,yBAAgBpB,OAAhB,EAAyB;MACvB,IAAI,CAACA,OAAO,CAACQ,QAAb,EAAuB;QACrB,MAAM,IAAIQ,KAAJ,CAAU,oCAAV,CAAN;MACD;;MAED,IAAI,CAAChB,OAAO,CAACO,OAAb,EAAsB;QACpB,MAAM,IAAIS,KAAJ,CAAU,yCAAV,CAAN;MACD;IACF;IACD;;;;;IAvFA;AACF;AACA;IACE,kBAAgB;MACd;MACA,OAAO,IAAIjB,kBAAJ,CAAuB;QAACM,KAAK,EAAE;MAAR,CAAvB,CAAP;IACD;;;EAP6CgB,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["JS_SDK_SERVICE_NOT_FOUND"],"sources":["metrics.js"],"sourcesContent":["// Metrics for service catalog\nexport default {\n JS_SDK_SERVICE_NOT_FOUND: 'JS_SDK_SERVICE_NOT_FOUND'
|
|
1
|
+
{"version":3,"names":["JS_SDK_SERVICE_NOT_FOUND"],"sources":["metrics.js"],"sourcesContent":["// Metrics for service catalog\nexport default {\n JS_SDK_SERVICE_NOT_FOUND: 'JS_SDK_SERVICE_NOT_FOUND',\n};\n"],"mappings":";;;;;;;;;AAAA;eACe;EACbA,wBAAwB,EAAE;AADb,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","name","serviceGroup","serviceUrls","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","existingService","forEach","service","push","_unloadServiceUrls","splice","indexOf","clean","length","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","key","defaultUrl","hosts","host","hostname","id","homeCluster","undefined","findServiceFromClusterId","clusterId","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","failHost","setAllowedDomains","updateServiceUrls","serviceHostmap","currentServiceUrls","unusedUrls","filter","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","resolve","reject","timeoutTimer","setTimeout","Error","once","clearTimeout"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\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: ['object', true, (() => ({\n discovery: [],\n override: [],\n preauth: [],\n postauth: [],\n signin: []\n }))],\n status: ['object', true, (() => ({\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 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 = (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), 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 &&\n 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 = (typeof serviceGroup === 'string') ?\n this.serviceGroups[serviceGroup] || [] : [\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(\n (serviceUrl) => serviceUrl.hosts.find(\n (host) => host.id === clusterId\n )\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 incomingUrlObj = Url.parse(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(\n (serviceUrl) => {\n if (incomingUrlObj.hostname ===\n Url.parse(serviceUrl.defaultUrl).hostname) {\n return true;\n }\n\n if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.hostname)) {\n return true;\n }\n\n return false;\n }\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(\n (allowedDomain) => urlObj.host.includes(allowedDomain)\n );\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 = (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(Object.keys(this.list()).find(\n (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 * 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(\n (serviceUrl) => serviceHostmap.every(\n (item) => item.name !== serviceUrl.name\n )\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 }\n else {\n this._loadServiceUrls(serviceGroup, [new ServiceUrl({\n ...serviceObj\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 timeoutTimer = setTimeout(() => reject(\n new Error(`services: timeout occured while waiting for '${serviceGroup}' catalog to populate`)\n ), (timeout) ? timeout * 1000 : 60000);\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;;AAEA;;AAEA;;;;;;;;;;;;AAEA;;AACA;AACA;AACA;AACA,IAAMA,cAAc,GAAGC,uBAAA,CAASC,MAAT,CAAgB;EACrCC,SAAS,EAAE,gBAD0B;EAGrCC,KAAK,EAAE;IACLC,aAAa,EAAE,CAAC,QAAD,EAAW,IAAX,EAAkB;MAAA,OAAO;QACtC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e,KAAR,GAAgB8B,UAAU,CAAC9B,KAAX,IAAoB,EAApC;MACD,CAHD,MAIK;QACH,MAAI,CAACnB,gBAAL,CAAsBL,YAAtB,EAAoC,CAAC,IAAIuD,mBAAJ,mBAChCD,UADgC,EAAD,CAApC;MAGD;IACF,CAZD;IAcA,KAAK7D,MAAL,CAAYO,YAAZ,EAA0BN,KAA1B,GAAkC,IAAlC;IACA,KAAK8D,OAAL,CAAaxD,YAAb;IAEA,OAAO,IAAP;EACD,CAlYoC;;EAoYrC;AACF;AACA;AACA;AACA;AACA;AACA;EACEyD,cA3YqC,0BA2YtBzD,YA3YsB,EA2YR0D,OA3YQ,EA2YC;IAAA;;IACpC,OAAO,qBAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;MACtC,IAAI,MAAI,CAACnE,MAAL,CAAYO,YAAZ,EAA0BN,KAA9B,EAAqC;QACnCiE,OAAO;MACR;;MAED,IAAME,YAAY,GAAGC,UAAU,CAAC;QAAA,OAAMF,MAAM,CAC1C,IAAIG,KAAJ,wDAA0D/D,YAA1D,2BAD0C,CAAZ;MAAA,CAAD,EAE3B0D,OAAD,GAAYA,OAAO,GAAG,IAAtB,GAA6B,KAFD,CAA/B;;MAIA,MAAI,CAACM,IAAL,CAAUhE,YAAV,EAAwB,YAAM;QAC5BiE,YAAY,CAACJ,YAAD,CAAZ;QACAF,OAAO;MACR,CAHD;IAID,CAbM,CAAP;EAcD;AA1ZoC,CAAhB,CAAvB;AA4ZA;;;eAEe7E,c"}
|
|
1
|
+
{"version":3,"names":["ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","name","serviceGroup","serviceUrls","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","existingService","forEach","service","push","_unloadServiceUrls","splice","indexOf","clean","length","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","key","defaultUrl","hosts","host","hostname","id","homeCluster","undefined","findServiceFromClusterId","clusterId","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","failHost","setAllowedDomains","updateServiceUrls","serviceHostmap","currentServiceUrls","unusedUrls","filter","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","resolve","reject","timeoutTimer","setTimeout","Error","once","clearTimeout"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\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 incomingUrlObj = Url.parse(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 if (incomingUrlObj.hostname === Url.parse(serviceUrl.defaultUrl).hostname) {\n return true;\n }\n\n if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.hostname)) {\n return true;\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 * 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 timeoutTimer = setTimeout(\n () =>\n reject(\n new Error(\n `services: timeout occured while waiting for '${serviceGroup}' catalog to populate`\n )\n ),\n timeout ? timeout * 1000 : 60000\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;;AAEA;;AAEA;;;;;;;;;;;;AAEA;;AACA;AACA;AACA;AACA,IAAMA,cAAc,GAAGC,uBAAA,CAAS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A8BC,YAA9B,CAAhB;;MAEA,IAAIS,OAAJ,EAAa;QACXA,OAAO,CAACc,UAAR,GAAqB+B,UAAU,CAAC/B,UAAhC;QACAd,OAAO,CAACe,KAAR,GAAgB8B,UAAU,CAAC9B,KAAX,IAAoB,EAApC;MACD,CAHD,MAGO;QACL,MAAI,CAACnB,gBAAL,CAAsBL,YAAtB,EAAoC,CAClC,IAAIuD,mBAAJ,mBACKD,UADL,EADkC,CAApC;MAKD;IACF,CAbD;IAeA,KAAK7D,MAAL,CAAYO,YAAZ,EAA0BN,KAA1B,GAAkC,IAAlC;IACA,KAAK8D,OAAL,CAAaxD,YAAb;IAEA,OAAO,IAAP;EACD,CAtYoC;;EAwYrC;AACF;AACA;AACA;AACA;AACA;AACA;EACEyD,cA/YqC,0BA+YtBzD,YA/YsB,EA+YR0D,OA/YQ,EA+YC;IAAA;;IACpC,OAAO,qBAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;MACtC,IAAI,MAAI,CAACnE,MAAL,CAAYO,YAAZ,EAA0BN,KAA9B,EAAqC;QACnCiE,OAAO;MACR;;MAED,IAAME,YAAY,GAAGC,UAAU,CAC7B;QAAA,OACEF,MAAM,CACJ,IAAIG,KAAJ,wDACkD/D,YADlD,2BADI,CADR;MAAA,CAD6B,EAO7B0D,OAAO,GAAGA,OAAO,GAAG,IAAb,GAAoB,KAPE,CAA/B;;MAUA,MAAI,CAACM,IAAL,CAAUhE,YAAV,EAAwB,YAAM;QAC5BiE,YAAY,CAACJ,YAAD,CAAZ;QACAF,OAAO;MACR,CAHD;IAID,CAnBM,CAAP;EAoBD;AApaoC,CAAhB,CAAvB;AAsaA;;;eAEe7E,c"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hydra","u2c"],"sources":["service-fed-ramp.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["hydra","u2c"],"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};\n"],"mappings":";;;;;;;;;eAAe;EACbA,KAAK,EAAE,gCADM;EAEbC,GAAG,EAAE;AAFQ,C"}
|
|
@@ -280,32 +280,32 @@ var ServiceHost = /*#__PURE__*/function () {
|
|
|
280
280
|
|
|
281
281
|
|
|
282
282
|
if (!_constants.SERVICE_CATALOGS.includes(catalog)) {
|
|
283
|
-
throwError('
|
|
283
|
+
throwError("'catalog' must be a string");
|
|
284
284
|
} // Validate the `defaultUri` property.
|
|
285
285
|
|
|
286
286
|
|
|
287
287
|
if (typeof defaultUri !== 'string') {
|
|
288
|
-
throwError('
|
|
288
|
+
throwError("'defaultUri' must be a string");
|
|
289
289
|
} // Validate the `hostGroup` property.
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
if (typeof hostGroup !== 'string') {
|
|
293
|
-
throwError('
|
|
293
|
+
throwError("'hostGroup' must be a string");
|
|
294
294
|
} // Validate the `id` property.
|
|
295
295
|
|
|
296
296
|
|
|
297
297
|
if (typeof id !== 'string' || id.split(':').length !== 4) {
|
|
298
|
-
throwError('
|
|
298
|
+
throwError("'id' must be a string that contains 3 ':' characters");
|
|
299
299
|
} // Validate the `priority` property.
|
|
300
300
|
|
|
301
301
|
|
|
302
302
|
if (typeof priority !== 'number') {
|
|
303
|
-
throwError('
|
|
303
|
+
throwError("'priority' must be a number");
|
|
304
304
|
} // Validate the `uri` property.
|
|
305
305
|
|
|
306
306
|
|
|
307
307
|
if (typeof uri !== 'string') {
|
|
308
|
-
throwError('
|
|
308
|
+
throwError("'uri' must be a string");
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceHost","pto","validate","catalog","default","defaultUri","hostGroup","id","priority","uri","failed","replaced","includes","split","urlObj","Url","parse","host","port","format","undefined","name","url","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({\n catalog,\n defaultUri,\n hostGroup,\n id,\n priority,\n uri\n }) {\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;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;IACqBA,W;EACnB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,qBAAYC,GAAZ,EAAiB;IAAA;IACf;IACAD,WAAW,CAACE,QAAZ,CAAqBD,GAArB,EAFe,CAIf;;IACA;AACJ;AACA;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C,GAAD,EAAS;QAC1B,MAAM,IAAIC,KAAJ,yDAA2DD,GAA3D,EAAN;MACD,CAFD,CAFC,CAMD;;;MACA,IAAI,CAACE,2BAAA,CAAiBd,QAAjB,CAA0BT,OAA1B,CAAL,EAAyC;QACvCoB,UAAU,CAAC,8BAAD,CAAV;MACD,CATA,CAWD;;;MACA,IAAI,OAAOlB,UAAP,KAAsB,QAA1B,EAAoC;QAClCkB,UAAU,CAAC,iCAAD,CAAV;MACD,CAdA,CAgBD;;;MACA,IAAI,OAAOjB,SAAP,KAAqB,QAAzB,EAAmC;QACjCiB,UAAU,CAAC,gCAAD,CAAV;MACD,CAnBA,CAqBD;;;MACA,IAAI,OAAOhB,EAAP,KAAc,QAAd,IAA0BA,EAAE,CAACM,KAAH,CAAS,GAAT,EAAcc,MAAd,KAAyB,CAAvD,EAA0D;QACxDJ,UAAU,CAAC,0DAAD,CAAV;MACD,CAxBA,CA0BD;;;MACA,IAAI,OAAOf,QAAP,KAAoB,QAAxB,EAAkC;QAChCe,UAAU,CAAC,+BAAD,CAAV;MACD,CA7BA,CA+BD;;;MACA,IAAI,OAAOd,GAAP,KAAe,QAAnB,EAA6B;QAC3Bc,UAAU,CAAC,0BAAD,CAAV;MACD;IACF"}
|
|
1
|
+
{"version":3,"names":["ServiceHost","pto","validate","catalog","default","defaultUri","hostGroup","id","priority","uri","failed","replaced","includes","split","urlObj","Url","parse","host","port","format","undefined","name","url","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;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;IACqBA,W;EACnB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,qBAAYC,GAAZ,EAAiB;IAAA;IACf;IACAD,WAAW,CAACE,QAAZ,CAAqBD,GAArB,EAFe,CAIf;;IACA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IACI,KAAKE,OAAL,GAAeF,GAAG,CAACE,OAAnB;IAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IACI,KAAKC,OAAL,GAAeH,GAAG,CAACI,UAAnB;IAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IACI,KAAKC,SAAL,GAAiBL,GAAG,CAACK,SAArB;IAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IACI,KAAKC,EAAL,GAAUN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,+BAAD,CAAV;MACD,CAdkE,CAgBnE;;;MACA,IAAI,OAAOjB,SAAP,KAAqB,QAAzB,EAAmC;QACjCiB,UAAU,CAAC,8BAAD,CAAV;MACD,CAnBkE,CAqBnE;;;MACA,IAAI,OAAOhB,EAAP,KAAc,QAAd,IAA0BA,EAAE,CAACM,KAAH,CAAS,GAAT,EAAcc,MAAd,KAAyB,CAAvD,EAA0D;QACxDJ,UAAU,CAAC,sDAAD,CAAV;MACD,CAxBkE,CA0BnE;;;MACA,IAAI,OAAOf,QAAP,KAAoB,QAAxB,EAAkC;QAChCe,UAAU,CAAC,6BAAD,CAAV;MACD,CA7BkE,CA+BnE;;;MACA,IAAI,OAAOd,GAAP,KAAe,QAAnB,EAA6B;QAC3Bc,UAAU,CAAC,wBAAD,CAAV;MACD;IACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceRegistry","hosts","find","active","local","priority","reduce","map","host","hostReference","service","url","filter","removing","includes","failing","forEach","setStatus","failed","catalog","catalogs","catalogId","mapCatalogName","id","type","SERVICE_CATALOGS_ENUM_TYPES","STRING","length","cluster","clusters","filteredHosts","currentHost","foundHost","hostGroup","push","foundHostCatalogPriority","NUMBER","currentHostCatalogPriority","splice","indexOf","services","urls","filterActive","filterCatalog","filterCluster","filterLocal","filterPriority","filterService","filterUrl","validHosts","loadableHost","ServiceHost","replacing","replaced","resetting","SERVICE_CATALOGS","undefined","hostCatalog","serviceLinks","catalogIndex","Error","output","key","defaultUri","split","uri"],"sources":["service-registry.js"],"sourcesContent":["import {\n SERVICE_CATALOGS,\n SERVICE_CATALOGS_ENUM_TYPES\n} from './constants';\nimport ServiceHost from './service-host';\n\n/**\n * The parameter transfer object for {@link ServiceRegistry#mapRemoteCatalog}.\n * This object is shaped to match the object returned from the **U2C** service.\n *\n * @typedef {Record<string, string>} RSL\n * @typedef {Record<string, Array<Record<string, number | string>>>} RHC\n *\n * @typedef {Object} MapRemoteCatalogPTO\n * @property {string} MapRemoteCatalogPTO.catalog - Service catalog name.\n * @property {RSL} MapRemoteCatalogPTO.serviceLinks - Service links.\n * @property {RHC} MapRemoteCatalogPTO.hostCatalog - Service host catalog.\n */\n\n/**\n * Service manipulation filter object for retrieving services within the\n * {@link ServiceRegistry} class.\n *\n * @typedef {Object} HostFilter\n * @property {boolean} [HostFilter.active] - Active state to filter.\n * @property {Array<string> | string} [HostFilter.catalog] - Catalogs to filter.\n * @property {Array<string> | string} [HostFilter.cluster] - Clusters to filter.\n * @property {boolean} [HostFilter.local] - Filter to the user's home cluster.\n * @property {boolean} [HostFilter.priority] - Filter for the highest priority.\n * @property {Array<string> | string} [HostFilter.service] - Services to filter.\n * @property {Array<string> | string} [HostFilter.url] - URL to filter.\n */\n\n/**\n * @class\n * @classdesc - Manages a collection of {@link ServiceHost} class objects.\n */\nexport default class ServiceRegistry {\n /**\n * Generate a new {@link ServiceHost}.\n *\n * @public\n * @constructor\n * @memberof ServiceHost\n */\n constructor() {\n /**\n * The collection of managed {@link ServiceHost}s.\n *\n * @instance\n * @type {Array<ServiceHost>}\n * @private\n * @memberof ServiceRegistry\n */\n this.hosts = [];\n }\n\n /**\n * An active, local, and priority mapped record of the current\n * {@link ServiceCatalog#hosts}.\n *\n * @public\n * @memberof ServiceCatalog\n * @type {Record<string, string>}\n */\n get map() {\n // Get a list of active, local, and priority-mapped hosts.\n return this.find({\n active: true,\n local: true,\n priority: true\n }).reduce(\n (map, host) => {\n // Generate a new object to assign the existing map.\n const hostReference = {};\n\n // Assign the key:value pair for the service and url.\n hostReference[host.service] = host.url;\n\n // Assign the reference to the map and return.\n return {...map, ...hostReference};\n }, {}\n );\n }\n\n /**\n * Removes a collection of {@link ServiceHost} class objects from the\n * {@link ServiceRegistry#hosts} array based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter for hosts to remove.\n * @returns {Array<ServiceHost>} - The removed {@link ServiceHost}s.\n */\n clear(filter) {\n // Collect a list of hosts to remove based on the provided filter.\n const removing = this.find(filter);\n\n // Remove the hosts from the array.\n this.hosts = this.hosts.filter(\n (host) => !removing.includes(host)\n );\n\n // Return the removed hosts.\n return removing;\n }\n\n /**\n * Mark a collection of {@link ServiceHost} class objects from the\n * {@link ServiceRegistry#hosts} array as failed based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter for hosts to mark failed.\n * @returns {Array<ServiceHost>} - The {@link ServiceHost}s marked failed.\n */\n failed(filter) {\n // Collect a list of hosts to mark as failed based on the provided filter.\n const failing = this.find(filter);\n\n // Mark the hosts from the array as failed.\n failing.forEach(\n (host) => {\n host.setStatus({failed: true});\n }\n );\n\n // Return the marked hosts.\n return failing;\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their active states.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {boolean} [active] - Filter for the host state.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterActive(active) {\n // Filter the host array if the active requirement is true.\n return (typeof active === 'boolean') ?\n this.hosts.filter((host) => host.active === active) :\n [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their assigned\n * catalog values.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [catalog] - Catalogs to filter.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterCatalog(catalog = []) {\n // Generate a catalog names array based on the provided catalog param.\n const catalogs = (Array.isArray(catalog) ? catalog : [catalog])\n .map((catalogId) => ServiceRegistry.mapCatalogName({\n id: catalogId,\n type: SERVICE_CATALOGS_ENUM_TYPES.STRING\n }) || catalogId);\n\n // Filter the host array against the catalog names array.\n return (catalogs.length > 0) ?\n this.hosts.filter((host) => catalogs.includes(host.catalog)) :\n [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their assigned\n * cluster values.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [cluster] - Clusters to filter for.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterCluster(cluster = []) {\n // Generate an array of clusters regardless of parameter type.\n const clusters = (Array.isArray(cluster) ? cluster : [cluster]);\n\n // Filter the host array against the provided clusters.\n return (clusters.length > 0) ?\n this.hosts.filter((host) => clusters.includes(host.id)) :\n [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their location in\n * reference to the authenticated user.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {boolean} [local] - Filter for the host location.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterLocal(local) {\n return (typeof local === 'boolean') ?\n this.hosts.filter((host) => host.local === local) :\n [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array for the highest priority\n * hosts for each specific service.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {boolean} [priority] - Filter for the highest priority\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterPriority(priority) {\n return (priority) ?\n this.hosts.reduce(\n (filteredHosts, currentHost) => {\n // Validate that the current host is not active.\n if (!currentHost.active) {\n return filteredHosts;\n }\n\n // Determine if the filtered hosts array contains a host from the same\n // host group.\n const foundHost = filteredHosts.find(\n (host) => host.hostGroup === currentHost.hostGroup\n );\n\n // Validate if a host was found.\n if (!foundHost) {\n filteredHosts.push(currentHost);\n\n return filteredHosts;\n }\n\n // Map the found host's catalog to its priority value.\n const foundHostCatalogPriority = ServiceRegistry.mapCatalogName({\n id: foundHost.catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER\n });\n\n // Map the current host's catalog to its priority value.\n const currentHostCatalogPriority = ServiceRegistry.mapCatalogName({\n id: currentHost.catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER\n });\n\n // Validate if the found host has a lower priority than the current\n // host.\n if (\n foundHostCatalogPriority < currentHostCatalogPriority ||\n foundHost.priority < currentHost.priority\n ) {\n filteredHosts.splice(filteredHosts.indexOf(foundHost, 1));\n filteredHosts.push(currentHost);\n }\n\n return filteredHosts;\n }, []\n ) : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array for hosts with a specified\n * set of service names.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [service] - Services to filter.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterService(service = []) {\n // Generate an array of services regardless of parameter type.\n const services = (Array.isArray(service) ? service : [service]);\n\n // Filter the host array against the provided services.\n return (services.length > 0) ?\n this.hosts.filter((host) => services.includes(host.service)) :\n [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array for hosts with a specified\n * set of URLs.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [url] - URL to filter.\n * @returns {Array<ServiceHost>} - The filter host array.\n */\n filterUrl(url = []) {\n // Generate an array of URLs regardless of the parameter type.\n const urls = (Array.isArray(url) ? url : [url]);\n\n // Filter the host array against the provided URLs.\n return (urls.length > 0) ?\n this.hosts.filter((host) => urls.includes(host.url)) :\n [...this.hosts];\n }\n\n /**\n * Get an array of {@link ServiceHost}s based on a provided\n * {@link HostFilter} from the {@link ServiceRegistry#hosts} array.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} [filter] - The inclusive filter for hosts to find.\n * @returns {Array<ServiceHost>} - The filtered hosts.\n */\n find({\n active,\n catalog,\n cluster,\n local,\n priority,\n service,\n url\n } = {}) {\n return this.hosts.filter(\n (host) => (\n this.filterActive(active).includes(host) &&\n this.filterCatalog(catalog).includes(host) &&\n this.filterCluster(cluster).includes(host) &&\n this.filterLocal(local).includes(host) &&\n this.filterPriority(priority).includes(host) &&\n this.filterService(service).includes(host) &&\n this.filterUrl(url).includes(host)\n )\n );\n }\n\n /**\n * Load a formatted array of {@link ServiceHost} constructor parameter\n * transfer objects as instances of {@link ServiceHost} class objects to the\n * {@link ServiceRegistry#hosts} array.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {Array<ServiceHost.ConstructorPTO>} hosts\n * @returns {this}\n */\n load(hosts = []) {\n // Validate that the provided hosts are eligible to be loaded.\n const validHosts = hosts.filter((host) => !!(\n ServiceRegistry.mapCatalogName({\n id: host.catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.STRING\n })));\n\n // Load the eligible hosts.\n this.hosts.push(\n ...validHosts.map((loadableHost) => new ServiceHost(loadableHost))\n );\n\n return this;\n }\n\n /**\n * Mark a collection of {@link ServiceHost} class objects from the\n * {@link ServiceRegistry#hosts} array as replaced based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter to mark replaced.\n * @returns {Array<ServiceHost>} - The {@link ServiceHost}s marked replaced.\n */\n replaced(filter) {\n // Collect a list of hosts to mark as replaced based on the provided filter.\n const replacing = this.find(filter);\n\n // Mark the hosts from the array as replaced.\n replacing.forEach(\n (host) => {\n host.setStatus({replaced: true});\n }\n );\n\n // Return the marked hosts.\n return replacing;\n }\n\n /**\n * Reset the failed status of a collection of {@link ServiceHost} class\n * objects from the {@link ServiceRegistry#hosts} array based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter of hosts to reset.\n * @returns {Array<ServiceHost>} - The {@link ServiceHost}s that reset.\n */\n reset(filter) {\n // Collect a list of hosts to mark as replaced based on the provided filter.\n const resetting = this.find(filter);\n\n // Mark the hosts from the array as replaced.\n resetting.forEach(\n (host) => {\n host.setStatus({failed: false});\n }\n );\n\n // Return the marked hosts.\n return resetting;\n }\n\n /**\n * Convert a {@link SERVICE_CATALOGS} identifier or value to its associated\n * idenfier or value.\n *\n * @public\n * @static\n * @memberof ServiceRegistry\n * @param {Object} pto - The parameter transfer object.\n * @property {string | number} pto.id - The identifier to convert in the enum.\n * @property {SERVICE_CATALOGS_ENUM_TYPES} pto.type - The desired output.\n * @returns {string|number} - The matching enum value or index.\n */\n static mapCatalogName({id, type}) {\n // Validate that the id is a number.\n if (typeof id === 'number') {\n // Validate that the desired type is a number.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.NUMBER) {\n return (SERVICE_CATALOGS[id] !== undefined) ? id : undefined;\n }\n\n // Validate that the desired type is a string.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.STRING) {\n return SERVICE_CATALOGS[id];\n }\n }\n\n // Validate that the id is a string.\n if (typeof id === 'string') {\n // Validate that the desired type is a string.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.STRING) {\n return SERVICE_CATALOGS.includes(id) ? id : undefined;\n }\n\n // Validate that the desired type is a number.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.NUMBER) {\n return (SERVICE_CATALOGS.includes(id)) ?\n SERVICE_CATALOGS.indexOf(id) :\n undefined;\n }\n }\n\n return undefined;\n }\n\n /**\n * Generate a formatted array based on the object received from the **U2C**\n * service for usage in the {@link ServiceRegistry#load} method.\n *\n * @public\n * @static\n * @memberof ServiceRegistry\n * @param {MapRemoteCatalogPTO} pto - The parameter transfer object.\n * @throws - If the target catalog does not exist.\n * @returns {Array<ServiceHost#ServiceHostConstructorPTO>}\n */\n static mapRemoteCatalog({catalog, hostCatalog, serviceLinks}) {\n // Collect the service catalog name if needed.\n const catalogIndex = ServiceRegistry.mapCatalogName({\n id: catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.STRING\n });\n\n // Validate that the target catalog exists.\n if (!SERVICE_CATALOGS.includes(catalogIndex)) {\n throw new Error(`service-catalogs: '${catalog}' is not a valid catalog`);\n }\n\n // Map the remote catalog to a mountable host array.\n return Object.keys(hostCatalog).reduce((output, key) => {\n output.push(\n ...hostCatalog[key].map((host) => ({\n catalog: catalogIndex,\n defaultUri: serviceLinks[host.id.split(':')[3]],\n hostGroup: key,\n id: host.id,\n priority: host.priority,\n uri: host.host\n }))\n );\n\n return output;\n }, []);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAIA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;A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CW,OAAO,EAAEwC,YADwB;YAEjCI,UAAU,EAAEL,YAAY,CAAClD,IAAI,CAACe,EAAL,CAAQyC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAFS;YAGjC/B,SAAS,EAAE6B,GAHsB;YAIjCvC,EAAE,EAAEf,IAAI,CAACe,EAJwB;YAKjClB,QAAQ,EAAEG,IAAI,CAACH,QALkB;YAMjC4D,GAAG,EAAEzD,IAAI,CAACA;UANuB,CAAX;QAAA,CAArB,CADC,EAAN;QAWA,OAAOqD,MAAP;MACD,CAbM,EAaJ,EAbI,CAAP;IAcD"}
|
|
1
|
+
{"version":3,"names":["ServiceRegistry","hosts","find","active","local","priority","reduce","map","host","hostReference","service","url","filter","removing","includes","failing","forEach","setStatus","failed","catalog","catalogs","catalogId","mapCatalogName","id","type","SERVICE_CATALOGS_ENUM_TYPES","STRING","length","cluster","clusters","filteredHosts","currentHost","foundHost","hostGroup","push","foundHostCatalogPriority","NUMBER","currentHostCatalogPriority","splice","indexOf","services","urls","filterActive","filterCatalog","filterCluster","filterLocal","filterPriority","filterService","filterUrl","validHosts","loadableHost","ServiceHost","replacing","replaced","resetting","SERVICE_CATALOGS","undefined","hostCatalog","serviceLinks","catalogIndex","Error","output","key","defaultUri","split","uri"],"sources":["service-registry.js"],"sourcesContent":["import {SERVICE_CATALOGS, SERVICE_CATALOGS_ENUM_TYPES} from './constants';\nimport ServiceHost from './service-host';\n\n/**\n * The parameter transfer object for {@link ServiceRegistry#mapRemoteCatalog}.\n * This object is shaped to match the object returned from the **U2C** service.\n *\n * @typedef {Record<string, string>} RSL\n * @typedef {Record<string, Array<Record<string, number | string>>>} RHC\n *\n * @typedef {Object} MapRemoteCatalogPTO\n * @property {string} MapRemoteCatalogPTO.catalog - Service catalog name.\n * @property {RSL} MapRemoteCatalogPTO.serviceLinks - Service links.\n * @property {RHC} MapRemoteCatalogPTO.hostCatalog - Service host catalog.\n */\n\n/**\n * Service manipulation filter object for retrieving services within the\n * {@link ServiceRegistry} class.\n *\n * @typedef {Object} HostFilter\n * @property {boolean} [HostFilter.active] - Active state to filter.\n * @property {Array<string> | string} [HostFilter.catalog] - Catalogs to filter.\n * @property {Array<string> | string} [HostFilter.cluster] - Clusters to filter.\n * @property {boolean} [HostFilter.local] - Filter to the user's home cluster.\n * @property {boolean} [HostFilter.priority] - Filter for the highest priority.\n * @property {Array<string> | string} [HostFilter.service] - Services to filter.\n * @property {Array<string> | string} [HostFilter.url] - URL to filter.\n */\n\n/**\n * @class\n * @classdesc - Manages a collection of {@link ServiceHost} class objects.\n */\nexport default class ServiceRegistry {\n /**\n * Generate a new {@link ServiceHost}.\n *\n * @public\n * @constructor\n * @memberof ServiceHost\n */\n constructor() {\n /**\n * The collection of managed {@link ServiceHost}s.\n *\n * @instance\n * @type {Array<ServiceHost>}\n * @private\n * @memberof ServiceRegistry\n */\n this.hosts = [];\n }\n\n /**\n * An active, local, and priority mapped record of the current\n * {@link ServiceCatalog#hosts}.\n *\n * @public\n * @memberof ServiceCatalog\n * @type {Record<string, string>}\n */\n get map() {\n // Get a list of active, local, and priority-mapped hosts.\n return this.find({\n active: true,\n local: true,\n priority: true,\n }).reduce((map, host) => {\n // Generate a new object to assign the existing map.\n const hostReference = {};\n\n // Assign the key:value pair for the service and url.\n hostReference[host.service] = host.url;\n\n // Assign the reference to the map and return.\n return {...map, ...hostReference};\n }, {});\n }\n\n /**\n * Removes a collection of {@link ServiceHost} class objects from the\n * {@link ServiceRegistry#hosts} array based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter for hosts to remove.\n * @returns {Array<ServiceHost>} - The removed {@link ServiceHost}s.\n */\n clear(filter) {\n // Collect a list of hosts to remove based on the provided filter.\n const removing = this.find(filter);\n\n // Remove the hosts from the array.\n this.hosts = this.hosts.filter((host) => !removing.includes(host));\n\n // Return the removed hosts.\n return removing;\n }\n\n /**\n * Mark a collection of {@link ServiceHost} class objects from the\n * {@link ServiceRegistry#hosts} array as failed based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter for hosts to mark failed.\n * @returns {Array<ServiceHost>} - The {@link ServiceHost}s marked failed.\n */\n failed(filter) {\n // Collect a list of hosts to mark as failed based on the provided filter.\n const failing = this.find(filter);\n\n // Mark the hosts from the array as failed.\n failing.forEach((host) => {\n host.setStatus({failed: true});\n });\n\n // Return the marked hosts.\n return failing;\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their active states.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {boolean} [active] - Filter for the host state.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterActive(active) {\n // Filter the host array if the active requirement is true.\n return typeof active === 'boolean'\n ? this.hosts.filter((host) => host.active === active)\n : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their assigned\n * catalog values.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [catalog] - Catalogs to filter.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterCatalog(catalog = []) {\n // Generate a catalog names array based on the provided catalog param.\n const catalogs = (Array.isArray(catalog) ? catalog : [catalog]).map(\n (catalogId) =>\n ServiceRegistry.mapCatalogName({\n id: catalogId,\n type: SERVICE_CATALOGS_ENUM_TYPES.STRING,\n }) || catalogId\n );\n\n // Filter the host array against the catalog names array.\n return catalogs.length > 0\n ? this.hosts.filter((host) => catalogs.includes(host.catalog))\n : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their assigned\n * cluster values.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [cluster] - Clusters to filter for.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterCluster(cluster = []) {\n // Generate an array of clusters regardless of parameter type.\n const clusters = Array.isArray(cluster) ? cluster : [cluster];\n\n // Filter the host array against the provided clusters.\n return clusters.length > 0\n ? this.hosts.filter((host) => clusters.includes(host.id))\n : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array against their location in\n * reference to the authenticated user.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {boolean} [local] - Filter for the host location.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterLocal(local) {\n return typeof local === 'boolean'\n ? this.hosts.filter((host) => host.local === local)\n : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array for the highest priority\n * hosts for each specific service.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {boolean} [priority] - Filter for the highest priority\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterPriority(priority) {\n return priority\n ? this.hosts.reduce((filteredHosts, currentHost) => {\n // Validate that the current host is not active.\n if (!currentHost.active) {\n return filteredHosts;\n }\n\n // Determine if the filtered hosts array contains a host from the same\n // host group.\n const foundHost = filteredHosts.find((host) => host.hostGroup === currentHost.hostGroup);\n\n // Validate if a host was found.\n if (!foundHost) {\n filteredHosts.push(currentHost);\n\n return filteredHosts;\n }\n\n // Map the found host's catalog to its priority value.\n const foundHostCatalogPriority = ServiceRegistry.mapCatalogName({\n id: foundHost.catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER,\n });\n\n // Map the current host's catalog to its priority value.\n const currentHostCatalogPriority = ServiceRegistry.mapCatalogName({\n id: currentHost.catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.NUMBER,\n });\n\n // Validate if the found host has a lower priority than the current\n // host.\n if (\n foundHostCatalogPriority < currentHostCatalogPriority ||\n foundHost.priority < currentHost.priority\n ) {\n filteredHosts.splice(filteredHosts.indexOf(foundHost, 1));\n filteredHosts.push(currentHost);\n }\n\n return filteredHosts;\n }, [])\n : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array for hosts with a specified\n * set of service names.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [service] - Services to filter.\n * @returns {Array<ServiceHost>} - The filtered host array.\n */\n filterService(service = []) {\n // Generate an array of services regardless of parameter type.\n const services = Array.isArray(service) ? service : [service];\n\n // Filter the host array against the provided services.\n return services.length > 0\n ? this.hosts.filter((host) => services.includes(host.service))\n : [...this.hosts];\n }\n\n /**\n * Filter the {@link ServiceRegistry#hosts} array for hosts with a specified\n * set of URLs.\n *\n * @private\n * @memberof ServiceRegistry\n * @param {Array<string> | string} [url] - URL to filter.\n * @returns {Array<ServiceHost>} - The filter host array.\n */\n filterUrl(url = []) {\n // Generate an array of URLs regardless of the parameter type.\n const urls = Array.isArray(url) ? url : [url];\n\n // Filter the host array against the provided URLs.\n return urls.length > 0 ? this.hosts.filter((host) => urls.includes(host.url)) : [...this.hosts];\n }\n\n /**\n * Get an array of {@link ServiceHost}s based on a provided\n * {@link HostFilter} from the {@link ServiceRegistry#hosts} array.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} [filter] - The inclusive filter for hosts to find.\n * @returns {Array<ServiceHost>} - The filtered hosts.\n */\n find({active, catalog, cluster, local, priority, service, url} = {}) {\n return this.hosts.filter(\n (host) =>\n this.filterActive(active).includes(host) &&\n this.filterCatalog(catalog).includes(host) &&\n this.filterCluster(cluster).includes(host) &&\n this.filterLocal(local).includes(host) &&\n this.filterPriority(priority).includes(host) &&\n this.filterService(service).includes(host) &&\n this.filterUrl(url).includes(host)\n );\n }\n\n /**\n * Load a formatted array of {@link ServiceHost} constructor parameter\n * transfer objects as instances of {@link ServiceHost} class objects to the\n * {@link ServiceRegistry#hosts} array.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {Array<ServiceHost.ConstructorPTO>} hosts\n * @returns {this}\n */\n load(hosts = []) {\n // Validate that the provided hosts are eligible to be loaded.\n const validHosts = hosts.filter(\n (host) =>\n !!ServiceRegistry.mapCatalogName({\n id: host.catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.STRING,\n })\n );\n\n // Load the eligible hosts.\n this.hosts.push(...validHosts.map((loadableHost) => new ServiceHost(loadableHost)));\n\n return this;\n }\n\n /**\n * Mark a collection of {@link ServiceHost} class objects from the\n * {@link ServiceRegistry#hosts} array as replaced based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter to mark replaced.\n * @returns {Array<ServiceHost>} - The {@link ServiceHost}s marked replaced.\n */\n replaced(filter) {\n // Collect a list of hosts to mark as replaced based on the provided filter.\n const replacing = this.find(filter);\n\n // Mark the hosts from the array as replaced.\n replacing.forEach((host) => {\n host.setStatus({replaced: true});\n });\n\n // Return the marked hosts.\n return replacing;\n }\n\n /**\n * Reset the failed status of a collection of {@link ServiceHost} class\n * objects from the {@link ServiceRegistry#hosts} array based on the provided\n * {@link HostFilter}.\n *\n * @public\n * @memberof ServiceRegistry\n * @param {HostFilter} filter - The inclusive filter of hosts to reset.\n * @returns {Array<ServiceHost>} - The {@link ServiceHost}s that reset.\n */\n reset(filter) {\n // Collect a list of hosts to mark as replaced based on the provided filter.\n const resetting = this.find(filter);\n\n // Mark the hosts from the array as replaced.\n resetting.forEach((host) => {\n host.setStatus({failed: false});\n });\n\n // Return the marked hosts.\n return resetting;\n }\n\n /**\n * Convert a {@link SERVICE_CATALOGS} identifier or value to its associated\n * idenfier or value.\n *\n * @public\n * @static\n * @memberof ServiceRegistry\n * @param {Object} pto - The parameter transfer object.\n * @property {string | number} pto.id - The identifier to convert in the enum.\n * @property {SERVICE_CATALOGS_ENUM_TYPES} pto.type - The desired output.\n * @returns {string|number} - The matching enum value or index.\n */\n static mapCatalogName({id, type}) {\n // Validate that the id is a number.\n if (typeof id === 'number') {\n // Validate that the desired type is a number.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.NUMBER) {\n return SERVICE_CATALOGS[id] !== undefined ? id : undefined;\n }\n\n // Validate that the desired type is a string.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.STRING) {\n return SERVICE_CATALOGS[id];\n }\n }\n\n // Validate that the id is a string.\n if (typeof id === 'string') {\n // Validate that the desired type is a string.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.STRING) {\n return SERVICE_CATALOGS.includes(id) ? id : undefined;\n }\n\n // Validate that the desired type is a number.\n if (type === SERVICE_CATALOGS_ENUM_TYPES.NUMBER) {\n return SERVICE_CATALOGS.includes(id) ? SERVICE_CATALOGS.indexOf(id) : undefined;\n }\n }\n\n return undefined;\n }\n\n /**\n * Generate a formatted array based on the object received from the **U2C**\n * service for usage in the {@link ServiceRegistry#load} method.\n *\n * @public\n * @static\n * @memberof ServiceRegistry\n * @param {MapRemoteCatalogPTO} pto - The parameter transfer object.\n * @throws - If the target catalog does not exist.\n * @returns {Array<ServiceHost#ServiceHostConstructorPTO>}\n */\n static mapRemoteCatalog({catalog, hostCatalog, serviceLinks}) {\n // Collect the service catalog name if needed.\n const catalogIndex = ServiceRegistry.mapCatalogName({\n id: catalog,\n type: SERVICE_CATALOGS_ENUM_TYPES.STRING,\n });\n\n // Validate that the target catalog exists.\n if (!SERVICE_CATALOGS.includes(catalogIndex)) {\n throw new Error(`service-catalogs: '${catalog}' is not a valid catalog`);\n }\n\n // Map the remote catalog to a mountable host array.\n return Object.keys(hostCatalog).reduce((output, key) => {\n output.push(\n ...hostCatalog[key].map((host) => ({\n catalog: catalogIndex,\n defaultUri: serviceLinks[host.id.split(':')[3]],\n hostGroup: key,\n id: host.id,\n priority: host.priority,\n uri: host.host,\n }))\n );\n\n return output;\n }, []);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;IACqBA,e;EACnB;AACF;AACA;AACA;AACA;AACA;AACA;EACE,2BAAc;IAAA;;IACZ;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,KAAKC,KAAL,GAAa,EAAb;EACD;EAED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,CAACe,EAJwB;YAKjClB,QAAQ,EAAEG,IAAI,CAACH,QALkB;YAMjC4D,GAAG,EAAEzD,IAAI,CAACA;UANuB,CAAX;QAAA,CAArB,CADC,EAAN;QAWA,OAAOqD,MAAP;MACD,CAbM,EAaJ,EAbI,CAAP;IAcD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceState","SERVICE_CATALOGS","forEach","catalog","generateCatalogState","collecting","ready"],"sources":["service-state.js"],"sourcesContent":["import {SERVICE_CATALOGS} from './constants';\n\n/**\n * The state of a specific catalog to be used by {@link ServiceState}.\n *\n * @typedef {Record<string, boolean>} CatalogState\n * @property {boolean} CatalogState.collecting - If the catalog is collecting.\n * @property {boolean} CatalogState.ready - If the catalog is ready.\n */\n\n/**\n * @class\n * @classdesc - Manages the state of the service catalogs for a webex instance.\n */\nexport default class ServiceState {\n /**\n * Generate a new {@link ServiceState}.\n *\n * @public\n * @constructor\n * @memberof ServiceState\n */\n constructor() {\n // Iterate over the possible catalog names and generate their states.\n SERVICE_CATALOGS.forEach(
|
|
1
|
+
{"version":3,"names":["ServiceState","SERVICE_CATALOGS","forEach","catalog","generateCatalogState","collecting","ready"],"sources":["service-state.js"],"sourcesContent":["import {SERVICE_CATALOGS} from './constants';\n\n/**\n * The state of a specific catalog to be used by {@link ServiceState}.\n *\n * @typedef {Record<string, boolean>} CatalogState\n * @property {boolean} CatalogState.collecting - If the catalog is collecting.\n * @property {boolean} CatalogState.ready - If the catalog is ready.\n */\n\n/**\n * @class\n * @classdesc - Manages the state of the service catalogs for a webex instance.\n */\nexport default class ServiceState {\n /**\n * Generate a new {@link ServiceState}.\n *\n * @public\n * @constructor\n * @memberof ServiceState\n */\n constructor() {\n // Iterate over the possible catalog names and generate their states.\n SERVICE_CATALOGS.forEach((catalog) => {\n this[catalog] = ServiceState.generateCatalogState();\n });\n }\n\n /**\n * Set a catalog to be collecting or not.\n *\n * @public\n * @memberof ServiceState\n * @param {string} catalog - Catalog to target.\n * @param {boolean} collecting - If the target is collecting or not.\n * @returns {undefined}\n */\n setCollecting(catalog, collecting) {\n // Validate that the catalog state exists.\n if (this[catalog]) {\n // Set the 'collecting' status of the catalog state.\n this[catalog].collecting = collecting;\n }\n }\n\n /**\n * Set a catalog to be ready or not.\n *\n * @public\n * @memberof ServiceState\n * @param {string} catalog - Catalog to target.\n * @param {boolean} ready - If the target is ready or not.\n * @returns {undefined}\n */\n setReady(catalog, ready) {\n // Validate that the catalog state exists.\n if (this[catalog]) {\n // Set the 'ready' status of the catalog state.\n this[catalog].ready = ready;\n }\n }\n\n /**\n * Generate a {@link CatalogState}.\n *\n * @public\n * @static\n * @memberof ServiceState\n * @returns {CatalogState} - The generated {@link CatalogState}.\n */\n static generateCatalogState() {\n return {\n collecting: false,\n ready: false,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;IACqBA,Y;EACnB;AACF;AACA;AACA;AACA;AACA;AACA;EACE,wBAAc;IAAA;;IAAA;;IACZ;IACAC,2BAAA,CAAiBC,OAAjB,CAAyB,UAACC,OAAD,EAAa;MACpC,KAAI,CAACA,OAAD,CAAJ,GAAgBH,YAAY,CAACI,oBAAb,EAAhB;IACD,CAFD;EAGD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;WACE,uBAAcD,OAAd,EAAuBE,UAAvB,EAAmC;MACjC;MACA,IAAI,KAAKF,OAAL,CAAJ,EAAmB;QACjB;QACA,KAAKA,OAAL,EAAcE,UAAd,GAA2BA,UAA3B;MACD;IACF;IAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;WACE,kBAASF,OAAT,EAAkBG,KAAlB,EAAyB;MACvB;MACA,IAAI,KAAKH,OAAL,CAAJ,EAAmB;QACjB;QACA,KAAKA,OAAL,EAAcG,KAAd,GAAsBA,KAAtB;MACD;IACF;IAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;;WACE,gCAA8B;MAC5B,OAAO;QACLD,UAAU,EAAE,KADP;QAELC,KAAK,EAAE;MAFF,CAAP;IAID"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceUrl","AmpState","extend","namespace","props","defaultUrl","undefined","hosts","name","_generateHostUrl","hostUri","url","Url","parse","host","port","format","_getHostUrls","map","priority","_getPriorityHostUrl","clusterId","length","filteredHosts","filter","id","homeCluster","aliveHosts","failed","reduce","previous","current","failHost","hostname","foundHost","find","hostObj","get","priorityHost"],"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, () =>
|
|
1
|
+
{"version":3,"names":["ServiceUrl","AmpState","extend","namespace","props","defaultUrl","undefined","hosts","name","_generateHostUrl","hostUri","url","Url","parse","host","port","format","_getHostUrls","map","priority","_getPriorityHostUrl","clusterId","length","filteredHosts","filter","id","homeCluster","aliveHosts","failed","reduce","previous","current","failHost","hostname","foundHost","find","hostObj","get","priorityHost"],"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;;AAEA;;AAEA;;AACA;AACA;AACA;AACA,IAAMA,UAAU,GAAGC,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;AACA;AACA;EACE+B,GAzGiC,eAyG7BC,YAzG6B,EAyGfjB,SAzGe,EAyGJ;IAC3B,IAAI,CAACiB,YAAL,EAAmB;MACjB,OAAO,KAAKjC,UAAZ;IACD;;IAED,OAAO,KAAKe,mBAAL,CAAyBC,SAAzB,CAAP;EACD;AA/GgC,CAAhB,CAAnB;AAiHA;;;eAEerB,U"}
|
|
@@ -189,10 +189,10 @@ var Services = _webexPlugin.default.extend({
|
|
|
189
189
|
},
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
* saves all the services from the pre and post catalog service
|
|
193
|
+
* @param {Object} serviceUrls
|
|
194
|
+
* @returns {void}
|
|
195
|
+
*/
|
|
196
196
|
_updateServiceUrls: function _updateServiceUrls(serviceUrls) {
|
|
197
197
|
this._serviceUrls = _objectSpread(_objectSpread({}, this._serviceUrls), serviceUrls);
|
|
198
198
|
},
|
|
@@ -221,7 +221,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
221
221
|
|
|
222
222
|
var catalog = this._getCatalog();
|
|
223
223
|
|
|
224
|
-
var formattedQuery
|
|
224
|
+
var formattedQuery;
|
|
225
|
+
var serviceGroup; // map catalog name to service group name.
|
|
225
226
|
|
|
226
227
|
switch (from) {
|
|
227
228
|
case 'limited':
|
|
@@ -499,7 +500,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
499
500
|
activationOptions = _ref5.activationOptions,
|
|
500
501
|
preloginUserId = _ref5.preloginUserId;
|
|
501
502
|
this.logger.info('services: sending user activation request');
|
|
502
|
-
var countryCode
|
|
503
|
+
var countryCode;
|
|
504
|
+
var timezone; // try to fetch client region info first
|
|
503
505
|
|
|
504
506
|
return this.fetchClientRegionInfo().then(function (clientRegionInfo) {
|
|
505
507
|
if (clientRegionInfo) {
|
|
@@ -1084,7 +1086,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1084
1086
|
}
|
|
1085
1087
|
});
|
|
1086
1088
|
},
|
|
1087
|
-
version: "3.0.0-beta.
|
|
1089
|
+
version: "3.0.0-beta.15"
|
|
1088
1090
|
});
|
|
1089
1091
|
/* eslint-enable no-underscore-dangle */
|
|
1090
1092
|
|