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

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.BackofficeUser = exports.BackofficeTenant = exports.BackofficePlugin = exports.BackofficeOrderpath = exports.BackofficeLayout = exports.BackofficeCustomer = exports.BackofficeCatalog = exports.BackofficeAuthorization = void 0;
8
+ exports.BackofficeUser = exports.BackofficeTenant = exports.BackofficePlugin = exports.BackofficeLayout = exports.BackofficeCustomer = exports.BackofficeCatalog = exports.BackofficeAuthorization = void 0;
9
9
 
10
10
  var _utils = require("../utils");
11
11
 
@@ -17,7 +17,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
17
17
 
18
18
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
19
 
20
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
21
 
22
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
23
 
@@ -27,7 +27,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
27
27
 
28
28
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
29
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
31
 
32
32
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
33
 
@@ -135,15 +135,15 @@ var BackofficeTenant = /*#__PURE__*/function (_BaseCallClass3) {
135
135
 
136
136
  exports.BackofficeTenant = BackofficeTenant;
137
137
 
138
- var BackofficeOrderpath = /*#__PURE__*/function (_BaseCallClass4) {
139
- _inherits(BackofficeOrderpath, _BaseCallClass4);
138
+ var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass4) {
139
+ _inherits(BackofficeLayout, _BaseCallClass4);
140
140
 
141
- var _super4 = _createSuper(BackofficeOrderpath);
141
+ var _super4 = _createSuper(BackofficeLayout);
142
142
 
143
- function BackofficeOrderpath() {
143
+ function BackofficeLayout() {
144
144
  var _this4;
145
145
 
146
- _classCallCheck(this, BackofficeOrderpath);
146
+ _classCallCheck(this, BackofficeLayout);
147
147
 
148
148
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
149
149
  args[_key4] = arguments[_key4];
@@ -151,25 +151,27 @@ var BackofficeOrderpath = /*#__PURE__*/function (_BaseCallClass4) {
151
151
 
152
152
  _this4 = _super4.call.apply(_super4, [this].concat(args));
153
153
 
154
- _defineProperty(_assertThisInitialized(_this4), "serviceName", 'orderpath');
154
+ _defineProperty(_assertThisInitialized(_this4), "serviceName", 'layout');
155
+
156
+ _defineProperty(_assertThisInitialized(_this4), "isAsideOpened", void 0);
155
157
 
156
158
  return _this4;
157
159
  }
158
160
 
159
- return _createClass(BackofficeOrderpath);
161
+ return _createClass(BackofficeLayout);
160
162
  }(_utils.BaseCallClass);
161
163
 
162
- exports.BackofficeOrderpath = BackofficeOrderpath;
164
+ exports.BackofficeLayout = BackofficeLayout;
163
165
 
164
- var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass5) {
165
- _inherits(BackofficeLayout, _BaseCallClass5);
166
+ var BackofficeAuthorization = /*#__PURE__*/function (_BaseCallClass5) {
167
+ _inherits(BackofficeAuthorization, _BaseCallClass5);
166
168
 
167
- var _super5 = _createSuper(BackofficeLayout);
169
+ var _super5 = _createSuper(BackofficeAuthorization);
168
170
 
169
- function BackofficeLayout() {
171
+ function BackofficeAuthorization() {
170
172
  var _this5;
171
173
 
172
- _classCallCheck(this, BackofficeLayout);
174
+ _classCallCheck(this, BackofficeAuthorization);
173
175
 
174
176
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
175
177
  args[_key5] = arguments[_key5];
@@ -177,39 +179,11 @@ var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass5) {
177
179
 
178
180
  _this5 = _super5.call.apply(_super5, [this].concat(args));
179
181
 
180
- _defineProperty(_assertThisInitialized(_this5), "serviceName", 'layout');
181
-
182
- _defineProperty(_assertThisInitialized(_this5), "isAsideOpened", void 0);
182
+ _defineProperty(_assertThisInitialized(_this5), "serviceName", 'authorization');
183
183
 
184
184
  return _this5;
185
185
  }
186
186
 
187
- return _createClass(BackofficeLayout);
188
- }(_utils.BaseCallClass);
189
-
190
- exports.BackofficeLayout = BackofficeLayout;
191
-
192
- var BackofficeAuthorization = /*#__PURE__*/function (_BaseCallClass6) {
193
- _inherits(BackofficeAuthorization, _BaseCallClass6);
194
-
195
- var _super6 = _createSuper(BackofficeAuthorization);
196
-
197
- function BackofficeAuthorization() {
198
- var _this6;
199
-
200
- _classCallCheck(this, BackofficeAuthorization);
201
-
202
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
203
- args[_key6] = arguments[_key6];
204
- }
205
-
206
- _this6 = _super6.call.apply(_super6, [this].concat(args));
207
-
208
- _defineProperty(_assertThisInitialized(_this6), "serviceName", 'authorization');
209
-
210
- return _this6;
211
- }
212
-
213
187
  _createClass(BackofficeAuthorization, [{
214
188
  key: "getAuthToken",
215
189
  value: function getAuthToken() {
@@ -222,29 +196,29 @@ var BackofficeAuthorization = /*#__PURE__*/function (_BaseCallClass6) {
222
196
 
223
197
  exports.BackofficeAuthorization = BackofficeAuthorization;
224
198
 
225
- var BackofficeCustomer = /*#__PURE__*/function (_BaseCallClass7) {
226
- _inherits(BackofficeCustomer, _BaseCallClass7);
199
+ var BackofficeCustomer = /*#__PURE__*/function (_BaseCallClass6) {
200
+ _inherits(BackofficeCustomer, _BaseCallClass6);
227
201
 
228
- var _super7 = _createSuper(BackofficeCustomer);
202
+ var _super6 = _createSuper(BackofficeCustomer);
229
203
 
230
204
  function BackofficeCustomer() {
231
- var _this7;
205
+ var _this6;
232
206
 
233
207
  _classCallCheck(this, BackofficeCustomer);
234
208
 
235
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
236
- args[_key7] = arguments[_key7];
209
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
210
+ args[_key6] = arguments[_key6];
237
211
  }
238
212
 
239
- _this7 = _super7.call.apply(_super7, [this].concat(args));
213
+ _this6 = _super6.call.apply(_super6, [this].concat(args));
240
214
 
241
- _defineProperty(_assertThisInitialized(_this7), "serviceName", 'customer');
215
+ _defineProperty(_assertThisInitialized(_this6), "serviceName", 'customer');
242
216
 
243
- _defineProperty(_assertThisInitialized(_this7), "id", void 0);
217
+ _defineProperty(_assertThisInitialized(_this6), "id", void 0);
244
218
 
245
- _defineProperty(_assertThisInitialized(_this7), "name", void 0);
219
+ _defineProperty(_assertThisInitialized(_this6), "name", void 0);
246
220
 
247
- return _this7;
221
+ return _this6;
248
222
  }
249
223
 
250
224
  return _createClass(BackofficeCustomer);
@@ -252,31 +226,31 @@ var BackofficeCustomer = /*#__PURE__*/function (_BaseCallClass7) {
252
226
 
253
227
  exports.BackofficeCustomer = BackofficeCustomer;
254
228
 
255
- var BackofficePlugin = /*#__PURE__*/function (_BaseCallClass8) {
256
- _inherits(BackofficePlugin, _BaseCallClass8);
229
+ var BackofficePlugin = /*#__PURE__*/function (_BaseCallClass7) {
230
+ _inherits(BackofficePlugin, _BaseCallClass7);
257
231
 
258
- var _super8 = _createSuper(BackofficePlugin);
232
+ var _super7 = _createSuper(BackofficePlugin);
259
233
 
260
234
  function BackofficePlugin() {
261
- var _this8;
235
+ var _this7;
262
236
 
263
237
  _classCallCheck(this, BackofficePlugin);
264
238
 
265
- for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
266
- args[_key8] = arguments[_key8];
239
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
240
+ args[_key7] = arguments[_key7];
267
241
  }
268
242
 
269
- _this8 = _super8.call.apply(_super8, [this].concat(args));
243
+ _this7 = _super7.call.apply(_super7, [this].concat(args));
270
244
 
271
- _defineProperty(_assertThisInitialized(_this8), "serviceName", 'plugin');
245
+ _defineProperty(_assertThisInitialized(_this7), "serviceName", 'plugin');
272
246
 
273
- _defineProperty(_assertThisInitialized(_this8), "id", void 0);
247
+ _defineProperty(_assertThisInitialized(_this7), "id", void 0);
274
248
 
275
- _defineProperty(_assertThisInitialized(_this8), "srcUrl", void 0);
249
+ _defineProperty(_assertThisInitialized(_this7), "srcUrl", void 0);
276
250
 
277
- _defineProperty(_assertThisInitialized(_this8), "name", void 0);
251
+ _defineProperty(_assertThisInitialized(_this7), "name", void 0);
278
252
 
279
- return _this8;
253
+ return _this7;
280
254
  }
281
255
 
282
256
  return _createClass(BackofficePlugin);
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","names":["BackofficeCatalog","call","id","BaseCallClass","BackofficeUser","BackofficeTenant","BackofficeOrderpath","BackofficeLayout","BackofficeAuthorization","BackofficeCustomer","BackofficePlugin"],"sources":["../../../src/backoffice/services.ts"],"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"],"mappings":";;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,iB;;;;;;;;;;;;;;;;kEACG,S;;;;;;;WAEd,2BAA2C;MACzC,OAAO,KAAKC,IAAL,CAAU,iBAAV,CAAP;IACD;;;WACD,sBAAoBC,EAApB,EAAkD;MAChD,OAAO,KAAKD,IAAL,CAAU,cAAV,EAA0BC,EAA1B,CAAP;IACD;;;;EARoCC,oB;;;;IAW1BC,c;;;;;;;;;;;;;;;;mEACG,M;;;;;;;;;;;;;;EADoBD,oB;;;;IAQvBE,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;EADsBF,oB;;;;IAOzBG,mB;;;;;;;;;;;;;;;;mEACG,W;;;;;;EADyBH,oB;;;;IAI5BI,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;EADsBJ,oB;;;;IAKzBK,uB;;;;;;;;;;;;;;;;mEACG,e;;;;;;;WAEd,wBAAgC;MAC9B,OAAO,KAAKP,IAAL,CAAU,cAAV,CAAP;IACD;;;;EAL0CE,oB;;;;IAQhCM,kB;;;;;;;;;;;;;;;;mEACG,U;;;;;;;;;;EADwBN,oB;;;;IAM3BO,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;EADsBP,oB"}
1
+ {"version":3,"sources":["../../../src/backoffice/services.ts"],"names":["BackofficeCatalog","call","id","BaseCallClass","BackofficeUser","BackofficeTenant","BackofficeLayout","BackofficeAuthorization","BackofficeCustomer","BackofficePlugin"],"mappings":";;;;;;;;;AACA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,iB;;;;;;;;;;;;;;;;kEACG,S;;;;;;;WAEd,2BAA2C;AACzC,aAAO,KAAKC,IAAL,CAAU,iBAAV,CAAP;AACD;;;WACD,sBAAoBC,EAApB,EAAkD;AAChD,aAAO,KAAKD,IAAL,CAAU,cAAV,EAA0BC,EAA1B,CAAP;AACD;;;;EARoCC,oB;;;;IAW1BC,c;;;;;;;;;;;;;;;;mEACG,M;;;;;;;;;;;;;;EADoBD,oB;;;;IAQvBE,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;EADsBF,oB;;;;IAOzBG,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;EADsBH,oB;;;;IAKzBI,uB;;;;;;;;;;;;;;;;mEACG,e;;;;;;;WAEd,wBAAgC;AAC9B,aAAO,KAAKN,IAAL,CAAU,cAAV,CAAP;AACD;;;;EAL0CE,oB;;;;IAQhCK,kB;;;;;;;;;;;;;;;;mEACG,U;;;;;;;;;;EADwBL,oB;;;;IAM3BM,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;EADsBN,oB","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"],"file":"services.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","names":["Events","_callbacks","key","callback","undefined","push","params","i","length"],"sources":["../../src/events.ts"],"sourcesContent":["class Events {\n _callbacks: Record<string, any>\n constructor () {\n this._callbacks = {}\n }\n\n on<T>(key: string, callback: (arg: T) => void) {\n // create an empty array for the event key\n if (this._callbacks[key] === undefined) { this._callbacks[key] = [] }\n // save the callback in the array for the event key\n this._callbacks[key].push(callback)\n }\n\n emit(key: string, ...params: Array<any>) {\n // if the key exists\n if (this._callbacks[key] !== undefined) {\n // iterate through the callbacks for the event key\n for (let i=0; i<this._callbacks[key].length; i++) {\n // trigger the callbacks with all provided params\n this._callbacks[key][i](...params)\n }\n }\n }\n}\n\nexport default Events\n"],"mappings":";;;;;;;;;;;;;;;IAAMA,M;EAEJ,kBAAe;IAAA;;IAAA;;IACb,KAAKC,UAAL,GAAkB,EAAlB;EACD;;;;WAED,YAAMC,GAAN,EAAmBC,QAAnB,EAA+C;MAC7C;MACA,IAAI,KAAKF,UAAL,CAAgBC,GAAhB,MAAyBE,SAA7B,EAAwC;QAAE,KAAKH,UAAL,CAAgBC,GAAhB,IAAuB,EAAvB;MAA2B,CAFxB,CAG7C;;;MACA,KAAKD,UAAL,CAAgBC,GAAhB,EAAqBG,IAArB,CAA0BF,QAA1B;IACD;;;WAED,cAAKD,GAAL,EAAyC;MACvC;MACA,IAAI,KAAKD,UAAL,CAAgBC,GAAhB,MAAyBE,SAA7B,EAAwC;QAAA,kCAFrBE,MAEqB;UAFrBA,MAEqB;QAAA;;QACtC;QACA,KAAK,IAAIC,CAAC,GAAC,CAAX,EAAcA,CAAC,GAAC,KAAKN,UAAL,CAAgBC,GAAhB,EAAqBM,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;UAAA;;UAChD;UACA,6BAAKN,UAAL,CAAgBC,GAAhB,GAAqBK,CAArB,8BAA2BD,MAA3B;QACD;MACF;IACF;;;;;;eAGYN,M"}
1
+ {"version":3,"sources":["../../src/events.ts"],"names":["Events","_callbacks","key","callback","undefined","push","params","i","length"],"mappings":";;;;;;;;;;;;;;;IAAMA,M;AAEJ,oBAAe;AAAA;;AAAA;;AACb,SAAKC,UAAL,GAAkB,EAAlB;AACD;;;;WAED,YAAMC,GAAN,EAAmBC,QAAnB,EAA+C;AAC7C;AACA,UAAI,KAAKF,UAAL,CAAgBC,GAAhB,MAAyBE,SAA7B,EAAwC;AAAE,aAAKH,UAAL,CAAgBC,GAAhB,IAAuB,EAAvB;AAA2B,OAFxB,CAG7C;;;AACA,WAAKD,UAAL,CAAgBC,GAAhB,EAAqBG,IAArB,CAA0BF,QAA1B;AACD;;;WAED,cAAKD,GAAL,EAAyC;AACvC;AACA,UAAI,KAAKD,UAAL,CAAgBC,GAAhB,MAAyBE,SAA7B,EAAwC;AAAA,0CAFrBE,MAEqB;AAFrBA,UAAAA,MAEqB;AAAA;;AACtC;AACA,aAAK,IAAIC,CAAC,GAAC,CAAX,EAAcA,CAAC,GAAC,KAAKN,UAAL,CAAgBC,GAAhB,EAAqBM,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;AAAA;;AAChD;AACA,uCAAKN,UAAL,CAAgBC,GAAhB,GAAqBK,CAArB,8BAA2BD,MAA3B;AACD;AACF;AACF;;;;;;eAGYN,M","sourcesContent":["class Events {\n _callbacks: Record<string, any>\n constructor () {\n this._callbacks = {}\n }\n\n on<T>(key: string, callback: (arg: T) => void) {\n // create an empty array for the event key\n if (this._callbacks[key] === undefined) { this._callbacks[key] = [] }\n // save the callback in the array for the event key\n this._callbacks[key].push(callback)\n }\n\n emit(key: string, ...params: Array<any>) {\n // if the key exists\n if (this._callbacks[key] !== undefined) {\n // iterate through the callbacks for the event key\n for (let i=0; i<this._callbacks[key].length; i++) {\n // trigger the callbacks with all provided params\n this._callbacks[key][i](...params)\n }\n }\n }\n}\n\nexport default Events\n"],"file":"events.js"}
package/lib/cjs/index.js CHANGED
@@ -49,7 +49,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
49
49
 
50
50
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
51
51
 
52
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
52
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
53
53
 
54
54
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
55
55
 
@@ -59,7 +59,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
59
59
 
60
60
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
61
61
 
62
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
62
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
63
63
 
64
64
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
65
65
 
@@ -258,11 +258,15 @@ var Sdk = /*#__PURE__*/function (_Events) {
258
258
  method: fun,
259
259
  payload: payload
260
260
  });
261
- return new Promise(function (resolve) {
261
+ return new Promise(function (resolve, reject) {
262
262
  var onChannelMessage = function onChannelMessage(response) {
263
263
  if (response.callId === callId) {
264
264
  _this4.channel.unsubscribe(_sdkShared.Message.METHOD_RESULT, onChannelMessage);
265
265
 
266
+ if (response !== null && response !== void 0 && response.isException) {
267
+ return reject(response.result);
268
+ }
269
+
266
270
  return resolve(response.result);
267
271
  }
268
272
  };
@@ -329,7 +333,6 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
329
333
  hash: '',
330
334
  query: {}
331
335
  },
332
- orderpath: new _services.BackofficeOrderpath(_this5.callFunction.bind(_assertThisInitialized(_this5))),
333
336
  catalog: new _services.BackofficeCatalog(_this5.callFunction.bind(_assertThisInitialized(_this5))),
334
337
  user: new _services.BackofficeUser(_this5.callFunction.bind(_assertThisInitialized(_this5))),
335
338
  tenant: new _services.BackofficeTenant(_this5.callFunction.bind(_assertThisInitialized(_this5))),
@@ -374,7 +377,8 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
374
377
  catalog: new _services2.ShopCatalog(_this6.callFunction.bind(_assertThisInitialized(_this6))),
375
378
  account: new _services2.ShopAccount(_this6.callFunction.bind(_assertThisInitialized(_this6))),
376
379
  utils: new _services2.ShopUtils(_this6.callFunction.bind(_assertThisInitialized(_this6))),
377
- config: new _services2.ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6)))
380
+ config: new _services2.ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6))),
381
+ wishlist: new _services2.ShopWishlist(_this6.callFunction.bind(_assertThisInitialized(_this6)))
378
382
  });
379
383
 
380
384
  return _this6;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["SdkInternalEvents","SdkEvents","Sdk","options","initializeServiceGetters","origin","channel","Channel","targetOrigin","target","window","parent","subscribe","Message","INIT","payload","log","Object","entries","instances","forEach","key","value","BaseCallClass","update","attributesForKey","warn","emit","isInitialized","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","contextClass","callFunction","bind","keys","serviceName","defineProperty","get","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","debug","context","service","fun","callId","generateCallId","METHOD_CALL","method","Promise","resolve","onChannelMessage","response","unsubscribe","METHOD_RESULT","result","event","NAVIGATION_PUSH","data","console","Events","BackofficeSdk","route","hash","query","orderpath","BackofficeOrderpath","catalog","BackofficeCatalog","user","BackofficeUser","tenant","BackofficeTenant","layout","BackofficeLayout","authorization","BackofficeAuthorization","customer","BackofficeCustomer","plugin","BackofficePlugin","initializeContextClass","ShopSdk","ShopAuthorization","cart","ShopCart","ShopCatalog","account","ShopAccount","utils","ShopUtils","ShopConfig"],"sources":["../../src/index.ts"],"sourcesContent":["import {\n Backoffice,\n Message,\n Route,\n Shop\n} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n AddToCartContext,\n} from \"./backoffice/context\";\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficeOrderpath,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n} from \"./backoffice/services\";\nimport Events from \"./events\";\nimport {\n ShopAccount, ShopAuthorization,\n ShopCart,\n ShopCatalog, ShopConfig, ShopUtils,\n} from \"./shop/services\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nexport type AvailableContext = AddToCartContext\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 context?: Class<AvailableContext>;\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nexport type Class<T = any> = new (...args: any[]) => T;\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 contextClass?: Class<AvailableContext>;\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 public initializeContextClass(): AvailableContext {\n if (this.contextClass) {\n return new this.contextClass(this.callFunction.bind(this))\n }\n return {} as AvailableContext\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 this.contextClass = options.context\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 context: AvailableContext\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 context: this.initializeContextClass()\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\nexport {\n AddToCartContext\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAMA;;AAEA;;AAGA;;AAUA;;AACA;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIKA,iB;;WAAAA,iB;EAAAA,iB;EAAAA,iB;GAAAA,iB,KAAAA,iB;;IAIOC,S;;;WAAAA,S;EAAAA,S;EAAAA,S;GAAA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;;;;;;;;;;;;;;;;iEACC;MACVpB,KAAK,EAAE;QACLC,IAAI,EAAE,EADD;QAELC,KAAK,EAAE;MAFF,CADG;MAKVW,aAAa,EAAE,IAAIQ,4BAAJ,CAAsB,OAAKxE,YAAL,CAAkBC,IAAlB,gCAAtB,CALL;MAMVwE,IAAI,EAAE,IAAIC,mBAAJ,CAAa,OAAK1E,YAAL,CAAkBC,IAAlB,gCAAb,CANI;MAOVuD,OAAO,EAAE,IAAImB,sBAAJ,CAAgB,OAAK3E,YAAL,CAAkBC,IAAlB,gCAAhB,CAPC;MAQV2E,OAAO,EAAE,IAAIC,sBAAJ,CAAgB,OAAK7E,YAAL,CAAkBC,IAAlB,gCAAhB,CARC;MASV6E,KAAK,EAAE,IAAIC,oBAAJ,CAAc,OAAK/E,YAAL,CAAkBC,IAAlB,gCAAd,CATG;MAUVmB,MAAM,EAAE,IAAI4D,qBAAJ,CAAe,OAAKhF,YAAL,CAAkBC,IAAlB,gCAAf;IAVE,C;;;;;;EADerC,G"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["SdkInternalEvents","SdkEvents","Sdk","options","initializeServiceGetters","origin","channel","Channel","targetOrigin","target","window","parent","subscribe","Message","INIT","payload","log","Object","entries","instances","forEach","key","value","BaseCallClass","update","attributesForKey","warn","emit","isInitialized","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","contextClass","callFunction","bind","keys","serviceName","defineProperty","get","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","debug","context","service","fun","callId","METHOD_CALL","method","Promise","resolve","reject","onChannelMessage","response","unsubscribe","METHOD_RESULT","isException","result","event","NAVIGATION_PUSH","data","console","Events","BackofficeSdk","route","hash","query","catalog","BackofficeCatalog","user","BackofficeUser","tenant","BackofficeTenant","layout","BackofficeLayout","authorization","BackofficeAuthorization","customer","BackofficeCustomer","plugin","BackofficePlugin","initializeContextClass","ShopSdk","ShopAuthorization","cart","ShopCart","ShopCatalog","account","ShopAccount","utils","ShopUtils","ShopConfig","wishlist","ShopWishlist"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAMA;;AAEA;;AAGA;;AASA;;AACA;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIKA,iB;;WAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,KAAAA,iB;;IAIOC,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;IAuBGC,G;;;;;AAqCb,eAAYC,OAAZ,EAAiC;AAAA;;AAAA;;AAC/B;;AAD+B;;AAAA,iEAlCZ,IAkCY;;AAAA,6EAjCA,IAiCA;;AAAA;;AAAA,oEA/BjB,KA+BiB;;AAAA;;AAAA;;AAE/B,UAAKC,wBAAL;;AACA,UAAKC,MAAL,GAAcF,OAAO,CAACE,MAAtB;AACA,UAAKC,OAAL,GAAe,IAAIC,yBAAJ,CAAY;AACzBC,MAAAA,YAAY,EAAE,MAAKH,MADM;AAEzBI,MAAAA,MAAM,EAAEC,MAAM,CAACC;AAFU,KAAZ,CAAf;;AAIA,UAAKL,OAAL,CAAaM,SAAb,CAAuBC,mBAAQC,IAA/B,EAAqC,UAACC,OAAD,EAAkB;AACrDb,MAAAA,GAAG,CAACc,GAAJ,CAAQ,uBAAR;AACAC,MAAAA,MAAM,CAACC,OAAP,CAAe,MAAKC,SAApB,EAAgCC,OAAhC,CAAwC,gBAA6E;AAAA;AAAA,YAA3EC,GAA2E;AAAA,YAAtEC,KAAsE;;AACnH,YAAIA,KAAK,YAAYC,oBAArB,EAAoC;AAClCD,UAAAA,KAAK,CAACE,MAAN,CAAaT,OAAb;AACD,SAFD,MAEO;AACL,cAAMU,gBAAgB,GAAGV,OAAO,CAACM,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,gCAAhB,CARC;AASV4E,MAAAA,KAAK,EAAE,IAAIC,oBAAJ,CAAc,OAAK9E,YAAL,CAAkBC,IAAlB,gCAAd,CATG;AAUVmB,MAAAA,MAAM,EAAE,IAAI2D,qBAAJ,CAAe,OAAK/E,YAAL,CAAkBC,IAAlB,gCAAf,CAVE;AAWV+E,MAAAA,QAAQ,EAAE,IAAIC,uBAAJ,CAAiB,OAAKjF,YAAL,CAAkBC,IAAlB,gCAAjB;AAXA,K;;;;;;EADerC,G","sourcesContent":["import {\n Backoffice,\n Message,\n Route,\n Shop\n} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n AddToCartContext,\n} from \"./backoffice/context\";\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n} from \"./backoffice/services\";\nimport Events from \"./events\";\nimport {\n ShopAccount,\n ShopAuthorization,\n ShopCart,\n ShopCatalog,\n ShopConfig,\n ShopUtils,\n ShopWishlist,\n} from \"./shop/services\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nexport type AvailableContext = AddToCartContext\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 context?: Class<AvailableContext>;\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nexport type Class<T = any> = new (...args: any[]) => T;\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 contextClass?: Class<AvailableContext>;\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 public initializeContextClass(): AvailableContext {\n if (this.contextClass) {\n return new this.contextClass(this.callFunction.bind(this))\n }\n return {} as AvailableContext\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 this.contextClass = options.context\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 context: AvailableContext\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 context: this.initializeContextClass()\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\nexport {\n AddToCartContext\n}\n"],"file":"index.js"}