rerobe-js-orm 2.7.16 → 2.7.19
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/lib/factories/User/UserFromAuthTemplateMethod.js +2 -2
- package/lib/factories/User/UserFromFormState.js +3 -1
- package/lib/helpers/AnalyticsHelpers.js +4 -1
- package/lib/models/User.d.ts +2 -0
- package/lib/models/User.js +26 -2
- package/lib/types/rerobe-user-types.d.ts +9 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ const UserFactory_1 = require("./UserFactory");
|
|
|
4
4
|
const User_1 = require("../../models/User");
|
|
5
5
|
class UserFromAuthTemplateMethod extends UserFactory_1.default {
|
|
6
6
|
createUser(props) {
|
|
7
|
-
const { authUserProfile, prevUserProfile, shoppingBag, savedItems, devicePlatform, shoppingSessionId } = props;
|
|
7
|
+
const { authUserProfile, prevUserProfile, shoppingBag, savedItems, devicePlatform, shoppingSessionId = '', registrationSource = '', } = props;
|
|
8
8
|
let prevShoppingBag = [];
|
|
9
9
|
let prevSavedItems = [];
|
|
10
10
|
if (prevUserProfile) {
|
|
@@ -18,7 +18,7 @@ class UserFromAuthTemplateMethod extends UserFactory_1.default {
|
|
|
18
18
|
[, gid] = this.shopifyHelpers.getDecodedShopifyId(authUserProfile.id).split('Customer/');
|
|
19
19
|
}
|
|
20
20
|
const newUserProfile = Object.assign(Object.assign({}, (prevUserProfile ? prevUserProfile : {})), { uid: authUserProfile.id, gid, displayName: authUserProfile.displayName, firstName: authUserProfile.firstName, lastName: authUserProfile.lastName, email: authUserProfile.email, phone: authUserProfile.phone, addresses: authUserProfile.addresses, referralCode: authUserProfile.id.slice(-7).toLowerCase(), shoppingBag: this.utilities.uniqArray([...prevShoppingBag, ...shoppingBag]), savedItems: this.utilities.uniqArray([...prevSavedItems, ...savedItems]), orders: authUserProfile.orders, devicePlatform,
|
|
21
|
-
shoppingSessionId, lastLogin: new Date().toISOString() });
|
|
21
|
+
shoppingSessionId, lastLogin: new Date().toISOString(), registrationSource });
|
|
22
22
|
return new User_1.default(Object.assign({}, newUserProfile));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -4,7 +4,7 @@ const UserFactory_1 = require("./UserFactory");
|
|
|
4
4
|
const User_1 = require("../../models/User");
|
|
5
5
|
class UserFromFormState extends UserFactory_1.default {
|
|
6
6
|
createUser(props) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
8
8
|
const userAttributes = {
|
|
9
9
|
documentId: ((_a = props.props) === null || _a === void 0 ? void 0 : _a.documentId) || '',
|
|
10
10
|
uid: ((_b = props.props) === null || _b === void 0 ? void 0 : _b.uid) || '',
|
|
@@ -72,6 +72,8 @@ class UserFromFormState extends UserFactory_1.default {
|
|
|
72
72
|
itemRejectionPct: ((_3 = props.props) === null || _3 === void 0 ? void 0 : _3.itemRejectionPct) || 0,
|
|
73
73
|
itemSoldPct: ((_4 = props.props) === null || _4 === void 0 ? void 0 : _4.itemSoldPct) || 0,
|
|
74
74
|
lastOrderDate: ((_5 = props.props) === null || _5 === void 0 ? void 0 : _5.lastOrderDate) || '',
|
|
75
|
+
lastUploadDate: ((_6 = props.props) === null || _6 === void 0 ? void 0 : _6.lastUploadDate) || '',
|
|
76
|
+
registrationSource: ((_7 = props.props) === null || _7 === void 0 ? void 0 : _7.registrationSource) || '',
|
|
75
77
|
};
|
|
76
78
|
return new User_1.default(Object.assign({}, userAttributes));
|
|
77
79
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
class AnalyticsHelpers {
|
|
4
4
|
// Trait object for analytics.identify (https://segment.com/docs/connections/spec/identify/)
|
|
5
5
|
static createIdentifyPayloadForSegment(userProps) {
|
|
6
|
-
const { firstName, lastName, email, phone, documentId, createdAt, updatedAt, addresses, title, isSeller, ordersCount, amountSpent, itemsUploadedCount, lastOrderDate, inventoryValue, inventoryCount, itemsSoldCount, itemsSoldValue, itemRejectionPct, itemSoldPct, } = userProps;
|
|
6
|
+
const { firstName, lastName, email, phone, documentId, createdAt, updatedAt, addresses, title, isSeller, ordersCount = 0, amountSpent = 0, itemsUploadedCount = 0, lastOrderDate, inventoryValue = 0, inventoryCount = 0, itemsSoldCount = 0, itemsSoldValue = 0, itemRejectionPct, itemSoldPct, lastUploadDate, availableCredit, registrationSource = '', } = userProps;
|
|
7
7
|
// Step 1. Get all reserved traits (https://segment.com/docs/connections/spec/identify/#traits)
|
|
8
8
|
const reservedTraitsObj = {
|
|
9
9
|
firstName,
|
|
@@ -29,6 +29,9 @@ class AnalyticsHelpers {
|
|
|
29
29
|
itemRejectionPct,
|
|
30
30
|
itemSoldPct,
|
|
31
31
|
lastOrderDate,
|
|
32
|
+
lastUploadDate,
|
|
33
|
+
availableCredit,
|
|
34
|
+
registrationSource,
|
|
32
35
|
};
|
|
33
36
|
return {
|
|
34
37
|
userId: documentId || '',
|
package/lib/models/User.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export default class User extends Base {
|
|
|
44
44
|
itemRejectionPct: number;
|
|
45
45
|
itemSoldPct: number;
|
|
46
46
|
lastOrderDate: string;
|
|
47
|
+
lastUploadDate: string;
|
|
48
|
+
registrationSource: string;
|
|
47
49
|
constructor(props?: any);
|
|
48
50
|
toObj(): UserAttributes;
|
|
49
51
|
toCustomerUpdateInputObjForShopify(): any;
|
package/lib/models/User.js
CHANGED
|
@@ -64,6 +64,8 @@ class User extends Base_1.default {
|
|
|
64
64
|
this.itemRejectionPct = (props === null || props === void 0 ? void 0 : props.itemRejectionPct) || 0;
|
|
65
65
|
this.itemSoldPct = (props === null || props === void 0 ? void 0 : props.itemSoldPct) || 0;
|
|
66
66
|
this.lastOrderDate = (props === null || props === void 0 ? void 0 : props.lastOrderDate) || '';
|
|
67
|
+
this.lastUploadDate = (props === null || props === void 0 ? void 0 : props.lastUploadDate) || '';
|
|
68
|
+
this.registrationSource = (props === null || props === void 0 ? void 0 : props.registrationSource) || '';
|
|
67
69
|
}
|
|
68
70
|
toObj() {
|
|
69
71
|
return {
|
|
@@ -108,6 +110,8 @@ class User extends Base_1.default {
|
|
|
108
110
|
itemRejectionPct: this.itemRejectionPct,
|
|
109
111
|
itemSoldPct: this.itemSoldPct,
|
|
110
112
|
lastOrderDate: this.lastOrderDate,
|
|
113
|
+
lastUploadDate: this.lastUploadDate,
|
|
114
|
+
registrationSource: this.registrationSource,
|
|
111
115
|
};
|
|
112
116
|
}
|
|
113
117
|
toCustomerUpdateInputObjForShopify() {
|
|
@@ -185,6 +189,8 @@ class User extends Base_1.default {
|
|
|
185
189
|
itemRejectionPct: this.itemRejectionPct,
|
|
186
190
|
itemSoldPct: this.itemSoldPct,
|
|
187
191
|
lastOrderDate: this.lastOrderDate,
|
|
192
|
+
lastUploadDate: this.lastUploadDate,
|
|
193
|
+
registrationSource: this.registrationSource,
|
|
188
194
|
};
|
|
189
195
|
return customerInput;
|
|
190
196
|
}
|
|
@@ -289,7 +295,22 @@ class User extends Base_1.default {
|
|
|
289
295
|
},
|
|
290
296
|
{
|
|
291
297
|
facet: true,
|
|
292
|
-
name: '
|
|
298
|
+
name: 'lastOrderTimestamp',
|
|
299
|
+
type: 'int64',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
facet: true,
|
|
303
|
+
name: 'lastUploadTimestamp',
|
|
304
|
+
type: 'int64',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
facet: true,
|
|
308
|
+
name: 'availableCredit',
|
|
309
|
+
type: 'float',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
facet: true,
|
|
313
|
+
name: 'registrationSource',
|
|
293
314
|
type: 'string',
|
|
294
315
|
},
|
|
295
316
|
],
|
|
@@ -317,7 +338,10 @@ class User extends Base_1.default {
|
|
|
317
338
|
itemsSoldValue: this.utilities.sanitizeNumber(this.itemsSoldValue),
|
|
318
339
|
itemRejectionPct: this.utilities.sanitizeNumber(this.itemRejectionPct),
|
|
319
340
|
itemSoldPct: this.utilities.sanitizeNumber(this.itemSoldPct),
|
|
320
|
-
|
|
341
|
+
lastOrderTimestamp: this.utilities.sanitizeMillisTimeStamp(new Date(this.lastOrderDate).getTime()),
|
|
342
|
+
lastUploadTimestamp: this.utilities.sanitizeMillisTimeStamp(new Date(this.lastUploadDate).getTime()),
|
|
343
|
+
availableCredit: this.utilities.sanitizeNumber(this.availableCredit),
|
|
344
|
+
registrationSource: this.utilities.sanitizeString(this.registrationSource),
|
|
321
345
|
};
|
|
322
346
|
return stagedObj;
|
|
323
347
|
}
|
|
@@ -40,6 +40,8 @@ interface UserAttributes extends ReRobeDocument {
|
|
|
40
40
|
itemRejectionPct?: number;
|
|
41
41
|
itemSoldPct?: number;
|
|
42
42
|
lastOrderDate?: string;
|
|
43
|
+
lastUploadDate?: string;
|
|
44
|
+
registrationSource?: string;
|
|
43
45
|
}
|
|
44
46
|
declare type RibbnCustomerObj = {
|
|
45
47
|
uid?: string;
|
|
@@ -74,6 +76,8 @@ declare type RibbnCustomerObj = {
|
|
|
74
76
|
itemRejectionPct?: number;
|
|
75
77
|
itemSoldPct?: number;
|
|
76
78
|
lastOrderDate?: string;
|
|
79
|
+
lastUploadDate?: string;
|
|
80
|
+
registrationSource?: string;
|
|
77
81
|
};
|
|
78
82
|
declare type UserObjForAuthTemplateMethod = {
|
|
79
83
|
authUserProfile: UserFromShopifyGraphQLResp;
|
|
@@ -82,6 +86,7 @@ declare type UserObjForAuthTemplateMethod = {
|
|
|
82
86
|
savedItems: string[];
|
|
83
87
|
devicePlatform: string;
|
|
84
88
|
shoppingSessionId: string;
|
|
89
|
+
registrationSource?: string;
|
|
85
90
|
};
|
|
86
91
|
declare type UserFromShopifyRESTResp = {
|
|
87
92
|
[key: string]: any;
|
|
@@ -165,5 +170,8 @@ declare type TypesenseUserObj = {
|
|
|
165
170
|
itemsSoldValue: number;
|
|
166
171
|
itemRejectionPct: number;
|
|
167
172
|
itemSoldPct: number;
|
|
168
|
-
|
|
173
|
+
lastOrderTimestamp: number;
|
|
174
|
+
lastUploadTimestamp: number;
|
|
175
|
+
availableCredit: number;
|
|
176
|
+
registrationSource: string;
|
|
169
177
|
};
|