Major backend refactor (#599)

Backend refactor
This commit is contained in:
Zef Hemel
2023-12-13 17:52:56 +01:00
committed by GitHub
parent 60d7cc704a
commit 9f082c83a9
42 changed files with 959 additions and 503 deletions
+11 -6
View File
@@ -1,21 +1,26 @@
// export type FileEncoding = "utf8" | "arraybuffer" | "dataurl";
// export type FileData = ArrayBuffer | string;
import { FileMeta } from "$sb/types.ts";
import type { FileMeta } from "$sb/types.ts";
/**
* A generic interface used by `Space` to interact with the underlying storage, designed to be easy to implement for different storage backends
*/
export interface SpacePrimitives {
// Returns a list of file meta data as well as the timestamp of this snapshot
fetchFileList(): Promise<FileMeta[]>;
// The result of this should be consistent with the result of fetchFileList for this entry
getFileMeta(name: string): Promise<FileMeta>;
readFile(
name: string,
): Promise<{ data: Uint8Array; meta: FileMeta }>;
getFileMeta(name: string): Promise<FileMeta>;
writeFile(
name: string,
data: Uint8Array,
// Used to decide whether or not to emit change events
selfUpdate?: boolean,
// May be ignored, but ideally should be used to set the lastModified time
meta?: FileMeta,
): Promise<FileMeta>;
deleteFile(name: string): Promise<void>;
}