sendi/tests
jmcqueen f18f024fc7 Add stale-space tooling: Webex report + DB pruner
Two operational scripts and their shared library. Both are read-only by
default; the pruner requires an explicit --apply flag to touch anything.

scripts/webex-rooms-report.ts
- Fetches every room the current WEBEX_TOKEN can see (paginated /v1/rooms)
- Buckets rooms by lastActivity age (7d, 30d, 3m, 6m, 12m, 18m, 24m, >24m)
- Cross-references against legacy/spaces.json to distinguish sendi-managed
  rooms from others
- Prints a summary table plus a sample listing; makes zero writes

scripts/prune-stale-spaces.ts
- Finds Space rows whose most recent Message.createdAt (falling back to
  Space.createdAt) is older than --months=N (default 24)
- Dry-run by default; --apply performs deletions
- Deletes the Webex room via REST (Bearer WEBEX_TOKEN) then removes the
  Space row (cascade removes Message, BulkJob, Survey, PendingMessage)
- --no-webex skips the Webex delete for DB-only pruning
- --limit=N caps how many spaces get processed per run

src/lib/staleSpaces.ts
- Pure `monthsAgo` and `computeLastActivity` helpers used by the pruner
- `findStaleSpaces(prisma, months)` runs the query and sorts oldest-first

package.json scripts: `webex-rooms-report`, `prune-spaces`

Tests: 6 new unit tests for the pure helpers (51 total, all green)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 12:19:17 -04:00
..
integration Harden packaging, add error taxonomy, persist pending messages 2026-07-06 11:41:18 -04:00
unit Add stale-space tooling: Webex report + DB pruner 2026-07-06 12:19:17 -04:00
setup.ts Initial commit: Sendi 2.0 SMS gateway (Webex + Twilio) 2026-07-06 11:10:44 -04:00