rerobe-js-orm 3.0.7 → 3.0.8

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.
@@ -4,9 +4,8 @@ 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;
8
- const merchantAttributes = {
9
- id: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.id) || '',
7
+ var _a;
8
+ const MerchantMutableData = {
10
9
  name: fs.fields.name.inputValue,
11
10
  type: fs.fields.type.selectedValue,
12
11
  contactEmail: fs.fields.contactEmail.inputValue,
@@ -18,22 +17,13 @@ class MerchantFromFormState extends MerchantFactory_1.default {
18
17
  currency: fs.fields.currency.selectedValue,
19
18
  timeZone: fs.fields.timeZone.selectedValue,
20
19
  unitSystem: fs.fields.unitSystem.selectedValue,
21
- paymentTier: fs.fields.paymentTier.selectedValue,
22
20
  defaultWeightUnit: fs.fields.defaultWeightUnit.selectedValue,
23
- defaultLocation: (_b = fs.props) === null || _b === void 0 ? void 0 : _b.defaultLocation,
24
- documentId: (_c = fs.props) === null || _c === void 0 ? void 0 : _c.documentId,
25
- numCustomers: (_d = fs.props) === null || _d === void 0 ? void 0 : _d.numCustomers,
26
- numFiles: (_e = fs.props) === null || _e === void 0 ? void 0 : _e.numFiles,
27
- numOrders: (_f = fs.props) === null || _f === void 0 ? void 0 : _f.numOrders,
28
- numProducts: (_g = fs.props) === null || _g === void 0 ? void 0 : _g.numProducts,
29
- webshopTenantId: (_h = fs.props) === null || _h === void 0 ? void 0 : _h.webshopTenantId,
21
+ defaultLocation: (_a = fs.props) === null || _a === void 0 ? void 0 : _a.defaultLocation,
30
22
  webhooks: fs.fields.webhooks.selectedValues,
31
- sharedSecret: (_j = fs.props) === null || _j === void 0 ? void 0 : _j.sharedSecret,
32
- ribbnId: fs.fields.ribbnId.inputValue,
33
23
  primaryDomain: fs.fields.primaryDomain.inputValue,
34
- webshopHomePageId: (_k = fs.props) === null || _k === void 0 ? void 0 : _k.webshopHomePageId,
24
+ socialLinks: fs.fields.socialLinks.selectedValue,
35
25
  };
36
- return new Merchant_1.default(Object.assign({}, merchantAttributes));
26
+ return new Merchant_1.default(Object.assign(Object.assign({}, fs.props), MerchantMutableData));
37
27
  }
38
28
  }
39
29
  exports.default = MerchantFromFormState;
@@ -10,7 +10,6 @@ class MerchantFormState extends FormState_1.default {
10
10
  this.props = new Merchant_1.default(props).toObj();
11
11
  this.fields.name = this.fieldFactory('textInput', 'name');
12
12
  this.fields.type = this.fieldFactory('singleSelect', 'type', options_1.merchantTypeOptions);
13
- this.fields.paymentTier = this.fieldFactory('singleSelect', 'paymentTier', options_1.paymentTierOptions);
14
13
  this.fields.contactEmail = this.fieldFactory('textInput', 'contactEmail');
15
14
  this.fields.senderEmail = this.fieldFactory('textInput', 'senderEmail');
16
15
  this.fields.industry = this.fieldFactory('singleSelect', 'industry', options_1.industryOptions);
@@ -22,8 +21,8 @@ class MerchantFormState extends FormState_1.default {
22
21
  this.fields.unitSystem = this.fieldFactory('singleSelect', 'unitSystem', options_1.unitSystemOptions);
23
22
  this.fields.defaultWeightUnit = this.fieldFactory('singleSelect', 'defaultWeightUnit');
24
23
  this.fields.webhooks = this.fieldFactory('multiSelect', 'webhooks');
25
- this.fields.ribbnId = this.fieldFactory('textInput', 'ribbnId');
26
24
  this.fields.primaryDomain = this.fieldFactory('textInput', 'primaryDomain');
25
+ this.fields.socialLinks = this.fieldFactory('singleSelect', 'socialLinks');
27
26
  }
28
27
  createMerchant() {
29
28
  const merchantFactory = new MerchantFromFormState_1.default();
@@ -31,7 +30,7 @@ class MerchantFormState extends FormState_1.default {
31
30
  }
32
31
  fieldFactory(fieldType, fieldKey, fieldOptions) {
33
32
  const options = fieldOptions || [];
34
- if (fieldType === 'textInput' && fieldKey !== 'address' && fieldKey !== 'webhooks') {
33
+ if (fieldType === 'textInput' && fieldKey !== 'address' && fieldKey !== 'webhooks' && fieldKey !== 'socialLinks') {
35
34
  const inputValue = this.props[fieldKey] || '';
36
35
  const valid = !!this.props[fieldKey];
37
36
  let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
@@ -87,6 +86,20 @@ class MerchantFormState extends FormState_1.default {
87
86
  !!Object.keys(this.props.address).length &&
88
87
  !!Object.values(this.props.address).filter((item) => !!item).length;
89
88
  }
89
+ else if (fieldKey === 'socialLinks') {
90
+ selectedValue = this.props.socialLinks || {
91
+ facebook: '',
92
+ instagram: '',
93
+ linkedIn: '',
94
+ twitter: '',
95
+ pintrest: '',
96
+ tiktok: '',
97
+ };
98
+ valid =
99
+ !!this.props.socialLinks &&
100
+ !!Object.keys(this.props.socialLinks).length &&
101
+ !!Object.values(this.props.socialLinks).filter((item) => !!item).length;
102
+ }
90
103
  else if (fieldKey === 'unitSystem') {
91
104
  onChangeHandler = (val) => this.unitSystemSelectHandler(val);
92
105
  selectedValue = this.props[fieldKey] || '';
@@ -37,7 +37,6 @@ export default class Merchant extends Base {
37
37
  productDelete: string;
38
38
  };
39
39
  name: string;
40
- id: string;
41
40
  type: MerchantTypes | string;
42
41
  paymentTier: RibbnPaymentTiers | string;
43
42
  contactEmail: string;
@@ -62,6 +61,8 @@ export default class Merchant extends Base {
62
61
  ribbnId: string;
63
62
  primaryDomain: string;
64
63
  webshopHomePageId: string;
64
+ socialLinks: SocialLinksType | null;
65
65
  constructor(props?: any);
66
66
  toObj(): MerchantObj;
67
+ toMerchantMutableData(): MerchantMutableData;
67
68
  }
@@ -5,7 +5,6 @@ class Merchant extends Base_1.default {
5
5
  constructor(props) {
6
6
  super();
7
7
  this.name = (props === null || props === void 0 ? void 0 : props.name) || '';
8
- this.id = (props === null || props === void 0 ? void 0 : props.id) || '';
9
8
  this.type = (props === null || props === void 0 ? void 0 : props.type) || Merchant.MERCHANT_TYPES.individual;
10
9
  this.paymentTier = (props === null || props === void 0 ? void 0 : props.paymentTier) || Merchant.PAYMENT_TIERS.free;
11
10
  this.contactEmail = (props === null || props === void 0 ? void 0 : props.contactEmail) || '';
@@ -39,11 +38,18 @@ class Merchant extends Base_1.default {
39
38
  this.ribbnId = (props === null || props === void 0 ? void 0 : props.ribbnId) || '';
40
39
  this.primaryDomain = (props === null || props === void 0 ? void 0 : props.primaryDomain) || '';
41
40
  this.webshopHomePageId = (props === null || props === void 0 ? void 0 : props.webshopHomePageId) || 'home';
41
+ this.socialLinks = (props === null || props === void 0 ? void 0 : props.socialLinks) || {
42
+ facebook: '',
43
+ instagram: '',
44
+ linkedIn: '',
45
+ twitter: '',
46
+ pintrest: '',
47
+ tiktok: '',
48
+ };
42
49
  }
43
50
  toObj() {
44
51
  return {
45
52
  name: this.name,
46
- id: this.id,
47
53
  type: this.type,
48
54
  paymentTier: this.paymentTier,
49
55
  contactEmail: this.contactEmail,
@@ -68,6 +74,27 @@ class Merchant extends Base_1.default {
68
74
  ribbnId: this.ribbnId,
69
75
  primaryDomain: this.primaryDomain,
70
76
  webshopHomePageId: this.webshopHomePageId,
77
+ socialLinks: this.socialLinks,
78
+ };
79
+ }
80
+ toMerchantMutableData() {
81
+ return {
82
+ name: this.name,
83
+ type: this.type,
84
+ contactEmail: this.contactEmail,
85
+ senderEmail: this.senderEmail,
86
+ industry: this.industry,
87
+ legalName: this.legalName,
88
+ phone: this.phone,
89
+ address: this.address,
90
+ currency: this.currency,
91
+ timeZone: this.timeZone,
92
+ unitSystem: this.unitSystem,
93
+ defaultWeightUnit: this.defaultWeightUnit,
94
+ defaultLocation: this.defaultLocation,
95
+ primaryDomain: this.primaryDomain,
96
+ webhooks: this.webhooks,
97
+ socialLinks: this.socialLinks,
71
98
  };
72
99
  }
73
100
  }
@@ -1,8 +1,14 @@
1
- declare type MerchantObj = {
1
+ declare type SocialLinksType = {
2
+ facebook: string;
3
+ instagram: string;
4
+ linkedIn: string;
5
+ twitter: string;
6
+ pintrest: string;
7
+ tiktok: string;
8
+ };
9
+ declare type MerchantMutableData = {
2
10
  name: string;
3
- id: string;
4
11
  type: MerchantTypes | string;
5
- paymentTier: RibbnPaymentTiers | string;
6
12
  contactEmail: string;
7
13
  senderEmail: string;
8
14
  industry: MerchantIndustryTypes | string | null;
@@ -14,18 +20,23 @@ declare type MerchantObj = {
14
20
  unitSystem: UnitSystemTypes | string | null;
15
21
  defaultWeightUnit: MetricWeightTypes | ImperialWeightTypes | string | null;
16
22
  defaultLocation: string;
23
+ primaryDomain: string;
24
+ webhooks: MerchantWebHook[];
25
+ socialLinks: SocialLinksType | null;
26
+ };
27
+ declare type MerchantSystemOnlyMutableData = {
28
+ paymentTier: RibbnPaymentTiers | string;
17
29
  documentId: string;
18
30
  numCustomers: number;
19
31
  numFiles: number;
20
32
  numOrders: number;
21
33
  numProducts: number;
22
- webhooks: MerchantWebHook[];
23
34
  webshopTenantId: string;
24
35
  sharedSecret: string;
25
36
  ribbnId: string;
26
- primaryDomain: string;
27
37
  webshopHomePageId: string;
28
38
  };
39
+ declare type MerchantObj = MerchantMutableData & MerchantSystemOnlyMutableData;
29
40
  declare type MerchantTypes = 'INDIVIDUAL' | 'BUSINESS';
30
41
  declare type RibbnPaymentTiers = 'FREE' | 'TIER_ONE';
31
42
  declare type MerchantIndustryTypes = 'BEAUTY' | 'CLOTHING' | 'ELECTRONICS' | 'FURNITURE' | 'HANDCRAFTS' | 'JEWELRY' | 'SPORTS' | 'TOYS' | 'OTHER';
@@ -52,7 +63,6 @@ declare type MerchantWebHook = {
52
63
  declare type MerchantFormFields = {
53
64
  name: TextInputFormField<string>;
54
65
  type: SingleSelectFormField<string>;
55
- paymentTier: SingleSelectFormField<string>;
56
66
  contactEmail: TextInputFormField<string>;
57
67
  senderEmail: TextInputFormField<string>;
58
68
  industry: SingleSelectFormField<string>;
@@ -64,8 +74,8 @@ declare type MerchantFormFields = {
64
74
  unitSystem: SingleSelectFormField<string>;
65
75
  defaultWeightUnit: SingleSelectFormField<string>;
66
76
  webhooks: MultiSelectFormField<MerchantWebHook>;
67
- ribbnId: TextInputFormField<string>;
68
77
  primaryDomain: TextInputFormField<string>;
78
+ socialLinks: SingleSelectFormField<SocialLinksType>;
69
79
  };
70
80
  declare type WebhookFormFields = {
71
81
  event: SingleSelectFormField<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",