silverbullet/common/spaces/space_primitives.ts

22 lines
674 B
TypeScript
Raw Normal View History

import type { FileMeta } from "../types.ts";
// export type FileEncoding = "utf8" | "arraybuffer" | "dataurl";
// export type FileData = ArrayBuffer | string;
2022-04-07 21:21:30 +08:00
export interface SpacePrimitives {
2023-01-13 22:41:29 +08:00
// Returns a list of file meta data as well as the timestamp of this snapshot
2022-09-12 20:50:37 +08:00
fetchFileList(): Promise<FileMeta[]>;
readFile(
2022-04-07 21:21:30 +08:00
name: string,
): Promise<{ data: Uint8Array; meta: FileMeta }>;
2022-09-12 20:50:37 +08:00
getFileMeta(name: string): Promise<FileMeta>;
writeFile(
name: string,
data: Uint8Array,
2023-01-13 22:41:29 +08:00
// Used to decide whether or not to emit change events
2022-10-12 17:47:13 +08:00
selfUpdate?: boolean,
meta?: FileMeta,
2022-09-12 20:50:37 +08:00
): Promise<FileMeta>;
deleteFile(name: string): Promise<void>;
2022-04-07 21:21:30 +08:00
}