{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Horizon development activity batch",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "records"
  ],
  "properties": {
    "schema": {
      "const": "horizon.development-activity-batch/1"
    },
    "records": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/activity"
      }
    }
  },
  "$defs": {
    "activity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "record_id",
        "revision_id",
        "identity_scope",
        "dataset",
        "category",
        "identifier",
        "source_type",
        "source_status",
        "event_date",
        "end_date",
        "locality",
        "state",
        "postal_code",
        "jurisdiction",
        "source_url",
        "observed_at",
        "source_revision"
      ],
      "properties": {
        "schema": {
          "const": "horizon.development-activity/1"
        },
        "record_id": {
          "type": "string",
          "pattern": "^act_[a-f0-9]{64}$"
        },
        "revision_id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "identity_scope": {
          "enum": [
            "source_record",
            "content_snapshot"
          ]
        },
        "dataset": {
          "enum": [
            "property_activity",
            "city_chicago_il",
            "city_nyc_ny",
            "city_philadelphia_pa",
            "city_seattle_wa",
            "city_atlanta_ga",
            "city_los_angeles_ca",
            "city_boston_ma",
            "city_miami_fl"
          ]
        },
        "category": {
          "enum": [
            "property_activity",
            "permit",
            "business_license",
            "municipal_contract",
            "code_enforcement",
            "street_work"
          ]
        },
        "identifier": {
          "type": "string"
        },
        "source_type": {
          "type": "string"
        },
        "source_status": {
          "type": "string"
        },
        "event_date": {
          "type": "string"
        },
        "end_date": {
          "type": "string"
        },
        "locality": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "postal_code": {
          "type": "string"
        },
        "jurisdiction": {
          "type": "string"
        },
        "observed_at": {
          "type": "string"
        },
        "source_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_revision": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "release_id",
            "sha256",
            "logical_row"
          ],
          "properties": {
            "release_id": {
              "type": "string"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "logical_row": {
              "type": "integer",
              "minimum": 2
            }
          }
        }
      }
    }
  }
}
