{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://create-my-saas.dev/schemas/template-manifest-v1.json",
  "title": "create-my-saas template manifest",
  "description": "Metadata a generator uses to discover and combine starter templates.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "id",
    "version",
    "kind",
    "displayName",
    "description",
    "runtime",
    "capabilities",
    "environment"
  ],
  "properties": {
    "$schema": { "type": "string" },
    "schemaVersion": { "const": 1 },
    "id": {
      "type": "string",
      "pattern": "^(backend|frontend):[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?$"
    },
    "kind": { "enum": ["backend", "frontend"] },
    "displayName": { "type": "string", "minLength": 1 },
    "description": { "type": "string", "minLength": 1 },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": ["language", "packageManager"],
      "properties": {
        "language": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 },
        "packageManager": { "type": "string", "minLength": 1 }
      }
    },
    "capabilities": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)*$"
      }
    },
    "development": {
      "type": "object",
      "additionalProperties": false,
      "required": ["port", "baseUrl"],
      "properties": {
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
        "baseUrl": { "type": "string", "pattern": "^https?://[^/]+(?:/.*)?$" }
      }
    },
    "compatibility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["requiresBackendCapabilities"],
      "properties": {
        "requiresBackendCapabilities": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)*$"
          }
        }
      }
    },
    "features": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "description", "capabilities", "requiresBackendCapabilities"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
          "description": { "type": "string", "minLength": 1 },
          "capabilities": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)*$" }
          },
          "requiresBackendCapabilities": {
            "type": "array",
            "uniqueItems": true,
            "items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)*$" }
          }
        }
      }
    },
    "environment": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required"],
      "properties": {
        "required": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "secret", "description"],
            "properties": {
              "name": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" },
              "secret": { "type": "boolean" },
              "description": { "type": "string", "minLength": 1 }
            }
          }
        }
      }
    }
  }
}
