@crystaldesign/basket-handler 25.5.0-beta.2 → 25.5.0-beta.21

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.
@@ -37,6 +37,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
37
37
  var BASKET_SAVE_ERROR = /*#__PURE__*/function (BASKET_SAVE_ERROR) {
38
38
  BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED"] = "ERROR_NO_BASKET_SAVED";
39
39
  BASKET_SAVE_ERROR["ERROR_BASKET_AFTER_SAVE"] = "ERROR_BASKET_AFTER_SAVE";
40
+ BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED_ENTITY_EXISTS"] = "ERROR_NO_BASKET_SAVED_ENTITY_EXISTS";
40
41
  return BASKET_SAVE_ERROR;
41
42
  }({});
42
43
  var BasketHandler = /*#__PURE__*/function () {
@@ -62,7 +63,7 @@ var BasketHandler = /*#__PURE__*/function () {
62
63
  key: "saveBasket",
63
64
  value: function () {
64
65
  var _saveBasket = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref) {
65
- var jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _DivaUtils$Configurat, _api2Result, authHeader, _this$LOG2, resultBasket, api2Result, _this$LOG3;
66
+ var jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _DivaUtils$Configurat, _api2Result, authHeader, resultBasket, api2Result, _e$response, _e$response2, _this$LOG4, _this$LOG2, _this$LOG3;
66
67
  return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
67
68
  while (1) switch (_context.prev = _context.next) {
68
69
  case 0:
@@ -94,22 +95,15 @@ var BasketHandler = /*#__PURE__*/function () {
94
95
  });
95
96
  case 10:
96
97
  response = _context.sent;
97
- if (!(response.status !== 201)) {
98
- _context.next = 14;
99
- break;
100
- }
101
- (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed.');
102
- return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
103
- case 14:
104
- _context.next = 16;
98
+ _context.next = 13;
105
99
  return response.data;
106
- case 16:
100
+ case 13:
107
101
  resultBasket = _context.sent;
108
102
  if (!saveToApi2) {
109
- _context.next = 21;
103
+ _context.next = 18;
110
104
  break;
111
105
  }
112
- _context.next = 20;
106
+ _context.next = 17;
113
107
  return this.api2SaveBasket({
114
108
  basket: basket,
115
109
  sessionGuid: sessionGuid,
@@ -118,20 +112,34 @@ var BasketHandler = /*#__PURE__*/function () {
118
112
  saveToApi2: saveToApi2,
119
113
  _id: resultBasket._id
120
114
  });
121
- case 20:
115
+ case 17:
122
116
  api2Result = _context.sent;
123
- case 21:
117
+ case 18:
124
118
  return _context.abrupt("return", (_api2Result = api2Result) !== null && _api2Result !== void 0 ? _api2Result : resultBasket);
125
- case 24:
126
- _context.prev = 24;
119
+ case 21:
120
+ _context.prev = 21;
127
121
  _context.t0 = _context["catch"](6);
128
- (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
129
- return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
122
+ if (!(((_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.status) === 409)) {
123
+ _context.next = 28;
124
+ break;
125
+ }
126
+ (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed - Entity already exists.');
127
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED_ENTITY_EXISTS);
130
128
  case 28:
129
+ if (!(((_e$response2 = _context.t0.response) === null || _e$response2 === void 0 ? void 0 : _e$response2.status) !== 201)) {
130
+ _context.next = 31;
131
+ break;
132
+ }
133
+ (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket failed.');
134
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
135
+ case 31:
136
+ (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
137
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
138
+ case 33:
131
139
  case "end":
132
140
  return _context.stop();
133
141
  }
134
- }, _callee, this, [[6, 24]]);
142
+ }, _callee, this, [[6, 21]]);
135
143
  }));
136
144
  function saveBasket(_x) {
137
145
  return _saveBasket.apply(this, arguments);
@@ -142,7 +150,7 @@ var BasketHandler = /*#__PURE__*/function () {
142
150
  key: "api2SaveBasket",
143
151
  value: function () {
144
152
  var _api2SaveBasket = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref2) {
145
- var basket, sessionGuid, awaitPDF, _id, _this$LOG4, _this$LOG5, fullUrl, response, _DivaUtils$Configurat2, _response$Result, _this$LOG6, _this$LOG7;
153
+ var basket, sessionGuid, awaitPDF, _id, _this$LOG5, _this$LOG6, fullUrl, response, _DivaUtils$Configurat2, _response$Result, _this$LOG7, _this$LOG8;
146
154
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
147
155
  while (1) switch (_context2.prev = _context2.next) {
148
156
  case 0:
@@ -151,14 +159,14 @@ var BasketHandler = /*#__PURE__*/function () {
151
159
  _context2.next = 4;
152
160
  break;
153
161
  }
154
- (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
162
+ (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
155
163
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
156
164
  case 4:
157
165
  if (sessionGuid) {
158
166
  _context2.next = 7;
159
167
  break;
160
168
  }
161
- (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Cant create api2 Basket without sessionguid');
169
+ (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Cant create api2 Basket without sessionguid');
162
170
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
163
171
  case 7:
164
172
  fullUrl = this.api2Url + '?function=SetJsonBasketData3' + '&callHeadlessBrowserAsync=' + (!awaitPDF ? '1' : '0');
@@ -185,7 +193,7 @@ var BasketHandler = /*#__PURE__*/function () {
185
193
  _context2.next = 15;
186
194
  break;
187
195
  }
188
- (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
196
+ (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
189
197
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
190
198
  case 15:
191
199
  _context2.next = 21;
@@ -193,7 +201,7 @@ var BasketHandler = /*#__PURE__*/function () {
193
201
  case 17:
194
202
  _context2.prev = 17;
195
203
  _context2.t0 = _context2["catch"](8);
196
- (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
204
+ (_this$LOG8 = this.LOG) === null || _this$LOG8 === void 0 || _this$LOG8.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
197
205
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
198
206
  case 21:
199
207
  return _context2.abrupt("return", undefined);
@@ -23,6 +23,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
23
23
  var BASKET_SAVE_ERROR = /*#__PURE__*/function (BASKET_SAVE_ERROR) {
24
24
  BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED"] = "ERROR_NO_BASKET_SAVED";
25
25
  BASKET_SAVE_ERROR["ERROR_BASKET_AFTER_SAVE"] = "ERROR_BASKET_AFTER_SAVE";
26
+ BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED_ENTITY_EXISTS"] = "ERROR_NO_BASKET_SAVED_ENTITY_EXISTS";
26
27
  return BASKET_SAVE_ERROR;
27
28
  }({});
28
29
  var BasketHandler = /*#__PURE__*/function () {
@@ -48,7 +49,7 @@ var BasketHandler = /*#__PURE__*/function () {
48
49
  key: "saveBasket",
49
50
  value: function () {
50
51
  var _saveBasket = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
51
- var jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _DivaUtils$Configurat, _api2Result, authHeader, _this$LOG2, resultBasket, api2Result, _this$LOG3;
52
+ var jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _DivaUtils$Configurat, _api2Result, authHeader, resultBasket, api2Result, _e$response, _e$response2, _this$LOG4, _this$LOG2, _this$LOG3;
52
53
  return _regeneratorRuntime.wrap(function _callee$(_context) {
53
54
  while (1) switch (_context.prev = _context.next) {
54
55
  case 0:
@@ -80,22 +81,15 @@ var BasketHandler = /*#__PURE__*/function () {
80
81
  });
81
82
  case 10:
82
83
  response = _context.sent;
83
- if (!(response.status !== 201)) {
84
- _context.next = 14;
85
- break;
86
- }
87
- (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed.');
88
- return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
89
- case 14:
90
- _context.next = 16;
84
+ _context.next = 13;
91
85
  return response.data;
92
- case 16:
86
+ case 13:
93
87
  resultBasket = _context.sent;
94
88
  if (!saveToApi2) {
95
- _context.next = 21;
89
+ _context.next = 18;
96
90
  break;
97
91
  }
98
- _context.next = 20;
92
+ _context.next = 17;
99
93
  return this.api2SaveBasket({
100
94
  basket: basket,
101
95
  sessionGuid: sessionGuid,
@@ -104,20 +98,34 @@ var BasketHandler = /*#__PURE__*/function () {
104
98
  saveToApi2: saveToApi2,
105
99
  _id: resultBasket._id
106
100
  });
107
- case 20:
101
+ case 17:
108
102
  api2Result = _context.sent;
109
- case 21:
103
+ case 18:
110
104
  return _context.abrupt("return", (_api2Result = api2Result) !== null && _api2Result !== void 0 ? _api2Result : resultBasket);
111
- case 24:
112
- _context.prev = 24;
105
+ case 21:
106
+ _context.prev = 21;
113
107
  _context.t0 = _context["catch"](6);
114
- (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
115
- return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
108
+ if (!(((_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.status) === 409)) {
109
+ _context.next = 28;
110
+ break;
111
+ }
112
+ (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed - Entity already exists.');
113
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED_ENTITY_EXISTS);
116
114
  case 28:
115
+ if (!(((_e$response2 = _context.t0.response) === null || _e$response2 === void 0 ? void 0 : _e$response2.status) !== 201)) {
116
+ _context.next = 31;
117
+ break;
118
+ }
119
+ (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket failed.');
120
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
121
+ case 31:
122
+ (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
123
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
124
+ case 33:
117
125
  case "end":
118
126
  return _context.stop();
119
127
  }
120
- }, _callee, this, [[6, 24]]);
128
+ }, _callee, this, [[6, 21]]);
121
129
  }));
122
130
  function saveBasket(_x) {
123
131
  return _saveBasket.apply(this, arguments);
@@ -128,7 +136,7 @@ var BasketHandler = /*#__PURE__*/function () {
128
136
  key: "api2SaveBasket",
129
137
  value: function () {
130
138
  var _api2SaveBasket = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
131
- var basket, sessionGuid, awaitPDF, _id, _this$LOG4, _this$LOG5, fullUrl, response, _DivaUtils$Configurat2, _response$Result, _this$LOG6, _this$LOG7;
139
+ var basket, sessionGuid, awaitPDF, _id, _this$LOG5, _this$LOG6, fullUrl, response, _DivaUtils$Configurat2, _response$Result, _this$LOG7, _this$LOG8;
132
140
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
133
141
  while (1) switch (_context2.prev = _context2.next) {
134
142
  case 0:
@@ -137,14 +145,14 @@ var BasketHandler = /*#__PURE__*/function () {
137
145
  _context2.next = 4;
138
146
  break;
139
147
  }
140
- (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
148
+ (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
141
149
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
142
150
  case 4:
143
151
  if (sessionGuid) {
144
152
  _context2.next = 7;
145
153
  break;
146
154
  }
147
- (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Cant create api2 Basket without sessionguid');
155
+ (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Cant create api2 Basket without sessionguid');
148
156
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
149
157
  case 7:
150
158
  fullUrl = this.api2Url + '?function=SetJsonBasketData3' + '&callHeadlessBrowserAsync=' + (!awaitPDF ? '1' : '0');
@@ -171,7 +179,7 @@ var BasketHandler = /*#__PURE__*/function () {
171
179
  _context2.next = 15;
172
180
  break;
173
181
  }
174
- (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
182
+ (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
175
183
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
176
184
  case 15:
177
185
  _context2.next = 21;
@@ -179,7 +187,7 @@ var BasketHandler = /*#__PURE__*/function () {
179
187
  case 17:
180
188
  _context2.prev = 17;
181
189
  _context2.t0 = _context2["catch"](8);
182
- (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
190
+ (_this$LOG8 = this.LOG) === null || _this$LOG8 === void 0 || _this$LOG8.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
183
191
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
184
192
  case 21:
185
193
  return _context2.abrupt("return", undefined);
@@ -3,7 +3,8 @@
3
3
  import { SaveBasketProps, SaveBasketProps2 } from './types';
4
4
  export declare enum BASKET_SAVE_ERROR {
5
5
  ERROR_NO_BASKET_SAVED = "ERROR_NO_BASKET_SAVED",
6
- ERROR_BASKET_AFTER_SAVE = "ERROR_BASKET_AFTER_SAVE"
6
+ ERROR_BASKET_AFTER_SAVE = "ERROR_BASKET_AFTER_SAVE",
7
+ ERROR_NO_BASKET_SAVED_ENTITY_EXISTS = "ERROR_NO_BASKET_SAVED_ENTITY_EXISTS"
7
8
  }
8
9
  export default class BasketHandler {
9
10
  private LOG;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI5D,oBAAY,iBAAiB;IAC3B,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;CACpD;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;IAI9B,OAAO,CAAC,GAAG;IAHb,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;gBAEf,GAAG,EAAE,GAAG,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;IAMjB,IAAI,aAAa,WAEhB;IAED,IAAI,OAAO,WAEV;IAEK,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,eAAe;IAwCtF,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,gBAAgB;CAsC9E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI5D,oBAAY,iBAAiB;IAC3B,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,mCAAmC,wCAAwC;CAC5E;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;IAI9B,OAAO,CAAC,GAAG;IAHb,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;gBAEf,GAAG,EAAE,GAAG,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;IAMjB,IAAI,aAAa,WAEhB;IAED,IAAI,OAAO,WAEV;IAEK,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,eAAe;IA2CtF,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,gBAAgB;CAsC9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/basket-handler",
3
- "version": "25.5.0-beta.2",
3
+ "version": "25.5.0-beta.21",
4
4
  "peerDependencies": {
5
5
  "@crystaldesign/basket-model": "*"
6
6
  },
@@ -12,5 +12,5 @@
12
12
  "axios": "^1.7.7",
13
13
  "md5.js": "^1.3.5"
14
14
  },
15
- "gitHead": "06df2926f45c8f3d5095080e65ef98f5e4acf883"
15
+ "gitHead": "c3902f86973020505dd852a92100aabe1af52e47"
16
16
  }