rerobe-js-orm 4.8.1 → 4.8.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.
@@ -1,3 +1,4 @@
1
+ export function getDefaultTaxCategory(isConsignment: any, countryCode: any): any;
1
2
  export namespace SELLER_DRIVEN_STATES {
2
3
  let sellerDonated: string;
3
4
  let sellRequestReview: string;
@@ -327,6 +328,16 @@ export namespace PAYOUT_SYSTEM {
327
328
  export { RIBBN_CREDITS_1 as RIBBN_CREDITS };
328
329
  }
329
330
  export const ADMIN_STATES: {};
331
+ export namespace TAX_CATEGORIES {
332
+ let STANDARD: string;
333
+ let FOOD: string;
334
+ let CULTURE: string;
335
+ let EXEMPT: string;
336
+ }
337
+ export namespace CONSIGNMENT_TAX_DEFAULTS {
338
+ let SE: string;
339
+ let _default: string;
340
+ }
330
341
  export namespace PRODUCT_CLASS_VALUES {
331
342
  let UNIQUE: string;
332
343
  let MULTIVARIANT: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRODUCT_CLASS_VALUES = exports.ADMIN_STATES = exports.PAYOUT_SYSTEM = exports.PAYOUT_METHOD = exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.ADMIN_SIMPLIFIED_STATES = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
3
+ exports.PRODUCT_CLASS_VALUES = exports.CONSIGNMENT_TAX_DEFAULTS = exports.TAX_CATEGORIES = exports.ADMIN_STATES = exports.PAYOUT_SYSTEM = exports.PAYOUT_METHOD = exports.PUBLISH_TYPE = exports.MEASUREMENT_FIELDS_DICT = exports.MEASUREMENT_CATEGORY = exports.PRODUCT_STATE_LABELS_ADMIN_VIEW = exports.PRODUCT_STATE_LABELS = exports.ADMIN_SIMPLIFIED_STATES = exports.PRODUCT_STATES = exports.SYSTEM_DRIVEN_STATES = exports.ADMIN_ACTION_DRIVEN_STATES = exports.ADMIN_DRIVEN_STATES = exports.SELLER_DRIVEN_STATES = void 0;
4
+ exports.getDefaultTaxCategory = getDefaultTaxCategory;
4
5
  exports.SELLER_DRIVEN_STATES = {
5
6
  sellerDonated: 'SELLER_DONATED',
6
7
  sellRequestReview: 'SELL_REQUEST_REVIEW',
@@ -234,6 +235,24 @@ exports.ADMIN_STATES = Object.entries(exports.PRODUCT_STATES)
234
235
  acc[key] = value;
235
236
  return acc;
236
237
  }, {});
238
+ exports.TAX_CATEGORIES = {
239
+ STANDARD: 'STANDARD',
240
+ FOOD: 'FOOD',
241
+ CULTURE: 'CULTURE',
242
+ EXEMPT: 'EXEMPT',
243
+ };
244
+ exports.CONSIGNMENT_TAX_DEFAULTS = {
245
+ SE: 'EXEMPT',
246
+ _default: 'EXEMPT',
247
+ };
248
+ function getDefaultTaxCategory(isConsignment, countryCode) {
249
+ if (!isConsignment)
250
+ return exports.TAX_CATEGORIES.STANDARD;
251
+ const map = exports.CONSIGNMENT_TAX_DEFAULTS;
252
+ if (countryCode && map[countryCode] !== undefined)
253
+ return map[countryCode];
254
+ return map._default;
255
+ }
237
256
  exports.PRODUCT_CLASS_VALUES = {
238
257
  UNIQUE: 'UNIQUE',
239
258
  MULTIVARIANT: 'MULTIVARIANT',
@@ -17,6 +17,7 @@ class ProductFromFormState extends ProductFactory_1.default {
17
17
  imageUrlsForAI: ((_e = props.props) === null || _e === void 0 ? void 0 : _e.imageUrlsForAI) || [],
18
18
  price: props.fields.price.inputValue,
19
19
  isTaxable: props.fields.isTaxable.selectedValue,
20
+ taxCategory: props.fields.taxCategory.selectedValue,
20
21
  productClass: props.fields.productClass.selectedValue,
21
22
  createdAt: ((_f = props.props) === null || _f === void 0 ? void 0 : _f.createdAt) || new Date().toUTCString(), // ToDo look into different timestamp
22
23
  updatedAt: ((_g = props.props) === null || _g === void 0 ? void 0 : _g.updatedAt) || new Date().toUTCString(), // ToDo look into different timestamp
@@ -31,7 +31,10 @@ export default class ProductFormState extends FormState {
31
31
  majorDefects: string[];
32
32
  minorDefects: string[];
33
33
  primaryAgeCategories: string[];
34
+ countryCode?: string;
35
+ isConsignment?: boolean;
34
36
  };
37
+ private _rawProps?;
35
38
  constructor(props?: any, opts?: any);
36
39
  autoCreateTitle(): string;
37
40
  autoCreateDescription(): string;
@@ -15,9 +15,11 @@ const FormState_1 = require("../FormState");
15
15
  const options_1 = require("./options");
16
16
  const Product_1 = require("../../models/Product");
17
17
  const ProductFromFormState_1 = require("../../factories/Product/ProductFromFormState");
18
+ const product_constants_1 = require("../../constants/product-constants");
18
19
  class ProductFormState extends FormState_1.default {
19
20
  constructor(props, opts) {
20
21
  super();
22
+ this._rawProps = props;
21
23
  this.props = new Product_1.default(props).toObj();
22
24
  this.opts = opts;
23
25
  // ProductAttributesFormFields
@@ -26,6 +28,7 @@ class ProductFormState extends FormState_1.default {
26
28
  this.fields.title = this.fieldFactory('textInput', 'title');
27
29
  this.fields.price = this.fieldFactory('textInput', 'price');
28
30
  this.fields.isTaxable = this.fieldFactory('singleSelect', 'isTaxable', options_1.productYesNoOptions);
31
+ this.fields.taxCategory = this.fieldFactory('singleSelect', 'taxCategory', options_1.taxCategoryOptions);
29
32
  this.fields.weight = this.fieldFactory('textInput', 'weight');
30
33
  this.fields.weightRange = this.fieldFactory('singleSelect', 'weightRange', options_1.productWeightRanges);
31
34
  this.fields.weightUnit = this.fieldFactory('singleSelect', 'weightUnit', options_1.weightUnits);
@@ -1042,7 +1045,7 @@ class ProductFormState extends FormState_1.default {
1042
1045
  this.fields.inventoryLocations.valid = aggregated.length > 0;
1043
1046
  }
1044
1047
  fieldFactory(fieldType, fieldKey, fieldOptions) {
1045
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
1048
+ 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;
1046
1049
  let options = fieldOptions || [];
1047
1050
  let hidden = false;
1048
1051
  if (fieldType === 'singleSelect') {
@@ -1060,7 +1063,16 @@ class ProductFormState extends FormState_1.default {
1060
1063
  onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
1061
1064
  }
1062
1065
  if (fieldKey === 'isTaxable') {
1063
- selectedValue = this.props[fieldKey] || '';
1066
+ const hasExplicitValue = this._rawProps && this._rawProps.isTaxable;
1067
+ selectedValue = hasExplicitValue ? this.props[fieldKey] || '' : ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.isConsignment) ? 'no' : '';
1068
+ valid = true;
1069
+ onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
1070
+ }
1071
+ if (fieldKey === 'taxCategory') {
1072
+ const hasExplicitValue = this._rawProps && this._rawProps.taxCategory;
1073
+ selectedValue = hasExplicitValue
1074
+ ? this.props[fieldKey] || 'STANDARD'
1075
+ : (0, product_constants_1.getDefaultTaxCategory)(!!((_b = this.opts) === null || _b === void 0 ? void 0 : _b.isConsignment), (_c = this.opts) === null || _c === void 0 ? void 0 : _c.countryCode);
1064
1076
  valid = true;
1065
1077
  onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
1066
1078
  }
@@ -1090,7 +1102,7 @@ class ProductFormState extends FormState_1.default {
1090
1102
  });
1091
1103
  }
1092
1104
  }
1093
- if ((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.materials) === null || _b === void 0 ? void 0 : _b.length) {
1105
+ if ((_e = (_d = this.opts) === null || _d === void 0 ? void 0 : _d.materials) === null || _e === void 0 ? void 0 : _e.length) {
1094
1106
  const materialsOptions = this.opts.materials.map((t) => ({
1095
1107
  label: t,
1096
1108
  value: t,
@@ -1151,7 +1163,7 @@ class ProductFormState extends FormState_1.default {
1151
1163
  options.splice(0, 0, ...selectedSizeOptions);
1152
1164
  }
1153
1165
  }
1154
- if ((_d = (_c = this.opts) === null || _c === void 0 ? void 0 : _c.sizes) === null || _d === void 0 ? void 0 : _d.length) {
1166
+ if ((_g = (_f = this.opts) === null || _f === void 0 ? void 0 : _f.sizes) === null || _g === void 0 ? void 0 : _g.length) {
1155
1167
  const sizesOptions = this.opts.sizes.map((t) => ({ label: t, value: t }));
1156
1168
  options = this.utilities.uniqObjArray([...selectedSizeOptions, ...sizesOptions], 'value');
1157
1169
  }
@@ -1165,7 +1177,7 @@ class ProductFormState extends FormState_1.default {
1165
1177
  options.splice(0, 0, ...selectedJeanSizeOptions);
1166
1178
  }
1167
1179
  }
1168
- if ((_f = (_e = this.opts) === null || _e === void 0 ? void 0 : _e.jeanSizes) === null || _f === void 0 ? void 0 : _f.length) {
1180
+ if ((_j = (_h = this.opts) === null || _h === void 0 ? void 0 : _h.jeanSizes) === null || _j === void 0 ? void 0 : _j.length) {
1169
1181
  const jeanSizesOptions = this.opts.jeanSizes.map((t) => ({ label: t, value: t }));
1170
1182
  options = this.utilities.uniqObjArray([...selectedJeanSizeOptions, ...jeanSizesOptions], 'value');
1171
1183
  }
@@ -1179,7 +1191,7 @@ class ProductFormState extends FormState_1.default {
1179
1191
  options.splice(0, 0, ...selectedShoeSizeOptions);
1180
1192
  }
1181
1193
  }
1182
- if ((_h = (_g = this.opts) === null || _g === void 0 ? void 0 : _g.shoeSizes) === null || _h === void 0 ? void 0 : _h.length) {
1194
+ if ((_l = (_k = this.opts) === null || _k === void 0 ? void 0 : _k.shoeSizes) === null || _l === void 0 ? void 0 : _l.length) {
1183
1195
  const shoeSizesOptions = this.opts.shoeSizes.map((t) => ({ label: t, value: t }));
1184
1196
  options = this.utilities.uniqObjArray([...selectedShoeSizeOptions, ...shoeSizesOptions], 'value');
1185
1197
  }
@@ -1192,7 +1204,7 @@ class ProductFormState extends FormState_1.default {
1192
1204
  options.splice(0, 0, ...selectedBrandOptions);
1193
1205
  }
1194
1206
  }
1195
- if ((_k = (_j = this.opts) === null || _j === void 0 ? void 0 : _j.brands) === null || _k === void 0 ? void 0 : _k.length) {
1207
+ if ((_o = (_m = this.opts) === null || _m === void 0 ? void 0 : _m.brands) === null || _o === void 0 ? void 0 : _o.length) {
1196
1208
  const brandsOptions = this.opts.brands.map((t) => ({ label: t, value: t }));
1197
1209
  options = this.utilities.uniqObjArray([...selectedBrandOptions, ...brandsOptions], 'value');
1198
1210
  }
@@ -1205,7 +1217,7 @@ class ProductFormState extends FormState_1.default {
1205
1217
  options.splice(0, 0, ...selectedColorOptions);
1206
1218
  }
1207
1219
  }
1208
- if ((_m = (_l = this.opts) === null || _l === void 0 ? void 0 : _l.colors) === null || _m === void 0 ? void 0 : _m.length) {
1220
+ if ((_q = (_p = this.opts) === null || _p === void 0 ? void 0 : _p.colors) === null || _q === void 0 ? void 0 : _q.length) {
1209
1221
  const colorsOptions = this.opts.colors.map((t) => ({ label: t, value: t }));
1210
1222
  options = this.utilities.uniqObjArray([...selectedColorOptions, ...colorsOptions], 'value');
1211
1223
  }
@@ -1230,7 +1242,7 @@ class ProductFormState extends FormState_1.default {
1230
1242
  options.splice(0, 0, ...selectedPrimaryAgeCategoryOptions);
1231
1243
  }
1232
1244
  }
1233
- if ((_p = (_o = this.opts) === null || _o === void 0 ? void 0 : _o.primaryAgeCategories) === null || _p === void 0 ? void 0 : _p.length) {
1245
+ if ((_s = (_r = this.opts) === null || _r === void 0 ? void 0 : _r.primaryAgeCategories) === null || _s === void 0 ? void 0 : _s.length) {
1234
1246
  const suppliedPrimaryAgeCategoryOptions = this.opts.primaryAgeCategories.map((t) => ({ label: t, value: t }));
1235
1247
  options = this.utilities.uniqObjArray([...selectedPrimaryAgeCategoryOptions, ...suppliedPrimaryAgeCategoryOptions], 'value');
1236
1248
  }
@@ -1243,7 +1255,7 @@ class ProductFormState extends FormState_1.default {
1243
1255
  options.splice(0, 0, ...selectedOptions);
1244
1256
  }
1245
1257
  }
1246
- if ((_r = (_q = this.opts) === null || _q === void 0 ? void 0 : _q.conditions) === null || _r === void 0 ? void 0 : _r.length) {
1258
+ if ((_u = (_t = this.opts) === null || _t === void 0 ? void 0 : _t.conditions) === null || _u === void 0 ? void 0 : _u.length) {
1247
1259
  const conditionsOptions = this.opts.conditions.map((t) => ({
1248
1260
  label: t.label || '',
1249
1261
  value: t.value || '',
@@ -1298,7 +1310,7 @@ class ProductFormState extends FormState_1.default {
1298
1310
  if (this.props.gender === 'Man') {
1299
1311
  options = options_1.manClothingSizeOptions;
1300
1312
  }
1301
- if ((_t = (_s = this.opts) === null || _s === void 0 ? void 0 : _s.clothingSizes) === null || _t === void 0 ? void 0 : _t.length) {
1313
+ if ((_w = (_v = this.opts) === null || _v === void 0 ? void 0 : _v.clothingSizes) === null || _w === void 0 ? void 0 : _w.length) {
1302
1314
  const clothingSizesOptions = this.opts.clothingSizes.map((t) => ({ label: t, value: t }));
1303
1315
  options = this.utilities.uniqObjArray(clothingSizesOptions, 'value');
1304
1316
  }
@@ -1311,7 +1323,7 @@ class ProductFormState extends FormState_1.default {
1311
1323
  selectedMajorDefectsOptions = this.props.majorDefects.map((t) => ({ label: t, value: t }));
1312
1324
  }
1313
1325
  let majorDefectsOptions = [];
1314
- if ((_v = (_u = this.opts) === null || _u === void 0 ? void 0 : _u.majorDefects) === null || _v === void 0 ? void 0 : _v.length) {
1326
+ if ((_y = (_x = this.opts) === null || _x === void 0 ? void 0 : _x.majorDefects) === null || _y === void 0 ? void 0 : _y.length) {
1315
1327
  majorDefectsOptions = this.opts.majorDefects.map((t) => ({ label: t, value: t }));
1316
1328
  }
1317
1329
  options = this.utilities.uniqObjArray([...selectedMajorDefectsOptions, ...majorDefectsOptions], 'value');
@@ -1323,7 +1335,7 @@ class ProductFormState extends FormState_1.default {
1323
1335
  selectedMinorDefectsOptions = this.props.minorDefects.map((t) => ({ label: t, value: t }));
1324
1336
  }
1325
1337
  let minorDefectsOptions = [];
1326
- if ((_x = (_w = this.opts) === null || _w === void 0 ? void 0 : _w.minorDefects) === null || _x === void 0 ? void 0 : _x.length) {
1338
+ if ((_0 = (_z = this.opts) === null || _z === void 0 ? void 0 : _z.minorDefects) === null || _0 === void 0 ? void 0 : _0.length) {
1327
1339
  minorDefectsOptions = this.opts.minorDefects.map((t) => ({ label: t, value: t }));
1328
1340
  }
1329
1341
  options = this.utilities.uniqObjArray([...selectedMinorDefectsOptions, ...minorDefectsOptions], 'value');
@@ -175,6 +175,10 @@ export const productYesNoOptions: {
175
175
  label: string;
176
176
  value: string;
177
177
  }[];
178
+ export const taxCategoryOptions: {
179
+ label: string;
180
+ value: string;
181
+ }[];
178
182
  export const productClassOptions: {
179
183
  label: string;
180
184
  value: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.primaryAgeCategoryOptions = exports.adminStatusOptionsSimplified = exports.adminStatusOptions = exports.measurementCategoryOptions = exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productClassOptions = exports.productYesNoOptions = 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.genderOptions = 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.primaryAgeCategoryOptions = exports.adminStatusOptionsSimplified = exports.adminStatusOptions = exports.measurementCategoryOptions = exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productClassOptions = exports.taxCategoryOptions = exports.productYesNoOptions = 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.genderOptions = 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 = [
@@ -1058,6 +1058,13 @@ const productYesNoOptions = [
1058
1058
  },
1059
1059
  ];
1060
1060
  exports.productYesNoOptions = productYesNoOptions;
1061
+ const taxCategoryOptions = [
1062
+ { label: 'Standard', value: 'STANDARD' },
1063
+ { label: 'Food & Beverages', value: 'FOOD' },
1064
+ { label: 'Books & Culture', value: 'CULTURE' },
1065
+ { label: 'Exempt', value: 'EXEMPT' },
1066
+ ];
1067
+ exports.taxCategoryOptions = taxCategoryOptions;
1061
1068
  const productClassOptions = [
1062
1069
  {
1063
1070
  label: 'Unique',
@@ -42,6 +42,7 @@ class Product extends Base_1.default {
42
42
  metaDataTitle: (props === null || props === void 0 ? void 0 : props.metaDataTitle) || '',
43
43
  metaDataDescription: (props === null || props === void 0 ? void 0 : props.metaDataDescription) || '',
44
44
  isTaxable: (props === null || props === void 0 ? void 0 : props.isTaxable) || '',
45
+ taxCategory: (props === null || props === void 0 ? void 0 : props.taxCategory) || 'STANDARD',
45
46
  productClass: (props === null || props === void 0 ? void 0 : props.productClass) || 'UNIQUE',
46
47
  };
47
48
  this.filterAttributes = {
@@ -31,6 +31,7 @@ type ProductAttributes = {
31
31
  metaDataTitle?: string;
32
32
  metaDataDescription?: string;
33
33
  isTaxable?: string;
34
+ taxCategory?: string;
34
35
  productClass?: 'UNIQUE' | 'MULTIVARIANT' | 'TEMPLATE' | 'SUPPLY' | 'DIGITAL' | string;
35
36
  variantInventory?: VariantInventory[];
36
37
  };
@@ -206,6 +207,7 @@ type ProductAttributesFormFields = {
206
207
  metaDataDescription: TextInputFormField<string>;
207
208
  handle: TextInputFormField<string>;
208
209
  isTaxable: SingleSelectFormField<string>;
210
+ taxCategory: SingleSelectFormField<string>;
209
211
  productClass: SingleSelectFormField<string>;
210
212
  variantInventory: MultiSelectFormField<VariantInventory>;
211
213
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.8.1",
3
+ "version": "4.8.2",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",