3.5 KiB
3.5 KiB
Tasks — extend-better-auth-surrealdb-v1.6-adapter
1. Implementation
- 1.1 Read installed
node_modules/better-auth/dist/index.d.mtsforBetterAuthOptions.database+DBAdapterInstancetype - 1.2 Read
node_modules/@better-auth/core/dist/db/adapter/index.d.mtsforcreateAdapterFactorysignature + every method the v1.6DBAdapterrequires - 1.3 Add
src/adapter/v1.6.{ts,test.ts,md}exportingbetterAuthSurrealAdapter(options): DBAdapterInstance; barrel updated in existingsrc/adapter/index.ts - 1.4 v1.6.ts internals:
- 1.4.1 Zod-validate
optionsvia the existingBetterAuthSurrealAdapterOptionsSchema - 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}pertransaction()invocation
- 1.4.1 Zod-validate
- 1.5 Add subpath export
./adapter/v1.6topackage.jsonexports - 1.6 Re-export
betterAuthSurrealAdapter+BetterAuthSurrealAdapterV16Optionstype fromsrc/index.ts(named exports only) - 1.7 Update
README.mdquick-start to lead withbetterAuthSurrealAdapterv1.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—expectTypeOfconfirms the return type satisfies Better-Auth'sDBAdapterInstance - 2.3 Extend
tests/integration/conformance.test.tswith v1.6 smoke describe block (the full v1.4-shape harness is incompatible with the v1.6 wrapper because Better-Auth'stransformInputwhitelists 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.signUpEmailround-trip against a real SurrealDB testcontainer; assertsuserandaccountrows 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.6subpath - 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