{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://basecamp.sh/schema/basecamp-lock.json",
  "title": "Basecamp Lock",
  "type": "object",
  "required": [
    "schema",
    "environment_id",
    "stack",
    "host",
    "target",
    "runtime",
    "inputs",
    "layers"
  ],
  "properties": {
    "schema": {
      "const": 1
    },
    "environment_id": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "stack": {
      "type": "string"
    },
    "host": {
      "type": "string"
    },
    "target": {
      "type": "string"
    },
    "runtime": {
      "type": "object",
      "required": [
        "name",
        "version"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "inputs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/input"
      },
      "minItems": 1
    },
    "layers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/layer"
      },
      "minItems": 1
    }
  },
  "$defs": {
    "input": {
      "type": "object",
      "required": [
        "kind",
        "path",
        "digest"
      ],
      "properties": {
        "kind": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "digest": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    },
    "layer": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "name",
        "source",
        "materialize"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "kind": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "materialize": {
          "type": "object",
          "required": [
            "format"
          ],
          "properties": {
            "format": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        "depends_on": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      },
      "additionalProperties": false
    },
    "source": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "type",
            "url",
            "sha256"
          ],
          "properties": {
            "type": {
              "const": "url"
            },
            "url": {
              "type": "string"
            },
            "sha256": {
              "type": "string",
              "pattern": "^sha256:[a-f0-9]{64}$"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "type",
            "ecosystem",
            "lock_digest"
          ],
          "properties": {
            "type": {
              "const": "registry"
            },
            "ecosystem": {
              "type": "string"
            },
            "lock_digest": {
              "type": "string",
              "pattern": "^sha256:[a-f0-9]{64}$"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "type",
            "url",
            "sha256"
          ],
          "properties": {
            "type": {
              "const": "basecamp"
            },
            "url": {
              "type": "string"
            },
            "sha256": {
              "type": "string",
              "pattern": "^sha256:[a-f0-9]{64}$"
            }
          },
          "additionalProperties": false
        }
      ]
    }
  },
  "additionalProperties": false
}
