@atproto/api 0.6.4 → 0.6.6

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 (82) hide show
  1. package/dist/bsky-agent.d.ts +1 -0
  2. package/dist/client/index.d.ts +6 -0
  3. package/dist/client/lexicons.d.ts +87 -0
  4. package/dist/client/types/app/bsky/actor/createScene.d.ts +32 -0
  5. package/dist/client/types/app/bsky/actor/ref.d.ts +28 -0
  6. package/dist/client/types/app/bsky/actor/search.d.ts +22 -0
  7. package/dist/client/types/app/bsky/actor/searchTypeahead.d.ts +20 -0
  8. package/dist/client/types/app/bsky/actor/updateProfile.d.ts +40 -0
  9. package/dist/client/types/app/bsky/feed/feedViewPost.d.ts +28 -0
  10. package/dist/client/types/app/bsky/feed/getActorLikes.d.ts +28 -0
  11. package/dist/client/types/app/bsky/feed/getSavedFeeds.d.ts +21 -0
  12. package/dist/client/types/app/bsky/feed/getVotes.d.ts +36 -0
  13. package/dist/client/types/app/bsky/feed/saveFeed.d.ts +17 -0
  14. package/dist/client/types/app/bsky/feed/setVote.d.ts +25 -0
  15. package/dist/client/types/app/bsky/feed/trend.d.ts +9 -0
  16. package/dist/client/types/app/bsky/feed/unsaveFeed.d.ts +17 -0
  17. package/dist/client/types/app/bsky/feed/vote.d.ts +10 -0
  18. package/dist/client/types/app/bsky/graph/assertCreator.d.ts +1 -0
  19. package/dist/client/types/app/bsky/graph/assertMember.d.ts +1 -0
  20. package/dist/client/types/app/bsky/graph/assertion.d.ts +10 -0
  21. package/dist/client/types/app/bsky/graph/confirmation.d.ts +11 -0
  22. package/dist/client/types/app/bsky/graph/getAssertions.d.ts +48 -0
  23. package/dist/client/types/app/bsky/graph/getListBlocks.d.ts +21 -0
  24. package/dist/client/types/app/bsky/graph/getMembers.d.ts +36 -0
  25. package/dist/client/types/app/bsky/graph/getMemberships.d.ts +36 -0
  26. package/dist/client/types/app/bsky/graph/listblock.d.ts +8 -0
  27. package/dist/client/types/app/bsky/graph/mute.d.ts +17 -0
  28. package/dist/client/types/app/bsky/graph/subscribeMuteList.d.ts +17 -0
  29. package/dist/client/types/app/bsky/graph/unmute.d.ts +17 -0
  30. package/dist/client/types/app/bsky/graph/unsubscribeMuteList.d.ts +17 -0
  31. package/dist/client/types/app/bsky/notification/getCount.d.ts +17 -0
  32. package/dist/client/types/app/bsky/notification/list.d.ts +35 -0
  33. package/dist/client/types/app/bsky/notification/registerPush.d.ts +20 -0
  34. package/dist/client/types/app/bsky/system/actorScene.d.ts +1 -0
  35. package/dist/client/types/app/bsky/system/actorUser.d.ts +1 -0
  36. package/dist/client/types/app/bsky/system/declRef.d.ts +8 -0
  37. package/dist/client/types/app/bsky/system/declaration.d.ts +7 -0
  38. package/dist/client/types/app/bsky/unspecced/registerPushNotification.d.ts +16 -0
  39. package/dist/client/types/com/atproto/account/create.d.ts +41 -0
  40. package/dist/client/types/com/atproto/account/createInviteCode.d.ts +22 -0
  41. package/dist/client/types/com/atproto/account/delete.d.ts +25 -0
  42. package/dist/client/types/com/atproto/account/get.d.ts +12 -0
  43. package/dist/client/types/com/atproto/account/requestDelete.d.ts +13 -0
  44. package/dist/client/types/com/atproto/account/requestPasswordReset.d.ts +17 -0
  45. package/dist/client/types/com/atproto/account/resetPassword.d.ts +24 -0
  46. package/dist/client/types/com/atproto/admin/blob.d.ts +37 -0
  47. package/dist/client/types/com/atproto/admin/moderationAction.d.ts +60 -0
  48. package/dist/client/types/com/atproto/admin/moderationReport.d.ts +37 -0
  49. package/dist/client/types/com/atproto/admin/record.d.ts +43 -0
  50. package/dist/client/types/com/atproto/admin/repo.d.ts +45 -0
  51. package/dist/client/types/com/atproto/blob/upload.d.ts +19 -0
  52. package/dist/client/types/com/atproto/handle/resolve.d.ts +18 -0
  53. package/dist/client/types/com/atproto/handle/update.d.ts +17 -0
  54. package/dist/client/types/com/atproto/repo/batchWrite.d.ts +46 -0
  55. package/dist/client/types/com/atproto/repo/describe.d.ts +22 -0
  56. package/dist/client/types/com/atproto/repo/recordRef.d.ts +8 -0
  57. package/dist/client/types/com/atproto/repo/repoRef.d.ts +7 -0
  58. package/dist/client/types/com/atproto/report/create.d.ts +39 -0
  59. package/dist/client/types/com/atproto/report/reasonType.d.ts +3 -0
  60. package/dist/client/types/com/atproto/report/subject.d.ts +23 -0
  61. package/dist/client/types/com/atproto/server/getAccountsConfig.d.ts +27 -0
  62. package/dist/client/types/com/atproto/session/create.d.ts +29 -0
  63. package/dist/client/types/com/atproto/session/delete.d.ts +13 -0
  64. package/dist/client/types/com/atproto/session/get.d.ts +18 -0
  65. package/dist/client/types/com/atproto/session/refresh.d.ts +24 -0
  66. package/dist/client/types/com/atproto/sync/getRoot.d.ts +18 -0
  67. package/dist/client/types/com/atproto/sync/subscribeAllRepos.d.ts +9 -0
  68. package/dist/client/types/com/atproto/sync/updateRepo.d.ts +15 -0
  69. package/dist/helpers/bsky.d.ts +20 -0
  70. package/dist/index.js +226 -85
  71. package/dist/index.js.map +4 -4
  72. package/dist/mixins/bsky.d.ts +23 -0
  73. package/dist/rich-text/sanitize.d.ts +4 -0
  74. package/dist/session.d.ts +42 -0
  75. package/package.json +1 -1
  76. package/src/bsky-agent.ts +3 -0
  77. package/src/client/index.ts +26 -0
  78. package/src/client/lexicons.ts +93 -0
  79. package/src/client/types/app/bsky/feed/getActorLikes.ts +53 -0
  80. package/src/client/types/app/bsky/notification/registerPush.ts +35 -0
  81. package/src/client/types/com/atproto/sync/subscribeRepos.ts +1 -0
  82. package/tsconfig.build.tsbuildinfo +1 -1
@@ -0,0 +1,23 @@
1
+ import { AtpAgentType } from '../types';
2
+ export declare function addBsky<TBase extends AtpAgentType>(Base: TBase): {
3
+ new (...args: any[]): {
4
+ like(uri: string, cid: string): Promise<{
5
+ uri: string;
6
+ cid: string;
7
+ }>;
8
+ unlike(likeUri: string): Promise<void>;
9
+ repost(uri: string, cid: string): Promise<{
10
+ uri: string;
11
+ cid: string;
12
+ }>;
13
+ unrepost(repostUri: string): Promise<void>;
14
+ follow(subjectDid: string): Promise<{
15
+ uri: string;
16
+ cid: string;
17
+ }>;
18
+ unfollow(followUri: string): Promise<void>;
19
+ service: URL;
20
+ api: import("..").AtpServiceClient;
21
+ session?: import("../types").AtpSessionData | undefined;
22
+ };
23
+ } & TBase;
@@ -0,0 +1,4 @@
1
+ import { RichText } from './rich-text';
2
+ export declare function sanitizeRichText(richText: RichText, opts: {
3
+ cleanNewlines?: boolean;
4
+ }): RichText;
@@ -0,0 +1,42 @@
1
+ import { CallOptions, Client as XrpcClient, ServiceClient as XrpcServiceClient, QueryParams, XRPCResponse } from '@atproto/xrpc';
2
+ import TypedEmitter from 'typed-emitter';
3
+ import { Client, ServiceClient } from './client';
4
+ export declare class SessionClient extends Client {
5
+ service(serviceUri: string | URL): SessionServiceClient;
6
+ }
7
+ declare const defaultInst: SessionClient;
8
+ export default defaultInst;
9
+ export declare class SessionServiceClient extends ServiceClient {
10
+ xrpc: SessionXrpcServiceClient;
11
+ sessionManager: SessionManager;
12
+ constructor(baseClient: Client, xrpcService: SessionXrpcServiceClient);
13
+ }
14
+ export declare class SessionXrpcServiceClient extends XrpcServiceClient {
15
+ sessionManager: SessionManager;
16
+ refreshing?: Promise<XRPCResponse>;
17
+ constructor(baseClient: XrpcClient, serviceUri: string | URL);
18
+ call(methodNsid: string, params?: QueryParams, data?: unknown, opts?: CallOptions): Promise<XRPCResponse>;
19
+ refresh(opts?: CallOptions): Promise<XRPCResponse>;
20
+ private _refresh;
21
+ }
22
+ declare const SessionManager_base: new () => TypedEmitter<SessionEvents>;
23
+ export declare class SessionManager extends SessionManager_base {
24
+ session?: Session;
25
+ get(): Session | undefined;
26
+ set(session: Session): void;
27
+ unset(): void;
28
+ active(): boolean;
29
+ accessHeaders(): {
30
+ authorization: string;
31
+ } | undefined;
32
+ refreshHeaders(): {
33
+ authorization: string;
34
+ } | undefined;
35
+ }
36
+ export declare type Session = {
37
+ refreshJwt: string;
38
+ accessJwt: string;
39
+ };
40
+ declare type SessionEvents = {
41
+ session: (session?: Session) => void;
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "codegen": "yarn docgen && node ./scripts/generate-code.mjs && lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
package/src/bsky-agent.ts CHANGED
@@ -17,6 +17,9 @@ export class BskyAgent extends AtpAgent {
17
17
  getAuthorFeed: typeof this.api.app.bsky.feed.getAuthorFeed = (params, opts) =>
18
18
  this.api.app.bsky.feed.getAuthorFeed(params, opts)
19
19
 
20
+ getActorLikes: typeof this.api.app.bsky.feed.getActorLikes = (params, opts) =>
21
+ this.api.app.bsky.feed.getActorLikes(params, opts)
22
+
20
23
  getPostThread: typeof this.api.app.bsky.feed.getPostThread = (params, opts) =>
21
24
  this.api.app.bsky.feed.getPostThread(params, opts)
22
25
 
@@ -89,6 +89,7 @@ import * as AppBskyFeedDefs from './types/app/bsky/feed/defs'
89
89
  import * as AppBskyFeedDescribeFeedGenerator from './types/app/bsky/feed/describeFeedGenerator'
90
90
  import * as AppBskyFeedGenerator from './types/app/bsky/feed/generator'
91
91
  import * as AppBskyFeedGetActorFeeds from './types/app/bsky/feed/getActorFeeds'
92
+ import * as AppBskyFeedGetActorLikes from './types/app/bsky/feed/getActorLikes'
92
93
  import * as AppBskyFeedGetAuthorFeed from './types/app/bsky/feed/getAuthorFeed'
93
94
  import * as AppBskyFeedGetFeed from './types/app/bsky/feed/getFeed'
94
95
  import * as AppBskyFeedGetFeedGenerator from './types/app/bsky/feed/getFeedGenerator'
@@ -120,6 +121,7 @@ import * as AppBskyGraphUnmuteActor from './types/app/bsky/graph/unmuteActor'
120
121
  import * as AppBskyGraphUnmuteActorList from './types/app/bsky/graph/unmuteActorList'
121
122
  import * as AppBskyNotificationGetUnreadCount from './types/app/bsky/notification/getUnreadCount'
122
123
  import * as AppBskyNotificationListNotifications from './types/app/bsky/notification/listNotifications'
124
+ import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
123
125
  import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
124
126
  import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
125
127
  import * as AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
@@ -209,6 +211,7 @@ export * as AppBskyFeedDefs from './types/app/bsky/feed/defs'
209
211
  export * as AppBskyFeedDescribeFeedGenerator from './types/app/bsky/feed/describeFeedGenerator'
210
212
  export * as AppBskyFeedGenerator from './types/app/bsky/feed/generator'
211
213
  export * as AppBskyFeedGetActorFeeds from './types/app/bsky/feed/getActorFeeds'
214
+ export * as AppBskyFeedGetActorLikes from './types/app/bsky/feed/getActorLikes'
212
215
  export * as AppBskyFeedGetAuthorFeed from './types/app/bsky/feed/getAuthorFeed'
213
216
  export * as AppBskyFeedGetFeed from './types/app/bsky/feed/getFeed'
214
217
  export * as AppBskyFeedGetFeedGenerator from './types/app/bsky/feed/getFeedGenerator'
@@ -240,6 +243,7 @@ export * as AppBskyGraphUnmuteActor from './types/app/bsky/graph/unmuteActor'
240
243
  export * as AppBskyGraphUnmuteActorList from './types/app/bsky/graph/unmuteActorList'
241
244
  export * as AppBskyNotificationGetUnreadCount from './types/app/bsky/notification/getUnreadCount'
242
245
  export * as AppBskyNotificationListNotifications from './types/app/bsky/notification/listNotifications'
246
+ export * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
243
247
  export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
244
248
  export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
245
249
  export * as AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
@@ -1246,6 +1250,17 @@ export class FeedNS {
1246
1250
  })
1247
1251
  }
1248
1252
 
1253
+ getActorLikes(
1254
+ params?: AppBskyFeedGetActorLikes.QueryParams,
1255
+ opts?: AppBskyFeedGetActorLikes.CallOptions,
1256
+ ): Promise<AppBskyFeedGetActorLikes.Response> {
1257
+ return this._service.xrpc
1258
+ .call('app.bsky.feed.getActorLikes', params, undefined, opts)
1259
+ .catch((e) => {
1260
+ throw AppBskyFeedGetActorLikes.toKnownErr(e)
1261
+ })
1262
+ }
1263
+
1249
1264
  getAuthorFeed(
1250
1265
  params?: AppBskyFeedGetAuthorFeed.QueryParams,
1251
1266
  opts?: AppBskyFeedGetAuthorFeed.CallOptions,
@@ -2011,6 +2026,17 @@ export class NotificationNS {
2011
2026
  })
2012
2027
  }
2013
2028
 
2029
+ registerPush(
2030
+ data?: AppBskyNotificationRegisterPush.InputSchema,
2031
+ opts?: AppBskyNotificationRegisterPush.CallOptions,
2032
+ ): Promise<AppBskyNotificationRegisterPush.Response> {
2033
+ return this._service.xrpc
2034
+ .call('app.bsky.notification.registerPush', opts?.qp, data, opts)
2035
+ .catch((e) => {
2036
+ throw AppBskyNotificationRegisterPush.toKnownErr(e)
2037
+ })
2038
+ }
2039
+
2014
2040
  updateSeen(
2015
2041
  data?: AppBskyNotificationUpdateSeen.InputSchema,
2016
2042
  opts?: AppBskyNotificationUpdateSeen.CallOptions,
@@ -3575,6 +3575,8 @@ export const schemaDict = {
3575
3575
  },
3576
3576
  repoOp: {
3577
3577
  type: 'object',
3578
+ description:
3579
+ "A repo operation, ie a write of a single record. For creates and updates, cid is the record's CID as of this operation. For deletes, it's null.",
3578
3580
  required: ['action', 'path', 'cid'],
3579
3581
  nullable: ['cid'],
3580
3582
  properties: {
@@ -4816,6 +4818,62 @@ export const schemaDict = {
4816
4818
  },
4817
4819
  },
4818
4820
  },
4821
+ AppBskyFeedGetActorLikes: {
4822
+ lexicon: 1,
4823
+ id: 'app.bsky.feed.getActorLikes',
4824
+ defs: {
4825
+ main: {
4826
+ type: 'query',
4827
+ description: 'A view of the posts liked by an actor.',
4828
+ parameters: {
4829
+ type: 'params',
4830
+ required: ['actor'],
4831
+ properties: {
4832
+ actor: {
4833
+ type: 'string',
4834
+ format: 'at-identifier',
4835
+ },
4836
+ limit: {
4837
+ type: 'integer',
4838
+ minimum: 1,
4839
+ maximum: 100,
4840
+ default: 50,
4841
+ },
4842
+ cursor: {
4843
+ type: 'string',
4844
+ },
4845
+ },
4846
+ },
4847
+ output: {
4848
+ encoding: 'application/json',
4849
+ schema: {
4850
+ type: 'object',
4851
+ required: ['feed'],
4852
+ properties: {
4853
+ cursor: {
4854
+ type: 'string',
4855
+ },
4856
+ feed: {
4857
+ type: 'array',
4858
+ items: {
4859
+ type: 'ref',
4860
+ ref: 'lex:app.bsky.feed.defs#feedViewPost',
4861
+ },
4862
+ },
4863
+ },
4864
+ },
4865
+ },
4866
+ errors: [
4867
+ {
4868
+ name: 'BlockedActor',
4869
+ },
4870
+ {
4871
+ name: 'BlockedByActor',
4872
+ },
4873
+ ],
4874
+ },
4875
+ },
4876
+ },
4819
4877
  AppBskyFeedGetAuthorFeed: {
4820
4878
  lexicon: 1,
4821
4879
  id: 'app.bsky.feed.getAuthorFeed',
@@ -6311,6 +6369,39 @@ export const schemaDict = {
6311
6369
  },
6312
6370
  },
6313
6371
  },
6372
+ AppBskyNotificationRegisterPush: {
6373
+ lexicon: 1,
6374
+ id: 'app.bsky.notification.registerPush',
6375
+ defs: {
6376
+ main: {
6377
+ type: 'procedure',
6378
+ description: 'Register for push notifications with a service',
6379
+ input: {
6380
+ encoding: 'application/json',
6381
+ schema: {
6382
+ type: 'object',
6383
+ required: ['serviceDid', 'token', 'platform', 'appId'],
6384
+ properties: {
6385
+ serviceDid: {
6386
+ type: 'string',
6387
+ format: 'did',
6388
+ },
6389
+ token: {
6390
+ type: 'string',
6391
+ },
6392
+ platform: {
6393
+ type: 'string',
6394
+ knownValues: ['ios', 'android', 'web'],
6395
+ },
6396
+ appId: {
6397
+ type: 'string',
6398
+ },
6399
+ },
6400
+ },
6401
+ },
6402
+ },
6403
+ },
6404
+ },
6314
6405
  AppBskyNotificationUpdateSeen: {
6315
6406
  lexicon: 1,
6316
6407
  id: 'app.bsky.notification.updateSeen',
@@ -6657,6 +6748,7 @@ export const ids = {
6657
6748
  AppBskyFeedDescribeFeedGenerator: 'app.bsky.feed.describeFeedGenerator',
6658
6749
  AppBskyFeedGenerator: 'app.bsky.feed.generator',
6659
6750
  AppBskyFeedGetActorFeeds: 'app.bsky.feed.getActorFeeds',
6751
+ AppBskyFeedGetActorLikes: 'app.bsky.feed.getActorLikes',
6660
6752
  AppBskyFeedGetAuthorFeed: 'app.bsky.feed.getAuthorFeed',
6661
6753
  AppBskyFeedGetFeed: 'app.bsky.feed.getFeed',
6662
6754
  AppBskyFeedGetFeedGenerator: 'app.bsky.feed.getFeedGenerator',
@@ -6689,6 +6781,7 @@ export const ids = {
6689
6781
  AppBskyNotificationGetUnreadCount: 'app.bsky.notification.getUnreadCount',
6690
6782
  AppBskyNotificationListNotifications:
6691
6783
  'app.bsky.notification.listNotifications',
6784
+ AppBskyNotificationRegisterPush: 'app.bsky.notification.registerPush',
6692
6785
  AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen',
6693
6786
  AppBskyRichtextFacet: 'app.bsky.richtext.facet',
6694
6787
  AppBskyUnspeccedApplyLabels: 'app.bsky.unspecced.applyLabels',
@@ -0,0 +1,53 @@
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 AppBskyFeedDefs from './defs'
10
+
11
+ export interface QueryParams {
12
+ actor: string
13
+ limit?: number
14
+ cursor?: string
15
+ }
16
+
17
+ export type InputSchema = undefined
18
+
19
+ export interface OutputSchema {
20
+ cursor?: string
21
+ feed: AppBskyFeedDefs.FeedViewPost[]
22
+ [k: string]: unknown
23
+ }
24
+
25
+ export interface CallOptions {
26
+ headers?: Headers
27
+ }
28
+
29
+ export interface Response {
30
+ success: boolean
31
+ headers: Headers
32
+ data: OutputSchema
33
+ }
34
+
35
+ export class BlockedActorError extends XRPCError {
36
+ constructor(src: XRPCError) {
37
+ super(src.status, src.error, src.message, src.headers)
38
+ }
39
+ }
40
+
41
+ export class BlockedByActorError extends XRPCError {
42
+ constructor(src: XRPCError) {
43
+ super(src.status, src.error, src.message, src.headers)
44
+ }
45
+ }
46
+
47
+ export function toKnownErr(e: any) {
48
+ if (e instanceof XRPCError) {
49
+ if (e.error === 'BlockedActor') return new BlockedActorError(e)
50
+ if (e.error === 'BlockedByActor') return new BlockedByActorError(e)
51
+ }
52
+ return e
53
+ }
@@ -0,0 +1,35 @@
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
+ serviceDid: string
14
+ token: string
15
+ platform: 'ios' | 'android' | 'web' | (string & {})
16
+ appId: string
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export interface CallOptions {
21
+ headers?: Headers
22
+ qp?: QueryParams
23
+ encoding: 'application/json'
24
+ }
25
+
26
+ export interface Response {
27
+ success: boolean
28
+ headers: Headers
29
+ }
30
+
31
+ export function toKnownErr(e: any) {
32
+ if (e instanceof XRPCError) {
33
+ }
34
+ return e
35
+ }
@@ -111,6 +111,7 @@ export function validateInfo(v: unknown): ValidationResult {
111
111
  return lexicons.validate('com.atproto.sync.subscribeRepos#info', v)
112
112
  }
113
113
 
114
+ /** A repo operation, ie a write of a single record. For creates and updates, cid is the record's CID as of this operation. For deletes, it's null. */
114
115
  export interface RepoOp {
115
116
  action: 'create' | 'update' | 'delete' | (string & {})
116
117
  path: string