Skip to content

Commit

Permalink
sync lex: #account firehose event; account status errors; and getAcco…
Browse files Browse the repository at this point in the history
…untStatus endpoint (bluesky-social#2263)

* subscribe repos lex: new #account event type

* lex: getAccountStatus endpoint

* lex: add account status errors to sync methods

* tweak type of token union

* fix getAccountStatus parameter name

* Account -> Repo

* codegen

* schema tweaks

* update identity evt

* add description to handle field

* status on listRepos & notate deprecated firehose events

---------

Co-authored-by: dholms <[email protected]>
  • Loading branch information
bnewbold and dholms authored May 29, 2024
1 parent c4af6a4 commit ee0e635
Show file tree
Hide file tree
Showing 53 changed files with 1,519 additions and 50 deletions.
9 changes: 8 additions & 1 deletion lexicons/com/atproto/sync/getBlob.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
},
"output": {
"encoding": "*/*"
}
},
"errors": [
{ "name": "BlobNotFound" },
{ "name": "RepoNotFound" },
{ "name": "RepoTakendown" },
{ "name": "RepoSuspended" },
{ "name": "RepoDeactivated" }
]
}
}
}
9 changes: 8 additions & 1 deletion lexicons/com/atproto/sync/getBlocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
},
"output": {
"encoding": "application/vnd.ipld.car"
}
},
"errors": [
{ "name": "BlockNotFound" },
{ "name": "RepoNotFound" },
{ "name": "RepoTakendown" },
{ "name": "RepoSuspended" },
{ "name": "RepoDeactivated" }
]
}
}
}
7 changes: 6 additions & 1 deletion lexicons/com/atproto/sync/getLatestCommit.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
}
}
},
"errors": [{ "name": "RepoNotFound" }]
"errors": [
{ "name": "RepoNotFound" },
{ "name": "RepoTakendown" },
{ "name": "RepoSuspended" },
{ "name": "RepoDeactivated" }
]
}
}
}
9 changes: 8 additions & 1 deletion lexicons/com/atproto/sync/getRecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
},
"output": {
"encoding": "application/vnd.ipld.car"
}
},
"errors": [
{ "name": "RecordNotFound" },
{ "name": "RepoNotFound" },
{ "name": "RepoTakendown" },
{ "name": "RepoSuspended" },
{ "name": "RepoDeactivated" }
]
}
}
}
8 changes: 7 additions & 1 deletion lexicons/com/atproto/sync/getRepo.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
},
"output": {
"encoding": "application/vnd.ipld.car"
}
},
"errors": [
{ "name": "RepoNotFound" },
{ "name": "RepoTakendown" },
{ "name": "RepoSuspended" },
{ "name": "RepoDeactivated" }
]
}
}
}
42 changes: 42 additions & 0 deletions lexicons/com/atproto/sync/getRepoStatus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"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", "deactivated"]
},
"rev": {
"type": "string",
"description": "Optional field, the current rev of the repo, if active=true"
}
}
}
},
"errors": [{ "name": "RepoNotFound" }]
}
}
}
8 changes: 7 additions & 1 deletion lexicons/com/atproto/sync/listBlobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
}
}
}
}
},
"errors": [
{ "name": "RepoNotFound" },
{ "name": "RepoTakendown" },
{ "name": "RepoSuspended" },
{ "name": "RepoDeactivated" }
]
}
}
}
8 changes: 7 additions & 1 deletion lexicons/com/atproto/sync/listRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
"format": "cid",
"description": "Current repo commit CID"
},
"rev": { "type": "string" }
"rev": { "type": "string" },
"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", "deactivated"]
}
}
}
}
Expand Down
33 changes: 29 additions & 4 deletions lexicons/com/atproto/sync/subscribeRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"refs": [
"#commit",
"#identity",
"#account",
"#handle",
"#migrate",
"#tombstone",
Expand Down Expand Up @@ -118,12 +119,36 @@
"properties": {
"seq": { "type": "integer" },
"did": { "type": "string", "format": "did" },
"time": { "type": "string", "format": "datetime" }
"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"]
}
}
},
"handle": {
"type": "object",
"description": "Represents an update of the account's handle, or transition to/from invalid state. NOTE: Will be deprecated in favor of #identity.",
"description": "DEPRECATED -- Use #identity event instead",
"required": ["seq", "did", "handle", "time"],
"properties": {
"seq": { "type": "integer" },
Expand All @@ -134,7 +159,7 @@
},
"migrate": {
"type": "object",
"description": "Represents an account moving from one PDS instance to another. NOTE: not implemented; account migration uses #identity instead",
"description": "DEPRECATED -- Use #account event instead",
"required": ["seq", "did", "migrateTo", "time"],
"nullable": ["migrateTo"],
"properties": {
Expand All @@ -146,7 +171,7 @@
},
"tombstone": {
"type": "object",
"description": "Indicates that an account has been deleted. NOTE: may be deprecated in favor of #identity or a future #account event",
"description": "DEPRECATED -- Use #account event instead",
"required": ["seq", "did", "time"],
"properties": {
"seq": { "type": "integer" },
Expand Down
13 changes: 13 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import * as ComAtprotoSyncGetHead from './types/com/atproto/sync/getHead'
import * as ComAtprotoSyncGetLatestCommit from './types/com/atproto/sync/getLatestCommit'
import * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord'
import * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo'
import * as ComAtprotoSyncGetRepoStatus from './types/com/atproto/sync/getRepoStatus'
import * as ComAtprotoSyncListBlobs from './types/com/atproto/sync/listBlobs'
import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos'
import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate'
Expand Down Expand Up @@ -257,6 +258,7 @@ export * as ComAtprotoSyncGetHead from './types/com/atproto/sync/getHead'
export * as ComAtprotoSyncGetLatestCommit from './types/com/atproto/sync/getLatestCommit'
export * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord'
export * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo'
export * as ComAtprotoSyncGetRepoStatus from './types/com/atproto/sync/getRepoStatus'
export * as ComAtprotoSyncListBlobs from './types/com/atproto/sync/listBlobs'
export * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos'
export * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate'
Expand Down Expand Up @@ -1229,6 +1231,17 @@ export class ComAtprotoSyncNS {
})
}

getRepoStatus(
params?: ComAtprotoSyncGetRepoStatus.QueryParams,
opts?: ComAtprotoSyncGetRepoStatus.CallOptions,
): Promise<ComAtprotoSyncGetRepoStatus.Response> {
return this._service.xrpc
.call('com.atproto.sync.getRepoStatus', params, undefined, opts)
.catch((e) => {
throw ComAtprotoSyncGetRepoStatus.toKnownErr(e)
})
}

listBlobs(
params?: ComAtprotoSyncListBlobs.QueryParams,
opts?: ComAtprotoSyncListBlobs.CallOptions,
Expand Down
Loading

0 comments on commit ee0e635

Please sign in to comment.