Pronouns labels on Bluesky

add types from atcute

+3 -2
package-lock.json
··· 8 8 "name": "pronouns-bsky", 9 9 "version": "1.0.0", 10 10 "dependencies": { 11 + "@atcute/bluesky": "^1.0.6", 12 + "@atcute/client": "^2.0.1", 11 13 "@skyware/jetstream": "^0.1.3", 12 14 "@skyware/labeler": "^0.1.7", 13 15 "dotenv": "^16.4.5" ··· 57 59 "version": "2.0.1", 58 60 "resolved": "https://registry.npmjs.org/@atcute/client/-/client-2.0.1.tgz", 59 61 "integrity": "sha512-M4q0QchcjcPTypgXTKc4MO06eJMno5op14qHAMWhKbxROOnxnhLfjG9rbcNr7nOycQb5THmUIEAwvvabrv1AjA==", 60 - "license": "MIT", 61 - "peer": true 62 + "license": "MIT" 62 63 }, 63 64 "node_modules/@atcute/varint": { 64 65 "version": "1.0.0",
+2
package.json
··· 11 11 "typescript": "^5.5.3" 12 12 }, 13 13 "dependencies": { 14 + "@atcute/bluesky": "^1.0.6", 15 + "@atcute/client": "^2.0.1", 14 16 "@skyware/jetstream": "^0.1.3", 15 17 "@skyware/labeler": "^0.1.7", 16 18 "dotenv": "^16.4.5"
+5 -2
src/label.ts
··· 1 + import { ComAtprotoLabelDefs } from "@atcute/client/lexicons"; 1 2 import { 2 3 DID, 3 4 PORT, ··· 6 7 SIGNING_KEY, 7 8 DELETE, 8 9 } from "./constants.js"; 9 - import { Label } from "./types.js"; 10 10 import { LabelerServer } from "@skyware/labeler"; 11 11 12 12 const server = new LabelerServer({ did: DID, signingKey: SIGNING_KEY }); ··· 18 18 19 19 export const label = async (did: string, rkey: string) => { 20 20 const query = server.db 21 - .prepare<unknown[], Label>(`SELECT * FROM labels WHERE uri = ?`) 21 + .prepare< 22 + unknown[], 23 + ComAtprotoLabelDefs.Label 24 + >(`SELECT * FROM labels WHERE uri = ?`) 22 25 .all(did); 23 26 24 27 const labels = query.reduce((set, label) => {
+2 -2
src/main.ts
··· 2 2 import { DID } from "./constants.js"; 3 3 import fs from "node:fs"; 4 4 import { Jetstream } from "@skyware/jetstream"; 5 - import { LikeRecord } from "./types.js"; 5 + import { AppBskyFeedLike } from "@atcute/client/lexicons"; 6 6 7 7 let cursor = 0; 8 8 let intervalID: NodeJS.Timeout; ··· 29 29 30 30 jetstream.onCreate("app.bsky.feed.like", (event) => { 31 31 cursor = event.time_us; 32 - const record = event.commit.record as LikeRecord; 32 + const record = event.commit.record as AppBskyFeedLike.Record; 33 33 if (record.subject?.uri?.includes(`${DID}/app.bsky.feed.post`)) 34 34 label(event.did, record.subject.uri.split("/").pop()!); 35 35 });
-21
src/types.ts
··· 1 - export interface LikeRecord { 2 - $type: string; 3 - createdAt: string; 4 - subject: { 5 - cid: string; 6 - uri: string; 7 - }; 8 - } 9 - 10 - export interface Label { 11 - ver?: number; 12 - src: string; 13 - uri: string; 14 - cid?: string; 15 - val: string; 16 - neg?: boolean; 17 - cts: string; 18 - exp?: string; 19 - sig?: Uint8Array; 20 - [k: string]: unknown; 21 - }
+2 -2
tsconfig.json
··· 2 2 "compilerOptions": { 3 3 "strict": true, 4 4 "target": "ESNext", 5 - "module": "ESNext", 6 - "moduleResolution": "node", 5 + "module": "nodenext", 6 + "moduleResolution": "nodenext", 7 7 "allowSyntheticDefaultImports": true, 8 8 "esModuleInterop": true, 9 9 },