{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aimapio.com/schema/tool.schema.json",
  "title": "AIMapio tool record",
  "type": "object",
  "required": [
    "id",
    "type",
    "name",
    "developer",
    "website",
    "category",
    "tags",
    "platforms",
    "summary",
    "verification_status",
    "lifecycle",
    "added_on",
    "facts",
    "relations",
    "translation",
    "disclosure"
  ],
  "additionalProperties": false,
  "$defs": {
    "i18n": {
      "type": "object",
      "required": [
        "en",
        "zh",
        "es"
      ],
      "additionalProperties": false,
      "properties": {
        "en": {
          "type": "string",
          "minLength": 1
        },
        "zh": {
          "type": "string",
          "minLength": 1
        },
        "es": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "sourced": {
      "type": "object",
      "required": [
        "value",
        "source",
        "verified_on"
      ],
      "properties": {
        "source": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "verified_on": {
          "oneOf": [
            {
              "$ref": "#/$defs/date"
            },
            {
              "type": "null"
            }
          ]
        },
        "note": {
          "$ref": "#/$defs/i18n"
        },
        "complete": {
          "type": "boolean"
        }
      }
    },
    "plan": {
      "type": "object",
      "required": [
        "name",
        "price",
        "currency",
        "period",
        "billing"
      ],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "price": {
          "type": "number",
          "minimum": 0
        },
        "currency": {
          "enum": [
            "USD",
            "EUR",
            "CNY",
            "GBP"
          ]
        },
        "period": {
          "enum": [
            "month",
            "year",
            "1M tokens"
          ]
        },
        "billing": {
          "enum": [
            "monthly",
            "annual",
            "usage"
          ]
        },
        "note": {
          "type": "string"
        }
      }
    }
  },
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "type": {
      "enum": [
        "software",
        "model",
        "hardware"
      ]
    },
    "name": {
      "type": "string"
    },
    "name_zh": {
      "type": "string"
    },
    "developer": {
      "type": "object",
      "required": [
        "name",
        "country"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "country": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[A-Z]{2}$"
        }
      }
    },
    "website": {
      "type": "string",
      "format": "uri"
    },
    "category": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "platforms": {
      "type": "array",
      "items": {
        "enum": [
          "web",
          "ios",
          "android",
          "mobile",
          "desktop",
          "api",
          "ide",
          "cli",
          "self-hosted"
        ]
      }
    },
    "summary": {
      "$ref": "#/$defs/i18n"
    },
    "notes": {
      "$ref": "#/$defs/i18n"
    },
    "verification_status": {
      "enum": [
        "listed",
        "source_verified",
        "independently_tested",
        "needs_reverification"
      ]
    },
    "lifecycle": {
      "enum": [
        "active",
        "inactive",
        "closed",
        "acquired"
      ]
    },
    "added_on": {
      "$ref": "#/$defs/date"
    },
    "facts": {
      "type": "object",
      "required": [
        "pricing_model",
        "free_tier",
        "plans",
        "commercial_use",
        "availability"
      ],
      "additionalProperties": false,
      "properties": {
        "pricing_model": {
          "allOf": [
            {
              "$ref": "#/$defs/sourced"
            },
            {
              "properties": {
                "value": {
                  "enum": [
                    "free",
                    "freemium",
                    "paid",
                    "usage",
                    null
                  ]
                }
              }
            }
          ]
        },
        "free_tier": {
          "allOf": [
            {
              "$ref": "#/$defs/sourced"
            },
            {
              "properties": {
                "value": {
                  "oneOf": [
                    {
                      "$ref": "#/$defs/i18n"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          ]
        },
        "plans": {
          "allOf": [
            {
              "$ref": "#/$defs/sourced"
            },
            {
              "required": [
                "complete"
              ],
              "properties": {
                "value": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/plan"
                  }
                }
              }
            }
          ]
        },
        "commercial_use": {
          "allOf": [
            {
              "$ref": "#/$defs/sourced"
            },
            {
              "properties": {
                "value": {
                  "oneOf": [
                    {
                      "$ref": "#/$defs/i18n"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          ]
        },
        "availability": {
          "$ref": "#/$defs/sourced"
        }
      }
    },
    "relations": {
      "type": "object",
      "properties": {
        "alternatives": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "translation": {
      "type": "object",
      "required": [
        "en",
        "zh",
        "es"
      ],
      "properties": {
        "en": {
          "enum": [
            "source",
            "machine",
            "ai_checked",
            "human"
          ]
        },
        "zh": {
          "enum": [
            "source",
            "machine",
            "ai_checked",
            "human"
          ]
        },
        "es": {
          "enum": [
            "source",
            "machine",
            "ai_checked",
            "human"
          ]
        }
      }
    },
    "disclosure": {
      "type": "object",
      "required": [
        "affiliate",
        "sponsored"
      ],
      "properties": {
        "affiliate": {
          "type": "boolean"
        },
        "sponsored": {
          "type": "boolean"
        }
      }
    }
  }
}