Run codemod for replacing BskyAgent with AtpAgent (#10862)

This commit is contained in:
DS Boyce
2026-06-11 08:46:01 -07:00
committed by GitHub
parent e3e7db2350
commit c8634105c1
37 changed files with 195 additions and 134 deletions
+3 -3
View File
@@ -1,20 +1,20 @@
import {
AppBskyFeedDefs,
type AppBskyFeedGetAuthorFeed as GetAuthorFeed,
type BskyAgent,
type AtpAgent,
} from '@atproto/api'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class AuthorFeedAPI implements FeedAPI {
agent: BskyAgent
agent: AtpAgent
_params: GetAuthorFeed.QueryParams
constructor({
agent,
feedParams,
}: {
agent: BskyAgent
agent: AtpAgent
feedParams: GetAuthorFeed.QueryParams
}) {
this.agent = agent
+4 -4
View File
@@ -1,7 +1,7 @@
import {
type AppBskyFeedDefs,
type AppBskyFeedGetFeed as GetCustomFeed,
BskyAgent,
AtpAgent,
jsonStringToLex,
} from '@atproto/api'
@@ -13,7 +13,7 @@ import {type FeedAPI, type FeedAPIResponse} from './types'
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
export class CustomFeedAPI implements FeedAPI {
agent: BskyAgent
agent: AtpAgent
params: GetCustomFeed.QueryParams
userInterests?: string
@@ -22,7 +22,7 @@ export class CustomFeedAPI implements FeedAPI {
feedParams,
userInterests,
}: {
agent: BskyAgent
agent: AtpAgent
feedParams: GetCustomFeed.QueryParams
userInterests?: string
}) {
@@ -113,7 +113,7 @@ async function loggedOutFetch({
* @see https://github.com/bluesky-social/atproto/blob/60df3fc652b00cdff71dd9235d98a7a4bb828f05/packages/api/src/agent.ts#L120
*/
const labelersHeader = {
'atproto-accept-labelers': BskyAgent.appLabelers
'atproto-accept-labelers': AtpAgent.appLabelers
.map(l => `${l};redact`)
.join(', '),
}
+3 -3
View File
@@ -1,12 +1,12 @@
import {type AppBskyFeedDefs, type BskyAgent} from '@atproto/api'
import {type AppBskyFeedDefs, type AtpAgent} from '@atproto/api'
import {DEMO_FEED} from '#/lib/demo'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class DemoFeedAPI implements FeedAPI {
agent: BskyAgent
agent: AtpAgent
constructor({agent}: {agent: BskyAgent}) {
constructor({agent}: {agent: AtpAgent}) {
this.agent = agent
}
+3 -3
View File
@@ -1,11 +1,11 @@
import {type AppBskyFeedDefs, type BskyAgent} from '@atproto/api'
import {type AppBskyFeedDefs, type AtpAgent} from '@atproto/api'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class FollowingFeedAPI implements FeedAPI {
agent: BskyAgent
agent: AtpAgent
constructor({agent}: {agent: BskyAgent}) {
constructor({agent}: {agent: AtpAgent}) {
this.agent = agent
}
+3 -3
View File
@@ -1,4 +1,4 @@
import {type AppBskyFeedDefs, type BskyAgent} from '@atproto/api'
import {type AppBskyFeedDefs, type AtpAgent} from '@atproto/api'
import {PROD_DEFAULT_FEED} from '#/lib/constants'
import {CustomFeedAPI} from './custom'
@@ -27,7 +27,7 @@ export const FALLBACK_MARKER_POST: AppBskyFeedDefs.FeedViewPost = {
}
export class HomeFeedAPI implements FeedAPI {
agent: BskyAgent
agent: AtpAgent
following: FollowingFeedAPI
discover: CustomFeedAPI
usingDiscover = false
@@ -39,7 +39,7 @@ export class HomeFeedAPI implements FeedAPI {
agent,
}: {
userInterests?: string
agent: BskyAgent
agent: AtpAgent
}) {
this.agent = agent
this.following = new FollowingFeedAPI({agent})
+3 -3
View File
@@ -1,20 +1,20 @@
import {
type AppBskyFeedDefs,
type AppBskyFeedGetActorLikes as GetActorLikes,
type BskyAgent,
type AtpAgent,
} from '@atproto/api'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class LikesFeedAPI implements FeedAPI {
agent: BskyAgent
agent: AtpAgent
params: GetActorLikes.QueryParams
constructor({
agent,
feedParams,
}: {
agent: BskyAgent
agent: AtpAgent
feedParams: GetActorLikes.QueryParams
}) {
this.agent = agent
+7 -7
View File
@@ -1,7 +1,7 @@
import {
type AppBskyFeedDefs,
type AppBskyFeedGetTimeline,
type BskyAgent,
type AtpAgent,
} from '@atproto/api'
import shuffle from 'lodash.shuffle'
@@ -24,7 +24,7 @@ const POST_AGE_CUTOFF = 60e3 * 60 * 24 // 24hours
export class MergeFeedAPI implements FeedAPI {
userInterests?: string
agent: BskyAgent
agent: AtpAgent
params: FeedParams
feedTuners: FeedTunerFn[]
following: MergeFeedSource_Following
@@ -39,7 +39,7 @@ export class MergeFeedAPI implements FeedAPI {
feedTuners,
userInterests,
}: {
agent: BskyAgent
agent: AtpAgent
feedParams: FeedParams
feedTuners: FeedTunerFn[]
userInterests?: string
@@ -175,7 +175,7 @@ export class MergeFeedAPI implements FeedAPI {
}
class MergeFeedSource {
agent: BskyAgent
agent: AtpAgent
feedTuners: FeedTunerFn[]
sourceInfo: ReasonFeedSource | undefined
cursor: string | undefined = undefined
@@ -186,7 +186,7 @@ class MergeFeedSource {
agent,
feedTuners,
}: {
agent: BskyAgent
agent: AtpAgent
feedTuners: FeedTunerFn[]
}) {
this.agent = agent
@@ -253,7 +253,7 @@ class MergeFeedSource_Following extends MergeFeedSource {
}
class MergeFeedSource_Custom extends MergeFeedSource {
agent: BskyAgent
agent: AtpAgent
minDate: Date
feedUri: string
userInterests?: string
@@ -264,7 +264,7 @@ class MergeFeedSource_Custom extends MergeFeedSource {
feedTuners,
userInterests,
}: {
agent: BskyAgent
agent: AtpAgent
feedUri: string
feedTuners: FeedTunerFn[]
userInterests?: string
+7 -7
View File
@@ -7,8 +7,8 @@ import {
type AppBskyEmbedRecordWithMedia,
type AppBskyEmbedVideo,
AppBskyFeedPost,
type AtpAgent,
BlobRef,
type BskyAgent,
ChatBskyGroupDefs,
type ComAtprotoLabelDefs,
type ComAtprotoRepoApplyWrites,
@@ -55,7 +55,7 @@ interface PostOpts {
}
export async function post(
agent: BskyAgent,
agent: AtpAgent,
queryClient: QueryClient,
opts: PostOpts,
) {
@@ -197,7 +197,7 @@ export async function post(
return {uris}
}
async function resolveRT(agent: BskyAgent, richtext: RichText) {
async function resolveRT(agent: AtpAgent, richtext: RichText) {
const trimmedText = richtext.text
// Trim leading whitespace-only lines (but don't break ASCII art).
.replace(/^(\s*\n)+/, '')
@@ -217,7 +217,7 @@ export class ReplyDeletedError extends Error {
}
}
async function resolveReply(agent: BskyAgent, replyTo: string) {
async function resolveReply(agent: AtpAgent, replyTo: string) {
const {data} = await agent.app.bsky.feed.getPosts({
uris: [replyTo],
})
@@ -250,7 +250,7 @@ async function resolveReply(agent: BskyAgent, replyTo: string) {
}
async function resolveEmbed(
agent: BskyAgent,
agent: AtpAgent,
queryClient: QueryClient,
draft: PostDraft,
onStateChange: ((state: string) => void) | undefined,
@@ -309,7 +309,7 @@ async function resolveEmbed(
}
async function resolveMedia(
agent: BskyAgent,
agent: AtpAgent,
queryClient: QueryClient,
embedDraft: EmbedDraft,
onStateChange: ((state: string) => void) | undefined,
@@ -482,7 +482,7 @@ async function resolveMedia(
}
async function resolveRecord(
agent: BskyAgent,
agent: AtpAgent,
queryClient: QueryClient,
uri: string,
): Promise<ComAtprotoRepoStrongRef.Main> {
+2 -2
View File
@@ -1,5 +1,5 @@
import {copyAsync} from 'expo-file-system/legacy'
import {type BskyAgent, type ComAtprotoRepoUploadBlob} from '@atproto/api'
import {type AtpAgent, type ComAtprotoRepoUploadBlob} from '@atproto/api'
import {safeDeleteAsync} from '#/lib/media/manip'
@@ -7,7 +7,7 @@ import {safeDeleteAsync} from '#/lib/media/manip'
* @param encoding Allows overriding the blob's type
*/
export async function uploadBlob(
agent: BskyAgent,
agent: AtpAgent,
input: string | Blob,
encoding?: string,
): Promise<ComAtprotoRepoUploadBlob.Response> {
+2 -2
View File
@@ -1,4 +1,4 @@
import {type BskyAgent, type ComAtprotoRepoUploadBlob} from '@atproto/api'
import {type AtpAgent, type ComAtprotoRepoUploadBlob} from '@atproto/api'
/**
* @note It is recommended, on web, to use the `file` instance of the file
@@ -7,7 +7,7 @@ import {type BskyAgent, type ComAtprotoRepoUploadBlob} from '@atproto/api'
* be passed directly to this function.
*/
export async function uploadBlob(
agent: BskyAgent,
agent: AtpAgent,
input: string | Blob,
encoding?: string,
): Promise<ComAtprotoRepoUploadBlob.Response> {