rerobe-js-orm 2.4.99 → 2.5.2

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
  }
@@ -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, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
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, _12, _13, _14;
8
8
  const productAttributes = {
9
9
  availableForSale: props.fields.availableForSale.selectedValue,
10
10
  description: props.fields.description.inputValue,
@@ -101,6 +101,7 @@ class ProductFromFormState extends ProductFactory_1.default {
101
101
  sellerSelfRejectTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerSelfRejectTimestamp,
102
102
  liquidationRequestedTimestamp: (_12 = props.props) === null || _12 === void 0 ? void 0 : _12.liquidationRequestedTimestamp,
103
103
  sellerLiquidatedTimestamp: (_13 = props.props) === null || _13 === void 0 ? void 0 : _13.sellerLiquidatedTimestamp,
104
+ archivedTimestamp: (_14 = props.props) === null || _14 === void 0 ? void 0 : _14.archivedTimestamp,
104
105
  };
105
106
  return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
106
107
  }
@@ -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
  }
@@ -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,
@@ -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),
@@ -410,7 +412,7 @@ class Product extends Base_1.default {
410
412
  return acc;
411
413
  }, '');
412
414
  }
413
- generateSchemaForTypesense(name = 'prod_products_20210108') {
415
+ generateSchemaForTypesense(name = 'prod_products_20220503') {
414
416
  return {
415
417
  default_sorting_field: 'createdAtTimestamp',
416
418
  fields: [
@@ -550,18 +552,18 @@ class Product extends Base_1.default {
550
552
  type: 'string',
551
553
  },
552
554
  {
553
- facet: false,
555
+ facet: true,
554
556
  optional: true,
555
557
  name: '.*Timestamp',
556
558
  type: 'int32',
557
559
  },
558
560
  {
559
- facet: false,
561
+ facet: true,
560
562
  name: 'createdAtTimestamp',
561
563
  type: 'int32',
562
564
  },
563
565
  {
564
- facet: false,
566
+ facet: true,
565
567
  name: 'updatedAtTimestamp',
566
568
  type: 'int32',
567
569
  },
@@ -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>;
@@ -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;
@@ -279,6 +280,7 @@ declare type TypesenseProductObj = {
279
280
  sellerSelfRejectTimestamp: number;
280
281
  liquidationRequestedTimestamp: number;
281
282
  sellerLiquidatedTimestamp: number;
283
+ archivedTimestamp: number;
282
284
  availableForSale: boolean;
283
285
  color: string;
284
286
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.99",
3
+ "version": "2.5.2",
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",