{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://dashremix.com/spec/legal/1.1.0/legal@1.schema.json",
 "title": "legal@1 v1.1.0",
 "description": "One property per table (an array of rows). Generated from schema.sql by spec/build.py. Extension tables (x_<owner>_*) belong to forks and board-derived tables (d_*) to the board that rebuilds them; both are allowed as additional properties.",
 "type": "object",
 "properties": {
  "meta": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "key": {
      "type": "string"
     },
     "value": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "key"
    ],
    "additionalProperties": false
   }
  },
  "entities": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "entity_id": {
      "type": "string"
     },
     "label": {
      "type": "string"
     },
     "kind": {
      "type": "string",
      "enum": [
       "company",
       "nonprofit",
       "partnership",
       "trust",
       "other"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "active",
       "inactive",
       "dissolved",
       "unknown"
      ]
     },
     "jurisdiction": {
      "type": [
       "string",
       "null"
      ]
     },
     "registration_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "registered_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "entity_id",
     "label",
     "kind",
     "status",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "entity_roles": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "role_id": {
      "type": "string"
     },
     "entity_id": {
      "type": "string"
     },
     "role": {
      "type": "string"
     },
     "starts_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "ends_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "role_id",
     "entity_id",
     "role",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "contracts": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "contract_id": {
      "type": "string"
     },
     "entity_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "label": {
      "type": "string"
     },
     "counterparty_label": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "draft",
       "active",
       "ended",
       "cancelled",
       "unknown"
      ]
     },
     "starts_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "term_ends_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "renewal_mode": {
      "type": "string",
      "enum": [
       "automatic",
       "manual",
       "none",
       "unknown"
      ]
     },
     "notice_days": {
      "type": [
       "integer",
       "null"
      ]
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "contract_id",
     "label",
     "status",
     "renewal_mode",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "obligations": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "obligation_id": {
      "type": "string"
     },
     "entity_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "contract_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "kind": {
      "type": "string",
      "enum": [
       "filing",
       "notice",
       "renewal",
       "payment",
       "review",
       "other"
      ]
     },
     "label": {
      "type": "string"
     },
     "due_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "status": {
      "type": "string",
      "enum": [
       "open",
       "completed",
       "waived",
       "cancelled",
       "unknown"
      ]
     },
     "resolved_on": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "owner_role": {
      "type": [
       "string",
       "null"
      ]
     },
     "authority": {
      "type": [
       "string",
       "null"
      ]
     },
     "reference": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "obligation_id",
     "kind",
     "label",
     "due_on",
     "status",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "contract_prices": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "contract_id": {
      "type": "string"
     },
     "effective_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "amount": {
      "type": "number"
     },
     "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
     },
     "period": {
      "type": "string",
      "enum": [
       "once",
       "monthly",
       "quarterly",
       "annual"
      ]
     },
     "source": {
      "type": "string"
     },
     "source_ref": {
      "type": "string"
     },
     "imported_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "contract_id",
     "effective_on",
     "amount",
     "currency",
     "period",
     "source",
     "source_ref",
     "imported_at"
    ],
    "additionalProperties": false
   }
  },
  "import_issues": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "issue_id": {
      "type": "string"
     },
     "severity": {
      "type": "string",
      "enum": [
       "info",
       "warn",
       "error"
      ]
     },
     "kind": {
      "type": "string"
     },
     "file": {
      "type": [
       "string",
       "null"
      ]
     },
     "line": {
      "type": [
       "integer",
       "null"
      ]
     },
     "detail": {
      "type": "string"
     },
     "handling": {
      "type": "string"
     },
     "source": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "issue_id",
     "severity",
     "kind",
     "detail",
     "handling"
    ],
    "additionalProperties": false
   }
  },
  "annotations": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "annotation_id": {
      "type": "string"
     },
     "target": {
      "type": "string"
     },
     "kind": {
      "type": "string"
     },
     "body": {
      "type": "string"
     },
     "author": {
      "type": [
       "string",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ]
     },
     "data_hash": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "annotation_id",
     "target",
     "kind",
     "body"
    ],
    "additionalProperties": false
   }
  },
  "metric_registry": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "metric_id": {
      "type": "string"
     },
     "version": {
      "type": [
       "integer",
       "null"
      ]
     },
     "unit": {
      "type": [
       "string",
       "null"
      ]
     },
     "params": {
      "type": [
       "string",
       "null"
      ]
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "sql": {
      "type": [
       "string",
       "null"
      ]
     },
     "test": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "metric_id"
    ],
    "additionalProperties": false
   }
  }
 },
 "required": [
  "meta",
  "entities",
  "entity_roles",
  "contracts",
  "obligations",
  "contract_prices",
  "annotations",
  "metric_registry"
 ],
 "patternProperties": {
  "^x_[a-z0-9_]+$": {
   "type": "array"
  },
  "^d_[a-z0-9_]+$": {
   "type": "array"
  }
 },
 "additionalProperties": false
}
