import type {} from "@atcute/atproto"; import type {} from "@atcute/bluesky"; import { Client, CredentialManager, ok } from "@atcute/client"; /* ------------------------------------------------------------------ */ /* 1. Log in */ /* ------------------------------------------------------------------ */ const manager = new CredentialManager({ service: "https://bsky.social" }); await manager.login({ identifier: "handle.invalid", // ← your handle or email password: "xD", // ← app-password recommended }); const rpc = new Client({ handler: manager }); /* ------------------------------------------------------------------ */ /* 2. Remove lowercase `alt` from every social.grain.photo record */ /* ------------------------------------------------------------------ */ const collection = "social.grain.photo"; const repo = "did:plc:tas6hj2xjrqben5653v5kohk"; let cursor: string | undefined; do { const res = await ok( rpc.get("com.atproto.repo.listRecords", { params: { repo, collection, cursor, limit: 100 }, }) ); for (const rec of res.records) { const uri = rec.uri as string; const record = rec.value as any; if (!("alt" in record)) continue; // ← lowercase check const { alt, ...cleaned } = record; // ← lowercase delete await ok( rpc.post("com.atproto.repo.putRecord", { input: { collection, repo, rkey: uri.split("/").pop()!, record: cleaned, }, }) ); console.log(`✔ removed \`alt\` from ${uri}`); } cursor = res.cursor; } while (cursor); console.log("All done 🎉");