genesys-spark 4.0.0-beta.56 → 4.0.0-beta.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,22 +1,15 @@
1
1
  // Default domain to load assets from
2
2
  var DEFAULT_DOMAIN = 'mypurecloud.com';
3
- // List of Genesys UI domains
4
- var DOMAIN_LIST = [
5
- 'apne2.pure.cloud',
6
- 'aps1.pure.cloud',
7
- 'cac1.pure.cloud',
8
- 'euw2.pure.cloud',
3
+ // List of Genesys UI domains that do not follow the ${region}.pure.cloud format
4
+ var NON_STANDARD_DOMAINS = [
9
5
  'inindca.com',
10
6
  'inintca.com',
11
7
  'mypurecloud.com.au',
12
8
  'mypurecloud.com',
13
9
  'mypurecloud.de',
14
10
  'mypurecloud.ie',
15
- 'mypurecloud.jp',
16
- 'sae1.pure.cloud',
17
- 'use2.maximus-pure.cloud',
18
- // 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP and should fallback to the default domain
19
- 'usw2.pure.cloud'
11
+ 'mypurecloud.jp'
12
+ // 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP. It should fall back to the default domain.
20
13
  ];
21
14
  /**
22
15
  * Returns the origin that web component assets should be loaded from.
@@ -31,7 +24,14 @@ function getFontOrigin() {
31
24
  }
32
25
  function getRegionDomain() {
33
26
  var pageHost = window.location.hostname;
34
- return DOMAIN_LIST.find(function (regionDomain) { return pageHost.endsWith(regionDomain); });
27
+ // We can automatically handle the standard domain format: ${region}.pure.cloud
28
+ if (pageHost.endsWith('.pure.cloud')) {
29
+ return pageHost.split('.').slice(-3).join('.');
30
+ }
31
+ // For older domains, we have to do a lookup
32
+ return NON_STANDARD_DOMAINS.find(function (regionDomain) {
33
+ return pageHost.endsWith(regionDomain);
34
+ });
35
35
  }
36
36
 
37
37
  /******************************************************************************
@@ -152,7 +152,7 @@ function checkAndLoadFonts(fonts) {
152
152
  })).then(function () { }); // flatten the promise array
153
153
  }
154
154
 
155
- var ASSET_PREFIX = '/spark-components/build-assets/4.0.0-beta.56-88/genesys-webcomponents/';
155
+ var ASSET_PREFIX = '/spark-components/build-assets/4.0.0-beta.58-90/genesys-webcomponents/';
156
156
  var SCRIPT_PATH = 'genesys-webcomponents.esm.js';
157
157
  var STYLE_PATH = 'genesys-webcomponents.css';
158
158
  var assetsOrigin = getAssetsOrigin();
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genesys-spark",
3
- "version": "4.0.0-beta.56",
3
+ "version": "4.0.0-beta.58",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
package/src/hosts.ts CHANGED
@@ -7,23 +7,16 @@ declare global {
7
7
  // Default domain to load assets from
8
8
  const DEFAULT_DOMAIN = 'mypurecloud.com';
9
9
 
10
- // List of Genesys UI domains
11
- const DOMAIN_LIST = [
12
- 'apne2.pure.cloud',
13
- 'aps1.pure.cloud',
14
- 'cac1.pure.cloud',
15
- 'euw2.pure.cloud',
10
+ // List of Genesys UI domains that do not follow the ${region}.pure.cloud format
11
+ const NON_STANDARD_DOMAINS = [
16
12
  'inindca.com',
17
13
  'inintca.com',
18
14
  'mypurecloud.com.au',
19
15
  'mypurecloud.com',
20
16
  'mypurecloud.de',
21
17
  'mypurecloud.ie',
22
- 'mypurecloud.jp',
23
- 'sae1.pure.cloud',
24
- 'use2.maximus-pure.cloud',
25
- // 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP and should fallback to the default domain
26
- 'usw2.pure.cloud'
18
+ 'mypurecloud.jp'
19
+ // 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP. It should fall back to the default domain.
27
20
  ];
28
21
 
29
22
  /**
@@ -51,5 +44,14 @@ export function getFontOrigin(): string {
51
44
 
52
45
  function getRegionDomain() {
53
46
  const pageHost = window.location.hostname;
54
- return DOMAIN_LIST.find(regionDomain => pageHost.endsWith(regionDomain));
47
+
48
+ // We can automatically handle the standard domain format: ${region}.pure.cloud
49
+ if (pageHost.endsWith('.pure.cloud')) {
50
+ return pageHost.split('.').slice(-3).join('.');
51
+ }
52
+
53
+ // For older domains, we have to do a lookup
54
+ return NON_STANDARD_DOMAINS.find(regionDomain =>
55
+ pageHost.endsWith(regionDomain)
56
+ );
55
57
  }
@@ -0,0 +1,69 @@
1
+ import { getAssetsOrigin, getFontOrigin } from '../src/hosts';
2
+
3
+ const NON_STANDARD_DOMAINS = [
4
+ 'inindca.com',
5
+ 'inintca.com',
6
+ 'mypurecloud.com.au',
7
+ 'mypurecloud.com',
8
+ 'mypurecloud.de',
9
+ 'mypurecloud.ie',
10
+ 'mypurecloud.jp'
11
+ ];
12
+
13
+ describe('The hosts module', () => {
14
+ beforeEach(() => {
15
+ window.IS_DEV_MODE = false;
16
+ });
17
+
18
+ describe('when determining asset domains', () => {
19
+ it('Will return the correct domain for pages in a `pure.cloud` region', () => {
20
+ setLocation('https://uis.region.pure.cloud/page');
21
+ expect(getAssetsOrigin()).toBe('https://app.region.pure.cloud');
22
+ });
23
+
24
+ it('Will return a default domain for non-genesys hosted pages', () => {
25
+ setLocation('https://www.example.com/page');
26
+ expect(getAssetsOrigin()).toBe('https://app.mypurecloud.com');
27
+ });
28
+
29
+ NON_STANDARD_DOMAINS.forEach(domain => {
30
+ const withSubDomain = `https://dummySubdomain.${domain}/page`;
31
+ it(`Will recognize ${withSubDomain} as a Genesys domain`, () => {
32
+ setLocation(withSubDomain);
33
+ expect(getAssetsOrigin()).toBe(`https://app.${domain}`);
34
+ });
35
+ });
36
+ });
37
+
38
+ describe('when determining font domains', () => {
39
+ it('Will return the correct domain for pages in a `pure.cloud` region', () => {
40
+ setLocation('https://uis.region.pure.cloud/page');
41
+ expect(getFontOrigin()).toBe('https://app.region.pure.cloud');
42
+ });
43
+
44
+ it('Will return a default domain for non-genesys hosted pages', () => {
45
+ setLocation('https://www.example.com/page');
46
+ expect(getFontOrigin()).toBe('https://app.mypurecloud.com');
47
+ });
48
+
49
+ NON_STANDARD_DOMAINS.forEach(domain => {
50
+ const withSubDomain = `https://dummySubdomain.${domain}/page`;
51
+ it(`Will recognize ${withSubDomain} as a Genesys domain`, () => {
52
+ setLocation(withSubDomain);
53
+ expect(getFontOrigin()).toBe(`https://app.${domain}`);
54
+ });
55
+ });
56
+ });
57
+ });
58
+
59
+ /**
60
+ * This is an absolutely disgusting abdication of the type system, but it's a
61
+ * damn sight simpler than most ways to get dynamic per-test location updates.
62
+ * See: https://github.com/jestjs/jest/issues/5124
63
+ */
64
+ function setLocation(location: string) {
65
+ //@ts-ignore
66
+ delete window.location;
67
+ //@ts-ignore
68
+ window.location = new URL(location);
69
+ }