Simplify: one abstract base class per layer
CI / Node 20 (pull_request) Successful in 10s
CI / Node 22 (pull_request) Successful in 11s

- BaseKVStorage / BaseEventStorage / BaseDocumentStorage define the API once;
  implementations provide only raw primitives (client and server share an API)
- Drop KV indexes, query planner, unique indexes; document stores take index fields
- Escape every char <= '/' so child keys stay contiguous; skip-scan is now simple
- Event-sourced documents = event storage + any document store for projections
- New folder layout (kv-storage, event-storage, document-storage, utils); tests only in test/

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qxbkp4tA7G5SCWjzWuxmE
This commit is contained in:
Claude
2026-10-23 08:05:03 +00:00
parent e27541c46a
commit 08fb78721f
80 changed files with 2518 additions and 6337 deletions
+16 -16
View File
@@ -1,24 +1,24 @@
# PotentialStorage
Layered TypeScript storage library: KV → Events → Documents. The full design, milestones and
implementation decisions are in [DESIGN.md](./DESIGN.md) — read it before changing anything.
Record new decisions in DESIGN.md section 12.
Layered TypeScript storage library: KV → Events → Documents. The design is in
[DESIGN.md](./DESIGN.md); read it before changing anything and keep it up to date.
## Commands
- `npm test` — `tsc --noEmit` then all Vitest tests (including `*.test-d.ts` type tests)
- `npm run test:only -- <file>` — Vitest only, e.g. a single file
- `npm run typecheck` — `tsc --noEmit` over src, test and bench
- `npm run bench` — `vitest bench`
- `npm run build` — emit `dist/`
- `npm run format` / `npm run format:check` — Prettier
- `npm test`: `tsc --noEmit`, then all Vitest tests (including `test/types.test-d.ts`)
- `npm run test:only -- <file>`: Vitest only
- `npm run typecheck`, `npm run build`, `npm run bench`
- `npm run format` / `npm run format:check`: Prettier
CI (`.gitea/workflows/ci.yml`, Gitea Actions) runs format check, typecheck, tests and build on Node 20 and 22.
CI (`.gitea/workflows/ci.yml`, Gitea Actions) runs the format check, typecheck, tests and build on Node 20 and 22.
## Rules
## Conventions
- No runtime dependencies in `src/`. Dev dependencies only.
- Drivers stay flat and string-keyed; all path/index/escaping logic lives in the node classes.
- Self vs child dispatch is by `arguments.length`; a passed-but-`undefined`/`null` key throws.
- Multi-result reads are `AsyncIterable`; don't build large arrays internally.
- Keep tests green and commit per milestone. Ask the owner before pushing.
- One abstract base class per layer (`src/<layer>/base-*.ts`); implementations only provide the raw
primitives, and the user-facing API lives in the base class.
- Classes over loose functions; TS `private`, not `#`; no overloads (use `param?` or tuple-union
rest params); don't override base methods in subclasses.
- No runtime dependencies. Tests live only in `test/`, mirroring `src/`.
- New KV/document implementations must pass `test/kv-storage/kv-storage.conformance.ts` /
`test/document-storage/document-storage.suite.ts`.
- Ask the owner before pushing.