{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://forgecascade.org/offers.schema.json",
  "title": "Forge Cascade paid offer catalog",
  "description": "Machine-readable schema for Forge offer catalog entries, same-origin buy routes, and Stripe checkout fallbacks.",
  "type": "object",
  "required": [
    "$schema",
    "updated",
    "currency",
    "checkout_routes",
    "recommended_first_checkout",
    "recommended_quick_checkout",
    "fast_paid_starts",
    "offers",
    "invoice_request"
  ],
  "properties": {
    "$schema": {
      "const": "https://forgecascade.org/offers.schema.json"
    },
    "updated": {
      "type": "string"
    },
    "currency": {
      "const": "USD"
    },
    "contact": {
      "type": "string"
    },
    "pricing": {
      "type": "string",
      "format": "uri"
    },
    "buy_json": {
      "type": "string",
      "format": "uri"
    },
    "buy_page": {
      "type": "string",
      "format": "uri"
    },
    "buy_html": {
      "type": "string",
      "format": "uri"
    },
    "checkout_page": {
      "type": "string",
      "format": "uri"
    },
    "checkout_html": {
      "type": "string",
      "format": "uri"
    },
    "checkout_routes": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://forgecascade\\.org/buy/"
      }
    },
    "recommended_first_checkout": {
      "$ref": "#/$defs/offer"
    },
    "recommended_quick_checkout": {
      "$ref": "#/$defs/offer"
    },
    "fast_paid_starts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/offer"
      }
    },
    "offers": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/offer"
      }
    },
    "proof_links": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/proof_link"
      }
    },
    "invoice_request": {
      "type": "object",
      "required": [
        "label",
        "email",
        "href"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "subject": {
          "type": "string"
        },
        "href": {
          "type": "string",
          "pattern": "^mailto:"
        }
      },
      "additionalProperties": true
    }
  },
  "$defs": {
    "proof_link": {
      "type": "object",
      "required": [
        "name",
        "url",
        "status"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "status": {
          "const": "live_listing"
        },
        "kind": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "offer": {
      "type": "object",
      "required": [
        "name",
        "price",
        "route_url",
        "checkout_url"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "price": {
          "type": "number",
          "minimum": 0
        },
        "cadence": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "preferred_url": {
          "type": "string",
          "format": "uri"
        },
        "route_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://forgecascade\\.org/buy/"
        },
        "checkout_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://buy\\.stripe\\.com/"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
