@evergis/api 3.0.79 → 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.esm.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { EventEmitter } from '@evergis/event-emitter';
2
+ import { HubConnectionBuilder, HubConnectionState } from '@microsoft/signalr';
1
3
  import ky, { HTTPError } from 'ky';
2
4
  export { HTTPError, TimeoutError } from 'ky';
3
- import { EventEmitter } from '@evergis/event-emitter';
4
5
  import { stringify } from 'query-string';
5
6
  import { customAlphabet } from 'nanoid';
6
7
  import { DomPainter } from '@evergis/sgis/es/painters/DomPainter/DomPainter';
@@ -173,6 +174,126 @@ function _get(target, property, receiver) {
173
174
  return _get(target, property, receiver || target);
174
175
  }
175
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
+
176
297
  /* eslint-disable */
177
298
 
178
299
  /* tslint:disable */
@@ -395,114 +516,6 @@ let Security = /*#__PURE__*/function (_SecurityService) {
395
516
  return Security;
396
517
  }(SecurityService);
397
518
 
398
- let HttpClient = /*#__PURE__*/function () {
399
- function HttpClient(options) {
400
- var _options$prefixUrl;
401
-
402
- if (options === void 0) {
403
- options = {};
404
- }
405
-
406
- _classCallCheck(this, HttpClient);
407
-
408
- this.ky = ky.extend(options);
409
- this.prefixUrl = ((_options$prefixUrl = options.prefixUrl) == null ? void 0 : _options$prefixUrl.toString()) || '';
410
- }
411
-
412
- _createClass(HttpClient, [{
413
- key: "extend",
414
- value: function extend(options) {
415
- var _options$prefixUrl2;
416
-
417
- this.ky = ky.extend(options);
418
- this.prefixUrl = ((_options$prefixUrl2 = options.prefixUrl) == null ? void 0 : _options$prefixUrl2.toString()) || '';
419
- }
420
- }, {
421
- key: "get",
422
- value: function get(url, params) {
423
- return this.ky.get(this.stripSlashes(url), {
424
- searchParams: qs(params)
425
- });
426
- }
427
- }, {
428
- key: "post",
429
- value: function post(url, body, params) {
430
- const options = kyOptions(params, body);
431
- return this.ky.post(this.stripSlashes(url), options);
432
- }
433
- }, {
434
- key: "put",
435
- value: function put(url, body, params) {
436
- const options = kyOptions(params, body);
437
- return this.ky.put(this.stripSlashes(url), options);
438
- }
439
- }, {
440
- key: "patch",
441
- value: function patch(url, body, params) {
442
- const options = kyOptions(params, body);
443
- return this.ky.patch(this.stripSlashes(url), options);
444
- }
445
- }, {
446
- key: "delete",
447
- value: function _delete(url, body, params) {
448
- const options = kyOptions(params, body);
449
- return this.ky.delete(this.stripSlashes(url), options);
450
- }
451
- }, {
452
- key: "createUrl",
453
- value: function createUrl(url, params) {
454
- const queryString = params ? "?" + qs(params) : '';
455
- return this.prefixUrl + this.stripSlashes(url) + queryString;
456
- }
457
- }, {
458
- key: "stripSlashes",
459
- value: function stripSlashes(url) {
460
- if (this.prefixUrl) {
461
- return url.replace(/^\//g, '');
462
- }
463
-
464
- return url;
465
- }
466
- }]);
467
-
468
- return HttpClient;
469
- }();
470
-
471
- function kyOptions(params, body) {
472
- const options = {
473
- searchParams: qs(params)
474
- };
475
-
476
- if (!isNotObject(body) || Array.isArray(body)) {
477
- options.json = body;
478
- } else {
479
- options.body = body;
480
- }
481
-
482
- return options;
483
- }
484
-
485
- function isNotObject(value) {
486
- return !(value !== void 0 && typeof value === 'object' && value !== null && value.constructor === Object);
487
- }
488
-
489
- function qs(params) {
490
- if (params === void 0) {
491
- params = {};
492
- }
493
-
494
- return stringify(params, {
495
- arrayFormat: 'comma'
496
- });
497
- }
498
-
499
- function toFormData(input) {
500
- return Object.keys(input).reduce((data, key) => {
501
- data.append(key, input[key]);
502
- return data;
503
- }, new FormData());
504
- }
505
-
506
519
  /**
507
520
  * @title Spatial Processing Core API
508
521
  * @version v0.6.0
@@ -634,49 +647,17 @@ let ImportService = /*#__PURE__*/function (_Service) {
634
647
  * No description
635
648
  *
636
649
  * @tags ImportService
637
- * @name GetExcelDataSchema
638
- * @operationId ImportServiceController_GetExcelDataSchema
639
- * @summary Using a file uploaded to the file upload service, reads the headers of the excel file and returns the information about data schema of all layers in that file, available for import.
640
- * @request GET:/import/excelDataSchema
641
- * @response `200` Success
642
- */
643
-
644
- }, {
645
- key: "getExcelDataSchema",
646
- value: function getExcelDataSchema(query) {
647
- return this.http.get("/import/excelDataSchema", query).json();
648
- }
649
- /**
650
- * No description
651
- *
652
- * @tags ImportService
653
- * @name GetCsvDataSchema
654
- * @operationId ImportServiceController_GetCsvDataSchema
655
- * @summary Using a file uploaded to the file upload service, reads the headers of the csv file and returns the information about data schema of all layers in that file, available for import.
656
- * @request GET:/import/csvDataSchema
657
- * @response `200` Success
658
- */
659
-
660
- }, {
661
- key: "getCsvDataSchema",
662
- value: function getCsvDataSchema(query) {
663
- return this.http.get("/import/csvDataSchema", query).json();
664
- }
665
- /**
666
- * No description
667
- *
668
- * @tags ImportService
669
- * @name GetKmlDataSchema
670
- * @operationId ImportServiceController_GetKmlDataSchema
671
- * @summary Using a file uploaded to the file upload service, reads the kml file and returns the information about data schema of all layers in that file, available for import.
672
- * @request GET:/import/kmlDataSchema
650
+ * @name GetFeaturesCount
651
+ * @operationId ImportServiceController_GetFeaturesCount
652
+ * @summary Returns the features count of the given file in temporary static storage.
653
+ * @request POST:/import/count
673
654
  * @response `200` Success
674
655
  */
675
656
 
676
657
  }, {
677
- key: "getKmlDataSchema",
678
- value: function getKmlDataSchema(query) {
679
- return this.http.get("/import/kmlDataSchema", query).json();
658
+ key: "getFeaturesCount",
659
+ value: function getFeaturesCount(data) {
660
+ return this.http.post("/import/count", data).json();
680
661
  }
681
662
  /**
682
663
  * No description
@@ -5788,14 +5769,6 @@ let Print = /*#__PURE__*/function (_PrintService) {
5788
5769
  return _createClass(Print);
5789
5770
  }(PrintService);
5790
5771
 
5791
- var ApiEvent;
5792
-
5793
- (function (ApiEvent) {
5794
- ApiEvent["ConnectionLost"] = "ConnectionLost";
5795
- ApiEvent["Unauthorized"] = "Unauthorized";
5796
- ApiEvent["SessionClosed"] = "SessionClosed";
5797
- })(ApiEvent || (ApiEvent = {}));
5798
-
5799
5772
  var UrlPath;
5800
5773
 
5801
5774
  (function (UrlPath) {
@@ -5820,6 +5793,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5820
5793
  let {
5821
5794
  url,
5822
5795
  wsUrl,
5796
+ snappingHubUrl,
5823
5797
  http,
5824
5798
  urlPath,
5825
5799
  httpOptions
@@ -5879,6 +5853,9 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5879
5853
  _this.names = new Names({
5880
5854
  account: _this.account
5881
5855
  });
5856
+ _this.snappingHub = snappingHubUrl ? new HubConnectionBuilder().withUrl(snappingHubUrl, {
5857
+ withCredentials: true
5858
+ }).withAutomaticReconnect().build() : null;
5882
5859
  return _this;
5883
5860
  }
5884
5861
 
@@ -5951,6 +5928,13 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
5951
5928
  });
5952
5929
  }
5953
5930
  }
5931
+ }, {
5932
+ key: "connectSignalR",
5933
+ value: async function connectSignalR() {
5934
+ if (this.account.isAuth && this.snappingHub && this.snappingHub.state !== HubConnectionState.Connected) {
5935
+ await this.snappingHub.start();
5936
+ }
5937
+ }
5954
5938
  }, {
5955
5939
  key: "logout",
5956
5940
  value: async function logout() {