Organisation

Teams

Teams owned by an operation or the platform, members with a role from their team kind's ladder, and mapping rules that give people a team role without adding them by hand.

Teams holds the teams crew work in: the bars of a festival operation, a first aid team of the platform. Each team has a kind, and the kind's ladder holds the roles its members can have. Your app defines its kinds and ladders, such as a bar ladder of volunteer, bartender, lead and coordinator. Staff add members by hand, or add mapping rules so that everyone with a global role or a plan holds a team role on their own: a global supervisor is a lead in every bar of an operation. It is the source of team roles for the team grant kind of Auth's record audiences and the volunteering modules, such as Crew. For permissions that code checks, use Authorization instead.

The package is @frigear-nu/teams. It owns owner references, and registers the team grant kind of record audiences.

What you get

  • Admin area (opt-in, with Admin): a team list at /admin/teams, filterable by owner, and a team page at /admin/teams/:id with its members, mapping rules, the projects it works on and the ladder of its kind; a project list at /admin/projects and a project page at /admin/projects/:id. The sidebar entries needs Menu. With Widget, a Teams tab on the operation page of Operations (@frigear-nu/operations).
  • Public pages (on by default): a list and a page per team for each public section (/teams and /teams/:slug), and /projects and /projects/:slug, for teams and projects staff made public. Each kind picks its section. Members choose themselves whether they are shown there. See Public pages.
  • Server routes (on by default): your own teams and roles, the public team reads, a team's page and members, and a staff API for teams, members, mapping rules and ladders.
  • Server helpers (auto-imported): resolveTeamRoles, teamMembers and isTeamLead for other modules.
  • Hooks: teams:member:added, teams:member:removed, teams:member:role-changed, and the provider hooks teams:roles:resolve and teams:members:candidates.
  • OAuth claim: a teams claim in id tokens and userinfo, with OAuth Server.
  • Emails. None built in. Send one from teams:member:added.
ServerClientMobile
Installed for you:Auth, Users, UI and Module Kit. You add:@nuxthub/core, and @nuxt/ui for the pages. Optional:Admin for the admin pages, Widget for the tab on the operation page, Menu for the sidebar entry, Subscriptions for plan rules, OAuth Server for the claim, and Authorization so mapped members can be listed.

Quick setup

Install Teams

pnpm add @frigear-nu/teams @nuxthub/core

Add it to nuxt.config.ts

List Admin (or Widget and Menu) before Teams, so the tab and the menu entry register.

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxthub/core', '@frigear-nu/admin', '@frigear-nu/teams'],
  teams: {
    settings: {
      pages: { admin: true, adminTeam: true },
    },
  },
})

Generate the migration

Without a migration the teams tables do not exist, and every request to them fails.
pnpm db:generate

Decide who manages teams

Staff routes check permissions through Authorization. Without a role that holds teams:manage, nobody can manage teams. The admin role holds it when your app defines it; grant it to your own roles by name (authorization.roles.<role>.grant: ['teams:manage', 'teams:pii']).
What you should see: a coordinator opens an operation's Teams tab and adds "Main bar". They add a mapping rule "global role supervisor is lead" for every team of the operation. A user with the global role supervisor now sees the bar with the role lead and source: 'mapped' at GET /api/teams/me, without being added.

Options

Options go under the teams key.

OptionTypeDefaultPurpose
laddersRecord<kind, { label?, description?, section?, roles, leadFrom? }>the generic default ladder (member, lead)Your app's ladders by team kind, stored on the first request. Your app's ladders sit next to the shipped ones; a kind of the same name replaces the shipped one. Seed only: see Ladders.
imageUploadbooleanfalseAn image upload in the staff team and project forms, stored in NuxtHub Blob (turns Blob on) and shown on the public pages.
maxImageBytesnumber2 MBThe largest image upload.
seed{ enabled?, teams?, projects? }off, noneTeams and projects to create when their slug is free. See Seed teams and projects.
settings.pages.publicstring | booleantrueThe public pages: a list at /<section> and a team page at /<section>/:slug for every section, and /projects and /projects/:slug. A string puts them under that prefix ('/crew' gives /crew/teams and /crew/projects); false turns them off.
settings.pages.adminstring | booleanoffThe staff team list. true is /admin/teams.
settings.pages.adminTeamstring | booleanoffThe staff team page. true is /admin/teams/:id.
settings.pages.adminProjectsstring | booleanoffThe staff project list. true is /admin/projects.
settings.pages.adminProjectstring | booleanoffThe staff project page. true is /admin/projects/:id.
settings.operationsTabbooleantrueAdd the Teams tab to the admin.operations tab area.

ladders label and description (Translated, optional) name the kind in the kind selects of the admin and on the public pages; without a label the key is shown title-cased (first-aid is "First aid"). They are read from the option every time, not stored, so changing them applies to a stored ladder too. So is section, the kind's public section. Roles are { key, label }, lowest first. Keys are lower case (a-z, 0-9, -, _). leadFrom is the lowest role that leads a team of that kind. An invalid ladder fails the build. A kind is stored on the first boot that sees it; changing its option later does not overwrite the stored row, so edit a stored ladder in admin.

nuxt.config.ts
export default defineNuxtConfig({
  teams: {
    ladders: {
      bar: {
        label: { en: 'Bar', da: 'Bar' },
        description: { en: 'Serves at the bars of an operation.', da: 'Står i barerne til en operation.' },
        roles: [
          { key: 'volunteer', label: { en: 'Volunteer', da: 'Frivillig' } },
          { key: 'bartender', label: { en: 'Bartender', da: 'Bartender' } },
          { key: 'lead', label: { en: 'Lead', da: 'Leder' } },
          { key: 'coordinator', label: { en: 'Coordinator', da: 'Koordinator' } },
        ],
        leadFrom: 'lead',
      },
      firstaid: {
        roles: [{ key: 'helper', label: { en: 'Helper', da: 'Hjælper' } }, { key: 'medic', label: 'Medic' }],
        leadFrom: 'medic',
      },
    },
  },
})

Permissions

Teams registers these permissions with Authorization.

NameFlagsHeld by defaultWhat it allows
teams:readimplicitevery signed-in userRead the teams you belong to, your role and who else is on them.
teams:leadimplicitevery signed-in userLead the teams where you hold a lead role. Other modules check it on a team.
teams:manageadminCreate teams, manage members, mapping rules and ladders.
teams:piisensitiveadminSee the email addresses of team members.
  • Scope: a token may use the named scope teams or teams:read itself. Either reads your teams and their members, never the staff routes. teams:pii is usable as a scope too.
  • Why teams:pii: a member list shows names and avatars to everyone on the team. Emails are other people's contact details, so they sit behind a separate grant. It ends in :pii, so it is sensitive: teams:* and * never cover it, and it is only held when granted by name.
  • Policy on teams:read: a team is readable by the people who hold a role on it, explicit or mapped, and by callers with teams:manage. Anyone else gets 403.
  • Policy on teams:lead: the caller holds a role on the record's team at or above the ladder's leadFrom (lead and up on the bar ladder above), explicit or mapped. The record is a team, or any record with a teamId.
// In another module's policy, for a record with a teamId:
definePolicy('shifts:lead', async ({ event, user, record }) => record ? isTeamLead(event, user.id, record.teamId) : undefined)

isTeamLead and teamGrantOf load the caller's team roles once per request and answer later checks from that, so a policy that calls them stays off the database after the first check. A list of the caller's teams filters in its query instead.

Server

Everything under /api is in the Routes section. This section covers what other modules build on.

Role ladder

A person climbs a ladder of team roles on a team. Staff above it hold global roles.

volunteer → bartender → lead → coordinator   team roles, per team (Teams)
admin, and your app's own global roles       global roles (Authorization)
  • Team roles are held per team. A person can be a lead at one bar and a volunteer at another. Teams stores explicit memberships and resolves mapped ones when they are read.
  • Ladders are per team kind, lowest first, with keys in lower case. The module ships one generic default ladder (member, lead); your app defines its own kinds, such as the bar ladder above or first aid, with the ladders option.
  • A grant can reach a whole kind. A team grant names one team or every team of a kind; the kind's ladder decides who is at or above its minRole (see Grants).
  • Global roles stay in Authorization. They grant staff permissions, and mapping rules turn them into team roles: a global supervisor is a lead.

Team roles

resolveTeamRoles(event, userId, { type: 'operation', id: operationId }) // TeamRoleGrant[] on that owner

A grant is { ownerType, ownerId, teamId, kind, role, source }, and source is explicit or mapped. ownerId is null for a platform-owned team, as in an OwnerRef. Modules that only need to know who may see a record never call resolveTeamRoles: they store a team grant and let Auth evaluate it (see Grants), so they do not import teams.

  1. Explicit memberships are the rows of team_members whose status is null or 'active'. They come first. See Membership status.
  2. Mapping rules give the other teams a mapped grant. A role rule matches a global role of the user, closed over inherit, from Auth's getEffectiveRoles, unless the user also holds one of the rule's except roles. A plan rule matches an active subscription. Listeners of teams:roles:resolve add more. In the rule form staff pick the role with Authorization's RoleSelect and the plan with Subscriptions' PlanSelect when those modules are installed, and type the key otherwise.
  3. Explicit beats mapped on the same team, whatever the rule. Any explicit row counts, whatever its status: a pending or inactive member gets no mapped role on that team either.
  4. Between mapped rules on one team, the highest priority wins, then the higher role on the ladder.
  5. A rule whose teamRole is not on a team's ladder skips that team.

Mapped grants are never stored. Every request reads the rules and the user's roles again, and caches the result for the rest of that request. teams:roles:resolve fires only when there are rules in play: a source with no rule rows gives no grants.

Errors fail closed. A teams:roles:resolve listener that throws loses the grants it pushed (and so do the listeners after it); the explicit memberships and teams' own role rules still count. A plan that cannot be checked is not held. A team grant admits nobody, and the OAuth claim is left out, when resolution fails; the claim is also left out when a teams:roles:resolve listener throws, rather than issued without that listener's teams. Each failure is logged.

Membership status

status on a membership belongs to the module that uses it: crew sets it next to its own crew status. Teams reads one thing from it: a row grants its role only when status is null or 'active'. Any other value, such as 'pending' or 'inactive', keeps the person listed on the team for staff and leads, with the status, without a grant: they cannot read the team, do not lead it, and no team grant admits them. The row also overrides mapping, so a mapping rule gives them no role on that team. The members list shows such rows, and every row's status, only to callers with teams:manage or a lead role on the team; other members see only the rows that grant. isTeamLead(event, userId, teamId) and teamMembers(event, teamId, { mapped }) use the same cache.

Mapping rules

A rule belongs to an owner, like a team: ownerType and ownerId, with ownerId: null for the platform.

FieldValue
teamIdOne team of the owner, or null for every team of the owner.
match{ role: 'supervisor' } or { plan: 'yearly' }, exactly one of the two; anything else is 400. A role match may add except: global roles whose holders it leaves out.
teamRoleA role key of the team's ladder. For every team, a key of at least one ladder.
priorityAn integer, 0 by default. Higher wins.

A role rule matches the roles that inherit its role too, so a rule for supervisor also maps every admin when admin inherits supervisor. except leaves them out, inheritance included: { role: 'supervisor', except: ['manager'] } matches supervisors but not managers or the roles above them. The rule's own role cannot be in except.

role rules work out of the box. plan rules need Subscriptions: Teams answers them from a server plugin it registers only then, with hasActiveSubscription. Plans are identified by their plan key.

Ladders

Each team kind has one ladder in team_role_ladders. The module option's ladders, and the default one the module ships, are stored on the first request when their kind has no row yet. They are never overwritten, so admins may edit them. Until a kind is stored, the option's ladder applies.

The ladders option only seeds. Once a kind is stored, the stored row wins, edited or not: adding a role to that kind in nuxt.config, or changing its leadFrom, changes nothing. Edit a stored ladder in the admin (the team page, or PUT /api/admin/teams/ladders/:kind). A kind that is new in the option is still stored on the first request after the next start.

A ladder cannot drop a role that an explicit member of a team of that kind holds, that a rule for one such team maps to, or that a rule for every team of an owner maps to when that owner has a team of the kind: 409 with the code team_role_in_use and the roles in data.roles.

Members

teamMembers(event, teamId, { mapped?, pii? }) lists the explicit members, highest role first. With mapped: true it also lists the people a rule gives a role on the team. Mapped members are not rows, so Teams finds the candidates and checks each one:

  • the holders of a role the team's rules name, or of a role that inherits one, from Auth's listRoleHolders. Authorization provides them; without it (or another role provider with holders) nobody is listed this way;
  • users with an entitled subscription (active or trialing, not ended) to a plan the rules name, when Subscriptions is installed;
  • the user ids that teams:members:candidates listeners add.

A role that comes only from defaultRoles, an auto role or an authorization:roles listener cannot be enumerated, so those people are not listed, although they do hold the role. At most 1000 candidates are checked, in bulk: Teams loads the candidates and their assigned roles at once (Auth's loadAuthUsers and primeAssignedRoles, through the role provider's assignedRolesOf), checks role rules in memory and plan rules with one Subscriptions query, so the number of statements does not grow with the candidates (each lookup is chunked for D1). Rules of other kinds go to the teams:roles:resolve listeners once per candidate (see Hooks). That is why mapped members are on demand only: ?include=mapped on the API (staff with teams:manage and the team's leads, 403 for anyone else), and a switch on the team page that starts off. A candidate source that fails is logged and adds nobody.

Grants

Teams registers the team kind of Auth's record audiences:

KindKeysAdmitsmembers
teamteamId, minRoleSigned-in users holding minRole, or a role above it on the ladder of the team's kind, on that team. Explicit and mapped roles count; a membership whose status gives no grant does not.The team's members at or above minRole, mapped ones included (see teamMembers).
teamteamKind, minRoleThe same on any team of that kind, whoever owns it: every bar of every operation.The members at or above minRole of every team of the kind.
[
  { "kind": "team", "teamId": "tem_123", "minRole": "lead" },
  { "kind": "team", "teamKind": "bar", "minRole": "bartender" }
]

A grant has either teamId or teamKind, never both. The ladders stay inside Teams: a grant names a team or a kind and a role key, and Teams compares them on the kind's ladder (roleAtLeast(keys, held, min) from @frigear-nu/teams/utils). A role that is not on the ladder admits nobody. A grant naming a team that does not exist, a kind without a ladder, or a role off the ladder, is refused when it is stored. In <GrantsEditor> the field picks one team or a team kind, then a role of its ladder. The team list searches on the server (the name, in any language), so every team can be picked, and shows each team's owner (the operation's name, or Platform) under its name, since teams of several operations often share one. teamGrantSchema, isTeamKindGrant and the TeamGrant, TeamIdGrant and TeamKindGrant types are exported from @frigear-nu/teams/utils.

Owners

Teams owns owner references: the ownerType / ownerId columns and their type, OwnerRef ({ type, id }) and OwnerType. Other modules that store an owner (help-center categories, mailboxes) import the type from @frigear-nu/teams; there is no global list of owner types. resolveTeamsOwner(event, owner) answers an owner's label and whether it exists, through the teams:owner:resolve hook:

Owner typeAnswered by
platformNobody: it has no id (ownerId: null).
teamTeams: the team's name, and whether it exists.
operationTeams, from the operations table, when Operations is installed.
Anything elseYour app, from a teams:owner:resolve listener.

A team is created for an owner. The platform has no id (ownerType: 'platform', ownerId: null). Any other owner must exist according to teams:owner:resolve. An unknown id, or an owner type nobody answers, is 400. The owner and the kind of a team are fixed once it exists.

Owners are found by name through the teams:owner:search hook, which Teams answers for team and operation (the same tables as above). searchTeamsOwners(event, type, q, limit) runs it and answers { results, searchable }. To make your own owner type searchable, set searchable and push at most limit results whose name contains q (an empty q lists the first ones), ordered by name:

server/plugins/venues.ts
export default defineNitroPlugin((nitro) => {
  nitro.hooks.hook('teams:owner:search', async (ctx) => {
    if (ctx.type !== 'venue') return
    ctx.searchable = true
    ctx.results.push(...(await findVenues(ctx.q, ctx.limit)).map(venue => ({ id: venue.id, label: venue.name })))
  })
})

OAuth claim

With OAuth Server installed, an application granted teams or teams:read gets a teams claim in the id token and from userinfo:

{ "teams": [{ "id": "tem_...", "ownerType": "operation", "ownerId": "opr_...", "kind": "bar", "role": "lead", "source": "mapped" }] }

Access tokens never carry it, and an existing teams claim is never replaced. The same application reads the members of those teams with GET /api/teams/:id/members and a bearer token.

Public pages

A team is public when staff turn on Show on the public pages and it has a URL name (slug); anything else is a 404 on the public routes, the same as an unknown slug. Every team has optional startsAt and endsAt, shown on the public page when set. Projects have public pages of their own: see Projects.

The public reads have no authorize: anonymous callers are welcome, so each answer is an allowlist. The list has the slug, name, kind and its label (kindLabel), description, image and dates. The team page adds contactEmail, form, members and projects:

  • form is { slug, name } of the form formRef names (a form id, or a slug) when Forms is installed and that form is published; otherwise null. Without Forms nothing is looked up. The page's Apply button links to the form page (forms.settings.pages.form). Store the id: a slug can be renamed.
  • members lists only the members who chose to be shown (showPublicly) and whose membership grants (status null or active): their name, their avatar (none when they opted out of photos) and their role's label. No ids and no emails.
  • projects are the public projects the team works on (slug, name, image and the link's note); see Projects. A project that is not public, or has no slug, is left out.

Visibility. A member is hidden until they turn on Show me on the public page on their dashboard item (PUT /api/teams/me/:teamId/visibility, explicit memberships only). Staff can set it too, from the member slideover on the admin team page (showPublicly on PATCH /api/admin/teams/:id/members/:userId). Each change records who set it and when (showPubliclySetBy, showPubliclySetAt); the member DTO says whether it was the member themselves (showPubliclySetBy.self), and the admin member table shows "Their own choice" or "Set by on ".

Image. With imageUpload, the staff form uploads a PNG, JPEG or WebP (at most maxImageBytes, 4096 pixels each way) to PUT /api/admin/teams/:id/image. It is served publicly by GET /api/teams/images/:teamId/:file, cached for a year (each upload has a new name). Replacing, removing or deleting the team deletes the old file.

Form picker. The staff form shows the FormSelectField component of Forms (on value-key="id") when Forms is installed and registers it, and a plain text input for the form id otherwise. Its search runs on Forms' admin list, so it needs forms:manage.

Sections

Every kind is listed in one public section. A ladder's section names it: { path, label, itemLabel? }, with label the plural ("Festivals") and itemLabel the singular ("Festival"), both Translated. A kind without one, or a kind that only exists as a stored ladder, is in the default teams section (Teams / Hold, singular Team / Hold). Two kinds may share a section; the first kind's labels name it.

nuxt.config.ts
export default defineNuxtConfig({
  teams: {
    ladders: {
      festival: {
        section: { path: 'festivals', label: { en: 'Festivals', da: 'Festivaler' }, itemLabel: { en: 'Festival', da: 'Festival' } },
        roles: [{ key: 'crew', label: 'Crew' }],
      },
    },
  },
})
  • URLs. The module registers one list page (/<path>) and one team page (/<path>/:slug) per section it knows at build time, from the ladders option and the shipped ladders. A list shows only the teams whose kind is in its section.
  • Paths are lowercase letters, numbers and dashes, and may not be api, admin, account, dashboard, auth, oauth, login, logout, register, forms, operations, me, public, images, new, edit or projects (the project pages). A bad path fails the build.
  • Redirects. Slugs are unique across every section. A team asked for under another section's path (/teams/garden for a festival) answers 301 to its own section (/festivals/garden).
  • Links. The public DTOs and GET /api/teams/me carry section (the path). Build links with useTeamLinks().publicTeam(section, slug) and publicList(section), never a hard-coded /teams.
  • Wording. The pages use the section's labels: the heading, "Festival members", "Apply to the festival", the empty state and the back link. The admin list always says "Teams".

Projects

A project (FGR, a film, a festival build) is something several teams work on, led by its project leads. It is not a kind of team: it has a table of its own (projects), its own small list of leads and members (project_members, role lead or member) and the teams working on it (project_teams). The volunteers belong to those teams.

  • Fields. Like a team's public fields: an owner (platform or operation, as on teams), a Translated name and description, slug, public, image, contactEmail, formRef, startsAt, endsAt and sort. The staff list filters by owner and by status from the dates (upcoming, active: started or undated and not ended, ended).
  • Teams on a project are managed on the project page ("Teams on this project"), each with an optional Translated note (what the team does there) and a sort. A team is linked once per project (409 conflict); an unknown team is a 400. The team page lists its projects read-only.
  • Access. Everything takes teams:manage. A project lead gets no extra rights: the role is who leads the project and is shown on its page.
  • Public pages. /projects lists the public projects (public, with a URL name); /projects/:slug shows the image, description, dates, the public teams on it with their note, the leads and members who chose to be shown, Apply and Contact. The answers are allowlists like the team ones: no ids, no emails. A member shows themselves with PUT /api/teams/me/:projectId/visibility (the project id in place of a team id); staff set it with showPublicly on the member.
  • Page. content is the body of the public project page: Markdown with MDC components, Translated (one text, or one per language). The admin project page shows a preview in a Page section; Edit page (or Write page) opens ContentEditor in a wide modal, full screen on phones, with a tab per language and Save page / Cancel (closing with unsaved changes asks first). It offers the components the app registers in appConfig.frigearUi.contentComponents. /projects/:slug renders it in the visitor's language with <MDC> (Nuxt Content or @nuxtjs/mdc, from your app) in a prose block, or as plain Markdown without MDC. description stays the short summary for the lists and the page's meta description. At most 100,000 characters per language; empty texts are dropped, and nothing left clears it.
  • Images are stored like team images (teams/<projectId>/ in Blob) and served by GET /api/projects/images/:projectId/:file. With imageUpload, the page editor uploads images too (toolbar, / menu, paste and drop; PNG, JPEG or WebP up to maxImageBytes) to POST /api/admin/projects/:id/content-images, stored as content-<random>.<ext> next to the project's image and served publicly by the same route, so a page shows them before the project is public too (the names are random). They are deleted with the project; an image taken out of the page stays stored until then.
  • Deleting a project deletes its leads, members and team links; deleting a team deletes its project links. The other side stays.

Seed teams and projects

seed.teams lists teams to create on the first request when no team has their slug: slug, name, and optionally kind (default default, it needs a ladder in the option), ownerType (default platform) and ownerId, description, public, contactEmail, formRef, startsAt and endsAt (ISO). seed.projects takes the same fields without kind, for projects. An existing slug is skipped and never updated, so staff edits are safe. It only runs with seed.enabled, which you can turn on at runtime with NUXT_TEAMS_SEED_ENABLED=true. The module ships none.

nuxt.config.ts
export default defineNuxtConfig({
  teams: {
    seed: {
      teams: [{ slug: 'welcome-crew', name: { en: 'Welcome crew', da: 'Velkomstcrew' }, public: true }],
      projects: [{ slug: 'summer-build', name: { en: 'Summer build', da: 'Sommeropbygning' }, public: true }],
    },
  },
})

Dashboard item

With Dashboard installed, Teams adds teams.mine to crew.home and the hub's dashboard (permission teams:read, order 60, two columns wide): the teams the person is on with their role (the ladder's label, translated), from GET /api/teams/me; a role a mapping rule gives them is marked "By role". On a team with a public page, an explicit member gets the switch Show me on the public page under it, and the team's name links to the page. Texts are under teams.dashboard.

App

Pages

PagePathFor
Public list/teams, one per sectionEverybody. Cards with the image, name, kind and description of each public team of the section. Off with settings.pages.public: false.
Public team page/teams/:slug, ...Everybody. A team asked for under another section moves (301) to its own. Image, description, dates, the members who chose to be shown, the public projects it works on, Apply (a published form) and Contact (the contact address).
Public project list/projectsEverybody. Cards with the image, name, dates and description of each public project. Off with settings.pages.public: false.
Public project page/projects/:slugEverybody. Image, description, dates, the page body, the public teams on it, the leads and members who chose to be shown, Apply and Contact.
Team list/admin/teamsStaff with teams:manage. Search, an owner filter (?ownerType=&ownerId=), a kind filter (?kind=) and sortable columns.
Team page/admin/teams/:idStaff with teams:manage. Key facts, members, mapping rules, the projects it works on (read-only), and the kind's ladder.
Project list/admin/projectsStaff with teams:manage. Search, an owner filter, a status filter (?status=upcoming|active|ended) and sortable columns. Sidebar entry Projects.
Project page/admin/projects/:idStaff with teams:manage. Key facts, the page body (Page), the teams on the project (add, edit note, take off) and its leads and members.

The team slideover has the public page fields: the URL name (suggested from the name until you edit it), the public switch, the image (with imageUpload), the contact address, the dates and the form. The member table has a Public page column: shown or hidden, and who set it. The row menu offers Edit member (the role, and whether they are shown) and Remove member. For a mapped member it offers Assign role, which adds them explicitly. Add member opens a slideover with the UserPicker of Users on GET /api/admin/teams/users: it searches people by name, and by email with teams:pii. Staff who hold users:create can create the person from the picker, and the new user is selected. Rules and the ladder are edited in slideovers too.

Tab on the operation page

Teams adds a Teams tab to the admin.operations tab area of Widget, with the prop ownerType: 'operation'. It reads the operation's id from the tab context and never imports Operations. It lists the operation's teams and adds new ones for it. Rendered without an operation, it shows an empty state and queries nothing. Turn it off with settings.operationsTab: false.

Owner picker

OwnerSelect is a global component for forms that store an owner (ownerType / ownerId), in Teams and in other modules. It searches owners of type by name as you type, through GET /api/admin/teams/owners (staff with teams:manage), and binds the owner's id. An edit form shows the current owner's name. When nobody answers teams:owner:search for the type, or the route refuses or fails, it falls back to a text input for the id.

<OwnerSelect v-model="state.ownerId" :type="state.ownerType" />
PropTypeWhat it does
v-modelstring | nullThe owner's id.
typestringThe owner type (team, operation, or your own). Searched again when it changes.
disabledbooleanDisables the select.
placeholderstringReplaces the placeholder.

Composables

ComposableWhat it does
useTeamActions()create, edit, remove and menu(team), with toasts and confirmations.
useTeamMemberActions(team, ladders)add, changeRole, remove and menu(member).
useTeamMappingActions(context)create, edit, remove and menu(rule).
useProjectActions()create, edit, remove and menu(project), with toasts and confirmations.
useProjectMemberActions(project)add, edit (the role and the public visibility), remove and menu(member) for its leads and members.
useProjectTeamActions(project, exclude?)add (a team and a note), edit (the note), remove and menu(link) for the teams on project.
useTeamLinks()Locale-aware links to the admin pages (adminTeam(id), adminProjects(), adminProject(id)) and the public pages (publicList(section?), publicTeam(section, slug), publicProjects(), publicProject(slug)).
useTeamSection()On a public page: its section and the labels (label, item and lower-case forms).
useTeamsTranslate()tr(value) for Translated texts, and tr.kindLabel(ladders, kind), tr.kindDescription(ladders, kind) and tr.kindItems(ladders) for kind labels and selects.

Hooks

Your app answers these Nitro hooks from a server plugin (server/plugins/*.ts).

HookWhenPayload
teams:member:addedWhen an explicit membership starts granting: added with status null or active, or its status became one of those.{ event, team, member }
teams:member:removedWhen an explicit membership stops granting: removed while it granted, or its status left null / active.{ event, team, member }
teams:member:role-changedWhen the role of a membership that grants changed.{ event, team, member, from, to }
teams:roles:resolveWhile resolving a user's mapped grants. Push grants into grants.{ event, user, owner, globalRoles, rules, teams, ladders, grants }
teams:members:candidatesWhile listing mapped members. Add user ids to userIds.{ event, team, rules, userIds }
teams:owner:resolveWhile an owner is checked or labelled. Set label and exists for your own owner types.{ event, owner, label, exists }
teams:owner:searchWhile owners are found by name (the owner picker). Set searchable and push at most limit results for your own owner types.{ event, type, q, limit, results, searchable }
  • team is the staff DTO and member the member DTO with the email, whatever the caller may see.
  • teams:roles:resolve. owner is null: one resolution covers every owner. event is undefined while the OAuth claim is built. rules are the rules in play, teams the teams they cover. Give a pushed grant the priority of the rule it stands for; mappedGrantsFor(teams, rules, ladders) from @frigear-nu/teams/utils builds them. While mapped members are listed, the hook runs once per candidate with teams holding that one team, its owner, and only the rules Teams cannot answer in bulk (not role rules, nor plan rules when Subscriptions is installed). Keep such a listener free of per-call queries: load what it needs in bulk in teams:members:candidates.
  • The member hooks follow the grant, not the row. A pending row fires nothing when it is added, deleted or given another role; added fires when its status becomes active (with the role it has then), and removed when an active membership becomes inactive. Crew fires its own hooks on the same transitions, so both agree on when a person starts and stops working on a team. Mapped grants fire no hooks.
  • Deleting a team fires no teams:member:removed for the memberships that go with it.

Routes

Typed path builders are exported as teamsApi from @frigear-nu/teams/api.

RouteWhoWhat it does
GET /api/teams/meteams:readYour grants on every owner, explicit first, each with source, the team's name and the role's ladder label roleLabel.
PUT /api/teams/me/:teamId/visibilityteams:read + policy{ showPublicly }: show or hide yourself on the team's public page, or a project's (a prj_ id). Explicit members only (404 otherwise). Recorded as set by you.
GET /api/teams/publicAnyoneThe public teams (public, with a slug), each with its section. ?section=festivals keeps one section.
GET /api/teams/public/:slugAnyoneOne public team with its contact address, published form, shown members, and the public projects it works on. 404 for anything not public.
GET /api/projects/publicAnyoneThe public projects (public, with a slug).
GET /api/projects/public/:slugAnyoneOne public project with its contact address, published form, shown leads and members (role) and public teams (with section, kindLabel and note). 404 for anything not public.
GET /api/projects/images/:projectId/:fileAnyoneAn uploaded project image or page body image. Only with imageUpload.
GET /api/teams/images/:teamId/:fileAnyoneAn uploaded image. Only with imageUpload.
GET /api/teams/:idteams:read + policyOne team.
GET /api/teams/:id/membersteams:read + policyNames and avatars; email only with teams:pii. Staff and leads see every row with its status; other members only the rows that grant. ?include=mapped (staff and leads) adds mapped members.
GET /api/admin/teamsteams:managePaginated list with ownerType, ownerId, kind, q (name in every language) and sort.
POST /api/admin/teamsteams:manageCreate a team: ownerType, ownerId, kind, name, description, parentId, capacity, sort, slug, public, contactEmail, formRef, startsAt, endsAt. 409 conflict for a slug in use; 400 for a malformed or reserved slug (me, public, images, ...).
GET /api/admin/teams/:idteams:manageOne team, with ownerLabel and memberCount.
PATCH /api/admin/teams/:idteams:manageEdit any field but the owner and the kind.
PUT /api/admin/teams/:id/imageteams:manageUpload the image (multipart file). Only with imageUpload.
DELETE /api/admin/teams/:id/imageteams:manageRemove the image. Only with imageUpload.
DELETE /api/admin/teams/:idteams:manageDelete a team; its members, its own rules and its project links go with it (foreign key cascades).
POST /api/admin/teams/:id/membersteams:manageAdd { userId, role, status? }. 400 for a role off the ladder, 409 for a member already.
PATCH /api/admin/teams/:id/members/:userIdteams:manageChange role, status and showPublicly (recorded as set by you).
DELETE /api/admin/teams/:id/members/:userIdteams:manageRemove an explicit member.
GET /api/admin/teams/:id/projectsteams:manageThe projects the team works on, public or not (read-only; links are managed on the project).
GET /api/admin/projectsteams:managePaginated list with ownerType, ownerId, status (upcoming, active, ended), q and sort (sort, createdAt, startsAt). Each with ownerLabel, memberCount and teamCount.
POST /api/admin/projectsteams:manageCreate a project: ownerType, ownerId, name, description, content, sort, slug, public, contactEmail, formRef, startsAt, endsAt. 409 conflict for a slug in use.
GET /api/admin/projects/:idteams:manageOne project.
PATCH /api/admin/projects/:idteams:manageEdit any field but the owner.
DELETE /api/admin/projects/:idteams:manageDelete a project with its leads, members and team links.
PUT /api/admin/projects/:id/imageteams:manageUpload the image (multipart file). Only with imageUpload.
DELETE /api/admin/projects/:id/imageteams:manageRemove the image. Only with imageUpload.
POST /api/admin/projects/:id/content-imagesteams:manageUpload an image for the page body (multipart file); 201 with { file, url }. 415 for anything but a PNG, JPEG or WebP, 413 above maxImageBytes. Only with imageUpload.
GET /api/admin/projects/:id/membersteams:manageLeads first, then members; email only with teams:pii.
POST /api/admin/projects/:id/membersteams:manageAdd { userId, role: 'lead' | 'member' }. 400 for an unknown user, 409 when on the project already.
PATCH /api/admin/projects/:id/members/:memberIdteams:manageChange role and showPublicly (recorded as set by you).
DELETE /api/admin/projects/:id/members/:memberIdteams:manageRemove a lead or member.
GET /api/admin/projects/:id/teamsteams:manageThe teams on the project, public or not. Each link has note, sort, project and team (id, name, kind, slug, public, section).
POST /api/admin/projects/:id/teamsteams:manageLink { teamId, note?, sort? }. 400 for an unknown team, 409 conflict when linked already.
PATCH /api/admin/projects/:id/teams/:linkIdteams:manageChange note and sort. 404 for a link of another project.
DELETE /api/admin/projects/:id/teams/:linkIdteams:manageTake the team off the project; both stay.
GET /api/admin/teams/mappingsteams:manageRules, by ownerType and ownerId, or those covering teamId.
POST /api/admin/teams/mappingsteams:manageAdd a rule.
PATCH /api/admin/teams/mappings/:idteams:manageEdit teamId, match, teamRole, priority.
DELETE /api/admin/teams/mappings/:idteams:manageDelete a rule.
GET /api/admin/teams/laddersteams:manageEvery ladder, with source: 'stored' | 'default'.
GET /api/admin/teams/ladders/:kindteams:manageOne ladder.
PUT /api/admin/teams/ladders/:kindteams:manageReplace { roles, leadFrom }. 409 team_role_in_use.
GET /api/admin/teams/usersteams:manage?q= finds people to add by name; with teams:pii also by email, and the answer has the emails.
GET /api/admin/teams/ownersteams:manage?type=&q= finds owners of a type by name (at most 20; no q lists the first ones); ?type=&id= labels one owner. { items: { id, label }[], searchable }, searchable: false when nobody answers teams:owner:search for the type.

Adding and removing members is staff only. Leads hold teams:lead, which other modules check, but they do not manage their team's members.

status on a membership is set by the module that uses it, such as crew; see Membership status.

Database

Tables the module adds. Generate and commit a migration after installing.

TableHolds
teamstem_ id, ownerType, ownerId (null for the platform), parentId, kind, Translated name and description, searchText (the name folded for search), capacity, sort, and for the public page a unique slug, public, image (the uploaded file's name), contactEmail, formRef, startsAt, endsAt.
team_memberstmm_ id, teamId (cascade), userId, role, status, addedBy, and showPublicly, showPubliclySetBy, showPubliclySetAt. One row per team and user. Crew adds columns and their indexes through its extension file.
team_role_ladderskind, ordered roles ([{ key, label }]) and leadFrom.
team_role_mappingstrm_ id, owner, teamId (cascade, null for every team), match, teamRole, priority.
projectsprj_ id, owner, Translated name, description and content (the page body), searchText, a unique slug, public, image, contactEmail, formRef, startsAt, endsAt, sort.
project_membersprm_ id, projectId (cascade), userId, role (lead or member), addedBy, and showPublicly, showPubliclySetBy, showPubliclySetAt. One row per project and user.
project_teamsptm_ id, projectId (cascade), teamId (cascade), Translated note, sort. One row per pair.

User ids have no foreign key: the users table belongs to Users. Whoever deletes a user removes their memberships.

Translations

Override any string in your app's i18n/locales/<code>.json. The module registers da and en files under teams.*. See overriding module strings.

Key groups: menu.*, permissions.*, scopes.*, public.* (the public pages), dashboard.* and admin.* (with admin.tabs.*, admin.ownerTypes.* and admin.sources.*). Ladder role labels are data: edit them on the ladder.

Next steps

  • Crew – applications and invites that put people on teams.
  • Record audiences – the grant lists the team kind belongs to.
Copyright © 2026