@@ -15,6 +15,8 @@ import {
1515 CountResult ,
1616 VersionResult ,
1717 FrameRow ,
18+ EventRow ,
19+ AnchorRow ,
1820 ProjectRegistryRow ,
1921} from './database-adapter.js' ;
2022import type { Frame , Event , Anchor } from '../context/index.js' ;
@@ -283,7 +285,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
283285 const needsCascade = ( table : string ) : boolean => {
284286 const rows = this . db ! . prepare (
285287 `PRAGMA foreign_key_list(${ table } )`
286- ) . all ( ) as any [ ] ;
288+ ) . all ( ) as Array < { table : string ; on_delete : string } > ;
287289 // If any FK points to frames without cascade, we need migration
288290 return rows . some (
289291 ( r ) =>
@@ -831,7 +833,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
831833
832834 query += ' ORDER BY depth ASC, created_at ASC' ;
833835
834- const rows = this . db . prepare ( query ) . all ( ...params ) as any [ ] ;
836+ const rows = this . db . prepare ( query ) . all ( ...params ) as FrameRow [ ] ;
835837
836838 return rows . map ( ( row ) => ( {
837839 ...row ,
@@ -896,7 +898,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
896898 ) ;
897899 query += this . buildLimitClause ( options ?. limit , options ?. offset ) ;
898900
899- const rows = this . db . prepare ( query ) . all ( frameId ) as any [ ] ;
901+ const rows = this . db . prepare ( query ) . all ( frameId ) as EventRow [ ] ;
900902
901903 return rows . map ( ( row ) => ( {
902904 ...row ,
@@ -958,7 +960,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
958960 ORDER BY priority DESC, created_at ASC
959961 `
960962 )
961- . all ( frameId ) as any [ ] ;
963+ . all ( frameId ) as AnchorRow [ ] ;
962964
963965 return rows . map ( ( row ) => ( {
964966 ...row ,
@@ -1063,7 +1065,9 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
10631065 if ( options . projectId ) params . push ( options . projectId ) ;
10641066 params . push ( limit , offset ) ;
10651067
1066- const rows = this . db ! . prepare ( sql ) . all ( ...params ) as any [ ] ;
1068+ const rows = this . db ! . prepare ( sql ) . all ( ...params ) as ( FrameRow & {
1069+ score : number ;
1070+ } ) [ ] ;
10671071
10681072 // Note: scoreThreshold is not applied to FTS results because BM25 scores
10691073 // are on a different scale than LIKE-based scores. FTS results are already
@@ -1100,7 +1104,9 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
11001104 const params : any [ ] = Array ( 6 ) . fill ( likeParam ) ;
11011105 if ( options . projectId ) params . push ( options . projectId ) ;
11021106
1103- let rows = this . db ! . prepare ( sql ) . all ( ...params ) as any [ ] ;
1107+ let rows = this . db ! . prepare ( sql ) . all ( ...params ) as ( FrameRow & {
1108+ score : number ;
1109+ } ) [ ] ;
11041110
11051111 if ( options . scoreThreshold ) {
11061112 rows = rows . filter ( ( row ) => row . score >= options . scoreThreshold ) ;
@@ -1147,7 +1153,9 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
11471153
11481154 const rows = this . db
11491155 . prepare ( sql )
1150- . all ( JSON . stringify ( embedding ) , limit ) as any [ ] ;
1156+ . all ( JSON . stringify ( embedding ) , limit ) as ( FrameRow & {
1157+ similarity : number ;
1158+ } ) [ ] ;
11511159
11521160 return rows . map ( ( row ) => ( {
11531161 ...row ,
@@ -1371,7 +1379,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
13711379 if ( sinceRowid != null ) params . push ( sinceRowid ) ;
13721380 params . push ( limit ) ;
13731381
1374- const rows = this . db . prepare ( sql ) . all ( ...params ) as any [ ] ;
1382+ const rows = this . db . prepare ( sql ) . all ( ...params ) as FrameRow [ ] ;
13751383 return rows . map ( ( row ) => ( {
13761384 ...row ,
13771385 inputs : JSON . parse ( row . inputs || '{}' ) ,
@@ -1532,7 +1540,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
15321540
15331541 return this . db
15341542 . prepare ( sql )
1535- . all ( ...Object . values ( options . having || { } ) ) as any [ ] ;
1543+ . all ( ...Object . values ( options . having || { } ) ) as Record < string , unknown > [ ] ;
15361544 }
15371545
15381546 // Pattern detection (basic)
@@ -1566,7 +1574,12 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
15661574
15671575 sql += ' GROUP BY type HAVING COUNT(*) > 1 ORDER BY frequency DESC' ;
15681576
1569- const rows = this . db . prepare ( sql ) . all ( ...params ) as any [ ] ;
1577+ const rows = this . db . prepare ( sql ) . all ( ...params ) as Array < {
1578+ pattern : string ;
1579+ type : string ;
1580+ frequency : number ;
1581+ last_seen : number ;
1582+ } > ;
15701583
15711584 return rows . map ( ( row ) => ( {
15721585 pattern : row . pattern ,
@@ -1909,7 +1922,7 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
19091922 this . db ! . prepare ( `DELETE FROM ${ table } ` ) . run ( ) ;
19101923 }
19111924
1912- for ( const row of rows as any [ ] ) {
1925+ for ( const row of rows as Record < string , unknown > [ ] ) {
19131926 const cols = Object . keys ( row ) ;
19141927 const placeholders = cols . map ( ( ) => '?' ) . join ( ',' ) ;
19151928
0 commit comments