Skip to content

Commit 663f2c5

Browse files
committed
chore: fix pre-existing Biome linting errors across agent, account-agent, api, and workflows packages
1 parent 4e006fa commit 663f2c5

File tree

20 files changed

+187
-162
lines changed

20 files changed

+187
-162
lines changed

biome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"files": {
4+
"ignore": ["**/dist/**", "**/node_modules/**", "**/.next/**", "**/build/**"]
5+
},
36
"formatter": {
47
"enabled": true,
58
"indentStyle": "tab"

packages/account-agent/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function parseInsights(text: string | null): InsightOutput[] {
226226
if (!Array.isArray(parsed)) return [];
227227
// Basic validation
228228
return parsed.filter(
229-
(i: any) =>
229+
(i: InsightOutput) =>
230230
i.category &&
231231
i.insight_type &&
232232
i.severity &&

packages/account-agent/src/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ async function getSubgraphSchemaHealth(
523523

524524
for (const [tableName, tableDef] of Object.entries(defSchema) as [
525525
string,
526-
any,
526+
{ columns?: Record<string, unknown>; indexes?: string[][] },
527527
][]) {
528528
// Get actual PG columns
529529
const pgCols = await sql<{

packages/agent/src/db/__tests__/queries.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("snapshots", () => {
5858

5959
const snap = getLatestSnapshot(db);
6060
expect(snap).not.toBeNull();
61-
expect(snap!.disk).toBe('{"usedPct":45}');
61+
expect(snap?.disk).toBe('{"usedPct":45}');
6262
});
6363
});
6464

@@ -93,8 +93,8 @@ describe("getUnresolvedAlertForService", () => {
9393

9494
const alert = getUnresolvedAlertForService(db, "indexer");
9595
expect(alert).not.toBeNull();
96-
expect(alert!.id).toBe(id);
97-
expect(alert!.slackTs).toBe("1234567890.123456");
96+
expect(alert?.id).toBe(id);
97+
expect(alert?.slackTs).toBe("1234567890.123456");
9898
});
9999

100100
test("returns null after resolve", () => {

packages/agent/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function main(): Promise<void> {
4646
log(` services: ${config.services.map((s) => s.name).join(", ")}`);
4747

4848
// Ensure data dir exists
49-
const { mkdirSync } = await import("fs");
49+
const { mkdirSync } = await import("node:fs");
5050
mkdirSync(config.dataDir, { recursive: true });
5151

5252
const db = initDb(config.dbPath);

packages/agent/src/notify/__tests__/slack-callback.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Database } from "bun:sqlite";
22
import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
3-
import { createHmac } from "crypto";
3+
import { createHmac } from "node:crypto";
44
import { initDb } from "../../db/index.ts";
55
import {
66
getAlertById,
@@ -22,9 +22,7 @@ function makeSignedRequest(
2222
): Request {
2323
const ts = opts?.timestamp ?? String(Math.floor(Date.now() / 1000));
2424
const secret = opts?.secret ?? SECRET;
25-
const sig =
26-
"v0=" +
27-
createHmac("sha256", secret).update(`v0:${ts}:${body}`).digest("hex");
25+
const sig = `v0=${createHmac("sha256", secret).update(`v0:${ts}:${body}`).digest("hex")}`;
2826

2927
return new Request("http://localhost:3900/hooks/slack", {
3028
method: "POST",

packages/agent/src/notify/__tests__/slack-verify.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from "bun:test";
2-
import { createHmac } from "crypto";
2+
import { createHmac } from "node:crypto";
33
import { verifySlackSignature } from "../slack-verify.ts";
44

55
const SECRET = "test_signing_secret_12345";
@@ -9,10 +9,7 @@ function makeSignature(
99
timestamp: string,
1010
body: string,
1111
): string {
12-
return (
13-
"v0=" +
14-
createHmac("sha256", secret).update(`v0:${timestamp}:${body}`).digest("hex")
15-
);
12+
return `v0=${createHmac("sha256", secret).update(`v0:${timestamp}:${body}`).digest("hex")}`;
1613
}
1714

1815
function nowTimestamp(): string {

packages/agent/src/notify/slack-verify.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createHmac } from "crypto";
1+
import { createHmac } from "node:crypto";
22

33
const MAX_TIMESTAMP_DRIFT_S = 300; // 5 minutes
44

@@ -13,21 +13,19 @@ export function verifySlackSignature(
1313

1414
// Reject replay attacks
1515
const ts = Number.parseInt(timestamp, 10);
16-
if (isNaN(ts)) return false;
16+
if (Number.isNaN(ts)) return false;
1717
const now = Math.floor(Date.now() / 1000);
1818
if (Math.abs(now - ts) > MAX_TIMESTAMP_DRIFT_S) return false;
1919

2020
const basestring = `v0:${timestamp}:${body}`;
21-
const expected =
22-
"v0=" +
23-
createHmac("sha256", signingSecret).update(basestring).digest("hex");
21+
const expected = `v0=${createHmac("sha256", signingSecret).update(basestring).digest("hex")}`;
2422

2523
// Timing-safe comparison
2624
if (signature.length !== expected.length) return false;
2725
const sigBuf = Buffer.from(signature);
2826
const expBuf = Buffer.from(expected);
2927
try {
30-
const { timingSafeEqual } = require("crypto");
28+
const { timingSafeEqual } = require("node:crypto");
3129
return timingSafeEqual(sigBuf, expBuf);
3230
} catch {
3331
return signature === expected;

packages/api/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { closeDb, getDb } from "@secondlayer/shared/db";
99
// API service - REST API for stream management
1010
import { Hono } from "hono";
1111
import { cors } from "hono/cors";
12+
import { requireAdmin } from "./middleware/admin.ts";
1213
import { errorHandler } from "./middleware/error.ts";
1314
import { requestLogger } from "./middleware/logging.ts";
1415
import { countApiRequests } from "./middleware/usage.ts";
1516
import accountsRouter from "./routes/accounts.ts";
17+
import adminRouter from "./routes/admin.ts";
1618
import authRouter from "./routes/auth.ts";
1719
import chatSessionsRouter from "./routes/chat-sessions.ts";
1820
import insightsRouter from "./routes/insights.ts";
@@ -30,8 +32,6 @@ import subgraphsRouter, {
3032
} from "./routes/subgraphs.ts";
3133
import waitlistRouter from "./routes/waitlist.ts";
3234
import workflowsRouter from "./routes/workflows.ts";
33-
import adminRouter from "./routes/admin.ts";
34-
import { requireAdmin } from "./middleware/admin.ts";
3535

3636
const app = new Hono();
3737

packages/api/src/lib/ownership.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ForbiddenError, StreamNotFoundError } from "@secondlayer/shared";
22
import type { Database } from "@secondlayer/shared/db";
33
import { getDb } from "@secondlayer/shared/db";
4+
import type { Context } from "hono";
45
import type { Kysely } from "kysely";
56

67
/**
@@ -74,18 +75,18 @@ export async function assertSubgraphOwnership(
7475
}
7576

7677
/** Extract api_key_id from Hono context, or undefined in DEV_MODE */
77-
export function getApiKeyId(c: any): string | undefined {
78-
const apiKey = c.get("apiKey");
78+
export function getApiKeyId(c: Context): string | undefined {
79+
const apiKey = c.get("apiKey") as { id: string } | undefined;
7980
return apiKey?.id;
8081
}
8182

8283
/** Extract account_id from Hono context, or undefined in DEV_MODE */
83-
export function getAccountId(c: any): string | undefined {
84+
export function getAccountId(c: Context): string | undefined {
8485
return c.get("accountId") as string | undefined;
8586
}
8687

8788
/** Resolve all active API key IDs for the current request's account. */
88-
export async function resolveKeyIds(c: any): Promise<string[] | undefined> {
89+
export async function resolveKeyIds(c: Context): Promise<string[] | undefined> {
8990
const accountId = getAccountId(c);
9091
if (!accountId) return undefined;
9192
const ids = await getAccountKeyIds(getDb(), accountId);
@@ -108,7 +109,7 @@ export async function resolveKeyIds(c: any): Promise<string[] | undefined> {
108109
* - the account has zero active API keys (caller should 403 with NO_API_KEY)
109110
*/
110111
export async function resolveApiKeyIdForWrite(
111-
c: any,
112+
c: Context,
112113
): Promise<string | undefined> {
113114
const direct = getApiKeyId(c);
114115
if (direct) return direct;

0 commit comments

Comments
 (0)