{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://staticapi.gracesoft.dev/schemas/product-blueprint-1.json",
  "title": "GraceSoft product blueprint v1",
  "description": "A short, reviewed description of one GraceSoft product. Concierge's fallback knowledge source when the product has no Footing content feed.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "product",
    "name",
    "tagline",
    "status",
    "published",
    "version",
    "reviewed_at",
    "cite_url",
    "summary",
    "features",
    "links"
  ],
  "properties": {
    "schema": { "const": "gracesoft.product-blueprint/1" },
    "product": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "maxLength": 40 },
    "name": { "type": "string", "minLength": 1, "maxLength": 60 },
    "tagline": { "type": "string", "minLength": 1, "maxLength": 140 },
    "status": { "enum": ["planned", "early_access", "beta", "live", "sunset"] },
    "published": { "type": "boolean" },
    "version": { "type": "integer", "minimum": 1 },
    "reviewed_at": { "$ref": "#/$defs/date" },
    "cite_url": { "$ref": "#/$defs/httpsUrl" },
    "summary": { "type": "string", "minLength": 1, "maxLength": 3000 },
    "audience": {
      "type": "array",
      "maxItems": 10,
      "items": { "type": "string", "minLength": 1, "maxLength": 120 }
    },
    "features": {
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": { "$ref": "#/$defs/feature" }
    },
    "not_offered": {
      "type": "array",
      "maxItems": 30,
      "items": { "type": "string", "minLength": 1, "maxLength": 200 }
    },
    "plans": {
      "type": "array",
      "maxItems": 10,
      "items": { "$ref": "#/$defs/plan" }
    },
    "pricing_note": { "type": "string", "maxLength": 500 },
    "privacy_highlights": {
      "type": "array",
      "maxItems": 10,
      "items": { "type": "string", "minLength": 1, "maxLength": 240 }
    },
    "links": { "$ref": "#/$defs/links" },
    "faq": {
      "type": "array",
      "maxItems": 30,
      "items": { "$ref": "#/$defs/faqEntry" }
    },
    "changelog": {
      "type": "array",
      "maxItems": 50,
      "items": { "$ref": "#/$defs/changelogEntry" }
    },
    "sunset": {
      "type": "object",
      "additionalProperties": false,
      "required": ["date", "note"],
      "properties": {
        "date": { "$ref": "#/$defs/date" },
        "note": { "type": "string", "minLength": 1, "maxLength": 500 }
      }
    }
  },
  "allOf": [
    {
      "if": { "properties": { "status": { "const": "sunset" } }, "required": ["status"] },
      "then": { "required": ["sunset"] }
    },
    {
      "if": { "properties": { "status": { "const": "planned" } }, "required": ["status"] },
      "then": { "properties": { "plans": { "maxItems": 0 } } }
    },
    {
      "if": {
        "properties": { "status": { "enum": ["early_access", "beta", "live"] } },
        "required": ["status"]
      },
      "then": { "properties": { "links": { "required": ["terms", "privacy"] } } }
    }
  ],
  "$defs": {
    "date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$", "format": "date" },
    "httpsUrl": { "type": "string", "format": "uri", "pattern": "^https://", "maxLength": 500 },
    "planKey": { "type": "string", "pattern": "^[a-z0-9_-]+$", "maxLength": 30 },
    "feature": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "description", "availability"],
      "properties": {
        "name": { "type": "string", "minLength": 1, "maxLength": 80 },
        "description": { "type": "string", "minLength": 1, "maxLength": 400 },
        "availability": { "enum": ["available", "planned"] },
        "plans": {
          "type": "array",
          "uniqueItems": true,
          "items": { "$ref": "#/$defs/planKey" }
        }
      }
    },
    "plan": {
      "type": "object",
      "additionalProperties": false,
      "required": ["key", "name", "price", "currency", "interval"],
      "properties": {
        "key": { "$ref": "#/$defs/planKey" },
        "name": { "type": "string", "minLength": 1, "maxLength": 40 },
        "price": { "type": ["number", "null"], "minimum": 0 },
        "currency": { "type": "string", "pattern": "^[A-Z]{3}$" },
        "interval": { "enum": ["month", "year", "one_time", null] },
        "features": {
          "type": "array",
          "maxItems": 20,
          "items": { "type": "string", "minLength": 1, "maxLength": 160 }
        },
        "max_members": { "type": ["integer", "null"], "minimum": 1 },
        "note": { "type": "string", "maxLength": 240 }
      }
    },
    "links": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "landing": { "$ref": "#/$defs/httpsUrl" },
        "pricing": { "$ref": "#/$defs/httpsUrl" },
        "signup": { "$ref": "#/$defs/httpsUrl" },
        "docs": { "$ref": "#/$defs/httpsUrl" },
        "terms": { "$ref": "#/$defs/httpsUrl" },
        "privacy": { "$ref": "#/$defs/httpsUrl" },
        "status": { "$ref": "#/$defs/httpsUrl" }
      }
    },
    "faqEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["q", "a"],
      "properties": {
        "q": { "type": "string", "minLength": 1, "maxLength": 200 },
        "a": { "type": "string", "minLength": 1, "maxLength": 1200 }
      }
    },
    "changelogEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["date", "summary"],
      "properties": {
        "date": { "$ref": "#/$defs/date" },
        "summary": { "type": "string", "minLength": 1, "maxLength": 300 }
      }
    }
  }
}
