@evergis/api 3.0.81 → 3.0.84

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/dist/api.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- import { HubConnectionBuilder } from '@microsoft/signalr';
1
+ import { EventEmitter } from '@evergis/event-emitter';
2
+ import { HubConnectionBuilder, HubConnectionState } from '@microsoft/signalr';
2
3
  import ky, { HTTPError } from 'ky';
3
4
  export { HTTPError, TimeoutError } from 'ky';
4
- import { EventEmitter } from '@evergis/event-emitter';
5
5
  import { stringify } from 'query-string';
6
6
  import { customAlphabet } from 'nanoid';
7
7
  import { DomPainter } from '@evergis/sgis/es/painters/DomPainter/DomPainter';
@@ -174,6 +174,126 @@ function _get(target, property, receiver) {
174
174
  return _get(target, property, receiver || target);
175
175
  }
176
176
 
177
+ let HttpClient = /*#__PURE__*/function () {
178
+ function HttpClient(options) {
179
+ var _options$prefixUrl;
180
+
181
+ if (options === void 0) {
182
+ options = {};
183
+ }
184
+
185
+ _classCallCheck(this, HttpClient);
186
+
187
+ this.ky = ky.extend(options);
188
+ this.prefixUrl = ((_options$prefixUrl = options.prefixUrl) == null ? void 0 : _options$prefixUrl.toString()) || '';
189
+ }
190
+
191
+ _createClass(HttpClient, [{
192
+ key: "extend",
193
+ value: function extend(options) {
194
+ var _options$prefixUrl2;
195
+
196
+ this.ky = ky.extend(options);
197
+ this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
198
+ }
199
+ }, {
200
+ key: "get",
201
+ value: function get(url, params) {
202
+ return this.ky.get(this.stripSlashes(url), {
203
+ searchParams: qs(params)
204
+ });
205
+ }
206
+ }, {
207
+ key: "post",
208
+ value: function post(url, body, params) {
209
+ const options = kyOptions(params, body);
210
+ return this.ky.post(this.stripSlashes(url), options);
211
+ }
212
+ }, {
213
+ key: "put",
214
+ value: function put(url, body, params) {
215
+ const options = kyOptions(params, body);
216
+ return this.ky.put(this.stripSlashes(url), options);
217
+ }
218
+ }, {
219
+ key: "patch",
220
+ value: function patch(url, body, params) {
221
+ const options = kyOptions(params, body);
222
+ return this.ky.patch(this.stripSlashes(url), options);
223
+ }
224
+ }, {
225
+ key: "delete",
226
+ value: function _delete(url, body, params) {
227
+ const options = kyOptions(params, body);
228
+ return this.ky.delete(this.stripSlashes(url), options);
229
+ }
230
+ }, {
231
+ key: "createUrl",
232
+ value: function createUrl(url, params) {
233
+ const queryString = params ? "?" + qs(params) : '';
234
+ return this.prefixUrl + this.stripSlashes(url) + queryString;
235
+ }
236
+ }, {
237
+ key: "stripSlashes",
238
+ value: function stripSlashes(url) {
239
+ if (this.prefixUrl) {
240
+ return url.replace(/^\//g, '');
241
+ }
242
+
243
+ return url;
244
+ }
245
+ }]);
246
+
247
+ return HttpClient;
248
+ }();
249
+
250
+ function kyOptions(params, body) {
251
+ const options = {
252
+ searchParams: qs(params)
253
+ };
254
+
255
+ if (!isNotObject(body) || Array.isArray(body)) {
256
+ options.json = body;
257
+ } else {
258
+ options.body = body;
259
+ }
260
+
261
+ return options;
262
+ }
263
+
264
+ function isNotObject(value) {
265
+ return !(value !== void 0 && typeof value === 'object' && value !== null && value.constructor === Object);
266
+ }
267
+
268
+ function qs(params) {
269
+ if (params === void 0) {
270
+ params = {};
271
+ }
272
+
273
+ return stringify(params, {
274
+ arrayFormat: 'comma'
275
+ });
276
+ }
277
+
278
+ function toFormData(input) {
279
+ if (input instanceof FormData) {
280
+ return input;
281
+ }
282
+
283
+ return Object.keys(input).reduce((data, key) => {
284
+ data.append(key, input[key]);
285
+ return data;
286
+ }, new FormData());
287
+ }
288
+
289
+ var ApiEvent;
290
+
291
+ (function (ApiEvent) {
292
+ ApiEvent["ConnectionLost"] = "ConnectionLost";
293
+ ApiEvent["Unauthorized"] = "Unauthorized";
294
+ ApiEvent["SessionClosed"] = "SessionClosed";
295
+ })(ApiEvent || (ApiEvent = {}));
296
+
177
297
  /* eslint-disable */
178
298
 
179
299
  /* tslint:disable */
@@ -396,118 +516,6 @@ let Security = /*#__PURE__*/function (_SecurityService) {
396
516
  return Security;
397
517
  }(SecurityService);
398
518
 
399
- let HttpClient = /*#__PURE__*/function () {
400
- function HttpClient(options) {
401
- var _options$prefixUrl;
402
-
403
- if (options === void 0) {
404
- options = {};
405
- }
406
-
407
- _classCallCheck(this, HttpClient);
408
-
409
- this.ky = ky.extend(options);
410
- this.prefixUrl = ((_options$prefixUrl = options.prefixUrl) == null ? void 0 : _options$prefixUrl.toString()) || '';
411
- }
412
-
413
- _createClass(HttpClient, [{
414
- key: "extend",
415
- value: function extend(options) {
416
- var _options$prefixUrl2;
417
-
418
- this.ky = ky.extend(options);
419
- this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
420
- }
421
- }, {
422
- key: "get",
423
- value: function get(url, params) {
424
- return this.ky.get(this.stripSlashes(url), {
425
- searchParams: qs(params)
426
- });
427
- }
428
- }, {
429
- key: "post",
430
- value: function post(url, body, params) {
431
- const options = kyOptions(params, body);
432
- return this.ky.post(this.stripSlashes(url), options);
433
- }
434
- }, {
435
- key: "put",
436
- value: function put(url, body, params) {
437
- const options = kyOptions(params, body);
438
- return this.ky.put(this.stripSlashes(url), options);
439
- }
440
- }, {
441
- key: "patch",
442
- value: function patch(url, body, params) {
443
- const options = kyOptions(params, body);
444
- return this.ky.patch(this.stripSlashes(url), options);
445
- }
446
- }, {
447
- key: "delete",
448
- value: function _delete(url, body, params) {
449
- const options = kyOptions(params, body);
450
- return this.ky.delete(this.stripSlashes(url), options);
451
- }
452
- }, {
453
- key: "createUrl",
454
- value: function createUrl(url, params) {
455
- const queryString = params ? "?" + qs(params) : '';
456
- return this.prefixUrl + this.stripSlashes(url) + queryString;
457
- }
458
- }, {
459
- key: "stripSlashes",
460
- value: function stripSlashes(url) {
461
- if (this.prefixUrl) {
462
- return url.replace(/^\//g, '');
463
- }
464
-
465
- return url;
466
- }
467
- }]);
468
-
469
- return HttpClient;
470
- }();
471
-
472
- function kyOptions(params, body) {
473
- const options = {
474
- searchParams: qs(params)
475
- };
476
-
477
- if (!isNotObject(body) || Array.isArray(body)) {
478
- options.json = body;
479
- } else {
480
- options.body = body;
481
- }
482
-
483
- return options;
484
- }
485
-
486
- function isNotObject(value) {
487
- return !(value !== void 0 && typeof value === 'object' && value !== null && value.constructor === Object);
488
- }
489
-
490
- function qs(params) {
491
- if (params === void 0) {
492
- params = {};
493
- }
494
-
495
- return stringify(params, {
496
- arrayFormat: 'comma'
497
- });
498
- }
499
-
500
- function toFormData(input) {
501
- if (input instanceof FormData) {
502
- return input;
503
- }
504
-
505
- return Object.keys(input).reduce((data, key) => {
506
- data.append(key, input[key]);
507
- return data;
508
- }, new FormData());
509
- }
510
-
511
519
  /**
512
520
  * @title Spatial Processing Core API
513
521
  * @version v0.6.0
@@ -5761,14 +5769,6 @@ let Print = /*#__PURE__*/function (_PrintService) {
5761
5769
  return _createClass(Print);
5762
5770
  }(PrintService);
5763
5771
 
5764
- var ApiEvent;
5765
-
5766
- (function (ApiEvent) {
5767
- ApiEvent["ConnectionLost"] = "ConnectionLost";
5768
- ApiEvent["Unauthorized"] = "Unauthorized";
5769
- ApiEvent["SessionClosed"] = "SessionClosed";
5770
- })(ApiEvent || (ApiEvent = {}));
5771
-
5772
5772
  var UrlPath;
5773
5773
 
5774
5774
  (function (UrlPath) {
@@ -5865,7 +5865,6 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5865
5865
  let {
5866
5866
  authParams,
5867
5867
  connectWs,
5868
- connectSignalR,
5869
5868
  initScheduler,
5870
5869
  fetchSettings,
5871
5870
  fetchUser
@@ -5882,10 +5881,6 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5882
5881
  await this.connectWs();
5883
5882
  }
5884
5883
 
5885
- if (connectSignalR) {
5886
- await this.connectSignalR();
5887
- }
5888
-
5889
5884
  if (initScheduler) {
5890
5885
  await this.initScheduler();
5891
5886
  }
@@ -5936,7 +5931,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5936
5931
  }, {
5937
5932
  key: "connectSignalR",
5938
5933
  value: async function connectSignalR() {
5939
- if (this.account.isAuth && this.snappingHub) {
5934
+ if (this.account.isAuth && this.snappingHub && this.snappingHub.state !== HubConnectionState.Connected) {
5940
5935
  await this.snappingHub.start();
5941
5936
  }
5942
5937
  }