2022-10-10 12:50:21 +00:00
|
|
|
import { SysCallMapping } from "../../plugos/system.ts";
|
2023-10-03 12:16:33 +00:00
|
|
|
import { DataStore } from "../../plugos/lib/datastore.ts";
|
|
|
|
import { KvKey } from "$sb/types.ts";
|
2022-04-04 13:25:07 +00:00
|
|
|
|
2023-05-23 18:53:53 +00:00
|
|
|
export function clientStoreSyscalls(
|
2023-10-03 12:16:33 +00:00
|
|
|
ds: DataStore,
|
|
|
|
prefix: KvKey = ["client"],
|
2023-05-23 18:53:53 +00:00
|
|
|
): SysCallMapping {
|
2023-10-03 12:16:33 +00:00
|
|
|
return {
|
|
|
|
"clientStore.get": (ctx, key: string): Promise<any> => {
|
|
|
|
return ds.get([...prefix, ctx.plug!.name!, key]);
|
2022-10-10 12:50:21 +00:00
|
|
|
},
|
2023-10-03 12:16:33 +00:00
|
|
|
"clientStore.set": (ctx, key: string, val: any): Promise<void> => {
|
|
|
|
return ds.set([...prefix, ctx.plug!.name!, key], val);
|
|
|
|
},
|
|
|
|
"clientStore.delete": (ctx, key: string): Promise<void> => {
|
|
|
|
return ds.delete([...prefix, ctx.plug!.name!, key]);
|
|
|
|
},
|
|
|
|
};
|
2022-04-04 13:25:07 +00:00
|
|
|
}
|