Tighten up types
This commit is contained in:
@@ -2,7 +2,9 @@ import {
|
||||
AppBskyGraphFollow,
|
||||
AppBskyGraphGetFollows,
|
||||
BskyAgent,
|
||||
ComAtprotoRepoApplyWrites,
|
||||
} from '@atproto/api'
|
||||
import {$Typed} from '@atproto/api/dist/client/util'
|
||||
import {TID} from '@atproto/common-web'
|
||||
import chunk from 'lodash.chunk'
|
||||
|
||||
@@ -15,7 +17,7 @@ export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
|
||||
throw new Error(`bulkWriteFollows failed: no session`)
|
||||
}
|
||||
|
||||
const followRecords: AppBskyGraphFollow.Record[] = dids.map(did => {
|
||||
const followRecords: $Typed<AppBskyGraphFollow.Record>[] = dids.map(did => {
|
||||
return {
|
||||
$type: 'app.bsky.graph.follow',
|
||||
subject: did,
|
||||
@@ -23,12 +25,13 @@ export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
|
||||
}
|
||||
})
|
||||
|
||||
const followWrites = followRecords.map(r => ({
|
||||
$type: 'com.atproto.repo.applyWrites#create',
|
||||
collection: 'app.bsky.graph.follow',
|
||||
rkey: TID.nextStr(),
|
||||
value: r,
|
||||
}))
|
||||
const followWrites: $Typed<ComAtprotoRepoApplyWrites.Create>[] =
|
||||
followRecords.map(r => ({
|
||||
$type: 'com.atproto.repo.applyWrites#create',
|
||||
collection: 'app.bsky.graph.follow',
|
||||
rkey: TID.nextStr(),
|
||||
value: r,
|
||||
}))
|
||||
|
||||
const chunks = chunk(followWrites, 50)
|
||||
for (const chunk of chunks) {
|
||||
|
||||
Reference in New Issue
Block a user