rerobe-js-orm 4.1.7 → 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.
- package/lib/constants/product-constants.d.ts +4 -0
- package/lib/constants/product-constants.js +5 -1
- package/lib/form-states/Product/options.js +4 -4
- package/lib/helpers/OrderHelpers.js +2 -1
- package/lib/helpers/ReRobeProductHelpers.d.ts +1 -0
- package/lib/helpers/ReRobeProductHelpers.js +89 -17
- package/lib/helpers/Utilities.js +1 -0
- package/lib/models/Merchant.d.ts +1 -0
- package/lib/models/Product.js +11 -7
- package/lib/types/merchant-types.d.ts +10 -0
- package/lib/types/rerobe-product-types.d.ts +11 -1
- package/package.json +1 -1
|
@@ -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:
|
|
21
|
+
label: product_constants_1.PUBLISH_TYPE.USER_PUBLISHED,
|
|
22
22
|
description: 'Select this option if item originated from self-service.',
|
|
23
|
-
value:
|
|
23
|
+
value: product_constants_1.PUBLISH_TYPE.USER_PUBLISHED,
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
label:
|
|
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:
|
|
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)
|
|
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
|
}
|
|
@@ -248,7 +248,11 @@ class ReRobeProductHelpers {
|
|
|
248
248
|
}
|
|
249
249
|
const baseTitle = parts.join(' ');
|
|
250
250
|
// For non-'Vintage' brands, append "by ${brand.trim()}"
|
|
251
|
-
const titleWithBrand = !brand.
|
|
251
|
+
const titleWithBrand = !(brand.toLowerCase().trim().includes('vintage') ||
|
|
252
|
+
brand.toLowerCase().trim().includes('unknown') ||
|
|
253
|
+
brand.toLowerCase().trim().includes('none'))
|
|
254
|
+
? `${brand.trim()} - ${baseTitle}`
|
|
255
|
+
: baseTitle;
|
|
252
256
|
// Add size to the end of the title if it's available
|
|
253
257
|
return size && size.trim() !== ''
|
|
254
258
|
? `${titleWithBrand}, Size ${standardSize ? standardSize.trim() : size.trim()}`
|
|
@@ -264,11 +268,12 @@ class ReRobeProductHelpers {
|
|
|
264
268
|
}
|
|
265
269
|
static autoCreateMetaDescription(productObj) {
|
|
266
270
|
var _a;
|
|
267
|
-
const { color, productType, productStyle, condition, size, standardSize, brand, sizeComment, materialComposition } = productObj;
|
|
271
|
+
const { color, productType, productStyle, condition, size, standardSize, brand, sizeComment, materialComposition, gender, } = productObj;
|
|
268
272
|
const materials = this.materialCompJoinedString(materialComposition);
|
|
269
273
|
const fit = ((_a = options_1.sizeCommentOptions.find((option) => option.value === sizeComment)) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
270
274
|
const joinedProductStyle = productStyle.join(', ');
|
|
271
275
|
const elements = [
|
|
276
|
+
gender && `Primary segment: ${gender}`,
|
|
272
277
|
brand && `Brand: ${brand}`,
|
|
273
278
|
size && `Size: ${standardSize ? standardSize : size}`,
|
|
274
279
|
color && `Color: ${color}`,
|
|
@@ -278,9 +283,8 @@ class ReRobeProductHelpers {
|
|
|
278
283
|
materials && `Material: ${materials}`,
|
|
279
284
|
fit && `Fit: ${fit}`,
|
|
280
285
|
].filter(Boolean); // Removes any falsey values
|
|
281
|
-
const baseDescription = elements.join(', ')
|
|
282
|
-
|
|
283
|
-
return baseDescription + ellipsis;
|
|
286
|
+
const baseDescription = elements.join(', ');
|
|
287
|
+
return baseDescription;
|
|
284
288
|
}
|
|
285
289
|
static autoCreateFullSwedishDescriptionForTraderaHTML(productDescription, merchantName = 'våra') {
|
|
286
290
|
return `
|
|
@@ -625,16 +629,6 @@ class ReRobeProductHelpers {
|
|
|
625
629
|
return 'out of stock';
|
|
626
630
|
}
|
|
627
631
|
};
|
|
628
|
-
const conditionMapper = (condition) => {
|
|
629
|
-
if (!condition)
|
|
630
|
-
return 'used';
|
|
631
|
-
try {
|
|
632
|
-
return condition.toLowerCase().includes('new') ? 'new' : 'used';
|
|
633
|
-
}
|
|
634
|
-
catch (error) {
|
|
635
|
-
return 'used';
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
632
|
const ageGroupMapper = (ageGroup) => {
|
|
639
633
|
if (!ageGroup)
|
|
640
634
|
return 'adult';
|
|
@@ -693,13 +687,91 @@ class ReRobeProductHelpers {
|
|
|
693
687
|
: undefined,
|
|
694
688
|
sale_price: isOnSale ? `${Number(productObj.salePrice).toFixed(2)} ${currency}` : undefined,
|
|
695
689
|
brand: productObj.brand || 'Unknown',
|
|
696
|
-
condition:
|
|
690
|
+
condition: 'used',
|
|
697
691
|
availability: availabilityMapper(productObj.status),
|
|
698
692
|
gender: genderMapper(productObj.gender),
|
|
699
693
|
age_group: ageGroupMapper(productObj.primaryAgeCategory),
|
|
700
694
|
color: productObj.color || 'various',
|
|
701
|
-
size: productObj.standardSize || 'unknown',
|
|
695
|
+
size: productObj.standardSize || productObj.size || 'unknown',
|
|
702
696
|
material: this.materialCompJoinedString(productObj.materialComposition),
|
|
697
|
+
identifier_exists: 'no',
|
|
698
|
+
};
|
|
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),
|
|
703
775
|
};
|
|
704
776
|
}
|
|
705
777
|
}
|
package/lib/helpers/Utilities.js
CHANGED
package/lib/models/Merchant.d.ts
CHANGED
|
@@ -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;
|
package/lib/models/Product.js
CHANGED
|
@@ -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) ||
|
|
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) ||
|
|
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) || [],
|
|
@@ -492,7 +492,11 @@ class Product extends Base_1.default {
|
|
|
492
492
|
}
|
|
493
493
|
const baseTitle = parts.join(' ');
|
|
494
494
|
// For non-'Vintage' brands, append "by ${brand.trim()}"
|
|
495
|
-
const titleWithBrand = !brand.
|
|
495
|
+
const titleWithBrand = !(brand.toLowerCase().trim().includes('vintage') ||
|
|
496
|
+
brand.toLowerCase().trim().includes('unknown') ||
|
|
497
|
+
brand.toLowerCase().trim().includes('none'))
|
|
498
|
+
? `${brand.trim()} - ${baseTitle}`
|
|
499
|
+
: baseTitle;
|
|
496
500
|
// Add size to the end of the title if it's available
|
|
497
501
|
return size && size.trim() !== ''
|
|
498
502
|
? `${titleWithBrand}, Size ${standardSize ? standardSize.trim() : size.trim()}`
|
|
@@ -600,12 +604,13 @@ class Product extends Base_1.default {
|
|
|
600
604
|
}
|
|
601
605
|
autoCreateMetaDescription() {
|
|
602
606
|
var _a;
|
|
603
|
-
const { color, productType, productStyle, condition, size, brand, standardSize } = this.filterAttributes;
|
|
607
|
+
const { color, productType, productStyle, condition, size, brand, standardSize, gender } = this.filterAttributes;
|
|
604
608
|
const { sizeComment } = this.consignmentAttributes;
|
|
605
609
|
const materials = this.materialCompJoinedString();
|
|
606
610
|
const fit = ((_a = options_1.sizeCommentOptions.find((option) => option.value === sizeComment)) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
607
611
|
const joinedProductStyle = productStyle.join(', ');
|
|
608
612
|
const elements = [
|
|
613
|
+
gender && `Primary segment: ${gender}`,
|
|
609
614
|
brand && `Brand: ${brand}`,
|
|
610
615
|
size && `Size: ${standardSize ? standardSize : size}`,
|
|
611
616
|
color && `Color: ${color}`,
|
|
@@ -615,9 +620,8 @@ class Product extends Base_1.default {
|
|
|
615
620
|
materials && `Material: ${materials}`,
|
|
616
621
|
fit && `Fit: ${fit}`,
|
|
617
622
|
].filter(Boolean); // Removes any falsey values
|
|
618
|
-
const baseDescription = elements.join(', ')
|
|
619
|
-
|
|
620
|
-
return baseDescription + ellipsis;
|
|
623
|
+
const baseDescription = elements.join(', ');
|
|
624
|
+
return baseDescription;
|
|
621
625
|
}
|
|
622
626
|
generateSchemaForTypesense(name = 'prod_products_20220503') {
|
|
623
627
|
return {
|
|
@@ -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' | '
|
|
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;
|
|
@@ -363,6 +363,7 @@ type GoogleMerchantCenterProductObj = {
|
|
|
363
363
|
color: string;
|
|
364
364
|
size: string;
|
|
365
365
|
material: string;
|
|
366
|
+
identifier_exists?: string;
|
|
366
367
|
style?: string;
|
|
367
368
|
weight?: number;
|
|
368
369
|
weight_unit?: string;
|
|
@@ -389,3 +390,12 @@ type GoogleMerchantCenterProductObj = {
|
|
|
389
390
|
expiration_date?: string;
|
|
390
391
|
[key: string]: any;
|
|
391
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
|
+
};
|