// Generated TypeScript client for AT Protocol records // Generated at: 2025-10-03 14:17:15 UTC // Lexicons: 2 /** * @example Usage * ```ts * import { AtProtoClient } from "./generated_client.ts"; * * const client = new AtProtoClient( * 'https://api.slices.network', * 'at://did:plc:ovreo3dlfroo4ztkep3kjlle/network.slices.slice/3m25liqjjnh2o' * ); * * // Get records from the run.smallweb.server collection * const records = await client.run.smallweb.server.getRecords(); * * // Get a specific record * const record = await client.run.smallweb.server.getRecord({ * uri: 'at://did:plc:example/run.smallweb.server/3abc123' * }); * * // Get records with filtering and search * const filteredRecords = await client.run.smallweb.server.getRecords({ * where: { * text: { contains: "example search term" } * } * }); * * // Use slice-level methods for cross-collection queries with type safety * const sliceRecords = await client.network.slices.slice.getSliceRecords({ * where: { * collection: { eq: 'run.smallweb.server' } * } * }); * * // Search across multiple collections using union types * const multiCollectionRecords = await client.network.slices.slice.getSliceRecords({ * where: { * collection: { in: ['run.smallweb.server', 'app.bsky.actor.profile'] }, * text: { contains: 'example search term' }, * did: { in: ['did:plc:user1', 'did:plc:user2'] } * }, * limit: 20 * }); * * // Serve the records as JSON * Deno.serve(async () => new Response(JSON.stringify(records.records.map(r => r.value)))); * ``` */ import { type AuthProvider, type BlobRef, type CountRecordsResponse, type GetRecordParams, type GetRecordsResponse, type IndexedRecordFields, type RecordResponse, SlicesClient, type SortField, type WhereCondition, } from "@slices/client"; import type { OAuthClient } from "@slices/oauth"; export interface RunSmallwebServer { /** The DID of the server owner */ owner: string; /** The domain name of the server */ domain: string; /** The timestamp when the server was created */ createdAt: string; } export type RunSmallwebServerSortFields = "owner" | "domain" | "createdAt"; export interface RunSmallwebApp { /** Name of the app */ name: string; /** The server where the app is hosted */ server: string; /** The URL of the app */ url: string; /** The DID of the app owner */ owner: string; /** The timestamp when the app was created */ createdAt: string; } export type RunSmallwebAppSortFields = | "name" | "server" | "url" | "owner" | "createdAt"; class ServerSmallwebRunClient { private readonly client: SlicesClient; constructor(client: SlicesClient) { this.client = client; } async getRecords( params?: { limit?: number; cursor?: string; where?: { [K in RunSmallwebServerSortFields | IndexedRecordFields]?: WhereCondition; }; orWhere?: { [K in RunSmallwebServerSortFields | IndexedRecordFields]?: WhereCondition; }; sortBy?: SortField[]; }, ): Promise> { return await this.client.getRecords("run.smallweb.server", params); } async getRecord( params: GetRecordParams, ): Promise> { return await this.client.getRecord("run.smallweb.server", params); } async countRecords( params?: { limit?: number; cursor?: string; where?: { [K in RunSmallwebServerSortFields | IndexedRecordFields]?: WhereCondition; }; orWhere?: { [K in RunSmallwebServerSortFields | IndexedRecordFields]?: WhereCondition; }; sortBy?: SortField[]; }, ): Promise { return await this.client.countRecords("run.smallweb.server", params); } async createRecord( record: RunSmallwebServer, useSelfRkey?: boolean, ): Promise<{ uri: string; cid: string }> { return await this.client.createRecord( "run.smallweb.server", record, useSelfRkey, ); } async updateRecord( rkey: string, record: RunSmallwebServer, ): Promise<{ uri: string; cid: string }> { return await this.client.updateRecord("run.smallweb.server", rkey, record); } async deleteRecord(rkey: string): Promise { return await this.client.deleteRecord("run.smallweb.server", rkey); } } class AppSmallwebRunClient { private readonly client: SlicesClient; constructor(client: SlicesClient) { this.client = client; } async getRecords( params?: { limit?: number; cursor?: string; where?: { [K in RunSmallwebAppSortFields | IndexedRecordFields]?: WhereCondition; }; orWhere?: { [K in RunSmallwebAppSortFields | IndexedRecordFields]?: WhereCondition; }; sortBy?: SortField[]; }, ): Promise> { return await this.client.getRecords("run.smallweb.app", params); } async getRecord( params: GetRecordParams, ): Promise> { return await this.client.getRecord("run.smallweb.app", params); } async countRecords( params?: { limit?: number; cursor?: string; where?: { [K in RunSmallwebAppSortFields | IndexedRecordFields]?: WhereCondition; }; orWhere?: { [K in RunSmallwebAppSortFields | IndexedRecordFields]?: WhereCondition; }; sortBy?: SortField[]; }, ): Promise { return await this.client.countRecords("run.smallweb.app", params); } async createRecord( record: RunSmallwebApp, useSelfRkey?: boolean, ): Promise<{ uri: string; cid: string }> { return await this.client.createRecord( "run.smallweb.app", record, useSelfRkey, ); } async updateRecord( rkey: string, record: RunSmallwebApp, ): Promise<{ uri: string; cid: string }> { return await this.client.updateRecord("run.smallweb.app", rkey, record); } async deleteRecord(rkey: string): Promise { return await this.client.deleteRecord("run.smallweb.app", rkey); } } class SmallwebRunClient { readonly server: ServerSmallwebRunClient; readonly app: AppSmallwebRunClient; private readonly client: SlicesClient; constructor(client: SlicesClient) { this.client = client; this.server = new ServerSmallwebRunClient(client); this.app = new AppSmallwebRunClient(client); } } class RunClient { readonly smallweb: SmallwebRunClient; private readonly client: SlicesClient; constructor(client: SlicesClient) { this.client = client; this.smallweb = new SmallwebRunClient(client); } } export class AtProtoClient extends SlicesClient { readonly run: RunClient; readonly oauth?: OAuthClient | AuthProvider; constructor( baseUrl: string, sliceUri: string, oauthClient?: OAuthClient | AuthProvider, ) { super(baseUrl, sliceUri, oauthClient); this.run = new RunClient(this); this.oauth = oauthClient; } }