@atproto/bsky 0.0.56 → 0.0.58

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 (129) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/app/bsky/actor/getProfile.js +7 -3
  3. package/dist/api/app/bsky/actor/getProfile.js.map +1 -1
  4. package/dist/api/app/bsky/graph/getFollowers.js +3 -3
  5. package/dist/api/app/bsky/graph/getFollowers.js.map +1 -1
  6. package/dist/api/app/bsky/graph/getFollows.js +3 -3
  7. package/dist/api/app/bsky/graph/getFollows.js.map +1 -1
  8. package/dist/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.d.ts +4 -0
  9. package/dist/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.d.ts.map +1 -0
  10. package/dist/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.js +15 -0
  11. package/dist/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.js.map +1 -0
  12. package/dist/data-plane/server/db/migrations/index.d.ts +1 -0
  13. package/dist/data-plane/server/db/migrations/index.d.ts.map +1 -1
  14. package/dist/data-plane/server/db/migrations/index.js +2 -1
  15. package/dist/data-plane/server/db/migrations/index.js.map +1 -1
  16. package/dist/data-plane/server/db/tables/actor.d.ts +1 -0
  17. package/dist/data-plane/server/db/tables/actor.d.ts.map +1 -1
  18. package/dist/data-plane/server/db/tables/actor.js.map +1 -1
  19. package/dist/data-plane/server/indexing/index.d.ts +2 -1
  20. package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
  21. package/dist/data-plane/server/indexing/index.js +18 -1
  22. package/dist/data-plane/server/indexing/index.js.map +1 -1
  23. package/dist/data-plane/server/routes/profile.d.ts.map +1 -1
  24. package/dist/data-plane/server/routes/profile.js +9 -0
  25. package/dist/data-plane/server/routes/profile.js.map +1 -1
  26. package/dist/data-plane/server/subscription/index.d.ts +1 -1
  27. package/dist/data-plane/server/subscription/index.d.ts.map +1 -1
  28. package/dist/data-plane/server/subscription/index.js +14 -3
  29. package/dist/data-plane/server/subscription/index.js.map +1 -1
  30. package/dist/data-plane/server/subscription/util.d.ts +1 -1
  31. package/dist/data-plane/server/subscription/util.d.ts.map +1 -1
  32. package/dist/data-plane/server/subscription/util.js +3 -0
  33. package/dist/data-plane/server/subscription/util.js.map +1 -1
  34. package/dist/hydration/actor.d.ts +1 -0
  35. package/dist/hydration/actor.d.ts.map +1 -1
  36. package/dist/hydration/actor.js +4 -1
  37. package/dist/hydration/actor.js.map +1 -1
  38. package/dist/lexicon/index.d.ts +2 -0
  39. package/dist/lexicon/index.d.ts.map +1 -1
  40. package/dist/lexicon/index.js +4 -0
  41. package/dist/lexicon/index.js.map +1 -1
  42. package/dist/lexicon/lexicons.d.ts +137 -0
  43. package/dist/lexicon/lexicons.d.ts.map +1 -1
  44. package/dist/lexicon/lexicons.js +217 -4
  45. package/dist/lexicon/lexicons.js.map +1 -1
  46. package/dist/lexicon/types/chat/bsky/convo/defs.d.ts +1 -1
  47. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +1 -0
  48. package/dist/lexicon/types/com/atproto/admin/defs.d.ts.map +1 -1
  49. package/dist/lexicon/types/com/atproto/admin/defs.js.map +1 -1
  50. package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +1 -0
  51. package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts.map +1 -1
  52. package/dist/lexicon/types/com/atproto/server/createSession.d.ts +3 -0
  53. package/dist/lexicon/types/com/atproto/server/createSession.d.ts.map +1 -1
  54. package/dist/lexicon/types/com/atproto/server/getSession.d.ts +3 -0
  55. package/dist/lexicon/types/com/atproto/server/getSession.d.ts.map +1 -1
  56. package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +3 -0
  57. package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts.map +1 -1
  58. package/dist/lexicon/types/com/atproto/sync/getBlob.d.ts +1 -0
  59. package/dist/lexicon/types/com/atproto/sync/getBlob.d.ts.map +1 -1
  60. package/dist/lexicon/types/com/atproto/sync/getBlocks.d.ts +1 -0
  61. package/dist/lexicon/types/com/atproto/sync/getBlocks.d.ts.map +1 -1
  62. package/dist/lexicon/types/com/atproto/sync/getLatestCommit.d.ts +1 -1
  63. package/dist/lexicon/types/com/atproto/sync/getLatestCommit.d.ts.map +1 -1
  64. package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts +1 -0
  65. package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts.map +1 -1
  66. package/dist/lexicon/types/com/atproto/sync/getRepo.d.ts +1 -0
  67. package/dist/lexicon/types/com/atproto/sync/getRepo.d.ts.map +1 -1
  68. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.d.ts +42 -0
  69. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.d.ts.map +1 -0
  70. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.js +3 -0
  71. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.js.map +1 -0
  72. package/dist/lexicon/types/com/atproto/sync/listBlobs.d.ts +1 -0
  73. package/dist/lexicon/types/com/atproto/sync/listBlobs.d.ts.map +1 -1
  74. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +3 -0
  75. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts.map +1 -1
  76. package/dist/lexicon/types/com/atproto/sync/listRepos.js.map +1 -1
  77. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts +19 -4
  78. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
  79. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js +11 -1
  80. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js.map +1 -1
  81. package/dist/proto/bsky_connect.d.ts +10 -1
  82. package/dist/proto/bsky_connect.d.ts.map +1 -1
  83. package/dist/proto/bsky_connect.js +9 -0
  84. package/dist/proto/bsky_connect.js.map +1 -1
  85. package/dist/proto/bsky_pb.d.ts +42 -0
  86. package/dist/proto/bsky_pb.d.ts.map +1 -1
  87. package/dist/proto/bsky_pb.js +132 -1
  88. package/dist/proto/bsky_pb.js.map +1 -1
  89. package/dist/views/index.d.ts +2 -0
  90. package/dist/views/index.d.ts.map +1 -1
  91. package/dist/views/index.js +12 -0
  92. package/dist/views/index.js.map +1 -1
  93. package/package.json +4 -4
  94. package/proto/bsky.proto +11 -0
  95. package/src/api/app/bsky/actor/getProfile.ts +12 -8
  96. package/src/api/app/bsky/graph/getFollowers.ts +3 -4
  97. package/src/api/app/bsky/graph/getFollows.ts +3 -4
  98. package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +12 -0
  99. package/src/data-plane/server/db/migrations/index.ts +1 -0
  100. package/src/data-plane/server/db/tables/actor.ts +1 -0
  101. package/src/data-plane/server/indexing/index.ts +17 -1
  102. package/src/data-plane/server/routes/profile.ts +10 -0
  103. package/src/data-plane/server/subscription/index.ts +11 -3
  104. package/src/data-plane/server/subscription/util.ts +2 -0
  105. package/src/hydration/actor.ts +6 -1
  106. package/src/lexicon/index.ts +12 -0
  107. package/src/lexicon/lexicons.ts +228 -7
  108. package/src/lexicon/types/chat/bsky/convo/defs.ts +1 -1
  109. package/src/lexicon/types/com/atproto/admin/defs.ts +1 -0
  110. package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +1 -0
  111. package/src/lexicon/types/com/atproto/server/createSession.ts +3 -0
  112. package/src/lexicon/types/com/atproto/server/getSession.ts +3 -0
  113. package/src/lexicon/types/com/atproto/server/refreshSession.ts +3 -0
  114. package/src/lexicon/types/com/atproto/sync/getBlob.ts +6 -0
  115. package/src/lexicon/types/com/atproto/sync/getBlocks.ts +6 -0
  116. package/src/lexicon/types/com/atproto/sync/getLatestCommit.ts +1 -1
  117. package/src/lexicon/types/com/atproto/sync/getRecord.ts +6 -0
  118. package/src/lexicon/types/com/atproto/sync/getRepo.ts +1 -0
  119. package/src/lexicon/types/com/atproto/sync/getRepoStatus.ts +52 -0
  120. package/src/lexicon/types/com/atproto/sync/listBlobs.ts +1 -0
  121. package/src/lexicon/types/com/atproto/sync/listRepos.ts +3 -0
  122. package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +30 -3
  123. package/src/proto/bsky_connect.ts +11 -0
  124. package/src/proto/bsky_pb.ts +137 -0
  125. package/src/views/index.ts +13 -0
  126. package/tests/data-plane/db.test.ts +1 -2
  127. package/tests/data-plane/indexing.test.ts +3 -3
  128. package/tests/data-plane/subscription/repo.test.ts +1 -1
  129. package/tests/views/account-deactivation.test.ts +76 -0
@@ -3760,6 +3760,11 @@ export class ActorInfo extends Message<ActorInfo> {
3760
3760
  */
3761
3761
  allowIncomingChatsFrom = ''
3762
3762
 
3763
+ /**
3764
+ * @generated from field: string upstream_status = 9;
3765
+ */
3766
+ upstreamStatus = ''
3767
+
3763
3768
  constructor(data?: PartialMessage<ActorInfo>) {
3764
3769
  super()
3765
3770
  proto3.util.initPartial(data, this)
@@ -3786,6 +3791,12 @@ export class ActorInfo extends Message<ActorInfo> {
3786
3791
  kind: 'scalar',
3787
3792
  T: 9 /* ScalarType.STRING */,
3788
3793
  },
3794
+ {
3795
+ no: 9,
3796
+ name: 'upstream_status',
3797
+ kind: 'scalar',
3798
+ T: 9 /* ScalarType.STRING */,
3799
+ },
3789
3800
  ])
3790
3801
 
3791
3802
  static fromBinary(
@@ -10007,6 +10018,132 @@ export class PingResponse extends Message<PingResponse> {
10007
10018
  }
10008
10019
  }
10009
10020
 
10021
+ /**
10022
+ * @generated from message bsky.UpdateActorUpstreamStatusRequest
10023
+ */
10024
+ export class UpdateActorUpstreamStatusRequest extends Message<UpdateActorUpstreamStatusRequest> {
10025
+ /**
10026
+ * @generated from field: string actor_did = 1;
10027
+ */
10028
+ actorDid = ''
10029
+
10030
+ /**
10031
+ * @generated from field: bool active = 2;
10032
+ */
10033
+ active = false
10034
+
10035
+ /**
10036
+ * @generated from field: string upstream_status = 3;
10037
+ */
10038
+ upstreamStatus = ''
10039
+
10040
+ constructor(data?: PartialMessage<UpdateActorUpstreamStatusRequest>) {
10041
+ super()
10042
+ proto3.util.initPartial(data, this)
10043
+ }
10044
+
10045
+ static readonly runtime: typeof proto3 = proto3
10046
+ static readonly typeName = 'bsky.UpdateActorUpstreamStatusRequest'
10047
+ static readonly fields: FieldList = proto3.util.newFieldList(() => [
10048
+ { no: 1, name: 'actor_did', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
10049
+ { no: 2, name: 'active', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
10050
+ {
10051
+ no: 3,
10052
+ name: 'upstream_status',
10053
+ kind: 'scalar',
10054
+ T: 9 /* ScalarType.STRING */,
10055
+ },
10056
+ ])
10057
+
10058
+ static fromBinary(
10059
+ bytes: Uint8Array,
10060
+ options?: Partial<BinaryReadOptions>,
10061
+ ): UpdateActorUpstreamStatusRequest {
10062
+ return new UpdateActorUpstreamStatusRequest().fromBinary(bytes, options)
10063
+ }
10064
+
10065
+ static fromJson(
10066
+ jsonValue: JsonValue,
10067
+ options?: Partial<JsonReadOptions>,
10068
+ ): UpdateActorUpstreamStatusRequest {
10069
+ return new UpdateActorUpstreamStatusRequest().fromJson(jsonValue, options)
10070
+ }
10071
+
10072
+ static fromJsonString(
10073
+ jsonString: string,
10074
+ options?: Partial<JsonReadOptions>,
10075
+ ): UpdateActorUpstreamStatusRequest {
10076
+ return new UpdateActorUpstreamStatusRequest().fromJsonString(
10077
+ jsonString,
10078
+ options,
10079
+ )
10080
+ }
10081
+
10082
+ static equals(
10083
+ a:
10084
+ | UpdateActorUpstreamStatusRequest
10085
+ | PlainMessage<UpdateActorUpstreamStatusRequest>
10086
+ | undefined,
10087
+ b:
10088
+ | UpdateActorUpstreamStatusRequest
10089
+ | PlainMessage<UpdateActorUpstreamStatusRequest>
10090
+ | undefined,
10091
+ ): boolean {
10092
+ return proto3.util.equals(UpdateActorUpstreamStatusRequest, a, b)
10093
+ }
10094
+ }
10095
+
10096
+ /**
10097
+ * @generated from message bsky.UpdateActorUpstreamStatusResponse
10098
+ */
10099
+ export class UpdateActorUpstreamStatusResponse extends Message<UpdateActorUpstreamStatusResponse> {
10100
+ constructor(data?: PartialMessage<UpdateActorUpstreamStatusResponse>) {
10101
+ super()
10102
+ proto3.util.initPartial(data, this)
10103
+ }
10104
+
10105
+ static readonly runtime: typeof proto3 = proto3
10106
+ static readonly typeName = 'bsky.UpdateActorUpstreamStatusResponse'
10107
+ static readonly fields: FieldList = proto3.util.newFieldList(() => [])
10108
+
10109
+ static fromBinary(
10110
+ bytes: Uint8Array,
10111
+ options?: Partial<BinaryReadOptions>,
10112
+ ): UpdateActorUpstreamStatusResponse {
10113
+ return new UpdateActorUpstreamStatusResponse().fromBinary(bytes, options)
10114
+ }
10115
+
10116
+ static fromJson(
10117
+ jsonValue: JsonValue,
10118
+ options?: Partial<JsonReadOptions>,
10119
+ ): UpdateActorUpstreamStatusResponse {
10120
+ return new UpdateActorUpstreamStatusResponse().fromJson(jsonValue, options)
10121
+ }
10122
+
10123
+ static fromJsonString(
10124
+ jsonString: string,
10125
+ options?: Partial<JsonReadOptions>,
10126
+ ): UpdateActorUpstreamStatusResponse {
10127
+ return new UpdateActorUpstreamStatusResponse().fromJsonString(
10128
+ jsonString,
10129
+ options,
10130
+ )
10131
+ }
10132
+
10133
+ static equals(
10134
+ a:
10135
+ | UpdateActorUpstreamStatusResponse
10136
+ | PlainMessage<UpdateActorUpstreamStatusResponse>
10137
+ | undefined,
10138
+ b:
10139
+ | UpdateActorUpstreamStatusResponse
10140
+ | PlainMessage<UpdateActorUpstreamStatusResponse>
10141
+ | undefined,
10142
+ ): boolean {
10143
+ return proto3.util.equals(UpdateActorUpstreamStatusResponse, a, b)
10144
+ }
10145
+ }
10146
+
10010
10147
  /**
10011
10148
  * @generated from message bsky.TakedownActorRequest
10012
10149
  */
@@ -63,8 +63,21 @@ export class Views {
63
63
  // Actor
64
64
  // ------------
65
65
 
66
+ actorIsNoHosted(did: string, state: HydrationState): boolean {
67
+ return (
68
+ this.actorIsDeactivated(did, state) || this.actorIsTakendown(did, state)
69
+ )
70
+ }
71
+
72
+ actorIsDeactivated(did: string, state: HydrationState): boolean {
73
+ if (state.actors?.get(did)?.upstreamStatus === 'deactivated') return true
74
+ return false
75
+ }
76
+
66
77
  actorIsTakendown(did: string, state: HydrationState): boolean {
67
78
  if (state.actors?.get(did)?.takedownRef) return true
79
+ if (state.actors?.get(did)?.upstreamStatus === 'takendown') return true
80
+ if (state.actors?.get(did)?.upstreamStatus === 'suspended') return true
68
81
  if (state.labels?.get(did)?.isTakendown) return true
69
82
  return false
70
83
  }
@@ -64,7 +64,7 @@ describe('db', () => {
64
64
 
65
65
  const row = await db.db
66
66
  .selectFrom('actor')
67
- .selectAll()
67
+ .select(['did', 'handle', 'indexedAt'])
68
68
  .where('did', '=', 'x')
69
69
  .executeTakeFirst()
70
70
 
@@ -72,7 +72,6 @@ describe('db', () => {
72
72
  did: 'x',
73
73
  handle: 'x',
74
74
  indexedAt: 'bad-date',
75
- takedownRef: null,
76
75
  })
77
76
  })
78
77
 
@@ -614,14 +614,14 @@ describe('indexing', () => {
614
614
  })
615
615
  })
616
616
 
617
- describe('tombstoneActor', () => {
617
+ describe('deleteActor', () => {
618
618
  it('does not unindex actor when they are still being hosted by their pds', async () => {
619
619
  const { data: profileBefore } = await agent.api.app.bsky.actor.getProfile(
620
620
  { actor: sc.dids.alice },
621
621
  { headers: await network.serviceHeaders(sc.dids.bob) },
622
622
  )
623
623
  // Attempt indexing tombstone
624
- await network.bsky.sub.indexingSvc.tombstoneActor(sc.dids.alice)
624
+ await network.bsky.sub.indexingSvc.deleteActor(sc.dids.alice)
625
625
  const { data: profileAfter } = await agent.api.app.bsky.actor.getProfile(
626
626
  { actor: sc.dids.alice },
627
627
  { headers: await network.serviceHeaders(sc.dids.bob) },
@@ -648,7 +648,7 @@ describe('indexing', () => {
648
648
  })
649
649
  await network.pds.ctx.backgroundQueue.processAll()
650
650
  // Index tombstone
651
- await network.bsky.sub.indexingSvc.tombstoneActor(alice)
651
+ await network.bsky.sub.indexingSvc.deleteActor(alice)
652
652
  const getProfileAfter = agent.api.app.bsky.actor.getProfile(
653
653
  { actor: alice },
654
654
  { headers: await network.serviceHeaders(sc.dids.bob) },
@@ -86,7 +86,7 @@ describe('sync', () => {
86
86
  const evt = cborDecode(seqEvt.event) as sequencer.CommitEvt
87
87
  evt.blocks = new Uint8Array() // bad blocks
88
88
  seqEvt.event = cborEncode(evt)
89
- await network.pds.ctx.sequencer.sequenceEvt(seqEvt)
89
+ return await network.pds.ctx.sequencer.sequenceEvt(seqEvt)
90
90
  }
91
91
  // create account and index the initial commit event
92
92
  await sc.createAccount('jack', {
@@ -0,0 +1,76 @@
1
+ import AtpAgent from '@atproto/api'
2
+ import { TestNetwork, SeedClient, basicSeed } from '@atproto/dev-env'
3
+
4
+ describe('bsky account deactivation', () => {
5
+ let network: TestNetwork
6
+ let agent: AtpAgent
7
+ let sc: SeedClient
8
+
9
+ let alice: string
10
+
11
+ beforeAll(async () => {
12
+ network = await TestNetwork.create({
13
+ dbPostgresSchema: 'bsky_views_account_deactivation',
14
+ })
15
+ agent = network.bsky.getClient()
16
+ sc = network.getSeedClient()
17
+ await basicSeed(sc)
18
+ alice = sc.dids.alice
19
+ const pdsAgent = network.pds.getClient()
20
+ await pdsAgent.com.atproto.server.deactivateAccount(
21
+ {},
22
+ { encoding: 'application/json', headers: sc.getHeaders(alice) },
23
+ )
24
+ await network.processAll()
25
+ })
26
+
27
+ afterAll(async () => {
28
+ await network.close()
29
+ })
30
+
31
+ it('does not return deactivated profiles', async () => {
32
+ const attempt = agent.api.app.bsky.actor.getProfile({
33
+ actor: alice,
34
+ })
35
+ await expect(attempt).rejects.toThrow('Account is deactivated')
36
+ const res = await agent.api.app.bsky.actor.getProfiles({
37
+ actors: [sc.dids.alice, sc.dids.bob, sc.dids.carol],
38
+ })
39
+ expect(res.data.profiles.length).toBe(2)
40
+ expect(res.data.profiles.some((p) => p.did === alice)).toBe(false)
41
+ })
42
+
43
+ it('does not return deactivated accounts in follows', async () => {
44
+ const follows = await agent.api.app.bsky.graph.getFollows({
45
+ actor: sc.dids.bob,
46
+ })
47
+ expect(follows.data.follows.some((f) => f.did === alice)).toBe(false)
48
+ const followers = await agent.api.app.bsky.graph.getFollowers({
49
+ actor: sc.dids.bob,
50
+ })
51
+ expect(followers.data.followers.some((f) => f.did === alice)).toBe(false)
52
+ })
53
+
54
+ it('does not return posts from deactivated accounts', async () => {
55
+ const uris = [
56
+ sc.posts[sc.dids.alice][0].ref.uriStr,
57
+ sc.posts[sc.dids.alice][1].ref.uriStr,
58
+ sc.posts[sc.dids.bob][0].ref.uriStr,
59
+ sc.posts[sc.dids.carol][0].ref.uriStr,
60
+ sc.posts[sc.dids.dan][1].ref.uriStr,
61
+ sc.replies[sc.dids.alice][0].ref.uriStr,
62
+ ]
63
+ const res = await agent.api.app.bsky.feed.getPosts({ uris })
64
+
65
+ expect(res.data.posts.length).toBe(3)
66
+ expect(res.data.posts.some((p) => p.author.did === alice)).toBe(false)
67
+ })
68
+
69
+ it('does not return posts from deactivated in timelines', async () => {
70
+ const res = await agent.api.app.bsky.feed.getTimeline(
71
+ {},
72
+ { headers: await network.serviceHeaders(sc.dids.bob) },
73
+ )
74
+ expect(res.data.feed.some((p) => p.post.author.did === alice)).toBe(false)
75
+ })
76
+ })