@@ -10,7 +10,7 @@ import {
1010} from "./contribution-profile.js" ;
1111import {
1212 normalizeLocalStoreDbPath ,
13- openLocalStoreDb ,
13+ openLocalStoreAdapter ,
1414 resolveLocalStoreDbPath ,
1515} from "./local-store.js" ;
1616import { applySchemaMigrations } from "./schema-version.js" ;
@@ -63,12 +63,16 @@ function normalizeRepoFullName(repoFullName: unknown): string {
6363
6464/**
6565 * Open the 100%-local contribution-profile cache. The DB only lives on this machine (#6797).
66+ *
67+ * Opened through the #7175 SqliteDriver seam (`openLocalStoreAdapter`): CRUD goes through `driver.query`,
68+ * while schema creation/migrations / purge still use the underlying DatabaseSync until those helpers are
69+ * migrated. Public API stays synchronous so callers need no async cascade in this #7282 slice.
6670 */
6771export function initContributionProfileCache (
6872 dbPath : string = resolveContributionProfileCacheDbPath ( ) ,
6973) : ContributionProfileCache {
7074 const resolvedPath = normalizeDbPath ( dbPath ) ;
71- const db = openLocalStoreDb ( resolvedPath ) ;
75+ const { db , driver } = openLocalStoreAdapter ( resolvedPath ) ;
7276 db . exec ( `
7377 CREATE TABLE IF NOT EXISTS ${ CONTRIBUTION_PROFILE_STORE_TABLE } (
7478 repo_full_name TEXT PRIMARY KEY,
@@ -79,16 +83,14 @@ export function initContributionProfileCache(
7983 // Schema-version convention (#4832): stamp the baseline. No post-baseline migrations for this v1 store yet.
8084 applySchemaMigrations ( db , [ ] ) ;
8185
82- const getStatement = db . prepare (
83- `SELECT profile_json, fetched_at FROM ${ CONTRIBUTION_PROFILE_STORE_TABLE } WHERE repo_full_name = ?` ,
84- ) ;
85- const putStatement = db . prepare ( `
86+ const getSql = `SELECT profile_json, fetched_at FROM ${ CONTRIBUTION_PROFILE_STORE_TABLE } WHERE repo_full_name = ?` ;
87+ const putSql = `
8688 INSERT INTO ${ CONTRIBUTION_PROFILE_STORE_TABLE } (repo_full_name, profile_json, fetched_at)
8789 VALUES (?, ?, ?)
8890 ON CONFLICT(repo_full_name) DO UPDATE SET
8991 profile_json = excluded.profile_json,
9092 fetched_at = excluded.fetched_at
91- ` ) ;
93+ ` ;
9294
9395 return {
9496 dbPath : resolvedPath ,
@@ -98,7 +100,8 @@ export function initContributionProfileCache(
98100 * miss (fail closed) rather than throwing — a corrupted/hand-edited file must not break discover.
99101 */
100102 get ( repoFullName : string , nowMs : number = Date . now ( ) ) : CachedContributionProfile | null {
101- const row = getStatement . get ( normalizeRepoFullName ( repoFullName ) ) as
103+ const { rows } = driver . query ( getSql , [ normalizeRepoFullName ( repoFullName ) ] ) ;
104+ const row = rows [ 0 ] as
102105 | { profile_json : string ; fetched_at : string }
103106 | undefined ;
104107 if ( ! row ) return null ;
@@ -121,7 +124,7 @@ export function initContributionProfileCache(
121124 put ( profile : ContributionProfile , nowMs : number = Date . now ( ) ) : { repoFullName : string ; fetchedAt : string } {
122125 const repoFullName = normalizeRepoFullName ( profile ?. repoFullName ) ;
123126 const fetchedAt = new Date ( nowMs ) . toISOString ( ) ;
124- putStatement . run ( repoFullName , JSON . stringify ( profile ) , fetchedAt ) ;
127+ driver . query ( putSql , [ repoFullName , JSON . stringify ( profile ) , fetchedAt ] ) ;
125128 return { repoFullName, fetchedAt } ;
126129 } ,
127130 /**
0 commit comments