You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(billing): hygiene polish — stack trace, req.id, $slice ledger, TTL archived, cache utils
Étape 5 — Polish (devkit-only):
A — lastError + req.id correlation
- incrementAttempts stores err.stack (not just message); JSON fallback for plain-object throws
- withIdempotency accepts optional ctx.requestId; logs entry/skip/retry/dead-letter
- Webhook controller reads req.id and threads it into all withIdempotency calls
B — Performance hygiene
- listLedger: new listLedgerPage() repo method uses $slice aggregation — only the page
is transferred over the wire; perf integration test asserts < 50ms on 1000 entries
- BillingUsage: TTL index on archivedAt (1-year, partialFilterExpression $type date)
so archived weekly periods are auto-purged without touching active docs
C — Tier 3 nits
- Removed module-scope METER_RUN_BASE const (stale at load time); getMeterRunBase()
function kept and re-exported from billing.meter.service.js
- Exported clearPlansCache() from billing.plans.service.js for test isolation
- fetchPlansFromStripe: explicit warn log when Stripe price ID mapped to multiple plans
* fix(billing): harden tests + $ifNull guard on listLedgerPage ledger field
- Add $ifNull(['$ledger', []]) guard in $size and $sortArray expressions
so listLedgerPage is robust against legacy/partial docs with missing ledger
- Add toHaveBeenCalledTimes(1) assertions before mock.calls[0] access in
webhook idempotency + hardening tests for clearer failure diagnostics
- Add dedicated controller test asserting req.id is propagated as requestId
into withIdempotency third arg
0 commit comments