@atproto/bsky 0.0.13 → 0.0.15

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 +18 -0
  2. package/dist/api/app/bsky/feed/searchPosts.d.ts +3 -0
  3. package/dist/api/com/atproto/temp/fetchLabels.d.ts +3 -0
  4. package/dist/config.d.ts +2 -2
  5. package/dist/context.d.ts +1 -1
  6. package/dist/index.js +723 -443
  7. package/dist/index.js.map +3 -3
  8. package/dist/lexicon/index.d.ts +7 -0
  9. package/dist/lexicon/lexicons.d.ts +63 -0
  10. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +2 -0
  11. package/dist/lexicon/types/com/atproto/server/getSession.d.ts +1 -0
  12. package/dist/lexicon/types/com/atproto/temp/fetchLabels.d.ts +33 -0
  13. package/package.json +10 -11
  14. package/src/api/app/bsky/actor/getSuggestions.ts +45 -21
  15. package/src/api/app/bsky/feed/getPostThread.ts +16 -4
  16. package/src/api/app/bsky/feed/searchPosts.ts +127 -0
  17. package/src/api/com/atproto/admin/reverseModerationAction.ts +3 -3
  18. package/src/api/com/atproto/admin/takeModerationAction.ts +2 -2
  19. package/src/api/com/atproto/admin/util.ts +3 -1
  20. package/src/api/com/atproto/temp/fetchLabels.ts +30 -0
  21. package/src/api/index.ts +4 -0
  22. package/src/config.ts +6 -6
  23. package/src/context.ts +11 -9
  24. package/src/db/periodic-moderation-action-reversal.ts +1 -9
  25. package/src/lexicon/index.ts +22 -0
  26. package/src/lexicon/lexicons.ts +192 -129
  27. package/src/lexicon/types/app/bsky/actor/defs.ts +2 -2
  28. package/src/lexicon/types/app/bsky/actor/searchActors.ts +2 -2
  29. package/src/lexicon/types/app/bsky/actor/searchActorsTypeahead.ts +2 -2
  30. package/src/lexicon/types/app/bsky/feed/searchPosts.ts +3 -3
  31. package/src/lexicon/types/app/bsky/graph/defs.ts +2 -2
  32. package/src/lexicon/types/app/bsky/unspecced/searchActorsSkeleton.ts +4 -4
  33. package/src/lexicon/types/app/bsky/unspecced/searchPostsSkeleton.ts +3 -3
  34. package/src/lexicon/types/com/atproto/admin/defs.ts +5 -3
  35. package/src/lexicon/types/com/atproto/admin/disableAccountInvites.ts +1 -1
  36. package/src/lexicon/types/com/atproto/admin/enableAccountInvites.ts +1 -1
  37. package/src/lexicon/types/com/atproto/admin/getModerationReports.ts +3 -3
  38. package/src/lexicon/types/com/atproto/admin/takeModerationAction.ts +1 -1
  39. package/src/lexicon/types/com/atproto/label/defs.ts +9 -9
  40. package/src/lexicon/types/com/atproto/label/queryLabels.ts +2 -2
  41. package/src/lexicon/types/com/atproto/repo/applyWrites.ts +1 -1
  42. package/src/lexicon/types/com/atproto/repo/createRecord.ts +2 -2
  43. package/src/lexicon/types/com/atproto/repo/deleteRecord.ts +2 -2
  44. package/src/lexicon/types/com/atproto/repo/listRecords.ts +1 -1
  45. package/src/lexicon/types/com/atproto/repo/putRecord.ts +3 -3
  46. package/src/lexicon/types/com/atproto/server/getSession.ts +1 -0
  47. package/src/lexicon/types/com/atproto/sync/listBlobs.ts +1 -1
  48. package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +4 -4
  49. package/src/lexicon/types/com/atproto/temp/fetchLabels.ts +47 -0
  50. package/tests/admin/get-repo.test.ts +33 -0
  51. package/tests/views/suggestions.test.ts +15 -7
package/src/api/index.ts CHANGED
@@ -13,6 +13,7 @@ import getLikes from './app/bsky/feed/getLikes'
13
13
  import getListFeed from './app/bsky/feed/getListFeed'
14
14
  import getPostThread from './app/bsky/feed/getPostThread'
15
15
  import getPosts from './app/bsky/feed/getPosts'
16
+ import searchPosts from './app/bsky/feed/searchPosts'
16
17
  import getActorLikes from './app/bsky/feed/getActorLikes'
17
18
  import getProfile from './app/bsky/actor/getProfile'
18
19
  import getProfiles from './app/bsky/actor/getProfiles'
@@ -52,6 +53,7 @@ import getModerationReport from './com/atproto/admin/getModerationReport'
52
53
  import getModerationReports from './com/atproto/admin/getModerationReports'
53
54
  import resolveHandle from './com/atproto/identity/resolveHandle'
54
55
  import getRecord from './com/atproto/repo/getRecord'
56
+ import fetchLabels from './com/atproto/temp/fetchLabels'
55
57
 
56
58
  export * as health from './health'
57
59
 
@@ -74,6 +76,7 @@ export default function (server: Server, ctx: AppContext) {
74
76
  getListFeed(server, ctx)
75
77
  getPostThread(server, ctx)
76
78
  getPosts(server, ctx)
79
+ searchPosts(server, ctx)
77
80
  getActorLikes(server, ctx)
78
81
  getProfile(server, ctx)
79
82
  getProfiles(server, ctx)
@@ -114,5 +117,6 @@ export default function (server: Server, ctx: AppContext) {
114
117
  getModerationReports(server, ctx)
115
118
  resolveHandle(server, ctx)
116
119
  getRecord(server, ctx)
120
+ fetchLabels(server, ctx)
117
121
  return server
118
122
  }
package/src/config.ts CHANGED
@@ -23,7 +23,7 @@ export interface ServerConfigValues {
23
23
  adminPassword: string
24
24
  moderatorPassword?: string
25
25
  triagePassword?: string
26
- moderationActionReverseUrl?: string
26
+ moderationPushUrl?: string
27
27
  }
28
28
 
29
29
  export class ServerConfig {
@@ -78,8 +78,8 @@ export class ServerConfig {
78
78
  const moderatorPassword = process.env.MODERATOR_PASSWORD || undefined
79
79
  const triagePassword = process.env.TRIAGE_PASSWORD || undefined
80
80
  const labelerDid = process.env.LABELER_DID || 'did:example:labeler'
81
- const moderationActionReverseUrl =
82
- overrides?.moderationActionReverseUrl ||
81
+ const moderationPushUrl =
82
+ overrides?.moderationPushUrl ||
83
83
  process.env.MODERATION_PUSH_URL ||
84
84
  undefined
85
85
  return new ServerConfig({
@@ -104,7 +104,7 @@ export class ServerConfig {
104
104
  adminPassword,
105
105
  moderatorPassword,
106
106
  triagePassword,
107
- moderationActionReverseUrl,
107
+ moderationPushUrl,
108
108
  ...stripUndefineds(overrides ?? {}),
109
109
  })
110
110
  }
@@ -206,8 +206,8 @@ export class ServerConfig {
206
206
  return this.cfg.triagePassword
207
207
  }
208
208
 
209
- get moderationActionReverseUrl() {
210
- return this.cfg.moderationActionReverseUrl
209
+ get moderationPushUrl() {
210
+ return this.cfg.moderationPushUrl
211
211
  }
212
212
  }
213
213
 
package/src/context.ts CHANGED
@@ -15,6 +15,7 @@ import { LabelCache } from './label-cache'
15
15
  import { NotificationServer } from './notifications'
16
16
 
17
17
  export class AppContext {
18
+ public moderationPushAgent: AtpAgent | undefined
18
19
  constructor(
19
20
  private opts: {
20
21
  db: DatabaseCoordinator
@@ -30,7 +31,16 @@ export class AppContext {
30
31
  algos: MountedAlgos
31
32
  notifServer: NotificationServer
32
33
  },
33
- ) {}
34
+ ) {
35
+ if (opts.cfg.moderationPushUrl) {
36
+ const url = new URL(opts.cfg.moderationPushUrl)
37
+ this.moderationPushAgent = new AtpAgent({ service: url.origin })
38
+ this.moderationPushAgent.api.setHeader(
39
+ 'authorization',
40
+ auth.buildBasicAuth(url.username, url.password),
41
+ )
42
+ }
43
+ }
34
44
 
35
45
  get db(): DatabaseCoordinator {
36
46
  return this.opts.db
@@ -107,14 +117,6 @@ export class AppContext {
107
117
  })
108
118
  }
109
119
 
110
- async pdsAdminAgent(did: string): Promise<AtpAgent> {
111
- const data = await this.idResolver.did.resolveAtprotoData(did)
112
- const agent = new AtpAgent({ service: data.pds })
113
- const jwt = await this.serviceAuthJwt(did)
114
- agent.api.setHeader('authorization', `Bearer ${jwt}`)
115
- return agent
116
- }
117
-
118
120
  get backgroundQueue(): BackgroundQueue {
119
121
  return this.opts.backgroundQueue
120
122
  }
@@ -3,7 +3,6 @@ import { Leader } from './leader'
3
3
  import { dbLogger } from '../logger'
4
4
  import AppContext from '../context'
5
5
  import AtpAgent from '@atproto/api'
6
- import { buildBasicAuth } from '../auth'
7
6
  import { LabelService } from '../services/label'
8
7
  import { ModerationActionRow } from '../services/moderation'
9
8
 
@@ -18,14 +17,7 @@ export class PeriodicModerationActionReversal {
18
17
  pushAgent?: AtpAgent
19
18
 
20
19
  constructor(private appContext: AppContext) {
21
- if (appContext.cfg.moderationActionReverseUrl) {
22
- const url = new URL(appContext.cfg.moderationActionReverseUrl)
23
- this.pushAgent = new AtpAgent({ service: url.origin })
24
- this.pushAgent.api.setHeader(
25
- 'authorization',
26
- buildBasicAuth(url.username, url.password),
27
- )
28
- }
20
+ this.pushAgent = appContext.moderationPushAgent
29
21
  }
30
22
 
31
23
  // invert label creation & negations
@@ -75,6 +75,7 @@ import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos'
75
75
  import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate'
76
76
  import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
77
77
  import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
78
+ import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels'
78
79
  import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
79
80
  import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
80
81
  import * as AppBskyActorGetProfiles from './types/app/bsky/actor/getProfiles'
@@ -175,6 +176,7 @@ export class AtprotoNS {
175
176
  repo: RepoNS
176
177
  server: ServerNS
177
178
  sync: SyncNS
179
+ temp: TempNS
178
180
 
179
181
  constructor(server: Server) {
180
182
  this._server = server
@@ -185,6 +187,7 @@ export class AtprotoNS {
185
187
  this.repo = new RepoNS(server)
186
188
  this.server = new ServerNS(server)
187
189
  this.sync = new SyncNS(server)
190
+ this.temp = new TempNS(server)
188
191
  }
189
192
  }
190
193
 
@@ -970,6 +973,25 @@ export class SyncNS {
970
973
  }
971
974
  }
972
975
 
976
+ export class TempNS {
977
+ _server: Server
978
+
979
+ constructor(server: Server) {
980
+ this._server = server
981
+ }
982
+
983
+ fetchLabels<AV extends AuthVerifier>(
984
+ cfg: ConfigOf<
985
+ AV,
986
+ ComAtprotoTempFetchLabels.Handler<ExtractAuth<AV>>,
987
+ ComAtprotoTempFetchLabels.HandlerReqCtx<ExtractAuth<AV>>
988
+ >,
989
+ ) {
990
+ const nsid = 'com.atproto.temp.fetchLabels' // @ts-ignore
991
+ return this._server.xrpc.method(nsid, cfg)
992
+ }
993
+ }
994
+
973
995
  export class AppNS {
974
996
  _server: Server
975
997
  bsky: BskyNS