generated_client.ts
edited
1// Generated TypeScript client for AT Protocol records
2// Generated at: 2025-09-23 20:55:55 UTC
3// Lexicons: 3
4
5/**
6 * @example Usage
7 * ```ts
8 * import { AtProtoClient } from "./generated_client.ts";
9 *
10 * const client = new AtProtoClient(
11 * 'https://api.slices.network',
12 * 'at://did:plc:bcgltzqazw5tb6k2g3ttenbj/network.slices.slice/3lzjs5zxpxz2z'
13 * );
14 *
15 * // Get records from the community.lexicon.calendar.rsvp collection
16 * const records = await client.community.lexicon.calendar.rsvp.getRecords();
17 *
18 * // Get a specific record
19 * const record = await client.community.lexicon.calendar.rsvp.getRecord({
20 * uri: 'at://did:plc:example/community.lexicon.calendar.rsvp/3abc123'
21 * });
22 *
23 * // Get records with filtering and search
24 * const filteredRecords = await client.community.lexicon.calendar.rsvp.getRecords({
25 * where: {
26 * text: { contains: "example search term" }
27 * }
28 * });
29 *
30 * // Use slice-level methods for cross-collection queries with type safety
31 * const sliceRecords = await client.network.slices.slice.getSliceRecords<CommunityLexiconCalendarRsvp>({
32 * where: {
33 * collection: { eq: 'community.lexicon.calendar.rsvp' }
34 * }
35 * });
36 *
37 * // Search across multiple collections using union types
38 * const multiCollectionRecords = await client.network.slices.slice.getSliceRecords<CommunityLexiconCalendarRsvp | AppBskyActorProfile>({
39 * where: {
40 * collection: { in: ['community.lexicon.calendar.rsvp', 'app.bsky.actor.profile'] },
41 * text: { contains: 'example search term' },
42 * did: { in: ['did:plc:user1', 'did:plc:user2'] }
43 * },
44 * limit: 20
45 * });
46 *
47 * // Serve the records as JSON
48 * Deno.serve(async () => new Response(JSON.stringify(records.records.map(r => r.value))));
49 * ```
50 */
51
52import {
53 type BlobRef,
54 type CountRecordsResponse,
55 type GetRecordParams,
56 type GetRecordsResponse,
57 type IndexedRecordFields,
58 type RecordResponse,
59 SlicesClient,
60 type SortField,
61 type WhereCondition,
62} from "@slices/client";
63import { OAuthClient } from "@slices/oauth";
64
65export type CommunityLexiconCalendarRsvpStatus =
66 | "community.lexicon.calendar.rsvp#interested"
67 | "community.lexicon.calendar.rsvp#going"
68 | "community.lexicon.calendar.rsvp#notgoing"
69 | (string & {});
70
71export type CommunityLexiconCalendarEventMode =
72 | "community.lexicon.calendar.event#hybrid"
73 | "community.lexicon.calendar.event#inperson"
74 | "community.lexicon.calendar.event#virtual"
75 | (string & {});
76
77export type CommunityLexiconCalendarEventStatus =
78 | "community.lexicon.calendar.event#cancelled"
79 | "community.lexicon.calendar.event#planned"
80 | "community.lexicon.calendar.event#postponed"
81 | "community.lexicon.calendar.event#rescheduled"
82 | "community.lexicon.calendar.event#scheduled"
83 | (string & {});
84
85export interface ComAtprotoRepoStrongRef {
86 uri: string;
87 cid: string;
88}
89
90export interface CommunityLexiconCalendarRsvp {
91 subject: ComAtprotoRepoStrongRef;
92 status: CommunityLexiconCalendarRsvpStatus;
93}
94
95export type CommunityLexiconCalendarRsvpSortFields = "status";
96export type CommunityLexiconCalendarRsvpInterested =
97 "community.lexicon.calendar.rsvp#interested";
98export type CommunityLexiconCalendarRsvpGoing =
99 "community.lexicon.calendar.rsvp#going";
100export type CommunityLexiconCalendarRsvpNotgoing =
101 "community.lexicon.calendar.rsvp#notgoing";
102
103export interface CommunityLexiconCalendarEvent {
104 /** The name of the event. */
105 name: string;
106 /** The description of the event. */
107 description?: string;
108 /** Client-declared timestamp when the event was created. */
109 createdAt: string;
110 /** Client-declared timestamp when the event starts. */
111 startsAt?: string;
112 /** Client-declared timestamp when the event ends. */
113 endsAt?: string;
114 /** The attendance mode of the event. */
115 mode?: CommunityLexiconCalendarEvent["Mode"];
116 /** The status of the event. */
117 status?: CommunityLexiconCalendarEvent["Status"];
118 /** The locations where the event takes place. */
119 locations?:
120 | CommunityLexiconCalendarEvent["Uri"]
121 | CommunityLexiconLocationAddress
122 | CommunityLexiconLocationFsq
123 | CommunityLexiconLocationGeo
124 | CommunityLexiconLocationHthree
125 | { $type: string; [key: string]: unknown }[];
126 /** URIs associated with the event. */
127 uris?: CommunityLexiconCalendarEvent["Uri"][];
128}
129
130export type CommunityLexiconCalendarEventSortFields =
131 | "name"
132 | "description"
133 | "createdAt"
134 | "startsAt"
135 | "endsAt";
136export type CommunityLexiconCalendarEventVirtual =
137 "community.lexicon.calendar.event#virtual";
138export type CommunityLexiconCalendarEventInperson =
139 "community.lexicon.calendar.event#inperson";
140export type CommunityLexiconCalendarEventHybrid =
141 "community.lexicon.calendar.event#hybrid";
142export type CommunityLexiconCalendarEventPlanned =
143 "community.lexicon.calendar.event#planned";
144export type CommunityLexiconCalendarEventScheduled =
145 "community.lexicon.calendar.event#scheduled";
146export type CommunityLexiconCalendarEventRescheduled =
147 "community.lexicon.calendar.event#rescheduled";
148export type CommunityLexiconCalendarEventCancelled =
149 "community.lexicon.calendar.event#cancelled";
150export type CommunityLexiconCalendarEventPostponed =
151 "community.lexicon.calendar.event#postponed";
152
153export interface CommunityLexiconCalendarEventUri {
154 uri: string;
155 /** The display name of the URI. */
156 name?: string;
157}
158
159export interface CommunityLexiconCalendarRsvp {
160 readonly Main: CommunityLexiconCalendarRsvp;
161 readonly Interested: CommunityLexiconCalendarRsvpInterested;
162 readonly Going: CommunityLexiconCalendarRsvpGoing;
163 readonly Notgoing: CommunityLexiconCalendarRsvpNotgoing;
164}
165
166export interface CommunityLexiconCalendarEvent {
167 readonly Main: CommunityLexiconCalendarEvent;
168 readonly Mode: CommunityLexiconCalendarEventMode;
169 readonly Virtual: CommunityLexiconCalendarEventVirtual;
170 readonly Inperson: CommunityLexiconCalendarEventInperson;
171 readonly Hybrid: CommunityLexiconCalendarEventHybrid;
172 readonly Status: CommunityLexiconCalendarEventStatus;
173 readonly Planned: CommunityLexiconCalendarEventPlanned;
174 readonly Scheduled: CommunityLexiconCalendarEventScheduled;
175 readonly Rescheduled: CommunityLexiconCalendarEventRescheduled;
176 readonly Cancelled: CommunityLexiconCalendarEventCancelled;
177 readonly Postponed: CommunityLexiconCalendarEventPostponed;
178 readonly Uri: CommunityLexiconCalendarEventUri;
179}
180
181class RsvpCalendarLexiconCommunityClient {
182 private readonly client: SlicesClient;
183
184 constructor(client: SlicesClient) {
185 this.client = client;
186 }
187
188 async getRecords(
189 params?: {
190 limit?: number;
191 cursor?: string;
192 where?: {
193 [K in CommunityLexiconCalendarRsvpSortFields | IndexedRecordFields]?:
194 WhereCondition;
195 };
196 orWhere?: {
197 [K in CommunityLexiconCalendarRsvpSortFields | IndexedRecordFields]?:
198 WhereCondition;
199 };
200 sortBy?: SortField<CommunityLexiconCalendarRsvpSortFields>[];
201 },
202 ): Promise<GetRecordsResponse<CommunityLexiconCalendarRsvp>> {
203 return await this.client.getRecords(
204 "community.lexicon.calendar.rsvp",
205 params,
206 );
207 }
208
209 async getRecord(
210 params: GetRecordParams,
211 ): Promise<RecordResponse<CommunityLexiconCalendarRsvp>> {
212 return await this.client.getRecord(
213 "community.lexicon.calendar.rsvp",
214 params,
215 );
216 }
217
218 async countRecords(
219 params?: {
220 limit?: number;
221 cursor?: string;
222 where?: {
223 [K in CommunityLexiconCalendarRsvpSortFields | IndexedRecordFields]?:
224 WhereCondition;
225 };
226 orWhere?: {
227 [K in CommunityLexiconCalendarRsvpSortFields | IndexedRecordFields]?:
228 WhereCondition;
229 };
230 sortBy?: SortField<CommunityLexiconCalendarRsvpSortFields>[];
231 },
232 ): Promise<CountRecordsResponse> {
233 return await this.client.countRecords(
234 "community.lexicon.calendar.rsvp",
235 params,
236 );
237 }
238
239 async createRecord(
240 record: CommunityLexiconCalendarRsvp,
241 useSelfRkey?: boolean,
242 ): Promise<{ uri: string; cid: string }> {
243 return await this.client.createRecord(
244 "community.lexicon.calendar.rsvp",
245 record,
246 useSelfRkey,
247 );
248 }
249
250 async updateRecord(
251 rkey: string,
252 record: CommunityLexiconCalendarRsvp,
253 ): Promise<{ uri: string; cid: string }> {
254 return await this.client.updateRecord(
255 "community.lexicon.calendar.rsvp",
256 rkey,
257 record,
258 );
259 }
260
261 async deleteRecord(rkey: string): Promise<void> {
262 return await this.client.deleteRecord(
263 "community.lexicon.calendar.rsvp",
264 rkey,
265 );
266 }
267}
268
269class EventCalendarLexiconCommunityClient {
270 private readonly client: SlicesClient;
271
272 constructor(client: SlicesClient) {
273 this.client = client;
274 }
275
276 async getRecords(
277 params?: {
278 limit?: number;
279 cursor?: string;
280 where?: {
281 [K in CommunityLexiconCalendarEventSortFields | IndexedRecordFields]?:
282 WhereCondition;
283 };
284 orWhere?: {
285 [K in CommunityLexiconCalendarEventSortFields | IndexedRecordFields]?:
286 WhereCondition;
287 };
288 sortBy?: SortField<CommunityLexiconCalendarEventSortFields>[];
289 },
290 ): Promise<GetRecordsResponse<CommunityLexiconCalendarEvent>> {
291 return await this.client.getRecords(
292 "community.lexicon.calendar.event",
293 params,
294 );
295 }
296
297 async getRecord(
298 params: GetRecordParams,
299 ): Promise<RecordResponse<CommunityLexiconCalendarEvent>> {
300 return await this.client.getRecord(
301 "community.lexicon.calendar.event",
302 params,
303 );
304 }
305
306 async countRecords(
307 params?: {
308 limit?: number;
309 cursor?: string;
310 where?: {
311 [K in CommunityLexiconCalendarEventSortFields | IndexedRecordFields]?:
312 WhereCondition;
313 };
314 orWhere?: {
315 [K in CommunityLexiconCalendarEventSortFields | IndexedRecordFields]?:
316 WhereCondition;
317 };
318 sortBy?: SortField<CommunityLexiconCalendarEventSortFields>[];
319 },
320 ): Promise<CountRecordsResponse> {
321 return await this.client.countRecords(
322 "community.lexicon.calendar.event",
323 params,
324 );
325 }
326
327 async createRecord(
328 record: CommunityLexiconCalendarEvent,
329 useSelfRkey?: boolean,
330 ): Promise<{ uri: string; cid: string }> {
331 return await this.client.createRecord(
332 "community.lexicon.calendar.event",
333 record,
334 useSelfRkey,
335 );
336 }
337
338 async updateRecord(
339 rkey: string,
340 record: CommunityLexiconCalendarEvent,
341 ): Promise<{ uri: string; cid: string }> {
342 return await this.client.updateRecord(
343 "community.lexicon.calendar.event",
344 rkey,
345 record,
346 );
347 }
348
349 async deleteRecord(rkey: string): Promise<void> {
350 return await this.client.deleteRecord(
351 "community.lexicon.calendar.event",
352 rkey,
353 );
354 }
355}
356
357class CalendarLexiconCommunityClient {
358 readonly rsvp: RsvpCalendarLexiconCommunityClient;
359 readonly event: EventCalendarLexiconCommunityClient;
360 private readonly client: SlicesClient;
361
362 constructor(client: SlicesClient) {
363 this.client = client;
364 this.rsvp = new RsvpCalendarLexiconCommunityClient(client);
365 this.event = new EventCalendarLexiconCommunityClient(client);
366 }
367}
368
369class LexiconCommunityClient {
370 readonly calendar: CalendarLexiconCommunityClient;
371 private readonly client: SlicesClient;
372
373 constructor(client: SlicesClient) {
374 this.client = client;
375 this.calendar = new CalendarLexiconCommunityClient(client);
376 }
377}
378
379class CommunityClient {
380 readonly lexicon: LexiconCommunityClient;
381 private readonly client: SlicesClient;
382
383 constructor(client: SlicesClient) {
384 this.client = client;
385 this.lexicon = new LexiconCommunityClient(client);
386 }
387}
388
389export class AtProtoClient extends SlicesClient {
390 readonly community: CommunityClient;
391 readonly oauth?: OAuthClient;
392
393 constructor(baseUrl: string, sliceUri: string, oauthClient?: OAuthClient) {
394 super(baseUrl, sliceUri, oauthClient);
395 this.community = new CommunityClient(this);
396 this.oauth = oauthClient;
397 }
398}