{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://marketyard.com/schemas/open-lot-manifest-0.1.json",
  "title": "Open Lot Manifest",
  "description": "A machine-readable manifest for a lot of surplus/returns inventory: counts, condition grade, and a defensible retail estimate. The interchange format behind MarketYard listings and the YTP agent API. Mirrors ManifestSchema in web/src/lib/manifest.ts — keep the two in lockstep and bump the version on any change.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "category",
    "grade",
    "grade_reasoning",
    "unit_type",
    "unit_count",
    "lines",
    "est_retail_value",
    "retail_basis",
    "uncertainties"
  ],
  "properties": {
    "category": {
      "description": "Best-fit category for the lot as a whole.",
      "type": "string",
      "enum": [
        "Appliances",
        "Tools & Machinery",
        "Home & Garden",
        "Consumer Electronics",
        "Business & Industrial",
        "Sporting Goods",
        "Computers & Networking",
        "Health & Beauty",
        "Cell Phones & Accessories",
        "Clothing, Shoes & Accessories",
        "Jewelry & Watches"
      ]
    },
    "grade": {
      "description": "A = new/like-new with packaging. B = functional, cosmetic wear. C = untested returns. D = known defects. salvage = material recovery only.",
      "type": "string",
      "enum": ["A", "B", "C", "D", "salvage"]
    },
    "grade_reasoning": {
      "description": "One sentence on why this grade, citing what is visible.",
      "type": "string"
    },
    "unit_type": {
      "type": "string",
      "enum": ["pallet", "case", "each", "bay", "truckload"]
    },
    "unit_count": {
      "description": "How many pallets/cases/units the lot contains.",
      "type": "integer",
      "minimum": 1
    },
    "lines": {
      "description": "Item lines visible across the photos.",
      "type": "array",
      "items": { "$ref": "#/$defs/manifestLine" }
    },
    "est_retail_value": {
      "description": "Estimated total RETAIL value of the lot in USD major units, before any liquidation discount. An estimate document — becomes integer minor units when promoted to a listing.",
      "type": "number",
      "minimum": 0
    },
    "retail_basis": {
      "description": "One sentence on how the retail estimate was reached.",
      "type": "string"
    },
    "uncertainties": {
      "description": "What could NOT be determined from the photos and the seller should confirm. Rarely empty in an honest manifest.",
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "$defs": {
    "manifestLine": {
      "type": "object",
      "additionalProperties": false,
      "required": ["description", "brand", "quantity", "condition_note", "confidence"],
      "properties": {
        "description": {
          "description": "What the item is, as a buyer would list it.",
          "type": "string"
        },
        "brand": {
          "description": "Brand if legible on packaging, otherwise empty string.",
          "type": "string"
        },
        "quantity": {
          "description": "Visible or reasonably inferred unit count.",
          "type": "integer",
          "minimum": 0
        },
        "condition_note": {
          "description": "Visible damage, packaging state, or 'none visible'.",
          "type": "string"
        },
        "confidence": {
          "description": "'low' when inferring beyond what the photos actually show.",
          "type": "string",
          "enum": ["high", "medium", "low"]
        }
      }
    }
  }
}
