a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

feature(car): expose cid value as well

Mary 83cffb0a c5950aa3

+12 -11
+12 -11
packages/utilities/car/lib/atproto-repo.ts
··· 5 5 6 6 const decoder = new TextDecoder(); 7 7 8 - export interface RepoEntry { 9 - collection: string; 10 - rkey: string; 11 - record: unknown; 8 + export class RepoEntry { 9 + constructor( 10 + public readonly collection: string, 11 + public readonly rkey: string, 12 + public readonly cid: CBOR.CIDLink, 13 + private blockmap: BlockMap, 14 + ) {} 15 + 16 + get record(): unknown { 17 + return readObject(this.blockmap, this.cid); 18 + } 12 19 } 13 20 14 21 export function* iterateAtpCar(buf: Uint8Array): Generator<RepoEntry> { ··· 26 33 for (const { key, cid } of walkEntries(blockmap, commit.data)) { 27 34 const [collection, rkey] = key.split('/'); 28 35 29 - yield { 30 - collection, 31 - rkey, 32 - get record() { 33 - return readObject(blockmap, cid); 34 - }, 35 - }; 36 + yield new RepoEntry(collection, rkey, cid, blockmap); 36 37 } 37 38 } 38 39