{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://verifiedbkk.com/data/schema/listing-fields-p0.schema.json",
  "title": "VerifiedBKK P0 listing fields (provenance envelope)",
  "description": "Draft schema for P0 fields. Invent no values. Pattern from blueprint §3.1.",
  "$defs": {
    "provenance": {
      "type": [
        "object",
        "null"
      ],
      "description": "Provenance envelope (§3.1). Every non-trivial fact is {value, source, as_of, check_level} or null.",
      "required": [
        "value",
        "source",
        "as_of",
        "check_level"
      ],
      "properties": {
        "value": {},
        "source": {
          "type": "string",
          "enum": [
            "DBD",
            "OWN",
            "CLAIM",
            "DOC",
            "REG",
            "US",
            "JOB"
          ]
        },
        "source_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "as_of": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}"
        },
        "check_level": {
          "type": "string",
          "enum": [
            "stated_by_firm",
            "seen_on_own_site",
            "checked_in_register",
            "document_seen",
            "tested_by_us",
            "job_confirmed"
          ]
        },
        "display": {
          "type": "object",
          "properties": {
            "en": {
              "type": "string"
            },
            "th": {
              "type": "string"
            }
          },
          "description": "Our own neutral summary (authored text only). Firm wording is never mixed in; see verbatim_quotes."
        },
        "verbatim_quotes": {
          "type": "array",
          "description": "The firm's own words, byte-exact as published, with where and when they were stated. Optional; added alongside display (CH-19).",
          "items": {
            "type": "object",
            "required": [
              "text",
              "source",
              "verbatim",
              "as_stated_on"
            ],
            "properties": {
              "text": {
                "type": "string"
              },
              "lang": {
                "type": "string"
              },
              "source": {
                "type": "string"
              },
              "verbatim": {
                "const": true
              },
              "as_stated_on": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}"
              },
              "rechecked_on": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}",
                "description": "Date we last saw the excerpt byte-exact on source."
              },
              "supports": {
                "type": "string",
                "description": "The claim this excerpt backs: \"display\" or \"value.<key>\"."
              },
              "verbatim_join": {
                "type": "string",
                "description": "Joiner we used between source parts (e.g. table cells). The parts are verbatim; the joiner is ours."
              },
              "excerpt_form": {
                "type": "string"
              }
            }
          }
        },
        "withholding_label": {
          "type": "object",
          "description": "Neutral label for withholding facts kept in value only; not rendered.",
          "properties": {
            "en": {
              "type": "string"
            }
          }
        },
        "support_status": {
          "type": "object",
          "description": "Open support items, e.g. {\"display\": \"pending: …\"}."
        }
      },
      "additionalProperties": true
    },
    "provenance_or_null": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/provenance"
        }
      ]
    }
  },
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "services": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Tagged taxonomy service ids; empty until filled"
    },
    "hours": {
      "$ref": "#/$defs/provenance_or_null"
    },
    "availability": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "open_now": {
              "$ref": "#/$defs/provenance_or_null"
            },
            "is_24_7": {
              "$ref": "#/$defs/provenance_or_null"
            },
            "same_day": {
              "$ref": "#/$defs/provenance_or_null"
            },
            "emergency": {
              "$ref": "#/$defs/provenance_or_null"
            },
            "holidays": {
              "$ref": "#/$defs/provenance_or_null"
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "property_types": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "e.g. house, condo, townhouse — empty until filled"
    },
    "site_rules": {
      "type": "object",
      "properties": {
        "condo_ready": {
          "$ref": "#/$defs/provenance_or_null"
        }
      },
      "additionalProperties": true
    },
    "pricing": {
      "$ref": "#/$defs/provenance_or_null"
    },
    "payment": {
      "description": "L10: payment methods as descriptive text only — never receive/hold funds",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "methods": {
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "$ref": "#/$defs/provenance"
                }
              ]
            },
            "tax_invoice": {
              "$ref": "#/$defs/provenance_or_null"
            }
          },
          "additionalProperties": true
        },
        {
          "$ref": "#/$defs/provenance"
        }
      ]
    },
    "warranty": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/provenance"
      }
    },
    "languages": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Service languages (not nationality)"
    },
    "brands": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "company": {
      "type": "object",
      "properties": {
        "years": {
          "$ref": "#/$defs/provenance_or_null"
        },
        "vat_registered": {
          "$ref": "#/$defs/provenance_or_null"
        }
      },
      "additionalProperties": true
    },
    "areas_province": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Nearby provinces beyond Bangkok khet; empty until filled"
    },
    "listed_on": {
      "type": [
        "string",
        "null"
      ]
    },
    "last_reviewed_on": {
      "type": [
        "string",
        "null"
      ]
    },
    "profile_langs": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "en",
          "th"
        ]
      }
    },
    "provenance_note": {
      "type": "string"
    },
    "team": {
      "type": "object",
      "description": "L8: female_tech_on_request is a firm-declared service option field; filter UI gated by FEATURE_FEMALE_TECH until the feature flag is on.",
      "properties": {
        "female_tech_on_request": {
          "$ref": "#/$defs/provenance_or_null"
        }
      },
      "additionalProperties": true
    },
    "reviews": {
      "description": "L7 stub — no display while FEATURE_REVIEWS=false",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "items": {
              "type": "array",
              "items": {
                "type": "object"
              },
              "maxItems": 0
            }
          }
        }
      ]
    },
    "inclusion": {
      "type": "object",
      "description": "L8: female_tech_on_request firm-declared service option; filter UI FEATURE_FEMALE_TECH OFF until C2.",
      "properties": {
        "female_tech_on_request": {
          "$ref": "#/$defs/provenance_or_null"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
