{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://propieda.io/estorbos-publicos/datos/esquema.json",
  "title": "Inventario de propiedades declaradas estorbo público",
  "description": "Esquema 1.1.0-ps1602. Preparado para los campos que propone el P. del S. 1602 (medida propuesta, no ley vigente). El Art. 4.011 del Código Municipal vigente ya exige un inventario público.",
  "type": "object",
  "required": [
    "schemaVersion",
    "generatedAt",
    "items"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.1.0-ps1602"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "municipio": {
      "type": [
        "string",
        "null"
      ]
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/estorbo"
      }
    }
  },
  "$defs": {
    "estorbo": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "publicId",
        "municipio",
        "municipioSlug",
        "address",
        "status",
        "active",
        "availability",
        "caseStatus",
        "history",
        "source",
        "updatedAt",
        "indexable"
      ],
      "properties": {
        "publicId": {
          "type": "string",
          "description": "Identificador estable del registro en Propieda."
        },
        "municipio": {
          "type": "string",
          "description": "(a) Municipio."
        },
        "municipioSlug": {
          "type": "string"
        },
        "address": {
          "type": "string",
          "description": "(a) Dirección física."
        },
        "barrio": {
          "type": [
            "string",
            "null"
          ],
          "description": "(a) Barrio."
        },
        "sector": {
          "type": [
            "string",
            "null"
          ],
          "description": "(a) Sector."
        },
        "lat": {
          "type": [
            "number",
            "null"
          ],
          "minimum": -90,
          "maximum": 90
        },
        "lng": {
          "type": [
            "number",
            "null"
          ],
          "minimum": -180,
          "maximum": 180
        },
        "approximateLocation": {
          "type": "boolean",
          "description": "true cuando la ubicación es el centroide del catastro."
        },
        "catastro": {
          "type": [
            "string",
            "null"
          ],
          "description": "(c) Número de catastro normalizado NNN-NNN-NNN-NN[-NNN]."
        },
        "parcelPageSlug": {
          "type": [
            "string",
            "null"
          ]
        },
        "registryDescription": {
          "type": [
            "string",
            "null"
          ],
          "description": "(b) Descripción registral (texto del municipio sin nombres de personas cuando no publica propietarios), o \"No inscrita en el Registro de la Propiedad\"."
        },
        "inscrita": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "(b) Si consta inscrita en el Registro de la Propiedad; null = no consta."
        },
        "owners": {
          "type": [
            "array",
            "null"
          ],
          "description": "(d) Propietario, poseedor o persona con interés. null cuando el municipio no lo publica.",
          "items": {
            "type": "object",
            "required": [
              "name",
              "relation"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "relation": {
                "enum": [
                  "propietario",
                  "poseedor",
                  "persona_con_interes",
                  "sucesion",
                  "desconocido"
                ]
              }
            }
          }
        },
        "appraisal": {
          "type": [
            "object",
            "null"
          ],
          "description": "(e) Valor según tasación, o \"pendiente\".",
          "properties": {
            "status": {
              "enum": [
                "tasada",
                "pendiente",
                "no_aplica"
              ]
            },
            "valueUsd": {
              "type": [
                "number",
                "null"
              ]
            },
            "appraisedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          }
        },
        "appraisalHidden": {
          "type": "boolean",
          "description": "(e) true cuando el municipio decidió no publicar la tasación; con appraisal null y false, no consta en la información publicada."
        },
        "liens": {
          "type": [
            "array",
            "null"
          ],
          "description": "Gravámenes (P. del S. 1212, medida propuesta). null salvo que el municipio los publique o use un perfil 1212.",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "enum": [
                  "hipoteca",
                  "embargo",
                  "gravamen_municipal",
                  "aviso_demanda",
                  "otro"
                ]
              },
              "holder": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "amountUsd": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "recordedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        },
        "crimDebtUsd": {
          "type": [
            "number",
            "null"
          ]
        },
        "crimDebtAsOf": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "caseStatus": {
          "type": "object",
          "description": "(f) Estado del procedimiento.",
          "required": [
            "challengeFiled",
            "stayActive"
          ],
          "properties": {
            "forum": {
              "type": [
                "string",
                "null"
              ]
            },
            "caseNumber": {
              "type": [
                "string",
                "null"
              ]
            },
            "courtCaseNumber": {
              "type": [
                "string",
                "null"
              ]
            },
            "stage": {
              "type": [
                "string",
                "null"
              ]
            },
            "challengeFiled": {
              "type": "boolean"
            },
            "stayActive": {
              "type": "boolean"
            }
          }
        },
        "status": {
          "enum": [
            "identificado",
            "notificado",
            "declarado",
            "firme",
            "en_expropiacion",
            "adquirido_municipio",
            "disponible",
            "en_rehabilitacion",
            "transferido",
            "vendido",
            "demolido",
            "retirado"
          ]
        },
        "active": {
          "type": "boolean"
        },
        "declaredAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "(g) Fecha de declaración."
        },
        "finalAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "(g) Fecha en que advino final y firme."
        },
        "municipalAcquiredAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "(h) Fecha de adquisición por el municipio."
        },
        "rehabStartedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Historial: inicio de la rehabilitación."
        },
        "rehabCompletedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Historial: rehabilitación completada."
        },
        "transferredAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Historial: fecha de transferencia."
        },
        "soldAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Historial: fecha de venta."
        },
        "demolishedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Historial: fecha de demolición."
        },
        "adjudicatedArt4010e": {
          "type": "boolean"
        },
        "inLey97PriorityWindow": {
          "type": "boolean"
        },
        "availability": {
          "enum": [
            "disponible_adquisicion",
            "disponible_rehabilitacion",
            "disponible_ambas",
            "no_disponible",
            "por_determinar"
          ],
          "description": "(i) Disponibilidad."
        },
        "permittedUse": {
          "type": [
            "string",
            "null"
          ],
          "description": "(j) Uso permitido según el municipio."
        },
        "photo": {
          "type": [
            "object",
            "null"
          ],
          "description": "(k) Fotografía exterior fechada.",
          "properties": {
            "url": {
              "type": "string",
              "format": "uri"
            },
            "takenAt": {
              "type": "string",
              "format": "date-time"
            }
          }
        },
        "photoMissingReason": {
          "enum": [
            "acceso_restringido",
            "riesgo_seguridad",
            "pendiente_inspeccion",
            "otro",
            null
          ]
        },
        "photoMissingNote": {
          "type": [
            "string",
            "null"
          ],
          "description": "(k) Razón consignada por el municipio cuando no hay fotografía."
        },
        "photos": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string"
              },
              "takenAt": {
                "type": "string"
              },
              "caption": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "history": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "at",
              "event"
            ],
            "properties": {
              "at": {
                "type": "string"
              },
              "event": {
                "type": "string"
              },
              "status": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "source": {
          "type": "object",
          "required": [
            "kind"
          ],
          "properties": {
            "kind": {
              "enum": [
                "municipio_portal",
                "importado_publicacion_oficial"
              ]
            },
            "sourceUrl": {
              "type": [
                "string",
                "null"
              ]
            },
            "asOf": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          }
        },
        "correctionInReview": {
          "type": "boolean"
        },
        "lastVerifiedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "indexable": {
          "type": "boolean"
        }
      }
    }
  }
}