Files
plainleaf/plug-api/syscalls/index.ts
T
Zef HemelandGitHub dc2987a3f9 Sync engine rearchitecture (#1516)
* Don't require auth for .ping
* Finally introducing loggers
* Remove file list caching from disk_space_primitives
I don't think this is required anymore with the sync model
* Simplification of space primitives and more tests
* More reliable online status
* Add .zed settings
* Remove selfUpdate argument from `writeFile` no longer used
- Add `sync` config schema and document sync options
- Move sync config handling to client boot logic
- Move BootConfig type to ui_types.ts
- Remove sync env vars from server
- Update documentation for sync and architecture
* Improve sync logic and proxy routing for full sync state
* Add BoxProxy for late-bound client and improve Lua boot
- Add isMobile syscall for editor
* Add concurrency to sync process and log indexing duration
* Better service worker lifecycle management
2025-09-12 14:43:57 +02:00

59 lines
1.8 KiB
TypeScript

import type { LuaCollectionQuery } from "../../lib/space_lua/query_collection.ts";
import { syscall } from "@silverbulletmd/silverbullet/syscall";
import type { ObjectValue } from "../../type/index.ts";
/**
* Exposes the SilverBullet object indexing system
* @module
*/
/**
* Indexes objects for a specific page
* @param page - The page identifier where objects will be indexed
* @param objects - Array of objects to be indexed
* @returns Promise that resolves when indexing is complete
*/
export function indexObjects<T>(
page: string,
objects: ObjectValue<T>[],
): Promise<void> {
return syscall("index.indexObjects", page, objects);
}
/**
* Queries objects using a Lua-based collection query
* @param tag - The tag to filter objects by
* @param query - Lua query parameters to filter objects
* @param scopedVariables - Optional variables to be used in the Lua query
* @returns Promise that resolves with an array of matching objects
*/
export function queryLuaObjects<T>(
tag: string,
query: LuaCollectionQuery,
scopedVariables?: Record<string, any>,
): Promise<ObjectValue<T>[]> {
return syscall("index.queryLuaObjects", tag, query, scopedVariables);
}
/**
* Retrieves a specific object by its reference
* @param page - The page identifier where the object is located
* @param tag - The tag of the object
* @param ref - The reference identifier of the object
* @returns Promise that resolves with the matching object or undefined if not found
*/
export function getObjectByRef<T>(
page: string,
tag: string,
ref: string,
): Promise<ObjectValue<T> | undefined> {
return syscall("index.getObjectByRef", page, tag, ref);
}
/**
* Ensures that the full index is built and up-to-date
*/
export function ensureFullIndex(): Promise<void> {
return syscall("index.ensureFullIndex");
}