{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://postageagent.com/schema.json",
 "title": "Postage public index record",
 "description": "One row of the free public index. Listings are opportunities; cards are standing. No names, no prices.",
 "oneOf": [
  {
   "$ref": "#/$defs/listing"
  },
  {
   "$ref": "#/$defs/card"
  }
 ],
 "$defs": {
  "ticks": {
   "type": "object",
   "properties": {
    "industry": {
     "type": "string"
    },
    "industry_qualifier": {
     "type": "string"
    },
    "geo": {
     "type": "string",
     "description": "Region code. US state in the mock."
    },
    "geo_qualifier": {
     "enum": [
      "rural",
      "metro",
      "regional"
     ]
    },
    "size_band": {
     "enum": [
      "owner_operator",
      "5_15",
      "10_40",
      "40_120",
      "120_plus"
     ]
    },
    "horizon": {
     "enum": [
      "3m",
      "6m",
      "12m",
      "24m"
     ]
    },
    "role": {
     "enum": [
      "owner_operator",
      "director",
      "gm"
     ]
    },
    "years": {
     "enum": [
      "under_5",
      "5_10",
      "10y_plus"
     ]
    },
    "intent": {
     "type": "string"
    },
    "product_kind": {
     "enum": [
      "line",
      "plant",
      "stock"
     ]
    },
    "service_kind": {
     "enum": [
      "crew",
      "advisory"
     ]
    },
    "function": {
     "enum": [
      "estimator",
      "leading_hand",
      "gm",
      "director",
      "bookkeeper",
      "operator",
      "supervisor",
      "salesperson",
      "mechanic",
      "designer"
     ]
    },
    "value_band": {
     "enum": [
      "ev_0_2m",
      "ev_2_5m",
      "ev_5_10m",
      "ev_10_20m",
      "ev_20_50m",
      "ev_50m_plus"
     ]
    },
    "ticket_band": {
     "enum": [
      "under_20k",
      "20k_50k",
      "50k_250k",
      "250k_1m",
      "1m_plus"
     ]
    },
    "pay_band": {
     "enum": [
      "under_80k",
      "80k_120k",
      "120k_180k",
      "180k_250k",
      "250k_plus"
     ]
    }
   },
   "required": [
    "industry",
    "geo"
   ]
  },
  "common": {
   "type": "object",
   "properties": {
    "did": {
     "type": "string",
     "pattern": "^did:oa:"
    },
    "findable": {
     "type": "boolean"
    },
    "ticks": {
     "$ref": "#/$defs/ticks"
    },
    "rating": {
     "type": [
      "number",
      "null"
     ]
    },
    "no_shows": {
     "type": "integer"
    },
    "intros": {
     "type": "integer"
    },
    "trust_tier": {
     "enum": [
      "self_asserted",
      "document_reviewed",
      "registry_checked"
     ]
    }
   },
   "required": [
    "did",
    "kind",
    "side",
    "ticks",
    "trust_tier"
   ]
  },
  "listing": {
   "allOf": [
    {
     "$ref": "#/$defs/common"
    },
    {
     "properties": {
      "kind": {
       "const": "listing"
      },
      "listing_id": {
       "type": "string",
       "pattern": "^L-"
      },
      "object": {
       "enum": [
        "business",
        "product",
        "capital",
        "service",
        "seat"
       ]
      },
      "side": {
       "enum": [
        "seek",
        "offer"
       ]
      }
     },
     "required": [
      "listing_id",
      "object"
     ]
    }
   ]
  },
  "card": {
   "allOf": [
    {
     "$ref": "#/$defs/common"
    },
    {
     "properties": {
      "kind": {
       "const": "card"
      },
      "side": {
       "const": "standing"
      },
      "open_to": {
       "type": "array",
       "items": {
        "enum": [
         "serendipity",
         "they_want_you"
        ]
       }
      }
     }
    }
   ]
  },
  "intent": {
   "business": {
    "seek": [
     "buy_succession",
     "buy_bolt_on",
     "buy_platform"
    ],
    "offer": [
     "sell_succession",
     "sell_trade",
     "partial_exit"
    ]
   },
   "product_line": {
    "seek": [
     "take_on_line",
     "exclusive_territory"
    ],
    "offer": [
     "appoint_dealer",
     "supply_line"
    ]
   },
   "product_plant": {
    "seek": [
     "buy_used",
     "wet_hire",
     "dry_hire"
    ],
    "offer": [
     "sell_surplus",
     "wet_hire_out",
     "dispose_fleet"
    ]
   },
   "product_stock": {
    "seek": [
     "need_supplier",
     "need_stock"
    ],
    "offer": [
     "sell_to_trade",
     "wholesale"
    ]
   },
   "capital": {
    "seek": [
     "raise_equity",
     "raise_debt"
    ],
    "offer": [
     "deploy_equity",
     "lend"
    ]
   },
   "service_crew": {
    "seek": [
     "need_crew",
     "need_subbie"
    ],
    "offer": [
     "have_capacity",
     "have_work"
    ]
   },
   "service_advisory": {
    "seek": [
     "need_advisor",
     "need_design"
    ],
    "offer": [
     "have_advisory",
     "have_mandate"
    ]
   },
   "seat": {
    "seek": [
     "looking_perm",
     "looking_contract",
     "looking_fractional"
    ],
    "offer": [
     "hire_perm",
     "hire_contract",
     "hire_fractional"
    ]
   }
  },
  "brief": {
   "type": "object",
   "description": "What a registered sender files. lead_stamps is what they will pay if the recipient engages.",
   "properties": {
    "target": {
     "type": "string",
     "description": "listing_id or did"
    },
    "object": {
     "enum": [
      "business",
      "product",
      "capital",
      "service",
      "seat"
     ]
    },
    "side": {
     "enum": [
      "seek",
      "offer"
     ]
    },
    "ticks": {
     "$ref": "#/$defs/ticks"
    },
    "brief": {
     "type": "string",
     "maxLength": 600
    },
    "proofs": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "lead_stamps": {
     "type": "number",
     "minimum": 1
    }
   },
   "required": [
    "target",
    "object",
    "side",
    "ticks",
    "brief",
    "lead_stamps"
   ]
  }
 }
}