{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://spec.soustack.org/stacks/equipment.schema.json",
  "title": "Equipment Stack",
  "type": "object",
  "properties": {
    "equipment": {
      "type": "array",
      "minItems": 1,
      "items": {
        "anyOf": [
          { "type": "string", "minLength": 1 },
          { "$ref": "#/$defs/equipmentItem" }
        ]
      }
    }
  },
  "required": ["equipment"],
  "$defs": {
    "equipmentItem": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._-]+$",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "count": {
          "type": "integer",
          "minimum": 1
        },
        "countScaling": {
          "oneOf": [
            { "type": "string", "enum": ["fixed", "linear"] },
            {
              "type": "object",
              "properties": {
                "mode": { "const": "threshold" },
                "steps": {
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "type": "object",
                    "properties": {
                      "maxFactor": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 1
                      }
                    },
                    "required": ["maxFactor", "count"],
                    "additionalProperties": false
                  }
                }
              },
              "required": ["mode", "steps"],
              "additionalProperties": false
            }
          ]
        },
        "upgrades": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "properties": {
              "minFactor": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "use": {
                "type": "string",
                "pattern": "^[A-Za-z0-9._-]+$",
                "minLength": 1
              }
            },
            "required": ["minFactor", "use"],
            "additionalProperties": false
          }
        }
      },
      "required": ["id", "name"],
      "additionalProperties": false,
      "patternProperties": {
        "^x-": { "$ref": "../defs/common.schema.json#/properties/extensionLaneValue" }
      }
    }
  },
  "additionalProperties": false
}

