diff --git a/components/layout/app-shell.tsx b/components/layout/app-shell.tsx index 8586c55..d35d20b 100644 --- a/components/layout/app-shell.tsx +++ b/components/layout/app-shell.tsx @@ -123,7 +123,7 @@ export function AppShell({ Log out -

v1.2.2

+

v2.0.0

diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9cff5be..0d3a358 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -21,6 +21,80 @@ _Nothing yet._ --- +## [2.0.0] - 2026-11-06 + +**Breaking:** the Reporter, Supervisor and CAPA Owner roles are merged into one +role, **Site Safety Assistant (SSA)**. Existing sessions carry the old role, so +those users must log out and in again after the deploy. + +### Changed + +- **Roles — `reporter`, `supervisor` and `capa_owner` become `ssa`.** + The role set is now `ssa`, `hse`, `management`, `admin`. + - SSA sees incidents for their own site and their own reports, can update + incidents, and works their assigned CAPAs. + - Role checks in the API, the nav, notifications (e.g. new-incident and CAPA + escalation emails) and the user manager now use `ssa`. + - Unknown roles fall back to the SSA navigation. +- **Pages moved under `/ssa`:** `/reporter` → `/ssa/my-reports`, + `/supervisor` → `/ssa`, `/supervisor/incidents` → `/ssa/incidents`, + `/capa-owner` → `/ssa/capas`. The header search for SSA targets `/ssa/incidents`. + +### Removed + +- Legacy Supabase code and dependencies: `lib/supabase/*`, `@supabase/ssr`, + `@supabase/supabase-js` and the `supabase/` migrations folder. The app already + ran on local PostgreSQL; `db/schema.sql` and `db/rls.sql` are the schema source + of truth. + +### Affected modules + +Auth and roles (`lib/auth/roles.ts`), navigation and shell (`components/layout/*`), +SSA pages (`app/(protected)/ssa/*`), incident, CAPA and addenda API routes, +admin user manager, email and CAPA-escalation notifications, RLS policies. + +### Database migrations + +- **`db/ops/2026-11-06-merge-roles-into-ssa.sql`**, applied by hand to production + on 2026-11-06 as the `postgres` superuser (the app DB user cannot bypass RLS). + One transaction: converts `reporter`/`supervisor`/`capa_owner` users to `ssa`, + recreates the `user_role` enum as `ssa, hse, management, admin`, recreates + `auth_user_role()`, then drops and re-creates all 34 RLS policies. + Take a `pg_dump` first. Users with the old role in their session cookie must log + out and in again. +- No migration is needed for the Supabase removal. + +### API changes + +- No endpoint was added or removed. The role value in the session and in + `/api/admin/users` is now `ssa` instead of `reporter`, `supervisor` or + `capa_owner`. Creating or updating a user with any role outside the four new + ones returns `422 Invalid role`; the default role for a new user is `ssa`. +- Page routes changed as listed under **Changed**. + +### Testing + +1. Log in as an `ssa` user. Check `/ssa`, `/ssa/my-reports`, `/ssa/incidents` + (site incidents only) and `/ssa/capas`. +2. Submit a new incident at `/report` and confirm it shows under **My Reports**. +3. Open an assigned CAPA and submit proof (note and photos). +4. As `hse` and `admin`, confirm dashboards, incident lists and the user manager + still work, and that the user manager offers only the four new roles. +5. Run `npm run test` and `npm run build`. Seven tests fail on `main` as well + (AI routes, bulk-import, email); no new failures were introduced. +6. In Postgres: `SELECT DISTINCT role FROM users;` returns only + `ssa`, `hse`, `management`, `admin`. + +### Also in this version since 1.2.2 (summarised from git history) + +- IMS Admin UI refresh: new tokens, Geist, `TableCard`, new shells; Incidents and + CAPA lists migrated. +- CAPA owners submit proof with a note and photos; HSE sees a photo gallery. +- Trucks are linked to a site; the report form lists all trucks. +- AI provider switched to a local model. + +--- + ## [1.1.0] - 2026-07-16 ### Fixed diff --git a/package-lock.json b/package-lock.json index 16a07ce..a013dc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ims-app", - "version": "1.2.2", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ims-app", - "version": "1.2.2", + "version": "2.0.0", "dependencies": { "@anthropic-ai/sdk": "^0.111.0", "bcryptjs": "^3.0.3", diff --git a/package.json b/package.json index 23fa892..14c6661 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ims-app", - "version": "1.2.2", + "version": "2.0.0", "private": true, "scripts": { "dev": "next dev", diff --git a/tests/components/layout/app-shell.test.tsx b/tests/components/layout/app-shell.test.tsx index 023257d..84e35aa 100644 --- a/tests/components/layout/app-shell.test.tsx +++ b/tests/components/layout/app-shell.test.tsx @@ -62,7 +62,7 @@ describe('AppShell', () => { it('shows the user chip, version label, and logs out', async () => { render() expect(screen.getAllByText('AL').length).toBeGreaterThan(0) - expect(screen.getByText('v1.2.2')).toBeTruthy() + expect(screen.getByText('v2.0.0')).toBeTruthy() fireEvent.click(screen.getAllByRole('button', { name: /Log ?out/i })[0]) await Promise.resolve() expect(fetch).toHaveBeenCalledWith('/api/auth/logout', { method: 'POST' })