{
  "id": "ctzn.network/owned-items-view",
  "title": "Owned items view",
  "description": "List items owned by a user.",
  "type": "json-view",
  "parameters": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "array",
    "minItems": 1,
    "additionalItems": false,
    "items": [
      {"type": "string"},
      {
        "type": "object",
        "properties": {
          "limit": {"type": "number"},
          "lt": {"type": "string"},
          "lte": {"type": "string"},
          "gt": {"type": "string"},
          "gte": {"type": "string"},
          "reverse": {"type": "boolean"}
        }
      }
    ]
  },
  "definition": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": ["items"],
    "properties": {
      "items": {
        "type": "array",
        "items": {
          "type": "object",
          "required": ["databaseId", "key", "seq", "url", "value"],
          "properties": {
            "seq": {"type": "number"},
            "key": {"type": "string"},
            "url": {"type": "string", "format": "uri"},
            "databaseId": {"type": "string", "pattern": ".+@.+"},
            "itemClass": {
              "type": "object",
              "required": ["key", "seq", "url", "value"],
              "properties": {
                "seq": {"type": "number"},
                "key": {"type": "string"},
                "url": {"type": "string", "format": "uri"},
                "value": {
                  "type": "object",
                  "required": ["id", "grouping", "createdAt"],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^([a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9])$",
                      "minLength": 1,
                      "maxLength": 64
                    },
                    "grouping": {
                      "type": "string",
                      "enum": ["unique", "fungible"]
                    },
                    "displayName": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    },
                    "description": {
                      "type": "string",
                      "maxLength": 256
                    },
                    "iconBlobName": {
                      "type": "string"
                    },
                    "definition": {
                      "type": "object"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            },
            "value": {
              "type": "object",
              "required": ["classId", "qty", "createdAt"],
              "properties": {
                "classId": {"type": "string"},
                "qty": {"type": "integer"},
                "owner": {
                  "type": "object",
                  "required": ["dbUrl", "userId"],
                  "properties": {
                    "dbUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "userId": {
                      "type": "string",
                      "pattern": ".+@.+"
                    }
                  }
                },
                "properties": {
                  "type": "object"
                },
                "createdBy": {
                  "type": "object",
                  "required": ["dbUrl", "userId"],
                  "properties": {
                    "dbUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "userId": {
                      "type": "string",
                      "pattern": ".+@.+"
                    }
                  }
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          }
        }
      }
    }
  }
}