rerobe-js-orm 2.4.53 → 2.4.57

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.
Files changed (74) hide show
  1. package/lib/factories/FormState/Address/AddressFormStateFactory.d.ts +1 -1
  2. package/lib/factories/FormState/Address/AddressFormStateFactory.js +1 -1
  3. package/lib/factories/FormState/Merchant/MerchantFormStateFactory.d.ts +1 -1
  4. package/lib/factories/FormState/Merchant/MerchantFormStateFactory.js +1 -1
  5. package/lib/factories/FormState/Order/OrderFormStateFactory.d.ts +1 -1
  6. package/lib/factories/FormState/Order/OrderFormStateFactory.js +1 -1
  7. package/lib/factories/FormState/Order/RefundFormStateFactory.d.ts +1 -1
  8. package/lib/factories/FormState/Order/RefundFormStateFactory.js +1 -1
  9. package/lib/factories/FormState/PickUp/PickUpFormStateFactory.d.ts +1 -1
  10. package/lib/factories/FormState/PickUp/PickUpFormStateFactory.js +1 -1
  11. package/lib/factories/FormState/Product/ProductFormStateFactory.d.ts +1 -1
  12. package/lib/factories/FormState/Product/ProductFormStateFactory.js +1 -1
  13. package/lib/factories/FormState/SellRequest/SellRequestFormStateFactory.d.ts +1 -1
  14. package/lib/factories/FormState/SellRequest/SellRequestFormStateFactory.js +1 -1
  15. package/lib/factories/FormState/User/UserFormStateFactory.d.ts +1 -1
  16. package/lib/factories/FormState/User/UserFormStateFactory.js +1 -1
  17. package/lib/factories/Merchant/MerchantFactory.d.ts +1 -1
  18. package/lib/factories/Merchant/MerchantFromFormState.d.ts +1 -1
  19. package/lib/factories/Merchant/MerchantFromFormState.js +1 -0
  20. package/lib/factories/Order/OrderFactory.d.ts +1 -1
  21. package/lib/factories/Order/OrderFromFormState.d.ts +1 -1
  22. package/lib/factories/Order/OrderFromFormState.js +2 -1
  23. package/lib/factories/Order/RefundFactory.d.ts +1 -1
  24. package/lib/factories/Order/RefundFromFormState.d.ts +1 -1
  25. package/lib/factories/PayoutAccount/PayoutAccountFromFormState.d.ts +1 -1
  26. package/lib/factories/Product/ProductFactory.d.ts +1 -1
  27. package/lib/factories/Product/ProductFromFormState.d.ts +1 -1
  28. package/lib/factories/Product/ProductFromFormState.js +7 -6
  29. package/lib/factories/User/UserFactory.d.ts +1 -1
  30. package/lib/factories/User/UserFromFormState.d.ts +1 -1
  31. package/lib/{models/FormStates → form-states}/Address/AddressFormState.d.ts +0 -0
  32. package/lib/{models/FormStates → form-states}/Address/AddressFormState.js +1 -3
  33. package/lib/{models/FormStates → form-states}/FormState.d.ts +1 -1
  34. package/lib/{models/FormStates → form-states}/FormState.js +1 -1
  35. package/lib/{models/FormStates → form-states}/Merchant/MerchantFormState.d.ts +1 -1
  36. package/lib/{models/FormStates → form-states}/Merchant/MerchantFormState.js +19 -4
  37. package/lib/form-states/Merchant/WebhookFormState.d.ts +8 -0
  38. package/lib/form-states/Merchant/WebhookFormState.js +52 -0
  39. package/lib/{models/FormStates → form-states}/Merchant/options.d.ts +8 -0
  40. package/lib/{models/FormStates → form-states}/Merchant/options.js +15 -2
  41. package/lib/{models/FormStates → form-states}/Order/OrderFormState.d.ts +2 -2
  42. package/lib/{models/FormStates → form-states}/Order/OrderFormState.js +3 -3
  43. package/lib/{models/FormStates → form-states}/Order/RefundFormState.d.ts +1 -1
  44. package/lib/{models/FormStates → form-states}/Order/RefundFormState.js +2 -2
  45. package/lib/{models/FormStates → form-states}/Order/options.d.ts +0 -0
  46. package/lib/{models/FormStates → form-states}/Order/options.js +0 -0
  47. package/lib/{models/FormStates → form-states}/PayoutAccount/PayoutAccountFormState.d.ts +1 -1
  48. package/lib/{models/FormStates → form-states}/PayoutAccount/PayoutAccountFormState.js +2 -2
  49. package/lib/{models/FormStates → form-states}/PayoutAccount/options.d.ts +0 -0
  50. package/lib/{models/FormStates → form-states}/PayoutAccount/options.js +0 -0
  51. package/lib/{models/FormStates → form-states}/PickUp/PickUpFormState.d.ts +0 -0
  52. package/lib/{models/FormStates → form-states}/PickUp/PickUpFormState.js +0 -0
  53. package/lib/{models/FormStates → form-states}/Product/ProductFormState.d.ts +1 -1
  54. package/lib/{models/FormStates → form-states}/Product/ProductFormState.js +2 -2
  55. package/lib/{models/FormStates → form-states}/Product/options.d.ts +0 -0
  56. package/lib/{models/FormStates → form-states}/Product/options.js +0 -0
  57. package/lib/{models/FormStates → form-states}/SellRequest/SellRequestFormState.d.ts +0 -0
  58. package/lib/{models/FormStates → form-states}/SellRequest/SellRequestFormState.js +1 -1
  59. package/lib/{models/FormStates → form-states}/User/UserFormState.d.ts +1 -1
  60. package/lib/{models/FormStates → form-states}/User/UserFormState.js +2 -2
  61. package/lib/helpers/OrderHelpers.d.ts +3 -0
  62. package/lib/helpers/OrderHelpers.js +53 -0
  63. package/lib/helpers/ReRobeProductHelpers.js +8 -5
  64. package/lib/index.d.ts +4 -3
  65. package/lib/index.js +5 -3
  66. package/lib/models/Merchant.d.ts +6 -0
  67. package/lib/models/Merchant.js +8 -0
  68. package/lib/models/Order.d.ts +1 -0
  69. package/lib/models/Order.js +2 -0
  70. package/lib/models/Product.js +2 -1
  71. package/lib/types/merchant-types.d.ts +12 -0
  72. package/lib/types/rerobe-order-types.d.ts +23 -2
  73. package/lib/types/rerobe-product-types.d.ts +1 -0
  74. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import AddressFormState from '../../../models/FormStates/Address/AddressFormState';
2
+ import AddressFormState from '../../../form-states/Address/AddressFormState';
3
3
  export default class AddressFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: AddressInput): AddressFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const AddressFormState_1 = require("../../../models/FormStates/Address/AddressFormState");
4
+ const AddressFormState_1 = require("../../../form-states/Address/AddressFormState");
5
5
  class AddressFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props) {
7
7
  return new AddressFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import MerchantFormState from '../../../models/FormStates/Merchant/MerchantFormState';
2
+ import MerchantFormState from '../../../form-states/Merchant/MerchantFormState';
3
3
  export default class MerchantFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: MerchantObj): MerchantFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const MerchantFormState_1 = require("../../../models/FormStates/Merchant/MerchantFormState");
4
+ const MerchantFormState_1 = require("../../../form-states/Merchant/MerchantFormState");
5
5
  class MerchantFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props) {
7
7
  return new MerchantFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import OrderFormState from '../../../models/FormStates/Order/OrderFormState';
2
+ import OrderFormState from '../../../form-states/Order/OrderFormState';
3
3
  export default class OrderFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: any, opts?: any): OrderFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const OrderFormState_1 = require("../../../models/FormStates/Order/OrderFormState");
4
+ const OrderFormState_1 = require("../../../form-states/Order/OrderFormState");
5
5
  class OrderFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props, opts) {
7
7
  return new OrderFormState_1.default(props, opts);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import RefundFormState from '../../../models/FormStates/Order/RefundFormState';
2
+ import RefundFormState from '../../../form-states/Order/RefundFormState';
3
3
  export default class RefundFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: any, opts?: any): RefundFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const RefundFormState_1 = require("../../../models/FormStates/Order/RefundFormState");
4
+ const RefundFormState_1 = require("../../../form-states/Order/RefundFormState");
5
5
  class RefundFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props, opts) {
7
7
  return new RefundFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import PickUpFormState from '../../../models/FormStates/PickUp/PickUpFormState';
2
+ import PickUpFormState from '../../../form-states/PickUp/PickUpFormState';
3
3
  export default class PickUpFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: PickUp): PickUpFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const PickUpFormState_1 = require("../../../models/FormStates/PickUp/PickUpFormState");
4
+ const PickUpFormState_1 = require("../../../form-states/PickUp/PickUpFormState");
5
5
  class PickUpFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props) {
7
7
  return new PickUpFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import ProductFormState from '../../../models/FormStates/Product/ProductFormState';
2
+ import ProductFormState from '../../../form-states/Product/ProductFormState';
3
3
  export default class ProductFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: CompleteProduct): ProductFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const ProductFormState_1 = require("../../../models/FormStates/Product/ProductFormState");
4
+ const ProductFormState_1 = require("../../../form-states/Product/ProductFormState");
5
5
  class ProductFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props) {
7
7
  return new ProductFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import SellRequestFormState from '../../../models/FormStates/SellRequest/SellRequestFormState';
2
+ import SellRequestFormState from '../../../form-states/SellRequest/SellRequestFormState';
3
3
  export default class SellRequestFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: SellRequest): SellRequestFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const SellRequestFormState_1 = require("../../../models/FormStates/SellRequest/SellRequestFormState");
4
+ const SellRequestFormState_1 = require("../../../form-states/SellRequest/SellRequestFormState");
5
5
  class SellRequestFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props) {
7
7
  return new SellRequestFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
- import UserFormState from '../../../models/FormStates/User/UserFormState';
2
+ import UserFormState from '../../../form-states/User/UserFormState';
3
3
  export default class UserFormStateFactory extends FormStateFactory {
4
4
  createFormState(props?: UserAttributes): UserFormState;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
- const UserFormState_1 = require("../../../models/FormStates/User/UserFormState");
4
+ const UserFormState_1 = require("../../../form-states/User/UserFormState");
5
5
  class UserFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props) {
7
7
  return new UserFormState_1.default(props);
@@ -1,5 +1,5 @@
1
1
  import Merchant from '../../models/Merchant';
2
- import MerchantFormState from '../../models/FormStates/Merchant/MerchantFormState';
2
+ import MerchantFormState from '../../form-states/Merchant/MerchantFormState';
3
3
  import Base from '../../Base';
4
4
  export default abstract class MerchantFactory extends Base {
5
5
  abstract createMerchant(props: MerchantFormState): Merchant;
@@ -1,6 +1,6 @@
1
1
  import MerchantFactory from './MerchantFactory';
2
2
  import Merchant from '../../models/Merchant';
3
- import MerchantFormState from '../../models/FormStates/Merchant/MerchantFormState';
3
+ import MerchantFormState from '../../form-states/Merchant/MerchantFormState';
4
4
  export default class MerchantFromFormState extends MerchantFactory {
5
5
  createMerchant(fs: MerchantFormState): Merchant;
6
6
  }
@@ -29,6 +29,7 @@ class MerchantFromFormState extends MerchantFactory_1.default {
29
29
  orderTags: (_h = fs.props) === null || _h === void 0 ? void 0 : _h.orderTags,
30
30
  theme: (_j = fs.props) === null || _j === void 0 ? void 0 : _j.theme,
31
31
  webshopTenantId: (_k = fs.props) === null || _k === void 0 ? void 0 : _k.webshopTenantId,
32
+ webhooks: fs.fields.webhooks.selectedValues,
32
33
  };
33
34
  return new Merchant_1.default(Object.assign({}, merchantAttributes));
34
35
  }
@@ -1,5 +1,5 @@
1
1
  import Base from '../../Base';
2
- import OrderFormState from '../../models/FormStates/Order/OrderFormState';
2
+ import OrderFormState from '../../form-states/Order/OrderFormState';
3
3
  import Order from '../../models/Order';
4
4
  export default abstract class OrderFactory extends Base {
5
5
  abstract createOrder(order: ShopifyStorefrontOrderObj | ShopifyAdminOrderObj | ShopifyRestApiOrderObj | OrderFormState | OrderInput): ReRobeOrderObj | Order;
@@ -1,5 +1,5 @@
1
1
  import OrderFactory from './OrderFactory';
2
- import OrderFormState from '../../models/FormStates/Order/OrderFormState';
2
+ import OrderFormState from '../../form-states/Order/OrderFormState';
3
3
  export default class OrderFromFormState extends OrderFactory {
4
4
  createOrder(fs: OrderFormState): ReRobeOrderObj;
5
5
  }
@@ -4,7 +4,7 @@ const OrderFactory_1 = require("./OrderFactory");
4
4
  const Order_1 = require("../../models/Order");
5
5
  class OrderFromFormState extends OrderFactory_1.default {
6
6
  createOrder(fs) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
8
8
  const currencyCode = fs.fields.currencyCode.inputValue || 'SEK';
9
9
  const customer = fs.fields.customer.selectedValue || {};
10
10
  const firstName = fs.fields.firstName.inputValue;
@@ -86,6 +86,7 @@ class OrderFromFormState extends OrderFactory_1.default {
86
86
  paymentDetails: fs.fields.paymentDetails.selectedValue || {},
87
87
  merchantId: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.merchantId) || '',
88
88
  tags: fs.fields.tags.selectedValues || [],
89
+ refunds: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.refunds) || [],
89
90
  };
90
91
  return new Order_1.default(Object.assign({}, orderAttributes));
91
92
  }
@@ -1,5 +1,5 @@
1
1
  import Base from '../../Base';
2
- import RefundFormState from '../../models/FormStates/Order/RefundFormState';
2
+ import RefundFormState from '../../form-states/Order/RefundFormState';
3
3
  export default abstract class RefundFactory extends Base {
4
4
  abstract createRefund(refund: RefundFormState): OrderRefund;
5
5
  }
@@ -1,4 +1,4 @@
1
- import RefundFormState from '../../models/FormStates/Order/RefundFormState';
1
+ import RefundFormState from '../../form-states/Order/RefundFormState';
2
2
  import RefundFactory from './RefundFactory';
3
3
  export default class RefundFromFormState extends RefundFactory {
4
4
  createRefund(fs: RefundFormState): OrderRefund;
@@ -1,6 +1,6 @@
1
1
  import PayoutAccountFactory from './PayoutAccountFactory';
2
2
  import PayoutAccount from '../../models/PayoutAccount';
3
- import PayoutAccountFormState from '../../models/FormStates/PayoutAccount/PayoutAccountFormState';
3
+ import PayoutAccountFormState from '../../form-states/PayoutAccount/PayoutAccountFormState';
4
4
  export default class PayoutAccountFromFormState extends PayoutAccountFactory {
5
5
  createPayoutAccount(props: PayoutAccountFormState): PayoutAccount;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import Product from '../../models/Product';
2
- import ProductFormState from '../../models/FormStates/Product/ProductFormState';
2
+ import ProductFormState from '../../form-states/Product/ProductFormState';
3
3
  import Base from '../../Base';
4
4
  export default abstract class ProductFactory extends Base {
5
5
  abstract createProduct(props: ProductRespFromShopifyWebhook | ProductRespFromShopifyJSClient | ProductRespFromAlgolia | ProductFormState): Product;
@@ -1,6 +1,6 @@
1
1
  import ProductFactory from './ProductFactory';
2
2
  import Product from '../../models/Product';
3
- import ProductFormState from '../../models/FormStates/Product/ProductFormState';
3
+ import ProductFormState from '../../form-states/Product/ProductFormState';
4
4
  export default class ProductFromFormState extends ProductFactory {
5
5
  createProduct(props: ProductFormState): Product;
6
6
  }
@@ -4,7 +4,7 @@ const ProductFactory_1 = require("./ProductFactory");
4
4
  const Product_1 = require("../../models/Product");
5
5
  class ProductFromFormState extends ProductFactory_1.default {
6
6
  createProduct(props) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
8
8
  const productAttributes = {
9
9
  availableForSale: props.fields.availableForSale.selectedValue,
10
10
  description: props.fields.description.inputValue,
@@ -28,9 +28,10 @@ class ProductFromFormState extends ProductFactory_1.default {
28
28
  quantity: props.fields.quantity.inputValue,
29
29
  merchants: ((_l = props.props) === null || _l === void 0 ? void 0 : _l.merchants) || [],
30
30
  editorAuthorizations: props.fields.editorAuthorizations.selectedValue,
31
+ rfidTag: ((_m = props.props) === null || _m === void 0 ? void 0 : _m.rfidTag) || '',
31
32
  };
32
33
  const productFilterAttributes = {
33
- documentId: (_m = props.props) === null || _m === void 0 ? void 0 : _m.documentId,
34
+ documentId: (_o = props.props) === null || _o === void 0 ? void 0 : _o.documentId,
34
35
  brand: props.fields.brand.selectedValue,
35
36
  clothingSize: props.fields.clothingSize.selectedValues,
36
37
  color: props.fields.color.selectedValue,
@@ -47,7 +48,7 @@ class ProductFromFormState extends ProductFactory_1.default {
47
48
  };
48
49
  const consignmentAttributes = {
49
50
  previousSellers: props.fields.previousSellers.selectedValues,
50
- sellRequestId: ((_o = props.props) === null || _o === void 0 ? void 0 : _o.sellRequestId) || '',
51
+ sellRequestId: ((_p = props.props) === null || _p === void 0 ? void 0 : _p.sellRequestId) || '',
51
52
  publishType: props.fields.publishType.selectedValue,
52
53
  conditionRemarks: props.fields.conditionRemarks.inputValue,
53
54
  productRemarks: props.fields.productRemarks.inputValue,
@@ -60,18 +61,18 @@ class ProductFromFormState extends ProductFactory_1.default {
60
61
  nextAvailableSeason: props.fields.nextAvailableSeason.selectedValue,
61
62
  notesForProductionTeam: props.fields.notesForProductionTeam.inputValue,
62
63
  reviewedBy: props.fields.reviewedBy.selectedValue,
63
- sellRequestImageUrls: ((_p = props.props) === null || _p === void 0 ? void 0 : _p.sellRequestImageUrls) || [],
64
+ sellRequestImageUrls: ((_q = props.props) === null || _q === void 0 ? void 0 : _q.sellRequestImageUrls) || [],
64
65
  dateSold: props.fields.dateSold.selectedValue || '',
65
66
  dateInQualityControl: props.fields.dateInQualityControl.selectedValue || '',
66
67
  dateInPendingPublication: props.fields.dateInPendingPublication.selectedValue || '',
67
68
  dateListedOnline: props.fields.dateListedOnline.selectedValue || '',
68
69
  salesChannel: props.fields.salesChannel.selectedValues || [],
69
70
  sizeComment: props.fields.sizeComment.selectedValue,
70
- salePrice: ((_q = props.props) === null || _q === void 0 ? void 0 : _q.salePrice) || '',
71
+ salePrice: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.salePrice) || '',
71
72
  isOnSale: props.fields.isOnSale.selectedValue || '',
72
73
  discountType: props.fields.discountType.selectedValue || '',
73
74
  discountValue: props.fields.discountValue.inputValue || '',
74
- selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
75
+ selectedForClearance: ((_s = props.props) === null || _s === void 0 ? void 0 : _s.selectedForClearance) || '',
75
76
  };
76
77
  return new Product_1.default(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes));
77
78
  }
@@ -1,5 +1,5 @@
1
1
  import User from '../../models/User';
2
- import UserFormState from '../../models/FormStates/User/UserFormState';
2
+ import UserFormState from '../../form-states/User/UserFormState';
3
3
  import Base from '../../Base';
4
4
  export default abstract class UserFactory extends Base {
5
5
  abstract createUser(props: UserFormState | UserRespFromShopifyWebhook | UserObjForAuthTemplateMethod): User;
@@ -1,6 +1,6 @@
1
1
  import UserFactory from './UserFactory';
2
2
  import User from '../../models/User';
3
- import UserFormState from '../../models/FormStates/User/UserFormState';
3
+ import UserFormState from '../../form-states/User/UserFormState';
4
4
  export default class UserFromFormState extends UserFactory {
5
5
  createUser(props: UserFormState): User;
6
6
  }
@@ -32,9 +32,7 @@ class AddressFormState extends FormState_1.default {
32
32
  zip: this.fields.zip.inputValue,
33
33
  };
34
34
  }
35
- fieldFactory(fieldType, fieldKey, fieldOptions) {
36
- const options = fieldOptions || [];
37
- const hidden = false;
35
+ fieldFactory(fieldType, fieldKey) {
38
36
  if (fieldType === 'textInput') {
39
37
  const inputValue = this.props[fieldKey] || '';
40
38
  const valid = !!this.props[fieldKey];
@@ -1,4 +1,4 @@
1
- import Base from '../../Base';
1
+ import Base from '../Base';
2
2
  export default abstract class FormState extends Base {
3
3
  fields: FormStateObject;
4
4
  singleSelectChangeHandler<T>(key: keyof FormStateObject, value: T): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Base_1 = require("../../Base");
3
+ const Base_1 = require("../Base");
4
4
  class FormState extends Base_1.default {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -1,5 +1,5 @@
1
1
  import FormState from '../FormState';
2
- import Merchant from '../../Merchant';
2
+ import Merchant from '../../models/Merchant';
3
3
  export default class MerchantFormState extends FormState {
4
4
  fields: MerchantFormFields;
5
5
  props: MerchantObj;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
- const Merchant_1 = require("../../Merchant");
5
- const MerchantFromFormState_1 = require("../../../factories/Merchant/MerchantFromFormState");
4
+ const Merchant_1 = require("../../models/Merchant");
5
+ const MerchantFromFormState_1 = require("../../factories/Merchant/MerchantFromFormState");
6
6
  const options_1 = require("./options");
7
7
  class MerchantFormState extends FormState_1.default {
8
8
  constructor(props) {
@@ -21,6 +21,7 @@ class MerchantFormState extends FormState_1.default {
21
21
  this.fields.timeZone = this.fieldFactory('singleSelect', 'timeZone', options_1.timeZoneOptions);
22
22
  this.fields.unitSystem = this.fieldFactory('singleSelect', 'unitSystem', options_1.unitSystemOptions);
23
23
  this.fields.defaultWeightUnit = this.fieldFactory('singleSelect', 'defaultWeightUnit');
24
+ this.fields.webhooks = this.fieldFactory('multiSelect', 'webhooks');
24
25
  }
25
26
  createMerchant() {
26
27
  const merchantFactory = new MerchantFromFormState_1.default();
@@ -28,7 +29,7 @@ class MerchantFormState extends FormState_1.default {
28
29
  }
29
30
  fieldFactory(fieldType, fieldKey, fieldOptions) {
30
31
  const options = fieldOptions || [];
31
- if (fieldType === 'textInput' && fieldKey !== 'address') {
32
+ if (fieldType === 'textInput' && fieldKey !== 'address' && fieldKey !== 'webhooks') {
32
33
  const inputValue = this.props[fieldKey] || '';
33
34
  const valid = !!this.props[fieldKey];
34
35
  let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
@@ -50,7 +51,21 @@ class MerchantFormState extends FormState_1.default {
50
51
  onChangeHandler,
51
52
  };
52
53
  }
53
- if (fieldType === 'singleSelect') {
54
+ if (fieldType === 'multiSelect') {
55
+ let selectedValues = [];
56
+ let valid = false;
57
+ if (fieldKey === 'webhooks') {
58
+ selectedValues = this.props.webhooks || [];
59
+ valid = true;
60
+ }
61
+ return {
62
+ options,
63
+ selectedValues,
64
+ valid,
65
+ onChangeHandler: (val) => this.multiSelectChangeHandler(fieldKey, val),
66
+ };
67
+ }
68
+ if (fieldType === 'singleSelect' && fieldKey !== 'webhooks') {
54
69
  let selectedValue = '';
55
70
  let valid = true;
56
71
  let onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
@@ -0,0 +1,8 @@
1
+ import FormState from '../FormState';
2
+ export default class WebhookFormState extends FormState {
3
+ fields: WebhookFormFields;
4
+ props: MerchantWebHook;
5
+ constructor(props?: any);
6
+ toObj(): MerchantWebHook;
7
+ private fieldFactory;
8
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FormState_1 = require("../FormState");
4
+ const options_1 = require("./options");
5
+ class WebhookFormState extends FormState_1.default {
6
+ constructor(props) {
7
+ super();
8
+ this.props = {
9
+ key: (props === null || props === void 0 ? void 0 : props.key) || '',
10
+ method: (props === null || props === void 0 ? void 0 : props.method) || '',
11
+ url: (props === null || props === void 0 ? void 0 : props.url) || '',
12
+ };
13
+ this.fields.key = this.fieldFactory('singleSelect', 'key', options_1.webhookKeyOptions);
14
+ this.fields.method = this.fieldFactory('singleSelect', 'method', options_1.httpRequestMethodOptions);
15
+ this.fields.url = this.fieldFactory('textInput', 'url');
16
+ }
17
+ toObj() {
18
+ return {
19
+ key: this.fields.key.selectedValue,
20
+ method: this.fields.method.selectedValue,
21
+ url: this.fields.url.inputValue,
22
+ };
23
+ }
24
+ fieldFactory(fieldType, fieldKey, fieldOptions) {
25
+ if (fieldType === 'singleSelect') {
26
+ const options = fieldOptions || [];
27
+ const selectedValue = this.props[fieldKey] || '';
28
+ const valid = !!this.props[fieldKey];
29
+ const onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, String(val));
30
+ return {
31
+ options,
32
+ selectedValue,
33
+ valid,
34
+ onChangeHandler,
35
+ };
36
+ }
37
+ if (fieldType === 'textInput') {
38
+ const inputValue = this.props[fieldKey] || '';
39
+ const valid = !!this.props[fieldKey];
40
+ const onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
41
+ return {
42
+ inputValue,
43
+ valid,
44
+ onChangeHandler,
45
+ };
46
+ }
47
+ return {
48
+ valid: false,
49
+ };
50
+ }
51
+ }
52
+ exports.default = WebhookFormState;
@@ -27,3 +27,11 @@ export const timeZoneOptions: {
27
27
  label: string;
28
28
  value: string;
29
29
  }[];
30
+ export const webhookKeyOptions: {
31
+ label: string;
32
+ value: string;
33
+ }[];
34
+ export const httpRequestMethodOptions: {
35
+ label: string;
36
+ value: string;
37
+ }[];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timeZoneOptions = exports.currencyOptions = exports.imperialWeightOptions = exports.metricWeightOptions = exports.unitSystemOptions = exports.industryOptions = exports.paymentTierOptions = exports.merchantTypeOptions = void 0;
4
- const Merchant_1 = require("../../Merchant");
3
+ exports.httpRequestMethodOptions = exports.webhookKeyOptions = exports.timeZoneOptions = exports.currencyOptions = exports.imperialWeightOptions = exports.metricWeightOptions = exports.unitSystemOptions = exports.industryOptions = exports.paymentTierOptions = exports.merchantTypeOptions = void 0;
4
+ const Merchant_1 = require("../../models/Merchant");
5
5
  const merchantTypeOptions = [
6
6
  { label: 'Individual', value: Merchant_1.default.MERCHANT_TYPES.individual },
7
7
  { label: 'Business', value: Merchant_1.default.MERCHANT_TYPES.business },
@@ -362,3 +362,16 @@ const tzArr = [
362
362
  ];
363
363
  const timeZoneOptions = tzArr.map((tz) => ({ label: `${tz[2]}`, value: `${tz[2]}` }));
364
364
  exports.timeZoneOptions = timeZoneOptions;
365
+ const webhookKeyOptions = [
366
+ { label: 'Create Product', value: Merchant_1.default.RIBBN_WEBHOOK_DICT.createProductWebhook },
367
+ { label: 'Update Product', value: Merchant_1.default.RIBBN_WEBHOOK_DICT.updateProductWebhook },
368
+ { label: 'Delete Product', value: Merchant_1.default.RIBBN_WEBHOOK_DICT.deleteProductWebhook },
369
+ ];
370
+ exports.webhookKeyOptions = webhookKeyOptions;
371
+ const httpRequestMethodOptions = [
372
+ { label: 'GET', value: 'GET' },
373
+ { label: 'POST', value: 'POST' },
374
+ { label: 'PUT', value: 'PUT' },
375
+ { label: 'DELETE', value: 'DELETE' },
376
+ ];
377
+ exports.httpRequestMethodOptions = httpRequestMethodOptions;
@@ -1,6 +1,6 @@
1
1
  import FormState from '../FormState';
2
- import Order from '../../Order';
3
- import OrderHelpers from '../../../helpers/OrderHelpers';
2
+ import Order from '../../models/Order';
3
+ import OrderHelpers from '../../helpers/OrderHelpers';
4
4
  export default class OrderFormState extends FormState {
5
5
  fields: OrderAttributesFormFields;
6
6
  props: CompleteOrder;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
- const Order_1 = require("../../Order");
5
- const OrderFromFormState_1 = require("../../../factories/Order/OrderFromFormState");
6
- const OrderHelpers_1 = require("../../../helpers/OrderHelpers");
4
+ const Order_1 = require("../../models/Order");
5
+ const OrderFromFormState_1 = require("../../factories/Order/OrderFromFormState");
6
+ const OrderHelpers_1 = require("../../helpers/OrderHelpers");
7
7
  const options_1 = require("./options");
8
8
  class OrderFormState extends FormState_1.default {
9
9
  constructor(props, opts) {
@@ -1,5 +1,5 @@
1
1
  import FormState from '../FormState';
2
- import Refund from '../../Refund';
2
+ import Refund from '../../models/Refund';
3
3
  export default class RefundFormState extends FormState {
4
4
  fields: OrderRefundFormFields;
5
5
  props: CompleteRefund;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
- const RefundFromFormState_1 = require("../../../factories/Order/RefundFromFormState");
5
- const Refund_1 = require("../../Refund");
4
+ const RefundFromFormState_1 = require("../../factories/Order/RefundFromFormState");
5
+ const Refund_1 = require("../../models/Refund");
6
6
  class RefundFormState extends FormState_1.default {
7
7
  constructor(props) {
8
8
  super();
@@ -1,5 +1,5 @@
1
1
  import FormState from '../FormState';
2
- import PayoutAccount from '../../../models/PayoutAccount';
2
+ import PayoutAccount from '../../models/PayoutAccount';
3
3
  export default class PayoutAccountFormState extends FormState {
4
4
  fields: PayoutAccountFormFields;
5
5
  props: PayoutAccountObj;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
- const PayoutAccount_1 = require("../../../models/PayoutAccount");
4
+ const PayoutAccount_1 = require("../../models/PayoutAccount");
5
5
  const options_1 = require("./options");
6
- const PayoutAccountFromFormState_1 = require("../../../factories/PayoutAccount/PayoutAccountFromFormState");
6
+ const PayoutAccountFromFormState_1 = require("../../factories/PayoutAccount/PayoutAccountFromFormState");
7
7
  class PayoutAccountFormState extends FormState_1.default {
8
8
  constructor(props) {
9
9
  super();
@@ -1,5 +1,5 @@
1
1
  import FormState from '../FormState';
2
- import Product from '../../../models/Product';
2
+ import Product from '../../models/Product';
3
3
  export default class ProductFormState extends FormState {
4
4
  fields: ProductFormFields;
5
5
  props: CompleteProduct;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
4
  const options_1 = require("./options");
5
- const Product_1 = require("../../../models/Product");
6
- const ProductFromFormState_1 = require("../../../factories/Product/ProductFromFormState");
5
+ const Product_1 = require("../../models/Product");
6
+ const ProductFromFormState_1 = require("../../factories/Product/ProductFromFormState");
7
7
  class ProductFormState extends FormState_1.default {
8
8
  constructor(props) {
9
9
  super();
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
- const Product_1 = require("../../../models/Product");
4
+ const Product_1 = require("../../models/Product");
5
5
  class SellRequestFormState extends FormState_1.default {
6
6
  constructor(sellRequest) {
7
7
  super();
@@ -1,5 +1,5 @@
1
1
  import FormState from '../FormState';
2
- import User from '../../User';
2
+ import User from '../../models/User';
3
3
  export default class UserFormState extends FormState {
4
4
  fields: UserFormFields;
5
5
  props: UserAttributes;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormState_1 = require("../FormState");
4
- const User_1 = require("../../User");
5
- const UserFromFormState_1 = require("../../../factories/User/UserFromFormState");
4
+ const User_1 = require("../../models/User");
5
+ const UserFromFormState_1 = require("../../factories/User/UserFromFormState");
6
6
  class UserFormState extends FormState_1.default {
7
7
  constructor(props) {
8
8
  super();
@@ -4,4 +4,7 @@ export default class OrderHelpers {
4
4
  getPaymentTypeUsingTags(tags: string | null | undefined): string | null;
5
5
  getSalesChannelUsingTags(tags: string | null | undefined): string | null;
6
6
  buildLineItemFromProduct(product: CompleteProduct, currencyCode: string, quantity?: number): ReRobeOrderLineItem;
7
+ fixPrice(price: number | string): string;
8
+ getAmountSumByField(array: OrderRefund[], fieldKey: string): number;
9
+ getOrderInfoWithRefunds(order: CompleteOrder): OrderWithRefundsInfoObj;
7
10
  }
@@ -77,5 +77,58 @@ class OrderHelpers {
77
77
  productId: product.documentId,
78
78
  };
79
79
  }
80
+ fixPrice(price) {
81
+ return Number(price).toFixed(2);
82
+ }
83
+ getAmountSumByField(array, fieldKey) {
84
+ return array.map((item) => Number(item[fieldKey].amount)).reduce((a, b) => a + b, 0);
85
+ }
86
+ getOrderInfoWithRefunds(order) {
87
+ var _a;
88
+ const orderRefunds = order.refunds || [];
89
+ const preparedOrder = {
90
+ documentId: order.documentId || '',
91
+ currencyCode: order.currencyCode,
92
+ fulfillmentStatus: order.fulfillmentStatus || '',
93
+ totalDiscount: order.totalDiscount ? Object.assign({}, order.totalDiscount) : { amount: 0 },
94
+ totalTax: order.totalTax ? Object.assign({}, order.totalTax) : { amount: 0 },
95
+ subtotalPrice: order.subtotalPrice ? Object.assign({}, order.subtotalPrice) : { amount: 0 },
96
+ totalRefunded: order.totalRefunded ? Object.assign({}, order.totalRefunded) : { amount: 0 },
97
+ totalShippingPrice: order.totalShippingPrice ? Object.assign({}, order.totalShippingPrice) : { amount: 0 },
98
+ totalPrice: order.totalPrice ? Object.assign({}, order.totalPrice) : { amount: 0 },
99
+ lineItems: order.lineItems,
100
+ discountType: 'Custom discount',
101
+ shippingRate: 'Custom shipping rate',
102
+ refundedItems: [],
103
+ orderRefunds,
104
+ };
105
+ if (!orderRefunds.length) {
106
+ return preparedOrder;
107
+ }
108
+ preparedOrder.totalDiscount.amount =
109
+ Number(order.totalDiscount.amount) - this.getAmountSumByField(orderRefunds, 'refundDiscount');
110
+ preparedOrder.subtotalPrice.amount =
111
+ Number(order.subtotalPrice.amount) - this.getAmountSumByField(orderRefunds, 'subtotalRefunded');
112
+ preparedOrder.totalShippingPrice.amount =
113
+ Number(((_a = order.totalShippingPrice) === null || _a === void 0 ? void 0 : _a.amount) || 0) - this.getAmountSumByField(orderRefunds, 'refundShipping');
114
+ preparedOrder.totalPrice.amount =
115
+ Number(order.totalPrice.amount) - this.getAmountSumByField(orderRefunds, 'totalRefunded');
116
+ const lineItemsWithRefundedQuantity = order.lineItems.map((item) => {
117
+ const currentItem = item.productId;
118
+ const refundedQuantity = orderRefunds.reduce((result, { refundLineItems }) => {
119
+ if (refundLineItems.length) {
120
+ const refundProdItem = refundLineItems.find(({ lineItem }) => lineItem.productId === currentItem);
121
+ if (refundProdItem) {
122
+ result = result + Number(refundProdItem.quantityRefund);
123
+ }
124
+ }
125
+ return result;
126
+ }, 0);
127
+ return Object.assign(Object.assign({}, item), { quantity: Number(item.quantity) - refundedQuantity, refundedQuantity });
128
+ });
129
+ preparedOrder.lineItems = lineItemsWithRefundedQuantity.filter(({ quantity }) => quantity > 0);
130
+ preparedOrder.refundedItems = lineItemsWithRefundedQuantity.filter(({ refundedQuantity }) => refundedQuantity > 0);
131
+ return preparedOrder;
132
+ }
80
133
  }
81
134
  exports.default = OrderHelpers;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-ignore
4
4
  const lodash_1 = require("lodash");
5
- const options_1 = require("../models/FormStates/Product/options");
5
+ const options_1 = require("../form-states/Product/options");
6
6
  const ProductStateManager_1 = require("../models/ProductStateManager");
7
7
  class ReRobeProductHelpers {
8
8
  static calculateProductionFee(commission) {
@@ -45,13 +45,16 @@ class ReRobeProductHelpers {
45
45
  return '';
46
46
  }
47
47
  static measurementsJoinedString(measurementsObj = {}) {
48
- if (measurementsObj && Object.keys(measurementsObj).length > 0) {
48
+ if (measurementsObj && Object.values(measurementsObj).filter((e) => e).length > 0) {
49
49
  const measurementStr = Object.keys(measurementsObj).reduce((acc, cur) => {
50
50
  let result = acc;
51
51
  if (cur !== 'unit') {
52
- result = acc
53
- ? `${measurementsObj[cur]} ${measurementsObj.unit} ${cur} x ${acc}`
54
- : `${measurementsObj[cur]} ${measurementsObj.unit} ${cur}`;
52
+ if (measurementsObj[cur]) {
53
+ if (acc === '') {
54
+ return (result = `${measurementsObj[cur]} ${measurementsObj.unit} ${cur}`);
55
+ }
56
+ return (result = `${measurementsObj[cur]} ${measurementsObj.unit} ${cur} x ${acc}`);
57
+ }
55
58
  }
56
59
  return result;
57
60
  }, '');
package/lib/index.d.ts CHANGED
@@ -25,9 +25,10 @@ import Merchant from './models/Merchant';
25
25
  import User from './models/User';
26
26
  import ProductStateManager from './models/ProductStateManager';
27
27
  import PayoutAccount from './models/PayoutAccount';
28
- import PayoutAccountFormState from './models/FormStates/PayoutAccount/PayoutAccountFormState';
29
- import MerchantFormState from './models/FormStates/Merchant/MerchantFormState';
28
+ import PayoutAccountFormState from './form-states/PayoutAccount/PayoutAccountFormState';
29
+ import MerchantFormState from './form-states/Merchant/MerchantFormState';
30
+ import WebhookFormState from './form-states/Merchant/WebhookFormState';
30
31
  import ReRobeProductHelpers from './helpers/ReRobeProductHelpers';
31
32
  import AnalyticsHelpers from './helpers/AnalyticsHelpers';
32
33
  import OrderHelpers from './helpers/OrderHelpers';
33
- export { ProductFromAlgoliaJSONDoc, ProductFromShopifyWebhookJSONDoc, ProductFromShopifyJSClientJSONDoc, ProductFormStateFactory, 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, };
34
+ export { ProductFromAlgoliaJSONDoc, ProductFromShopifyWebhookJSONDoc, ProductFromShopifyJSClientJSONDoc, ProductFormStateFactory, 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.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.ProductFormStateFactory = exports.ProductFromShopifyJSClientJSONDoc = exports.ProductFromShopifyWebhookJSONDoc = exports.ProductFromAlgoliaJSONDoc = void 0;
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.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");
@@ -55,10 +55,12 @@ const ProductStateManager_1 = require("./models/ProductStateManager");
55
55
  exports.ProductStateManager = ProductStateManager_1.default;
56
56
  const PayoutAccount_1 = require("./models/PayoutAccount");
57
57
  exports.PayoutAccount = PayoutAccount_1.default;
58
- const PayoutAccountFormState_1 = require("./models/FormStates/PayoutAccount/PayoutAccountFormState");
58
+ const PayoutAccountFormState_1 = require("./form-states/PayoutAccount/PayoutAccountFormState");
59
59
  exports.PayoutAccountFormState = PayoutAccountFormState_1.default;
60
- const MerchantFormState_1 = require("./models/FormStates/Merchant/MerchantFormState");
60
+ const MerchantFormState_1 = require("./form-states/Merchant/MerchantFormState");
61
61
  exports.MerchantFormState = MerchantFormState_1.default;
62
+ const WebhookFormState_1 = require("./form-states/Merchant/WebhookFormState");
63
+ exports.WebhookFormState = WebhookFormState_1.default;
62
64
  const ReRobeProductHelpers_1 = require("./helpers/ReRobeProductHelpers");
63
65
  exports.ReRobeProductHelpers = ReRobeProductHelpers_1.default;
64
66
  const AnalyticsHelpers_1 = require("./helpers/AnalyticsHelpers");
@@ -31,6 +31,11 @@ export default class Merchant extends Base {
31
31
  pound: string;
32
32
  once: string;
33
33
  };
34
+ static RIBBN_WEBHOOK_DICT: {
35
+ createProductWebhook: string;
36
+ updateProductWebhook: string;
37
+ deleteProductWebhook: string;
38
+ };
34
39
  name: string;
35
40
  id: string;
36
41
  type: MerchantTypes | string;
@@ -54,6 +59,7 @@ export default class Merchant extends Base {
54
59
  orderTags: string[];
55
60
  theme: MerchantTheme;
56
61
  webshopTenantId: string;
62
+ webhooks: MerchantWebHook[];
57
63
  constructor(props?: any);
58
64
  toObj(): MerchantObj;
59
65
  }
@@ -48,6 +48,7 @@ class Merchant extends Base_1.default {
48
48
  logoImageWidth: '60',
49
49
  };
50
50
  this.webshopTenantId = (props === null || props === void 0 ? void 0 : props.webshopTenantId) || '';
51
+ this.webhooks = (props === null || props === void 0 ? void 0 : props.webhooks) || [];
51
52
  }
52
53
  toObj() {
53
54
  return {
@@ -74,6 +75,7 @@ class Merchant extends Base_1.default {
74
75
  orderTags: this.orderTags,
75
76
  theme: this.theme,
76
77
  webshopTenantId: this.webshopTenantId,
78
+ webhooks: this.webhooks,
77
79
  };
78
80
  }
79
81
  }
@@ -109,3 +111,9 @@ Merchant.IMPERIAL_WEIGHT_TYPES = {
109
111
  pound: 'POUND',
110
112
  once: 'ONCE',
111
113
  };
114
+ Merchant.RIBBN_WEBHOOK_DICT = {
115
+ createProductWebhook: 'CREATE_PRODUCT_WEBHOOK',
116
+ updateProductWebhook: 'UPDATE_PRODUCT_WEBHOOK',
117
+ deleteProductWebhook: 'DELETE_PRODUCT_WEBHOOK',
118
+ // TODO: Add webhook keys for other models (Orders, User, etc)
119
+ };
@@ -78,6 +78,7 @@ export default class Order extends Base {
78
78
  notes: string;
79
79
  customerName: string;
80
80
  merchantId: string;
81
+ refunds: OrderRefund[];
81
82
  constructor(props?: any);
82
83
  toObj(): ReRobeOrderObj;
83
84
  }
@@ -102,6 +102,7 @@ class Order extends Base_1.default {
102
102
  this.notes = (props === null || props === void 0 ? void 0 : props.notes) || '';
103
103
  this.customerName = (props === null || props === void 0 ? void 0 : props.customerName) || '';
104
104
  this.merchantId = (props === null || props === void 0 ? void 0 : props.merchantId) || '';
105
+ this.refunds = (props === null || props === void 0 ? void 0 : props.refunds) || [];
105
106
  }
106
107
  toObj() {
107
108
  const orderObj = {
@@ -144,6 +145,7 @@ class Order extends Base_1.default {
144
145
  notes: this.notes,
145
146
  customerName: this.customerName,
146
147
  merchantId: this.merchantId,
148
+ refunds: this.refunds,
147
149
  };
148
150
  if (this.paymentType) {
149
151
  orderObj.paymentType = this.paymentType;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const Base_1 = require("../Base");
4
- const options_1 = require("../models/FormStates/Product/options");
4
+ const options_1 = require("../form-states/Product/options");
5
5
  class Product extends Base_1.default {
6
6
  constructor(props) {
7
7
  super();
@@ -29,6 +29,7 @@ class Product extends Base_1.default {
29
29
  quantity: (props === null || props === void 0 ? void 0 : props.quantity) || 0,
30
30
  merchants: (props === null || props === void 0 ? void 0 : props.merchants) || [],
31
31
  editorAuthorizations: (props === null || props === void 0 ? void 0 : props.editorAuthorizations) || {},
32
+ rfidTag: (props === null || props === void 0 ? void 0 : props.rfidTag) || '',
32
33
  // dateInQualityControlTimeStamp: props?.dateInQualityControlTimeStamp || 0,
33
34
  // dateInPendingPublicationTimeStamp: props?.dateInPendingPublicationTimeStamp || 0,
34
35
  // dateListedOnlineTimeStamp: props?.dateListedOnlineTimeStamp || 0,
@@ -21,6 +21,7 @@ declare type MerchantObj = {
21
21
  numProducts: number;
22
22
  orderTags: string[];
23
23
  theme: MerchantTheme;
24
+ webhooks: MerchantWebHook[];
24
25
  webshopTenantId: string;
25
26
  };
26
27
  declare type MerchantTypes = 'INDIVIDUAL' | 'BUSINESS';
@@ -42,6 +43,11 @@ declare type MerchantTheme = {
42
43
  textColor: string;
43
44
  warningColor: string;
44
45
  };
46
+ declare type MerchantWebHook = {
47
+ key: string;
48
+ method: string;
49
+ url: string;
50
+ };
45
51
  declare type MerchantFormFields = {
46
52
  name: TextInputFormField<string>;
47
53
  type: SingleSelectFormField<string>;
@@ -56,4 +62,10 @@ declare type MerchantFormFields = {
56
62
  timeZone: SingleSelectFormField<string>;
57
63
  unitSystem: SingleSelectFormField<string>;
58
64
  defaultWeightUnit: SingleSelectFormField<string>;
65
+ webhooks: MultiSelectFormField<MerchantWebHook>;
66
+ };
67
+ declare type WebhookFormFields = {
68
+ key: SingleSelectFormField<string>;
69
+ method: SingleSelectFormField<string>;
70
+ url: TextInputFormField<string>;
59
71
  };
@@ -32,7 +32,7 @@ declare type ReRobeOrderObj = {
32
32
  paymentType?: ReRobePaymentTypes | string;
33
33
  paymentMethod?: string | null;
34
34
  paymentDetails?: PaymentDetails | null;
35
- salesChannel?: SalesChannels | string;
35
+ salesChannel?: SalesChannels | string | null;
36
36
  shippingAddress?: AddressInput;
37
37
  shippingDiscountAllocations: DiscountAllocation[];
38
38
  shippingLine?: OrderShippingLine;
@@ -58,6 +58,25 @@ declare type ReRobeOrderObj = {
58
58
  notes?: string;
59
59
  customerName?: string;
60
60
  merchantId?: string;
61
+ refunds?: OrderRefund[];
62
+ createdAt?: string;
63
+ updatedAt?: string;
64
+ };
65
+ declare type OrderWithRefundsInfoObj = {
66
+ documentId?: string;
67
+ currencyCode: string;
68
+ fulfillmentStatus?: FulfillmentStatusTypes | string;
69
+ totalDiscount: Money;
70
+ totalPrice: Money;
71
+ totalRefunded?: Money;
72
+ totalShippingPrice?: Money;
73
+ totalTax?: Money;
74
+ subtotalPrice: Money;
75
+ lineItems: ReRobeOrderLineItem[];
76
+ discountType: string;
77
+ shippingRate: string;
78
+ orderRefunds: OrderRefund[];
79
+ refundedItems: ReRobeOrderLineItem[];
61
80
  };
62
81
  declare type OrderInput = {
63
82
  id?: string | null;
@@ -171,7 +190,7 @@ declare type MoneyBag = {
171
190
  };
172
191
  interface OrderLineItem {
173
192
  title: string;
174
- quantity: number;
193
+ quantity: number | string;
175
194
  variant: ProductVariant | null;
176
195
  originalTotalPrice?: Money;
177
196
  originalUnitPrice?: Money;
@@ -182,6 +201,7 @@ interface ReRobeOrderLineItem extends OrderLineItem {
182
201
  brand?: string | null;
183
202
  productId?: string | null;
184
203
  shopifyProductId?: string | number | null;
204
+ refundedQuantity?: number;
185
205
  }
186
206
  declare type OrderLineItemConnection = {
187
207
  edges: OrderLineItemEdge[];
@@ -590,6 +610,7 @@ declare type OrderAttributesFormFields = {
590
610
  paymentMethod: SingleSelectFormField<string>;
591
611
  paymentDetails: SingleSelectFormField<PaymentDetails>;
592
612
  tags: MultiSelectFormField<string>;
613
+ refunds: MultiSelectFormField<OrderRefund>;
593
614
  };
594
615
  declare type OrderRefundFormFields = {
595
616
  totalRefunded: TextInputFormField<string | number>;
@@ -21,6 +21,7 @@ declare type ProductAttributes = {
21
21
  quantity?: number | string;
22
22
  merchants?: string[];
23
23
  editorAuthorizations?: EditorAuthorization;
24
+ rfidTag?: string;
24
25
  };
25
26
  declare type ProductFilterAttributes = {
26
27
  documentId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.53",
3
+ "version": "2.4.57",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",