import type { Query } from "../plugos-syscall/store.ts"; import { syscall } from "./syscall.ts"; export type KV = { key: string; value: any; }; export function set( page: string, key: string, value: any, ): Promise { return syscall("index.set", page, key, value); } export function batchSet(page: string, kvs: KV[]): Promise { return syscall("index.batchSet", page, kvs); } export function get(page: string, key: string): Promise { return syscall("index.get", page, key); } export function del(page: string, key: string): Promise { return syscall("index.delete", page, key); } export function queryPrefix( prefix: string, ): Promise<{ key: string; page: string; value: any }[]> { return syscall("index.queryPrefix", prefix); } export function query( query: Query, ): Promise<{ key: string; page: string; value: any }[]> { return syscall("index.query", query); } export function clearPageIndexForPage(page: string): Promise { return syscall("index.clearPageIndexForPage", page); } export function deletePrefixForPage( page: string, prefix: string, ): Promise { return syscall("index.deletePrefixForPage", page, prefix); } export function clearPageIndex(): Promise { return syscall("index.clearPageIndex"); }