1
0
silverbullet/server/syscalls/space.ts

28 lines
736 B
TypeScript
Raw Normal View History

2022-04-05 15:02:17 +00:00
import { PageMeta } from "../../common/types";
import { SysCallMapping } from "../../plugos/system";
import { Storage } from "../disk_storage";
2022-03-28 13:25:05 +00:00
export default (storage: Storage): SysCallMapping => {
2022-03-28 13:25:05 +00:00
return {
"space.listPages": (ctx): Promise<PageMeta[]> => {
return storage.listPages();
2022-03-28 13:25:05 +00:00
},
"space.readPage": async (
2022-03-28 13:25:05 +00:00
ctx,
name: string
): Promise<{ text: string; meta: PageMeta }> => {
return storage.readPage(name);
2022-03-28 13:25:05 +00:00
},
"space.writePage": async (
ctx,
name: string,
text: string
): Promise<PageMeta> => {
return storage.writePage(name, text);
2022-03-28 13:25:05 +00:00
},
"space.deletePage": async (ctx, name: string) => {
return storage.deletePage(name);
2022-03-28 13:25:05 +00:00
},
};
};