rerobe-js-orm 4.1.8 → 4.1.9

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.
@@ -271,3 +271,7 @@ export namespace MEASUREMENT_FIELDS_DICT {
271
271
  const handDrop: string;
272
272
  const shoulderDrop: string;
273
273
  }
274
+ export namespace PUBLISH_TYPE {
275
+ const USER_PUBLISHED: string;
276
+ const MERCHANT_PUBLISHED: string;
277
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_SIMPLIFIED_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
3
+ exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_SIMPLIFIED_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
4
4
  exports.SELLER_DRIVEN_STATES = {
5
5
  archived: 'ARCHIVED',
6
6
  sellerDonated: 'SELLER_DONATED',
@@ -184,3 +184,7 @@ exports.MEASUREMENT_FIELDS_DICT = {
184
184
  handDrop: 'Hand Drop',
185
185
  shoulderDrop: 'Shoulder Drop',
186
186
  };
187
+ exports.PUBLISH_TYPE = {
188
+ USER_PUBLISHED: 'USER_PUBLISHED',
189
+ MERCHANT_PUBLISHED: 'MERCHANT_PUBLISHED',
190
+ };
@@ -18,14 +18,14 @@ const availableForSaleOptions = [
18
18
  exports.availableForSaleOptions = availableForSaleOptions;
19
19
  const publishTypeOptions = [
20
20
  {
21
- label: 'USER_PUBLISHED',
21
+ label: product_constants_1.PUBLISH_TYPE.USER_PUBLISHED,
22
22
  description: 'Select this option if item originated from self-service.',
23
- value: 'USER_PUBLISHED',
23
+ value: product_constants_1.PUBLISH_TYPE.USER_PUBLISHED,
24
24
  },
25
25
  {
26
- label: 'REROBE_PUBLISHED',
26
+ label: product_constants_1.PUBLISH_TYPE.MERCHANT_PUBLISHED,
27
27
  description: 'Select this option if item originated from concierge or drop-off.',
28
- value: 'REROBE_PUBLISHED',
28
+ value: product_constants_1.PUBLISH_TYPE.MERCHANT_PUBLISHED,
29
29
  },
30
30
  ];
31
31
  exports.publishTypeOptions = publishTypeOptions;
@@ -66,6 +66,7 @@ class OrderHelpers {
66
66
  return null;
67
67
  }
68
68
  buildLineItemFromProduct(product, currencyCode, quantity = 1, taxProps = {}) {
69
+ var _a;
69
70
  const q = quantity || 1;
70
71
  const getImgSrc = () => {
71
72
  if (product.imageUrls && !!product.imageUrls.length) {
@@ -108,7 +109,7 @@ class OrderHelpers {
108
109
  fromCountry: (taxProps === null || taxProps === void 0 ? void 0 : taxProps.fromCountry) || '',
109
110
  toCountry: (taxProps === null || taxProps === void 0 ? void 0 : taxProps.toCountry) || '',
110
111
  discountedPrice: {
111
- amount: Number(Number((taxProps === null || taxProps === void 0 ? void 0 : taxProps.discountedPrice) || product.price).toFixed(2)),
112
+ amount: Number(Number((_a = taxProps === null || taxProps === void 0 ? void 0 : taxProps.discountedPrice) !== null && _a !== void 0 ? _a : product.price).toFixed(2)),
112
113
  currencyCode,
113
114
  },
114
115
  taxAmountWithDiscount: {
@@ -30,4 +30,5 @@ export default class ReRobeProductHelpers {
30
30
  static buildLineItem(productObj: CompleteProduct, quantity?: number): ProductLineItem;
31
31
  static productStatusPretty(status: string): any;
32
32
  static convertToGoogleMerchantCenterProduct(productObj: CompleteProduct, merchantObj: MerchantObj): GoogleMerchantCenterProductObj;
33
+ static convertToMetaCommerceProduct(productObj: CompleteProduct, merchantObj: MerchantObj): MetaCommerceProductObj;
33
34
  }
@@ -629,16 +629,6 @@ class ReRobeProductHelpers {
629
629
  return 'out of stock';
630
630
  }
631
631
  };
632
- const conditionMapper = (condition) => {
633
- if (!condition)
634
- return 'used';
635
- try {
636
- return condition.toLowerCase().includes('new') ? 'new' : 'used';
637
- }
638
- catch (error) {
639
- return 'used';
640
- }
641
- };
642
632
  const ageGroupMapper = (ageGroup) => {
643
633
  if (!ageGroup)
644
634
  return 'adult';
@@ -697,15 +687,92 @@ class ReRobeProductHelpers {
697
687
  : undefined,
698
688
  sale_price: isOnSale ? `${Number(productObj.salePrice).toFixed(2)} ${currency}` : undefined,
699
689
  brand: productObj.brand || 'Unknown',
700
- condition: conditionMapper(productObj.condition),
690
+ condition: 'used',
701
691
  availability: availabilityMapper(productObj.status),
702
692
  gender: genderMapper(productObj.gender),
703
693
  age_group: ageGroupMapper(productObj.primaryAgeCategory),
704
694
  color: productObj.color || 'various',
705
- size: productObj.standardSize || 'unknown',
695
+ size: productObj.standardSize || productObj.size || 'unknown',
706
696
  material: this.materialCompJoinedString(productObj.materialComposition),
707
697
  identifier_exists: 'no',
708
698
  };
709
699
  }
700
+ static convertToMetaCommerceProduct(productObj, merchantObj) {
701
+ const { primaryDomain, currency } = merchantObj;
702
+ const availabilityMapper = (status) => {
703
+ if (!status)
704
+ return 'out of stock';
705
+ try {
706
+ if ([product_constants_1.PRODUCT_STATES.listed, product_constants_1.PRODUCT_STATES.clearance, product_constants_1.PRODUCT_STATES.availableInStore].includes(status)) {
707
+ return 'in stock';
708
+ }
709
+ return 'out of stock';
710
+ }
711
+ catch (error) {
712
+ return 'out of stock';
713
+ }
714
+ };
715
+ const genderMapper = (gender) => {
716
+ if (!gender)
717
+ return 'unisex';
718
+ try {
719
+ if (gender.toLowerCase().includes('men') ||
720
+ gender.toLowerCase().includes('male') ||
721
+ gender.toLowerCase().includes('herr') ||
722
+ gender.toLowerCase().includes('man'))
723
+ return 'male';
724
+ if (gender.toLowerCase().includes('women') ||
725
+ gender.toLowerCase().includes('female') ||
726
+ gender.toLowerCase().includes('dam') ||
727
+ gender.toLowerCase().includes('woman') ||
728
+ gender.toLowerCase().includes('kvinna'))
729
+ return 'female';
730
+ return 'unisex';
731
+ }
732
+ catch (error) {
733
+ return 'unisex';
734
+ }
735
+ };
736
+ const ageGroupMapper = (ageGroup) => {
737
+ if (!ageGroup)
738
+ return 'adult';
739
+ try {
740
+ const ageGroupLower = ageGroup.toLowerCase();
741
+ if (ageGroupLower.includes('newborn'))
742
+ return 'newborn';
743
+ if (ageGroupLower.includes('infant'))
744
+ return 'infant';
745
+ if (ageGroupLower.includes('toddler'))
746
+ return 'toddler';
747
+ if (ageGroupLower.includes('kids'))
748
+ return 'kids';
749
+ return 'adult';
750
+ }
751
+ catch (error) {
752
+ return 'adult';
753
+ }
754
+ };
755
+ const isOnSale = productObj.status === product_constants_1.PRODUCT_STATES.clearance &&
756
+ productObj.isOnSale === 'yes' &&
757
+ productObj.salePrice &&
758
+ productObj.clearanceTimestamp;
759
+ return {
760
+ id: productObj.documentId,
761
+ title: productObj.metaDataTitle || productObj.title,
762
+ description: productObj.description || '',
763
+ availability: availabilityMapper(productObj.status),
764
+ condition: 'used',
765
+ price: `${Number(productObj.price).toFixed(2)} ${currency}`,
766
+ link: `${primaryDomain}/products/${productObj.handle}`,
767
+ image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
768
+ sale_price: isOnSale ? `${Number(productObj.salePrice).toFixed(2)} ${currency}` : undefined,
769
+ brand: productObj.brand || 'Unknown',
770
+ color: productObj.color || 'various',
771
+ gender: genderMapper(productObj.gender),
772
+ size: productObj.standardSize || productObj.size || 'unknown',
773
+ material: this.materialCompJoinedString(productObj.materialComposition),
774
+ age_group: ageGroupMapper(productObj.primaryAgeCategory),
775
+ };
776
+ }
710
777
  }
711
778
  exports.default = ReRobeProductHelpers;
@@ -89,6 +89,7 @@ export default class Merchant extends Base {
89
89
  hasAutomatedPayouts?: boolean;
90
90
  hasAIQuickList?: boolean;
91
91
  hasReceiptPrinter?: boolean;
92
+ activeSubscription?: StripeSubscription;
92
93
  constructor(props?: any);
93
94
  toObj(): MerchantObj;
94
95
  toMerchantMutableData(): MerchantMutableData;
@@ -68,7 +68,7 @@ class Product extends Base_1.default {
68
68
  this.consignmentAttributes = {
69
69
  sellRequestImageUrls: (props === null || props === void 0 ? void 0 : props.sellRequestImageUrls) || [],
70
70
  sellRequestId: (props === null || props === void 0 ? void 0 : props.sellRequestId) || '',
71
- publishType: (props === null || props === void 0 ? void 0 : props.publishType) || 'USER_PUBLISHED',
71
+ publishType: (props === null || props === void 0 ? void 0 : props.publishType) || product_constants_1.PUBLISH_TYPE.USER_PUBLISHED,
72
72
  reRobeCommission: (props === null || props === void 0 ? void 0 : props.reRobeCommission) || '',
73
73
  suggestedResalePrice: (props === null || props === void 0 ? void 0 : props.suggestedResalePrice) || '',
74
74
  rejectedReason: (props === null || props === void 0 ? void 0 : props.rejectedReason) || '',
@@ -77,7 +77,7 @@ class Product extends Base_1.default {
77
77
  reviewedBy: (props === null || props === void 0 ? void 0 : props.reviewedBy) || '',
78
78
  conditionRemarks: (props === null || props === void 0 ? void 0 : props.conditionRemarks) || '',
79
79
  productRemarks: (props === null || props === void 0 ? void 0 : props.productRemarks) || '',
80
- status: (props === null || props === void 0 ? void 0 : props.status) || 'SELL_REQUEST_REVIEW',
80
+ status: (props === null || props === void 0 ? void 0 : props.status) || product_constants_1.PRODUCT_STATES.draft,
81
81
  purchasePrice: (props === null || props === void 0 ? void 0 : props.purchasePrice) || '',
82
82
  yearPurchased: (props === null || props === void 0 ? void 0 : props.yearPurchased) || '',
83
83
  salesChannel: (props === null || props === void 0 ? void 0 : props.salesChannel) || [],
@@ -102,3 +102,13 @@ interface LocationInput extends AddressInput {
102
102
  locationId?: string;
103
103
  documentId?: string;
104
104
  }
105
+ type StripeSubscription = {
106
+ id: string;
107
+ status: 'active' | 'past_due' | 'canceled' | 'unpaid' | 'trialing' | 'incomplete' | 'incomplete_expired';
108
+ currentPeriodStart: number;
109
+ currentPeriodEnd: number;
110
+ priceId: string;
111
+ productId: string;
112
+ cancelAtPeriodEnd: boolean;
113
+ canceledAt?: number;
114
+ };
@@ -145,7 +145,7 @@ type EditorAuthorization = {
145
145
  [key: string]: string[];
146
146
  };
147
147
  type ProductSellStatusKeys = 'SELL_REQUEST_REVIEW' | 'REJECTED' | 'HOLD' | 'ACCEPTED' | 'DROP_OFF_AT_REROBE' | 'SHIP_TO_REROBE' | 'AT_HOME_PICK_UP' | 'QUALITY_CONTROL' | 'LISTED' | 'SOLD' | 'RETURNED' | 'SOLD_SELLER_TO_BE_PAID' | 'SOLD_SELLER_PAID';
148
- type ProductPublishKeys = 'USER_PUBLISHED' | 'REROBE_PUBLISHED';
148
+ type ProductPublishKeys = 'USER_PUBLISHED' | 'MERCHANT_PUBLISHED';
149
149
  type ShopifyProduct = ProductAttributes & ProductFilterAttributes;
150
150
  type CompleteProduct = ProductAttributes & ProductFilterAttributes & ProductConsignmentAttributes & {
151
151
  [key: string]: any;
@@ -390,3 +390,12 @@ type GoogleMerchantCenterProductObj = {
390
390
  expiration_date?: string;
391
391
  [key: string]: any;
392
392
  };
393
+ type MetaCommerceProductObj = {
394
+ id: string;
395
+ title: string;
396
+ description: string;
397
+ link: string;
398
+ image_link: string;
399
+ price: string;
400
+ [key: string]: any;
401
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.1.8",
3
+ "version": "4.1.9",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",