rerobe-js-orm 2.4.97 → 2.5.0

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 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: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.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: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.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: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.canceledAt) || '',
60
- customerUrl: ((_o = fs.props) === null || _o === void 0 ? void 0 : _o.customerUrl) || '',
61
- discountApplications: ((_p = fs.props) === null || _p === void 0 ? void 0 : _p.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: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.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: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.merchantId) || '',
89
+ merchantId: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.merchantId) || '',
89
90
  tags: fs.fields.tags.selectedValues || [],
90
- refunds: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.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) : '0';
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;
@@ -9,7 +9,7 @@ export const publishTypeOptions: {
9
9
  value: string;
10
10
  }[];
11
11
  export const statusOptions: {
12
- label: string;
12
+ label: any;
13
13
  value: string;
14
14
  }[];
15
15
  export const clothingSizeOptions: {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.conditionTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.gender = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.clothingSizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
4
+ const ProductStateManager_1 = require("../../models/ProductStateManager");
5
+ const lodash_1 = require("lodash");
4
6
  const availableForSaleOptions = [
5
7
  {
6
8
  label: 'Zero',
@@ -27,72 +29,10 @@ const publishTypeOptions = [
27
29
  },
28
30
  ];
29
31
  exports.publishTypeOptions = publishTypeOptions;
30
- const statusOptions = [
31
- {
32
- label: 'Sell Request Review',
33
- value: 'SELL_REQUEST_REVIEW',
34
- },
35
- {
36
- label: 'Rejected',
37
- value: 'REJECTED',
38
- },
39
- {
40
- label: 'Seller Liquidated',
41
- value: 'SELLER_LIQUIDATED',
42
- },
43
- {
44
- label: 'Hold',
45
- value: 'HOLD',
46
- },
47
- {
48
- label: 'Accepted',
49
- value: 'ACCEPTED',
50
- },
51
- {
52
- label: 'To Be Dropped Off By Seller',
53
- value: 'DROP_OFF_AT_REROBE',
54
- },
55
- {
56
- label: 'To Be Shipped By Seller',
57
- value: 'SHIP_TO_REROBE',
58
- },
59
- {
60
- label: 'To Be Picked Up From Seller (At Home Pick-up)',
61
- value: 'AT_HOME_PICK_UP',
62
- },
63
- {
64
- label: 'In Quality Control',
65
- value: 'QUALITY_CONTROL',
66
- },
67
- {
68
- label: 'Pending Publication',
69
- value: 'PENDING_PUBLICATION',
70
- },
71
- {
72
- label: 'Listed For Sale',
73
- value: 'LISTED',
74
- },
75
- {
76
- label: 'Reserved',
77
- value: 'RESERVED',
78
- },
79
- {
80
- label: 'Sold (IN RETURN PERIOD)',
81
- value: 'SOLD',
82
- },
83
- {
84
- label: 'Returned',
85
- value: 'RETURNED',
86
- },
87
- {
88
- label: 'Sold (Seller To Be Paid)',
89
- value: 'SOLD_SELLER_TO_BE_PAID',
90
- },
91
- {
92
- label: 'Sold (Paid)',
93
- value: 'SOLD_SELLER_PAID',
94
- },
95
- ];
32
+ const statusOptions = Object.values(ProductStateManager_1.default.PRODUCT_STATES).map((val) => ({
33
+ label: lodash_1.startCase(lodash_1.toLower(val)),
34
+ value: val,
35
+ }));
96
36
  exports.statusOptions = statusOptions;
97
37
  const clothingSizeOptions = [
98
38
  {
@@ -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[];
@@ -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,
@@ -350,6 +350,9 @@ class Product extends Base_1.default {
350
350
  if (productType === 'Suit Jacket' || productType === 'Shirts & Blouses' || productType === 'Outerwear') {
351
351
  productType = '';
352
352
  }
353
+ if (['Blazers', 'Dresses', 'Jumpsuits', 'Skirts', 'Tops'].includes(productType)) {
354
+ productType = productType.substring(0, productType.length - 1);
355
+ }
353
356
  let result;
354
357
  if (brand.includes('Vintage')) {
355
358
  if (productType !== '') {
@@ -69,3 +69,7 @@ declare type WebhookFormFields = {
69
69
  event: SingleSelectFormField<string>;
70
70
  callBackUrl: TextInputFormField<string>;
71
71
  };
72
+ interface LocationInput extends AddressInput {
73
+ name?: string;
74
+ locationId?: string;
75
+ }
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.97",
3
+ "version": "2.5.0",
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",