diff --git a/frontend/history-ui/src/lib/types/ClientCursors.ts b/frontend/history-ui/src/lib/types/ClientCursors.ts new file mode 100644 index 00000000..bb629100 --- /dev/null +++ b/frontend/history-ui/src/lib/types/ClientCursors.ts @@ -0,0 +1,4 @@ +// 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"; + +export type ClientCursors = { userName: string, deviceId: string, documentsWithCursors: Array, }; diff --git a/frontend/history-ui/src/lib/types/CreateDocumentVersion.ts b/frontend/history-ui/src/lib/types/CreateDocumentVersion.ts new file mode 100644 index 00000000..86ba60f3 --- /dev/null +++ b/frontend/history-ui/src/lib/types/CreateDocumentVersion.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type CreateDocumentVersion = { relative_path: string, content: Array, }; diff --git a/frontend/history-ui/src/lib/types/CursorPositionFromClient.ts b/frontend/history-ui/src/lib/types/CursorPositionFromClient.ts new file mode 100644 index 00000000..60b48e5e --- /dev/null +++ b/frontend/history-ui/src/lib/types/CursorPositionFromClient.ts @@ -0,0 +1,4 @@ +// 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"; + +export type CursorPositionFromClient = { documentsWithCursors: Array, }; diff --git a/frontend/history-ui/src/lib/types/CursorPositionFromServer.ts b/frontend/history-ui/src/lib/types/CursorPositionFromServer.ts new file mode 100644 index 00000000..c8444892 --- /dev/null +++ b/frontend/history-ui/src/lib/types/CursorPositionFromServer.ts @@ -0,0 +1,4 @@ +// 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"; + +export type CursorPositionFromServer = { clients: Array, }; diff --git a/frontend/history-ui/src/lib/types/CursorSpan.ts b/frontend/history-ui/src/lib/types/CursorSpan.ts new file mode 100644 index 00000000..d0bce6ea --- /dev/null +++ b/frontend/history-ui/src/lib/types/CursorSpan.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type CursorSpan = { start: number, end: number, }; diff --git a/frontend/history-ui/src/lib/types/DocumentUpdateResponse.ts b/frontend/history-ui/src/lib/types/DocumentUpdateResponse.ts new file mode 100644 index 00000000..418117e6 --- /dev/null +++ b/frontend/history-ui/src/lib/types/DocumentUpdateResponse.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DocumentVersion } from "./DocumentVersion"; +import type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent"; + +/** + * Response to an update document request. + */ +export type DocumentUpdateResponse = { "type": "FastForwardUpdate" } & DocumentVersionWithoutContent | { "type": "MergingUpdate" } & DocumentVersion; diff --git a/frontend/history-ui/src/lib/types/DocumentVersion.ts b/frontend/history-ui/src/lib/types/DocumentVersion.ts new file mode 100644 index 00000000..37bd32ca --- /dev/null +++ b/frontend/history-ui/src/lib/types/DocumentVersion.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type DocumentVersion = { vaultUpdateId: number, documentId: string, relativePath: string, updatedDate: string, contentBase64: string, isDeleted: boolean, userId: string, deviceId: string, }; diff --git a/frontend/history-ui/src/lib/types/DocumentVersionWithoutContent.ts b/frontend/history-ui/src/lib/types/DocumentVersionWithoutContent.ts new file mode 100644 index 00000000..03be2f63 --- /dev/null +++ b/frontend/history-ui/src/lib/types/DocumentVersionWithoutContent.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type DocumentVersionWithoutContent = { vaultUpdateId: number, documentId: string, relativePath: string, updatedDate: string, isDeleted: boolean, userId: string, deviceId: string, contentSize: number, }; diff --git a/frontend/history-ui/src/lib/types/DocumentWithCursors.ts b/frontend/history-ui/src/lib/types/DocumentWithCursors.ts new file mode 100644 index 00000000..38857a35 --- /dev/null +++ b/frontend/history-ui/src/lib/types/DocumentWithCursors.ts @@ -0,0 +1,4 @@ +// 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"; + +export type DocumentWithCursors = { vault_update_id: number | null, document_id: string, relative_path: string, cursors: Array, }; diff --git a/frontend/history-ui/src/lib/types/FetchLatestDocumentsResponse.ts b/frontend/history-ui/src/lib/types/FetchLatestDocumentsResponse.ts new file mode 100644 index 00000000..ce572684 --- /dev/null +++ b/frontend/history-ui/src/lib/types/FetchLatestDocumentsResponse.ts @@ -0,0 +1,11 @@ +// 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"; + +/** + * Response to a fetch latest documents request. + */ +export type FetchLatestDocumentsResponse = { latestDocuments: Array, +/** + * The update ID of the latest document in the response. + */ +lastUpdateId: bigint, }; diff --git a/frontend/history-ui/src/lib/types/PingResponse.ts b/frontend/history-ui/src/lib/types/PingResponse.ts new file mode 100644 index 00000000..c38845d2 --- /dev/null +++ b/frontend/history-ui/src/lib/types/PingResponse.ts @@ -0,0 +1,24 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Response to a ping request. + */ +export type PingResponse = { +/** + * Semantic version of the server. + */ +serverVersion: string, +/** + * Whether the client is authenticated based on the sent Authorization + * header. + */ +isAuthenticated: boolean, +/** + * List of file extensions that are allowed to be merged. + */ +mergeableFileExtensions: Array, +/** + * API version ensuring backwards & forwards compatibility between the client + * and server. + */ +supportedApiVersion: number, }; diff --git a/frontend/history-ui/src/lib/types/SerializedError.ts b/frontend/history-ui/src/lib/types/SerializedError.ts new file mode 100644 index 00000000..5e3fa9b9 --- /dev/null +++ b/frontend/history-ui/src/lib/types/SerializedError.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SerializedError = { errorType: string, message: string, causes: Array, }; diff --git a/frontend/history-ui/src/lib/types/UpdateTextDocumentVersion.ts b/frontend/history-ui/src/lib/types/UpdateTextDocumentVersion.ts new file mode 100644 index 00000000..458fc2bb --- /dev/null +++ b/frontend/history-ui/src/lib/types/UpdateTextDocumentVersion.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type UpdateTextDocumentVersion = { parentVersionId: number, relativePath: string, content: Array, }; diff --git a/frontend/history-ui/src/lib/types/VaultHistoryResponse.ts b/frontend/history-ui/src/lib/types/VaultHistoryResponse.ts new file mode 100644 index 00000000..ae91b480 --- /dev/null +++ b/frontend/history-ui/src/lib/types/VaultHistoryResponse.ts @@ -0,0 +1,7 @@ +// 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"; + +/** + * Response to a vault history request (paginated). + */ +export type VaultHistoryResponse = { versions: Array, hasMore: boolean, }; diff --git a/frontend/history-ui/src/lib/types/WebSocketClientMessage.ts b/frontend/history-ui/src/lib/types/WebSocketClientMessage.ts new file mode 100644 index 00000000..5765a0d0 --- /dev/null +++ b/frontend/history-ui/src/lib/types/WebSocketClientMessage.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CursorPositionFromClient } from "./CursorPositionFromClient"; +import type { WebSocketHandshake } from "./WebSocketHandshake"; + +export type WebSocketClientMessage = { "type": "handshake" } & WebSocketHandshake | { "type": "cursorPositions" } & CursorPositionFromClient; diff --git a/frontend/history-ui/src/lib/types/WebSocketHandshake.ts b/frontend/history-ui/src/lib/types/WebSocketHandshake.ts new file mode 100644 index 00000000..85c2cf0d --- /dev/null +++ b/frontend/history-ui/src/lib/types/WebSocketHandshake.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type WebSocketHandshake = { token: string, deviceId: string, lastSeenVaultUpdateId: number | null, }; diff --git a/frontend/history-ui/src/lib/types/WebSocketServerMessage.ts b/frontend/history-ui/src/lib/types/WebSocketServerMessage.ts new file mode 100644 index 00000000..45e37358 --- /dev/null +++ b/frontend/history-ui/src/lib/types/WebSocketServerMessage.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CursorPositionFromServer } from "./CursorPositionFromServer"; +import type { WebSocketVaultUpdate } from "./WebSocketVaultUpdate"; + +export type WebSocketServerMessage = { "type": "vaultUpdate" } & WebSocketVaultUpdate | { "type": "cursorPositions" } & CursorPositionFromServer; diff --git a/frontend/history-ui/src/lib/types/WebSocketVaultUpdate.ts b/frontend/history-ui/src/lib/types/WebSocketVaultUpdate.ts new file mode 100644 index 00000000..b627ac3c --- /dev/null +++ b/frontend/history-ui/src/lib/types/WebSocketVaultUpdate.ts @@ -0,0 +1,4 @@ +// 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"; + +export type WebSocketVaultUpdate = { documents: Array, isInitialSync: boolean, }; diff --git a/frontend/history-ui/src/lib/types/index.ts b/frontend/history-ui/src/lib/types/index.ts new file mode 100644 index 00000000..6377ebda --- /dev/null +++ b/frontend/history-ui/src/lib/types/index.ts @@ -0,0 +1,26 @@ +export type { DocumentVersion } from "./DocumentVersion"; +export type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent"; +export type { FetchLatestDocumentsResponse } from "./FetchLatestDocumentsResponse"; +export type { PingResponse } from "./PingResponse"; +export type { VaultHistoryResponse } from "./VaultHistoryResponse"; + +export type ActionType = + | "created" + | "updated" + | "renamed" + | "deleted" + | "restored"; + +export interface VersionEvent extends DocumentVersionWithoutContent { + action: ActionType; + previousPath?: string; +} + +export interface TreeNode { + name: string; + path: string; + isFolder: boolean; + children: TreeNode[]; + document?: DocumentVersionWithoutContent; + isDeleted?: boolean; +} diff --git a/scripts/update-api-types.sh b/scripts/update-api-types.sh index 36ca100d..1f10944c 100755 --- a/scripts/update-api-types.sh +++ b/scripts/update-api-types.sh @@ -9,6 +9,7 @@ cargo test export_bindings cd - cp -r sync-server/bindings/* frontend/sync-client/src/services/types/ +cp -r sync-server/bindings/* frontend/history-ui/src/lib/types/ cd frontend npm run lint