feat: SQLiteAppender, source map resolution, callSiteOffset #62

Merged
mburchard merged 8 commits from demo/sqlite into main 2026-02-25 12:43:12 +00:00
Owner

Summary

  • Add SQLiteAppender with better-sqlite3 as optional peer dependency (dynamic import, close() method, full test suite)
  • Add automatic source map resolution for call-site positions in bundled environments (optional @jridgewell/trace-mapping)
  • Extract stack-trace parsing into dedicated module
  • Add configurable callSiteOffset for logger wrappers (skips additional stack frames in Tier 2/3, not for real Errors)
  • Upgrade to Node 22, update dependencies and build config

Test plan

  • 261 tests passing
  • Coverage: 100% lines, 100% branch
  • Lint and typecheck clean
  • Manual test with SQLiteAppender and better-sqlite3
  • Verify source map resolution in bundled environment
## Summary - Add SQLiteAppender with better-sqlite3 as optional peer dependency (dynamic import, close() method, full test suite) - Add automatic source map resolution for call-site positions in bundled environments (optional @jridgewell/trace-mapping) - Extract stack-trace parsing into dedicated module - Add configurable callSiteOffset for logger wrappers (skips additional stack frames in Tier 2/3, not for real Errors) - Upgrade to Node 22, update dependencies and build config ## Test plan - [x] 261 tests passing - [x] Coverage: 100% lines, 100% branch - [x] Lint and typecheck clean - [x] Manual test with SQLiteAppender and better-sqlite3 - [ ] Verify source map resolution in bundled environment
- Add close() method to cleanly release the database connection
- Use close() in afterEach to prevent leaking file handles across tests
- Add close() idempotency test verifying re-open after close works
- Add test verifying standard array payload is stored correctly in the DB
- Remove completed Todo section from README
- Move better-sqlite3 from optionalDependencies to peerDependencies (optional: true)
- Replace static import with dynamic import() in initDB() so the module can be imported
  without requiring the peer dependency to be installed
- Add isModuleNotFound() helper with recursive cause-chain inspection for clear error
  messages when the dependency is missing
- Add export entry for SQLiteAppender in package.json
- Update better-sqlite3 to v12.6.2
- Add test for missing dependency error message
- Extract stack-trace helpers (resolveFirstCallSite, findErrorInArgs, resolveCallSiteFromStack)
  from logger.ts into dedicated stack-trace.ts module
- Add source-map-resolver.ts for automatic call-site resolution in DOM environments using
  @jridgewell/trace-mapping (optional peer dependency)
- Upgrade from @tsconfig/node20 to @tsconfig/node22, replace .npmrc with .node-version
- Move pnpm.onlyBuiltDependencies to pnpm-workspace.yaml (pnpm 10 convention)
- Add dedicated tests for stack-trace.ts and source-map-resolver.ts (100% coverage)
- Add branch-coverage tests for SQLiteAppender (non-Error throw, calcFullFilePath failure)
- Add source-map queuing test in logger.spec.ts
- Rewrite README: add feature overview, document source map resolution and @jridgewell/trace-mapping
- Bump version to 1.2.0
feat: add configurable callSiteOffset for logger wrappers
All checks were successful
Run Tests / test (pull_request) Successful in 1m8s
45c8c65e96
- Add callSiteOffset to LoggerConfig and ILogger interfaces
- Implement property with parent inheritance in Logger class
- Extend resolveFirstCallSite and resolveCallSiteFromStack
  with offset parameter (skips additional stack frames)
- Offset applies to Tier 2 (captureStackTrace) and Tier 3
  (fallback) only; real Errors in payload stay unaffected
- Wire offset through configureLogging for root and logger
- Add 10 new tests (261 total), all green, coverage stable
- Document feature in README (Call Site Offset section)
docs: update trace-mapping link to active monorepo
All checks were successful
Run Tests / test (pull_request) Successful in 1m0s
Run Tests / test (push) Successful in 1m9s
6186883f99
mburchard deleted branch demo/sqlite 2026-02-25 12:43:12 +00:00
Sign in to join this conversation.
No description provided.