import { RequestBuilder } from "../request-builder"; import type { RequestOptions } from "../base-client"; /** * User-scoped, workspace-isolated preference storage. * * Stores arbitrary JSONB data keyed by context string. * Preferences are scoped to the authenticated user and current workspace. */ export interface UserPreference { id: string; workspaceId: string; contextKey: string; preferences: Record; createdAt: string; updatedAt: string; } /** Attributes for upserting a user preference. */ export interface UpsertPreferenceAttributes { /** Scoping key (e.g., "health-metrics:client_abc123") */ context_key: string; /** Arbitrary preference data — full replacement on upsert */ preferences: Record; } /** * Creates the preferences namespace with SDK methods. * * @example * ```typescript * // Save chart preferences * await sdk.preferences.upsert("health-metrics:abc", { chartOrder: ["weight", "hba1c"] }); * * // Retrieve preferences * const prefs = await sdk.preferences.get("health-metrics:abc"); * * // List all with prefix * const all = await sdk.preferences.list({ prefix: "health-metrics:" }); * * // Delete * await sdk.preferences.delete("health-metrics:abc"); * ``` */ export declare function createPreferencesNamespace(rb: RequestBuilder): { /** * Get preference data by context key. * * @param contextKey - The context key to look up * @returns The preferences JSONB object, or null if not found * * @example * ```typescript * const prefs = await sdk.preferences.get("health-metrics:client123"); * if (prefs) { * console.log(prefs.chartOrder); * } * ``` */ get(contextKey: string, options?: RequestOptions): Promise | null>; /** * Create or replace a user preference. * * @param contextKey - The context key * @param data - Arbitrary preference data (full replacement) * @returns The full UserPreference record * * @example * ```typescript * const pref = await sdk.preferences.upsert("ui:sidebar", { collapsed: true }); * ``` */ upsert(contextKey: string, data: Record, options?: RequestOptions): Promise; /** * Delete a preference by context key. * * Single-request delete via the `destroy_by_key` action. * * @param contextKey - The context key to delete * * @example * ```typescript * await sdk.preferences.delete("health-metrics:client123"); * ``` */ delete(contextKey: string, options?: RequestOptions): Promise; /** * List all preferences for the current user in the current workspace. * * @param opts - Optional filter options * @param opts.prefix - Filter context keys starting with this prefix * @returns Array of UserPreference records * * @example * ```typescript * const all = await sdk.preferences.list(); * const healthOnly = await sdk.preferences.list({ prefix: "health-metrics:" }); * ``` */ list(opts?: { prefix?: string; }, options?: RequestOptions): Promise; }; export type PreferencesAPI = ReturnType; //# sourceMappingURL=preferences.d.ts.map