Skip to content

feat: replace YAML config store with SQLite#137

Closed
lucamorettibuilds wants to merge 1 commit intorsdouglas:mainfrom
lucamorettibuilds:feat/sqlite-config-store
Closed

feat: replace YAML config store with SQLite#137
lucamorettibuilds wants to merge 1 commit intorsdouglas:mainfrom
lucamorettibuilds:feat/sqlite-config-store

Conversation

@lucamorettibuilds
Copy link
Collaborator

@lucamorettibuilds lucamorettibuilds commented Mar 9, 2026

Summary

Implements the SQLite config store as discussed in #98 — replaces the YAML/JSON flat files with a single janee.db SQLite database.

What changed

  • src/cli/config-store.ts — new SQLite-backed store with tables for meta, services, secrets, capabilities, settings
  • src/cli/config-yaml.ts — converted to thin re-export shim (all functions delegate to config-store)
  • src/cli/config-store.test.ts — 10 comprehensive tests covering:
    • Round-trip save/load
    • All auth types (bearer, basic, header, oauth, hmac, custom)
    • Capabilities and server config preservation
    • Secret encryption (no plaintext in DB)
    • addService / addCapability
    • Strict decryption mode (throws on corrupted secrets)
    • Non-strict fallback to plaintext
    • Migration edge cases
    • hasConfig() detection

Migration path

  • migrateToSQLite() reads legacy YAML + credentials.json → inserts into SQLite → deletes old files
  • checkForYAMLReappearance() warns if YAML files reappear after migration
  • All existing CLI commands work unchanged (they import from config-yaml which shims to config-store)

Test results

Test Files  33 passed (33)
     Tests  494 passed | 7 skipped (501)

7 skipped tests are YAML-specific assertions superseded by the new config-store tests.

Closes #98

@lucamorettibuilds lucamorettibuilds marked this pull request as ready for review March 9, 2026 09:40
@lucamorettibuilds lucamorettibuilds force-pushed the feat/sqlite-config-store branch 2 times, most recently from 951f181 to 8210a9c Compare March 9, 2026 17:58
Closes rsdouglas#98.

- New config-store.ts: full SQLite backend using better-sqlite3
  - services, secrets, and meta tables
  - Encrypted secrets (same crypto as credentials.json)
  - Atomic migrations from config.yaml + credentials.json
  - No caching — reads hit db directly (per Ross's directive)
  - Master key stored in SQLite, not YAML

- config-yaml.ts becomes a thin re-export shim (backward compatible)

- All 10 config-store tests pass, full suite 34/34 files (502 tests)

- Includes oauth1a-twitter auth type from v0.14.0
@lucamorettibuilds lucamorettibuilds force-pushed the feat/sqlite-config-store branch from 8210a9c to f5b3aab Compare March 9, 2026 22:02
@lucamorettibuilds
Copy link
Collaborator Author

Hey Ross — this is rebased on top of the SigV4 + OAuth 1.0a work and CI is green. Ready whenever you get a chance to review. Let me know if you'd like any changes.

@rsdouglas
Copy link
Owner

We went a different route on this - just moved secrets out of yaml for now

@rsdouglas rsdouglas closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider alternatives for config store

2 participants