import type { LexMap, LexValue, TypedLexMap } from '@atproto/lex-data'; import type { AtIdentifierString, AtUriString, CidString, DidString, Infer, InferMethodInputBody, InferMethodOutputBody, InferRecordKey, LexiconRecordKey, Main, NsidString, Params, Restricted } from '@atproto/lex-schema'; import { Procedure, Query, RecordSchema } from '@atproto/lex-schema'; import type { Agent, AgentOptions } from './agent.js'; import type { XrpcFailure } from './errors.js'; import applyWrites from './lexicons/com/atproto/repo/applyWrites.js'; import createRecord from './lexicons/com/atproto/repo/createRecord.js'; import deleteRecord from './lexicons/com/atproto/repo/deleteRecord.js'; import getRecord from './lexicons/com/atproto/repo/getRecord.js'; import listRecords, { type Record as ListRecordsRecord } from './lexicons/com/atproto/repo/listRecords.js'; import putRecord from './lexicons/com/atproto/repo/putRecord.js'; import uploadBlob from './lexicons/com/atproto/repo/uploadBlob.js'; import getBlob from './lexicons/com/atproto/sync/getBlob.js'; import type { XrpcResponse, XrpcResponseBody, XrpcResponseOptions } from './response.js'; import { type BinaryBodyInit, type Service } from './types.js'; import { type RecordKeyOptions, type XrpcRequestHeadersOptions } from './util.js'; import { type WriteOperation, type WriteOperationCreateOptions, type WriteOperationDeleteOptions, WriteOperationHelper, type WriteOperationUpdateOptions, type WriteOperationsFactory } from './write-operation-builder.js'; import { type XrpcOptions, type XrpcRequestParams, type XrpcRequestProcessingOptions } from './xrpc.js'; export { type AtIdentifierString, type CidString, type DidString, type Infer, type InferMethodInputBody, type InferMethodOutputBody, type InferRecordKey, type LexMap, type LexValue, type LexiconRecordKey, type Main, type NsidString, type Params, Procedure, Query, RecordSchema, type Restricted, type TypedLexMap, type WriteOperation, type WriteOperationCreateOptions, type WriteOperationDeleteOptions, WriteOperationHelper, type WriteOperationUpdateOptions, type WriteOperationsFactory, }; /** * Configuration options for creating a {@link Client}. * * @property {@link ClientOptions.labelers} - An iterable of labeler DIDs to include in requests. These will be combined with any global app labelers configured via {@link Client.configure}. * @property {@link ClientOptions.service} - An optional service identifier (DID or URL) for routing requests with service proxying. * @property {@link ClientOptions.headers} - Custom headers to include in all requests made by this client instance. * @property {@link ClientOptions.validateRequest} - If true, validates request bodies against their lexicon schemas before sending. Defaults to false for performance. * @property {@link ClientOptions.validateResponse} - If false, skips validation of response bodies against their lexicon schemas. Defaults to true to catch errors, but can be disabled for performance if you trust the server responses. Note that defaults will not be applied if validation is disabled, which can cause typing inconsistencies, so use with caution. * @property {@link ClientOptions.strictResponseProcessing} - If false, relaxes certain validation rules during response processing (e.g., allowing floats, deeper nesting, etc.). Defaults to true for strict compliance with {@link https://atproto.com/specs/data-model lexicon data model}, but can be disabled to handle non-compliant responses. * * @see {@link XrpcRequestHeadersOptions} * @see {@link XrpcRequestProcessingOptions} * @see {@link XrpcResponseOptions} * * @example * ```typescript * const options: ClientOptions = { * labelers: ['did:plc:labeler1'], * service: 'did:web:api.bsky.app#bsky_appview', * headers: { 'X-Custom-Header': 'value' }, * validateRequest: false, * validateResponse: true, * strictResponseProcessing: false, * } * ``` */ export type ClientOptions = XrpcRequestHeadersOptions & Pick & XrpcResponseOptions; export type ActionOptions = { /** AbortSignal to cancel the request. */ signal?: AbortSignal; }; /** * A composable action that can be invoked via {@link Client.call}. * * Actions provide a way to define custom operations that integrate with the * Client's call interface, enabling type-safe, reusable business logic. * * @typeParam I - The input type for the action * @typeParam O - The output type for the action * * @example * ```typescript * const myAction: Action<{ userId: string }, { profile: Profile }> = async (client, input, options) => { * const response = await client.xrpc(someMethod, { params: { actor: input.userId }, ...options }) * return { profile: response.body } * } * ``` */ export type Action = (client: Client, input: I, options: ActionOptions) => O | Promise; /** * Extracts the input type from an {@link Action}. * @typeParam A - The Action type to extract from */ export type InferActionInput = A extends Action ? I : never; /** * Extracts the output type from an {@link Action}. * @typeParam A - The Action type to extract from */ export type InferActionOutput = A extends Action ? O : never; /** * Options for creating a record in an AT Protocol repository. * * @see {@link Client.createRecord} */ export type CreateRecordOptions = Omit, 'body'> & { /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */ repo?: AtIdentifierString; /** Compare-and-swap on the repo commit. If specified, must match current commit. */ swapCommit?: string; /** * Whether the PDS should validate the record against its lexicon schema. * When `true`, the PDS is asked to explicitly validate the record. When * `false`, the PDS is asked to explicitly skip validation. When `undefined` * (default), the PDS decides -- typically validating only collections whose * schemas it knows. This is server-side validation; for client-side * validation before sending, use {@link XrpcRequestProcessingOptions.validateRequest}. */ validate?: boolean; }; /** * Options for deleting a record from an AT Protocol repository. * * @see {@link Client.deleteRecord} */ export type DeleteRecordOptions = Omit, 'body'> & { /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */ repo?: AtIdentifierString; /** Compare-and-swap on the repo commit. If specified, must match current commit. */ swapCommit?: string; /** Compare-and-swap on the record CID. If specified, must match current record. */ swapRecord?: string; }; /** * Options for retrieving a record from an AT Protocol repository. * * @see {@link Client.getRecord} */ export type GetRecordOptions = Omit, 'params'> & { /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */ repo?: AtIdentifierString; }; /** * Options for creating or updating a record in an AT Protocol repository. * * @see {@link Client.putRecord} */ export type PutRecordOptions = Omit, 'body'> & { /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */ repo?: AtIdentifierString; /** Compare-and-swap on the repo commit. If specified, must match current commit. */ swapCommit?: string; /** Compare-and-swap on the record CID. If specified, must match current record. */ swapRecord?: string; /** * Whether the PDS should validate the record against its lexicon schema. * When `true`, the PDS is asked to explicitly validate the record. When * `false`, the PDS is asked to explicitly skip validation. When `undefined` * (default), the PDS decides — typically validating only collections whose * schemas it knows. This is server-side validation; for client-side * validation before sending, use {@link XrpcRequestProcessingOptions.validateRequest}. */ validate?: boolean; }; /** * Options for listing records in an AT Protocol repository collection. * * @see {@link Client.listRecords} */ export type ListRecordsOptions = Omit, 'params'> & { /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */ repo?: AtIdentifierString; /** Maximum number of records to return. */ limit?: number; /** Pagination cursor from a previous response. */ cursor?: string; /** If true, returns records in reverse chronological order. */ reverse?: boolean; }; /** * Options for applying a batch of writes (create/update/delete) to an AT Protocol repository. * * @see {@link Client.applyWrites} */ export type ApplyWritesOptions = Omit, 'body'> & { /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */ repo?: AtIdentifierString; /** * Whether the PDS should validate the records against their lexicon schemas. * When `true`, the PDS is asked to explicitly validate every record. When * `false`, the PDS is asked to explicitly skip validation. When `undefined` * (default), the PDS decides — typically validating only collections whose * schemas it knows. */ validate?: boolean; /** Compare-and-swap on the repo commit. If specified, must match current commit. */ swapCommit?: CidString; }; export type UploadBlobOptions = Omit, 'body'>; export type GetBlobOptions = Omit, 'params'>; /** * Type-safe options for {@link Client.create}, combining record options with key requirements. * @typeParam T - The record schema type * @see {@link CreateRecordOptions} */ export type CreateOptions = CreateRecordOptions & RecordKeyOptions; /** * Output type for record creation operations. * Contains the URI and CID of the newly created record. */ export type CreateOutput = InferMethodOutputBody; /** * Type-safe options for {@link Client.delete}, combining delete options with key requirements. * @typeParam T - The record schema type */ export type DeleteOptions = DeleteRecordOptions & RecordKeyOptions; /** * Output type for record deletion operations. */ export type DeleteOutput = InferMethodOutputBody; /** * Type-safe options for {@link Client.get}, combining get options with key requirements. * @typeParam T - The record schema type */ export type GetOptions = GetRecordOptions & RecordKeyOptions; /** * Output type for record retrieval operations. * Contains the record value validated against the schema type. * @typeParam T - The record schema type */ export type GetOutput = Omit, 'value'> & { value: Infer; }; /** * Type-safe options for {@link Client.put}, combining put options with key requirements. * @typeParam T - The record schema type */ export type PutOptions = PutRecordOptions & RecordKeyOptions; /** * Output type for record put (create/update) operations. * Contains the URI and CID of the record. */ export type PutOutput = InferMethodOutputBody; /** * Options for {@link Client.list} operations. */ export type ListOptions = ListRecordsOptions; /** * Output type for record listing operations. * Contains validated records and any invalid records that failed schema validation. * @typeParam T - The record schema type */ export type ListOutput = Omit, 'records'> & { /** Records that successfully validated against the schema. */ records: ListRecordItem>[]; }; /** * A discriminated union type representing the result of a record listing * operation. */ export type ListRecordItem = { uri: AtUriString; cid: CidString; valid: true; value: Value; } | { uri: AtUriString; cid: CidString; valid: false; value: LexMap; }; /** * The Client class is the primary interface for interacting with AT Protocol * services. It provides type-safe methods for XRPC calls, record operations, * and blob handling. * * @example * ```typescript * import { Client } from '@atproto/lex' * import { app } from '#/lexicons * * const client = new Client(oauthSession) * * const response = await client.xrpc(app.bsky.feed.getTimeline, { * params: { limit: 50 } * }) * ``` */ export declare class Client { static appLabelers: readonly DidString[]; /** * Configures the Client (or its sub classes) globally. */ static configure(opts: { appLabelers?: Iterable; }): void; /** The underlying agent used for making requests. */ readonly agent: Agent; /** Default header values to include in all requests made by this client instance. */ readonly headers: Headers; /** Default {@link XrpcOptions} for this client instance. */ readonly xrpcDefaults: Readonly<{ service: Service | null; labelers: Set; appLabelers?: null | Iterable; validateRequest: boolean; validateResponse: boolean; strictResponseProcessing: boolean; }>; constructor(agent: Agent | AgentOptions, options?: ClientOptions); /** * The DID of the authenticated user, or `undefined` if not authenticated. */ get did(): DidString | undefined; /** * The DID of the authenticated user. * @throws {Error} if not authenticated */ get assertDid(): DidString; get service(): Service | null; get labelers(): Set; /** * Asserts that the client is authenticated. * Use as a type guard when you need to ensure authentication. * * @throws {Error} if not authenticated * * @example * ```typescript * client.assertAuthenticated() * // TypeScript now knows client.did is defined * console.log(client.did) * ``` */ assertAuthenticated(): asserts this is { did: DidString; }; /** * Replaces all labelers with the given set. * @param labelers - Iterable of labeler DIDs */ setLabelers(labelers?: Iterable): void; /** * Adds labelers to the current set. * @param labelers - Iterable of labeler DIDs to add */ addLabelers(labelers: Iterable): void; /** * Removes all labelers from this client instance. */ clearLabelers(): void; /** * Makes an XRPC request. Throws on failure. * * @param ns - The lexicon method definition (e.g., `app.bsky.feed.getTimeline`) * @param options - Request options including params and body * @returns The successful XRPC response * @throws {XrpcFailure} when the request fails or returns an error * * @example Query with parameters * ```typescript * const response = await client.xrpc(app.bsky.feed.getTimeline, { * params: { limit: 50, cursor: 'abc123' } * }) * console.log(response.body.feed) * ``` * * @example Procedure with body * ```typescript * const response = await client.xrpc(com.atproto.repo.createRecord, { * body: { * repo: client.assertDid, * collection: 'app.bsky.feed.post', * record: { text: 'Hello!', createdAt: new Date().toISOString() } * } * }) * ``` * * @see {@link xrpcSafe} for a non-throwing variant */ xrpc(ns: NonNullable extends XrpcOptions ? Main : Restricted<'This XRPC method requires an "options" argument'>): Promise>; xrpc(ns: Main, options: XrpcOptions): Promise>; /** * Makes an XRPC request without throwing on failure. * Returns either a successful response or a failure object. * * @param ns - The lexicon method definition * @param options - Request options * @returns Either an XrpcResponse on success or XrpcFailure on failure * * @example * ```typescript * const result = await client.xrpcSafe(app.bsky.actor.getProfile, { * params: { actor: 'alice.bsky.social' } * }) * * if (result.success) { * console.log(result.body.displayName) * } else { * console.error('Failed:', result.error) * } * ``` * * @see {@link xrpc} for a throwing variant */ xrpcSafe(ns: NonNullable extends XrpcOptions ? Main : Restricted<'This XRPC method requires an "options" argument'>): Promise | XrpcFailure>; xrpcSafe(ns: Main, options: XrpcOptions): Promise | XrpcFailure>; protected buildXrpcOptions(options: XrpcOptions): XrpcOptions; /** * Creates a new record in an AT Protocol repository. * * @param record - The record to create, must include an {@link NsidString} `$type` * @param rkey - Optional record key; if omitted, server generates a TID * @param options - Create options including repo, swapCommit, validate * @returns The XRPC response containing the created record's URI and CID * * @example * ```typescript * const response = await client.createRecord( * { $type: 'app.bsky.feed.post', text: 'Hello!', createdAt: new Date().toISOString() }, * undefined, // Let server generate rkey * { validate: true } * ) * console.log(response.body.uri) * ``` * * @see {@link create} for a higher-level typed alternative * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ createRecord(record: TypedLexMap, rkey?: string, { service, labelers, ...options }?: CreateRecordOptions): Promise, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ repo: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-identifier"; }>; collection: import("@atproto/lex-schema").StringSchema<{ readonly format: "nsid"; }>; rkey: import("@atproto/lex-schema").OptionalSchema>; validate: import("@atproto/lex-schema").OptionalSchema; record: import("@atproto/lex-schema").LexMapSchema; swapCommit: import("@atproto/lex-schema").OptionalSchema>; }>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ uri: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-uri"; }>; cid: import("@atproto/lex-schema").StringSchema<{ readonly format: "cid"; }>; commit: import("@atproto/lex-schema").OptionalSchema>>; validationStatus: import("@atproto/lex-schema").OptionalSchema>; }>>, readonly ["InvalidSwap"]>>>; /** * Deletes a record from an AT Protocol repository. * * @param collection - The collection NSID * @param rkey - The record key * @param options - Delete options including repo, swapCommit, swapRecord * * @see {@link delete} for a higher-level typed alternative * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ deleteRecord(collection: NsidString, rkey: string, { service, labelers, ...options }?: DeleteRecordOptions): Promise, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ repo: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-identifier"; }>; collection: import("@atproto/lex-schema").StringSchema<{ readonly format: "nsid"; }>; rkey: import("@atproto/lex-schema").StringSchema<{ readonly format: "record-key"; }>; swapRecord: import("@atproto/lex-schema").OptionalSchema>; swapCommit: import("@atproto/lex-schema").OptionalSchema>; }>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ commit: import("@atproto/lex-schema").OptionalSchema>>; }>>, readonly ["InvalidSwap"]>>>; /** * Retrieves a record from an AT Protocol repository. * * @param collection - The collection NSID * @param rkey - The record key * @param options - Get options including repo * * @see {@link get} for a higher-level typed alternative * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ getRecord(collection: NsidString, rkey: string, { service, labelers, ...options }?: GetRecordOptions): Promise; readonly collection: import("@atproto/lex-schema").StringSchema<{ readonly format: "nsid"; }>; readonly rkey: import("@atproto/lex-schema").StringSchema<{ readonly format: "record-key"; }>; readonly cid: import("@atproto/lex-schema").OptionalSchema>; }>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ uri: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-uri"; }>; cid: import("@atproto/lex-schema").OptionalSchema>; value: import("@atproto/lex-schema").LexMapSchema; }>>, readonly ["RecordNotFound"]>>>; /** * Creates or updates a record in a repository. * * @param record - The record to put, must include an {@link NsidString} `$type` * @param rkey - The record key * @param options - Put options including repo, swapCommit, swapRecord, validate * * @see {@link put} for a higher-level typed alternative * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ putRecord(record: TypedLexMap, rkey: string, { service, labelers, ...options }?: PutRecordOptions): Promise, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ repo: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-identifier"; }>; collection: import("@atproto/lex-schema").StringSchema<{ readonly format: "nsid"; }>; rkey: import("@atproto/lex-schema").StringSchema<{ readonly format: "record-key"; readonly maxLength: 512; }>; validate: import("@atproto/lex-schema").OptionalSchema; record: import("@atproto/lex-schema").LexMapSchema; swapRecord: import("@atproto/lex-schema").OptionalSchema>>; swapCommit: import("@atproto/lex-schema").OptionalSchema>; }>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ uri: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-uri"; }>; cid: import("@atproto/lex-schema").StringSchema<{ readonly format: "cid"; }>; commit: import("@atproto/lex-schema").OptionalSchema>>; validationStatus: import("@atproto/lex-schema").OptionalSchema>; }>>, readonly ["InvalidSwap"]>>>; /** * Lists records in a collection. * * @param nsid - The collection NSID * @param options - List options including repo, limit, cursor, reverse * * @see {@link list} for a higher-level typed alternative * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ listRecords(nsid: NsidString, { service, labelers, ...options }?: ListRecordsOptions): Promise; readonly collection: import("@atproto/lex-schema").StringSchema<{ readonly format: "nsid"; }>; readonly limit: import("@atproto/lex-schema").OptionalSchema>; readonly cursor: import("@atproto/lex-schema").OptionalSchema>; readonly reverse: import("@atproto/lex-schema").OptionalSchema; }>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ cursor: import("@atproto/lex-schema").OptionalSchema>; records: import("@atproto/lex-schema").ArraySchema>>; }>>, undefined>>>; /** * Performs an atomic batch of create, update, and delete operations on records in a repository. * * @param builder - A function that receives an {@link ApplyWritesOperations} instance to build the operations * @param options - ApplyWrites options including repo, validate, swapCommit * @returns The XRPC response from the applyWrites call * * @example * ```typescript * const response = await client.applyWrites((op) => [ * op.create(app.bsky.feed.post, { text: 'Hello!' }), * op.update(app.bsky.feed.post, { text: 'Updated text' }, { rkey: 'post123' }), * op.delete(app.bsky.feed.post, 'post456'), * op.update(app.bsky.actor.profile, { displayName: 'Alice' }), * ], { * validate: true, * }) * * for (const result of response.body.results) { * console.log(result.uri) * } * ``` * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ applyWrites(factory: WriteOperationsFactory, { service, labelers, ...options }?: ApplyWritesOptions): Promise, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ repo: import("@atproto/lex-schema").StringSchema<{ readonly format: "at-identifier"; }>; validate: import("@atproto/lex-schema").OptionalSchema; writes: import("@atproto/lex-schema").ArraySchema>, import("@atproto/lex-schema").TypedRefSchema>, import("@atproto/lex-schema").TypedRefSchema>], true>>; swapCommit: import("@atproto/lex-schema").OptionalSchema>; }>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ commit: import("@atproto/lex-schema").OptionalSchema>>; results: import("@atproto/lex-schema").OptionalSchema>, import("@atproto/lex-schema").TypedRefSchema>, import("@atproto/lex-schema").TypedRefSchema>], true>>>; }>>, readonly ["InvalidSwap"]>>>; /** * Uploads a blob to an AT Protocol repository. * * @param body - The blob data (Uint8Array, ReadableStream, Blob, etc.) * @param options - Upload options including encoding hint * @returns Response containing the blob reference * * @example * ```typescript * const imageData = await fetch('image.png').then(r => r.arrayBuffer()) * const response = await client.uploadBlob(new Uint8Array(imageData), { * encoding: 'image/png' * }) * console.log(response.body.blob) // Use this ref in records * ``` * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ uploadBlob(body: BinaryBodyInit, { service, labelers, ...options }?: UploadBlobOptions): Promise, import("@atproto/lex-schema").Payload<"*/*", undefined>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{ blob: import("@atproto/lex-schema").BlobSchema<{}>; }>>, undefined>>>; /** * Retrieves a blob by DID and CID. * * @param did - The DID of the repository containing the blob * @param cid - The CID of the blob * @param options - Call options * * @note This method will ignore the `service` and `labelers` instance wide * defaults, and will always use `null` unless explicitly overridden in the * options. */ getBlob(did: DidString, cid: CidString, { service, labelers, ...options }?: GetBlobOptions): Promise; readonly cid: import("@atproto/lex-schema").StringSchema<{ readonly format: "cid"; }>; }>, import("@atproto/lex-schema").Payload<"*/*", undefined>, readonly ["BlobNotFound", "RepoNotFound", "RepoTakendown", "RepoSuspended", "RepoDeactivated"]>>>; /** * Universal call method for queries, procedures, and custom actions. * Automatically determines the call type based on the lexicon definition. * * @param ns - The lexicon method or action definition * @param arg - The input argument (params for queries, body for procedures, input for actions) * @param options - Call options * @returns The method response body or action output * @see {@link xrpc} if you need access to the full response object * * @example Query * ```typescript * const profile = await client.call(app.bsky.actor.getProfile, { * actor: 'alice.bsky.social' * }) * ``` * * @example Procedure * ```typescript * const result = await client.call(com.atproto.repo.createRecord, { * repo: did, * collection: 'app.bsky.feed.post', * record: { text: 'Hello!' } * }) * ``` * * @example Action * ```typescript * const result = await client.call(updateProfile, (profile) => { * profile.displayName = 'Alice' * }) * ``` */ call(ns: NonNullable extends XrpcRequestParams ? Main : Restricted<'This query type requires a "params" argument'>): Promise>; call(ns: undefined extends InferMethodInputBody ? Main : Restricted<'This procedure type requires an "input" argument'>): Promise>; call(ns: void extends InferActionInput ? Main : Restricted<'This action type requires an "input" argument'>): Promise>; call(ns: Main, arg: T extends Action ? InferActionInput : T extends Procedure ? InferMethodInputBody : T extends Query ? XrpcRequestParams : never, options?: T extends Action ? ActionOptions : T extends Procedure ? Omit, 'body'> : T extends Query ? Omit, 'params'> : never): Promise : T extends Procedure ? XrpcResponseBody : T extends Query ? XrpcResponseBody : never>; /** * Creates a new record with full type safety based on the schema. * * @param ns - The record schema definition * @param input - The record data (without `$type`, which is added automatically) * @param options - Create options including rkey (required for some record types) * @returns The create output including URI and CID * * @example Creating a post * ```typescript * const result = await client.create(app.bsky.feed.post, { * text: 'Hello, world!', * createdAt: new Date().toISOString() * }) * console.log(result.uri) * ``` * * @example Creating a record with explicit rkey * ```typescript * const result = await client.create(app.bsky.actor.profile, { * displayName: 'Alice' * }, { rkey: 'self' }) * ``` * * @see {@link createRecord} for a lower-level method that returns the raw response without schema validation */ create(ns: NonNullable extends CreateOptions ? Main : Restricted<'This record type requires an "options" argument'>, input: Omit, '$type'>): Promise; create(ns: Main, input: Omit, '$type'>, options: CreateOptions): Promise; /** * Deletes a record with type-safe options. * * @param ns - The record schema definition * @param options - Delete options (rkey required for non-literal keys) * @returns The delete output * * @see {@link deleteRecord} for a lower-level method that returns the raw response without schema validation */ delete(ns: NonNullable extends DeleteOptions ? Main : Restricted<'This record type requires an "options" argument'>): Promise; delete(ns: Main, options?: DeleteOptions): Promise; /** * Retrieves a record with type-safe validation. * * @param ns - The record schema definition * @param options - Get options (rkey required for non-literal keys) * @returns The record data validated against the schema * * @example * ```typescript * const profile = await client.get(app.bsky.actor.profile) * // profile.value is typed as app.bsky.actor.profile.Record * console.log(profile.value.displayName) * ``` * * @see {@link getRecord} for a lower-level method that returns the raw record without schema validation */ get(ns: T['key'] extends `literal:${string}` ? Main : Restricted<'This record type requires an "options" argument'>): Promise>; get(ns: Main, options: GetOptions): Promise>; /** * Creates or updates a record with full type safety. * * @param ns - The record schema definition * @param input - The record data * @param options - Put options (rkey required for non-literal keys) * @returns The put output including URI and CID * * @example Creating a new record * ```typescript * const result = await client.put(app.bsky.feed.post, { * text: 'Hello, world!', * createdAt: new Date().toISOString() * }) * console.log(result.uri) * ``` * * @example Updating an existing record with explicit rkey * ```typescript * const result = await client.put(app.bsky.actor.profile, { * displayName: 'Alice' * }, { rkey: 'self' }) * ``` * * @see {@link putRecord} for a lower-level method that returns the raw record without schema validation */ put(ns: NonNullable extends PutOptions ? Main : Restricted<'This record type requires an "options" argument'>, input: Omit, '$type'>): Promise; put(ns: Main, input: Omit, '$type'>, options: PutOptions): Promise; /** * Lists records with type-safe validation and separation of valid/invalid records. * * @param ns - The record schema definition * @param options - List options * @returns Records validated against the schema, with invalid records included as LexMap * * @example * ```typescript * const result = await client.list(app.bsky.feed.post, { limit: 100 }) * for (const record of result.records) { * if (record.valid) { * record.value // Fully typed * } else { * record.value // Invalid record, typed as LexMap * } * } * ``` * * @see {@link listRecords} for a lower-level method that returns the raw records without schema validation */ list(ns: Main, options?: ListOptions): Promise>; /** * Asynchronously iterates over all records in a collection, handling * pagination automatically. * * @param ns - The record schema definition * @param options - List options including limit and cursor * @returns An async generator yielding each record validated against the schema * * @see {@link list} for a method that returns a single page of records * @see {@link listRecords} for a lower-level method that returns raw records without schema validation */ listAll(ns: Main, { maxRetries, ...options }?: ListOptions): AsyncGenerator>, void, unknown>; } //# sourceMappingURL=client.d.ts.map