Files
2026-05-27 23:29:53 +01:00

3.5 KiB

Tasks — extend-better-auth-surrealdb-v1.6-adapter

1. Implementation

  • 1.1 Read installed node_modules/better-auth/dist/index.d.mts for BetterAuthOptions.database + DBAdapterInstance type
  • 1.2 Read node_modules/@better-auth/core/dist/db/adapter/index.d.mts for createAdapterFactory signature + every method the v1.6 DBAdapter requires
  • 1.3 Add src/adapter/v1.6.{ts,test.ts,md} exporting betterAuthSurrealAdapter(options): DBAdapterInstance; barrel updated in existing src/adapter/index.ts
  • 1.4 v1.6.ts internals:
    • 1.4.1 Zod-validate options via the existing BetterAuthSurrealAdapterOptionsSchema
    • 1.4.2 Build the underlying 10-method adapter via createBetterAuthSurrealAdapter(options)
    • 1.4.3 Return (betterAuthOptions) => createAdapterFactory(...) wired with CRUD forwarders, schema literal, and tx-aware transaction
    • 1.4.4 OTel: emit better_auth.surrealdb.operations_total{model: "_transaction", operation: "transaction", outcome} per transaction() invocation
  • 1.5 Add subpath export ./adapter/v1.6 to package.json exports
  • 1.6 Re-export betterAuthSurrealAdapter + BetterAuthSurrealAdapterV16Options type from src/index.ts (named exports only)
  • 1.7 Update README.md quick-start to lead with betterAuthSurrealAdapter v1.6; keep v1.4 surface in an "Advanced" section

2. Tests

  • 2.1 src/adapter/v1.6.test.ts — 11 unit scenarios covering the spec delta (factory shape; INVALID_INPUT for bad options; CRUD method existence; createSchema verbatim; errors propagate; createAsIsTransaction fallback; per-method round-trip; SurrealAdapter-branch transaction round-trip; transaction CRUD coverage)
  • 2.2 src/adapter/v1.6.spec-conformance.test.ts — expectTypeOf confirms the return type satisfies Better-Auth's DBAdapterInstance
  • 2.3 Extend tests/integration/conformance.test.ts with v1.6 smoke describe block (the full v1.4-shape harness is incompatible with the v1.6 wrapper because Better-Auth's transformInput whitelists fields against an in-memory schema that uses column names different from the bundled SurrealQL schema — see end-to-end test for the production signal)
  • 2.4 Add tests/integration/better-auth-end-to-end.test.ts — betterAuth({ database: betterAuthSurrealAdapter({ client }), … }) → auth.api.signUpEmail round-trip against a real SurrealDB testcontainer; asserts user and account rows landed
  • 2.5 All new tests via @suaveplan/testing/runner, { timeout: 5000 } (60000 for integration)

3. Gates

  • 3.1 bunx turbo lint typecheck test --filter=@suaveplan/better-auth-surrealdb --force → green
  • 3.2 Coverage 100/100/100/100 on the new v1.6 path (bunx vitest run --coverage src/ tests/dep-graph.test.ts tests/property.test.ts)
  • 3.3 bun scripts/openspec-conformance.ts @suaveplan/better-auth-surrealdb → PASS (0 error)
  • 3.4 bunx turbo build --filter=@suaveplan/better-auth-surrealdb --force → green; dist/adapter/v1.6.{js,d.ts} emitted and resolves via the new ./adapter/v1.6 subpath
  • 3.5 Banned-pattern + no export * + no direct runner imports (bun scripts/lint/check-test-runner-imports.ts → green)

4. Archive

  • 4.1 Fold spec → append the 5 new requirements to canonical openspec/specs/better-auth-surrealdb/spec.md
  • 4.2 mv change → openspec/archive/2026-05-18-extend-better-auth-surrealdb-v1.6-adapter/
  • 4.3 DO NOT refresh MANIFEST or STATUS — orchestrator consolidates after the chain