@atproto/bsky 0.0.64 → 0.0.66
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/CHANGELOG.md +19 -0
- package/dist/api/app/bsky/actor/getSuggestions.js +1 -1
- package/dist/api/app/bsky/actor/getSuggestions.js.map +1 -1
- package/dist/api/app/bsky/actor/searchActors.js +1 -1
- package/dist/api/app/bsky/actor/searchActors.js.map +1 -1
- package/dist/api/app/bsky/feed/getPostThread.js +1 -10
- package/dist/api/app/bsky/feed/getPostThread.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPosts.js +1 -1
- package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
- package/dist/api/app/bsky/graph/getActorStarterPacks.d.ts +4 -0
- package/dist/api/app/bsky/graph/getActorStarterPacks.d.ts.map +1 -0
- package/dist/api/app/bsky/graph/getActorStarterPacks.js +58 -0
- package/dist/api/app/bsky/graph/getActorStarterPacks.js.map +1 -0
- package/dist/api/app/bsky/graph/getStarterPack.d.ts +4 -0
- package/dist/api/app/bsky/graph/getStarterPack.d.ts.map +1 -0
- package/dist/api/app/bsky/graph/getStarterPack.js +45 -0
- package/dist/api/app/bsky/graph/getStarterPack.js.map +1 -0
- package/dist/api/app/bsky/graph/getStarterPacks.d.ts +4 -0
- package/dist/api/app/bsky/graph/getStarterPacks.d.ts.map +1 -0
- package/dist/api/app/bsky/graph/getStarterPacks.js +40 -0
- package/dist/api/app/bsky/graph/getStarterPacks.js.map +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +6 -0
- package/dist/api/index.js.map +1 -1
- package/dist/data-plane/server/db/database-schema.d.ts +2 -1
- package/dist/data-plane/server/db/database-schema.d.ts.map +1 -1
- package/dist/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.d.ts +4 -0
- package/dist/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.d.ts.map +1 -0
- package/dist/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.js +47 -0
- package/dist/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.js.map +1 -0
- package/dist/data-plane/server/db/migrations/index.d.ts +1 -0
- package/dist/data-plane/server/db/migrations/index.d.ts.map +1 -1
- package/dist/data-plane/server/db/migrations/index.js +2 -1
- package/dist/data-plane/server/db/migrations/index.js.map +1 -1
- package/dist/data-plane/server/db/tables/profile.d.ts +2 -0
- package/dist/data-plane/server/db/tables/profile.d.ts.map +1 -1
- package/dist/data-plane/server/db/tables/starter-pack.d.ts +14 -0
- package/dist/data-plane/server/db/tables/starter-pack.d.ts.map +1 -0
- package/dist/data-plane/server/db/tables/starter-pack.js +5 -0
- package/dist/data-plane/server/db/tables/starter-pack.js.map +1 -0
- package/dist/data-plane/server/indexing/index.d.ts +2 -0
- package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/index.js +2 -0
- package/dist/data-plane/server/indexing/index.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/profile.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/profile.js +18 -2
- package/dist/data-plane/server/indexing/plugins/profile.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts +11 -0
- package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts.map +1 -0
- package/dist/data-plane/server/indexing/plugins/starter-pack.js +78 -0
- package/dist/data-plane/server/indexing/plugins/starter-pack.js.map +1 -0
- package/dist/data-plane/server/routes/index.d.ts.map +1 -1
- package/dist/data-plane/server/routes/index.js +2 -0
- package/dist/data-plane/server/routes/index.js.map +1 -1
- package/dist/data-plane/server/routes/interactions.d.ts.map +1 -1
- package/dist/data-plane/server/routes/interactions.js +57 -1
- package/dist/data-plane/server/routes/interactions.js.map +1 -1
- package/dist/data-plane/server/routes/profile.d.ts.map +1 -1
- package/dist/data-plane/server/routes/profile.js +1 -0
- package/dist/data-plane/server/routes/profile.js.map +1 -1
- package/dist/data-plane/server/routes/records.d.ts.map +1 -1
- package/dist/data-plane/server/routes/records.js +1 -0
- package/dist/data-plane/server/routes/records.js.map +1 -1
- package/dist/data-plane/server/routes/starter-packs.d.ts +6 -0
- package/dist/data-plane/server/routes/starter-packs.d.ts.map +1 -0
- package/dist/data-plane/server/routes/starter-packs.js +25 -0
- package/dist/data-plane/server/routes/starter-packs.js.map +1 -0
- package/dist/data-plane/server/util.d.ts +6 -6
- package/dist/hydration/actor.d.ts +2 -0
- package/dist/hydration/actor.d.ts.map +1 -1
- package/dist/hydration/actor.js +2 -0
- package/dist/hydration/actor.js.map +1 -1
- package/dist/hydration/feed.d.ts +1 -5
- package/dist/hydration/feed.d.ts.map +1 -1
- package/dist/hydration/feed.js +0 -1
- package/dist/hydration/feed.js.map +1 -1
- package/dist/hydration/graph.d.ts +17 -1
- package/dist/hydration/graph.d.ts.map +1 -1
- package/dist/hydration/graph.js +30 -1
- package/dist/hydration/graph.js.map +1 -1
- package/dist/hydration/hydrator.d.ts +9 -3
- package/dist/hydration/hydrator.d.ts.map +1 -1
- package/dist/hydration/hydrator.js +114 -5
- package/dist/hydration/hydrator.js.map +1 -1
- package/dist/hydration/util.d.ts +4 -0
- package/dist/hydration/util.d.ts.map +1 -1
- package/dist/hydration/util.js.map +1 -1
- package/dist/lexicon/index.d.ts +7 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +13 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +362 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +367 -2
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts +22 -1
- package/dist/lexicon/types/app/bsky/actor/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/defs.js +21 -1
- package/dist/lexicon/types/app/bsky/actor/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts +3 -0
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/profile.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts +36 -1
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/defs.js +23 -1
- package/dist/lexicon/types/app/bsky/graph/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/getActorStarterPacks.d.ts +39 -0
- package/dist/lexicon/types/app/bsky/graph/getActorStarterPacks.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/getActorStarterPacks.js +3 -0
- package/dist/lexicon/types/app/bsky/graph/getActorStarterPacks.js.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPack.d.ts +37 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPack.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPack.js +3 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPack.js.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPacks.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPacks.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPacks.js +3 -0
- package/dist/lexicon/types/app/bsky/graph/getStarterPacks.js.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/starterpack.d.ts +25 -0
- package/dist/lexicon/types/app/bsky/graph/starterpack.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/graph/starterpack.js +27 -0
- package/dist/lexicon/types/app/bsky/graph/starterpack.js.map +1 -0
- package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts +2 -2
- package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/listNotifications.js.map +1 -1
- package/dist/proto/bsky_connect.d.ts +39 -1
- package/dist/proto/bsky_connect.d.ts.map +1 -1
- package/dist/proto/bsky_connect.js +38 -0
- package/dist/proto/bsky_connect.js.map +1 -1
- package/dist/proto/bsky_pb.d.ts +160 -0
- package/dist/proto/bsky_pb.d.ts.map +1 -1
- package/dist/proto/bsky_pb.js +508 -4
- package/dist/proto/bsky_pb.js.map +1 -1
- package/dist/views/index.d.ts +4 -1
- package/dist/views/index.d.ts.map +1 -1
- package/dist/views/index.js +89 -0
- package/dist/views/index.js.map +1 -1
- package/package.json +5 -5
- package/proto/bsky.proto +47 -0
- package/src/api/app/bsky/actor/getSuggestions.ts +1 -1
- package/src/api/app/bsky/actor/searchActors.ts +1 -1
- package/src/api/app/bsky/feed/getPostThread.ts +1 -9
- package/src/api/app/bsky/feed/searchPosts.ts +1 -1
- package/src/api/app/bsky/graph/getActorStarterPacks.ts +99 -0
- package/src/api/app/bsky/graph/getStarterPack.ts +80 -0
- package/src/api/app/bsky/graph/getStarterPacks.ts +81 -0
- package/src/api/index.ts +6 -0
- package/src/data-plane/server/db/database-schema.ts +2 -0
- package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +45 -0
- package/src/data-plane/server/db/migrations/index.ts +1 -0
- package/src/data-plane/server/db/tables/profile.ts +2 -0
- package/src/data-plane/server/db/tables/starter-pack.ts +16 -0
- package/src/data-plane/server/indexing/index.ts +3 -0
- package/src/data-plane/server/indexing/plugins/profile.ts +16 -2
- package/src/data-plane/server/indexing/plugins/starter-pack.ts +76 -0
- package/src/data-plane/server/routes/index.ts +2 -0
- package/src/data-plane/server/routes/interactions.ts +56 -2
- package/src/data-plane/server/routes/profile.ts +1 -0
- package/src/data-plane/server/routes/records.ts +1 -0
- package/src/data-plane/server/routes/starter-packs.ts +32 -0
- package/src/hydration/actor.ts +5 -0
- package/src/hydration/feed.ts +1 -2
- package/src/hydration/graph.ts +55 -2
- package/src/hydration/hydrator.ts +143 -6
- package/src/hydration/util.ts +2 -0
- package/src/lexicon/index.ts +37 -0
- package/src/lexicon/lexicons.ts +372 -2
- package/src/lexicon/types/app/bsky/actor/defs.ts +44 -0
- package/src/lexicon/types/app/bsky/actor/profile.ts +3 -0
- package/src/lexicon/types/app/bsky/graph/defs.ts +58 -0
- package/src/lexicon/types/app/bsky/graph/getActorStarterPacks.ts +49 -0
- package/src/lexicon/types/app/bsky/graph/getStarterPack.ts +47 -0
- package/src/lexicon/types/app/bsky/graph/getStarterPacks.ts +46 -0
- package/src/lexicon/types/app/bsky/graph/starterpack.ts +50 -0
- package/src/lexicon/types/app/bsky/notification/listNotifications.ts +2 -1
- package/src/proto/bsky_connect.ts +46 -0
- package/src/proto/bsky_pb.ts +512 -0
- package/src/views/index.ts +98 -1
- package/tests/__snapshots__/feed-generation.test.ts.snap +28 -0
- package/tests/data-plane/__snapshots__/indexing.test.ts.snap +9 -0
- package/tests/views/__snapshots__/author-feed.test.ts.snap +29 -0
- package/tests/views/__snapshots__/block-lists.test.ts.snap +16 -0
- package/tests/views/__snapshots__/blocks.test.ts.snap +4 -0
- package/tests/views/__snapshots__/follows.test.ts.snap +34 -0
- package/tests/views/__snapshots__/labeler-service.test.ts.snap +4 -0
- package/tests/views/__snapshots__/likes.test.ts.snap +1 -0
- package/tests/views/__snapshots__/list-feed.test.ts.snap +12 -0
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +20 -0
- package/tests/views/__snapshots__/mutes.test.ts.snap +8 -0
- package/tests/views/__snapshots__/notifications.test.ts.snap +10 -0
- package/tests/views/__snapshots__/posts.test.ts.snap +6 -0
- package/tests/views/__snapshots__/profile.test.ts.snap +18 -0
- package/tests/views/__snapshots__/reposts.test.ts.snap +1 -0
- package/tests/views/__snapshots__/starter-packs.test.ts.snap +482 -0
- package/tests/views/__snapshots__/thread.test.ts.snap +22 -0
- package/tests/views/__snapshots__/threadgating.test.ts.snap +2 -0
- package/tests/views/__snapshots__/timeline.test.ts.snap +81 -0
- package/tests/views/starter-packs.test.ts +121 -0
package/src/hydration/graph.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Record as FollowRecord } from '../lexicon/types/app/bsky/graph/follow'
|
|
2
2
|
import { Record as BlockRecord } from '../lexicon/types/app/bsky/graph/block'
|
|
3
|
+
import { Record as StarterPackRecord } from '../lexicon/types/app/bsky/graph/starterpack'
|
|
3
4
|
import { Record as ListRecord } from '../lexicon/types/app/bsky/graph/list'
|
|
4
5
|
import { Record as ListItemRecord } from '../lexicon/types/app/bsky/graph/listitem'
|
|
5
6
|
import { DataPlaneClient } from '../data-plane/client'
|
|
6
|
-
import { HydrationMap, RecordInfo, parseRecord } from './util'
|
|
7
|
+
import { HydrationMap, ItemRef, RecordInfo, parseRecord } from './util'
|
|
7
8
|
import { FollowInfo } from '../proto/bsky_pb'
|
|
8
9
|
|
|
9
10
|
export type List = RecordInfo<ListRecord>
|
|
@@ -25,6 +26,23 @@ export type Follows = HydrationMap<Follow>
|
|
|
25
26
|
|
|
26
27
|
export type Block = RecordInfo<BlockRecord>
|
|
27
28
|
|
|
29
|
+
export type StarterPack = RecordInfo<StarterPackRecord>
|
|
30
|
+
export type StarterPacks = HydrationMap<StarterPack>
|
|
31
|
+
|
|
32
|
+
export type StarterPackAgg = {
|
|
33
|
+
joinedWeek: number
|
|
34
|
+
joinedAllTime: number
|
|
35
|
+
listItemSampleUris?: string[] // gets set during starter pack hydration (not for basic view)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type StarterPackAggs = HydrationMap<StarterPackAgg>
|
|
39
|
+
|
|
40
|
+
export type ListAgg = {
|
|
41
|
+
listItems: number
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ListAggs = HydrationMap<ListAgg>
|
|
45
|
+
|
|
28
46
|
export type RelationshipPair = [didA: string, didB: string]
|
|
29
47
|
|
|
30
48
|
const dedupePairs = (pairs: RelationshipPair[]): RelationshipPair[] => {
|
|
@@ -84,7 +102,6 @@ export class GraphHydrator {
|
|
|
84
102
|
}, new HydrationMap<List>())
|
|
85
103
|
}
|
|
86
104
|
|
|
87
|
-
// @TODO may not be supported yet by data plane
|
|
88
105
|
async getListItems(
|
|
89
106
|
uris: string[],
|
|
90
107
|
includeTakedowns = false,
|
|
@@ -195,4 +212,40 @@ export class GraphHydrator {
|
|
|
195
212
|
})
|
|
196
213
|
return { followers: res.followers, cursor: res.cursor }
|
|
197
214
|
}
|
|
215
|
+
|
|
216
|
+
async getStarterPacks(
|
|
217
|
+
uris: string[],
|
|
218
|
+
includeTakedowns = false,
|
|
219
|
+
): Promise<StarterPacks> {
|
|
220
|
+
if (!uris.length) return new HydrationMap<StarterPack>()
|
|
221
|
+
const res = await this.dataplane.getStarterPackRecords({ uris })
|
|
222
|
+
return uris.reduce((acc, uri, i) => {
|
|
223
|
+
const record = parseRecord<StarterPackRecord>(
|
|
224
|
+
res.records[i],
|
|
225
|
+
includeTakedowns,
|
|
226
|
+
)
|
|
227
|
+
return acc.set(uri, record ?? null)
|
|
228
|
+
}, new HydrationMap<StarterPack>())
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async getStarterPackAggregates(refs: ItemRef[]) {
|
|
232
|
+
if (!refs.length) return new HydrationMap<StarterPackAgg>()
|
|
233
|
+
const counts = await this.dataplane.getStarterPackCounts({ refs })
|
|
234
|
+
return refs.reduce((acc, { uri }, i) => {
|
|
235
|
+
return acc.set(uri, {
|
|
236
|
+
joinedWeek: counts.joinedWeek[i] ?? 0,
|
|
237
|
+
joinedAllTime: counts.joinedAllTime[i] ?? 0,
|
|
238
|
+
})
|
|
239
|
+
}, new HydrationMap<StarterPackAgg>())
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async getListAggregates(refs: ItemRef[]) {
|
|
243
|
+
if (!refs.length) return new HydrationMap<ListAgg>()
|
|
244
|
+
const counts = await this.dataplane.getListCounts({ refs })
|
|
245
|
+
return refs.reduce((acc, { uri }, i) => {
|
|
246
|
+
return acc.set(uri, {
|
|
247
|
+
listItems: counts.listItems[i] ?? 0,
|
|
248
|
+
})
|
|
249
|
+
}, new HydrationMap<ListAgg>())
|
|
250
|
+
}
|
|
198
251
|
}
|
|
@@ -19,10 +19,13 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
Follows,
|
|
21
21
|
GraphHydrator,
|
|
22
|
+
ListAggs,
|
|
22
23
|
ListItems,
|
|
23
24
|
ListViewerStates,
|
|
24
25
|
Lists,
|
|
25
26
|
RelationshipPair,
|
|
27
|
+
StarterPackAggs,
|
|
28
|
+
StarterPacks,
|
|
26
29
|
} from './graph'
|
|
27
30
|
import {
|
|
28
31
|
LabelHydrator,
|
|
@@ -35,6 +38,7 @@ import {
|
|
|
35
38
|
HydrationMap,
|
|
36
39
|
Merges,
|
|
37
40
|
RecordInfo,
|
|
41
|
+
ItemRef,
|
|
38
42
|
didFromUri,
|
|
39
43
|
urisByCollection,
|
|
40
44
|
} from './util'
|
|
@@ -51,7 +55,6 @@ import {
|
|
|
51
55
|
PostViewerStates,
|
|
52
56
|
Threadgates,
|
|
53
57
|
FeedItem,
|
|
54
|
-
ItemRef,
|
|
55
58
|
} from './feed'
|
|
56
59
|
import { ParsedLabelers } from '../util'
|
|
57
60
|
|
|
@@ -85,6 +88,7 @@ export type HydrationState = {
|
|
|
85
88
|
followBlocks?: FollowBlocks
|
|
86
89
|
threadgates?: Threadgates
|
|
87
90
|
lists?: Lists
|
|
91
|
+
listAggs?: ListAggs
|
|
88
92
|
listViewers?: ListViewerStates
|
|
89
93
|
listItems?: ListItems
|
|
90
94
|
likes?: Likes
|
|
@@ -92,6 +96,8 @@ export type HydrationState = {
|
|
|
92
96
|
feedgens?: FeedGens
|
|
93
97
|
feedgenViewers?: FeedGenViewerStates
|
|
94
98
|
feedgenAggs?: FeedGenAggs
|
|
99
|
+
starterPacks?: StarterPacks
|
|
100
|
+
starterPackAggs?: StarterPackAggs
|
|
95
101
|
labelers?: Labelers
|
|
96
102
|
labelerViewers?: LabelerViewerStates
|
|
97
103
|
labelerAggs?: LabelerAggs
|
|
@@ -190,6 +196,10 @@ export class Hydrator {
|
|
|
190
196
|
// - profile detailed
|
|
191
197
|
// - profile
|
|
192
198
|
// - list basic
|
|
199
|
+
// - starterpack
|
|
200
|
+
// - profile
|
|
201
|
+
// - list basic
|
|
202
|
+
// - labels
|
|
193
203
|
async hydrateProfilesDetailed(
|
|
194
204
|
dids: string[],
|
|
195
205
|
ctx: HydrateCtx,
|
|
@@ -213,11 +223,21 @@ export class Hydrator {
|
|
|
213
223
|
this.hydrateProfiles(allDids, ctx),
|
|
214
224
|
this.actor.getProfileAggregates(dids),
|
|
215
225
|
])
|
|
216
|
-
|
|
217
|
-
|
|
226
|
+
const starterPackUriSet = new Set<string>()
|
|
227
|
+
state.actors?.forEach((actor) => {
|
|
228
|
+
if (actor?.profile?.joinedViaStarterPack) {
|
|
229
|
+
starterPackUriSet.add(actor?.profile?.joinedViaStarterPack?.uri)
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
const starterPackState = await this.hydrateStarterPacksBasic(
|
|
233
|
+
[...starterPackUriSet],
|
|
234
|
+
ctx,
|
|
235
|
+
)
|
|
236
|
+
return mergeManyStates(state, starterPackState, {
|
|
218
237
|
profileAggs,
|
|
219
238
|
knownFollowers,
|
|
220
|
-
|
|
239
|
+
ctx,
|
|
240
|
+
})
|
|
221
241
|
}
|
|
222
242
|
|
|
223
243
|
// app.bsky.graph.defs#listView
|
|
@@ -238,8 +258,9 @@ export class Hydrator {
|
|
|
238
258
|
uris: string[],
|
|
239
259
|
ctx: HydrateCtx,
|
|
240
260
|
): Promise<HydrationState> {
|
|
241
|
-
const [lists, listViewers, labels] = await Promise.all([
|
|
261
|
+
const [lists, listAggs, listViewers, labels] = await Promise.all([
|
|
242
262
|
this.graph.getLists(uris, ctx.includeTakedowns),
|
|
263
|
+
this.graph.getListAggregates(uris.map((uri) => ({ uri }))),
|
|
243
264
|
ctx.viewer ? this.graph.getListViewerStates(uris, ctx.viewer) : undefined,
|
|
244
265
|
this.label.getLabelsForSubjects(uris, ctx.labelers),
|
|
245
266
|
])
|
|
@@ -248,7 +269,7 @@ export class Hydrator {
|
|
|
248
269
|
actionTakedownLabels(uris, lists, labels)
|
|
249
270
|
}
|
|
250
271
|
|
|
251
|
-
return { lists, listViewers, labels, ctx }
|
|
272
|
+
return { lists, listAggs, listViewers, labels, ctx }
|
|
252
273
|
}
|
|
253
274
|
|
|
254
275
|
// app.bsky.graph.defs#listItemView
|
|
@@ -534,6 +555,106 @@ export class Hydrator {
|
|
|
534
555
|
})
|
|
535
556
|
}
|
|
536
557
|
|
|
558
|
+
// app.bsky.graph.defs#starterPackViewBasic
|
|
559
|
+
// - starterpack
|
|
560
|
+
// - profile
|
|
561
|
+
// - list basic
|
|
562
|
+
// - labels
|
|
563
|
+
async hydrateStarterPacksBasic(
|
|
564
|
+
uris: string[],
|
|
565
|
+
ctx: HydrateCtx,
|
|
566
|
+
): Promise<HydrationState> {
|
|
567
|
+
const [starterPacks, starterPackAggs, profileState, labels] =
|
|
568
|
+
await Promise.all([
|
|
569
|
+
this.graph.getStarterPacks(uris, ctx.includeTakedowns),
|
|
570
|
+
this.graph.getStarterPackAggregates(uris.map((uri) => ({ uri }))),
|
|
571
|
+
this.hydrateProfiles(uris.map(didFromUri), ctx),
|
|
572
|
+
this.label.getLabelsForSubjects(uris, ctx.labelers),
|
|
573
|
+
])
|
|
574
|
+
if (!ctx.includeTakedowns) {
|
|
575
|
+
actionTakedownLabels(uris, starterPacks, labels)
|
|
576
|
+
}
|
|
577
|
+
return mergeStates(profileState, {
|
|
578
|
+
starterPacks,
|
|
579
|
+
starterPackAggs,
|
|
580
|
+
labels,
|
|
581
|
+
ctx,
|
|
582
|
+
})
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// app.bsky.graph.defs#starterPackView
|
|
586
|
+
// - starterpack
|
|
587
|
+
// - profile
|
|
588
|
+
// - list basic
|
|
589
|
+
// - feedgen
|
|
590
|
+
// - profile
|
|
591
|
+
// - list basic
|
|
592
|
+
// - list basic
|
|
593
|
+
// - list item
|
|
594
|
+
// - profile
|
|
595
|
+
// - list basic
|
|
596
|
+
// - labels
|
|
597
|
+
async hydrateStarterPacks(
|
|
598
|
+
uris: string[],
|
|
599
|
+
ctx: HydrateCtx,
|
|
600
|
+
): Promise<HydrationState> {
|
|
601
|
+
const starterPackState = await this.hydrateStarterPacksBasic(uris, ctx)
|
|
602
|
+
// gather feed and list uris
|
|
603
|
+
const feedUriSet = new Set<string>()
|
|
604
|
+
const listUriSet = new Set<string>()
|
|
605
|
+
starterPackState.starterPacks?.forEach((sp) => {
|
|
606
|
+
sp?.record.feeds?.forEach((feed) => feedUriSet.add(feed.uri))
|
|
607
|
+
if (sp?.record.list) {
|
|
608
|
+
listUriSet.add(sp?.record.list)
|
|
609
|
+
}
|
|
610
|
+
})
|
|
611
|
+
const feedUris = [...feedUriSet]
|
|
612
|
+
const listUris = [...listUriSet]
|
|
613
|
+
// hydrate feeds, lists, and their members
|
|
614
|
+
const [feedGenState, listState, ...listsMembers] = await Promise.all([
|
|
615
|
+
this.hydrateFeedGens(feedUris, ctx),
|
|
616
|
+
this.hydrateLists(listUris, ctx),
|
|
617
|
+
...listUris.map((uri) =>
|
|
618
|
+
this.dataplane.getListMembers({ listUri: uri, limit: 50 }),
|
|
619
|
+
),
|
|
620
|
+
])
|
|
621
|
+
// collect list info
|
|
622
|
+
const listMembersByList = new Map(
|
|
623
|
+
listUris.map((uri, i) => [uri, listsMembers[i]]),
|
|
624
|
+
)
|
|
625
|
+
const listMemberDids = listsMembers.flatMap((lm) =>
|
|
626
|
+
lm.listitems.map((li) => li.did),
|
|
627
|
+
)
|
|
628
|
+
// sample top list items per starter pack based on their follows
|
|
629
|
+
const listMemberAggs = await this.actor.getProfileAggregates(listMemberDids)
|
|
630
|
+
const listItemUris: string[] = []
|
|
631
|
+
uris.forEach((uri) => {
|
|
632
|
+
const sp = starterPackState.starterPacks?.get(uri)
|
|
633
|
+
const agg = starterPackState.starterPackAggs?.get(uri)
|
|
634
|
+
if (!sp?.record.list || !agg) return
|
|
635
|
+
const members = listMembersByList.get(sp.record.list)
|
|
636
|
+
if (!members) return
|
|
637
|
+
// update aggregation with list items for top 12 most followed members
|
|
638
|
+
agg.listItemSampleUris = [...members.listitems]
|
|
639
|
+
.sort((li1, li2) => {
|
|
640
|
+
const score1 = listMemberAggs.get(li1.did)?.followers ?? 0
|
|
641
|
+
const score2 = listMemberAggs.get(li2.did)?.followers ?? 0
|
|
642
|
+
return score2 - score1
|
|
643
|
+
})
|
|
644
|
+
.slice(0, 12)
|
|
645
|
+
.map((li) => li.uri)
|
|
646
|
+
listItemUris.push(...agg.listItemSampleUris)
|
|
647
|
+
})
|
|
648
|
+
// hydrate sampled list items
|
|
649
|
+
const listItemState = await this.hydrateListItems(listItemUris, ctx)
|
|
650
|
+
return mergeManyStates(
|
|
651
|
+
starterPackState,
|
|
652
|
+
feedGenState,
|
|
653
|
+
listState,
|
|
654
|
+
listItemState,
|
|
655
|
+
)
|
|
656
|
+
}
|
|
657
|
+
|
|
537
658
|
// app.bsky.feed.getLikes#like
|
|
538
659
|
// - like
|
|
539
660
|
// - profile
|
|
@@ -685,6 +806,11 @@ export class Hydrator {
|
|
|
685
806
|
(await this.graph.getBlocks([uri], includeTakedowns)).get(uri) ??
|
|
686
807
|
undefined
|
|
687
808
|
)
|
|
809
|
+
} else if (collection === ids.AppBskyGraphStarterpack) {
|
|
810
|
+
return (
|
|
811
|
+
(await this.graph.getStarterPacks([uri], includeTakedowns)).get(uri) ??
|
|
812
|
+
undefined
|
|
813
|
+
)
|
|
688
814
|
} else if (collection === ids.AppBskyFeedGenerator) {
|
|
689
815
|
return (
|
|
690
816
|
(await this.feed.getFeedGens([uri], includeTakedowns)).get(uri) ??
|
|
@@ -742,6 +868,14 @@ export class Hydrator {
|
|
|
742
868
|
includeTakedowns: vals.includeTakedowns,
|
|
743
869
|
})
|
|
744
870
|
}
|
|
871
|
+
|
|
872
|
+
async resolveUri(uriStr: string) {
|
|
873
|
+
const uri = new AtUri(uriStr)
|
|
874
|
+
const [did] = await this.actor.getDids([uri.host])
|
|
875
|
+
if (!did) return uriStr
|
|
876
|
+
uri.host = did
|
|
877
|
+
return uri.toString()
|
|
878
|
+
}
|
|
745
879
|
}
|
|
746
880
|
|
|
747
881
|
// service refs may look like "did:plc:example#service_id". we want to extract the did part "did:plc:example".
|
|
@@ -874,6 +1008,7 @@ export const mergeStates = (
|
|
|
874
1008
|
followBlocks: mergeMaps(stateA.followBlocks, stateB.followBlocks),
|
|
875
1009
|
threadgates: mergeMaps(stateA.threadgates, stateB.threadgates),
|
|
876
1010
|
lists: mergeMaps(stateA.lists, stateB.lists),
|
|
1011
|
+
listAggs: mergeMaps(stateA.listAggs, stateB.listAggs),
|
|
877
1012
|
listViewers: mergeMaps(stateA.listViewers, stateB.listViewers),
|
|
878
1013
|
listItems: mergeMaps(stateA.listItems, stateB.listItems),
|
|
879
1014
|
likes: mergeMaps(stateA.likes, stateB.likes),
|
|
@@ -881,6 +1016,8 @@ export const mergeStates = (
|
|
|
881
1016
|
feedgens: mergeMaps(stateA.feedgens, stateB.feedgens),
|
|
882
1017
|
feedgenAggs: mergeMaps(stateA.feedgenAggs, stateB.feedgenAggs),
|
|
883
1018
|
feedgenViewers: mergeMaps(stateA.feedgenViewers, stateB.feedgenViewers),
|
|
1019
|
+
starterPacks: mergeMaps(stateA.starterPacks, stateB.starterPacks),
|
|
1020
|
+
starterPackAggs: mergeMaps(stateA.starterPackAggs, stateB.starterPackAggs),
|
|
884
1021
|
labelers: mergeMaps(stateA.labelers, stateB.labelers),
|
|
885
1022
|
labelerAggs: mergeMaps(stateA.labelerAggs, stateB.labelerAggs),
|
|
886
1023
|
labelerViewers: mergeMaps(stateA.labelerViewers, stateB.labelerViewers),
|
package/src/hydration/util.ts
CHANGED
package/src/lexicon/index.ts
CHANGED
|
@@ -107,6 +107,7 @@ import * as AppBskyFeedGetSuggestedFeeds from './types/app/bsky/feed/getSuggeste
|
|
|
107
107
|
import * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
|
|
108
108
|
import * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
|
|
109
109
|
import * as AppBskyFeedSendInteractions from './types/app/bsky/feed/sendInteractions'
|
|
110
|
+
import * as AppBskyGraphGetActorStarterPacks from './types/app/bsky/graph/getActorStarterPacks'
|
|
110
111
|
import * as AppBskyGraphGetBlocks from './types/app/bsky/graph/getBlocks'
|
|
111
112
|
import * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers'
|
|
112
113
|
import * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows'
|
|
@@ -117,6 +118,8 @@ import * as AppBskyGraphGetListMutes from './types/app/bsky/graph/getListMutes'
|
|
|
117
118
|
import * as AppBskyGraphGetLists from './types/app/bsky/graph/getLists'
|
|
118
119
|
import * as AppBskyGraphGetMutes from './types/app/bsky/graph/getMutes'
|
|
119
120
|
import * as AppBskyGraphGetRelationships from './types/app/bsky/graph/getRelationships'
|
|
121
|
+
import * as AppBskyGraphGetStarterPack from './types/app/bsky/graph/getStarterPack'
|
|
122
|
+
import * as AppBskyGraphGetStarterPacks from './types/app/bsky/graph/getStarterPacks'
|
|
120
123
|
import * as AppBskyGraphGetSuggestedFollowsByActor from './types/app/bsky/graph/getSuggestedFollowsByActor'
|
|
121
124
|
import * as AppBskyGraphMuteActor from './types/app/bsky/graph/muteActor'
|
|
122
125
|
import * as AppBskyGraphMuteActorList from './types/app/bsky/graph/muteActorList'
|
|
@@ -178,6 +181,7 @@ export const APP_BSKY_FEED = {
|
|
|
178
181
|
export const APP_BSKY_GRAPH = {
|
|
179
182
|
DefsModlist: 'app.bsky.graph.defs#modlist',
|
|
180
183
|
DefsCuratelist: 'app.bsky.graph.defs#curatelist',
|
|
184
|
+
DefsReferencelist: 'app.bsky.graph.defs#referencelist',
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
export function createServer(options?: XrpcOptions): Server {
|
|
@@ -1443,6 +1447,17 @@ export class AppBskyGraphNS {
|
|
|
1443
1447
|
this._server = server
|
|
1444
1448
|
}
|
|
1445
1449
|
|
|
1450
|
+
getActorStarterPacks<AV extends AuthVerifier>(
|
|
1451
|
+
cfg: ConfigOf<
|
|
1452
|
+
AV,
|
|
1453
|
+
AppBskyGraphGetActorStarterPacks.Handler<ExtractAuth<AV>>,
|
|
1454
|
+
AppBskyGraphGetActorStarterPacks.HandlerReqCtx<ExtractAuth<AV>>
|
|
1455
|
+
>,
|
|
1456
|
+
) {
|
|
1457
|
+
const nsid = 'app.bsky.graph.getActorStarterPacks' // @ts-ignore
|
|
1458
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1446
1461
|
getBlocks<AV extends AuthVerifier>(
|
|
1447
1462
|
cfg: ConfigOf<
|
|
1448
1463
|
AV,
|
|
@@ -1553,6 +1568,28 @@ export class AppBskyGraphNS {
|
|
|
1553
1568
|
return this._server.xrpc.method(nsid, cfg)
|
|
1554
1569
|
}
|
|
1555
1570
|
|
|
1571
|
+
getStarterPack<AV extends AuthVerifier>(
|
|
1572
|
+
cfg: ConfigOf<
|
|
1573
|
+
AV,
|
|
1574
|
+
AppBskyGraphGetStarterPack.Handler<ExtractAuth<AV>>,
|
|
1575
|
+
AppBskyGraphGetStarterPack.HandlerReqCtx<ExtractAuth<AV>>
|
|
1576
|
+
>,
|
|
1577
|
+
) {
|
|
1578
|
+
const nsid = 'app.bsky.graph.getStarterPack' // @ts-ignore
|
|
1579
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
getStarterPacks<AV extends AuthVerifier>(
|
|
1583
|
+
cfg: ConfigOf<
|
|
1584
|
+
AV,
|
|
1585
|
+
AppBskyGraphGetStarterPacks.Handler<ExtractAuth<AV>>,
|
|
1586
|
+
AppBskyGraphGetStarterPacks.HandlerReqCtx<ExtractAuth<AV>>
|
|
1587
|
+
>,
|
|
1588
|
+
) {
|
|
1589
|
+
const nsid = 'app.bsky.graph.getStarterPacks' // @ts-ignore
|
|
1590
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1556
1593
|
getSuggestedFollowsByActor<AV extends AuthVerifier>(
|
|
1557
1594
|
cfg: ConfigOf<
|
|
1558
1595
|
AV,
|