Skip to content

feat(teams): backend foundation — orgs/teams/RBAC APIs + schema#6

Merged
PolGuixe merged 1 commit into
stagingfrom
feat/teams-backend-foundation
Jun 5, 2026
Merged

feat(teams): backend foundation — orgs/teams/RBAC APIs + schema#6
PolGuixe merged 1 commit into
stagingfrom
feat/teams-backend-foundation

Conversation

@PolGuixe

@PolGuixe PolGuixe commented Jun 5, 2026

Copy link
Copy Markdown
Member

Phases 1 (schema) + 2 (backend APIs) of docs/TEAMS_AND_ORGS_PLAN.md, plus most of Phase 3 (invitations).

Schema (backend/migrations/0001_teams_orgs.sql, additive, applied+verified on staging):
orgs/teams/members, permissions(29)/roles(5)/role_permissions(107), role_assignments, invitations, resource_locks, audit_log; nullable org_id/team_id on resource tables; personal-org provisioning + backfill. No RLS yet (deferred to the coordinated hardening phase).

Backend APIs:

  • /organizations (list+auto-provision personal, create, get, update, delete)
  • /organizations/:orgId/teams|members|roles|invitations
  • /invitations/accept
  • /locks/:type/:id (acquire/heartbeat/release/status)
  • RBAC via loadOrgContext + requirePerm; audit logging; Resend email wrapper (returns accept_url until SMTP wired).

Safety: non-breaking — existing routes untouched, new tables/columns additive, service-role backend unaffected. tsc green.

Deploys to staging on merge for API testing. Prod untouched.

🤖 Generated with Claude Code

Phase 1 (schema) + Phase 2 (backend APIs) of the teams/orgs plan.

Migration backend/migrations/0001_teams_orgs.sql (additive, no RLS yet):
- organizations, organization_members, teams, team_members
- permissions (29), roles (5 system) + role_permissions (107 mappings)
- role_assignments, invitations, resource_locks, audit_log
- nullable org_id/team_id on projects/workflows/tabular_reviews/chats/subfolders
- app_provision_personal_org() + backfill of personal orgs for existing users
Applied + verified on the staging Supabase project.

Backend:
- lib/tenancy.ts — membership + permission resolution, loadOrgContext +
  requirePerm middleware, audit + personal-org helpers
- lib/email.ts — Resend wrapper (no-ops without RESEND_API_KEY; returns
  accept_url for manual sharing until SMTP is wired)
- routes: organizations, teams, members, roles, invitations (+ accept), locks
- wired into index.ts (nested routers use mergeParams for :orgId)

Non-breaking: existing routes untouched; new tables/columns are additive and
the service-role backend is unaffected. RLS, the user_id->uuid migration,
frontend, and resource scoping are tracked as later phases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PolGuixe PolGuixe merged commit e86a05b into staging Jun 5, 2026
5 checks passed
@PolGuixe PolGuixe deleted the feat/teams-backend-foundation branch June 5, 2026 14:46
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.

1 participant