{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "delete": { "type": "boolean", "default": false },
    "id": { "type": "string" },
    "url": { "type": "string", "format": "uri" },
    "timestamp": { "type": "integer" },
    "content": {
      "type": "object",
      "properties": {
        "title": { "type": "string" },
        "subtitle": { "type": "string" },
        "text": { "type": "string" },
        "duration": { "type": "integer" }
      }
    },
    "originPlatform": {
      "type": "string",
      "enum": [
        "youtube", "podcasts", "facebook", "instagram", "reddit", "sina_weibo", "wechat", "twitter",
        "linkedin", "pinterest", "twitch", "tiktok", "douyin", "little_red_book", "youku", "bilibili",
        "threads", "kakaotalk", "linevoom", "discord", "snapchat", "bluesky", "news_publisher",
        "broadcast", "tender_portal", "reviews", "blogs", "forums", "social_comments", "telegram"
      ]
    },
    "contentType": {
      "type": "string",
      "enum": [
        "video", "comment", "repost", "reply", "quoted", "audio", "post",
        "online_press", "print_press", "tender", "product_review", "voc"
      ]
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "mime": { "type": "string" },
          "altText": { "type": "string" },
          "type": { "type": "string", "enum": ["image", "audio", "video"] },
          "thumbnail": { "type": "string" }
        },
        "required": ["url", "mime", "type"]
      }
    },
    "source": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "url": { "type": "string", "format": "uri" },
        "location": {
          "type": "object",
          "properties": {
            "countryCode": { "type": "string" },
            "locationString": { "type": "string" },
            "coordinates": {
              "type": "object",
              "properties": {
                "lat": { "type": "number" },
                "lon": { "type": "number" }
              },
              "required": ["lat", "lon"]
            }
          }
        }
      },
      "required": ["name", "url"]
    },
    "user": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "handle": {"type": "string"},
        "url": { "type": "string", "format": "uri" },
        "imageUrl": { "type": "string", "format": "uri" },
        "gender": { "type": "string", "enum": ["m", "f", "n"] },
        "location": {
          "type": "object",
          "properties": {
            "countryCode": { "type": "string" },
            "locationString": { "type": "string" },
            "coordinates": {
              "type": "object",
              "properties": {
                "lat": { "type": "number" },
                "lon": { "type": "number" }
              },
              "required": ["lat", "lon"]
            }
          }
        }
      },
      "anyOf": [
        { "required": ["name"] },
        { "required": ["handle"] }
      ]
    },
    "parent": {
      "type": "object",
      "properties": {
        "id": { "type": "string" },
        "url": { "type": "string", "format": "uri" },
        "title": { "type": "string" }
      }
    },
    "product": {
      "type": "object",
      "properties": {
        "name": { "type": "string" }
      }
    },
    "metrics": {
      "type": "object",
      "properties": {
        "views": { "type": "integer" },
        "audience": { "type": "integer" },
        "ave": { "type": "number" },
        "score": { "type": "number" },
        "likes": { "type": "integer" },
        "shares": { "type": "integer" },
        "comments": { "type": "integer" },
        "replies": { "type": "integer" }
      },
      "additionalProperties": false
    },
    "sentiment": {
      "type": "string",
      "enum": ["positive", "neutral", "negative", "unknown"]
    },
    "customFields": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object",
        "properties": {
          "label": { "type": "string" },
          "values": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": { "type": "string" }
          }
        },
        "required": ["label", "values"],
        "additionalProperties": false
      }
    }
  },
  "required": ["url", "timestamp", "originPlatform", "contentType", "source"],
  "allOf": [
    {
      "if": {
        "required": [
          "originPlatform",
          "contentType"
        ]
      },
      "then": {
        "anyOf": [
          {
            "properties": {
              "originPlatform": {
                "const": "youtube"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "podcasts"
              },
              "contentType": {
                "enum": [
                  "audio"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "facebook"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "instagram"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "reddit"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "sina_weibo"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "wechat"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "twitter"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "linkedin"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "pinterest"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "twitch"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "tiktok"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "douyin"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "little_red_book"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "youku"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "bilibili"
              },
              "contentType": {
                "enum": [
                  "video",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "threads"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "kakaotalk"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "linevoom"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "discord"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "snapchat"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "bluesky"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "repost",
                  "reply",
                  "quoted"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "news_publisher"
              },
              "contentType": {
                "enum": [
                  "online_press",
                  "print_press"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "broadcast"
              },
              "contentType": {
                "enum": [
                  "audio",
                  "video"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "tender_portal"
              },
              "contentType": {
                "enum": [
                  "tender"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "reviews"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "reply",
                  "product_review",
                  "voc"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "blogs"
              },
              "contentType": {
                "enum": [
                  "post"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "forums"
              },
              "contentType": {
                "enum": [
                  "post",
                  "comment",
                  "reply"
                ]
              }
            }
          },
          {
            "properties": {
              "originPlatform": {
                "const": "social_comments"
              },
              "contentType": {
                "enum": [
                  "comment",
                  "reply"
                ]
              }
            }
          }
        ]
      }
    }
  ]
}
