rerobe-js-orm 3.0.19 → 3.0.21

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.
@@ -455,7 +455,7 @@ class ReRobeProductHelpers {
455
455
  }
456
456
  static mapToOldSizesToStandardSize(productObj) {
457
457
  const { clothingSize = [], jeanSize = '', shoeSize = '' } = productObj;
458
- const validSizes = clothingSize.filter((size) => typeof size === 'string' && size);
458
+ const validSizes = clothingSize.filter((size) => size);
459
459
  if (jeanSize)
460
460
  validSizes.push(jeanSize);
461
461
  if (shoeSize)
@@ -27,4 +27,5 @@ export default class Utilities {
27
27
  createdAtMonth: string;
28
28
  createdAtYear: string;
29
29
  };
30
+ humanize(str: string): string;
30
31
  }
@@ -171,5 +171,9 @@ class Utilities {
171
171
  createdAtYear,
172
172
  };
173
173
  }
174
+ humanize(str) {
175
+ const result = str.replace(/([A-Z])/g, ' $1');
176
+ return result.charAt(0).toUpperCase() + result.slice(1);
177
+ }
174
178
  }
175
179
  exports.default = Utilities;
@@ -30,6 +30,10 @@ export default class Product extends Base {
30
30
  })[];
31
31
  name: string;
32
32
  };
33
+ getAttributesOptions(): {
34
+ label: string;
35
+ value: string;
36
+ }[];
33
37
  private materialCompTagsArrayForShopify;
34
38
  private materialCompJoinedString;
35
39
  private measurementsJoinedString;
@@ -797,6 +797,18 @@ class Product extends Base_1.default {
797
797
  name,
798
798
  };
799
799
  }
800
+ getAttributesOptions() {
801
+ const attributeKeys = Object.keys(this.attributes);
802
+ const filterAttributeKeys = Object.keys(this.filterAttributes);
803
+ const consignmentAttributeKeys = Object.keys(this.consignmentAttributes);
804
+ const timestampAttributeKeys = Object.keys(this.timestampAttributes);
805
+ const allKeys = [...attributeKeys, ...filterAttributeKeys, ...consignmentAttributeKeys, ...timestampAttributeKeys];
806
+ const options = allKeys.map((key) => ({
807
+ label: this.utilities.humanize(key),
808
+ value: key,
809
+ }));
810
+ return options;
811
+ }
800
812
  materialCompTagsArrayForShopify() {
801
813
  return Object.keys(this.filterAttributes.materialComposition).reduce((acc, cur, idx) => {
802
814
  acc.push(`${cur} ${Object.values(this.filterAttributes.materialComposition)[idx]}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",