fix(mcp): use local sqlite scene storage
This commit is contained in:
@@ -1,29 +1,17 @@
|
||||
import type { SceneStore } from './types'
|
||||
|
||||
export * from './slug'
|
||||
export * from './sqlite-scene-store'
|
||||
export * from './types'
|
||||
|
||||
/**
|
||||
* Factory that picks the correct `SceneStore` backend based on env:
|
||||
* - If `SUPABASE_URL` and `SUPABASE_SERVICE_ROLE_KEY` are both set → Supabase.
|
||||
* - Otherwise → filesystem.
|
||||
* Factory for Pascal's local-first scene store.
|
||||
*
|
||||
* Implementations are loaded via dynamic `import()` so consumers only pay the
|
||||
* cost of the backend they actually use.
|
||||
* The store is backed by the runtime's built-in SQLite driver. By default it
|
||||
* writes to `~/.pascal/data/pascal.db`; set `PASCAL_DB_PATH` for an exact file
|
||||
* path or `PASCAL_DATA_DIR` for a directory containing `pascal.db`.
|
||||
*/
|
||||
export async function createSceneStore(env?: NodeJS.ProcessEnv): Promise<SceneStore> {
|
||||
const resolved = env ?? (typeof process !== 'undefined' ? process.env : undefined)
|
||||
const supabaseUrl = resolved?.SUPABASE_URL
|
||||
const supabaseKey = resolved?.SUPABASE_SERVICE_ROLE_KEY
|
||||
|
||||
if (supabaseUrl && supabaseKey) {
|
||||
const mod = await import('./supabase-scene-store')
|
||||
return new mod.SupabaseSceneStore({
|
||||
url: supabaseUrl,
|
||||
serviceRoleKey: supabaseKey,
|
||||
})
|
||||
}
|
||||
|
||||
const mod = await import('./filesystem-scene-store')
|
||||
return new mod.FilesystemSceneStore()
|
||||
const mod = await import('./sqlite-scene-store')
|
||||
return new mod.SqliteSceneStore({ env })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user