rerobe-js-orm 2.4.87 → 2.4.91

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/README.md CHANGED
@@ -1 +1 @@
1
- #ReRobe Product
1
+ #Ribbn and ReRobe ORM
@@ -4,7 +4,7 @@ const MerchantFactory_1 = require("./MerchantFactory");
4
4
  const Merchant_1 = require("../../models/Merchant");
5
5
  class MerchantFromFormState extends MerchantFactory_1.default {
6
6
  createMerchant(fs) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
8
8
  const merchantAttributes = {
9
9
  id: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.id) || '',
10
10
  name: fs.fields.name.inputValue,
@@ -27,10 +27,11 @@ class MerchantFromFormState extends MerchantFactory_1.default {
27
27
  numOrders: (_f = fs.props) === null || _f === void 0 ? void 0 : _f.numOrders,
28
28
  numProducts: (_g = fs.props) === null || _g === void 0 ? void 0 : _g.numProducts,
29
29
  orderTags: (_h = fs.props) === null || _h === void 0 ? void 0 : _h.orderTags,
30
- theme: (_j = fs.props) === null || _j === void 0 ? void 0 : _j.theme,
31
- webshopTenantId: (_k = fs.props) === null || _k === void 0 ? void 0 : _k.webshopTenantId,
30
+ productTags: (_j = fs.props) === null || _j === void 0 ? void 0 : _j.productTags,
31
+ theme: (_k = fs.props) === null || _k === void 0 ? void 0 : _k.theme,
32
+ webshopTenantId: (_l = fs.props) === null || _l === void 0 ? void 0 : _l.webshopTenantId,
32
33
  webhooks: fs.fields.webhooks.selectedValues,
33
- sharedSecret: (_l = fs.props) === null || _l === void 0 ? void 0 : _l.sharedSecret,
34
+ sharedSecret: (_m = fs.props) === null || _m === void 0 ? void 0 : _m.sharedSecret,
34
35
  };
35
36
  return new Merchant_1.default(Object.assign({}, merchantAttributes));
36
37
  }
@@ -22,7 +22,7 @@ class ProductFromFormState extends ProductFactory_1.default {
22
22
  weight: props.fields.weight.inputValue,
23
23
  variantId: ((_j = props.props) === null || _j === void 0 ? void 0 : _j.variantId) || '',
24
24
  reservedBy: ((_k = props.props) === null || _k === void 0 ? void 0 : _k.reservedBy) || [],
25
- variants: props.fields.variants.selectedValue,
25
+ options: props.fields.options.selectedValue,
26
26
  costPerItem: props.fields.costPerItem.inputValue,
27
27
  compareAtPrice: props.fields.compareAtPrice.inputValue,
28
28
  quantity: props.fields.quantity.inputValue,
@@ -8,6 +8,10 @@ export default class ProductFormState extends FormState {
8
8
  label: string;
9
9
  value: string;
10
10
  }[];
11
+ tags: string[];
12
+ taxonomy: {
13
+ [key: string]: any;
14
+ };
11
15
  };
12
16
  constructor(props?: any, opts?: any);
13
17
  autoCreateTitle(): string;
@@ -19,8 +23,11 @@ export default class ProductFormState extends FormState {
19
23
  private productCategorySelectHandler;
20
24
  private productTypeSelectHandler;
21
25
  private setPriceRangeFromPrice;
26
+ private setProductCategoreisFromGender;
22
27
  private setProductTypesFromCategory;
28
+ private setProductTypesFromPassedOptions;
23
29
  private setProductStylesFromCategoryAndType;
30
+ private setProductStylesFromPassedOptions;
24
31
  private discountTypeChangeHandler;
25
32
  private discountValueChangeHandler;
26
33
  private calculateSalePrice;
@@ -20,7 +20,7 @@ class ProductFormState extends FormState_1.default {
20
20
  valid: false,
21
21
  onChangeHandler: (fileArr) => this.multiSelectMediaChangeHandler('officialFilesToUpload', fileArr),
22
22
  };
23
- this.fields.variants = this.fieldFactory('singleSelect', 'variants');
23
+ this.fields.options = this.fieldFactory('singleSelect', 'options', options_1.productOptions);
24
24
  this.fields.costPerItem = this.fieldFactory('textInput', 'costPerItem');
25
25
  this.fields.compareAtPrice = this.fieldFactory('textInput', 'compareAtPrice');
26
26
  this.fields.quantity = this.fieldFactory('textInput', 'quantity');
@@ -101,11 +101,12 @@ class ProductFormState extends FormState_1.default {
101
101
  this.fields.gender.selectedValue = value;
102
102
  this.fields.gender.valid = !!value;
103
103
  // Reset productCategory fields except options
104
+ this.fields.productCategory.options = this.setProductCategoreisFromGender(value);
104
105
  this.fields.productCategory.hidden = true;
105
106
  this.fields.productCategory.valid = false;
106
107
  this.fields.productCategory.selectedValue = '';
107
108
  // Resets productType fields
108
- this.fields.productType.options = this.setProductTypesFromCategory(this.fields.productCategory.selectedValue, value);
109
+ this.fields.productType.options = this.setProductTypesFromPassedOptions(this.fields.productCategory.selectedValue, value);
109
110
  this.fields.productType.hidden = true;
110
111
  this.fields.productType.selectedValue = '';
111
112
  this.fields.productType.valid = false;
@@ -220,7 +221,7 @@ class ProductFormState extends FormState_1.default {
220
221
  this.fields.productCategory.selectedValue = value;
221
222
  this.fields.productCategory.valid = !!value;
222
223
  // Update Product Type options based on new category value and selected gender
223
- this.fields.productType.options = this.setProductTypesFromCategory(value, this.fields.gender.selectedValue);
224
+ this.fields.productType.options = this.setProductTypesFromPassedOptions(value, this.fields.gender.selectedValue);
224
225
  this.fields.productType.hidden = !value;
225
226
  this.fields.productType.valid = false;
226
227
  this.fields.productType.selectedValue = '';
@@ -248,7 +249,7 @@ class ProductFormState extends FormState_1.default {
248
249
  this.fields.productType.valid = !!value;
249
250
  // Update productStyle options based on selected value and productCategory selected
250
251
  // and resets other props
251
- this.fields.productStyle.options = this.setProductStylesFromCategoryAndType(this.fields.productCategory.selectedValue, value);
252
+ this.fields.productStyle.options = this.setProductStylesFromPassedOptions(this.fields.productCategory.selectedValue, value);
252
253
  this.fields.productStyle.selectedValues = [];
253
254
  this.fields.productStyle.valid = false;
254
255
  this.fields.productStyle.hidden = !value;
@@ -274,6 +275,20 @@ class ProductFormState extends FormState_1.default {
274
275
  }
275
276
  return '1000+ SEK';
276
277
  }
278
+ setProductCategoreisFromGender(genderSelected) {
279
+ let productCategoryOptions = [];
280
+ if (this.opts && this.opts.taxonomy && Object.keys(this.opts.taxonomy).length > 0 && genderSelected) {
281
+ const t = this.opts.taxonomy;
282
+ const { [genderSelected]: genderObj = {} } = t;
283
+ productCategoryOptions = Object.keys(genderObj).map((k) => ({ label: k, value: k }));
284
+ }
285
+ else {
286
+ productCategoryOptions = options_1.productCategories;
287
+ }
288
+ const selectedCategoryOptions = this.props.productCategory ? [{ label: this.props.productCategory, value: this.props.productCategory }] : [];
289
+ const options = this.utilities.uniqObjArray([...productCategoryOptions, ...selectedCategoryOptions], 'value');
290
+ return options;
291
+ }
277
292
  setProductTypesFromCategory(productCategory, genderSelected) {
278
293
  switch (productCategory) {
279
294
  case 'Clothing':
@@ -320,6 +335,18 @@ class ProductFormState extends FormState_1.default {
320
335
  return [];
321
336
  }
322
337
  }
338
+ setProductTypesFromPassedOptions(productCategory, genderSelected) {
339
+ if (productCategory &&
340
+ genderSelected &&
341
+ this.opts &&
342
+ this.opts.taxonomy &&
343
+ Object.keys(this.opts.taxonomy).length > 0) {
344
+ const t = this.opts.taxonomy;
345
+ const { [genderSelected]: { [productCategory]: productTypeArr = [] } = {} } = t;
346
+ return productTypeArr;
347
+ }
348
+ return this.setProductTypesFromCategory(productCategory, genderSelected);
349
+ }
323
350
  setProductStylesFromCategoryAndType(productCategory, productType) {
324
351
  switch (productCategory) {
325
352
  case 'Clothing':
@@ -381,6 +408,23 @@ class ProductFormState extends FormState_1.default {
381
408
  return [];
382
409
  }
383
410
  }
411
+ setProductStylesFromPassedOptions(productCategory, productType) {
412
+ if (this.opts &&
413
+ this.opts.taxonomy &&
414
+ Object.keys(this.opts.taxonomy).length > 0 &&
415
+ productCategory &&
416
+ productType) {
417
+ const t = this.opts.taxonomy;
418
+ const genderSelected = this.fields.gender.selectedValue;
419
+ const { [genderSelected]: { [productCategory]: productTypeArr = [] } = {} } = t;
420
+ const [pType] = productTypeArr.filter((p) => p.value === productType);
421
+ if (pType) {
422
+ return pType.styles.map((s) => ({ label: s, value: s }));
423
+ }
424
+ return [];
425
+ }
426
+ return this.setProductStylesFromCategoryAndType(productCategory, productType);
427
+ }
384
428
  discountTypeChangeHandler(val) {
385
429
  const prevVal = this.fields.discountType.selectedValue;
386
430
  if (val === 'amount' && prevVal === 'percentage' && this.fields.discountValue.inputValue) {
@@ -465,14 +509,19 @@ class ProductFormState extends FormState_1.default {
465
509
  selectedValue = this.props[fieldKey] || {};
466
510
  valid = Object.keys(this.props[fieldKey]).length > 0;
467
511
  }
512
+ if (fieldKey === 'options') {
513
+ selectedValue = this.props[fieldKey] || {};
514
+ valid = Object.keys(this.props[fieldKey]).length > 0;
515
+ }
468
516
  if (fieldKey === 'gender') {
469
517
  onChangeHandler = (val) => this.genderSelectHandler(val);
470
518
  }
471
519
  if (fieldKey === 'productCategory') {
520
+ options = this.setProductCategoreisFromGender(this.props.gender);
472
521
  onChangeHandler = (val) => this.productCategorySelectHandler(val);
473
522
  }
474
523
  if (fieldKey === 'productType') {
475
- options = this.setProductTypesFromCategory(this.props.productCategory, this.props.gender);
524
+ options = this.setProductTypesFromPassedOptions(this.props.productCategory, this.props.gender);
476
525
  hidden = !this.props.productCategory;
477
526
  onChangeHandler = (val) => this.productTypeSelectHandler(val);
478
527
  }
@@ -520,7 +569,7 @@ class ProductFormState extends FormState_1.default {
520
569
  if (fieldType === 'multiSelect') {
521
570
  let onChangeHandler = (val) => this.multiSelectChangeHandler(fieldKey, val);
522
571
  if (fieldKey === 'productStyle') {
523
- options = this.setProductStylesFromCategoryAndType(this.props.productCategory, this.props.productType);
572
+ options = this.setProductStylesFromPassedOptions(this.props.productCategory, this.props.productType);
524
573
  if (this.props.productStyle && this.props.productStyle.length > 0) {
525
574
  this.props.productStyle.forEach((productStyle) => {
526
575
  if (!options.map((o) => o.value).includes(productStyle)) {
@@ -531,13 +580,15 @@ class ProductFormState extends FormState_1.default {
531
580
  hidden = this.props.productStyle.length < 1;
532
581
  }
533
582
  if (fieldKey === 'tags') {
583
+ let selectedTagOptions = [];
534
584
  if (this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length > 0) {
535
- this.props.tags.forEach((tag) => {
536
- if (!options.map((o) => o.value).includes(tag)) {
537
- options.splice(0, 0, { label: tag, value: tag });
538
- }
539
- });
585
+ selectedTagOptions = this.props.tags.map((t) => ({ label: t, value: t }));
586
+ }
587
+ let tagOptions = [];
588
+ if (this.opts && this.opts.tags && this.opts.tags.length > 0) {
589
+ tagOptions = this.opts.tags.map((t) => ({ label: t, value: t }));
540
590
  }
591
+ options = this.utilities.uniqObjArray([...selectedTagOptions, ...tagOptions], 'value');
541
592
  hidden = Boolean(this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length < 1);
542
593
  }
543
594
  if (fieldKey === 'featuredCollections') {
@@ -156,3 +156,7 @@ export const productIsOnSaleOptions: {
156
156
  label: string;
157
157
  value: string;
158
158
  }[];
159
+ export const productOptions: {
160
+ value: string;
161
+ label: string;
162
+ }[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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;
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
4
  const availableForSaleOptions = [
5
5
  {
6
6
  label: 'Zero',
@@ -1672,14 +1672,26 @@ const gender = [
1672
1672
  label: 'Woman',
1673
1673
  value: 'Woman',
1674
1674
  },
1675
+ {
1676
+ label: 'Girl',
1677
+ value: 'Girl',
1678
+ },
1675
1679
  {
1676
1680
  label: 'Man',
1677
1681
  value: 'Man',
1678
1682
  },
1683
+ {
1684
+ label: 'Boy',
1685
+ value: 'Boy',
1686
+ },
1679
1687
  {
1680
1688
  label: 'Unisex',
1681
1689
  value: 'Unisex',
1682
1690
  },
1691
+ {
1692
+ label: 'NA',
1693
+ value: 'NA',
1694
+ },
1683
1695
  ];
1684
1696
  exports.gender = gender;
1685
1697
  const jeanSizes = [
@@ -3453,3 +3465,10 @@ const productIsOnSaleOptions = [
3453
3465
  },
3454
3466
  ];
3455
3467
  exports.productIsOnSaleOptions = productIsOnSaleOptions;
3468
+ const productOptions = [
3469
+ { value: 'size', label: 'Size' },
3470
+ { value: 'color', label: 'Color' },
3471
+ { value: 'style', label: 'Style' },
3472
+ { value: 'material', label: 'Material' },
3473
+ ];
3474
+ exports.productOptions = productOptions;
@@ -57,6 +57,7 @@ export default class Merchant extends Base {
57
57
  numOrders: number;
58
58
  numProducts: number;
59
59
  orderTags: string[];
60
+ productTags: string[];
60
61
  theme: MerchantTheme;
61
62
  webshopTenantId: string;
62
63
  webhooks: MerchantWebHook[];
@@ -34,6 +34,7 @@ class Merchant extends Base_1.default {
34
34
  this.numOrders = (props === null || props === void 0 ? void 0 : props.numOrders) || 0;
35
35
  this.numProducts = (props === null || props === void 0 ? void 0 : props.numProducts) || 0;
36
36
  this.orderTags = (props === null || props === void 0 ? void 0 : props.orderTags) || [];
37
+ this.productTags = (props === null || props === void 0 ? void 0 : props.productTags) || [];
37
38
  this.theme = (props === null || props === void 0 ? void 0 : props.theme) || {
38
39
  layoutType: 'StandardNavLayout',
39
40
  bgColor: '#fff',
@@ -74,6 +75,7 @@ class Merchant extends Base_1.default {
74
75
  numOrders: this.numOrders,
75
76
  numProducts: this.numProducts,
76
77
  orderTags: this.orderTags,
78
+ productTags: this.productTags,
77
79
  theme: this.theme,
78
80
  webshopTenantId: this.webshopTenantId,
79
81
  webhooks: this.webhooks,
@@ -23,7 +23,7 @@ class Product extends Base_1.default {
23
23
  vendorName: (props === null || props === void 0 ? void 0 : props.vendorName) || '',
24
24
  variantId: (props === null || props === void 0 ? void 0 : props.variantId) || '',
25
25
  reservedBy: (props === null || props === void 0 ? void 0 : props.reservedBy) || [],
26
- variants: (props === null || props === void 0 ? void 0 : props.variants) || {},
26
+ options: (props === null || props === void 0 ? void 0 : props.options) || {},
27
27
  costPerItem: (props === null || props === void 0 ? void 0 : props.costPerItem) || '',
28
28
  compareAtPrice: (props === null || props === void 0 ? void 0 : props.compareAtPrice) || '',
29
29
  quantity: (props === null || props === void 0 ? void 0 : props.quantity) || 0,
@@ -277,6 +277,7 @@ class Product extends Base_1.default {
277
277
  sellerSelfRejectTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerSelfRejectTimestamp),
278
278
  liquidationRequestedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.liquidationRequestedTimestamp),
279
279
  sellerLiquidatedTimestamp: this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.sellerLiquidatedTimestamp),
280
+ selectedForClearance: this.utilities.sanitizeString(this.consignmentAttributes.selectedForClearance),
280
281
  availableForSale: !!this.attributes.availableForSale,
281
282
  color: this.utilities.sanitizeString(this.filterAttributes.color),
282
283
  description: this.utilities.sanitizeString(this.attributes.description),
@@ -284,6 +285,7 @@ class Product extends Base_1.default {
284
285
  discountValue: this.utilities.sanitizeNumber(this.consignmentAttributes.discountValue, 0),
285
286
  id: this.utilities.sanitizeString(this.filterAttributes.documentId),
286
287
  documentId: this.utilities.sanitizeString(this.filterAttributes.documentId),
288
+ shopifyId: this.utilities.sanitizeString(this.attributes.shopifyId),
287
289
  gender: this.utilities.sanitizeString(this.filterAttributes.gender),
288
290
  handle: this.utilities.sanitizeString(this.attributes.handle),
289
291
  imageUrls: this.utilities.sanitzeStringArr(this.attributes.imageUrls),
@@ -405,7 +407,7 @@ class Product extends Base_1.default {
405
407
  return acc;
406
408
  }, '');
407
409
  }
408
- generateSchemaForTypesense(name = 'prod_products_202101061') {
410
+ generateSchemaForTypesense(name = 'prod_products_20210108') {
409
411
  return {
410
412
  default_sorting_field: 'createdAtTimestamp',
411
413
  fields: [
@@ -561,10 +563,15 @@ class Product extends Base_1.default {
561
563
  type: 'int32',
562
564
  },
563
565
  {
564
- facet: false,
566
+ facet: true,
565
567
  name: 'availableForSale',
566
568
  type: 'bool',
567
569
  },
570
+ {
571
+ facet: true,
572
+ name: 'selectedForClearance',
573
+ type: 'string',
574
+ },
568
575
  {
569
576
  facet: true,
570
577
  name: 'color',
@@ -597,6 +604,11 @@ class Product extends Base_1.default {
597
604
  name: 'documentId',
598
605
  type: 'string',
599
606
  },
607
+ {
608
+ facet: false,
609
+ name: 'shopifyId',
610
+ type: 'string',
611
+ },
600
612
  {
601
613
  facet: true,
602
614
  name: 'gender',
@@ -20,6 +20,7 @@ declare type MerchantObj = {
20
20
  numOrders: number;
21
21
  numProducts: number;
22
22
  orderTags: string[];
23
+ productTags: string[];
23
24
  theme: MerchantTheme;
24
25
  webhooks: MerchantWebHook[];
25
26
  webshopTenantId: string;
@@ -15,7 +15,7 @@ declare type ProductAttributes = {
15
15
  vendorName?: string;
16
16
  variantId: string;
17
17
  reservedBy: string[];
18
- variants?: Variants | null;
18
+ options?: ProductOptions | null;
19
19
  costPerItem?: string;
20
20
  compareAtPrice?: string;
21
21
  quantity?: number | string;
@@ -140,7 +140,7 @@ declare type ProductAttributesFormFields = {
140
140
  price: TextInputFormField<string>;
141
141
  weight: TextInputFormField<string>;
142
142
  officialFilesToUpload: MultiMediaSelectFormField;
143
- variants: SingleSelectFormField<Variants>;
143
+ options: SingleSelectFormField<ProductOptions>;
144
144
  costPerItem: TextInputFormField<string>;
145
145
  compareAtPrice: TextInputFormField<string>;
146
146
  quantity: TextInputFormField<string | number>;
@@ -199,7 +199,7 @@ interface ParamsForBuildProductInputObjForShopify {
199
199
  productShopifyId?: string;
200
200
  }
201
201
  declare type ConditionTypes = 'NEW' | 'USED';
202
- declare type Variants = {
202
+ declare type ProductOptions = {
203
203
  size?: string[];
204
204
  color?: string[];
205
205
  material?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.87",
3
+ "version": "2.4.91",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",