forked from
samuel.fm/statusphere-react
the statusphere demo reworked into a vite/react app in a monorepo
1/**
2 * GENERATED CODE - DO NOT MODIFY
3 */
4import { FetchHandler, FetchHandlerOptions, XrpcClient } from '@atproto/xrpc'
5import { CID } from 'multiformats/cid'
6
7import { schemas } from './lexicons.js'
8import * as AppBskyActorDefs from './types/app/bsky/actor/defs.js'
9import * as AppBskyActorProfile from './types/app/bsky/actor/profile.js'
10import * as ComAtprotoLabelDefs from './types/com/atproto/label/defs.js'
11import * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites.js'
12import * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js'
13import * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs.js'
14import * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord.js'
15import * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo.js'
16import * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord.js'
17import * as ComAtprotoRepoImportRepo from './types/com/atproto/repo/importRepo.js'
18import * as ComAtprotoRepoListMissingBlobs from './types/com/atproto/repo/listMissingBlobs.js'
19import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords.js'
20import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord.js'
21import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef.js'
22import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob.js'
23import * as XyzStatusphereDefs from './types/xyz/statusphere/defs.js'
24import * as XyzStatusphereGetStatuses from './types/xyz/statusphere/getStatuses.js'
25import * as XyzStatusphereGetUser from './types/xyz/statusphere/getUser.js'
26import * as XyzStatusphereSendStatus from './types/xyz/statusphere/sendStatus.js'
27import * as XyzStatusphereStatus from './types/xyz/statusphere/status.js'
28import { OmitKey, Un$Typed } from './util.js'
29
30export * as XyzStatusphereDefs from './types/xyz/statusphere/defs.js'
31export * as XyzStatusphereGetStatuses from './types/xyz/statusphere/getStatuses.js'
32export * as XyzStatusphereGetUser from './types/xyz/statusphere/getUser.js'
33export * as XyzStatusphereSendStatus from './types/xyz/statusphere/sendStatus.js'
34export * as XyzStatusphereStatus from './types/xyz/statusphere/status.js'
35export * as ComAtprotoLabelDefs from './types/com/atproto/label/defs.js'
36export * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites.js'
37export * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js'
38export * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs.js'
39export * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord.js'
40export * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo.js'
41export * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord.js'
42export * as ComAtprotoRepoImportRepo from './types/com/atproto/repo/importRepo.js'
43export * as ComAtprotoRepoListMissingBlobs from './types/com/atproto/repo/listMissingBlobs.js'
44export * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords.js'
45export * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord.js'
46export * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef.js'
47export * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob.js'
48export * as AppBskyActorDefs from './types/app/bsky/actor/defs.js'
49export * as AppBskyActorProfile from './types/app/bsky/actor/profile.js'
50
51export class AtpBaseClient extends XrpcClient {
52 xyz: XyzNS
53 com: ComNS
54 app: AppNS
55
56 constructor(options: FetchHandler | FetchHandlerOptions) {
57 super(options, schemas)
58 this.xyz = new XyzNS(this)
59 this.com = new ComNS(this)
60 this.app = new AppNS(this)
61 }
62
63 /** @deprecated use `this` instead */
64 get xrpc(): XrpcClient {
65 return this
66 }
67}
68
69export class XyzNS {
70 _client: XrpcClient
71 statusphere: XyzStatusphereNS
72
73 constructor(client: XrpcClient) {
74 this._client = client
75 this.statusphere = new XyzStatusphereNS(client)
76 }
77}
78
79export class XyzStatusphereNS {
80 _client: XrpcClient
81 status: StatusRecord
82
83 constructor(client: XrpcClient) {
84 this._client = client
85 this.status = new StatusRecord(client)
86 }
87
88 getStatuses(
89 params?: XyzStatusphereGetStatuses.QueryParams,
90 opts?: XyzStatusphereGetStatuses.CallOptions,
91 ): Promise<XyzStatusphereGetStatuses.Response> {
92 return this._client.call(
93 'xyz.statusphere.getStatuses',
94 params,
95 undefined,
96 opts,
97 )
98 }
99
100 getUser(
101 params?: XyzStatusphereGetUser.QueryParams,
102 opts?: XyzStatusphereGetUser.CallOptions,
103 ): Promise<XyzStatusphereGetUser.Response> {
104 return this._client.call('xyz.statusphere.getUser', params, undefined, opts)
105 }
106
107 sendStatus(
108 data?: XyzStatusphereSendStatus.InputSchema,
109 opts?: XyzStatusphereSendStatus.CallOptions,
110 ): Promise<XyzStatusphereSendStatus.Response> {
111 return this._client.call('xyz.statusphere.sendStatus', opts?.qp, data, opts)
112 }
113}
114
115export class StatusRecord {
116 _client: XrpcClient
117
118 constructor(client: XrpcClient) {
119 this._client = client
120 }
121
122 async list(
123 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
124 ): Promise<{
125 cursor?: string
126 records: { uri: string; value: XyzStatusphereStatus.Record }[]
127 }> {
128 const res = await this._client.call('com.atproto.repo.listRecords', {
129 collection: 'xyz.statusphere.status',
130 ...params,
131 })
132 return res.data
133 }
134
135 async get(
136 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
137 ): Promise<{ uri: string; cid: string; value: XyzStatusphereStatus.Record }> {
138 const res = await this._client.call('com.atproto.repo.getRecord', {
139 collection: 'xyz.statusphere.status',
140 ...params,
141 })
142 return res.data
143 }
144
145 async create(
146 params: OmitKey<
147 ComAtprotoRepoCreateRecord.InputSchema,
148 'collection' | 'record'
149 >,
150 record: Un$Typed<XyzStatusphereStatus.Record>,
151 headers?: Record<string, string>,
152 ): Promise<{ uri: string; cid: string }> {
153 const collection = 'xyz.statusphere.status'
154 const res = await this._client.call(
155 'com.atproto.repo.createRecord',
156 undefined,
157 { collection, ...params, record: { ...record, $type: collection } },
158 { encoding: 'application/json', headers },
159 )
160 return res.data
161 }
162
163 async delete(
164 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
165 headers?: Record<string, string>,
166 ): Promise<void> {
167 await this._client.call(
168 'com.atproto.repo.deleteRecord',
169 undefined,
170 { collection: 'xyz.statusphere.status', ...params },
171 { headers },
172 )
173 }
174}
175
176export class ComNS {
177 _client: XrpcClient
178 atproto: ComAtprotoNS
179
180 constructor(client: XrpcClient) {
181 this._client = client
182 this.atproto = new ComAtprotoNS(client)
183 }
184}
185
186export class ComAtprotoNS {
187 _client: XrpcClient
188 repo: ComAtprotoRepoNS
189
190 constructor(client: XrpcClient) {
191 this._client = client
192 this.repo = new ComAtprotoRepoNS(client)
193 }
194}
195
196export class ComAtprotoRepoNS {
197 _client: XrpcClient
198
199 constructor(client: XrpcClient) {
200 this._client = client
201 }
202
203 applyWrites(
204 data?: ComAtprotoRepoApplyWrites.InputSchema,
205 opts?: ComAtprotoRepoApplyWrites.CallOptions,
206 ): Promise<ComAtprotoRepoApplyWrites.Response> {
207 return this._client
208 .call('com.atproto.repo.applyWrites', opts?.qp, data, opts)
209 .catch((e) => {
210 throw ComAtprotoRepoApplyWrites.toKnownErr(e)
211 })
212 }
213
214 createRecord(
215 data?: ComAtprotoRepoCreateRecord.InputSchema,
216 opts?: ComAtprotoRepoCreateRecord.CallOptions,
217 ): Promise<ComAtprotoRepoCreateRecord.Response> {
218 return this._client
219 .call('com.atproto.repo.createRecord', opts?.qp, data, opts)
220 .catch((e) => {
221 throw ComAtprotoRepoCreateRecord.toKnownErr(e)
222 })
223 }
224
225 deleteRecord(
226 data?: ComAtprotoRepoDeleteRecord.InputSchema,
227 opts?: ComAtprotoRepoDeleteRecord.CallOptions,
228 ): Promise<ComAtprotoRepoDeleteRecord.Response> {
229 return this._client
230 .call('com.atproto.repo.deleteRecord', opts?.qp, data, opts)
231 .catch((e) => {
232 throw ComAtprotoRepoDeleteRecord.toKnownErr(e)
233 })
234 }
235
236 describeRepo(
237 params?: ComAtprotoRepoDescribeRepo.QueryParams,
238 opts?: ComAtprotoRepoDescribeRepo.CallOptions,
239 ): Promise<ComAtprotoRepoDescribeRepo.Response> {
240 return this._client.call(
241 'com.atproto.repo.describeRepo',
242 params,
243 undefined,
244 opts,
245 )
246 }
247
248 getRecord(
249 params?: ComAtprotoRepoGetRecord.QueryParams,
250 opts?: ComAtprotoRepoGetRecord.CallOptions,
251 ): Promise<ComAtprotoRepoGetRecord.Response> {
252 return this._client
253 .call('com.atproto.repo.getRecord', params, undefined, opts)
254 .catch((e) => {
255 throw ComAtprotoRepoGetRecord.toKnownErr(e)
256 })
257 }
258
259 importRepo(
260 data?: ComAtprotoRepoImportRepo.InputSchema,
261 opts?: ComAtprotoRepoImportRepo.CallOptions,
262 ): Promise<ComAtprotoRepoImportRepo.Response> {
263 return this._client.call(
264 'com.atproto.repo.importRepo',
265 opts?.qp,
266 data,
267 opts,
268 )
269 }
270
271 listMissingBlobs(
272 params?: ComAtprotoRepoListMissingBlobs.QueryParams,
273 opts?: ComAtprotoRepoListMissingBlobs.CallOptions,
274 ): Promise<ComAtprotoRepoListMissingBlobs.Response> {
275 return this._client.call(
276 'com.atproto.repo.listMissingBlobs',
277 params,
278 undefined,
279 opts,
280 )
281 }
282
283 listRecords(
284 params?: ComAtprotoRepoListRecords.QueryParams,
285 opts?: ComAtprotoRepoListRecords.CallOptions,
286 ): Promise<ComAtprotoRepoListRecords.Response> {
287 return this._client.call(
288 'com.atproto.repo.listRecords',
289 params,
290 undefined,
291 opts,
292 )
293 }
294
295 putRecord(
296 data?: ComAtprotoRepoPutRecord.InputSchema,
297 opts?: ComAtprotoRepoPutRecord.CallOptions,
298 ): Promise<ComAtprotoRepoPutRecord.Response> {
299 return this._client
300 .call('com.atproto.repo.putRecord', opts?.qp, data, opts)
301 .catch((e) => {
302 throw ComAtprotoRepoPutRecord.toKnownErr(e)
303 })
304 }
305
306 uploadBlob(
307 data?: ComAtprotoRepoUploadBlob.InputSchema,
308 opts?: ComAtprotoRepoUploadBlob.CallOptions,
309 ): Promise<ComAtprotoRepoUploadBlob.Response> {
310 return this._client.call(
311 'com.atproto.repo.uploadBlob',
312 opts?.qp,
313 data,
314 opts,
315 )
316 }
317}
318
319export class AppNS {
320 _client: XrpcClient
321 bsky: AppBskyNS
322
323 constructor(client: XrpcClient) {
324 this._client = client
325 this.bsky = new AppBskyNS(client)
326 }
327}
328
329export class AppBskyNS {
330 _client: XrpcClient
331 actor: AppBskyActorNS
332
333 constructor(client: XrpcClient) {
334 this._client = client
335 this.actor = new AppBskyActorNS(client)
336 }
337}
338
339export class AppBskyActorNS {
340 _client: XrpcClient
341 profile: ProfileRecord
342
343 constructor(client: XrpcClient) {
344 this._client = client
345 this.profile = new ProfileRecord(client)
346 }
347}
348
349export class ProfileRecord {
350 _client: XrpcClient
351
352 constructor(client: XrpcClient) {
353 this._client = client
354 }
355
356 async list(
357 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
358 ): Promise<{
359 cursor?: string
360 records: { uri: string; value: AppBskyActorProfile.Record }[]
361 }> {
362 const res = await this._client.call('com.atproto.repo.listRecords', {
363 collection: 'app.bsky.actor.profile',
364 ...params,
365 })
366 return res.data
367 }
368
369 async get(
370 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
371 ): Promise<{ uri: string; cid: string; value: AppBskyActorProfile.Record }> {
372 const res = await this._client.call('com.atproto.repo.getRecord', {
373 collection: 'app.bsky.actor.profile',
374 ...params,
375 })
376 return res.data
377 }
378
379 async create(
380 params: OmitKey<
381 ComAtprotoRepoCreateRecord.InputSchema,
382 'collection' | 'record'
383 >,
384 record: Un$Typed<AppBskyActorProfile.Record>,
385 headers?: Record<string, string>,
386 ): Promise<{ uri: string; cid: string }> {
387 const collection = 'app.bsky.actor.profile'
388 const res = await this._client.call(
389 'com.atproto.repo.createRecord',
390 undefined,
391 {
392 collection,
393 rkey: 'self',
394 ...params,
395 record: { ...record, $type: collection },
396 },
397 { encoding: 'application/json', headers },
398 )
399 return res.data
400 }
401
402 async delete(
403 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
404 headers?: Record<string, string>,
405 ): Promise<void> {
406 await this._client.call(
407 'com.atproto.repo.deleteRecord',
408 undefined,
409 { collection: 'app.bsky.actor.profile', ...params },
410 { headers },
411 )
412 }
413}