Ka-Note/ka-note/shared/src/sync.ts

39 lines
840 B
TypeScript

import type { AgendaContext, Topic, HistoryEntry, Rating, ImageBlob, Page, Notebook, PageNotebook } from './types.js';
export interface SyncChanges {
contexts: AgendaContext[];
topics: Topic[];
historyEntries: HistoryEntry[];
ratings: Rating[];
imageBlobs: ImageBlob[];
pages: Page[];
notebooks: Notebook[];
pageNotebooks: PageNotebook[];
}
export interface SyncPushRequest {
changes: SyncChanges;
}
export interface SyncConflict {
entityType: string;
entityId: string;
clientVersion: number;
serverVersion: number;
}
export interface SyncPushResponse {
accepted: number;
conflicts: SyncConflict[];
serverTimestamp: string;
}
export interface SyncPullRequest {
since: string; // ISO timestamp, "" = full pull
}
export interface SyncPullResponse {
changes: SyncChanges;
serverTimestamp: string;
}