Skip to content

Commit

Permalink
Fix typo in getRelationships (#2091)
Browse files Browse the repository at this point in the history
fix typo in getRelationships + codegen
  • Loading branch information
dholms authored Jan 25, 2024
1 parent fb979b1 commit 43eb405
Show file tree
Hide file tree
Showing 17 changed files with 818 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lexicons/app/bsky/graph/getRelationships.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"items": {
"type": "union",
"refs": [
"app.bsky.graph.def#relationship",
"app.bsky.graph.defs#relationship",
"app.bsky.graph.defs#notFoundActor"
]
}
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 @@ -132,6 +132,7 @@ import * as AppBskyGraphGetListBlocks from './types/app/bsky/graph/getListBlocks
import * as AppBskyGraphGetListMutes from './types/app/bsky/graph/getListMutes'
import * as AppBskyGraphGetLists from './types/app/bsky/graph/getLists'
import * as AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
import * as AppBskyGraphGetRelationships from './types/app/bsky/graph/getRelationships'
import * as AppBskyGraphGetSuggestedFollowsByActor from './types/app/bsky/graph/getSuggestedFollowsByActor'
import * as AppBskyGraphList from './types/app/bsky/graph/list'
import * as AppBskyGraphListblock from './types/app/bsky/graph/listblock'
Expand Down Expand Up @@ -277,6 +278,7 @@ export * as AppBskyGraphGetListBlocks from './types/app/bsky/graph/getListBlocks
export * as AppBskyGraphGetListMutes from './types/app/bsky/graph/getListMutes'
export * as AppBskyGraphGetLists from './types/app/bsky/graph/getLists'
export * as AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
export * as AppBskyGraphGetRelationships from './types/app/bsky/graph/getRelationships'
export * as AppBskyGraphGetSuggestedFollowsByActor from './types/app/bsky/graph/getSuggestedFollowsByActor'
export * as AppBskyGraphList from './types/app/bsky/graph/list'
export * as AppBskyGraphListblock from './types/app/bsky/graph/listblock'
Expand Down Expand Up @@ -2057,6 +2059,17 @@ export class AppBskyGraphNS {
})
}

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

getSuggestedFollowsByActor(
params?: AppBskyGraphGetSuggestedFollowsByActor.QueryParams,
opts?: AppBskyGraphGetSuggestedFollowsByActor.CallOptions,
Expand Down
99 changes: 99 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6925,6 +6925,45 @@ export const schemaDict = {
},
},
},
notFoundActor: {
type: 'object',
description: 'indicates that a handle or DID could not be resolved',
required: ['actor', 'notFound'],
properties: {
actor: {
type: 'string',
format: 'at-identifier',
},
notFound: {
type: 'boolean',
const: true,
},
},
},
relationship: {
type: 'object',
description:
'lists the bi-directional graph relationships between one actor (not indicated in the object), and the target actors (the DID included in the object)',
required: ['did'],
properties: {
did: {
type: 'string',
format: 'did',
},
following: {
type: 'string',
format: 'at-uri',
description:
'if the actor follows this DID, this is the AT-URI of the follow record',
},
followedBy: {
type: 'string',
format: 'at-uri',
description:
'if the actor is followed by this DID, contains the AT-URI of the follow record',
},
},
},
},
},
AppBskyGraphFollow: {
Expand Down Expand Up @@ -7328,6 +7367,65 @@ export const schemaDict = {
},
},
},
AppBskyGraphGetRelationships: {
lexicon: 1,
id: 'app.bsky.graph.getRelationships',
defs: {
main: {
type: 'query',
description:
'Enumerates public relationships between one account, and a list of other accounts',
parameters: {
type: 'params',
required: ['actor'],
properties: {
actor: {
type: 'string',
format: 'at-identifier',
},
others: {
type: 'array',
maxLength: 30,
items: {
type: 'string',
format: 'at-identifier',
},
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['relationships'],
properties: {
actor: {
type: 'string',
format: 'did',
},
relationships: {
type: 'array',
items: {
type: 'union',
refs: [
'lex:app.bsky.graph.defs#relationship',
'lex:app.bsky.graph.defs#notFoundActor',
],
},
},
},
},
},
errors: [
{
name: 'ActorNotFound',
description:
'the primary actor at-identifier could not be resolved',
},
],
},
},
},
AppBskyGraphGetSuggestedFollowsByActor: {
lexicon: 1,
id: 'app.bsky.graph.getSuggestedFollowsByActor',
Expand Down Expand Up @@ -8272,6 +8370,7 @@ export const ids = {
AppBskyGraphGetListMutes: 'app.bsky.graph.getListMutes',
AppBskyGraphGetLists: 'app.bsky.graph.getLists',
AppBskyGraphGetMutes: 'app.bsky.graph.getMutes',
AppBskyGraphGetRelationships: 'app.bsky.graph.getRelationships',
AppBskyGraphGetSuggestedFollowsByActor:
'app.bsky.graph.getSuggestedFollowsByActor',
AppBskyGraphList: 'app.bsky.graph.list',
Expand Down
41 changes: 41 additions & 0 deletions packages/api/src/client/types/app/bsky/graph/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,44 @@ export function isListViewerState(v: unknown): v is ListViewerState {
export function validateListViewerState(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.graph.defs#listViewerState', v)
}

/** indicates that a handle or DID could not be resolved */
export interface NotFoundActor {
actor: string
notFound: true
[k: string]: unknown
}

export function isNotFoundActor(v: unknown): v is NotFoundActor {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.graph.defs#notFoundActor'
)
}

export function validateNotFoundActor(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.graph.defs#notFoundActor', v)
}

/** lists the bi-directional graph relationships between one actor (not indicated in the object), and the target actors (the DID included in the object) */
export interface Relationship {
did: string
/** if the actor follows this DID, this is the AT-URI of the follow record */
following?: string
/** if the actor is followed by this DID, contains the AT-URI of the follow record */
followedBy?: string
[k: string]: unknown
}

export function isRelationship(v: unknown): v is Relationship {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.graph.defs#relationship'
)
}

export function validateRelationship(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.graph.defs#relationship', v)
}
49 changes: 49 additions & 0 deletions packages/api/src/client/types/app/bsky/graph/getRelationships.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, XRPCError } from '@atproto/xrpc'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as AppBskyGraphDefs from './defs'

export interface QueryParams {
actor: string
others?: string[]
}

export type InputSchema = undefined

export interface OutputSchema {
actor?: string
relationships: (
| AppBskyGraphDefs.Relationship
| AppBskyGraphDefs.NotFoundActor
| { $type: string; [k: string]: unknown }
)[]
[k: string]: unknown
}

export interface CallOptions {
headers?: Headers
}

export interface Response {
success: boolean
headers: Headers
data: OutputSchema
}

export class ActorNotFoundError extends XRPCError {
constructor(src: XRPCError) {
super(src.status, src.error, src.message, src.headers)
}
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
if (e.error === 'ActorNotFound') return new ActorNotFoundError(e)
}
return e
}
12 changes: 12 additions & 0 deletions packages/bsky/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import * as AppBskyGraphGetListBlocks from './types/app/bsky/graph/getListBlocks
import * as AppBskyGraphGetListMutes from './types/app/bsky/graph/getListMutes'
import * as AppBskyGraphGetLists from './types/app/bsky/graph/getLists'
import * as AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
import * as AppBskyGraphGetRelationships from './types/app/bsky/graph/getRelationships'
import * as AppBskyGraphGetSuggestedFollowsByActor from './types/app/bsky/graph/getSuggestedFollowsByActor'
import * as AppBskyGraphMuteActor from './types/app/bsky/graph/muteActor'
import * as AppBskyGraphMuteActorList from './types/app/bsky/graph/muteActorList'
Expand Down Expand Up @@ -1480,6 +1481,17 @@ export class AppBskyGraphNS {
return this._server.xrpc.method(nsid, cfg)
}

getRelationships<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
AppBskyGraphGetRelationships.Handler<ExtractAuth<AV>>,
AppBskyGraphGetRelationships.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'app.bsky.graph.getRelationships' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

getSuggestedFollowsByActor<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
Loading

0 comments on commit 43eb405

Please sign in to comment.