@atproto/api 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "codegen": "lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
package/src/bsky-agent.ts CHANGED
@@ -23,6 +23,9 @@ export class BskyAgent extends AtpAgent {
23
23
  getPost: typeof this.api.app.bsky.feed.post.get = (params) =>
24
24
  this.api.app.bsky.feed.post.get(params)
25
25
 
26
+ getPosts: typeof this.api.app.bsky.feed.getPosts = (params, opts) =>
27
+ this.api.app.bsky.feed.getPosts(params, opts)
28
+
26
29
  getLikes: typeof this.api.app.bsky.feed.getLikes = (params, opts) =>
27
30
  this.api.app.bsky.feed.getLikes(params, opts)
28
31
 
@@ -41,6 +44,11 @@ export class BskyAgent extends AtpAgent {
41
44
  getProfiles: typeof this.api.app.bsky.actor.getProfiles = (params, opts) =>
42
45
  this.api.app.bsky.actor.getProfiles(params, opts)
43
46
 
47
+ getSuggestions: typeof this.api.app.bsky.actor.getSuggestions = (
48
+ params,
49
+ opts,
50
+ ) => this.api.app.bsky.actor.getSuggestions(params, opts)
51
+
44
52
  searchActors: typeof this.api.app.bsky.actor.searchActors = (params, opts) =>
45
53
  this.api.app.bsky.actor.searchActors(params, opts)
46
54
 
@@ -88,7 +88,9 @@ import * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
88
88
  import * as AppBskyFeedLike from './types/app/bsky/feed/like'
89
89
  import * as AppBskyFeedPost from './types/app/bsky/feed/post'
90
90
  import * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
91
+ import * as AppBskyGraphBlock from './types/app/bsky/graph/block'
91
92
  import * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
93
+ import * as AppBskyGraphGetBlocks from './types/app/bsky/graph/getBlocks'
92
94
  import * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
93
95
  import * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
94
96
  import * as AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
@@ -181,7 +183,9 @@ export * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
181
183
  export * as AppBskyFeedLike from './types/app/bsky/feed/like'
182
184
  export * as AppBskyFeedPost from './types/app/bsky/feed/post'
183
185
  export * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
186
+ export * as AppBskyGraphBlock from './types/app/bsky/graph/block'
184
187
  export * as AppBskyGraphFollow from './types/app/bsky/graph/follow'
188
+ export * as AppBskyGraphGetBlocks from './types/app/bsky/graph/getBlocks'
185
189
  export * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
186
190
  export * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
187
191
  export * as AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
@@ -1339,13 +1343,26 @@ export class RepostRecord {
1339
1343
 
1340
1344
  export class GraphNS {
1341
1345
  _service: AtpServiceClient
1346
+ block: BlockRecord
1342
1347
  follow: FollowRecord
1343
1348
 
1344
1349
  constructor(service: AtpServiceClient) {
1345
1350
  this._service = service
1351
+ this.block = new BlockRecord(service)
1346
1352
  this.follow = new FollowRecord(service)
1347
1353
  }
1348
1354
 
1355
+ getBlocks(
1356
+ params?: AppBskyGraphGetBlocks.QueryParams,
1357
+ opts?: AppBskyGraphGetBlocks.CallOptions,
1358
+ ): Promise<AppBskyGraphGetBlocks.Response> {
1359
+ return this._service.xrpc
1360
+ .call('app.bsky.graph.getBlocks', params, undefined, opts)
1361
+ .catch((e) => {
1362
+ throw AppBskyGraphGetBlocks.toKnownErr(e)
1363
+ })
1364
+ }
1365
+
1349
1366
  getFollowers(
1350
1367
  params?: AppBskyGraphGetFollowers.QueryParams,
1351
1368
  opts?: AppBskyGraphGetFollowers.CallOptions,
@@ -1402,6 +1419,67 @@ export class GraphNS {
1402
1419
  }
1403
1420
  }
1404
1421
 
1422
+ export class BlockRecord {
1423
+ _service: AtpServiceClient
1424
+
1425
+ constructor(service: AtpServiceClient) {
1426
+ this._service = service
1427
+ }
1428
+
1429
+ async list(
1430
+ params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
1431
+ ): Promise<{
1432
+ cursor?: string
1433
+ records: { uri: string; value: AppBskyGraphBlock.Record }[]
1434
+ }> {
1435
+ const res = await this._service.xrpc.call('com.atproto.repo.listRecords', {
1436
+ collection: 'app.bsky.graph.block',
1437
+ ...params,
1438
+ })
1439
+ return res.data
1440
+ }
1441
+
1442
+ async get(
1443
+ params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
1444
+ ): Promise<{ uri: string; cid: string; value: AppBskyGraphBlock.Record }> {
1445
+ const res = await this._service.xrpc.call('com.atproto.repo.getRecord', {
1446
+ collection: 'app.bsky.graph.block',
1447
+ ...params,
1448
+ })
1449
+ return res.data
1450
+ }
1451
+
1452
+ async create(
1453
+ params: Omit<
1454
+ ComAtprotoRepoCreateRecord.InputSchema,
1455
+ 'collection' | 'record'
1456
+ >,
1457
+ record: AppBskyGraphBlock.Record,
1458
+ headers?: Record<string, string>,
1459
+ ): Promise<{ uri: string; cid: string }> {
1460
+ record.$type = 'app.bsky.graph.block'
1461
+ const res = await this._service.xrpc.call(
1462
+ 'com.atproto.repo.createRecord',
1463
+ undefined,
1464
+ { collection: 'app.bsky.graph.block', ...params, record },
1465
+ { encoding: 'application/json', headers },
1466
+ )
1467
+ return res.data
1468
+ }
1469
+
1470
+ async delete(
1471
+ params: Omit<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
1472
+ headers?: Record<string, string>,
1473
+ ): Promise<void> {
1474
+ await this._service.xrpc.call(
1475
+ 'com.atproto.repo.deleteRecord',
1476
+ undefined,
1477
+ { collection: 'app.bsky.graph.block', ...params },
1478
+ { headers },
1479
+ )
1480
+ }
1481
+ }
1482
+
1405
1483
  export class FollowRecord {
1406
1484
  _service: AtpServiceClient
1407
1485
 
@@ -3394,6 +3394,13 @@ export const schemaDict = {
3394
3394
  muted: {
3395
3395
  type: 'boolean',
3396
3396
  },
3397
+ blockedBy: {
3398
+ type: 'boolean',
3399
+ },
3400
+ blocking: {
3401
+ type: 'string',
3402
+ format: 'at-uri',
3403
+ },
3397
3404
  following: {
3398
3405
  type: 'string',
3399
3406
  format: 'at-uri',
@@ -3793,6 +3800,7 @@ export const schemaDict = {
3793
3800
  refs: [
3794
3801
  'lex:app.bsky.embed.record#viewRecord',
3795
3802
  'lex:app.bsky.embed.record#viewNotFound',
3803
+ 'lex:app.bsky.embed.record#viewBlocked',
3796
3804
  ],
3797
3805
  },
3798
3806
  },
@@ -3816,6 +3824,13 @@ export const schemaDict = {
3816
3824
  value: {
3817
3825
  type: 'unknown',
3818
3826
  },
3827
+ labels: {
3828
+ type: 'array',
3829
+ items: {
3830
+ type: 'ref',
3831
+ ref: 'lex:com.atproto.label.defs#label',
3832
+ },
3833
+ },
3819
3834
  embeds: {
3820
3835
  type: 'array',
3821
3836
  items: {
@@ -3844,6 +3859,16 @@ export const schemaDict = {
3844
3859
  },
3845
3860
  },
3846
3861
  },
3862
+ viewBlocked: {
3863
+ type: 'object',
3864
+ required: ['uri'],
3865
+ properties: {
3866
+ uri: {
3867
+ type: 'string',
3868
+ format: 'at-uri',
3869
+ },
3870
+ },
3871
+ },
3847
3872
  },
3848
3873
  },
3849
3874
  AppBskyEmbedRecordWithMedia: {
@@ -4015,6 +4040,7 @@ export const schemaDict = {
4015
4040
  refs: [
4016
4041
  'lex:app.bsky.feed.defs#threadViewPost',
4017
4042
  'lex:app.bsky.feed.defs#notFoundPost',
4043
+ 'lex:app.bsky.feed.defs#blockedPost',
4018
4044
  ],
4019
4045
  },
4020
4046
  replies: {
@@ -4024,6 +4050,7 @@ export const schemaDict = {
4024
4050
  refs: [
4025
4051
  'lex:app.bsky.feed.defs#threadViewPost',
4026
4052
  'lex:app.bsky.feed.defs#notFoundPost',
4053
+ 'lex:app.bsky.feed.defs#blockedPost',
4027
4054
  ],
4028
4055
  },
4029
4056
  },
@@ -4043,6 +4070,20 @@ export const schemaDict = {
4043
4070
  },
4044
4071
  },
4045
4072
  },
4073
+ blockedPost: {
4074
+ type: 'object',
4075
+ required: ['uri', 'blocked'],
4076
+ properties: {
4077
+ uri: {
4078
+ type: 'string',
4079
+ format: 'at-uri',
4080
+ },
4081
+ blocked: {
4082
+ type: 'boolean',
4083
+ const: true,
4084
+ },
4085
+ },
4086
+ },
4046
4087
  },
4047
4088
  },
4048
4089
  AppBskyFeedGetAuthorFeed: {
@@ -4090,6 +4131,14 @@ export const schemaDict = {
4090
4131
  },
4091
4132
  },
4092
4133
  },
4134
+ errors: [
4135
+ {
4136
+ name: 'BlockedActor',
4137
+ },
4138
+ {
4139
+ name: 'BlockedByActor',
4140
+ },
4141
+ ],
4093
4142
  },
4094
4143
  },
4095
4144
  },
@@ -4200,6 +4249,7 @@ export const schemaDict = {
4200
4249
  refs: [
4201
4250
  'lex:app.bsky.feed.defs#threadViewPost',
4202
4251
  'lex:app.bsky.feed.defs#notFoundPost',
4252
+ 'lex:app.bsky.feed.defs#blockedPost',
4203
4253
  ],
4204
4254
  },
4205
4255
  },
@@ -4507,6 +4557,31 @@ export const schemaDict = {
4507
4557
  },
4508
4558
  },
4509
4559
  },
4560
+ AppBskyGraphBlock: {
4561
+ lexicon: 1,
4562
+ id: 'app.bsky.graph.block',
4563
+ defs: {
4564
+ main: {
4565
+ type: 'record',
4566
+ description: 'A block.',
4567
+ key: 'tid',
4568
+ record: {
4569
+ type: 'object',
4570
+ required: ['subject', 'createdAt'],
4571
+ properties: {
4572
+ subject: {
4573
+ type: 'string',
4574
+ format: 'did',
4575
+ },
4576
+ createdAt: {
4577
+ type: 'string',
4578
+ format: 'datetime',
4579
+ },
4580
+ },
4581
+ },
4582
+ },
4583
+ },
4584
+ },
4510
4585
  AppBskyGraphFollow: {
4511
4586
  lexicon: 1,
4512
4587
  id: 'app.bsky.graph.follow',
@@ -4532,6 +4607,49 @@ export const schemaDict = {
4532
4607
  },
4533
4608
  },
4534
4609
  },
4610
+ AppBskyGraphGetBlocks: {
4611
+ lexicon: 1,
4612
+ id: 'app.bsky.graph.getBlocks',
4613
+ defs: {
4614
+ main: {
4615
+ type: 'query',
4616
+ description: "Who is the requester's account blocking?",
4617
+ parameters: {
4618
+ type: 'params',
4619
+ properties: {
4620
+ limit: {
4621
+ type: 'integer',
4622
+ minimum: 1,
4623
+ maximum: 100,
4624
+ default: 50,
4625
+ },
4626
+ cursor: {
4627
+ type: 'string',
4628
+ },
4629
+ },
4630
+ },
4631
+ output: {
4632
+ encoding: 'application/json',
4633
+ schema: {
4634
+ type: 'object',
4635
+ required: ['blocks'],
4636
+ properties: {
4637
+ cursor: {
4638
+ type: 'string',
4639
+ },
4640
+ blocks: {
4641
+ type: 'array',
4642
+ items: {
4643
+ type: 'ref',
4644
+ ref: 'lex:app.bsky.actor.defs#profileView',
4645
+ },
4646
+ },
4647
+ },
4648
+ },
4649
+ },
4650
+ },
4651
+ },
4652
+ },
4535
4653
  AppBskyGraphGetFollowers: {
4536
4654
  lexicon: 1,
4537
4655
  id: 'app.bsky.graph.getFollowers',
@@ -5081,7 +5199,9 @@ export const ids = {
5081
5199
  AppBskyFeedLike: 'app.bsky.feed.like',
5082
5200
  AppBskyFeedPost: 'app.bsky.feed.post',
5083
5201
  AppBskyFeedRepost: 'app.bsky.feed.repost',
5202
+ AppBskyGraphBlock: 'app.bsky.graph.block',
5084
5203
  AppBskyGraphFollow: 'app.bsky.graph.follow',
5204
+ AppBskyGraphGetBlocks: 'app.bsky.graph.getBlocks',
5085
5205
  AppBskyGraphGetFollowers: 'app.bsky.graph.getFollowers',
5086
5206
  AppBskyGraphGetFollows: 'app.bsky.graph.getFollows',
5087
5207
  AppBskyGraphGetMutes: 'app.bsky.graph.getMutes',
@@ -83,6 +83,8 @@ export function validateProfileViewDetailed(v: unknown): ValidationResult {
83
83
 
84
84
  export interface ViewerState {
85
85
  muted?: boolean
86
+ blockedBy?: boolean
87
+ blocking?: string
86
88
  following?: string
87
89
  followedBy?: string
88
90
  [k: string]: unknown
@@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { CID } from 'multiformats/cid'
8
8
  import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef'
9
9
  import * as AppBskyActorDefs from '../actor/defs'
10
+ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
10
11
  import * as AppBskyEmbedImages from './images'
11
12
  import * as AppBskyEmbedExternal from './external'
12
13
  import * as AppBskyEmbedRecordWithMedia from './recordWithMedia'
@@ -30,7 +31,11 @@ export function validateMain(v: unknown): ValidationResult {
30
31
  }
31
32
 
32
33
  export interface View {
33
- record: ViewRecord | ViewNotFound | { $type: string; [k: string]: unknown }
34
+ record:
35
+ | ViewRecord
36
+ | ViewNotFound
37
+ | ViewBlocked
38
+ | { $type: string; [k: string]: unknown }
34
39
  [k: string]: unknown
35
40
  }
36
41
 
@@ -49,6 +54,7 @@ export interface ViewRecord {
49
54
  cid: string
50
55
  author: AppBskyActorDefs.ProfileViewBasic
51
56
  value: {}
57
+ labels?: ComAtprotoLabelDefs.Label[]
52
58
  embeds?: (
53
59
  | AppBskyEmbedImages.View
54
60
  | AppBskyEmbedExternal.View
@@ -88,3 +94,20 @@ export function isViewNotFound(v: unknown): v is ViewNotFound {
88
94
  export function validateViewNotFound(v: unknown): ValidationResult {
89
95
  return lexicons.validate('app.bsky.embed.record#viewNotFound', v)
90
96
  }
97
+
98
+ export interface ViewBlocked {
99
+ uri: string
100
+ [k: string]: unknown
101
+ }
102
+
103
+ export function isViewBlocked(v: unknown): v is ViewBlocked {
104
+ return (
105
+ isObj(v) &&
106
+ hasProp(v, '$type') &&
107
+ v.$type === 'app.bsky.embed.record#viewBlocked'
108
+ )
109
+ }
110
+
111
+ export function validateViewBlocked(v: unknown): ValidationResult {
112
+ return lexicons.validate('app.bsky.embed.record#viewBlocked', v)
113
+ }
@@ -118,10 +118,12 @@ export interface ThreadViewPost {
118
118
  parent?:
119
119
  | ThreadViewPost
120
120
  | NotFoundPost
121
+ | BlockedPost
121
122
  | { $type: string; [k: string]: unknown }
122
123
  replies?: (
123
124
  | ThreadViewPost
124
125
  | NotFoundPost
126
+ | BlockedPost
125
127
  | { $type: string; [k: string]: unknown }
126
128
  )[]
127
129
  [k: string]: unknown
@@ -156,3 +158,21 @@ export function isNotFoundPost(v: unknown): v is NotFoundPost {
156
158
  export function validateNotFoundPost(v: unknown): ValidationResult {
157
159
  return lexicons.validate('app.bsky.feed.defs#notFoundPost', v)
158
160
  }
161
+
162
+ export interface BlockedPost {
163
+ uri: string
164
+ blocked: true
165
+ [k: string]: unknown
166
+ }
167
+
168
+ export function isBlockedPost(v: unknown): v is BlockedPost {
169
+ return (
170
+ isObj(v) &&
171
+ hasProp(v, '$type') &&
172
+ v.$type === 'app.bsky.feed.defs#blockedPost'
173
+ )
174
+ }
175
+
176
+ export function validateBlockedPost(v: unknown): ValidationResult {
177
+ return lexicons.validate('app.bsky.feed.defs#blockedPost', v)
178
+ }
@@ -32,8 +32,22 @@ export interface Response {
32
32
  data: OutputSchema
33
33
  }
34
34
 
35
+ export class BlockedActorError extends XRPCError {
36
+ constructor(src: XRPCError) {
37
+ super(src.status, src.error, src.message)
38
+ }
39
+ }
40
+
41
+ export class BlockedByActorError extends XRPCError {
42
+ constructor(src: XRPCError) {
43
+ super(src.status, src.error, src.message)
44
+ }
45
+ }
46
+
35
47
  export function toKnownErr(e: any) {
36
48
  if (e instanceof XRPCError) {
49
+ if (e.error === 'BlockedActor') return new BlockedActorError(e)
50
+ if (e.error === 'BlockedByActor') return new BlockedByActorError(e)
37
51
  }
38
52
  return e
39
53
  }
@@ -19,6 +19,7 @@ export interface OutputSchema {
19
19
  thread:
20
20
  | AppBskyFeedDefs.ThreadViewPost
21
21
  | AppBskyFeedDefs.NotFoundPost
22
+ | AppBskyFeedDefs.BlockedPost
22
23
  | { $type: string; [k: string]: unknown }
23
24
  [k: string]: unknown
24
25
  }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
5
+ import { isObj, hasProp } from '../../../../util'
6
+ import { lexicons } from '../../../../lexicons'
7
+ import { CID } from 'multiformats/cid'
8
+
9
+ export interface Record {
10
+ subject: string
11
+ createdAt: string
12
+ [k: string]: unknown
13
+ }
14
+
15
+ export function isRecord(v: unknown): v is Record {
16
+ return (
17
+ isObj(v) &&
18
+ hasProp(v, '$type') &&
19
+ (v.$type === 'app.bsky.graph.block#main' ||
20
+ v.$type === 'app.bsky.graph.block')
21
+ )
22
+ }
23
+
24
+ export function validateRecord(v: unknown): ValidationResult {
25
+ return lexicons.validate('app.bsky.graph.block#main', v)
26
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+ import * as AppBskyActorDefs from '../actor/defs'
10
+
11
+ export interface QueryParams {
12
+ limit?: number
13
+ cursor?: string
14
+ }
15
+
16
+ export type InputSchema = undefined
17
+
18
+ export interface OutputSchema {
19
+ cursor?: string
20
+ blocks: AppBskyActorDefs.ProfileView[]
21
+ [k: string]: unknown
22
+ }
23
+
24
+ export interface CallOptions {
25
+ headers?: Headers
26
+ }
27
+
28
+ export interface Response {
29
+ success: boolean
30
+ headers: Headers
31
+ data: OutputSchema
32
+ }
33
+
34
+ export function toKnownErr(e: any) {
35
+ if (e instanceof XRPCError) {
36
+ }
37
+ return e
38
+ }