/* * Copyright (C) 2024-present Puter Technologies Inc. * * This file is part of Puter. * * Puter is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /** * What core asks of Teams. Nothing here is an implementation: the pair is * registered by whatever provides the feature, and a deployment that does not * run it registers neither, so every caller treats both as absent. */ /** A team, as much of one as core reads back. */ export interface TeamRow { id: number; uid: string; owner_user_id: number; kind: string; name: string | null; handle: string | null; deleted_at: string | null; created_at: string; /** Whether an app acting for a member may read the member list. */ directory_enabled: number; /** Whether the accounts this team provisioned must hold 2FA. */ require_2fa: number; } /** The seat a user holds, for the gates that ask whether they hold one. */ export interface OrgSeatRow { id: number; user_id: number; uuid: string; username: string; team_uid: string; team_name: string | null; owner_user_id: number; /** Carried here so the per-request 2FA gate costs no extra read. */ require_2fa: number; } /** Most members one notification fans out to. */ export const NOTIFY_FANOUT_CAP = 500; /** The reads core makes of teams it did not create. */ export interface TeamStoreContract { getOrgSeat(userId: number): Promise; isMember(teamUid: string, userId: number): Promise; getByUid(uid: string): Promise; getByHandle(handle: string): Promise; getByIdIncludingDeleted(id: number): Promise; getByIdsIncludingDeleted(ids: number[]): Promise>; listGroupIdsForUser(userId: number): Promise; listMemberIdsByGroupId(groupId: number): Promise; memberIdsAmong(teamUid: string, userIds: number[]): Promise; countOwned(ownerUserId: number): Promise; countOwnedTeamsWithAccounts(ownerUserId: number): Promise; } /** The calls core makes when an account it owns changes. */ export interface TeamServiceContract { teamsAvailableTo(userId: number, email: string | null): Promise; captureSeatForBilling(userId: number): Promise; emitSeatDeleted(seat: unknown): void; forgetSeat(seat: unknown): Promise; releaseUnconfirmedSeatEmail(userId: number): Promise; recordPasswordSelfChange(userId: number): Promise; }