rerobe-js-orm 2.6.97 → 2.7.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/lib/factories/User/UserFromFormState.js +3 -1
- package/lib/models/ChatRoom.js +1 -1
- package/lib/models/Order.js +11 -3
- package/lib/models/User.d.ts +12 -0
- package/lib/models/User.js +91 -0
- package/lib/types/rerobe-order-types.d.ts +1 -0
- package/lib/types/rerobe-user-types.d.ts +16 -0
- 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 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;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
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) || '',
|
|
@@ -62,6 +62,8 @@ class UserFromFormState extends UserFactory_1.default {
|
|
|
62
62
|
ordersCount: ((_t = props.props) === null || _t === void 0 ? void 0 : _t.ordersCount) || 0,
|
|
63
63
|
amountSpent: ((_u = props.props) === null || _u === void 0 ? void 0 : _u.amountSpent) || 0,
|
|
64
64
|
emailVerified: ((_v = props.props) === null || _v === void 0 ? void 0 : _v.emailVerified) || false,
|
|
65
|
+
createdAtTimestamp: ((_w = props.props) === null || _w === void 0 ? void 0 : _w.createdAtTimestamp) || 0,
|
|
66
|
+
updatedAtTimestamp: ((_x = props.props) === null || _x === void 0 ? void 0 : _x.updatedAtTimestamp) || 0,
|
|
65
67
|
};
|
|
66
68
|
return new User_1.default(Object.assign({}, userAttributes));
|
|
67
69
|
}
|
package/lib/models/ChatRoom.js
CHANGED
package/lib/models/Order.js
CHANGED
|
@@ -280,6 +280,11 @@ class Order extends Base_1.default {
|
|
|
280
280
|
name: 'productIds',
|
|
281
281
|
type: 'string[]',
|
|
282
282
|
},
|
|
283
|
+
{
|
|
284
|
+
facet: true,
|
|
285
|
+
name: 'tags',
|
|
286
|
+
type: 'string[]',
|
|
287
|
+
},
|
|
283
288
|
{
|
|
284
289
|
facet: true,
|
|
285
290
|
name: 'productTitles',
|
|
@@ -296,11 +301,13 @@ class Order extends Base_1.default {
|
|
|
296
301
|
type: 'string',
|
|
297
302
|
},
|
|
298
303
|
],
|
|
299
|
-
name: '
|
|
304
|
+
name: 'dev_orders_20220809',
|
|
300
305
|
};
|
|
301
306
|
}
|
|
302
307
|
toObjForTypesense() {
|
|
303
|
-
|
|
308
|
+
const image = this.lineItems && this.lineItems[0] && this.lineItems[0].image && this.lineItems[0].image.originalSrc
|
|
309
|
+
? this.lineItems[0].image.originalSrc
|
|
310
|
+
: 'https://res.cloudinary.com/ribbn/image/fetch/e_blur:1000,o_20,q_50/https://cdn.shopify.com/s/files/1/0261/9686/9172/products/7AC16810-F519-4665-8891-7163EB29FBB7_1000x1000.jpg%3Fv%3D1634827512';
|
|
304
311
|
const stagedObj = {
|
|
305
312
|
id: this.utilities.sanitizeString(this.documentId),
|
|
306
313
|
documentId: this.utilities.sanitizeString(this.documentId),
|
|
@@ -308,7 +315,7 @@ class Order extends Base_1.default {
|
|
|
308
315
|
createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
|
|
309
316
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
310
317
|
merchantId: this.utilities.sanitizeString(this.merchantId),
|
|
311
|
-
image: this.utilities.sanitizeString(
|
|
318
|
+
image: this.utilities.sanitizeString(image),
|
|
312
319
|
orderNumber: this.utilities.sanitizeNumber(this.orderNumber),
|
|
313
320
|
customerName: this.utilities.sanitizeString(this.customerName),
|
|
314
321
|
customerEmail: this.utilities.sanitizeString(this.email),
|
|
@@ -322,6 +329,7 @@ class Order extends Base_1.default {
|
|
|
322
329
|
productIds: this.utilities.sanitzeStringArr(this.lineItems.map((l) => l.productId)),
|
|
323
330
|
productTitles: this.utilities.sanitzeStringArr(this.lineItems.map((l) => l.title)),
|
|
324
331
|
productBrands: this.utilities.sanitzeStringArr(this.lineItems.map((l) => l.brand)),
|
|
332
|
+
tags: this.utilities.sanitzeStringArr(this.tags),
|
|
325
333
|
};
|
|
326
334
|
return stagedObj;
|
|
327
335
|
}
|
package/lib/models/User.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export default class User extends Base {
|
|
|
14
14
|
availableCredit: number;
|
|
15
15
|
createdAt: string | FireStoreTimeStamp;
|
|
16
16
|
updatedAt: string | FireStoreTimeStamp;
|
|
17
|
+
createdAtTimestamp: number;
|
|
18
|
+
updatedAtTimestamp: number;
|
|
17
19
|
lastLogin: string;
|
|
18
20
|
devicePlatform: string;
|
|
19
21
|
shoppingSessionId: string;
|
|
@@ -41,4 +43,14 @@ export default class User extends Base {
|
|
|
41
43
|
toCustomerInputObjForAdmin(): any;
|
|
42
44
|
mergeUserObjWithFirebaseProps(props: UserAttributes): UserAttributes;
|
|
43
45
|
toCustomerInputObjForRibbn(): RibbnCustomerObj;
|
|
46
|
+
generateSchemaForTypesense(name?: string): {
|
|
47
|
+
default_sorting_field: string;
|
|
48
|
+
fields: {
|
|
49
|
+
facet: boolean;
|
|
50
|
+
name: string;
|
|
51
|
+
type: string;
|
|
52
|
+
}[];
|
|
53
|
+
name: string;
|
|
54
|
+
};
|
|
55
|
+
toObjForTypesense(merchantId: string): TypesenseUserObj;
|
|
44
56
|
}
|
package/lib/models/User.js
CHANGED
|
@@ -33,6 +33,8 @@ class User extends Base_1.default {
|
|
|
33
33
|
};
|
|
34
34
|
this.availableCredit = (props === null || props === void 0 ? void 0 : props.availableCredit) || 0;
|
|
35
35
|
this.createdAt = (props === null || props === void 0 ? void 0 : props.createdAt) || '';
|
|
36
|
+
this.createdAtTimestamp = (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) || 0;
|
|
37
|
+
this.updatedAtTimestamp = (props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) || 0;
|
|
36
38
|
this.updatedAt = (props === null || props === void 0 ? void 0 : props.updatedAt) || '';
|
|
37
39
|
this.devicePlatform = (props === null || props === void 0 ? void 0 : props.devicePlatform) || '';
|
|
38
40
|
this.shoppingSessionId = (props === null || props === void 0 ? void 0 : props.shoppingSessionId) || '';
|
|
@@ -71,6 +73,8 @@ class User extends Base_1.default {
|
|
|
71
73
|
availableCredit: this.availableCredit,
|
|
72
74
|
createdAt: this.createdAt,
|
|
73
75
|
updatedAt: this.updatedAt,
|
|
76
|
+
createdAtTimestamp: this.createdAtTimestamp,
|
|
77
|
+
updatedAtTimestamp: this.updatedAtTimestamp,
|
|
74
78
|
devicePlatform: this.devicePlatform,
|
|
75
79
|
shoppingSessionId: this.shoppingSessionId,
|
|
76
80
|
orders: this.orders,
|
|
@@ -86,6 +90,8 @@ class User extends Base_1.default {
|
|
|
86
90
|
notes: this.notes,
|
|
87
91
|
lastLogin: this.lastLogin,
|
|
88
92
|
emailVerified: this.emailVerified,
|
|
93
|
+
ordersCount: this.ordersCount,
|
|
94
|
+
amountSpent: this.amountSpent,
|
|
89
95
|
};
|
|
90
96
|
}
|
|
91
97
|
toCustomerUpdateInputObjForShopify() {
|
|
@@ -158,5 +164,90 @@ class User extends Base_1.default {
|
|
|
158
164
|
};
|
|
159
165
|
return customerInput;
|
|
160
166
|
}
|
|
167
|
+
generateSchemaForTypesense(name = 'dev_customers_20220811') {
|
|
168
|
+
return {
|
|
169
|
+
default_sorting_field: 'createdAtTimestamp',
|
|
170
|
+
fields: [
|
|
171
|
+
{
|
|
172
|
+
facet: false,
|
|
173
|
+
name: 'id',
|
|
174
|
+
type: 'string',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
facet: false,
|
|
178
|
+
name: 'documentId',
|
|
179
|
+
type: 'string',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
facet: false,
|
|
183
|
+
name: 'userId',
|
|
184
|
+
type: 'string',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
facet: true,
|
|
188
|
+
name: 'createdAtTimestamp',
|
|
189
|
+
type: 'int64',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
facet: true,
|
|
193
|
+
name: 'updatedAtTimestamp',
|
|
194
|
+
type: 'int64',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
facet: true,
|
|
198
|
+
name: 'firstName',
|
|
199
|
+
type: 'string',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
facet: true,
|
|
203
|
+
name: 'lastName',
|
|
204
|
+
type: 'string',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
facet: true,
|
|
208
|
+
name: 'email',
|
|
209
|
+
type: 'string',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
facet: true,
|
|
213
|
+
name: 'isSeller',
|
|
214
|
+
type: 'bool',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
facet: true,
|
|
218
|
+
name: 'amountSpent',
|
|
219
|
+
type: 'float',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
facet: true,
|
|
223
|
+
name: 'ordersCount',
|
|
224
|
+
type: 'int32',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
facet: true,
|
|
228
|
+
name: 'merchantId',
|
|
229
|
+
type: 'string',
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
name: 'prod_customers_20220811',
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
toObjForTypesense(merchantId) {
|
|
236
|
+
const stagedObj = {
|
|
237
|
+
id: this.utilities.sanitizeString(this.documentId),
|
|
238
|
+
documentId: this.utilities.sanitizeString(this.documentId),
|
|
239
|
+
userId: this.utilities.sanitizeString(this.uid),
|
|
240
|
+
createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
|
|
241
|
+
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
242
|
+
merchantId: this.utilities.sanitizeString(merchantId),
|
|
243
|
+
firstName: this.utilities.sanitizeString(this.firstName),
|
|
244
|
+
lastName: this.utilities.sanitizeString(this.lastName),
|
|
245
|
+
email: this.utilities.sanitizeString(this.email),
|
|
246
|
+
isSeller: this.isSeller,
|
|
247
|
+
amountSpent: this.utilities.sanitizeNumber(this.amountSpent),
|
|
248
|
+
ordersCount: this.utilities.sanitizeNumber(this.ordersCount),
|
|
249
|
+
};
|
|
250
|
+
return stagedObj;
|
|
251
|
+
}
|
|
161
252
|
}
|
|
162
253
|
exports.default = User;
|
|
@@ -30,6 +30,8 @@ interface UserAttributes extends ReRobeDocument {
|
|
|
30
30
|
amountSpent?: number;
|
|
31
31
|
lastLogin?: string;
|
|
32
32
|
emailVerified: boolean;
|
|
33
|
+
createdAtTimestamp: number;
|
|
34
|
+
updatedAtTimestamp: number;
|
|
33
35
|
}
|
|
34
36
|
declare type RibbnCustomerObj = {
|
|
35
37
|
uid?: string;
|
|
@@ -127,3 +129,17 @@ declare type UserRespFromShopifyWebhook = {
|
|
|
127
129
|
phone?: string;
|
|
128
130
|
addresses: AddressInput[];
|
|
129
131
|
};
|
|
132
|
+
declare type TypesenseUserObj = {
|
|
133
|
+
id: string;
|
|
134
|
+
documentId: string;
|
|
135
|
+
userId: string;
|
|
136
|
+
createdAtTimestamp: number;
|
|
137
|
+
updatedAtTimestamp: number;
|
|
138
|
+
firstName: string;
|
|
139
|
+
lastName: string;
|
|
140
|
+
email: string;
|
|
141
|
+
isSeller: boolean;
|
|
142
|
+
amountSpent: number;
|
|
143
|
+
ordersCount: number;
|
|
144
|
+
merchantId: string;
|
|
145
|
+
};
|