rerobe-js-orm 3.0.15 → 3.0.17

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.
@@ -20,6 +20,8 @@ class ProductFromAlgoliaJSONDoc extends ProductFactory_1.default {
20
20
  weight: String(props.grams),
21
21
  variantId: '',
22
22
  reservedBy: [],
23
+ weightRange: '',
24
+ weightUnit: 'GRAMS',
23
25
  };
24
26
  const productFilterAttributes = this.shopifyHelpers.tagsExtractor(props.named_tags);
25
27
  return new Product_1.default(Object.assign(Object.assign({}, productAttributes), productFilterAttributes));
@@ -20,6 +20,8 @@ class ProductFromFormState extends ProductFactory_1.default {
20
20
  vendorId: props.fields.vendorId.selectedValue || ((_h = props.props) === null || _h === void 0 ? void 0 : _h.vendorId) || '',
21
21
  vendorName: props.fields.vendorName.selectedValue || '',
22
22
  weight: props.fields.weight.inputValue,
23
+ weightRange: props.fields.weightRange.selectedValue || '',
24
+ weightUnit: props.fields.weightUnit.selectedValue || '',
23
25
  variantId: ((_j = props.props) === null || _j === void 0 ? void 0 : _j.variantId) || '',
24
26
  reservedBy: ((_k = props.props) === null || _k === void 0 ? void 0 : _k.reservedBy) || [],
25
27
  options: props.fields.options.selectedValue,
@@ -30,6 +32,7 @@ class ProductFromFormState extends ProductFactory_1.default {
30
32
  merchantId: ((_m = props.props) === null || _m === void 0 ? void 0 : _m.merchantId) || '',
31
33
  editorAuthorizations: props.fields.editorAuthorizations.selectedValue,
32
34
  rfidTag: props.fields.rfidTag.inputValue || '',
35
+ sku: props.fields.sku.inputValue || '',
33
36
  };
34
37
  const productFilterAttributes = {
35
38
  documentId: (_o = props.props) === null || _o === void 0 ? void 0 : _o.documentId,
@@ -20,6 +20,8 @@ class ProductFromShopifyJSClientJSONDoc extends ProductFactory_1.default {
20
20
  vendorId: props.vendor,
21
21
  variantId: this.getVariantId(props.variants),
22
22
  reservedBy: [],
23
+ weightRange: '',
24
+ weightUnit: 'GRAMS',
23
25
  };
24
26
  const productFilterAttributes = this.shopifyHelpers.tagsExtractor(props.tags);
25
27
  return new Product_1.default(Object.assign(Object.assign({}, productAttributes), productFilterAttributes));
@@ -20,6 +20,8 @@ class ProductFromShopifyWebhookJSONDoc extends ProductFactory_1.default {
20
20
  vendorId: props.vendor,
21
21
  variantId: this.getVariantId(props.variants),
22
22
  reservedBy: [],
23
+ weightRange: '',
24
+ weightUnit: 'GRAMS',
23
25
  };
24
26
  const productFilterAttributes = this.shopifyHelpers.tagsExtractor(props.tags.split(', '));
25
27
  return new Product_1.default(Object.assign(Object.assign({}, productAttributes), productFilterAttributes));
@@ -34,6 +34,10 @@ export default class ProductFormState extends FormState {
34
34
  private priceInputChangeHandler;
35
35
  private setGenderFromPassedOptions;
36
36
  private genderSelectHandler;
37
+ private geWeightArray;
38
+ private findWeightRange;
39
+ private weightRangeSelectHandler;
40
+ private weightInputChangeHandler;
37
41
  private conditionSelectHandler;
38
42
  private productCategorySelectHandler;
39
43
  private productTypeSelectHandler;
@@ -15,6 +15,8 @@ class ProductFormState extends FormState_1.default {
15
15
  this.fields.title = this.fieldFactory('textInput', 'title');
16
16
  this.fields.price = this.fieldFactory('textInput', 'price');
17
17
  this.fields.weight = this.fieldFactory('textInput', 'weight');
18
+ this.fields.weightRange = this.fieldFactory('singleSelect', 'weightRange', options_1.productWeightRanges);
19
+ this.fields.weightUnit = this.fieldFactory('singleSelect', 'weightUnit', options_1.weightUnits);
18
20
  this.fields.officialFilesToUpload = {
19
21
  selectedValues: [],
20
22
  valid: false,
@@ -69,6 +71,7 @@ class ProductFormState extends FormState_1.default {
69
71
  this.fields.vendorId = this.fieldFactory('singleSelect', 'vendorId');
70
72
  this.fields.vendorName = this.fieldFactory('singleSelect', 'vendorName');
71
73
  this.fields.rfidTag = this.fieldFactory('textInput', 'rfidTag');
74
+ this.fields.sku = this.fieldFactory('textInput', 'sku');
72
75
  this.fields.locationIds = this.fieldFactory('multiSelect', 'locationIds');
73
76
  this.fields.inventoryLocations = this.fieldFactory('multiSelect', 'inventoryLocations');
74
77
  this.fields.featuredCollections = this.fieldFactory('multiSelect', 'featuredCollections');
@@ -144,6 +147,41 @@ class ProductFormState extends FormState_1.default {
144
147
  this.fields.size.valid = false;
145
148
  this.fields.size.selectedValue = '';
146
149
  }
150
+ geWeightArray(range) {
151
+ if (!range)
152
+ return ['', ''];
153
+ if (range.endsWith('+')) {
154
+ return ['0', range.replace('+', '').trim()];
155
+ }
156
+ const [min, max] = range.split('-');
157
+ return [min.trim(), max.trim()];
158
+ }
159
+ findWeightRange(weightRanges, weight) {
160
+ for (const rangeStr of weightRanges) {
161
+ const [min, max] = this.geWeightArray(rangeStr);
162
+ if (weight >= parseFloat(min) && weight <= parseFloat(max)) {
163
+ return rangeStr;
164
+ }
165
+ }
166
+ return weightRanges[weightRanges.length - 1];
167
+ }
168
+ weightRangeSelectHandler(value) {
169
+ const [_, max] = this.geWeightArray(value);
170
+ // Mutate weightRange selectedValue and valid prop
171
+ this.fields.weightRange.selectedValue = value;
172
+ this.fields.weightRange.valid = !!value;
173
+ // Reset weight fields except options
174
+ this.fields.weight.hidden = false;
175
+ this.fields.weight.valid = !!max;
176
+ this.fields.weight.inputValue = max;
177
+ }
178
+ weightInputChangeHandler(value) {
179
+ const weightRanges = this.fields.weightRange.options.map((i) => i.value);
180
+ const matchRange = this.findWeightRange(weightRanges, parseFloat(value));
181
+ this.fields.weightRange.selectedValue = matchRange;
182
+ this.fields.weightRange.valid = !!matchRange;
183
+ this.fields.weight.inputValue = value;
184
+ }
147
185
  conditionSelectHandler(value) {
148
186
  // Mutate condition selectedValue and valid prop
149
187
  this.fields.condition.selectedValue = value;
@@ -557,6 +595,16 @@ class ProductFormState extends FormState_1.default {
557
595
  options = this.utilities.uniqObjArray([...selectedColorOptions, ...colorsOptions], 'value');
558
596
  }
559
597
  }
598
+ if (fieldKey === 'weightRange') {
599
+ onChangeHandler = (val) => this.weightRangeSelectHandler(val);
600
+ let selectedOptions = [];
601
+ if (this.props.weightRange) {
602
+ selectedOptions = [{ label: this.props.weightRange, value: this.props.weightRange }];
603
+ if (!options.map((o) => o.value).includes(this.props.weightRange)) {
604
+ options.splice(0, 0, ...selectedOptions);
605
+ }
606
+ }
607
+ }
560
608
  if (fieldKey === 'primaryAgeCategory') {
561
609
  let selectedPrimaryAgeCategoryOptions = [];
562
610
  if (this.props.primaryAgeCategory) {
@@ -689,6 +737,9 @@ class ProductFormState extends FormState_1.default {
689
737
  valid = true;
690
738
  onChangeHandler = (val) => this.discountValueChangeHandler(val);
691
739
  }
740
+ if (fieldKey === 'weight') {
741
+ onChangeHandler = (val) => this.weightInputChangeHandler(val);
742
+ }
692
743
  return {
693
744
  inputValue,
694
745
  valid,
@@ -111,6 +111,14 @@ export const unisexShoes: {
111
111
  value: string;
112
112
  styles: string[];
113
113
  }[];
114
+ export const productWeightRanges: {
115
+ label: string;
116
+ value: string;
117
+ }[];
118
+ export const weightUnits: {
119
+ label: string;
120
+ value: string;
121
+ }[];
114
122
  export const bags: {
115
123
  label: string;
116
124
  value: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = 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.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.sizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
3
+ exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.weightUnits = exports.productWeightRanges = 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.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.sizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
4
4
  const product_constants_1 = require("../../constants/product-constants");
5
5
  const lodash_1 = require("lodash");
6
6
  const availableForSaleOptions = [
@@ -1818,6 +1818,25 @@ const shoeSizes = [
1818
1818
  { label: '45.3', value: '45.3' },
1819
1819
  ];
1820
1820
  exports.shoeSizes = shoeSizes;
1821
+ const productWeightRanges = [
1822
+ '0.01 - 0.1',
1823
+ '0.01 - 0.2',
1824
+ '0.01 - 0.5',
1825
+ '0.2 - 1.0',
1826
+ '0.5 - 1.0',
1827
+ '1.0 - 2.0',
1828
+ '2.0 - 5.0',
1829
+ '5.0 - 10.0',
1830
+ '10.0 - 20.0',
1831
+ '20.0 - 50.0',
1832
+ '50.0 - 100.0',
1833
+ '100.0 - 200.0',
1834
+ '100.0+',
1835
+ '200.0+',
1836
+ ].map((i) => ({ label: i, value: i }));
1837
+ exports.productWeightRanges = productWeightRanges;
1838
+ const weightUnits = ['GRAMS', 'KILOGRAMS', 'OUNCES', 'POUNDS'].map((i) => ({ label: i, value: i }));
1839
+ exports.weightUnits = weightUnits;
1821
1840
  const clothingMaterials = [
1822
1841
  {
1823
1842
  label: 'Acetate',
@@ -25,7 +25,7 @@ class OrderHelpers {
25
25
  if (shippingLines[0].title === 'Localy delivery') {
26
26
  return Order_1.default.SHIPPING_TYPES.localDelivery;
27
27
  }
28
- return shippingLines[0].price_set.shop_money.amount > 0
28
+ return Number(shippingLines[0].price_set.shop_money.amount) > 0
29
29
  ? Order_1.default.SHIPPING_TYPES.localDelivery
30
30
  : Order_1.default.SHIPPING_TYPES.localPickUp;
31
31
  }
@@ -221,7 +221,7 @@ class OrderHelpers {
221
221
  return 0;
222
222
  }
223
223
  const subtotal = this.getSubtotalPrice(lineItems);
224
- return subtotal > userAvailableCredit ? Number(userAvailableCredit) : subtotal;
224
+ return subtotal > Number(userAvailableCredit) ? Number(userAvailableCredit) : subtotal;
225
225
  }
226
226
  getSaleDiscount(lineItems = []) {
227
227
  return lineItems.reduce((acc, cur) => {
@@ -19,6 +19,8 @@ class Product extends Base_1.default {
19
19
  updatedAt: (props === null || props === void 0 ? void 0 : props.updatedAt) || '',
20
20
  publishedAt: (props === null || props === void 0 ? void 0 : props.publishedAt) || '',
21
21
  weight: (props === null || props === void 0 ? void 0 : props.weight) || '999',
22
+ weightRange: (props === null || props === void 0 ? void 0 : props.weightRange) || '',
23
+ weightUnit: (props === null || props === void 0 ? void 0 : props.weightUnit) || 'GRAMS',
22
24
  vendorId: (props === null || props === void 0 ? void 0 : props.vendorId) || '',
23
25
  vendorName: (props === null || props === void 0 ? void 0 : props.vendorName) || '',
24
26
  variantId: (props === null || props === void 0 ? void 0 : props.variantId) || '',
@@ -31,6 +33,7 @@ class Product extends Base_1.default {
31
33
  merchantId: (props === null || props === void 0 ? void 0 : props.merchantId) || '',
32
34
  editorAuthorizations: (props === null || props === void 0 ? void 0 : props.editorAuthorizations) || {},
33
35
  rfidTag: (props === null || props === void 0 ? void 0 : props.rfidTag) || '',
36
+ sku: (props === null || props === void 0 ? void 0 : props.sku) || '',
34
37
  };
35
38
  this.filterAttributes = {
36
39
  documentId: (props === null || props === void 0 ? void 0 : props.documentId) || this.utilities.makeRandId(28),
@@ -286,12 +289,15 @@ class Product extends Base_1.default {
286
289
  productStyle: this.utilities.sanitzeStringArr(this.filterAttributes.productStyle),
287
290
  reRobeCommission: this.sanitizeCommission(),
288
291
  rfidTag: this.utilities.sanitizeString(this.attributes.rfidTag),
292
+ sku: this.utilities.sanitizeString(this.attributes.sku),
289
293
  salesChannel: this.utilities.sanitzeStringArr(this.consignmentAttributes.salesChannel),
290
294
  status: this.utilities.sanitizeString(this.consignmentAttributes.status),
291
295
  tags: this.utilities.sanitzeStringArr(this.filterAttributes.tags),
292
296
  title: this.utilities.sanitizeString(this.attributes.title),
293
297
  vendorName: this.utilities.sanitizeString(this.attributes.vendorName),
294
298
  vendorId: this.utilities.sanitizeString(this.attributes.vendorId),
299
+ weightRange: this.utilities.sanitizeString(this.attributes.weightRange),
300
+ weightUnit: this.utilities.sanitizeString(this.attributes.weightUnit),
295
301
  createdAtTimestamp,
296
302
  createdAtHour,
297
303
  createdAtDay,
@@ -581,6 +587,12 @@ class Product extends Base_1.default {
581
587
  name: 'rfidTag',
582
588
  type: 'string',
583
589
  },
590
+ {
591
+ facet: true,
592
+ optional: true,
593
+ name: 'sku',
594
+ type: 'string',
595
+ },
584
596
  {
585
597
  facet: true,
586
598
  optional: true,
@@ -769,6 +781,18 @@ class Product extends Base_1.default {
769
781
  type: 'string',
770
782
  optional: true,
771
783
  },
784
+ {
785
+ facet: true,
786
+ name: 'weightRange',
787
+ type: 'string',
788
+ optional: true,
789
+ },
790
+ {
791
+ facet: true,
792
+ name: 'weightUnit',
793
+ type: 'string',
794
+ optional: true,
795
+ },
772
796
  ],
773
797
  name,
774
798
  };
@@ -11,6 +11,8 @@ declare type ProductAttributes = {
11
11
  updatedAt: string;
12
12
  publishedAt: string;
13
13
  weight: string;
14
+ weightRange: string;
15
+ weightUnit: WeightUnit;
14
16
  vendorId: string;
15
17
  vendorName?: string;
16
18
  variantId: string;
@@ -23,6 +25,7 @@ declare type ProductAttributes = {
23
25
  merchantId?: string;
24
26
  editorAuthorizations?: EditorAuthorization;
25
27
  rfidTag?: string;
28
+ sku?: string;
26
29
  };
27
30
  declare type ProductFilterAttributes = {
28
31
  documentId: string;
@@ -141,6 +144,8 @@ declare type ProductAttributesFormFields = {
141
144
  title: TextInputFormField<string>;
142
145
  price: TextInputFormField<string>;
143
146
  weight: TextInputFormField<string>;
147
+ weightRange: SingleSelectFormField<string>;
148
+ weightUnit: SingleSelectFormField<WeightUnit>;
144
149
  officialFilesToUpload: MultiMediaSelectFormField;
145
150
  options: SingleSelectFormField<ProductOptions>;
146
151
  costPerItem: TextInputFormField<string>;
@@ -151,6 +156,7 @@ declare type ProductAttributesFormFields = {
151
156
  vendorId: SingleSelectFormField<string>;
152
157
  vendorName: SingleSelectFormField<string>;
153
158
  rfidTag: TextInputFormField<string>;
159
+ sku: TextInputFormField<string>;
154
160
  };
155
161
  declare type ProductFilterAttributesFormFields = {
156
162
  brand: SingleSelectFormField<string>;
@@ -214,6 +220,7 @@ declare type Measurements = {
214
220
  unit?: string;
215
221
  [key: string]: any;
216
222
  };
223
+ declare type WeightUnit = 'GRAMS' | 'KILOGRAMS' | 'OUNCES' | 'POUNDS';
217
224
  declare type ProductLineItem = {
218
225
  title: string;
219
226
  variant: {
@@ -255,6 +262,7 @@ declare type TypesenseProductObj = {
255
262
  productStyle: string[];
256
263
  reRobeCommission: number;
257
264
  rfidTag: string;
265
+ sku: string;
258
266
  salesChannel: string[];
259
267
  status: string;
260
268
  tags: string[];
@@ -303,5 +311,7 @@ declare type TypesenseProductObj = {
303
311
  createdAtMonth: string;
304
312
  createdAtHour: string;
305
313
  createdAtYear: string;
314
+ weightRange: string;
315
+ weightUnit: string;
306
316
  [key: string]: any;
307
317
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",