From 007620865894026fc08c0b1c3f8378f654a9148d Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 17 Jan 2025 18:31:17 +0100 Subject: [PATCH] Fixes to index APIs --- common/syscalls/index.ts | 48 ++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/common/syscalls/index.ts b/common/syscalls/index.ts index d77946e2..4c97e1d1 100644 --- a/common/syscalls/index.ts +++ b/common/syscalls/index.ts @@ -10,40 +10,60 @@ import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts"; export function indexSyscalls(system: System): SysCallMapping { return { - "index.indexObjects": (_ctx, page: string, objects: ObjectValue[]) => { - return system.invokeFunction("index.indexObjects", [page, objects]); + "index.indexObjects": (ctx, page: string, objects: ObjectValue[]) => { + return system.syscall(ctx, "system.invokeFunction", [ + "index.indexObjects", + page, + objects, + ]); }, "index.queryObjects": ( - _ctx, + ctx, tag: string, query: ObjectQuery, ttlSecs?: number, ) => { - return system.invokeFunction("index.queryObjects", [ + return system.syscall(ctx, "system.invokeFunction", [ + "index.queryObjects", tag, query, ttlSecs, ]); }, "index.queryLuaObjects": ( - _ctx, + ctx, tag: string, query: LuaCollectionQuery, scopedVariables?: Record, ) => { - return system.invokeFunction( + return system.syscall(ctx, "system.invokeFunction", [ "index.queryLuaObjects", - [tag, query, scopedVariables], - ); + tag, + query, + scopedVariables, + ]); }, - "index.queryDeleteObjects": (_ctx, tag: string, query: ObjectQuery) => { - return system.invokeFunction("index.queryDeleteObjects", [tag, query]); + "index.queryDeleteObjects": (ctx, tag: string, query: ObjectQuery) => { + return system.syscall(ctx, "system.invokeFunction", [ + "index.queryDeleteObjects", + tag, + query, + ]); }, - "index.query": (_ctx, query: KvQuery, variables?: Record) => { - return system.invokeFunction("index.query", [query, variables]); + "index.query": (ctx, query: KvQuery, variables?: Record) => { + return system.syscall(ctx, "system.invokeFunction", [ + "index.query", + query, + variables, + ]); }, - "index.getObjectByRef": (_ctx, page: string, tag: string, ref: string) => { - return system.invokeFunction("index.getObjectByRef", [page, tag, ref]); + "index.getObjectByRef": (ctx, page: string, tag: string, ref: string) => { + return system.syscall(ctx, "system.invokeFunction", [ + "index.getObjectByRef", + page, + tag, + ref, + ]); }, }; }