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