2022-04-01 15:07:08 +00:00
|
|
|
import { syscall } from "./syscall";
|
2022-09-05 11:36:04 +00:00
|
|
|
import { AttachmentMeta, PageMeta } from "../common/types";
|
2022-04-01 15:07:08 +00:00
|
|
|
|
2022-04-26 17:04:36 +00:00
|
|
|
export async function listPages(unfiltered = false): Promise<PageMeta[]> {
|
|
|
|
return syscall("space.listPages", unfiltered);
|
2022-04-01 15:07:08 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 11:36:04 +00:00
|
|
|
export async function getPageMeta(name: string): Promise<PageMeta> {
|
2022-08-08 11:33:20 +00:00
|
|
|
return syscall("space.getPageMeta", name);
|
|
|
|
}
|
|
|
|
|
2022-04-01 15:07:08 +00:00
|
|
|
export async function readPage(
|
|
|
|
name: string
|
|
|
|
): Promise<{ text: string; meta: PageMeta }> {
|
|
|
|
return syscall("space.readPage", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function writePage(name: string, text: string): Promise<PageMeta> {
|
|
|
|
return syscall("space.writePage", name, text);
|
|
|
|
}
|
|
|
|
|
2022-09-05 11:36:04 +00:00
|
|
|
export async function deletePage(name: string): Promise<void> {
|
2022-04-01 15:07:08 +00:00
|
|
|
return syscall("space.deletePage", name);
|
|
|
|
}
|
2022-09-05 11:36:04 +00:00
|
|
|
|
2022-09-12 12:50:37 +00:00
|
|
|
export async function listPlugs(): Promise<string[]> {
|
|
|
|
return syscall("space.listPlugs");
|
|
|
|
}
|
|
|
|
|
2022-09-05 11:36:04 +00:00
|
|
|
export async function listAttachments(): Promise<PageMeta[]> {
|
|
|
|
return syscall("space.listAttachments");
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getAttachmentMeta(name: string): Promise<AttachmentMeta> {
|
|
|
|
return syscall("space.getAttachmentMeta", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function readAttachment(
|
|
|
|
name: string
|
2022-09-05 14:33:56 +00:00
|
|
|
): Promise<{ data: string; meta: AttachmentMeta }> {
|
2022-09-05 11:36:04 +00:00
|
|
|
return syscall("space.readAttachment", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function writeAttachment(
|
|
|
|
name: string,
|
2022-09-12 12:50:37 +00:00
|
|
|
encoding: "string" | "dataurl",
|
|
|
|
data: string
|
2022-09-05 11:36:04 +00:00
|
|
|
): Promise<AttachmentMeta> {
|
2022-09-12 12:50:37 +00:00
|
|
|
return syscall("space.writeAttachment", name, encoding, data);
|
2022-09-05 11:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function deleteAttachment(name: string): Promise<void> {
|
|
|
|
return syscall("space.deleteAttachment", name);
|
|
|
|
}
|