mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-26 07:37:54 +00:00
release-please / release-please (push) Canceled after 0s
Notify HeyPuter / notify (push) Canceled after 0s
Backend Tests / changes (push) Canceled after 0s
Backend Tests / typecheck (push) Canceled after 0s
Backend Tests / test shard 1/4 (push) Canceled after 0s
Backend Tests / test shard 2/4 (push) Canceled after 0s
Backend Tests / test shard 3/4 (push) Canceled after 0s
Backend Tests / test shard 4/4 (push) Canceled after 0s
Backend Tests / test (main) (push) Canceled after 0s
Backend Tests / coverage (push) Canceled after 0s
Maintain Release Merge PR / update-release-pr (push) Canceled after 0s
* refactor: let core run without a teams registration
Teams becomes optional: `services.team` and `stores.team` may be absent, and
core stops assuming either is there.
Seventeen call sites across share, signup, account deletion and the homepage
now degrade instead of throwing: a team recipient that cannot be resolved is
"no such recipient" rather than a fault, a group share folds in nothing, and
account deletion stops asking what a seat was charged for. This generalises
the pattern `gates.ts` and `SocketService` already used.
Teams' own files take a private handle to their store and service, so the
feature's code stays free of optionality that only core needs.
No behaviour changes where Teams is registered.
* refactor: put a contract between core and teams
`core/teams.ts` holds the shapes core reads and the calls it makes, and the
registries declare the pair as provided rather than built in. The service,
store and controller are registered by whatever runs the feature.
Typing them properly turned up eight AuthController call sites the previous
commit could not see: the controller reads its stores from the built-in
registry, so an absent `team` fell to an index signature and typed as
`unknown` instead of erroring. They now go through the same optional path as
the rest.
The feature's own tests move with it. The cases in core suites that build a
team to exercise a core rule still need relocating, so those suites are red
here.
* test: stub core's seat rules, rehome the rest with the feature
A core suite can no longer build a team, so the rules that refuse a seat get
`testFixtures/seatStub.ts` instead: it answers the contract, which is all
those rules read, and puts the registry back when the test ends.
Seventeen cases move that way. Four could not: group shares and a seat's 2FA
enrolment over HTTP need the real feature and the `/teams` route, so they go
with it, as does the whole of `GroupGrants.test.ts`.
Two whoami cases asserted a seat's team through `extension.import`, which
resolves the registry rather than the stores object. They now assert the
absent case, and the behaviour they covered is asserted against
`buildUserDetails`, which takes its stores as an argument.
Suite: 12252 passed, 38 skipped.
* refactor: take the teams console out of the built-in tabs
`TabTeams`, `teamsConsole` and `teamActionIcons` are no longer built in. The
dashboard already invites a tab through its `dashboard-will-open` event, so
whatever provides Teams contributes the console the same way.
Its 113 strings go with it and register into the shipped English dictionary
at load, so `i18n('teams_*')` resolves as it did. Only `en.js` ever carried
them, so no translation is lost.
Three modules stay, because things other than the console use them:
`teamBadge` (the dashboard shell), `orgSeat` (Home, Account, Security) and
`shareTeams` (the share picker). They already render nothing when the
account has no team. `teams_account_of` stays with `teamBadge` for the same
reason, and the `share_*` and `plan_team_*` strings stay with their callers.
The GUI builds clean with no console at all, and builds it in when the tab
is contributed.
* docs: seats past the owner's current limit get no allowance
82 lines
3.1 KiB
TypeScript
82 lines
3.1 KiB
TypeScript
/*
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
* 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<OrgSeatRow | null>;
|
|
isMember(teamUid: string, userId: number): Promise<boolean>;
|
|
getByUid(uid: string): Promise<TeamRow | null>;
|
|
getByHandle(handle: string): Promise<TeamRow | null>;
|
|
getByIdIncludingDeleted(id: number): Promise<TeamRow | null>;
|
|
getByIdsIncludingDeleted(ids: number[]): Promise<Map<number, TeamRow>>;
|
|
listGroupIdsForUser(userId: number): Promise<number[]>;
|
|
listMemberIdsByGroupId(groupId: number): Promise<number[]>;
|
|
memberIdsAmong(teamUid: string, userIds: number[]): Promise<number[]>;
|
|
countOwned(ownerUserId: number): Promise<number>;
|
|
countOwnedTeamsWithAccounts(ownerUserId: number): Promise<number>;
|
|
}
|
|
|
|
/** The calls core makes when an account it owns changes. */
|
|
export interface TeamServiceContract {
|
|
teamsAvailableTo(userId: number, email: string | null): Promise<boolean>;
|
|
captureSeatForBilling(userId: number): Promise<unknown | null>;
|
|
emitSeatDeleted(seat: unknown): void;
|
|
forgetSeat(seat: unknown): Promise<void>;
|
|
releaseUnconfirmedSeatEmail(userId: number): Promise<boolean>;
|
|
recordPasswordSelfChange(userId: number): Promise<void>;
|
|
}
|