rerobe-js-orm 2.4.77 → 2.4.82
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/Product/ProductFromFormState.js +24 -2
- package/lib/helpers/ReRobeProductHelpers.d.ts +3 -0
- package/lib/helpers/ReRobeProductHelpers.js +80 -0
- package/lib/models/Order.js +1 -1
- package/lib/models/Product.d.ts +1 -0
- package/lib/models/Product.js +31 -1
- package/lib/types/rerobe-product-types.d.ts +22 -0
- package/package.json +1 -1
|
@@ -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;
|
|
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;
|
|
8
8
|
const productAttributes = {
|
|
9
9
|
availableForSale: props.fields.availableForSale.selectedValue,
|
|
10
10
|
description: props.fields.description.inputValue,
|
|
@@ -77,7 +77,29 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
77
77
|
selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
|
|
78
78
|
locationIds: props.fields.locationIds.selectedValues || [],
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
const timestampAttributes = {
|
|
81
|
+
sellRequestReviewTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.sellRequestReviewTimestamp,
|
|
82
|
+
sellRequestReviewDraftTimestamp: (_t = props.props) === null || _t === void 0 ? void 0 : _t.sellRequestReviewDraftTimestamp,
|
|
83
|
+
rejectedTimestamp: (_u = props.props) === null || _u === void 0 ? void 0 : _u.rejectedTimestamp,
|
|
84
|
+
holdTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.holdTimestamp,
|
|
85
|
+
acceptedTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.acceptedTimestamp,
|
|
86
|
+
sellerToDropOffTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.sellerToDropOffTimestamp,
|
|
87
|
+
sellerToShipTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.sellerToShipTimestamp,
|
|
88
|
+
sellerToGetPickUpTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellerToGetPickUpTimestamp,
|
|
89
|
+
qualityControlTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.qualityControlTimestamp,
|
|
90
|
+
pendingPublicationTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.pendingPublicationTimestamp,
|
|
91
|
+
listedTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.listedTimestamp,
|
|
92
|
+
clearanceTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.clearanceTimestamp,
|
|
93
|
+
reservedTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.reservedTimestamp,
|
|
94
|
+
soldTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.soldTimestamp,
|
|
95
|
+
returnedTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.returnedTimestamp,
|
|
96
|
+
soldSellerToBePaidTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.soldSellerToBePaidTimestamp,
|
|
97
|
+
soldSellerPaidTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.soldSellerPaidTimestamp,
|
|
98
|
+
sellerSelfRejectTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.sellerSelfRejectTimestamp,
|
|
99
|
+
liquidationRequestedTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.liquidationRequestedTimestamp,
|
|
100
|
+
sellerLiquidatedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerLiquidatedTimestamp,
|
|
101
|
+
};
|
|
102
|
+
return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
|
|
81
103
|
}
|
|
82
104
|
}
|
|
83
105
|
exports.default = ProductFromFormState;
|
|
@@ -12,6 +12,9 @@ export default class ReRobeProductHelpers {
|
|
|
12
12
|
static prepareProductForMutation(productObj: CompleteProduct, mediaInputArr?: {
|
|
13
13
|
originalSource: string;
|
|
14
14
|
}[]): CompleteProduct;
|
|
15
|
+
static createTimestampsForStates(productObj: CompleteProduct): {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
};
|
|
15
18
|
static getSubtitle(title: string): string;
|
|
16
19
|
static sizeFinder(sizeLabel: string, sizeToMatch: string): boolean;
|
|
17
20
|
static convertReRobeSizeToStandardSize(productObj: CompleteProduct): string;
|
|
@@ -223,6 +223,86 @@ class ReRobeProductHelpers {
|
|
|
223
223
|
}
|
|
224
224
|
return productObjClone;
|
|
225
225
|
}
|
|
226
|
+
static createTimestampsForStates(productObj) {
|
|
227
|
+
const docFieldsToUpdate = {};
|
|
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;
|
|
230
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReviewDraft && !sellRequestReviewDraftTimestamp) {
|
|
231
|
+
docFieldsToUpdate.sellRequestReviewDraftTimestamp = new Date().getTime();
|
|
232
|
+
}
|
|
233
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReview && !sellRequestReviewTimestamp) {
|
|
234
|
+
docFieldsToUpdate.sellRequestReviewTimestamp = new Date().getTime();
|
|
235
|
+
}
|
|
236
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.rejected && !rejectedTimestamp) {
|
|
237
|
+
docFieldsToUpdate.rejectedTimestamp = new Date().getTime();
|
|
238
|
+
}
|
|
239
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.hold && !holdTimestamp) {
|
|
240
|
+
docFieldsToUpdate.holdTimestamp = new Date().getTime();
|
|
241
|
+
}
|
|
242
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.accepted && !acceptedTimestamp) {
|
|
243
|
+
docFieldsToUpdate.acceptedTimestamp = new Date().getTime();
|
|
244
|
+
}
|
|
245
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerToDropOff && !sellerToDropOffTimestamp) {
|
|
246
|
+
docFieldsToUpdate.sellerToDropOffTimestamp = new Date().getTime();
|
|
247
|
+
}
|
|
248
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerToShip && !sellerToShipTimestamp) {
|
|
249
|
+
docFieldsToUpdate.sellerToShipTimestamp = new Date().getTime();
|
|
250
|
+
}
|
|
251
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerToGetPickUp && !sellerToGetPickUpTimestamp) {
|
|
252
|
+
docFieldsToUpdate.sellerToGetPickUpTimestamp = new Date().getTime();
|
|
253
|
+
}
|
|
254
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.qualityControl && !qualityControlTimestamp) {
|
|
255
|
+
docFieldsToUpdate.qualityControlTimestamp = new Date().getTime();
|
|
256
|
+
}
|
|
257
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.pendingPublication && !pendingPublicationTimestamp) {
|
|
258
|
+
docFieldsToUpdate.pendingPublicationTimestamp = new Date().getTime();
|
|
259
|
+
}
|
|
260
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.listed && !listedTimestamp) {
|
|
261
|
+
docFieldsToUpdate.listedTimestamp = new Date().getTime();
|
|
262
|
+
}
|
|
263
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.clearance && !clearanceTimestamp) {
|
|
264
|
+
docFieldsToUpdate.clearanceTimestamp = new Date().getTime();
|
|
265
|
+
}
|
|
266
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.reserved && !reservedTimestamp) {
|
|
267
|
+
docFieldsToUpdate.reservedTimestamp = new Date().getTime();
|
|
268
|
+
}
|
|
269
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sold && !soldTimestamp) {
|
|
270
|
+
docFieldsToUpdate.soldTimestamp = new Date().getTime();
|
|
271
|
+
}
|
|
272
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.soldSellerToBePaid && !soldSellerToBePaidTimestamp) {
|
|
273
|
+
const timeNow = new Date().getTime();
|
|
274
|
+
docFieldsToUpdate.soldSellerToBePaidTimestamp = timeNow;
|
|
275
|
+
if (!soldTimestamp) {
|
|
276
|
+
docFieldsToUpdate.soldTimestamp =
|
|
277
|
+
dateSold && typeof dateSold === 'string' ? new Date(dateSold).getTime() : timeNow;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.soldSellerPaid && !soldSellerPaidTimestamp) {
|
|
281
|
+
const timeNow = new Date().getTime();
|
|
282
|
+
docFieldsToUpdate.soldSellerPaidTimestamp = timeNow;
|
|
283
|
+
if (!soldSellerToBePaidTimestamp) {
|
|
284
|
+
docFieldsToUpdate.soldSellerToBePaidTimestamp = timeNow;
|
|
285
|
+
}
|
|
286
|
+
if (!soldTimestamp) {
|
|
287
|
+
docFieldsToUpdate.soldTimestamp =
|
|
288
|
+
dateSold && typeof dateSold === 'string' ? new Date(dateSold).getTime() : timeNow;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.returned && !returnedTimestamp) {
|
|
292
|
+
docFieldsToUpdate.returnedTimestamp = new Date().getTime();
|
|
293
|
+
}
|
|
294
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerSelfReject && !sellerSelfRejectTimestamp) {
|
|
295
|
+
docFieldsToUpdate.sellerSelfRejectTimestamp = new Date().getTime();
|
|
296
|
+
}
|
|
297
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.liquidationRequested && !liquidationRequestedTimestamp) {
|
|
298
|
+
docFieldsToUpdate.liquidationRequestedTimestamp = new Date().getTime();
|
|
299
|
+
}
|
|
300
|
+
if (status === ProductStateManager_1.default.PRODUCT_STATES.sellerLiquidated && !sellerLiquidatedTimestamp) {
|
|
301
|
+
docFieldsToUpdate.sellerLiquidatedTimestamp = new Date().getTime();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return docFieldsToUpdate;
|
|
305
|
+
}
|
|
226
306
|
static getSubtitle(title) {
|
|
227
307
|
if (typeof title === 'string' && title.trim()) {
|
|
228
308
|
return title.split('by')[0].trim();
|
package/lib/models/Order.js
CHANGED
package/lib/models/Product.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export default class Product extends Base {
|
|
|
3
3
|
attributes: ProductAttributes;
|
|
4
4
|
filterAttributes: ProductFilterAttributes;
|
|
5
5
|
consignmentAttributes: ProductConsignmentAttributes;
|
|
6
|
+
timestampAttributes: ProductTimestampAttributes;
|
|
6
7
|
FIELD_NOT_TRANSLATABLE_KEY: string;
|
|
7
8
|
constructor(props?: any);
|
|
8
9
|
toPartialObj(): ShopifyProduct;
|
package/lib/models/Product.js
CHANGED
|
@@ -81,12 +81,42 @@ class Product extends Base_1.default {
|
|
|
81
81
|
selectedForClearance: (props === null || props === void 0 ? void 0 : props.selectedForClearance) || '',
|
|
82
82
|
locationIds: (props === null || props === void 0 ? void 0 : props.locationIds) || [],
|
|
83
83
|
};
|
|
84
|
+
this.timestampAttributes = {
|
|
85
|
+
sellRequestReviewDraftTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
|
|
86
|
+
? Number(props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
|
|
87
|
+
: null,
|
|
88
|
+
sellRequestReviewTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellRequestReviewTimestamp) : null,
|
|
89
|
+
rejectedTimestamp: (props === null || props === void 0 ? void 0 : props.rejectedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.rejectedTimestamp) : null,
|
|
90
|
+
holdTimestamp: (props === null || props === void 0 ? void 0 : props.holdTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.holdTimestamp) : null,
|
|
91
|
+
acceptedTimestamp: (props === null || props === void 0 ? void 0 : props.acceptedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.acceptedTimestamp) : null,
|
|
92
|
+
sellerToDropOffTimestamp: (props === null || props === void 0 ? void 0 : props.sellerToDropOffTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerToDropOffTimestamp) : null,
|
|
93
|
+
sellerToShipTimestamp: (props === null || props === void 0 ? void 0 : props.sellerToShipTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerToShipTimestamp) : null,
|
|
94
|
+
sellerToGetPickUpTimestamp: (props === null || props === void 0 ? void 0 : props.sellerToGetPickUpTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerToGetPickUpTimestamp) : null,
|
|
95
|
+
qualityControlTimestamp: (props === null || props === void 0 ? void 0 : props.qualityControlTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.qualityControlTimestamp) : null,
|
|
96
|
+
pendingPublicationTimestamp: (props === null || props === void 0 ? void 0 : props.pendingPublicationTimestamp)
|
|
97
|
+
? Number(props === null || props === void 0 ? void 0 : props.pendingPublicationTimestamp)
|
|
98
|
+
: null,
|
|
99
|
+
listedTimestamp: (props === null || props === void 0 ? void 0 : props.listedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.listedTimestamp) : null,
|
|
100
|
+
clearanceTimestamp: (props === null || props === void 0 ? void 0 : props.clearanceTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.clearanceTimestamp) : null,
|
|
101
|
+
reservedTimestamp: (props === null || props === void 0 ? void 0 : props.reservedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.reservedTimestamp) : null,
|
|
102
|
+
soldTimestamp: (props === null || props === void 0 ? void 0 : props.soldTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.soldTimestamp) : null,
|
|
103
|
+
returnedTimestamp: (props === null || props === void 0 ? void 0 : props.returnedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.returnedTimestamp) : null,
|
|
104
|
+
soldSellerToBePaidTimestamp: (props === null || props === void 0 ? void 0 : props.soldSellerToBePaidTimestamp)
|
|
105
|
+
? Number(props === null || props === void 0 ? void 0 : props.soldSellerToBePaidTimestamp)
|
|
106
|
+
: null,
|
|
107
|
+
soldSellerPaidTimestamp: (props === null || props === void 0 ? void 0 : props.soldSellerPaidTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.soldSellerPaidTimestamp) : null,
|
|
108
|
+
sellerSelfRejectTimestamp: (props === null || props === void 0 ? void 0 : props.sellerSelfRejectTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerSelfRejectTimestamp) : null,
|
|
109
|
+
liquidationRequestedTimestamp: (props === null || props === void 0 ? void 0 : props.liquidationRequestedTimestamp)
|
|
110
|
+
? Number(props === null || props === void 0 ? void 0 : props.liquidationRequestedTimestamp)
|
|
111
|
+
: null,
|
|
112
|
+
sellerLiquidatedTimestamp: (props === null || props === void 0 ? void 0 : props.sellerLiquidatedTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.sellerLiquidatedTimestamp) : null,
|
|
113
|
+
};
|
|
84
114
|
}
|
|
85
115
|
toPartialObj() {
|
|
86
116
|
return Object.assign(Object.assign({}, this.attributes), this.filterAttributes);
|
|
87
117
|
}
|
|
88
118
|
toObj() {
|
|
89
|
-
return Object.assign(Object.assign(Object.assign({}, this.attributes), this.filterAttributes), this.consignmentAttributes);
|
|
119
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, this.attributes), this.filterAttributes), this.consignmentAttributes), this.timestampAttributes);
|
|
90
120
|
}
|
|
91
121
|
toProductInputObjForShopify(location) {
|
|
92
122
|
const productInputObj = {
|
|
@@ -70,6 +70,28 @@ declare type ProductConsignmentAttributes = {
|
|
|
70
70
|
selectedForClearance: string;
|
|
71
71
|
locationIds?: string[];
|
|
72
72
|
};
|
|
73
|
+
declare type ProductTimestampAttributes = {
|
|
74
|
+
sellRequestReviewTimestamp: number | null;
|
|
75
|
+
sellRequestReviewDraftTimestamp: number | null;
|
|
76
|
+
rejectedTimestamp: number | null;
|
|
77
|
+
holdTimestamp: number | null;
|
|
78
|
+
acceptedTimestamp: number | null;
|
|
79
|
+
sellerToDropOffTimestamp: number | null;
|
|
80
|
+
sellerToShipTimestamp: number | null;
|
|
81
|
+
sellerToGetPickUpTimestamp: number | null;
|
|
82
|
+
qualityControlTimestamp: number | null;
|
|
83
|
+
pendingPublicationTimestamp: number | null;
|
|
84
|
+
listedTimestamp: number | null;
|
|
85
|
+
clearanceTimestamp: number | null;
|
|
86
|
+
reservedTimestamp: number | null;
|
|
87
|
+
soldTimestamp: number | null;
|
|
88
|
+
returnedTimestamp: number | null;
|
|
89
|
+
soldSellerToBePaidTimestamp: number | null;
|
|
90
|
+
soldSellerPaidTimestamp: number | null;
|
|
91
|
+
sellerSelfRejectTimestamp: number | null;
|
|
92
|
+
liquidationRequestedTimestamp: number | null;
|
|
93
|
+
sellerLiquidatedTimestamp: number | null;
|
|
94
|
+
};
|
|
73
95
|
declare type TranslatableAttributes = {
|
|
74
96
|
description: string;
|
|
75
97
|
color: string;
|