{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/tier-run-pricing-json/latest.json",
  "title": "Pricing Model",
  "description": "A pricing.json model definition used by tier",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/tierrun/tier/main/pricing/schema.json",
    "sourceSha256": "436ea23a676832f28aa54469bfd6215b8fae0fd8cd24b44dfb342b300ad67ade",
    "fileMatch": [
      "pricing.json"
    ],
    "parsers": [
      "json"
    ]
  },
  "type": "object",
  "properties": {
    "plans": {
      "description": "The collection of all defined plans",
      "type": "object",
      "propertyNames": {
        "pattern": "^plan:[a-zA-Z0-9:]+@[a-zA-Z0-9]+$"
      },
      "patternProperties": {
        "": {
          "$ref": "#/$defs/plan"
        }
      }
    }
  },
  "$defs": {
    "plan": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "currency": {
          "type": "string"
        },
        "interval": {
          "enum": [
            "@daily",
            "@weekly",
            "@monthly",
            "@yearly"
          ]
        },
        "features": {
          "type": "object",
          "propertyNames": {
            "pattern": "^feature:[a-zA-Z0-9:]+$"
          },
          "patternProperties": {
            "": {
              "$ref": "#/$defs/feature"
            }
          }
        }
      },
      "additionalProperties": false
    },
    "feature": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "aggregate": {
          "enum": [
            "sum",
            "max",
            "last",
            "perpetual"
          ]
        },
        "mode": {
          "enum": [
            "graduated",
            "volume"
          ]
        },
        "base": {
          "type": "number"
        },
        "tiers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tier"
          }
        },
        "divide": {
          "type": "object",
          "properties": {
            "by": {
              "type": "number"
            },
            "rounding": {
              "enum": [
                "up"
              ]
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "tier": {
      "type": "object",
      "properties": {
        "upto": {
          "type": "number"
        },
        "price": {
          "type": "number"
        },
        "base": {
          "type": "number"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
