@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
33 lines • 1.78 kB
TypeScript
import type { StorageDeleteFavoritesForEntityInput, StorageIsFavoritedBatchInput, StorageListFavoritesInput, StorageFavoriteKey } from '../../types.js';
import type { InMemoryDB } from '../inmemory-db.js';
import type { FavoriteToggleResult } from './base.js';
import { FavoritesStorage } from './base.js';
/**
* In-memory implementation of FavoritesStorage. Mutates the shared InMemoryDB
* Maps for favorites and the parent entity records (agents, skills) so that the
* denormalized `favoriteCount` stays in sync.
*
* Atomicity is provided by the JavaScript single-threaded event loop: each
* favorite/unfavorite runs to completion within one synchronous block.
*/
export declare class InMemoryFavoritesStorage extends FavoritesStorage {
private db;
constructor({ db }: {
db: InMemoryDB;
});
init(): Promise<void>;
dangerouslyClearAll(): Promise<void>;
favorite({ userId, entityType, entityId }: StorageFavoriteKey): Promise<FavoriteToggleResult>;
unfavorite({ userId, entityType, entityId }: StorageFavoriteKey): Promise<FavoriteToggleResult>;
isFavorited({ userId, entityType, entityId }: StorageFavoriteKey): Promise<boolean>;
isFavoritedBatch({ userId, entityType, entityIds }: StorageIsFavoritedBatchInput): Promise<Set<string>>;
listFavoritedIds({ userId, entityType }: StorageListFavoritesInput): Promise<string[]>;
deleteFavoritesForEntity({ entityType, entityId }: StorageDeleteFavoritesForEntityInput): Promise<number>;
/**
* Look up the parent entity record for counter maintenance. Throws if the
* entity does not exist — callers should validate existence (and access)
* before invoking favorite/unfavorite.
*/
private requireEntity;
}
//# sourceMappingURL=inmemory.d.ts.map