ninety-teams.ts
Language TypeScript2.4 KB60 lines
/*** Ninety teams, and which of them carry restricted work.** As read from the directory (`pnpm smoke` prints it):** Leadership Team 3daec27fdbd4c3a983e95864 12 open to-dos* Operations Team 20b8a35b8edd3ed30b2d8f30 2* All Hands eb3d8bb215506d3263d47cac 19* (no team) 3** The rule: Leadership Team to-dos are visible only to the people cleared for* them (`seesLeadership` in the roster). Everything in All Hands stays visible* to everyone, so the whole team can see where the company stands. That is a* confidentiality boundary, so it is written down in one place rather than* inferred from a team name at three call sites.** Matched by id first. A team gets renamed the same way a person does, and the* whole reason `ninetyId` exists on the roster is that display names in Ninety* drift. A rename here would not merely mislabel something; it would silently* unrestrict it.*//** Ninety team id -> display name. */export const NINETY_TEAMS: Record<string, string> = {'3daec27fdbd4c3a983e95864': 'Leadership Team','20b8a35b8edd3ed30b2d8f30': 'Operations Team','eb3d8bb215506d3263d47cac': 'All Hands',}export const LEADERSHIP_TEAM_ID = '3daec27fdbd4c3a983e95864'/** Kept only so a rename is recognisable; the id is what decides. */const LEADERSHIP_NAMES = new Set(['leadership team', 'leadership'])/*** Whether a to-do is restricted to the leadership-cleared readers.** Untagged counts as restricted. Some to-dos carry no team at all, and an item* with no team could be anything. Failing open would mean a Leadership to-do* that lost its tag becomes readable by everyone, silently. Failing closed hides at most a* few All Hands items, and `untaggedTodoCount()` exists so that is stated on the* page rather than absorbed.*/export function isRestrictedTeam(teamId: string | null | undefined,teamName?: string | null,): boolean {if (!teamId) return trueif (teamId === LEADERSHIP_TEAM_ID) return true// An id this file has never seen is also unknown work. Same reasoning.if (!(teamId in NINETY_TEAMS)) return truereturn LEADERSHIP_NAMES.has((teamName ?? '').trim().toLowerCase())}/** How many to-dos are restricted only because nothing says which team they are in. */export function untaggedTodoCount(todos: { teamId: string | null | undefined }[],): number {return todos.filter((t) => !t.teamId).length}