AFFiNE/packages/storage/index.d.ts

53 lines
1.5 KiB
TypeScript

/* auto-generated by NAPI-RS */
/* eslint-disable */
export class Doc {
get guid(): string;
}
export class Storage {
/** Create a storage instance and establish connection to persist store. */
static connect(
database: string,
debugOnlyAutoMigrate?: boolean | undefined | null
): Promise<Storage>;
/** Get a workspace by id */
getWorkspace(workspaceId: string): Promise<Workspace | null>;
/** Create a new workspace with a init update. */
createWorkspace(workspaceId: string, init: Buffer): Promise<Workspace>;
/** Delete a workspace. */
deleteWorkspace(workspaceId: string): Promise<void>;
/** Sync doc updates. */
sync(workspaceId: string, guid: string, update: Buffer): Promise<void>;
/** Sync doc update with doc guid encoded. */
syncWithGuid(workspaceId: string, update: Buffer): Promise<void>;
/** Load doc as update buffer. */
load(guid: string): Promise<Buffer | null>;
/** Fetch a workspace blob. */
blob(workspaceId: string, name: string): Promise<Blob | null>;
/** Upload a blob into workspace storage. */
uploadBlob(workspaceId: string, blob: Buffer): Promise<string>;
/** Workspace size taken by blobs. */
blobsSize(workspaceId: string): Promise<number>;
}
export class Workspace {
get doc(): Doc;
isEmpty(): boolean;
get id(): string;
get clientId(): string;
search(query: string): Array<SearchResult>;
}
export interface Blob {
contentType: string;
lastModified: string;
size: number;
data: Buffer;
}
export interface SearchResult {
blockId: string;
score: number;
}