import { syscall } from "../syscall.ts"; /** * Gets a config value by path, with support for dot notation. * @param path The path to get the value from * @param defaultValue The default value to return if the path doesn't exist * @returns The value at the path, or the default value */ export function get(path: string | string[], defaultValue: T): Promise { return syscall("config.get", path, defaultValue); } /** * Sets a config value by path, with support for dot notation. * @param path The path to set the value at * @param value The value to set */ export function set(path: string, value: T): Promise; /** * Sets multiple config values at once. * @param values An object containing key-value pairs to set */ export function set(values: Record): Promise; export function set( pathOrValues: string | Record, value?: T, ): Promise { return syscall("config.set", pathOrValues, value); } /** * Inserts a config value into an array */ export function insert(path: string | string[], value: T): Promise { return syscall("config.insert", path, value); } /** * Checks if a config path exists. * @param path The path to check * @returns True if the path exists, false otherwise */ export function has(path: string): Promise { return syscall("config.has", path); } /** * Defines a JSON schema for a configuration key. * The schema will be used to validate values when setting this key. * @param key The configuration key to define a schema for * @param schema The JSON schema to validate against */ export function define(key: string, schema: any): Promise { return syscall("config.define", key, schema); } /** * Defines (or updates) a UI category for the configuration manager. Categories * are referenced by name from a schema field's `ui.category` and are sorted in * ascending `order` (default 0); unknown categories fall to the bottom in * alphabetical order. */ export function defineCategory(definition: { name: string; description?: string; order?: number; }): Promise { return syscall("config.defineCategory", definition); } /** * Gets all config values as a single object. * @returns The entire config values object */ export function getValues(): Promise> { return syscall("config.getValues"); } /** * Gets all defined config schemas. * @returns The schema definitions object */ export function getSchemas(): Promise> { return syscall("config.getSchemas"); } /** * Gets all registered UI categories for the configuration manager. */ export function getCategories(): Promise< Record > { return syscall("config.getCategories"); }