import { n as Did } from "../types-DNGNVV4Q.js"; import { FetchHandler, FetchHandlerObject } from "@atcute/client"; import { RegistryRecordCollection, RegistryRecords } from "@emdash-cms/registry-lexicons"; import { Nsid } from "@atcute/lexicons"; //#region src/publishing/index.d.ts /** * Options accepted by `PublishingClient.fromHandler`. */ interface PublishingClientFromHandlerOptions { /** * The atproto fetch handler. Typically this is the handler returned by an * authenticated `@atcute/oauth-node-client` session. */ handler: FetchHandler | FetchHandlerObject; /** Publisher DID. The repo we operate on. */ did: Did; /** * PDS endpoint. Used informationally (e.g. logging "publishing to "); * the actual routing comes from the handler. */ pds: string; } /** * Single create operation in an `applyWrites` batch. */ interface PublishCreate { op: "create"; collection: C; rkey: string; record: RegistryRecords[C]; } /** * Single update operation in an `applyWrites` batch. */ interface PublishUpdate { op: "update"; collection: C; rkey: string; record: RegistryRecords[C]; } /** * Single delete operation in an `applyWrites` batch. */ interface PublishDelete { op: "delete"; collection: Nsid; rkey: string; } type PublishOperation = PublishCreate | PublishUpdate | PublishDelete; interface ApplyWritesResult { /** Per-operation results, in input order. */ results: Array<{ op: "create"; uri: string; cid: string; } | { op: "update"; uri: string; cid: string; } | { op: "delete"; }>; } /** * High-level operations against a publisher's atproto repo, scoped to the * registry's NSIDs. * * All methods are stateless: they do not cache, retry, or batch. Callers * wanting those behaviours should layer them on top. */ declare class PublishingClient { #private; readonly did: Did; readonly pds: string; private constructor(); /** * Build a publishing client from a pre-authenticated atproto fetch handler. * This is the preferred constructor: the CLI builds the handler via OAuth * and hands it in. */ static fromHandler(options: PublishingClientFromHandlerOptions): PublishingClient; /** * Put a typed registry record into the publisher's repo. The record's TS * shape is derived from the collection NSID so callers can't put a * profile-shaped record into a release collection (or vice versa). * * Defaults to `validate: true` -- the PDS will reject records that don't * match the lexicon for the collection. The `unsafePutRecord` escape hatch * exists for when you really need to bypass. */ putRecord(input: { collection: C; rkey: string; record: RegistryRecords[C]; /** * Skip lexicon validation server-side. Defaults to `false` (validation * is on). Setting `true` is almost always wrong; only do it when you * deliberately want to publish a record the PDS doesn't yet know how to * validate (e.g. during a lexicon migration window). */ skipValidation?: boolean; /** * Optimistic-concurrency precondition. When set, the write fails with * `InvalidSwap` if the record's current CID doesn't match. Use the * `cid` returned from a prior `getRecord` to ensure a read-then-write * flow doesn't silently overwrite a concurrent edit. */ swapRecord?: string; }): Promise<{ uri: string; cid: string; }>; /** * Untyped escape hatch for putting any record into any collection. Bypasses * the `RegistryRecords` map type-check; lexicon validation server-side is * still on by default. Use this only when you really must (e.g. tools that * deal in opaque records like `com.atproto.*`). */ unsafePutRecord(input: { collection: Nsid; rkey: string; record: Record; skipValidation?: boolean; /** * Optimistic-concurrency precondition. See `putRecord`. */ swapRecord?: string; }): Promise<{ uri: string; cid: string; }>; /** * Apply a batch of create/update/delete operations atomically against the * publisher's repo. Either every operation succeeds (single commit, single * firehose event) or none do. * * Used by the publish flow to bootstrap a profile and put a release in a * single round-trip, so a network blip between the two writes can't leave * a half-published state. * * Defaults to `validate: true`. Pass `skipValidation: true` to opt out; * see `putRecord` for the rationale. */ applyWrites(input: { writes: PublishOperation[]; skipValidation?: boolean; /** * If supplied, the operation aborts unless the publisher repo's current * commit matches this CID. Use to detect concurrent writers. */ swapCommit?: string; }): Promise; /** * Fetch a record from the publisher's repo by NSID and rkey. */ getRecord(input: { collection: Nsid; rkey: string; }): Promise<{ uri: string; cid: string; value: unknown; }>; /** * List records in a collection. Returns up to `limit` records and an * optional cursor for pagination. */ listRecords(input: { collection: Nsid; limit?: number; cursor?: string; reverse?: boolean; }): Promise<{ records: Array<{ uri: string; cid: string; value: unknown; }>; cursor?: string; }>; } //#endregion export { ApplyWritesResult, PublishCreate, PublishDelete, PublishOperation, PublishUpdate, PublishingClient, PublishingClientFromHandlerOptions }; //# sourceMappingURL=index.d.ts.map