/** * @module minions-sdk/storage * Storage abstraction layer for the Minions structured object system. * * The `StorageAdapter` interface is the single contract that all storage * backends must satisfy. New backends (Postgres, MongoDB, Supabase, …) can * be added later by implementing this interface without touching the rest of * the SDK. */ import type { Minion } from '../types/index.js'; /** * Options for file-based storage adapters. * * When `directoryMode` is enabled, each minion is stored as a directory * containing a primary data file (`minion.json` / `minion.yaml`) plus * optional attachment files: * * ``` * /// * ├── minion.yaml ← the Minion object * └── ... ← attachments * ``` * * When disabled (the default), the original flat layout is used: * * ``` * //.yaml * ``` */ export interface FileStorageOptions { /** * Use directory-per-minion layout, enabling attachment file storage. * Default: `false` (flat file). */ directoryMode?: boolean; } /** Options for filtering the result set when listing minions. */ export interface StorageFilter { /** Only return minions of this type. */ minionTypeId?: string; /** Only return minions with this status. */ status?: string; /** When true, include soft-deleted minions. Defaults to false. */ includeDeleted?: boolean; /** Only return minions that have all of the given tags. */ tags?: string[]; /** Maximum number of results to return. */ limit?: number; /** Number of results to skip (for pagination). */ offset?: number; /** Sort results by this field. */ sortBy?: 'createdAt' | 'updatedAt' | 'title'; /** Sort direction. Defaults to ascending. */ sortOrder?: 'asc' | 'desc'; } /** * Storage adapter interface. * * Every backend implementation must satisfy this contract. All methods are * asynchronous so that adapters backed by remote databases work identically * to local / in-process ones. */ export interface StorageAdapter { /** * Retrieve a single minion by its ID. * Returns `undefined` when no matching minion exists. */ get(id: string): Promise; /** * Persist a minion. * If a minion with the same `id` already exists it is overwritten. */ set(minion: Minion): Promise; /** * Remove a minion by its ID. * Resolves silently even if no matching minion exists. */ delete(id: string): Promise; /** * List all stored minions, with optional filtering. */ list(filter?: StorageFilter): Promise; /** * Full-text search across stored minions. * * The query is matched case-insensitively against the pre-computed * `searchableText` field (title + description + string-like fields). * Returns minions where `searchableText` contains every token in the query. */ search(query: string): Promise; /** * Write an attachment file for a minion. * The file is stored alongside the minion's primary data file. * Overwrites if the file already exists. */ putFile?(id: string, filename: string, data: Uint8Array): Promise; /** * Read an attachment file for a minion. * Returns `undefined` if the file or minion does not exist. */ getFile?(id: string, filename: string): Promise; /** * Delete an attachment file for a minion. * Resolves silently if the file does not exist. */ deleteFile?(id: string, filename: string): Promise; /** * List all attachment filenames for a minion. * Returns an empty array if the minion has no attachments or * the adapter is not in directory mode. */ listFiles?(id: string): Promise; } //# sourceMappingURL=StorageAdapter.d.ts.map