@one-commerce/sdk-core 1.18.0-alpha.0 → 1.18.0

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.
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.ShopUtils = exports.ShopConfig = exports.ShopCatalog = exports.ShopCart = exports.ShopAuthorization = exports.ShopAccount = void 0;
8
+ exports.ShopWishlist = exports.ShopUtils = exports.ShopConfig = exports.ShopCatalog = exports.ShopCart = exports.ShopAuthorization = exports.ShopAccount = void 0;
9
9
 
10
10
  var _utils = require("./utils");
11
11
 
@@ -73,15 +73,15 @@ var ShopCatalog = /*#__PURE__*/function (_BaseCallClass) {
73
73
 
74
74
  exports.ShopCatalog = ShopCatalog;
75
75
 
76
- var ShopAccount = /*#__PURE__*/function (_BaseCallClass2) {
77
- _inherits(ShopAccount, _BaseCallClass2);
76
+ var ShopWishlist = /*#__PURE__*/function (_BaseCallClass2) {
77
+ _inherits(ShopWishlist, _BaseCallClass2);
78
78
 
79
- var _super2 = _createSuper(ShopAccount);
79
+ var _super2 = _createSuper(ShopWishlist);
80
80
 
81
- function ShopAccount() {
81
+ function ShopWishlist() {
82
82
  var _this2;
83
83
 
84
- _classCallCheck(this, ShopAccount);
84
+ _classCallCheck(this, ShopWishlist);
85
85
 
86
86
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
87
87
  args[_key2] = arguments[_key2];
@@ -89,17 +89,60 @@ var ShopAccount = /*#__PURE__*/function (_BaseCallClass2) {
89
89
 
90
90
  _this2 = _super2.call.apply(_super2, [this].concat(args));
91
91
 
92
- _defineProperty(_assertThisInitialized(_this2), "serviceName", 'account');
92
+ _defineProperty(_assertThisInitialized(_this2), "serviceName", 'wishlist');
93
93
 
94
- _defineProperty(_assertThisInitialized(_this2), "client", void 0);
94
+ return _this2;
95
+ }
95
96
 
96
- _defineProperty(_assertThisInitialized(_this2), "isAuthenticated", void 0);
97
+ _createClass(ShopWishlist, [{
98
+ key: "addProductsToWishlist",
99
+ value: function addProductsToWishlist(wishlistId, newProduct) {
100
+ return this.call('addProductsToWishlist', wishlistId, newProduct);
101
+ }
102
+ }, {
103
+ key: "getWishlists",
104
+ value: function getWishlists() {
105
+ return this.call('getWishlists');
106
+ }
107
+ }, {
108
+ key: "createWishlist",
109
+ value: function createWishlist(name) {
110
+ return this.call('createWishlist', name);
111
+ }
112
+ }]);
97
113
 
98
- _defineProperty(_assertThisInitialized(_this2), "user", void 0);
114
+ return ShopWishlist;
115
+ }(_utils.BaseCallClass);
99
116
 
100
- _defineProperty(_assertThisInitialized(_this2), "manager", void 0);
117
+ exports.ShopWishlist = ShopWishlist;
101
118
 
102
- return _this2;
119
+ var ShopAccount = /*#__PURE__*/function (_BaseCallClass3) {
120
+ _inherits(ShopAccount, _BaseCallClass3);
121
+
122
+ var _super3 = _createSuper(ShopAccount);
123
+
124
+ function ShopAccount() {
125
+ var _this3;
126
+
127
+ _classCallCheck(this, ShopAccount);
128
+
129
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
130
+ args[_key3] = arguments[_key3];
131
+ }
132
+
133
+ _this3 = _super3.call.apply(_super3, [this].concat(args));
134
+
135
+ _defineProperty(_assertThisInitialized(_this3), "serviceName", 'account');
136
+
137
+ _defineProperty(_assertThisInitialized(_this3), "client", void 0);
138
+
139
+ _defineProperty(_assertThisInitialized(_this3), "isAuthenticated", void 0);
140
+
141
+ _defineProperty(_assertThisInitialized(_this3), "user", void 0);
142
+
143
+ _defineProperty(_assertThisInitialized(_this3), "manager", void 0);
144
+
145
+ return _this3;
103
146
  }
104
147
 
105
148
  _createClass(ShopAccount, [{
@@ -118,31 +161,31 @@ var ShopAccount = /*#__PURE__*/function (_BaseCallClass2) {
118
161
 
119
162
  exports.ShopAccount = ShopAccount;
120
163
 
121
- var ShopCart = /*#__PURE__*/function (_BaseCallClass3) {
122
- _inherits(ShopCart, _BaseCallClass3);
164
+ var ShopCart = /*#__PURE__*/function (_BaseCallClass4) {
165
+ _inherits(ShopCart, _BaseCallClass4);
123
166
 
124
- var _super3 = _createSuper(ShopCart);
167
+ var _super4 = _createSuper(ShopCart);
125
168
 
126
169
  function ShopCart() {
127
- var _this3;
170
+ var _this4;
128
171
 
129
172
  _classCallCheck(this, ShopCart);
130
173
 
131
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
132
- args[_key3] = arguments[_key3];
174
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
175
+ args[_key4] = arguments[_key4];
133
176
  }
134
177
 
135
- _this3 = _super3.call.apply(_super3, [this].concat(args));
178
+ _this4 = _super4.call.apply(_super4, [this].concat(args));
136
179
 
137
- _defineProperty(_assertThisInitialized(_this3), "serviceName", 'cart');
180
+ _defineProperty(_assertThisInitialized(_this4), "serviceName", 'cart');
138
181
 
139
- _defineProperty(_assertThisInitialized(_this3), "carts", void 0);
182
+ _defineProperty(_assertThisInitialized(_this4), "carts", void 0);
140
183
 
141
- _defineProperty(_assertThisInitialized(_this3), "currentCart", void 0);
184
+ _defineProperty(_assertThisInitialized(_this4), "currentCart", void 0);
142
185
 
143
- _defineProperty(_assertThisInitialized(_this3), "totalCartPrice", void 0);
186
+ _defineProperty(_assertThisInitialized(_this4), "totalCartPrice", void 0);
144
187
 
145
- return _this3;
188
+ return _this4;
146
189
  }
147
190
 
148
191
  _createClass(ShopCart, [{
@@ -157,25 +200,25 @@ var ShopCart = /*#__PURE__*/function (_BaseCallClass3) {
157
200
 
158
201
  exports.ShopCart = ShopCart;
159
202
 
160
- var ShopAuthorization = /*#__PURE__*/function (_BaseCallClass4) {
161
- _inherits(ShopAuthorization, _BaseCallClass4);
203
+ var ShopAuthorization = /*#__PURE__*/function (_BaseCallClass5) {
204
+ _inherits(ShopAuthorization, _BaseCallClass5);
162
205
 
163
- var _super4 = _createSuper(ShopAuthorization);
206
+ var _super5 = _createSuper(ShopAuthorization);
164
207
 
165
208
  function ShopAuthorization() {
166
- var _this4;
209
+ var _this5;
167
210
 
168
211
  _classCallCheck(this, ShopAuthorization);
169
212
 
170
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
171
- args[_key4] = arguments[_key4];
213
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
214
+ args[_key5] = arguments[_key5];
172
215
  }
173
216
 
174
- _this4 = _super4.call.apply(_super4, [this].concat(args));
217
+ _this5 = _super5.call.apply(_super5, [this].concat(args));
175
218
 
176
- _defineProperty(_assertThisInitialized(_this4), "serviceName", 'authorization');
219
+ _defineProperty(_assertThisInitialized(_this5), "serviceName", 'authorization');
177
220
 
178
- return _this4;
221
+ return _this5;
179
222
  }
180
223
 
181
224
  _createClass(ShopAuthorization, [{
@@ -190,41 +233,41 @@ var ShopAuthorization = /*#__PURE__*/function (_BaseCallClass4) {
190
233
 
191
234
  exports.ShopAuthorization = ShopAuthorization;
192
235
 
193
- var ShopUtils = /*#__PURE__*/function (_BaseCallClass5) {
194
- _inherits(ShopUtils, _BaseCallClass5);
236
+ var ShopUtils = /*#__PURE__*/function (_BaseCallClass6) {
237
+ _inherits(ShopUtils, _BaseCallClass6);
195
238
 
196
- var _super5 = _createSuper(ShopUtils);
239
+ var _super6 = _createSuper(ShopUtils);
197
240
 
198
241
  function ShopUtils(call) {
199
- var _this5;
242
+ var _this6;
200
243
 
201
244
  _classCallCheck(this, ShopUtils);
202
245
 
203
- _this5 = _super5.call(this, call);
246
+ _this6 = _super6.call(this, call);
204
247
 
205
- _defineProperty(_assertThisInitialized(_this5), "serviceName", 'utils');
248
+ _defineProperty(_assertThisInitialized(_this6), "serviceName", 'utils');
206
249
 
207
- _defineProperty(_assertThisInitialized(_this5), "currency", void 0);
250
+ _defineProperty(_assertThisInitialized(_this6), "currency", void 0);
208
251
 
209
- _defineProperty(_assertThisInitialized(_this5), "isAnonymousAndPurchaseDisabled", void 0);
252
+ _defineProperty(_assertThisInitialized(_this6), "isAnonymousAndPurchaseDisabled", void 0);
210
253
 
211
- _defineProperty(_assertThisInitialized(_this5), "isB2B", void 0);
254
+ _defineProperty(_assertThisInitialized(_this6), "isB2B", void 0);
212
255
 
213
- _defineProperty(_assertThisInitialized(_this5), "isB2BAndPlatformIsNotOpened", void 0);
256
+ _defineProperty(_assertThisInitialized(_this6), "isB2BAndPlatformIsNotOpened", void 0);
214
257
 
215
- _defineProperty(_assertThisInitialized(_this5), "isIndexPage", void 0);
258
+ _defineProperty(_assertThisInitialized(_this6), "isIndexPage", void 0);
216
259
 
217
- _defineProperty(_assertThisInitialized(_this5), "isPurchaseEnabledOrAuthenticated", void 0);
260
+ _defineProperty(_assertThisInitialized(_this6), "isPurchaseEnabledOrAuthenticated", void 0);
218
261
 
219
- _defineProperty(_assertThisInitialized(_this5), "routes", void 0);
262
+ _defineProperty(_assertThisInitialized(_this6), "routes", void 0);
220
263
 
221
- _this5.routes = {
222
- getCategoryPath: _this5.getCategoryPath,
223
- getManufacturerSearchUrl: _this5.getManufacturerSearchUrl,
224
- getProductUrl: _this5.getProductUrl,
225
- isExternalUrl: _this5.isExternalUrl
264
+ _this6.routes = {
265
+ getCategoryPath: _this6.getCategoryPath,
266
+ getManufacturerSearchUrl: _this6.getManufacturerSearchUrl,
267
+ getProductUrl: _this6.getProductUrl,
268
+ isExternalUrl: _this6.isExternalUrl
226
269
  };
227
- return _this5;
270
+ return _this6;
228
271
  }
229
272
 
230
273
  _createClass(ShopUtils, [{
@@ -254,43 +297,43 @@ var ShopUtils = /*#__PURE__*/function (_BaseCallClass5) {
254
297
 
255
298
  exports.ShopUtils = ShopUtils;
256
299
 
257
- var ShopConfig = /*#__PURE__*/function (_BaseCallClass6) {
258
- _inherits(ShopConfig, _BaseCallClass6);
300
+ var ShopConfig = /*#__PURE__*/function (_BaseCallClass7) {
301
+ _inherits(ShopConfig, _BaseCallClass7);
259
302
 
260
- var _super6 = _createSuper(ShopConfig);
303
+ var _super7 = _createSuper(ShopConfig);
261
304
 
262
305
  function ShopConfig() {
263
- var _this6;
306
+ var _this7;
264
307
 
265
308
  _classCallCheck(this, ShopConfig);
266
309
 
267
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
268
- args[_key5] = arguments[_key5];
310
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
311
+ args[_key6] = arguments[_key6];
269
312
  }
270
313
 
271
- _this6 = _super6.call.apply(_super6, [this].concat(args));
314
+ _this7 = _super7.call.apply(_super7, [this].concat(args));
272
315
 
273
- _defineProperty(_assertThisInitialized(_this6), "serviceName", 'config');
316
+ _defineProperty(_assertThisInitialized(_this7), "serviceName", 'config');
274
317
 
275
- _defineProperty(_assertThisInitialized(_this6), "accessMode", void 0);
318
+ _defineProperty(_assertThisInitialized(_this7), "accessMode", void 0);
276
319
 
277
- _defineProperty(_assertThisInitialized(_this6), "isB2CRegistrationEnabled", void 0);
320
+ _defineProperty(_assertThisInitialized(_this7), "isB2CRegistrationEnabled", void 0);
278
321
 
279
- _defineProperty(_assertThisInitialized(_this6), "isCatalogOpened", void 0);
322
+ _defineProperty(_assertThisInitialized(_this7), "isCatalogOpened", void 0);
280
323
 
281
- _defineProperty(_assertThisInitialized(_this6), "isGrossSelected", void 0);
324
+ _defineProperty(_assertThisInitialized(_this7), "isGrossSelected", void 0);
282
325
 
283
- _defineProperty(_assertThisInitialized(_this6), "isPlatformClosed", void 0);
326
+ _defineProperty(_assertThisInitialized(_this7), "isPlatformClosed", void 0);
284
327
 
285
- _defineProperty(_assertThisInitialized(_this6), "isPlatformOpened", void 0);
328
+ _defineProperty(_assertThisInitialized(_this7), "isPlatformOpened", void 0);
286
329
 
287
- _defineProperty(_assertThisInitialized(_this6), "isPurchaseEnabled", void 0);
330
+ _defineProperty(_assertThisInitialized(_this7), "isPurchaseEnabled", void 0);
288
331
 
289
- _defineProperty(_assertThisInitialized(_this6), "isRegistrationEnabled", void 0);
332
+ _defineProperty(_assertThisInitialized(_this7), "isRegistrationEnabled", void 0);
290
333
 
291
- _defineProperty(_assertThisInitialized(_this6), "currency", void 0);
334
+ _defineProperty(_assertThisInitialized(_this7), "currency", void 0);
292
335
 
293
- return _this6;
336
+ return _this7;
294
337
  }
295
338
 
296
339
  return _createClass(ShopConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shopServices.ts"],"names":["ShopCatalog","productId","call","categoryId","BaseCallClass","ShopAccount","name","ShopCart","amount","where","cartId","ShopAuthorization","ShopUtils","routes","getCategoryPath","getManufacturerSearchUrl","getProductUrl","isExternalUrl","id","manufacturer","product","url","ShopConfig"],"mappings":";;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,W;;;;;;;;;;;;;;;;kEACG,S;;;;;;;;;;;WAId,sBAAaC,SAAb,EAA8C;AAC5C,aAAO,KAAKC,IAAL,CAAU,cAAV,EAA0BD,SAA1B,CAAP;AACD;;;WAED,yBAAgBE,UAAhB,EAAkD;AAChD,aAAO,KAAKD,IAAL,CAAU,iBAAV,EAA6BC,UAA7B,CAAP;AACD;;;;EAX8BC,oB;;;;IAgBpBC,W;;;;;;;;;;;;;;;;mEACG,S;;;;;;;;;;;;;;;WAoDd,oBAAWC,IAAX,EAA2C;AACzC,aAAO,KAAKJ,IAAL,CAAU,YAAV,EAAwBI,IAAxB,CAAP;AACD;;;WAWD,kBAAe,CACb;AACD;;;;EApE8BF,oB;;;;IAuEpBG,Q;;;;;;;;;;;;;;;;mEACG,M;;;;;;;;;;;;;WAKd,mBAAUN,SAAV,EAA6BO,MAA7B,EAA6CC,KAA7C,EAA4DC,MAA5D,EAA4F;AAC1F,aAAO,KAAKR,IAAL,CAAU,WAAV,EAAuBD,SAAvB,EAAkCO,MAAlC,EAA0CC,KAA1C,EAAiDC,MAAjD,CAAP;AACD;;;;EAR2BN,oB;;;;IAWjBO,iB;;;;;;;;;;;;;;;;mEACG,e;;;;;;;WAEd,wBAAgC;AAC9B,aAAO,KAAKT,IAAL,CAAU,cAAV,CAAP;AACD;;;;EALoCE,oB;;;;IAQ1BQ,S;;;;;AASX,qBAAYV,IAAZ,EAA+E;AAAA;;AAAA;;AAC7E,gCAAMA,IAAN;;AAD6E,mEARjE,OAQiE;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAE7E,WAAKW,MAAL,GAAc;AACZC,MAAAA,eAAe,EAAE,OAAKA,eADV;AAEZC,MAAAA,wBAAwB,EAAE,OAAKA,wBAFnB;AAGZC,MAAAA,aAAa,EAAE,OAAKA,aAHR;AAIZC,MAAAA,aAAa,EAAE,OAAKA;AAJR,KAAd;AAF6E;AAQ9E;;;;WAED,yBAAgBC,EAAhB,EAAqD;AACnD,aAAO,KAAKhB,IAAL,CAAU,iBAAV,EAA6BgB,EAA7B,CAAP;AACD;;;WAED,kCAAyBC,YAAzB,EAAgE;AAC9D,aAAO,KAAKjB,IAAL,CAAU,0BAAV,EAAsCiB,YAAtC,CAAP;AACD;;;WAED,uBAAcC,OAAd,EAAoD;AAClD,aAAO,KAAKlB,IAAL,CAAU,eAAV,EAA2BkB,OAA3B,CAAP;AACD;;;WAED,uBAAcC,GAAd,EAA6C;AAC3C,aAAO,KAAKnB,IAAL,CAAU,eAAV,EAA2BmB,GAA3B,CAAP;AACD;;;;EAjC4BjB,oB;;;;IAuDlBkB,U;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;;;;;;;;;;;;;EADgBlB,oB","sourcesContent":["import {Backoffice, Shop} from \"@one-commerce/sdk-shared\";\n\nimport {BaseCallClass} from \"./utils\";\n\nexport class ShopCatalog extends BaseCallClass implements Shop.Catalog {\n serviceName = 'catalog'\n categories!: Array<any>;\n selectedCategoryId!: string | null;\n\n fetchProduct(productId: string): Promise<any> {\n return this.call('fetchProduct', productId)\n }\n\n getCategoryById(categoryId: string): Promise<any> {\n return this.call('getCategoryById', categoryId)\n }\n\n\n}\n\nexport class ShopAccount extends BaseCallClass implements Shop.Account {\n serviceName = 'account'\n client!: {\n id: string;\n name: string;\n externalId?: string;\n tin?: string;\n phone?: string;\n segmentId?: string;\n segments: {\n additionalSegments?: Array<{\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n }>;\n mainSegment: {\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n };\n };\n warehouseId?: string;\n termPayment?: {\n id: string;\n label?: string;\n paymentDaysPeriod?: number;\n };\n isTaxPayer?: boolean;\n billingAddress?: {\n city: string;\n country: string;\n id: string;\n isDefault: boolean;\n name: string;\n phone: string;\n street: string;\n type: string;\n zipCode: string\n }\n };\n isAuthenticated!: boolean;\n user!: {\n email?: string;\n name?: string;\n phone?: string;\n /**\n * @deprecated Use non-nested function instead\n */\n hasSegment(name: string): Promise<boolean>\n };\n\n hasSegment(name: string): Promise<boolean> {\n return this.call('hasSegment', name)\n }\n\n manager!: {\n additionalEmail?: string;\n email: string; id: string;\n landlinePhone?: string;\n mobilePhone?: string;\n name: string;\n photo?: string\n };\n\n logout(): void {\n // NotImplementedYet\n }\n}\n\nexport class ShopCart extends BaseCallClass implements Shop.Cart {\n serviceName = 'cart'\n carts!: Array<any>;\n currentCart!: any;\n totalCartPrice!: number;\n\n addToCart(productId: string, amount: number, where: string, cartId?: string): Promise<void> {\n return this.call('addToCart', productId, amount, where, cartId)\n }\n}\n\nexport class ShopAuthorization extends BaseCallClass implements Shop.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class ShopUtils extends BaseCallClass implements Shop.Utils {\n serviceName = 'utils'\n currency!: any;\n isAnonymousAndPurchaseDisabled!: boolean;\n isB2B!: boolean;\n isB2BAndPlatformIsNotOpened!: boolean;\n isIndexPage!: boolean;\n isPurchaseEnabledOrAuthenticated!: boolean;\n\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n super(call)\n this.routes = {\n getCategoryPath: this.getCategoryPath,\n getManufacturerSearchUrl: this.getManufacturerSearchUrl,\n getProductUrl: this.getProductUrl,\n isExternalUrl: this.isExternalUrl\n }\n }\n\n getCategoryPath(id?: string): Promise<string | null> {\n return this.call('getCategoryPath', id)\n }\n\n getManufacturerSearchUrl(manufacturer: string): Promise<string> {\n return this.call('getManufacturerSearchUrl', manufacturer)\n }\n\n getProductUrl(product: any): Promise<string | null> {\n return this.call('getProductUrl', product)\n }\n\n isExternalUrl(url: string): Promise<boolean> {\n return this.call('isExternalUrl', url)\n }\n\n routes: {\n /**\n * @deprecated Use non-nested function instead\n */\n getCategoryPath(id?: string): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n getManufacturerSearchUrl(manufacturer: string): (Promise<string> | string);\n /**\n * @deprecated Use non-nested function instead\n */\n getProductUrl(product: any): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n isExternalUrl(url: string): (Promise<boolean> | boolean)\n };\n}\n\nexport class ShopConfig extends BaseCallClass implements Shop.Config {\n serviceName = 'config'\n accessMode!: string;\n isB2CRegistrationEnabled!: boolean;\n isCatalogOpened!: boolean;\n isGrossSelected!: boolean;\n isPlatformClosed!: boolean;\n isPlatformOpened!: boolean;\n isPurchaseEnabled!: boolean;\n isRegistrationEnabled!: boolean;\n currency: any;\n}\n"],"file":"shopServices.js"}
1
+ {"version":3,"sources":["../../src/shopServices.ts"],"names":["ShopCatalog","productId","call","categoryId","BaseCallClass","ShopWishlist","wishlistId","newProduct","name","ShopAccount","ShopCart","amount","where","cartId","ShopAuthorization","ShopUtils","routes","getCategoryPath","getManufacturerSearchUrl","getProductUrl","isExternalUrl","id","manufacturer","product","url","ShopConfig"],"mappings":";;;;;;;;;AACA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,W;;;;;;;;;;;;;;;;kEACG,S;;;;;;;;;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jE,OAQiE;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAE7E,WAAKc,MAAL,GAAc;AACZC,MAAAA,eAAe,EAAE,OAAKA,eADV;AAEZC,MAAAA,wBAAwB,EAAE,OAAKA,wBAFnB;AAGZC,MAAAA,aAAa,EAAE,OAAKA,aAHR;AAIZC,MAAAA,aAAa,EAAE,OAAKA;AAJR,KAAd;AAF6E;AAQ9E;;;;WAED,yBAAgBC,EAAhB,EAAqD;AACnD,aAAO,KAAKnB,IAAL,CAAU,iBAAV,EAA6BmB,EAA7B,CAAP;AACD;;;WAED,kCAAyBC,YAAzB,EAAgE;AAC9D,aAAO,KAAKpB,IAAL,CAAU,0BAAV,EAAsCoB,YAAtC,CAAP;AACD;;;WAED,uBAAcC,OAAd,EAAoD;AAClD,aAAO,KAAKrB,IAAL,CAAU,eAAV,EAA2BqB,OAA3B,CAAP;AACD;;;WAED,uBAAcC,GAAd,EAA6C;AAC3C,aAAO,KAAKtB,IAAL,CAAU,eAAV,EAA2BsB,GAA3B,CAAP;AACD;;;;EAjC4BpB,oB;;;;IAuDlBqB,U;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;;;;;;;;;;;;;EADgBrB,oB","sourcesContent":["import {Shop} from \"@one-commerce/sdk-shared\";\nimport {BaseCallClass} from \"./utils\";\n\nexport class ShopCatalog extends BaseCallClass implements Shop.Catalog {\n serviceName = 'catalog'\n categories!: Array<any>;\n selectedCategoryId!: string | null;\n\n fetchProduct(productId: string): Promise<any> {\n return this.call('fetchProduct', productId)\n }\n\n getCategoryById(categoryId: string): Promise<any> {\n return this.call('getCategoryById', categoryId)\n }\n}\nexport class ShopWishlist extends BaseCallClass implements Shop.Wishlist {\n serviceName = 'wishlist'\n\n addProductsToWishlist(wishlistId: string, newProduct: any): Promise<void> {\n return this.call('addProductsToWishlist', wishlistId, newProduct)\n }\n\n getWishlists(): Promise<any> {\n return this.call('getWishlists')\n }\n\n createWishlist(name: string): Promise<any> {\n return this.call('createWishlist', name)\n }\n}\nexport class ShopAccount extends BaseCallClass implements Shop.Account {\n serviceName = 'account'\n client!: {\n id: string;\n name: string;\n externalId?: string;\n tin?: string;\n phone?: string;\n segmentId?: string;\n segments: {\n additionalSegments?: Array<{\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n }>;\n mainSegment: {\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n };\n };\n warehouseId?: string;\n termPayment?: {\n id: string;\n label?: string;\n paymentDaysPeriod?: number;\n };\n isTaxPayer?: boolean;\n billingAddress?: {\n city: string;\n country: string;\n id: string;\n isDefault: boolean;\n name: string;\n phone: string;\n street: string;\n type: string;\n zipCode: string\n }\n };\n isAuthenticated!: boolean;\n user!: {\n email?: string;\n name?: string;\n phone?: string;\n /**\n * @deprecated Use non-nested function instead\n */\n hasSegment(name: string): Promise<boolean>\n };\n\n hasSegment(name: string): Promise<boolean> {\n return this.call('hasSegment', name)\n }\n\n manager!: {\n additionalEmail?: string;\n email: string; id: string;\n landlinePhone?: string;\n mobilePhone?: string;\n name: string;\n photo?: string\n };\n\n logout(): void {\n // NotImplementedYet\n }\n}\n\nexport class ShopCart extends BaseCallClass implements Shop.Cart {\n serviceName = 'cart'\n carts!: Array<any>;\n currentCart!: any;\n totalCartPrice!: number;\n\n addToCart(productId: string, amount: number, where: string, cartId?: string): Promise<void> {\n return this.call('addToCart', productId, amount, where, cartId)\n }\n}\n\nexport class ShopAuthorization extends BaseCallClass implements Shop.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class ShopUtils extends BaseCallClass implements Shop.Utils {\n serviceName = 'utils'\n currency!: any;\n isAnonymousAndPurchaseDisabled!: boolean;\n isB2B!: boolean;\n isB2BAndPlatformIsNotOpened!: boolean;\n isIndexPage!: boolean;\n isPurchaseEnabledOrAuthenticated!: boolean;\n\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n super(call)\n this.routes = {\n getCategoryPath: this.getCategoryPath,\n getManufacturerSearchUrl: this.getManufacturerSearchUrl,\n getProductUrl: this.getProductUrl,\n isExternalUrl: this.isExternalUrl\n }\n }\n\n getCategoryPath(id?: string): Promise<string | null> {\n return this.call('getCategoryPath', id)\n }\n\n getManufacturerSearchUrl(manufacturer: string): Promise<string> {\n return this.call('getManufacturerSearchUrl', manufacturer)\n }\n\n getProductUrl(product: any): Promise<string | null> {\n return this.call('getProductUrl', product)\n }\n\n isExternalUrl(url: string): Promise<boolean> {\n return this.call('isExternalUrl', url)\n }\n\n routes: {\n /**\n * @deprecated Use non-nested function instead\n */\n getCategoryPath(id?: string): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n getManufacturerSearchUrl(manufacturer: string): (Promise<string> | string);\n /**\n * @deprecated Use non-nested function instead\n */\n getProductUrl(product: any): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n isExternalUrl(url: string): (Promise<boolean> | boolean)\n };\n}\n\nexport class ShopConfig extends BaseCallClass implements Shop.Config {\n serviceName = 'config'\n accessMode!: string;\n isB2CRegistrationEnabled!: boolean;\n isCatalogOpened!: boolean;\n isGrossSelected!: boolean;\n isPlatformClosed!: boolean;\n isPlatformOpened!: boolean;\n isPurchaseEnabled!: boolean;\n isRegistrationEnabled!: boolean;\n currency: any;\n}\n"],"file":"shopServices.js"}
@@ -46,14 +46,6 @@ export class BackofficeTenant extends BaseCallClass {
46
46
  _defineProperty(this, "currency", void 0);
47
47
  }
48
48
 
49
- }
50
- export class BackofficeOrderpath extends BaseCallClass {
51
- constructor(...args) {
52
- super(...args);
53
-
54
- _defineProperty(this, "serviceName", 'orderpath');
55
- }
56
-
57
49
  }
58
50
  export class BackofficeLayout extends BaseCallClass {
59
51
  constructor(...args) {
@@ -102,31 +94,5 @@ export class BackofficePlugin extends BaseCallClass {
102
94
  _defineProperty(this, "name", void 0);
103
95
  }
104
96
 
105
- }
106
- export class BackofficeAddToCartContext extends BaseCallClass {
107
- constructor(...args) {
108
- super(...args);
109
-
110
- _defineProperty(this, "serviceName", 'addToCartContext');
111
-
112
- _defineProperty(this, "productId", void 0);
113
-
114
- _defineProperty(this, "cartId", void 0);
115
-
116
- _defineProperty(this, "warehouses", void 0);
117
- }
118
-
119
- closePlugin() {
120
- this.call('closePlugin');
121
- }
122
-
123
- closePluginAndAddToCart() {
124
- this.call('closePluginAndAddToCart');
125
- }
126
-
127
- closePluginAndRefreshCart() {
128
- this.call('closePluginAndRefreshCart');
129
- }
130
-
131
97
  }
132
98
  //# sourceMappingURL=backofficeServices.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/backofficeServices.ts"],"names":["BaseCallClass","BackofficeCatalog","fetchCategories","call","fetchProduct","id","BackofficeUser","BackofficeTenant","BackofficeOrderpath","BackofficeLayout","BackofficeAuthorization","getAuthToken","BackofficeCustomer","BackofficePlugin","BackofficeAddToCartContext","closePlugin","closePluginAndAddToCart","closePluginAndRefreshCart"],"mappings":";;AAEA,SAAQA,aAAR,QAA4B,SAA5B;AAEA,OAAO,MAAMC,iBAAN,SAAgCD,aAAhC,CAA4E;AAAA;AAAA;;AAAA,yCACnE,SADmE;AAAA;;AAGjFE,EAAAA,eAAe,GAA4B;AACzC,WAAO,KAAKC,IAAL,CAAU,iBAAV,CAAP;AACD;;AACMC,EAAAA,YAAY,CAACC,EAAD,EAA+B;AAChD,WAAO,KAAKF,IAAL,CAAU,cAAV,EAA0BE,EAA1B,CAAP;AACD;;AARgF;AAWnF,OAAO,MAAMC,cAAN,SAA6BN,aAA7B,CAAsE;AAAA;AAAA;;AAAA,yCAC7D,MAD6D;;AAAA;;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAQ7E,OAAO,MAAMO,gBAAN,SAA+BP,aAA/B,CAA0E;AAAA;AAAA;;AAAA,yCACjE,QADiE;;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAOjF,OAAO,MAAMQ,mBAAN,SAAkCR,aAAlC,CAAgF;AAAA;AAAA;;AAAA,yCACvE,WADuE;AAAA;;AAAA;AAIvF,OAAO,MAAMS,gBAAN,SAA+BT,aAA/B,CAA0E;AAAA;AAAA;;AAAA,yCACjE,QADiE;;AAAA;AAAA;;AAAA;AAKjF,OAAO,MAAMU,uBAAN,SAAsCV,aAAtC,CAAwF;AAAA;AAAA;;AAAA,yCAC/E,eAD+E;AAAA;;AAG7FW,EAAAA,YAAY,GAAoB;AAC9B,WAAO,KAAKR,IAAL,CAAU,cAAV,CAAP;AACD;;AAL4F;AAQ/F,OAAO,MAAMS,kBAAN,SAAiCZ,aAAjC,CAA8E;AAAA;AAAA;;AAAA,yCACrE,UADqE;;AAAA;;AAAA;AAAA;;AAAA;AAMrF,OAAO,MAAMa,gBAAN,SAA+Bb,aAA/B,CAA0E;AAAA;AAAA;;AAAA,yCACjE,QADiE;;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAOjF,OAAO,MAAMc,0BAAN,SAAyCd,aAAzC,CAA8F;AAAA;AAAA;;AAAA,yCACrF,kBADqF;;AAAA;;AAAA;;AAAA;AAAA;;AAKnGe,EAAAA,WAAW,GAAU;AACnB,SAAKZ,IAAL,CAAU,aAAV;AACD;;AACDa,EAAAA,uBAAuB,GAAU;AAC/B,SAAKb,IAAL,CAAU,yBAAV;AACD;;AACDc,EAAAA,yBAAyB,GAAU;AACjC,SAAKd,IAAL,CAAU,2BAAV;AACD;;AAbkG","sourcesContent":["import {Backoffice} from \"@one-commerce/sdk-shared\";\n\nimport {BaseCallClass} from \"./utils\";\n\nexport class BackofficeCatalog extends BaseCallClass implements Backoffice.Catalog {\n serviceName = 'catalog'\n\n fetchCategories(): Promise<Array<unknown>> {\n return this.call('fetchCategories')\n }\n public fetchProduct(id: string): Promise<unknown> {\n return this.call('fetchProduct', id)\n }\n}\n\nexport class BackofficeUser extends BaseCallClass implements Backoffice.User {\n serviceName = 'user'\n email?: string;\n id!: string;\n name?: string;\n authorities!: Array<string>;\n}\n\nexport class BackofficeTenant extends BaseCallClass implements Backoffice.Tenant {\n serviceName = 'tenant'\n tenantKey?: string;\n language?: string;\n currency?: string;\n}\n\nexport class BackofficeOrderpath extends BaseCallClass implements Backoffice.Orderpath {\n serviceName = 'orderpath'\n}\n\nexport class BackofficeLayout extends BaseCallClass implements Backoffice.Layout {\n serviceName = 'layout'\n isAsideOpened!: boolean;\n}\n\nexport class BackofficeAuthorization extends BaseCallClass implements Backoffice.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class BackofficeCustomer extends BaseCallClass implements Backoffice.Customer {\n serviceName = 'customer'\n id?: string;\n name?: string;\n}\n\nexport class BackofficePlugin extends BaseCallClass implements Backoffice.Plugin {\n serviceName = 'plugin'\n id: string;\n srcUrl?: string;\n name?: string;\n}\n\nexport class BackofficeAddToCartContext extends BaseCallClass implements Backoffice.AddToCartContext {\n serviceName = 'addToCartContext'\n productId?: string;\n cartId?: string;\n warehouses?: Array<any>;\n closePlugin?(): void {\n this.call('closePlugin')\n }\n closePluginAndAddToCart?(): void {\n this.call('closePluginAndAddToCart')\n }\n closePluginAndRefreshCart?(): void {\n this.call('closePluginAndRefreshCart')\n }\n}\n"],"file":"backofficeServices.js"}
1
+ {"version":3,"sources":["../../src/backofficeServices.ts"],"names":["BaseCallClass","BackofficeCatalog","fetchCategories","call","fetchProduct","id","BackofficeUser","BackofficeTenant","BackofficeLayout","BackofficeAuthorization","getAuthToken","BackofficeCustomer","BackofficePlugin"],"mappings":";;AACA,SAASA,aAAT,QAA8B,SAA9B;AAEA,OAAO,MAAMC,iBAAN,SAAgCD,aAAhC,CAA4E;AAAA;AAAA;;AAAA,yCACnE,SADmE;AAAA;;AAGjFE,EAAAA,eAAe,GAA4B;AACzC,WAAO,KAAKC,IAAL,CAAU,iBAAV,CAAP;AACD;;AACMC,EAAAA,YAAY,CAACC,EAAD,EAA+B;AAChD,WAAO,KAAKF,IAAL,CAAU,cAAV,EAA0BE,EAA1B,CAAP;AACD;;AARgF;AAWnF,OAAO,MAAMC,cAAN,SAA6BN,aAA7B,CAAsE;AAAA;AAAA;;AAAA,yCAC7D,MAD6D;;AAAA;;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAQ7E,OAAO,MAAMO,gBAAN,SAA+BP,aAA/B,CAA0E;AAAA;AAAA;;AAAA,yCACjE,QADiE;;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAOjF,OAAO,MAAMQ,gBAAN,SAA+BR,aAA/B,CAA0E;AAAA;AAAA;;AAAA,yCACjE,QADiE;;AAAA;AAAA;;AAAA;AAKjF,OAAO,MAAMS,uBAAN,SAAsCT,aAAtC,CAAwF;AAAA;AAAA;;AAAA,yCAC/E,eAD+E;AAAA;;AAG7FU,EAAAA,YAAY,GAAoB;AAC9B,WAAO,KAAKP,IAAL,CAAU,cAAV,CAAP;AACD;;AAL4F;AAQ/F,OAAO,MAAMQ,kBAAN,SAAiCX,aAAjC,CAA8E;AAAA;AAAA;;AAAA,yCACrE,UADqE;;AAAA;;AAAA;AAAA;;AAAA;AAMrF,OAAO,MAAMY,gBAAN,SAA+BZ,aAA/B,CAA0E;AAAA;AAAA;;AAAA,yCACjE,QADiE;;AAAA;;AAAA;;AAAA;AAAA;;AAAA","sourcesContent":["import { Backoffice } from \"@one-commerce/sdk-shared\";\nimport { BaseCallClass } from \"./utils\";\n\nexport class BackofficeCatalog extends BaseCallClass implements Backoffice.Catalog {\n serviceName = 'catalog'\n\n fetchCategories(): Promise<Array<unknown>> {\n return this.call('fetchCategories')\n }\n public fetchProduct(id: string): Promise<unknown> {\n return this.call('fetchProduct', id)\n }\n}\n\nexport class BackofficeUser extends BaseCallClass implements Backoffice.User {\n serviceName = 'user'\n email?: string;\n id!: string;\n name?: string;\n authorities!: Array<string>;\n}\n\nexport class BackofficeTenant extends BaseCallClass implements Backoffice.Tenant {\n serviceName = 'tenant'\n tenantKey?: string;\n language?: string;\n currency?: string;\n}\n\nexport class BackofficeLayout extends BaseCallClass implements Backoffice.Layout {\n serviceName = 'layout'\n isAsideOpened!: boolean;\n}\n\nexport class BackofficeAuthorization extends BaseCallClass implements Backoffice.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class BackofficeCustomer extends BaseCallClass implements Backoffice.Customer {\n serviceName = 'customer'\n id?: string;\n name?: string;\n}\n\nexport class BackofficePlugin extends BaseCallClass implements Backoffice.Plugin {\n serviceName = 'plugin'\n id: string;\n srcUrl?: string;\n name?: string;\n}\n\n"],"file":"backofficeServices.js"}
package/lib/esm/index.js CHANGED
@@ -2,9 +2,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
2
2
 
3
3
  import { Message } from "@one-commerce/sdk-shared";
4
4
  import Channel from "iframe-channel";
5
- import { BackofficeAuthorization, BackofficeCatalog, BackofficeCustomer, BackofficeLayout, BackofficeOrderpath, BackofficePlugin, BackofficeTenant, BackofficeUser, BackofficeAddToCartContext } from "./backofficeServices";
5
+ import { BackofficeAuthorization, BackofficeCatalog, BackofficeCustomer, BackofficeLayout, BackofficePlugin, BackofficeTenant, BackofficeUser } from "./backofficeServices";
6
6
  import Events from "./events";
7
- import { ShopAccount, ShopAuthorization, ShopCart, ShopCatalog, ShopConfig, ShopUtils } from "./shopServices";
7
+ import { ShopAccount, ShopAuthorization, ShopCart, ShopCatalog, ShopConfig, ShopUtils, ShopWishlist } from "./shopServices";
8
8
  import { BaseCallClass, generateCallId } from "./utils";
9
9
  var SdkInternalEvents;
10
10
 
@@ -155,10 +155,15 @@ class Sdk extends Events {
155
155
  method: fun,
156
156
  payload: payload
157
157
  });
158
- return new Promise(resolve => {
158
+ return new Promise((resolve, reject) => {
159
159
  const onChannelMessage = response => {
160
160
  if (response.callId === callId) {
161
161
  this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage);
162
+
163
+ if (response.isException) {
164
+ return reject(response.result);
165
+ }
166
+
162
167
  return resolve(response.result);
163
168
  }
164
169
  };
@@ -188,15 +193,13 @@ export class BackofficeSdk extends Sdk {
188
193
  hash: '',
189
194
  query: {}
190
195
  },
191
- orderpath: new BackofficeOrderpath(this.callFunction.bind(this)),
192
196
  catalog: new BackofficeCatalog(this.callFunction.bind(this)),
193
197
  user: new BackofficeUser(this.callFunction.bind(this)),
194
198
  tenant: new BackofficeTenant(this.callFunction.bind(this)),
195
199
  layout: new BackofficeLayout(this.callFunction.bind(this)),
196
200
  authorization: new BackofficeAuthorization(this.callFunction.bind(this)),
197
201
  customer: new BackofficeCustomer(this.callFunction.bind(this)),
198
- plugin: new BackofficePlugin(this.callFunction.bind(this)),
199
- addToCartContext: new BackofficeAddToCartContext(this.callFunction.bind(this))
202
+ plugin: new BackofficePlugin(this.callFunction.bind(this))
200
203
  });
201
204
  }
202
205
 
@@ -215,7 +218,8 @@ export class ShopSdk extends Sdk {
215
218
  catalog: new ShopCatalog(this.callFunction.bind(this)),
216
219
  account: new ShopAccount(this.callFunction.bind(this)),
217
220
  utils: new ShopUtils(this.callFunction.bind(this)),
218
- config: new ShopConfig(this.callFunction.bind(this))
221
+ config: new ShopConfig(this.callFunction.bind(this)),
222
+ wishlist: new ShopWishlist(this.callFunction.bind(this))
219
223
  });
220
224
  }
221
225
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["Message","Channel","BackofficeAuthorization","BackofficeCatalog","BackofficeCustomer","BackofficeLayout","BackofficeOrderpath","BackofficePlugin","BackofficeTenant","BackofficeUser","BackofficeAddToCartContext","Events","ShopAccount","ShopAuthorization","ShopCart","ShopCatalog","ShopConfig","ShopUtils","BaseCallClass","generateCallId","SdkInternalEvents","SdkEvents","Sdk","log","data","debug","console","warn","initializeServiceGetters","instances","Object","keys","forEach","serviceName","defineProperty","get","isInitialized","constructor","options","origin","channel","targetOrigin","target","window","parent","subscribe","INIT","payload","entries","key","value","update","attributesForKey","emit","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","body","document","html","documentElement","height","Math","max","scrollHeight","offsetHeight","clientHeight","postMessage","FRAME_HEIGHT_CHANGE","onMutationObserved","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","heightMutationObserver","MutationObserver","observe","callFunction","service","fun","callId","METHOD_CALL","method","Promise","resolve","onChannelMessage","response","unsubscribe","METHOD_RESULT","result","navigate","event","NAVIGATION_PUSH","BackofficeSdk","route","hash","query","orderpath","bind","catalog","user","tenant","layout","authorization","customer","plugin","addToCartContext","ShopSdk","cart","account","utils"],"mappings":";;AAAA,SAAoBA,OAApB,QAA+C,0BAA/C;AACA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,SACEC,uBADF,EAEEC,iBAFF,EAGEC,kBAHF,EAIEC,gBAJF,EAKEC,mBALF,EAMEC,gBANF,EAOEC,gBAPF,EAQEC,cARF,EASEC,0BATF,QAUO,sBAVP;AAWA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SACEC,WADF,EACeC,iBADf,EAEEC,QAFF,EAGEC,WAHF,EAGeC,UAHf,EAG2BC,SAH3B,QAIO,gBAJP;AAKA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,SAA9C;IAEKC,iB;;WAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,KAAAA,iB;;AAIL,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAoBZ,MAAeC,GAAf,SAA8BX,MAA9B,CAAqC;AASjB,SAAHY,GAAG,CAAC,GAAGC,IAAJ,EAAiB;AACjCF,IAAAA,GAAG,CAACG,KAAJ,IAAaC,OAAO,CAACH,GAAR,CAAY,aAAZ,EAA2B,GAAGC,IAA9B,CAAb;AACD;;AAEkB,SAAJG,IAAI,CAAC,GAAGH,IAAJ,EAAiB;AAClCE,IAAAA,OAAO,CAACC,IAAR,CAAa,aAAb,EAA4B,GAAGH,IAA/B;AACD;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,IAAInG,iBAAJ,CAAsB,KAAKyE,YAAL,CAAkBqB,IAAlB,CAAuB,IAAvB,CAAtB,CALL;AAMVU,MAAAA,IAAI,EAAE,IAAIvG,QAAJ,CAAa,KAAKwE,YAAL,CAAkBqB,IAAlB,CAAuB,IAAvB,CAAb,CANI;AAOVC,MAAAA,OAAO,EAAE,IAAI7F,WAAJ,CAAgB,KAAKuE,YAAL,CAAkBqB,IAAlB,CAAuB,IAAvB,CAAhB,CAPC;AAQVW,MAAAA,OAAO,EAAE,IAAI1G,WAAJ,CAAgB,KAAK0E,YAAL,CAAkBqB,IAAlB,CAAuB,IAAvB,CAAhB,CARC;AASVY,MAAAA,KAAK,EAAE,IAAItG,SAAJ,CAAc,KAAKqE,YAAL,CAAkBqB,IAAlB,CAAuB,IAAvB,CAAd,CATG;AAUV/B,MAAAA,MAAM,EAAE,IAAI5D,UAAJ,CAAe,KAAKsE,YAAL,CAAkBqB,IAAlB,CAAuB,IAAvB,CAAf;AAVE,KADkC;AAAA;;AAAA","sourcesContent":["import {Backoffice, Message, Route, Shop} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficeOrderpath,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n BackofficeAddToCartContext\n} from \"./backofficeServices\";\nimport Events from \"./events\";\nimport {\n ShopAccount, ShopAuthorization,\n ShopCart,\n ShopCatalog, ShopConfig, ShopUtils,\n} from \"./shopServices\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nenum SdkInternalEvents {\n INIT='INIT',\n UPDATE='UPDATE'\n}\nexport enum SdkEvents {\n INIT='INIT',\n UPDATE='UPDATE',\n}\nexport interface SdkOptions {\n debug?: boolean\n autoheight?: boolean\n origin: string\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nabstract class Sdk<T> extends Events {\n private channel!: Channel;\n private static debug = false\n private autoheight = true\n private heightMutationObserver = null\n origin: string;\n isInitialized = false\n instances!: T;\n\n private static log(...data: any[]) {\n Sdk.debug && console.log('[SDK Core] ', ...data)\n }\n\n private static warn(...data: any[]) {\n console.warn('[SDK Core] ', ...data)\n }\n\n private initializeServiceGetters(): void {\n if (this.instances) {\n Object.keys(this.instances).forEach((serviceName: string) => {\n Object.defineProperty(this, serviceName, {\n get: () => {\n return this.isInitialized ? this.instances![serviceName as keyof T] : null\n }\n })\n })\n }\n }\n\n constructor(options: SdkOptions) {\n super()\n this.initializeServiceGetters()\n this.origin = options.origin\n this.channel = new Channel({\n targetOrigin: this.origin,\n target: window.parent,\n })\n this.channel.subscribe(Message.INIT, (payload: any) => {\n Sdk.log('Handling INIT message')\n Object.entries(this.instances!).forEach(([key, value]: [key: string, value: BaseCallClass | Record<string, any>]) => {\n if (value instanceof BaseCallClass) {\n value.update(payload)\n } else {\n const attributesForKey = payload[key]\n if (typeof attributesForKey !== 'undefined') {\n BaseCallClass.update(value as Record<string, any>, payload[key])\n } else {\n Sdk.warn(`Missing attributes for ${key} in `, payload)\n }\n }\n })\n Sdk.log('Emitting INIT with payload ', this.instances)\n this.emit(SdkInternalEvents.INIT, this.instances)\n this.isInitialized = true\n })\n this.channel.subscribe(Message.UPDATE, (payload: any) => {\n Sdk.log('Emitting UPDATE with payload ', payload)\n this.emit(SdkInternalEvents.UPDATE, payload)\n })\n this.channel.subscribe(Message.FRAME_HEIGHT_REQUEST, (payload: any) => {\n if (this.autoheight) {\n Sdk.log('Request for iframe height')\n this.sendFrameHeight()\n }\n })\n this.channel.connect().then(() => {\n Sdk.log('Connected with ONe SDK')\n if(this.autoheight) {\n this.initializeHeightObserver()\n }\n })\n this.setupOptions(options)\n Sdk.log('Initialized.')\n }\n\n private sendFrameHeight() {\n const body = document.body, html = document.documentElement;\n const height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight);\n this.channel.postMessage(Message.FRAME_HEIGHT_CHANGE, height)\n }\n\n private initializeHeightObserver() {\n if (\"MutationObserver\" in window) {\n const onMutationObserved = () => {\n this.sendFrameHeight()\n }\n const target = document.querySelector('body'),\n config = {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n }\n\n this.heightMutationObserver = new MutationObserver(onMutationObserved)\n\n Sdk.log('Create body MutationObserver')\n this.heightMutationObserver.observe(target, config)\n } else {\n Sdk.warn('MutationObserver not available. Auto-height functionality disabled.')\n }\n }\n\n private setupOptions(options?: SdkOptions) {\n if (options) {\n if (typeof options.debug !== 'undefined') {\n Sdk.debug = options.debug\n }\n if (typeof options.autoheight !== 'undefined') {\n this.autoheight = options.autoheight\n }\n }\n }\n protected callFunction(service: string, fun: string, ...payload: any) {\n const callId: string = generateCallId()\n if (this.isInitialized) {\n Sdk.log(`Call ID ${callId} for ${service}:${fun}`, payload)\n this.channel.postMessage(Message.METHOD_CALL, {\n callId,\n service,\n method: fun,\n payload: payload,\n })\n return new Promise((resolve) => {\n const onChannelMessage = (response: any) => {\n if (response.callId === callId) {\n this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage)\n return resolve(response.result)\n }\n }\n this.channel.subscribe(Message.METHOD_RESULT, onChannelMessage)\n })\n }\n Sdk.log('SDK is not initialized!')\n return Promise.resolve(null)\n }\n\n public navigate(event: NamedNavigationPayload | PathNavigationPayload) {\n this.channel.postMessage(Message.NAVIGATION_PUSH, event)\n }\n\n}\n\nexport interface BackofficeInstances extends Backoffice.Api {\n route: Route,\n orderpath: BackofficeOrderpath,\n catalog: BackofficeCatalog,\n user: BackofficeUser,\n tenant: BackofficeTenant,\n layout: BackofficeLayout,\n authorization: BackofficeAuthorization,\n customer: BackofficeCustomer,\n plugin: BackofficePlugin,\n addToCartContext: BackofficeAddToCartContext\n}\n\nexport interface ShopInstances extends Shop.Api {\n authorization: ShopAuthorization,\n route: Route,\n cart: ShopCart,\n catalog: ShopCatalog,\n account: ShopAccount,\n utils: ShopUtils\n config: ShopConfig\n}\n\nexport class BackofficeSdk extends Sdk<BackofficeInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n orderpath: new BackofficeOrderpath(this.callFunction.bind(this)),\n catalog: new BackofficeCatalog(this.callFunction.bind(this)),\n user: new BackofficeUser(this.callFunction.bind(this)),\n tenant: new BackofficeTenant(this.callFunction.bind(this)),\n layout: new BackofficeLayout(this.callFunction.bind(this)),\n authorization: new BackofficeAuthorization(this.callFunction.bind(this)),\n customer: new BackofficeCustomer(this.callFunction.bind(this)),\n plugin: new BackofficePlugin(this.callFunction.bind(this)),\n addToCartContext: new BackofficeAddToCartContext(this.callFunction.bind(this)),\n }\n}\n\nexport class ShopSdk extends Sdk<ShopInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n authorization: new ShopAuthorization(this.callFunction.bind(this)),\n cart: new ShopCart(this.callFunction.bind(this)),\n catalog: new ShopCatalog(this.callFunction.bind(this)),\n account: new ShopAccount(this.callFunction.bind(this)),\n utils: new ShopUtils(this.callFunction.bind(this)),\n config: new ShopConfig(this.callFunction.bind(this))\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["Message","Channel","BackofficeAuthorization","BackofficeCatalog","BackofficeCustomer","BackofficeLayout","BackofficePlugin","BackofficeTenant","BackofficeUser","Events","ShopAccount","ShopAuthorization","ShopCart","ShopCatalog","ShopConfig","ShopUtils","ShopWishlist","BaseCallClass","generateCallId","SdkInternalEvents","SdkEvents","Sdk","log","data","debug","console","warn","initializeServiceGetters","instances","Object","keys","forEach","serviceName","defineProperty","get","isInitialized","constructor","options","origin","channel","targetOrigin","target","window","parent","subscribe","INIT","payload","entries","key","value","update","attributesForKey","emit","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","body","document","html","documentElement","height","Math","max","scrollHeight","offsetHeight","clientHeight","postMessage","FRAME_HEIGHT_CHANGE","onMutationObserved","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","heightMutationObserver","MutationObserver","observe","callFunction","service","fun","callId","METHOD_CALL","method","Promise","resolve","reject","onChannelMessage","response","unsubscribe","METHOD_RESULT","isException","result","navigate","event","NAVIGATION_PUSH","BackofficeSdk","route","hash","query","catalog","bind","user","tenant","layout","authorization","customer","plugin","ShopSdk","cart","account","utils","wishlist"],"mappings":";;AAAA,SAAoBA,OAApB,QAA+C,0BAA/C;AACA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,SACEC,uBADF,EAEEC,iBAFF,EAGEC,kBAHF,EAIEC,gBAJF,EAKEC,gBALF,EAMEC,gBANF,EAOEC,cAPF,QAQO,sBARP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SACEC,WADF,EAEEC,iBAFF,EAGEC,QAHF,EAIEC,WAJF,EAKEC,UALF,EAMEC,SANF,EAOEC,YAPF,QAQO,gBARP;AASA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,SAA9C;IAEKC,iB;;WAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,KAAAA,iB;;AAIL,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAoBZ,MAAeC,GAAf,SAA8BZ,MAA9B,CAAqC;AASjB,SAAHa,GAAG,CAAC,GAAGC,IAAJ,EAAiB;AACjCF,IAAAA,GAAG,CAACG,KAAJ,IAAaC,OAAO,CAACH,GAAR,CAAY,aAAZ,EAA2B,GAAGC,IAA9B,CAAb;AACD;;AAEkB,SAAJG,IAAI,CAAC,GAAGH,IAAJ,EAAiB;AAClCE,IAAAA,OAAO,CAACC,IAAR,CAAa,aAAb,EAA4B,GAAGH,IAA/B;AACD;;AAEOI,EAAAA,wBAAwB,GAAS;AACvC,QAAI,KAAKC,SAAT,EAAoB;AAClBC,MAAAA,MAAM,CAACC,IAAP,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MAAAA,OAAO,EAAE,IAAI9F,WAAJ,CAAgB,KAAKwE,YAAL,CAAkBuB,IAAlB,CAAuB,IAAvB,CAAhB,CAPC;AAQVS,MAAAA,OAAO,EAAE,IAAI3G,WAAJ,CAAgB,KAAK2E,YAAL,CAAkBuB,IAAlB,CAAuB,IAAvB,CAAhB,CARC;AASVU,MAAAA,KAAK,EAAE,IAAIvG,SAAJ,CAAc,KAAKsE,YAAL,CAAkBuB,IAAlB,CAAuB,IAAvB,CAAd,CATG;AAUVjC,MAAAA,MAAM,EAAE,IAAI7D,UAAJ,CAAe,KAAKuE,YAAL,CAAkBuB,IAAlB,CAAuB,IAAvB,CAAf,CAVE;AAWVW,MAAAA,QAAQ,EAAE,IAAIvG,YAAJ,CAAiB,KAAKqE,YAAL,CAAkBuB,IAAlB,CAAuB,IAAvB,CAAjB;AAXA,KADkC;AAAA;;AAAA","sourcesContent":["import {Backoffice, Message, Route, Shop} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser\n} from \"./backofficeServices\";\nimport Events from \"./events\";\nimport {\n ShopAccount,\n ShopAuthorization,\n ShopCart,\n ShopCatalog,\n ShopConfig,\n ShopUtils,\n ShopWishlist,\n} from \"./shopServices\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nenum SdkInternalEvents {\n INIT='INIT',\n UPDATE='UPDATE'\n}\nexport enum SdkEvents {\n INIT='INIT',\n UPDATE='UPDATE',\n}\nexport interface SdkOptions {\n debug?: boolean\n autoheight?: boolean\n origin: string\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nabstract class Sdk<T> extends Events {\n private channel!: Channel;\n private static debug = false\n private autoheight = true\n private heightMutationObserver = null\n origin: string;\n isInitialized = false\n instances!: T;\n\n private static log(...data: any[]) {\n Sdk.debug && console.log('[SDK Core] ', ...data)\n }\n\n private static warn(...data: any[]) {\n console.warn('[SDK Core] ', ...data)\n }\n\n private initializeServiceGetters(): void {\n if (this.instances) {\n Object.keys(this.instances).forEach((serviceName: string) => {\n Object.defineProperty(this, serviceName, {\n get: () => {\n return this.isInitialized ? this.instances![serviceName as keyof T] : null\n }\n })\n })\n }\n }\n\n constructor(options: SdkOptions) {\n super()\n this.initializeServiceGetters()\n this.origin = options.origin\n this.channel = new Channel({\n targetOrigin: this.origin,\n target: window.parent,\n })\n this.channel.subscribe(Message.INIT, (payload: any) => {\n Sdk.log('Handling INIT message')\n Object.entries(this.instances!).forEach(([key, value]: [key: string, value: BaseCallClass | Record<string, any>]) => {\n if (value instanceof BaseCallClass) {\n value.update(payload)\n } else {\n const attributesForKey = payload[key]\n if (typeof attributesForKey !== 'undefined') {\n BaseCallClass.update(value as Record<string, any>, payload[key])\n } else {\n Sdk.warn(`Missing attributes for ${key} in `, payload)\n }\n }\n })\n Sdk.log('Emitting INIT with payload ', this.instances)\n this.emit(SdkInternalEvents.INIT, this.instances)\n this.isInitialized = true\n })\n this.channel.subscribe(Message.UPDATE, (payload: any) => {\n Sdk.log('Emitting UPDATE with payload ', payload)\n this.emit(SdkInternalEvents.UPDATE, payload)\n })\n this.channel.subscribe(Message.FRAME_HEIGHT_REQUEST, (payload: any) => {\n if (this.autoheight) {\n Sdk.log('Request for iframe height')\n this.sendFrameHeight()\n }\n })\n this.channel.connect().then(() => {\n Sdk.log('Connected with ONe SDK')\n if(this.autoheight) {\n this.initializeHeightObserver()\n }\n })\n this.setupOptions(options)\n Sdk.log('Initialized.')\n }\n\n private sendFrameHeight() {\n const body = document.body, html = document.documentElement;\n const height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight);\n this.channel.postMessage(Message.FRAME_HEIGHT_CHANGE, height)\n }\n\n private initializeHeightObserver() {\n if (\"MutationObserver\" in window) {\n const onMutationObserved = () => {\n this.sendFrameHeight()\n }\n const target = document.querySelector('body'),\n config = {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n }\n\n this.heightMutationObserver = new MutationObserver(onMutationObserved)\n\n Sdk.log('Create body MutationObserver')\n this.heightMutationObserver.observe(target, config)\n } else {\n Sdk.warn('MutationObserver not available. Auto-height functionality disabled.')\n }\n }\n\n private setupOptions(options?: SdkOptions) {\n if (options) {\n if (typeof options.debug !== 'undefined') {\n Sdk.debug = options.debug\n }\n if (typeof options.autoheight !== 'undefined') {\n this.autoheight = options.autoheight\n }\n }\n }\n protected callFunction(service: string, fun: string, ...payload: any) {\n const callId: string = generateCallId()\n if (this.isInitialized) {\n Sdk.log(`Call ID ${callId} for ${service}:${fun}`, payload)\n this.channel.postMessage(Message.METHOD_CALL, {\n callId,\n service,\n method: fun,\n payload: payload,\n })\n return new Promise((resolve, reject) => {\n const onChannelMessage = (response: any) => {\n if (response.callId === callId) {\n this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage)\n if (response.isException) {\n return reject(response.result);\n }\n\n return resolve(response.result)\n }\n }\n this.channel.subscribe(Message.METHOD_RESULT, onChannelMessage)\n })\n }\n Sdk.log('SDK is not initialized!')\n return Promise.resolve(null)\n }\n\n public navigate(event: NamedNavigationPayload | PathNavigationPayload) {\n this.channel.postMessage(Message.NAVIGATION_PUSH, event)\n }\n\n}\n\nexport interface BackofficeInstances extends Backoffice.Api {\n route: Route,\n catalog: BackofficeCatalog,\n user: BackofficeUser,\n tenant: BackofficeTenant,\n layout: BackofficeLayout,\n authorization: BackofficeAuthorization,\n customer: BackofficeCustomer,\n plugin: BackofficePlugin\n}\n\nexport interface ShopInstances extends Shop.Api {\n authorization: ShopAuthorization,\n route: Route,\n cart: ShopCart,\n catalog: ShopCatalog,\n account: ShopAccount,\n utils: ShopUtils\n config: ShopConfig,\n wishlist: ShopWishlist,\n}\n\nexport class BackofficeSdk extends Sdk<BackofficeInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n catalog: new BackofficeCatalog(this.callFunction.bind(this)),\n user: new BackofficeUser(this.callFunction.bind(this)),\n tenant: new BackofficeTenant(this.callFunction.bind(this)),\n layout: new BackofficeLayout(this.callFunction.bind(this)),\n authorization: new BackofficeAuthorization(this.callFunction.bind(this)),\n customer: new BackofficeCustomer(this.callFunction.bind(this)),\n plugin: new BackofficePlugin(this.callFunction.bind(this)),\n }\n}\n\nexport class ShopSdk extends Sdk<ShopInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n authorization: new ShopAuthorization(this.callFunction.bind(this)),\n cart: new ShopCart(this.callFunction.bind(this)),\n catalog: new ShopCatalog(this.callFunction.bind(this)),\n account: new ShopAccount(this.callFunction.bind(this)),\n utils: new ShopUtils(this.callFunction.bind(this)),\n config: new ShopConfig(this.callFunction.bind(this)),\n wishlist: new ShopWishlist(this.callFunction.bind(this)),\n }\n}\n"],"file":"index.js"}
@@ -20,6 +20,26 @@ export class ShopCatalog extends BaseCallClass {
20
20
  return this.call('getCategoryById', categoryId);
21
21
  }
22
22
 
23
+ }
24
+ export class ShopWishlist extends BaseCallClass {
25
+ constructor(...args) {
26
+ super(...args);
27
+
28
+ _defineProperty(this, "serviceName", 'wishlist');
29
+ }
30
+
31
+ addProductsToWishlist(wishlistId, newProduct) {
32
+ return this.call('addProductsToWishlist', wishlistId, newProduct);
33
+ }
34
+
35
+ getWishlists() {
36
+ return this.call('getWishlists');
37
+ }
38
+
39
+ createWishlist(name) {
40
+ return this.call('createWishlist', name);
41
+ }
42
+
23
43
  }
24
44
  export class ShopAccount extends BaseCallClass {
25
45
  constructor(...args) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shopServices.ts"],"names":["BaseCallClass","ShopCatalog","fetchProduct","productId","call","getCategoryById","categoryId","ShopAccount","hasSegment","name","logout","ShopCart","addToCart","amount","where","cartId","ShopAuthorization","getAuthToken","ShopUtils","constructor","routes","getCategoryPath","getManufacturerS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ASjEmB,EAAAA,WAAW,CAACf,IAAD,EAAoE;AAC7E,UAAMA,IAAN;;AAD6E,yCARjE,OAQiE;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAE7E,SAAKgB,MAAL,GAAc;AACZC,MAAAA,eAAe,EAAE,KAAKA,eADV;AAEZC,MAAAA,wBAAwB,EAAE,KAAKA,wBAFnB;AAGZC,MAAAA,aAAa,EAAE,KAAKA,aAHR;AAIZC,MAAAA,aAAa,EAAE,KAAKA;AAJR,KAAd;AAMD;;AAEDH,EAAAA,eAAe,CAACI,EAAD,EAAsC;AACnD,WAAO,KAAKrB,IAAL,CAAU,iBAAV,EAA6BqB,EAA7B,CAAP;AACD;;AAEDH,EAAAA,wBAAwB,CAACI,YAAD,EAAwC;AAC9D,WAAO,KAAKtB,IAAL,CAAU,0BAAV,EAAsCsB,YAAtC,CAAP;AACD;;AAEDH,EAAAA,aAAa,CAACI,OAAD,EAAuC;AAClD,WAAO,KAAKvB,IAAL,CAAU,eAAV,EAA2BuB,OAA3B,CAAP;AACD;;AAEDH,EAAAA,aAAa,CAACI,GAAD,EAAgC;AAC3C,WAAO,KAAKxB,IAAL,CAAU,eAAV,EAA2BwB,GAA3B,CAAP;AACD;;AAjCgE;AAuDnE,OAAO,MAAMC,UAAN,SAAyB7B,aAAzB,CAA8D;AAAA;AAAA;;AAAA,yCACrD,QADqD;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;AAAA;;AAAA","sourcesContent":["import {Backoffice, Shop} from \"@one-commerce/sdk-shared\";\n\nimport {BaseCallClass} from \"./utils\";\n\nexport class ShopCatalog extends BaseCallClass implements Shop.Catalog {\n serviceName = 'catalog'\n categories!: Array<any>;\n selectedCategoryId!: string | null;\n\n fetchProduct(productId: string): Promise<any> {\n return this.call('fetchProduct', productId)\n }\n\n getCategoryById(categoryId: string): Promise<any> {\n return this.call('getCategoryById', categoryId)\n }\n\n\n}\n\nexport class ShopAccount extends BaseCallClass implements Shop.Account {\n serviceName = 'account'\n client!: {\n id: string;\n name: string;\n externalId?: string;\n tin?: string;\n phone?: string;\n segmentId?: string;\n segments: {\n additionalSegments?: Array<{\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n }>;\n mainSegment: {\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n };\n };\n warehouseId?: string;\n termPayment?: {\n id: string;\n label?: string;\n paymentDaysPeriod?: number;\n };\n isTaxPayer?: boolean;\n billingAddress?: {\n city: string;\n country: string;\n id: string;\n isDefault: boolean;\n name: string;\n phone: string;\n street: string;\n type: string;\n zipCode: string\n }\n };\n isAuthenticated!: boolean;\n user!: {\n email?: string;\n name?: string;\n phone?: string;\n /**\n * @deprecated Use non-nested function instead\n */\n hasSegment(name: string): Promise<boolean>\n };\n\n hasSegment(name: string): Promise<boolean> {\n return this.call('hasSegment', name)\n }\n\n manager!: {\n additionalEmail?: string;\n email: string; id: string;\n landlinePhone?: string;\n mobilePhone?: string;\n name: string;\n photo?: string\n };\n\n logout(): void {\n // NotImplementedYet\n }\n}\n\nexport class ShopCart extends BaseCallClass implements Shop.Cart {\n serviceName = 'cart'\n carts!: Array<any>;\n currentCart!: any;\n totalCartPrice!: number;\n\n addToCart(productId: string, amount: number, where: string, cartId?: string): Promise<void> {\n return this.call('addToCart', productId, amount, where, cartId)\n }\n}\n\nexport class ShopAuthorization extends BaseCallClass implements Shop.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class ShopUtils extends BaseCallClass implements Shop.Utils {\n serviceName = 'utils'\n currency!: any;\n isAnonymousAndPurchaseDisabled!: boolean;\n isB2B!: boolean;\n isB2BAndPlatformIsNotOpened!: boolean;\n isIndexPage!: boolean;\n isPurchaseEnabledOrAuthenticated!: boolean;\n\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n super(call)\n this.routes = {\n getCategoryPath: this.getCategoryPath,\n getManufacturerSearchUrl: this.getManufacturerSearchUrl,\n getProductUrl: this.getProductUrl,\n isExternalUrl: this.isExternalUrl\n }\n }\n\n getCategoryPath(id?: string): Promise<string | null> {\n return this.call('getCategoryPath', id)\n }\n\n getManufacturerSearchUrl(manufacturer: string): Promise<string> {\n return this.call('getManufacturerSearchUrl', manufacturer)\n }\n\n getProductUrl(product: any): Promise<string | null> {\n return this.call('getProductUrl', product)\n }\n\n isExternalUrl(url: string): Promise<boolean> {\n return this.call('isExternalUrl', url)\n }\n\n routes: {\n /**\n * @deprecated Use non-nested function instead\n */\n getCategoryPath(id?: string): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n getManufacturerSearchUrl(manufacturer: string): (Promise<string> | string);\n /**\n * @deprecated Use non-nested function instead\n */\n getProductUrl(product: any): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n isExternalUrl(url: string): (Promise<boolean> | boolean)\n };\n}\n\nexport class ShopConfig extends BaseCallClass implements Shop.Config {\n serviceName = 'config'\n accessMode!: string;\n isB2CRegistrationEnabled!: boolean;\n isCatalogOpened!: boolean;\n isGrossSelected!: boolean;\n isPlatformClosed!: boolean;\n isPlatformOpened!: boolean;\n isPurchaseEnabled!: boolean;\n isRegistrationEnabled!: boolean;\n currency: any;\n}\n"],"file":"shopServices.js"}
1
+ {"version":3,"sources":["../../src/shopServices.ts"],"names":["BaseCallClass","ShopCatalog","fetchProduct","productId","call","getCategoryById","categoryId","ShopWishlist","addProductsToWishlist","wishlistId","newProduct","getWishlists","createWishlist","name","ShopAccount","hasSegment","logout","ShopCart","addToCart","amount","where","cartId","ShopAuthorization","getAuthToken","ShopUtils","constructor","routes","getCategoryPath","getManufacturerSearchUrl","getProductUrl","isExternalUrl","id","manufacturer","product","url","ShopConfig"],"mappings":";;AACA,SAAQA,aAAR,QAA4B,SAA5B;AAEA,OAAO,MAAMC,WAAN,SAA0BD,aAA1B,CAAgE;AAAA;AAAA;;AAAA,y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"@one-commerce/sdk-shared\";\nimport {BaseCallClass} from \"./utils\";\n\nexport class ShopCatalog extends BaseCallClass implements Shop.Catalog {\n serviceName = 'catalog'\n categories!: Array<any>;\n selectedCategoryId!: string | null;\n\n fetchProduct(productId: string): Promise<any> {\n return this.call('fetchProduct', productId)\n }\n\n getCategoryById(categoryId: string): Promise<any> {\n return this.call('getCategoryById', categoryId)\n }\n}\nexport class ShopWishlist extends BaseCallClass implements Shop.Wishlist {\n serviceName = 'wishlist'\n\n addProductsToWishlist(wishlistId: string, newProduct: any): Promise<void> {\n return this.call('addProductsToWishlist', wishlistId, newProduct)\n }\n\n getWishlists(): Promise<any> {\n return this.call('getWishlists')\n }\n\n createWishlist(name: string): Promise<any> {\n return this.call('createWishlist', name)\n }\n}\nexport class ShopAccount extends BaseCallClass implements Shop.Account {\n serviceName = 'account'\n client!: {\n id: string;\n name: string;\n externalId?: string;\n tin?: string;\n phone?: string;\n segmentId?: string;\n segments: {\n additionalSegments?: Array<{\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n }>;\n mainSegment: {\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n };\n };\n warehouseId?: string;\n termPayment?: {\n id: string;\n label?: string;\n paymentDaysPeriod?: number;\n };\n isTaxPayer?: boolean;\n billingAddress?: {\n city: string;\n country: string;\n id: string;\n isDefault: boolean;\n name: string;\n phone: string;\n street: string;\n type: string;\n zipCode: string\n }\n };\n isAuthenticated!: boolean;\n user!: {\n email?: string;\n name?: string;\n phone?: string;\n /**\n * @deprecated Use non-nested function instead\n */\n hasSegment(name: string): Promise<boolean>\n };\n\n hasSegment(name: string): Promise<boolean> {\n return this.call('hasSegment', name)\n }\n\n manager!: {\n additionalEmail?: string;\n email: string; id: string;\n landlinePhone?: string;\n mobilePhone?: string;\n name: string;\n photo?: string\n };\n\n logout(): void {\n // NotImplementedYet\n }\n}\n\nexport class ShopCart extends BaseCallClass implements Shop.Cart {\n serviceName = 'cart'\n carts!: Array<any>;\n currentCart!: any;\n totalCartPrice!: number;\n\n addToCart(productId: string, amount: number, where: string, cartId?: string): Promise<void> {\n return this.call('addToCart', productId, amount, where, cartId)\n }\n}\n\nexport class ShopAuthorization extends BaseCallClass implements Shop.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class ShopUtils extends BaseCallClass implements Shop.Utils {\n serviceName = 'utils'\n currency!: any;\n isAnonymousAndPurchaseDisabled!: boolean;\n isB2B!: boolean;\n isB2BAndPlatformIsNotOpened!: boolean;\n isIndexPage!: boolean;\n isPurchaseEnabledOrAuthenticated!: boolean;\n\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n super(call)\n this.routes = {\n getCategoryPath: this.getCategoryPath,\n getManufacturerSearchUrl: this.getManufacturerSearchUrl,\n getProductUrl: this.getProductUrl,\n isExternalUrl: this.isExternalUrl\n }\n }\n\n getCategoryPath(id?: string): Promise<string | null> {\n return this.call('getCategoryPath', id)\n }\n\n getManufacturerSearchUrl(manufacturer: string): Promise<string> {\n return this.call('getManufacturerSearchUrl', manufacturer)\n }\n\n getProductUrl(product: any): Promise<string | null> {\n return this.call('getProductUrl', product)\n }\n\n isExternalUrl(url: string): Promise<boolean> {\n return this.call('isExternalUrl', url)\n }\n\n routes: {\n /**\n * @deprecated Use non-nested function instead\n */\n getCategoryPath(id?: string): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n getManufacturerSearchUrl(manufacturer: string): (Promise<string> | string);\n /**\n * @deprecated Use non-nested function instead\n */\n getProductUrl(product: any): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n isExternalUrl(url: string): (Promise<boolean> | boolean)\n };\n}\n\nexport class ShopConfig extends BaseCallClass implements Shop.Config {\n serviceName = 'config'\n accessMode!: string;\n isB2CRegistrationEnabled!: boolean;\n isCatalogOpened!: boolean;\n isGrossSelected!: boolean;\n isPlatformClosed!: boolean;\n isPlatformOpened!: boolean;\n isPurchaseEnabled!: boolean;\n isRegistrationEnabled!: boolean;\n currency: any;\n}\n"],"file":"shopServices.js"}
@@ -18,9 +18,6 @@ export declare class BackofficeTenant extends BaseCallClass implements Backoffic
18
18
  language?: string;
19
19
  currency?: string;
20
20
  }
21
- export declare class BackofficeOrderpath extends BaseCallClass implements Backoffice.Orderpath {
22
- serviceName: string;
23
- }
24
21
  export declare class BackofficeLayout extends BaseCallClass implements Backoffice.Layout {
25
22
  serviceName: string;
26
23
  isAsideOpened: boolean;
@@ -40,13 +37,4 @@ export declare class BackofficePlugin extends BaseCallClass implements Backoffic
40
37
  srcUrl?: string;
41
38
  name?: string;
42
39
  }
43
- export declare class BackofficeAddToCartContext extends BaseCallClass implements Backoffice.AddToCartContext {
44
- serviceName: string;
45
- productId?: string;
46
- cartId?: string;
47
- warehouses?: Array<any>;
48
- closePlugin?(): void;
49
- closePluginAndAddToCart?(): void;
50
- closePluginAndRefreshCart?(): void;
51
- }
52
40
  //# sourceMappingURL=backofficeServices.d.ts.map