rerobe-js-orm 2.4.98 → 2.5.1
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/Order/OrderFromFormState.js +10 -9
- package/lib/form-states/Product/ProductFormState.js +1 -1
- package/lib/helpers/ReRobeProductHelpers.js +4 -1
- package/lib/models/Order.d.ts +1 -0
- package/lib/models/Order.js +2 -0
- package/lib/models/Product.js +9 -4
- package/lib/types/merchant-types.d.ts +4 -0
- package/lib/types/rerobe-order-types.d.ts +8 -0
- package/lib/types/rerobe-product-types.d.ts +1 -0
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ const OrderFactory_1 = require("./OrderFactory");
|
|
|
4
4
|
const Order_1 = require("../../models/Order");
|
|
5
5
|
class OrderFromFormState extends OrderFactory_1.default {
|
|
6
6
|
createOrder(fs) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
8
8
|
const currencyCode = fs.fields.currencyCode.inputValue || 'SEK';
|
|
9
9
|
const customer = fs.fields.customer.selectedValue || {};
|
|
10
10
|
const firstName = fs.fields.firstName.inputValue;
|
|
@@ -22,9 +22,10 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
22
22
|
currencyCode: fs.fields.currencyCode.inputValue,
|
|
23
23
|
statusUrl: ((_h = fs.props) === null || _h === void 0 ? void 0 : _h.statusUrl) || '',
|
|
24
24
|
processedAt: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.processedAt) || new Date().toUTCString(),
|
|
25
|
+
fulfillmentLocations: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.fulfillmentLocations) || [],
|
|
25
26
|
financialStatus: fs.fields.financialStatus.selectedValue,
|
|
26
27
|
fulfillmentStatus: fs.fields.fulfillmentStatus.selectedValue,
|
|
27
|
-
fulfillments: ((
|
|
28
|
+
fulfillments: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.fulfillments) || [],
|
|
28
29
|
shippingAddress: fs.fields.shippingAddress.selectedValue || {
|
|
29
30
|
id: '',
|
|
30
31
|
address1: '',
|
|
@@ -35,7 +36,7 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
35
36
|
province: '',
|
|
36
37
|
zip: '',
|
|
37
38
|
},
|
|
38
|
-
shippingDiscountAllocations: ((
|
|
39
|
+
shippingDiscountAllocations: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.shippingDiscountAllocations) || [],
|
|
39
40
|
shippingLine: fs.fields.shippingLine
|
|
40
41
|
? fs.fields.shippingLine.selectedValue
|
|
41
42
|
: {
|
|
@@ -56,9 +57,9 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
56
57
|
originalTotalPrice: { amount: fs.fields.originalTotalPrice.inputValue || 0, currencyCode },
|
|
57
58
|
lineItems: fs.fields.lineItems.selectedValues || [],
|
|
58
59
|
cancelReason: fs.fields.cancelReason.selectedValue || '',
|
|
59
|
-
canceledAt: ((
|
|
60
|
-
customerUrl: ((
|
|
61
|
-
discountApplications: ((
|
|
60
|
+
canceledAt: ((_o = fs.props) === null || _o === void 0 ? void 0 : _o.canceledAt) || '',
|
|
61
|
+
customerUrl: ((_p = fs.props) === null || _p === void 0 ? void 0 : _p.customerUrl) || '',
|
|
62
|
+
discountApplications: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.discountApplications) || [],
|
|
62
63
|
physicalLocation: fs.fields.physicalLocation.selectedValue || {
|
|
63
64
|
id: '',
|
|
64
65
|
activatable: true,
|
|
@@ -77,7 +78,7 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
77
78
|
},
|
|
78
79
|
notes: fs.fields.notes.inputValue || '',
|
|
79
80
|
userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || '',
|
|
80
|
-
customerName: ((
|
|
81
|
+
customerName: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.customerName) ||
|
|
81
82
|
(customer.displayName ? customer.displayName : '') ||
|
|
82
83
|
(customer.firstName && customer.lastName ? `${customer.firstName} ${customer.lastName}` : '') ||
|
|
83
84
|
(firstName && lastName ? `${firstName} ${lastName}` : ''),
|
|
@@ -85,9 +86,9 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
85
86
|
phone: (customer === null || customer === void 0 ? void 0 : customer.phone) || fs.fields.phone.inputValue || '',
|
|
86
87
|
paymentMethod: fs.fields.paymentMethod.selectedValue || '',
|
|
87
88
|
paymentDetails: fs.fields.paymentDetails.selectedValue || {},
|
|
88
|
-
merchantId: ((
|
|
89
|
+
merchantId: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.merchantId) || '',
|
|
89
90
|
tags: fs.fields.tags.selectedValues || [],
|
|
90
|
-
refunds: ((
|
|
91
|
+
refunds: ((_t = fs.props) === null || _t === void 0 ? void 0 : _t.refunds) || [],
|
|
91
92
|
};
|
|
92
93
|
return new Order_1.default(Object.assign({}, orderAttributes));
|
|
93
94
|
}
|
|
@@ -86,7 +86,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
86
86
|
return productFactory.createProduct(this);
|
|
87
87
|
}
|
|
88
88
|
priceInputChangeHandler(value) {
|
|
89
|
-
const priceValAsValNumberString = Number(value) > 0 ? String(value) : '
|
|
89
|
+
const priceValAsValNumberString = Number(value) > 0 ? String(value) : '';
|
|
90
90
|
// Mutate price inputValue and valid prop
|
|
91
91
|
this.fields.price.inputValue = priceValAsValNumberString;
|
|
92
92
|
this.fields.price.valid = Number(value) > 0;
|
|
@@ -226,7 +226,7 @@ class ReRobeProductHelpers {
|
|
|
226
226
|
static createTimestampsForStates(productObj) {
|
|
227
227
|
const docFieldsToUpdate = {};
|
|
228
228
|
if (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;
|
|
229
|
+
const { status, sellRequestReviewDraftTimestamp, sellRequestReviewTimestamp, rejectedTimestamp, holdTimestamp, acceptedTimestamp, sellerToDropOffTimestamp, sellerToShipTimestamp, sellerToGetPickUpTimestamp, qualityControlTimestamp, pendingPublicationTimestamp, listedTimestamp, clearanceTimestamp, reservedTimestamp, soldTimestamp, soldSellerToBePaidTimestamp, soldSellerPaidTimestamp, returnedTimestamp, sellerSelfRejectTimestamp, liquidationRequestedTimestamp, sellerLiquidatedTimestamp, archivedTimestamp, } = productObj;
|
|
230
230
|
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReviewDraft && !sellRequestReviewDraftTimestamp) {
|
|
231
231
|
docFieldsToUpdate.sellRequestReviewDraftTimestamp = new Date().getTime();
|
|
232
232
|
}
|
|
@@ -298,6 +298,9 @@ class ReRobeProductHelpers {
|
|
|
298
298
|
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerLiquidated && !sellerLiquidatedTimestamp) {
|
|
299
299
|
docFieldsToUpdate.sellerLiquidatedTimestamp = new Date().getTime();
|
|
300
300
|
}
|
|
301
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.archived && !archivedTimestamp) {
|
|
302
|
+
docFieldsToUpdate.archivedTimestamp = new Date().getTime();
|
|
303
|
+
}
|
|
301
304
|
}
|
|
302
305
|
return docFieldsToUpdate;
|
|
303
306
|
}
|
package/lib/models/Order.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export default class Order extends Base {
|
|
|
45
45
|
currencyCode: string;
|
|
46
46
|
statusUrl: string;
|
|
47
47
|
processedAt: string;
|
|
48
|
+
fulfillmentLocations: FulfillmentLocationItem[];
|
|
48
49
|
financialStatus: FinancialStatusTypes | string;
|
|
49
50
|
fulfillmentStatus: FulfillmentStatusTypes | string;
|
|
50
51
|
fulfillments: FulfillmentAdmin[];
|
package/lib/models/Order.js
CHANGED
|
@@ -17,6 +17,7 @@ class Order extends Base_1.default {
|
|
|
17
17
|
this.financialStatus = (props === null || props === void 0 ? void 0 : props.financialStatus)
|
|
18
18
|
? props === null || props === void 0 ? void 0 : props.financialStatus.toUpperCase()
|
|
19
19
|
: Order.FINANCIAL_TYPES.pending;
|
|
20
|
+
this.fulfillmentLocations = (props === null || props === void 0 ? void 0 : props.fulfillmentLocations) || [];
|
|
20
21
|
this.fulfillmentStatus = (props === null || props === void 0 ? void 0 : props.fulfillmentStatus)
|
|
21
22
|
? props === null || props === void 0 ? void 0 : props.fulfillmentStatus.toUpperCase()
|
|
22
23
|
: Order.FULFILLMENT_TYPES.unfulfilled;
|
|
@@ -116,6 +117,7 @@ class Order extends Base_1.default {
|
|
|
116
117
|
processedAt: this.processedAt,
|
|
117
118
|
statusUrl: this.statusUrl,
|
|
118
119
|
financialStatus: this.financialStatus,
|
|
120
|
+
fulfillmentLocations: this.fulfillmentLocations,
|
|
119
121
|
fulfillmentStatus: this.fulfillmentStatus,
|
|
120
122
|
fulfillments: this.fulfillments,
|
|
121
123
|
salesChannel: this.salesChannel,
|
package/lib/models/Product.js
CHANGED
|
@@ -113,6 +113,7 @@ class Product extends Base_1.default {
|
|
|
113
113
|
? Number(props === null || props === void 0 ? void 0 : props.liquidationRequestedTimestamp)
|
|
114
114
|
: null,
|
|
115
115
|
sellerLiquidatedTimestamp: (props === null || props === void 0 ? void 0 : props.sellerLiquidatedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerLiquidatedTimestamp) : null,
|
|
116
|
+
archivedTimestamp: (props === null || props === void 0 ? void 0 : props.archivedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.archivedTimestamp) : null,
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
119
|
toPartialObj() {
|
|
@@ -277,6 +278,7 @@ class Product extends Base_1.default {
|
|
|
277
278
|
sellerSelfRejectTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerSelfRejectTimestamp),
|
|
278
279
|
liquidationRequestedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.liquidationRequestedTimestamp),
|
|
279
280
|
sellerLiquidatedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerLiquidatedTimestamp),
|
|
281
|
+
archivedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.archivedTimestamp),
|
|
280
282
|
selectedForClearance: this.utilities.sanitizeString(this.consignmentAttributes.selectedForClearance),
|
|
281
283
|
availableForSale: !!this.attributes.availableForSale,
|
|
282
284
|
color: this.utilities.sanitizeString(this.filterAttributes.color),
|
|
@@ -350,6 +352,9 @@ class Product extends Base_1.default {
|
|
|
350
352
|
if (productType === 'Suit Jacket' || productType === 'Shirts & Blouses' || productType === 'Outerwear') {
|
|
351
353
|
productType = '';
|
|
352
354
|
}
|
|
355
|
+
if (['Blazers', 'Dresses', 'Jumpsuits', 'Skirts', 'Tops'].includes(productType)) {
|
|
356
|
+
productType = productType.substring(0, productType.length - 1);
|
|
357
|
+
}
|
|
353
358
|
let result;
|
|
354
359
|
if (brand.includes('Vintage')) {
|
|
355
360
|
if (productType !== '') {
|
|
@@ -407,7 +412,7 @@ class Product extends Base_1.default {
|
|
|
407
412
|
return acc;
|
|
408
413
|
}, '');
|
|
409
414
|
}
|
|
410
|
-
generateSchemaForTypesense(name = '
|
|
415
|
+
generateSchemaForTypesense(name = 'prod_products_20220503') {
|
|
411
416
|
return {
|
|
412
417
|
default_sorting_field: 'createdAtTimestamp',
|
|
413
418
|
fields: [
|
|
@@ -547,18 +552,18 @@ class Product extends Base_1.default {
|
|
|
547
552
|
type: 'string',
|
|
548
553
|
},
|
|
549
554
|
{
|
|
550
|
-
facet:
|
|
555
|
+
facet: true,
|
|
551
556
|
optional: true,
|
|
552
557
|
name: '.*Timestamp',
|
|
553
558
|
type: 'int32',
|
|
554
559
|
},
|
|
555
560
|
{
|
|
556
|
-
facet:
|
|
561
|
+
facet: true,
|
|
557
562
|
name: 'createdAtTimestamp',
|
|
558
563
|
type: 'int32',
|
|
559
564
|
},
|
|
560
565
|
{
|
|
561
|
-
facet:
|
|
566
|
+
facet: true,
|
|
562
567
|
name: 'updatedAtTimestamp',
|
|
563
568
|
type: 'int32',
|
|
564
569
|
},
|
|
@@ -26,6 +26,7 @@ declare type ReRobeOrderObj = {
|
|
|
26
26
|
discountApplications?: DiscountApplication[];
|
|
27
27
|
statusUrl?: string;
|
|
28
28
|
processedAt?: string;
|
|
29
|
+
fulfillmentLocations?: FulfillmentLocationItem[];
|
|
29
30
|
financialStatus?: FinancialStatusTypes | string;
|
|
30
31
|
fulfillmentStatus?: FulfillmentStatusTypes | string;
|
|
31
32
|
fulfillments?: FulfillmentAdmin[];
|
|
@@ -336,6 +337,12 @@ declare type OrderLocation = {
|
|
|
336
337
|
name?: string;
|
|
337
338
|
shipsInventory?: boolean;
|
|
338
339
|
};
|
|
340
|
+
declare type FulfillmentLocationItem = {
|
|
341
|
+
location: LocationInput;
|
|
342
|
+
productsIds: string[];
|
|
343
|
+
shippingRateName?: string;
|
|
344
|
+
shippingPrice?: string | number;
|
|
345
|
+
};
|
|
339
346
|
declare type Fulfillment = {
|
|
340
347
|
fulfillmentLineItems: FulfillmentLineItemConnection;
|
|
341
348
|
trackingCompany: string;
|
|
@@ -619,6 +626,7 @@ declare type CompleteRefund = OrderRefund & {
|
|
|
619
626
|
};
|
|
620
627
|
declare type OrderAttributesFormFields = {
|
|
621
628
|
currencyCode: TextInputFormField<string>;
|
|
629
|
+
fulfillmentLocations: MultiSelectFormField<FulfillmentLocationItem>;
|
|
622
630
|
financialStatus: SingleSelectFormField<FinancialStatusTypes>;
|
|
623
631
|
fulfillmentStatus: SingleSelectFormField<FulfillmentStatusTypes>;
|
|
624
632
|
fulfillments: MultiSelectFormField<FulfillmentAdmin>;
|
|
@@ -94,6 +94,7 @@ declare type ProductTimestampAttributes = {
|
|
|
94
94
|
sellerSelfRejectTimestamp: number | null;
|
|
95
95
|
liquidationRequestedTimestamp: number | null;
|
|
96
96
|
sellerLiquidatedTimestamp: number | null;
|
|
97
|
+
archivedTimestamp: number | null;
|
|
97
98
|
};
|
|
98
99
|
declare type TranslatableAttributes = {
|
|
99
100
|
description: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rerobe-js-orm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "ReRobe's Javascript ORM Framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
12
12
|
"lint": "tslint -p tsconfig.json",
|
|
13
|
-
"prepare": "npm run build",
|
|
13
|
+
"prepare": "npm run clean && npm run build && npm run test",
|
|
14
14
|
"prepublishOnly": "npm test && npm run lint",
|
|
15
15
|
"preversion": "npm run lint",
|
|
16
16
|
"version": "npm run format && git add -A src",
|