a tool for shared writing and social publishing
1/**
2 * GENERATED CODE - DO NOT MODIFY
3 */
4import {
5 XrpcClient,
6 type FetchHandler,
7 type FetchHandlerOptions,
8} from '@atproto/xrpc'
9import { schemas } from './lexicons'
10import { CID } from 'multiformats/cid'
11import { type OmitKey, type Un$Typed } from './util'
12import * as AppBskyActorProfile from './types/app/bsky/actor/profile'
13import * as ComAtprotoLabelDefs from './types/com/atproto/label/defs'
14import * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites'
15import * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord'
16import * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs'
17import * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord'
18import * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo'
19import * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord'
20import * as ComAtprotoRepoImportRepo from './types/com/atproto/repo/importRepo'
21import * as ComAtprotoRepoListMissingBlobs from './types/com/atproto/repo/listMissingBlobs'
22import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords'
23import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
24import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
25import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
26import * as PubLeafletBlocksBlockquote from './types/pub/leaflet/blocks/blockquote'
27import * as PubLeafletBlocksBskyPost from './types/pub/leaflet/blocks/bskyPost'
28import * as PubLeafletBlocksCode from './types/pub/leaflet/blocks/code'
29import * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header'
30import * as PubLeafletBlocksHorizontalRule from './types/pub/leaflet/blocks/horizontalRule'
31import * as PubLeafletBlocksIframe from './types/pub/leaflet/blocks/iframe'
32import * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image'
33import * as PubLeafletBlocksMath from './types/pub/leaflet/blocks/math'
34import * as PubLeafletBlocksPage from './types/pub/leaflet/blocks/page'
35import * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text'
36import * as PubLeafletBlocksUnorderedList from './types/pub/leaflet/blocks/unorderedList'
37import * as PubLeafletBlocksWebsite from './types/pub/leaflet/blocks/website'
38import * as PubLeafletComment from './types/pub/leaflet/comment'
39import * as PubLeafletDocument from './types/pub/leaflet/document'
40import * as PubLeafletGraphSubscription from './types/pub/leaflet/graph/subscription'
41import * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument'
42import * as PubLeafletPublication from './types/pub/leaflet/publication'
43import * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet'
44import * as PubLeafletThemeBackgroundImage from './types/pub/leaflet/theme/backgroundImage'
45import * as PubLeafletThemeColor from './types/pub/leaflet/theme/color'
46
47export * as AppBskyActorProfile from './types/app/bsky/actor/profile'
48export * as ComAtprotoLabelDefs from './types/com/atproto/label/defs'
49export * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites'
50export * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord'
51export * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs'
52export * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord'
53export * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo'
54export * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord'
55export * as ComAtprotoRepoImportRepo from './types/com/atproto/repo/importRepo'
56export * as ComAtprotoRepoListMissingBlobs from './types/com/atproto/repo/listMissingBlobs'
57export * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords'
58export * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
59export * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
60export * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
61export * as PubLeafletBlocksBlockquote from './types/pub/leaflet/blocks/blockquote'
62export * as PubLeafletBlocksBskyPost from './types/pub/leaflet/blocks/bskyPost'
63export * as PubLeafletBlocksCode from './types/pub/leaflet/blocks/code'
64export * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header'
65export * as PubLeafletBlocksHorizontalRule from './types/pub/leaflet/blocks/horizontalRule'
66export * as PubLeafletBlocksIframe from './types/pub/leaflet/blocks/iframe'
67export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image'
68export * as PubLeafletBlocksMath from './types/pub/leaflet/blocks/math'
69export * as PubLeafletBlocksPage from './types/pub/leaflet/blocks/page'
70export * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text'
71export * as PubLeafletBlocksUnorderedList from './types/pub/leaflet/blocks/unorderedList'
72export * as PubLeafletBlocksWebsite from './types/pub/leaflet/blocks/website'
73export * as PubLeafletComment from './types/pub/leaflet/comment'
74export * as PubLeafletDocument from './types/pub/leaflet/document'
75export * as PubLeafletGraphSubscription from './types/pub/leaflet/graph/subscription'
76export * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument'
77export * as PubLeafletPublication from './types/pub/leaflet/publication'
78export * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet'
79export * as PubLeafletThemeBackgroundImage from './types/pub/leaflet/theme/backgroundImage'
80export * as PubLeafletThemeColor from './types/pub/leaflet/theme/color'
81
82export const PUB_LEAFLET_PAGES = {
83 LinearDocumentTextAlignLeft: 'pub.leaflet.pages.linearDocument#textAlignLeft',
84 LinearDocumentTextAlignCenter:
85 'pub.leaflet.pages.linearDocument#textAlignCenter',
86 LinearDocumentTextAlignRight:
87 'pub.leaflet.pages.linearDocument#textAlignRight',
88}
89
90export class AtpBaseClient extends XrpcClient {
91 app: AppNS
92 com: ComNS
93 pub: PubNS
94
95 constructor(options: FetchHandler | FetchHandlerOptions) {
96 super(options, schemas)
97 this.app = new AppNS(this)
98 this.com = new ComNS(this)
99 this.pub = new PubNS(this)
100 }
101
102 /** @deprecated use `this` instead */
103 get xrpc(): XrpcClient {
104 return this
105 }
106}
107
108export class AppNS {
109 _client: XrpcClient
110 bsky: AppBskyNS
111
112 constructor(client: XrpcClient) {
113 this._client = client
114 this.bsky = new AppBskyNS(client)
115 }
116}
117
118export class AppBskyNS {
119 _client: XrpcClient
120 actor: AppBskyActorNS
121
122 constructor(client: XrpcClient) {
123 this._client = client
124 this.actor = new AppBskyActorNS(client)
125 }
126}
127
128export class AppBskyActorNS {
129 _client: XrpcClient
130 profile: AppBskyActorProfileRecord
131
132 constructor(client: XrpcClient) {
133 this._client = client
134 this.profile = new AppBskyActorProfileRecord(client)
135 }
136}
137
138export class AppBskyActorProfileRecord {
139 _client: XrpcClient
140
141 constructor(client: XrpcClient) {
142 this._client = client
143 }
144
145 async list(
146 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
147 ): Promise<{
148 cursor?: string
149 records: { uri: string; value: AppBskyActorProfile.Record }[]
150 }> {
151 const res = await this._client.call('com.atproto.repo.listRecords', {
152 collection: 'app.bsky.actor.profile',
153 ...params,
154 })
155 return res.data
156 }
157
158 async get(
159 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
160 ): Promise<{ uri: string; cid: string; value: AppBskyActorProfile.Record }> {
161 const res = await this._client.call('com.atproto.repo.getRecord', {
162 collection: 'app.bsky.actor.profile',
163 ...params,
164 })
165 return res.data
166 }
167
168 async create(
169 params: OmitKey<
170 ComAtprotoRepoCreateRecord.InputSchema,
171 'collection' | 'record'
172 >,
173 record: Un$Typed<AppBskyActorProfile.Record>,
174 headers?: Record<string, string>,
175 ): Promise<{ uri: string; cid: string }> {
176 const collection = 'app.bsky.actor.profile'
177 const res = await this._client.call(
178 'com.atproto.repo.createRecord',
179 undefined,
180 {
181 collection,
182 rkey: 'self',
183 ...params,
184 record: { ...record, $type: collection },
185 },
186 { encoding: 'application/json', headers },
187 )
188 return res.data
189 }
190
191 async put(
192 params: OmitKey<
193 ComAtprotoRepoPutRecord.InputSchema,
194 'collection' | 'record'
195 >,
196 record: Un$Typed<AppBskyActorProfile.Record>,
197 headers?: Record<string, string>,
198 ): Promise<{ uri: string; cid: string }> {
199 const collection = 'app.bsky.actor.profile'
200 const res = await this._client.call(
201 'com.atproto.repo.putRecord',
202 undefined,
203 { collection, ...params, record: { ...record, $type: collection } },
204 { encoding: 'application/json', headers },
205 )
206 return res.data
207 }
208
209 async delete(
210 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
211 headers?: Record<string, string>,
212 ): Promise<void> {
213 await this._client.call(
214 'com.atproto.repo.deleteRecord',
215 undefined,
216 { collection: 'app.bsky.actor.profile', ...params },
217 { headers },
218 )
219 }
220}
221
222export class ComNS {
223 _client: XrpcClient
224 atproto: ComAtprotoNS
225
226 constructor(client: XrpcClient) {
227 this._client = client
228 this.atproto = new ComAtprotoNS(client)
229 }
230}
231
232export class ComAtprotoNS {
233 _client: XrpcClient
234 repo: ComAtprotoRepoNS
235
236 constructor(client: XrpcClient) {
237 this._client = client
238 this.repo = new ComAtprotoRepoNS(client)
239 }
240}
241
242export class ComAtprotoRepoNS {
243 _client: XrpcClient
244
245 constructor(client: XrpcClient) {
246 this._client = client
247 }
248
249 applyWrites(
250 data?: ComAtprotoRepoApplyWrites.InputSchema,
251 opts?: ComAtprotoRepoApplyWrites.CallOptions,
252 ): Promise<ComAtprotoRepoApplyWrites.Response> {
253 return this._client
254 .call('com.atproto.repo.applyWrites', opts?.qp, data, opts)
255 .catch((e) => {
256 throw ComAtprotoRepoApplyWrites.toKnownErr(e)
257 })
258 }
259
260 createRecord(
261 data?: ComAtprotoRepoCreateRecord.InputSchema,
262 opts?: ComAtprotoRepoCreateRecord.CallOptions,
263 ): Promise<ComAtprotoRepoCreateRecord.Response> {
264 return this._client
265 .call('com.atproto.repo.createRecord', opts?.qp, data, opts)
266 .catch((e) => {
267 throw ComAtprotoRepoCreateRecord.toKnownErr(e)
268 })
269 }
270
271 deleteRecord(
272 data?: ComAtprotoRepoDeleteRecord.InputSchema,
273 opts?: ComAtprotoRepoDeleteRecord.CallOptions,
274 ): Promise<ComAtprotoRepoDeleteRecord.Response> {
275 return this._client
276 .call('com.atproto.repo.deleteRecord', opts?.qp, data, opts)
277 .catch((e) => {
278 throw ComAtprotoRepoDeleteRecord.toKnownErr(e)
279 })
280 }
281
282 describeRepo(
283 params?: ComAtprotoRepoDescribeRepo.QueryParams,
284 opts?: ComAtprotoRepoDescribeRepo.CallOptions,
285 ): Promise<ComAtprotoRepoDescribeRepo.Response> {
286 return this._client.call(
287 'com.atproto.repo.describeRepo',
288 params,
289 undefined,
290 opts,
291 )
292 }
293
294 getRecord(
295 params?: ComAtprotoRepoGetRecord.QueryParams,
296 opts?: ComAtprotoRepoGetRecord.CallOptions,
297 ): Promise<ComAtprotoRepoGetRecord.Response> {
298 return this._client
299 .call('com.atproto.repo.getRecord', params, undefined, opts)
300 .catch((e) => {
301 throw ComAtprotoRepoGetRecord.toKnownErr(e)
302 })
303 }
304
305 importRepo(
306 data?: ComAtprotoRepoImportRepo.InputSchema,
307 opts?: ComAtprotoRepoImportRepo.CallOptions,
308 ): Promise<ComAtprotoRepoImportRepo.Response> {
309 return this._client.call(
310 'com.atproto.repo.importRepo',
311 opts?.qp,
312 data,
313 opts,
314 )
315 }
316
317 listMissingBlobs(
318 params?: ComAtprotoRepoListMissingBlobs.QueryParams,
319 opts?: ComAtprotoRepoListMissingBlobs.CallOptions,
320 ): Promise<ComAtprotoRepoListMissingBlobs.Response> {
321 return this._client.call(
322 'com.atproto.repo.listMissingBlobs',
323 params,
324 undefined,
325 opts,
326 )
327 }
328
329 listRecords(
330 params?: ComAtprotoRepoListRecords.QueryParams,
331 opts?: ComAtprotoRepoListRecords.CallOptions,
332 ): Promise<ComAtprotoRepoListRecords.Response> {
333 return this._client.call(
334 'com.atproto.repo.listRecords',
335 params,
336 undefined,
337 opts,
338 )
339 }
340
341 putRecord(
342 data?: ComAtprotoRepoPutRecord.InputSchema,
343 opts?: ComAtprotoRepoPutRecord.CallOptions,
344 ): Promise<ComAtprotoRepoPutRecord.Response> {
345 return this._client
346 .call('com.atproto.repo.putRecord', opts?.qp, data, opts)
347 .catch((e) => {
348 throw ComAtprotoRepoPutRecord.toKnownErr(e)
349 })
350 }
351
352 uploadBlob(
353 data?: ComAtprotoRepoUploadBlob.InputSchema,
354 opts?: ComAtprotoRepoUploadBlob.CallOptions,
355 ): Promise<ComAtprotoRepoUploadBlob.Response> {
356 return this._client.call(
357 'com.atproto.repo.uploadBlob',
358 opts?.qp,
359 data,
360 opts,
361 )
362 }
363}
364
365export class PubNS {
366 _client: XrpcClient
367 leaflet: PubLeafletNS
368
369 constructor(client: XrpcClient) {
370 this._client = client
371 this.leaflet = new PubLeafletNS(client)
372 }
373}
374
375export class PubLeafletNS {
376 _client: XrpcClient
377 comment: PubLeafletCommentRecord
378 document: PubLeafletDocumentRecord
379 publication: PubLeafletPublicationRecord
380 blocks: PubLeafletBlocksNS
381 graph: PubLeafletGraphNS
382 pages: PubLeafletPagesNS
383 richtext: PubLeafletRichtextNS
384 theme: PubLeafletThemeNS
385
386 constructor(client: XrpcClient) {
387 this._client = client
388 this.blocks = new PubLeafletBlocksNS(client)
389 this.graph = new PubLeafletGraphNS(client)
390 this.pages = new PubLeafletPagesNS(client)
391 this.richtext = new PubLeafletRichtextNS(client)
392 this.theme = new PubLeafletThemeNS(client)
393 this.comment = new PubLeafletCommentRecord(client)
394 this.document = new PubLeafletDocumentRecord(client)
395 this.publication = new PubLeafletPublicationRecord(client)
396 }
397}
398
399export class PubLeafletBlocksNS {
400 _client: XrpcClient
401
402 constructor(client: XrpcClient) {
403 this._client = client
404 }
405}
406
407export class PubLeafletGraphNS {
408 _client: XrpcClient
409 subscription: PubLeafletGraphSubscriptionRecord
410
411 constructor(client: XrpcClient) {
412 this._client = client
413 this.subscription = new PubLeafletGraphSubscriptionRecord(client)
414 }
415}
416
417export class PubLeafletGraphSubscriptionRecord {
418 _client: XrpcClient
419
420 constructor(client: XrpcClient) {
421 this._client = client
422 }
423
424 async list(
425 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
426 ): Promise<{
427 cursor?: string
428 records: { uri: string; value: PubLeafletGraphSubscription.Record }[]
429 }> {
430 const res = await this._client.call('com.atproto.repo.listRecords', {
431 collection: 'pub.leaflet.graph.subscription',
432 ...params,
433 })
434 return res.data
435 }
436
437 async get(
438 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
439 ): Promise<{
440 uri: string
441 cid: string
442 value: PubLeafletGraphSubscription.Record
443 }> {
444 const res = await this._client.call('com.atproto.repo.getRecord', {
445 collection: 'pub.leaflet.graph.subscription',
446 ...params,
447 })
448 return res.data
449 }
450
451 async create(
452 params: OmitKey<
453 ComAtprotoRepoCreateRecord.InputSchema,
454 'collection' | 'record'
455 >,
456 record: Un$Typed<PubLeafletGraphSubscription.Record>,
457 headers?: Record<string, string>,
458 ): Promise<{ uri: string; cid: string }> {
459 const collection = 'pub.leaflet.graph.subscription'
460 const res = await this._client.call(
461 'com.atproto.repo.createRecord',
462 undefined,
463 { collection, ...params, record: { ...record, $type: collection } },
464 { encoding: 'application/json', headers },
465 )
466 return res.data
467 }
468
469 async put(
470 params: OmitKey<
471 ComAtprotoRepoPutRecord.InputSchema,
472 'collection' | 'record'
473 >,
474 record: Un$Typed<PubLeafletGraphSubscription.Record>,
475 headers?: Record<string, string>,
476 ): Promise<{ uri: string; cid: string }> {
477 const collection = 'pub.leaflet.graph.subscription'
478 const res = await this._client.call(
479 'com.atproto.repo.putRecord',
480 undefined,
481 { collection, ...params, record: { ...record, $type: collection } },
482 { encoding: 'application/json', headers },
483 )
484 return res.data
485 }
486
487 async delete(
488 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
489 headers?: Record<string, string>,
490 ): Promise<void> {
491 await this._client.call(
492 'com.atproto.repo.deleteRecord',
493 undefined,
494 { collection: 'pub.leaflet.graph.subscription', ...params },
495 { headers },
496 )
497 }
498}
499
500export class PubLeafletPagesNS {
501 _client: XrpcClient
502
503 constructor(client: XrpcClient) {
504 this._client = client
505 }
506}
507
508export class PubLeafletRichtextNS {
509 _client: XrpcClient
510
511 constructor(client: XrpcClient) {
512 this._client = client
513 }
514}
515
516export class PubLeafletThemeNS {
517 _client: XrpcClient
518
519 constructor(client: XrpcClient) {
520 this._client = client
521 }
522}
523
524export class PubLeafletCommentRecord {
525 _client: XrpcClient
526
527 constructor(client: XrpcClient) {
528 this._client = client
529 }
530
531 async list(
532 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
533 ): Promise<{
534 cursor?: string
535 records: { uri: string; value: PubLeafletComment.Record }[]
536 }> {
537 const res = await this._client.call('com.atproto.repo.listRecords', {
538 collection: 'pub.leaflet.comment',
539 ...params,
540 })
541 return res.data
542 }
543
544 async get(
545 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
546 ): Promise<{ uri: string; cid: string; value: PubLeafletComment.Record }> {
547 const res = await this._client.call('com.atproto.repo.getRecord', {
548 collection: 'pub.leaflet.comment',
549 ...params,
550 })
551 return res.data
552 }
553
554 async create(
555 params: OmitKey<
556 ComAtprotoRepoCreateRecord.InputSchema,
557 'collection' | 'record'
558 >,
559 record: Un$Typed<PubLeafletComment.Record>,
560 headers?: Record<string, string>,
561 ): Promise<{ uri: string; cid: string }> {
562 const collection = 'pub.leaflet.comment'
563 const res = await this._client.call(
564 'com.atproto.repo.createRecord',
565 undefined,
566 { collection, ...params, record: { ...record, $type: collection } },
567 { encoding: 'application/json', headers },
568 )
569 return res.data
570 }
571
572 async put(
573 params: OmitKey<
574 ComAtprotoRepoPutRecord.InputSchema,
575 'collection' | 'record'
576 >,
577 record: Un$Typed<PubLeafletComment.Record>,
578 headers?: Record<string, string>,
579 ): Promise<{ uri: string; cid: string }> {
580 const collection = 'pub.leaflet.comment'
581 const res = await this._client.call(
582 'com.atproto.repo.putRecord',
583 undefined,
584 { collection, ...params, record: { ...record, $type: collection } },
585 { encoding: 'application/json', headers },
586 )
587 return res.data
588 }
589
590 async delete(
591 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
592 headers?: Record<string, string>,
593 ): Promise<void> {
594 await this._client.call(
595 'com.atproto.repo.deleteRecord',
596 undefined,
597 { collection: 'pub.leaflet.comment', ...params },
598 { headers },
599 )
600 }
601}
602
603export class PubLeafletDocumentRecord {
604 _client: XrpcClient
605
606 constructor(client: XrpcClient) {
607 this._client = client
608 }
609
610 async list(
611 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
612 ): Promise<{
613 cursor?: string
614 records: { uri: string; value: PubLeafletDocument.Record }[]
615 }> {
616 const res = await this._client.call('com.atproto.repo.listRecords', {
617 collection: 'pub.leaflet.document',
618 ...params,
619 })
620 return res.data
621 }
622
623 async get(
624 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
625 ): Promise<{ uri: string; cid: string; value: PubLeafletDocument.Record }> {
626 const res = await this._client.call('com.atproto.repo.getRecord', {
627 collection: 'pub.leaflet.document',
628 ...params,
629 })
630 return res.data
631 }
632
633 async create(
634 params: OmitKey<
635 ComAtprotoRepoCreateRecord.InputSchema,
636 'collection' | 'record'
637 >,
638 record: Un$Typed<PubLeafletDocument.Record>,
639 headers?: Record<string, string>,
640 ): Promise<{ uri: string; cid: string }> {
641 const collection = 'pub.leaflet.document'
642 const res = await this._client.call(
643 'com.atproto.repo.createRecord',
644 undefined,
645 { collection, ...params, record: { ...record, $type: collection } },
646 { encoding: 'application/json', headers },
647 )
648 return res.data
649 }
650
651 async put(
652 params: OmitKey<
653 ComAtprotoRepoPutRecord.InputSchema,
654 'collection' | 'record'
655 >,
656 record: Un$Typed<PubLeafletDocument.Record>,
657 headers?: Record<string, string>,
658 ): Promise<{ uri: string; cid: string }> {
659 const collection = 'pub.leaflet.document'
660 const res = await this._client.call(
661 'com.atproto.repo.putRecord',
662 undefined,
663 { collection, ...params, record: { ...record, $type: collection } },
664 { encoding: 'application/json', headers },
665 )
666 return res.data
667 }
668
669 async delete(
670 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
671 headers?: Record<string, string>,
672 ): Promise<void> {
673 await this._client.call(
674 'com.atproto.repo.deleteRecord',
675 undefined,
676 { collection: 'pub.leaflet.document', ...params },
677 { headers },
678 )
679 }
680}
681
682export class PubLeafletPublicationRecord {
683 _client: XrpcClient
684
685 constructor(client: XrpcClient) {
686 this._client = client
687 }
688
689 async list(
690 params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>,
691 ): Promise<{
692 cursor?: string
693 records: { uri: string; value: PubLeafletPublication.Record }[]
694 }> {
695 const res = await this._client.call('com.atproto.repo.listRecords', {
696 collection: 'pub.leaflet.publication',
697 ...params,
698 })
699 return res.data
700 }
701
702 async get(
703 params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>,
704 ): Promise<{
705 uri: string
706 cid: string
707 value: PubLeafletPublication.Record
708 }> {
709 const res = await this._client.call('com.atproto.repo.getRecord', {
710 collection: 'pub.leaflet.publication',
711 ...params,
712 })
713 return res.data
714 }
715
716 async create(
717 params: OmitKey<
718 ComAtprotoRepoCreateRecord.InputSchema,
719 'collection' | 'record'
720 >,
721 record: Un$Typed<PubLeafletPublication.Record>,
722 headers?: Record<string, string>,
723 ): Promise<{ uri: string; cid: string }> {
724 const collection = 'pub.leaflet.publication'
725 const res = await this._client.call(
726 'com.atproto.repo.createRecord',
727 undefined,
728 { collection, ...params, record: { ...record, $type: collection } },
729 { encoding: 'application/json', headers },
730 )
731 return res.data
732 }
733
734 async put(
735 params: OmitKey<
736 ComAtprotoRepoPutRecord.InputSchema,
737 'collection' | 'record'
738 >,
739 record: Un$Typed<PubLeafletPublication.Record>,
740 headers?: Record<string, string>,
741 ): Promise<{ uri: string; cid: string }> {
742 const collection = 'pub.leaflet.publication'
743 const res = await this._client.call(
744 'com.atproto.repo.putRecord',
745 undefined,
746 { collection, ...params, record: { ...record, $type: collection } },
747 { encoding: 'application/json', headers },
748 )
749 return res.data
750 }
751
752 async delete(
753 params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>,
754 headers?: Record<string, string>,
755 ): Promise<void> {
756 await this._client.call(
757 'com.atproto.repo.deleteRecord',
758 undefined,
759 { collection: 'pub.leaflet.publication', ...params },
760 { headers },
761 )
762 }
763}