feat(federation): grants service CRUD + status transitions (FED-M2-06) #496
Reference in New Issue
Block a user
Delete Branch "feat/federation-m2-grants-service"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
'pending'tograntStatusEnum(lifecycle:pending → active → revoked/expired), with migration0009_federation_grant_pending.sqlGrantsServicewith six methods:createGrant,getGrant,listGrants,activateGrant,revokeGrant,expireGrantparseFederationScopebefore insert; invalid transitions throwConflictException; missing grants throwNotFoundExceptionFederationModuleupdated to provide and exportGrantsServiceCloses #461
Test plan
pnpm typecheckpassespnpm lintpassespnpm format:checkpassespnpm testpasses (414 gateway tests including 25 new grants service specs)0009_federation_grant_pending.sqlapplies cleanly on a fresh DB🤖 Generated with Claude Code
Independent Code Review — APPROVE
Reviewed by Opus 4.7 (independent agent, no shared context with author).
HIGH issues: None
MEDIUM (non-blockers, defer to follow-up)
parseFederationScopethrowsFederationScopeError(plain Error). When M2-07 wires this to HTTP it will be a 500. Fix in M2-07: catch and re-throw asBadRequestException, or add a Nest exception filter.listGrants({})is unbounded — no LIMIT. Add default cap +limit/offsettoListGrantsDtobefore row count grows.!non-null assertions on.returning()results — safe in practice; a smallassertReturned()helper would surface schema regressions more clearly.@IsObject()validates top-level only — fine architecturally; compounds #1 until scope error mapping is fixed.Checklist
revoke-already-revoked,activate-already-active/revoked/expired,expire-pending/expired/revoked) throwConflictException. Tested. ✓ALTER TYPE ... ADD VALUE 'pending' BEFORE 'active'+SET DEFAULT 'pending'verified against PG17 — runs in transaction. ✓deploy/portainer/federated-test.stack.ymlnot in this commit. ✓anytypes. ✓.jsimports, explicit@Inject(DB), DTOs in*.dto.ts— all compliant. ✓Verdict: APPROVE