Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
smallweb-slice client.ts
7.3 kB · 272 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273// 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<RunSmallwebServer>({ * where: { * collection: { eq: 'run.smallweb.server' } * } * }); * * // Search across multiple collections using union types * const multiCollectionRecords = await client.network.slices.slice.getSliceRecords<RunSmallwebServer | AppBskyActorProfile>({ * 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<RunSmallwebServerSortFields>[]; }, ): Promise<GetRecordsResponse<RunSmallwebServer>> { return await this.client.getRecords("run.smallweb.server", params); }
async getRecord( params: GetRecordParams, ): Promise<RecordResponse<RunSmallwebServer>> { 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<RunSmallwebServerSortFields>[]; }, ): Promise<CountRecordsResponse> { 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<void> { 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<RunSmallwebAppSortFields>[]; }, ): Promise<GetRecordsResponse<RunSmallwebApp>> { return await this.client.getRecords("run.smallweb.app", params); }
async getRecord( params: GetRecordParams, ): Promise<RecordResponse<RunSmallwebApp>> { 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<RunSmallwebAppSortFields>[]; }, ): Promise<CountRecordsResponse> { 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<void> { 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; }}