(core) Converting server-side Comm.js to typescript

Summary:
- Add app/common/CommTypes.ts to define types shared by client and server.
- Include @types/ws npm package

Test Plan: Intended to have no changes in behavior

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3467
This commit is contained in:
Dmitry S
2022-06-04 00:12:30 -04:00
parent 519f1be93a
commit 4f1cb53b29
23 changed files with 655 additions and 716 deletions

View File

@@ -2,31 +2,6 @@ declare module "app/server/lib/ActionLog";
declare module "app/server/lib/sandboxUtil";
declare module "app/server/lib/User";
declare module "app/server/lib/Comm" {
import {Client, ClientMethod} from "app/server/lib/Client";
import {ScopedSession} from "app/server/lib/BrowserSession";
import * as http from "http";
class Comm {
constructor(server: http.Server, options: any);
public broadcastMessage(type: string, messageData: any): void;
public destroyAllClients(): void;
public setServerVersion(serverVersion: string|null): void;
public setServerActivation(active: boolean): void;
public getSessionIdFromCookie(gristSidCookie: string): string;
public getOrCreateSession(sessionId: string, req: any): ScopedSession;
public registerMethods(methods: {[name: string]: ClientMethod}): void;
public getClient(clientId: string): Client;
public testServerShutdown(): Promise<void>;
public testServerRestart(): Promise<void>;
public testSetClientPersistence(ttlMs: number): void;
}
namespace Comm {
function sendDocMessage(client: Client, docFD: number, type: string, mesageData: any, fromSelf: boolean): void;
}
export = Comm;
}
declare module "app/server/lib/shutdown" {
export function addCleanupHandler<T>(context: T, method: (this: T) => void, timeout?: number, name?: string): void;
export function removeCleanupHandlers<T>(context: T): void;
@@ -91,9 +66,6 @@ declare module "app-module-path" {
export function addPath(path: string): void;
}
// Used in tests
declare module "ws";
// version of pidusage that has correct ctime on linux
declare module '@gristlabs/pidusage' {
import * as pidusage from 'pidusage';