rerobe-js-orm 3.0.11 → 3.0.13
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/helpers/Utilities.d.ts +6 -0
- package/lib/helpers/Utilities.js +25 -0
- package/lib/models/Order.d.ts +8 -2
- package/lib/models/Order.js +25 -1
- package/lib/models/Product.d.ts +1 -1
- package/lib/models/Product.js +26 -1
- package/lib/models/User.d.ts +8 -2
- package/lib/models/User.js +25 -1
- package/lib/types/rerobe-order-types.d.ts +4 -0
- package/lib/types/rerobe-product-types.d.ts +4 -0
- package/lib/types/rerobe-user-types.d.ts +4 -0
- package/package.json +1 -1
package/lib/helpers/Utilities.js
CHANGED
|
@@ -146,5 +146,30 @@ class Utilities {
|
|
|
146
146
|
}
|
|
147
147
|
return res;
|
|
148
148
|
}
|
|
149
|
+
formatTimestamp(timestampMillis) {
|
|
150
|
+
if (typeof timestampMillis !== 'number' || Number.isNaN(new Date(timestampMillis).valueOf())) {
|
|
151
|
+
return {
|
|
152
|
+
createdAtHour: '',
|
|
153
|
+
createdAtDay: '',
|
|
154
|
+
createdAtMonth: '',
|
|
155
|
+
createdAtYear: '',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const dateObj = new Date(timestampMillis);
|
|
159
|
+
const year = dateObj.getUTCFullYear();
|
|
160
|
+
const month = (dateObj.getUTCMonth() + 1).toString().padStart(2, '0'); // Months are 0-indexed in JS
|
|
161
|
+
const day = dateObj.getUTCDate().toString().padStart(2, '0');
|
|
162
|
+
const hour = dateObj.getUTCHours().toString().padStart(2, '0');
|
|
163
|
+
const createdAtHour = `${year}-${month}-${day} ${hour}`;
|
|
164
|
+
const createdAtDay = `${year}-${month}-${day}`;
|
|
165
|
+
const createdAtMonth = `${year}-${month}`;
|
|
166
|
+
const createdAtYear = `${year}`;
|
|
167
|
+
return {
|
|
168
|
+
createdAtHour,
|
|
169
|
+
createdAtDay,
|
|
170
|
+
createdAtMonth,
|
|
171
|
+
createdAtYear,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
149
174
|
}
|
|
150
175
|
exports.default = Utilities;
|
package/lib/models/Order.d.ts
CHANGED
|
@@ -103,11 +103,17 @@ export default class Order extends Base {
|
|
|
103
103
|
toObj(): ReRobeOrderObj;
|
|
104
104
|
generateSchemaForTypesense(name?: string): {
|
|
105
105
|
default_sorting_field: string;
|
|
106
|
-
fields: {
|
|
106
|
+
fields: ({
|
|
107
107
|
facet: boolean;
|
|
108
108
|
name: string;
|
|
109
109
|
type: string;
|
|
110
|
-
|
|
110
|
+
optional?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
facet: boolean;
|
|
113
|
+
name: string;
|
|
114
|
+
type: string;
|
|
115
|
+
optional: boolean;
|
|
116
|
+
})[];
|
|
111
117
|
name: string;
|
|
112
118
|
};
|
|
113
119
|
toObjForTypesense(): TypesenseOrderObj;
|
package/lib/models/Order.js
CHANGED
|
@@ -308,6 +308,24 @@ class Order extends Base_1.default {
|
|
|
308
308
|
name: 'merchantId',
|
|
309
309
|
type: 'string',
|
|
310
310
|
},
|
|
311
|
+
{
|
|
312
|
+
facet: true,
|
|
313
|
+
name: 'createdAtHour',
|
|
314
|
+
type: 'string',
|
|
315
|
+
optional: true,
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
facet: true,
|
|
319
|
+
name: 'createdAtDay',
|
|
320
|
+
type: 'string',
|
|
321
|
+
optional: true,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
facet: true,
|
|
325
|
+
name: 'createdAtMonth',
|
|
326
|
+
type: 'string',
|
|
327
|
+
optional: true,
|
|
328
|
+
},
|
|
311
329
|
],
|
|
312
330
|
name: 'dev_orders_20220809',
|
|
313
331
|
};
|
|
@@ -316,11 +334,17 @@ class Order extends Base_1.default {
|
|
|
316
334
|
const image = this.lineItems && this.lineItems[0] && this.lineItems[0].image && this.lineItems[0].image.originalSrc
|
|
317
335
|
? this.lineItems[0].image.originalSrc
|
|
318
336
|
: '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';
|
|
337
|
+
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp);
|
|
338
|
+
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
319
339
|
const stagedObj = {
|
|
320
340
|
id: this.utilities.sanitizeString(this.documentId),
|
|
321
341
|
documentId: this.utilities.sanitizeString(this.documentId),
|
|
322
342
|
userId: this.utilities.sanitizeString(this.userId),
|
|
323
|
-
createdAtTimestamp
|
|
343
|
+
createdAtTimestamp,
|
|
344
|
+
createdAtHour,
|
|
345
|
+
createdAtDay,
|
|
346
|
+
createdAtMonth,
|
|
347
|
+
createdAtYear,
|
|
324
348
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
325
349
|
merchantId: this.utilities.sanitizeString(this.merchantId),
|
|
326
350
|
image: this.utilities.sanitizeString(image),
|
package/lib/models/Product.d.ts
CHANGED
package/lib/models/Product.js
CHANGED
|
@@ -261,6 +261,8 @@ class Product extends Base_1.default {
|
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
263
|
toObjForTypesense() {
|
|
264
|
+
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.createdAtTimestamp);
|
|
265
|
+
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
264
266
|
const stagedObj = {
|
|
265
267
|
brand: this.utilities.sanitizeString(this.filterAttributes.brand),
|
|
266
268
|
size: this.utilities.sanitizeString(this.filterAttributes.size),
|
|
@@ -290,7 +292,11 @@ class Product extends Base_1.default {
|
|
|
290
292
|
title: this.utilities.sanitizeString(this.attributes.title),
|
|
291
293
|
vendorName: this.utilities.sanitizeString(this.attributes.vendorName),
|
|
292
294
|
vendorId: this.utilities.sanitizeString(this.attributes.vendorId),
|
|
293
|
-
createdAtTimestamp
|
|
295
|
+
createdAtTimestamp,
|
|
296
|
+
createdAtHour,
|
|
297
|
+
createdAtDay,
|
|
298
|
+
createdAtMonth,
|
|
299
|
+
createdAtYear,
|
|
294
300
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.updatedAtTimestamp),
|
|
295
301
|
sellRequestReviewTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewTimestamp),
|
|
296
302
|
sellRequestReviewDraftTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewDraftTimestamp),
|
|
@@ -463,6 +469,7 @@ class Product extends Base_1.default {
|
|
|
463
469
|
facet: true,
|
|
464
470
|
name: 'size',
|
|
465
471
|
type: 'string',
|
|
472
|
+
optional: true,
|
|
466
473
|
},
|
|
467
474
|
{
|
|
468
475
|
facet: true,
|
|
@@ -738,6 +745,24 @@ class Product extends Base_1.default {
|
|
|
738
745
|
name: 'materialComposition..*.value',
|
|
739
746
|
type: 'int32',
|
|
740
747
|
},
|
|
748
|
+
{
|
|
749
|
+
facet: true,
|
|
750
|
+
name: 'createdAtHour',
|
|
751
|
+
type: 'string',
|
|
752
|
+
optional: true,
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
facet: true,
|
|
756
|
+
name: 'createdAtDay',
|
|
757
|
+
type: 'string',
|
|
758
|
+
optional: true,
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
facet: true,
|
|
762
|
+
name: 'createdAtMonth',
|
|
763
|
+
type: 'string',
|
|
764
|
+
optional: true,
|
|
765
|
+
},
|
|
741
766
|
],
|
|
742
767
|
name,
|
|
743
768
|
};
|
package/lib/models/User.d.ts
CHANGED
|
@@ -50,11 +50,17 @@ export default class User extends Base {
|
|
|
50
50
|
toCustomerInputObjForRibbn(): RibbnCustomerObj;
|
|
51
51
|
generateSchemaForTypesense(name?: string): {
|
|
52
52
|
default_sorting_field: string;
|
|
53
|
-
fields: {
|
|
53
|
+
fields: ({
|
|
54
54
|
facet: boolean;
|
|
55
55
|
name: string;
|
|
56
56
|
type: string;
|
|
57
|
-
|
|
57
|
+
optional?: undefined;
|
|
58
|
+
} | {
|
|
59
|
+
facet: boolean;
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
optional: boolean;
|
|
63
|
+
})[];
|
|
58
64
|
name: string;
|
|
59
65
|
};
|
|
60
66
|
toObjForTypesense(merchantId: string): TypesenseUserObj;
|
package/lib/models/User.js
CHANGED
|
@@ -295,16 +295,40 @@ class User extends Base_1.default {
|
|
|
295
295
|
name: 'registrationSource',
|
|
296
296
|
type: 'string',
|
|
297
297
|
},
|
|
298
|
+
{
|
|
299
|
+
facet: true,
|
|
300
|
+
name: 'createdAtHour',
|
|
301
|
+
type: 'string',
|
|
302
|
+
optional: true,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
facet: true,
|
|
306
|
+
name: 'createdAtDay',
|
|
307
|
+
type: 'string',
|
|
308
|
+
optional: true,
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
facet: true,
|
|
312
|
+
name: 'createdAtMonth',
|
|
313
|
+
type: 'string',
|
|
314
|
+
optional: true,
|
|
315
|
+
},
|
|
298
316
|
],
|
|
299
317
|
name: 'prod_customers_20220907',
|
|
300
318
|
};
|
|
301
319
|
}
|
|
302
320
|
toObjForTypesense(merchantId) {
|
|
321
|
+
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp);
|
|
322
|
+
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
303
323
|
const stagedObj = {
|
|
304
324
|
id: this.utilities.sanitizeString(this.documentId),
|
|
305
325
|
documentId: this.utilities.sanitizeString(this.documentId),
|
|
306
326
|
userId: this.utilities.sanitizeString(this.uid),
|
|
307
|
-
createdAtTimestamp
|
|
327
|
+
createdAtTimestamp,
|
|
328
|
+
createdAtHour,
|
|
329
|
+
createdAtDay,
|
|
330
|
+
createdAtMonth,
|
|
331
|
+
createdAtYear,
|
|
308
332
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
309
333
|
merchantId: this.utilities.sanitizeString(merchantId),
|
|
310
334
|
firstName: this.utilities.sanitizeString(this.firstName),
|
|
@@ -299,5 +299,9 @@ declare type TypesenseProductObj = {
|
|
|
299
299
|
reservedBy: string[];
|
|
300
300
|
'inventoryLocations.ids': string[];
|
|
301
301
|
'materialComposition.names': string[];
|
|
302
|
+
createdAtDay: string;
|
|
303
|
+
createdAtMonth: string;
|
|
304
|
+
createdAtHour: string;
|
|
305
|
+
createdAtYear: string;
|
|
302
306
|
[key: string]: any;
|
|
303
307
|
};
|