Skip to content

Commit 2ccce1b

Browse files
committed
Fix type errors
1 parent 88cb828 commit 2ccce1b

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed

src/allowlist/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StarbaseDBConfiguration } from "../handler";
2-
import { DataSource } from "../types";
2+
import { DataSource, QueryResult } from "../types";
33

44
const parser = new (require("node-sql-parser").Parser)();
55

@@ -17,7 +17,7 @@ function normalizeSQL(sql: string) {
1717
async function loadAllowlist(dataSource: DataSource): Promise<string[]> {
1818
try {
1919
const statement = "SELECT sql_statement FROM tmp_allowlist_queries";
20-
const result = await dataSource.rpc.executeQuery({ sql: statement });
20+
const result = await dataSource.rpc.executeQuery({ sql: statement }) as QueryResult[]
2121
return result.map((row) => String(row.sql_statement));
2222
} catch (error) {
2323
console.error("Error loading allowlist:", error);

src/cache/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StarbaseDBConfiguration } from "../handler";
2-
import { DataSource } from "../types";
2+
import { DataSource, QueryResult } from "../types";
33
import sqlparser from "node-sql-parser";
44
const parser = new sqlparser.Parser();
55

@@ -62,7 +62,7 @@ export async function beforeQueryCache(opts: {
6262
const result = await dataSource.rpc.executeQuery({
6363
sql: fetchCacheStatement,
6464
params: [sql],
65-
});
65+
}) as any[];
6666

6767
if (result?.length) {
6868
const { timestamp, ttl, results } = result[0] as QueryResult;
@@ -115,7 +115,7 @@ export async function afterQueryCache(opts: {
115115
const exists = await dataSource.rpc.executeQuery({
116116
sql: "SELECT 1 FROM tmp_cache WHERE query = ? LIMIT 1",
117117
params: [sql],
118-
});
118+
}) as QueryResult[];
119119

120120
const query = exists?.length
121121
? {

src/rls/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StarbaseDBConfiguration } from "../handler";
2-
import { DataSource } from "../types";
2+
import { DataSource, QueryResult } from "../types";
33

44
const parser = new (require("node-sql-parser").Parser)();
55

@@ -53,7 +53,7 @@ async function loadPolicies(dataSource: DataSource): Promise<Policy[]> {
5353
'SELECT "actions", "schema", "table", "column", "value", "value_type", "operator" FROM tmp_rls_policies';
5454
const result = await dataSource.rpc.executeQuery({
5555
sql: statement,
56-
});
56+
}) as QueryResult[];
5757

5858
if (!result || result.length === 0) {
5959
// Discussion point to be had here. For safety precautions I am ejecting

src/types.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@ export type DataSource = {
5757
cacheTTL?: number;
5858
};
5959

60-
// export interface InternalConnection {
61-
// durableObject: DatabaseStub;
62-
// }
63-
64-
// export type DatabaseStub = DurableObjectStub & {
65-
// fetch: (init?: RequestInit | Request) => Promise<Response>;
66-
// executeQuery(
67-
// sql: string,
68-
// params: any[] | undefined,
69-
// isRaw: boolean
70-
// ): QueryResponse;
71-
// executeTransaction(
72-
// queries: { sql: string; params?: any[] }[],
73-
// isRaw: boolean
74-
// ): any[];
75-
// };
76-
7760
export enum RegionLocationHint {
7861
AUTO = "auto",
7962
WNAM = "wnam", // Western North America

0 commit comments

Comments
 (0)