{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ggaction.github.io/ggaction/schemas/action-card.schema.json",
  "title": "ggaction compact action card",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "name",
    "layer",
    "domain",
    "summary",
    "signature",
    "intents",
    "lifecycle",
    "resources",
    "authoringRoles",
    "wraps",
    "editableVia",
    "supports",
    "units",
    "inference",
    "completionRequirements",
    "options",
    "callPatterns",
    "snippet",
    "errors",
    "route"
  ],
  "properties": {
    "schemaVersion": { "const": 3 },
    "name": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]*$" },
    "layer": { "enum": ["user-facing", "advanced", "primitive"] },
    "domain": { "type": "string", "minLength": 1 },
    "summary": { "type": "string", "minLength": 20, "maxLength": 420 },
    "signature": { "type": "string", "minLength": 10 },
    "intents": {
      "type": "array",
      "minItems": 3,
      "maxItems": 7,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 2, "maxLength": 80 }
    },
    "lifecycle": { "type": "string", "minLength": 3 },
    "resources": {
      "type": "object",
      "additionalProperties": false,
      "required": ["prerequisites", "owns", "idOptions"],
      "properties": {
        "prerequisites": {
          "type": "array",
          "maxItems": 4,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 2, "maxLength": 100 }
        },
        "owns": {
          "type": "array",
          "maxItems": 3,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 2, "maxLength": 80 }
        },
        "idOptions": {
          "type": "array",
          "maxItems": 10,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 2, "maxLength": 30 }
        }
      }
    },
    "authoringRoles": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "uniqueItems": true,
      "items": { "enum": ["H0", "H1", "H2", "H3", "H4"] }
    },
    "wraps": {
      "type": "array",
      "maxItems": 20,
      "uniqueItems": true,
      "items": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]*$" }
    },
    "editableVia": {
      "type": "array",
      "maxItems": 20,
      "uniqueItems": true,
      "items": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]*$" }
    },
    "supports": {
      "type": "object",
      "additionalProperties": false,
      "required": ["entryPoints"],
      "properties": {
        "entryPoints": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2,
          "uniqueItems": true,
          "items": { "enum": ["default", "basic"] }
        }
      }
    },
    "units": {
      "type": "array",
      "maxItems": 16,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "unit"],
        "properties": {
          "path": { "type": "string", "minLength": 1, "maxLength": 80 },
          "unit": {
            "enum": [
              "logical-pixel",
              "degree",
              "angle",
              "ratio",
              "probability",
              "count",
              "calendar-unit",
              "temporal-input",
              "data-value",
              "band-fraction"
            ]
          }
        }
      }
    },
    "inference": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["input", "strategy"],
        "properties": {
          "input": { "type": "string", "minLength": 1, "maxLength": 80 },
          "strategy": {
            "enum": [
              "explicit",
              "explicit-or-current",
              "explicit-current-unique-or-error",
              "documented-auto",
              "documented-default"
            ]
          }
        }
      }
    },
    "completionRequirements": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "requires", "allowsEmpty"],
      "properties": {
        "state": { "enum": ["complete", "deferred", "contextual", "not-applicable"] },
        "requires": {
          "type": "array",
          "maxItems": 4,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 2, "maxLength": 100 }
        },
        "allowsEmpty": { "type": "boolean" }
      }
    },
    "options": {
      "type": "array",
      "maxItems": 40,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "required", "type"],
        "properties": {
          "name": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9]*$" },
          "required": { "type": "boolean" },
          "type": { "type": "string", "minLength": 1, "maxLength": 500 }
        }
      }
    },
    "callPatterns": {
      "type": "array",
      "minItems": 1,
      "maxItems": 2,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 3, "maxLength": 260 }
    },
    "snippet": { "type": "string", "minLength": 3, "maxLength": 700 },
    "errors": {
      "type": "array",
      "maxItems": 2,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["error", "fix"],
        "properties": {
          "error": { "type": "string", "minLength": 5, "maxLength": 220 },
          "fix": { "type": "string", "minLength": 5, "maxLength": 220 }
        }
      }
    },
    "route": { "type": "string", "pattern": "^/reference/" }
  }
}
