{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://getshiori.app/schemas/now/v1",
  "title": "Shiori now",
  "description": "A user's current media: in progress, planned, the dated log and the undated shelf, as served by GET /v1/me/now and GET /v1/users/{handle}/now.json (SOLUTION_DESIGN.md 6.6).",
  "type": "object",
  "properties": {
    "version": {
      "type": "string",
      "const": "https://getshiori.app/schemas/now/v1"
    },
    "handle": {
      "type": [
        "string",
        "null"
      ]
    },
    "name": {
      "type": [
        "string",
        "null"
      ]
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "timezone": {
      "type": "string"
    },
    "currently": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/NowEntry"
      }
    },
    "planned": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/NowEntry"
      }
    },
    "log": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/NowEntry"
      }
    },
    "log_next_cursor": {
      "type": [
        "string",
        "null"
      ]
    },
    "shelf": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/NowEntry"
      }
    },
    "counts": {
      "$ref": "#/definitions/NowCounts"
    },
    "attribution": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "version",
    "handle",
    "name",
    "generated_at",
    "timezone",
    "currently",
    "planned",
    "log",
    "log_next_cursor",
    "shelf",
    "counts",
    "attribution"
  ],
  "additionalProperties": false,
  "definitions": {
    "NowEntry": {
      "type": "object",
      "properties": {
        "entry_id": {
          "type": "string",
          "format": "uuid"
        },
        "type": {
          "type": "string",
          "enum": [
            "movie",
            "tv",
            "anime",
            "manga",
            "book",
            "game"
          ]
        },
        "title": {
          "type": "string"
        },
        "title_english": {
          "type": [
            "string",
            "null"
          ]
        },
        "year": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "season": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "show_title": {
                  "type": "string"
                },
                "sequence": {
                  "anyOf": [
                    {
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "show_title",
                "sequence"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "planned",
            "in_progress",
            "finished",
            "paused",
            "dropped"
          ]
        },
        "started_on": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
              "description": "Calendar date as YYYY-MM-DD, no time component"
            },
            {
              "type": "null"
            }
          ],
          "description": "Calendar date as YYYY-MM-DD, no time component"
        },
        "started_precision": {
          "type": "string",
          "enum": [
            "day",
            "month",
            "year",
            "unknown"
          ],
          "description": "How much of the calendar date is known"
        },
        "finished_on": {
          "anyOf": [
            {
              "$ref": "#/definitions/NowEntry/properties/started_on/anyOf/0"
            },
            {
              "type": "null"
            }
          ],
          "description": "Calendar date as YYYY-MM-DD, no time component"
        },
        "finished_precision": {
          "$ref": "#/definitions/NowEntry/properties/started_precision"
        },
        "rating": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 10
            },
            {
              "type": "null"
            }
          ]
        },
        "repeat_index": {
          "type": "integer",
          "minimum": 1
        },
        "progress": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "review": {
          "type": "string"
        },
        "review_visibility": {
          "type": "string",
          "enum": [
            "private",
            "unlisted",
            "public"
          ]
        },
        "hidden": {
          "type": "boolean"
        },
        "links": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "rel": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "rel",
              "url"
            ],
            "additionalProperties": false
          }
        },
        "ids": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "image": {
          "type": "object",
          "properties": {
            "provider": {
              "type": "string"
            },
            "url": {
              "type": "string",
              "format": "uri"
            }
          },
          "required": [
            "provider",
            "url"
          ],
          "additionalProperties": false
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "entry_id",
        "type",
        "title",
        "title_english",
        "year",
        "season",
        "status",
        "started_on",
        "started_precision",
        "finished_on",
        "finished_precision",
        "rating",
        "repeat_index",
        "progress",
        "links",
        "ids"
      ],
      "additionalProperties": false
    },
    "NowCounts": {
      "type": "object",
      "properties": {
        "finished_this_year": {
          "type": "integer",
          "minimum": 0
        },
        "in_progress": {
          "$ref": "#/definitions/NowCounts/properties/finished_this_year"
        },
        "planned": {
          "$ref": "#/definitions/NowCounts/properties/finished_this_year"
        },
        "log": {
          "$ref": "#/definitions/NowCounts/properties/finished_this_year"
        },
        "shelf": {
          "$ref": "#/definitions/NowCounts/properties/finished_this_year"
        },
        "by_type": {
          "type": "object",
          "properties": {
            "movie": {
              "$ref": "#/definitions/NowCounts/properties/finished_this_year"
            },
            "tv": {
              "$ref": "#/definitions/NowCounts/properties/finished_this_year"
            },
            "anime": {
              "$ref": "#/definitions/NowCounts/properties/finished_this_year"
            },
            "manga": {
              "$ref": "#/definitions/NowCounts/properties/finished_this_year"
            },
            "book": {
              "$ref": "#/definitions/NowCounts/properties/finished_this_year"
            },
            "game": {
              "$ref": "#/definitions/NowCounts/properties/finished_this_year"
            }
          },
          "required": [
            "movie",
            "tv",
            "anime",
            "manga",
            "book",
            "game"
          ],
          "additionalProperties": false
        },
        "truncated": {
          "type": "boolean"
        }
      },
      "required": [
        "finished_this_year",
        "in_progress",
        "planned",
        "log",
        "shelf",
        "by_type"
      ],
      "additionalProperties": false
    }
  }
}
