API reference
Account, team and help
Security, pricing, team, profile and help center rules.
Everything in utils/ is a pure function: it takes data and returns data, with no Vue and no global state. Pass the current date as now so results are deterministic. Each file has its unit tests in tests/unit/.
securityChecks()
The checks of the security tab: password age, 2FA, sign-in alerts and recovery phone.
securityChecks(security: SecuritySettings, now: Date): { id: SecurityCheckId; ok: boolean; }[]securityLevel()
A level from the checks.
securityLevel(checks: { ok: boolean }[]): "strong" | "good" | "weak"recoveryCodesLeft()
Unused recovery codes (a code with usedAt no longer works).
recoveryCodesLeft(codes: RecoveryCode[]): number
isRecoveryCodesLow()
Whether the unused codes reached RECOVERY_CODES_LOW.
isRecoveryCodesLow(codes: RecoveryCode[]): boolean
generateRecoveryCodes()
A new set of XXXX-XXXX codes; pass random for deterministic tests.
generateRecoveryCodes(count = RECOVERY_CODE_COUNT, random = Math.random): RecoveryCode[]
passwordAgeDays()
Days since the password changed.
passwordAgeDays(security: Pick<SecuritySettings, 'passwordChangedAt'>, now: Date): number
PLAN_ORDER
Plans from lowest to highest.
const PLAN_ORDER: PlanId[]
yearlySeatPrice()
Monthly seat price with the yearly discount.
yearlySeatPrice(monthlyPrice: number, discount: number): number
yearlySavings()
What a seat saves per year.
yearlySavings(monthlyPrice: number, discount: number): number
recommendedPlan()
The next plan up.
recommendedPlan(current: PlanId): PlanId | undefined
isDowngrade()
Whether a change is a downgrade.
isDowngrade(target: PlanId, current: PlanId): boolean
periodCharge()
The charge of the billing period.
periodCharge(seatPrice: number, seats: number, period: Subscription['period']): number
prorationCredit()
The credit left in the current period.
prorationCredit(subscription: Pick<Subscription, 'period' | 'renewsAt'>, charge: number, now: Date): number
downgradeImpact()
What a downgrade removes and whether the team fits.
downgradeImpact(plan: Pick<PlanModel, 'seatLimit' | 'projectLimit'>, usage: { seatsUsed: number; projects: number; customRoles: number }, options: { credit: number; keepsCustomRoles: boolean }): DowngradeImpactremovedMembersreadOnlyProjectsremovedRolescreditblockedmemberState()
Active, invited or inactive.
memberState(member: Pick<TeamMember, 'status' | 'lastActiveAt'>, now: Date): TeamMemberState
memberInviteDaysLeft()
Days before an invitation expires.
memberInviteDaysLeft(member: Pick<TeamMember, 'invitedAt'>, now: Date): number
seatUsage()
Seats used and free.
seatUsage(members: Pick<TeamMember, 'status'>[], seats: number): { active: number; invited: number; used: number; free: number; }activeinvitedusedfreemembersWithoutTwoFactor()
Active members without 2FA.
membersWithoutTwoFactor(members: Pick<TeamMember, 'status' | 'twoFactor'>[]): number
matchesTeamView()
Whether a member belongs to a view.
matchesTeamView(state: TeamMemberState, view: TeamView): boolean
teamViewCounts()
The count of every team view.
teamViewCounts(states: TeamMemberState[]): Record<TeamView, number>
togglePermission()
Toggles one permission; any action implies View of the module.
togglePermission(permissions: Permission[], module: PermissionModule, action: PermissionAction): ("dashboard.view" | "dashboard.create" | "dashboard.update" | "dashboard.delete" | "orders.view" | "orders.create" | "orders.update" | "orders.delete" | "customers.view" | ... 22 …togglePermissionModule()
Toggles every action of a module.
togglePermissionModule(permissions: Permission[], module: PermissionModule, enabled: boolean): ("dashboard.view" | "dashboard.create" | "dashboard.update" | "dashboard.delete" | "orders.view" | "orders.create" | "orders.update" | "orders.delete" | "customers.view" | ... 22 …togglePermissionColumn()
Toggles one action in every module.
togglePermissionColumn(permissions: Permission[], action: PermissionAction, enabled: boolean): ("dashboard.view" | "dashboard.create" | "dashboard.update" | "dashboard.delete" | "orders.view" | "orders.create" | "orders.update" | "orders.delete" | "customers.view" | ... 22 …permissionSummary()
A readable summary of a set of permissions.
permissionSummary(permissions: Permission[]): Record<"view" | "create" | "update" | "delete", number>
profileWork()
Open tasks, cards and events of the user for the profile tiles.
profileWork({ tasks, board, events, me, today }: ProfileWorkSources): { open: number; dueToday: number; overdue: number; done: number; assigned: number; cards: number; cardsDueSoon: number; boardName: string; meetings: number; nextMeeting: CalendarE…opendueTodayoverduedoneassignedcardscardsDueSoonboardNamemeetingsnextMeetingprofileAgenda()
Today’s meetings and due tasks.
profileAgenda({ tasks, events, me, today }: Omit<ProfileWorkSources, 'board'>): { meetings: CalendarEvent[]; due: TodoTask[]; }meetingsdueprofileCollaborators()
The people the user works with most.
profileCollaborators({ tasks, board, me }: Pick<ProfileWorkSources, 'tasks' | 'board' | 'me'>, limit: number): { name: string; color: string; count: number; }[]profileCompletion()
Profile completion from its checklist.
profileCompletion(items: { done: boolean }[]): numbersnippet()
An excerpt around the search term.
snippet(text: string, term: string, radius = SNIPPET_RADIUS): string
rankByOverlap()
Ranks items by word overlap with a query, for suggestions.
rankByOverlap(query: string, items: T[], text: (item: T) => string, limit = 3): T[]
adjacent()
The previous and next items of a list.
adjacent(items: T[], isCurrent: (item: T) => boolean): { previous: T | undefined; next: T | undefined; }previousnextuptimePercent()
Uptime percentage of a list of days.
uptimePercent(days: UptimeDay[]): number