import { n as ServiceHandle, t as ServiceClientOptions } from "../service-rpc-BugpSF7V.mjs"; import { a as FileSystemType, c as StorageEntryInfo, d as StorageValueType, i as FileSystemInfo, l as StorageKeyValueMap, n as FileInfo, o as KvNameResult, r as FileSystemCapacity, s as MediumType, t as FileEntry, u as StorageValue } from "../storage-types-D8S9NX-i.mjs"; //#region src/storage/storage-client.d.ts /** Registered name (`helper::Storage::get_name()`). */ declare const STORAGE_SERVICE_NAME = "Storage"; /** Default namespace when omitted on the device (`helper::Storage::DEFAULT_NAMESPACE`). */ declare const STORAGE_DEFAULT_NAMESPACE = "storage"; /** RPC function names (`helper::Storage::FunctionId`). */ declare const STORAGE_FUNCTIONS: { readonly KVList: "KVList"; readonly KVSet: "KVSet"; readonly KVGet: "KVGet"; readonly KVErase: "KVErase"; readonly GetFileSystems: "GetFileSystems"; readonly GetFileSystemCapacity: "GetFileSystemCapacity"; readonly FSStat: "FSStat"; readonly FSList: "FSList"; readonly FSMkdir: "FSMkdir"; readonly FSReadText: "FSReadText"; readonly FSWriteText: "FSWriteText"; readonly FSRemove: "FSRemove"; readonly FSRename: "FSRename"; readonly FSCopyTree: "FSCopyTree"; readonly MakeKVKey: "MakeKVKey"; readonly MakeKVNamespace: "MakeKVNamespace"; }; type StorageClientOptions = ServiceClientOptions; /** Check whether the Storage service is registered on the device. */ declare function isStorageAvailable(options?: StorageClientOptions): boolean; /** Bind the Storage service for the current app context. */ declare function openStorage(options?: StorageClientOptions): ServiceHandle; /** Release a handle from {@link openStorage}. */ declare function closeStorage(handle: ServiceHandle, options?: StorageClientOptions): void; /** List entries in a Storage KV namespace. */ declare function kvList(handle: ServiceHandle, nspace?: string, options?: StorageClientOptions): StorageEntryInfo[]; /** Write key-value pairs into a Storage KV namespace. */ declare function kvSet(handle: ServiceHandle, nspace: string, keyValuePairs: StorageKeyValueMap, options?: StorageClientOptions): void; /** * Read keys from a Storage KV namespace. * When `keys` is omitted or empty, the device returns all pairs in the namespace. */ declare function kvGet(handle: ServiceHandle, nspace: string, keys?: string[], options?: StorageClientOptions): StorageKeyValueMap; /** * Erase keys from a Storage KV namespace. * When `keys` is omitted or empty, the device erases all pairs in the namespace. */ declare function kvErase(handle: ServiceHandle, nspace: string, keys?: string[], options?: StorageClientOptions): void; /** List mounted storage file systems. */ declare function getFileSystems(handle: ServiceHandle, options?: StorageClientOptions): FileSystemInfo[]; /** Get capacity info for one mounted file system. */ declare function getFileSystemCapacity(handle: ServiceHandle, mountPoint: string, options?: StorageClientOptions): FileSystemCapacity; /** Generate a KV key that satisfies the backend limits. */ declare function makeKvKey(handle: ServiceHandle, parts: string[], separator?: string, options?: StorageClientOptions): KvNameResult; /** Generate a KV namespace that satisfies the backend limits. */ declare function makeKvNamespace(handle: ServiceHandle, parts: string[], separator?: string, options?: StorageClientOptions): KvNameResult; /** * Run `fn` with a Storage handle that is always closed in a `finally` block. */ declare function withStorage(fn: (handle: ServiceHandle) => T | Promise, options?: StorageClientOptions): Promise; //#endregion //#region src/storage/storage.d.ts type StorageModuleOptions = StorageClientOptions; /** * Inject a mock RPC host and reset the cached service handle (vitest / Node only). * * @param options - Client options, typically `{ host }` from `@brookesia/service/hosts/storage` */ declare function configure(options: StorageModuleOptions): void; declare const storage: { /** * Whether the device registered the Storage service. * @returns `true` when `brookesia.service_available('Storage')` is true */ available(): boolean; /** * Write one key-value pair (maps to C++ `KVSet`). * * @param ns - KV namespace; empty uses default `storage` * @param key - Key name within the namespace * @param value - `string`, `number`, or `boolean` */ set(ns: string, key: string, value: StorageValue): void; /** * Write multiple keys in one RPC call (maps to C++ `KVSet` / `KeyValuePairs`). * * @param ns - KV namespace * @param pairs - Map of key → value * * @example * storage.write('my_app', { theme: 'dark', count: 42 }); */ write(ns: string, pairs: StorageKeyValueMap): void; /** * Read one or more keys (maps to C++ `KVGet`). * * @param ns - KV namespace * @param keyOrKeys - Single key (`string`), multiple keys (`string[]`), or `[]` for entire namespace * @returns Single value when `keyOrKeys` is a string; otherwise a key-value map. Missing keys are omitted. */ get(ns: string, keyOrKeys: string | string[]): StorageValue | StorageKeyValueMap | undefined; /** * List entry metadata in a namespace (maps to C++ `KVList`). * * @param ns - KV namespace; defaults to `storage` * @returns Array of `{ key, type, size, ... }` entries */ list(ns?: string): StorageEntryInfo[]; /** * Erase keys from a namespace (maps to C++ `KVErase`). * * @param ns - KV namespace * @param keys - Keys to remove; omit or pass `[]` to clear the whole namespace */ erase(ns: string, keys?: string[]): void; /** * List mounted storage file systems (maps to C++ `GetFileSystems`). * @returns Mount points such as `littlefs`, `sdcard` */ getFileSystems(): FileSystemInfo[]; /** * Get capacity info for one mounted file system (maps to C++ `GetFileSystemCapacity`). * * @param mountPoint - Mount point name from {@link getFileSystems} */ getFileSystemCapacity(mountPoint: string): FileSystemCapacity; /** * Stat a file-system path: get type, size, and mtime (maps to C++ `FSStat`). * * @param path - Absolute path under a mounted file system */ fsStat(path: string): FileInfo; /** * List direct children under a file-system directory (maps to C++ `FSList`). * * @param dirPath - Absolute directory path */ fsList(dirPath: string): FileEntry[]; /** * Create a directory (mkdir -p) on a mounted file system (maps to C++ `FSMkdir`). * * @param dirPath - Absolute directory path */ fsMkdir(dirPath: string): void; /** * Read a text file from a mounted file system (maps to C++ `FSReadText`). * * @param filePath - Absolute file path * @returns File contents as a string */ fsReadText(filePath: string): string; /** * Write a text file to a mounted file system (maps to C++ `FSWriteText`). * * @param filePath - Absolute file path * @param data - Text content to write */ fsWriteText(filePath: string, data: string): void; /** * Remove a file or empty directory (maps to C++ `FSRemove`). * * @param filePath - Absolute path to remove */ fsRemove(filePath: string): void; /** * Rename (move) a file or directory (maps to C++ `FSRename`). * * @param from - Source absolute path * @param to - Destination absolute path */ fsRename(from: string, to: string): void; /** * Recursively copy a file or directory tree (maps to C++ `FSCopyTree`). * * @param from - Source absolute path * @param to - Destination absolute path * @param overwrite - Overwrite existing destination files */ fsCopyTree(from: string, to: string, overwrite: boolean): void; /** * Generate a KV key that satisfies backend length limits (maps to C++ `MakeKVKey`). * * @param parts - Key segments joined by `separator` * @param separator - Join character (default `.`) */ makeKvKey(parts: string[], separator?: string): KvNameResult; /** * Generate a KV namespace that satisfies backend limits (maps to C++ `MakeKVNamespace`). * * @param parts - Namespace segments joined by `separator` * @param separator - Join character (default `.`) */ makeKvNamespace(parts: string[], separator?: string): KvNameResult; /** Release the Storage service binding. Safe to call multiple times. */ close(): void; }; //#endregion export { type FileSystemCapacity, type FileSystemInfo, type FileSystemType, type KvNameResult, type MediumType, STORAGE_DEFAULT_NAMESPACE, STORAGE_FUNCTIONS, STORAGE_SERVICE_NAME, type StorageClientOptions, type StorageEntryInfo, type ServiceHandle as StorageHandle, type StorageKeyValueMap, type StorageModuleOptions, type StorageValue, type StorageValueType, closeStorage, configure, storage as default, getFileSystemCapacity, getFileSystems, isStorageAvailable, kvErase, kvGet, kvList, kvSet, makeKvKey, makeKvNamespace, openStorage, withStorage }; //# sourceMappingURL=index.d.mts.map