{
  "lexicon": 1,
  "id": "sh.tangled.git.listRefs",
  "defs": {
    "main": {
      "type": "query",
      "description": "List every ref & its commit SHA for a git repo, equivalent to git ls-remote. Gives the full ref state of a repo.",
      "parameters": {
        "type": "params",
        "required": ["repo"],
        "properties": {
          "repo": {
            "type": "string",
            "format": "did",
            "description": "DID of the git repo as minted by the knot"
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 100,
            "description": "Maximum number of refs to return in this page"
          },
          "cursor": {
            "type": "string",
            "description": "Pagination cursor"
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["refs"],
          "properties": {
            "refs": {
              "type": "array",
              "items": { "type": "ref", "ref": "#ref" },
              "maxLength": 1000
            },
            "cursor": {
              "type": "string",
              "description": "Cursor for the next page, absent when the last page is reached"
            },
            "defaultBranch": {
              "type": "ref",
              "ref": "#defaultBranch"
            }
          }
        }
      },
      "errors": [
        {
          "name": "RepoNotFound",
          "description": "Repo is not registered on this knot"
        },
        {
          "name": "InvalidRequest",
          "description": "Invalid request parameters"
        }
      ]
    },
    "ref": {
      "type": "object",
      "required": ["ref", "sha"],
      "properties": {
        "ref": {
          "type": "string",
          "description": "Full ref name, eg. refs/heads/main or refs/tags/v1.0",
          "maxGraphemes": 256,
          "maxLength": 2560
        },
        "sha": {
          "type": "string",
          "description": "Object SHA the ref points at. Width depends on the repo's git object-format.",
          "minLength": 40,
          "maxLength": 128
        }
      }
    },
    "defaultBranch": {
      "type": "object",
      "required": ["ref"],
      "properties": {
        "ref": {
          "type": "string",
          "description": "Default branch ref name that HEAD points at, eg. refs/heads/main.",
          "maxGraphemes": 256,
          "maxLength": 2560
        },
        "head": {
          "type": "string",
          "description": "Commit SHA at the tip of the default branch, for reconciling against a last-known state. Width depends on the repo's git object-format.",
          "minLength": 40,
          "maxLength": 128
        }
      }
    }
  }
}
