cast branded params with the dedicated syntax types

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-03 15:57:24 +03:00
parent 384058d6a2
commit 3f8016139c
12 changed files with 25 additions and 18 deletions
+3 -3
View File
@@ -1,3 +1,4 @@
import {type DidString} from '@atproto/syntax'
import {type QueryClient, useInfiniteQuery} from '@tanstack/react-query' import {type QueryClient, useInfiniteQuery} from '@tanstack/react-query'
import {useAppviewClient} from '#/state/session' import {useAppviewClient} from '#/state/session'
@@ -25,7 +26,7 @@ export function useActorStarterPacksQuery({
queryFn: async ({pageParam}: {pageParam?: string}) => { queryFn: async ({pageParam}: {pageParam?: string}) => {
return await client.call(app.bsky.graph.getActorStarterPacks, { return await client.call(app.bsky.graph.getActorStarterPacks, {
// the enabled flag prevents this from running until did is set // the enabled flag prevents this from running until did is set
actor: did! as app.bsky.graph.getActorStarterPacks.$Params['actor'], actor: did! as DidString,
limit: 10, limit: 10,
cursor: pageParam, cursor: pageParam,
}) })
@@ -50,8 +51,7 @@ export function useActorStarterPacksWithMembershipsQuery({
queryFn: async ({pageParam}: {pageParam?: string}) => { queryFn: async ({pageParam}: {pageParam?: string}) => {
return await client.call(app.bsky.graph.getStarterPacksWithMembership, { return await client.call(app.bsky.graph.getStarterPacksWithMembership, {
// the enabled flag prevents this from running until did is set // the enabled flag prevents this from running until did is set
actor: actor: did! as DidString,
did! as app.bsky.graph.getStarterPacksWithMembership.$Params['actor'],
limit: 10, limit: 10,
cursor: pageParam, cursor: pageParam,
}) })
+2 -1
View File
@@ -1,4 +1,5 @@
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryClient, type QueryClient,
@@ -28,7 +29,7 @@ export function useProfileKnownFollowersQuery(did: string | undefined) {
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
return await client.call(app.bsky.graph.getKnownFollowers, { return await client.call(app.bsky.graph.getKnownFollowers, {
// the enabled flag prevents this from running until did is set // the enabled flag prevents this from running until did is set
actor: did! as app.bsky.graph.getKnownFollowers.$Params['actor'], actor: did! as DidString,
limit: PAGE_SIZE, limit: PAGE_SIZE,
cursor: pageParam, cursor: pageParam,
}) })
+2 -1
View File
@@ -3,6 +3,7 @@ import {
type AppBskyGraphDefs, type AppBskyGraphDefs,
type AtpAgent, type AtpAgent,
} from '@atproto/api' } from '@atproto/api'
import {type AtUriString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryClient, type QueryClient,
@@ -37,7 +38,7 @@ export function useListMembersQuery(uri?: string, limit: number = PAGE_SIZE) {
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
return await client.call(app.bsky.graph.getList, { return await client.call(app.bsky.graph.getList, {
// the enabled flag will prevent this from running until uri is set // the enabled flag will prevent this from running until uri is set
list: uri! as app.bsky.graph.getList.$Params['list'], list: uri! as AtUriString,
limit, limit,
cursor: pageParam, cursor: pageParam,
}) })
+2 -1
View File
@@ -1,4 +1,5 @@
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {type AtIdentifierString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryClient, type QueryClient,
@@ -37,7 +38,7 @@ export function useListsWithMembershipQuery({
queryFn: async ({pageParam}: {pageParam?: string}) => { queryFn: async ({pageParam}: {pageParam?: string}) => {
return await client.call(app.bsky.graph.getListsWithMembership, { return await client.call(app.bsky.graph.getListsWithMembership, {
// the enabled flag prevents this from running until actor is set // the enabled flag prevents this from running until actor is set
actor: actor! as app.bsky.graph.getListsWithMembership.$Params['actor'], actor: actor! as AtIdentifierString,
limit: 50, limit: 50,
cursor: pageParam, cursor: pageParam,
}) })
+2 -2
View File
@@ -1,4 +1,5 @@
import {type AppBskyGraphDefs} from '@atproto/api' import {type AppBskyGraphDefs} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import {type QueryClient, useQuery} from '@tanstack/react-query' import {type QueryClient, useQuery} from '@tanstack/react-query'
import {accumulate} from '#/lib/async/accumulate' import {accumulate} from '#/lib/async/accumulate'
@@ -27,8 +28,7 @@ export function useMyListsQuery(filter: MyListsFilter) {
accumulate(cursor => accumulate(cursor =>
client client
.call(app.bsky.graph.getLists, { .call(app.bsky.graph.getLists, {
actor: currentAccount! actor: currentAccount!.did as DidString,
.did as app.bsky.graph.getLists.$Params['actor'],
cursor, cursor,
limit: 50, limit: 50,
}) })
+2 -2
View File
@@ -1,3 +1,4 @@
import {type DidString} from '@atproto/syntax'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useMutation, useQueryClient} from '@tanstack/react-query' import {useMutation, useQueryClient} from '@tanstack/react-query'
@@ -35,8 +36,7 @@ export function usePinnedPostMutation() {
// get the currently pinned post so we can optimistically remove the pin from it // get the currently pinned post so we can optimistically remove the pin from it
if (!currentAccount) throw new Error('Not signed in') if (!currentAccount) throw new Error('Not signed in')
const profile = await client.call(app.bsky.actor.getProfile, { const profile = await client.call(app.bsky.actor.getProfile, {
actor: actor: currentAccount.did as DidString,
currentAccount.did as app.bsky.actor.getProfile.$Params['actor'],
}) })
prevPinnedPost = profile.pinnedPost?.uri prevPinnedPost = profile.pinnedPost?.uri
if (prevPinnedPost && prevPinnedPost !== postUri) { if (prevPinnedPost && prevPinnedPost !== postUri) {
+2 -1
View File
@@ -1,4 +1,5 @@
import {moderateFeedGenerator} from '@atproto/api' import {moderateFeedGenerator} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryKey, type QueryKey,
@@ -33,7 +34,7 @@ export function useProfileFeedgensQuery(
queryKey: RQKEY(did), queryKey: RQKEY(did),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const data = await client.call(app.bsky.feed.getActorFeeds, { const data = await client.call(app.bsky.feed.getActorFeeds, {
actor: did as app.bsky.feed.getActorFeeds.$Params['actor'], actor: did as DidString,
limit: PAGE_SIZE, limit: PAGE_SIZE,
cursor: pageParam, cursor: pageParam,
}) })
+2 -1
View File
@@ -1,4 +1,5 @@
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryClient, type QueryClient,
@@ -51,7 +52,7 @@ export function useProfileFollowersQuery(
* is `undefined`, hence the conditional spread. * is `undefined`, hence the conditional spread.
*/ */
return await client.call(app.bsky.graph.getFollowers, { return await client.call(app.bsky.graph.getFollowers, {
actor: (did || '') as app.bsky.graph.getFollowers.$Params['actor'], actor: (did || '') as DidString,
limit: PAGE_SIZE, limit: PAGE_SIZE,
cursor: pageParam, cursor: pageParam,
...(sortParam ? {sort: sortParam} : {}), ...(sortParam ? {sort: sortParam} : {}),
+2 -1
View File
@@ -1,4 +1,5 @@
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryClient, type QueryClient,
@@ -56,7 +57,7 @@ export function useProfileFollowsQuery(
* is `undefined`, hence the conditional spread. * is `undefined`, hence the conditional spread.
*/ */
return await client.call(app.bsky.graph.getFollows, { return await client.call(app.bsky.graph.getFollows, {
actor: (did || '') as app.bsky.graph.getFollows.$Params['actor'], actor: (did || '') as DidString,
limit: limit || PAGE_SIZE, limit: limit || PAGE_SIZE,
cursor: pageParam, cursor: pageParam,
...(sortParam ? {sort: sortParam} : {}), ...(sortParam ? {sort: sortParam} : {}),
+2 -1
View File
@@ -1,4 +1,5 @@
import {moderateUserList} from '@atproto/api' import {moderateUserList} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryKey, type QueryKey,
@@ -29,7 +30,7 @@ export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) {
queryKey: RQKEY(did), queryKey: RQKEY(did),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
return await client.call(app.bsky.graph.getLists, { return await client.call(app.bsky.graph.getLists, {
actor: did as app.bsky.graph.getLists.$Params['actor'], actor: did as DidString,
limit: PAGE_SIZE, limit: PAGE_SIZE,
cursor: pageParam, cursor: pageParam,
}) })
+2 -2
View File
@@ -1,5 +1,6 @@
import {useCallback, useMemo} from 'react' import {useCallback, useMemo} from 'react'
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {type DidString} from '@atproto/syntax'
import { import {
type InfiniteData, type InfiniteData,
type QueryClient, type QueryClient,
@@ -37,8 +38,7 @@ export function useSuggestedFollowsByActorQuery({
const data = await client.call( const data = await client.call(
app.bsky.graph.getSuggestedFollowsByActor, app.bsky.graph.getSuggestedFollowsByActor,
{ {
actor: actor: did as DidString,
did as app.bsky.graph.getSuggestedFollowsByActor.$Params['actor'],
}, },
) )
const suggestions = data.suggestions.filter( const suggestions = data.suggestions.filter(
@@ -1,4 +1,5 @@
import {useCallback} from 'react' import {useCallback} from 'react'
import {type DidString} from '@atproto/syntax'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
import {logger} from '#/logger' import {logger} from '#/logger'
@@ -20,8 +21,7 @@ export function useUpdateProfileVerificationCache() {
async ({profile}: {profile: bsky.profile.AnyProfileView}) => { async ({profile}: {profile: bsky.profile.AnyProfileView}) => {
try { try {
const updated = await client.call(app.bsky.actor.getProfile, { const updated = await client.call(app.bsky.actor.getProfile, {
actor: (profile.did ?? actor: (profile.did ?? '') as DidString,
'') as app.bsky.actor.getProfile.$Params['actor'],
}) })
updateProfileShadow(qc, profile.did, { updateProfileShadow(qc, profile.did, {
verification: updated.verification, verification: updated.verification,