@one-commerce/sdk-core 1.7.0 → 1.11.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.
- package/lib/bundles/bundle.esm.js +943 -0
- package/lib/bundles/bundle.esm.js.map +1 -0
- package/lib/bundles/bundle.esm.min.js +2 -0
- package/lib/bundles/bundle.esm.min.js.map +1 -0
- package/lib/bundles/bundle.umd.js +954 -0
- package/lib/bundles/bundle.umd.js.map +1 -0
- package/lib/bundles/bundle.umd.min.js +2 -0
- package/lib/bundles/bundle.umd.min.js.map +1 -0
- package/lib/cjs/backofficeServices.js +180 -28
- package/lib/cjs/backofficeServices.js.map +1 -0
- package/lib/cjs/events.js +56 -22
- package/lib/cjs/events.js.map +1 -0
- package/lib/cjs/index.js +289 -121
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/shopServices.js +248 -54
- package/lib/cjs/shopServices.js.map +1 -0
- package/lib/cjs/utils.js +63 -28
- package/lib/cjs/utils.js.map +1 -0
- package/lib/esm/backofficeServices.js +59 -16
- package/lib/esm/backofficeServices.js.map +1 -0
- package/lib/esm/events.js +30 -22
- package/lib/esm/events.js.map +1 -0
- package/lib/esm/index.js +150 -108
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/shopServices.js +125 -67
- package/lib/esm/shopServices.js.map +1 -0
- package/lib/esm/utils.js +34 -25
- package/lib/esm/utils.js.map +1 -0
- package/lib/{cjs → types}/backofficeServices.d.ts +7 -0
- package/lib/types/backofficeServices.d.ts.map +1 -0
- package/lib/{cjs → types}/events.d.ts +1 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/iframe-channel.d.ts +19 -0
- package/lib/{esm → types}/index.d.ts +6 -2
- package/lib/types/index.d.ts.map +1 -0
- package/lib/{esm → types}/shopServices.d.ts +1 -0
- package/lib/types/shopServices.d.ts.map +1 -0
- package/lib/{esm → types}/utils.d.ts +1 -0
- package/lib/types/utils.d.ts.map +1 -0
- package/package.json +42 -16
- package/lib/cjs/index.d.ts +0 -74
- package/lib/cjs/shopServices.d.ts +0 -98
- package/lib/cjs/utils.d.ts +0 -8
- package/lib/esm/backofficeServices.d.ts +0 -21
- package/lib/esm/events.d.ts +0 -7
- package/lib/tsconfig.module.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/cjs/shopServices.js
CHANGED
|
@@ -1,73 +1,267 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ShopUtils = exports.ShopConfig = exports.ShopCatalog = exports.ShopCart = exports.ShopAccount = void 0;
|
|
9
|
+
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
15
|
+
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
|
|
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
|
+
|
|
20
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
|
+
|
|
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
|
+
|
|
24
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
25
|
+
|
|
26
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
+
|
|
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
|
+
|
|
30
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
|
+
|
|
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
|
+
|
|
34
|
+
var ShopCatalog = /*#__PURE__*/function (_BaseCallClass) {
|
|
35
|
+
_inherits(ShopCatalog, _BaseCallClass);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(ShopCatalog);
|
|
38
|
+
|
|
39
|
+
function ShopCatalog() {
|
|
40
|
+
var _this;
|
|
41
|
+
|
|
42
|
+
_classCallCheck(this, ShopCatalog);
|
|
43
|
+
|
|
44
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
|
+
args[_key] = arguments[_key];
|
|
9
46
|
}
|
|
10
|
-
|
|
11
|
-
|
|
47
|
+
|
|
48
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
49
|
+
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "serviceName", 'catalog');
|
|
51
|
+
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "categories", void 0);
|
|
53
|
+
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "selectedCategoryId", void 0);
|
|
55
|
+
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_createClass(ShopCatalog, [{
|
|
60
|
+
key: "fetchProduct",
|
|
61
|
+
value: function fetchProduct(productId) {
|
|
62
|
+
return this.call('fetchProduct', productId);
|
|
12
63
|
}
|
|
13
|
-
|
|
14
|
-
|
|
64
|
+
}, {
|
|
65
|
+
key: "getCategoryById",
|
|
66
|
+
value: function getCategoryById(categoryId) {
|
|
67
|
+
return this.call('getCategoryById', categoryId);
|
|
15
68
|
}
|
|
16
|
-
}
|
|
69
|
+
}]);
|
|
70
|
+
|
|
71
|
+
return ShopCatalog;
|
|
72
|
+
}(_utils.BaseCallClass);
|
|
73
|
+
|
|
17
74
|
exports.ShopCatalog = ShopCatalog;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
75
|
+
|
|
76
|
+
var ShopAccount = /*#__PURE__*/function (_BaseCallClass2) {
|
|
77
|
+
_inherits(ShopAccount, _BaseCallClass2);
|
|
78
|
+
|
|
79
|
+
var _super2 = _createSuper(ShopAccount);
|
|
80
|
+
|
|
81
|
+
function ShopAccount() {
|
|
82
|
+
var _this2;
|
|
83
|
+
|
|
84
|
+
_classCallCheck(this, ShopAccount);
|
|
85
|
+
|
|
86
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
87
|
+
args[_key2] = arguments[_key2];
|
|
22
88
|
}
|
|
23
|
-
|
|
24
|
-
|
|
89
|
+
|
|
90
|
+
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
91
|
+
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this2), "serviceName", 'account');
|
|
93
|
+
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this2), "client", void 0);
|
|
95
|
+
|
|
96
|
+
_defineProperty(_assertThisInitialized(_this2), "isAuthenticated", void 0);
|
|
97
|
+
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this2), "user", void 0);
|
|
99
|
+
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this2), "manager", void 0);
|
|
101
|
+
|
|
102
|
+
return _this2;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_createClass(ShopAccount, [{
|
|
106
|
+
key: "hasSegment",
|
|
107
|
+
value: function hasSegment(name) {
|
|
108
|
+
return this.call('hasSegment', name);
|
|
25
109
|
}
|
|
26
|
-
|
|
27
|
-
|
|
110
|
+
}, {
|
|
111
|
+
key: "logout",
|
|
112
|
+
value: function logout() {// NotImplementedYet
|
|
28
113
|
}
|
|
29
|
-
}
|
|
114
|
+
}]);
|
|
115
|
+
|
|
116
|
+
return ShopAccount;
|
|
117
|
+
}(_utils.BaseCallClass);
|
|
118
|
+
|
|
30
119
|
exports.ShopAccount = ShopAccount;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
120
|
+
|
|
121
|
+
var ShopCart = /*#__PURE__*/function (_BaseCallClass3) {
|
|
122
|
+
_inherits(ShopCart, _BaseCallClass3);
|
|
123
|
+
|
|
124
|
+
var _super3 = _createSuper(ShopCart);
|
|
125
|
+
|
|
126
|
+
function ShopCart() {
|
|
127
|
+
var _this3;
|
|
128
|
+
|
|
129
|
+
_classCallCheck(this, ShopCart);
|
|
130
|
+
|
|
131
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
132
|
+
args[_key3] = arguments[_key3];
|
|
35
133
|
}
|
|
36
|
-
|
|
37
|
-
|
|
134
|
+
|
|
135
|
+
_this3 = _super3.call.apply(_super3, [this].concat(args));
|
|
136
|
+
|
|
137
|
+
_defineProperty(_assertThisInitialized(_this3), "serviceName", 'cart');
|
|
138
|
+
|
|
139
|
+
_defineProperty(_assertThisInitialized(_this3), "carts", void 0);
|
|
140
|
+
|
|
141
|
+
_defineProperty(_assertThisInitialized(_this3), "currentCart", void 0);
|
|
142
|
+
|
|
143
|
+
_defineProperty(_assertThisInitialized(_this3), "totalCartPrice", void 0);
|
|
144
|
+
|
|
145
|
+
return _this3;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_createClass(ShopCart, [{
|
|
149
|
+
key: "addToCart",
|
|
150
|
+
value: function addToCart(productId, amount, where, cartId) {
|
|
151
|
+
return this.call('addToCart', productId, amount, where, cartId);
|
|
38
152
|
}
|
|
39
|
-
}
|
|
153
|
+
}]);
|
|
154
|
+
|
|
155
|
+
return ShopCart;
|
|
156
|
+
}(_utils.BaseCallClass);
|
|
157
|
+
|
|
40
158
|
exports.ShopCart = ShopCart;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
159
|
+
|
|
160
|
+
var ShopUtils = /*#__PURE__*/function (_BaseCallClass4) {
|
|
161
|
+
_inherits(ShopUtils, _BaseCallClass4);
|
|
162
|
+
|
|
163
|
+
var _super4 = _createSuper(ShopUtils);
|
|
164
|
+
|
|
165
|
+
function ShopUtils(call) {
|
|
166
|
+
var _this4;
|
|
167
|
+
|
|
168
|
+
_classCallCheck(this, ShopUtils);
|
|
169
|
+
|
|
170
|
+
_this4 = _super4.call(this, call);
|
|
171
|
+
|
|
172
|
+
_defineProperty(_assertThisInitialized(_this4), "serviceName", 'utils');
|
|
173
|
+
|
|
174
|
+
_defineProperty(_assertThisInitialized(_this4), "currency", void 0);
|
|
175
|
+
|
|
176
|
+
_defineProperty(_assertThisInitialized(_this4), "isAnonymousAndPurchaseDisabled", void 0);
|
|
177
|
+
|
|
178
|
+
_defineProperty(_assertThisInitialized(_this4), "isB2B", void 0);
|
|
179
|
+
|
|
180
|
+
_defineProperty(_assertThisInitialized(_this4), "isB2BAndPlatformIsNotOpened", void 0);
|
|
181
|
+
|
|
182
|
+
_defineProperty(_assertThisInitialized(_this4), "isIndexPage", void 0);
|
|
183
|
+
|
|
184
|
+
_defineProperty(_assertThisInitialized(_this4), "isPurchaseEnabledOrAuthenticated", void 0);
|
|
185
|
+
|
|
186
|
+
_defineProperty(_assertThisInitialized(_this4), "routes", void 0);
|
|
187
|
+
|
|
188
|
+
_this4.routes = {
|
|
189
|
+
getCategoryPath: _this4.getCategoryPath,
|
|
190
|
+
getManufacturerSearchUrl: _this4.getManufacturerSearchUrl,
|
|
191
|
+
getProductUrl: _this4.getProductUrl,
|
|
192
|
+
isExternalUrl: _this4.isExternalUrl
|
|
193
|
+
};
|
|
194
|
+
return _this4;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_createClass(ShopUtils, [{
|
|
198
|
+
key: "getCategoryPath",
|
|
199
|
+
value: function getCategoryPath(id) {
|
|
200
|
+
return this.call('getCategoryPath', id);
|
|
51
201
|
}
|
|
52
|
-
|
|
53
|
-
|
|
202
|
+
}, {
|
|
203
|
+
key: "getManufacturerSearchUrl",
|
|
204
|
+
value: function getManufacturerSearchUrl(manufacturer) {
|
|
205
|
+
return this.call('getManufacturerSearchUrl', manufacturer);
|
|
54
206
|
}
|
|
55
|
-
|
|
56
|
-
|
|
207
|
+
}, {
|
|
208
|
+
key: "getProductUrl",
|
|
209
|
+
value: function getProductUrl(product) {
|
|
210
|
+
return this.call('getProductUrl', product);
|
|
57
211
|
}
|
|
58
|
-
|
|
59
|
-
|
|
212
|
+
}, {
|
|
213
|
+
key: "isExternalUrl",
|
|
214
|
+
value: function isExternalUrl(url) {
|
|
215
|
+
return this.call('isExternalUrl', url);
|
|
60
216
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
217
|
+
}]);
|
|
218
|
+
|
|
219
|
+
return ShopUtils;
|
|
220
|
+
}(_utils.BaseCallClass);
|
|
221
|
+
|
|
65
222
|
exports.ShopUtils = ShopUtils;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
223
|
+
|
|
224
|
+
var ShopConfig = /*#__PURE__*/function (_BaseCallClass5) {
|
|
225
|
+
_inherits(ShopConfig, _BaseCallClass5);
|
|
226
|
+
|
|
227
|
+
var _super5 = _createSuper(ShopConfig);
|
|
228
|
+
|
|
229
|
+
function ShopConfig() {
|
|
230
|
+
var _this5;
|
|
231
|
+
|
|
232
|
+
_classCallCheck(this, ShopConfig);
|
|
233
|
+
|
|
234
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
235
|
+
args[_key4] = arguments[_key4];
|
|
70
236
|
}
|
|
71
|
-
|
|
237
|
+
|
|
238
|
+
_this5 = _super5.call.apply(_super5, [this].concat(args));
|
|
239
|
+
|
|
240
|
+
_defineProperty(_assertThisInitialized(_this5), "serviceName", 'config');
|
|
241
|
+
|
|
242
|
+
_defineProperty(_assertThisInitialized(_this5), "accessMode", void 0);
|
|
243
|
+
|
|
244
|
+
_defineProperty(_assertThisInitialized(_this5), "isB2CRegistrationEnabled", void 0);
|
|
245
|
+
|
|
246
|
+
_defineProperty(_assertThisInitialized(_this5), "isCatalogOpened", void 0);
|
|
247
|
+
|
|
248
|
+
_defineProperty(_assertThisInitialized(_this5), "isGrossSelected", void 0);
|
|
249
|
+
|
|
250
|
+
_defineProperty(_assertThisInitialized(_this5), "isPlatformClosed", void 0);
|
|
251
|
+
|
|
252
|
+
_defineProperty(_assertThisInitialized(_this5), "isPlatformOpened", void 0);
|
|
253
|
+
|
|
254
|
+
_defineProperty(_assertThisInitialized(_this5), "isPurchaseEnabled", void 0);
|
|
255
|
+
|
|
256
|
+
_defineProperty(_assertThisInitialized(_this5), "isRegistrationEnabled", void 0);
|
|
257
|
+
|
|
258
|
+
_defineProperty(_assertThisInitialized(_this5), "currency", void 0);
|
|
259
|
+
|
|
260
|
+
return _this5;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return _createClass(ShopConfig);
|
|
264
|
+
}(_utils.BaseCallClass);
|
|
265
|
+
|
|
72
266
|
exports.ShopConfig = ShopConfig;
|
|
73
|
-
//# sourceMappingURL=
|
|
267
|
+
//# sourceMappingURL=shopServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shopServices.ts"],"names":["ShopCatalog","productId","call","categoryId","BaseCallClass","ShopAccount","name","ShopCart","amount","where","cartId","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;;;;;;;;;;;;;;;WA0Bd,oBAAWC,IAAX,EAA2C;AACzC,aAAO,KAAKJ,IAAL,CAAU,YAAV,EAAwBI,IAAxB,CAAP;AACD;;;WAWD,kBAAe,CACb;AACD;;;;EA1C8BF,oB;;;;IA6CpBG,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,S;;;;;AASX,qBAAYT,IAAZ,EAA+E;AAAA;;AAAA;;AAC7E,gCAAMA,IAAN;;AAD6E,mEARjE,OAQiE;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAE7E,WAAKU,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,KAAKf,IAAL,CAAU,iBAAV,EAA6Be,EAA7B,CAAP;AACD;;;WAED,kCAAyBC,YAAzB,EAAgE;AAC9D,aAAO,KAAKhB,IAAL,CAAU,0BAAV,EAAsCgB,YAAtC,CAAP;AACD;;;WAED,uBAAcC,OAAd,EAAoD;AAClD,aAAO,KAAKjB,IAAL,CAAU,eAAV,EAA2BiB,OAA3B,CAAP;AACD;;;WAED,uBAAcC,GAAd,EAA6C;AAC3C,aAAO,KAAKlB,IAAL,CAAU,eAAV,EAA2BkB,GAA3B,CAAP;AACD;;;;EAjC4BhB,oB;;;;IAuDlBiB,U;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;;;;;;;;;;;;;EADgBjB,oB","sourcesContent":["import {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 name: string;\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 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"}
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,34 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BaseCallClass = void 0;
|
|
7
|
+
exports.generateCallId = generateCallId;
|
|
8
|
+
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
12
|
+
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
var dec2hex = function dec2hex(dec) {
|
|
18
|
+
return dec.toString(16).padStart(2, "0");
|
|
19
|
+
}; // generateId :: Integer -> String
|
|
20
|
+
|
|
21
|
+
|
|
8
22
|
function generateCallId() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
var arr = new Uint8Array((10 || 40) / 2);
|
|
24
|
+
window.crypto.getRandomValues(arr);
|
|
25
|
+
return Array.from(arr, dec2hex).join('');
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
|
|
28
|
+
var BaseCallClass = /*#__PURE__*/function () {
|
|
29
|
+
function BaseCallClass(call) {
|
|
30
|
+
var _this = this;
|
|
31
|
+
|
|
32
|
+
_classCallCheck(this, BaseCallClass);
|
|
33
|
+
|
|
34
|
+
_defineProperty(this, "serviceName", '');
|
|
35
|
+
|
|
36
|
+
_defineProperty(this, "call", void 0);
|
|
37
|
+
|
|
38
|
+
this.call = function (fun) {
|
|
39
|
+
for (var _len = arguments.length, arg = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
40
|
+
arg[_key - 1] = arguments[_key];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return call.apply(void 0, [_this.serviceName, fun].concat(arg));
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_createClass(BaseCallClass, [{
|
|
48
|
+
key: "update",
|
|
49
|
+
value: function update(payload) {
|
|
50
|
+
var attributes = payload[this.serviceName];
|
|
51
|
+
|
|
52
|
+
if (attributes) {
|
|
53
|
+
BaseCallClass.update(this, attributes);
|
|
54
|
+
}
|
|
20
55
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
56
|
+
}], [{
|
|
57
|
+
key: "update",
|
|
58
|
+
value: function update(target, payload) {
|
|
59
|
+
Object.keys(payload).forEach(function (key) {
|
|
60
|
+
target[key] = payload[key];
|
|
61
|
+
});
|
|
25
62
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
63
|
+
}]);
|
|
64
|
+
|
|
65
|
+
return BaseCallClass;
|
|
66
|
+
}();
|
|
67
|
+
|
|
33
68
|
exports.BaseCallClass = BaseCallClass;
|
|
34
|
-
//# sourceMappingURL=
|
|
69
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"names":["dec2hex","dec","toString","padStart","generateCallId","arr","Uint8Array","window","crypto","getRandomValues","Array","from","join","BaseCallClass","call","fun","arg","serviceName","payload","attributes","update","target","Object","keys","forEach","key"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAI,SAAXA,OAAW,CAACC,GAAD,EAAyB;AACxC,SAAOA,GAAG,CAACC,QAAJ,CAAa,EAAb,EAAiBC,QAAjB,CAA0B,CAA1B,EAA6B,GAA7B,CAAP;AACD,CAFD,C,CAIA;;;AACO,SAASC,cAAT,GAA2B;AAChC,MAAMC,GAAG,GAAG,IAAIC,UAAJ,CAAe,CAAC,MAAM,EAAP,IAAa,CAA5B,CAAZ;AACAC,EAAAA,MAAM,CAACC,MAAP,CAAcC,eAAd,CAA8BJ,GAA9B;AACA,SAAOK,KAAK,CAACC,IAAN,CAAWN,GAAX,EAAgBL,OAAhB,EAAyBY,IAAzB,CAA8B,EAA9B,CAAP;AACD;;IAEYC,a;AAGX,yBAAYC,IAAZ,EAA+E;AAAA;;AAAA;;AAAA,yCAFjE,EAEiE;;AAAA;;AAC7E,SAAKA,IAAL,GAAY,UAACC,GAAD,EAA8B;AAAA,wCAAbC,GAAa;AAAbA,QAAAA,GAAa;AAAA;;AACxC,aAAOF,IAAI,MAAJ,UAAK,KAAI,CAACG,WAAV,EAAuBF,GAAvB,SAA+BC,GAA/B,EAAP;AACD,KAFD;AAGD;;;;WAMD,gBAAOE,OAAP,EAAqB;AACnB,UAAMC,UAAe,GAAGD,OAAO,CAAC,KAAKD,WAAN,CAA/B;;AACA,UAAIE,UAAJ,EAAgB;AACdN,QAAAA,aAAa,CAACO,MAAd,CAAqB,IAArB,EAA2BD,UAA3B;AACD;AACF;;;WAVD,gBAAcE,MAAd,EAA2CH,OAA3C,EAAyE;AACvEI,MAAAA,MAAM,CAACC,IAAP,CAAYL,OAAZ,EAAqBM,OAArB,CAA6B,UAACC,GAAD,EAAiB;AAC5CJ,QAAAA,MAAM,CAACI,GAAD,CAAN,GAAcP,OAAO,CAACO,GAAD,CAArB;AACD,OAFD;AAGD","sourcesContent":["const dec2hex = (dec: number): string => {\n return dec.toString(16).padStart(2, \"0\")\n}\n\n// generateId :: Integer -> String\nexport function generateCallId () {\n const arr = new Uint8Array((10 || 40) / 2)\n window.crypto.getRandomValues(arr)\n return Array.from(arr, dec2hex).join('')\n}\n\nexport class BaseCallClass {\n serviceName = ''\n call: (fun: string, ...arg: any[]) => Promise<any>;\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n this.call = (fun: string, ...arg: any) => {\n return call(this.serviceName, fun, ...arg)\n }\n }\n static update(target: Record<string, any>, payload: Record<string, any>) {\n Object.keys(payload).forEach((key: string) => {\n target[key] = payload[key]\n })\n }\n update(payload: any) {\n const attributes: any = payload[this.serviceName]\n if (attributes) {\n BaseCallClass.update(this, attributes)\n }\n }\n}\n"],"file":"utils.js"}
|
|
@@ -1,25 +1,68 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
1
3
|
import { BaseCallClass } from "./utils";
|
|
2
4
|
export class BackofficeCatalog extends BaseCallClass {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
super(...args);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "serviceName", 'catalog');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
fetchCategories() {
|
|
12
|
+
return this.call('fetchCategories');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
fetchProduct(id) {
|
|
16
|
+
return this.call('fetchProduct', id);
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
}
|
|
11
20
|
export class BackofficeUser extends BaseCallClass {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
constructor(...args) {
|
|
22
|
+
super(...args);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "serviceName", 'user');
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "email", void 0);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "id", void 0);
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "name", void 0);
|
|
31
|
+
|
|
32
|
+
_defineProperty(this, "authorities", void 0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
export class BackofficeTenant extends BaseCallClass {
|
|
37
|
+
constructor(...args) {
|
|
38
|
+
super(...args);
|
|
39
|
+
|
|
40
|
+
_defineProperty(this, "serviceName", 'tenant');
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "tenantKey", void 0);
|
|
43
|
+
|
|
44
|
+
_defineProperty(this, "language", void 0);
|
|
45
|
+
|
|
46
|
+
_defineProperty(this, "currency", void 0);
|
|
47
|
+
}
|
|
48
|
+
|
|
17
49
|
}
|
|
18
50
|
export class BackofficeOrderpath extends BaseCallClass {
|
|
19
|
-
|
|
51
|
+
constructor(...args) {
|
|
52
|
+
super(...args);
|
|
53
|
+
|
|
54
|
+
_defineProperty(this, "serviceName", 'orderpath');
|
|
55
|
+
}
|
|
56
|
+
|
|
20
57
|
}
|
|
21
58
|
export class BackofficeLayout extends BaseCallClass {
|
|
22
|
-
|
|
23
|
-
|
|
59
|
+
constructor(...args) {
|
|
60
|
+
super(...args);
|
|
61
|
+
|
|
62
|
+
_defineProperty(this, "serviceName", 'layout');
|
|
63
|
+
|
|
64
|
+
_defineProperty(this, "isAsideOpened", void 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
24
67
|
}
|
|
25
|
-
//# sourceMappingURL=
|
|
68
|
+
//# sourceMappingURL=backofficeServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/backofficeServices.ts"],"names":["BaseCallClass","BackofficeCatalog","fetchCategories","call","fetchProduct","id","BackofficeUser","BackofficeTenant","BackofficeOrderpath","BackofficeLayout"],"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","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"],"file":"backofficeServices.js"}
|
package/lib/esm/events.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
1
3
|
class Events {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
constructor() {
|
|
5
|
+
_defineProperty(this, "_callbacks", void 0);
|
|
6
|
+
|
|
7
|
+
this._callbacks = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
on(key, callback) {
|
|
11
|
+
// create an empty array for the event key
|
|
12
|
+
if (this._callbacks[key] === undefined) {
|
|
13
|
+
this._callbacks[key] = [];
|
|
14
|
+
} // save the callback in the array for the event key
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
this._callbacks[key].push(callback);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
emit(key, ...params) {
|
|
21
|
+
// if the key exists
|
|
22
|
+
if (this._callbacks[key] !== undefined) {
|
|
23
|
+
// iterate through the callbacks for the event key
|
|
24
|
+
for (let i = 0; i < this._callbacks[key].length; i++) {
|
|
25
|
+
// trigger the callbacks with all provided params
|
|
26
|
+
this._callbacks[key][i](...params);
|
|
27
|
+
}
|
|
23
28
|
}
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
}
|
|
32
|
+
|
|
25
33
|
export default Events;
|
|
26
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/events.ts"],"names":["Events","constructor","_callbacks","on","key","callback","undefined","push","emit","params","i","length"],"mappings":";;AAAA,MAAMA,MAAN,CAAa;AAEXC,EAAAA,WAAW,GAAI;AAAA;;AACb,SAAKC,UAAL,GAAkB,EAAlB;AACD;;AAEDC,EAAAA,EAAE,CAAIC,GAAJ,EAAiBC,QAAjB,EAA6C;AAC7C;AACA,QAAI,KAAKH,UAAL,CAAgBE,GAAhB,MAAyBE,SAA7B,EAAwC;AAAE,WAAKJ,UAAL,CAAgBE,GAAhB,IAAuB,EAAvB;AAA2B,KAFxB,CAG7C;;;AACA,SAAKF,UAAL,CAAgBE,GAAhB,EAAqBG,IAArB,CAA0BF,QAA1B;AACD;;AAEDG,EAAAA,IAAI,CAACJ,GAAD,EAAc,GAAGK,MAAjB,EAAqC;AACvC;AACA,QAAI,KAAKP,UAAL,CAAgBE,GAAhB,MAAyBE,SAA7B,EAAwC;AACtC;AACA,WAAK,IAAII,CAAC,GAAC,CAAX,EAAcA,CAAC,GAAC,KAAKR,UAAL,CAAgBE,GAAhB,EAAqBO,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;AAChD;AACA,aAAKR,UAAL,CAAgBE,GAAhB,EAAqBM,CAArB,EAAwB,GAAGD,MAA3B;AACD;AACF;AACF;;AAtBU;;AAyBb,eAAeT,MAAf","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"}
|