2023-12-13 16:52:56 +00:00
|
|
|
import type { FileMeta } from "$sb/types.ts";
|
2023-08-20 15:51:00 +00:00
|
|
|
|
2023-12-13 16:52:56 +00:00
|
|
|
/**
|
|
|
|
* A generic interface used by `Space` to interact with the underlying storage, designed to be easy to implement for different storage backends
|
|
|
|
*/
|
2022-04-07 13:21:30 +00:00
|
|
|
export interface SpacePrimitives {
|
2022-09-12 12:50:37 +00:00
|
|
|
fetchFileList(): Promise<FileMeta[]>;
|
2023-12-13 16:52:56 +00:00
|
|
|
|
|
|
|
// The result of this should be consistent with the result of fetchFileList for this entry
|
|
|
|
getFileMeta(name: string): Promise<FileMeta>;
|
|
|
|
|
2022-09-12 12:50:37 +00:00
|
|
|
readFile(
|
2022-04-07 13:21:30 +00:00
|
|
|
name: string,
|
2023-05-23 18:53:53 +00:00
|
|
|
): Promise<{ data: Uint8Array; meta: FileMeta }>;
|
2023-12-13 16:52:56 +00:00
|
|
|
|
2022-09-12 12:50:37 +00:00
|
|
|
writeFile(
|
2022-09-05 09:47:30 +00:00
|
|
|
name: string,
|
2023-05-23 18:53:53 +00:00
|
|
|
data: Uint8Array,
|
2023-01-13 14:41:29 +00:00
|
|
|
// Used to decide whether or not to emit change events
|
2022-10-12 09:47:13 +00:00
|
|
|
selfUpdate?: boolean,
|
2023-12-13 16:52:56 +00:00
|
|
|
// May be ignored, but ideally should be used to set the lastModified time
|
2023-07-02 09:25:32 +00:00
|
|
|
meta?: FileMeta,
|
2022-09-12 12:50:37 +00:00
|
|
|
): Promise<FileMeta>;
|
2023-12-13 16:52:56 +00:00
|
|
|
|
2022-09-12 12:50:37 +00:00
|
|
|
deleteFile(name: string): Promise<void>;
|
2022-04-07 13:21:30 +00:00
|
|
|
}
|