@@ -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 and the repo-scoped purge still use the underlying DatabaseSync until those
69+ * helpers are migrated. Public API stays synchronous so callers need no async cascade in this part-1 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,7 @@ 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 row = driver . query ( getSql , [ normalizeRepoFullName ( repoFullName ) ] ) . rows [ 0 ] as
102104 | { profile_json : string ; fetched_at : string }
103105 | undefined ;
104106 if ( ! row ) return null ;
@@ -121,7 +123,7 @@ export function initContributionProfileCache(
121123 put ( profile : ContributionProfile , nowMs : number = Date . now ( ) ) : { repoFullName : string ; fetchedAt : string } {
122124 const repoFullName = normalizeRepoFullName ( profile ?. repoFullName ) ;
123125 const fetchedAt = new Date ( nowMs ) . toISOString ( ) ;
124- putStatement . run ( repoFullName , JSON . stringify ( profile ) , fetchedAt ) ;
126+ driver . query ( putSql , [ repoFullName , JSON . stringify ( profile ) , fetchedAt ] ) ;
125127 return { repoFullName, fetchedAt } ;
126128 } ,
127129 /**
0 commit comments