···11+import "@tlex/emitter";
22+33+namespace com.atproto.identity.requestPlcOperationSignature {
44+ @doc("Request an email with a code to in order to request a signed PLC operation. Requires Auth.")
55+ @procedure
66+ op main(): void;
77+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.identity.submitPlcOperation {
44+ @doc("Validates a PLC operation to ensure that it doesn't violate a service's constraints or get the identity into a bad state, then submits it to the PLC registry")
55+ @procedure
66+ op main(input: {
77+ @required operation: unknown;
88+ }): void;
99+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.repo.importRepo {
44+ @doc("Import a repo in the form of a CAR file. Requires Content-Length HTTP header to be set.")
55+ @procedure
66+ op main(
77+ @encoding("application/vnd.ipld.car")
88+ input: void
99+ ): void;
1010+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.repo.uploadBlob {
44+ @doc("Upload a new blob, to be referenced from a repository record. The blob will be deleted if it is not referenced within a time window (eg, minutes). Blob restrictions (mimetype, size, etc) are enforced when the reference is created. Requires auth, implemented by PDS.")
55+ @procedure
66+ op main(
77+ @encoding("*/*")
88+ input: void
99+ ): {
1010+ @required blob: Blob<#[], 0>;
1111+ };
1212+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.getBlob {
44+ @doc("Get a blob associated with a given account. Returns the full blob as originally uploaded. Does not require auth; implemented by PDS.")
55+ @query
66+ @encoding("*/*")
77+ @errors(BlobNotFound, RepoNotFound, RepoTakendown, RepoSuspended, RepoDeactivated)
88+ op main(
99+ @doc("The DID of the account.")
1010+ @required
1111+ did: did,
1212+1313+ @doc("The CID of the blob to fetch")
1414+ @required
1515+ cid: cid
1616+ ): void;
1717+1818+ model BlobNotFound {}
1919+ model RepoNotFound {}
2020+ model RepoTakendown {}
2121+ model RepoSuspended {}
2222+ model RepoDeactivated {}
2323+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.getBlocks {
44+ @doc("Get data blocks from a given repo, by CID. For example, intermediate MST nodes, or records. Does not require auth; implemented by PDS.")
55+ @query
66+ @encoding("application/vnd.ipld.car")
77+ @errors(BlockNotFound, RepoNotFound, RepoTakendown, RepoSuspended, RepoDeactivated)
88+ op main(
99+ @doc("The DID of the repo.")
1010+ @required
1111+ did: did,
1212+1313+ @required cids: cid[]
1414+ ): void;
1515+1616+ model BlockNotFound {}
1717+ model RepoNotFound {}
1818+ model RepoTakendown {}
1919+ model RepoSuspended {}
2020+ model RepoDeactivated {}
2121+}
···11+import "@tlex/emitter";
22+import "./defs.tsp";
33+44+namespace com.atproto.sync.getHostStatus {
55+ @doc("Returns information about a specified upstream host, as consumed by the server. Implemented by relays.")
66+ @query
77+ @errors(HostNotFound)
88+ op main(
99+ @doc("Hostname of the host (eg, PDS or relay) being queried.")
1010+ @required
1111+ hostname: string
1212+ ): {
1313+ @required hostname: string;
1414+1515+ @doc("Recent repo stream event sequence number. May be delayed from actual stream processing (eg, persisted cursor not in-memory cursor).")
1616+ seq?: integer;
1717+1818+ @doc("Number of accounts on the server which are associated with the upstream host. Note that the upstream may actually have more accounts.")
1919+ accountCount?: integer;
2020+2121+ status?: com.atproto.sync.defs.HostStatus;
2222+ };
2323+2424+ model HostNotFound {}
2525+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.getLatestCommit {
44+ @doc("Get the current commit CID & revision of the specified repo. Does not require auth.")
55+ @query
66+ @errors(RepoNotFound, RepoTakendown, RepoSuspended, RepoDeactivated)
77+ op main(
88+ @doc("The DID of the repo.")
99+ @required
1010+ did: did
1111+ ): {
1212+ @required cid: cid;
1313+ @required rev: tid;
1414+ };
1515+1616+ model RepoNotFound {}
1717+ model RepoTakendown {}
1818+ model RepoSuspended {}
1919+ model RepoDeactivated {}
2020+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.getRecord {
44+ @doc("Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.")
55+ @query
66+ @encoding("application/vnd.ipld.car")
77+ @errors(RecordNotFound, RepoNotFound, RepoTakendown, RepoSuspended, RepoDeactivated)
88+ op main(
99+ @doc("The DID of the repo.")
1010+ @required
1111+ did: did,
1212+1313+ @required collection: nsid,
1414+1515+ @doc("Record Key")
1616+ @required
1717+ rkey: recordKey
1818+ ): void;
1919+2020+ model RecordNotFound {}
2121+ model RepoNotFound {}
2222+ model RepoTakendown {}
2323+ model RepoSuspended {}
2424+ model RepoDeactivated {}
2525+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.getRepo {
44+ @doc("Download a repository export as CAR file. Optionally only a 'diff' since a previous revision. Does not require auth; implemented by PDS.")
55+ @query
66+ @encoding("application/vnd.ipld.car")
77+ @errors(RepoNotFound, RepoTakendown, RepoSuspended, RepoDeactivated)
88+ op main(
99+ @doc("The DID of the repo.")
1010+ @required
1111+ did: did,
1212+1313+ @doc("The revision ('rev') of the repo to create a diff from.")
1414+ since?: tid
1515+ ): void;
1616+1717+ model RepoNotFound {}
1818+ model RepoTakendown {}
1919+ model RepoSuspended {}
2020+ model RepoDeactivated {}
2121+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.getRepoStatus {
44+ @doc("Get the hosting status for a repository, on this server. Expected to be implemented by PDS and Relay.")
55+ @query
66+ @errors(RepoNotFound)
77+ op main(
88+ @doc("The DID of the repo.")
99+ @required
1010+ did: did
1111+ ): {
1212+ @required did: did;
1313+ @required active: boolean;
1414+1515+ @doc("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.")
1616+ status?: "takendown" | "suspended" | "deleted" | "deactivated" | "desynchronized" | "throttled" | string;
1717+1818+ @doc("Optional field, the current rev of the repo, if active=true")
1919+ rev?: tid;
2020+ };
2121+2222+ model RepoNotFound {}
2323+}
···11+import "@tlex/emitter";
22+import "./defs.tsp";
33+44+namespace com.atproto.sync.listHosts {
55+ @doc("Enumerates upstream hosts (eg, PDS or relay instances) that this service consumes from. Implemented by relays.")
66+ @query
77+ op main(
88+ @minValue(1)
99+ @maxValue(1000)
1010+ limit?: int32 = 200,
1111+1212+ cursor?: string
1313+ ): {
1414+ cursor?: string;
1515+1616+ @doc("Sort order is not formally specified. Recommended order is by time host was first seen by the server, with oldest first.")
1717+ @required
1818+ hosts: Host[];
1919+ };
2020+2121+ model Host {
2222+ @doc("hostname of server; not a URL (no scheme)")
2323+ @required
2424+ hostname: string;
2525+2626+ @doc("Recent repo stream event sequence number. May be delayed from actual stream processing (eg, persisted cursor not in-memory cursor).")
2727+ seq?: integer;
2828+2929+ accountCount?: integer;
3030+ status?: com.atproto.sync.defs.HostStatus;
3131+ }
3232+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.listRepos {
44+ @doc("Enumerates all the DID, rev, and commit CID for all repos hosted by this service. Does not require auth; implemented by PDS and Relay.")
55+ @query
66+ op main(
77+ @minValue(1)
88+ @maxValue(1000)
99+ limit?: int32 = 500,
1010+1111+ cursor?: string
1212+ ): {
1313+ cursor?: string;
1414+ @required repos: Repo[];
1515+ };
1616+1717+ model Repo {
1818+ @required did: did;
1919+2020+ @doc("Current repo commit CID")
2121+ @required
2222+ head: cid;
2323+2424+ @required rev: tid;
2525+ active?: boolean;
2626+2727+ @doc("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.")
2828+ status?: "takendown" | "suspended" | "deleted" | "deactivated" | "desynchronized" | "throttled" | string;
2929+ }
3030+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.listReposByCollection {
44+ @doc("Enumerates all the DIDs which have records with the given collection NSID.")
55+ @query
66+ op main(
77+ @required collection: nsid,
88+99+ @doc("Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists.")
1010+ @minValue(1)
1111+ @maxValue(2000)
1212+ limit?: int32 = 500,
1313+1414+ cursor?: string
1515+ ): {
1616+ cursor?: string;
1717+ @required repos: Repo[];
1818+ };
1919+2020+ model Repo {
2121+ @required did: did;
2222+ }
2323+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.notifyOfUpdate {
44+ @doc("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")
55+ @procedure
66+ op main(input: {
77+ @doc("Hostname of the current service (usually a PDS) that is notifying of update.")
88+ @required
99+ hostname: string;
1010+ }): void;
1111+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.requestCrawl {
44+ @doc("Request a service to persistently crawl hosted repos. Expected use is new PDS instances declaring their existence to Relays. Does not require auth.")
55+ @procedure
66+ @errors(HostBanned)
77+ op main(input: {
88+ @doc("Hostname of the current service (eg, PDS) that is requesting to be crawled.")
99+ @required
1010+ hostname: string;
1111+ }): void;
1212+1313+ model HostBanned {}
1414+}
···11+import "@tlex/emitter";
22+33+namespace com.atproto.sync.subscribeRepos {
44+ @subscription
55+ @errors(FutureCursor, ConsumerTooSlow)
66+ @doc("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.")
77+ op main(
88+ @doc("The last known event seq number to backfill from.")
99+ cursor?: integer
1010+ ): (Commit | Sync | Identity | Account | Info | unknown);
1111+1212+ model FutureCursor {}
1313+1414+ @doc("If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.")
1515+ model ConsumerTooSlow {}
1616+1717+ @doc("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.")
1818+ model Commit {
1919+ @doc("The stream sequence number of this message.")
2020+ @required
2121+ seq: integer;
2222+2323+ @doc("DEPRECATED -- unused")
2424+ @required
2525+ rebase: boolean;
2626+2727+ @doc("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.")
2828+ @required
2929+ tooBig: boolean;
3030+3131+ @doc("The repo this event comes from. Note that all other message types name this field 'did'.")
3232+ @required
3333+ repo: did;
3434+3535+ @doc("Repo commit object CID.")
3636+ @required
3737+ commit: cidLink;
3838+3939+ @doc("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.")
4040+ @required
4141+ rev: tid;
4242+4343+ @doc("The rev of the last emitted commit from this repo (if any).")
4444+ @required
4545+ since: tid | null;
4646+4747+ @doc("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.")
4848+ @bytesMaxLength(2000000)
4949+ @required
5050+ blocks: bytes;
5151+5252+ @maxItems(200)
5353+ @required
5454+ @doc("List of repo mutation operations in this commit (eg, records created, updated, or deleted).")
5555+ ops: RepoOp[];
5656+5757+ @doc("DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.")
5858+ @required blobs: cidLink[];
5959+6060+ @doc("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.")
6161+ prevData?: cidLink;
6262+6363+ @doc("Timestamp of when this message was originally broadcast.")
6464+ @required
6565+ time: datetime;
6666+ }
6767+6868+ @doc("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.")
6969+ model Sync {
7070+ @doc("The stream sequence number of this message.")
7171+ @required
7272+ seq: integer;
7373+7474+ @doc("The account this repo event corresponds to. Must match that in the commit object.")
7575+ @required
7676+ did: did;
7777+7878+ @doc("CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.")
7979+ @bytesMaxLength(10000)
8080+ @required
8181+ blocks: bytes;
8282+8383+ @doc("The rev of the commit. This value must match that in the commit object.")
8484+ @required
8585+ rev: string;
8686+8787+ @doc("Timestamp of when this message was originally broadcast.")
8888+ @required
8989+ time: datetime;
9090+ }
9191+9292+ @doc("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.")
9393+ model Identity {
9494+ @required seq: integer;
9595+ @required did: did;
9696+ @required time: datetime;
9797+9898+ @doc("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.")
9999+ handle?: handle;
100100+ }
101101+102102+ @doc("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.")
103103+ model Account {
104104+ @required seq: integer;
105105+ @required did: did;
106106+ @required time: datetime;
107107+108108+ @doc("Indicates that the account has a repository which can be fetched from the host that emitted this event.")
109109+ @required
110110+ active: boolean;
111111+112112+ @doc("If active=false, this optional field indicates a reason for why the account is not active.")
113113+ status?: "takendown" | "suspended" | "deleted" | "deactivated" | "desynchronized" | "throttled" | string;
114114+ }
115115+116116+ model Info {
117117+ @required name: "OutdatedCursor" | string;
118118+ message?: string;
119119+ }
120120+121121+ @doc("A repo operation, ie a mutation of a single record.")
122122+ model RepoOp {
123123+ @required action: "create" | "update" | "delete" | string;
124124+ @required path: string;
125125+126126+ @doc("For creates and updates, the new record CID. For deletions, null.")
127127+ @required
128128+ cid: cidLink | null;
129129+130130+ @doc("For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.")
131131+ prev?: cidLink;
132132+ }
133133+}
···8181 },
8282 "ops": {
8383 "type": "array",
8484+ "description": "List of repo mutation operations in this commit (eg, records created, updated, or deleted).",
8485 "items": {
8586 "type": "ref",
8686- "ref": "#repoOp",
8787- "description": "List of repo mutation operations in this commit (eg, records created, updated, or deleted)."
8787+ "ref": "#repoOp"
8888 },
8989 "maxLength": 200
9090 },
9191 "blobs": {
9292 "type": "array",
9393+ "description": "DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.",
9394 "items": {
9494- "type": "cid-link",
9595- "description": "DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit."
9595+ "type": "cid-link"
9696 }
9797 },
9898 "prevData": {