CRUD syscalls for attachments

This commit is contained in:
Zef Hemel
2022-09-05 13:36:04 +02:00
parent 24be260a34
commit 9415624b93
3 changed files with 80 additions and 7 deletions
+26 -1
View File
@@ -1,4 +1,4 @@
import { PageMeta } from "@silverbulletmd/common/types";
import { AttachmentMeta, PageMeta } from "@silverbulletmd/common/types";
import { SysCallMapping } from "@plugos/plugos/system";
import { Space } from "@silverbulletmd/common/spaces/space";
@@ -26,5 +26,30 @@ export default (space: Space): SysCallMapping => {
"space.deletePage": async (ctx, name: string) => {
return space.deletePage(name);
},
"space.listAttachments": async (ctx): Promise<AttachmentMeta[]> => {
return [...(await space.fetchAttachmentList()).attachments];
},
"space.readAttachment": async (
ctx,
name: string
): Promise<{ buffer: ArrayBuffer; meta: AttachmentMeta }> => {
return await space.readAttachment(name);
},
"space.getAttachmentMeta": async (
ctx,
name: string
): Promise<AttachmentMeta> => {
return await space.getAttachmentMeta(name);
},
"space.writeAttachment": async (
ctx,
name: string,
buffer: ArrayBuffer
): Promise<AttachmentMeta> => {
return await space.writeAttachment(name, buffer);
},
"space.deleteAttachment": async (ctx, name: string) => {
await space.deleteAttachment(name);
},
};
};