Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(teams): add a shareable team invite link (#8452)

Jacob Beckerman3ac09caeb9e7
diff --git a/.sqlx/query-0f651f5ef335b7847909f83e887a76603dd1c99ea9706c84b44ca3ec23666408.json b/.sqlx/query-0f651f5ef335b7847909f83e887a76603dd1c99ea9706c84b44ca3ec23666408.json
new file mode 100644
index 0000000000..d236c7a3cf
--- /dev/null
+++ b/.sqlx/query-0f651f5ef335b7847909f83e887a76603dd1c99ea9706c84b44ca3ec23666408.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO team_invite_link (team_id, token)\n VALUES ($1, $2)\n ON CONFLICT (team_id) DO UPDATE\n SET token = EXCLUDED.token,\n created_at = now()\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Uuid"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "0f651f5ef335b7847909f83e887a76603dd1c99ea9706c84b44ca3ec23666408"
+}
diff --git a/.sqlx/query-264337b16935491ee6b4fea2c8d709b6d32748017db5747db7e43a78b1f3f306.json b/.sqlx/query-264337b16935491ee6b4fea2c8d709b6d32748017db5747db7e43a78b1f3f306.json
new file mode 100644
index 0000000000..c331d4867d
--- /dev/null
+++ b/.sqlx/query-264337b16935491ee6b4fea2c8d709b6d32748017db5747db7e43a78b1f3f306.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT token\n FROM team_invite_link\n WHERE team_id = $1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "token",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "264337b16935491ee6b4fea2c8d709b6d32748017db5747db7e43a78b1f3f306"
+}
diff --git a/.sqlx/query-68794f79630068cedcb8b8cc032163bb0a6bd0a085d46d5aed9e65763498ed96.json b/.sqlx/query-68794f79630068cedcb8b8cc032163bb0a6bd0a085d46d5aed9e65763498ed96.json
new file mode 100644
index 0000000000..74a08b5d39
--- /dev/null
+++ b/.sqlx/query-68794f79630068cedcb8b8cc032163bb0a6bd0a085d46d5aed9e65763498ed96.json
@@ -0,0 +1,14 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n DELETE FROM team_invite_link\n WHERE team_id = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "68794f79630068cedcb8b8cc032163bb0a6bd0a085d46d5aed9e65763498ed96"
+}
diff --git a/.sqlx/query-dc1959980c413d6b876e02f6a39856348289fadb52c30a943b51a706e91e8322.json b/.sqlx/query-dc1959980c413d6b876e02f6a39856348289fadb52c30a943b51a706e91e8322.json
new file mode 100644
index 0000000000..2e2a097f09
--- /dev/null
+++ b/.sqlx/query-dc1959980c413d6b876e02f6a39856348289fadb52c30a943b51a706e91e8322.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT t.id AS team_id, t.name AS team_name\n FROM team_invite_link l\n JOIN team t ON t.id = l.team_id\n WHERE l.token = $1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "team_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "team_name",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false
+ ]
+ },
+ "hash": "dc1959980c413d6b876e02f6a39856348289fadb52c30a943b51a706e91e8322"
+}
diff --git a/apps/web/src/features/settings/Team.tsx b/apps/web/src/features/settings/Team.tsx
index 233214a068..19b24c0d7d 100644
--- a/apps/web/src/features/settings/Team.tsx
+++ b/apps/web/src/features/settings/Team.tsx
@@ -33,6 +33,7 @@ import {
} from 'solid-js';
import { z } from 'zod';
import { SettingsCard, SettingsPage, SettingsSection } from './primitives';
+import { TeamInviteLinkSection } from './TeamInviteLinkSection';
import { isTeamAdminOrOwner } from './teamMemberPermissions';
const emailSchema = z.string().email();
@@ -452,6 +453,8 @@ export function CreateTeamDialog(props: {
/** Invite people to an existing team by email. */
export function InviteToTeamDialog(props: {
teamId: string;
+ /** Team admins and owners may reset or turn off the invite link. */
+ canManageLink: boolean;
open: boolean;
onClose: () => void;
}) {
@@ -507,6 +510,12 @@ export function InviteToTeamDialog(props: {
</Panel.Header>
<Panel.Body class="p-3 flex flex-col gap-3">
+ <TeamInviteLinkSection
+ teamId={props.teamId}
+ canManage={props.canManageLink}
+ />
+ <div class="h-px bg-edge-muted" />
+ <div class="text-sm text-ink">Invite by email</div>
<InviteEmailsInput
invites={invites()}
onChange={setInvites}
diff --git a/apps/web/src/features/settings/TeamInviteLinkSection.test.tsx b/apps/web/src/features/settings/TeamInviteLinkSection.test.tsx
new file mode 100644
index 0000000000..aac5935aac
--- /dev/null
+++ b/apps/web/src/features/settings/TeamInviteLinkSection.test.tsx
@@ -0,0 +1,135 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { TeamInviteLinkSection } from './TeamInviteLinkSection';
+
+const link = vi.hoisted(() => ({
+ token: null as string | null,
+ // Undefined data with no pending load: the first fetch failed.
+ loadFailed: false,
+ refetch: vi.fn(),
+ create: vi.fn(),
+ remove: vi.fn(),
+ copied: [] as string[],
+}));
+
+vi.mock('@core/component/Toast/Toast', () => ({
+ toast: { success: vi.fn(), failure: vi.fn() },
+}));
+vi.mock('@core/util/webOrigin', () => ({
+ getWebOrigin: () => 'https://macro.com',
+}));
+vi.mock('@core/util/dataTransfer', () => ({
+ writeClipboardData: async (data: Record<string, string>) => {
+ link.copied.push(data['text/plain']);
+ return true;
+ },
+}));
+vi.mock('@queries/team/invite-link', () => ({
+ useTeamInviteLinkQuery: () => ({
+ isPending: false,
+ get data() {
+ return link.loadFailed ? undefined : { token: link.token };
+ },
+ refetch: link.refetch,
+ }),
+ useCreateTeamInviteLinkMutation: () => ({
+ isPending: false,
+ mutate: link.create,
+ }),
+ useDeleteTeamInviteLinkMutation: () => ({
+ isPending: false,
+ mutate: link.remove,
+ }),
+}));
+
+let motionStyles: HTMLStyleElement;
+beforeEach(() => {
+ link.token = null;
+ link.loadFailed = false;
+ link.refetch.mockReset();
+ link.refetch.mockResolvedValue(undefined);
+ link.copied = [];
+ link.create.mockReset();
+ link.remove.mockReset();
+ motionStyles = document.createElement('style');
+ // jsdom never fires animation events, so presence would keep closed dialogs mounted.
+ motionStyles.textContent =
+ '* { transition-duration: 0s; animation-name: none; }';
+ document.head.append(motionStyles);
+});
+
+afterEach(() => {
+ cleanup();
+ motionStyles.remove();
+});
+
+describe('TeamInviteLinkSection', () => {
+ it('creates the first link for anyone who may invite', () => {
+ render(() => <TeamInviteLinkSection teamId="team-1" canManage={false} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Create link' }));
+
+ expect(link.create).toHaveBeenCalledWith({ teamId: 'team-1' });
+ expect(screen.queryByRole('button', { name: 'Reset link' })).toBeNull();
+ });
+
+ it('copies the join page for an existing link', async () => {
+ link.token = 'abc-123';
+ render(() => <TeamInviteLinkSection teamId="team-1" canManage={false} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Copy link' }));
+
+ await vi.waitFor(() =>
+ expect(link.copied).toEqual([
+ 'https://macro.com/app/team-invite?link=abc-123',
+ ])
+ );
+ expect(link.create).not.toHaveBeenCalled();
+ expect(screen.queryByRole('button', { name: 'Turn off' })).toBeNull();
+ });
+
+ it('offers a retry, not a reset, when the link never loaded', () => {
+ link.loadFailed = true;
+ render(() => <TeamInviteLinkSection teamId="team-1" canManage />);
+
+ expect(screen.queryByRole('button', { name: 'Create link' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+
+ expect(link.refetch).toHaveBeenCalled();
+ expect(link.create).not.toHaveBeenCalled();
+ });
+
+ it('lets admins reset the link after confirming', async () => {
+ link.token = 'abc-123';
+ render(() => <TeamInviteLinkSection teamId="team-1" canManage />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Reset link' }));
+ expect(link.create).not.toHaveBeenCalled();
+
+ const dialog = await screen.findByRole('dialog');
+ const confirm = [...dialog.querySelectorAll('button')].find(
+ (button) => button.textContent === 'Reset link'
+ );
+ fireEvent.click(confirm!);
+
+ expect(link.create).toHaveBeenCalledWith({ teamId: 'team-1' });
+ });
+
+ it('lets admins turn the link off after confirming', async () => {
+ link.token = 'abc-123';
+ render(() => <TeamInviteLinkSection teamId="team-1" canManage />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Turn off' }));
+ const dialog = await screen.findByRole('dialog');
+ const confirm = [...dialog.querySelectorAll('button')].find(
+ (button) => button.textContent === 'Turn off'
+ );
+ fireEvent.click(confirm!);
+
+ expect(link.remove).toHaveBeenCalledWith({ teamId: 'team-1' });
+ });
+});
diff --git a/apps/web/src/features/settings/TeamInviteLinkSection.tsx b/apps/web/src/features/settings/TeamInviteLinkSection.tsx
new file mode 100644
index 0000000000..3a14065937
--- /dev/null
+++ b/apps/web/src/features/settings/TeamInviteLinkSection.tsx
@@ -0,0 +1,153 @@
+import { toast } from '@core/component/Toast/Toast';
+import { writeClipboardData } from '@core/util/dataTransfer';
+import { fireAndForget } from '@core/util/fireAndForget';
+import { getWebOrigin } from '@core/util/webOrigin';
+import LinkIcon from '@phosphor/link.svg';
+import {
+ useCreateTeamInviteLinkMutation,
+ useDeleteTeamInviteLinkMutation,
+ useTeamInviteLinkQuery,
+} from '@queries/team/invite-link';
+import { Button, ConfirmDialog } from '@ui';
+import { createSignal, Show } from 'solid-js';
+
+/** The page a team invite link opens; see `TeamInviteLinkAcceptance`. */
+export function teamInviteLinkUrl(token: string) {
+ return `${getWebOrigin()}/app/team-invite?link=${encodeURIComponent(token)}`;
+}
+
+async function copyTeamInviteLink(token: string) {
+ if (await writeClipboardData({ 'text/plain': teamInviteLinkUrl(token) })) {
+ toast.success('Invite link copied');
+ } else {
+ toast.failure('Could not copy invite link');
+ }
+}
+
+/**
+ * The team's shareable invite link: anyone who opens it can join the team.
+ * Anyone who may invite can copy it or create the first one; admins can
+ * reset it or turn it off, which breaks links already shared.
+ */
+export function TeamInviteLinkSection(props: {
+ teamId: string;
+ canManage: boolean;
+}) {
+ const linkQuery = useTeamInviteLinkQuery(
+ () => props.teamId,
+ () => true
+ );
+ const createLink = useCreateTeamInviteLinkMutation({
+ onSuccess: (token) => copyTeamInviteLink(token),
+ });
+ const deleteLink = useDeleteTeamInviteLinkMutation();
+ const [confirming, setConfirming] = createSignal<'reset' | 'off'>();
+
+ // Keep the cached link through a failed refetch. When it never loaded, the
+ // link is unknown rather than missing: "Create link" would replace a link
+ // people already share, so offer a retry instead.
+ const link = () => (linkQuery.isPending ? undefined : linkQuery.data);
+ const token = () => link()?.token ?? null;
+ const unknown = () => !linkQuery.isPending && link() === undefined;
+ const busy = () =>
+ linkQuery.isPending || createLink.isPending || deleteLink.isPending;
+
+ const handleCopyOrCreate = () => {
+ const current = token();
+ if (current) {
+ fireAndForget(copyTeamInviteLink(current), 'team-invite-link');
+ } else {
+ createLink.mutate({ teamId: props.teamId });
+ }
+ };
+
+ const handleConfirm = () => {
+ if (confirming() === 'reset') {
+ createLink.mutate({ teamId: props.teamId });
+ } else {
+ deleteLink.mutate({ teamId: props.teamId });
+ }
+ setConfirming(undefined);
+ };
+
+ return (
+ <div class="flex flex-col gap-2">
+ <div class="flex items-center justify-between gap-3">
+ <div class="min-w-0">
+ <div class="text-sm text-ink">Invite link</div>
+ <div class="text-xs text-ink-muted">
+ <Show when={!unknown()} fallback="Couldn't load the invite link.">
+ Anyone with the link can join your team. Paste it in Slack or an
+ email.
+ </Show>
+ </div>
+ </div>
+ <Show
+ when={!unknown()}
+ fallback={
+ <Button
+ variant="outline"
+ size="sm"
+ class="shrink-0"
+ onClick={() =>
+ fireAndForget(linkQuery.refetch(), 'team-invite-link')
+ }
+ >
+ Retry
+ </Button>
+ }
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ class="shrink-0"
+ disabled={busy()}
+ onClick={handleCopyOrCreate}
+ >
+ <LinkIcon class="size-4" />
+ <Show when={token()} fallback="Create link">
+ Copy link
+ </Show>
+ </Button>
+ </Show>
+ </div>
+ <Show when={props.canManage && token()}>
+ <div class="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="xs"
+ disabled={busy()}
+ onClick={() => setConfirming('reset')}
+ >
+ Reset link
+ </Button>
+ <Button
+ variant="ghost"
+ size="xs"
+ disabled={busy()}
+ onClick={() => setConfirming('off')}
+ >
+ Turn off
+ </Button>
+ </div>
+ </Show>
+ <ConfirmDialog
+ open={!!confirming()}
+ onOpenChange={(open) => !open && setConfirming(undefined)}
+ title={
+ confirming() === 'reset'
+ ? 'Reset invite link'
+ : 'Turn off invite link'
+ }
+ tone="danger"
+ confirmLabel={confirming() === 'reset' ? 'Reset link' : 'Turn off'}
+ onConfirm={handleConfirm}
+ body={
+ confirming() === 'reset'
+ ? 'The current link stops working and a new one is copied. People who already joined stay on the team.'
+ : 'The current link stops working. People who already joined stay on the team.'
+ }
+ />
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/TeamMembers.tsx b/apps/web/src/features/settings/TeamMembers.tsx
index 737266b144..5873c66fef 100644
--- a/apps/web/src/features/settings/TeamMembers.tsx
+++ b/apps/web/src/features/settings/TeamMembers.tsx
@@ -680,6 +680,7 @@ export function TeamMembers(props: { team: TeamSummary }) {
<InviteToTeamDialog
teamId={props.team.id}
+ canManageLink={isAdminOrOwner()}
open={showInviteModal()}
onClose={() => setShowInviteModal(false)}
/>
diff --git a/apps/web/src/features/settings/TeamSidebarAction.tsx b/apps/web/src/features/settings/TeamSidebarAction.tsx
index 088949edc9..6d7f98c4eb 100644
--- a/apps/web/src/features/settings/TeamSidebarAction.tsx
+++ b/apps/web/src/features/settings/TeamSidebarAction.tsx
@@ -6,7 +6,7 @@ import { useTeamQuery, useUserTeamsQuery } from '@queries/team/teams';
import { pressHandlers } from '@ui';
import { createSignal, type JSX, Show } from 'solid-js';
import { CreateTeamDialog, InviteToTeamDialog } from './Team';
-import { canInviteToTeam } from './teamMemberPermissions';
+import { canInviteToTeam, isTeamAdminOrOwner } from './teamMemberPermissions';
/**
* The settings sidebar's footer action: invite people to your team, or create
@@ -49,13 +49,14 @@ function InviteToTeamAction(props: { teamId: string }) {
const userId = useUserId();
const teamQuery = useTeamQuery(() => props.teamId);
const [open, setOpen] = createSignal(false);
+ const role = () => {
+ const team = teamQuery.isSuccess ? teamQuery.data : undefined;
+ return team?.members.find((member) => member.user_id === userId())?.role;
+ };
const canInvite = () => {
const team = teamQuery.isSuccess ? teamQuery.data : undefined;
if (!team) return false;
- const role = team.members.find(
- (member) => member.user_id === userId()
- )?.role;
- return canInviteToTeam(role, team.team.allow_non_admin_invites);
+ return canInviteToTeam(role(), team.team.allow_non_admin_invites);
};
return (
@@ -67,6 +68,7 @@ function InviteToTeamAction(props: { teamId: string }) {
/>
<InviteToTeamDialog
teamId={props.teamId}
+ canManageLink={isTeamAdminOrOwner(role())}
open={open()}
onClose={() => setOpen(false)}
/>
diff --git a/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx b/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx
index fc143027e2..c1314081dc 100644
--- a/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx
+++ b/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx
@@ -14,6 +14,7 @@ import { useCurrentTeamQuery, useTeamQuery } from '@queries/team/teams';
import { useNavigate, useSearchParams } from '@solidjs/router';
import { Button, Surface } from '@ui';
import { createMemo, Match, Show, Switch } from 'solid-js';
+import { TeamInviteLinkAcceptance } from './TeamInviteLinkAcceptance';
export function TeamInviteAcceptance() {
const [searchParams] = useSearchParams();
@@ -21,6 +22,9 @@ export function TeamInviteAcceptance() {
const userInfo = useUserInfo();
const inviteId = () => searchParams.id as string | undefined;
+ // A team's shareable invite link opens this page with `link` instead of an
+ // emailed invite's `id`.
+ const inviteLink = () => searchParams.link as string | undefined;
const invitesQuery = useUserInvitesQuery();
@@ -71,7 +75,12 @@ export function TeamInviteAcceptance() {
const handleLogin = () => {
const id = inviteId();
- const returnUrl = id ? `/team-invite?id=${encodeURIComponent(id)}` : '/';
+ const link = inviteLink();
+ const returnUrl = link
+ ? `/team-invite?link=${encodeURIComponent(link)}`
+ : id
+ ? `/team-invite?id=${encodeURIComponent(id)}`
+ : '/';
navigate(`/login?redirect=${encodeURIComponent(returnUrl)}`);
};
@@ -103,7 +112,7 @@ export function TeamInviteAcceptance() {
</div>
<div class="flex flex-col items-center">
<Switch>
- <Match when={!inviteId()}>
+ <Match when={!inviteId() && !inviteLink()}>
<NoInviteId />
</Match>
@@ -111,6 +120,10 @@ export function TeamInviteAcceptance() {
<UnauthenticatedView onLogin={handleLogin} />
</Match>
+ <Match when={inviteLink()}>
+ {(token) => <TeamInviteLinkAcceptance token={token()} />}
+ </Match>
+
<Match when={isLoading()}>
<LoadingBlock />
</Match>
diff --git a/apps/web/src/features/team-invitations/TeamInviteLinkAcceptance.test.tsx b/apps/web/src/features/team-invitations/TeamInviteLinkAcceptance.test.tsx
new file mode 100644
index 0000000000..bff3fcbb35
--- /dev/null
+++ b/apps/web/src/features/team-invitations/TeamInviteLinkAcceptance.test.tsx
@@ -0,0 +1,110 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import { ThrownResultError } from '@core/util/result';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { TeamInviteLinkAcceptance } from './TeamInviteLinkAcceptance';
+
+const state = vi.hoisted(() => ({
+ team: undefined as { team_id: string; team_name: string } | undefined,
+ teamError: undefined as unknown,
+ joinError: undefined as unknown,
+ join: vi.fn(),
+ navigate: vi.fn(),
+}));
+
+vi.mock('@core/component/Toast/Toast', () => ({
+ toast: { success: vi.fn(), failure: vi.fn() },
+}));
+vi.mock('@solidjs/router', () => ({ useNavigate: () => state.navigate }));
+vi.mock('@queries/team/invite-link', () => ({
+ useTeamByInviteLinkQuery: () => ({
+ get isPending() {
+ return !state.team && state.teamError === undefined;
+ },
+ get error() {
+ return state.teamError;
+ },
+ get data() {
+ return state.team;
+ },
+ }),
+ useJoinTeamByInviteLinkMutation: () => ({
+ isPending: false,
+ get isError() {
+ return state.joinError !== undefined;
+ },
+ get error() {
+ return state.joinError;
+ },
+ mutate: state.join,
+ }),
+}));
+
+beforeEach(() => {
+ state.team = undefined;
+ state.teamError = undefined;
+ state.joinError = undefined;
+ state.join.mockReset();
+});
+
+afterEach(cleanup);
+
+describe('TeamInviteLinkAcceptance', () => {
+ it('names the team and joins it with the link token', () => {
+ state.team = { team_id: 'team-1', team_name: 'Acme' };
+ render(() => <TeamInviteLinkAcceptance token="abc-123" />);
+
+ expect(screen.getByRole('heading', { name: 'Join Acme' })).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Join Team' }));
+
+ expect(state.join).toHaveBeenCalledWith({ token: 'abc-123' });
+ });
+
+ it('explains a link that was reset or turned off', () => {
+ state.teamError = new ThrownResultError([
+ { code: 'NOT_FOUND', message: 'Resource not found' },
+ ]);
+ render(() => <TeamInviteLinkAcceptance token="abc-123" />);
+
+ expect(
+ screen.getByRole('heading', { name: 'Invite Link Not Valid' })
+ ).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Join Team' })).toBeNull();
+ });
+
+ it('keeps a loaded team joinable when a refetch fails', () => {
+ state.team = { team_id: 'team-1', team_name: 'Acme' };
+ state.teamError = new ThrownResultError([
+ { code: 'NETWORK_ERROR', message: 'Network error occurred' },
+ ]);
+ render(() => <TeamInviteLinkAcceptance token="abc-123" />);
+
+ expect(screen.getByRole('button', { name: 'Join Team' })).toBeTruthy();
+ });
+
+ it("doesn't call a link invalid when it only failed to load", () => {
+ state.teamError = new ThrownResultError([
+ { code: 'NETWORK_ERROR', message: 'Network error occurred' },
+ ]);
+ render(() => <TeamInviteLinkAcceptance token="abc-123" />);
+
+ expect(
+ screen.getByRole('heading', { name: "Couldn't Load Invite" })
+ ).toBeTruthy();
+ });
+
+ it('tells users on another team to leave it first', () => {
+ state.team = { team_id: 'team-1', team_name: 'Acme' };
+ state.joinError = new ThrownResultError([
+ { code: 'CONFLICT', message: 'Resource conflict' },
+ ]);
+ render(() => <TeamInviteLinkAcceptance token="abc-123" />);
+
+ expect(
+ screen.getByRole('heading', { name: 'Already on Another Team' })
+ ).toBeTruthy();
+ });
+});
diff --git a/apps/web/src/features/team-invitations/TeamInviteLinkAcceptance.tsx b/apps/web/src/features/team-invitations/TeamInviteLinkAcceptance.tsx
new file mode 100644
index 0000000000..e2b1f7cb34
--- /dev/null
+++ b/apps/web/src/features/team-invitations/TeamInviteLinkAcceptance.tsx
@@ -0,0 +1,119 @@
+import { LoadingBlock } from '@core/component/LoadingBlock';
+import { toast } from '@core/component/Toast/Toast';
+import { thrownResultErrorHasCode } from '@core/util/result';
+import SpinnerIcon from '@phosphor/spinner.svg';
+import UsersThreeIcon from '@phosphor/users-three.svg';
+import {
+ useJoinTeamByInviteLinkMutation,
+ useTeamByInviteLinkQuery,
+} from '@queries/team/invite-link';
+import { useNavigate } from '@solidjs/router';
+import { Button } from '@ui';
+import { Match, Show, Switch } from 'solid-js';
+
+/**
+ * The page a team's shareable invite link opens, for a signed-in user: names
+ * the team and joins it on confirmation.
+ */
+export function TeamInviteLinkAcceptance(props: { token: string }) {
+ const navigate = useNavigate();
+ const teamQuery = useTeamByInviteLinkQuery(
+ () => props.token,
+ () => true
+ );
+ // Keep the team on screen through a failed refetch; only a link the server
+ // says is gone is "not valid".
+ const team = () => (teamQuery.isPending ? undefined : teamQuery.data);
+ const teamName = () => team()?.team_name ?? '';
+
+ const joinMutation = useJoinTeamByInviteLinkMutation({
+ onSuccess: (result) => {
+ toast.success(
+ result.already_member
+ ? `You're already on ${teamName()}`
+ : `Joined ${teamName()}`
+ );
+ navigate('/', { replace: true });
+ },
+ });
+ const linkGone = () =>
+ thrownResultErrorHasCode(teamQuery.error, 'NOT_FOUND') ||
+ thrownResultErrorHasCode(joinMutation.error, 'NOT_FOUND');
+ const joinConflict = () =>
+ joinMutation.isError &&
+ thrownResultErrorHasCode(joinMutation.error, 'CONFLICT');
+
+ return (
+ <Switch>
+ <Match when={teamQuery.isPending}>
+ <LoadingBlock />
+ </Match>
+ <Match when={linkGone()}>
+ <Outcome
+ title="Invite Link Not Valid"
+ body="This invite link was reset or turned off. Ask someone on the team for a new one."
+ />
+ </Match>
+ <Match when={joinConflict()}>
+ <Outcome
+ title="Already on Another Team"
+ body="You can be on one team at a time. Leave your current team in Settings to join this one."
+ />
+ </Match>
+ <Match when={!team()}>
+ <Outcome
+ title="Couldn't Load Invite"
+ body="Check your connection and open the link again."
+ />
+ </Match>
+ <Match when={team()}>
+ <div class="flex flex-col items-center gap-6 text-center w-full">
+ <div class="flex flex-col gap-2">
+ <h2 class="flex items-center justify-center gap-2 text-lg font-medium text-ink">
+ <UsersThreeIcon class="size-5" />
+ Join {teamName()}
+ </h2>
+ <p class="text-sm text-ink-muted">
+ You've been invited to join{' '}
+ <span class="text-ink">{teamName()}</span> on Macro.
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ size="md"
+ class="w-full"
+ disabled={joinMutation.isPending}
+ onClick={() => joinMutation.mutate({ token: props.token })}
+ >
+ <Show when={joinMutation.isPending} fallback="Join Team">
+ <SpinnerIcon class="size-4 animate-spin" />
+ </Show>
+ </Button>
+ <Show when={joinMutation.isError}>
+ <p class="text-sm text-failure-ink" role="alert">
+ Couldn't join the team. Try again.
+ </p>
+ </Show>
+ </div>
+ </Match>
+ </Switch>
+ );
+}
+
+function Outcome(props: { title: string; body: string }) {
+ const navigate = useNavigate();
+ return (
+ <div class="w-full flex flex-col items-center gap-4 text-center">
+ <h2 class="text-lg font-medium text-ink">{props.title}</h2>
+ <p class="text-sm text-ink-muted">{props.body}</p>
+ <Button
+ variant="outline"
+ size="md"
+ class="w-full"
+ onClick={() => navigate('/')}
+ >
+ Go to Home
+ </Button>
+ </div>
+ );
+}
diff --git a/apps/web/src/lib/analytics/analytics.ts b/apps/web/src/lib/analytics/analytics.ts
index 40ee3a6267..79bb1f344f 100644
--- a/apps/web/src/lib/analytics/analytics.ts
+++ b/apps/web/src/lib/analytics/analytics.ts
@@ -11,8 +11,8 @@ import { DEV_MODE_ENV, PROD_MODE_ENV } from '@core/constant/featureFlags';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { getPlatform, isTauri } from '@core/util/platform';
import {
- redactCallLinkProperties,
- redactCallLinkTokens,
+ redactLinkTokenProperties,
+ redactLinkTokens,
} from '@core/util/telemetryUrl';
import { getWebOrigin } from '@core/util/webOrigin';
import type { Team } from '@service-auth/generated/schemas/team';
@@ -124,7 +124,7 @@ const POSTHOG_RECORDER_PROXY_SCRIPT_NAME = 'runtime.js';
function isPrivateCallPage() {
const path = window.location.pathname + window.location.hash;
- return redactCallLinkTokens(path) !== path;
+ return redactLinkTokens(path) !== path;
}
const initializePosthog = (instance: PostHog) => {
@@ -149,10 +149,10 @@ const initializePosthog = (instance: PostHog) => {
// Call URLs are bearer capabilities and meeting content must not replay.
if (isPrivateCallPage()) return null;
if (cr) {
- cr.properties = redactCallLinkProperties(cr.properties);
- if (cr.$set) cr.$set = redactCallLinkProperties(cr.$set);
+ cr.properties = redactLinkTokenProperties(cr.properties);
+ if (cr.$set) cr.$set = redactLinkTokenProperties(cr.$set);
if (cr.$set_once) {
- cr.$set_once = redactCallLinkProperties(cr.$set_once);
+ cr.$set_once = redactLinkTokenProperties(cr.$set_once);
}
cr.properties.env = DEV_MODE_ENV
? 'DEV'
@@ -405,10 +405,8 @@ const createAnalytics = () => {
if (disabled) return;
if (isPrivateCallPage()) return;
- const pagePath = redactCallLinkTokens(
- opts?.path ?? window.location.pathname
- );
- const pageLocation = redactCallLinkTokens(
+ const pagePath = redactLinkTokens(opts?.path ?? window.location.pathname);
+ const pageLocation = redactLinkTokens(
opts?.location ?? window.location.href
);
const deviceType = getDeviceType();
diff --git a/apps/web/src/lib/core/util/fetchWithToken.ts b/apps/web/src/lib/core/util/fetchWithToken.ts
index 6c015f7147..496c6038dc 100644
--- a/apps/web/src/lib/core/util/fetchWithToken.ts
+++ b/apps/web/src/lib/core/util/fetchWithToken.ts
@@ -12,7 +12,7 @@ import {
type SafeFetchInit,
safeFetch,
} from './safeFetch';
-import { redactCallLinkTokens, telemetryUrl } from './telemetryUrl';
+import { redactLinkTokens, telemetryUrl } from './telemetryUrl';
export type FetchWithTokenErrorCode = BaseFetchErrorCode;
@@ -209,7 +209,7 @@ export async function fetchWithToken<
Telemetry.error('fetchWithToken: fetchWithAuth failed', {
input: telemetryUrl(input),
method: init?.method,
- errors: redactCallLinkTokens(JSON.stringify(result.error)),
+ errors: redactLinkTokens(JSON.stringify(result.error)),
});
}
diff --git a/apps/web/src/lib/core/util/safeFetch.ts b/apps/web/src/lib/core/util/safeFetch.ts
index e40d5b5749..a91497d07f 100644
--- a/apps/web/src/lib/core/util/safeFetch.ts
+++ b/apps/web/src/lib/core/util/safeFetch.ts
@@ -5,7 +5,7 @@ import { match } from 'ts-pattern';
import { platformFetch } from './platformFetch';
import type { ObjectLike, ResultError } from './result';
import { sleep } from './sleep';
-import { redactCallLinkTokens } from './telemetryUrl';
+import { redactLinkTokens } from './telemetryUrl';
const tracedOrigins: ReadonlySet<string> = (() => {
const origins = new Set<string>();
@@ -45,7 +45,7 @@ function tracedFetch(
const url = requestUrl(input);
if (!url) return platformFetch(input, init);
const method = (init.method ?? 'GET').toUpperCase();
- const path = redactCallLinkTokens(url.pathname);
+ const path = redactLinkTokens(url.pathname);
const span = Telemetry.clientSpan(`http ${method} ${path}`);
const started = performance.now();
span.setAttr('http.method', method);
@@ -81,12 +81,10 @@ function tracedFetch(
error instanceof Error
? {
name: error.name,
- message: redactCallLinkTokens(error.message),
- stack: error.stack
- ? redactCallLinkTokens(error.stack)
- : undefined,
+ message: redactLinkTokens(error.message),
+ stack: error.stack ? redactLinkTokens(error.stack) : undefined,
}
- : redactCallLinkTokens(String(error))
+ : redactLinkTokens(String(error))
);
throw error;
} finally {
@@ -347,9 +345,7 @@ export async function safeFetch<
return fetchErr([
{
code: 'UNKNOWN_ERROR',
- message: redactCallLinkTokens(
- `An unknown error occurred: ${error}`
- ),
+ message: redactLinkTokens(`An unknown error occurred: ${error}`),
},
]);
}
diff --git a/apps/web/src/lib/core/util/telemetryUrl.test.ts b/apps/web/src/lib/core/util/telemetryUrl.test.ts
index 436a3421b1..1e76223875 100644
--- a/apps/web/src/lib/core/util/telemetryUrl.test.ts
+++ b/apps/web/src/lib/core/util/telemetryUrl.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
- redactCallLinkProperties,
- redactCallLinkTokens,
+ redactLinkTokenProperties,
+ redactLinkTokens,
telemetryUrl,
} from './telemetryUrl';
@@ -32,6 +32,38 @@ describe('meeting URL telemetry', () => {
expect(telemetryUrl(input)).toBe(expected);
});
+ it.each([
+ [
+ 'https://macro.com/app/team-invite?link=0a1b2c3d-secret',
+ 'https://macro.com/app/team-invite?link=:inviteToken',
+ ],
+ [
+ '/app/team-invite?utm_source=slack&link=secret#top',
+ '/app/team-invite?utm_source=slack&link=:inviteToken#top',
+ ],
+ ['/app/team-invite?id=invite-id', '/app/team-invite?id=invite-id'],
+ [
+ 'https://macro.com/app/login?redirect=%2Fteam-invite%3Flink%3Dsecret',
+ 'https://macro.com/app/login?redirect=%2Fteam-invite%3Flink%3D:inviteToken',
+ ],
+ [
+ '/app/login?redirect=%2Fteam-invite%3Fsource%3Dslack%26link%3Dsecret&next=1',
+ '/app/login?redirect=%2Fteam-invite%3Fsource%3Dslack%26link%3D:inviteToken&next=1',
+ ],
+ ])('redacts a team invite link token in %s', (input, expected) => {
+ expect(redactLinkTokens(input)).toBe(expected);
+ });
+
+ it('redacts team invite link tokens in pageview properties', () => {
+ expect(
+ redactLinkTokenProperties({
+ $current_url: 'https://macro.com/app/team-invite?link=secret',
+ })
+ ).toEqual({
+ $current_url: 'https://macro.com/app/team-invite?link=:inviteToken',
+ });
+ });
+
it('keeps unrelated endpoint paths intact', () => {
expect(telemetryUrl('/call/record/id/link')).toBe('/call/record/id/link');
expect(telemetryUrl('/calendar/meetings')).toBe('/calendar/meetings');
@@ -42,8 +74,8 @@ describe('meeting URL telemetry', () => {
it('redacts tokens included in serialized errors and exception messages', () => {
const message =
'Request to https://gateway.macro.com/dss/call/join/secret/leave failed';
- expect(redactCallLinkTokens(message)).not.toContain('secret');
- expect(redactCallLinkTokens(JSON.stringify({ message }))).not.toContain(
+ expect(redactLinkTokens(message)).not.toContain('secret');
+ expect(redactLinkTokens(JSON.stringify({ message }))).not.toContain(
'secret'
);
});
@@ -62,7 +94,7 @@ describe('meeting URL telemetry', () => {
$set_once: initialProperties,
};
- const sanitized = redactCallLinkProperties(properties);
+ const sanitized = redactLinkTokenProperties(properties);
expect(JSON.stringify(sanitized)).not.toContain('secret');
expect(sanitized.$set).toEqual({
@@ -75,12 +107,14 @@ describe('meeting URL telemetry', () => {
expect(sanitized.$current_url).toBe('https://macro.com/app');
expect(sanitized.$set).not.toBe(initialProperties);
expect(properties.$set.$initial_pathname).toBe('/app/meet/secret');
- expect(redactCallLinkProperties(initialProperties)).toEqual(sanitized.$set);
+ expect(redactLinkTokenProperties(initialProperties)).toEqual(
+ sanitized.$set
+ );
});
it('redacts setup capabilities in serialized messages and retained person properties', () => {
const url = 'https://macro.com/app/meet/join/private-token?source=calendar';
- const sanitized = redactCallLinkProperties({
+ const sanitized = redactLinkTokenProperties({
$current_url: url,
$set: { $initial_current_url: url },
$set_once: { $initial_referrer: url },
@@ -90,7 +124,7 @@ describe('meeting URL telemetry', () => {
'https://macro.com/app/meet/join/:shareToken?source=calendar'
);
expect(
- redactCallLinkTokens(JSON.stringify({ message: `Failed ${url}` }))
+ redactLinkTokens(JSON.stringify({ message: `Failed ${url}` }))
).not.toContain('private-token');
});
@@ -98,7 +132,7 @@ describe('meeting URL telemetry', () => {
const details = { count: 3 };
const properties = { details, $set: null, $set_once: ['unchanged'] };
- expect(redactCallLinkProperties(properties)).toEqual(properties);
- expect(redactCallLinkProperties(properties).details).toBe(details);
+ expect(redactLinkTokenProperties(properties)).toEqual(properties);
+ expect(redactLinkTokenProperties(properties).details).toBe(details);
});
});
diff --git a/apps/web/src/lib/core/util/telemetryUrl.ts b/apps/web/src/lib/core/util/telemetryUrl.ts
index 4bec225fb2..4608cbab06 100644
--- a/apps/web/src/lib/core/util/telemetryUrl.ts
+++ b/apps/web/src/lib/core/util/telemetryUrl.ts
@@ -1,27 +1,36 @@
-/** Meeting URLs contain bearer capabilities; retain the route, never the token. */
-export function redactCallLinkTokens(value: string): string {
- return value.replace(
- /(\/call\/(?:meetings\/)?(?:join|invite)\/|\/(?:app\/)?meet\/(?:join\/)?)([^/?#\s"']+)/g,
- (match, prefix: string, token: string) => {
- if (
- (prefix === '/meet/' || prefix === '/app/meet/') &&
- (token === 'new' || token === 'join')
- ) {
- return match;
+/**
+ * Meeting URLs and team invite links contain bearer capabilities; retain the
+ * route, never the token. Invite links are also matched percent-encoded, as in
+ * a login `redirect` parameter.
+ */
+export function redactLinkTokens(value: string): string {
+ return value
+ .replace(
+ /(\/call\/(?:meetings\/)?(?:join|invite)\/|\/(?:app\/)?meet\/(?:join\/)?)([^/?#\s"']+)/g,
+ (match, prefix: string, token: string) => {
+ if (
+ (prefix === '/meet/' || prefix === '/app/meet/') &&
+ (token === 'new' || token === 'join')
+ ) {
+ return match;
+ }
+ return `${prefix}:shareToken`;
}
- return `${prefix}:shareToken`;
- }
- );
+ )
+ .replace(
+ /((?:\/|%2F)team-invite(?:\?|%3F)(?:[^#\s"']*?(?:&|%26))?link(?:=|%3D))[^&%#\s"']+/gi,
+ '$1:inviteToken'
+ );
}
-/** Person-property updates can retain landing URLs after a meeting is closed. */
-export function redactCallLinkProperties(
+/** Person-property updates can retain landing URLs after the page is closed. */
+export function redactLinkTokenProperties(
properties: Record<string, unknown>
): Record<string, unknown> {
return Object.fromEntries(
Object.entries(properties).map(([key, value]) => {
if (typeof value === 'string') {
- return [key, redactCallLinkTokens(value)];
+ return [key, redactLinkTokens(value)];
}
if (
(key === '$set' || key === '$set_once') &&
@@ -35,7 +44,7 @@ export function redactCallLinkProperties(
Object.entries(value).map(([property, initialValue]) => [
property,
typeof initialValue === 'string'
- ? redactCallLinkTokens(initialValue)
+ ? redactLinkTokens(initialValue)
: initialValue,
])
),
@@ -49,5 +58,5 @@ export function redactCallLinkProperties(
/** Keep fetch diagnostics useful without recording query or path credentials. */
export function telemetryUrl(input: RequestInfo): string {
const raw = typeof input === 'string' ? input : input.url;
- return redactCallLinkTokens(raw.split(/[?#]/, 1)[0]);
+ return redactLinkTokens(raw.split(/[?#]/, 1)[0]);
}
diff --git a/apps/web/src/lib/queries/team/invite-link.ts b/apps/web/src/lib/queries/team/invite-link.ts
new file mode 100644
index 0000000000..40bedb6150
--- /dev/null
+++ b/apps/web/src/lib/queries/team/invite-link.ts
@@ -0,0 +1,125 @@
+import { toast } from '@core/component/Toast/Toast';
+import { throwOnErr } from '@core/util/result';
+import { authServiceClient } from '@service-auth/client';
+import type { JoinTeamByInviteLinkResponse } from '@service-auth/generated/schemas/joinTeamByInviteLinkResponse';
+import type { TeamInviteLinkResponse } from '@service-auth/generated/schemas/teamInviteLinkResponse';
+import { queryOptions, useMutation, useQuery } from '@tanstack/solid-query';
+import type { Accessor } from 'solid-js';
+import { queryClient } from '../client';
+import { type MutationCallbacks, withCallbacks } from '../utils';
+import { teamKeys } from './keys';
+import { invalidateUserTeams } from './teams';
+
+function fetchTeamInviteLink() {
+ return throwOnErr(() => authServiceClient.getTeamInviteLink());
+}
+
+const teamInviteLinkQueryOptions = (teamId: string, enabled: boolean) =>
+ queryOptions({
+ queryKey: teamKeys.inviteLink(teamId).queryKey,
+ queryFn: fetchTeamInviteLink,
+ enabled: !!teamId && enabled,
+ });
+
+/** The team's invite link token, or null when the team has none. */
+export function useTeamInviteLinkQuery(
+ teamId: Accessor<string>,
+ enabled: Accessor<boolean>
+) {
+ return useQuery(() => teamInviteLinkQueryOptions(teamId(), enabled()));
+}
+
+function setTeamInviteLink(teamId: string, token: string | null) {
+ queryClient.setQueryData<TeamInviteLinkResponse>(
+ teamKeys.inviteLink(teamId).queryKey,
+ { token }
+ );
+}
+
+type TeamInviteLinkArgs = { teamId: string };
+
+/** Creates the team's invite link, or replaces it with a new one. */
+export function useCreateTeamInviteLinkMutation(
+ callbacks?: MutationCallbacks<string, Error, TeamInviteLinkArgs>
+) {
+ return useMutation(() => ({
+ mutationFn: async (_args: TeamInviteLinkArgs) =>
+ (await throwOnErr(() => authServiceClient.createTeamInviteLink())).token,
+
+ ...withCallbacks<string, Error, TeamInviteLinkArgs>(
+ {
+ onSuccess: (token, { teamId }) => setTeamInviteLink(teamId, token),
+ onError: (error) => {
+ console.error('Failed to create team invite link', error);
+ toast.failure('Failed to create invite link');
+ },
+ },
+ callbacks
+ ),
+ }));
+}
+
+/** Turns off the team's invite link. */
+export function useDeleteTeamInviteLinkMutation(
+ callbacks?: MutationCallbacks<void, Error, TeamInviteLinkArgs>
+) {
+ return useMutation(() => ({
+ mutationFn: async (_args: TeamInviteLinkArgs) => {
+ await throwOnErr(() => authServiceClient.deleteTeamInviteLink());
+ },
+
+ ...withCallbacks<void, Error, TeamInviteLinkArgs>(
+ {
+ onSuccess: (_data, { teamId }) => {
+ setTeamInviteLink(teamId, null);
+ toast.success('Invite link turned off');
+ },
+ onError: (error) => {
+ console.error('Failed to turn off team invite link', error);
+ toast.failure('Failed to turn off invite link');
+ },
+ },
+ callbacks
+ ),
+ }));
+}
+
+function fetchTeamByInviteLink(token: string) {
+ return throwOnErr(() => authServiceClient.getTeamByInviteLink(token));
+}
+
+const teamByInviteLinkQueryOptions = (token: string, enabled: boolean) =>
+ queryOptions({
+ queryKey: teamKeys.inviteLinkTeam(token).queryKey,
+ queryFn: () => fetchTeamByInviteLink(token),
+ enabled: !!token && enabled,
+ // A missing link stays missing; don't retry the 404.
+ retry: false,
+ });
+
+/** The team an invite link joins. */
+export function useTeamByInviteLinkQuery(
+ token: Accessor<string>,
+ enabled: Accessor<boolean>
+) {
+ return useQuery(() => teamByInviteLinkQueryOptions(token(), enabled()));
+}
+
+/** Joins the team an invite link belongs to. */
+export function useJoinTeamByInviteLinkMutation(
+ callbacks?: MutationCallbacks<
+ JoinTeamByInviteLinkResponse,
+ Error,
+ { token: string }
+ >
+) {
+ return useMutation(() => ({
+ mutationFn: ({ token }: { token: string }) =>
+ throwOnErr(() => authServiceClient.joinTeamByInviteLink(token)),
+
+ ...withCallbacks<JoinTeamByInviteLinkResponse, Error, { token: string }>(
+ { onSuccess: () => invalidateUserTeams() },
+ callbacks
+ ),
+ }));
+}
diff --git a/apps/web/src/lib/queries/team/keys.ts b/apps/web/src/lib/queries/team/keys.ts
index 6a6c8412bb..642ce841b0 100644
--- a/apps/web/src/lib/queries/team/keys.ts
+++ b/apps/web/src/lib/queries/team/keys.ts
@@ -8,4 +8,6 @@ export const teamKeys = createQueryKeys('team', {
rejectInvite: null,
detail: (teamId: string) => [teamId],
invites: (teamId: string) => [teamId],
+ inviteLink: (teamId: string) => [teamId],
+ inviteLinkTeam: (token: string) => [token],
});
diff --git a/apps/web/src/lib/service-clients/service-auth/client.ts b/apps/web/src/lib/service-clients/service-auth/client.ts
index fb5c503ebe..f382ccf482 100644
--- a/apps/web/src/lib/service-clients/service-auth/client.ts
+++ b/apps/web/src/lib/service-clients/service-auth/client.ts
@@ -46,6 +46,7 @@ import type {
UserQuota,
} from './generated/schemas';
import type { AppleLoginRequest } from './generated/schemas/appleLoginRequest';
+import type { CreatedTeamInviteLinkResponse } from './generated/schemas/createdTeamInviteLinkResponse';
import type { CreateGtmInviteLinkRequest } from './generated/schemas/createGtmInviteLinkRequest';
import type { CreateTeamRequest } from './generated/schemas/createTeamRequest';
import type { EmptyResponse } from './generated/schemas/emptyResponse';
@@ -58,6 +59,7 @@ import type { GtmInviteLinkList } from './generated/schemas/gtmInviteLinkList';
import type { GtmInviteOffer } from './generated/schemas/gtmInviteOffer';
import type { GtmInviteOfferStatus } from './generated/schemas/gtmInviteOfferStatus';
import type { InviteToTeamRequest } from './generated/schemas/inviteToTeamRequest';
+import type { JoinTeamByInviteLinkResponse } from './generated/schemas/joinTeamByInviteLinkResponse';
import type { MacroApiTokenResponse } from './generated/schemas/macroApiTokenResponse';
import type { PasswordRequest } from './generated/schemas/passwordRequest';
import type { PatchTeamRequest } from './generated/schemas/patchTeamRequest';
@@ -69,6 +71,8 @@ import type { PublicGtmInviteLink } from './generated/schemas/publicGtmInviteLin
import type { PutProfilePictureParams } from './generated/schemas/putProfilePictureParams';
import type { PutUserNameQueryParams } from './generated/schemas/putUserNameQueryParams';
import type { Team } from './generated/schemas/team';
+import type { TeamInviteLinkResponse } from './generated/schemas/teamInviteLinkResponse';
+import type { TeamInviteLinkTeam } from './generated/schemas/teamInviteLinkTeam';
import type { TeamInvitesResponse } from './generated/schemas/teamInvitesResponse';
import type { TeamWithMembers } from './generated/schemas/teamWithMembers';
import type { ToggleAutoJoinDomainResponse } from './generated/schemas/toggleAutoJoinDomainResponse';
@@ -1290,6 +1294,69 @@ export const authServiceClient = {
).map((result) => result);
},
+ /**
+ * The caller's team invite link token, or null when the team has none.
+ * Anyone who may invite people to the team may read it.
+ */
+ async getTeamInviteLink() {
+ return (
+ await fetchWithAuth<TeamInviteLinkResponse>(
+ `${authHost}/team/invite-link`,
+ { method: 'GET' }
+ )
+ ).map((result) => result);
+ },
+
+ /**
+ * Creates the team's invite link, replacing any existing one so links
+ * already shared stop working. Replacing a link is admin-only.
+ */
+ async createTeamInviteLink() {
+ return (
+ await fetchWithAuth<CreatedTeamInviteLinkResponse>(
+ `${authHost}/team/invite-link`,
+ { method: 'POST' }
+ )
+ ).map((result) => result);
+ },
+
+ /** Turns off the team's invite link. Admin/Owner only. */
+ async deleteTeamInviteLink() {
+ return (
+ await fetchWithAuth<{}>(`${authHost}/team/invite-link`, {
+ method: 'DELETE',
+ })
+ ).map(() => undefined);
+ },
+
+ /** The team an invite link joins, shown before the user joins it. */
+ async getTeamByInviteLink(token: string) {
+ return (
+ await fetchWithAuth<TeamInviteLinkTeam>(
+ `${authHost}/team/invite-link/team`,
+ {
+ method: 'POST',
+ // In the body, not the path, so request telemetry never records it.
+ body: JSON.stringify({ token }),
+ }
+ )
+ ).map((result) => result);
+ },
+
+ /**
+ * Joins the team an invite link belongs to. Fails with NOT_FOUND when the
+ * link was reset or turned off, and CONFLICT when the user is on another
+ * team.
+ */
+ async joinTeamByInviteLink(token: string) {
+ return (
+ await fetchWithAuth<JoinTeamByInviteLinkResponse>(
+ `${authHost}/team/invite-link/join`,
+ { method: 'POST', body: JSON.stringify({ token }) }
+ )
+ ).map((result) => result);
+ },
+
async deleteTeamInvite(teamInviteId: string) {
return (
await fetchWithAuth<{}>(`${authHost}/team/invite/${teamInviteId}`, {
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/client.ts b/apps/web/src/lib/service-clients/service-auth/generated/client.ts
index 4a04928fb7..b550134f49 100644
--- a/apps/web/src/lib/service-clients/service-auth/generated/client.ts
+++ b/apps/web/src/lib/service-clients/service-auth/generated/client.ts
@@ -17,6 +17,7 @@ import type {
CodexLoginStart,
CreateAccountMergeRequest,
CreateCheckoutSessionV2Request,
+ CreatedTeamInviteLinkResponse,
CreateGtmInviteLinkRequest,
CreateInProgressLinkResponse,
CreatePortalSessionRequest,
@@ -53,6 +54,7 @@ import type {
InitOutlookLinkParams,
InitOutlookLinkResponse,
InviteToTeamRequest,
+ JoinTeamByInviteLinkResponse,
ListGtmInviteLinksParams,
MacroApiTokenParams,
MacroApiTokenResponse,
@@ -90,6 +92,9 @@ import type {
StripeSessionResponse,
SubscriptionStatus,
Team,
+ TeamInviteLinkResponse,
+ TeamInviteLinkTeam,
+ TeamInviteLinkTokenRequest,
TeamInvitesResponse,
TeamMember,
TeamWithMembers,
@@ -4279,6 +4284,333 @@ export const inviteToTeam = async (
} as inviteToTeamResponse;
};
+/**
+ * @summary Gets the team's invite link. Anyone who may invite people to the team may
+see it.
+ */
+export type getTeamInviteLinkResponse200 = {
+ data: TeamInviteLinkResponse;
+ status: 200;
+};
+
+export type getTeamInviteLinkResponse401 = {
+ data: ErrorResponse;
+ status: 401;
+};
+
+export type getTeamInviteLinkResponse403 = {
+ data: ErrorResponse;
+ status: 403;
+};
+
+export type getTeamInviteLinkResponse500 = {
+ data: ErrorResponse;
+ status: 500;
+};
+
+export type getTeamInviteLinkResponseSuccess = getTeamInviteLinkResponse200 & {
+ headers: Headers;
+};
+export type getTeamInviteLinkResponseError = (
+ | getTeamInviteLinkResponse401
+ | getTeamInviteLinkResponse403
+ | getTeamInviteLinkResponse500
+) & {
+ headers: Headers;
+};
+
+export type getTeamInviteLinkResponse =
+ | getTeamInviteLinkResponseSuccess
+ | getTeamInviteLinkResponseError;
+
+export const getGetTeamInviteLinkUrl = () => {
+ return `/team/invite-link`;
+};
+
+export const getTeamInviteLink = async (
+ options?: RequestInit
+): Promise<getTeamInviteLinkResponse> => {
+ const res = await fetch(getGetTeamInviteLinkUrl(), {
+ ...options,
+ method: 'GET',
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: getTeamInviteLinkResponse['data'] = body ? JSON.parse(body) : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as getTeamInviteLinkResponse;
+};
+
+/**
+ * @summary Creates the team's invite link, replacing any existing one. Anyone who may
+invite people may create the first link; replacing one requires a team
+admin or owner.
+ */
+export type createTeamInviteLinkResponse201 = {
+ data: CreatedTeamInviteLinkResponse;
+ status: 201;
+};
+
+export type createTeamInviteLinkResponse401 = {
+ data: ErrorResponse;
+ status: 401;
+};
+
+export type createTeamInviteLinkResponse403 = {
+ data: ErrorResponse;
+ status: 403;
+};
+
+export type createTeamInviteLinkResponse500 = {
+ data: ErrorResponse;
+ status: 500;
+};
+
+export type createTeamInviteLinkResponseSuccess =
+ createTeamInviteLinkResponse201 & {
+ headers: Headers;
+ };
+export type createTeamInviteLinkResponseError = (
+ | createTeamInviteLinkResponse401
+ | createTeamInviteLinkResponse403
+ | createTeamInviteLinkResponse500
+) & {
+ headers: Headers;
+};
+
+export type createTeamInviteLinkResponse =
+ | createTeamInviteLinkResponseSuccess
+ | createTeamInviteLinkResponseError;
+
+export const getCreateTeamInviteLinkUrl = () => {
+ return `/team/invite-link`;
+};
+
+export const createTeamInviteLink = async (
+ options?: RequestInit
+): Promise<createTeamInviteLinkResponse> => {
+ const res = await fetch(getCreateTeamInviteLinkUrl(), {
+ ...options,
+ method: 'POST',
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: createTeamInviteLinkResponse['data'] = body
+ ? JSON.parse(body)
+ : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as createTeamInviteLinkResponse;
+};
+
+/**
+ * @summary Turns off the team's invite link. Requires a team admin or owner.
+ */
+export type deleteTeamInviteLinkResponse204 = {
+ data: void;
+ status: 204;
+};
+
+export type deleteTeamInviteLinkResponse401 = {
+ data: ErrorResponse;
+ status: 401;
+};
+
+export type deleteTeamInviteLinkResponse403 = {
+ data: ErrorResponse;
+ status: 403;
+};
+
+export type deleteTeamInviteLinkResponse500 = {
+ data: ErrorResponse;
+ status: 500;
+};
+
+export type deleteTeamInviteLinkResponseSuccess =
+ deleteTeamInviteLinkResponse204 & {
+ headers: Headers;
+ };
+export type deleteTeamInviteLinkResponseError = (
+ | deleteTeamInviteLinkResponse401
+ | deleteTeamInviteLinkResponse403
+ | deleteTeamInviteLinkResponse500
+) & {
+ headers: Headers;
+};
+
+export type deleteTeamInviteLinkResponse =
+ | deleteTeamInviteLinkResponseSuccess
+ | deleteTeamInviteLinkResponseError;
+
+export const getDeleteTeamInviteLinkUrl = () => {
+ return `/team/invite-link`;
+};
+
+export const deleteTeamInviteLink = async (
+ options?: RequestInit
+): Promise<deleteTeamInviteLinkResponse> => {
+ const res = await fetch(getDeleteTeamInviteLinkUrl(), {
+ ...options,
+ method: 'DELETE',
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: deleteTeamInviteLinkResponse['data'] = body
+ ? JSON.parse(body)
+ : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as deleteTeamInviteLinkResponse;
+};
+
+/**
+ * @summary Joins the team an invite link belongs to.
+ */
+export type joinTeamByInviteLinkResponse200 = {
+ data: JoinTeamByInviteLinkResponse;
+ status: 200;
+};
+
+export type joinTeamByInviteLinkResponse401 = {
+ data: ErrorResponse;
+ status: 401;
+};
+
+export type joinTeamByInviteLinkResponse404 = {
+ data: ErrorResponse;
+ status: 404;
+};
+
+export type joinTeamByInviteLinkResponse409 = {
+ data: ErrorResponse;
+ status: 409;
+};
+
+export type joinTeamByInviteLinkResponse500 = {
+ data: ErrorResponse;
+ status: 500;
+};
+
+export type joinTeamByInviteLinkResponseSuccess =
+ joinTeamByInviteLinkResponse200 & {
+ headers: Headers;
+ };
+export type joinTeamByInviteLinkResponseError = (
+ | joinTeamByInviteLinkResponse401
+ | joinTeamByInviteLinkResponse404
+ | joinTeamByInviteLinkResponse409
+ | joinTeamByInviteLinkResponse500
+) & {
+ headers: Headers;
+};
+
+export type joinTeamByInviteLinkResponse =
+ | joinTeamByInviteLinkResponseSuccess
+ | joinTeamByInviteLinkResponseError;
+
+export const getJoinTeamByInviteLinkUrl = () => {
+ return `/team/invite-link/join`;
+};
+
+export const joinTeamByInviteLink = async (
+ teamInviteLinkTokenRequest: TeamInviteLinkTokenRequest,
+ options?: RequestInit
+): Promise<joinTeamByInviteLinkResponse> => {
+ const res = await fetch(getJoinTeamByInviteLinkUrl(), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(teamInviteLinkTokenRequest),
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: joinTeamByInviteLinkResponse['data'] = body
+ ? JSON.parse(body)
+ : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as joinTeamByInviteLinkResponse;
+};
+
+/**
+ * @summary Gets the team an invite link joins, so the user can see it before joining.
+ */
+export type getTeamByInviteLinkResponse200 = {
+ data: TeamInviteLinkTeam;
+ status: 200;
+};
+
+export type getTeamByInviteLinkResponse401 = {
+ data: ErrorResponse;
+ status: 401;
+};
+
+export type getTeamByInviteLinkResponse404 = {
+ data: ErrorResponse;
+ status: 404;
+};
+
+export type getTeamByInviteLinkResponse500 = {
+ data: ErrorResponse;
+ status: 500;
+};
+
+export type getTeamByInviteLinkResponseSuccess =
+ getTeamByInviteLinkResponse200 & {
+ headers: Headers;
+ };
+export type getTeamByInviteLinkResponseError = (
+ | getTeamByInviteLinkResponse401
+ | getTeamByInviteLinkResponse404
+ | getTeamByInviteLinkResponse500
+) & {
+ headers: Headers;
+};
+
+export type getTeamByInviteLinkResponse =
+ | getTeamByInviteLinkResponseSuccess
+ | getTeamByInviteLinkResponseError;
+
+export const getGetTeamByInviteLinkUrl = () => {
+ return `/team/invite-link/team`;
+};
+
+export const getTeamByInviteLink = async (
+ teamInviteLinkTokenRequest: TeamInviteLinkTokenRequest,
+ options?: RequestInit
+): Promise<getTeamByInviteLinkResponse> => {
+ const res = await fetch(getGetTeamByInviteLinkUrl(), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(teamInviteLinkTokenRequest),
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: getTeamByInviteLinkResponse['data'] = body
+ ? JSON.parse(body)
+ : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as getTeamByInviteLinkResponse;
+};
+
/**
* @summary Deletes a team invite from a team.
*/
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/createdTeamInviteLinkResponse.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/createdTeamInviteLinkResponse.ts
new file mode 100644
index 0000000000..34cefa33f4
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/createdTeamInviteLinkResponse.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { TeamInviteLinkToken } from './teamInviteLinkToken';
+
+/**
+ * A newly created team invite link.
+ */
+export interface CreatedTeamInviteLinkResponse {
+ /** The new link's token. Any previous link stops working. */
+ token: TeamInviteLinkToken;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts
index 14a5ab36f2..c682e2b41b 100644
--- a/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts
@@ -36,6 +36,7 @@ export * from './createAccountMergeRequest';
export * from './createCheckoutSessionV2Request';
export * from './createCheckoutSessionV2RequestDiscount';
export * from './createCheckoutSessionV2RequestPlan';
+export * from './createdTeamInviteLinkResponse';
export * from './createGtmInviteLinkRequest';
export * from './createGtmInviteLinkRequestNote';
export * from './createGtmInviteLinkRequestRecipientEmail';
@@ -139,6 +140,7 @@ export * from './initOutlookLinkParams';
export * from './initOutlookLinkResponse';
export * from './inviteEntry';
export * from './inviteToTeamRequest';
+export * from './joinTeamByInviteLinkResponse';
export * from './linkShare';
export * from './listGtmInviteLinksParams';
export * from './macroApiTokenParams';
@@ -201,6 +203,11 @@ export * from './team';
export * from './teamAutoJoinDomain';
export * from './teamDefaultLinkShare';
export * from './teamInviteDetails';
+export * from './teamInviteLinkResponse';
+export * from './teamInviteLinkResponseToken';
+export * from './teamInviteLinkTeam';
+export * from './teamInviteLinkToken';
+export * from './teamInviteLinkTokenRequest';
export * from './teamInvitesResponse';
export * from './teamMember';
export * from './teamPlan';
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/joinTeamByInviteLinkResponse.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/joinTeamByInviteLinkResponse.ts
new file mode 100644
index 0000000000..d5dfd91499
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/joinTeamByInviteLinkResponse.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The result of opening a team invite link.
+ */
+export interface JoinTeamByInviteLinkResponse {
+ /** True when the user was already on the team and nothing changed. */
+ already_member: boolean;
+ /** The team the link joins. */
+ team_id: string;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkResponse.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkResponse.ts
new file mode 100644
index 0000000000..03d269643a
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkResponse.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { TeamInviteLinkResponseToken } from './teamInviteLinkResponseToken';
+
+/**
+ * The caller's team invite link.
+ */
+export interface TeamInviteLinkResponse {
+ token?: TeamInviteLinkResponseToken;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkResponseToken.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkResponseToken.ts
new file mode 100644
index 0000000000..b7ae7af51c
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkResponseToken.ts
@@ -0,0 +1,9 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { TeamInviteLinkToken } from './teamInviteLinkToken';
+
+export type TeamInviteLinkResponseToken = null | TeamInviteLinkToken;
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkTeam.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkTeam.ts
new file mode 100644
index 0000000000..cece7c3f4b
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkTeam.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The team an invite link joins, shown before the user accepts.
+ */
+export interface TeamInviteLinkTeam {
+ /** Id of the team the link joins. */
+ team_id: string;
+ /** Name of the team the link joins. */
+ team_name: string;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkToken.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkToken.ts
new file mode 100644
index 0000000000..5c6dc75b54
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkToken.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The secret in a team's shareable invite link.
+
+Anyone signed in who holds the token can join the team, so it is a random
+value rather than a time-ordered id, and an admin resetting the link
+replaces it.
+ */
+export type TeamInviteLinkToken = string;
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkTokenRequest.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkTokenRequest.ts
new file mode 100644
index 0000000000..cf074d82cf
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/teamInviteLinkTokenRequest.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { TeamInviteLinkToken } from './teamInviteLinkToken';
+
+/**
+ * Identifies an invite link. The token travels in the body, not the path, so
+request spans and access logs that record the path never see it.
+ */
+export interface TeamInviteLinkTokenRequest {
+ /** The invite link's token. */
+ token: TeamInviteLinkToken;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/openapi.json b/apps/web/src/lib/service-clients/service-auth/openapi.json
index 4aacf78ac8..ffbdbdbd24 100644
--- a/apps/web/src/lib/service-clients/service-auth/openapi.json
+++ b/apps/web/src/lib/service-clients/service-auth/openapi.json
@@ -3600,6 +3600,270 @@
}
}
},
+ "/team/invite-link": {
+ "get": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Gets the team's invite link. Anyone who may invite people to the team may\nsee it.",
+ "operationId": "get_team_invite_link",
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Creates the team's invite link, replacing any existing one. Anyone who may\ninvite people may create the first link; replacing one requires a team\nadmin or owner.",
+ "operationId": "create_team_invite_link",
+ "responses": {
+ "201": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CreatedTeamInviteLinkResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ },
+ "delete": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Turns off the team's invite link. Requires a team admin or owner.",
+ "operationId": "delete_team_invite_link",
+ "responses": {
+ "204": {
+ "description": ""
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/team/invite-link/join": {
+ "post": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Joins the team an invite link belongs to.",
+ "operationId": "join_team_by_invite_link",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkTokenRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/JoinTeamByInviteLinkResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/team/invite-link/team": {
+ "post": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Gets the team an invite link joins, so the user can see it before joining.",
+ "operationId": "get_team_by_invite_link",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkTokenRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkTeam"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/team/invite/{team_invite_id}": {
"delete": {
"tags": ["teams::inbound::axum_router::delete_team_invite"],
@@ -5570,6 +5834,17 @@
}
}
},
+ "CreatedTeamInviteLinkResponse": {
+ "type": "object",
+ "description": "A newly created team invite link.",
+ "required": ["token"],
+ "properties": {
+ "token": {
+ "$ref": "#/components/schemas/TeamInviteLinkToken",
+ "description": "The new link's token. Any previous link stops working."
+ }
+ }
+ },
"CreditCheckoutRequestBody": {
"type": "object",
"description": "Request body for [`create_credit_checkout_handler`].",
@@ -6568,6 +6843,22 @@
}
}
},
+ "JoinTeamByInviteLinkResponse": {
+ "type": "object",
+ "description": "The result of opening a team invite link.",
+ "required": ["team_id", "already_member"],
+ "properties": {
+ "already_member": {
+ "type": "boolean",
+ "description": "True when the user was already on the team and nothing changed."
+ },
+ "team_id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "The team the link joins."
+ }
+ }
+ },
"LinkShare": {
"type": "string",
"description": "Defines who can access an item through its share link.",
@@ -7277,6 +7568,54 @@
}
}
},
+ "TeamInviteLinkResponse": {
+ "type": "object",
+ "description": "The caller's team invite link.",
+ "properties": {
+ "token": {
+ "oneOf": [
+ {
+ "type": "null"
+ },
+ {
+ "$ref": "#/components/schemas/TeamInviteLinkToken",
+ "description": "The link's token, or null when the team has no invite link."
+ }
+ ]
+ }
+ }
+ },
+ "TeamInviteLinkTeam": {
+ "type": "object",
+ "description": "The team an invite link joins, shown before the user accepts.",
+ "required": ["team_id", "team_name"],
+ "properties": {
+ "team_id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Id of the team the link joins."
+ },
+ "team_name": {
+ "type": "string",
+ "description": "Name of the team the link joins."
+ }
+ }
+ },
+ "TeamInviteLinkToken": {
+ "type": "string",
+ "description": "The secret in a team's shareable invite link.\n\nAnyone signed in who holds the token can join the team, so it is a random\nvalue rather than a time-ordered id, and an admin resetting the link\nreplaces it."
+ },
+ "TeamInviteLinkTokenRequest": {
+ "type": "object",
+ "description": "Identifies an invite link. The token travels in the body, not the path, so\nrequest spans and access logs that record the path never see it.",
+ "required": ["token"],
+ "properties": {
+ "token": {
+ "$ref": "#/components/schemas/TeamInviteLinkToken",
+ "description": "The invite link's token."
+ }
+ }
+ },
"TeamInvitesResponse": {
"type": "object",
"description": "Response containing a list of team invites",
diff --git a/crates/agent_code_mode/src/domain/operations.json b/crates/agent_code_mode/src/domain/operations.json
index 4a471e44fd..0165cca54b 100644
--- a/crates/agent_code_mode/src/domain/operations.json
+++ b/crates/agent_code_mode/src/domain/operations.json
@@ -111,6 +111,11 @@
"auth.toggleTeamAutoJoinDomain": "Toggle Team Auto Join Domain",
"auth.patchTeamCrmSettings": "Patch Team Crm Settings",
"auth.inviteToTeam": "Invite To Team",
+ "auth.deleteTeamInviteLink": "Delete Team Invite Link",
+ "auth.getTeamInviteLink": "Get Team Invite Link",
+ "auth.createTeamInviteLink": "Create Team Invite Link",
+ "auth.joinTeamByInviteLink": "Join Team By Invite Link",
+ "auth.getTeamByInviteLink": "Get Team By Invite Link",
"auth.deleteTeamInviteHandler": "Delete Team Invite",
"auth.getTeamInvites": "Get Team Invites",
"auth.rejectInvitation": "Reject Invitation",
diff --git a/crates/code_execution/src/outbound/deno/sdk.mjs b/crates/code_execution/src/outbound/deno/sdk.mjs
index 8c2489618c..2100f4b0c6 100644
--- a/crates/code_execution/src/outbound/deno/sdk.mjs
+++ b/crates/code_execution/src/outbound/deno/sdk.mjs
@@ -9,7 +9,7 @@ async function bO($,O,j){if(!Number.isInteger(O)||O<1)throw RangeError(`concurre
`);U=g.pop()??"";for(let r of g){let p=r.split(`
`),F=[],y;for(let R of p)if(R.startsWith("data:"))F.push(R.replace(/^data:\s*/,""));else if(R.startsWith("event:"))y=R.replace(/^event:\s*/,"");else if(R.startsWith("id:"))Q=R.replace(/^id:\s*/,"");else if(R.startsWith("retry:")){let h=Number.parseInt(R.replace(/^retry:\s*/,""),10);if(!Number.isNaN(h))V=h}let _,v=!1;if(F.length){let R=F.join(`
-`);try{_=JSON.parse(R),v=!0}catch{_=R}}if(v){if(S)await S(_);if(x)_=await x(_)}if(j?.({data:_,event:y,id:Q,retry:V}),F.length)yield _}}}finally{I.removeEventListener("abort",k),H.releaseLock()}break}catch(D){if(O?.(D),Z!==void 0&&B>=Z)break;let C=Math.min(V*2**(B-1),X??30000);await T(C)}}}()}}var Q7=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},J7=($)=>{switch($){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},V7=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Pj=({allowReserved:$,explode:O,name:j,style:x,value:S})=>{if(!O){let X=($?S:S.map((G)=>encodeURIComponent(G))).join(J7(x));switch(x){case"label":return`.${X}`;case"matrix":return`;${j}=${X}`;case"simple":return X;default:return`${j}=${X}`}}let K=Q7(x),Z=S.map((X)=>{if(x==="label"||x==="simple")return $?X:encodeURIComponent(X);return TO({allowReserved:$,name:j,value:X})}).join(K);return x==="label"||x==="matrix"?K+Z:Z},TO=({allowReserved:$,name:O,value:j})=>{if(j===void 0||j===null)return"";if(typeof j==="object")throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${O}=${$?j:encodeURIComponent(j)}`},Fj=({allowReserved:$,explode:O,name:j,style:x,value:S,valueOnly:K})=>{if(S instanceof Date)return K?S.toISOString():`${j}=${S.toISOString()}`;if(x!=="deepObject"&&!O){let G=[];Object.entries(S).forEach(([Y,Q])=>{G=[...G,Y,$?Q:encodeURIComponent(Q)]});let L=G.join(",");switch(x){case"form":return`${j}=${L}`;case"label":return`.${L}`;case"matrix":return`;${j}=${L}`;default:return L}}let Z=V7(x),X=Object.entries(S).map(([G,L])=>TO({allowReserved:$,name:x==="deepObject"?`${j}[${G}]`:G,value:L})).join(Z);return x==="label"||x==="matrix"?Z+X:X};var W7=/\{[^{}]+\}/g,B7=({path:$,url:O})=>{let j=O,x=O.match(W7);if(x)for(let S of x){let K=!1,Z=S.substring(1,S.length-1),X="simple";if(Z.endsWith("*"))K=!0,Z=Z.substring(0,Z.length-1);if(Z.startsWith("."))Z=Z.substring(1),X="label";else if(Z.startsWith(";"))Z=Z.substring(1),X="matrix";let G=$[Z];if(G===void 0||G===null)continue;if(Array.isArray(G)){j=j.replace(S,Pj({explode:K,name:Z,style:X,value:G}));continue}if(typeof G==="object"){j=j.replace(S,Fj({explode:K,name:Z,style:X,value:G,valueOnly:!0}));continue}if(X==="matrix"){j=j.replace(S,`;${TO({name:Z,value:G})}`);continue}let L=encodeURIComponent(X==="label"?`.${G}`:G);j=j.replace(S,L)}return j},e1=({baseUrl:$,path:O,query:j,querySerializer:x,url:S})=>{let K=S.startsWith("/")?S:`/${S}`,Z=($??"")+K;if(O)Z=B7({path:O,url:Z});let X=j?x(j):"";if(X.startsWith("?"))X=X.substring(1);if(X)Z+=`?${X}`;return Z};function q0($){let O=$.body!==void 0;if(O&&$.bodySerializer){if("serializedBody"in $)return $.serializedBody!==void 0&&$.serializedBody!==""?$.serializedBody:null;return $.body!==""?$.body:null}if(O)return $.body;return}var o1=async($,O)=>{let j=typeof O==="function"?await O($):O;if(!j)return;if($.scheme==="bearer")return`Bearer ${j}`;if($.scheme==="basic")return`Basic ${btoa(j)}`;return j};var $S={bodySerializer:($)=>JSON.stringify($,(O,j)=>typeof j==="bigint"?j.toString():j)};var OS=({parameters:$={},...O}={})=>{return(x)=>{let S=[];if(x&&typeof x==="object")for(let K in x){let Z=x[K];if(Z===void 0||Z===null)continue;let X=$[K]||O;if(Array.isArray(Z)){let G=Pj({allowReserved:X.allowReserved,explode:!0,name:K,style:"form",value:Z,...X.array});if(G)S.push(G)}else if(typeof Z==="object"){let G=Fj({allowReserved:X.allowReserved,explode:!0,name:K,style:"deepObject",value:Z,...X.object});if(G)S.push(G)}else{let G=TO({allowReserved:X.allowReserved,name:K,value:Z});if(G)S.push(G)}}return S.join("&")}},jS=($)=>{if(!$)return"stream";let O=$.split(";")[0]?.trim();if(!O)return;if(O.startsWith("application/json")||O.endsWith("+json"))return"json";if(O==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((j)=>O.startsWith(j)))return"blob";if(O.startsWith("text/"))return"text";return},L7=($,O)=>{if(!O)return!1;if($.headers.has(O)||$.query?.[O]||$.headers.get("Cookie")?.includes(`${O}=`))return!0;return!1};async function xS($){for(let O of $.security??[]){if(L7($,O.name))continue;let j=await o1(O,$.auth);if(!j)continue;let x=O.name??"Authorization";switch(O.in){case"query":if(!$.query)$.query={};$.query[x]=j;break;case"cookie":$.headers.append("Cookie",`${x}=${j}`);break;case"header":default:$.headers.set(x,j);break}}}var f0=($)=>e1({baseUrl:$.baseUrl,path:$.path,query:$.query,querySerializer:typeof $.querySerializer==="function"?$.querySerializer:OS($.querySerializer),url:$.url}),b0=($,O)=>{let j={...$,...O};if(j.baseUrl?.endsWith("/"))j.baseUrl=j.baseUrl.substring(0,j.baseUrl.length-1);return j.headers=wj($.headers,O.headers),j},N7=($)=>{let O=[];return $.forEach((j,x)=>{O.push([x,j])}),O},wj=(...$)=>{let O=new Headers;for(let j of $){if(!j)continue;let x=j instanceof Headers?N7(j):Object.entries(j);for(let[S,K]of x)if(K===null)O.delete(S);else if(Array.isArray(K))for(let Z of K)O.append(S,Z);else if(K!==void 0)O.set(S,typeof K==="object"?JSON.stringify(K):K)}return O};class Ej{fns=[];clear(){this.fns=[]}eject($){let O=this.getInterceptorIndex($);if(this.fns[O])this.fns[O]=null}exists($){let O=this.getInterceptorIndex($);return Boolean(this.fns[O])}getInterceptorIndex($){if(typeof $==="number")return this.fns[$]?$:-1;return this.fns.indexOf($)}update($,O){let j=this.getInterceptorIndex($);if(this.fns[j])return this.fns[j]=O,$;return!1}use($){return this.fns.push($),this.fns.length-1}}var SS=()=>({error:new Ej,request:new Ej,response:new Ej}),U7=OS({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),z7={"Content-Type":"application/json"},iO=($={})=>({...$S,headers:z7,parseAs:"auto",querySerializer:U7,...$});var k0=($={})=>{let O=b0(iO(),$),j=()=>({...O}),x=(Y)=>{return O=b0(O,Y),j()},S=SS(),K=async(Y)=>{let Q={...O,...Y,fetch:Y.fetch??O.fetch??globalThis.fetch,headers:wj(O.headers,Y.headers),serializedBody:void 0};if(Q.security)await xS(Q);if(Q.requestValidator)await Q.requestValidator(Q);if(Q.body!==void 0&&Q.bodySerializer)Q.serializedBody=Q.bodySerializer(Q.body);if(Q.body===void 0||Q.serializedBody==="")Q.headers.delete("Content-Type");let T=Q,z=f0(T);return{opts:T,url:z}},Z=async(Y)=>{let Q=Y.throwOnError??O.throwOnError,T=Y.responseStyle??O.responseStyle,z,W;try{let{opts:V,url:B}=await K(Y),I={redirect:"follow",...V,body:q0(V)};z=new Request(B,I);for(let N of S.request.fns)if(N)z=await N(z,V);let P=V.fetch;W=await P(z);for(let N of S.response.fns)if(N)W=await N(W,z,V);let D={request:z,response:W};if(W.ok){let N=(V.parseAs==="auto"?jS(W.headers.get("Content-Type")):V.parseAs)??"json";if(W.status===204||W.headers.get("Content-Length")==="0"){let U;switch(N){case"arrayBuffer":case"blob":case"text":U=await W[N]();break;case"formData":U=new FormData;break;case"stream":U=W.body;break;case"json":default:U={};break}return V.responseStyle==="data"?U:{data:U,...D}}let H;switch(N){case"arrayBuffer":case"blob":case"formData":case"text":H=await W[N]();break;case"json":{let U=await W.text();H=U?JSON.parse(U):{};break}case"stream":return V.responseStyle==="data"?W.body:{data:W.body,...D}}if(N==="json"){if(V.responseValidator)await V.responseValidator(H);if(V.responseTransformer)H=await V.responseTransformer(H)}return V.responseStyle==="data"?H:{data:H,...D}}let C=await W.text(),E;try{E=JSON.parse(C)}catch{}throw E??C}catch(V){let B=V;for(let I of S.error.fns)if(I)B=await I(B,W,z,Y);if(B=B||{},Q)throw B;return T==="data"?void 0:{error:B,request:z,response:W}}},X=(Y)=>(Q)=>Z({...Q,method:Y}),G=(Y)=>async(Q)=>{let{opts:T,url:z}=await K(Q);return t1({...T,body:T.body,method:Y,onRequest:async(W,V)=>{let B=new Request(W,V);for(let I of S.request.fns)if(I)B=await I(B,T);return B},serializedBody:q0(T),url:z})};return{buildUrl:(Y)=>f0({...O,...Y}),connect:X("CONNECT"),delete:X("DELETE"),get:X("GET"),getConfig:j,head:X("HEAD"),interceptors:S,options:X("OPTIONS"),patch:X("PATCH"),post:X("POST"),put:X("PUT"),request:Z,setConfig:x,sse:{connect:G("CONNECT"),delete:G("DELETE"),get:G("GET"),head:G("HEAD"),options:G("OPTIONS"),patch:G("PATCH"),post:G("POST"),put:G("PUT"),trace:G("TRACE")},trace:X("TRACE")}};var ZS=k0(iO());class XS{client;constructor($){this.client=$?.client??ZS}}class GS{defaultKey="default";instances=new Map;get($){let O=this.instances.get($??this.defaultKey);if(!O)throw Error('No SDK client found. Create one with "new Sdk()" to fix this error.');return O}set($,O){this.instances.set(O??this.defaultKey,$)}}class qj extends XS{static __registry=new GS;constructor($){super($);qj.__registry.set(this,$?.key)}updateAiBillingAutoReload($){return($.client??this.client).patch({url:"/ai-billing/auto-reload",...$,headers:{"Content-Type":"application/json",...$.headers}})}createAiCreditCheckout($){return($.client??this.client).post({url:"/ai-billing/credits/checkout",...$,headers:{"Content-Type":"application/json",...$.headers}})}updateAiBillingOverage($){return($.client??this.client).patch({url:"/ai-billing/overage",...$,headers:{"Content-Type":"application/json",...$.headers}})}getAiBillingPlans($){return($?.client??this.client).get({url:"/ai-billing/plans",...$})}getAiBillingSummary($){return($?.client??this.client).get({url:"/ai-billing/summary",...$})}disconnectCodex($){return($?.client??this.client).delete({url:"/codex",...$})}getCodexConnection($){return($?.client??this.client).get({url:"/codex",...$})}configureCodex($){return($.client??this.client).put({url:"/codex/config",...$,headers:{"Content-Type":"application/json",...$.headers}})}listCodexEnvironments($){return($?.client??this.client).get({url:"/codex/environments",...$})}startCodexLogin($){return($?.client??this.client).post({url:"/codex/login",...$})}cancelCodexLogin($){return($.client??this.client).delete({url:"/codex/login/{attempt_id}",...$})}pollCodexLogin($){return($.client??this.client).get({url:"/codex/login/{attempt_id}",...$})}deleteCursorApiKey($){return($?.client??this.client).delete({url:"/cursor-api-key",...$})}getCursorApiKey($){return($?.client??this.client).get({url:"/cursor-api-key",...$})}putCursorApiKey($){return($.client??this.client).put({url:"/cursor-api-key",...$,headers:{"Content-Type":"application/json",...$.headers}})}putCursorDefaultModel($){return($.client??this.client).put({url:"/cursor-api-key/default-model",...$,headers:{"Content-Type":"application/json",...$.headers}})}listCursorModels($){return($?.client??this.client).get({url:"/cursor-api-key/models",...$})}verifyFusionauthUserEmail($){return($.client??this.client).get({url:"/email/fusionauth/verify/{verification_id}",...$})}resendFusionauthVerifyUserEmail($){return($.client??this.client).post({url:"/email/fusionauth_resend",...$,headers:{"Content-Type":"application/json",...$.headers}})}generateEmailLink($){return($.client??this.client).post({url:"/email/generate/link",...$,headers:{"Content-Type":"application/json",...$.headers}})}verifyEmailLink($){return($.client??this.client).get({url:"/email/verify/{verification_id}",...$})}setGithubPullRequestDraft($){return($.client??this.client).post({url:"/github_pull_requests/draft",...$,headers:{"Content-Type":"application/json",...$.headers}})}enrichGithubPullRequests($){return($.client??this.client).post({url:"/github_pull_requests/enrich",...$,headers:{"Content-Type":"application/json",...$.headers}})}mergeGithubPullRequest($){return($.client??this.client).post({url:"/github_pull_requests/merge",...$,headers:{"Content-Type":"application/json",...$.headers}})}getGithubPullRequestMergeability($){return($.client??this.client).post({url:"/github_pull_requests/mergeability",...$,headers:{"Content-Type":"application/json",...$.headers}})}listGtmInviteLinks($){return($?.client??this.client).get({url:"/gtm-invite/links",...$})}createGtmInviteLink($){return($.client??this.client).post({url:"/gtm-invite/links",...$,headers:{"Content-Type":"application/json",...$.headers}})}revokeGtmInviteLink($){return($.client??this.client).delete({url:"/gtm-invite/links/{id}",...$})}getGtmInviteOffer($){return($?.client??this.client).get({url:"/gtm-invite/offer",...$})}resolveGtmInviteLink($){return($.client??this.client).get({url:"/gtm-invite/public/{token}",...$})}redeemGtmInviteLink($){return($.client??this.client).post({url:"/gtm-invite/redeem",...$,headers:{"Content-Type":"application/json",...$.headers}})}healthHandler($){return($?.client??this.client).get({url:"/health",...$})}macroApiToken($){return($.client??this.client).get({url:"/jwt/macro_api_token",...$})}refresh($){return($?.client??this.client).post({url:"/jwt/refresh",...$})}createInProgressLink($){return($?.client??this.client).post({url:"/link",...$})}emailConnectionProviders($){return($?.client??this.client).get({url:"/link/email/providers",...$})}deleteGithubLink($){return($?.client??this.client).delete({url:"/link/github",...$})}initGithubLink($){return($.client??this.client).post({url:"/link/github",...$})}checkGithubLinkStatus($){return($?.client??this.client).get({url:"/link/github/status",...$})}initGmailLink($){return($.client??this.client).post({url:"/link/gmail",...$})}checkGmailLinkStatus($){return($?.client??this.client).get({url:"/link/gmail/status",...$})}initOutlookLink($){return($?.client??this.client).post({url:"/link/outlook",...$})}appleLogin($){return($.client??this.client).post({url:"/login/apple",...$,headers:{"Content-Type":"application/json",...$.headers}})}passwordLogin($){return($.client??this.client).post({url:"/login/password",...$,headers:{"Content-Type":"application/json",...$.headers}})}passwordlessLogin($){return($.client??this.client).post({url:"/login/passwordless",...$,headers:{"Content-Type":"application/json",...$.headers}})}ssoLogin($){return($.client??this.client).get({url:"/login/sso",...$})}logout($){return($?.client??this.client).post({url:"/logout",...$})}createMergeRequest($){return($.client??this.client).post({url:"/merge",...$,headers:{"Content-Type":"application/json",...$.headers}})}verifyMergeRequest($){return($.client??this.client).get({url:"/merge/verify/{code}",...$})}sendMobileWelcomeEmail($){return($.client??this.client).post({url:"/mobile-welcome-email",...$,headers:{"Content-Type":"application/json",...$.headers}})}passwordlessCallback($){return($.client??this.client).get({url:"/oauth/passwordless/{code}",...$})}oauthRedirect($){return($?.client??this.client).get({url:"/oauth/redirect",...$})}oauth2Callback($){return($.client??this.client).get({url:"/oauth2/{provider}/callback",...$})}getPermissions($){return($?.client??this.client).get({url:"/permissions",...$})}getUserPermissions($){return($?.client??this.client).get({url:"/permissions/me",...$})}getReferralCode($){return($?.client??this.client).get({url:"/referral/code",...$})}sendReferralCode($){return($.client??this.client).post({url:"/referral/send",...$,headers:{"Content-Type":"application/json",...$.headers}})}sessionCreation($){return($?.client??this.client).post({url:"/session",...$})}sessionLogin($){return($.client??this.client).get({url:"/session/login/{session_code}",...$})}deleteTeam($){return($?.client??this.client).delete({url:"/team",...$})}getTeam($){return($?.client??this.client).get({url:"/team",...$})}patchTeam($){return($.client??this.client).patch({url:"/team",...$,headers:{"Content-Type":"application/json",...$.headers}})}createTeam($){return($.client??this.client).post({url:"/team",...$,headers:{"Content-Type":"application/json",...$.headers}})}toggleTeamAutoJoinDomain($){return($?.client??this.client).post({url:"/team/auto-join-domain/toggle",...$})}patchTeamCrmSettings($){return($.client??this.client).patch({url:"/team/crm",...$,headers:{"Content-Type":"application/json",...$.headers}})}inviteToTeam($){return($.client??this.client).post({url:"/team/invite",...$,headers:{"Content-Type":"application/json",...$.headers}})}deleteTeamInviteHandler($){return($.client??this.client).delete({url:"/team/invite/{team_invite_id}",...$})}getTeamInvites($){return($?.client??this.client).get({url:"/team/invites",...$})}rejectInvitation($){return($.client??this.client).delete({url:"/team/join/{team_invite_id}",...$})}joinTeam($){return($.client??this.client).get({url:"/team/join/{team_invite_id}",...$})}patchTeamMemberPlan($){return($.client??this.client).patch({url:"/team/members/{member_user_id}/plan",...$,headers:{"Content-Type":"application/json",...$.headers}})}toggleTeamNonAdminInvites($){return($?.client??this.client).post({url:"/team/non-admin-invites/toggle",...$})}removeUserFromTeam($){return($.client??this.client).delete({url:"/team/remove/{remove_user_id}",...$})}getUserTeams($){return($?.client??this.client).get({url:"/team/user",...$})}getUserInvites($){return($?.client??this.client).get({url:"/team/user/invites",...$})}getUserNames($){return($.client??this.client).post({url:"/user/get_names",...$,headers:{"Content-Type":"application/json",...$.headers}})}getUserNamesWithEmail($){return($.client??this.client).post({url:"/user/get_names_with_email",...$,headers:{"Content-Type":"application/json",...$.headers}})}patchUserGroup($){return($.client??this.client).patch({url:"/user/group",...$,headers:{"Content-Type":"application/json",...$.headers}})}getLegacyUserPermissions($){return($?.client??this.client).get({url:"/user/legacy_user_permissions",...$})}getUserLinkExists($){return($.client??this.client).get({url:"/user/link_exists",...$})}deleteUser($){return($?.client??this.client).delete({url:"/user/me",...$})}getUserInfo($){return($?.client??this.client).get({url:"/user/me",...$})}getUserName($){return($?.client??this.client).get({url:"/user/name",...$})}putUserName($){return($?.client??this.client).put({url:"/user/name",...$})}patchUserOnboarding($){return($.client??this.client).patch({url:"/user/onboarding",...$,headers:{"Content-Type":"application/json",...$.headers}})}getUserOrganization($){return($?.client??this.client).get({url:"/user/organization",...$})}putProfilePicture($){return($.client??this.client).put({url:"/user/profile_picture",...$})}postProfilePictures($){return($.client??this.client).post({url:"/user/profile_pictures",...$,headers:{"Content-Type":"application/json",...$.headers}})}getUserQuota($){return($?.client??this.client).get({url:"/user/quota",...$})}createCheckoutSessionV2($){return($.client??this.client).post({url:"/user/stripe/checkoutv2",...$,headers:{"Content-Type":"application/json",...$.headers}})}getSubscriptionStatus($){return($?.client??this.client).get({url:"/user/stripe/plan",...$})}changePlan($){return($.client??this.client).post({url:"/user/stripe/plan",...$,headers:{"Content-Type":"application/json",...$.headers}})}createPortalSession($){return($.client??this.client).post({url:"/user/stripe/portal",...$,headers:{"Content-Type":"application/json",...$.headers}})}getTrialEligibility($){return($?.client??this.client).get({url:"/user/stripe/trial_eligibility",...$})}patchUserTutorial($){return($.client??this.client).patch({url:"/user/tutorial",...$,headers:{"Content-Type":"application/json",...$.headers}})}}function KS({onRequest:$,onSseError:O,onSseEvent:j,responseTransformer:x,responseValidator:S,sseDefaultRetryDelay:K,sseMaxRetryAttempts:Z,sseMaxRetryDelay:X,sseSleepFn:G,url:L,...Y}){let Q,T=G??((V)=>new Promise((B)=>setTimeout(B,V)));return{stream:async function*(){let V=K??3000,B=0,I=Y.signal??new AbortController().signal;while(!0){if(I.aborted)break;B++;let P=Y.headers instanceof Headers?Y.headers:new Headers(Y.headers);if(Q!==void 0)P.set("Last-Event-ID",Q);try{let D={redirect:"follow",...Y,body:Y.serializedBody,headers:P,signal:I},C=new Request(L,D);if($)C=await $(L,D);let N=await(Y.fetch??globalThis.fetch)(C);if(!N.ok)throw Error(`SSE failed: ${N.status} ${N.statusText}`);if(!N.body)throw Error("No body in SSE response");let H=N.body.pipeThrough(new TextDecoderStream).getReader(),U="",k=()=>{try{H.cancel()}catch{}};I.addEventListener("abort",k);try{while(!0){let{done:d,value:l}=await H.read();if(d)break;U+=l,U=U.replace(/\r\n?/g,`
+`);try{_=JSON.parse(R),v=!0}catch{_=R}}if(v){if(S)await S(_);if(x)_=await x(_)}if(j?.({data:_,event:y,id:Q,retry:V}),F.length)yield _}}}finally{I.removeEventListener("abort",k),H.releaseLock()}break}catch(D){if(O?.(D),Z!==void 0&&B>=Z)break;let C=Math.min(V*2**(B-1),X??30000);await T(C)}}}()}}var Q7=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},J7=($)=>{switch($){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},V7=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Pj=({allowReserved:$,explode:O,name:j,style:x,value:S})=>{if(!O){let X=($?S:S.map((G)=>encodeURIComponent(G))).join(J7(x));switch(x){case"label":return`.${X}`;case"matrix":return`;${j}=${X}`;case"simple":return X;default:return`${j}=${X}`}}let K=Q7(x),Z=S.map((X)=>{if(x==="label"||x==="simple")return $?X:encodeURIComponent(X);return TO({allowReserved:$,name:j,value:X})}).join(K);return x==="label"||x==="matrix"?K+Z:Z},TO=({allowReserved:$,name:O,value:j})=>{if(j===void 0||j===null)return"";if(typeof j==="object")throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${O}=${$?j:encodeURIComponent(j)}`},Fj=({allowReserved:$,explode:O,name:j,style:x,value:S,valueOnly:K})=>{if(S instanceof Date)return K?S.toISOString():`${j}=${S.toISOString()}`;if(x!=="deepObject"&&!O){let G=[];Object.entries(S).forEach(([Y,Q])=>{G=[...G,Y,$?Q:encodeURIComponent(Q)]});let L=G.join(",");switch(x){case"form":return`${j}=${L}`;case"label":return`.${L}`;case"matrix":return`;${j}=${L}`;default:return L}}let Z=V7(x),X=Object.entries(S).map(([G,L])=>TO({allowReserved:$,name:x==="deepObject"?`${j}[${G}]`:G,value:L})).join(Z);return x==="label"||x==="matrix"?Z+X:X};var W7=/\{[^{}]+\}/g,B7=({path:$,url:O})=>{let j=O,x=O.match(W7);if(x)for(let S of x){let K=!1,Z=S.substring(1,S.length-1),X="simple";if(Z.endsWith("*"))K=!0,Z=Z.substring(0,Z.length-1);if(Z.startsWith("."))Z=Z.substring(1),X="label";else if(Z.startsWith(";"))Z=Z.substring(1),X="matrix";let G=$[Z];if(G===void 0||G===null)continue;if(Array.isArray(G)){j=j.replace(S,Pj({explode:K,name:Z,style:X,value:G}));continue}if(typeof G==="object"){j=j.replace(S,Fj({explode:K,name:Z,style:X,value:G,valueOnly:!0}));continue}if(X==="matrix"){j=j.replace(S,`;${TO({name:Z,value:G})}`);continue}let L=encodeURIComponent(X==="label"?`.${G}`:G);j=j.replace(S,L)}return j},e1=({baseUrl:$,path:O,query:j,querySerializer:x,url:S})=>{let K=S.startsWith("/")?S:`/${S}`,Z=($??"")+K;if(O)Z=B7({path:O,url:Z});let X=j?x(j):"";if(X.startsWith("?"))X=X.substring(1);if(X)Z+=`?${X}`;return Z};function q0($){let O=$.body!==void 0;if(O&&$.bodySerializer){if("serializedBody"in $)return $.serializedBody!==void 0&&$.serializedBody!==""?$.serializedBody:null;return $.body!==""?$.body:null}if(O)return $.body;return}var o1=async($,O)=>{let j=typeof O==="function"?await O($):O;if(!j)return;if($.scheme==="bearer")return`Bearer ${j}`;if($.scheme==="basic")return`Basic ${btoa(j)}`;return j};var $S={bodySerializer:($)=>JSON.stringify($,(O,j)=>typeof j==="bigint"?j.toString():j)};var OS=({parameters:$={},...O}={})=>{return(x)=>{let S=[];if(x&&typeof x==="object")for(let K in x){let Z=x[K];if(Z===void 0||Z===null)continue;let X=$[K]||O;if(Array.isArray(Z)){let G=Pj({allowReserved:X.allowReserved,explode:!0,name:K,style:"form",value:Z,...X.array});if(G)S.push(G)}else if(typeof Z==="object"){let G=Fj({allowReserved:X.allowReserved,explode:!0,name:K,style:"deepObject",value:Z,...X.object});if(G)S.push(G)}else{let G=TO({allowReserved:X.allowReserved,name:K,value:Z});if(G)S.push(G)}}return S.join("&")}},jS=($)=>{if(!$)return"stream";let O=$.split(";")[0]?.trim();if(!O)return;if(O.startsWith("application/json")||O.endsWith("+json"))return"json";if(O==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((j)=>O.startsWith(j)))return"blob";if(O.startsWith("text/"))return"text";return},L7=($,O)=>{if(!O)return!1;if($.headers.has(O)||$.query?.[O]||$.headers.get("Cookie")?.includes(`${O}=`))return!0;return!1};async function xS($){for(let O of $.security??[]){if(L7($,O.name))continue;let j=await o1(O,$.auth);if(!j)continue;let x=O.name??"Authorization";switch(O.in){case"query":if(!$.query)$.query={};$.query[x]=j;break;case"cookie":$.headers.append("Cookie",`${x}=${j}`);break;case"header":default:$.headers.set(x,j);break}}}var f0=($)=>e1({baseUrl:$.baseUrl,path:$.path,query:$.query,querySerializer:typeof $.querySerializer==="function"?$.querySerializer:OS($.querySerializer),url:$.url}),b0=($,O)=>{let j={...$,...O};if(j.baseUrl?.endsWith("/"))j.baseUrl=j.baseUrl.substring(0,j.baseUrl.length-1);return j.headers=wj($.headers,O.headers),j},N7=($)=>{let O=[];return $.forEach((j,x)=>{O.push([x,j])}),O},wj=(...$)=>{let O=new Headers;for(let j of $){if(!j)continue;let x=j instanceof Headers?N7(j):Object.entries(j);for(let[S,K]of x)if(K===null)O.delete(S);else if(Array.isArray(K))for(let Z of K)O.append(S,Z);else if(K!==void 0)O.set(S,typeof K==="object"?JSON.stringify(K):K)}return O};class Ej{fns=[];clear(){this.fns=[]}eject($){let O=this.getInterceptorIndex($);if(this.fns[O])this.fns[O]=null}exists($){let O=this.getInterceptorIndex($);return Boolean(this.fns[O])}getInterceptorIndex($){if(typeof $==="number")return this.fns[$]?$:-1;return this.fns.indexOf($)}update($,O){let j=this.getInterceptorIndex($);if(this.fns[j])return this.fns[j]=O,$;return!1}use($){return this.fns.push($),this.fns.length-1}}var SS=()=>({error:new Ej,request:new Ej,response:new Ej}),U7=OS({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),z7={"Content-Type":"application/json"},iO=($={})=>({...$S,headers:z7,parseAs:"auto",querySerializer:U7,...$});var k0=($={})=>{let O=b0(iO(),$),j=()=>({...O}),x=(Y)=>{return O=b0(O,Y),j()},S=SS(),K=async(Y)=>{let Q={...O,...Y,fetch:Y.fetch??O.fetch??globalThis.fetch,headers:wj(O.headers,Y.headers),serializedBody:void 0};if(Q.security)await xS(Q);if(Q.requestValidator)await Q.requestValidator(Q);if(Q.body!==void 0&&Q.bodySerializer)Q.serializedBody=Q.bodySerializer(Q.body);if(Q.body===void 0||Q.serializedBody==="")Q.headers.delete("Content-Type");let T=Q,z=f0(T);return{opts:T,url:z}},Z=async(Y)=>{let Q=Y.throwOnError??O.throwOnError,T=Y.responseStyle??O.responseStyle,z,W;try{let{opts:V,url:B}=await K(Y),I={redirect:"follow",...V,body:q0(V)};z=new Request(B,I);for(let N of S.request.fns)if(N)z=await N(z,V);let P=V.fetch;W=await P(z);for(let N of S.response.fns)if(N)W=await N(W,z,V);let D={request:z,response:W};if(W.ok){let N=(V.parseAs==="auto"?jS(W.headers.get("Content-Type")):V.parseAs)??"json";if(W.status===204||W.headers.get("Content-Length")==="0"){let U;switch(N){case"arrayBuffer":case"blob":case"text":U=await W[N]();break;case"formData":U=new FormData;break;case"stream":U=W.body;break;case"json":default:U={};break}return V.responseStyle==="data"?U:{data:U,...D}}let H;switch(N){case"arrayBuffer":case"blob":case"formData":case"text":H=await W[N]();break;case"json":{let U=await W.text();H=U?JSON.parse(U):{};break}case"stream":return V.responseStyle==="data"?W.body:{data:W.body,...D}}if(N==="json"){if(V.responseValidator)await V.responseValidator(H);if(V.responseTransformer)H=await V.responseTransformer(H)}return V.responseStyle==="data"?H:{data:H,...D}}let C=await W.text(),E;try{E=JSON.parse(C)}catch{}throw E??C}catch(V){let B=V;for(let I of S.error.fns)if(I)B=await I(B,W,z,Y);if(B=B||{},Q)throw B;return T==="data"?void 0:{error:B,request:z,response:W}}},X=(Y)=>(Q)=>Z({...Q,method:Y}),G=(Y)=>async(Q)=>{let{opts:T,url:z}=await K(Q);return t1({...T,body:T.body,method:Y,onRequest:async(W,V)=>{let B=new Request(W,V);for(let I of S.request.fns)if(I)B=await I(B,T);return B},serializedBody:q0(T),url:z})};return{buildUrl:(Y)=>f0({...O,...Y}),connect:X("CONNECT"),delete:X("DELETE"),get:X("GET"),getConfig:j,head:X("HEAD"),interceptors:S,options:X("OPTIONS"),patch:X("PATCH"),post:X("POST"),put:X("PUT"),request:Z,setConfig:x,sse:{connect:G("CONNECT"),delete:G("DELETE"),get:G("GET"),head:G("HEAD"),options:G("OPTIONS"),patch:G("PATCH"),post:G("POST"),put:G("PUT"),trace:G("TRACE")},trace:X("TRACE")}};var ZS=k0(iO());class XS{client;constructor($){this.client=$?.client??ZS}}class GS{defaultKey="default";instances=new Map;get($){let O=this.instances.get($??this.defaultKey);if(!O)throw Error('No SDK client found. Create one with "new Sdk()" to fix this error.');return O}set($,O){this.instances.set(O??this.defaultKey,$)}}class qj extends XS{static __registry=new GS;constructor($){super($);qj.__registry.set(this,$?.key)}updateAiBillingAutoReload($){return($.client??this.client).patch({url:"/ai-billing/auto-reload",...$,headers:{"Content-Type":"application/json",...$.headers}})}createAiCreditCheckout($){return($.client??this.client).post({url:"/ai-billing/credits/checkout",...$,headers:{"Content-Type":"application/json",...$.headers}})}updateAiBillingOverage($){return($.client??this.client).patch({url:"/ai-billing/overage",...$,headers:{"Content-Type":"application/json",...$.headers}})}getAiBillingPlans($){return($?.client??this.client).get({url:"/ai-billing/plans",...$})}getAiBillingSummary($){return($?.client??this.client).get({url:"/ai-billing/summary",...$})}disconnectCodex($){return($?.client??this.client).delete({url:"/codex",...$})}getCodexConnection($){return($?.client??this.client).get({url:"/codex",...$})}configureCodex($){return($.client??this.client).put({url:"/codex/config",...$,headers:{"Content-Type":"application/json",...$.headers}})}listCodexEnvironments($){return($?.client??this.client).get({url:"/codex/environments",...$})}startCodexLogin($){return($?.client??this.client).post({url:"/codex/login",...$})}cancelCodexLogin($){return($.client??this.client).delete({url:"/codex/login/{attempt_id}",...$})}pollCodexLogin($){return($.client??this.client).get({url:"/codex/login/{attempt_id}",...$})}deleteCursorApiKey($){return($?.client??this.client).delete({url:"/cursor-api-key",...$})}getCursorApiKey($){return($?.client??this.client).get({url:"/cursor-api-key",...$})}putCursorApiKey($){return($.client??this.client).put({url:"/cursor-api-key",...$,headers:{"Content-Type":"application/json",...$.headers}})}putCursorDefaultModel($){return($.client??this.client).put({url:"/cursor-api-key/default-model",...$,headers:{"Content-Type":"application/json",...$.headers}})}listCursorModels($){return($?.client??this.client).get({url:"/cursor-api-key/models",...$})}verifyFusionauthUserEmail($){return($.client??this.client).get({url:"/email/fusionauth/verify/{verification_id}",...$})}resendFusionauthVerifyUserEmail($){return($.client??this.client).post({url:"/email/fusionauth_resend",...$,headers:{"Content-Type":"application/json",...$.headers}})}generateEmailLink($){return($.client??this.client).post({url:"/email/generate/link",...$,headers:{"Content-Type":"application/json",...$.headers}})}verifyEmailLink($){return($.client??this.client).get({url:"/email/verify/{verification_id}",...$})}setGithubPullRequestDraft($){return($.client??this.client).post({url:"/github_pull_requests/draft",...$,headers:{"Content-Type":"application/json",...$.headers}})}enrichGithubPullRequests($){return($.client??this.client).post({url:"/github_pull_requests/enrich",...$,headers:{"Content-Type":"application/json",...$.headers}})}mergeGithubPullRequest($){return($.client??this.client).post({url:"/github_pull_requests/merge",...$,headers:{"Content-Type":"application/json",...$.headers}})}getGithubPullRequestMergeability($){return($.client??this.client).post({url:"/github_pull_requests/mergeability",...$,headers:{"Content-Type":"application/json",...$.headers}})}listGtmInviteLinks($){return($?.client??this.client).get({url:"/gtm-invite/links",...$})}createGtmInviteLink($){return($.client??this.client).post({url:"/gtm-invite/links",...$,headers:{"Content-Type":"application/json",...$.headers}})}revokeGtmInviteLink($){return($.client??this.client).delete({url:"/gtm-invite/links/{id}",...$})}getGtmInviteOffer($){return($?.client??this.client).get({url:"/gtm-invite/offer",...$})}resolveGtmInviteLink($){return($.client??this.client).get({url:"/gtm-invite/public/{token}",...$})}redeemGtmInviteLink($){return($.client??this.client).post({url:"/gtm-invite/redeem",...$,headers:{"Content-Type":"application/json",...$.headers}})}healthHandler($){return($?.client??this.client).get({url:"/health",...$})}macroApiToken($){return($.client??this.client).get({url:"/jwt/macro_api_token",...$})}refresh($){return($?.client??this.client).post({url:"/jwt/refresh",...$})}createInProgressLink($){return($?.client??this.client).post({url:"/link",...$})}emailConnectionProviders($){return($?.client??this.client).get({url:"/link/email/providers",...$})}deleteGithubLink($){return($?.client??this.client).delete({url:"/link/github",...$})}initGithubLink($){return($.client??this.client).post({url:"/link/github",...$})}checkGithubLinkStatus($){return($?.client??this.client).get({url:"/link/github/status",...$})}initGmailLink($){return($.client??this.client).post({url:"/link/gmail",...$})}checkGmailLinkStatus($){return($?.client??this.client).get({url:"/link/gmail/status",...$})}initOutlookLink($){return($?.client??this.client).post({url:"/link/outlook",...$})}appleLogin($){return($.client??this.client).post({url:"/login/apple",...$,headers:{"Content-Type":"application/json",...$.headers}})}passwordLogin($){return($.client??this.client).post({url:"/login/password",...$,headers:{"Content-Type":"application/json",...$.headers}})}passwordlessLogin($){return($.client??this.client).post({url:"/login/passwordless",...$,headers:{"Content-Type":"application/json",...$.headers}})}ssoLogin($){return($.client??this.client).get({url:"/login/sso",...$})}logout($){return($?.client??this.client).post({url:"/logout",...$})}createMergeRequest($){return($.client??this.client).post({url:"/merge",...$,headers:{"Content-Type":"application/json",...$.headers}})}verifyMergeRequest($){return($.client??this.client).get({url:"/merge/verify/{code}",...$})}sendMobileWelcomeEmail($){return($.client??this.client).post({url:"/mobile-welcome-email",...$,headers:{"Content-Type":"application/json",...$.headers}})}passwordlessCallback($){return($.client??this.client).get({url:"/oauth/passwordless/{code}",...$})}oauthRedirect($){return($?.client??this.client).get({url:"/oauth/redirect",...$})}oauth2Callback($){return($.client??this.client).get({url:"/oauth2/{provider}/callback",...$})}getPermissions($){return($?.client??this.client).get({url:"/permissions",...$})}getUserPermissions($){return($?.client??this.client).get({url:"/permissions/me",...$})}getReferralCode($){return($?.client??this.client).get({url:"/referral/code",...$})}sendReferralCode($){return($.client??this.client).post({url:"/referral/send",...$,headers:{"Content-Type":"application/json",...$.headers}})}sessionCreation($){return($?.client??this.client).post({url:"/session",...$})}sessionLogin($){return($.client??this.client).get({url:"/session/login/{session_code}",...$})}deleteTeam($){return($?.client??this.client).delete({url:"/team",...$})}getTeam($){return($?.client??this.client).get({url:"/team",...$})}patchTeam($){return($.client??this.client).patch({url:"/team",...$,headers:{"Content-Type":"application/json",...$.headers}})}createTeam($){return($.client??this.client).post({url:"/team",...$,headers:{"Content-Type":"application/json",...$.headers}})}toggleTeamAutoJoinDomain($){return($?.client??this.client).post({url:"/team/auto-join-domain/toggle",...$})}patchTeamCrmSettings($){return($.client??this.client).patch({url:"/team/crm",...$,headers:{"Content-Type":"application/json",...$.headers}})}inviteToTeam($){return($.client??this.client).post({url:"/team/invite",...$,headers:{"Content-Type":"application/json",...$.headers}})}deleteTeamInviteLink($){return($?.client??this.client).delete({url:"/team/invite-link",...$})}getTeamInviteLink($){return($?.client??this.client).get({url:"/team/invite-link",...$})}createTeamInviteLink($){return($?.client??this.client).post({url:"/team/invite-link",...$})}joinTeamByInviteLink($){return($.client??this.client).post({url:"/team/invite-link/join",...$,headers:{"Content-Type":"application/json",...$.headers}})}getTeamByInviteLink($){return($.client??this.client).post({url:"/team/invite-link/team",...$,headers:{"Content-Type":"application/json",...$.headers}})}deleteTeamInviteHandler($){return($.client??this.client).delete({url:"/team/invite/{team_invite_id}",...$})}getTeamInvites($){return($?.client??this.client).get({url:"/team/invites",...$})}rejectInvitation($){return($.client??this.client).delete({url:"/team/join/{team_invite_id}",...$})}joinTeam($){return($.client??this.client).get({url:"/team/join/{team_invite_id}",...$})}patchTeamMemberPlan($){return($.client??this.client).patch({url:"/team/members/{member_user_id}/plan",...$,headers:{"Content-Type":"application/json",...$.headers}})}toggleTeamNonAdminInvites($){return($?.client??this.client).post({url:"/team/non-admin-invites/toggle",...$})}removeUserFromTeam($){return($.client??this.client).delete({url:"/team/remove/{remove_user_id}",...$})}getUserTeams($){return($?.client??this.client).get({url:"/team/user",...$})}getUserInvites($){return($?.client??this.client).get({url:"/team/user/invites",...$})}getUserNames($){return($.client??this.client).post({url:"/user/get_names",...$,headers:{"Content-Type":"application/json",...$.headers}})}getUserNamesWithEmail($){return($.client??this.client).post({url:"/user/get_names_with_email",...$,headers:{"Content-Type":"application/json",...$.headers}})}patchUserGroup($){return($.client??this.client).patch({url:"/user/group",...$,headers:{"Content-Type":"application/json",...$.headers}})}getLegacyUserPermissions($){return($?.client??this.client).get({url:"/user/legacy_user_permissions",...$})}getUserLinkExists($){return($.client??this.client).get({url:"/user/link_exists",...$})}deleteUser($){return($?.client??this.client).delete({url:"/user/me",...$})}getUserInfo($){return($?.client??this.client).get({url:"/user/me",...$})}getUserName($){return($?.client??this.client).get({url:"/user/name",...$})}putUserName($){return($?.client??this.client).put({url:"/user/name",...$})}patchUserOnboarding($){return($.client??this.client).patch({url:"/user/onboarding",...$,headers:{"Content-Type":"application/json",...$.headers}})}getUserOrganization($){return($?.client??this.client).get({url:"/user/organization",...$})}putProfilePicture($){return($.client??this.client).put({url:"/user/profile_picture",...$})}postProfilePictures($){return($.client??this.client).post({url:"/user/profile_pictures",...$,headers:{"Content-Type":"application/json",...$.headers}})}getUserQuota($){return($?.client??this.client).get({url:"/user/quota",...$})}createCheckoutSessionV2($){return($.client??this.client).post({url:"/user/stripe/checkoutv2",...$,headers:{"Content-Type":"application/json",...$.headers}})}getSubscriptionStatus($){return($?.client??this.client).get({url:"/user/stripe/plan",...$})}changePlan($){return($.client??this.client).post({url:"/user/stripe/plan",...$,headers:{"Content-Type":"application/json",...$.headers}})}createPortalSession($){return($.client??this.client).post({url:"/user/stripe/portal",...$,headers:{"Content-Type":"application/json",...$.headers}})}getTrialEligibility($){return($?.client??this.client).get({url:"/user/stripe/trial_eligibility",...$})}patchUserTutorial($){return($.client??this.client).patch({url:"/user/tutorial",...$,headers:{"Content-Type":"application/json",...$.headers}})}}function KS({onRequest:$,onSseError:O,onSseEvent:j,responseTransformer:x,responseValidator:S,sseDefaultRetryDelay:K,sseMaxRetryAttempts:Z,sseMaxRetryDelay:X,sseSleepFn:G,url:L,...Y}){let Q,T=G??((V)=>new Promise((B)=>setTimeout(B,V)));return{stream:async function*(){let V=K??3000,B=0,I=Y.signal??new AbortController().signal;while(!0){if(I.aborted)break;B++;let P=Y.headers instanceof Headers?Y.headers:new Headers(Y.headers);if(Q!==void 0)P.set("Last-Event-ID",Q);try{let D={redirect:"follow",...Y,body:Y.serializedBody,headers:P,signal:I},C=new Request(L,D);if($)C=await $(L,D);let N=await(Y.fetch??globalThis.fetch)(C);if(!N.ok)throw Error(`SSE failed: ${N.status} ${N.statusText}`);if(!N.body)throw Error("No body in SSE response");let H=N.body.pipeThrough(new TextDecoderStream).getReader(),U="",k=()=>{try{H.cancel()}catch{}};I.addEventListener("abort",k);try{while(!0){let{done:d,value:l}=await H.read();if(d)break;U+=l,U=U.replace(/\r\n?/g,`
`);let g=U.split(`
`);U=g.pop()??"";for(let r of g){let p=r.split(`
diff --git a/crates/macro_db_client/migrations/20261021154031_team_invite_link.sql b/crates/macro_db_client/migrations/20261021154031_team_invite_link.sql
new file mode 100644
index 0000000000..293c4ed4a6
--- /dev/null
+++ b/crates/macro_db_client/migrations/20261021154031_team_invite_link.sql
@@ -0,0 +1,9 @@
+-- A team's shareable invite link. Anyone signed in who holds the token can
+-- join the team; a team has at most one link, and resetting it replaces the
+-- token so links already shared stop working. Deleting the team deletes its
+-- link; the link outlives whoever created it.
+CREATE TABLE team_invite_link (
+ team_id UUID PRIMARY KEY REFERENCES team (id) ON DELETE CASCADE,
+ token UUID NOT NULL UNIQUE,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
diff --git a/crates/teams/AGENTS.md b/crates/teams/AGENTS.md
index a89a4153a4..b6f11c11ee 100644
--- a/crates/teams/AGENTS.md
+++ b/crates/teams/AGENTS.md
@@ -11,6 +11,9 @@ event contract (schema, sanitization, delivery semantics).
- `src/domain/team_service.rs`: the main service — creation, invites,
membership, role changes, auto-join-domain toggle.
+- `src/domain/team_service/invite_link.rs`: the team's shareable invite link
+ (`TeamInviteLinkService`) — who may see, create, reset, or turn it off, and
+ joining through it via the same direct-join path as domain auto-join.
- `src/domain/owned_entity_cleanup.rs` + `open_seat_release.rs`: account/team
deletion side effects (owned-entity transfer, seat release).
- `src/inbound/axum_router.rs` / `src/inbound/toolset.rs`: HTTP routes and AI
diff --git a/crates/teams/README.md b/crates/teams/README.md
index 060780db52..a6f661ba12 100644
--- a/crates/teams/README.md
+++ b/crates/teams/README.md
@@ -21,7 +21,7 @@ between different teams is unspecified.
| `team.invite_created` | A new invite is persisted; one event is produced per newly invited lowercase email | `team_id`, `invite_id`, `email`, `invited_by`, `team_name` |
| `team.invite_rejected` | The invitee successfully rejects and deletes an invite | `team_id`, `invite_id`, `email`, `actor_user_id` |
| `team.invite_revoked` | An administrator successfully deletes an invite | `team_id`, `invite_id`, `email`, `actor_user_id` |
-| `team.member_joined` | An invited or domain-auto-joined membership and all rollback-capable side effects succeed | `team_id`, `member_id`, `teammate_ids`, `role`, `join_method` |
+| `team.member_joined` | An invited, domain-auto-joined, or invite-link membership and all rollback-capable side effects succeed | `team_id`, `member_id`, `teammate_ids`, `role`, `join_method` |
| `team.member_removed` | Membership removal and all rollback-capable side effects succeed | `team_id`, `member_id`, `removed_by`, `role` |
| `team.member_role_changed` | Each individual member role update succeeds | `team_id`, `actor_user_id`, `member_id`, `role`, `previous_role` |
| `team.auto_join_domain_toggled` | An explicit auto-join-domain toggle succeeds | `team_id`, `actor_user_id`, `auto_join_domain` |
@@ -56,7 +56,9 @@ default a missing field to `[]` so events published before this field existed
still decode.
`join_method` is a tagged union. An accepted invite includes its invite UUID and
-the inviter; a domain auto-join is encoded as `{"type":"domain_auto_join"}`.
+the inviter; a domain auto-join is encoded as `{"type":"domain_auto_join"}` and
+a join through the team's shareable invite link as `{"type":"invite_link"}`.
+Consumers should ignore join methods they don't recognize.
A complete invite-accepted membership envelope has this shape:
```json
diff --git a/crates/teams/src/domain/events.rs b/crates/teams/src/domain/events.rs
index c92d47e1f4..5a634c6587 100644
--- a/crates/teams/src/domain/events.rs
+++ b/crates/teams/src/domain/events.rs
@@ -144,6 +144,8 @@ pub enum TeamJoinMethod {
},
/// The user joined because their email matched the team's automatic-join domain.
DomainAutoJoin,
+ /// The user opened the team's shareable invite link.
+ InviteLink,
}
/// Metadata for [`TeamTopicEvent::MemberJoined`].
diff --git a/crates/teams/src/domain/model.rs b/crates/teams/src/domain/model.rs
index 4b41bcee80..e735a6fc88 100644
--- a/crates/teams/src/domain/model.rs
+++ b/crates/teams/src/domain/model.rs
@@ -11,6 +11,13 @@ use roles_and_permissions::domain::model::{ProductTier, RoleId, UserRolesAndPerm
use crate::domain::owned_entity_cleanup::OwnedEntityCleanupError;
+mod invite_link;
+
+pub use invite_link::{
+ JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, ManageTeamInviteLinkError,
+ TeamInviteLinkTeam, TeamInviteLinkToken,
+};
+
/// Team plans
#[derive(
Eq,
@@ -841,9 +848,10 @@ pub enum ToggleAutoJoinDomainError {
TeamError(#[from] TeamError),
}
-/// Errors for automatically joining a team by email domain
+/// Errors for adding a user to a team without an email invite: by matching
+/// the team's auto-join domain, or through the team's invite link.
#[derive(Debug, thiserror::Error)]
-pub enum TryJoinTeamByDomainError {
+pub enum JoinTeamDirectlyError {
/// Underlying team error
#[error("Underlying team error {0}")]
TeamError(#[from] TeamError),
diff --git a/crates/teams/src/domain/model/invite_link.rs b/crates/teams/src/domain/model/invite_link.rs
new file mode 100644
index 0000000000..9f3b0ab298
--- /dev/null
+++ b/crates/teams/src/domain/model/invite_link.rs
@@ -0,0 +1,106 @@
+//! Domain models for a team's shareable invite link.
+
+use serde::{Deserialize, Serialize};
+
+use super::{JoinTeamDirectlyError, TeamError, TeamMember};
+
+/// The secret in a team's shareable invite link.
+///
+/// Anyone signed in who holds the token can join the team, so it is a random
+/// value rather than a time-ordered id, and an admin resetting the link
+/// replaces it.
+#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
+#[serde(transparent)]
+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]
+#[cfg_attr(feature = "axum", schema(value_type = String))]
+pub struct TeamInviteLinkToken(uuid::Uuid);
+
+/// Redacted, so a token in a logged struct or error never reaches telemetry.
+impl std::fmt::Debug for TeamInviteLinkToken {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.write_str("TeamInviteLinkToken(<redacted>)")
+ }
+}
+
+impl TeamInviteLinkToken {
+ /// Generates a new unguessable token.
+ pub fn generate() -> Self {
+ // A secret, not an id: v4 carries 122 random bits where v7 leaks
+ // creation time and has fewer.
+ Self(uuid::Uuid::new_v4())
+ }
+
+ /// Wraps a token read from storage or a request path.
+ pub fn from_uuid(token: uuid::Uuid) -> Self {
+ Self(token)
+ }
+
+ /// The token as a UUID.
+ pub fn as_uuid(&self) -> &uuid::Uuid {
+ &self.0
+ }
+}
+
+/// The team an invite link joins, shown before the user accepts.
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]
+pub struct TeamInviteLinkTeam {
+ /// Id of the team the link joins.
+ pub team_id: uuid::Uuid,
+ /// Name of the team the link joins.
+ pub team_name: String,
+}
+
+/// What happened when a user opened a team's invite link.
+#[derive(Debug, Clone)]
+pub enum JoinTeamByInviteLinkOutcome {
+ /// The user joined the team.
+ Joined(TeamMember<'static>),
+ /// The user was already on the team, so nothing changed.
+ AlreadyMember {
+ /// The team the link joins.
+ team_id: uuid::Uuid,
+ },
+}
+
+impl JoinTeamByInviteLinkOutcome {
+ /// The team the link joins.
+ pub fn team_id(&self) -> uuid::Uuid {
+ match self {
+ Self::Joined(member) => member.team_id,
+ Self::AlreadyMember { team_id } => *team_id,
+ }
+ }
+}
+
+/// Errors for reading or changing a team's invite link.
+#[derive(Debug, thiserror::Error)]
+pub enum ManageTeamInviteLinkError {
+ /// The team only lets admins invite and the caller is not an admin.
+ #[error("only team admins may invite users to this team")]
+ NonAdminInvitesDisabled,
+ /// Replacing an existing link breaks links already shared, so only admins
+ /// may do it.
+ #[error("only team admins may reset the team's invite link")]
+ ResetRequiresAdmin,
+ /// Underlying team error.
+ #[error("Underlying team error {0}")]
+ TeamError(#[from] TeamError),
+}
+
+/// Errors for joining a team through its invite link.
+#[derive(Debug, thiserror::Error)]
+pub enum JoinTeamByInviteLinkError {
+ /// No team has this link: it never existed, was reset, or was turned off.
+ #[error("this invite link is no longer valid")]
+ LinkNotFound,
+ /// Users belong to at most one team.
+ #[error("you're already on another team")]
+ AlreadyInAnotherTeam,
+ /// Underlying team error.
+ #[error("Underlying team error {0}")]
+ TeamError(#[from] TeamError),
+ /// Adding the user to the team failed.
+ #[error("Underlying join error {0}")]
+ JoinError(#[from] JoinTeamDirectlyError),
+}
diff --git a/crates/teams/src/domain/model/test.rs b/crates/teams/src/domain/model/test.rs
index 8de9e28a32..394d8f4140 100644
--- a/crates/teams/src/domain/model/test.rs
+++ b/crates/teams/src/domain/model/test.rs
@@ -135,3 +135,15 @@ fn is_generic_email_domain_allows_company_domains() {
assert!(!is_generic_email_domain("example.org"));
assert!(!is_generic_email_domain("gmail.com.evil.com"));
}
+
+#[test]
+fn invite_link_tokens_never_print_their_secret() {
+ let secret = uuid::Uuid::from_u128(0x1234_5678_9abc_def0_1234_5678_9abc_def0);
+ let token = TeamInviteLinkToken::from_uuid(secret);
+
+ let printed = format!("{token:?} {:?}", Some(token));
+
+ assert!(!printed.contains(&secret.to_string()));
+ assert!(!printed.contains(&secret.simple().to_string()));
+ assert!(printed.contains("<redacted>"));
+}
diff --git a/crates/teams/src/domain/team_repo.rs b/crates/teams/src/domain/team_repo.rs
index 18862f2f6f..28c0e88e16 100644
--- a/crates/teams/src/domain/team_repo.rs
+++ b/crates/teams/src/domain/team_repo.rs
@@ -8,12 +8,14 @@ use entity_access::domain::models::{
use macro_user_id::{email::Email, lowercased::Lowercase, user_id::MacroUserIdStr};
use crate::domain::model::{
- AcceptedTeamInvite, CreateTeamError, DeleteTeamError, InviteUsersToTeamError, JoinTeamError,
- PatchTeamCrmSettingsResponse, PatchTeamRequest, RemoveTeamInviteError,
- RemoveUserFromAllTeamsError, RemoveUserFromTeamError, RestorePermissionsForTeamMembersError,
- RevokePermissionsForTeamMembersError, SeatPlan, SetTeamMemberPlanError, Team, TeamError,
- TeamInvite, TeamInviteDetails, TeamMember, TeamMembers, TeamPlan, TeamRole, TeamWithMembers,
- ToggleAutoJoinDomainError, TryJoinTeamByDomainError,
+ AcceptedTeamInvite, CreateTeamError, DeleteTeamError, InviteUsersToTeamError,
+ JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, JoinTeamDirectlyError, JoinTeamError,
+ ManageTeamInviteLinkError, PatchTeamCrmSettingsResponse, PatchTeamRequest,
+ RemoveTeamInviteError, RemoveUserFromAllTeamsError, RemoveUserFromTeamError,
+ RestorePermissionsForTeamMembersError, RevokePermissionsForTeamMembersError, SeatPlan,
+ SetTeamMemberPlanError, Team, TeamError, TeamInvite, TeamInviteDetails, TeamInviteLinkTeam,
+ TeamInviteLinkToken, TeamMember, TeamMembers, TeamPlan, TeamRole, TeamWithMembers,
+ ToggleAutoJoinDomainError,
};
use crate::domain::owned_entity_cleanup::ClearedTeam;
@@ -333,6 +335,31 @@ pub trait TeamRepository: Clone + Send + Sync + 'static {
after_team_id: Option<uuid::Uuid>,
limit: u32,
) -> impl Future<Output = Result<Vec<uuid::Uuid>, TeamError>> + Send;
+
+ /// The token of the team's invite link, if the team has one.
+ fn get_team_invite_link(
+ &self,
+ team_id: &uuid::Uuid,
+ ) -> impl Future<Output = Result<Option<TeamInviteLinkToken>, TeamError>> + Send;
+
+ /// Sets the team's invite link to `token`, replacing any existing link.
+ fn set_team_invite_link(
+ &self,
+ team_id: &uuid::Uuid,
+ token: &TeamInviteLinkToken,
+ ) -> impl Future<Output = Result<(), TeamError>> + Send;
+
+ /// Removes the team's invite link. A no-op when the team has none.
+ fn delete_team_invite_link(
+ &self,
+ team_id: &uuid::Uuid,
+ ) -> impl Future<Output = Result<(), TeamError>> + Send;
+
+ /// The team whose invite link has `token`, if any.
+ fn get_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ ) -> impl Future<Output = Result<Option<TeamInviteLinkTeam>, TeamError>> + Send;
}
/// The TeamMembersService defines read-only team membership queries.
@@ -563,5 +590,46 @@ pub trait TeamService: Clone + Send + Sync + 'static {
fn try_join_team_by_domain(
&self,
user_id: &MacroUserIdStr<'_>,
- ) -> impl Future<Output = Result<Option<TeamMember<'static>>, TryJoinTeamByDomainError>> + Send;
+ ) -> impl Future<Output = Result<Option<TeamMember<'static>>, JoinTeamDirectlyError>> + Send;
+}
+
+/// Manages a team's shareable invite link and joins users through it.
+///
+/// Showing or creating the link is inviting, so it follows the team's invite
+/// policy: any member by default, admins only when the team restricts
+/// inviting. Replacing or turning off a link that already exists breaks links
+/// people have shared, so only admins may do it.
+pub trait TeamInviteLinkService: Clone + Send + Sync + 'static {
+ /// The token of the caller's team invite link, if the team has one.
+ fn get_team_invite_link(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<MemberTeamRole>,
+ ) -> impl Future<Output = Result<Option<TeamInviteLinkToken>, ManageTeamInviteLinkError>> + Send;
+
+ /// Creates the team's invite link, or replaces it with a new token when
+ /// one already exists. Returns the new token.
+ fn create_team_invite_link(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<MemberTeamRole>,
+ ) -> impl Future<Output = Result<TeamInviteLinkToken, ManageTeamInviteLinkError>> + Send;
+
+ /// Turns off the team's invite link.
+ fn delete_team_invite_link(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<AdminTeamRole>,
+ ) -> impl Future<Output = Result<(), TeamError>> + Send;
+
+ /// The team an invite link joins, so the user can see it before joining.
+ fn get_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ ) -> impl Future<Output = Result<TeamInviteLinkTeam, JoinTeamByInviteLinkError>> + Send;
+
+ /// Adds the user to the team whose invite link has `token`, with the same
+ /// billing, role, and channel side effects as accepting an email invite.
+ fn join_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ user_id: &MacroUserIdStr<'_>,
+ ) -> impl Future<Output = Result<JoinTeamByInviteLinkOutcome, JoinTeamByInviteLinkError>> + Send;
}
diff --git a/crates/teams/src/domain/team_service.rs b/crates/teams/src/domain/team_service.rs
index c4ed567dd0..13a6dc7323 100644
--- a/crates/teams/src/domain/team_service.rs
+++ b/crates/teams/src/domain/team_service.rs
@@ -1,5 +1,6 @@
//! Contains the service logic for teams
+mod invite_link;
#[cfg(test)]
mod test;
@@ -42,13 +43,13 @@ use crate::domain::{
TeamMemberRemovedMetadata, TeamMemberRoleChangedMetadata, TeamUpdatedMetadata,
},
model::{
- CreateTeamError, CustomerError, DeleteTeamError, InviteUsersToTeamError, JoinTeamError,
- PatchTeamCrmSettingsResponse, PatchTeamRequest, RemoveTeamInviteError,
- RemoveUserFromAllTeamsError, RemoveUserFromTeamError,
+ CreateTeamError, CustomerError, DeleteTeamError, InviteUsersToTeamError,
+ JoinTeamDirectlyError, JoinTeamError, PatchTeamCrmSettingsResponse, PatchTeamRequest,
+ RemoveTeamInviteError, RemoveUserFromAllTeamsError, RemoveUserFromTeamError,
RestorePermissionsForTeamMembersError, RevokePermissionsForTeamMembersError, SeatPlan,
SetTeamMemberPlanError, Team, TeamError, TeamInvite, TeamInviteDetails, TeamMember,
- TeamMembers, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError,
- TryJoinTeamByDomainError, is_generic_email_domain, team_slug_from_name,
+ TeamMembers, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError, is_generic_email_domain,
+ team_slug_from_name,
},
open_seat_release::{NoOpOpenSeatRelease, OpenSeatRelease, SeatPlanChange, SubscriptionStart},
owned_entity_cleanup::{OwnedEntityCleanup, UnwiredOwnedEntityCleanup, clear_team},
@@ -298,6 +299,227 @@ where
OSR: OpenSeatRelease,
OEC: OwnedEntityCleanup,
{
+ /// Adds the user to the team without an email invite (domain auto-join
+ /// or invite link), then runs the same billing / roles / channels side
+ /// effects as `join_team`, rolling the membership back if any of them
+ /// fail. Returns None when the user is already a member.
+ #[tracing::instrument(skip(self), err)]
+ async fn join_team_directly(
+ &self,
+ team_id: &uuid::Uuid,
+ user_id: &MacroUserIdStr<'_>,
+ join_method: TeamJoinMethod,
+ ) -> Result<Option<TeamMember<'static>>, JoinTeamDirectlyError> {
+ let team_id = *team_id;
+
+ let enterprise = self
+ .team_repository
+ .get_team_enterprise_status(&team_id)
+ .await?;
+
+ // Add the user to the team directly (no invite), then run the same
+ // billing / roles / channels side effects as join_team, rolling
+ // the membership back if any of them fail.
+ let Some(team_member) = self
+ .team_repository
+ .add_user_to_team(&team_id, user_id)
+ .await?
+ else {
+ tracing::info!(%team_id, %user_id, "skipping direct team join: user is already a member");
+ return Ok(None);
+ };
+
+ let subscription_id = if enterprise {
+ None
+ } else {
+ let team_payment_status =
+ match self.team_repository.get_team_payment_status(&team_id).await {
+ Ok(team_payment_status) => team_payment_status,
+ Err(error) => {
+ self.rollback_add_user_to_team(
+ &team_id,
+ user_id,
+ "getting team payment status",
+ )
+ .await;
+ return Err(error.into());
+ }
+ };
+
+ if !team_payment_status {
+ // If the team has a subscription id and they are set to not paying continue to error
+ let team_subscription_id = match self
+ .team_repository
+ .get_team_subscription_id(&team_id)
+ .await
+ {
+ Ok(team_subscription_id) => team_subscription_id,
+ Err(error) => {
+ self.rollback_add_user_to_team(
+ &team_id,
+ user_id,
+ "getting team subscription id",
+ )
+ .await;
+ return Err(error.into());
+ }
+ };
+
+ if team_subscription_id.is_some() {
+ self.rollback_add_user_to_team(&team_id, user_id, "the payment status check")
+ .await;
+ return Err(JoinTeamError::TeamError(TeamError::TeamNotPaying).into());
+ }
+
+ if let Err(e) = self
+ .backfill_legacy_team_subscription_or_free(&team_id)
+ .await
+ {
+ self.rollback_add_user_to_team(
+ &team_id,
+ user_id,
+ "backfilling team subscription",
+ )
+ .await;
+ return Err(e.into_join_team_error().into());
+ }
+ }
+
+ let team_subscription_id = match self
+ .team_repository
+ .get_team_subscription_id(&team_id)
+ .await
+ {
+ Ok(team_subscription_id) => team_subscription_id,
+ Err(error) => {
+ self.rollback_add_user_to_team(&team_id, user_id, "getting team subscription")
+ .await;
+ return Err(error.into());
+ }
+ };
+
+ match team_subscription_id {
+ // Free membership never creates a paid seat or grants premium roles.
+ None => None,
+ Some(subscription_id) => {
+ if let Err(e) = self
+ .customer_repository
+ .increment_seat_count(&subscription_id, team_member.plan, 1)
+ .await
+ {
+ self.rollback_add_user_to_team(
+ &team_id,
+ user_id,
+ "incrementing seat count",
+ )
+ .await;
+ return Err(JoinTeamError::CustomerError(e).into());
+ }
+
+ Some(subscription_id)
+ }
+ }
+ };
+
+ // Premium roles come with a paid or enterprise team; free-team
+ // members keep their existing (free) entitlements.
+ let grants_premium = enterprise || subscription_id.is_some();
+ let roles_to_add = team_member_roles_to_add(team_member.plan);
+
+ if grants_premium {
+ // subscribe the user to professional features from the TeamSubscriber role and the role associated with their tier
+ let roles = non_empty::NonEmpty::new(roles_to_add.as_slice()).unwrap();
+
+ if let Err(e) = self
+ .user_roles_and_permissions_service
+ .dangerous_upsert_roles_for_user(user_id, roles)
+ .await
+ {
+ if let Some(subscription_id) = subscription_id.as_ref() {
+ self.customer_repository
+ .decrement_seat_count(subscription_id, team_member.plan, 1)
+ .await
+ .inspect_err(|rollback_err| {
+ tracing::error!(
+ error=?rollback_err,
+ "unable to rollback customer seat count after adding team member roles failed"
+ );
+ })
+ .ok();
+ }
+ self.rollback_add_user_to_team(&team_id, user_id, "adding team member roles")
+ .await;
+ return Err(JoinTeamError::AddRolesToUserError(e).into());
+ }
+ }
+
+ if let Err(e) = self
+ .channel_service
+ .auto_join_by_team_id(&team_id, user_id)
+ .await
+ {
+ if grants_premium {
+ let roles = non_empty::NonEmpty::new(roles_to_add.as_slice()).unwrap();
+ self.user_roles_and_permissions_service
+ .dangerous_remove_roles_from_user(user_id, &roles)
+ .await
+ .inspect_err(|rollback_err| {
+ tracing::error!(
+ error=?rollback_err,
+ "unable to rollback team member roles after adding team member to channels failed"
+ );
+ })
+ .ok();
+ }
+ if let Some(subscription_id) = subscription_id.as_ref() {
+ self.customer_repository
+ .decrement_seat_count(subscription_id, team_member.plan, 1)
+ .await
+ .inspect_err(|rollback_err| {
+ tracing::error!(
+ error=?rollback_err,
+ "unable to rollback customer seat count after adding team member to channels failed"
+ );
+ })
+ .ok();
+ }
+ self.rollback_add_user_to_team(&team_id, user_id, "adding team member to channels")
+ .await;
+ return Err(JoinTeamError::TeamError(channel_error_to_team_error(e)).into());
+ }
+
+ // Best-effort: ask the email service to seed CRM tables from this
+ // user's historical sent mail, same as join_team.
+ if let Err(e) = self
+ .crm_enqueuer
+ .enqueue_populate_crm_for_user(user_id)
+ .await
+ {
+ tracing::error!(
+ error = ?e,
+ team_id = %team_id,
+ macro_id = %user_id,
+ "Failed to enqueue PopulateCrmForUser after a direct team join; CRM tables will not be seeded from sent-mail history (per-message fan-out will still cover future sends)"
+ );
+ }
+
+ let teammate_ids = self.teammate_ids_except(&team_id, user_id).await;
+ self.enqueue_joining_user_contacts(user_id, &teammate_ids)
+ .await;
+
+ // NOTE: no TeamJoined analytics event here - that event is tied to
+ // the team invite that was accepted, and a direct join has none.
+ self.publish_team_event(&TeamMacroEvent::member_joined(TeamMemberJoinedMetadata {
+ team_id,
+ member_id: team_member.user_id.clone().into_owned(),
+ teammate_ids,
+ role: team_member.role,
+ join_method,
+ }));
+
+ Ok(Some(team_member))
+ }
+
/// Reconcile while the caller holds the owning team billing guard.
async fn reconcile_team_billing_locked(
&self,
@@ -2418,216 +2640,12 @@ where
async fn try_join_team_by_domain(
&self,
user_id: &MacroUserIdStr<'_>,
- ) -> Result<Option<TeamMember<'static>>, TryJoinTeamByDomainError> {
+ ) -> Result<Option<TeamMember<'static>>, JoinTeamDirectlyError> {
let Some(team_id) = self.team_repository.get_team_id_by_domain(user_id).await? else {
return Ok(None);
};
- let enterprise = self
- .team_repository
- .get_team_enterprise_status(&team_id)
- .await?;
-
- // Add the user to the team directly (no invite), then run the same
- // billing / roles / channels side effects as join_team, rolling
- // the membership back if any of them fail.
- let Some(team_member) = self
- .team_repository
- .add_user_to_team(&team_id, user_id)
- .await?
- else {
- tracing::info!(%team_id, %user_id, "skipping team auto-join: user is already a member");
- return Ok(None);
- };
-
- let subscription_id = if enterprise {
- None
- } else {
- let team_payment_status =
- match self.team_repository.get_team_payment_status(&team_id).await {
- Ok(team_payment_status) => team_payment_status,
- Err(error) => {
- self.rollback_add_user_to_team(
- &team_id,
- user_id,
- "getting team payment status",
- )
- .await;
- return Err(error.into());
- }
- };
-
- if !team_payment_status {
- // If the team has a subscription id and they are set to not paying continue to error
- let team_subscription_id = match self
- .team_repository
- .get_team_subscription_id(&team_id)
- .await
- {
- Ok(team_subscription_id) => team_subscription_id,
- Err(error) => {
- self.rollback_add_user_to_team(
- &team_id,
- user_id,
- "getting team subscription id",
- )
- .await;
- return Err(error.into());
- }
- };
-
- if team_subscription_id.is_some() {
- self.rollback_add_user_to_team(&team_id, user_id, "the payment status check")
- .await;
- return Err(JoinTeamError::TeamError(TeamError::TeamNotPaying).into());
- }
-
- if let Err(e) = self
- .backfill_legacy_team_subscription_or_free(&team_id)
- .await
- {
- self.rollback_add_user_to_team(
- &team_id,
- user_id,
- "backfilling team subscription",
- )
- .await;
- return Err(e.into_join_team_error().into());
- }
- }
-
- let team_subscription_id = match self
- .team_repository
- .get_team_subscription_id(&team_id)
- .await
- {
- Ok(team_subscription_id) => team_subscription_id,
- Err(error) => {
- self.rollback_add_user_to_team(&team_id, user_id, "getting team subscription")
- .await;
- return Err(error.into());
- }
- };
-
- match team_subscription_id {
- // Free membership never creates a paid seat or grants premium roles.
- None => None,
- Some(subscription_id) => {
- if let Err(e) = self
- .customer_repository
- .increment_seat_count(&subscription_id, team_member.plan, 1)
- .await
- {
- self.rollback_add_user_to_team(
- &team_id,
- user_id,
- "incrementing seat count",
- )
- .await;
- return Err(JoinTeamError::CustomerError(e).into());
- }
-
- Some(subscription_id)
- }
- }
- };
-
- // Premium roles come with a paid or enterprise team; free-team
- // members keep their existing (free) entitlements.
- let grants_premium = enterprise || subscription_id.is_some();
- let roles_to_add = team_member_roles_to_add(team_member.plan);
-
- if grants_premium {
- // subscribe the user to professional features from the TeamSubscriber role and the role associated with their tier
- let roles = non_empty::NonEmpty::new(roles_to_add.as_slice()).unwrap();
-
- if let Err(e) = self
- .user_roles_and_permissions_service
- .dangerous_upsert_roles_for_user(user_id, roles)
- .await
- {
- if let Some(subscription_id) = subscription_id.as_ref() {
- self.customer_repository
- .decrement_seat_count(subscription_id, team_member.plan, 1)
- .await
- .inspect_err(|rollback_err| {
- tracing::error!(
- error=?rollback_err,
- "unable to rollback customer seat count after adding team member roles failed"
- );
- })
- .ok();
- }
- self.rollback_add_user_to_team(&team_id, user_id, "adding team member roles")
- .await;
- return Err(JoinTeamError::AddRolesToUserError(e).into());
- }
- }
-
- if let Err(e) = self
- .channel_service
- .auto_join_by_team_id(&team_id, user_id)
- .await
- {
- if grants_premium {
- let roles = non_empty::NonEmpty::new(roles_to_add.as_slice()).unwrap();
- self.user_roles_and_permissions_service
- .dangerous_remove_roles_from_user(user_id, &roles)
- .await
- .inspect_err(|rollback_err| {
- tracing::error!(
- error=?rollback_err,
- "unable to rollback team member roles after adding team member to channels failed"
- );
- })
- .ok();
- }
- if let Some(subscription_id) = subscription_id.as_ref() {
- self.customer_repository
- .decrement_seat_count(subscription_id, team_member.plan, 1)
- .await
- .inspect_err(|rollback_err| {
- tracing::error!(
- error=?rollback_err,
- "unable to rollback customer seat count after adding team member to channels failed"
- );
- })
- .ok();
- }
- self.rollback_add_user_to_team(&team_id, user_id, "adding team member to channels")
- .await;
- return Err(JoinTeamError::TeamError(channel_error_to_team_error(e)).into());
- }
-
- // Best-effort: ask the email service to seed CRM tables from this
- // user's historical sent mail, same as join_team.
- if let Err(e) = self
- .crm_enqueuer
- .enqueue_populate_crm_for_user(user_id)
+ self.join_team_directly(&team_id, user_id, TeamJoinMethod::DomainAutoJoin)
.await
- {
- tracing::error!(
- error = ?e,
- team_id = %team_id,
- macro_id = %user_id,
- "Failed to enqueue PopulateCrmForUser after team auto-join; CRM tables will not be seeded from sent-mail history (per-message fan-out will still cover future sends)"
- );
- }
-
- let teammate_ids = self.teammate_ids_except(&team_id, user_id).await;
- self.enqueue_joining_user_contacts(user_id, &teammate_ids)
- .await;
-
- // NOTE: no TeamJoined analytics event here - that event is tied to
- // the team invite that was accepted, and a domain auto-join has none.
- self.publish_team_event(&TeamMacroEvent::member_joined(TeamMemberJoinedMetadata {
- team_id,
- member_id: team_member.user_id.clone().into_owned(),
- teammate_ids,
- role: team_member.role,
- join_method: TeamJoinMethod::DomainAutoJoin,
- }));
-
- Ok(Some(team_member))
}
}
diff --git a/crates/teams/src/domain/team_service/invite_link.rs b/crates/teams/src/domain/team_service/invite_link.rs
new file mode 100644
index 0000000000..0b82b91630
--- /dev/null
+++ b/crates/teams/src/domain/team_service/invite_link.rs
@@ -0,0 +1,184 @@
+//! A team's shareable invite link: the policy for who may see and change it,
+//! and joining through it.
+
+use channels::domain::ports::ChannelService;
+use entity_access::domain::models::{AdminTeamRole, EntityAccessReceipt, MemberTeamRole};
+use macro_event_broker::MacroEventBroker;
+use macro_user_id::user_id::MacroUserIdStr;
+use notification::domain::service::NotificationIngress;
+use roles_and_permissions::domain::port::UserRolesAndPermissionsService;
+
+use super::TeamServiceImpl;
+use crate::domain::{
+ contacts_enqueuer::ContactsEnqueuer,
+ crm_enqueuer::CrmEnqueuer,
+ customer_repo::CustomerRepository,
+ events::TeamJoinMethod,
+ model::{
+ JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, ManageTeamInviteLinkError,
+ TeamError, TeamInviteLinkTeam, TeamInviteLinkToken, TeamRole,
+ },
+ open_seat_release::OpenSeatRelease,
+ owned_entity_cleanup::OwnedEntityCleanup,
+ team_analytics::TeamAnalytics,
+ team_crm_settings_repo::TeamCrmSettingsRepository,
+ team_repo::{TeamInviteLinkService, TeamRepository},
+};
+
+/// The team and caller a member-level receipt was minted for.
+fn receipt_team_and_user(
+ receipt: &EntityAccessReceipt<MemberTeamRole>,
+) -> Result<(uuid::Uuid, &MacroUserIdStr<'static>), TeamError> {
+ let team_id = macro_uuid::string_to_uuid(&receipt.entity().entity_id)?;
+ let user_id = receipt.get_authenticated_user()?;
+ Ok((team_id, user_id))
+}
+
+impl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC>
+ TeamServiceImpl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC>
+where
+ TR: TeamRepository,
+ CR: CustomerRepository,
+ CS: ChannelService + Clone,
+ URPS: UserRolesAndPermissionsService,
+ NI: NotificationIngress,
+ CE: CrmEnqueuer,
+ TCRMS: TeamCrmSettingsRepository,
+ TA: TeamAnalytics,
+ CNE: ContactsEnqueuer,
+ EB: MacroEventBroker,
+ OSR: OpenSeatRelease,
+ OEC: OwnedEntityCleanup,
+{
+ /// Checks the caller may invite people to the team, the same rule as
+ /// email invites, and returns whether they are a team admin or owner.
+ async fn caller_may_invite(
+ &self,
+ team_id: &uuid::Uuid,
+ user_id: &MacroUserIdStr<'_>,
+ ) -> Result<bool, ManageTeamInviteLinkError> {
+ let is_admin = matches!(
+ self.team_repository.get_team_role(team_id, user_id).await?,
+ Some(TeamRole::Admin | TeamRole::Owner)
+ );
+ if !is_admin
+ && !self
+ .team_repository
+ .get_team_allow_non_admin_invites(team_id)
+ .await?
+ {
+ return Err(ManageTeamInviteLinkError::NonAdminInvitesDisabled);
+ }
+ Ok(is_admin)
+ }
+}
+
+impl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC> TeamInviteLinkService
+ for TeamServiceImpl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC>
+where
+ TR: TeamRepository,
+ CR: CustomerRepository,
+ CS: ChannelService + Clone,
+ URPS: UserRolesAndPermissionsService,
+ NI: NotificationIngress,
+ CE: CrmEnqueuer,
+ TCRMS: TeamCrmSettingsRepository,
+ TA: TeamAnalytics,
+ CNE: ContactsEnqueuer,
+ EB: MacroEventBroker + Clone,
+ OSR: OpenSeatRelease,
+ OEC: OwnedEntityCleanup,
+{
+ #[tracing::instrument(skip(self), err)]
+ async fn get_team_invite_link(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<MemberTeamRole>,
+ ) -> Result<Option<TeamInviteLinkToken>, ManageTeamInviteLinkError> {
+ let (team_id, user_id) = receipt_team_and_user(&entity_access_receipt)?;
+ self.caller_may_invite(&team_id, user_id).await?;
+ Ok(self.team_repository.get_team_invite_link(&team_id).await?)
+ }
+
+ #[tracing::instrument(skip(self), err)]
+ async fn create_team_invite_link(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<MemberTeamRole>,
+ ) -> Result<TeamInviteLinkToken, ManageTeamInviteLinkError> {
+ let (team_id, user_id) = receipt_team_and_user(&entity_access_receipt)?;
+ let is_admin = self.caller_may_invite(&team_id, user_id).await?;
+
+ if !is_admin
+ && self
+ .team_repository
+ .get_team_invite_link(&team_id)
+ .await?
+ .is_some()
+ {
+ return Err(ManageTeamInviteLinkError::ResetRequiresAdmin);
+ }
+
+ let token = TeamInviteLinkToken::generate();
+ self.team_repository
+ .set_team_invite_link(&team_id, &token)
+ .await?;
+ Ok(token)
+ }
+
+ #[tracing::instrument(skip(self), err)]
+ async fn delete_team_invite_link(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<AdminTeamRole>,
+ ) -> Result<(), TeamError> {
+ let team_id = macro_uuid::string_to_uuid(&entity_access_receipt.entity().entity_id)?;
+ self.team_repository.delete_team_invite_link(&team_id).await
+ }
+
+ #[tracing::instrument(skip(self, token), err)]
+ async fn get_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ ) -> Result<TeamInviteLinkTeam, JoinTeamByInviteLinkError> {
+ self.team_repository
+ .get_team_by_invite_link(token)
+ .await?
+ .ok_or(JoinTeamByInviteLinkError::LinkNotFound)
+ }
+
+ #[tracing::instrument(skip(self, token), err)]
+ async fn join_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ user_id: &MacroUserIdStr<'_>,
+ ) -> Result<JoinTeamByInviteLinkOutcome, JoinTeamByInviteLinkError> {
+ let team = self.get_team_by_invite_link(token).await?;
+
+ let user_teams = self.team_repository.get_user_teams(user_id).await?;
+ if user_teams.iter().any(|t| t.id == team.team_id) {
+ return Ok(JoinTeamByInviteLinkOutcome::AlreadyMember {
+ team_id: team.team_id,
+ });
+ }
+ if !user_teams.is_empty() {
+ return Err(JoinTeamByInviteLinkError::AlreadyInAnotherTeam);
+ }
+
+ match self
+ .join_team_directly(&team.team_id, user_id, TeamJoinMethod::InviteLink)
+ .await?
+ {
+ Some(member) => Ok(JoinTeamByInviteLinkOutcome::Joined(member)),
+ // The insert found an existing membership, which a concurrent
+ // join may have created on either this team or another one.
+ None => {
+ let user_teams = self.team_repository.get_user_teams(user_id).await?;
+ if user_teams.iter().any(|t| t.id == team.team_id) {
+ Ok(JoinTeamByInviteLinkOutcome::AlreadyMember {
+ team_id: team.team_id,
+ })
+ } else {
+ Err(JoinTeamByInviteLinkError::AlreadyInAnotherTeam)
+ }
+ }
+ }
+ }
+}
diff --git a/crates/teams/src/domain/team_service/test.rs b/crates/teams/src/domain/team_service/test.rs
index 8afea1b74d..bcd3d2035c 100644
--- a/crates/teams/src/domain/team_service/test.rs
+++ b/crates/teams/src/domain/team_service/test.rs
@@ -55,17 +55,18 @@ use super::*;
use crate::domain::{
customer_repo::CustomerRepository,
model::{
- AcceptedTeamInvite, CustomerError, PatchTeamRequest, PatchTeamUserRole,
- RemoveTeamInviteError, RemoveUserFromAllTeamsError, RemoveUserFromTeamError, SeatPlan,
- SetTeamMemberPlanError, Team, TeamError, TeamInvite, TeamInviteDetails, TeamInviteSnapshot,
- TeamMember, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError,
- TryJoinTeamByDomainError,
+ AcceptedTeamInvite, CustomerError, JoinTeamDirectlyError, PatchTeamRequest,
+ PatchTeamUserRole, RemoveTeamInviteError, RemoveUserFromAllTeamsError,
+ RemoveUserFromTeamError, SeatPlan, SetTeamMemberPlanError, Team, TeamError, TeamInvite,
+ TeamInviteDetails, TeamInviteLinkTeam, TeamInviteLinkToken, TeamInviteSnapshot, TeamMember,
+ TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError,
},
owned_entity_cleanup::ClearedTeam,
team_repo::TeamRepository,
};
mod delete_team;
+mod invite_link;
use delete_team::{Journal, RecordingOwnedEntityCleanup, Step};
@@ -138,7 +139,12 @@ struct MockTeamRepository {
team_ids: Vec<uuid::Uuid>,
reject_owner: bool,
user_teams: Vec<Team>,
+ /// What `get_user_teams` returns once `add_user_to_team` has run, to model
+ /// a membership created concurrently.
+ user_teams_after_add: Option<Vec<Team>>,
journal: Journal,
+ invite_link: Arc<Mutex<Option<TeamInviteLinkToken>>>,
+ invite_link_team: Option<TeamInviteLinkTeam>,
}
impl MockTeamRepository {
@@ -218,7 +224,10 @@ impl MockTeamRepository {
team_ids: Vec::new(),
reject_owner: false,
user_teams: Vec::new(),
+ user_teams_after_add: None,
journal: Journal::default(),
+ invite_link: Arc::new(Mutex::new(None)),
+ invite_link_team: None,
}
}
@@ -664,7 +673,10 @@ impl TeamRepository for MockTeamRepository {
&self,
_: &MacroUserIdStr<'_>,
) -> impl Future<Output = Result<Vec<Team>, TeamError>> + Send {
- let teams = self.user_teams.clone();
+ let teams = match &self.user_teams_after_add {
+ Some(teams) if *self.add_user_to_team_calls.lock().unwrap() > 0 => teams.clone(),
+ _ => self.user_teams.clone(),
+ };
async move { Ok(teams) }
}
@@ -887,6 +899,41 @@ impl TeamRepository for MockTeamRepository {
team_ids.truncate(limit as usize);
async move { Ok(team_ids) }
}
+
+ fn get_team_invite_link(
+ &self,
+ _: &uuid::Uuid,
+ ) -> impl Future<Output = Result<Option<TeamInviteLinkToken>, TeamError>> + Send {
+ let token = *self.invite_link.lock().unwrap();
+ async move { Ok(token) }
+ }
+
+ fn set_team_invite_link(
+ &self,
+ _: &uuid::Uuid,
+ token: &TeamInviteLinkToken,
+ ) -> impl Future<Output = Result<(), TeamError>> + Send {
+ *self.invite_link.lock().unwrap() = Some(*token);
+ async { Ok(()) }
+ }
+
+ fn delete_team_invite_link(
+ &self,
+ _: &uuid::Uuid,
+ ) -> impl Future<Output = Result<(), TeamError>> + Send {
+ *self.invite_link.lock().unwrap() = None;
+ async { Ok(()) }
+ }
+
+ fn get_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ ) -> impl Future<Output = Result<Option<TeamInviteLinkTeam>, TeamError>> + Send {
+ let team = (*self.invite_link.lock().unwrap() == Some(*token))
+ .then(|| self.invite_link_team.clone())
+ .flatten();
+ async move { Ok(team) }
+ }
}
// -- Mock CustomerRepository --
@@ -6303,7 +6350,7 @@ async fn test_try_join_team_by_domain_rolls_back_membership_when_roles_fail() {
assert!(matches!(
err,
- TryJoinTeamByDomainError::JoinTeamError(JoinTeamError::AddRolesToUserError(_))
+ JoinTeamDirectlyError::JoinTeamError(JoinTeamError::AddRolesToUserError(_))
));
// The seat increment happened, was rolled back, and the membership
// itself was removed again.
@@ -6346,7 +6393,7 @@ async fn try_join_team_by_domain_rolls_back_membership_when_billing_lookup_fails
assert!(matches!(
error,
- TryJoinTeamByDomainError::TeamError(TeamError::StorageLayerError(_))
+ JoinTeamDirectlyError::TeamError(TeamError::StorageLayerError(_))
));
assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 1);
assert_eq!(*team_repository.remove_user_calls.lock().unwrap(), 1);
@@ -6520,7 +6567,7 @@ async fn try_join_team_by_domain_enterprise_rolls_back_membership_when_roles_fai
assert!(matches!(
error,
- TryJoinTeamByDomainError::JoinTeamError(JoinTeamError::AddRolesToUserError(_))
+ JoinTeamDirectlyError::JoinTeamError(JoinTeamError::AddRolesToUserError(_))
));
assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 1);
assert_eq!(*team_repository.remove_user_calls.lock().unwrap(), 1);
@@ -6567,7 +6614,7 @@ async fn try_join_team_by_domain_enterprise_rolls_back_roles_when_channels_fail(
assert!(matches!(
error,
- TryJoinTeamByDomainError::JoinTeamError(JoinTeamError::TeamError(_))
+ JoinTeamDirectlyError::JoinTeamError(JoinTeamError::TeamError(_))
));
assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 1);
assert_eq!(*team_repository.remove_user_calls.lock().unwrap(), 1);
@@ -7225,7 +7272,7 @@ async fn try_join_team_by_domain_enterprise_status_read_precedes_membership_muta
assert!(matches!(
error,
- TryJoinTeamByDomainError::TeamError(TeamError::StorageLayerError(_))
+ JoinTeamDirectlyError::TeamError(TeamError::StorageLayerError(_))
));
assert_eq!(
*team_repository
diff --git a/crates/teams/src/domain/team_service/test/invite_link.rs b/crates/teams/src/domain/team_service/test/invite_link.rs
new file mode 100644
index 0000000000..eee0663cd1
--- /dev/null
+++ b/crates/teams/src/domain/team_service/test/invite_link.rs
@@ -0,0 +1,293 @@
+use uuid::Uuid;
+
+use super::*;
+use crate::domain::{
+ model::{
+ JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, ManageTeamInviteLinkError,
+ TeamInviteLinkTeam, TeamInviteLinkToken,
+ },
+ team_repo::TeamInviteLinkService,
+};
+
+const TEAM_ID: Uuid = Uuid::from_u128(0x1_1000);
+const CALLER: &str = "macro|[email protected]";
+const JOINER: &str = "macro|[email protected]";
+
+fn caller() -> MacroUserIdStr<'static> {
+ MacroUserIdStr::parse_from_str(CALLER).unwrap()
+}
+
+fn joiner() -> MacroUserIdStr<'static> {
+ MacroUserIdStr::parse_from_str(JOINER).unwrap()
+}
+
+fn repository(role: TeamRole, allow_non_admin_invites: bool) -> MockTeamRepository {
+ MockTeamRepository::new(Vec::new(), "Acme", Arc::new(Mutex::new(Vec::new())))
+ .with_caller_team_role(Some(role))
+ .with_allow_non_admin_invites(allow_non_admin_invites)
+}
+
+fn service(team_repository: MockTeamRepository) -> impl TeamInviteLinkService + use<> {
+ TeamServiceImpl::new(
+ team_repository,
+ MockCustomerRepository::default(),
+ RecordingChannelService::default(),
+ MockUserRolesAndPermissionsService::default(),
+ Arc::new(MockNotificationIngress::new(HashSet::new())),
+ NoOpCrmEnqueuer,
+ NoOpTeamCrmSettingsRepository,
+ )
+}
+
+/// A repository whose team has an invite link and whose free team accepts
+/// `JOINER` as a new member.
+fn repository_with_link(token: TeamInviteLinkToken) -> MockTeamRepository {
+ let mut team_repository = repository(TeamRole::Member, true);
+ *team_repository.invite_link.lock().unwrap() = Some(token);
+ team_repository.invite_link_team = Some(TeamInviteLinkTeam {
+ team_id: TEAM_ID,
+ team_name: "Acme".to_string(),
+ });
+ team_repository.add_user_to_team_result = Some(TeamMember {
+ team_id: TEAM_ID,
+ user_id: joiner(),
+ role: TeamRole::Member,
+ plan: SeatPlan::Premium,
+ });
+ team_repository
+}
+
+fn acme(team_id: Uuid) -> Team {
+ Team::new(
+ team_id,
+ "Acme".to_string(),
+ "ACME".to_string(),
+ caller(),
+ false,
+ false,
+ )
+}
+
+#[tokio::test]
+async fn members_create_the_first_link_when_anyone_may_invite() {
+ let team_repository = repository(TeamRole::Member, true);
+ let service = service(team_repository.clone());
+
+ let token = service
+ .create_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await
+ .unwrap();
+
+ assert_eq!(*team_repository.invite_link.lock().unwrap(), Some(token));
+ assert_eq!(
+ service
+ .get_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await
+ .unwrap(),
+ Some(token)
+ );
+}
+
+#[tokio::test]
+async fn members_cannot_see_or_create_links_when_only_admins_may_invite() {
+ let team_repository = repository(TeamRole::Member, false);
+ *team_repository.invite_link.lock().unwrap() = Some(TeamInviteLinkToken::generate());
+ let service = service(team_repository.clone());
+
+ assert!(matches!(
+ service
+ .get_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await,
+ Err(ManageTeamInviteLinkError::NonAdminInvitesDisabled)
+ ));
+ assert!(matches!(
+ service
+ .create_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await,
+ Err(ManageTeamInviteLinkError::NonAdminInvitesDisabled)
+ ));
+}
+
+#[tokio::test]
+async fn admins_manage_links_when_only_admins_may_invite() {
+ let team_repository = repository(TeamRole::Admin, false);
+ let service = service(team_repository.clone());
+
+ let token = service
+ .create_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await
+ .unwrap();
+
+ assert_eq!(
+ service
+ .get_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await
+ .unwrap(),
+ Some(token)
+ );
+}
+
+#[tokio::test]
+async fn only_admins_reset_an_existing_link() {
+ let existing = TeamInviteLinkToken::generate();
+ let member_repository = repository(TeamRole::Member, true);
+ *member_repository.invite_link.lock().unwrap() = Some(existing);
+
+ assert!(matches!(
+ service(member_repository.clone())
+ .create_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await,
+ Err(ManageTeamInviteLinkError::ResetRequiresAdmin)
+ ));
+ assert_eq!(
+ *member_repository.invite_link.lock().unwrap(),
+ Some(existing)
+ );
+
+ let owner_repository = repository(TeamRole::Owner, true);
+ *owner_repository.invite_link.lock().unwrap() = Some(existing);
+ let reset = service(owner_repository.clone())
+ .create_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await
+ .unwrap();
+
+ assert_ne!(reset, existing);
+ assert_eq!(*owner_repository.invite_link.lock().unwrap(), Some(reset));
+}
+
+#[tokio::test]
+async fn turning_off_the_link_stops_it_from_joining() {
+ let token = TeamInviteLinkToken::generate();
+ let team_repository = repository_with_link(token);
+ let service = service(team_repository.clone());
+
+ service
+ .delete_team_invite_link(test_team_receipt(TEAM_ID, &caller()))
+ .await
+ .unwrap();
+
+ assert!(matches!(
+ service.get_team_by_invite_link(&token).await,
+ Err(JoinTeamByInviteLinkError::LinkNotFound)
+ ));
+ assert!(matches!(
+ service.join_team_by_invite_link(&token, &joiner()).await,
+ Err(JoinTeamByInviteLinkError::LinkNotFound)
+ ));
+ assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 0);
+}
+
+#[tokio::test]
+async fn joining_by_link_adds_the_user_and_publishes_the_join_method() {
+ let token = TeamInviteLinkToken::generate();
+ let team_repository = repository_with_link(token);
+ let channels = RecordingChannelService::default();
+ let event_broker = RecordingEventBroker::default();
+ let service = TeamServiceImpl::new(
+ team_repository.clone(),
+ MockCustomerRepository::default(),
+ channels.clone(),
+ MockUserRolesAndPermissionsService::default(),
+ Arc::new(MockNotificationIngress::new(HashSet::new())),
+ NoOpCrmEnqueuer,
+ NoOpTeamCrmSettingsRepository,
+ )
+ .with_event_broker(event_broker.clone());
+
+ let outcome = service
+ .join_team_by_invite_link(&token, &joiner())
+ .await
+ .unwrap();
+
+ let JoinTeamByInviteLinkOutcome::Joined(member) = outcome else {
+ panic!("expected the user to join, got {outcome:?}");
+ };
+ assert_eq!(member.team_id, TEAM_ID);
+ assert_eq!(member.user_id, joiner());
+ assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 1);
+ assert_eq!(
+ *channels.auto_join_calls.lock().unwrap(),
+ vec![(TEAM_ID, JOINER.to_string())]
+ );
+ let published = event_broker.events();
+ assert_eq!(published.len(), 1);
+ assert_eq!(
+ published[0].envelope["metadata"]["join_method"],
+ serde_json::json!({ "type": "invite_link" })
+ );
+}
+
+#[tokio::test]
+async fn joining_by_a_wrong_token_changes_nothing() {
+ let team_repository = repository_with_link(TeamInviteLinkToken::generate());
+ let service = service(team_repository.clone());
+
+ assert!(matches!(
+ service
+ .join_team_by_invite_link(&TeamInviteLinkToken::generate(), &joiner())
+ .await,
+ Err(JoinTeamByInviteLinkError::LinkNotFound)
+ ));
+ assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 0);
+}
+
+#[tokio::test]
+async fn joining_a_team_you_are_on_is_a_no_op() {
+ let token = TeamInviteLinkToken::generate();
+ let mut team_repository = repository_with_link(token);
+ team_repository.user_teams = vec![acme(TEAM_ID)];
+ let service = service(team_repository.clone());
+
+ let outcome = service
+ .join_team_by_invite_link(&token, &joiner())
+ .await
+ .unwrap();
+
+ assert!(matches!(
+ outcome,
+ JoinTeamByInviteLinkOutcome::AlreadyMember { team_id: TEAM_ID }
+ ));
+ assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 0);
+}
+
+#[tokio::test]
+async fn a_concurrent_join_to_the_same_team_is_a_no_op() {
+ let token = TeamInviteLinkToken::generate();
+ let mut team_repository = repository_with_link(token);
+ team_repository.add_user_to_team_result = None;
+ team_repository.user_teams_after_add = Some(vec![acme(TEAM_ID)]);
+ let service = service(team_repository.clone());
+
+ assert!(matches!(
+ service.join_team_by_invite_link(&token, &joiner()).await,
+ Ok(JoinTeamByInviteLinkOutcome::AlreadyMember { team_id: TEAM_ID })
+ ));
+}
+
+#[tokio::test]
+async fn a_concurrent_join_to_another_team_is_reported_as_a_conflict() {
+ let token = TeamInviteLinkToken::generate();
+ let mut team_repository = repository_with_link(token);
+ team_repository.add_user_to_team_result = None;
+ team_repository.user_teams_after_add = Some(vec![acme(Uuid::from_u128(0x2_2000))]);
+ let service = service(team_repository.clone());
+
+ assert!(matches!(
+ service.join_team_by_invite_link(&token, &joiner()).await,
+ Err(JoinTeamByInviteLinkError::AlreadyInAnotherTeam)
+ ));
+}
+
+#[tokio::test]
+async fn users_on_another_team_cannot_join_by_link() {
+ let token = TeamInviteLinkToken::generate();
+ let mut team_repository = repository_with_link(token);
+ team_repository.user_teams = vec![acme(Uuid::from_u128(0x2_2000))];
+ let service = service(team_repository.clone());
+
+ assert!(matches!(
+ service.join_team_by_invite_link(&token, &joiner()).await,
+ Err(JoinTeamByInviteLinkError::AlreadyInAnotherTeam)
+ ));
+ assert_eq!(*team_repository.add_user_to_team_calls.lock().unwrap(), 0);
+}
diff --git a/crates/teams/src/inbound/axum_router.rs b/crates/teams/src/inbound/axum_router.rs
index 71f6015b14..7c7c1579f5 100644
--- a/crates/teams/src/inbound/axum_router.rs
+++ b/crates/teams/src/inbound/axum_router.rs
@@ -14,6 +14,9 @@ pub mod get_team_invites;
pub mod get_user_invites;
/// Get all teams for a user.
pub mod get_user_teams;
+/// Read, create, and turn off a team's shareable invite link, and join
+/// through it.
+pub mod invite_link;
/// Invite users to a team.
pub mod invite_to_team;
/// Join a team via invite.
@@ -57,7 +60,7 @@ use crate::domain::{
RemoveTeamInviteError, RemoveUserFromTeamError, SetTeamMemberPlanError, TeamError,
ToggleAutoJoinDomainError,
},
- team_repo::TeamService,
+ team_repo::{TeamInviteLinkService, TeamService},
};
/// Router state containing the team service.
@@ -96,7 +99,7 @@ impl<T, Eas, Auth> Clone for TeamRouterState<T, Eas, Auth> {
/// Build the teams router with all endpoints.
pub fn teams_router<T, Eas, Auth, S>(state: TeamRouterState<T, Eas, Auth>) -> Router<S>
where
- T: TeamService,
+ T: TeamService + TeamInviteLinkService,
Eas: EntityAccessService,
Auth: MacroAuthorizationService,
S: Send + Sync + 'static,
@@ -129,6 +132,20 @@ where
)
.route("/invites", get(get_team_invites::handler::<T, Eas, Auth>))
.route("/invite", post(invite_to_team::handler::<T, Eas, Auth>))
+ .route(
+ "/invite-link",
+ get(invite_link::get_handler::<T, Eas, Auth>)
+ .post(invite_link::create_handler::<T, Eas, Auth>)
+ .delete(invite_link::delete_handler::<T, Eas, Auth>),
+ )
+ .route(
+ "/invite-link/team",
+ post(invite_link::get_team_handler::<T, Eas, Auth>),
+ )
+ .route(
+ "/invite-link/join",
+ post(invite_link::join_handler::<T, Eas, Auth>),
+ )
.route(
"/join/{team_invite_id}",
delete(reject_invitation::handler::<T, Eas, Auth>),
diff --git a/crates/teams/src/inbound/axum_router/invite_link.rs b/crates/teams/src/inbound/axum_router/invite_link.rs
new file mode 100644
index 0000000000..602503abf4
--- /dev/null
+++ b/crates/teams/src/inbound/axum_router/invite_link.rs
@@ -0,0 +1,251 @@
+use axum::{
+ Json,
+ extract::State,
+ http::StatusCode,
+ response::{IntoResponse, Response},
+};
+use entity_access::{
+ domain::{
+ models::{AdminTeamRole, MemberTeamRole},
+ ports::EntityAccessService,
+ },
+ inbound::axum_extractors::MacroUserTeamExtractorV2,
+};
+use macro_authorization::{MacroAuthorizationExtractor, MacroAuthorizationService, UserOrInternal};
+use model_error_response::ErrorResponse;
+
+use crate::domain::{
+ model::{
+ JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, JoinTeamDirectlyError,
+ ManageTeamInviteLinkError, TeamError, TeamInviteLinkTeam, TeamInviteLinkToken,
+ },
+ team_repo::{TeamInviteLinkService, TeamService},
+};
+
+use super::TeamRouterState;
+
+/// The caller's team invite link.
+#[derive(serde::Serialize, utoipa::ToSchema)]
+pub struct TeamInviteLinkResponse {
+ /// The link's token, or null when the team has no invite link.
+ pub token: Option<TeamInviteLinkToken>,
+}
+
+/// A newly created team invite link.
+#[derive(serde::Serialize, utoipa::ToSchema)]
+pub struct CreatedTeamInviteLinkResponse {
+ /// The new link's token. Any previous link stops working.
+ pub token: TeamInviteLinkToken,
+}
+
+/// The result of opening a team invite link.
+#[derive(serde::Serialize, utoipa::ToSchema)]
+pub struct JoinTeamByInviteLinkResponse {
+ /// The team the link joins.
+ pub team_id: uuid::Uuid,
+ /// True when the user was already on the team and nothing changed.
+ pub already_member: bool,
+}
+
+/// Identifies an invite link. The token travels in the body, not the path, so
+/// request spans and access logs that record the path never see it.
+#[derive(serde::Deserialize, utoipa::ToSchema)]
+pub struct TeamInviteLinkTokenRequest {
+ /// The invite link's token.
+ pub token: TeamInviteLinkToken,
+}
+
+impl IntoResponse for ManageTeamInviteLinkError {
+ fn into_response(self) -> Response {
+ match self {
+ ManageTeamInviteLinkError::NonAdminInvitesDisabled
+ | ManageTeamInviteLinkError::ResetRequiresAdmin => (
+ StatusCode::FORBIDDEN,
+ Json(ErrorResponse {
+ message: self.to_string().into(),
+ }),
+ )
+ .into_response(),
+ ManageTeamInviteLinkError::TeamError(e) => e.into_response(),
+ }
+ }
+}
+
+impl IntoResponse for JoinTeamByInviteLinkError {
+ fn into_response(self) -> Response {
+ match self {
+ JoinTeamByInviteLinkError::LinkNotFound => (
+ StatusCode::NOT_FOUND,
+ Json(ErrorResponse {
+ message: self.to_string().into(),
+ }),
+ )
+ .into_response(),
+ JoinTeamByInviteLinkError::AlreadyInAnotherTeam => (
+ StatusCode::CONFLICT,
+ Json(ErrorResponse {
+ message: self.to_string().into(),
+ }),
+ )
+ .into_response(),
+ JoinTeamByInviteLinkError::TeamError(e)
+ | JoinTeamByInviteLinkError::JoinError(JoinTeamDirectlyError::TeamError(e)) => {
+ e.into_response()
+ }
+ JoinTeamByInviteLinkError::JoinError(JoinTeamDirectlyError::JoinTeamError(e)) => {
+ e.into_response()
+ }
+ }
+ }
+}
+
+/// Gets the team's invite link. Anyone who may invite people to the team may
+/// see it.
+#[utoipa::path(
+ get,
+ path = "/team/invite-link",
+ operation_id = "get_team_invite_link",
+ responses(
+ (status = 200, body = TeamInviteLinkResponse),
+ (status = 401, body = ErrorResponse),
+ (status = 403, body = ErrorResponse),
+ (status = 500, body = ErrorResponse),
+ ),
+)]
+#[tracing::instrument(skip_all, err)]
+pub async fn get_handler<
+ T: TeamService + TeamInviteLinkService,
+ Eas: EntityAccessService,
+ Auth: MacroAuthorizationService,
+>(
+ access: MacroUserTeamExtractorV2<MemberTeamRole, Eas, Auth>,
+ State(state): State<TeamRouterState<T, Eas, Auth>>,
+) -> Result<Json<TeamInviteLinkResponse>, ManageTeamInviteLinkError> {
+ let token = state
+ .service
+ .get_team_invite_link(access.entity_access_receipt)
+ .await?;
+ Ok(Json(TeamInviteLinkResponse { token }))
+}
+
+/// Creates the team's invite link, replacing any existing one. Anyone who may
+/// invite people may create the first link; replacing one requires a team
+/// admin or owner.
+#[utoipa::path(
+ post,
+ path = "/team/invite-link",
+ operation_id = "create_team_invite_link",
+ responses(
+ (status = 201, body = CreatedTeamInviteLinkResponse),
+ (status = 401, body = ErrorResponse),
+ (status = 403, body = ErrorResponse),
+ (status = 500, body = ErrorResponse),
+ ),
+)]
+#[tracing::instrument(skip_all, err)]
+pub async fn create_handler<
+ T: TeamService + TeamInviteLinkService,
+ Eas: EntityAccessService,
+ Auth: MacroAuthorizationService,
+>(
+ access: MacroUserTeamExtractorV2<MemberTeamRole, Eas, Auth>,
+ State(state): State<TeamRouterState<T, Eas, Auth>>,
+) -> Result<(StatusCode, Json<CreatedTeamInviteLinkResponse>), ManageTeamInviteLinkError> {
+ let token = state
+ .service
+ .create_team_invite_link(access.entity_access_receipt)
+ .await?;
+ Ok((
+ StatusCode::CREATED,
+ Json(CreatedTeamInviteLinkResponse { token }),
+ ))
+}
+
+/// Turns off the team's invite link. Requires a team admin or owner.
+#[utoipa::path(
+ delete,
+ path = "/team/invite-link",
+ operation_id = "delete_team_invite_link",
+ responses(
+ (status = 204),
+ (status = 401, body = ErrorResponse),
+ (status = 403, body = ErrorResponse),
+ (status = 500, body = ErrorResponse),
+ ),
+)]
+#[tracing::instrument(skip_all, err)]
+pub async fn delete_handler<
+ T: TeamService + TeamInviteLinkService,
+ Eas: EntityAccessService,
+ Auth: MacroAuthorizationService,
+>(
+ access: MacroUserTeamExtractorV2<AdminTeamRole, Eas, Auth>,
+ State(state): State<TeamRouterState<T, Eas, Auth>>,
+) -> Result<StatusCode, TeamError> {
+ state
+ .service
+ .delete_team_invite_link(access.entity_access_receipt)
+ .await?;
+ Ok(StatusCode::NO_CONTENT)
+}
+
+/// Gets the team an invite link joins, so the user can see it before joining.
+#[utoipa::path(
+ post,
+ path = "/team/invite-link/team",
+ operation_id = "get_team_by_invite_link",
+ request_body = TeamInviteLinkTokenRequest,
+ responses(
+ (status = 200, body = TeamInviteLinkTeam),
+ (status = 401, body = ErrorResponse),
+ (status = 404, body = ErrorResponse),
+ (status = 500, body = ErrorResponse),
+ ),
+)]
+#[tracing::instrument(skip_all, err)]
+pub async fn get_team_handler<
+ T: TeamService + TeamInviteLinkService,
+ Eas: EntityAccessService,
+ Auth: MacroAuthorizationService,
+>(
+ State(state): State<TeamRouterState<T, Eas, Auth>>,
+ _authorization: MacroAuthorizationExtractor<Auth, UserOrInternal>,
+ Json(TeamInviteLinkTokenRequest { token }): Json<TeamInviteLinkTokenRequest>,
+) -> Result<Json<TeamInviteLinkTeam>, JoinTeamByInviteLinkError> {
+ let team = state.service.get_team_by_invite_link(&token).await?;
+ Ok(Json(team))
+}
+
+/// Joins the team an invite link belongs to.
+#[utoipa::path(
+ post,
+ path = "/team/invite-link/join",
+ operation_id = "join_team_by_invite_link",
+ request_body = TeamInviteLinkTokenRequest,
+ responses(
+ (status = 200, body = JoinTeamByInviteLinkResponse),
+ (status = 401, body = ErrorResponse),
+ (status = 404, body = ErrorResponse),
+ (status = 409, body = ErrorResponse),
+ (status = 500, body = ErrorResponse),
+ ),
+)]
+#[tracing::instrument(skip_all, err)]
+pub async fn join_handler<
+ T: TeamService + TeamInviteLinkService,
+ Eas: EntityAccessService,
+ Auth: MacroAuthorizationService,
+>(
+ State(state): State<TeamRouterState<T, Eas, Auth>>,
+ authorization: MacroAuthorizationExtractor<Auth, UserOrInternal>,
+ Json(TeamInviteLinkTokenRequest { token }): Json<TeamInviteLinkTokenRequest>,
+) -> Result<Json<JoinTeamByInviteLinkResponse>, JoinTeamByInviteLinkError> {
+ let outcome = state
+ .service
+ .join_team_by_invite_link(&token, &authorization.authorization.user.macro_user_id)
+ .await?;
+ Ok(Json(JoinTeamByInviteLinkResponse {
+ team_id: outcome.team_id(),
+ already_member: matches!(outcome, JoinTeamByInviteLinkOutcome::AlreadyMember { .. }),
+ }))
+}
diff --git a/crates/teams/src/inbound/axum_router/test.rs b/crates/teams/src/inbound/axum_router/test.rs
index e753e621a9..21b89df409 100644
--- a/crates/teams/src/inbound/axum_router/test.rs
+++ b/crates/teams/src/inbound/axum_router/test.rs
@@ -36,15 +36,16 @@ use tower::ServiceExt;
use crate::domain::{
model::{
- CreateTeamError, CustomerError, DeleteTeamError, InviteUsersToTeamError, JoinTeamError,
- PatchTeamCrmSettingsResponse, PatchTeamRequest, RemoveTeamInviteError,
- RemoveUserFromTeamError, RestorePermissionsForTeamMembersError,
+ CreateTeamError, CustomerError, DeleteTeamError, InviteUsersToTeamError,
+ JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, JoinTeamDirectlyError,
+ JoinTeamError, ManageTeamInviteLinkError, PatchTeamCrmSettingsResponse, PatchTeamRequest,
+ RemoveTeamInviteError, RemoveUserFromTeamError, RestorePermissionsForTeamMembersError,
RevokePermissionsForTeamMembersError, SeatPlan, SetTeamMemberPlanError, Team, TeamError,
- TeamInvite, TeamInviteDetails, TeamMember, TeamWithMembers, ToggleAutoJoinDomainError,
- TryJoinTeamByDomainError,
+ TeamInvite, TeamInviteDetails, TeamInviteLinkTeam, TeamInviteLinkToken, TeamMember,
+ TeamWithMembers, ToggleAutoJoinDomainError,
},
owned_entity_cleanup::OwnedEntityCleanupError,
- team_repo::TeamService,
+ team_repo::{TeamInviteLinkService, TeamService},
};
use super::{
@@ -80,6 +81,41 @@ async fn assert_customer_error_is_obfuscated(error: impl IntoResponse) {
assert!(!body_text.contains(CUSTOMER_ERROR_SENTINEL));
}
+#[tokio::test]
+async fn invite_link_errors_map_to_their_statuses() {
+ for (error, status) in [
+ (
+ ManageTeamInviteLinkError::NonAdminInvitesDisabled.into_response(),
+ StatusCode::FORBIDDEN,
+ ),
+ (
+ ManageTeamInviteLinkError::ResetRequiresAdmin.into_response(),
+ StatusCode::FORBIDDEN,
+ ),
+ (
+ JoinTeamByInviteLinkError::LinkNotFound.into_response(),
+ StatusCode::NOT_FOUND,
+ ),
+ (
+ JoinTeamByInviteLinkError::AlreadyInAnotherTeam.into_response(),
+ StatusCode::CONFLICT,
+ ),
+ (
+ JoinTeamByInviteLinkError::JoinError(JoinTeamDirectlyError::JoinTeamError(
+ JoinTeamError::CustomerError(customer_error()),
+ ))
+ .into_response(),
+ StatusCode::INTERNAL_SERVER_ERROR,
+ ),
+ ] {
+ assert_eq!(error.status(), status);
+ }
+ assert_customer_error_is_obfuscated(JoinTeamByInviteLinkError::JoinError(
+ JoinTeamDirectlyError::JoinTeamError(JoinTeamError::CustomerError(customer_error())),
+ ))
+ .await;
+}
+
#[tokio::test]
async fn delete_team_customer_error_response_is_obfuscated() {
assert_customer_error_is_obfuscated(DeleteTeamError::CustomerError(customer_error())).await;
@@ -457,11 +493,49 @@ impl TeamService for FakeTeamService {
async fn try_join_team_by_domain(
&self,
_user_id: &MacroUserIdStr<'_>,
- ) -> Result<Option<TeamMember<'static>>, TryJoinTeamByDomainError> {
+ ) -> Result<Option<TeamMember<'static>>, JoinTeamDirectlyError> {
panic!("unexpected try_join_team_by_domain call")
}
}
+impl TeamInviteLinkService for FakeTeamService {
+ async fn get_team_invite_link(
+ &self,
+ _entity_access_receipt: EntityAccessReceipt<MemberTeamRole>,
+ ) -> Result<Option<TeamInviteLinkToken>, ManageTeamInviteLinkError> {
+ panic!("unexpected get_team_invite_link call")
+ }
+
+ async fn create_team_invite_link(
+ &self,
+ _entity_access_receipt: EntityAccessReceipt<MemberTeamRole>,
+ ) -> Result<TeamInviteLinkToken, ManageTeamInviteLinkError> {
+ panic!("unexpected create_team_invite_link call")
+ }
+
+ async fn delete_team_invite_link(
+ &self,
+ _entity_access_receipt: EntityAccessReceipt<AdminTeamRole>,
+ ) -> Result<(), TeamError> {
+ panic!("unexpected delete_team_invite_link call")
+ }
+
+ async fn get_team_by_invite_link(
+ &self,
+ _token: &TeamInviteLinkToken,
+ ) -> Result<TeamInviteLinkTeam, JoinTeamByInviteLinkError> {
+ panic!("unexpected get_team_by_invite_link call")
+ }
+
+ async fn join_team_by_invite_link(
+ &self,
+ _token: &TeamInviteLinkToken,
+ _user_id: &MacroUserIdStr<'_>,
+ ) -> Result<JoinTeamByInviteLinkOutcome, JoinTeamByInviteLinkError> {
+ panic!("unexpected join_team_by_invite_link call")
+ }
+}
+
#[derive(Clone, Default)]
struct FakeEntityAccessService {
membership: Option<(String, TeamRole)>,
diff --git a/crates/teams/src/outbound/team_repo.rs b/crates/teams/src/outbound/team_repo.rs
index 4be6c05d65..fc4b48dbe7 100644
--- a/crates/teams/src/outbound/team_repo.rs
+++ b/crates/teams/src/outbound/team_repo.rs
@@ -3,8 +3,9 @@ use crate::domain::{
model::{
AcceptedTeamInvite, CreateTeamError, InviteUsersToTeamError, PatchTeamRequest,
RemoveTeamInviteError, RemoveUserFromTeamError, SeatPlan, Team, TeamError, TeamInvite,
- TeamInviteDetails, TeamInviteSnapshot, TeamMember, TeamMembers, TeamPlan, TeamRole,
- TeamWithMembers, ToggleAutoJoinDomainError, is_generic_email_domain, normalize_team_slug,
+ TeamInviteDetails, TeamInviteLinkTeam, TeamInviteLinkToken, TeamInviteSnapshot, TeamMember,
+ TeamMembers, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError,
+ is_generic_email_domain, normalize_team_slug,
},
owned_entity_cleanup::ClearedTeam,
team_repo::{TeamMembersService, TeamRepository},
@@ -28,6 +29,7 @@ fn type_err<E: std::fmt::Display>(e: E) -> sqlx::Error {
}
}
+mod invite_link;
#[cfg(test)]
mod test;
@@ -1524,6 +1526,36 @@ impl TeamRepository for TeamRepositoryImpl {
Ok(new_domain)
}
+ #[tracing::instrument(skip(self), err)]
+ async fn get_team_invite_link(
+ &self,
+ team_id: &uuid::Uuid,
+ ) -> Result<Option<TeamInviteLinkToken>, TeamError> {
+ invite_link::get_team_invite_link(&self.pool, team_id).await
+ }
+
+ #[tracing::instrument(skip(self, token), err)]
+ async fn set_team_invite_link(
+ &self,
+ team_id: &uuid::Uuid,
+ token: &TeamInviteLinkToken,
+ ) -> Result<(), TeamError> {
+ invite_link::set_team_invite_link(&self.pool, team_id, token).await
+ }
+
+ #[tracing::instrument(skip(self), err)]
+ async fn delete_team_invite_link(&self, team_id: &uuid::Uuid) -> Result<(), TeamError> {
+ invite_link::delete_team_invite_link(&self.pool, team_id).await
+ }
+
+ #[tracing::instrument(skip(self, token), err)]
+ async fn get_team_by_invite_link(
+ &self,
+ token: &TeamInviteLinkToken,
+ ) -> Result<Option<TeamInviteLinkTeam>, TeamError> {
+ invite_link::get_team_by_invite_link(&self.pool, token).await
+ }
+
#[tracing::instrument(skip(self), err)]
async fn get_team_allow_non_admin_invites(
&self,
diff --git a/crates/teams/src/outbound/team_repo/invite_link.rs b/crates/teams/src/outbound/team_repo/invite_link.rs
new file mode 100644
index 0000000000..8ca875c021
--- /dev/null
+++ b/crates/teams/src/outbound/team_repo/invite_link.rs
@@ -0,0 +1,80 @@
+//! Queries for a team's shareable invite link.
+
+use sqlx::PgPool;
+
+use crate::domain::model::{TeamError, TeamInviteLinkTeam, TeamInviteLinkToken};
+
+pub(super) async fn get_team_invite_link(
+ pool: &PgPool,
+ team_id: &uuid::Uuid,
+) -> Result<Option<TeamInviteLinkToken>, TeamError> {
+ let token = sqlx::query_scalar!(
+ r#"
+ SELECT token
+ FROM team_invite_link
+ WHERE team_id = $1
+ "#,
+ team_id,
+ )
+ .fetch_optional(pool)
+ .await?;
+
+ Ok(token.map(TeamInviteLinkToken::from_uuid))
+}
+
+pub(super) async fn set_team_invite_link(
+ pool: &PgPool,
+ team_id: &uuid::Uuid,
+ token: &TeamInviteLinkToken,
+) -> Result<(), TeamError> {
+ sqlx::query!(
+ r#"
+ INSERT INTO team_invite_link (team_id, token)
+ VALUES ($1, $2)
+ ON CONFLICT (team_id) DO UPDATE
+ SET token = EXCLUDED.token,
+ created_at = now()
+ "#,
+ team_id,
+ token.as_uuid(),
+ )
+ .execute(pool)
+ .await?;
+
+ Ok(())
+}
+
+pub(super) async fn delete_team_invite_link(
+ pool: &PgPool,
+ team_id: &uuid::Uuid,
+) -> Result<(), TeamError> {
+ sqlx::query!(
+ r#"
+ DELETE FROM team_invite_link
+ WHERE team_id = $1
+ "#,
+ team_id,
+ )
+ .execute(pool)
+ .await?;
+
+ Ok(())
+}
+
+pub(super) async fn get_team_by_invite_link(
+ pool: &PgPool,
+ token: &TeamInviteLinkToken,
+) -> Result<Option<TeamInviteLinkTeam>, TeamError> {
+ Ok(sqlx::query_as!(
+ TeamInviteLinkTeam,
+ r#"
+ SELECT t.id AS team_id, t.name AS team_name
+ FROM team_invite_link l
+ JOIN team t ON t.id = l.team_id
+ WHERE l.token = $1
+ "#,
+ token.as_uuid(),
+ )
+ .fetch_optional(pool)
+ .await?)
+}
diff --git a/crates/teams/src/outbound/team_repo/test.rs b/crates/teams/src/outbound/team_repo/test.rs
index fe1b71092e..2428f26131 100644
--- a/crates/teams/src/outbound/team_repo/test.rs
+++ b/crates/teams/src/outbound/team_repo/test.rs
@@ -7,6 +7,7 @@ use super::*;
use crate::domain::model::SeatPlan;
mod delete_team;
+mod invite_link;
#[sqlx::test(
migrator = "MACRO_DB_MIGRATIONS",
diff --git a/crates/teams/src/outbound/team_repo/test/invite_link.rs b/crates/teams/src/outbound/team_repo/test/invite_link.rs
new file mode 100644
index 0000000000..0482f6f129
--- /dev/null
+++ b/crates/teams/src/outbound/team_repo/test/invite_link.rs
@@ -0,0 +1,50 @@
+use uuid::Uuid;
+
+use super::*;
+use crate::domain::model::{TeamInviteLinkTeam, TeamInviteLinkToken};
+
+const TEAM_1: Uuid = Uuid::from_u128(0x11111111_1111_1111_1111_111111111111);
+const TEAM_2: Uuid = Uuid::from_u128(0x22222222_2222_2222_2222_222222222222);
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("teams"))
+)]
+async fn invite_links_are_set_reset_and_turned_off_per_team(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool);
+
+ assert_eq!(team_repo.get_team_invite_link(&TEAM_1).await?, None);
+
+ let first = TeamInviteLinkToken::generate();
+ team_repo.set_team_invite_link(&TEAM_1, &first).await?;
+ assert_eq!(team_repo.get_team_invite_link(&TEAM_1).await?, Some(first));
+ assert_eq!(
+ team_repo.get_team_by_invite_link(&first).await?,
+ Some(TeamInviteLinkTeam {
+ team_id: TEAM_1,
+ team_name: "team1".to_string(),
+ })
+ );
+
+ // Resetting replaces the token, so the old link stops resolving.
+ let reset = TeamInviteLinkToken::generate();
+ team_repo.set_team_invite_link(&TEAM_1, &reset).await?;
+ assert_eq!(team_repo.get_team_invite_link(&TEAM_1).await?, Some(reset));
+ assert_eq!(team_repo.get_team_by_invite_link(&first).await?, None);
+
+ // Another team's link is independent.
+ let other = TeamInviteLinkToken::generate();
+ team_repo.set_team_invite_link(&TEAM_2, &other).await?;
+
+ team_repo.delete_team_invite_link(&TEAM_1).await?;
+ assert_eq!(team_repo.get_team_invite_link(&TEAM_1).await?, None);
+ assert_eq!(team_repo.get_team_by_invite_link(&reset).await?, None);
+ assert_eq!(team_repo.get_team_invite_link(&TEAM_2).await?, Some(other));
+
+ // Turning off a team with no link is a no-op.
+ team_repo.delete_team_invite_link(&TEAM_1).await?;
+
+ Ok(())
+}
diff --git a/docs/agent-guide/settings.md b/docs/agent-guide/settings.md
index e9326a88e6..d4670c3c03 100644
--- a/docs/agent-guide/settings.md
+++ b/docs/agent-guide/settings.md
@@ -135,6 +135,17 @@ enterprise teams retain their billing bypass.
On a local stack started with `--no-doppler`, verify free-team creation from a
fresh passwordless signup. It must work without Stripe credentials.
+The invite dialog (**Invite** on **Team → Members**, or **Invite your team**)
+starts with the team's **Invite link**: **Create link** makes one and copies it,
+**Copy link** copies it after that. Anyone signed in who opens
+`/app/team-invite?link=<token>` sees **Join <team>** and joins as a member with
+the same billing and channel effects as an emailed invite; users already on
+another team are told to leave it first. Team admins and owners also see
+**Reset link** (the old link stops working and a new one is copied) and
+**Turn off**, each behind a confirmation. Anyone who may invite can copy the
+link or create the first one. Below it, **Invite by email** sends invitations
+as before.
+
Under **Team → Members** (**Invite settings**), owners/admins can turn
**Auto-join on domain** off and can restrict invitations to admins with
**Members can invite**. These controls still apply.
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/README.md b/packages/sdk-docs/reference/generated/auth/types.gen/README.md
index 70a317d1df..3a742d8fe0 100644
--- a/packages/sdk-docs/reference/generated/auth/types.gen/README.md
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/README.md
@@ -58,6 +58,7 @@
- [CreateCheckoutSessionV2Request](type-aliases/CreateCheckoutSessionV2Request.md)
- [CreateCheckoutSessionV2Response](type-aliases/CreateCheckoutSessionV2Response.md)
- [CreateCheckoutSessionV2Responses](type-aliases/CreateCheckoutSessionV2Responses.md)
+- [CreatedTeamInviteLinkResponse](type-aliases/CreatedTeamInviteLinkResponse.md)
- [CreateGtmInviteLinkData](type-aliases/CreateGtmInviteLinkData.md)
- [CreateGtmInviteLinkError](type-aliases/CreateGtmInviteLinkError.md)
- [CreateGtmInviteLinkErrors](type-aliases/CreateGtmInviteLinkErrors.md)
@@ -84,6 +85,11 @@
- [CreateTeamData](type-aliases/CreateTeamData.md)
- [CreateTeamError](type-aliases/CreateTeamError.md)
- [CreateTeamErrors](type-aliases/CreateTeamErrors.md)
+- [CreateTeamInviteLinkData](type-aliases/CreateTeamInviteLinkData.md)
+- [CreateTeamInviteLinkError](type-aliases/CreateTeamInviteLinkError.md)
+- [CreateTeamInviteLinkErrors](type-aliases/CreateTeamInviteLinkErrors.md)
+- [CreateTeamInviteLinkResponse](type-aliases/CreateTeamInviteLinkResponse.md)
+- [CreateTeamInviteLinkResponses](type-aliases/CreateTeamInviteLinkResponses.md)
- [CreateTeamRequest](type-aliases/CreateTeamRequest.md)
- [CreateTeamResponse](type-aliases/CreateTeamResponse.md)
- [CreateTeamResponses](type-aliases/CreateTeamResponses.md)
@@ -109,6 +115,11 @@
- [DeleteTeamInviteHandlerError](type-aliases/DeleteTeamInviteHandlerError.md)
- [DeleteTeamInviteHandlerErrors](type-aliases/DeleteTeamInviteHandlerErrors.md)
- [DeleteTeamInviteHandlerResponses](type-aliases/DeleteTeamInviteHandlerResponses.md)
+- [DeleteTeamInviteLinkData](type-aliases/DeleteTeamInviteLinkData.md)
+- [DeleteTeamInviteLinkError](type-aliases/DeleteTeamInviteLinkError.md)
+- [DeleteTeamInviteLinkErrors](type-aliases/DeleteTeamInviteLinkErrors.md)
+- [DeleteTeamInviteLinkResponse](type-aliases/DeleteTeamInviteLinkResponse.md)
+- [DeleteTeamInviteLinkResponses](type-aliases/DeleteTeamInviteLinkResponses.md)
- [DeleteTeamResponses](type-aliases/DeleteTeamResponses.md)
- [DeleteUserData](type-aliases/DeleteUserData.md)
- [DeleteUserError](type-aliases/DeleteUserError.md)
@@ -191,9 +202,19 @@
- [GetSubscriptionStatusErrors](type-aliases/GetSubscriptionStatusErrors.md)
- [GetSubscriptionStatusResponse](type-aliases/GetSubscriptionStatusResponse.md)
- [GetSubscriptionStatusResponses](type-aliases/GetSubscriptionStatusResponses.md)
+- [GetTeamByInviteLinkData](type-aliases/GetTeamByInviteLinkData.md)
+- [GetTeamByInviteLinkError](type-aliases/GetTeamByInviteLinkError.md)
+- [GetTeamByInviteLinkErrors](type-aliases/GetTeamByInviteLinkErrors.md)
+- [GetTeamByInviteLinkResponse](type-aliases/GetTeamByInviteLinkResponse.md)
+- [GetTeamByInviteLinkResponses](type-aliases/GetTeamByInviteLinkResponses.md)
- [GetTeamData](type-aliases/GetTeamData.md)
- [GetTeamError](type-aliases/GetTeamError.md)
- [GetTeamErrors](type-aliases/GetTeamErrors.md)
+- [GetTeamInviteLinkData](type-aliases/GetTeamInviteLinkData.md)
+- [GetTeamInviteLinkError](type-aliases/GetTeamInviteLinkError.md)
+- [GetTeamInviteLinkErrors](type-aliases/GetTeamInviteLinkErrors.md)
+- [GetTeamInviteLinkResponse](type-aliases/GetTeamInviteLinkResponse.md)
+- [GetTeamInviteLinkResponses](type-aliases/GetTeamInviteLinkResponses.md)
- [GetTeamInvitesData](type-aliases/GetTeamInvitesData.md)
- [GetTeamInvitesError](type-aliases/GetTeamInvitesError.md)
- [GetTeamInvitesErrors](type-aliases/GetTeamInvitesErrors.md)
@@ -305,6 +326,12 @@
- [InviteToTeamErrors](type-aliases/InviteToTeamErrors.md)
- [InviteToTeamRequest](type-aliases/InviteToTeamRequest.md)
- [InviteToTeamResponses](type-aliases/InviteToTeamResponses.md)
+- [JoinTeamByInviteLinkData](type-aliases/JoinTeamByInviteLinkData.md)
+- [JoinTeamByInviteLinkError](type-aliases/JoinTeamByInviteLinkError.md)
+- [JoinTeamByInviteLinkErrors](type-aliases/JoinTeamByInviteLinkErrors.md)
+- [JoinTeamByInviteLinkResponse](type-aliases/JoinTeamByInviteLinkResponse.md)
+- [JoinTeamByInviteLinkResponse2](type-aliases/JoinTeamByInviteLinkResponse2.md)
+- [JoinTeamByInviteLinkResponses](type-aliases/JoinTeamByInviteLinkResponses.md)
- [JoinTeamData](type-aliases/JoinTeamData.md)
- [JoinTeamError](type-aliases/JoinTeamError.md)
- [JoinTeamErrors](type-aliases/JoinTeamErrors.md)
@@ -520,6 +547,10 @@
- [SubscriptionStatus](type-aliases/SubscriptionStatus.md)
- [Team](type-aliases/Team.md)
- [TeamInviteDetails](type-aliases/TeamInviteDetails.md)
+- [TeamInviteLinkResponse](type-aliases/TeamInviteLinkResponse.md)
+- [TeamInviteLinkTeam](type-aliases/TeamInviteLinkTeam.md)
+- [TeamInviteLinkToken](type-aliases/TeamInviteLinkToken.md)
+- [TeamInviteLinkTokenRequest](type-aliases/TeamInviteLinkTokenRequest.md)
- [TeamInvitesResponse](type-aliases/TeamInvitesResponse.md)
- [TeamMember](type-aliases/TeamMember.md)
- [TeamPlan](type-aliases/TeamPlan.md)
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkData.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkData.md
new file mode 100644
index 0000000000..573851e718
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkData.md
@@ -0,0 +1,12 @@
+# Type Alias: CreateTeamInviteLinkData
+
+> **CreateTeamInviteLinkData** = \{ `body?`: `never`; `path?`: `never`; `query?`: `never`; `url`: `"/team/invite-link"`; \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-body"></a> `body?` | `never` |
+| <a id="property-path"></a> `path?` | `never` |
+| <a id="property-query"></a> `query?` | `never` |
+| <a id="property-url"></a> `url` | `"/team/invite-link"` |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkError.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkError.md
new file mode 100644
index 0000000000..14fc0ca534
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkError.md
@@ -0,0 +1,3 @@
+# Type Alias: CreateTeamInviteLinkError
+
+> **CreateTeamInviteLinkError** = [`CreateTeamInviteLinkErrors`](CreateTeamInviteLinkErrors.md)\[keyof [`CreateTeamInviteLinkErrors`](CreateTeamInviteLinkErrors.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkErrors.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkErrors.md
new file mode 100644
index 0000000000..73b4bd28ef
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkErrors.md
@@ -0,0 +1,11 @@
+# Type Alias: CreateTeamInviteLinkErrors
+
+> **CreateTeamInviteLinkErrors** = \{ `401`: [`ErrorResponse`](ErrorResponse.md); `403`: [`ErrorResponse`](ErrorResponse.md); `500`: [`ErrorResponse`](ErrorResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-401"></a> `401` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-403"></a> `403` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-500"></a> `500` | [`ErrorResponse`](ErrorResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkResponse.md
new file mode 100644
index 0000000000..8a33d9bdd8
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkResponse.md
@@ -0,0 +1,3 @@
+# Type Alias: CreateTeamInviteLinkResponse
+
+> **CreateTeamInviteLinkResponse** = [`CreateTeamInviteLinkResponses`](CreateTeamInviteLinkResponses.md)\[keyof [`CreateTeamInviteLinkResponses`](CreateTeamInviteLinkResponses.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkResponses.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkResponses.md
new file mode 100644
index 0000000000..49ba2bf6de
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreateTeamInviteLinkResponses.md
@@ -0,0 +1,9 @@
+# Type Alias: CreateTeamInviteLinkResponses
+
+> **CreateTeamInviteLinkResponses** = \{ `201`: [`CreatedTeamInviteLinkResponse`](CreatedTeamInviteLinkResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-201"></a> `201` | [`CreatedTeamInviteLinkResponse`](CreatedTeamInviteLinkResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreatedTeamInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreatedTeamInviteLinkResponse.md
new file mode 100644
index 0000000000..e26694a9fd
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/CreatedTeamInviteLinkResponse.md
@@ -0,0 +1,11 @@
+# Type Alias: CreatedTeamInviteLinkResponse
+
+> **CreatedTeamInviteLinkResponse** = \{ `token`: [`TeamInviteLinkToken`](TeamInviteLinkToken.md); \}
+
+A newly created team invite link.
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| <a id="property-token"></a> `token` | [`TeamInviteLinkToken`](TeamInviteLinkToken.md) | The new link's token. Any previous link stops working. |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkData.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkData.md
new file mode 100644
index 0000000000..55839b8136
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkData.md
@@ -0,0 +1,12 @@
+# Type Alias: DeleteTeamInviteLinkData
+
+> **DeleteTeamInviteLinkData** = \{ `body?`: `never`; `path?`: `never`; `query?`: `never`; `url`: `"/team/invite-link"`; \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-body"></a> `body?` | `never` |
+| <a id="property-path"></a> `path?` | `never` |
+| <a id="property-query"></a> `query?` | `never` |
+| <a id="property-url"></a> `url` | `"/team/invite-link"` |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkError.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkError.md
new file mode 100644
index 0000000000..a75119ba23
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkError.md
@@ -0,0 +1,3 @@
+# Type Alias: DeleteTeamInviteLinkError
+
+> **DeleteTeamInviteLinkError** = [`DeleteTeamInviteLinkErrors`](DeleteTeamInviteLinkErrors.md)\[keyof [`DeleteTeamInviteLinkErrors`](DeleteTeamInviteLinkErrors.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkErrors.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkErrors.md
new file mode 100644
index 0000000000..88d8f1f9d7
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkErrors.md
@@ -0,0 +1,11 @@
+# Type Alias: DeleteTeamInviteLinkErrors
+
+> **DeleteTeamInviteLinkErrors** = \{ `401`: [`ErrorResponse`](ErrorResponse.md); `403`: [`ErrorResponse`](ErrorResponse.md); `500`: [`ErrorResponse`](ErrorResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-401"></a> `401` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-403"></a> `403` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-500"></a> `500` | [`ErrorResponse`](ErrorResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkResponse.md
new file mode 100644
index 0000000000..eecf9a6674
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkResponse.md
@@ -0,0 +1,3 @@
+# Type Alias: DeleteTeamInviteLinkResponse
+
+> **DeleteTeamInviteLinkResponse** = [`DeleteTeamInviteLinkResponses`](DeleteTeamInviteLinkResponses.md)\[keyof [`DeleteTeamInviteLinkResponses`](DeleteTeamInviteLinkResponses.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkResponses.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkResponses.md
new file mode 100644
index 0000000000..924cfedb07
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/DeleteTeamInviteLinkResponses.md
@@ -0,0 +1,9 @@
+# Type Alias: DeleteTeamInviteLinkResponses
+
+> **DeleteTeamInviteLinkResponses** = \{ `204`: `void`; \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-204"></a> `204` | `void` |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkData.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkData.md
new file mode 100644
index 0000000000..12ad8a4d8d
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkData.md
@@ -0,0 +1,12 @@
+# Type Alias: GetTeamByInviteLinkData
+
+> **GetTeamByInviteLinkData** = \{ `body`: [`TeamInviteLinkTokenRequest`](TeamInviteLinkTokenRequest.md); `path?`: `never`; `query?`: `never`; `url`: `"/team/invite-link/team"`; \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-body"></a> `body` | [`TeamInviteLinkTokenRequest`](TeamInviteLinkTokenRequest.md) |
+| <a id="property-path"></a> `path?` | `never` |
+| <a id="property-query"></a> `query?` | `never` |
+| <a id="property-url"></a> `url` | `"/team/invite-link/team"` |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkError.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkError.md
new file mode 100644
index 0000000000..af908066f6
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkError.md
@@ -0,0 +1,3 @@
+# Type Alias: GetTeamByInviteLinkError
+
+> **GetTeamByInviteLinkError** = [`GetTeamByInviteLinkErrors`](GetTeamByInviteLinkErrors.md)\[keyof [`GetTeamByInviteLinkErrors`](GetTeamByInviteLinkErrors.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkErrors.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkErrors.md
new file mode 100644
index 0000000000..9774fc74ea
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkErrors.md
@@ -0,0 +1,11 @@
+# Type Alias: GetTeamByInviteLinkErrors
+
+> **GetTeamByInviteLinkErrors** = \{ `401`: [`ErrorResponse`](ErrorResponse.md); `404`: [`ErrorResponse`](ErrorResponse.md); `500`: [`ErrorResponse`](ErrorResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-401"></a> `401` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-404"></a> `404` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-500"></a> `500` | [`ErrorResponse`](ErrorResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkResponse.md
new file mode 100644
index 0000000000..caef337433
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkResponse.md
@@ -0,0 +1,3 @@
+# Type Alias: GetTeamByInviteLinkResponse
+
+> **GetTeamByInviteLinkResponse** = [`GetTeamByInviteLinkResponses`](GetTeamByInviteLinkResponses.md)\[keyof [`GetTeamByInviteLinkResponses`](GetTeamByInviteLinkResponses.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkResponses.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkResponses.md
new file mode 100644
index 0000000000..830e8a72b6
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamByInviteLinkResponses.md
@@ -0,0 +1,9 @@
+# Type Alias: GetTeamByInviteLinkResponses
+
+> **GetTeamByInviteLinkResponses** = \{ `200`: [`TeamInviteLinkTeam`](TeamInviteLinkTeam.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-200"></a> `200` | [`TeamInviteLinkTeam`](TeamInviteLinkTeam.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkData.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkData.md
new file mode 100644
index 0000000000..2fb09f8cbc
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkData.md
@@ -0,0 +1,12 @@
+# Type Alias: GetTeamInviteLinkData
+
+> **GetTeamInviteLinkData** = \{ `body?`: `never`; `path?`: `never`; `query?`: `never`; `url`: `"/team/invite-link"`; \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-body"></a> `body?` | `never` |
+| <a id="property-path"></a> `path?` | `never` |
+| <a id="property-query"></a> `query?` | `never` |
+| <a id="property-url"></a> `url` | `"/team/invite-link"` |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkError.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkError.md
new file mode 100644
index 0000000000..8ec32aa0d9
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkError.md
@@ -0,0 +1,3 @@
+# Type Alias: GetTeamInviteLinkError
+
+> **GetTeamInviteLinkError** = [`GetTeamInviteLinkErrors`](GetTeamInviteLinkErrors.md)\[keyof [`GetTeamInviteLinkErrors`](GetTeamInviteLinkErrors.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkErrors.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkErrors.md
new file mode 100644
index 0000000000..cd27dfa2c8
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkErrors.md
@@ -0,0 +1,11 @@
+# Type Alias: GetTeamInviteLinkErrors
+
+> **GetTeamInviteLinkErrors** = \{ `401`: [`ErrorResponse`](ErrorResponse.md); `403`: [`ErrorResponse`](ErrorResponse.md); `500`: [`ErrorResponse`](ErrorResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-401"></a> `401` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-403"></a> `403` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-500"></a> `500` | [`ErrorResponse`](ErrorResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkResponse.md
new file mode 100644
index 0000000000..c1a71de991
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkResponse.md
@@ -0,0 +1,3 @@
+# Type Alias: GetTeamInviteLinkResponse
+
+> **GetTeamInviteLinkResponse** = [`GetTeamInviteLinkResponses`](GetTeamInviteLinkResponses.md)\[keyof [`GetTeamInviteLinkResponses`](GetTeamInviteLinkResponses.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkResponses.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkResponses.md
new file mode 100644
index 0000000000..90bd614d39
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/GetTeamInviteLinkResponses.md
@@ -0,0 +1,9 @@
+# Type Alias: GetTeamInviteLinkResponses
+
+> **GetTeamInviteLinkResponses** = \{ `200`: [`TeamInviteLinkResponse`](TeamInviteLinkResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-200"></a> `200` | [`TeamInviteLinkResponse`](TeamInviteLinkResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkData.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkData.md
new file mode 100644
index 0000000000..5389ae92e1
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkData.md
@@ -0,0 +1,12 @@
+# Type Alias: JoinTeamByInviteLinkData
+
+> **JoinTeamByInviteLinkData** = \{ `body`: [`TeamInviteLinkTokenRequest`](TeamInviteLinkTokenRequest.md); `path?`: `never`; `query?`: `never`; `url`: `"/team/invite-link/join"`; \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-body"></a> `body` | [`TeamInviteLinkTokenRequest`](TeamInviteLinkTokenRequest.md) |
+| <a id="property-path"></a> `path?` | `never` |
+| <a id="property-query"></a> `query?` | `never` |
+| <a id="property-url"></a> `url` | `"/team/invite-link/join"` |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkError.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkError.md
new file mode 100644
index 0000000000..2e17db2ae8
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkError.md
@@ -0,0 +1,3 @@
+# Type Alias: JoinTeamByInviteLinkError
+
+> **JoinTeamByInviteLinkError** = [`JoinTeamByInviteLinkErrors`](JoinTeamByInviteLinkErrors.md)\[keyof [`JoinTeamByInviteLinkErrors`](JoinTeamByInviteLinkErrors.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkErrors.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkErrors.md
new file mode 100644
index 0000000000..baae3f97ae
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkErrors.md
@@ -0,0 +1,12 @@
+# Type Alias: JoinTeamByInviteLinkErrors
+
+> **JoinTeamByInviteLinkErrors** = \{ `401`: [`ErrorResponse`](ErrorResponse.md); `404`: [`ErrorResponse`](ErrorResponse.md); `409`: [`ErrorResponse`](ErrorResponse.md); `500`: [`ErrorResponse`](ErrorResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-401"></a> `401` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-404"></a> `404` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-409"></a> `409` | [`ErrorResponse`](ErrorResponse.md) |
+| <a id="property-500"></a> `500` | [`ErrorResponse`](ErrorResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponse.md
new file mode 100644
index 0000000000..7178b5bfa7
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponse.md
@@ -0,0 +1,12 @@
+# Type Alias: JoinTeamByInviteLinkResponse
+
+> **JoinTeamByInviteLinkResponse** = \{ `already_member`: `boolean`; `team_id`: `string`; \}
+
+The result of opening a team invite link.
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| <a id="property-already_member"></a> `already_member` | `boolean` | True when the user was already on the team and nothing changed. |
+| <a id="property-team_id"></a> `team_id` | `string` | The team the link joins. |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponse2.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponse2.md
new file mode 100644
index 0000000000..9873c2d981
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponse2.md
@@ -0,0 +1,3 @@
+# Type Alias: JoinTeamByInviteLinkResponse2
+
+> **JoinTeamByInviteLinkResponse2** = [`JoinTeamByInviteLinkResponses`](JoinTeamByInviteLinkResponses.md)\[keyof [`JoinTeamByInviteLinkResponses`](JoinTeamByInviteLinkResponses.md)\]
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponses.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponses.md
new file mode 100644
index 0000000000..c86c337ef6
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/JoinTeamByInviteLinkResponses.md
@@ -0,0 +1,9 @@
+# Type Alias: JoinTeamByInviteLinkResponses
+
+> **JoinTeamByInviteLinkResponses** = \{ `200`: [`JoinTeamByInviteLinkResponse`](JoinTeamByInviteLinkResponse.md); \}
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-200"></a> `200` | [`JoinTeamByInviteLinkResponse`](JoinTeamByInviteLinkResponse.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkResponse.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkResponse.md
new file mode 100644
index 0000000000..918564f27c
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkResponse.md
@@ -0,0 +1,11 @@
+# Type Alias: TeamInviteLinkResponse
+
+> **TeamInviteLinkResponse** = \{ `token?`: `null` \| [`TeamInviteLinkToken`](TeamInviteLinkToken.md); \}
+
+The caller's team invite link.
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| <a id="property-token"></a> `token?` | `null` \| [`TeamInviteLinkToken`](TeamInviteLinkToken.md) |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkTeam.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkTeam.md
new file mode 100644
index 0000000000..eeddb8b3c2
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkTeam.md
@@ -0,0 +1,12 @@
+# Type Alias: TeamInviteLinkTeam
+
+> **TeamInviteLinkTeam** = \{ `team_id`: `string`; `team_name`: `string`; \}
+
+The team an invite link joins, shown before the user accepts.
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| <a id="property-team_id"></a> `team_id` | `string` | Id of the team the link joins. |
+| <a id="property-team_name"></a> `team_name` | `string` | Name of the team the link joins. |
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkToken.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkToken.md
new file mode 100644
index 0000000000..1204442258
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkToken.md
@@ -0,0 +1,9 @@
+# Type Alias: TeamInviteLinkToken
+
+> **TeamInviteLinkToken** = `string`
+
+The secret in a team's shareable invite link.
+
+Anyone signed in who holds the token can join the team, so it is a random
+value rather than a time-ordered id, and an admin resetting the link
+replaces it.
diff --git a/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkTokenRequest.md b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkTokenRequest.md
new file mode 100644
index 0000000000..ac60893546
--- /dev/null
+++ b/packages/sdk-docs/reference/generated/auth/types.gen/type-aliases/TeamInviteLinkTokenRequest.md
@@ -0,0 +1,12 @@
+# Type Alias: TeamInviteLinkTokenRequest
+
+> **TeamInviteLinkTokenRequest** = \{ `token`: [`TeamInviteLinkToken`](TeamInviteLinkToken.md); \}
+
+Identifies an invite link. The token travels in the body, not the path, so
+request spans and access logs that record the path never see it.
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| <a id="property-token"></a> `token` | [`TeamInviteLinkToken`](TeamInviteLinkToken.md) | The invite link's token. |
diff --git a/packages/sdk/generated/auth/index.ts b/packages/sdk/generated/auth/index.ts
index 6b7dd1ea0a..f761d76bcd 100644
--- a/packages/sdk/generated/auth/index.ts
+++ b/packages/sdk/generated/auth/index.ts
@@ -1,4 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export { type Options, Sdk } from './sdk.gen';
-export type { AbGroup, AiBillingErrorBody, AppleLoginData, AppleLoginError, AppleLoginErrors, AppleLoginRequest, AppleLoginResponse, AppleLoginResponses, AutoReloadDefaults, AutoReloadMonthlyBudget, AutoReloadSnapshot, CancelCodexLoginData, CancelCodexLoginResponse, CancelCodexLoginResponses, ChangePlanData, ChangePlanError, ChangePlanErrors, ChangePlanRequest, ChangePlanResponse, ChangePlanResponse2, ChangePlanResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusError, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponse, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusError, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponse, CheckGmailLinkStatusResponses, CheckoutSessionMetadata, CheckoutSessionV2Response, ClientOptions, CodexConfigRequest, CodexConnectionStatus, CodexEnvironment, CodexEnvironmentRepository, CodexLoginPoll, CodexLoginStart, CodexLoginState, ConfigureCodexData, ConfigureCodexResponse, ConfigureCodexResponses, CreateAccountMergeRequest, CreateAiCreditCheckoutData, CreateAiCreditCheckoutError, CreateAiCreditCheckoutErrors, CreateAiCreditCheckoutResponse, CreateAiCreditCheckoutResponses, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Error, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Request, CreateCheckoutSessionV2Response, CreateCheckoutSessionV2Responses, CreateGtmInviteLinkData, CreateGtmInviteLinkError, CreateGtmInviteLinkErrors, CreateGtmInviteLinkRequest, CreateGtmInviteLinkResponse, CreateGtmInviteLinkResponses, CreateInProgressLinkData, CreateInProgressLinkError, CreateInProgressLinkErrors, CreateInProgressLinkResponse, CreateInProgressLinkResponse2, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestError, CreateMergeRequestErrors, CreateMergeRequestResponse, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionError, CreatePortalSessionErrors, CreatePortalSessionRequest, CreatePortalSessionResponse, CreatePortalSessionResponses, CreateTeamData, CreateTeamError, CreateTeamErrors, CreateTeamRequest, CreateTeamResponse, CreateTeamResponses, CreditCheckoutRequestBody, CreditCheckoutResponse, CursorApiKeyStatus, CursorModelOption, CursorModelsResponse, DeleteCursorApiKeyData, DeleteCursorApiKeyError, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponse, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkError, DeleteGithubLinkErrors, DeleteGithubLinkResponse, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamError, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerError, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamResponses, DeleteUserData, DeleteUserError, DeleteUserErrors, DeleteUserResponse, DeleteUserResponses, DenyReason, DisconnectCodexData, DisconnectCodexResponse, DisconnectCodexResponses, EmailConnectionProviders, EmailConnectionProvidersData, EmailConnectionProvidersError, EmailConnectionProvidersErrors, EmailConnectionProvidersResponse, EmailConnectionProvidersResponses, EmptyResponse, EnrichedGithubPullRequest, EnrichGithubPullRequestsData, EnrichGithubPullRequestsError, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsProxyRequest, EnrichGithubPullRequestsResponse, EnrichGithubPullRequestsResponse2, EnrichGithubPullRequestsResponses, ErrorResponse, GenerateEmailLinkData, GenerateEmailLinkError, GenerateEmailLinkErrors, GenerateEmailLinkRequest, GenerateEmailLinkResponse, GenerateEmailLinkResponses, GenericSuccessResponse, GetAiBillingPlansData, GetAiBillingPlansResponse, GetAiBillingPlansResponses, GetAiBillingSummaryData, GetAiBillingSummaryError, GetAiBillingSummaryErrors, GetAiBillingSummaryResponse, GetAiBillingSummaryResponses, GetCodexConnectionData, GetCodexConnectionResponse, GetCodexConnectionResponses, GetCursorApiKeyData, GetCursorApiKeyError, GetCursorApiKeyErrors, GetCursorApiKeyResponse, GetCursorApiKeyResponses, GetGithubPullRequestMergeabilityData, GetGithubPullRequestMergeabilityError, GetGithubPullRequestMergeabilityErrors, GetGithubPullRequestMergeabilityResponse, GetGithubPullRequestMergeabilityResponses, GetGtmInviteOfferData, GetGtmInviteOfferError, GetGtmInviteOfferErrors, GetGtmInviteOfferResponse, GetGtmInviteOfferResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsError, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponse, GetLegacyUserPermissionsResponse2, GetLegacyUserPermissionsResponses, GetNamesWithEmailRequestBody, GetPermissionsData, GetPermissionsError, GetPermissionsErrors, GetPermissionsResponse, GetPermissionsResponses, GetProfilePicturesRequestBody, GetReferralCodeData, GetReferralCodeError, GetReferralCodeErrors, GetReferralCodeResponse, GetReferralCodeResponses, GetSubscriptionStatusData, GetSubscriptionStatusError, GetSubscriptionStatusErrors, GetSubscriptionStatusResponse, GetSubscriptionStatusResponses, GetTeamData, GetTeamError, GetTeamErrors, GetTeamInvitesData, GetTeamInvitesError, GetTeamInvitesErrors, GetTeamInvitesResponse, GetTeamInvitesResponses, GetTeamResponse, GetTeamResponses, GetTrialEligibilityData, GetTrialEligibilityError, GetTrialEligibilityErrors, GetTrialEligibilityResponse, GetTrialEligibilityResponses, GetUserInfo, GetUserInfoData, GetUserInfoError, GetUserInfoErrors, GetUserInfoResponse, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesError, GetUserInvitesErrors, GetUserInvitesResponse, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsError, GetUserLinkExistsErrors, GetUserLinkExistsResponse, GetUserLinkExistsResponses, GetUserNameData, GetUserNameError, GetUserNameErrors, GetUserNameResponse, GetUserNameResponses, GetUserNamesData, GetUserNamesError, GetUserNamesErrors, GetUserNamesResponse, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailError, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponse, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationError, GetUserOrganizationErrors, GetUserOrganizationResponse, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsError, GetUserPermissionsErrors, GetUserPermissionsResponse, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaError, GetUserQuotaErrors, GetUserQuotaResponse, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsError, GetUserTeamsErrors, GetUserTeamsResponse, GetUserTeamsResponses, GithubLinkStatusResponse, GithubMergeMethod, GithubPullRequestCheckRun, GithubPullRequestComment, GithubPullRequestLabel, GithubPullRequestMergeability, GithubPullRequestMergeabilityEntry, GithubPullRequestMergeabilityRequest, GithubPullRequestMergeabilityResponse, GithubPullRequestNumber, GithubPullRequestRef, GithubPullRequestReview, GithubPullRequestReviewState, GithubPullRequestStatus, GithubPullRequestUser, GmailLinkStatusResponse, GtmInviteLink, GtmInviteLinkList, GtmInviteLinkStatus, GtmInviteOffer, GtmInviteOfferStatus, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkError, InitGithubLinkErrors, InitGithubLinkResponse, InitGithubLinkResponse2, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkError, InitGmailLinkErrors, InitGmailLinkResponse, InitGmailLinkResponse2, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkError, InitOutlookLinkErrors, InitOutlookLinkResponse, InitOutlookLinkResponse2, InitOutlookLinkResponses, InviteEntry, InviteToTeamData, InviteToTeamError, InviteToTeamErrors, InviteToTeamRequest, InviteToTeamResponses, JoinTeamData, JoinTeamError, JoinTeamErrors, JoinTeamResponses, LinkShare, ListCodexEnvironmentsData, ListCodexEnvironmentsResponse, ListCodexEnvironmentsResponses, ListCursorModelsData, ListCursorModelsError, ListCursorModelsErrors, ListCursorModelsResponse, ListCursorModelsResponses, ListGtmInviteLinksData, ListGtmInviteLinksError, ListGtmInviteLinksErrors, ListGtmInviteLinksResponse, ListGtmInviteLinksResponses, LogoutData, LogoutResponse, LogoutResponses, MacroApiTokenData, MacroApiTokenError, MacroApiTokenErrors, MacroApiTokenResponse, MacroApiTokenResponse2, MacroApiTokenResponses, MergeGithubPullRequestData, MergeGithubPullRequestError, MergeGithubPullRequestErrors, MergeGithubPullRequestRequest, MergeGithubPullRequestResponse, MergeGithubPullRequestResponse2, MergeGithubPullRequestResponses, Oauth2CallbackData, Oauth2CallbackError, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectError, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackError, PasswordlessCallbackErrors, PasswordlessCallbackResponse, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginError, PasswordlessLoginErrors, PasswordlessLoginResponse, PasswordlessLoginResponses, PasswordlessRequest, PasswordlessStartedResponse, PasswordLoginData, PasswordLoginError, PasswordLoginErrors, PasswordLoginResponse, PasswordLoginResponses, PasswordRequest, PatchTeamCrmSettingsData, PatchTeamCrmSettingsError, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsRequest, PatchTeamCrmSettingsResponse, PatchTeamCrmSettingsResponse2, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamError, PatchTeamErrors, PatchTeamMemberPlanData, PatchTeamMemberPlanError, PatchTeamMemberPlanErrors, PatchTeamMemberPlanRequest, PatchTeamMemberPlanResponse, PatchTeamMemberPlanResponses, PatchTeamRequest, PatchTeamResponses, PatchTeamUserRole, PatchUserGroupData, PatchUserGroupError, PatchUserGroupErrors, PatchUserGroupRequest, PatchUserGroupResponse, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingError, PatchUserOnboardingErrors, PatchUserOnboardingRequest, PatchUserOnboardingResponse, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialError, PatchUserTutorialErrors, PatchUserTutorialRequest, PatchUserTutorialResponse, PatchUserTutorialResponses, Permission, PlanCatalogEntry, PlanCatalogResponse, PlanTier, PollCodexLoginData, PollCodexLoginResponse, PollCodexLoginResponses, PostGetNamesRequestBody, PostProfilePicturesData, PostProfilePicturesError, PostProfilePicturesErrors, PostProfilePicturesResponse, PostProfilePicturesResponses, ProfilePictureQueryParams, ProfilePictures, PublicGtmInviteLink, PutCursorApiKeyData, PutCursorApiKeyError, PutCursorApiKeyErrors, PutCursorApiKeyRequest, PutCursorApiKeyResponse, PutCursorApiKeyResponses, PutCursorDefaultModelData, PutCursorDefaultModelError, PutCursorDefaultModelErrors, PutCursorDefaultModelRequest, PutCursorDefaultModelResponse, PutCursorDefaultModelResponses, PutProfilePictureData, PutProfilePictureError, PutProfilePictureErrors, PutProfilePictureResponse, PutProfilePictureResponses, PutUserNameData, PutUserNameError, PutUserNameErrors, PutUserNameQueryParams, PutUserNameResponse, PutUserNameResponses, RedeemGtmInviteLinkData, RedeemGtmInviteLinkError, RedeemGtmInviteLinkErrors, RedeemGtmInviteLinkRequest, RedeemGtmInviteLinkResponse, RedeemGtmInviteLinkResponses, RefreshData, RefreshError, RefreshErrors, RefreshResponse, RefreshResponses, RejectInvitationData, RejectInvitationError, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamError, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailError, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailRequest, ResendFusionauthVerifyUserEmailResponse, ResendFusionauthVerifyUserEmailResponses, ResolveGtmInviteLinkData, ResolveGtmInviteLinkError, ResolveGtmInviteLinkErrors, ResolveGtmInviteLinkResponse, ResolveGtmInviteLinkResponses, RevokeGtmInviteLinkData, RevokeGtmInviteLinkError, RevokeGtmInviteLinkErrors, RevokeGtmInviteLinkResponse, RevokeGtmInviteLinkResponses, ScheduledSeatPlan, SeatPlan, SendInviteBody, SendMobileWelcomeEmailData, SendMobileWelcomeEmailError, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailRequest, SendMobileWelcomeEmailResponse, SendMobileWelcomeEmailResponse2, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeError, SendReferralCodeErrors, SendReferralCodeResponse, SendReferralCodeResponses, SessionCreationData, SessionCreationError, SessionCreationErrors, SessionCreationResponse, SessionCreationResponses, SessionLoginData, SessionLoginError, SessionLoginErrors, SessionLoginResponse, SessionLoginResponses, SetGithubPullRequestDraftData, SetGithubPullRequestDraftError, SetGithubPullRequestDraftErrors, SetGithubPullRequestDraftRequest, SetGithubPullRequestDraftResponse, SetGithubPullRequestDraftResponse2, SetGithubPullRequestDraftResponses, SsoLoginData, SsoLoginError, SsoLoginErrors, SsoLoginResponses, SsoRequiredResponse, StartCodexLoginData, StartCodexLoginResponse, StartCodexLoginResponses, StripeSessionResponse, SubscriptionStatus, Team, TeamInviteDetails, TeamInvitesResponse, TeamMember, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainResponse, ToggleNonAdminInvitesResponse, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainError, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponse, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesError, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponse, ToggleTeamNonAdminInvitesResponses, TrialEligibility, UpdateAiBillingAutoReloadData, UpdateAiBillingAutoReloadError, UpdateAiBillingAutoReloadErrors, UpdateAiBillingAutoReloadResponse, UpdateAiBillingAutoReloadResponses, UpdateAiBillingOverageData, UpdateAiBillingOverageError, UpdateAiBillingOverageErrors, UpdateAiBillingOverageResponse, UpdateAiBillingOverageResponses, UpdateAutoReloadRequest, UpdateOverageRequest, UsageSnapshot, UserLinkResponse, UserName, UserNames, UserOrganizationResponse, UserProfilePicture, UserQuota, UserTokensResponse, VerifyEmailLinkData, VerifyEmailLinkError, VerifyEmailLinkErrors, VerifyEmailLinkResponse, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailError, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponse, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestError, VerifyMergeRequestErrors, VerifyMergeRequestResponse, VerifyMergeRequestResponses } from './types.gen';
+export type { AbGroup, AiBillingErrorBody, AppleLoginData, AppleLoginError, AppleLoginErrors, AppleLoginRequest, AppleLoginResponse, AppleLoginResponses, AutoReloadDefaults, AutoReloadMonthlyBudget, AutoReloadSnapshot, CancelCodexLoginData, CancelCodexLoginResponse, CancelCodexLoginResponses, ChangePlanData, ChangePlanError, ChangePlanErrors, ChangePlanRequest, ChangePlanResponse, ChangePlanResponse2, ChangePlanResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusError, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponse, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusError, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponse, CheckGmailLinkStatusResponses, CheckoutSessionMetadata, CheckoutSessionV2Response, ClientOptions, CodexConfigRequest, CodexConnectionStatus, CodexEnvironment, CodexEnvironmentRepository, CodexLoginPoll, CodexLoginStart, CodexLoginState, ConfigureCodexData, ConfigureCodexResponse, ConfigureCodexResponses, CreateAccountMergeRequest, CreateAiCreditCheckoutData, CreateAiCreditCheckoutError, CreateAiCreditCheckoutErrors, CreateAiCreditCheckoutResponse, CreateAiCreditCheckoutResponses, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Error, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Request, CreateCheckoutSessionV2Response, CreateCheckoutSessionV2Responses, CreatedTeamInviteLinkResponse, CreateGtmInviteLinkData, CreateGtmInviteLinkError, CreateGtmInviteLinkErrors, CreateGtmInviteLinkRequest, CreateGtmInviteLinkResponse, CreateGtmInviteLinkResponses, CreateInProgressLinkData, CreateInProgressLinkError, CreateInProgressLinkErrors, CreateInProgressLinkResponse, CreateInProgressLinkResponse2, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestError, CreateMergeRequestErrors, CreateMergeRequestResponse, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionError, CreatePortalSessionErrors, CreatePortalSessionRequest, CreatePortalSessionResponse, CreatePortalSessionResponses, CreateTeamData, CreateTeamError, CreateTeamErrors, CreateTeamInviteLinkData, CreateTeamInviteLinkError, CreateTeamInviteLinkErrors, CreateTeamInviteLinkResponse, CreateTeamInviteLinkResponses, CreateTeamRequest, CreateTeamResponse, CreateTeamResponses, CreditCheckoutRequestBody, CreditCheckoutResponse, CursorApiKeyStatus, CursorModelOption, CursorModelsResponse, DeleteCursorApiKeyData, DeleteCursorApiKeyError, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponse, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkError, DeleteGithubLinkErrors, DeleteGithubLinkResponse, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamError, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerError, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamInviteLinkData, DeleteTeamInviteLinkError, DeleteTeamInviteLinkErrors, DeleteTeamInviteLinkResponse, DeleteTeamInviteLinkResponses, DeleteTeamResponses, DeleteUserData, DeleteUserError, DeleteUserErrors, DeleteUserResponse, DeleteUserResponses, DenyReason, DisconnectCodexData, DisconnectCodexResponse, DisconnectCodexResponses, EmailConnectionProviders, EmailConnectionProvidersData, EmailConnectionProvidersError, EmailConnectionProvidersErrors, EmailConnectionProvidersResponse, EmailConnectionProvidersResponses, EmptyResponse, EnrichedGithubPullRequest, EnrichGithubPullRequestsData, EnrichGithubPullRequestsError, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsProxyRequest, EnrichGithubPullRequestsResponse, EnrichGithubPullRequestsResponse2, EnrichGithubPullRequestsResponses, ErrorResponse, GenerateEmailLinkData, GenerateEmailLinkError, GenerateEmailLinkErrors, GenerateEmailLinkRequest, GenerateEmailLinkResponse, GenerateEmailLinkResponses, GenericSuccessResponse, GetAiBillingPlansData, GetAiBillingPlansResponse, GetAiBillingPlansResponses, GetAiBillingSummaryData, GetAiBillingSummaryError, GetAiBillingSummaryErrors, GetAiBillingSummaryResponse, GetAiBillingSummaryResponses, GetCodexConnectionData, GetCodexConnectionResponse, GetCodexConnectionResponses, GetCursorApiKeyData, GetCursorApiKeyError, GetCursorApiKeyErrors, GetCursorApiKeyResponse, GetCursorApiKeyResponses, GetGithubPullRequestMergeabilityData, GetGithubPullRequestMergeabilityError, GetGithubPullRequestMergeabilityErrors, GetGithubPullRequestMergeabilityResponse, GetGithubPullRequestMergeabilityResponses, GetGtmInviteOfferData, GetGtmInviteOfferError, GetGtmInviteOfferErrors, GetGtmInviteOfferResponse, GetGtmInviteOfferResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsError, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponse, GetLegacyUserPermissionsResponse2, GetLegacyUserPermissionsResponses, GetNamesWithEmailRequestBody, GetPermissionsData, GetPermissionsError, GetPermissionsErrors, GetPermissionsResponse, GetPermissionsResponses, GetProfilePicturesRequestBody, GetReferralCodeData, GetReferralCodeError, GetReferralCodeErrors, GetReferralCodeResponse, GetReferralCodeResponses, GetSubscriptionStatusData, GetSubscriptionStatusError, GetSubscriptionStatusErrors, GetSubscriptionStatusResponse, GetSubscriptionStatusResponses, GetTeamByInviteLinkData, GetTeamByInviteLinkError, GetTeamByInviteLinkErrors, GetTeamByInviteLinkResponse, GetTeamByInviteLinkResponses, GetTeamData, GetTeamError, GetTeamErrors, GetTeamInviteLinkData, GetTeamInviteLinkError, GetTeamInviteLinkErrors, GetTeamInviteLinkResponse, GetTeamInviteLinkResponses, GetTeamInvitesData, GetTeamInvitesError, GetTeamInvitesErrors, GetTeamInvitesResponse, GetTeamInvitesResponses, GetTeamResponse, GetTeamResponses, GetTrialEligibilityData, GetTrialEligibilityError, GetTrialEligibilityErrors, GetTrialEligibilityResponse, GetTrialEligibilityResponses, GetUserInfo, GetUserInfoData, GetUserInfoError, GetUserInfoErrors, GetUserInfoResponse, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesError, GetUserInvitesErrors, GetUserInvitesResponse, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsError, GetUserLinkExistsErrors, GetUserLinkExistsResponse, GetUserLinkExistsResponses, GetUserNameData, GetUserNameError, GetUserNameErrors, GetUserNameResponse, GetUserNameResponses, GetUserNamesData, GetUserNamesError, GetUserNamesErrors, GetUserNamesResponse, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailError, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponse, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationError, GetUserOrganizationErrors, GetUserOrganizationResponse, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsError, GetUserPermissionsErrors, GetUserPermissionsResponse, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaError, GetUserQuotaErrors, GetUserQuotaResponse, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsError, GetUserTeamsErrors, GetUserTeamsResponse, GetUserTeamsResponses, GithubLinkStatusResponse, GithubMergeMethod, GithubPullRequestCheckRun, GithubPullRequestComment, GithubPullRequestLabel, GithubPullRequestMergeability, GithubPullRequestMergeabilityEntry, GithubPullRequestMergeabilityRequest, GithubPullRequestMergeabilityResponse, GithubPullRequestNumber, GithubPullRequestRef, GithubPullRequestReview, GithubPullRequestReviewState, GithubPullRequestStatus, GithubPullRequestUser, GmailLinkStatusResponse, GtmInviteLink, GtmInviteLinkList, GtmInviteLinkStatus, GtmInviteOffer, GtmInviteOfferStatus, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkError, InitGithubLinkErrors, InitGithubLinkResponse, InitGithubLinkResponse2, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkError, InitGmailLinkErrors, InitGmailLinkResponse, InitGmailLinkResponse2, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkError, InitOutlookLinkErrors, InitOutlookLinkResponse, InitOutlookLinkResponse2, InitOutlookLinkResponses, InviteEntry, InviteToTeamData, InviteToTeamError, InviteToTeamErrors, InviteToTeamRequest, InviteToTeamResponses, JoinTeamByInviteLinkData, JoinTeamByInviteLinkError, JoinTeamByInviteLinkErrors, JoinTeamByInviteLinkResponse, JoinTeamByInviteLinkResponse2, JoinTeamByInviteLinkResponses, JoinTeamData, JoinTeamError, JoinTeamErrors, JoinTeamResponses, LinkShare, ListCodexEnvironmentsData, ListCodexEnvironmentsResponse, ListCodexEnvironmentsResponses, ListCursorModelsData, ListCursorModelsError, ListCursorModelsErrors, ListCursorModelsResponse, ListCursorModelsResponses, ListGtmInviteLinksData, ListGtmInviteLinksError, ListGtmInviteLinksErrors, ListGtmInviteLinksResponse, ListGtmInviteLinksResponses, LogoutData, LogoutResponse, LogoutResponses, MacroApiTokenData, MacroApiTokenError, MacroApiTokenErrors, MacroApiTokenResponse, MacroApiTokenResponse2, MacroApiTokenResponses, MergeGithubPullRequestData, MergeGithubPullRequestError, MergeGithubPullRequestErrors, MergeGithubPullRequestRequest, MergeGithubPullRequestResponse, MergeGithubPullRequestResponse2, MergeGithubPullRequestResponses, Oauth2CallbackData, Oauth2CallbackError, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectError, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackError, PasswordlessCallbackErrors, PasswordlessCallbackResponse, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginError, PasswordlessLoginErrors, PasswordlessLoginResponse, PasswordlessLoginResponses, PasswordlessRequest, PasswordlessStartedResponse, PasswordLoginData, PasswordLoginError, PasswordLoginErrors, PasswordLoginResponse, PasswordLoginResponses, PasswordRequest, PatchTeamCrmSettingsData, PatchTeamCrmSettingsError, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsRequest, PatchTeamCrmSettingsResponse, PatchTeamCrmSettingsResponse2, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamError, PatchTeamErrors, PatchTeamMemberPlanData, PatchTeamMemberPlanError, PatchTeamMemberPlanErrors, PatchTeamMemberPlanRequest, PatchTeamMemberPlanResponse, PatchTeamMemberPlanResponses, PatchTeamRequest, PatchTeamResponses, PatchTeamUserRole, PatchUserGroupData, PatchUserGroupError, PatchUserGroupErrors, PatchUserGroupRequest, PatchUserGroupResponse, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingError, PatchUserOnboardingErrors, PatchUserOnboardingRequest, PatchUserOnboardingResponse, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialError, PatchUserTutorialErrors, PatchUserTutorialRequest, PatchUserTutorialResponse, PatchUserTutorialResponses, Permission, PlanCatalogEntry, PlanCatalogResponse, PlanTier, PollCodexLoginData, PollCodexLoginResponse, PollCodexLoginResponses, PostGetNamesRequestBody, PostProfilePicturesData, PostProfilePicturesError, PostProfilePicturesErrors, PostProfilePicturesResponse, PostProfilePicturesResponses, ProfilePictureQueryParams, ProfilePictures, PublicGtmInviteLink, PutCursorApiKeyData, PutCursorApiKeyError, PutCursorApiKeyErrors, PutCursorApiKeyRequest, PutCursorApiKeyResponse, PutCursorApiKeyResponses, PutCursorDefaultModelData, PutCursorDefaultModelError, PutCursorDefaultModelErrors, PutCursorDefaultModelRequest, PutCursorDefaultModelResponse, PutCursorDefaultModelResponses, PutProfilePictureData, PutProfilePictureError, PutProfilePictureErrors, PutProfilePictureResponse, PutProfilePictureResponses, PutUserNameData, PutUserNameError, PutUserNameErrors, PutUserNameQueryParams, PutUserNameResponse, PutUserNameResponses, RedeemGtmInviteLinkData, RedeemGtmInviteLinkError, RedeemGtmInviteLinkErrors, RedeemGtmInviteLinkRequest, RedeemGtmInviteLinkResponse, RedeemGtmInviteLinkResponses, RefreshData, RefreshError, RefreshErrors, RefreshResponse, RefreshResponses, RejectInvitationData, RejectInvitationError, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamError, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailError, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailRequest, ResendFusionauthVerifyUserEmailResponse, ResendFusionauthVerifyUserEmailResponses, ResolveGtmInviteLinkData, ResolveGtmInviteLinkError, ResolveGtmInviteLinkErrors, ResolveGtmInviteLinkResponse, ResolveGtmInviteLinkResponses, RevokeGtmInviteLinkData, RevokeGtmInviteLinkError, RevokeGtmInviteLinkErrors, RevokeGtmInviteLinkResponse, RevokeGtmInviteLinkResponses, ScheduledSeatPlan, SeatPlan, SendInviteBody, SendMobileWelcomeEmailData, SendMobileWelcomeEmailError, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailRequest, SendMobileWelcomeEmailResponse, SendMobileWelcomeEmailResponse2, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeError, SendReferralCodeErrors, SendReferralCodeResponse, SendReferralCodeResponses, SessionCreationData, SessionCreationError, SessionCreationErrors, SessionCreationResponse, SessionCreationResponses, SessionLoginData, SessionLoginError, SessionLoginErrors, SessionLoginResponse, SessionLoginResponses, SetGithubPullRequestDraftData, SetGithubPullRequestDraftError, SetGithubPullRequestDraftErrors, SetGithubPullRequestDraftRequest, SetGithubPullRequestDraftResponse, SetGithubPullRequestDraftResponse2, SetGithubPullRequestDraftResponses, SsoLoginData, SsoLoginError, SsoLoginErrors, SsoLoginResponses, SsoRequiredResponse, StartCodexLoginData, StartCodexLoginResponse, StartCodexLoginResponses, StripeSessionResponse, SubscriptionStatus, Team, TeamInviteDetails, TeamInviteLinkResponse, TeamInviteLinkTeam, TeamInviteLinkToken, TeamInviteLinkTokenRequest, TeamInvitesResponse, TeamMember, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainResponse, ToggleNonAdminInvitesResponse, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainError, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponse, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesError, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponse, ToggleTeamNonAdminInvitesResponses, TrialEligibility, UpdateAiBillingAutoReloadData, UpdateAiBillingAutoReloadError, UpdateAiBillingAutoReloadErrors, UpdateAiBillingAutoReloadResponse, UpdateAiBillingAutoReloadResponses, UpdateAiBillingOverageData, UpdateAiBillingOverageError, UpdateAiBillingOverageErrors, UpdateAiBillingOverageResponse, UpdateAiBillingOverageResponses, UpdateAutoReloadRequest, UpdateOverageRequest, UsageSnapshot, UserLinkResponse, UserName, UserNames, UserOrganizationResponse, UserProfilePicture, UserQuota, UserTokensResponse, VerifyEmailLinkData, VerifyEmailLinkError, VerifyEmailLinkErrors, VerifyEmailLinkResponse, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailError, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponse, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestError, VerifyMergeRequestErrors, VerifyMergeRequestResponse, VerifyMergeRequestResponses } from './types.gen';
diff --git a/packages/sdk/generated/auth/sdk.gen.ts b/packages/sdk/generated/auth/sdk.gen.ts
index 8950989555..c73fddefd2 100644
--- a/packages/sdk/generated/auth/sdk.gen.ts
+++ b/packages/sdk/generated/auth/sdk.gen.ts
@@ -2,7 +2,7 @@
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
import { client } from './client.gen';
-import type { AppleLoginData, AppleLoginErrors, AppleLoginResponses, CancelCodexLoginData, CancelCodexLoginResponses, ChangePlanData, ChangePlanErrors, ChangePlanResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponses, ConfigureCodexData, ConfigureCodexResponses, CreateAiCreditCheckoutData, CreateAiCreditCheckoutErrors, CreateAiCreditCheckoutResponses, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Responses, CreateGtmInviteLinkData, CreateGtmInviteLinkErrors, CreateGtmInviteLinkResponses, CreateInProgressLinkData, CreateInProgressLinkErrors, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestErrors, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionErrors, CreatePortalSessionResponses, CreateTeamData, CreateTeamErrors, CreateTeamResponses, DeleteCursorApiKeyData, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkErrors, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamResponses, DeleteUserData, DeleteUserErrors, DeleteUserResponses, DisconnectCodexData, DisconnectCodexResponses, EmailConnectionProvidersData, EmailConnectionProvidersErrors, EmailConnectionProvidersResponses, EnrichGithubPullRequestsData, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsResponses, GenerateEmailLinkData, GenerateEmailLinkErrors, GenerateEmailLinkResponses, GetAiBillingPlansData, GetAiBillingPlansResponses, GetAiBillingSummaryData, GetAiBillingSummaryErrors, GetAiBillingSummaryResponses, GetCodexConnectionData, GetCodexConnectionResponses, GetCursorApiKeyData, GetCursorApiKeyErrors, GetCursorApiKeyResponses, GetGithubPullRequestMergeabilityData, GetGithubPullRequestMergeabilityErrors, GetGithubPullRequestMergeabilityResponses, GetGtmInviteOfferData, GetGtmInviteOfferErrors, GetGtmInviteOfferResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponses, GetPermissionsData, GetPermissionsErrors, GetPermissionsResponses, GetReferralCodeData, GetReferralCodeErrors, GetReferralCodeResponses, GetSubscriptionStatusData, GetSubscriptionStatusErrors, GetSubscriptionStatusResponses, GetTeamData, GetTeamErrors, GetTeamInvitesData, GetTeamInvitesErrors, GetTeamInvitesResponses, GetTeamResponses, GetTrialEligibilityData, GetTrialEligibilityErrors, GetTrialEligibilityResponses, GetUserInfoData, GetUserInfoErrors, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesErrors, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsErrors, GetUserLinkExistsResponses, GetUserNameData, GetUserNameErrors, GetUserNameResponses, GetUserNamesData, GetUserNamesErrors, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationErrors, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsErrors, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaErrors, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsErrors, GetUserTeamsResponses, HealthHandlerData, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkErrors, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkErrors, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkErrors, InitOutlookLinkResponses, InviteToTeamData, InviteToTeamErrors, InviteToTeamResponses, JoinTeamData, JoinTeamErrors, JoinTeamResponses, ListCodexEnvironmentsData, ListCodexEnvironmentsResponses, ListCursorModelsData, ListCursorModelsErrors, ListCursorModelsResponses, ListGtmInviteLinksData, ListGtmInviteLinksErrors, ListGtmInviteLinksResponses, LogoutData, LogoutResponses, MacroApiTokenData, MacroApiTokenErrors, MacroApiTokenResponses, MergeGithubPullRequestData, MergeGithubPullRequestErrors, MergeGithubPullRequestResponses, Oauth2CallbackData, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackErrors, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginErrors, PasswordlessLoginResponses, PasswordLoginData, PasswordLoginErrors, PasswordLoginResponses, PatchTeamCrmSettingsData, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamErrors, PatchTeamMemberPlanData, PatchTeamMemberPlanErrors, PatchTeamMemberPlanResponses, PatchTeamResponses, PatchUserGroupData, PatchUserGroupErrors, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingErrors, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialErrors, PatchUserTutorialResponses, PollCodexLoginData, PollCodexLoginResponses, PostProfilePicturesData, PostProfilePicturesErrors, PostProfilePicturesResponses, PutCursorApiKeyData, PutCursorApiKeyErrors, PutCursorApiKeyResponses, PutCursorDefaultModelData, PutCursorDefaultModelErrors, PutCursorDefaultModelResponses, PutProfilePictureData, PutProfilePictureErrors, PutProfilePictureResponses, PutUserNameData, PutUserNameErrors, PutUserNameResponses, RedeemGtmInviteLinkData, RedeemGtmInviteLinkErrors, RedeemGtmInviteLinkResponses, RefreshData, RefreshErrors, RefreshResponses, RejectInvitationData, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailResponses, ResolveGtmInviteLinkData, ResolveGtmInviteLinkErrors, ResolveGtmInviteLinkResponses, RevokeGtmInviteLinkData, RevokeGtmInviteLinkErrors, RevokeGtmInviteLinkResponses, SendMobileWelcomeEmailData, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeErrors, SendReferralCodeResponses, SessionCreationData, SessionCreationErrors, SessionCreationResponses, SessionLoginData, SessionLoginErrors, SessionLoginResponses, SetGithubPullRequestDraftData, SetGithubPullRequestDraftErrors, SetGithubPullRequestDraftResponses, SsoLoginData, SsoLoginErrors, SsoLoginResponses, StartCodexLoginData, StartCodexLoginResponses, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponses, UpdateAiBillingAutoReloadData, UpdateAiBillingAutoReloadErrors, UpdateAiBillingAutoReloadResponses, UpdateAiBillingOverageData, UpdateAiBillingOverageErrors, UpdateAiBillingOverageResponses, VerifyEmailLinkData, VerifyEmailLinkErrors, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestErrors, VerifyMergeRequestResponses } from './types.gen';
+import type { AppleLoginData, AppleLoginErrors, AppleLoginResponses, CancelCodexLoginData, CancelCodexLoginResponses, ChangePlanData, ChangePlanErrors, ChangePlanResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponses, ConfigureCodexData, ConfigureCodexResponses, CreateAiCreditCheckoutData, CreateAiCreditCheckoutErrors, CreateAiCreditCheckoutResponses, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Responses, CreateGtmInviteLinkData, CreateGtmInviteLinkErrors, CreateGtmInviteLinkResponses, CreateInProgressLinkData, CreateInProgressLinkErrors, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestErrors, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionErrors, CreatePortalSessionResponses, CreateTeamData, CreateTeamErrors, CreateTeamInviteLinkData, CreateTeamInviteLinkErrors, CreateTeamInviteLinkResponses, CreateTeamResponses, DeleteCursorApiKeyData, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkErrors, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamInviteLinkData, DeleteTeamInviteLinkErrors, DeleteTeamInviteLinkResponses, DeleteTeamResponses, DeleteUserData, DeleteUserErrors, DeleteUserResponses, DisconnectCodexData, DisconnectCodexResponses, EmailConnectionProvidersData, EmailConnectionProvidersErrors, EmailConnectionProvidersResponses, EnrichGithubPullRequestsData, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsResponses, GenerateEmailLinkData, GenerateEmailLinkErrors, GenerateEmailLinkResponses, GetAiBillingPlansData, GetAiBillingPlansResponses, GetAiBillingSummaryData, GetAiBillingSummaryErrors, GetAiBillingSummaryResponses, GetCodexConnectionData, GetCodexConnectionResponses, GetCursorApiKeyData, GetCursorApiKeyErrors, GetCursorApiKeyResponses, GetGithubPullRequestMergeabilityData, GetGithubPullRequestMergeabilityErrors, GetGithubPullRequestMergeabilityResponses, GetGtmInviteOfferData, GetGtmInviteOfferErrors, GetGtmInviteOfferResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponses, GetPermissionsData, GetPermissionsErrors, GetPermissionsResponses, GetReferralCodeData, GetReferralCodeErrors, GetReferralCodeResponses, GetSubscriptionStatusData, GetSubscriptionStatusErrors, GetSubscriptionStatusResponses, GetTeamByInviteLinkData, GetTeamByInviteLinkErrors, GetTeamByInviteLinkResponses, GetTeamData, GetTeamErrors, GetTeamInviteLinkData, GetTeamInviteLinkErrors, GetTeamInviteLinkResponses, GetTeamInvitesData, GetTeamInvitesErrors, GetTeamInvitesResponses, GetTeamResponses, GetTrialEligibilityData, GetTrialEligibilityErrors, GetTrialEligibilityResponses, GetUserInfoData, GetUserInfoErrors, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesErrors, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsErrors, GetUserLinkExistsResponses, GetUserNameData, GetUserNameErrors, GetUserNameResponses, GetUserNamesData, GetUserNamesErrors, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationErrors, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsErrors, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaErrors, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsErrors, GetUserTeamsResponses, HealthHandlerData, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkErrors, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkErrors, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkErrors, InitOutlookLinkResponses, InviteToTeamData, InviteToTeamErrors, InviteToTeamResponses, JoinTeamByInviteLinkData, JoinTeamByInviteLinkErrors, JoinTeamByInviteLinkResponses, JoinTeamData, JoinTeamErrors, JoinTeamResponses, ListCodexEnvironmentsData, ListCodexEnvironmentsResponses, ListCursorModelsData, ListCursorModelsErrors, ListCursorModelsResponses, ListGtmInviteLinksData, ListGtmInviteLinksErrors, ListGtmInviteLinksResponses, LogoutData, LogoutResponses, MacroApiTokenData, MacroApiTokenErrors, MacroApiTokenResponses, MergeGithubPullRequestData, MergeGithubPullRequestErrors, MergeGithubPullRequestResponses, Oauth2CallbackData, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackErrors, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginErrors, PasswordlessLoginResponses, PasswordLoginData, PasswordLoginErrors, PasswordLoginResponses, PatchTeamCrmSettingsData, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamErrors, PatchTeamMemberPlanData, PatchTeamMemberPlanErrors, PatchTeamMemberPlanResponses, PatchTeamResponses, PatchUserGroupData, PatchUserGroupErrors, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingErrors, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialErrors, PatchUserTutorialResponses, PollCodexLoginData, PollCodexLoginResponses, PostProfilePicturesData, PostProfilePicturesErrors, PostProfilePicturesResponses, PutCursorApiKeyData, PutCursorApiKeyErrors, PutCursorApiKeyResponses, PutCursorDefaultModelData, PutCursorDefaultModelErrors, PutCursorDefaultModelResponses, PutProfilePictureData, PutProfilePictureErrors, PutProfilePictureResponses, PutUserNameData, PutUserNameErrors, PutUserNameResponses, RedeemGtmInviteLinkData, RedeemGtmInviteLinkErrors, RedeemGtmInviteLinkResponses, RefreshData, RefreshErrors, RefreshResponses, RejectInvitationData, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailResponses, ResolveGtmInviteLinkData, ResolveGtmInviteLinkErrors, ResolveGtmInviteLinkResponses, RevokeGtmInviteLinkData, RevokeGtmInviteLinkErrors, RevokeGtmInviteLinkResponses, SendMobileWelcomeEmailData, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeErrors, SendReferralCodeResponses, SessionCreationData, SessionCreationErrors, SessionCreationResponses, SessionLoginData, SessionLoginErrors, SessionLoginResponses, SetGithubPullRequestDraftData, SetGithubPullRequestDraftErrors, SetGithubPullRequestDraftResponses, SsoLoginData, SsoLoginErrors, SsoLoginResponses, StartCodexLoginData, StartCodexLoginResponses, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponses, UpdateAiBillingAutoReloadData, UpdateAiBillingAutoReloadErrors, UpdateAiBillingAutoReloadResponses, UpdateAiBillingOverageData, UpdateAiBillingOverageErrors, UpdateAiBillingOverageResponses, VerifyEmailLinkData, VerifyEmailLinkErrors, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestErrors, VerifyMergeRequestResponses } from './types.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
/**
@@ -739,6 +739,58 @@ export class Sdk extends HeyApiClient {
});
}
+ /**
+ * Turns off the team's invite link. Requires a team admin or owner.
+ */
+ public deleteTeamInviteLink<ThrowOnError extends boolean = false>(options?: Options<DeleteTeamInviteLinkData, ThrowOnError>): RequestResult<DeleteTeamInviteLinkResponses, DeleteTeamInviteLinkErrors, ThrowOnError> {
+ return (options?.client ?? this.client).delete<DeleteTeamInviteLinkResponses, DeleteTeamInviteLinkErrors, ThrowOnError>({ url: '/team/invite-link', ...options });
+ }
+
+ /**
+ * Gets the team's invite link. Anyone who may invite people to the team may
+ * see it.
+ */
+ public getTeamInviteLink<ThrowOnError extends boolean = false>(options?: Options<GetTeamInviteLinkData, ThrowOnError>): RequestResult<GetTeamInviteLinkResponses, GetTeamInviteLinkErrors, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetTeamInviteLinkResponses, GetTeamInviteLinkErrors, ThrowOnError>({ url: '/team/invite-link', ...options });
+ }
+
+ /**
+ * Creates the team's invite link, replacing any existing one. Anyone who may
+ * invite people may create the first link; replacing one requires a team
+ * admin or owner.
+ */
+ public createTeamInviteLink<ThrowOnError extends boolean = false>(options?: Options<CreateTeamInviteLinkData, ThrowOnError>): RequestResult<CreateTeamInviteLinkResponses, CreateTeamInviteLinkErrors, ThrowOnError> {
+ return (options?.client ?? this.client).post<CreateTeamInviteLinkResponses, CreateTeamInviteLinkErrors, ThrowOnError>({ url: '/team/invite-link', ...options });
+ }
+
+ /**
+ * Joins the team an invite link belongs to.
+ */
+ public joinTeamByInviteLink<ThrowOnError extends boolean = false>(options: Options<JoinTeamByInviteLinkData, ThrowOnError>): RequestResult<JoinTeamByInviteLinkResponses, JoinTeamByInviteLinkErrors, ThrowOnError> {
+ return (options.client ?? this.client).post<JoinTeamByInviteLinkResponses, JoinTeamByInviteLinkErrors, ThrowOnError>({
+ url: '/team/invite-link/join',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers
+ }
+ });
+ }
+
+ /**
+ * Gets the team an invite link joins, so the user can see it before joining.
+ */
+ public getTeamByInviteLink<ThrowOnError extends boolean = false>(options: Options<GetTeamByInviteLinkData, ThrowOnError>): RequestResult<GetTeamByInviteLinkResponses, GetTeamByInviteLinkErrors, ThrowOnError> {
+ return (options.client ?? this.client).post<GetTeamByInviteLinkResponses, GetTeamByInviteLinkErrors, ThrowOnError>({
+ url: '/team/invite-link/team',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers
+ }
+ });
+ }
+
/**
* Deletes a team invite from a team.
*/
diff --git a/packages/sdk/generated/auth/types.gen.ts b/packages/sdk/generated/auth/types.gen.ts
index 737619464a..62d35e0d55 100644
--- a/packages/sdk/generated/auth/types.gen.ts
+++ b/packages/sdk/generated/auth/types.gen.ts
@@ -322,6 +322,16 @@ export type CreateTeamRequest = {
name: string;
};
+/**
+ * A newly created team invite link.
+ */
+export type CreatedTeamInviteLinkResponse = {
+ /**
+ * The new link's token. Any previous link stops working.
+ */
+ token: TeamInviteLinkToken;
+};
+
/**
* Request body for [`create_credit_checkout_handler`].
*/
@@ -1104,6 +1114,20 @@ export type InviteToTeamRequest = {
invites: Array<InviteEntry>;
};
+/**
+ * The result of opening a team invite link.
+ */
+export type JoinTeamByInviteLinkResponse = {
+ /**
+ * True when the user was already on the team and nothing changed.
+ */
+ already_member: boolean;
+ /**
+ * The team the link joins.
+ */
+ team_id: string;
+};
+
/**
* Defines who can access an item through its share link.
*/
@@ -1622,6 +1646,47 @@ export type TeamInviteDetails = {
team_role: TeamRole;
};
+/**
+ * The caller's team invite link.
+ */
+export type TeamInviteLinkResponse = {
+ token?: null | TeamInviteLinkToken;
+};
+
+/**
+ * The team an invite link joins, shown before the user accepts.
+ */
+export type TeamInviteLinkTeam = {
+ /**
+ * Id of the team the link joins.
+ */
+ team_id: string;
+ /**
+ * Name of the team the link joins.
+ */
+ team_name: string;
+};
+
+/**
+ * The secret in a team's shareable invite link.
+ *
+ * Anyone signed in who holds the token can join the team, so it is a random
+ * value rather than a time-ordered id, and an admin resetting the link
+ * replaces it.
+ */
+export type TeamInviteLinkToken = string;
+
+/**
+ * Identifies an invite link. The token travels in the body, not the path, so
+ * request spans and access logs that record the path never see it.
+ */
+export type TeamInviteLinkTokenRequest = {
+ /**
+ * The invite link's token.
+ */
+ token: TeamInviteLinkToken;
+};
+
/**
* Response containing a list of team invites
*/
@@ -3449,6 +3514,112 @@ export type InviteToTeamResponses = {
201: unknown;
};
+export type DeleteTeamInviteLinkData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/team/invite-link';
+};
+
+export type DeleteTeamInviteLinkErrors = {
+ 401: ErrorResponse;
+ 403: ErrorResponse;
+ 500: ErrorResponse;
+};
+
+export type DeleteTeamInviteLinkError = DeleteTeamInviteLinkErrors[keyof DeleteTeamInviteLinkErrors];
+
+export type DeleteTeamInviteLinkResponses = {
+ 204: void;
+};
+
+export type DeleteTeamInviteLinkResponse = DeleteTeamInviteLinkResponses[keyof DeleteTeamInviteLinkResponses];
+
+export type GetTeamInviteLinkData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/team/invite-link';
+};
+
+export type GetTeamInviteLinkErrors = {
+ 401: ErrorResponse;
+ 403: ErrorResponse;
+ 500: ErrorResponse;
+};
+
+export type GetTeamInviteLinkError = GetTeamInviteLinkErrors[keyof GetTeamInviteLinkErrors];
+
+export type GetTeamInviteLinkResponses = {
+ 200: TeamInviteLinkResponse;
+};
+
+export type GetTeamInviteLinkResponse = GetTeamInviteLinkResponses[keyof GetTeamInviteLinkResponses];
+
+export type CreateTeamInviteLinkData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/team/invite-link';
+};
+
+export type CreateTeamInviteLinkErrors = {
+ 401: ErrorResponse;
+ 403: ErrorResponse;
+ 500: ErrorResponse;
+};
+
+export type CreateTeamInviteLinkError = CreateTeamInviteLinkErrors[keyof CreateTeamInviteLinkErrors];
+
+export type CreateTeamInviteLinkResponses = {
+ 201: CreatedTeamInviteLinkResponse;
+};
+
+export type CreateTeamInviteLinkResponse = CreateTeamInviteLinkResponses[keyof CreateTeamInviteLinkResponses];
+
+export type JoinTeamByInviteLinkData = {
+ body: TeamInviteLinkTokenRequest;
+ path?: never;
+ query?: never;
+ url: '/team/invite-link/join';
+};
+
+export type JoinTeamByInviteLinkErrors = {
+ 401: ErrorResponse;
+ 404: ErrorResponse;
+ 409: ErrorResponse;
+ 500: ErrorResponse;
+};
+
+export type JoinTeamByInviteLinkError = JoinTeamByInviteLinkErrors[keyof JoinTeamByInviteLinkErrors];
+
+export type JoinTeamByInviteLinkResponses = {
+ 200: JoinTeamByInviteLinkResponse;
+};
+
+export type JoinTeamByInviteLinkResponse2 = JoinTeamByInviteLinkResponses[keyof JoinTeamByInviteLinkResponses];
+
+export type GetTeamByInviteLinkData = {
+ body: TeamInviteLinkTokenRequest;
+ path?: never;
+ query?: never;
+ url: '/team/invite-link/team';
+};
+
+export type GetTeamByInviteLinkErrors = {
+ 401: ErrorResponse;
+ 404: ErrorResponse;
+ 500: ErrorResponse;
+};
+
+export type GetTeamByInviteLinkError = GetTeamByInviteLinkErrors[keyof GetTeamByInviteLinkErrors];
+
+export type GetTeamByInviteLinkResponses = {
+ 200: TeamInviteLinkTeam;
+};
+
+export type GetTeamByInviteLinkResponse = GetTeamByInviteLinkResponses[keyof GetTeamByInviteLinkResponses];
+
export type DeleteTeamInviteHandlerData = {
body?: never;
path: {
diff --git a/packages/sdk/specs/auth.json b/packages/sdk/specs/auth.json
index 4aacf78ac8..ffbdbdbd24 100644
--- a/packages/sdk/specs/auth.json
+++ b/packages/sdk/specs/auth.json
@@ -3600,6 +3600,270 @@
}
}
},
+ "/team/invite-link": {
+ "get": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Gets the team's invite link. Anyone who may invite people to the team may\nsee it.",
+ "operationId": "get_team_invite_link",
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Creates the team's invite link, replacing any existing one. Anyone who may\ninvite people may create the first link; replacing one requires a team\nadmin or owner.",
+ "operationId": "create_team_invite_link",
+ "responses": {
+ "201": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CreatedTeamInviteLinkResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ },
+ "delete": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Turns off the team's invite link. Requires a team admin or owner.",
+ "operationId": "delete_team_invite_link",
+ "responses": {
+ "204": {
+ "description": ""
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/team/invite-link/join": {
+ "post": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Joins the team an invite link belongs to.",
+ "operationId": "join_team_by_invite_link",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkTokenRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/JoinTeamByInviteLinkResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/team/invite-link/team": {
+ "post": {
+ "tags": ["teams::inbound::axum_router::invite_link"],
+ "summary": "Gets the team an invite link joins, so the user can see it before joining.",
+ "operationId": "get_team_by_invite_link",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkTokenRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TeamInviteLinkTeam"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/team/invite/{team_invite_id}": {
"delete": {
"tags": ["teams::inbound::axum_router::delete_team_invite"],
@@ -5570,6 +5834,17 @@
}
}
},
+ "CreatedTeamInviteLinkResponse": {
+ "type": "object",
+ "description": "A newly created team invite link.",
+ "required": ["token"],
+ "properties": {
+ "token": {
+ "$ref": "#/components/schemas/TeamInviteLinkToken",
+ "description": "The new link's token. Any previous link stops working."
+ }
+ }
+ },
"CreditCheckoutRequestBody": {
"type": "object",
"description": "Request body for [`create_credit_checkout_handler`].",
@@ -6568,6 +6843,22 @@
}
}
},
+ "JoinTeamByInviteLinkResponse": {
+ "type": "object",
+ "description": "The result of opening a team invite link.",
+ "required": ["team_id", "already_member"],
+ "properties": {
+ "already_member": {
+ "type": "boolean",
+ "description": "True when the user was already on the team and nothing changed."
+ },
+ "team_id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "The team the link joins."
+ }
+ }
+ },
"LinkShare": {
"type": "string",
"description": "Defines who can access an item through its share link.",
@@ -7277,6 +7568,54 @@
}
}
},
+ "TeamInviteLinkResponse": {
+ "type": "object",
+ "description": "The caller's team invite link.",
+ "properties": {
+ "token": {
+ "oneOf": [
+ {
+ "type": "null"
+ },
+ {
+ "$ref": "#/components/schemas/TeamInviteLinkToken",
+ "description": "The link's token, or null when the team has no invite link."
+ }
+ ]
+ }
+ }
+ },
+ "TeamInviteLinkTeam": {
+ "type": "object",
+ "description": "The team an invite link joins, shown before the user accepts.",
+ "required": ["team_id", "team_name"],
+ "properties": {
+ "team_id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Id of the team the link joins."
+ },
+ "team_name": {
+ "type": "string",
+ "description": "Name of the team the link joins."
+ }
+ }
+ },
+ "TeamInviteLinkToken": {
+ "type": "string",
+ "description": "The secret in a team's shareable invite link.\n\nAnyone signed in who holds the token can join the team, so it is a random\nvalue rather than a time-ordered id, and an admin resetting the link\nreplaces it."
+ },
+ "TeamInviteLinkTokenRequest": {
+ "type": "object",
+ "description": "Identifies an invite link. The token travels in the body, not the path, so\nrequest spans and access logs that record the path never see it.",
+ "required": ["token"],
+ "properties": {
+ "token": {
+ "$ref": "#/components/schemas/TeamInviteLinkToken",
+ "description": "The invite link's token."
+ }
+ }
+ },
"TeamInvitesResponse": {
"type": "object",
"description": "Response containing a list of team invites",
diff --git a/packages/sdk/src/coverage/skipped.ts b/packages/sdk/src/coverage/skipped.ts
index 874976b6c0..496127933a 100644
--- a/packages/sdk/src/coverage/skipped.ts
+++ b/packages/sdk/src/coverage/skipped.ts
@@ -56,10 +56,12 @@ export const authExcluded = [
'createMergeRequest',
'createPortalSession',
'createTeam',
+ 'createTeamInviteLink',
'deleteCursorApiKey',
'deleteGithubLink',
'deleteTeam',
'deleteTeamInviteHandler',
+ 'deleteTeamInviteLink',
'deleteUser',
'disconnectCodex',
'enrichGithubPullRequests',
@@ -75,6 +77,8 @@ export const authExcluded = [
'getReferralCode',
// Renewal and scheduled-plan details are part of the app's billing settings.
'getSubscriptionStatus',
+ 'getTeamByInviteLink',
+ 'getTeamInviteLink',
'getTeamInvites',
// Introductory offers belong to the app's subscription checkout flow.
'getTrialEligibility',
@@ -91,6 +95,7 @@ export const authExcluded = [
'initOutlookLink',
'inviteToTeam',
'joinTeam',
+ 'joinTeamByInviteLink',
'listCodexEnvironments',
'listCursorModels',
'listGtmInviteLinks',
diff --git a/services/authentication_service/src/api/swagger.rs b/services/authentication_service/src/api/swagger.rs
index 923362b88f..f419732f7a 100644
--- a/services/authentication_service/src/api/swagger.rs
+++ b/services/authentication_service/src/api/swagger.rs
@@ -14,11 +14,14 @@ use gtm_invite::inbound::axum_router::dto::{
use model::authentication::login::request::{AppleLoginRequest, PasswordRequest};
use teams::domain::model::{
PatchTeamCrmSettingsRequest, PatchTeamCrmSettingsResponse, PatchTeamMemberPlanRequest,
- PatchTeamRequest, PatchTeamUserRole, Team, TeamInviteDetails, TeamMember, TeamPlan, TeamRole,
- TeamWithMembers,
+ PatchTeamRequest, PatchTeamUserRole, Team, TeamInviteDetails, TeamInviteLinkTeam,
+ TeamInviteLinkToken, TeamMember, TeamPlan, TeamRole, TeamWithMembers,
};
use teams::inbound::axum_router::get_team_invites::TeamInvitesResponse as TeamTeamInvitesResponse;
use teams::inbound::axum_router::get_user_invites::TeamInvitesResponse as UserTeamInvitesResponse;
+use teams::inbound::axum_router::invite_link::{
+ CreatedTeamInviteLinkResponse, JoinTeamByInviteLinkResponse, TeamInviteLinkResponse,
+};
use teams::inbound::axum_router::toggle_auto_join_domain::ToggleAutoJoinDomainResponse;
use teams::inbound::axum_router::toggle_non_admin_invites::ToggleNonAdminInvitesResponse;
use teams::inbound::axum_router::{
@@ -184,6 +187,11 @@ use model::user::{
teams::inbound::axum_router::remove_user_from_team::handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
teams::inbound::axum_router::patch_team_member_plan::handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
teams::inbound::axum_router::delete_team_invite::handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
+ teams::inbound::axum_router::invite_link::get_handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
+ teams::inbound::axum_router::invite_link::create_handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
+ teams::inbound::axum_router::invite_link::delete_handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
+ teams::inbound::axum_router::invite_link::get_team_handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
+ teams::inbound::axum_router::invite_link::join_handler::<crate::api::context::TeamsServiceType, crate::api::context::EntityAccessServiceType, crate::api::context::AuthorizationService>,
/// /referral
referral::inbound::axum_router::get_referral_code_handler::<crate::api::context::ReferralServiceType, crate::api::context::RateLimiter, crate::api::context::AuthorizationService>,
@@ -314,6 +322,11 @@ use model::user::{
PatchTeamCrmSettingsResponse,
ToggleAutoJoinDomainResponse,
ToggleNonAdminInvitesResponse,
+ TeamInviteLinkResponse,
+ CreatedTeamInviteLinkResponse,
+ JoinTeamByInviteLinkResponse,
+ TeamInviteLinkTeam,
+ TeamInviteLinkToken,
TeamTeamInvitesResponse,
UserTeamInvitesResponse,