@evergis/api
Advanced tools
Comparing version 0.1.32 to 0.1.33
@@ -117,3 +117,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -134,3 +134,3 @@ /** | ||
/** Acl set */ | ||
permissions: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -175,3 +175,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -207,3 +207,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -528,3 +528,3 @@ /** | ||
/** */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -558,3 +558,3 @@ /** | ||
/** */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -687,3 +687,3 @@ /** | ||
/** */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -780,3 +780,3 @@ /** | ||
/** */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -813,7 +813,7 @@ /** | ||
/** */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
/** */ | ||
acl?: { | ||
/** */ | ||
[key: string]: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
[key: string]: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -963,3 +963,3 @@ /** */ | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -1040,3 +1040,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -1068,3 +1068,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -1152,3 +1152,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -1553,3 +1553,3 @@ /** | ||
/** Resource permissions. */ | ||
permissions?: 'none' | 'read' | 'write' | 'configure' | 'read,write' | 'read,write,configure'; | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
@@ -1650,2 +1650,31 @@ /** | ||
/** | ||
* The {FailedServiceInfoDc} describes SPCore.Security.Base.Services.FailedServiceInfo data contact. | ||
*/ | ||
export declare type FailedServiceInfoDc = ServiceInfoDc & { | ||
/** */ | ||
configuration?: ServiceConfigurationBaseDc; | ||
/** */ | ||
type: string; | ||
/** */ | ||
categories?: string[]; | ||
/** */ | ||
name: string; | ||
/** */ | ||
ownName?: string; | ||
/** */ | ||
alias?: string; | ||
/** */ | ||
owner?: string; | ||
/** */ | ||
description?: string; | ||
/** */ | ||
preview?: string; | ||
/** */ | ||
createdDate?: string; | ||
/** */ | ||
changedDate?: string; | ||
/** */ | ||
permissions?: 'none' | 'configure' | 'write' | 'read' | 'read,write' | 'read,write,configure'; | ||
}; | ||
/** | ||
* The symbol that draws a feature as a circle. | ||
@@ -1652,0 +1681,0 @@ */ |
@@ -1,3 +0,3 @@ | ||
import { ResponsePromise } from 'ky'; | ||
export { HTTPError, TimeoutError } from 'ky'; | ||
import { Options, ResponsePromise } from 'ky'; | ||
export { HTTPError, TimeoutError, Options } from 'ky'; | ||
declare type SearchParams = { | ||
@@ -8,2 +8,3 @@ [key: string]: number | string | number[] | string[] | boolean | null | undefined; | ||
export interface IHttpClient { | ||
extend(options: Options): void; | ||
get(url: string, params?: SearchParams): ResponsePromise; | ||
@@ -20,2 +21,3 @@ post(url: string, body?: AllowedBody, params?: SearchParams): ResponsePromise; | ||
constructor(prefixUrl?: string | undefined); | ||
extend(options: Options): void; | ||
get(url: string, params?: SearchParams): ResponsePromise; | ||
@@ -22,0 +24,0 @@ post(url: string, body?: AllowedBody, params?: SearchParams): ResponsePromise; |
@@ -9,2 +9,5 @@ import ky from 'ky'; | ||
} | ||
extend(options) { | ||
this.ky = ky.extend(options); | ||
} | ||
get(url, params) { | ||
@@ -11,0 +14,0 @@ return this.ky.get(this.stripSlashes(url), { |
@@ -5,2 +5,3 @@ import { HttpClient } from './__generated__/HttpClient'; | ||
import { AuthorizationData } from './__generated__/data-contracts'; | ||
import { EventEmitter } from '@evergis/event-emitter'; | ||
export declare type ApiParams = { | ||
@@ -11,3 +12,6 @@ url: string; | ||
}; | ||
export declare class Api { | ||
export declare enum ApiEvent { | ||
ConnectionLost = "ConnectionLost" | ||
} | ||
export declare class Api extends EventEmitter { | ||
protected readonly http: HttpClient; | ||
@@ -31,4 +35,4 @@ private readonly wsUrl; | ||
protected connectSp(params: AuthorizationData): Promise<void>; | ||
protected connectWs(): void; | ||
protected connectWs(): Promise<void>; | ||
protected initScheduler(): Promise<void>; | ||
} |
@@ -1,8 +0,15 @@ | ||
import { HttpClient } from './__generated__/HttpClient'; | ||
import { defaultApiConfig } from './defaultApiConfig'; | ||
import { Security, FileUpload, Import, Scheduler, Notification, Layers, Tables, Projects, Resources, Styles, Geocode, ResourceCatalog, } from './services'; | ||
import { errorHandler } from './utils/errorHandler'; | ||
export class Api { | ||
import { EventEmitter } from '@evergis/event-emitter'; | ||
import { ExtendedHttpClient } from './utils/ExtendedHttpClient'; | ||
import { ConnectionStatus } from './services/Notification'; | ||
export var ApiEvent; | ||
(function (ApiEvent) { | ||
ApiEvent["ConnectionLost"] = "ConnectionLost"; | ||
})(ApiEvent || (ApiEvent = {})); | ||
export class Api extends EventEmitter { | ||
constructor({ url, wsUrl, config = defaultApiConfig }) { | ||
this.http = new HttpClient(url); | ||
super(); | ||
this.http = new ExtendedHttpClient(url, this); | ||
this.url = url; | ||
@@ -36,5 +43,10 @@ this.wsUrl = wsUrl || url; | ||
} | ||
connectWs() { | ||
async connectWs() { | ||
if (this.security.sessionId) { | ||
return this.notification.connectWs(this.wsUrl, this.security.sessionId); | ||
await this.notification.connectWs(this.wsUrl, this.security.sessionId); | ||
this.notification.on("ConnectionStatus" /* ConnectionStatus */, connection => { | ||
if (connection.data === ConnectionStatus.Break) { | ||
this.emit(ApiEvent.ConnectionLost, connection.data); | ||
} | ||
}); | ||
} | ||
@@ -41,0 +53,0 @@ } |
@@ -5,2 +5,12 @@ import { NotificationService } from '../__generated__/NotificationService'; | ||
declare type NotificationHandler<Data, Result> = (event: NotificationEvent<Data>) => Result; | ||
export declare enum ConnectionStatus { | ||
Initialized = "Initialized", | ||
Connected = "Connected", | ||
Break = "Break", | ||
Lost = "Lost" | ||
} | ||
export declare const enum NotificationTag { | ||
ConnectionStatus = "ConnectionStatus", | ||
ServerTask = "server_task" | ||
} | ||
export declare class Notification extends NotificationService { | ||
@@ -12,2 +22,4 @@ private readonly MAX_WS_RECONNECT_TRIES; | ||
private reconnectTries; | ||
private _connectStatus; | ||
connectStatus: ConnectionStatus; | ||
constructor(info: ServiceInfoDc, http: IHttpClient); | ||
@@ -14,0 +26,0 @@ on<Data, Result>(tag: string, handler: NotificationHandler<Data, Result>): void; |
import { NotificationService } from '../__generated__/NotificationService'; | ||
import { EventEmitter } from '@evergis/event-emitter'; | ||
export var ConnectionStatus; | ||
(function (ConnectionStatus) { | ||
ConnectionStatus["Initialized"] = "Initialized"; | ||
ConnectionStatus["Connected"] = "Connected"; | ||
ConnectionStatus["Break"] = "Break"; | ||
ConnectionStatus["Lost"] = "Lost"; | ||
})(ConnectionStatus || (ConnectionStatus = {})); | ||
export class Notification extends NotificationService { | ||
@@ -8,11 +15,15 @@ constructor(info, http) { | ||
this.reconnectTries = 0; | ||
this._connectStatus = ConnectionStatus.Initialized; | ||
this.onWsConnected = () => { | ||
console.log('WebSocket connection established.'); | ||
this.connectStatus = ConnectionStatus.Connected; | ||
}; | ||
this.onWsClosed = () => { | ||
console.log('WebSocket connection closed.'); | ||
if (this.reconnectTries < this.MAX_WS_RECONNECT_TRIES) { | ||
this.connectStatus = ConnectionStatus.Break; | ||
this.reconnectTries++; | ||
this.connect(); | ||
} | ||
else { | ||
this.connectStatus = ConnectionStatus.Lost; | ||
} | ||
}; | ||
@@ -34,2 +45,9 @@ this.onWsMessage = (event) => { | ||
} | ||
get connectStatus() { | ||
return this._connectStatus; | ||
} | ||
set connectStatus(connectStatus) { | ||
this.emitter.emit("ConnectionStatus" /* ConnectionStatus */, new NotificationEvent(connectStatus)); | ||
this._connectStatus = connectStatus; | ||
} | ||
on(tag, handler) { | ||
@@ -36,0 +54,0 @@ this.emitter.on(tag, handler); |
import { SchedulerService as SchedulerServiceBase } from '../__generated__/SchedulerService'; | ||
const SERVER_TASK = 'server_task'; | ||
export class Scheduler extends SchedulerServiceBase { | ||
init(notification) { | ||
this.notification = notification; | ||
return this.notification.subscribe(SERVER_TASK); | ||
return this.notification.subscribe("server_task" /* ServerTask */); | ||
} | ||
@@ -51,3 +50,3 @@ async runCopyTask(parameters) { | ||
this.notification && | ||
this.notification.off(SERVER_TASK, taskResultCallback); | ||
this.notification.off("server_task" /* ServerTask */, taskResultCallback); | ||
this.resolveTaskStatus(taskProgress, resolve, reject); | ||
@@ -57,3 +56,3 @@ } | ||
this.notification && | ||
this.notification.on(SERVER_TASK, taskResultCallback); | ||
this.notification.on("server_task" /* ServerTask */, taskResultCallback); | ||
}); | ||
@@ -60,0 +59,0 @@ } |
{ | ||
"name": "@evergis/api", | ||
"version": "0.1.32", | ||
"version": "0.1.33", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "everpoint", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247480
179
5301