rerobe-js-orm 3.9.5 → 3.9.7

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.
@@ -2,14 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ProductCollectionFactory_1 = require("./ProductCollectionFactory");
4
4
  const ProductCollection_1 = require("../../models/ProductCollection");
5
- // @ts-ignore
6
- const lodash_1 = require("lodash");
5
+ const slug = require("slug");
7
6
  class ProductCollectionFromFormState extends ProductCollectionFactory_1.default {
8
7
  createProductCollection(fs) {
9
8
  var _a;
10
9
  let collectionId = fs.fields.collectionId.inputValue;
11
10
  if (!collectionId) {
12
- collectionId = (0, lodash_1.camelCase)(fs.fields.title.inputValue) + new Date().toISOString().split('T')[0];
11
+ collectionId = slug(fs.fields.title.inputValue);
13
12
  }
14
13
  const productCollectionAttributes = {
15
14
  documentId: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.documentId) || '',
@@ -23,6 +22,7 @@ class ProductCollectionFromFormState extends ProductCollectionFactory_1.default
23
22
  refinements: fs.fields.refinements.selectedValue || {},
24
23
  tags: fs.fields.tags.selectedValues || [],
25
24
  collectionId,
25
+ isExclusive: fs.fields.isExclusive.selectedValue || '',
26
26
  };
27
27
  return new ProductCollection_1.default(Object.assign({}, productCollectionAttributes));
28
28
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
4
  const ProductCollection_1 = require("../../models/ProductCollection");
5
5
  const ProductCollectionFromFormState_1 = require("../../factories/ProductCollection/ProductCollectionFromFormState");
6
- // @ts-ignore
7
- const lodash_1 = require("lodash");
6
+ const slug = require("slug");
7
+ const options_1 = require("../Product/options");
8
8
  class ProductCollectionFormState extends FormState_1.default {
9
9
  constructor(props, opts) {
10
10
  super();
@@ -20,6 +20,7 @@ class ProductCollectionFormState extends FormState_1.default {
20
20
  this.fields.refinements = this.fieldFactory('singleSelect', 'refinements');
21
21
  this.fields.tags = this.fieldFactory('multiSelect', 'tags', []);
22
22
  this.fields.collectionId = this.fieldFactory('textInput', 'collectionId');
23
+ this.fields.isExclusive = this.fieldFactory('singleSelect', 'isExclusive', options_1.productYesNoOptions);
23
24
  }
24
25
  createProductCollection() {
25
26
  const productCollectionFactory = new ProductCollectionFromFormState_1.default();
@@ -43,7 +44,7 @@ class ProductCollectionFormState extends FormState_1.default {
43
44
  const valid = !!this.props[fieldKey];
44
45
  let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
45
46
  if (fieldKey === 'collectionId') {
46
- onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, (0, lodash_1.camelCase)(String(val)));
47
+ onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, slug(String(val)));
47
48
  }
48
49
  return {
49
50
  inputValue,
@@ -13,6 +13,7 @@ export default class ProductCollection extends Base {
13
13
  refinements: ProductRefinements;
14
14
  tags: string[];
15
15
  collectionId: string;
16
+ isExclusive: string;
16
17
  constructor(props?: any);
17
18
  toObj(): ProductCollectionType;
18
19
  generateSchemaForTypesense(name?: string): {
@@ -17,6 +17,7 @@ class ProductCollection extends Base_1.default {
17
17
  this.tags = (props === null || props === void 0 ? void 0 : props.tags) || [];
18
18
  this.collectionId = (props === null || props === void 0 ? void 0 : props.collectionId) || '';
19
19
  this.imageUrls = (props === null || props === void 0 ? void 0 : props.imageUrls) || [];
20
+ this.isExclusive = (props === null || props === void 0 ? void 0 : props.isExclusive) || '';
20
21
  }
21
22
  toObj() {
22
23
  const productCollectionObj = {
@@ -33,6 +34,7 @@ class ProductCollection extends Base_1.default {
33
34
  tags: this.tags,
34
35
  collectionId: this.collectionId,
35
36
  imageUrls: this.imageUrls,
37
+ isExclusive: this.isExclusive,
36
38
  };
37
39
  return productCollectionObj;
38
40
  }
@@ -185,6 +187,11 @@ class ProductCollection extends Base_1.default {
185
187
  name: 'collectionId',
186
188
  type: 'string',
187
189
  },
190
+ {
191
+ facet: true,
192
+ name: 'isExclusive',
193
+ type: 'string',
194
+ },
188
195
  ],
189
196
  name: 'dev_productCollections_20220726',
190
197
  };
@@ -218,6 +225,7 @@ class ProductCollection extends Base_1.default {
218
225
  tags: this.utilities.sanitzeStringArr(this.tags),
219
226
  imageUrls: this.utilities.sanitzeStringArr(this.imageUrls),
220
227
  collectionId: this.utilities.sanitizeString(this.collectionId),
228
+ isExclusive: this.utilities.sanitizeString(this.isExclusive),
221
229
  };
222
230
  return stagedObj;
223
231
  }
@@ -49,6 +49,7 @@ type ProductCollectionType = {
49
49
  tags: string[];
50
50
  collectionId: string;
51
51
  imageUrls: string[];
52
+ isExclusive: string;
52
53
  };
53
54
  type CompleteProductCollection = ProductCollectionType & {
54
55
  [key: string]: any;
@@ -64,6 +65,7 @@ type ProductCollectionFormFields = {
64
65
  tags: MultiSelectFormField<string>;
65
66
  imageUrls: MultiSelectFormField<string>;
66
67
  collectionId: TextInputFormField<string>;
68
+ isExclusive: SingleSelectFormField<string>;
67
69
  };
68
70
  type TypesenseProductCollectionObj = {
69
71
  id: string;
@@ -93,4 +95,5 @@ type TypesenseProductCollectionObj = {
93
95
  tags: string[];
94
96
  imageUrls: string[];
95
97
  collectionId: string;
98
+ isExclusive: string;
96
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.9.5",
3
+ "version": "3.9.7",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -29,6 +29,7 @@
29
29
  "homepage": "https://github.com/ReRobe/rerobe-product#readme",
30
30
  "devDependencies": {
31
31
  "@types/jest": "^26.0.23",
32
+ "@types/slug": "^5.0.9",
32
33
  "jest": "^26.6.3",
33
34
  "prettier": "^2.3.0",
34
35
  "ts-jest": "^26.5.6",
@@ -41,6 +42,7 @@
41
42
  ],
42
43
  "dependencies": {
43
44
  "js-base64": "^3.3.3",
44
- "lodash": "^4.17.21"
45
+ "lodash": "^4.17.21",
46
+ "slug": "^9.1.0"
45
47
  }
46
48
  }