Storage implementations for AT Protocol OAuth applications. Provides a simple key-value storage interface with implementations for in-memory and SQLite backends.

Rename valTownAdapter to sqliteAdapter

BREAKING CHANGE: valTownAdapter has been renamed to sqliteAdapter.
The adapter works with any SQLite driver using the execute({ sql, args })
pattern - not just Val Town. This includes Val Town, libSQL, and Turso.

+22
CHANGELOG.md
··· 2 2 3 3 All notable changes to this project will be documented in this file. 4 4 5 + ## [1.0.0] - 2025-12-05 6 + 7 + ### Breaking Changes 8 + 9 + - Renamed `valTownAdapter` to `sqliteAdapter` - the adapter works with any 10 + SQLite driver using the `execute({ sql, args })` pattern (Val.Town, libSQL, 11 + Turso, etc.) 12 + 13 + ### Migration 14 + 15 + Replace: 16 + 17 + ```typescript 18 + import { valTownAdapter } from "@tijs/atproto-storage"; 19 + ``` 20 + 21 + With: 22 + 23 + ```typescript 24 + import { sqliteAdapter } from "@tijs/atproto-storage"; 25 + ``` 26 + 5 27 ## [0.1.1] - 2025-11-27 6 28 7 29 ### Fixed
+1 -1
deno.json
··· 1 1 { 2 2 "$schema": "https://jsr.io/schema/config-file.v1.json", 3 3 "name": "@tijs/atproto-storage", 4 - "version": "0.1.1", 4 + "version": "1.0.0", 5 5 "license": "MIT", 6 6 "exports": "./mod.ts", 7 7 "publish": {
+4 -4
mod.ts
··· 7 7 * - In-memory storage (for testing/development) 8 8 * - SQLite storage (works with any SQLite driver via adapters) 9 9 * 10 - * @example Val.Town / libSQL 10 + * @example Val.Town / libSQL / Turso 11 11 * ```typescript 12 12 * import { sqlite } from "https://esm.town/v/std/sqlite"; 13 - * import { SQLiteStorage, valTownAdapter } from "@tijs/atproto-storage"; 13 + * import { SQLiteStorage, sqliteAdapter } from "@tijs/atproto-storage"; 14 14 * 15 - * const storage = new SQLiteStorage(valTownAdapter(sqlite)); 15 + * const storage = new SQLiteStorage(sqliteAdapter(sqlite)); 16 16 * ``` 17 17 * 18 18 * @example Deno native SQLite ··· 54 54 export { 55 55 betterSqlite3Adapter, 56 56 denoSqliteAdapter, 57 - valTownAdapter, 57 + sqliteAdapter, 58 58 } from "./src/adapters.ts"; 59 59 export type { ExecutableDriver, PrepareDriver } from "./src/adapters.ts";
+7 -7
src/adapters.ts
··· 25 25 } 26 26 27 27 /** 28 - * Adapter for Val.Town sqlite and libSQL/Turso client. 29 - * These drivers share the same execute({ sql, args }) API pattern. 28 + * Adapter for SQLite drivers using the execute({ sql, args }) pattern. 29 + * Works with Val.Town sqlite, libSQL/Turso, and similar drivers. 30 30 * 31 31 * @example Val.Town 32 32 * ```typescript 33 33 * import { sqlite } from "https://esm.town/v/std/sqlite"; 34 - * import { SQLiteStorage, valTownAdapter } from "@tijs/atproto-storage"; 34 + * import { SQLiteStorage, sqliteAdapter } from "@tijs/atproto-storage"; 35 35 * 36 - * const storage = new SQLiteStorage(valTownAdapter(sqlite)); 36 + * const storage = new SQLiteStorage(sqliteAdapter(sqlite)); 37 37 * ``` 38 38 * 39 39 * @example libSQL/Turso 40 40 * ```typescript 41 41 * import { createClient } from "@libsql/client"; 42 - * import { SQLiteStorage, valTownAdapter } from "@tijs/atproto-storage"; 42 + * import { SQLiteStorage, sqliteAdapter } from "@tijs/atproto-storage"; 43 43 * 44 44 * const client = createClient({ url: "libsql://..." }); 45 - * const storage = new SQLiteStorage(valTownAdapter(client)); 45 + * const storage = new SQLiteStorage(sqliteAdapter(client)); 46 46 * ``` 47 47 */ 48 - export function valTownAdapter(driver: ExecutableDriver): SQLiteAdapter { 48 + export function sqliteAdapter(driver: ExecutableDriver): SQLiteAdapter { 49 49 return { 50 50 execute: async (sql: string, params: unknown[]): Promise<unknown[][]> => { 51 51 const result = await driver.execute({ sql, args: params });
+6 -6
src/storage.test.ts
··· 1 1 import { assertEquals, assertExists } from "@std/assert"; 2 2 import { MemoryStorage } from "./memory.ts"; 3 3 import { SQLiteStorage } from "./sqlite.ts"; 4 - import { valTownAdapter } from "./adapters.ts"; 4 + import { sqliteAdapter } from "./adapters.ts"; 5 5 import type { SQLiteAdapter } from "./types.ts"; 6 6 7 7 // Mock SQLite database that implements the ExecutableDriver interface 8 - // (used with valTownAdapter to create an SQLiteAdapter) 8 + // (used with sqliteAdapter to create an SQLiteAdapter) 9 9 class MockExecutableDriver { 10 10 private tables = new Map<string, Map<string, unknown[]>>(); 11 11 ··· 300 300 }); 301 301 }); 302 302 303 - Deno.test("SQLiteStorage - with valTownAdapter", async (t) => { 303 + Deno.test("SQLiteStorage - with sqliteAdapter", async (t) => { 304 304 const mockDriver = new MockExecutableDriver(); 305 - const adapter = valTownAdapter(mockDriver); 305 + const adapter = sqliteAdapter(mockDriver); 306 306 const storage = new SQLiteStorage(adapter); 307 307 308 308 await t.step("set and get value", async () => { ··· 369 369 370 370 // ============ Adapter Tests ============ 371 371 372 - Deno.test("valTownAdapter - transforms execute signature", async () => { 372 + Deno.test("sqliteAdapter - transforms execute signature", async () => { 373 373 let capturedSql = ""; 374 374 let capturedParams: unknown[] = []; 375 375 ··· 381 381 }, 382 382 }; 383 383 384 - const adapter = valTownAdapter(mockDriver); 384 + const adapter = sqliteAdapter(mockDriver); 385 385 const result = await adapter.execute("SELECT * FROM test WHERE id = ?", [ 386 386 123, 387 387 ]);