import type { OrderListFilter } from '@platform-modules/commerce-orders'
import type { ProductInput } from '@platform-modules/commerce-catalog'
import type { ProductPatch } from '@platform-modules/commerce-marketplace'

/**
 * Injected, DB-free data seam for browser-side marketplace operations.
 * Host wires each method to an API route that derives the actor from the
 * authenticated session — vendorId NEVER appears as a client param (§1.1 IDOR floor).
 */
export interface MarketplaceClient {
  /** Returns wire Vendor | null. null = no vendor yet (host catches VendorNotFoundError → null). */
  getVendorProfile(): Promise<unknown>
  /** Vendor-scoped order list. Host derives vendorId from session (§1.1). */
  getVendorOrders(filter?: OrderListFilter): Promise<unknown>
  /** Apply as vendor. Host derives ownerUserId from session. */
  applyAsVendor(input: ApplyAsVendorWire): Promise<unknown>
  /** Create product. Host derives vendorId from session; strips client-supplied id (§1.2). */
  createVendorProduct(input: CreateVendorProductWire): Promise<unknown>
  /** Update product. Host verifies product.vendorId === actor's vendor (§1.2). */
  updateVendorProduct(productId: string, patch: ProductPatch): Promise<unknown>
}

/** Vendor application wire input — NO ownerUserId (derived from session by host). */
export interface ApplyAsVendorWire { name: string }

/** Product create wire input — NO id (server-minted), NO vendorId (§1.2 IDOR floor). */
export type CreateVendorProductWire = Omit<ProductInput, 'id' | 'vendorId'>
