rerobe-js-orm 2.4.84 → 2.4.88

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.
@@ -4,7 +4,7 @@ const ProductFactory_1 = require("./ProductFactory");
4
4
  const Product_1 = require("../../models/Product");
5
5
  class ProductFromFormState extends ProductFactory_1.default {
6
6
  createProduct(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, _6, _7, _8, _9, _10, _11;
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, _9, _10, _11, _12, _13;
8
8
  const productAttributes = {
9
9
  availableForSale: props.fields.availableForSale.selectedValue,
10
10
  description: props.fields.description.inputValue,
@@ -79,26 +79,28 @@ class ProductFromFormState extends ProductFactory_1.default {
79
79
  inventoryLocations: props.fields.inventoryLocations.selectedValues || [],
80
80
  };
81
81
  const timestampAttributes = {
82
- sellRequestReviewTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.sellRequestReviewTimestamp,
83
- sellRequestReviewDraftTimestamp: (_t = props.props) === null || _t === void 0 ? void 0 : _t.sellRequestReviewDraftTimestamp,
84
- rejectedTimestamp: (_u = props.props) === null || _u === void 0 ? void 0 : _u.rejectedTimestamp,
85
- holdTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.holdTimestamp,
86
- acceptedTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.acceptedTimestamp,
87
- sellerToDropOffTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.sellerToDropOffTimestamp,
88
- sellerToShipTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.sellerToShipTimestamp,
89
- sellerToGetPickUpTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellerToGetPickUpTimestamp,
90
- qualityControlTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.qualityControlTimestamp,
91
- pendingPublicationTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.pendingPublicationTimestamp,
92
- listedTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.listedTimestamp,
93
- clearanceTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.clearanceTimestamp,
94
- reservedTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.reservedTimestamp,
95
- soldTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.soldTimestamp,
96
- returnedTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.returnedTimestamp,
97
- soldSellerToBePaidTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.soldSellerToBePaidTimestamp,
98
- soldSellerPaidTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.soldSellerPaidTimestamp,
99
- sellerSelfRejectTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.sellerSelfRejectTimestamp,
100
- liquidationRequestedTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.liquidationRequestedTimestamp,
101
- sellerLiquidatedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerLiquidatedTimestamp,
82
+ createdAtTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.createdAtTimestamp,
83
+ updatedAtTimestamp: (_t = props.props) === null || _t === void 0 ? void 0 : _t.updatedAtTimestamp,
84
+ sellRequestReviewTimestamp: (_u = props.props) === null || _u === void 0 ? void 0 : _u.sellRequestReviewTimestamp,
85
+ sellRequestReviewDraftTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.sellRequestReviewDraftTimestamp,
86
+ rejectedTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.rejectedTimestamp,
87
+ holdTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.holdTimestamp,
88
+ acceptedTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.acceptedTimestamp,
89
+ sellerToDropOffTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellerToDropOffTimestamp,
90
+ sellerToShipTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.sellerToShipTimestamp,
91
+ sellerToGetPickUpTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.sellerToGetPickUpTimestamp,
92
+ qualityControlTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.qualityControlTimestamp,
93
+ pendingPublicationTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.pendingPublicationTimestamp,
94
+ listedTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.listedTimestamp,
95
+ clearanceTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.clearanceTimestamp,
96
+ reservedTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.reservedTimestamp,
97
+ soldTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.soldTimestamp,
98
+ returnedTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.returnedTimestamp,
99
+ soldSellerToBePaidTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.soldSellerToBePaidTimestamp,
100
+ soldSellerPaidTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.soldSellerPaidTimestamp,
101
+ sellerSelfRejectTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerSelfRejectTimestamp,
102
+ liquidationRequestedTimestamp: (_12 = props.props) === null || _12 === void 0 ? void 0 : _12.liquidationRequestedTimestamp,
103
+ sellerLiquidatedTimestamp: (_13 = props.props) === null || _13 === void 0 ? void 0 : _13.sellerLiquidatedTimestamp,
102
104
  };
103
105
  return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
104
106
  }
@@ -226,7 +226,7 @@ class ReRobeProductHelpers {
226
226
  static createTimestampsForStates(productObj) {
227
227
  const docFieldsToUpdate = {};
228
228
  if (productObj) {
229
- const { dateSold, status, sellRequestReviewDraftTimestamp, sellRequestReviewTimestamp, rejectedTimestamp, holdTimestamp, acceptedTimestamp, sellerToDropOffTimestamp, sellerToShipTimestamp, sellerToGetPickUpTimestamp, qualityControlTimestamp, pendingPublicationTimestamp, listedTimestamp, clearanceTimestamp, reservedTimestamp, soldTimestamp, soldSellerToBePaidTimestamp, soldSellerPaidTimestamp, returnedTimestamp, sellerSelfRejectTimestamp, liquidationRequestedTimestamp, sellerLiquidatedTimestamp, } = productObj;
229
+ const { status, sellRequestReviewDraftTimestamp, sellRequestReviewTimestamp, rejectedTimestamp, holdTimestamp, acceptedTimestamp, sellerToDropOffTimestamp, sellerToShipTimestamp, sellerToGetPickUpTimestamp, qualityControlTimestamp, pendingPublicationTimestamp, listedTimestamp, clearanceTimestamp, reservedTimestamp, soldTimestamp, soldSellerToBePaidTimestamp, soldSellerPaidTimestamp, returnedTimestamp, sellerSelfRejectTimestamp, liquidationRequestedTimestamp, sellerLiquidatedTimestamp, } = productObj;
230
230
  if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReviewDraft && !sellRequestReviewDraftTimestamp) {
231
231
  docFieldsToUpdate.sellRequestReviewDraftTimestamp = new Date().getTime();
232
232
  }
@@ -7,6 +7,11 @@ export default class Utilities {
7
7
  getWeekNumberFromDate(dateString: string): string;
8
8
  capitalizeString(s: string): string;
9
9
  startCase(s: string): string;
10
+ camelCase(s: string): string;
10
11
  constantCase(str: string): any;
11
12
  makeRandId(length: number): string;
13
+ sanitizeString(v: any): string;
14
+ sanitzeStringArr(v: any): string[];
15
+ sanitizeNumber(v: any, to?: number): number;
16
+ sanitizeMillisTimeStamp(t: any): number;
12
17
  }
@@ -47,6 +47,9 @@ class Utilities {
47
47
  startCase(s) {
48
48
  return lodash_1.startCase(s);
49
49
  }
50
+ camelCase(s) {
51
+ return lodash_1.camelCase(s);
52
+ }
50
53
  constantCase(str) {
51
54
  return lodash_1.snakeCase(str).toUpperCase();
52
55
  }
@@ -60,5 +63,26 @@ class Utilities {
60
63
  }
61
64
  return result;
62
65
  }
66
+ sanitizeString(v) {
67
+ if (v && (typeof v === 'string' || typeof v === 'number')) {
68
+ return String(v);
69
+ }
70
+ return '';
71
+ }
72
+ sanitzeStringArr(v) {
73
+ if (v && Array.isArray(v)) {
74
+ return v.filter((e) => e).map((e) => String(e));
75
+ }
76
+ return [];
77
+ }
78
+ sanitizeNumber(v, to = 1) {
79
+ return Number.isNaN(parseFloat(String(v))) ? Number(to) : parseFloat(String(v));
80
+ }
81
+ sanitizeMillisTimeStamp(t) {
82
+ if (t && typeof t === 'number') {
83
+ return t;
84
+ }
85
+ return 0;
86
+ }
63
87
  }
64
88
  exports.default = Utilities;
@@ -10,11 +10,29 @@ export default class Product extends Base {
10
10
  toObj(): CompleteProduct;
11
11
  toProductInputObjForShopify(location?: string): any;
12
12
  toObjForTextTranslation(): TranslatableAttributes;
13
+ toObjForTypesense(): TypesenseProductObj;
13
14
  updateSelfFromTranslatedTextArray(translatedTextArray?: string[]): void;
14
15
  autoCreateTitle(): string;
15
16
  autoCreateDescriptionHTML(): string;
17
+ generateSchemaForTypesense(name?: string): {
18
+ default_sorting_field: string;
19
+ fields: ({
20
+ facet: boolean;
21
+ name: string;
22
+ type: string;
23
+ optional?: undefined;
24
+ } | {
25
+ facet: boolean;
26
+ optional: boolean;
27
+ name: string;
28
+ type: string;
29
+ })[];
30
+ name: string;
31
+ };
16
32
  private materialCompTagsArrayForShopify;
17
33
  private materialCompJoinedString;
18
34
  private measurementsJoinedString;
19
35
  private convertMaterialCompJoinedStrToObj;
36
+ private sanitizeMaterialComp;
37
+ private sanitizeCommission;
20
38
  }
@@ -83,6 +83,8 @@ class Product extends Base_1.default {
83
83
  inventoryLocations: (props === null || props === void 0 ? void 0 : props.inventoryLocations) || [],
84
84
  };
85
85
  this.timestampAttributes = {
86
+ createdAtTimestamp: (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.createdAtTimestamp) : null,
87
+ updatedAtTimestamp: (props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) : null,
86
88
  sellRequestReviewDraftTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
87
89
  ? Number(props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
88
90
  : null,
@@ -115,7 +117,7 @@ class Product extends Base_1.default {
115
117
  }
116
118
  toPartialObj() {
117
119
  return Object.assign(Object.assign({}, this.attributes), this.filterAttributes);
118
- }
120
+ } // ToDo: Deprecate soon
119
121
  toObj() {
120
122
  return Object.assign(Object.assign(Object.assign(Object.assign({}, this.attributes), this.filterAttributes), this.consignmentAttributes), this.timestampAttributes);
121
123
  }
@@ -226,6 +228,87 @@ class Product extends Base_1.default {
226
228
  condition: this.filterAttributes.condition || this.FIELD_NOT_TRANSLATABLE_KEY,
227
229
  };
228
230
  }
231
+ toObjForTypesense() {
232
+ const stagedObj = {
233
+ brand: this.utilities.sanitizeString(this.filterAttributes.brand),
234
+ clothingSize: this.utilities.sanitzeStringArr(this.filterAttributes.clothingSize),
235
+ jeanSize: this.utilities.sanitizeString(this.filterAttributes.jeanSize),
236
+ shoeSize: this.utilities.sanitizeString(this.filterAttributes.shoeSize),
237
+ condition: this.utilities.sanitizeString(this.filterAttributes.condition),
238
+ featuredCollections: this.utilities.sanitzeStringArr(this.filterAttributes.featuredCollections),
239
+ isOnSale: this.utilities.sanitizeString(this.consignmentAttributes.isOnSale),
240
+ merchants: this.utilities.sanitzeStringArr(this.attributes.merchants),
241
+ price: this.utilities.sanitizeNumber(this.attributes.price),
242
+ suggestedResalePrice: this.utilities.sanitizeNumber(this.consignmentAttributes.suggestedResalePrice),
243
+ salePrice: this.utilities.sanitizeNumber(this.consignmentAttributes.salePrice),
244
+ compareAtPrice: this.utilities.sanitizeNumber(this.attributes.compareAtPrice),
245
+ costPerItem: this.utilities.sanitizeNumber(this.attributes.costPerItem),
246
+ priceRange: this.utilities.sanitizeString(this.filterAttributes.priceRange),
247
+ productCategory: this.utilities.sanitizeString(this.filterAttributes.productCategory),
248
+ productType: this.utilities.sanitizeString(this.filterAttributes.productType),
249
+ productStyle: this.utilities.sanitzeStringArr(this.filterAttributes.productStyle),
250
+ reRobeCommission: this.sanitizeCommission(),
251
+ rfidTag: this.utilities.sanitizeString(this.attributes.rfidTag),
252
+ salesChannel: this.utilities.sanitzeStringArr(this.consignmentAttributes.salesChannel),
253
+ status: this.utilities.sanitizeString(this.consignmentAttributes.status),
254
+ tags: this.utilities.sanitzeStringArr(this.filterAttributes.tags),
255
+ title: this.utilities.sanitizeString(this.attributes.title),
256
+ vendorName: this.utilities.sanitizeString(this.attributes.vendorName),
257
+ vendorId: this.utilities.sanitizeString(this.attributes.vendorId),
258
+ createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.createdAtTimestamp),
259
+ updatedAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.updatedAtTimestamp),
260
+ sellRequestReviewTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewTimestamp),
261
+ sellRequestReviewDraftTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellRequestReviewDraftTimestamp),
262
+ rejectedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.rejectedTimestamp),
263
+ holdTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.holdTimestamp),
264
+ acceptedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.acceptedTimestamp),
265
+ sellerToDropOffTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerToDropOffTimestamp),
266
+ sellerToShipTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerToShipTimestamp),
267
+ sellerToGetPickUpTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerToGetPickUpTimestamp),
268
+ qualityControlTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.qualityControlTimestamp),
269
+ pendingPublicationTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.pendingPublicationTimestamp),
270
+ listedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.listedTimestamp),
271
+ clearanceTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.clearanceTimestamp),
272
+ reservedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.reservedTimestamp),
273
+ soldTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.soldTimestamp),
274
+ returnedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.returnedTimestamp),
275
+ soldSellerToBePaidTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.soldSellerToBePaidTimestamp),
276
+ soldSellerPaidTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.soldSellerPaidTimestamp),
277
+ sellerSelfRejectTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerSelfRejectTimestamp),
278
+ liquidationRequestedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.liquidationRequestedTimestamp),
279
+ sellerLiquidatedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerLiquidatedTimestamp),
280
+ selectedForClearance: this.utilities.sanitizeString(this.consignmentAttributes.selectedForClearance),
281
+ availableForSale: !!this.attributes.availableForSale,
282
+ color: this.utilities.sanitizeString(this.filterAttributes.color),
283
+ description: this.utilities.sanitizeString(this.attributes.description),
284
+ discountType: this.utilities.sanitizeString(this.consignmentAttributes.discountType),
285
+ discountValue: this.utilities.sanitizeNumber(this.consignmentAttributes.discountValue, 0),
286
+ id: this.utilities.sanitizeString(this.filterAttributes.documentId),
287
+ documentId: this.utilities.sanitizeString(this.filterAttributes.documentId),
288
+ shopifyId: this.utilities.sanitizeString(this.attributes.shopifyId),
289
+ gender: this.utilities.sanitizeString(this.filterAttributes.gender),
290
+ handle: this.utilities.sanitizeString(this.attributes.handle),
291
+ imageUrls: this.utilities.sanitzeStringArr(this.attributes.imageUrls),
292
+ sellRequestImageUrls: this.utilities.sanitzeStringArr(this.consignmentAttributes.sellRequestImageUrls),
293
+ reservedBy: this.utilities.sanitzeStringArr(this.attributes.reservedBy),
294
+ 'materialComposition.names': Object.keys(this.sanitizeMaterialComp()),
295
+ 'inventoryLocations.ids': this.consignmentAttributes.inventoryLocations && Array.isArray(this.consignmentAttributes.inventoryLocations)
296
+ ? this.consignmentAttributes.inventoryLocations.map((c) => String(c.id))
297
+ : [],
298
+ };
299
+ this.consignmentAttributes.inventoryLocations.forEach((l) => {
300
+ if (l.id) {
301
+ stagedObj[`inventoryLocations.${l.id}.availableAmount`] = l.availableAmount || 0;
302
+ stagedObj[`inventoryLocations.${l.id}.incomingAmount`] = l.incomingAmount || 0;
303
+ }
304
+ });
305
+ Object.values(this.sanitizeMaterialComp()).forEach((v, i) => {
306
+ if (v) {
307
+ stagedObj[`materialComposition.${Object.keys(this.sanitizeMaterialComp())[i]}.value`] = v;
308
+ }
309
+ });
310
+ return stagedObj;
311
+ }
229
312
  updateSelfFromTranslatedTextArray(translatedTextArray = []) {
230
313
  const checkFieldTranslated = (val) => {
231
314
  return val !== this.FIELD_NOT_TRANSLATABLE_KEY;
@@ -324,6 +407,281 @@ class Product extends Base_1.default {
324
407
  return acc;
325
408
  }, '');
326
409
  }
410
+ generateSchemaForTypesense(name = 'prod_products_20210108') {
411
+ return {
412
+ default_sorting_field: 'createdAtTimestamp',
413
+ fields: [
414
+ {
415
+ facet: true,
416
+ name: 'brand',
417
+ type: 'string',
418
+ },
419
+ {
420
+ facet: true,
421
+ name: 'clothingSize',
422
+ type: 'string[]',
423
+ },
424
+ {
425
+ facet: true,
426
+ name: 'jeanSize',
427
+ type: 'string',
428
+ },
429
+ {
430
+ facet: true,
431
+ name: 'shoeSize',
432
+ type: 'string',
433
+ },
434
+ {
435
+ facet: true,
436
+ name: 'condition',
437
+ type: 'string',
438
+ },
439
+ {
440
+ facet: true,
441
+ optional: true,
442
+ name: 'featuredCollections',
443
+ type: 'string[]',
444
+ },
445
+ {
446
+ facet: true,
447
+ optional: true,
448
+ name: 'isOnSale',
449
+ type: 'string',
450
+ },
451
+ {
452
+ facet: false,
453
+ optional: false,
454
+ name: 'merchants',
455
+ type: 'string[]',
456
+ },
457
+ {
458
+ facet: true,
459
+ name: 'price',
460
+ type: 'float',
461
+ },
462
+ {
463
+ facet: true,
464
+ optional: true,
465
+ name: 'suggestedResalePrice',
466
+ type: 'float',
467
+ },
468
+ {
469
+ facet: true,
470
+ optional: true,
471
+ name: 'salePrice',
472
+ type: 'float',
473
+ },
474
+ {
475
+ facet: false,
476
+ optional: true,
477
+ name: 'compareAtPrice',
478
+ type: 'float',
479
+ },
480
+ {
481
+ facet: false,
482
+ optional: true,
483
+ name: 'costPerItem',
484
+ type: 'float',
485
+ },
486
+ {
487
+ facet: true,
488
+ name: 'priceRange',
489
+ type: 'string',
490
+ },
491
+ {
492
+ facet: true,
493
+ name: 'productCategory',
494
+ type: 'string',
495
+ },
496
+ {
497
+ facet: true,
498
+ name: 'productType',
499
+ type: 'string',
500
+ },
501
+ {
502
+ facet: true,
503
+ name: 'productStyle',
504
+ type: 'string[]',
505
+ },
506
+ {
507
+ facet: true,
508
+ name: 'reRobeCommission',
509
+ type: 'float',
510
+ },
511
+ {
512
+ facet: true,
513
+ optional: true,
514
+ name: 'rfidTag',
515
+ type: 'string',
516
+ },
517
+ {
518
+ facet: true,
519
+ optional: true,
520
+ name: 'salesChannel',
521
+ type: 'string[]',
522
+ },
523
+ {
524
+ facet: true,
525
+ name: 'status',
526
+ type: 'string',
527
+ },
528
+ {
529
+ facet: true,
530
+ optional: true,
531
+ name: 'tags',
532
+ type: 'string[]',
533
+ },
534
+ {
535
+ facet: false,
536
+ name: 'title',
537
+ type: 'string',
538
+ },
539
+ {
540
+ facet: true,
541
+ name: 'vendorName',
542
+ type: 'string',
543
+ },
544
+ {
545
+ facet: true,
546
+ name: 'vendorId',
547
+ type: 'string',
548
+ },
549
+ {
550
+ facet: false,
551
+ optional: true,
552
+ name: '.*Timestamp',
553
+ type: 'int32',
554
+ },
555
+ {
556
+ facet: false,
557
+ name: 'createdAtTimestamp',
558
+ type: 'int32',
559
+ },
560
+ {
561
+ facet: false,
562
+ name: 'updatedAtTimestamp',
563
+ type: 'int32',
564
+ },
565
+ {
566
+ facet: false,
567
+ name: 'availableForSale',
568
+ type: 'bool',
569
+ },
570
+ {
571
+ facet: false,
572
+ name: 'selectedForClearance',
573
+ type: 'string',
574
+ },
575
+ {
576
+ facet: true,
577
+ name: 'color',
578
+ type: 'string',
579
+ },
580
+ {
581
+ facet: false,
582
+ name: 'description',
583
+ type: 'string',
584
+ },
585
+ {
586
+ facet: false,
587
+ optional: true,
588
+ name: 'discountType',
589
+ type: 'string',
590
+ },
591
+ {
592
+ facet: false,
593
+ optional: true,
594
+ name: 'discountValue',
595
+ type: 'string',
596
+ },
597
+ {
598
+ facet: false,
599
+ name: 'id',
600
+ type: 'string',
601
+ },
602
+ {
603
+ facet: false,
604
+ name: 'documentId',
605
+ type: 'string',
606
+ },
607
+ {
608
+ facet: false,
609
+ name: 'shopifyId',
610
+ type: 'string',
611
+ },
612
+ {
613
+ facet: true,
614
+ name: 'gender',
615
+ type: 'string',
616
+ },
617
+ {
618
+ facet: false,
619
+ optional: true,
620
+ name: 'handle',
621
+ type: 'string',
622
+ },
623
+ {
624
+ facet: false,
625
+ name: 'imageUrls',
626
+ type: 'string[]',
627
+ },
628
+ {
629
+ facet: false,
630
+ name: 'sellRequestImageUrls',
631
+ type: 'string[]',
632
+ },
633
+ {
634
+ facet: false,
635
+ optional: true,
636
+ name: 'notesForProductionTeam',
637
+ type: 'string',
638
+ },
639
+ {
640
+ facet: false,
641
+ optional: true,
642
+ name: 'nextAvailableSeason',
643
+ type: 'string',
644
+ },
645
+ {
646
+ facet: false,
647
+ optional: true,
648
+ name: 'reservedBy',
649
+ type: 'string[]',
650
+ },
651
+ {
652
+ facet: true,
653
+ optional: true,
654
+ name: 'inventoryLocations.ids',
655
+ type: 'string[]',
656
+ },
657
+ {
658
+ facet: true,
659
+ optional: true,
660
+ name: 'inventoryLocations..*.availableAmount',
661
+ type: 'int32',
662
+ },
663
+ {
664
+ facet: true,
665
+ optional: true,
666
+ name: 'inventoryLocations..*.incomingAmount',
667
+ type: 'int32',
668
+ },
669
+ {
670
+ facet: true,
671
+ optional: true,
672
+ name: 'materialComposition.names',
673
+ type: 'string[]',
674
+ },
675
+ {
676
+ facet: true,
677
+ optional: true,
678
+ name: 'materialComposition..*.value',
679
+ type: 'int32',
680
+ },
681
+ ],
682
+ name,
683
+ };
684
+ }
327
685
  materialCompTagsArrayForShopify() {
328
686
  return Object.keys(this.filterAttributes.materialComposition).reduce((acc, cur, idx) => {
329
687
  acc.push(`${cur} ${Object.values(this.filterAttributes.materialComposition)[idx]}`);
@@ -365,5 +723,41 @@ class Product extends Base_1.default {
365
723
  }
366
724
  return materialObj;
367
725
  }
726
+ sanitizeMaterialComp() {
727
+ let materialComp = this.filterAttributes.materialComposition;
728
+ if (materialComp && Array.isArray(materialComp)) {
729
+ materialComp = materialComp.reduce((acc, cur) => {
730
+ const camelKey = this.utilities.camelCase(cur);
731
+ acc[camelKey] = 100;
732
+ return acc;
733
+ }, {});
734
+ }
735
+ if (typeof materialComp !== 'object') {
736
+ materialComp = {};
737
+ }
738
+ if (materialComp && Object.keys(materialComp).length > 0) {
739
+ const mcKeys = Object.keys(materialComp);
740
+ const mcValues = Object.values(materialComp);
741
+ materialComp = mcKeys.reduce((acc, curr, ind) => {
742
+ if (curr.charCodeAt(0) >= 65 && curr.charCodeAt(0) <= 90) {
743
+ return acc;
744
+ }
745
+ const camelKey = this.utilities.camelCase(curr);
746
+ acc[camelKey] = Number(mcValues[ind]);
747
+ return acc;
748
+ }, {});
749
+ }
750
+ return materialComp;
751
+ }
752
+ sanitizeCommission() {
753
+ const com = this.consignmentAttributes.reRobeCommission;
754
+ if (Number.isNaN(parseFloat(String(com)))) {
755
+ return 0.5;
756
+ }
757
+ if (parseFloat(String(com)) <= 1) {
758
+ return parseFloat(String(com));
759
+ }
760
+ return parseFloat(String(com)) / 100;
761
+ }
368
762
  }
369
763
  exports.default = Product;
@@ -72,6 +72,8 @@ declare type ProductConsignmentAttributes = {
72
72
  inventoryLocations: InventoryLocation[];
73
73
  };
74
74
  declare type ProductTimestampAttributes = {
75
+ createdAtTimestamp: number | null;
76
+ updatedAtTimestamp: number | null;
75
77
  sellRequestReviewTimestamp: number | null;
76
78
  sellRequestReviewDraftTimestamp: number | null;
77
79
  rejectedTimestamp: number | null;
@@ -229,3 +231,67 @@ declare type InventoryLocation = {
229
231
  incomingAmount: number;
230
232
  availableAmount: number;
231
233
  };
234
+ declare type TypesenseProductObj = {
235
+ brand: string;
236
+ clothingSize: string[];
237
+ jeanSize: string;
238
+ shoeSize: string;
239
+ condition: string;
240
+ featuredCollections: string[];
241
+ isOnSale: string;
242
+ merchants: string[];
243
+ price: number;
244
+ suggestedResalePrice: number;
245
+ salePrice: number;
246
+ compareAtPrice: number;
247
+ costPerItem: number;
248
+ priceRange: string;
249
+ productCategory: string;
250
+ productType: string;
251
+ productStyle: string[];
252
+ reRobeCommission: number;
253
+ rfidTag: string;
254
+ salesChannel: string[];
255
+ status: string;
256
+ tags: string[];
257
+ title: string;
258
+ vendorName: string;
259
+ vendorId: string;
260
+ createdAtTimestamp: number;
261
+ updatedAtTimestamp: number;
262
+ sellRequestReviewTimestamp: number;
263
+ sellRequestReviewDraftTimestamp: number;
264
+ rejectedTimestamp: number;
265
+ holdTimestamp: number;
266
+ acceptedTimestamp: number;
267
+ sellerToDropOffTimestamp: number;
268
+ sellerToShipTimestamp: number;
269
+ sellerToGetPickUpTimestamp: number;
270
+ qualityControlTimestamp: number;
271
+ pendingPublicationTimestamp: number;
272
+ listedTimestamp: number;
273
+ clearanceTimestamp: number;
274
+ reservedTimestamp: number;
275
+ soldTimestamp: number;
276
+ returnedTimestamp: number;
277
+ soldSellerToBePaidTimestamp: number;
278
+ soldSellerPaidTimestamp: number;
279
+ sellerSelfRejectTimestamp: number;
280
+ liquidationRequestedTimestamp: number;
281
+ sellerLiquidatedTimestamp: number;
282
+ availableForSale: boolean;
283
+ color: string;
284
+ description: string;
285
+ discountType: string;
286
+ discountValue: number;
287
+ id: string;
288
+ documentId: string;
289
+ gender: string;
290
+ handle: string;
291
+ imageUrls: string[];
292
+ sellRequestImageUrls: string[];
293
+ reservedBy: string[];
294
+ 'inventoryLocations.ids': string[];
295
+ 'materialComposition.names': string[];
296
+ [key: string]: any;
297
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.84",
3
+ "version": "2.4.88",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",