{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Email provider free tiers",
  "type": "object",
  "required": ["checkedAt", "providers"],
  "$defs": {
    "fact": {
      "type": "object",
      "required": ["value", "basis", "sourceUrl", "checkedAt"],
      "properties": {
        "value": {},
        "basis": { "enum": ["stated", "implied", "not_stated", "derived_from_code"] },
        "sourceUrl": { "type": ["string", "null"] },
        "checkedAt": { "type": "string", "format": "date" },
        "note": { "type": "string" }
      }
    },
    "intFact": { "allOf": [{ "$ref": "#/$defs/fact" }, { "properties": { "value": { "type": ["integer", "null"], "minimum": 0 } } }] },
    "boolFact": { "allOf": [{ "$ref": "#/$defs/fact" }, { "properties": { "value": { "type": ["boolean", "null"] } } }] }
  },
  "properties": {
    "checkedAt": { "type": "string", "format": "date" },
    "providers": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "category", "freeType", "dailyLimit", "monthlyLimit", "sources"],
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "category": { "enum": ["esp", "mailbox"] },
          "onesendAdapter": { "type": ["string", "null"] },
          "planName": { "type": ["string", "null"] },
          "freeType": { "allOf": [{ "$ref": "#/$defs/fact" }, { "properties": { "value": { "enum": ["permanent", "trial", "one_time_credit", "none", "mailbox", null] } } }] },
          "dailyLimit": { "$ref": "#/$defs/intFact" },
          "monthlyLimit": { "$ref": "#/$defs/intFact" },
          "trialDays": { "$ref": "#/$defs/intFact" },
          "oneTimeCredit": { "$ref": "#/$defs/intFact" },
          "creditCardRequired": { "$ref": "#/$defs/boolFact" },
          "customDomainsOnFree": { "$ref": "#/$defs/intFact" },
          "domainApi": { "$ref": "#/$defs/boolFact" },
          "inboundOnFree": { "$ref": "#/$defs/boolFact" },
          "webhooksOnFree": { "$ref": "#/$defs/boolFact" },
          "marketingAllowedOnFree": { "$ref": "#/$defs/boolFact" },
          "logRetentionDaysOnFree": { "$ref": "#/$defs/intFact" },
          "conditions": { "type": "array", "items": { "type": "string" } },
          "conflicts": { "type": "array", "items": { "type": "object", "required": ["field", "detail", "sources"] } },
          "sources": { "type": "array", "items": { "type": "string", "format": "uri" } }
        }
      }
    }
  }
}
