2024-08-07 02:11:38 +08:00
|
|
|
import { system } from "@silverbulletmd/silverbullet/syscalls";
|
2024-08-24 18:35:09 +08:00
|
|
|
import type { QueryProviderEvent } from "@silverbulletmd/silverbullet/types";
|
2024-08-07 02:11:38 +08:00
|
|
|
import { applyQuery } from "@silverbulletmd/silverbullet/lib/query";
|
2024-02-09 04:00:45 +08:00
|
|
|
import { builtinFunctions } from "$lib/builtin_query_functions.ts";
|
2023-10-03 20:16:33 +08:00
|
|
|
|
2024-02-06 23:51:04 +08:00
|
|
|
export async function syscallSourceProvider({
|
|
|
|
query,
|
|
|
|
variables,
|
|
|
|
}: QueryProviderEvent): Promise<any[]> {
|
|
|
|
const syscalls = await system.listSyscalls();
|
|
|
|
return applyQuery(
|
|
|
|
{ ...query, distinct: true },
|
|
|
|
syscalls,
|
|
|
|
variables || {},
|
|
|
|
builtinFunctions,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function commandSourceProvider({
|
|
|
|
query,
|
|
|
|
variables,
|
|
|
|
}: QueryProviderEvent): Promise<any[]> {
|
|
|
|
const commands = await system.listCommands();
|
|
|
|
return applyQuery(
|
|
|
|
{ ...query, distinct: true },
|
|
|
|
Object.values(commands),
|
|
|
|
variables || {},
|
|
|
|
builtinFunctions,
|
|
|
|
);
|
|
|
|
}
|