Feat/user interactions#13
Conversation
Move docs generation from runtime schema introspection to a pre-built HTML file. Adds scripts/build-docs.ts, updates Dockerfile to copy the built HTML, and moves @graphql-tools/schema to devDependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Evolve organisations table (add slug, isActive, timestamps). Add teams, teamMembers, and teamLocations tables for flexible geographic scoping. Add defaultTeamId on user for frontend convenience. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add resolveTeamMembership guard, buildLocationFilterForTeam utility using recursive CTE for hierarchy expansion, and defaultTeamId to Better Auth config. Simplify context to remove server-side team state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Organisation and Team types, queries (myOrganisations, myTeams), and mutations (CRUD for orgs/teams, member management, setTeamLocations, setDefaultTeam). Update signals/events/alerts queries to accept explicit teamId argument for location-based filtering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ations - Implemented role-based access control for fetching alerts, events, and signals. - Non-admin users must now provide a teamId to access alerts, events, and signals within their team scope. - Added error handling for missing team memberships and improved error messages for forbidden access. - Updated organisation resolvers to include checks for organisation existence and improved error handling for member removal. - Introduced new enums for organisation and team member roles in the GraphQL schema. - Added fields for organisation creation and updates, including active status and timestamps. - Created migrations to deduplicate organisation slugs and rename foreign key constraints.
feat: multi-tenancy with orgs, teams, and location scoping
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add: ancestorIds to filter datapoints by regions
Add: org & team invitation handlers
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (46)
📝 WalkthroughWalkthroughThis PR introduces comprehensive multi-tenancy support, geographic location hierarchies, and team-based access control. It adds organizations, teams, invitations, and alert subscriptions with scoped location filtering, geospatial utilities for location resolution and ancestry computation, password reset functionality, a feedback and comments system, and build-time documentation generation from the GraphQL schema. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Server
participant Prisma
participant PostGIS
participant EmailProvider
Client->>Server: inviteUser(email, orgId, teamId?)
Server->>Prisma: findUnique organisation
Server->>Prisma: findUnique user (by email)
alt User exists
Server->>Prisma: create invitation + synthetic record
else User not found
Server->>Prisma: create invitation with 7-day expiry
Server->>EmailProvider: send invite email
EmailProvider-->>Client: email delivered
end
Server-->>Client: Invitation
Client->>Server: acceptInvite(token)
Server->>Prisma: findUnique invitation by token
alt Token valid & not expired
Server->>Prisma: create user via auth
Server->>Prisma: create organisationUsers + teamMembers
Server->>Prisma: mark invitation accepted
else Invalid or expired
Server-->>Client: GraphQLError (BAD_USER_INPUT)
end
Server-->>Client: true
Client->>Server: queryAlerts(teamId)
Server->>Prisma: findMany teamLocations
Server->>PostGIS: expand location IDs + descendants
Server->>Prisma: findMany alerts (filtered by location scope)
Server-->>Client: [Alert!]!
Client->>Server: createAlert(event, triggeredAt, severity)
Server->>Prisma: create alert
Server->>Prisma: findMany subscriptions (frequency: immediately, location match)
Server->>Prisma: createMany userAlerts + notifications
Server->>EmailProvider: send alert notification (async)
EmailProvider-->>Client: email queued
Server-->>Client: Alert
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
Release Notes
New Features
Documentation
Chores