Pronouns labels on Bluesky

add types from atcute

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