diff --git a/packages/consumer/mod.ts b/packages/consumer/mod.ts index cdacd2c..4ff9269 100644 --- a/packages/consumer/mod.ts +++ b/packages/consumer/mod.ts @@ -1,7 +1,7 @@ import { produceRequirements } from "@cistern/shared"; import { generateKeys } from "@cistern/crypto"; import { generateRandomName } from "@puregarlic/randimal"; -import { is, parse } from "@atcute/lexicons"; +import { is, parse, type RecordKey } from "@atcute/lexicons"; import { JetstreamSubscription } from "@atcute/jetstream"; import type { Did } from "@atcute/lexicons/syntax"; import type { Client, CredentialManager } from "@atcute/client"; @@ -157,7 +157,20 @@ export class Consumer { /** * Deletes an item from the user's PDS by record key. - * @todo Delete item from PDS */ - async deleteItem() {} + async deleteItem(key: RecordKey) { + const res = await this.rpc.post("com.atproto.repo.deleteRecord", { + input: { + collection: "app.cistern.lexicon.item", + repo: this.did, + rkey: key, + }, + }); + + if (!res.ok) { + throw new Error( + `failed to delete item ${key}: ${res.status} ${res.data.error}`, + ); + } + } }