@evergis/api 3.0.81 → 3.0.82

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.d.ts CHANGED
@@ -1,10 +1,10 @@
1
+ import { EventEmitter } from '@evergis/event-emitter';
1
2
  import { HubConnection } from '@microsoft/signalr';
2
3
  import { Options as KyOptions } from 'ky';
3
- import { EventEmitter } from '@evergis/event-emitter';
4
- import { Account, External, ClientSettings, PortalSettings, FileUpload, General, Geocode, Import, Layers, Names, Namespace, Notification, Projects, ResourceCatalog, Resources, Scheduler, Security, Styles, Tables, Tools, AccountPreview, BulkOperations, IceRouter, Statistic, Feedback } from './services';
5
- import { Print } from './services/Print';
6
- import { HttpClient } from './__generated__/HttpClient';
7
4
  import { LoginDc } from './__generated__/data-contracts';
5
+ import { HttpClient } from './__generated__/HttpClient';
6
+ import { Account, AccountPreview, BulkOperations, ClientSettings, External, Feedback, FileUpload, General, Geocode, IceRouter, Import, Layers, Names, Namespace, Notification, PortalSettings, Projects, ResourceCatalog, Resources, Scheduler, Security, Statistic, Styles, Tables, Tools } from './services';
7
+ import { Print } from './services/Print';
8
8
  export declare type ApiParams = {
9
9
  url: string;
10
10
  wsUrl?: string;
@@ -53,7 +53,7 @@ export declare class Api extends EventEmitter {
53
53
  readonly feedback: Feedback;
54
54
  readonly snappingHub: HubConnection | null;
55
55
  constructor({ url, wsUrl, snappingHubUrl, http, urlPath, httpOptions }: ApiParams);
56
- init({ authParams, connectWs, connectSignalR, initScheduler, fetchSettings, fetchUser, }: {
56
+ init({ authParams, connectWs, initScheduler, fetchSettings, fetchUser, }: {
57
57
  authParams?: LoginDc;
58
58
  connectWs?: boolean;
59
59
  connectSignalR?: boolean;
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
+ var eventEmitter = require('@evergis/event-emitter');
7
8
  var signalr = require('@microsoft/signalr');
8
9
  var ky = require('ky');
9
10
  var ky__default = _interopDefault(ky);
10
- var eventEmitter = require('@evergis/event-emitter');
11
11
  var queryString = require('query-string');
12
12
  var nanoid = require('nanoid');
13
13
  var DomPainter = require('@evergis/sgis/es/painters/DomPainter/DomPainter');
@@ -180,6 +180,124 @@ function _get(target, property, receiver) {
180
180
  return _get(target, property, receiver || target);
181
181
  }
182
182
 
183
+ let HttpClient = /*#__PURE__*/function () {
184
+ function HttpClient(options) {
185
+ var _options$prefixUrl;
186
+
187
+ if (options === void 0) {
188
+ options = {};
189
+ }
190
+
191
+ _classCallCheck(this, HttpClient);
192
+
193
+ this.ky = ky__default.extend(options);
194
+ this.prefixUrl = ((_options$prefixUrl = options.prefixUrl) == null ? void 0 : _options$prefixUrl.toString()) || '';
195
+ }
196
+
197
+ _createClass(HttpClient, [{
198
+ key: "extend",
199
+ value: function extend(options) {
200
+ var _options$prefixUrl2;
201
+
202
+ this.ky = ky__default.extend(options);
203
+ this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
204
+ }
205
+ }, {
206
+ key: "get",
207
+ value: function get(url, params) {
208
+ return this.ky.get(this.stripSlashes(url), {
209
+ searchParams: qs(params)
210
+ });
211
+ }
212
+ }, {
213
+ key: "post",
214
+ value: function post(url, body, params) {
215
+ const options = kyOptions(params, body);
216
+ return this.ky.post(this.stripSlashes(url), options);
217
+ }
218
+ }, {
219
+ key: "put",
220
+ value: function put(url, body, params) {
221
+ const options = kyOptions(params, body);
222
+ return this.ky.put(this.stripSlashes(url), options);
223
+ }
224
+ }, {
225
+ key: "patch",
226
+ value: function patch(url, body, params) {
227
+ const options = kyOptions(params, body);
228
+ return this.ky.patch(this.stripSlashes(url), options);
229
+ }
230
+ }, {
231
+ key: "delete",
232
+ value: function _delete(url, body, params) {
233
+ const options = kyOptions(params, body);
234
+ return this.ky.delete(this.stripSlashes(url), options);
235
+ }
236
+ }, {
237
+ key: "createUrl",
238
+ value: function createUrl(url, params) {
239
+ const queryString = params ? "?" + qs(params) : '';
240
+ return this.prefixUrl + this.stripSlashes(url) + queryString;
241
+ }
242
+ }, {
243
+ key: "stripSlashes",
244
+ value: function stripSlashes(url) {
245
+ if (this.prefixUrl) {
246
+ return url.replace(/^\//g, '');
247
+ }
248
+
249
+ return url;
250
+ }
251
+ }]);
252
+
253
+ return HttpClient;
254
+ }();
255
+
256
+ function kyOptions(params, body) {
257
+ const options = {
258
+ searchParams: qs(params)
259
+ };
260
+
261
+ if (!isNotObject(body) || Array.isArray(body)) {
262
+ options.json = body;
263
+ } else {
264
+ options.body = body;
265
+ }
266
+
267
+ return options;
268
+ }
269
+
270
+ function isNotObject(value) {
271
+ return !(value !== void 0 && typeof value === 'object' && value !== null && value.constructor === Object);
272
+ }
273
+
274
+ function qs(params) {
275
+ if (params === void 0) {
276
+ params = {};
277
+ }
278
+
279
+ return queryString.stringify(params, {
280
+ arrayFormat: 'comma'
281
+ });
282
+ }
283
+
284
+ function toFormData(input) {
285
+ if (input instanceof FormData) {
286
+ return input;
287
+ }
288
+
289
+ return Object.keys(input).reduce((data, key) => {
290
+ data.append(key, input[key]);
291
+ return data;
292
+ }, new FormData());
293
+ }
294
+
295
+ (function (ApiEvent) {
296
+ ApiEvent["ConnectionLost"] = "ConnectionLost";
297
+ ApiEvent["Unauthorized"] = "Unauthorized";
298
+ ApiEvent["SessionClosed"] = "SessionClosed";
299
+ })(exports.ApiEvent || (exports.ApiEvent = {}));
300
+
183
301
  /* eslint-disable */
184
302
 
185
303
  /* tslint:disable */
@@ -402,118 +520,6 @@ let Security = /*#__PURE__*/function (_SecurityService) {
402
520
  return Security;
403
521
  }(SecurityService);
404
522
 
405
- let HttpClient = /*#__PURE__*/function () {
406
- function HttpClient(options) {
407
- var _options$prefixUrl;
408
-
409
- if (options === void 0) {
410
- options = {};
411
- }
412
-
413
- _classCallCheck(this, HttpClient);
414
-
415
- this.ky = ky__default.extend(options);
416
- this.prefixUrl = ((_options$prefixUrl = options.prefixUrl) == null ? void 0 : _options$prefixUrl.toString()) || '';
417
- }
418
-
419
- _createClass(HttpClient, [{
420
- key: "extend",
421
- value: function extend(options) {
422
- var _options$prefixUrl2;
423
-
424
- this.ky = ky__default.extend(options);
425
- this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
426
- }
427
- }, {
428
- key: "get",
429
- value: function get(url, params) {
430
- return this.ky.get(this.stripSlashes(url), {
431
- searchParams: qs(params)
432
- });
433
- }
434
- }, {
435
- key: "post",
436
- value: function post(url, body, params) {
437
- const options = kyOptions(params, body);
438
- return this.ky.post(this.stripSlashes(url), options);
439
- }
440
- }, {
441
- key: "put",
442
- value: function put(url, body, params) {
443
- const options = kyOptions(params, body);
444
- return this.ky.put(this.stripSlashes(url), options);
445
- }
446
- }, {
447
- key: "patch",
448
- value: function patch(url, body, params) {
449
- const options = kyOptions(params, body);
450
- return this.ky.patch(this.stripSlashes(url), options);
451
- }
452
- }, {
453
- key: "delete",
454
- value: function _delete(url, body, params) {
455
- const options = kyOptions(params, body);
456
- return this.ky.delete(this.stripSlashes(url), options);
457
- }
458
- }, {
459
- key: "createUrl",
460
- value: function createUrl(url, params) {
461
- const queryString = params ? "?" + qs(params) : '';
462
- return this.prefixUrl + this.stripSlashes(url) + queryString;
463
- }
464
- }, {
465
- key: "stripSlashes",
466
- value: function stripSlashes(url) {
467
- if (this.prefixUrl) {
468
- return url.replace(/^\//g, '');
469
- }
470
-
471
- return url;
472
- }
473
- }]);
474
-
475
- return HttpClient;
476
- }();
477
-
478
- function kyOptions(params, body) {
479
- const options = {
480
- searchParams: qs(params)
481
- };
482
-
483
- if (!isNotObject(body) || Array.isArray(body)) {
484
- options.json = body;
485
- } else {
486
- options.body = body;
487
- }
488
-
489
- return options;
490
- }
491
-
492
- function isNotObject(value) {
493
- return !(value !== void 0 && typeof value === 'object' && value !== null && value.constructor === Object);
494
- }
495
-
496
- function qs(params) {
497
- if (params === void 0) {
498
- params = {};
499
- }
500
-
501
- return queryString.stringify(params, {
502
- arrayFormat: 'comma'
503
- });
504
- }
505
-
506
- function toFormData(input) {
507
- if (input instanceof FormData) {
508
- return input;
509
- }
510
-
511
- return Object.keys(input).reduce((data, key) => {
512
- data.append(key, input[key]);
513
- return data;
514
- }, new FormData());
515
- }
516
-
517
523
  /**
518
524
  * @title Spatial Processing Core API
519
525
  * @version v0.6.0
@@ -5760,12 +5766,6 @@ let Print = /*#__PURE__*/function (_PrintService) {
5760
5766
  return _createClass(Print);
5761
5767
  }(PrintService);
5762
5768
 
5763
- (function (ApiEvent) {
5764
- ApiEvent["ConnectionLost"] = "ConnectionLost";
5765
- ApiEvent["Unauthorized"] = "Unauthorized";
5766
- ApiEvent["SessionClosed"] = "SessionClosed";
5767
- })(exports.ApiEvent || (exports.ApiEvent = {}));
5768
-
5769
5769
  (function (UrlPath) {
5770
5770
  UrlPath["Base"] = "/map";
5771
5771
  UrlPath["Shared"] = "/shared";
@@ -5860,7 +5860,6 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5860
5860
  let {
5861
5861
  authParams,
5862
5862
  connectWs,
5863
- connectSignalR,
5864
5863
  initScheduler,
5865
5864
  fetchSettings,
5866
5865
  fetchUser
@@ -5877,10 +5876,6 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5877
5876
  await this.connectWs();
5878
5877
  }
5879
5878
 
5880
- if (connectSignalR) {
5881
- await this.connectSignalR();
5882
- }
5883
-
5884
5879
  if (initScheduler) {
5885
5880
  await this.initScheduler();
5886
5881
  }
@@ -5931,7 +5926,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5931
5926
  }, {
5932
5927
  key: "connectSignalR",
5933
5928
  value: async function connectSignalR() {
5934
- if (this.account.isAuth && this.snappingHub) {
5929
+ if (this.account.isAuth && this.snappingHub && this.snappingHub.state !== signalr.HubConnectionState.Connected) {
5935
5930
  await this.snappingHub.start();
5936
5931
  }
5937
5932
  }