diff --git a/lexicons/app/bsky/actor/defs.json b/lexicons/app/bsky/actor/defs.json index 913957f1291..9f8e2ea97c8 100644 --- a/lexicons/app/bsky/actor/defs.json +++ b/lexicons/app/bsky/actor/defs.json @@ -104,7 +104,8 @@ "#savedFeedsPref", "#personalDetailsPref", "#feedViewPref", - "#threadViewPref" + "#threadViewPref", + "#interestsPref" ] } }, @@ -199,6 +200,18 @@ "description": "Show followed users at the top of all replies." } } + }, + "interestsPref": { + "type": "object", + "required": ["tags"], + "properties": { + "tags": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "maxLength": 640, "maxGraphemes": 64 }, + "description": "A list of tags which describe the account owner's interests gathered during onboarding." + } + } } } } diff --git a/lexicons/app/bsky/graph/defs.json b/lexicons/app/bsky/graph/defs.json index 219c4a6de27..737d984d08b 100644 --- a/lexicons/app/bsky/graph/defs.json +++ b/lexicons/app/bsky/graph/defs.json @@ -67,6 +67,33 @@ "muted": { "type": "boolean" }, "blocked": { "type": "string", "format": "at-uri" } } + }, + "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" + } + } } } } diff --git a/lexicons/app/bsky/graph/getRelationships.json b/lexicons/app/bsky/graph/getRelationships.json new file mode 100644 index 00000000000..ccd495dea7d --- /dev/null +++ b/lexicons/app/bsky/graph/getRelationships.json @@ -0,0 +1,51 @@ +{ + "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": [ + "app.bsky.graph.defs#relationship", + "app.bsky.graph.defs#notFoundActor" + ] + } + } + } + } + }, + "errors": [ + { + "name": "ActorNotFound", + "description": "the primary actor at-identifier could not be resolved" + } + ] + } + } +} diff --git a/lexicons/com/atproto/admin/defs.json b/lexicons/com/atproto/admin/defs.json index 5a65ae31562..133deaf9383 100644 --- a/lexicons/com/atproto/admin/defs.json +++ b/lexicons/com/atproto/admin/defs.json @@ -33,7 +33,8 @@ "#modEventAcknowledge", "#modEventEscalate", "#modEventMute", - "#modEventEmail" + "#modEventEmail", + "#modEventResolveAppeal" ] }, "subject": { @@ -70,6 +71,7 @@ "#modEventAcknowledge", "#modEventEscalate", "#modEventMute", + "#modEventEmail", "#modEventResolveAppeal" ] }, diff --git a/lexicons/com/atproto/admin/queryModerationEvents.json b/lexicons/com/atproto/admin/queryModerationEvents.json index 70af1bf8ae5..887921cfe20 100644 --- a/lexicons/com/atproto/admin/queryModerationEvents.json +++ b/lexicons/com/atproto/admin/queryModerationEvents.json @@ -23,6 +23,16 @@ "enum": ["asc", "desc"], "description": "Sort direction for the events. Defaults to descending order of created at timestamp." }, + "createdAfter": { + "type": "string", + "format": "datetime", + "description": "Retrieve events created after a given timestamp" + }, + "createdBefore": { + "type": "string", + "format": "datetime", + "description": "Retrieve events created before a given timestamp" + }, "subject": { "type": "string", "format": "uri" }, "includeAllUserRecords": { "type": "boolean", @@ -35,6 +45,30 @@ "maximum": 100, "default": 50 }, + "hasComment": { + "type": "boolean", + "description": "If true, only events with comments are returned" + }, + "comment": { + "type": "string", + "description": "If specified, only events with comments containing the keyword are returned" + }, + "addedLabels": { + "type": "array", + "items": { "type": "string" }, + "description": "If specified, only events where all of these labels were added are returned" + }, + "removedLabels": { + "type": "array", + "items": { "type": "string" }, + "description": "If specified, only events where all of these labels were removed are returned" + }, + "reportTypes": { + "type": "array", + "items": { + "type": "string" + } + }, "cursor": { "type": "string" } } }, diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts index 5b454a6ab0d..3719cb685c9 100644 --- a/packages/api/src/client/index.ts +++ b/packages/api/src/client/index.ts @@ -133,6 +133,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' @@ -280,6 +281,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' @@ -352,39 +354,39 @@ export class AtpServiceClient { export class ComNS { _service: AtpServiceClient - atproto: AtprotoNS + atproto: ComAtprotoNS constructor(service: AtpServiceClient) { this._service = service - this.atproto = new AtprotoNS(service) + this.atproto = new ComAtprotoNS(service) } } -export class AtprotoNS { +export class ComAtprotoNS { _service: AtpServiceClient - admin: AdminNS - identity: IdentityNS - label: LabelNS - moderation: ModerationNS - repo: RepoNS - server: ServerNS - sync: SyncNS - temp: TempNS + admin: ComAtprotoAdminNS + identity: ComAtprotoIdentityNS + label: ComAtprotoLabelNS + moderation: ComAtprotoModerationNS + repo: ComAtprotoRepoNS + server: ComAtprotoServerNS + sync: ComAtprotoSyncNS + temp: ComAtprotoTempNS constructor(service: AtpServiceClient) { this._service = service - this.admin = new AdminNS(service) - this.identity = new IdentityNS(service) - this.label = new LabelNS(service) - this.moderation = new ModerationNS(service) - this.repo = new RepoNS(service) - this.server = new ServerNS(service) - this.sync = new SyncNS(service) - this.temp = new TempNS(service) + this.admin = new ComAtprotoAdminNS(service) + this.identity = new ComAtprotoIdentityNS(service) + this.label = new ComAtprotoLabelNS(service) + this.moderation = new ComAtprotoModerationNS(service) + this.repo = new ComAtprotoRepoNS(service) + this.server = new ComAtprotoServerNS(service) + this.sync = new ComAtprotoSyncNS(service) + this.temp = new ComAtprotoTempNS(service) } } -export class AdminNS { +export class ComAtprotoAdminNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -670,7 +672,7 @@ export class AdminNS { } } -export class IdentityNS { +export class ComAtprotoIdentityNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -700,7 +702,7 @@ export class IdentityNS { } } -export class LabelNS { +export class ComAtprotoLabelNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -719,7 +721,7 @@ export class LabelNS { } } -export class ModerationNS { +export class ComAtprotoModerationNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -738,7 +740,7 @@ export class ModerationNS { } } -export class RepoNS { +export class ComAtprotoRepoNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -834,7 +836,7 @@ export class RepoNS { } } -export class ServerNS { +export class ComAtprotoServerNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -1073,7 +1075,7 @@ export class ServerNS { } } -export class SyncNS { +export class ComAtprotoSyncNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -1202,7 +1204,7 @@ export class SyncNS { } } -export class TempNS { +export class ComAtprotoTempNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -1278,37 +1280,37 @@ export class TempNS { export class AppNS { _service: AtpServiceClient - bsky: BskyNS + bsky: AppBskyNS constructor(service: AtpServiceClient) { this._service = service - this.bsky = new BskyNS(service) + this.bsky = new AppBskyNS(service) } } -export class BskyNS { +export class AppBskyNS { _service: AtpServiceClient - actor: ActorNS - embed: EmbedNS - feed: FeedNS - graph: GraphNS - notification: NotificationNS - richtext: RichtextNS - unspecced: UnspeccedNS + actor: AppBskyActorNS + embed: AppBskyEmbedNS + feed: AppBskyFeedNS + graph: AppBskyGraphNS + notification: AppBskyNotificationNS + richtext: AppBskyRichtextNS + unspecced: AppBskyUnspeccedNS constructor(service: AtpServiceClient) { this._service = service - this.actor = new ActorNS(service) - this.embed = new EmbedNS(service) - this.feed = new FeedNS(service) - this.graph = new GraphNS(service) - this.notification = new NotificationNS(service) - this.richtext = new RichtextNS(service) - this.unspecced = new UnspeccedNS(service) + this.actor = new AppBskyActorNS(service) + this.embed = new AppBskyEmbedNS(service) + this.feed = new AppBskyFeedNS(service) + this.graph = new AppBskyGraphNS(service) + this.notification = new AppBskyNotificationNS(service) + this.richtext = new AppBskyRichtextNS(service) + this.unspecced = new AppBskyUnspeccedNS(service) } } -export class ActorNS { +export class AppBskyActorNS { _service: AtpServiceClient profile: ProfileRecord @@ -1456,7 +1458,7 @@ export class ProfileRecord { } } -export class EmbedNS { +export class AppBskyEmbedNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -1464,7 +1466,7 @@ export class EmbedNS { } } -export class FeedNS { +export class AppBskyFeedNS { _service: AtpServiceClient generator: GeneratorRecord like: LikeRecord @@ -1967,7 +1969,7 @@ export class ThreadgateRecord { } } -export class GraphNS { +export class AppBskyGraphNS { _service: AtpServiceClient block: BlockRecord follow: FollowRecord @@ -2072,6 +2074,17 @@ export class GraphNS { }) } + getRelationships( + params?: AppBskyGraphGetRelationships.QueryParams, + opts?: AppBskyGraphGetRelationships.CallOptions, + ): Promise { + 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, @@ -2442,7 +2455,7 @@ export class ListitemRecord { } } -export class NotificationNS { +export class AppBskyNotificationNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -2494,7 +2507,7 @@ export class NotificationNS { } } -export class RichtextNS { +export class AppBskyRichtextNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { @@ -2502,7 +2515,7 @@ export class RichtextNS { } } -export class UnspeccedNS { +export class AppBskyUnspeccedNS { _service: AtpServiceClient constructor(service: AtpServiceClient) { diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index d7791d1bffd..9db3be4f817 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -91,6 +91,7 @@ export const schemaDict = { 'lex:com.atproto.admin.defs#modEventEscalate', 'lex:com.atproto.admin.defs#modEventMute', 'lex:com.atproto.admin.defs#modEventEmail', + 'lex:com.atproto.admin.defs#modEventResolveAppeal', ], }, subject: { @@ -147,6 +148,7 @@ export const schemaDict = { 'lex:com.atproto.admin.defs#modEventAcknowledge', 'lex:com.atproto.admin.defs#modEventEscalate', 'lex:com.atproto.admin.defs#modEventMute', + 'lex:com.atproto.admin.defs#modEventEmail', 'lex:com.atproto.admin.defs#modEventResolveAppeal', ], }, @@ -1450,6 +1452,16 @@ export const schemaDict = { description: 'Sort direction for the events. Defaults to descending order of created at timestamp.', }, + createdAfter: { + type: 'string', + format: 'datetime', + description: 'Retrieve events created after a given timestamp', + }, + createdBefore: { + type: 'string', + format: 'datetime', + description: 'Retrieve events created before a given timestamp', + }, subject: { type: 'string', format: 'uri', @@ -1466,6 +1478,37 @@ export const schemaDict = { maximum: 100, default: 50, }, + hasComment: { + type: 'boolean', + description: 'If true, only events with comments are returned', + }, + comment: { + type: 'string', + description: + 'If specified, only events with comments containing the keyword are returned', + }, + addedLabels: { + type: 'array', + items: { + type: 'string', + }, + description: + 'If specified, only events where all of these labels were added are returned', + }, + removedLabels: { + type: 'array', + items: { + type: 'string', + }, + description: + 'If specified, only events where all of these labels were removed are returned', + }, + reportTypes: { + type: 'array', + items: { + type: 'string', + }, + }, cursor: { type: 'string', }, @@ -4643,6 +4686,7 @@ export const schemaDict = { 'lex:app.bsky.actor.defs#personalDetailsPref', 'lex:app.bsky.actor.defs#feedViewPref', 'lex:app.bsky.actor.defs#threadViewPref', + 'lex:app.bsky.actor.defs#interestsPref', ], }, }, @@ -4746,6 +4790,23 @@ export const schemaDict = { }, }, }, + interestsPref: { + type: 'object', + required: ['tags'], + properties: { + tags: { + type: 'array', + maxLength: 100, + items: { + type: 'string', + maxLength: 640, + maxGraphemes: 64, + }, + description: + "A list of tags which describe the account owner's interests gathered during onboarding.", + }, + }, + }, }, }, AppBskyActorGetPreferences: { @@ -6953,6 +7014,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: { @@ -7356,6 +7456,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', @@ -8349,6 +8508,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', diff --git a/packages/api/src/client/types/app/bsky/actor/defs.ts b/packages/api/src/client/types/app/bsky/actor/defs.ts index 0cb22ea5797..5c1791e6130 100644 --- a/packages/api/src/client/types/app/bsky/actor/defs.ts +++ b/packages/api/src/client/types/app/bsky/actor/defs.ts @@ -112,6 +112,7 @@ export type Preferences = ( | PersonalDetailsPref | FeedViewPref | ThreadViewPref + | InterestsPref | { $type: string; [k: string]: unknown } )[] @@ -233,3 +234,21 @@ export function isThreadViewPref(v: unknown): v is ThreadViewPref { export function validateThreadViewPref(v: unknown): ValidationResult { return lexicons.validate('app.bsky.actor.defs#threadViewPref', v) } + +export interface InterestsPref { + /** A list of tags which describe the account owner's interests gathered during onboarding. */ + tags: string[] + [k: string]: unknown +} + +export function isInterestsPref(v: unknown): v is InterestsPref { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.actor.defs#interestsPref' + ) +} + +export function validateInterestsPref(v: unknown): ValidationResult { + return lexicons.validate('app.bsky.actor.defs#interestsPref', v) +} diff --git a/packages/api/src/client/types/app/bsky/graph/defs.ts b/packages/api/src/client/types/app/bsky/graph/defs.ts index 0b22401bcdf..0580b9bb158 100644 --- a/packages/api/src/client/types/app/bsky/graph/defs.ts +++ b/packages/api/src/client/types/app/bsky/graph/defs.ts @@ -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) +} diff --git a/packages/api/src/client/types/app/bsky/graph/getRelationships.ts b/packages/api/src/client/types/app/bsky/graph/getRelationships.ts new file mode 100644 index 00000000000..5fce53f635c --- /dev/null +++ b/packages/api/src/client/types/app/bsky/graph/getRelationships.ts @@ -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 +} diff --git a/packages/api/src/client/types/com/atproto/admin/defs.ts b/packages/api/src/client/types/com/atproto/admin/defs.ts index da154f8a845..c0d8157e6ac 100644 --- a/packages/api/src/client/types/com/atproto/admin/defs.ts +++ b/packages/api/src/client/types/com/atproto/admin/defs.ts @@ -40,6 +40,7 @@ export interface ModEventView { | ModEventEscalate | ModEventMute | ModEventEmail + | ModEventResolveAppeal | { $type: string; [k: string]: unknown } subject: | RepoRef @@ -76,6 +77,7 @@ export interface ModEventViewDetail { | ModEventAcknowledge | ModEventEscalate | ModEventMute + | ModEventEmail | ModEventResolveAppeal | { $type: string; [k: string]: unknown } subject: diff --git a/packages/api/src/client/types/com/atproto/admin/queryModerationEvents.ts b/packages/api/src/client/types/com/atproto/admin/queryModerationEvents.ts index ed21c739bcb..1540babae51 100644 --- a/packages/api/src/client/types/com/atproto/admin/queryModerationEvents.ts +++ b/packages/api/src/client/types/com/atproto/admin/queryModerationEvents.ts @@ -14,10 +14,23 @@ export interface QueryParams { createdBy?: string /** Sort direction for the events. Defaults to descending order of created at timestamp. */ sortDirection?: 'asc' | 'desc' + /** Retrieve events created after a given timestamp */ + createdAfter?: string + /** Retrieve events created before a given timestamp */ + createdBefore?: string subject?: string /** If true, events on all record types (posts, lists, profile etc.) owned by the did are returned */ includeAllUserRecords?: boolean limit?: number + /** If true, only events with comments are returned */ + hasComment?: boolean + /** If specified, only events with comments containing the keyword are returned */ + comment?: string + /** If specified, only events where all of these labels were added are returned */ + addedLabels?: string[] + /** If specified, only events where all of these labels were removed are returned */ + removedLabels?: string[] + reportTypes?: string[] cursor?: string } diff --git a/packages/bsky/src/lexicon/index.ts b/packages/bsky/src/lexicon/index.ts index c5168aeed4f..6e3088057c7 100644 --- a/packages/bsky/src/lexicon/index.ts +++ b/packages/bsky/src/lexicon/index.ts @@ -115,6 +115,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' @@ -168,39 +169,39 @@ export class Server { export class ComNS { _server: Server - atproto: AtprotoNS + atproto: ComAtprotoNS constructor(server: Server) { this._server = server - this.atproto = new AtprotoNS(server) + this.atproto = new ComAtprotoNS(server) } } -export class AtprotoNS { +export class ComAtprotoNS { _server: Server - admin: AdminNS - identity: IdentityNS - label: LabelNS - moderation: ModerationNS - repo: RepoNS - server: ServerNS - sync: SyncNS - temp: TempNS + admin: ComAtprotoAdminNS + identity: ComAtprotoIdentityNS + label: ComAtprotoLabelNS + moderation: ComAtprotoModerationNS + repo: ComAtprotoRepoNS + server: ComAtprotoServerNS + sync: ComAtprotoSyncNS + temp: ComAtprotoTempNS constructor(server: Server) { this._server = server - this.admin = new AdminNS(server) - this.identity = new IdentityNS(server) - this.label = new LabelNS(server) - this.moderation = new ModerationNS(server) - this.repo = new RepoNS(server) - this.server = new ServerNS(server) - this.sync = new SyncNS(server) - this.temp = new TempNS(server) + this.admin = new ComAtprotoAdminNS(server) + this.identity = new ComAtprotoIdentityNS(server) + this.label = new ComAtprotoLabelNS(server) + this.moderation = new ComAtprotoModerationNS(server) + this.repo = new ComAtprotoRepoNS(server) + this.server = new ComAtprotoServerNS(server) + this.sync = new ComAtprotoSyncNS(server) + this.temp = new ComAtprotoTempNS(server) } } -export class AdminNS { +export class ComAtprotoAdminNS { _server: Server constructor(server: Server) { @@ -461,7 +462,7 @@ export class AdminNS { } } -export class IdentityNS { +export class ComAtprotoIdentityNS { _server: Server constructor(server: Server) { @@ -491,7 +492,7 @@ export class IdentityNS { } } -export class LabelNS { +export class ComAtprotoLabelNS { _server: Server constructor(server: Server) { @@ -521,7 +522,7 @@ export class LabelNS { } } -export class ModerationNS { +export class ComAtprotoModerationNS { _server: Server constructor(server: Server) { @@ -540,7 +541,7 @@ export class ModerationNS { } } -export class RepoNS { +export class ComAtprotoRepoNS { _server: Server constructor(server: Server) { @@ -636,7 +637,7 @@ export class RepoNS { } } -export class ServerNS { +export class ComAtprotoServerNS { _server: Server constructor(server: Server) { @@ -875,7 +876,7 @@ export class ServerNS { } } -export class SyncNS { +export class ComAtprotoSyncNS { _server: Server constructor(server: Server) { @@ -1015,7 +1016,7 @@ export class SyncNS { } } -export class TempNS { +export class ComAtprotoTempNS { _server: Server constructor(server: Server) { @@ -1091,37 +1092,37 @@ export class TempNS { export class AppNS { _server: Server - bsky: BskyNS + bsky: AppBskyNS constructor(server: Server) { this._server = server - this.bsky = new BskyNS(server) + this.bsky = new AppBskyNS(server) } } -export class BskyNS { +export class AppBskyNS { _server: Server - actor: ActorNS - embed: EmbedNS - feed: FeedNS - graph: GraphNS - notification: NotificationNS - richtext: RichtextNS - unspecced: UnspeccedNS + actor: AppBskyActorNS + embed: AppBskyEmbedNS + feed: AppBskyFeedNS + graph: AppBskyGraphNS + notification: AppBskyNotificationNS + richtext: AppBskyRichtextNS + unspecced: AppBskyUnspeccedNS constructor(server: Server) { this._server = server - this.actor = new ActorNS(server) - this.embed = new EmbedNS(server) - this.feed = new FeedNS(server) - this.graph = new GraphNS(server) - this.notification = new NotificationNS(server) - this.richtext = new RichtextNS(server) - this.unspecced = new UnspeccedNS(server) + this.actor = new AppBskyActorNS(server) + this.embed = new AppBskyEmbedNS(server) + this.feed = new AppBskyFeedNS(server) + this.graph = new AppBskyGraphNS(server) + this.notification = new AppBskyNotificationNS(server) + this.richtext = new AppBskyRichtextNS(server) + this.unspecced = new AppBskyUnspeccedNS(server) } } -export class ActorNS { +export class AppBskyActorNS { _server: Server constructor(server: Server) { @@ -1206,7 +1207,7 @@ export class ActorNS { } } -export class EmbedNS { +export class AppBskyEmbedNS { _server: Server constructor(server: Server) { @@ -1214,7 +1215,7 @@ export class EmbedNS { } } -export class FeedNS { +export class AppBskyFeedNS { _server: Server constructor(server: Server) { @@ -1398,7 +1399,7 @@ export class FeedNS { } } -export class GraphNS { +export class AppBskyGraphNS { _server: Server constructor(server: Server) { @@ -1493,6 +1494,17 @@ export class GraphNS { return this._server.xrpc.method(nsid, cfg) } + getRelationships( + cfg: ConfigOf< + AV, + AppBskyGraphGetRelationships.Handler>, + AppBskyGraphGetRelationships.HandlerReqCtx> + >, + ) { + const nsid = 'app.bsky.graph.getRelationships' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + getSuggestedFollowsByActor( cfg: ConfigOf< AV, @@ -1549,7 +1561,7 @@ export class GraphNS { } } -export class NotificationNS { +export class AppBskyNotificationNS { _server: Server constructor(server: Server) { @@ -1601,7 +1613,7 @@ export class NotificationNS { } } -export class RichtextNS { +export class AppBskyRichtextNS { _server: Server constructor(server: Server) { @@ -1609,7 +1621,7 @@ export class RichtextNS { } } -export class UnspeccedNS { +export class AppBskyUnspeccedNS { _server: Server constructor(server: Server) { @@ -1694,11 +1706,13 @@ type RouteRateLimitOpts = { calcKey?: (ctx: T) => string calcPoints?: (ctx: T) => number } +type HandlerOpts = { blobLimit?: number } type HandlerRateLimitOpts = SharedRateLimitOpts | RouteRateLimitOpts type ConfigOf = | Handler | { auth?: Auth + opts?: HandlerOpts rateLimit?: HandlerRateLimitOpts | HandlerRateLimitOpts[] handler: Handler } diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index d7791d1bffd..9db3be4f817 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -91,6 +91,7 @@ export const schemaDict = { 'lex:com.atproto.admin.defs#modEventEscalate', 'lex:com.atproto.admin.defs#modEventMute', 'lex:com.atproto.admin.defs#modEventEmail', + 'lex:com.atproto.admin.defs#modEventResolveAppeal', ], }, subject: { @@ -147,6 +148,7 @@ export const schemaDict = { 'lex:com.atproto.admin.defs#modEventAcknowledge', 'lex:com.atproto.admin.defs#modEventEscalate', 'lex:com.atproto.admin.defs#modEventMute', + 'lex:com.atproto.admin.defs#modEventEmail', 'lex:com.atproto.admin.defs#modEventResolveAppeal', ], }, @@ -1450,6 +1452,16 @@ export const schemaDict = { description: 'Sort direction for the events. Defaults to descending order of created at timestamp.', }, + createdAfter: { + type: 'string', + format: 'datetime', + description: 'Retrieve events created after a given timestamp', + }, + createdBefore: { + type: 'string', + format: 'datetime', + description: 'Retrieve events created before a given timestamp', + }, subject: { type: 'string', format: 'uri', @@ -1466,6 +1478,37 @@ export const schemaDict = { maximum: 100, default: 50, }, + hasComment: { + type: 'boolean', + description: 'If true, only events with comments are returned', + }, + comment: { + type: 'string', + description: + 'If specified, only events with comments containing the keyword are returned', + }, + addedLabels: { + type: 'array', + items: { + type: 'string', + }, + description: + 'If specified, only events where all of these labels were added are returned', + }, + removedLabels: { + type: 'array', + items: { + type: 'string', + }, + description: + 'If specified, only events where all of these labels were removed are returned', + }, + reportTypes: { + type: 'array', + items: { + type: 'string', + }, + }, cursor: { type: 'string', }, @@ -4643,6 +4686,7 @@ export const schemaDict = { 'lex:app.bsky.actor.defs#personalDetailsPref', 'lex:app.bsky.actor.defs#feedViewPref', 'lex:app.bsky.actor.defs#threadViewPref', + 'lex:app.bsky.actor.defs#interestsPref', ], }, }, @@ -4746,6 +4790,23 @@ export const schemaDict = { }, }, }, + interestsPref: { + type: 'object', + required: ['tags'], + properties: { + tags: { + type: 'array', + maxLength: 100, + items: { + type: 'string', + maxLength: 640, + maxGraphemes: 64, + }, + description: + "A list of tags which describe the account owner's interests gathered during onboarding.", + }, + }, + }, }, }, AppBskyActorGetPreferences: { @@ -6953,6 +7014,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: { @@ -7356,6 +7456,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', @@ -8349,6 +8508,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', diff --git a/packages/bsky/src/lexicon/types/app/bsky/actor/defs.ts b/packages/bsky/src/lexicon/types/app/bsky/actor/defs.ts index c20177ca50e..8cdcafcb72f 100644 --- a/packages/bsky/src/lexicon/types/app/bsky/actor/defs.ts +++ b/packages/bsky/src/lexicon/types/app/bsky/actor/defs.ts @@ -112,6 +112,7 @@ export type Preferences = ( | PersonalDetailsPref | FeedViewPref | ThreadViewPref + | InterestsPref | { $type: string; [k: string]: unknown } )[] @@ -233,3 +234,21 @@ export function isThreadViewPref(v: unknown): v is ThreadViewPref { export function validateThreadViewPref(v: unknown): ValidationResult { return lexicons.validate('app.bsky.actor.defs#threadViewPref', v) } + +export interface InterestsPref { + /** A list of tags which describe the account owner's interests gathered during onboarding. */ + tags: string[] + [k: string]: unknown +} + +export function isInterestsPref(v: unknown): v is InterestsPref { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.actor.defs#interestsPref' + ) +} + +export function validateInterestsPref(v: unknown): ValidationResult { + return lexicons.validate('app.bsky.actor.defs#interestsPref', v) +} diff --git a/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts b/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts index be2d8c385d9..31791dd3647 100644 --- a/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts +++ b/packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts @@ -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) +} diff --git a/packages/bsky/src/lexicon/types/app/bsky/graph/getRelationships.ts b/packages/bsky/src/lexicon/types/app/bsky/graph/getRelationships.ts new file mode 100644 index 00000000000..32a27434782 --- /dev/null +++ b/packages/bsky/src/lexicon/types/app/bsky/graph/getRelationships.ts @@ -0,0 +1,53 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth } from '@atproto/xrpc-server' +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 type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'ActorNotFound' +} + +export type HandlerOutput = HandlerError | HandlerSuccess +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/bsky/src/lexicon/types/com/atproto/admin/defs.ts b/packages/bsky/src/lexicon/types/com/atproto/admin/defs.ts index 41be2ad96e7..2fab0bc19a4 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/admin/defs.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/admin/defs.ts @@ -40,6 +40,7 @@ export interface ModEventView { | ModEventEscalate | ModEventMute | ModEventEmail + | ModEventResolveAppeal | { $type: string; [k: string]: unknown } subject: | RepoRef @@ -76,6 +77,7 @@ export interface ModEventViewDetail { | ModEventAcknowledge | ModEventEscalate | ModEventMute + | ModEventEmail | ModEventResolveAppeal | { $type: string; [k: string]: unknown } subject: diff --git a/packages/bsky/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts b/packages/bsky/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts index f3c4f1fbb95..9972b688b71 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts @@ -15,10 +15,23 @@ export interface QueryParams { createdBy?: string /** Sort direction for the events. Defaults to descending order of created at timestamp. */ sortDirection: 'asc' | 'desc' + /** Retrieve events created after a given timestamp */ + createdAfter?: string + /** Retrieve events created before a given timestamp */ + createdBefore?: string subject?: string /** If true, events on all record types (posts, lists, profile etc.) owned by the did are returned */ includeAllUserRecords: boolean limit: number + /** If true, only events with comments are returned */ + hasComment?: boolean + /** If specified, only events with comments containing the keyword are returned */ + comment?: string + /** If specified, only events where all of these labels were added are returned */ + addedLabels?: string[] + /** If specified, only events where all of these labels were removed are returned */ + removedLabels?: string[] + reportTypes?: string[] cursor?: string } diff --git a/packages/pds/src/lexicon/index.ts b/packages/pds/src/lexicon/index.ts index c5168aeed4f..6e3088057c7 100644 --- a/packages/pds/src/lexicon/index.ts +++ b/packages/pds/src/lexicon/index.ts @@ -115,6 +115,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' @@ -168,39 +169,39 @@ export class Server { export class ComNS { _server: Server - atproto: AtprotoNS + atproto: ComAtprotoNS constructor(server: Server) { this._server = server - this.atproto = new AtprotoNS(server) + this.atproto = new ComAtprotoNS(server) } } -export class AtprotoNS { +export class ComAtprotoNS { _server: Server - admin: AdminNS - identity: IdentityNS - label: LabelNS - moderation: ModerationNS - repo: RepoNS - server: ServerNS - sync: SyncNS - temp: TempNS + admin: ComAtprotoAdminNS + identity: ComAtprotoIdentityNS + label: ComAtprotoLabelNS + moderation: ComAtprotoModerationNS + repo: ComAtprotoRepoNS + server: ComAtprotoServerNS + sync: ComAtprotoSyncNS + temp: ComAtprotoTempNS constructor(server: Server) { this._server = server - this.admin = new AdminNS(server) - this.identity = new IdentityNS(server) - this.label = new LabelNS(server) - this.moderation = new ModerationNS(server) - this.repo = new RepoNS(server) - this.server = new ServerNS(server) - this.sync = new SyncNS(server) - this.temp = new TempNS(server) + this.admin = new ComAtprotoAdminNS(server) + this.identity = new ComAtprotoIdentityNS(server) + this.label = new ComAtprotoLabelNS(server) + this.moderation = new ComAtprotoModerationNS(server) + this.repo = new ComAtprotoRepoNS(server) + this.server = new ComAtprotoServerNS(server) + this.sync = new ComAtprotoSyncNS(server) + this.temp = new ComAtprotoTempNS(server) } } -export class AdminNS { +export class ComAtprotoAdminNS { _server: Server constructor(server: Server) { @@ -461,7 +462,7 @@ export class AdminNS { } } -export class IdentityNS { +export class ComAtprotoIdentityNS { _server: Server constructor(server: Server) { @@ -491,7 +492,7 @@ export class IdentityNS { } } -export class LabelNS { +export class ComAtprotoLabelNS { _server: Server constructor(server: Server) { @@ -521,7 +522,7 @@ export class LabelNS { } } -export class ModerationNS { +export class ComAtprotoModerationNS { _server: Server constructor(server: Server) { @@ -540,7 +541,7 @@ export class ModerationNS { } } -export class RepoNS { +export class ComAtprotoRepoNS { _server: Server constructor(server: Server) { @@ -636,7 +637,7 @@ export class RepoNS { } } -export class ServerNS { +export class ComAtprotoServerNS { _server: Server constructor(server: Server) { @@ -875,7 +876,7 @@ export class ServerNS { } } -export class SyncNS { +export class ComAtprotoSyncNS { _server: Server constructor(server: Server) { @@ -1015,7 +1016,7 @@ export class SyncNS { } } -export class TempNS { +export class ComAtprotoTempNS { _server: Server constructor(server: Server) { @@ -1091,37 +1092,37 @@ export class TempNS { export class AppNS { _server: Server - bsky: BskyNS + bsky: AppBskyNS constructor(server: Server) { this._server = server - this.bsky = new BskyNS(server) + this.bsky = new AppBskyNS(server) } } -export class BskyNS { +export class AppBskyNS { _server: Server - actor: ActorNS - embed: EmbedNS - feed: FeedNS - graph: GraphNS - notification: NotificationNS - richtext: RichtextNS - unspecced: UnspeccedNS + actor: AppBskyActorNS + embed: AppBskyEmbedNS + feed: AppBskyFeedNS + graph: AppBskyGraphNS + notification: AppBskyNotificationNS + richtext: AppBskyRichtextNS + unspecced: AppBskyUnspeccedNS constructor(server: Server) { this._server = server - this.actor = new ActorNS(server) - this.embed = new EmbedNS(server) - this.feed = new FeedNS(server) - this.graph = new GraphNS(server) - this.notification = new NotificationNS(server) - this.richtext = new RichtextNS(server) - this.unspecced = new UnspeccedNS(server) + this.actor = new AppBskyActorNS(server) + this.embed = new AppBskyEmbedNS(server) + this.feed = new AppBskyFeedNS(server) + this.graph = new AppBskyGraphNS(server) + this.notification = new AppBskyNotificationNS(server) + this.richtext = new AppBskyRichtextNS(server) + this.unspecced = new AppBskyUnspeccedNS(server) } } -export class ActorNS { +export class AppBskyActorNS { _server: Server constructor(server: Server) { @@ -1206,7 +1207,7 @@ export class ActorNS { } } -export class EmbedNS { +export class AppBskyEmbedNS { _server: Server constructor(server: Server) { @@ -1214,7 +1215,7 @@ export class EmbedNS { } } -export class FeedNS { +export class AppBskyFeedNS { _server: Server constructor(server: Server) { @@ -1398,7 +1399,7 @@ export class FeedNS { } } -export class GraphNS { +export class AppBskyGraphNS { _server: Server constructor(server: Server) { @@ -1493,6 +1494,17 @@ export class GraphNS { return this._server.xrpc.method(nsid, cfg) } + getRelationships( + cfg: ConfigOf< + AV, + AppBskyGraphGetRelationships.Handler>, + AppBskyGraphGetRelationships.HandlerReqCtx> + >, + ) { + const nsid = 'app.bsky.graph.getRelationships' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + getSuggestedFollowsByActor( cfg: ConfigOf< AV, @@ -1549,7 +1561,7 @@ export class GraphNS { } } -export class NotificationNS { +export class AppBskyNotificationNS { _server: Server constructor(server: Server) { @@ -1601,7 +1613,7 @@ export class NotificationNS { } } -export class RichtextNS { +export class AppBskyRichtextNS { _server: Server constructor(server: Server) { @@ -1609,7 +1621,7 @@ export class RichtextNS { } } -export class UnspeccedNS { +export class AppBskyUnspeccedNS { _server: Server constructor(server: Server) { @@ -1694,11 +1706,13 @@ type RouteRateLimitOpts = { calcKey?: (ctx: T) => string calcPoints?: (ctx: T) => number } +type HandlerOpts = { blobLimit?: number } type HandlerRateLimitOpts = SharedRateLimitOpts | RouteRateLimitOpts type ConfigOf = | Handler | { auth?: Auth + opts?: HandlerOpts rateLimit?: HandlerRateLimitOpts | HandlerRateLimitOpts[] handler: Handler } diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index d7791d1bffd..9db3be4f817 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -91,6 +91,7 @@ export const schemaDict = { 'lex:com.atproto.admin.defs#modEventEscalate', 'lex:com.atproto.admin.defs#modEventMute', 'lex:com.atproto.admin.defs#modEventEmail', + 'lex:com.atproto.admin.defs#modEventResolveAppeal', ], }, subject: { @@ -147,6 +148,7 @@ export const schemaDict = { 'lex:com.atproto.admin.defs#modEventAcknowledge', 'lex:com.atproto.admin.defs#modEventEscalate', 'lex:com.atproto.admin.defs#modEventMute', + 'lex:com.atproto.admin.defs#modEventEmail', 'lex:com.atproto.admin.defs#modEventResolveAppeal', ], }, @@ -1450,6 +1452,16 @@ export const schemaDict = { description: 'Sort direction for the events. Defaults to descending order of created at timestamp.', }, + createdAfter: { + type: 'string', + format: 'datetime', + description: 'Retrieve events created after a given timestamp', + }, + createdBefore: { + type: 'string', + format: 'datetime', + description: 'Retrieve events created before a given timestamp', + }, subject: { type: 'string', format: 'uri', @@ -1466,6 +1478,37 @@ export const schemaDict = { maximum: 100, default: 50, }, + hasComment: { + type: 'boolean', + description: 'If true, only events with comments are returned', + }, + comment: { + type: 'string', + description: + 'If specified, only events with comments containing the keyword are returned', + }, + addedLabels: { + type: 'array', + items: { + type: 'string', + }, + description: + 'If specified, only events where all of these labels were added are returned', + }, + removedLabels: { + type: 'array', + items: { + type: 'string', + }, + description: + 'If specified, only events where all of these labels were removed are returned', + }, + reportTypes: { + type: 'array', + items: { + type: 'string', + }, + }, cursor: { type: 'string', }, @@ -4643,6 +4686,7 @@ export const schemaDict = { 'lex:app.bsky.actor.defs#personalDetailsPref', 'lex:app.bsky.actor.defs#feedViewPref', 'lex:app.bsky.actor.defs#threadViewPref', + 'lex:app.bsky.actor.defs#interestsPref', ], }, }, @@ -4746,6 +4790,23 @@ export const schemaDict = { }, }, }, + interestsPref: { + type: 'object', + required: ['tags'], + properties: { + tags: { + type: 'array', + maxLength: 100, + items: { + type: 'string', + maxLength: 640, + maxGraphemes: 64, + }, + description: + "A list of tags which describe the account owner's interests gathered during onboarding.", + }, + }, + }, }, }, AppBskyActorGetPreferences: { @@ -6953,6 +7014,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: { @@ -7356,6 +7456,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', @@ -8349,6 +8508,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', diff --git a/packages/pds/src/lexicon/types/app/bsky/actor/defs.ts b/packages/pds/src/lexicon/types/app/bsky/actor/defs.ts index c20177ca50e..8cdcafcb72f 100644 --- a/packages/pds/src/lexicon/types/app/bsky/actor/defs.ts +++ b/packages/pds/src/lexicon/types/app/bsky/actor/defs.ts @@ -112,6 +112,7 @@ export type Preferences = ( | PersonalDetailsPref | FeedViewPref | ThreadViewPref + | InterestsPref | { $type: string; [k: string]: unknown } )[] @@ -233,3 +234,21 @@ export function isThreadViewPref(v: unknown): v is ThreadViewPref { export function validateThreadViewPref(v: unknown): ValidationResult { return lexicons.validate('app.bsky.actor.defs#threadViewPref', v) } + +export interface InterestsPref { + /** A list of tags which describe the account owner's interests gathered during onboarding. */ + tags: string[] + [k: string]: unknown +} + +export function isInterestsPref(v: unknown): v is InterestsPref { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.actor.defs#interestsPref' + ) +} + +export function validateInterestsPref(v: unknown): ValidationResult { + return lexicons.validate('app.bsky.actor.defs#interestsPref', v) +} diff --git a/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts b/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts index be2d8c385d9..31791dd3647 100644 --- a/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts +++ b/packages/pds/src/lexicon/types/app/bsky/graph/defs.ts @@ -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) +} diff --git a/packages/pds/src/lexicon/types/app/bsky/graph/getRelationships.ts b/packages/pds/src/lexicon/types/app/bsky/graph/getRelationships.ts new file mode 100644 index 00000000000..32a27434782 --- /dev/null +++ b/packages/pds/src/lexicon/types/app/bsky/graph/getRelationships.ts @@ -0,0 +1,53 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth } from '@atproto/xrpc-server' +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 type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'ActorNotFound' +} + +export type HandlerOutput = HandlerError | HandlerSuccess +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/pds/src/lexicon/types/com/atproto/admin/defs.ts b/packages/pds/src/lexicon/types/com/atproto/admin/defs.ts index 41be2ad96e7..2fab0bc19a4 100644 --- a/packages/pds/src/lexicon/types/com/atproto/admin/defs.ts +++ b/packages/pds/src/lexicon/types/com/atproto/admin/defs.ts @@ -40,6 +40,7 @@ export interface ModEventView { | ModEventEscalate | ModEventMute | ModEventEmail + | ModEventResolveAppeal | { $type: string; [k: string]: unknown } subject: | RepoRef @@ -76,6 +77,7 @@ export interface ModEventViewDetail { | ModEventAcknowledge | ModEventEscalate | ModEventMute + | ModEventEmail | ModEventResolveAppeal | { $type: string; [k: string]: unknown } subject: diff --git a/packages/pds/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts b/packages/pds/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts index f3c4f1fbb95..9972b688b71 100644 --- a/packages/pds/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts +++ b/packages/pds/src/lexicon/types/com/atproto/admin/queryModerationEvents.ts @@ -15,10 +15,23 @@ export interface QueryParams { createdBy?: string /** Sort direction for the events. Defaults to descending order of created at timestamp. */ sortDirection: 'asc' | 'desc' + /** Retrieve events created after a given timestamp */ + createdAfter?: string + /** Retrieve events created before a given timestamp */ + createdBefore?: string subject?: string /** If true, events on all record types (posts, lists, profile etc.) owned by the did are returned */ includeAllUserRecords: boolean limit: number + /** If true, only events with comments are returned */ + hasComment?: boolean + /** If specified, only events with comments containing the keyword are returned */ + comment?: string + /** If specified, only events where all of these labels were added are returned */ + addedLabels?: string[] + /** If specified, only events where all of these labels were removed are returned */ + removedLabels?: string[] + reportTypes?: string[] cursor?: string } diff --git a/packages/pds/tests/proxied/feedgen.test.ts b/packages/pds/tests/proxied/feedgen.test.ts index 6f06ce0d020..b2189e995d6 100644 --- a/packages/pds/tests/proxied/feedgen.test.ts +++ b/packages/pds/tests/proxied/feedgen.test.ts @@ -1,5 +1,5 @@ import { makeAlgos } from '@atproto/bsky' -import AtpAgent, { AtUri, FeedNS } from '@atproto/api' +import AtpAgent, { AtUri, AppBskyFeedNS } from '@atproto/api' import { TestNetwork, SeedClient } from '@atproto/dev-env' import basicSeed from '../seeds/basic' import { forSnapshot } from '../_util' @@ -9,7 +9,7 @@ describe('feedgen proxy view', () => { let agent: AtpAgent let sc: SeedClient - const origGetFeedGenerator = FeedNS.prototype.getFeedGenerator + const origGetFeedGenerator = AppBskyFeedNS.prototype.getFeedGenerator const feedUri = AtUri.make( 'did:example:feed-publisher', 'app.bsky.feed.generator', @@ -36,7 +36,7 @@ describe('feedgen proxy view', () => { ) await network.processAll() // mock getFeedGenerator() for use by pds's getFeed since we don't have a proper feedGenDid or feed publisher - FeedNS.prototype.getFeedGenerator = async function (params, opts) { + AppBskyFeedNS.prototype.getFeedGenerator = async function (params, opts) { if (params?.feed === feedUri.toString()) { return { success: true, @@ -60,7 +60,7 @@ describe('feedgen proxy view', () => { }) afterAll(async () => { - FeedNS.prototype.getFeedGenerator = origGetFeedGenerator + AppBskyFeedNS.prototype.getFeedGenerator = origGetFeedGenerator await network.close() })