@rebuy/rebuy 1.0.2 → 1.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ 0000000000000000000000000000000000000000 28657bddf50c93f95e089397c1b7e8b745ec9ec3 Mike Reid <mike.reid@rebuyengine.com> 1658872537 -0600 branch: Created from HEAD
2
+ 28657bddf50c93f95e089397c1b7e8b745ec9ec3 d1073d6c613eeb3e53fa6de416fa507979a5b905 Mike Reid <mike.reid@rebuyengine.com> 1658872546 -0600 commit: New: Add additional named exports
@@ -0,0 +1 @@
1
+ d1073d6c613eeb3e53fa6de416fa507979a5b905
package/README.md CHANGED
@@ -1 +1,3 @@
1
1
  # Rebuy
2
+
3
+ Rebuy base package containing reusable API client, functions, and other common utilities. Initially developed for [@rebuy/rebuy-hydrogen](https://www.npmjs.com/package/@rebuy/rebuy-hydrogen).
package/api.js CHANGED
@@ -36,7 +36,7 @@ const makeCall = async (method, path, data, origin) => {
36
36
  return await request.json();
37
37
  };
38
38
 
39
- export default class Api {
39
+ export class Api {
40
40
  constructor(options) {
41
41
  if (typeof options == 'string') {
42
42
  config.key = options;
@@ -57,3 +57,5 @@ export default class Api {
57
57
  return await makeCall(method, path, data, config.domain);
58
58
  }
59
59
  }
60
+
61
+ export default { Api };
package/client.js CHANGED
@@ -11,7 +11,7 @@ const config = {
11
11
  };
12
12
 
13
13
  const trackEvent = async (eventData) => {
14
- if (config.identity.visitorId()) {
14
+ if (config.identity && config.identity.visitorId()) {
15
15
  eventData.uuid = config.identity.visitorId();
16
16
  }
17
17
 
@@ -33,7 +33,7 @@ const makeCall = async (endpoint, params, format) => {
33
33
  Object.assign(query, params);
34
34
  }
35
35
 
36
- if (config.identity.visitorId()) {
36
+ if (config.identity && config.identity.visitorId()) {
37
37
  query.uuid = config.identity.visitorId();
38
38
  }
39
39
 
@@ -48,7 +48,7 @@ const makeCall = async (endpoint, params, format) => {
48
48
  return response;
49
49
  };
50
50
 
51
- export default class RebuyClient {
51
+ export class RebuyClient {
52
52
  constructor(key, defaultParameters) {
53
53
  if (typeof key == 'string') {
54
54
  config.key = key;
@@ -102,3 +102,5 @@ export default class RebuyClient {
102
102
  return null;
103
103
  }
104
104
  }
105
+
106
+ export default { RebuyClient };
package/geolocation.js CHANGED
@@ -33,8 +33,12 @@ const getGeolocation = async () => {
33
33
  return config.geolocation;
34
34
  };
35
35
 
36
- export default class Geolocation {
36
+ export class Geolocation {
37
37
  constructor(key) {
38
+ if (typeof document == 'undefined') {
39
+ return;
40
+ }
41
+
38
42
  if (typeof key == 'string') {
39
43
  config.key = key;
40
44
  }
@@ -55,3 +59,5 @@ export default class Geolocation {
55
59
  return config.geolocation;
56
60
  }
57
61
  }
62
+
63
+ export default { Geolocation };
package/identity.js CHANGED
@@ -13,8 +13,12 @@ const config = {
13
13
  session: null,
14
14
  };
15
15
 
16
- export default class Identity {
16
+ export class Identity {
17
17
  constructor(key) {
18
+ if (typeof document == 'undefined') {
19
+ return;
20
+ }
21
+
18
22
  if (typeof key == 'string') {
19
23
  config.key = key;
20
24
  }
@@ -64,3 +68,5 @@ export default class Identity {
64
68
  return await config.geolocation.geolocation();
65
69
  }
66
70
  }
71
+
72
+ export default { Identity };
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from './api';
2
+ export * from './client';
3
+ export * from './cookie';
4
+ export * from './geolocation';
5
+ export * from './identity';
6
+ export * from './session';
7
+ export * from './utilities';
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.0.2",
4
+ "version": "1.1.0-rc.2",
5
5
  "license": "MIT",
6
6
  "author": "Rebuy, Inc.",
7
7
  "type": "module",
package/session.js CHANGED
@@ -10,8 +10,12 @@ const config = {
10
10
  },
11
11
  };
12
12
 
13
- export default class Session {
13
+ export class Session {
14
14
  constructor() {
15
+ if (typeof document == 'undefined') {
16
+ return;
17
+ }
18
+
15
19
  config.now = new Date().getTime();
16
20
  config.sessionId = Cookie.get(config.sessionIdCookie);
17
21
 
@@ -44,3 +48,5 @@ export default class Session {
44
48
  return parseInt((config.now - this.sessionStart()) / 1000 / 60);
45
49
  }
46
50
  }
51
+
52
+ export default { Session };