glp-companion/lib/features/pantry/domain/repositories/pantry_repository.dart

40 lines
1.5 KiB
Dart

import '../entities/pantry_item.dart';
import '../entities/shopping_list_item.dart';
/// Persistence contract for the pantry bounded context: on-hand inventory
/// plus the shopping checklist.
///
/// The presentation and domain layers depend only on this interface; the
/// drift-backed implementation lives in `data/repositories/` so widgets,
/// controllers, and use cases remain testable with in-memory fakes.
abstract class IPantryRepository {
/// Emits pantry stock (alphabetical) whenever it changes.
Stream<List<PantryItem>> watchItems();
/// One-shot snapshot of pantry stock (alphabetical).
Future<List<PantryItem>> getItems();
/// The inventory row with [id], or `null` when absent.
Future<PantryItem?> getItem(String id);
/// Inserts or updates [item] (keyed by `PantryItem.id`).
Future<PantryItem> saveItem(PantryItem item);
/// Removes the inventory row with [id], if present.
Future<void> deleteItem(String id);
/// Emits the shopping checklist (unchecked rows first) whenever it changes.
Stream<List<ShoppingListItem>> watchShoppingList();
/// One-shot snapshot of the shopping checklist (unchecked first).
Future<List<ShoppingListItem>> getShoppingList();
/// The checklist row with [id], or `null` when absent.
Future<ShoppingListItem?> getShoppingListItem(String id);
/// Inserts or updates [item] (keyed by `ShoppingListItem.id`).
Future<ShoppingListItem> saveShoppingListItem(ShoppingListItem item);
/// Removes the checklist row with [id], if present.
Future<void> deleteShoppingListItem(String id);
}