{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://dashremix.com/spec/library/1.0.0/library@1.schema.json",
 "title": "library@1 v1.0.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",
       "null"
      ]
     },
     "value": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [],
    "additionalProperties": false
   }
  },
  "items": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "item_id": {
      "type": "string"
     },
     "work_id": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "authors": {
      "type": [
       "string",
       "null"
      ]
     },
     "isbn13": {
      "type": [
       "string",
       "null"
      ]
     },
     "isbn10": {
      "type": [
       "string",
       "null"
      ]
     },
     "pages": {
      "type": [
       "integer",
       "null"
      ]
     },
     "pages_source": {
      "type": [
       "string",
       "null"
      ]
     },
     "format": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "print",
       "ebook",
       "audio",
       "unknown",
       null
      ]
     },
     "binding": {
      "type": [
       "string",
       "null"
      ]
     },
     "audio_s": {
      "type": [
       "integer",
       "null"
      ]
     },
     "year_published": {
      "type": [
       "integer",
       "null"
      ]
     },
     "original_year": {
      "type": [
       "integer",
       "null"
      ]
     },
     "publisher": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": "string",
      "enum": [
       "goodreads-csv",
       "storygraph-csv",
       "library-csv"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "item_id",
     "work_id",
     "title",
     "source"
    ],
    "additionalProperties": false
   }
  },
  "item_authors": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "item_id": {
      "type": "string"
     },
     "ord": {
      "type": "integer"
     },
     "author": {
      "type": "string"
     },
     "role": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "author",
       "translator",
       "narrator",
       "editor",
       "illustrator",
       "other",
       null
      ]
     }
    },
    "required": [
     "item_id",
     "ord",
     "author"
    ],
    "additionalProperties": false
   }
  },
  "reads": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "read_id": {
      "type": "string"
     },
     "item_id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "to_read",
       "reading",
       "read",
       "dnf",
       "paused"
      ]
     },
     "date_added": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "started": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "finished": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "rating": {
      "type": [
       "number",
       "null"
      ]
     },
     "reread_n": {
      "type": [
       "integer",
       "null"
      ]
     },
     "source_read_count": {
      "type": [
       "integer",
       "null"
      ]
     },
     "review_words": {
      "type": [
       "integer",
       "null"
      ]
     },
     "owned": {
      "type": [
       "integer",
       "null"
      ]
     },
     "source": {
      "type": "string",
      "enum": [
       "goodreads-csv",
       "storygraph-csv",
       "library-csv"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "read_id",
     "item_id",
     "status",
     "source"
    ],
    "additionalProperties": false
   }
  },
  "tags": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "item_id": {
      "type": "string"
     },
     "kind": {
      "type": "string",
      "enum": [
       "shelf",
       "genre",
       "tag",
       "mood"
      ]
     },
     "tag": {
      "type": "string"
     },
     "source": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "item_id",
     "kind",
     "tag"
    ],
    "additionalProperties": false
   }
  },
  "entries": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "entry_id": {
      "type": "string"
     },
     "tracker_id": {
      "type": "string"
     },
     "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "value": {
      "type": "number"
     },
     "note": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "app",
       "chat",
       "cli",
       "csv",
       "import",
       null
      ]
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "entry_id",
     "tracker_id",
     "date",
     "value"
    ],
    "additionalProperties": false
   }
  },
  "goals": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "year": {
      "type": "integer"
     },
     "books": {
      "type": [
       "integer",
       "null"
      ]
     },
     "pages": {
      "type": [
       "integer",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "year"
    ],
    "additionalProperties": false
   }
  },
  "source_matches": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "match_id": {
      "type": "string"
     },
     "item_id": {
      "type": "string"
     },
     "source": {
      "type": "string",
      "enum": [
       "goodreads-csv",
       "storygraph-csv",
       "library-csv"
      ]
     },
     "source_ref": {
      "type": "string"
     },
     "source_key": {
      "type": [
       "string",
       "null"
      ]
     },
     "method": {
      "type": "string",
      "enum": [
       "isbn",
       "title_author",
       "same_read",
       "confirmed",
       "possible_duplicate"
      ]
     },
     "kept": {
      "type": "integer"
     },
     "other_item_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "note": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "match_id",
     "item_id",
     "source",
     "source_ref",
     "method",
     "kept"
    ],
    "additionalProperties": false
   }
  },
  "data_issues": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "issue_id": {
      "type": "string"
     },
     "severity": {
      "type": "string",
      "enum": [
       "info",
       "warn",
       "error"
      ]
     },
     "kind": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "detail": {
      "type": "string"
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "handling": {
      "type": "string"
     }
    },
    "required": [
     "issue_id",
     "severity",
     "kind",
     "title",
     "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",
  "items",
  "reads"
 ],
 "patternProperties": {
  "^x_[a-z0-9_]+$": {
   "type": "array"
  },
  "^d_[a-z0-9_]+$": {
   "type": "array"
  }
 },
 "additionalProperties": false
}
