@vuu-ui/vuu-data-remote 4.1.0 → 5.0.0-alpha.1

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.
Files changed (43) hide show
  1. package/package.json +11 -11
  2. package/src/ConnectionManager.js +174 -66
  3. package/src/DedicatedWorker.js +5 -2
  4. package/src/VuuDataSource.js +10 -3
  5. package/src/WebSocketConnection.js +44 -8
  6. package/src/index.js +0 -4
  7. package/src/inlined-worker.js +1 -1
  8. package/src/server-proxy/server-proxy.js +13 -6
  9. package/src/server-proxy/viewport.js +3 -1
  10. package/src/worker.js +4 -3
  11. package/types/ConnectionManager.d.ts +45 -17
  12. package/types/DedicatedWorker.d.ts +10 -3
  13. package/types/VuuDataSource.d.ts +1 -1
  14. package/types/WebSocketConnection.d.ts +18 -3
  15. package/types/index.d.ts +0 -4
  16. package/types/inlined-worker.d.ts +1 -1
  17. package/types/server-proxy/server-proxy.d.ts +6 -2
  18. package/src/LostConnectionHandler.js +0 -89
  19. package/src/VuuAuthProvider.js +0 -78
  20. package/src/VuuAuthenticator.js +0 -36
  21. package/src/authenticate.js +0 -50
  22. package/types/LostConnectionHandler.d.ts +0 -28
  23. package/types/VuuAuthProvider.d.ts +0 -39
  24. package/types/VuuAuthenticator.d.ts +0 -21
  25. package/types/authenticate.d.ts +0 -15
  26. package/types/src/ConnectionManager.d.ts +0 -36
  27. package/types/src/DedicatedWorker.d.ts +0 -9
  28. package/types/src/LostConnectionHandler.d.ts +0 -28
  29. package/types/src/VuuAuthProvider.d.ts +0 -39
  30. package/types/src/VuuAuthenticator.d.ts +0 -21
  31. package/types/src/VuuDataSource.d.ts +0 -74
  32. package/types/src/WebSocketConnection.d.ts +0 -54
  33. package/types/src/authenticate.d.ts +0 -15
  34. package/types/src/constants.d.ts +0 -41
  35. package/types/src/data-source.d.ts +0 -6
  36. package/types/src/index.d.ts +0 -11
  37. package/types/src/inlined-worker.d.ts +0 -1
  38. package/types/src/message-utils.d.ts +0 -20
  39. package/types/src/server-proxy/array-backed-moving-window.d.ts +0 -27
  40. package/types/src/server-proxy/messages.d.ts +0 -33
  41. package/types/src/server-proxy/server-proxy.d.ts +0 -68
  42. package/types/src/server-proxy/viewport.d.ts +0 -132
  43. package/types/src/worker.d.ts +0 -1
@@ -1,78 +0,0 @@
1
- import { getCookieValue } from "@vuu-ui/vuu-utils";
2
- import { parseVuuUserFromToken } from "./authenticate.js";
3
- class VuuAuthProvider {
4
- authEndpoint;
5
- constructor(authEndpoint){
6
- this.authEndpoint = authEndpoint;
7
- }
8
- login = async (username, password)=>{
9
- const date = new Date();
10
- const days = 1;
11
- date.setTime(date.getTime() + 24 * days * 3600000);
12
- if (username && password) {
13
- const { token } = await this.getVuuTokenWithUsernameAndPassword(username, password);
14
- document.cookie = `vuu-auth-user=${username};expires=${date.toUTCString()};path=/`;
15
- document.cookie = `vuu-auth-password=${password};expires=${date.toUTCString()};path=/`;
16
- document.cookie = `vuu-auth-token=${token};expires=${date.toUTCString()};path=/`;
17
- return this.redirectToApplication();
18
- }
19
- {
20
- const userName = getCookieValue("vuu-auth-user");
21
- const password = getCookieValue("vuu-auth-password");
22
- if (!userName || !password) return this.redirectToLoginPage();
23
- {
24
- const { authorizations, token } = await this.getVuuTokenWithUsernameAndPassword(userName, password);
25
- document.cookie = `vuu-auth-token=${token};expires=${date.toUTCString()};path=/`;
26
- return {
27
- authorizations,
28
- user: {
29
- userName
30
- },
31
- token
32
- };
33
- }
34
- }
35
- };
36
- async getVuuTokenWithUsernameAndPassword(username, password) {
37
- const response = await fetch(this.authEndpoint, {
38
- method: "POST",
39
- credentials: "include",
40
- headers: {
41
- "Content-Type": "application/json",
42
- "access-control-allow-origin": location.host
43
- },
44
- body: JSON.stringify({
45
- username,
46
- password
47
- })
48
- });
49
- if (response.ok) {
50
- const vuuAuthToken = response.headers.get("vuu-auth-token");
51
- if ("string" == typeof vuuAuthToken && vuuAuthToken.length > 0) {
52
- const { authorizations } = parseVuuUserFromToken(vuuAuthToken);
53
- return {
54
- authorizations,
55
- token: vuuAuthToken
56
- };
57
- }
58
- throw Error("Authentication failed auth token not returned by server");
59
- }
60
- throw Error(`Authentication failed, ${response.status}`);
61
- }
62
- clear() {
63
- document.cookie = "vuu-auth-user= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
64
- document.cookie = "vuu-auth-password= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
65
- document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
66
- }
67
- redirectToLoginPage() {
68
- window.location.href = "login.html";
69
- }
70
- redirectToApplication() {
71
- window.location.href = "index.html";
72
- }
73
- logout() {
74
- this.clear();
75
- this.redirectToLoginPage();
76
- }
77
- }
78
- export { VuuAuthProvider };
@@ -1,36 +0,0 @@
1
- import ConnectionManager from "./ConnectionManager.js";
2
- const VuuAuthTokenIssuePolicy = {
3
- BearerToken: "bearer-token",
4
- UsernamePassword: "username-password"
5
- };
6
- class VuuAuthenticator {
7
- authProvider;
8
- authTokenIssuePolicy;
9
- websocketUrl;
10
- constructor({ authProvider, authTokenIssuePolicy = VuuAuthTokenIssuePolicy.BearerToken, websocketUrl }){
11
- this.authProvider = authProvider;
12
- this.authTokenIssuePolicy = authTokenIssuePolicy;
13
- this.websocketUrl = websocketUrl;
14
- }
15
- openWebsocketConnection = async (vuuToken)=>{
16
- await ConnectionManager.connect({
17
- url: this.websocketUrl,
18
- token: vuuToken
19
- }, true);
20
- };
21
- login = async ()=>{
22
- const { authorizations, user, token, websocket = true } = await this.authProvider.login();
23
- if (token && user) {
24
- if (websocket) await this.openWebsocketConnection(token);
25
- return [
26
- user,
27
- authorizations
28
- ];
29
- }
30
- throw Error("[VuuAuthenticator] login failed");
31
- };
32
- logout = ()=>{
33
- this.authProvider.logout();
34
- };
35
- }
36
- export { VuuAuthTokenIssuePolicy, VuuAuthenticator };
@@ -1,50 +0,0 @@
1
- const defaultAuthUrl = "api/authn";
2
- const isValidVuuUser = (response)=>"object" == typeof response && null !== response && "name" in response && "authorizations" in response && "string" == typeof response.name && Array.isArray(response.authorizations);
3
- const parseVuuUserFromToken = (token)=>{
4
- const [base64EncodedVuuUser] = token.split(".");
5
- const jsonString = atob(base64EncodedVuuUser);
6
- const response = JSON.parse(jsonString);
7
- if (isValidVuuUser(response)) return response;
8
- throw Error("auth token does not containe VuuUser");
9
- };
10
- const getVuuAuthToken = async (authUrl, token)=>{
11
- const response = await fetch(authUrl, {
12
- headers: {
13
- Authorization: `Bearer ${token}`
14
- }
15
- });
16
- if (!response.ok) throw Error("Authentication error: Auth token failure");
17
- const json = await response.json();
18
- const vuuUser = parseVuuUserFromToken(json.token);
19
- return {
20
- authorizations: vuuUser.authorizations,
21
- token: json.token
22
- };
23
- };
24
- const authenticate = async (username, password, authUrl = defaultAuthUrl)=>fetch(authUrl, {
25
- method: "POST",
26
- credentials: "include",
27
- headers: {
28
- "Content-Type": "application/json",
29
- "access-control-allow-origin": location.host
30
- },
31
- body: JSON.stringify({
32
- username,
33
- password
34
- })
35
- }).then((response)=>{
36
- if (response.ok) {
37
- const authToken = response.headers.get("vuu-auth-token");
38
- if ("string" == typeof authToken && authToken.length > 0) try {
39
- return {
40
- token: authToken,
41
- user: parseVuuUserFromToken(authToken)
42
- };
43
- } catch (e) {
44
- throw Error("Authentication error: vuu auth token decoding failed.");
45
- }
46
- throw Error("Authentication failed auth token not returned by server");
47
- }
48
- throw Error(`Authentication failed ${response.status} ${response.statusText}`);
49
- });
50
- export { authenticate, getVuuAuthToken, parseVuuUserFromToken };
@@ -1,28 +0,0 @@
1
- import { VuuAuthenticator } from "./VuuAuthenticator";
2
- interface RetryOptions {
3
- interval: number;
4
- next: () => void;
5
- remaining: number;
6
- }
7
- declare class RetryOptionsImpl implements RetryOptions {
8
- private retryIntervals;
9
- private ind;
10
- constructor(retryIntervals: number[]);
11
- next(): void;
12
- get remaining(): number;
13
- get interval(): number;
14
- }
15
- export declare function RetryOptions(retryIntervals: number[]): RetryOptionsImpl;
16
- export declare class RetryGenerator {
17
- private vuuAuth;
18
- private options;
19
- constructor(vuuAuth: VuuAuthenticator, options: RetryOptions);
20
- [Symbol.asyncIterator](): AsyncGenerator<"connected" | "connection-failed">;
21
- }
22
- export declare class LostConnectionHandler {
23
- private vuuAuth;
24
- private retryIntervals;
25
- constructor(vuuAuth: VuuAuthenticator, retryIntervals?: number[]);
26
- reconnect(): Promise<"connected" | "connection-failed">;
27
- }
28
- export {};
@@ -1,39 +0,0 @@
1
- export type User = {
2
- userName: string;
3
- };
4
- export interface AuthProvider {
5
- login: (username?: string, password?: string) => Promise<{
6
- authorizations: string[];
7
- token: string;
8
- user: User;
9
- websocket?: boolean;
10
- }>;
11
- logout: () => void;
12
- }
13
- /**
14
- * The Vuu AuthProvider is a simple Demoware auth provider that
15
- * grabs username and pasdsword from. a simple login form and
16
- * exchanges these for a Vuu Token. Password is manipulated in
17
- * plain text, hence not suitable for real world usage.
18
- *
19
- * This AuthProvider is used by the login panel, which sets
20
- * user credentials in cookies.
21
- * It is then used by the application itself to retrieve the
22
- * credentials and login to vuu.
23
- */
24
- export declare class VuuAuthProvider implements AuthProvider {
25
- private authEndpoint;
26
- constructor(authEndpoint: string);
27
- login: (username?: string, password?: string) => Promise<{
28
- authorizations: string[];
29
- user: {
30
- userName: string;
31
- };
32
- token: string;
33
- }>;
34
- private getVuuTokenWithUsernameAndPassword;
35
- private clear;
36
- private redirectToLoginPage;
37
- private redirectToApplication;
38
- logout(): void;
39
- }
@@ -1,21 +0,0 @@
1
- import { ValueOf } from "@vuu-ui/vuu-utils";
2
- import { User, type AuthProvider } from "./VuuAuthProvider";
3
- export declare const VuuAuthTokenIssuePolicy: {
4
- readonly BearerToken: "bearer-token";
5
- readonly UsernamePassword: "username-password";
6
- };
7
- export type VuuAuthTokenIssuePolicy = ValueOf<typeof VuuAuthTokenIssuePolicy>;
8
- export interface VuuAuthenticatorConstructorOptions {
9
- authProvider: AuthProvider;
10
- authTokenIssuePolicy?: VuuAuthTokenIssuePolicy;
11
- websocketUrl: string;
12
- }
13
- export declare class VuuAuthenticator {
14
- private authProvider;
15
- private authTokenIssuePolicy;
16
- private websocketUrl;
17
- constructor({ authProvider, authTokenIssuePolicy, websocketUrl, }: VuuAuthenticatorConstructorOptions);
18
- private openWebsocketConnection;
19
- login: () => Promise<[User, string[]] | never>;
20
- logout: () => void;
21
- }
@@ -1,15 +0,0 @@
1
- import type { VuuUser } from "@vuu-ui/vuu-protocol-types";
2
- /**
3
- * The auth token returned from authn call encodes (Base64) a VuuUser
4
- * within the first part of the token.
5
- */
6
- export declare const parseVuuUserFromToken: (token: string) => VuuUser;
7
- export type AuthenticationResponse = {
8
- token: string;
9
- user: VuuUser;
10
- };
11
- export declare const getVuuAuthToken: (authUrl: string, token: string) => Promise<{
12
- authorizations: string[];
13
- token: string;
14
- }>;
15
- export declare const authenticate: (username: string, password: string, authUrl?: string) => Promise<AuthenticationResponse>;
@@ -1,36 +0,0 @@
1
- import { ConnectOptions, DataSourceCallbackMessage, ServerAPI } from "@vuu-ui/vuu-data-types";
2
- import { EventEmitter } from "@vuu-ui/vuu-utils";
3
- import { ConnectionStatus, WebSocketConnectionEvents } from "./WebSocketConnection";
4
- import { ConnectionQualityMetrics } from "@vuu-ui/vuu-data-types";
5
- export type PostMessageToClientCallback = (msg: DataSourceCallbackMessage) => void;
6
- export type ConnectionEvents = WebSocketConnectionEvents & {
7
- "connection-metrics": (message: ConnectionQualityMetrics) => void;
8
- };
9
- declare class ConnectionManager extends EventEmitter<ConnectionEvents> {
10
- #private;
11
- private constructor();
12
- static get instance(): ConnectionManager;
13
- get connectionStatus(): ConnectionStatus;
14
- get connected(): boolean;
15
- /**
16
- * Open a connection to the VuuServer. This method opens the websocket connection
17
- * and logs in. It can be called from whichever client code has access to the auth
18
- * token (eg. the login page, or just a hardcoded login script in a sample).
19
- * This will unblock any DataSources which may have already tried to subscribe to data,
20
- * but lacked access to the auth token.
21
- *
22
- * @param serverUrl
23
- * @param token
24
- */
25
- connect(options: ConnectOptions, throwOnRejected?: boolean): Promise<"connected" | "connection-failed" | "reconnected" | "rejected">;
26
- disableActiveSubscriptions(): void;
27
- enableActiveSubscriptions(): void;
28
- private handleMessageFromWorker;
29
- get serverAPI(): Promise<ServerAPI>;
30
- private connectedServerAPI;
31
- private asyncRequest;
32
- disconnect(): Promise<"disconnected" | "rejected">;
33
- destroy(): void;
34
- }
35
- declare const _default: ConnectionManager;
36
- export default _default;
@@ -1,9 +0,0 @@
1
- import { ConnectOptions, VuuUIMessageIn, VuuUIMessageOut, WithRequestId } from "@vuu-ui/vuu-data-types";
2
- import { SelectRequest, VuuCreateVisualLink, VuuRemoveVisualLink, VuuRpcMenuRequest, VuuRpcServiceRequest } from "@vuu-ui/vuu-protocol-types";
3
- export declare class DedicatedWorker {
4
- #private;
5
- constructor(onMessage: (msg: VuuUIMessageIn) => void);
6
- connect(options: ConnectOptions): Promise<"connected" | "reconnected" | "rejected">;
7
- send(message: VuuUIMessageOut | WithRequestId<VuuCreateVisualLink | VuuRemoveVisualLink | VuuRpcServiceRequest | VuuRpcMenuRequest | SelectRequest>): Promise<void>;
8
- terminate(): Promise<void>;
9
- }
@@ -1,28 +0,0 @@
1
- import { VuuAuthenticator } from "./VuuAuthenticator";
2
- interface RetryOptions {
3
- interval: number;
4
- next: () => void;
5
- remaining: number;
6
- }
7
- declare class RetryOptionsImpl implements RetryOptions {
8
- private retryIntervals;
9
- private ind;
10
- constructor(retryIntervals: number[]);
11
- next(): void;
12
- get remaining(): number;
13
- get interval(): number;
14
- }
15
- export declare function RetryOptions(retryIntervals: number[]): RetryOptionsImpl;
16
- export declare class RetryGenerator {
17
- private vuuAuth;
18
- private options;
19
- constructor(vuuAuth: VuuAuthenticator, options: RetryOptions);
20
- [Symbol.asyncIterator](): AsyncGenerator<"connected" | "connection-failed">;
21
- }
22
- export declare class LostConnectionHandler {
23
- private vuuAuth;
24
- private retryIntervals;
25
- constructor(vuuAuth: VuuAuthenticator, retryIntervals?: number[]);
26
- reconnect(): Promise<"connected" | "connection-failed">;
27
- }
28
- export {};
@@ -1,39 +0,0 @@
1
- export type User = {
2
- userName: string;
3
- };
4
- export interface AuthProvider {
5
- login: (username?: string, password?: string) => Promise<{
6
- authorizations: string[];
7
- token: string;
8
- user: User;
9
- websocket?: boolean;
10
- }>;
11
- logout: () => void;
12
- }
13
- /**
14
- * The Vuu AuthProvider is a simple Demoware auth provider that
15
- * grabs username and pasdsword from. a simple login form and
16
- * exchanges these for a Vuu Token. Password is manipulated in
17
- * plain text, hence not suitable for real world usage.
18
- *
19
- * This AuthProvider is used by the login panel, which sets
20
- * user credentials in cookies.
21
- * It is then used by the application itself to retrieve the
22
- * credentials and login to vuu.
23
- */
24
- export declare class VuuAuthProvider implements AuthProvider {
25
- private authEndpoint;
26
- constructor(authEndpoint: string);
27
- login: (username?: string, password?: string) => Promise<{
28
- authorizations: string[];
29
- user: {
30
- userName: string;
31
- };
32
- token: string;
33
- }>;
34
- private getVuuTokenWithUsernameAndPassword;
35
- private clear;
36
- private redirectToLoginPage;
37
- private redirectToApplication;
38
- logout(): void;
39
- }
@@ -1,21 +0,0 @@
1
- import { ValueOf } from "@vuu-ui/vuu-utils";
2
- import { User, type AuthProvider } from "./VuuAuthProvider";
3
- export declare const VuuAuthTokenIssuePolicy: {
4
- readonly BearerToken: "bearer-token";
5
- readonly UsernamePassword: "username-password";
6
- };
7
- export type VuuAuthTokenIssuePolicy = ValueOf<typeof VuuAuthTokenIssuePolicy>;
8
- export interface VuuAuthenticatorConstructorOptions {
9
- authProvider: AuthProvider;
10
- authTokenIssuePolicy?: VuuAuthTokenIssuePolicy;
11
- websocketUrl: string;
12
- }
13
- export declare class VuuAuthenticator {
14
- private authProvider;
15
- private authTokenIssuePolicy;
16
- private websocketUrl;
17
- constructor({ authProvider, authTokenIssuePolicy, websocketUrl, }: VuuAuthenticatorConstructorOptions);
18
- private openWebsocketConnection;
19
- login: () => Promise<[User, string[]] | never>;
20
- logout: () => void;
21
- }
@@ -1,74 +0,0 @@
1
- import type { CopyOption, DataSource, DataSourceBase, SessionType, DataSourceCallbackMessage, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, DeleteRowMode, OptimizeStrategy, SessionDataSourceOverrides, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
- import type { MenuRpcResponse } from "@vuu-ui/vuu-data-types";
3
- import type { LinkDescriptorWithLabel, RpcResult, RpcResultError, RpcResultSuccess, SelectRequest, VuuGroupBy, VuuMenu, VuuRange, VuuRowDataItemType, VuuRpcMenuRequest, VuuRpcResponse, VuuRpcServiceRequest, VuuTable } from "@vuu-ui/vuu-protocol-types";
4
- import { BaseDataSource, Range } from "@vuu-ui/vuu-utils";
5
- type RangeRequest = (range: VuuRange) => void;
6
- export declare class VuuDataSource extends BaseDataSource implements DataSourceBase {
7
- #private;
8
- private bufferSize;
9
- private server;
10
- rangeRequest: RangeRequest;
11
- readonly isRemote = true;
12
- table: VuuTable;
13
- constructor({ session, sessionTableMessageColumn, ...props }: DataSourceConstructorProps);
14
- subscribe(subscribeProps: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
15
- handleMessageFromServer: (message: DataSourceCallbackMessage) => void;
16
- handleSessionMessageFromServer: (msg: DataSourceCallbackMessage) => void;
17
- unsubscribe(): void;
18
- suspend(escalateToDisable?: boolean, escalateDelay?: number | undefined): void;
19
- /**
20
- * Tell the server we wish to resume receiving messages. Server will send a
21
- * snapshot of rows currently in cache. This can be used to update with
22
- * latest data, e.g after an edit session during which we might have ignored
23
- * some updates.
24
- */
25
- private sendResumeMessage;
26
- isSessionDataSourceOf(dataSource: DataSource): boolean;
27
- resume(callback?: DataSourceSubscribeCallback): void;
28
- freeze(): void;
29
- unfreeze(): void;
30
- disable(): void;
31
- enable(callback?: DataSourceSubscribeCallback): void;
32
- select(selectRequest: Omit<SelectRequest, "vpId">): Promise<void>;
33
- openTreeNode(keyOrIndex: string | number): void;
34
- closeTreeNode(keyOrIndex: string | number): void;
35
- get columns(): string[];
36
- set columns(columns: string[]);
37
- get tableSchema(): TableSchema | undefined;
38
- set tableSchema(tableSchema: TableSchema | undefined);
39
- get links(): LinkDescriptorWithLabel[] | undefined;
40
- get maxRangeEnd(): number;
41
- get menu(): VuuMenu | undefined;
42
- get status(): DataSourceStatus;
43
- get optimize(): OptimizeStrategy;
44
- set optimize(optimize: OptimizeStrategy);
45
- private revertDebounce;
46
- get selectedRowsCount(): number;
47
- private rawRangeRequest;
48
- private debounceRangeRequest;
49
- private throttleRangeRequest;
50
- get config(): WithBaseFilter<WithFullConfig>;
51
- set config(config: WithBaseFilter<WithFullConfig>);
52
- set impendingConfig(config: WithBaseFilter<WithFullConfig>);
53
- get groupBy(): VuuGroupBy;
54
- set groupBy(groupBy: VuuGroupBy);
55
- get range(): Range;
56
- set range(range: Range);
57
- get title(): string;
58
- set title(title: string);
59
- get visualLink(): LinkDescriptorWithLabel | undefined;
60
- set visualLink(visualLink: LinkDescriptorWithLabel | undefined);
61
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
62
- createSessionDataSource(copyOption: CopyOption, sessionType?: SessionType, overrides?: SessionDataSourceOverrides): Promise<VuuDataSource | undefined>;
63
- beginEditSession(): Promise<VuuDataSource>;
64
- editCell(key: string, column: string, data: VuuRowDataItemType): Promise<RpcResultError | RpcResultSuccess>;
65
- endEditSession(saveChanges?: boolean, force?: boolean): Promise<void>;
66
- rpcRequest(rpcRequest: Omit<VuuRpcServiceRequest, "context">): Promise<RpcResultError | RpcResultSuccess>;
67
- menuRpcCall(rpcRequest: Omit<VuuRpcMenuRequest, "vpId">): Promise<MenuRpcResponse<any> | undefined>;
68
- insertRow(): Promise<string>;
69
- deleteRow(key: string, mode?: DeleteRowMode): Promise<true | string>;
70
- deleteSelectedRows(mode?: DeleteRowMode): Promise<RpcResultSuccess | RpcResultError>;
71
- addRow(rowData?: Record<string, VuuRowDataItemType>): Promise<RpcResult>;
72
- undoRowChange(key: string): Promise<RpcResultSuccess | RpcResultError>;
73
- }
74
- export {};
@@ -1,54 +0,0 @@
1
- import { WebSocketProtocol } from "@vuu-ui/vuu-data-types";
2
- import { InvalidSessionReason, InvalidTokenReason, LoginErrorMessage, VuuClientMessage, VuuServerMessage } from "@vuu-ui/vuu-protocol-types";
3
- import { EventEmitter } from "@vuu-ui/vuu-utils";
4
- export type ConnectionPhase = "initial-connection" | "post-disconnect-reconnection";
5
- export type ConnectingStatus = "connecting" | "reconnecting";
6
- export type ConnectedStatus = "connected" | "reconnected";
7
- export type ConnectionStatus = ConnectingStatus | ConnectedStatus | "closed" | "websocket-open" | "disconnected" | "failed" | "inactive";
8
- export declare const isInvalidTokenReason: (text: string) => text is InvalidTokenReason;
9
- export declare const isInvalidSessionReason: (text: string) => text is InvalidSessionReason;
10
- export declare const isWebSocketConnectionStatus: (msg: unknown) => msg is ConnectionStatus;
11
- export declare const isConnected: (status: ConnectionStatus) => status is ConnectedStatus;
12
- export type LoginRejectedMessage = {
13
- type: "LOGIN_REJECTED";
14
- reason: LoginErrorMessage;
15
- };
16
- export declare const isLoginRejectedMessage: (message: object) => message is LoginRejectedMessage;
17
- export type VuuServerMessageCallback = (msg: VuuServerMessage | LoginRejectedMessage) => void;
18
- export type WebSocketConnectionConfig = {
19
- url: string;
20
- protocols: WebSocketProtocol;
21
- callback: VuuServerMessageCallback;
22
- connectionTimeout?: number;
23
- };
24
- export type WebSocketConnectionCloseReason = LoginErrorMessage | "failure" | "shutdown";
25
- export type WebSocketConnectionEvents = {
26
- "connection-status": (status: ConnectionStatus) => void;
27
- };
28
- export declare class WebSocketConnection extends EventEmitter<WebSocketConnectionEvents> {
29
- #private;
30
- constructor({ callback, connectionTimeout, protocols, url, }: WebSocketConnectionConfig);
31
- get connectionTimeout(): number;
32
- get protocols(): WebSocketProtocol;
33
- get isClosed(): boolean;
34
- get isDisconnected(): boolean;
35
- get connectionPhase(): ConnectionPhase;
36
- get connectionStatus(): ConnectionStatus;
37
- private set connectionStatus(value);
38
- get confirmedOpen(): boolean;
39
- /**
40
- * We are 'confirmedOpen' when we see the first message transmitted
41
- * from the server. This ensures that even if we have one or more
42
- * proxies in our route to the endPoint, all connections have been
43
- * opened successfully.
44
- * First time in here (on our initial successful connection) we switch
45
- * from 'connect' phase to 'reconnect' phase. We may have different
46
- * retry configurations for these two phases.
47
- */
48
- private set confirmedOpen(value);
49
- get url(): string;
50
- openWebSocket(): Promise<unknown>;
51
- private receive;
52
- send: (msg: VuuClientMessage) => void;
53
- close(reason?: WebSocketConnectionCloseReason): void;
54
- }
@@ -1,15 +0,0 @@
1
- import type { VuuUser } from "@vuu-ui/vuu-protocol-types";
2
- /**
3
- * The auth token returned from authn call encodes (Base64) a VuuUser
4
- * within the first part of the token.
5
- */
6
- export declare const parseVuuUserFromToken: (token: string) => VuuUser;
7
- export type AuthenticationResponse = {
8
- token: string;
9
- user: VuuUser;
10
- };
11
- export declare const getVuuAuthToken: (authUrl: string, token: string) => Promise<{
12
- authorizations: string[];
13
- token: string;
14
- }>;
15
- export declare const authenticate: (username: string, password: string, authUrl?: string) => Promise<AuthenticationResponse>;
@@ -1,41 +0,0 @@
1
- export declare const connectionId: {
2
- readonly nextValue: number;
3
- };
4
- export declare const msgType: {
5
- connect: string;
6
- connectionStatus: string;
7
- getFilterData: string;
8
- rowData: string;
9
- rowSet: string;
10
- select: string;
11
- selectAll: string;
12
- selectNone: string;
13
- selected: string;
14
- snapshot: string;
15
- update: string;
16
- createLink: string;
17
- disable: string;
18
- enable: string;
19
- suspend: string;
20
- resume: string;
21
- addSubscription: string;
22
- closeTreeNode: string;
23
- columnList: string;
24
- data: string;
25
- openTreeNode: string;
26
- aggregate: string;
27
- filter: string;
28
- filterQuery: string;
29
- filterData: string;
30
- getSearchData: string;
31
- groupBy: string;
32
- modifySubscription: string;
33
- searchData: string;
34
- setGroupState: string;
35
- size: string;
36
- sort: string;
37
- subscribed: string;
38
- tableList: string;
39
- unsubscribe: string;
40
- viewRangeChanged: string;
41
- };
@@ -1,6 +0,0 @@
1
- import type { DataSourceCallbackMessage, DataSourceConfig, DataSourceConfigMessage, DataSourceDataSizeMessage, WithRequestId } from "@vuu-ui/vuu-data-types";
2
- import type { SelectSuccessWithRowCount } from "@vuu-ui/vuu-protocol-types";
3
- export declare const isSizeOnly: (message: DataSourceCallbackMessage) => message is DataSourceDataSizeMessage;
4
- export declare const toDataSourceConfig: (message: DataSourceConfigMessage) => DataSourceConfig;
5
- export declare const shouldMessageBeRoutedToDataSource: (message: unknown) => message is Exclude<DataSourceCallbackMessage, WithRequestId<SelectSuccessWithRowCount>>;
6
- export declare const isDataSourceConfigMessage: (message: DataSourceCallbackMessage) => message is DataSourceConfigMessage;
@@ -1,11 +0,0 @@
1
- export { authenticate, getVuuAuthToken, parseVuuUserFromToken, } from "./authenticate";
2
- export * from "./ConnectionManager";
3
- export { default as ConnectionManager } from "./ConnectionManager";
4
- export * from "./constants";
5
- export * from "./data-source";
6
- export { LostConnectionHandler, RetryOptions } from "./LostConnectionHandler";
7
- export * from "./message-utils";
8
- export { VuuAuthenticator, VuuAuthTokenIssuePolicy } from "./VuuAuthenticator";
9
- export { VuuAuthProvider, type AuthProvider } from "./VuuAuthProvider";
10
- export * from "./VuuDataSource";
11
- export { isConnected, type ConnectionStatus } from "./WebSocketConnection";