@rebuy/rebuy 1.3.12 → 1.4.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 +21 -0
- package/client.js +26 -4
- package/package.json +1 -1
package/api.js
CHANGED
|
@@ -3,15 +3,25 @@ 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
|
+
shieldDomain: 'https://cached.rebuyengine.com',
|
|
12
|
+
staticDomain: 'https://cdn.rebuyengine.com',
|
|
8
13
|
shop: null,
|
|
9
14
|
};
|
|
10
15
|
|
|
11
16
|
const staging = {
|
|
12
17
|
domain: 'https://enigneyuber.com',
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated
|
|
20
|
+
*/
|
|
13
21
|
cdnDomain: 'https://cdn.enigneyuber.com',
|
|
14
22
|
eventDomain: 'https://enigneyuber.com',
|
|
23
|
+
shieldDomain: 'https://cached.enigneyuber.com',
|
|
24
|
+
staticDomain: 'https://cdn.enigneyuber.com',
|
|
15
25
|
};
|
|
16
26
|
|
|
17
27
|
const stagingDomains = [
|
|
@@ -91,6 +101,17 @@ export class Api {
|
|
|
91
101
|
return await makeCall(method, path, data, config.eventDomain, options);
|
|
92
102
|
}
|
|
93
103
|
|
|
104
|
+
async callShield(method, path, data, options = {}) {
|
|
105
|
+
return await makeCall(method, path, data, config.shieldDomain, options);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async callStatic(method, path, data, options = {}) {
|
|
109
|
+
return await makeCall(method, path, data, config.staticDomain, options);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated
|
|
114
|
+
*/
|
|
94
115
|
async callCdn(method, path, data, options = {}) {
|
|
95
116
|
return await makeCall(method, path, data, config.cdnDomain, options);
|
|
96
117
|
}
|
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
|
|
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
|
}
|