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