{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rial-io/json-schema/rial-io-operator-database-schema.json",
  "title": "OperatorDatabase",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rial-io-openapi.json#/components/schemas/OperatorDatabase",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,64}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "identifier_column": {
          "type": "string"
        },
        "columns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "rows": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "source": {
          "type": "string",
          "enum": [
            "csv"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "columns",
        "rows",
        "created_at",
        "updated_at",
        "source"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,64}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "identifier_column": {
          "type": "string"
        },
        "columns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "rows": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "source": {
          "type": "string",
          "enum": [
            "provider"
          ]
        },
        "source_details": {
          "type": "object",
          "properties": {
            "provider": {
              "type": "string",
              "enum": [
                "google_sheets"
              ]
            },
            "connection_id": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,64}$"
            },
            "spreadsheet_id": {
              "type": "string",
              "minLength": 1
            },
            "spreadsheet_title": {
              "type": "string"
            },
            "sheet_id": {
              "type": "integer"
            },
            "sheet_title": {
              "type": "string"
            },
            "source_url": {
              "type": "string",
              "format": "uri"
            }
          },
          "required": [
            "provider",
            "connection_id",
            "spreadsheet_id",
            "spreadsheet_title",
            "sheet_id",
            "sheet_title",
            "source_url"
          ],
          "additionalProperties": false
        },
        "sync": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "synced",
                "syncing",
                "error",
                "reauthorization_required"
              ]
            },
            "last_synced_at": {
              "type": "string",
              "format": "date-time"
            },
            "last_attempt_at": {
              "type": "string",
              "format": "date-time"
            },
            "next_sync_at": {
              "type": "string",
              "format": "date-time"
            },
            "error_code": {
              "type": "string",
              "enum": [
                "source_not_found",
                "tab_not_found",
                "invalid_table",
                "quota",
                "upstream"
              ]
            }
          },
          "required": [
            "status",
            "last_synced_at",
            "last_attempt_at"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "name",
        "columns",
        "rows",
        "created_at",
        "updated_at",
        "source",
        "source_details",
        "sync"
      ],
      "additionalProperties": false
    }
  ]
}