import 'inventory_adjustment_result.dart';
import 'inventory_item.dart';

abstract class InventoryRepository {
  /// Returns all inventory items.
  Future<List<InventoryItem>> getInventoryItems();

  /// Adjusts the quantity of an item by [delta] (positive = add, negative = remove).
  /// Returns an [InventoryAdjustmentResult] indicating success or failure.
  Future<InventoryAdjustmentResult> adjustQuantity(String id, int delta, String reason);

  /// Sets the quantity of an item to an absolute [quantity].
  /// Returns an [InventoryAdjustmentResult] indicating success or failure.
  Future<InventoryAdjustmentResult> setQuantity(String id, int quantity, String reason);

  /// Creates a new inventory item.
  /// Returns the created [InventoryItem].
  Future<InventoryItem> createItem(InventoryItem item);

  /// Updates an existing inventory item with all fields from [item].
  /// Returns the updated [InventoryItem].
  Future<InventoryItem> updateItem(InventoryItem item);

  /// Updates the image URL for an inventory item.
  /// Returns an [InventoryAdjustmentResult] indicating success or failure.
  Future<InventoryAdjustmentResult> updateItemImage(String id, String imageUrl);

  // ── Stage 9B additions ─────────────────────────────────────────────────────

  /// Looks up an inventory item by its [sku].
  ///
  /// Returns `null` if no item with the given SKU exists.
  Future<InventoryItem?> getItemBySku(String sku);

  /// Synchronises a single item's stock quantity with a remote channel.
  ///
  /// [id] is the local inventory item ID.
  /// [remoteQuantity] is the authoritative quantity from the remote channel.
  /// [reason] is a human-readable description of why the sync occurred.
  ///
  /// Returns an [InventoryAdjustmentResult] reflecting the outcome.
  Future<InventoryAdjustmentResult> syncWithRemote(String id, int remoteQuantity, String reason);
}
