Skip to content

Typescript: API Modules > team.js → team.ts #8013

Description

@n-lark

team.js → team.ts — Test Plan

Second file of the Phase 3 API-module TypeScript migration, and the first "real" module (~40 methods, heavy enrichment). Rename to .ts, drop .js from imports, add client.get<T>() generics and domain-typed signatures from @/types. Load-bearing specifics for this file:

  • Union returngetTeam hits /:teamId and /slug/:teamSlug; type as Team | TeamSummary and let the union flow out (caller narrows).
  • Polymorphic paramgetTeam(team) takes string | { slug: string }; narrow with typeof team === 'object'. Don't change the callsite contract.
  • View-model intersections — many methods splice derived fields onto res.data before returning (link, roleName, lastSeenSince, status, createdSince, updatedSince, flowLastUpdatedSince, expires, device instance). Type each as Base & { ... }; keep the enrichment inline, don't refactor it out.
  • PostHog product.capture / groupUpdate side effects don't affect return types — leave them.

Static

  • team.js → team.ts. Spec kept as .js — matches the utils-phase precedent (util sources are .ts, their specs stayed .js). Renaming the spec makes vue-tsc deep-check it and fail on vitest globals + loose mock typing not set up project-wide; separate concern, not this PR.
  • .js dropped from the 6 imports (product, daysSince, elapsedTime, paginateUrl, roles, ./client)
  • npx vue-tsc --noEmit from frontend/ — no new errors (still only the 2 pre-existing, unrelated)
  • npx vitest run test/unit/frontend/api/team.spec.js — 16/16 pass (spec unchanged from HEAD)
  • getTeam typed Team | TeamSummary + polymorphic string | { slug } param; enriched methods carry view-model fields (TeamListItem, InvitationView, DeviceView)

Runtime (smoke — team api is app-wide)

  • Teams list loads; each row has role label + working link (getTeamsroleName/link)
  • Switch/open a team; page populates (getTeam object + string paths)
  • Team → Instances list renders with status/last-updated (getInstances)
  • Team → Devices list renders, "last seen" text present (getTeamDeviceslastSeenSince)
  • Invitations list shows role + expiry (getTeamInvitationsexpires)
  • Create team and delete team both succeed

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
Review

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions