{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "archivedAt": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "published": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "definition": {
          "type": "object",
          "properties": {
            "key": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "title": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "source": {
              "anyOf": [
                {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "x-search"
                        },
                        "query": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        }
                      },
                      "required": ["kind", "query"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "custom"
                        },
                        "namespace": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100,
                          "pattern": "^[a-zA-Z0-9_-]+$"
                        },
                        "identities": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          }
                        },
                        "accounts": {
                          "minItems": 1,
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[a-zA-Z][a-zA-Z0-9_]{0,39}$"
                          }
                        },
                        "data": {
                          "$ref": "#/$defs/__schema0"
                        },
                        "content": {
                          "type": "object",
                          "properties": {
                            "metrics": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^[a-z][a-zA-Z0-9]{0,39}$"
                              }
                            }
                          },
                          "required": ["metrics"]
                        },
                        "balance": {
                          "type": "object",
                          "properties": {
                            "chain": {
                              "type": "string",
                              "pattern": "^(?:solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp|eip155:[1-9][0-9]{0,15}|cosmos:[-_a-zA-Z0-9]{1,32})$"
                            },
                            "token": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 128
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": ["chain", "token"]
                        }
                      },
                      "required": ["kind", "namespace"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "discord-messages"
                        },
                        "text": {
                          "type": "boolean"
                        }
                      },
                      "required": ["kind"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "discord-reactions"
                        }
                      },
                      "required": ["kind"],
                      "additionalProperties": false
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {
                    "$ref": "#/$defs/__schema1"
                  }
                }
              ]
            },
            "window": {
              "type": "object",
              "properties": {
                "start": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 8640000000000000
                },
                "end": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 8640000000000000
                }
              },
              "required": ["start"]
            },
            "refreshSeconds": {
              "default": 21600,
              "type": "integer",
              "minimum": 300,
              "maximum": 86400
            },
            "maxPages": {
              "default": 60,
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          "required": [
            "key",
            "title",
            "source",
            "window",
            "refreshSeconds",
            "maxPages"
          ]
        },
        "publishedAt": {
          "type": "integer",
          "minimum": 0,
          "maximum": 8640000000000000
        },
        "actor": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": ["id", "version", "definition", "publishedAt", "actor"]
    },
    "paused": {
      "type": "boolean"
    },
    "pauseReason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "resumesAt": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 8640000000000000
        },
        {
          "type": "null"
        }
      ]
    },
    "effectiveRefreshSeconds": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "state": {
      "type": "string",
      "enum": ["idle", "syncing", "error", "complete"]
    },
    "lastStartedAt": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 8640000000000000
        },
        {
          "type": "null"
        }
      ]
    },
    "lastCompletedAt": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 8640000000000000
        },
        {
          "type": "null"
        }
      ]
    },
    "nextSyncAt": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 8640000000000000
        },
        {
          "type": "null"
        }
      ]
    },
    "coverage": {
      "type": "string",
      "enum": ["unknown", "partial", "complete"]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "records": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "origin": {
      "type": "string",
      "enum": ["code", "data"]
    }
  },
  "required": [
    "published",
    "paused",
    "state",
    "lastStartedAt",
    "lastCompletedAt",
    "nextSyncAt",
    "coverage",
    "error",
    "records"
  ],
  "$defs": {
    "__schema0": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "object",
            "array",
            "string",
            "number",
            "integer",
            "boolean",
            "null"
          ]
        },
        "properties": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        },
        "required": {
          "maxItems": 256,
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "additionalProperties": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "$ref": "#/$defs/__schema0"
            }
          ]
        },
        "propertyNames": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "string"
            },
            "enum": {
              "maxItems": 256,
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "required": ["type"]
        },
        "items": {
          "$ref": "#/$defs/__schema0"
        },
        "minItems": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "maxItems": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "minLength": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "maxLength": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "minimum": {
          "type": "number"
        },
        "maximum": {
          "type": "number"
        },
        "exclusiveMinimum": {
          "type": "number"
        },
        "exclusiveMaximum": {
          "type": "number"
        },
        "enum": {
          "minItems": 1,
          "maxItems": 256,
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "const": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "anyOf": {
          "minItems": 1,
          "maxItems": 16,
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        "oneOf": {
          "minItems": 1,
          "maxItems": 16,
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        "allOf": {
          "minItems": 1,
          "maxItems": 16,
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        }
      }
    },
    "__schema1": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema1"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema1"
          }
        }
      ]
    }
  }
}
