pi-mono/packages/durable/test/store-storage-node.ts
Mario Zechner 14b4c56e57 feat(chord,durable): Chord v2 slice 6b, Durable and jobs on the store
StoreStorage (Durable's storage on Chord v2's store, @earendil-works/pi-durable/storage/store) passes
Durable's storage conformance suite and runs Durable's harness tests (npm run test:store). The store
gets owner names and claims, one id allocator, Durable's Storage semantics for refused steps, history
none/latest/rewindable with reads at a point, archive revisions and applyBatch. self.follow follows
Durable's synchronous observers as Chord sources. Persisted jobs: records and state in the owner's
store, restarts as Durable's tasks, abort stored, deferred state. Chord's ./next export returns for
the adapter surface.
2026-10-28 19:18:30 +00:00

23 lines
1.2 KiB
TypeScript

// What `vitest.store.config.ts` puts in the place of `../src/storage/sqlite/node.ts`: the same exports, with
// `openNodeSqliteStorage(path)` opening Durable's storage on Chord's store over that file (`StoreStorage`), so the
// harness test files that take a SQLite storage run unchanged on the store.
import type { NodeSqliteDatabaseOptions } from "@earendil-works/chord/sqlite/node";
import type { SqliteStorageOptions } from "../src/storage/sqlite/index.ts";
import type { Storage } from "../src/types.ts";
import { openStoreStorage } from "./store-storage-support.ts";
export {
NodeSqliteDatabase,
type NodeSqliteDatabaseOptions,
openNodeSqliteDatabase,
} from "@earendil-works/chord/sqlite/node";
/** Node SQLite connection settings plus durable storage options, as the original takes them. */
export type NodeSqliteStorageOptions = NodeSqliteDatabaseOptions & SqliteStorageOptions;
/** A `StoreStorage` on a store over the file at `path`; a table prefix becomes nothing (the owner name separates). */
export function openNodeSqliteStorage(path: string, options: NodeSqliteStorageOptions = {}): Promise<Storage> {
const { prefix: _prefix, ...database } = options;
return openStoreStorage(path, database);
}