flip the lib type imports and move the xrpc error helpers off the old client

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-04 04:20:51 +03:00
parent 6792677be8
commit 8c228c2e4f
30 changed files with 169 additions and 198 deletions
+18
View File
@@ -4,11 +4,29 @@ import {
type Main,
type Procedure,
type Query,
XrpcError,
XrpcResponseError,
} from '@atproto/lex'
import {com} from '#/lexicons'
/**
* True for an XRPC error from a lex `Client` (`XrpcError` is the abstract base
* of `XrpcResponseError`/`XrpcInvalidResponseError`/`XrpcInternalError`).
*/
export function isXrpcError(e: unknown): e is XrpcError {
return e instanceof XrpcError
}
/**
* HTTP status, or undefined when `e` is not an XRPC error carrying a response.
* Only `XrpcResponseError` (a genuine server response) has a status; the
* internal/fetch lex errors do not.
*/
export function getErrorStatus(e: unknown): number | undefined {
return e instanceof XrpcResponseError ? e.status : undefined
}
/**
* Same nsid means `e` was thrown for this method schema, so `e` can be
* treated as an `XrpcResponseError<M>` - which is what lets the SDK's