@atproto/api 0.9.7 → 0.10.0

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/bsky-agent.d.ts +6 -1
  3. package/dist/client/index.d.ts +30 -9
  4. package/dist/client/lexicons.d.ts +449 -110
  5. package/dist/client/types/app/bsky/actor/defs.d.ts +20 -0
  6. package/dist/client/types/com/atproto/admin/defs.d.ts +9 -0
  7. package/dist/client/types/com/atproto/admin/emitModerationEvent.d.ts +1 -1
  8. package/dist/client/types/com/atproto/admin/queryModerationEvents.d.ts +2 -0
  9. package/dist/client/types/com/atproto/admin/queryModerationStatuses.d.ts +2 -0
  10. package/dist/client/types/com/atproto/identity/getRecommendedDidCredentials.d.ts +20 -0
  11. package/dist/client/types/com/atproto/{temp/pushBlob.d.ts → identity/requestPlcOperationSignature.d.ts} +1 -3
  12. package/dist/client/types/com/atproto/identity/signPlcOperation.d.ts +26 -0
  13. package/dist/client/types/com/atproto/identity/submitPlcOperation.d.ts +17 -0
  14. package/dist/client/types/com/atproto/{temp → repo}/importRepo.d.ts +0 -2
  15. package/dist/client/types/com/atproto/repo/listMissingBlobs.d.ts +28 -0
  16. package/dist/client/types/com/atproto/server/activateAccount.d.ts +13 -0
  17. package/dist/client/types/com/atproto/server/checkAccountStatus.d.ts +25 -0
  18. package/dist/client/types/com/atproto/server/deactivateAccount.d.ts +17 -0
  19. package/dist/client/types/com/atproto/server/describeServer.d.ts +1 -0
  20. package/dist/client/types/com/atproto/server/getServiceAuth.d.ts +18 -0
  21. package/dist/client/types/com/atproto/sync/subscribeRepos.d.ts +8 -0
  22. package/dist/index.js +1068 -549
  23. package/dist/index.js.map +3 -3
  24. package/dist/types.d.ts +3 -0
  25. package/package.json +2 -2
  26. package/src/bsky-agent.ts +136 -0
  27. package/src/client/index.ts +140 -39
  28. package/src/client/lexicons.ts +491 -138
  29. package/src/client/types/app/bsky/actor/defs.ts +59 -0
  30. package/src/client/types/app/bsky/feed/post.ts +1 -1
  31. package/src/client/types/com/atproto/admin/defs.ts +24 -0
  32. package/src/client/types/com/atproto/admin/emitModerationEvent.ts +1 -0
  33. package/src/client/types/com/atproto/admin/queryModerationEvents.ts +4 -0
  34. package/src/client/types/com/atproto/admin/queryModerationStatuses.ts +2 -0
  35. package/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts +37 -0
  36. package/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts +28 -0
  37. package/src/client/types/com/atproto/identity/signPlcOperation.ts +44 -0
  38. package/src/client/types/com/atproto/{temp/pushBlob.ts → identity/submitPlcOperation.ts} +6 -6
  39. package/src/client/types/com/atproto/{temp → repo}/importRepo.ts +1 -5
  40. package/src/client/types/com/atproto/repo/listMissingBlobs.ts +55 -0
  41. package/src/client/types/com/atproto/server/activateAccount.ts +28 -0
  42. package/src/client/types/com/atproto/server/checkAccountStatus.ts +41 -0
  43. package/src/client/types/com/atproto/server/deactivateAccount.ts +33 -0
  44. package/src/client/types/com/atproto/server/describeServer.ts +1 -0
  45. package/src/client/types/com/atproto/server/getServiceAuth.ts +36 -0
  46. package/src/client/types/com/atproto/sync/subscribeRepos.ts +23 -3
  47. package/src/types.ts +3 -0
  48. package/tests/agent.test.ts +1 -0
  49. package/tests/bsky-agent.test.ts +183 -0
  50. package/dist/client/types/com/atproto/temp/transferAccount.d.ts +0 -48
  51. package/src/client/types/com/atproto/temp/transferAccount.ts +0 -92
@@ -239,6 +239,8 @@ describe('agent', () => {
239
239
  interests: {
240
240
  tags: [],
241
241
  },
242
+ mutedWords: [],
243
+ hiddenPosts: [],
242
244
  })
243
245
 
244
246
  await agent.setAdultContentEnabled(true)
@@ -263,6 +265,8 @@ describe('agent', () => {
263
265
  interests: {
264
266
  tags: [],
265
267
  },
268
+ mutedWords: [],
269
+ hiddenPosts: [],
266
270
  })
267
271
 
268
272
  await agent.setAdultContentEnabled(false)
@@ -287,6 +291,8 @@ describe('agent', () => {
287
291
  interests: {
288
292
  tags: [],
289
293
  },
294
+ mutedWords: [],
295
+ hiddenPosts: [],
290
296
  })
291
297
 
292
298
  await agent.setContentLabelPref('impersonation', 'warn')
@@ -313,6 +319,8 @@ describe('agent', () => {
313
319
  interests: {
314
320
  tags: [],
315
321
  },
322
+ mutedWords: [],
323
+ hiddenPosts: [],
316
324
  })
317
325
 
318
326
  await agent.setContentLabelPref('spam', 'show') // will convert to 'ignore'
@@ -341,6 +349,8 @@ describe('agent', () => {
341
349
  interests: {
342
350
  tags: [],
343
351
  },
352
+ mutedWords: [],
353
+ hiddenPosts: [],
344
354
  })
345
355
 
346
356
  await agent.addSavedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -371,6 +381,8 @@ describe('agent', () => {
371
381
  interests: {
372
382
  tags: [],
373
383
  },
384
+ mutedWords: [],
385
+ hiddenPosts: [],
374
386
  })
375
387
 
376
388
  await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -401,6 +413,8 @@ describe('agent', () => {
401
413
  interests: {
402
414
  tags: [],
403
415
  },
416
+ mutedWords: [],
417
+ hiddenPosts: [],
404
418
  })
405
419
 
406
420
  await agent.removePinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -431,6 +445,8 @@ describe('agent', () => {
431
445
  interests: {
432
446
  tags: [],
433
447
  },
448
+ mutedWords: [],
449
+ hiddenPosts: [],
434
450
  })
435
451
 
436
452
  await agent.removeSavedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -461,6 +477,8 @@ describe('agent', () => {
461
477
  interests: {
462
478
  tags: [],
463
479
  },
480
+ mutedWords: [],
481
+ hiddenPosts: [],
464
482
  })
465
483
 
466
484
  await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -491,6 +509,8 @@ describe('agent', () => {
491
509
  interests: {
492
510
  tags: [],
493
511
  },
512
+ mutedWords: [],
513
+ hiddenPosts: [],
494
514
  })
495
515
 
496
516
  await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake2')
@@ -527,6 +547,8 @@ describe('agent', () => {
527
547
  interests: {
528
548
  tags: [],
529
549
  },
550
+ mutedWords: [],
551
+ hiddenPosts: [],
530
552
  })
531
553
 
532
554
  await agent.removeSavedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -557,6 +579,8 @@ describe('agent', () => {
557
579
  interests: {
558
580
  tags: [],
559
581
  },
582
+ mutedWords: [],
583
+ hiddenPosts: [],
560
584
  })
561
585
 
562
586
  await agent.setPersonalDetails({ birthDate: '2023-09-11T18:05:42.556Z' })
@@ -587,6 +611,8 @@ describe('agent', () => {
587
611
  interests: {
588
612
  tags: [],
589
613
  },
614
+ mutedWords: [],
615
+ hiddenPosts: [],
590
616
  })
591
617
 
592
618
  await agent.setFeedViewPrefs('home', { hideReplies: true })
@@ -617,6 +643,8 @@ describe('agent', () => {
617
643
  interests: {
618
644
  tags: [],
619
645
  },
646
+ mutedWords: [],
647
+ hiddenPosts: [],
620
648
  })
621
649
 
622
650
  await agent.setFeedViewPrefs('home', { hideReplies: false })
@@ -647,6 +675,8 @@ describe('agent', () => {
647
675
  interests: {
648
676
  tags: [],
649
677
  },
678
+ mutedWords: [],
679
+ hiddenPosts: [],
650
680
  })
651
681
 
652
682
  await agent.setFeedViewPrefs('other', { hideReplies: true })
@@ -684,6 +714,8 @@ describe('agent', () => {
684
714
  interests: {
685
715
  tags: [],
686
716
  },
717
+ mutedWords: [],
718
+ hiddenPosts: [],
687
719
  })
688
720
 
689
721
  await agent.setThreadViewPrefs({ sort: 'random' })
@@ -721,6 +753,8 @@ describe('agent', () => {
721
753
  interests: {
722
754
  tags: [],
723
755
  },
756
+ mutedWords: [],
757
+ hiddenPosts: [],
724
758
  })
725
759
 
726
760
  await agent.setThreadViewPrefs({ sort: 'oldest' })
@@ -758,6 +792,8 @@ describe('agent', () => {
758
792
  interests: {
759
793
  tags: [],
760
794
  },
795
+ mutedWords: [],
796
+ hiddenPosts: [],
761
797
  })
762
798
 
763
799
  await agent.setInterestsPref({ tags: ['foo', 'bar'] })
@@ -795,6 +831,8 @@ describe('agent', () => {
795
831
  interests: {
796
832
  tags: ['foo', 'bar'],
797
833
  },
834
+ mutedWords: [],
835
+ hiddenPosts: [],
798
836
  })
799
837
  })
800
838
 
@@ -921,6 +959,8 @@ describe('agent', () => {
921
959
  interests: {
922
960
  tags: [],
923
961
  },
962
+ mutedWords: [],
963
+ hiddenPosts: [],
924
964
  })
925
965
 
926
966
  await agent.setAdultContentEnabled(false)
@@ -950,6 +990,8 @@ describe('agent', () => {
950
990
  interests: {
951
991
  tags: [],
952
992
  },
993
+ mutedWords: [],
994
+ hiddenPosts: [],
953
995
  })
954
996
 
955
997
  await agent.setContentLabelPref('nsfw', 'hide')
@@ -979,6 +1021,8 @@ describe('agent', () => {
979
1021
  interests: {
980
1022
  tags: [],
981
1023
  },
1024
+ mutedWords: [],
1025
+ hiddenPosts: [],
982
1026
  })
983
1027
 
984
1028
  await agent.addPinnedFeed('at://bob.com/app.bsky.feed.generator/fake')
@@ -1008,6 +1052,8 @@ describe('agent', () => {
1008
1052
  interests: {
1009
1053
  tags: [],
1010
1054
  },
1055
+ mutedWords: [],
1056
+ hiddenPosts: [],
1011
1057
  })
1012
1058
 
1013
1059
  await agent.setPersonalDetails({ birthDate: '2023-09-11T18:05:42.556Z' })
@@ -1037,6 +1083,8 @@ describe('agent', () => {
1037
1083
  interests: {
1038
1084
  tags: [],
1039
1085
  },
1086
+ mutedWords: [],
1087
+ hiddenPosts: [],
1040
1088
  })
1041
1089
 
1042
1090
  await agent.setFeedViewPrefs('home', {
@@ -1077,6 +1125,8 @@ describe('agent', () => {
1077
1125
  interests: {
1078
1126
  tags: [],
1079
1127
  },
1128
+ mutedWords: [],
1129
+ hiddenPosts: [],
1080
1130
  })
1081
1131
 
1082
1132
  const res = await agent.app.bsky.actor.getPreferences()
@@ -1118,6 +1168,139 @@ describe('agent', () => {
1118
1168
  ].sort(byType),
1119
1169
  )
1120
1170
  })
1171
+
1172
+ describe('muted words', () => {
1173
+ let agent: BskyAgent
1174
+ const mutedWords = [
1175
+ { value: 'both', targets: ['content', 'tag'] },
1176
+ { value: 'content', targets: ['content'] },
1177
+ { value: 'tag', targets: ['tag'] },
1178
+ { value: 'tag_then_both', targets: ['tag'] },
1179
+ { value: 'tag_then_content', targets: ['tag'] },
1180
+ { value: 'tag_then_none', targets: ['tag'] },
1181
+ ]
1182
+
1183
+ beforeAll(async () => {
1184
+ agent = new BskyAgent({ service: network.pds.url })
1185
+ await agent.createAccount({
1186
+ handle: 'user7.test',
1187
+ email: 'user7@test.com',
1188
+ password: 'password',
1189
+ })
1190
+ })
1191
+
1192
+ it('upsertMutedWords', async () => {
1193
+ await agent.upsertMutedWords(mutedWords)
1194
+ await agent.upsertMutedWords(mutedWords) // double
1195
+ await expect(agent.getPreferences()).resolves.toHaveProperty(
1196
+ 'mutedWords',
1197
+ mutedWords,
1198
+ )
1199
+ })
1200
+
1201
+ it('upsertMutedWords with #', async () => {
1202
+ await agent.upsertMutedWords([{ value: '#hashtag', targets: ['tag'] }])
1203
+ const { mutedWords } = await agent.getPreferences()
1204
+ expect(mutedWords.find((m) => m.value === '#hashtag')).toBeFalsy()
1205
+ expect(mutedWords.find((m) => m.value === 'hashtag')).toBeTruthy()
1206
+ })
1207
+
1208
+ it('updateMutedWord', async () => {
1209
+ await agent.updateMutedWord({
1210
+ value: 'tag_then_content',
1211
+ targets: ['content'],
1212
+ })
1213
+ await agent.updateMutedWord({
1214
+ value: 'tag_then_both',
1215
+ targets: ['content', 'tag'],
1216
+ })
1217
+ await agent.updateMutedWord({ value: 'tag_then_none', targets: [] })
1218
+ await agent.updateMutedWord({ value: 'no_exist', targets: ['tag'] })
1219
+ const { mutedWords } = await agent.getPreferences()
1220
+
1221
+ expect(
1222
+ mutedWords.find((m) => m.value === 'tag_then_content'),
1223
+ ).toHaveProperty('targets', ['content'])
1224
+ expect(
1225
+ mutedWords.find((m) => m.value === 'tag_then_both'),
1226
+ ).toHaveProperty('targets', ['content', 'tag'])
1227
+ expect(
1228
+ mutedWords.find((m) => m.value === 'tag_then_none'),
1229
+ ).toHaveProperty('targets', [])
1230
+ expect(mutedWords.find((m) => m.value === 'no_exist')).toBeFalsy()
1231
+ })
1232
+
1233
+ it('updateMutedWord with #', async () => {
1234
+ await agent.updateMutedWord({
1235
+ value: 'hashtag',
1236
+ targets: ['tag', 'content'],
1237
+ })
1238
+ const { mutedWords } = await agent.getPreferences()
1239
+ expect(mutedWords.find((m) => m.value === 'hashtag')).toStrictEqual({
1240
+ value: 'hashtag',
1241
+ targets: ['tag', 'content'],
1242
+ })
1243
+ })
1244
+
1245
+ it('removeMutedWord', async () => {
1246
+ await agent.removeMutedWord({ value: 'tag_then_content', targets: [] })
1247
+ await agent.removeMutedWord({ value: 'tag_then_both', targets: [] })
1248
+ await agent.removeMutedWord({ value: 'tag_then_none', targets: [] })
1249
+ const { mutedWords } = await agent.getPreferences()
1250
+
1251
+ expect(
1252
+ mutedWords.find((m) => m.value === 'tag_then_content'),
1253
+ ).toBeFalsy()
1254
+ expect(mutedWords.find((m) => m.value === 'tag_then_both')).toBeFalsy()
1255
+ expect(mutedWords.find((m) => m.value === 'tag_then_none')).toBeFalsy()
1256
+ })
1257
+
1258
+ it('removeMutedWord with #', async () => {
1259
+ await agent.removeMutedWord({ value: '#hashtag', targets: [] })
1260
+ const { mutedWords } = await agent.getPreferences()
1261
+
1262
+ expect(mutedWords.find((m) => m.value === 'hashtag')).toBeFalsy()
1263
+ })
1264
+ })
1265
+
1266
+ describe('hidden posts', () => {
1267
+ let agent: BskyAgent
1268
+ const postUri = 'at://did:plc:fake/app.bsky.feed.post/fake'
1269
+
1270
+ beforeAll(async () => {
1271
+ agent = new BskyAgent({ service: network.pds.url })
1272
+ await agent.createAccount({
1273
+ handle: 'user8.test',
1274
+ email: 'user8@test.com',
1275
+ password: 'password',
1276
+ })
1277
+ })
1278
+
1279
+ it('hidePost', async () => {
1280
+ await agent.hidePost(postUri)
1281
+ await agent.hidePost(postUri) // double, should dedupe
1282
+ await expect(agent.getPreferences()).resolves.toHaveProperty(
1283
+ 'hiddenPosts',
1284
+ [postUri],
1285
+ )
1286
+ })
1287
+
1288
+ it('unhidePost', async () => {
1289
+ await agent.unhidePost(postUri)
1290
+ await expect(agent.getPreferences()).resolves.toHaveProperty(
1291
+ 'hiddenPosts',
1292
+ [],
1293
+ )
1294
+ // no issues calling a second time
1295
+ await agent.unhidePost(postUri)
1296
+ await expect(agent.getPreferences()).resolves.toHaveProperty(
1297
+ 'hiddenPosts',
1298
+ [],
1299
+ )
1300
+ })
1301
+ })
1302
+
1303
+ // end
1121
1304
  })
1122
1305
  })
1123
1306
 
@@ -1,48 +0,0 @@
1
- import { Headers, XRPCError } from '@atproto/xrpc';
2
- export interface QueryParams {
3
- }
4
- export interface InputSchema {
5
- handle: string;
6
- did: string;
7
- plcOp: {};
8
- [k: string]: unknown;
9
- }
10
- export interface OutputSchema {
11
- accessJwt: string;
12
- refreshJwt: string;
13
- handle: string;
14
- did: string;
15
- [k: string]: unknown;
16
- }
17
- export interface CallOptions {
18
- headers?: Headers;
19
- qp?: QueryParams;
20
- encoding: 'application/json';
21
- }
22
- export interface Response {
23
- success: boolean;
24
- headers: Headers;
25
- data: OutputSchema;
26
- }
27
- export declare class InvalidHandleError extends XRPCError {
28
- constructor(src: XRPCError);
29
- }
30
- export declare class InvalidPasswordError extends XRPCError {
31
- constructor(src: XRPCError);
32
- }
33
- export declare class InvalidInviteCodeError extends XRPCError {
34
- constructor(src: XRPCError);
35
- }
36
- export declare class HandleNotAvailableError extends XRPCError {
37
- constructor(src: XRPCError);
38
- }
39
- export declare class UnsupportedDomainError extends XRPCError {
40
- constructor(src: XRPCError);
41
- }
42
- export declare class UnresolvableDidError extends XRPCError {
43
- constructor(src: XRPCError);
44
- }
45
- export declare class IncompatibleDidDocError extends XRPCError {
46
- constructor(src: XRPCError);
47
- }
48
- export declare function toKnownErr(e: any): any;
@@ -1,92 +0,0 @@
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
-
10
- export interface QueryParams {}
11
-
12
- export interface InputSchema {
13
- handle: string
14
- did: string
15
- plcOp: {}
16
- [k: string]: unknown
17
- }
18
-
19
- export interface OutputSchema {
20
- accessJwt: string
21
- refreshJwt: string
22
- handle: string
23
- did: string
24
- [k: string]: unknown
25
- }
26
-
27
- export interface CallOptions {
28
- headers?: Headers
29
- qp?: QueryParams
30
- encoding: 'application/json'
31
- }
32
-
33
- export interface Response {
34
- success: boolean
35
- headers: Headers
36
- data: OutputSchema
37
- }
38
-
39
- export class InvalidHandleError extends XRPCError {
40
- constructor(src: XRPCError) {
41
- super(src.status, src.error, src.message, src.headers)
42
- }
43
- }
44
-
45
- export class InvalidPasswordError extends XRPCError {
46
- constructor(src: XRPCError) {
47
- super(src.status, src.error, src.message, src.headers)
48
- }
49
- }
50
-
51
- export class InvalidInviteCodeError extends XRPCError {
52
- constructor(src: XRPCError) {
53
- super(src.status, src.error, src.message, src.headers)
54
- }
55
- }
56
-
57
- export class HandleNotAvailableError extends XRPCError {
58
- constructor(src: XRPCError) {
59
- super(src.status, src.error, src.message, src.headers)
60
- }
61
- }
62
-
63
- export class UnsupportedDomainError extends XRPCError {
64
- constructor(src: XRPCError) {
65
- super(src.status, src.error, src.message, src.headers)
66
- }
67
- }
68
-
69
- export class UnresolvableDidError extends XRPCError {
70
- constructor(src: XRPCError) {
71
- super(src.status, src.error, src.message, src.headers)
72
- }
73
- }
74
-
75
- export class IncompatibleDidDocError extends XRPCError {
76
- constructor(src: XRPCError) {
77
- super(src.status, src.error, src.message, src.headers)
78
- }
79
- }
80
-
81
- export function toKnownErr(e: any) {
82
- if (e instanceof XRPCError) {
83
- if (e.error === 'InvalidHandle') return new InvalidHandleError(e)
84
- if (e.error === 'InvalidPassword') return new InvalidPasswordError(e)
85
- if (e.error === 'InvalidInviteCode') return new InvalidInviteCodeError(e)
86
- if (e.error === 'HandleNotAvailable') return new HandleNotAvailableError(e)
87
- if (e.error === 'UnsupportedDomain') return new UnsupportedDomainError(e)
88
- if (e.error === 'UnresolvableDid') return new UnresolvableDidError(e)
89
- if (e.error === 'IncompatibleDidDoc') return new IncompatibleDidDocError(e)
90
- }
91
- return e
92
- }