migrate runtime call sites to lex clients and sdk actions
Phase 3 tasks 3-7 (parallel wave): composer/post pipeline on pdsClient/appviewClient with structural+instance blob guards and a golden CID fixture test; chat Convo/EventBus/queries on the dedicated chat client; preferences sugar to SDK actions on the PDS client; remaining state/queries producers (usePostThread unspecced flip, video scoped-token clients, notifications, starter packs, lists) to client.call; UI runtime sweep (AtUri from @atproto/syntax, moderation fns from @bsky.app/sdk/moderation, SDK RichText, ozone reason tokens, guard rewrites via #/types/bsky). Intermediate checkpoint (hooks skipped): ~114 typecheck errors remain in cross-boundary consumer files, resolved by the type-only codemod next. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import {ComAtprotoTempCheckHandleAvailability} from '@atproto/api'
|
||||
import {useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {
|
||||
@@ -9,9 +8,21 @@ import {
|
||||
import {useDebouncedValue} from '#/lib/hooks/useDebouncedValue'
|
||||
import {createFullHandle} from '#/lib/strings/handles'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import * as bsky from '#/types/bsky'
|
||||
import {Agent} from '../session/agent'
|
||||
|
||||
/*
|
||||
* `com.atproto.temp.checkHandleAvailability` is an entryway-only endpoint that
|
||||
* isn't generated into `#/lexicons`, so we describe its result union locally.
|
||||
* The response is discriminated by `$type`; we narrow against these shapes
|
||||
* rather than a branded lexicon guard.
|
||||
*/
|
||||
type CheckHandleAvailabilityResult =
|
||||
| {$type: 'com.atproto.temp.checkHandleAvailability#resultAvailable'}
|
||||
| {
|
||||
$type: 'com.atproto.temp.checkHandleAvailability#resultUnavailable'
|
||||
suggestions: {handle: string; method: string}[]
|
||||
}
|
||||
|
||||
export const RQKEY_handleAvailability = (
|
||||
handle: string,
|
||||
domain: string,
|
||||
@@ -87,22 +98,20 @@ export async function checkHandleAvailability(
|
||||
email,
|
||||
})
|
||||
|
||||
const result = data.result as CheckHandleAvailabilityResult
|
||||
|
||||
if (
|
||||
bsky.dangerousIsType<ComAtprotoTempCheckHandleAvailability.ResultAvailable>(
|
||||
data.result,
|
||||
ComAtprotoTempCheckHandleAvailability.isResultAvailable,
|
||||
)
|
||||
result.$type ===
|
||||
'com.atproto.temp.checkHandleAvailability#resultAvailable'
|
||||
) {
|
||||
return {available: true} as const
|
||||
} else if (
|
||||
bsky.dangerousIsType<ComAtprotoTempCheckHandleAvailability.ResultUnavailable>(
|
||||
data.result,
|
||||
ComAtprotoTempCheckHandleAvailability.isResultUnavailable,
|
||||
)
|
||||
result.$type ===
|
||||
'com.atproto.temp.checkHandleAvailability#resultUnavailable'
|
||||
) {
|
||||
return {
|
||||
available: false,
|
||||
suggestions: data.result.suggestions,
|
||||
suggestions: result.suggestions,
|
||||
} as const
|
||||
} else {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user