rerobe-js-orm 3.0.10 → 3.0.12
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/Merchant/MerchantFromFormState.js +0 -2
- package/lib/helpers/Utilities.d.ts +5 -0
- package/lib/helpers/Utilities.js +22 -0
- package/lib/models/Merchant.js +0 -1
- package/lib/models/Order.d.ts +8 -2
- package/lib/models/Order.js +24 -1
- package/lib/models/Product.d.ts +1 -1
- package/lib/models/Product.js +26 -2
- package/lib/models/User.d.ts +8 -2
- package/lib/models/User.js +24 -1
- package/lib/types/merchant-types.d.ts +1 -1
- package/lib/types/rerobe-order-types.d.ts +3 -0
- package/lib/types/rerobe-product-types.d.ts +3 -0
- package/lib/types/rerobe-user-types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@ const MerchantFactory_1 = require("./MerchantFactory");
|
|
|
4
4
|
const Merchant_1 = require("../../models/Merchant");
|
|
5
5
|
class MerchantFromFormState extends MerchantFactory_1.default {
|
|
6
6
|
createMerchant(fs) {
|
|
7
|
-
var _a;
|
|
8
7
|
const MerchantMutableData = {
|
|
9
8
|
name: fs.fields.name.inputValue,
|
|
10
9
|
type: fs.fields.type.selectedValue,
|
|
@@ -18,7 +17,6 @@ class MerchantFromFormState extends MerchantFactory_1.default {
|
|
|
18
17
|
timeZone: fs.fields.timeZone.selectedValue,
|
|
19
18
|
unitSystem: fs.fields.unitSystem.selectedValue,
|
|
20
19
|
defaultWeightUnit: fs.fields.defaultWeightUnit.selectedValue,
|
|
21
|
-
defaultLocation: (_a = fs.props) === null || _a === void 0 ? void 0 : _a.defaultLocation,
|
|
22
20
|
webhooks: fs.fields.webhooks.selectedValues,
|
|
23
21
|
primaryDomain: fs.fields.primaryDomain.inputValue,
|
|
24
22
|
socialLinks: fs.fields.socialLinks.selectedValue,
|
package/lib/helpers/Utilities.js
CHANGED
|
@@ -146,5 +146,27 @@ 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
|
+
createdAtDay: '',
|
|
153
|
+
createdAtMonth: '',
|
|
154
|
+
createdAtHour: '',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const dateObj = new Date(timestampMillis);
|
|
158
|
+
const year = dateObj.getUTCFullYear();
|
|
159
|
+
const month = (dateObj.getUTCMonth() + 1).toString().padStart(2, '0'); // Months are 0-indexed in JS
|
|
160
|
+
const day = dateObj.getUTCDate().toString().padStart(2, '0');
|
|
161
|
+
const hour = dateObj.getUTCHours().toString().padStart(2, '0');
|
|
162
|
+
const createdAtDay = `${year}-${month}-${day}`;
|
|
163
|
+
const createdAtMonth = `${year}-${month}`;
|
|
164
|
+
const createdAtHour = `${year}-${month}-${day} ${hour}`;
|
|
165
|
+
return {
|
|
166
|
+
createdAtDay,
|
|
167
|
+
createdAtMonth,
|
|
168
|
+
createdAtHour,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
149
171
|
}
|
|
150
172
|
exports.default = Utilities;
|
package/lib/models/Merchant.js
CHANGED
|
@@ -91,7 +91,6 @@ class Merchant extends Base_1.default {
|
|
|
91
91
|
timeZone: this.timeZone,
|
|
92
92
|
unitSystem: this.unitSystem,
|
|
93
93
|
defaultWeightUnit: this.defaultWeightUnit,
|
|
94
|
-
defaultLocation: this.defaultLocation,
|
|
95
94
|
primaryDomain: this.primaryDomain,
|
|
96
95
|
webhooks: this.webhooks,
|
|
97
96
|
socialLinks: this.socialLinks,
|
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,16 @@ 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 } = 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,
|
|
324
347
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
325
348
|
merchantId: this.utilities.sanitizeString(this.merchantId),
|
|
326
349
|
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 } = 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,10 @@ 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,
|
|
294
299
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.updatedAtTimestamp),
|
|
295
300
|
sellRequestReviewTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewTimestamp),
|
|
296
301
|
sellRequestReviewDraftTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewDraftTimestamp),
|
|
@@ -463,6 +468,7 @@ class Product extends Base_1.default {
|
|
|
463
468
|
facet: true,
|
|
464
469
|
name: 'size',
|
|
465
470
|
type: 'string',
|
|
471
|
+
optional: true,
|
|
466
472
|
},
|
|
467
473
|
{
|
|
468
474
|
facet: true,
|
|
@@ -510,7 +516,7 @@ class Product extends Base_1.default {
|
|
|
510
516
|
},
|
|
511
517
|
{
|
|
512
518
|
facet: false,
|
|
513
|
-
optional:
|
|
519
|
+
optional: true,
|
|
514
520
|
name: 'merchantId',
|
|
515
521
|
type: 'string',
|
|
516
522
|
},
|
|
@@ -738,6 +744,24 @@ class Product extends Base_1.default {
|
|
|
738
744
|
name: 'materialComposition..*.value',
|
|
739
745
|
type: 'int32',
|
|
740
746
|
},
|
|
747
|
+
{
|
|
748
|
+
facet: true,
|
|
749
|
+
name: 'createdAtHour',
|
|
750
|
+
type: 'string',
|
|
751
|
+
optional: true,
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
facet: true,
|
|
755
|
+
name: 'createdAtDay',
|
|
756
|
+
type: 'string',
|
|
757
|
+
optional: true,
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
facet: true,
|
|
761
|
+
name: 'createdAtMonth',
|
|
762
|
+
type: 'string',
|
|
763
|
+
optional: true,
|
|
764
|
+
},
|
|
741
765
|
],
|
|
742
766
|
name,
|
|
743
767
|
};
|
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,39 @@ 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 } = 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,
|
|
308
331
|
updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.updatedAtTimestamp),
|
|
309
332
|
merchantId: this.utilities.sanitizeString(merchantId),
|
|
310
333
|
firstName: this.utilities.sanitizeString(this.firstName),
|
|
@@ -19,7 +19,6 @@ declare type MerchantMutableData = {
|
|
|
19
19
|
timeZone: string;
|
|
20
20
|
unitSystem: UnitSystemTypes | string | null;
|
|
21
21
|
defaultWeightUnit: MetricWeightTypes | ImperialWeightTypes | string | null;
|
|
22
|
-
defaultLocation: string;
|
|
23
22
|
primaryDomain: string;
|
|
24
23
|
webhooks: MerchantWebHook[];
|
|
25
24
|
socialLinks: SocialLinksType | null;
|
|
@@ -35,6 +34,7 @@ declare type MerchantSystemOnlyMutableData = {
|
|
|
35
34
|
sharedSecret: string;
|
|
36
35
|
ribbnId: string;
|
|
37
36
|
webshopHomePageId: string;
|
|
37
|
+
defaultLocation: string;
|
|
38
38
|
};
|
|
39
39
|
declare type MerchantObj = MerchantMutableData & MerchantSystemOnlyMutableData;
|
|
40
40
|
declare type MerchantTypes = 'INDIVIDUAL' | 'BUSINESS';
|
|
@@ -299,5 +299,8 @@ 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;
|
|
302
305
|
[key: string]: any;
|
|
303
306
|
};
|