add @bsky.app/sdk + @atproto/lex, vendor lexicons, codegen via lex cli

This commit is contained in:
Samuel Newman
2026-07-15 16:06:20 +03:00
parent 17c1ee4869
commit 15e232749a
306 changed files with 22544 additions and 2 deletions
+10
View File
@@ -0,0 +1,10 @@
{
"lexicon": 1,
"id": "com.atproto.sync.defs",
"defs": {
"hostStatus": {
"type": "string",
"knownValues": ["active", "idle", "offline", "throttled", "banned"]
}
}
}
+46
View File
@@ -0,0 +1,46 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getBlob",
"defs": {
"main": {
"type": "query",
"description": "Get a blob associated with a given account. Returns the full blob as originally uploaded. Does not require auth; implemented by PDS.",
"parameters": {
"type": "params",
"required": ["did", "cid"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the account."
},
"cid": {
"type": "string",
"format": "cid",
"description": "The CID of the blob to fetch"
}
}
},
"output": {
"encoding": "*/*"
},
"errors": [
{
"name": "BlobNotFound"
},
{
"name": "RepoNotFound"
},
{
"name": "RepoTakendown"
},
{
"name": "RepoSuspended"
},
{
"name": "RepoDeactivated"
}
]
}
}
}
+48
View File
@@ -0,0 +1,48 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getBlocks",
"defs": {
"main": {
"type": "query",
"description": "Get data blocks from a given repo, by CID. For example, intermediate MST nodes, or records. Does not require auth; implemented by PDS.",
"parameters": {
"type": "params",
"required": ["did", "cids"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
},
"cids": {
"type": "array",
"items": {
"type": "string",
"format": "cid"
}
}
}
},
"output": {
"encoding": "application/vnd.ipld.car"
},
"errors": [
{
"name": "BlockNotFound"
},
{
"name": "RepoNotFound"
},
{
"name": "RepoTakendown"
},
{
"name": "RepoSuspended"
},
{
"name": "RepoDeactivated"
}
]
}
}
}
@@ -0,0 +1,24 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getCheckout",
"defs": {
"main": {
"type": "query",
"description": "DEPRECATED - please use com.atproto.sync.getRepo instead",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
}
}
},
"output": {
"encoding": "application/vnd.ipld.car"
}
}
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getHead",
"defs": {
"main": {
"type": "query",
"description": "DEPRECATED - please use com.atproto.sync.getLatestCommit instead",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["root"],
"properties": {
"root": {
"type": "string",
"format": "cid"
}
}
}
},
"errors": [
{
"name": "HeadNotFound"
}
]
}
}
}
@@ -0,0 +1,49 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getHostStatus",
"defs": {
"main": {
"type": "query",
"description": "Returns information about a specified upstream host, as consumed by the server. Implemented by relays.",
"parameters": {
"type": "params",
"required": ["hostname"],
"properties": {
"hostname": {
"type": "string",
"description": "Hostname of the host (eg, PDS or relay) being queried."
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["hostname"],
"properties": {
"hostname": {
"type": "string"
},
"seq": {
"type": "integer",
"description": "Recent repo stream event sequence number. May be delayed from actual stream processing (eg, persisted cursor not in-memory cursor)."
},
"accountCount": {
"type": "integer",
"description": "Number of accounts on the server which are associated with the upstream host. Note that the upstream may actually have more accounts."
},
"status": {
"type": "ref",
"ref": "com.atproto.sync.defs#hostStatus"
}
}
}
},
"errors": [
{
"name": "HostNotFound"
}
]
}
}
}
@@ -0,0 +1,52 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getLatestCommit",
"defs": {
"main": {
"type": "query",
"description": "Get the current commit CID & revision of the specified repo. Does not require auth.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["cid", "rev"],
"properties": {
"cid": {
"type": "string",
"format": "cid"
},
"rev": {
"type": "string",
"format": "tid"
}
}
}
},
"errors": [
{
"name": "RepoNotFound"
},
{
"name": "RepoTakendown"
},
{
"name": "RepoSuspended"
},
{
"name": "RepoDeactivated"
}
]
}
}
}
+50
View File
@@ -0,0 +1,50 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getRecord",
"defs": {
"main": {
"type": "query",
"description": "Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.",
"parameters": {
"type": "params",
"required": ["did", "collection", "rkey"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
},
"collection": {
"type": "string",
"format": "nsid"
},
"rkey": {
"type": "string",
"description": "Record Key",
"format": "record-key"
}
}
},
"output": {
"encoding": "application/vnd.ipld.car"
},
"errors": [
{
"name": "RecordNotFound"
},
{
"name": "RepoNotFound"
},
{
"name": "RepoTakendown"
},
{
"name": "RepoSuspended"
},
{
"name": "RepoDeactivated"
}
]
}
}
}
+43
View File
@@ -0,0 +1,43 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getRepo",
"defs": {
"main": {
"type": "query",
"description": "Download a repository export as CAR file. Optionally only a 'diff' since a previous revision. Does not require auth; implemented by PDS.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
},
"since": {
"type": "string",
"format": "tid",
"description": "The revision ('rev') of the repo to create a diff from."
}
}
},
"output": {
"encoding": "application/vnd.ipld.car"
},
"errors": [
{
"name": "RepoNotFound"
},
{
"name": "RepoTakendown"
},
{
"name": "RepoSuspended"
},
{
"name": "RepoDeactivated"
}
]
}
}
}
@@ -0,0 +1,59 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getRepoStatus",
"defs": {
"main": {
"type": "query",
"description": "Get the hosting status for a repository, on this server. Expected to be implemented by PDS and Relay.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["did", "active"],
"properties": {
"did": {
"type": "string",
"format": "did"
},
"active": {
"type": "boolean"
},
"status": {
"type": "string",
"description": "If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.",
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"desynchronized",
"throttled"
]
},
"rev": {
"type": "string",
"format": "tid",
"description": "Optional field, the current rev of the repo, if active=true"
}
}
}
},
"errors": [
{
"name": "RepoNotFound"
}
]
}
}
}
+68
View File
@@ -0,0 +1,68 @@
{
"lexicon": 1,
"id": "com.atproto.sync.listBlobs",
"defs": {
"main": {
"type": "query",
"description": "List blob CIDs for an account, since some repo revision. Does not require auth; implemented by PDS.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did",
"description": "The DID of the repo."
},
"since": {
"type": "string",
"format": "tid",
"description": "Optional revision of the repo to list blobs since."
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 1000,
"default": 500
},
"cursor": {
"type": "string"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["cids"],
"properties": {
"cursor": {
"type": "string"
},
"cids": {
"type": "array",
"items": {
"type": "string",
"format": "cid"
}
}
}
}
},
"errors": [
{
"name": "RepoNotFound"
},
{
"name": "RepoTakendown"
},
{
"name": "RepoSuspended"
},
{
"name": "RepoDeactivated"
}
]
}
}
}
+65
View File
@@ -0,0 +1,65 @@
{
"lexicon": 1,
"id": "com.atproto.sync.listHosts",
"defs": {
"main": {
"type": "query",
"description": "Enumerates upstream hosts (eg, PDS or relay instances) that this service consumes from. Implemented by relays.",
"parameters": {
"type": "params",
"properties": {
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 1000,
"default": 200
},
"cursor": {
"type": "string"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["hosts"],
"properties": {
"cursor": {
"type": "string"
},
"hosts": {
"type": "array",
"items": {
"type": "ref",
"ref": "#host"
},
"description": "Sort order is not formally specified. Recommended order is by time host was first seen by the server, with oldest first."
}
}
}
}
},
"host": {
"type": "object",
"required": ["hostname"],
"properties": {
"hostname": {
"type": "string",
"description": "hostname of server; not a URL (no scheme)"
},
"seq": {
"type": "integer",
"description": "Recent repo stream event sequence number. May be delayed from actual stream processing (eg, persisted cursor not in-memory cursor)."
},
"accountCount": {
"type": "integer"
},
"status": {
"type": "ref",
"ref": "com.atproto.sync.defs#hostStatus"
}
}
}
}
}
+77
View File
@@ -0,0 +1,77 @@
{
"lexicon": 1,
"id": "com.atproto.sync.listRepos",
"defs": {
"main": {
"type": "query",
"description": "Enumerates all the DID, rev, and commit CID for all repos hosted by this service. Does not require auth; implemented by PDS and Relay.",
"parameters": {
"type": "params",
"properties": {
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 1000,
"default": 500
},
"cursor": {
"type": "string"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["repos"],
"properties": {
"cursor": {
"type": "string"
},
"repos": {
"type": "array",
"items": {
"type": "ref",
"ref": "#repo"
}
}
}
}
}
},
"repo": {
"type": "object",
"required": ["did", "head", "rev"],
"properties": {
"did": {
"type": "string",
"format": "did"
},
"head": {
"type": "string",
"format": "cid",
"description": "Current repo commit CID"
},
"rev": {
"type": "string",
"format": "tid"
},
"active": {
"type": "boolean"
},
"status": {
"type": "string",
"description": "If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.",
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"desynchronized",
"throttled"
]
}
}
}
}
}
@@ -0,0 +1,59 @@
{
"lexicon": 1,
"id": "com.atproto.sync.listReposByCollection",
"defs": {
"main": {
"type": "query",
"description": "Enumerates all the DIDs which have records with the given collection NSID.",
"parameters": {
"type": "params",
"required": ["collection"],
"properties": {
"collection": {
"type": "string",
"format": "nsid"
},
"limit": {
"type": "integer",
"description": "Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists.",
"minimum": 1,
"maximum": 2000,
"default": 500
},
"cursor": {
"type": "string"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["repos"],
"properties": {
"cursor": {
"type": "string"
},
"repos": {
"type": "array",
"items": {
"type": "ref",
"ref": "#repo"
}
}
}
}
}
},
"repo": {
"type": "object",
"required": ["did"],
"properties": {
"did": {
"type": "string",
"format": "did"
}
}
}
}
}
@@ -0,0 +1,23 @@
{
"lexicon": 1,
"id": "com.atproto.sync.notifyOfUpdate",
"defs": {
"main": {
"type": "procedure",
"description": "Notify a crawling service of a recent update, and that crawling should resume. Intended use is after a gap between repo stream events caused the crawling service to disconnect. Does not require auth; implemented by Relay. DEPRECATED: just use com.atproto.sync.requestCrawl",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["hostname"],
"properties": {
"hostname": {
"type": "string",
"description": "Hostname of the current service (usually a PDS) that is notifying of update."
}
}
}
}
}
}
}
@@ -0,0 +1,28 @@
{
"lexicon": 1,
"id": "com.atproto.sync.requestCrawl",
"defs": {
"main": {
"type": "procedure",
"description": "Request a service to persistently crawl hosted repos. Expected use is new PDS instances declaring their existence to Relays. Does not require auth.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["hostname"],
"properties": {
"hostname": {
"type": "string",
"description": "Hostname of the current service (eg, PDS) that is requesting to be crawled."
}
}
}
},
"errors": [
{
"name": "HostBanned"
}
]
}
}
}
@@ -0,0 +1,238 @@
{
"lexicon": 1,
"id": "com.atproto.sync.subscribeRepos",
"defs": {
"main": {
"type": "subscription",
"description": "Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay.",
"parameters": {
"type": "params",
"properties": {
"cursor": {
"type": "integer",
"description": "The last known event seq number to backfill from."
}
}
},
"message": {
"schema": {
"type": "union",
"refs": ["#commit", "#sync", "#identity", "#account", "#info"]
}
},
"errors": [
{
"name": "FutureCursor"
},
{
"name": "ConsumerTooSlow",
"description": "If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection."
}
]
},
"commit": {
"type": "object",
"description": "Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature.",
"required": [
"seq",
"rebase",
"tooBig",
"repo",
"commit",
"rev",
"since",
"blocks",
"ops",
"blobs",
"time"
],
"nullable": ["since"],
"properties": {
"seq": {
"type": "integer",
"description": "The stream sequence number of this message."
},
"rebase": {
"type": "boolean",
"description": "DEPRECATED -- unused"
},
"tooBig": {
"type": "boolean",
"description": "DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data."
},
"repo": {
"type": "string",
"format": "did",
"description": "The repo this event comes from. Note that all other message types name this field 'did'."
},
"commit": {
"type": "cid-link",
"description": "Repo commit object CID."
},
"rev": {
"type": "string",
"format": "tid",
"description": "The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event."
},
"since": {
"type": "string",
"format": "tid",
"description": "The rev of the last emitted commit from this repo (if any)."
},
"blocks": {
"type": "bytes",
"description": "CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.",
"maxLength": 2000000
},
"ops": {
"type": "array",
"items": {
"type": "ref",
"ref": "#repoOp",
"description": "List of repo mutation operations in this commit (eg, records created, updated, or deleted)."
},
"maxLength": 200
},
"blobs": {
"type": "array",
"items": {
"type": "cid-link",
"description": "DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit."
}
},
"prevData": {
"type": "cid-link",
"description": "The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose."
},
"time": {
"type": "string",
"format": "datetime",
"description": "Timestamp of when this message was originally broadcast."
}
}
},
"sync": {
"type": "object",
"description": "Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository.",
"required": ["seq", "did", "blocks", "rev", "time"],
"properties": {
"seq": {
"type": "integer",
"description": "The stream sequence number of this message."
},
"did": {
"type": "string",
"format": "did",
"description": "The account this repo event corresponds to. Must match that in the commit object."
},
"blocks": {
"type": "bytes",
"description": "CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.",
"maxLength": 10000
},
"rev": {
"type": "string",
"description": "The rev of the commit. This value must match that in the commit object."
},
"time": {
"type": "string",
"format": "datetime",
"description": "Timestamp of when this message was originally broadcast."
}
}
},
"identity": {
"type": "object",
"description": "Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache.",
"required": ["seq", "did", "time"],
"properties": {
"seq": {
"type": "integer"
},
"did": {
"type": "string",
"format": "did"
},
"time": {
"type": "string",
"format": "datetime"
},
"handle": {
"type": "string",
"format": "handle",
"description": "The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details."
}
}
},
"account": {
"type": "object",
"description": "Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active.",
"required": ["seq", "did", "time", "active"],
"properties": {
"seq": {
"type": "integer"
},
"did": {
"type": "string",
"format": "did"
},
"time": {
"type": "string",
"format": "datetime"
},
"active": {
"type": "boolean",
"description": "Indicates that the account has a repository which can be fetched from the host that emitted this event."
},
"status": {
"type": "string",
"description": "If active=false, this optional field indicates a reason for why the account is not active.",
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"desynchronized",
"throttled"
]
}
}
},
"info": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string",
"knownValues": ["OutdatedCursor"]
},
"message": {
"type": "string"
}
}
},
"repoOp": {
"type": "object",
"description": "A repo operation, ie a mutation of a single record.",
"required": ["action", "path", "cid"],
"nullable": ["cid"],
"properties": {
"action": {
"type": "string",
"knownValues": ["create", "update", "delete"]
},
"path": {
"type": "string"
},
"cid": {
"type": "cid-link",
"description": "For creates and updates, the new record CID. For deletions, null."
},
"prev": {
"type": "cid-link",
"description": "For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined."
}
}
}
}
}