a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(client): `ok()` shouldn't error on requests with `as: null`

Mary bd446e41 27aad10d

+14 -4
+5
.changeset/shy-geese-attack.md
··· 1 + --- 2 + '@atcute/client': patch 3 + --- 4 + 5 + `ok()` shouldn't error on requests with `as: null`
+9 -4
packages/clients/client/lib/client.ts
··· 141 141 /** represents a response returned by the client */ 142 142 export type ClientResponse<TDef, TInit> = SuccessClientResponse<TDef, TInit> | FailedClientResponse; 143 143 144 + type UnknownClientResponse = { status: number; headers: Headers } & ( 145 + | { ok: true; data: unknown } 146 + | { ok: false; data: XRPCErrorPayload } 147 + ); 148 + 144 149 // #endregion 145 150 146 151 // #region Client ··· 399 404 // #endregion 400 405 401 406 // #region Optimistic response helper 402 - type SuccessData<R> = R extends { ok: true; data: infer D } ? D : never; 407 + type ExtractSuccessData<R> = R extends { ok: true; data: infer D } ? D : never; 403 408 404 409 /** 405 410 * takes in the response returned by the client, and either returns the data if ··· 412 417 * // ^? ComAtprotoServerDescribeServer.Output 413 418 */ 414 419 export const ok: { 415 - <T extends Promise<ClientResponse<any, any>>>(promise: T): Promise<SuccessData<Awaited<T>>>; 416 - <T extends ClientResponse<any, any>>(response: T): SuccessData<T>; 417 - } = (input: Promise<ClientResponse<any, any>> | ClientResponse<any, any>): any => { 420 + <T extends Promise<UnknownClientResponse>>(promise: T): Promise<ExtractSuccessData<Awaited<T>>>; 421 + <T extends UnknownClientResponse>(response: T): ExtractSuccessData<T>; 422 + } = (input: Promise<UnknownClientResponse> | UnknownClientResponse): any => { 418 423 if (input instanceof Promise) { 419 424 return input.then(ok); 420 425 }