@rebuy/rebuy 1.3.12 → 1.5.0

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/api.js CHANGED
@@ -3,15 +3,27 @@ import { serialize } from './utilities.js';
3
3
  const config = {
4
4
  key: null,
5
5
  domain: 'https://rebuyengine.com',
6
+ /**
7
+ * @deprecated
8
+ */
6
9
  cdnDomain: 'https://cdn.rebuyengine.com',
7
10
  eventDomain: 'https://rebuyengine.com',
11
+ geoDomain: 'https://geo.rebuyengine.com',
12
+ shieldDomain: 'https://cached.rebuyengine.com',
13
+ staticDomain: 'https://cdn.rebuyengine.com',
8
14
  shop: null,
9
15
  };
10
16
 
11
17
  const staging = {
12
18
  domain: 'https://enigneyuber.com',
19
+ /**
20
+ * @deprecated
21
+ */
13
22
  cdnDomain: 'https://cdn.enigneyuber.com',
14
23
  eventDomain: 'https://enigneyuber.com',
24
+ geoDomain: 'https://geo.enigneyuber.com',
25
+ shieldDomain: 'https://cached.enigneyuber.com',
26
+ staticDomain: 'https://cdn.enigneyuber.com',
15
27
  };
16
28
 
17
29
  const stagingDomains = [
@@ -91,6 +103,21 @@ export class Api {
91
103
  return await makeCall(method, path, data, config.eventDomain, options);
92
104
  }
93
105
 
106
+ async callShield(method, path, data, options = {}) {
107
+ return await makeCall(method, path, data, config.shieldDomain, options);
108
+ }
109
+
110
+ async callStatic(method, path, data, options = {}) {
111
+ return await makeCall(method, path, data, config.staticDomain, options);
112
+ }
113
+
114
+ async callGeo(method, path, data, options = {}) {
115
+ return await makeCall(method, path, data, config.geoDomain, options);
116
+ }
117
+
118
+ /**
119
+ * @deprecated
120
+ */
94
121
  async callCdn(method, path, data, options = {}) {
95
122
  return await makeCall(method, path, data, config.cdnDomain, options);
96
123
  }
package/client.js CHANGED
@@ -1,6 +1,6 @@
1
- import { convertProductToStorefrontFormat } from './utilities.js';
2
- import Identity from './identity.js';
3
1
  import Api from './api.js';
2
+ import Identity from './identity.js';
3
+ import { convertProductToStorefrontFormat } from './utilities.js';
4
4
 
5
5
  const config = {
6
6
  key: null,
@@ -19,6 +19,17 @@ const trackEvent = async (eventData) => {
19
19
  return await config.api.callEvent('POST', '/api/v1/analytics/event', eventData);
20
20
  };
21
21
 
22
+ const makeShieldCall = async (endpoint, params, format, options = {}) => {
23
+ return await makeCall(endpoint, params, format, { ...options, shield: true });
24
+ };
25
+
26
+ const makeStaticCall = async (endpoint, params, format, options = {}) => {
27
+ return await makeCall(endpoint, params, format, { ...options, static: true });
28
+ };
29
+
30
+ /**
31
+ * @deprecated
32
+ */
22
33
  const makeCDNCall = async (endpoint, params, format, options = {}) => {
23
34
  return await makeCall(endpoint, params, format, { ...options, cdn: true });
24
35
  };
@@ -47,8 +58,8 @@ const makeCall = async (endpoint, params, format, options = {}) => {
47
58
  query.uuid = config.identity.visitorId();
48
59
  }
49
60
 
50
- // Origin or CDN?
51
- const source = options.cdn ? 'callCdn' : 'callApi';
61
+ // Origin or dedicated edge?
62
+ const source = options.cdn ? 'callCdn' : options.shield ? 'callShield' : options.static ? 'callStatic' : 'callApi';
52
63
  const response = await config.api[source]('GET', endpoint, query, options);
53
64
 
54
65
  if (response.data && format == 'storefront') {
@@ -94,10 +105,21 @@ export class RebuyClient {
94
105
  return await makeCall(endpoint, params, null, options);
95
106
  }
96
107
 
108
+ /**
109
+ * @deprecated
110
+ */
97
111
  async getDataFromCDN(endpoint, params, options = {}) {
98
112
  return await makeCDNCall(endpoint, params, null, options);
99
113
  }
100
114
 
115
+ async getShieldedAsset(endpoint, params, options = {}) {
116
+ return await makeShieldCall(endpoint, params, null, options);
117
+ }
118
+
119
+ async getStaticAsset(endpoint, params, options = {}) {
120
+ return await makeStaticCall(endpoint, params, null, options);
121
+ }
122
+
101
123
  async getStorefrontData(endpoint, params, options = {}) {
102
124
  return await makeCall(endpoint, params, 'storefront', options);
103
125
  }
package/geolocation.js CHANGED
@@ -1,5 +1,5 @@
1
- import Cookie from './cookie.js';
2
1
  import Api from './api.js';
2
+ import Cookie from './cookie.js';
3
3
 
4
4
  const config = {
5
5
  key: null,
@@ -12,7 +12,7 @@ const config = {
12
12
 
13
13
  const getGeolocation = async () => {
14
14
  const api = new Api(config.key);
15
- const response = await api.callApi('GET', '/api/v1/customers/geolocation');
15
+ const response = await api.callGeo('GET', '/');
16
16
 
17
17
  if (response.data) {
18
18
  // Update config with geolocation
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebuy/rebuy",
3
3
  "description": "This is the default library for Rebuy",
4
- "version": "1.3.12",
4
+ "version": "1.5.0",
5
5
  "license": "MIT",
6
6
  "author": "Rebuy, Inc.",
7
7
  "type": "module",