Skip to content

Commit

Permalink
Add app.bsky.graph.getAssertions() (bluesky-social#340)
Browse files Browse the repository at this point in the history
* Add app.bsky.graph.getAssertions()

* Update getAssertions to support query by author or subject

* Revert accidental change to members test
  • Loading branch information
pfrazee authored Nov 11, 2022
1 parent 962041e commit a1bee40
Show file tree
Hide file tree
Showing 11 changed files with 2,362 additions and 0 deletions.
90 changes: 90 additions & 0 deletions lexicons/app/bsky/graph/getAssertions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"lexicon": 1,
"id": "app.bsky.graph.getAssertions",
"type": "query",
"description": "General-purpose query for assertions.",
"parameters": {
"type": "object",
"properties": {
"author": {"type": "string"},
"subject": {"type": "string"},
"assertion": {"type": "string"},
"confirmed": {"type": "boolean"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["assertions"],
"properties": {
"cursor": {"type": "string"},
"assertions": {
"type": "array",
"items": {
"type": "object",
"required": ["uri", "cid", "assertion", "author", "subject", "indexedAt", "createdAt"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"assertion": {"type": "string"},
"confirmation": {"$ref": "#/defs/confirmation"},
"author": {"$ref": "#/defs/actor"},
"subject": {"$ref": "#/defs/actor"},
"indexedAt": {"type": "string", "format": "date-time"},
"createdAt": {"type": "string", "format": "date-time"}
}
}
}
}
}
},
"defs": {
"confirmation": {
"type": "object",
"required": ["uri", "cid", "indexedAt", "createdAt"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"indexedAt": {"type": "string", "format": "date-time"},
"createdAt": {"type": "string", "format": "date-time"}
}
},
"actor": {
"type": "object",
"required": ["did", "declaration", "handle"],
"properties": {
"did": {"type": "string"},
"declaration": {"$ref": "#/defs/declaration"},
"handle": {"type": "string"},
"displayName": {
"type": "string",
"maxLength": 64
}
}
},
"declaration": {
"type": "object",
"required": ["cid", "actorType"],
"properties": {
"cid": {"type": "string"},
"actorType": {
"oneOf": [
{"$ref": "#/defs/actorKnown"},
{"$ref": "#/defs/actorUnknown"}
]
}
}
},
"actorKnown": {
"type": "string",
"enum": ["app.bsky.system.actorUser", "app.bsky.system.actorScene"]
},
"actorUnknown": {
"type": "string",
"not": {"enum": ["app.bsky.system.actorUser", "app.bsky.system.actorScene"]}
}
}
}
13 changes: 13 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import * as AppBskyFeedVote from './types/app/bsky/feed/vote'
import * as AppBskyGraphAssertion from './types/app/bsky/graph/assertion'
import * as AppBskyGraphConfirmation from './types/app/bsky/graph/confirmation'
import * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
import * as AppBskyGraphGetAssertions from './types/app/bsky/graph/getAssertions'
import * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
import * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
import * as AppBskyGraphGetMembers from './types/app/bsky/graph/getMembers'
Expand Down Expand Up @@ -101,6 +102,7 @@ export * as AppBskyFeedVote from './types/app/bsky/feed/vote'
export * as AppBskyGraphAssertion from './types/app/bsky/graph/assertion'
export * as AppBskyGraphConfirmation from './types/app/bsky/graph/confirmation'
export * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
export * as AppBskyGraphGetAssertions from './types/app/bsky/graph/getAssertions'
export * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
export * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
export * as AppBskyGraphGetMembers from './types/app/bsky/graph/getMembers'
Expand Down Expand Up @@ -1043,6 +1045,17 @@ export class GraphNS {
this.follow = new FollowRecord(service)
}

getAssertions(
params?: AppBskyGraphGetAssertions.QueryParams,
opts?: AppBskyGraphGetAssertions.CallOptions
): Promise<AppBskyGraphGetAssertions.Response> {
return this._service.xrpc
.call('app.bsky.graph.getAssertions', params, undefined, opts)
.catch((e) => {
throw AppBskyGraphGetAssertions.toKnownErr(e)
})
}

getFollowers(
params?: AppBskyGraphGetFollowers.QueryParams,
opts?: AppBskyGraphGetFollowers.CallOptions
Expand Down
225 changes: 225 additions & 0 deletions packages/api/src/client/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3005,6 +3005,231 @@ export const methodSchemaDict: Record<string, MethodSchema> = {
},
},
},
'app.bsky.graph.getAssertions': {
lexicon: 1,
id: 'app.bsky.graph.getAssertions',
type: 'query',
description: 'General-purpose query for assertions.',
parameters: {
type: 'object',
properties: {
author: {
type: 'string',
},
subject: {
type: 'string',
},
assertion: {
type: 'string',
},
confirmed: {
type: 'boolean',
},
limit: {
type: 'number',
maximum: 100,
},
before: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['assertions'],
properties: {
cursor: {
type: 'string',
},
assertions: {
type: 'array',
items: {
type: 'object',
required: [
'uri',
'cid',
'assertion',
'author',
'subject',
'indexedAt',
'createdAt',
],
properties: {
uri: {
type: 'string',
},
cid: {
type: 'string',
},
assertion: {
type: 'string',
},
confirmation: {
$ref: '#/$defs/confirmation',
},
author: {
$ref: '#/$defs/actor',
},
subject: {
$ref: '#/$defs/actor',
},
indexedAt: {
type: 'string',
format: 'date-time',
},
createdAt: {
type: 'string',
format: 'date-time',
},
},
},
},
},
$defs: {
confirmation: {
type: 'object',
required: ['uri', 'cid', 'indexedAt', 'createdAt'],
properties: {
uri: {
type: 'string',
},
cid: {
type: 'string',
},
indexedAt: {
type: 'string',
format: 'date-time',
},
createdAt: {
type: 'string',
format: 'date-time',
},
},
},
actor: {
type: 'object',
required: ['did', 'declaration', 'handle'],
properties: {
did: {
type: 'string',
},
declaration: {
$ref: '#/$defs/declaration',
},
handle: {
type: 'string',
},
displayName: {
type: 'string',
maxLength: 64,
},
},
},
declaration: {
type: 'object',
required: ['cid', 'actorType'],
properties: {
cid: {
type: 'string',
},
actorType: {
oneOf: [
{
$ref: '#/$defs/actorKnown',
},
{
$ref: '#/$defs/actorUnknown',
},
],
},
},
},
actorKnown: {
type: 'string',
enum: ['app.bsky.system.actorUser', 'app.bsky.system.actorScene'],
},
actorUnknown: {
type: 'string',
not: {
enum: ['app.bsky.system.actorUser', 'app.bsky.system.actorScene'],
},
},
},
},
},
defs: {
confirmation: {
type: 'object',
required: ['uri', 'cid', 'indexedAt', 'createdAt'],
properties: {
uri: {
type: 'string',
},
cid: {
type: 'string',
},
indexedAt: {
type: 'string',
format: 'date-time',
},
createdAt: {
type: 'string',
format: 'date-time',
},
},
},
actor: {
type: 'object',
required: ['did', 'declaration', 'handle'],
properties: {
did: {
type: 'string',
},
declaration: {
$ref: '#/$defs/declaration',
},
handle: {
type: 'string',
},
displayName: {
type: 'string',
maxLength: 64,
},
},
},
declaration: {
type: 'object',
required: ['cid', 'actorType'],
properties: {
cid: {
type: 'string',
},
actorType: {
oneOf: [
{
$ref: '#/$defs/actorKnown',
},
{
$ref: '#/$defs/actorUnknown',
},
],
},
},
},
actorKnown: {
type: 'string',
enum: ['app.bsky.system.actorUser', 'app.bsky.system.actorScene'],
},
actorUnknown: {
type: 'string',
not: {
enum: ['app.bsky.system.actorUser', 'app.bsky.system.actorScene'],
},
},
},
},
'app.bsky.graph.getFollowers': {
lexicon: 1,
id: 'app.bsky.graph.getFollowers',
Expand Down
Loading

0 comments on commit a1bee40

Please sign in to comment.