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