rerobe-js-orm 2.4.68 → 2.4.69
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/lib/factories/ProductCollection/ProductCollectionFromFormState.js +10 -0
- package/lib/form-states/ProductCollection/ProductCollectionFormState.d.ts +1 -2
- package/lib/form-states/ProductCollection/ProductCollectionFormState.js +32 -3
- package/lib/helpers/ProductCollectionHelpers.d.ts +4 -0
- package/lib/helpers/ProductCollectionHelpers.js +27 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +5 -3
- package/lib/models/ProductCollection.d.ts +2 -0
- package/lib/models/ProductCollection.js +4 -0
- package/lib/types/product-collection-types.d.ts +25 -5
- package/package.json +1 -1
|
@@ -2,9 +2,17 @@
|
|
|
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
7
|
class ProductCollectionFromFormState extends ProductCollectionFactory_1.default {
|
|
6
8
|
createProductCollection(fs) {
|
|
9
|
+
var _a;
|
|
10
|
+
let collectionId = fs.fields.collectionId.inputValue;
|
|
11
|
+
if (!collectionId) {
|
|
12
|
+
collectionId = lodash_1.camelCase(fs.fields.title.inputValue) + new Date().toISOString().split('T')[0];
|
|
13
|
+
}
|
|
7
14
|
const productCollectionAttributes = {
|
|
15
|
+
documentId: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.documentId) || '',
|
|
8
16
|
preTitle: fs.fields.preTitle.inputValue || '',
|
|
9
17
|
title: fs.fields.title.inputValue || '',
|
|
10
18
|
subTitle: fs.fields.subTitle.inputValue || '',
|
|
@@ -12,6 +20,8 @@ class ProductCollectionFromFormState extends ProductCollectionFactory_1.default
|
|
|
12
20
|
type: fs.fields.type.selectedValue || '',
|
|
13
21
|
imgUrl: fs.fields.imgUrl.inputValue || '',
|
|
14
22
|
refinements: fs.fields.refinements.selectedValue || {},
|
|
23
|
+
tags: fs.fields.tags.selectedValues || [],
|
|
24
|
+
collectionId,
|
|
15
25
|
};
|
|
16
26
|
return new ProductCollection_1.default(Object.assign({}, productCollectionAttributes));
|
|
17
27
|
}
|
|
@@ -4,8 +4,7 @@ export default class ProductCollectionFormState extends FormState {
|
|
|
4
4
|
fields: ProductCollectionFormFields;
|
|
5
5
|
props: CompleteProductCollection;
|
|
6
6
|
opts: {
|
|
7
|
-
|
|
8
|
-
productAttrValuesOptions: string[];
|
|
7
|
+
tagOptions: string[];
|
|
9
8
|
};
|
|
10
9
|
constructor(props?: any, opts?: any);
|
|
11
10
|
createProductCollection(): ProductCollection;
|
|
@@ -3,6 +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
8
|
class ProductCollectionFormState extends FormState_1.default {
|
|
7
9
|
constructor(props, opts) {
|
|
8
10
|
super();
|
|
@@ -15,17 +17,19 @@ class ProductCollectionFormState extends FormState_1.default {
|
|
|
15
17
|
this.fields.type = this.fieldFactory('singleSelect', 'type');
|
|
16
18
|
this.fields.imgUrl = this.fieldFactory('textInput', 'imgUrl');
|
|
17
19
|
this.fields.refinements = this.fieldFactory('singleSelect', 'refinements');
|
|
20
|
+
this.fields.tags = this.fieldFactory('multiSelect', 'tags', []);
|
|
21
|
+
this.fields.collectionId = this.fieldFactory('textInput', 'collectionId');
|
|
18
22
|
}
|
|
19
23
|
createProductCollection() {
|
|
20
24
|
const productCollectionFactory = new ProductCollectionFromFormState_1.default();
|
|
21
25
|
return productCollectionFactory.createProductCollection(this);
|
|
22
26
|
}
|
|
23
27
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
28
|
+
let options = fieldOptions || [];
|
|
24
29
|
if (fieldType === 'singleSelect') {
|
|
25
|
-
const options = fieldOptions || [];
|
|
26
30
|
const selectedValue = this.props[fieldKey] || '';
|
|
27
31
|
const valid = !!this.props[fieldKey];
|
|
28
|
-
const onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey,
|
|
32
|
+
const onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
29
33
|
return {
|
|
30
34
|
options,
|
|
31
35
|
selectedValue,
|
|
@@ -36,13 +40,38 @@ class ProductCollectionFormState extends FormState_1.default {
|
|
|
36
40
|
if (fieldType === 'textInput') {
|
|
37
41
|
const inputValue = this.props[fieldKey] || '';
|
|
38
42
|
const valid = !!this.props[fieldKey];
|
|
39
|
-
|
|
43
|
+
let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
|
|
44
|
+
if (fieldKey === 'collectionId') {
|
|
45
|
+
onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, lodash_1.camelCase(String(val)));
|
|
46
|
+
}
|
|
40
47
|
return {
|
|
41
48
|
inputValue,
|
|
42
49
|
valid,
|
|
43
50
|
onChangeHandler,
|
|
44
51
|
};
|
|
45
52
|
}
|
|
53
|
+
if (fieldType === 'multiSelect') {
|
|
54
|
+
let selectedValues = [];
|
|
55
|
+
let valid = true;
|
|
56
|
+
const onChangeHandler = (val) => this.multiSelectChangeHandler(fieldKey, val);
|
|
57
|
+
if (fieldKey === 'tags') {
|
|
58
|
+
if (this.props.tags) {
|
|
59
|
+
if (Array.isArray(this.props.tags)) {
|
|
60
|
+
selectedValues = this.props.tags;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (this.opts && this.opts.tagOptions && this.opts.tagOptions.length > 0) {
|
|
64
|
+
options = this.utilities.uniqObjArray([...options, ...this.opts.tagOptions.map((t) => ({ label: t, value: t }))], 'value');
|
|
65
|
+
}
|
|
66
|
+
valid = true;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
options,
|
|
70
|
+
selectedValues,
|
|
71
|
+
valid,
|
|
72
|
+
onChangeHandler,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
46
75
|
return {
|
|
47
76
|
valid: false,
|
|
48
77
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ProductCollectionHelpers {
|
|
4
|
+
getFiltersByCollectionConditions(collectionRefinementsVal) {
|
|
5
|
+
if (!collectionRefinementsVal && !Object.keys(collectionRefinementsVal).length) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
return Object.keys(collectionRefinementsVal).reduce((result, key) => {
|
|
9
|
+
const keyName = key.replace('Refinement', '');
|
|
10
|
+
result[keyName] = collectionRefinementsVal[key];
|
|
11
|
+
return result;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
getCollectionRefinementsFromFilters(filtersList) {
|
|
15
|
+
if (!filtersList && !Object.keys(filtersList).length) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
return Object.keys(filtersList).reduce((result, key) => {
|
|
19
|
+
if (!filtersList[key].length) {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
result[`${key}Refinement`] = [...filtersList[key]];
|
|
23
|
+
return result;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = ProductCollectionHelpers;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import ProductFromShopifyJSClientJSONDoc from './factories/Product/ProductFromSh
|
|
|
2
2
|
import ProductFromAlgoliaJSONDoc from './factories/Product/ProductFromAlgoliaJSONDoc';
|
|
3
3
|
import ProductFromShopifyWebhookJSONDoc from './factories/Product/ProductFromShopifyWebhookJSONDoc';
|
|
4
4
|
import ProductFormStateFactory from './factories/FormState/Product/ProductFormStateFactory';
|
|
5
|
-
import
|
|
5
|
+
import ProductCollectionFormStateFactory from './factories/FormState/ProductCollection/ProductCollectionFormStateFactory';
|
|
6
|
+
import ProductCollectionHelpers from './helpers/ProductCollectionHelpers';
|
|
6
7
|
import SellRequestFormStateFactory from './factories/FormState/SellRequest/SellRequestFormStateFactory';
|
|
7
8
|
import PickUpFormStateFactory from './factories/FormState/PickUp/PickUpFormStateFactory';
|
|
8
9
|
import UserFormStateFactory from './factories/FormState/User/UserFormStateFactory';
|
|
@@ -32,4 +33,4 @@ import WebhookFormState from './form-states/Merchant/WebhookFormState';
|
|
|
32
33
|
import ReRobeProductHelpers from './helpers/ReRobeProductHelpers';
|
|
33
34
|
import AnalyticsHelpers from './helpers/AnalyticsHelpers';
|
|
34
35
|
import OrderHelpers from './helpers/OrderHelpers';
|
|
35
|
-
export { ProductFromAlgoliaJSONDoc, ProductFromShopifyWebhookJSONDoc, ProductFromShopifyJSClientJSONDoc, ProductFormStateFactory,
|
|
36
|
+
export { ProductFromAlgoliaJSONDoc, ProductFromShopifyWebhookJSONDoc, ProductFromShopifyJSClientJSONDoc, ProductFormStateFactory, ProductCollectionFormStateFactory, ProductCollectionHelpers, SellRequestFormStateFactory, PickUpFormStateFactory, AddressFormStateFactory, UserFormStateFactory, UserFromShopifyWebhookJSONDoc, UserFromAuthTemplateMethod, DraftOrderFromMirakl, DraftOrderFromApp, ChatRoomFromNewUserSignUp, KlarnaSessionFactory, Product, ProductStateManager, Order, OrderFromShopifyWebhook, OrderFromShopifyAdminApi, OrderFromShopifyStorefrontApi, OrderFromApp, OrderFormStateFactory, RefundFormStateFactory, PayoutAccount, PayoutAccountFormState, Merchant, MerchantFormState, MerchantFormStateFactory, ReRobeProductHelpers, User, AnalyticsHelpers, OrderHelpers, WebhookFormState, };
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookFormState = exports.OrderHelpers = exports.AnalyticsHelpers = exports.User = exports.ReRobeProductHelpers = exports.MerchantFormStateFactory = exports.MerchantFormState = exports.Merchant = exports.PayoutAccountFormState = exports.PayoutAccount = exports.RefundFormStateFactory = exports.OrderFormStateFactory = exports.OrderFromApp = exports.OrderFromShopifyStorefrontApi = exports.OrderFromShopifyAdminApi = exports.OrderFromShopifyWebhook = exports.Order = exports.ProductStateManager = exports.Product = exports.KlarnaSessionFactory = exports.ChatRoomFromNewUserSignUp = exports.DraftOrderFromApp = exports.DraftOrderFromMirakl = exports.UserFromAuthTemplateMethod = exports.UserFromShopifyWebhookJSONDoc = exports.UserFormStateFactory = exports.AddressFormStateFactory = exports.PickUpFormStateFactory = exports.SellRequestFormStateFactory = exports.
|
|
3
|
+
exports.WebhookFormState = exports.OrderHelpers = exports.AnalyticsHelpers = exports.User = exports.ReRobeProductHelpers = exports.MerchantFormStateFactory = exports.MerchantFormState = exports.Merchant = exports.PayoutAccountFormState = exports.PayoutAccount = exports.RefundFormStateFactory = exports.OrderFormStateFactory = exports.OrderFromApp = exports.OrderFromShopifyStorefrontApi = exports.OrderFromShopifyAdminApi = exports.OrderFromShopifyWebhook = exports.Order = exports.ProductStateManager = exports.Product = exports.KlarnaSessionFactory = exports.ChatRoomFromNewUserSignUp = exports.DraftOrderFromApp = exports.DraftOrderFromMirakl = exports.UserFromAuthTemplateMethod = exports.UserFromShopifyWebhookJSONDoc = exports.UserFormStateFactory = exports.AddressFormStateFactory = exports.PickUpFormStateFactory = exports.SellRequestFormStateFactory = exports.ProductCollectionHelpers = exports.ProductCollectionFormStateFactory = exports.ProductFormStateFactory = exports.ProductFromShopifyJSClientJSONDoc = exports.ProductFromShopifyWebhookJSONDoc = exports.ProductFromAlgoliaJSONDoc = void 0;
|
|
4
4
|
const ProductFromShopifyJSClientJSONDoc_1 = require("./factories/Product/ProductFromShopifyJSClientJSONDoc");
|
|
5
5
|
exports.ProductFromShopifyJSClientJSONDoc = ProductFromShopifyJSClientJSONDoc_1.default;
|
|
6
6
|
const ProductFromAlgoliaJSONDoc_1 = require("./factories/Product/ProductFromAlgoliaJSONDoc");
|
|
@@ -9,8 +9,10 @@ const ProductFromShopifyWebhookJSONDoc_1 = require("./factories/Product/ProductF
|
|
|
9
9
|
exports.ProductFromShopifyWebhookJSONDoc = ProductFromShopifyWebhookJSONDoc_1.default;
|
|
10
10
|
const ProductFormStateFactory_1 = require("./factories/FormState/Product/ProductFormStateFactory");
|
|
11
11
|
exports.ProductFormStateFactory = ProductFormStateFactory_1.default;
|
|
12
|
-
const
|
|
13
|
-
exports.
|
|
12
|
+
const ProductCollectionFormStateFactory_1 = require("./factories/FormState/ProductCollection/ProductCollectionFormStateFactory");
|
|
13
|
+
exports.ProductCollectionFormStateFactory = ProductCollectionFormStateFactory_1.default;
|
|
14
|
+
const ProductCollectionHelpers_1 = require("./helpers/ProductCollectionHelpers");
|
|
15
|
+
exports.ProductCollectionHelpers = ProductCollectionHelpers_1.default;
|
|
14
16
|
const SellRequestFormStateFactory_1 = require("./factories/FormState/SellRequest/SellRequestFormStateFactory");
|
|
15
17
|
exports.SellRequestFormStateFactory = SellRequestFormStateFactory_1.default;
|
|
16
18
|
const PickUpFormStateFactory_1 = require("./factories/FormState/PickUp/PickUpFormStateFactory");
|
|
@@ -12,6 +12,8 @@ class ProductCollection extends Base_1.default {
|
|
|
12
12
|
this.type = (props === null || props === void 0 ? void 0 : props.type) || 'AUTOMATED';
|
|
13
13
|
this.imgUrl = (props === null || props === void 0 ? void 0 : props.imgUrl) || '';
|
|
14
14
|
this.refinements = (props === null || props === void 0 ? void 0 : props.refinements) || {};
|
|
15
|
+
this.tags = (props === null || props === void 0 ? void 0 : props.tags) || [];
|
|
16
|
+
this.collectionId = (props === null || props === void 0 ? void 0 : props.collectionId) || '';
|
|
15
17
|
}
|
|
16
18
|
toObj() {
|
|
17
19
|
const productCollectionObj = {
|
|
@@ -23,6 +25,8 @@ class ProductCollection extends Base_1.default {
|
|
|
23
25
|
type: this.type,
|
|
24
26
|
imgUrl: this.imgUrl,
|
|
25
27
|
refinements: this.refinements,
|
|
28
|
+
tags: this.tags,
|
|
29
|
+
collectionId: this.collectionId,
|
|
26
30
|
};
|
|
27
31
|
return productCollectionObj;
|
|
28
32
|
}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
declare type ProductAttrRefinementsOptions = 'brand' | 'clothingSize' | 'color' | 'condition' | 'gender' | 'jeanSize' | 'materialComposition' | 'priceRange' | 'productCategory' | 'productType' | 'productStyle' | 'shoeSize';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
declare type ProductAttrRefinementsOptions = 'brand' | 'clothingSize' | 'color' | 'condition' | 'gender' | 'jeanSize' | 'materialComposition' | 'priceRange' | 'productCategory' | 'productType' | 'productStyle' | 'shoeSize' | 'status' | 'salesChannel';
|
|
2
|
+
declare type FiltersOptions = 'brandRefinement' | 'clothingSizeRefinement' | 'colorRefinement' | 'conditionRefinement' | 'genderRefinement' | 'jeanSizeRefinement' | 'materialCompositionRefinement' | 'priceRangeRefinement' | 'productCategoryRefinement' | 'productTypeRefinement' | 'productStyleRefinement' | 'shoeSizeRefinement' | 'statusRefinement' | 'salesChannelRefinement';
|
|
3
|
+
declare type FiltersObj = {
|
|
4
|
+
brand?: string[];
|
|
5
|
+
clothingSize?: string[];
|
|
6
|
+
color?: string[];
|
|
7
|
+
condition?: string[];
|
|
8
|
+
gender?: string[];
|
|
9
|
+
jeanSize?: string[];
|
|
10
|
+
materialComposition?: string[];
|
|
11
|
+
priceRange?: string[];
|
|
12
|
+
productCategory?: string[];
|
|
13
|
+
productType?: string[];
|
|
14
|
+
productStyle?: string[];
|
|
15
|
+
shoeSize?: string[];
|
|
16
|
+
status?: string[];
|
|
17
|
+
salesChannel?: string[];
|
|
18
|
+
};
|
|
19
|
+
interface ProductRefinements {
|
|
6
20
|
brandRefinement?: string[];
|
|
7
21
|
clothingSizeRefinement?: string[];
|
|
8
22
|
colorRefinement?: string[];
|
|
@@ -15,6 +29,8 @@ interface ProductRefinements extends Refinements {
|
|
|
15
29
|
productTypeRefinement?: string[];
|
|
16
30
|
productStyleRefinement?: string[];
|
|
17
31
|
shoeSizeRefinement?: string[];
|
|
32
|
+
statusRefinement?: string[];
|
|
33
|
+
salesChannelRefinement?: string[];
|
|
18
34
|
}
|
|
19
35
|
declare type CollectionType = 'AUTOMATED' | 'MANUAL';
|
|
20
36
|
declare type ProductCollectionType = {
|
|
@@ -28,6 +44,8 @@ declare type ProductCollectionType = {
|
|
|
28
44
|
type: CollectionType;
|
|
29
45
|
imgUrl: string;
|
|
30
46
|
refinements: ProductRefinements;
|
|
47
|
+
tags: string[];
|
|
48
|
+
collectionId: string;
|
|
31
49
|
};
|
|
32
50
|
declare type CompleteProductCollection = ProductCollectionType & {
|
|
33
51
|
[key: string]: any;
|
|
@@ -40,4 +58,6 @@ declare type ProductCollectionFormFields = {
|
|
|
40
58
|
type: SingleSelectFormField<CollectionType>;
|
|
41
59
|
imgUrl: TextInputFormField<string>;
|
|
42
60
|
refinements: SingleSelectFormField<ProductRefinements>;
|
|
61
|
+
tags: MultiSelectFormField<string>;
|
|
62
|
+
collectionId: TextInputFormField<string>;
|
|
43
63
|
};
|