Fixes to index APIs

pull/1220/head
Zef Hemel 2025-01-17 18:31:17 +01:00
parent ae20b81126
commit 0076208658
1 changed files with 34 additions and 14 deletions

View File

@ -10,40 +10,60 @@ import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts";
export function indexSyscalls(system: System<any>): SysCallMapping { export function indexSyscalls(system: System<any>): SysCallMapping {
return { return {
"index.indexObjects": (_ctx, page: string, objects: ObjectValue<any>[]) => { "index.indexObjects": (ctx, page: string, objects: ObjectValue<any>[]) => {
return system.invokeFunction("index.indexObjects", [page, objects]); return system.syscall(ctx, "system.invokeFunction", [
"index.indexObjects",
page,
objects,
]);
}, },
"index.queryObjects": ( "index.queryObjects": (
_ctx, ctx,
tag: string, tag: string,
query: ObjectQuery, query: ObjectQuery,
ttlSecs?: number, ttlSecs?: number,
) => { ) => {
return system.invokeFunction("index.queryObjects", [ return system.syscall(ctx, "system.invokeFunction", [
"index.queryObjects",
tag, tag,
query, query,
ttlSecs, ttlSecs,
]); ]);
}, },
"index.queryLuaObjects": ( "index.queryLuaObjects": (
_ctx, ctx,
tag: string, tag: string,
query: LuaCollectionQuery, query: LuaCollectionQuery,
scopedVariables?: Record<string, any>, scopedVariables?: Record<string, any>,
) => { ) => {
return system.invokeFunction( return system.syscall(ctx, "system.invokeFunction", [
"index.queryLuaObjects", "index.queryLuaObjects",
[tag, query, scopedVariables], tag,
); query,
scopedVariables,
]);
}, },
"index.queryDeleteObjects": (_ctx, tag: string, query: ObjectQuery) => { "index.queryDeleteObjects": (ctx, tag: string, query: ObjectQuery) => {
return system.invokeFunction("index.queryDeleteObjects", [tag, query]); return system.syscall(ctx, "system.invokeFunction", [
"index.queryDeleteObjects",
tag,
query,
]);
}, },
"index.query": (_ctx, query: KvQuery, variables?: Record<string, any>) => { "index.query": (ctx, query: KvQuery, variables?: Record<string, any>) => {
return system.invokeFunction("index.query", [query, variables]); return system.syscall(ctx, "system.invokeFunction", [
"index.query",
query,
variables,
]);
}, },
"index.getObjectByRef": (_ctx, page: string, tag: string, ref: string) => { "index.getObjectByRef": (ctx, page: string, tag: string, ref: string) => {
return system.invokeFunction("index.getObjectByRef", [page, tag, ref]); return system.syscall(ctx, "system.invokeFunction", [
"index.getObjectByRef",
page,
tag,
ref,
]);
}, },
}; };
} }