@evergis/api 5.0.29 → 5.0.31

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,6 @@
1
1
  import ky, { HTTPError } from 'ky';
2
2
  export { HTTPError, TimeoutError } from 'ky';
3
3
  import { stringify } from 'query-string';
4
- import { HubConnectionBuilder, HttpTransportType, HubConnectionState } from '@microsoft/signalr';
5
4
  import { customAlphabet } from 'nanoid';
6
5
 
7
6
  const API_USER_INFO_KEY = "@evergis/user-info";
@@ -2329,13 +2328,27 @@ function isString(v) {
2329
2328
  * @baseUrl /sp
2330
2329
  */
2331
2330
  class DataSourceService extends Service {
2331
+ /**
2332
+ * No description
2333
+ *
2334
+ * @tags DataSource
2335
+ * @name TestConnection
2336
+ * @operationId DataSourceController_TestConnection
2337
+ * @summary Test ArcGIS data source connection.
2338
+ * @request POST:/ds/arcgis/test-connection
2339
+ * @secure
2340
+ * @response `200` OK
2341
+ */
2342
+ testConnection(data) {
2343
+ return this.http.post(`/ds/arcgis/test-connection`, data).then(() => { });
2344
+ }
2332
2345
  /**
2333
2346
  * No description
2334
2347
  *
2335
2348
  * @tags DataSource
2336
2349
  * @name CreateArcGisDataSource
2337
2350
  * @operationId DataSourceController_CreateArcGisDataSource
2338
- * @summary Create S3 data source.
2351
+ * @summary Create ArcGIS data source.
2339
2352
  * @request POST:/ds/arcgis
2340
2353
  * @secure
2341
2354
  * @response `200` OK
@@ -2349,7 +2362,7 @@ class DataSourceService extends Service {
2349
2362
  * @tags DataSource
2350
2363
  * @name UpdateArcGisDataSource
2351
2364
  * @operationId DataSourceController_UpdateArcGisDataSource
2352
- * @summary Update arcgis data source.
2365
+ * @summary Update ArcGIS data source.
2353
2366
  * @request PATCH:/ds/arcgis
2354
2367
  * @secure
2355
2368
  * @response `200` OK
@@ -2433,15 +2446,15 @@ class DataSourceService extends Service {
2433
2446
  * No description
2434
2447
  *
2435
2448
  * @tags DataSource
2436
- * @name TestConnection
2437
- * @operationId DataSourceController_TestConnection
2438
- * @summary Test ds connection.
2439
- * @request POST:/ds/testConnection
2449
+ * @name TestConnection1
2450
+ * @operationId DataSourceController_TestConnection_1
2451
+ * @summary Test data.mos.ru data source connection.
2452
+ * @request POST:/ds/dataMosRu/test-connection
2440
2453
  * @secure
2441
2454
  * @response `200` OK
2442
2455
  */
2443
- testConnection(data) {
2444
- return this.http.post(`/ds/testConnection`, data).json();
2456
+ testConnection1(data) {
2457
+ return this.http.post(`/ds/dataMosRu/test-connection`, data).then(() => { });
2445
2458
  }
2446
2459
  /**
2447
2460
  * No description
@@ -2471,6 +2484,34 @@ class DataSourceService extends Service {
2471
2484
  updateMosRuDataSource(data) {
2472
2485
  return this.http.patch(`/ds/dataMosRu`, data).then(() => { });
2473
2486
  }
2487
+ /**
2488
+ * No description
2489
+ *
2490
+ * @tags DataSource
2491
+ * @name TestConnection2
2492
+ * @operationId DataSourceController_TestConnection_2
2493
+ * @summary Test PostgreSQL data source connection.
2494
+ * @request POST:/ds/test-connection
2495
+ * @secure
2496
+ * @response `200` OK
2497
+ */
2498
+ testConnection2(data) {
2499
+ return this.http.post(`/ds/test-connection`, data).then(() => { });
2500
+ }
2501
+ /**
2502
+ * No description
2503
+ *
2504
+ * @tags DataSource
2505
+ * @name TestConnection3
2506
+ * @operationId DataSourceController_TestConnection_3
2507
+ * @summary Test S3 data source connection.
2508
+ * @request POST:/ds/s3/test-connection
2509
+ * @secure
2510
+ * @response `200` OK
2511
+ */
2512
+ testConnection3(data) {
2513
+ return this.http.post(`/ds/s3/test-connection`, data).then(() => { });
2514
+ }
2474
2515
  /**
2475
2516
  * No description
2476
2517
  *
@@ -2491,7 +2532,7 @@ class DataSourceService extends Service {
2491
2532
  * @tags DataSource
2492
2533
  * @name UpdateS3DataSource
2493
2534
  * @operationId DataSourceController_UpdateS3DataSource
2494
- * @summary Create S3 data source.
2535
+ * @summary Update S3 data source.
2495
2536
  * @request PATCH:/ds/s3
2496
2537
  * @secure
2497
2538
  * @response `200` OK
@@ -2759,7 +2800,6 @@ class Api extends EventEmitter {
2759
2800
  tables;
2760
2801
  projects;
2761
2802
  security;
2762
- notification;
2763
2803
  file;
2764
2804
  filters;
2765
2805
  import;
@@ -2775,7 +2815,6 @@ class Api extends EventEmitter {
2775
2815
  bulk;
2776
2816
  statistic;
2777
2817
  feedback;
2778
- snappingHub;
2779
2818
  vectorTiles;
2780
2819
  spatialReference;
2781
2820
  eql;
@@ -2784,10 +2823,9 @@ class Api extends EventEmitter {
2784
2823
  dataSource;
2785
2824
  remoteTaskManager;
2786
2825
  http;
2787
- wsUrl;
2788
2826
  urlPath;
2789
2827
  refreshingToken = false;
2790
- constructor({ url, wsUrl, wsKeepAlive, snappingHubUrl, http, urlPath, httpOptions, }) {
2828
+ constructor({ url, http, urlPath, httpOptions, }) {
2791
2829
  super();
2792
2830
  const { hooks } = httpOptions || {};
2793
2831
  this.http =
@@ -2854,7 +2892,6 @@ class Api extends EventEmitter {
2854
2892
  },
2855
2893
  });
2856
2894
  this.url = url;
2857
- this.wsUrl = wsUrl || url;
2858
2895
  this.urlPath = urlPath || this.defineUrlPath();
2859
2896
  this.layers = new Layers(this.http);
2860
2897
  this.tables = new Tables(this.http);
@@ -2865,7 +2902,6 @@ class Api extends EventEmitter {
2865
2902
  this.accountPreview = new AccountPreview(this.http);
2866
2903
  this.bulk = new BulkOperations(this.http);
2867
2904
  this.security = new Security(this.http, this.account);
2868
- this.notification = new Notification(this.http, this, wsKeepAlive);
2869
2905
  this.file = new FileUpload(this.http);
2870
2906
  this.filters = new Filters(this.http);
2871
2907
  this.import = new Import(this.http);
@@ -2885,19 +2921,6 @@ class Api extends EventEmitter {
2885
2921
  this.names = new Names({
2886
2922
  account: this.account,
2887
2923
  });
2888
- this.snappingHub = snappingHubUrl
2889
- ? new HubConnectionBuilder()
2890
- .withUrl(snappingHubUrl, {
2891
- withCredentials: true,
2892
- skipNegotiation: true,
2893
- transport: HttpTransportType.WebSockets,
2894
- accessTokenFactory: () => {
2895
- return window.localStorage.getItem(STORAGE_TOKEN_KEY) || "";
2896
- },
2897
- })
2898
- .withAutomaticReconnect()
2899
- .build()
2900
- : null;
2901
2924
  }
2902
2925
  get isShared() {
2903
2926
  return this.urlPath === UrlPath.Shared;
@@ -2905,21 +2928,17 @@ class Api extends EventEmitter {
2905
2928
  get isPresentation() {
2906
2929
  return this.urlPath === UrlPath.Presentation || window.location.port === SHARED_PORT;
2907
2930
  }
2908
- async init({ authParams, authQueryParams, connectWs, fetchSettings, fetchUser, useJwt, }) {
2931
+ async init({ authParams, authQueryParams, fetchSettings, fetchUser, useJwt, }) {
2909
2932
  try {
2910
2933
  await this.account.login(authParams, authQueryParams, useJwt);
2911
2934
  if (fetchUser) {
2912
2935
  await this.account.fetchCurrentUser();
2913
2936
  }
2914
- if (connectWs) {
2915
- await this.connectWs();
2916
- }
2917
2937
  if (fetchSettings) {
2918
2938
  await this.clientSettings.fetchClientSettings({
2919
2939
  urlPath: getFetchingUrlPath(this.urlPath),
2920
2940
  });
2921
2941
  }
2922
- await this.notification.subscribe("service_update" /* SubscriptionTag.ServiceUpdate */);
2923
2942
  }
2924
2943
  catch (e) {
2925
2944
  throw errorHandler(e);
@@ -2938,26 +2957,6 @@ class Api extends EventEmitter {
2938
2957
  throw errorHandler(e);
2939
2958
  }
2940
2959
  }
2941
- async connectWs() {
2942
- if (this.account.isAuth) {
2943
- this.notification.connectWs(this.wsUrl);
2944
- this.notification.on("ConnectionStatus" /* NotificationTag.ConnectionStatus */, connection => {
2945
- if (connection.data === ConnectionStatus.Lost) {
2946
- this.emit(ApiEvent.ConnectionLost, connection.data);
2947
- }
2948
- else if (connection.data === ConnectionStatus.SessionClosed) {
2949
- this.emit(ApiEvent.SessionClosed, connection.data);
2950
- }
2951
- });
2952
- }
2953
- }
2954
- async connectSignalR() {
2955
- if (this.account.isAuth &&
2956
- this.snappingHub &&
2957
- this.snappingHub.state !== HubConnectionState.Connected) {
2958
- await this.snappingHub.start();
2959
- }
2960
- }
2961
2960
  async logout() {
2962
2961
  await this.account.logout();
2963
2962
  await this.security.reset();
@@ -3852,6 +3851,7 @@ function isTileLayerService(layer) {
3852
3851
  }
3853
3852
 
3854
3853
  const RESOURCE_TEMP_WORKSPACE = "temp";
3854
+ const generateFirstLatinLetter = customAlphabet("abcdefghijklmnopqrstuvwxyz", 1);
3855
3855
  var ResourceSeparator;
3856
3856
  (function (ResourceSeparator) {
3857
3857
  ResourceSeparator["Server"] = ".";
@@ -3863,7 +3863,7 @@ class Names {
3863
3863
  }
3864
3864
  /** Generates unique identifier */
3865
3865
  createId() {
3866
- return generateId();
3866
+ return generateFirstLatinLetter() + generateId().slice(1);
3867
3867
  }
3868
3868
  /** Generates new resource name using for client\server interactions */
3869
3869
  createResourceName(params = {}) {
@@ -3909,230 +3909,6 @@ class Names {
3909
3909
  }
3910
3910
  }
3911
3911
 
3912
- /* eslint-disable */
3913
- /* tslint:disable */
3914
- /*
3915
- * ---------------------------------------------------------------
3916
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
3917
- * ## ##
3918
- * ## AUTHOR: acacode ##
3919
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
3920
- * ---------------------------------------------------------------
3921
- */
3922
- // @ts-nocheck
3923
- /**
3924
- * @title Spatial Processing Gateway API
3925
- * @version 1.5.1.0
3926
- * @baseUrl /sp
3927
- */
3928
- class NotificationService extends Service {
3929
- /**
3930
- * No description
3931
- *
3932
- * @tags NotificationService
3933
- * @name GetSubscriptionList
3934
- * @operationId NotificationServiceController_GetSubscriptionList
3935
- * @summary Returns a list of notification tags that the current session is subscribed to.
3936
- * @request GET:/notifications/subscribes
3937
- * @secure
3938
- * @response `200` OK
3939
- */
3940
- getSubscriptionList() {
3941
- return this.http.get(`/notifications/subscribes`).json();
3942
- }
3943
- /**
3944
- * No description
3945
- *
3946
- * @tags NotificationService
3947
- * @name SubscribeOperation
3948
- * @operationId NotificationServiceController_SubscribeOperation
3949
- * @summary Subscribe current session by subscribe tag. A subscribed session will receive all notifications added for the specified tag.
3950
- * @request POST:/notifications/subscribes
3951
- * @secure
3952
- * @response `200` OK
3953
- */
3954
- subscribeOperation(query) {
3955
- return this.http.post(`/notifications/subscribes`, null, query).then(() => { });
3956
- }
3957
- /**
3958
- * No description
3959
- *
3960
- * @tags NotificationService
3961
- * @name UnsubscribeOperation
3962
- * @operationId NotificationServiceController_UnsubscribeOperation
3963
- * @summary Unsubscribe from receiving notifications that come for the specified tag.
3964
- * @request DELETE:/notifications/subscribes
3965
- * @secure
3966
- * @response `200` OK
3967
- */
3968
- unsubscribeOperation(query) {
3969
- return this.http.delete(`/notifications/subscribes`, null, query).then(() => { });
3970
- }
3971
- /**
3972
- * No description
3973
- *
3974
- * @tags NotificationService
3975
- * @name SubscribeListOperation
3976
- * @operationId NotificationServiceController_SubscribeListOperation
3977
- * @summary Subscribe current session by subscribe tags. A subscribed session will receive all notifications added for the specified tags.
3978
- * @request POST:/notifications/subscribe-list
3979
- * @secure
3980
- * @response `200` OK
3981
- */
3982
- subscribeListOperation(data) {
3983
- return this.http.post(`/notifications/subscribe-list`, data).then(() => { });
3984
- }
3985
- /**
3986
- * No description
3987
- *
3988
- * @tags NotificationService
3989
- * @name UnsubscribeListOperation
3990
- * @operationId NotificationServiceController_UnsubscribeListOperation
3991
- * @summary Unsubscribe from receiving notifications that come for the specified tags.
3992
- * @request POST:/notifications/unsubscribe-list
3993
- * @secure
3994
- * @response `200` OK
3995
- */
3996
- unsubscribeListOperation(data) {
3997
- return this.http.post(`/notifications/unsubscribe-list`, data).then(() => { });
3998
- }
3999
- }
4000
-
4001
- var ConnectionStatus;
4002
- (function (ConnectionStatus) {
4003
- ConnectionStatus["Initialized"] = "Initialized";
4004
- ConnectionStatus["Connected"] = "Connected";
4005
- ConnectionStatus["Break"] = "Break";
4006
- ConnectionStatus["Lost"] = "Lost";
4007
- ConnectionStatus["SessionClosed"] = "SessionClosed";
4008
- })(ConnectionStatus || (ConnectionStatus = {}));
4009
- const SUBSCRIPTION_DELAY = 500;
4010
- const KEEP_ALIVE_INTERVAL = 5 * 1000;
4011
- class Notification extends NotificationService {
4012
- api;
4013
- MAX_WS_RECONNECT_TRIES = 10;
4014
- emitter;
4015
- keepAlive = false;
4016
- ws;
4017
- wsUrl;
4018
- reconnectTries = 0;
4019
- subscriptions = [];
4020
- keepAliveTimeout;
4021
- _connectStatus = ConnectionStatus.Initialized;
4022
- // @ts-ignore
4023
- get connectStatus() {
4024
- return this._connectStatus;
4025
- }
4026
- // @ts-ignore
4027
- set connectStatus(connectStatus) {
4028
- this.emitter.emit("ConnectionStatus" /* NotificationTag.ConnectionStatus */, new NotificationEvent(connectStatus));
4029
- this._connectStatus = connectStatus;
4030
- }
4031
- get currentWs() {
4032
- return this.ws;
4033
- }
4034
- constructor(http, api, keepAlive = false) {
4035
- super(http);
4036
- this.api = api;
4037
- this.emitter = new EventEmitter();
4038
- this.keepAlive = keepAlive;
4039
- }
4040
- on(tag, handler) {
4041
- this.emitter.on(tag, handler);
4042
- }
4043
- off(tag, handler) {
4044
- this.emitter.off(tag, handler);
4045
- }
4046
- async subscribe(tag) {
4047
- this.subscriptions.push(tag);
4048
- setTimeout(() => {
4049
- if (!this.api.isShared && !this.api.isPresentation && this.subscriptions.length) {
4050
- this.subscribeListOperation(this.subscriptions);
4051
- }
4052
- this.subscriptions = [];
4053
- }, SUBSCRIPTION_DELAY);
4054
- }
4055
- async unsubscribe(tag) {
4056
- const subscriptions = await this.getSubscriptionList();
4057
- if (subscriptions.includes(tag)) {
4058
- return this.unsubscribeOperation({ tag });
4059
- }
4060
- }
4061
- connectWs(url) {
4062
- const urlWithWsScheme = url
4063
- .replace("http://", "ws://")
4064
- .replace("https://", "wss://");
4065
- this.wsUrl = urlWithWsScheme;
4066
- this.connect();
4067
- }
4068
- connect() {
4069
- if (this.wsUrl) {
4070
- this.ws = new WebSocket(this.wsUrl);
4071
- this.ws.onopen = this.onWsConnected;
4072
- this.ws.onclose = this.onWsClosed;
4073
- this.ws.onmessage = this.onWsMessage;
4074
- }
4075
- else {
4076
- console.warn("Connection to WebSocket not allowed. wsUrl not provided");
4077
- }
4078
- }
4079
- onWsConnected = () => {
4080
- this.connectStatus = ConnectionStatus.Connected;
4081
- if (this.keepAlive) {
4082
- this.keepAliveTimeout = setInterval(() => {
4083
- if (this.ws) {
4084
- this.ws.send(JSON.stringify({ keepAlive: true }));
4085
- }
4086
- }, KEEP_ALIVE_INTERVAL);
4087
- }
4088
- // TODO: comment for now. it launch endless flow of reconnections
4089
- // this.reconnectTries = 0;
4090
- };
4091
- onWsClosed = (event) => {
4092
- if (event.code === 4001 /* WsCloseStatusCode.SessionClosed */ ||
4093
- event.code === 4002 /* WsCloseStatusCode.InvalidSession */) {
4094
- this.connectStatus = ConnectionStatus.SessionClosed;
4095
- }
4096
- else if (this.reconnectTries < this.MAX_WS_RECONNECT_TRIES) {
4097
- this.connectStatus = ConnectionStatus.Break;
4098
- this.reconnectTries++;
4099
- if (this.ws) {
4100
- this.ws.onopen = null;
4101
- this.ws.onclose = null;
4102
- this.ws.onmessage = null;
4103
- this.ws = void 0;
4104
- }
4105
- this.keepAliveTimeout && clearInterval(this.keepAliveTimeout);
4106
- setTimeout(() => {
4107
- this.connect();
4108
- }, 0);
4109
- }
4110
- else {
4111
- this.connectStatus = ConnectionStatus.Lost;
4112
- }
4113
- };
4114
- onWsMessage = (event) => {
4115
- let message = {};
4116
- try {
4117
- message = JSON.parse(event.data);
4118
- }
4119
- catch (e) {
4120
- console.debug("Failed to parse ws message from sp.");
4121
- // ignore
4122
- }
4123
- if (message.type === "notification" && message.data) {
4124
- const { tag, data } = message.data;
4125
- tag && this.emitter.emit(tag, new NotificationEvent(data));
4126
- }
4127
- };
4128
- }
4129
- class NotificationEvent {
4130
- data;
4131
- constructor(data) {
4132
- this.data = data;
4133
- }
4134
- }
4135
-
4136
3912
  class PortalSettings extends ClientSettingsService {
4137
3913
  config = null;
4138
3914
  async fetchPortalSettings(query) {
@@ -5282,5 +5058,5 @@ class VectorTileService extends Service {
5282
5058
  class VectorTiles extends VectorTileService {
5283
5059
  }
5284
5060
 
5285
- export { AccessMode, Account, AccountPreview, AggregationFunction, Api, ApiEvent, AttributeConfigurationType, AttributeIconType, AttributeSelectorType, AttributeType, AuthorizationGrant, BulkOperations, CatalogResourceType, ClassificationType, ClassifyAttributeType, ClientSettings, ConflictResolutionStrategy, ConnectionStatus, DataSourceConnectionType, DataSourceType, DependencyType, Eql, ErrorDetailsType, ErrorReason, External, Feedback, FileUpload, Filters, GEOCODE_PROVIDER, Geocode, HttpClient, Import, LayerServiceType, Layers, Names, Notification, NotificationEvent, OgcGeometryType, PbfSchema, Permissions, PolicyType, PortalSettings, Projects, RemoteTaskManager, RemoteTaskStatus, ResourceSeparator, ResourceSubTypeFilter, ResourceType, ResourceTypeFilter, Resources, ResponseType, STORAGE_REFRESH_TOKEN_KEY, STORAGE_TOKEN_KEY, Security, SimplifyType, Statistic, StringSubType, TableConfigurationType, Tables, TaskResourceSubType, Tools, UrlPath, VectorTiles, WorkerMethodType, WorkerSettingsFieldType, addSubDomainToLocation, errorHandler, formDataFromFile, generateId, getFetchingUrlPath, isHTTPError, isHandledError, isProjectContentItems, isString, isTileLayerService, parseJwt, promiseAllIgnoreErrors, stripUselessSlashes, toFormData, unique, useToken };
5061
+ export { AccessMode, Account, AccountPreview, AggregationFunction, Api, ApiEvent, AttributeConfigurationType, AttributeIconType, AttributeSelectorType, AttributeType, AuthorizationGrant, BulkOperations, CatalogResourceType, ClassificationType, ClassifyAttributeType, ClientSettings, ConflictResolutionStrategy, DataSourceConnectionType, DataSourceType, DependencyType, Eql, ErrorDetailsType, ErrorReason, External, Feedback, FileUpload, Filters, GEOCODE_PROVIDER, Geocode, HttpClient, Import, LayerServiceType, Layers, Names, OgcGeometryType, PbfSchema, Permissions, PolicyType, PortalSettings, Projects, RemoteTaskManager, RemoteTaskStatus, ResourceSeparator, ResourceSubTypeFilter, ResourceType, ResourceTypeFilter, Resources, ResponseType, STORAGE_REFRESH_TOKEN_KEY, STORAGE_TOKEN_KEY, Security, SimplifyType, Statistic, StringSubType, TableConfigurationType, Tables, TaskResourceSubType, Tools, UrlPath, VectorTiles, WorkerMethodType, WorkerSettingsFieldType, addSubDomainToLocation, errorHandler, formDataFromFile, generateId, getFetchingUrlPath, isHTTPError, isHandledError, isProjectContentItems, isString, isTileLayerService, parseJwt, promiseAllIgnoreErrors, stripUselessSlashes, toFormData, unique, useToken };
5286
5062
  //# sourceMappingURL=api.esm.js.map