Update types
This commit is contained in:
parent
4493365076
commit
48234de10d
20 changed files with 43 additions and 104 deletions
|
|
@ -1,8 +1,4 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
import type { DocumentWithCursors } from "./DocumentWithCursors";
|
import type { DocumentWithCursors } from "./DocumentWithCursors";
|
||||||
|
|
||||||
export interface ClientCursors {
|
export interface ClientCursors { userName: string, deviceId: string, documentsWithCursors: DocumentWithCursors[], }
|
||||||
userName: string;
|
|
||||||
deviceId: string;
|
|
||||||
documentsWithCursors: DocumentWithCursors[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface CreateDocumentVersion {
|
export interface CreateDocumentVersion { relative_path: string, content: number[], }
|
||||||
relative_path: string;
|
|
||||||
content: number[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
import type { DocumentWithCursors } from "./DocumentWithCursors";
|
import type { DocumentWithCursors } from "./DocumentWithCursors";
|
||||||
|
|
||||||
export interface CursorPositionFromClient {
|
export interface CursorPositionFromClient { documentsWithCursors: DocumentWithCursors[], }
|
||||||
documentsWithCursors: DocumentWithCursors[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
import type { ClientCursors } from "./ClientCursors";
|
import type { ClientCursors } from "./ClientCursors";
|
||||||
|
|
||||||
export interface CursorPositionFromServer {
|
export interface CursorPositionFromServer { clients: ClientCursors[], }
|
||||||
clients: ClientCursors[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface CursorSpan {
|
export interface CursorSpan { start: number, end: number, }
|
||||||
start: number;
|
|
||||||
end: number;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,4 @@ import type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutCont
|
||||||
/**
|
/**
|
||||||
* Response to an update document request.
|
* Response to an update document request.
|
||||||
*/
|
*/
|
||||||
export type DocumentUpdateResponse =
|
export type DocumentUpdateResponse = { "type": "FastForwardUpdate" } & DocumentVersionWithoutContent | { "type": "MergingUpdate" } & DocumentVersion;
|
||||||
| ({ type: "FastForwardUpdate" } & DocumentVersionWithoutContent)
|
|
||||||
| ({ type: "MergingUpdate" } & DocumentVersion);
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface DocumentVersion {
|
export interface DocumentVersion { vaultUpdateId: number, documentId: string, relativePath: string, updatedDate: string, contentBase64: string, isDeleted: boolean, userId: string, deviceId: string, }
|
||||||
vaultUpdateId: number;
|
|
||||||
documentId: string;
|
|
||||||
relativePath: string;
|
|
||||||
updatedDate: string;
|
|
||||||
contentBase64: string;
|
|
||||||
isDeleted: boolean;
|
|
||||||
userId: string;
|
|
||||||
deviceId: string;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface DocumentVersionWithoutContent {
|
export interface DocumentVersionWithoutContent { vaultUpdateId: number, documentId: string, relativePath: string, updatedDate: string, isDeleted: boolean, userId: string, deviceId: string, contentSize: number, }
|
||||||
vaultUpdateId: number;
|
|
||||||
documentId: string;
|
|
||||||
relativePath: string;
|
|
||||||
updatedDate: string;
|
|
||||||
isDeleted: boolean;
|
|
||||||
userId: string;
|
|
||||||
deviceId: string;
|
|
||||||
contentSize: number;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
import type { CursorSpan } from "./CursorSpan";
|
import type { CursorSpan } from "./CursorSpan";
|
||||||
|
|
||||||
export interface DocumentWithCursors {
|
export interface DocumentWithCursors { vault_update_id: number | null, document_id: string, relative_path: string, cursors: CursorSpan[], }
|
||||||
vault_update_id: number | null;
|
|
||||||
document_id: string;
|
|
||||||
relative_path: string;
|
|
||||||
cursors: CursorSpan[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,8 @@ import type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutCont
|
||||||
/**
|
/**
|
||||||
* Response to a fetch latest documents request.
|
* Response to a fetch latest documents request.
|
||||||
*/
|
*/
|
||||||
export interface FetchLatestDocumentsResponse {
|
export interface FetchLatestDocumentsResponse { latestDocuments: DocumentVersionWithoutContent[],
|
||||||
latestDocuments: DocumentVersionWithoutContent[];
|
/**
|
||||||
/**
|
* The update ID of the latest document in the response.
|
||||||
* The update ID of the latest document in the response.
|
*/
|
||||||
*/
|
lastUpdateId: bigint, }
|
||||||
lastUpdateId: bigint;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,22 +4,21 @@
|
||||||
* Response to a ping request.
|
* Response to a ping request.
|
||||||
*/
|
*/
|
||||||
export interface PingResponse {
|
export interface PingResponse {
|
||||||
/**
|
/**
|
||||||
* Semantic version of the server.
|
* Semantic version of the server.
|
||||||
*/
|
*/
|
||||||
serverVersion: string;
|
serverVersion: string,
|
||||||
/**
|
/**
|
||||||
* Whether the client is authenticated based on the sent Authorization
|
* Whether the client is authenticated based on the sent Authorization
|
||||||
* header.
|
* header.
|
||||||
*/
|
*/
|
||||||
isAuthenticated: boolean;
|
isAuthenticated: boolean,
|
||||||
/**
|
/**
|
||||||
* List of file extensions that are allowed to be merged.
|
* List of file extensions that are allowed to be merged.
|
||||||
*/
|
*/
|
||||||
mergeableFileExtensions: string[];
|
mergeableFileExtensions: string[],
|
||||||
/**
|
/**
|
||||||
* API version ensuring backwards & forwards compatibility between the client
|
* API version ensuring backwards & forwards compatibility between the client
|
||||||
* and server.
|
* and server.
|
||||||
*/
|
*/
|
||||||
supportedApiVersion: number;
|
supportedApiVersion: number, }
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface SerializedError {
|
export interface SerializedError { errorType: string, message: string, causes: string[], }
|
||||||
errorType: string;
|
|
||||||
message: string;
|
|
||||||
causes: string[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface UpdateTextDocumentVersion {
|
export interface UpdateTextDocumentVersion { parentVersionId: number, relativePath: string, content: (number | string)[], }
|
||||||
parentVersionId: number;
|
|
||||||
relativePath: string;
|
|
||||||
content: (number | string)[];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,4 @@
|
||||||
import type { CursorPositionFromClient } from "./CursorPositionFromClient";
|
import type { CursorPositionFromClient } from "./CursorPositionFromClient";
|
||||||
import type { WebSocketHandshake } from "./WebSocketHandshake";
|
import type { WebSocketHandshake } from "./WebSocketHandshake";
|
||||||
|
|
||||||
export type WebSocketClientMessage =
|
export type WebSocketClientMessage = { "type": "handshake" } & WebSocketHandshake | { "type": "cursorPositions" } & CursorPositionFromClient;
|
||||||
| ({ type: "handshake" } & WebSocketHandshake)
|
|
||||||
| ({ type: "cursorPositions" } & CursorPositionFromClient);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export interface WebSocketHandshake {
|
export interface WebSocketHandshake { token: string, deviceId: string, lastSeenVaultUpdateId: number | null, }
|
||||||
token: string;
|
|
||||||
deviceId: string;
|
|
||||||
lastSeenVaultUpdateId: number | null;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,4 @@
|
||||||
import type { CursorPositionFromServer } from "./CursorPositionFromServer";
|
import type { CursorPositionFromServer } from "./CursorPositionFromServer";
|
||||||
import type { WebSocketVaultUpdate } from "./WebSocketVaultUpdate";
|
import type { WebSocketVaultUpdate } from "./WebSocketVaultUpdate";
|
||||||
|
|
||||||
export type WebSocketServerMessage =
|
export type WebSocketServerMessage = { "type": "vaultUpdate" } & WebSocketVaultUpdate | { "type": "cursorPositions" } & CursorPositionFromServer;
|
||||||
| ({ type: "vaultUpdate" } & WebSocketVaultUpdate)
|
|
||||||
| ({ type: "cursorPositions" } & CursorPositionFromServer);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
import type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent";
|
import type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent";
|
||||||
|
|
||||||
export interface WebSocketVaultUpdate {
|
export interface WebSocketVaultUpdate { documents: DocumentVersionWithoutContent[], isInitialSync: boolean, }
|
||||||
documents: DocumentVersionWithoutContent[];
|
|
||||||
isInitialSync: boolean;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { hash } from "../utils/hash";
|
||||||
import type { FileChangeNotifier } from "./file-change-notifier";
|
import type { FileChangeNotifier } from "./file-change-notifier";
|
||||||
import { Lock } from "../utils/data-structures/locks";
|
import { Lock } from "../utils/data-structures/locks";
|
||||||
import { EventListeners } from "../utils/data-structures/event-listeners";
|
import { EventListeners } from "../utils/data-structures/event-listeners";
|
||||||
import { Logger } from "../tracing/logger";
|
import type { Logger } from "../tracing/logger";
|
||||||
|
|
||||||
// Cursor positions are updated separately from documents. However, a given cursor position is only
|
// Cursor positions are updated separately from documents. However, a given cursor position is only
|
||||||
// valid within a certain version of the document it belongs to. This class tracks previous and the latest
|
// valid within a certain version of the document it belongs to. This class tracks previous and the latest
|
||||||
|
|
|
||||||
|
|
@ -118,10 +118,10 @@ export class Syncer {
|
||||||
public async syncLocallyDeletedFile(
|
public async syncLocallyDeletedFile(
|
||||||
relativePath: RelativePath
|
relativePath: RelativePath
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
let document =
|
const document =
|
||||||
this.database.getLatestDocumentByRelativePath(relativePath);
|
this.database.getLatestDocumentByRelativePath(relativePath);
|
||||||
|
|
||||||
if (document == null || document.isDeleted === true) {
|
if (document == null || document.isDeleted) {
|
||||||
// This is must be a consequence of us deleting a file because of a remote update
|
// This is must be a consequence of us deleting a file because of a remote update
|
||||||
// which triggered a local delete, so we don't need to do anything here.
|
// which triggered a local delete, so we don't need to do anything here.
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export function logToConsole(
|
||||||
): void {
|
): void {
|
||||||
logger.onLogEmitted.add((logLine: LogLine) => {
|
logger.onLogEmitted.add((logLine: LogLine) => {
|
||||||
const timestamp = logLine.timestamp.toISOString();
|
const timestamp = logLine.timestamp.toISOString();
|
||||||
const message = logLine.message;
|
const {message} = logLine;
|
||||||
|
|
||||||
let color = "";
|
let color = "";
|
||||||
let reset = "";
|
let reset = "";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue