⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
refactor(web): split the API client by domain (#340)
Croff620db84a041a
diff --git a/apps/api/src/modules/webhooks/service.ts b/apps/api/src/modules/webhooks/service.tsindex 29578542..234ed5c6 100644--- a/apps/api/src/modules/webhooks/service.ts+++ b/apps/api/src/modules/webhooks/service.ts@@ -10,7 +10,7 @@ import { iso } from '#shared/lib';// The event types a subscription can select. Keep this list in sync with the events// the delivery side emits (modules/issues/service.ts, activity.ts, links.ts) and-// with the frontend list (apps/web src/lib/api.ts).+// with the frontend list (apps/web src/lib/api/endpoints/webhooks.ts).//// issue.updated fires on any field change. The granular issue.assigned,// issue.state_changed, and issue.label_changed fire in addition, and only when thatdiff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex a0201b43..809f4260 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -98,7 +98,20 @@ next-intl, language from the `NEXT_LOCALE` cookie — no `[locale]` route segmen`getNextPageParam: nextPageParam` (`useCompletedCyclesQuery` is the shape to copy); a feedreads a cursor route instead. A picker that needs every row calls the list's `/options`endpoint — never a paged one with a large `pageSize`.-- Call the backend over HTTP at the API origin. `lib/api.ts` takes it from+- **The API client is split by domain.** `lib/api/core/` holds the transport —+ `client.ts` (`API_URL`, `request()`, `uploadFile()`, `ApiError`, `apiFailure`, the+ 401 sign-out), `paging.ts` (`Page<T>`, `PageParams`, `pageQuery`, `nextPageParam`)+ and `media.ts` (`mediaUrl`). `lib/api/endpoints/` holds one flat file per domain,+ named after the module of `apps/api/src/modules` it calls: an endpoint on the API in+ `modules/cycles/` is reached from `lib/api/endpoints/cycles.ts`. A file keeps its+ DTOs next to the functions that return them, and exports both by name — there is no+ `index.ts` anywhere under `lib/api`, and no barrel re-exporting the domains. Types+ cross domains with `import type`, which the compiler erases, so a composite like+ `ProjectDetail` is assembled in the domain that owns the route without a runtime+ cycle. A moved type whose name matches a DOM global (`Permissions`, `Notification`,+ `Storage`) resolves to that global when its import is missing, so tsc stays silent+ while the type is wrong: import it explicitly.+- Call the backend over HTTP at the API origin. `lib/api/core/client.ts` takes it from`utils/runtimeEnv`, which reads `API_URL` in the server process and hands it to thebrowser through the inline script in `components/runtime-env-script.tsx`. A per-instancevalue goes through there — never `process.env.NEXT_PUBLIC_*` in a component, whichdiff --git a/apps/web/src/components/common/Avatar.tsx b/apps/web/src/components/common/Avatar.tsxindex a2b58948..57f0d4bc 100644--- a/apps/web/src/components/common/Avatar.tsx+++ b/apps/web/src/components/common/Avatar.tsx@@ -3,7 +3,7 @@import { forwardRef, useState, type ComponentProps } from 'react';import Image from 'next/image';import { avatarColor, initials } from '@/utils/avatar';-import { mediaUrl } from '@/lib/api';+import { mediaUrl } from '@/lib/api/core/media';import { cn } from '@/lib/utils';// A person's avatar. With an uploaded `image` it shows that picture; otherwisediff --git a/apps/web/src/components/common/DocumentLinkList.tsx b/apps/web/src/components/common/DocumentLinkList.tsxindex 5b7f2961..868c315f 100644--- a/apps/web/src/components/common/DocumentLinkList.tsx+++ b/apps/web/src/components/common/DocumentLinkList.tsx@@ -1,7 +1,7 @@import Link from 'next/link';import { FileText, Loader2, Lock, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { IssueDocumentLink } from '@/lib/api';+import type { IssueDocumentLink } from '@/lib/api/endpoints/documents';import ArchivedBadge from '@/components/common/ArchivedBadge';import { Button } from '@/components/ui/button';import { documentPath } from '@/utils/paths';diff --git a/apps/web/src/components/common/IntegrationIcon.tsx b/apps/web/src/components/common/IntegrationIcon.tsxindex 4a21ab3c..047483b4 100644--- a/apps/web/src/components/common/IntegrationIcon.tsx+++ b/apps/web/src/components/common/IntegrationIcon.tsx@@ -1,4 +1,4 @@-import type { IntegrationMeta } from '@/lib/api';+import type { IntegrationMeta } from '@/lib/api/endpoints/integrations';import { cn } from '@/lib/utils';// A small square monogram for an integration: the first one or two letters of itsdiff --git a/apps/web/src/components/common/agent-chat/AgentChatMessage.tsx b/apps/web/src/components/common/agent-chat/AgentChatMessage.tsxindex 74520b2c..c2d4199d 100644--- a/apps/web/src/components/common/agent-chat/AgentChatMessage.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatMessage.tsx@@ -2,7 +2,7 @@import type { ChatMessage } from '@/hooks/useAgentChat';import { cn } from '@/lib/utils';-import type { AiChatPart, AiChatToolPart } from '@/lib/api';+import type { AiChatPart, AiChatToolPart } from '@/lib/api/endpoints/agentChat';import { formatLongDate, formatTime } from '@/utils/dates';import Markdown from '@/components/common/Markdown';import { Bubble, BubbleContent } from '@/components/ui/bubble';diff --git a/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx b/apps/web/src/components/common/agent-chat/AgentChatPanel.tsxindex 86a96a4d..9b4f077d 100644--- a/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx@@ -2,8 +2,8 @@import { useRef, useState, type ReactNode } from 'react';import { ArrowUp, Bot, Paperclip, RotateCw, Square, X } from 'lucide-react';-import { uploadChatAttachment, type ChatAttachment } from '@/lib/api';-import type { AiAgent } from '@/lib/api';+import { uploadChatAttachment, type ChatAttachment } from '@/lib/api/endpoints/agentChat';+import type { AiAgent } from '@/lib/api/endpoints/agents';import type { ChatMessage, ChatStatus, PendingMessage } from '@/hooks/useAgentChat';import { AgentChatTranscript } from './AgentChatTranscript';import { AgentRunnerStatus } from './AgentRunnerStatus';diff --git a/apps/web/src/components/common/agent-chat/AgentChatToolCall.tsx b/apps/web/src/components/common/agent-chat/AgentChatToolCall.tsxindex cbe19ee1..914ebfcd 100644--- a/apps/web/src/components/common/agent-chat/AgentChatToolCall.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatToolCall.tsx@@ -2,7 +2,7 @@import { Wrench } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { AiChatToolPart } from '@/lib/api';+import type { AiChatToolPart } from '@/lib/api/endpoints/agentChat';import { Marker, MarkerContent, MarkerIcon } from '@/components/ui/marker';import AgentChatToolBlock from './AgentChatToolBlock';import AgentChatToolDisclosure from './AgentChatToolDisclosure';diff --git a/apps/web/src/components/common/agent-chat/AgentChatToolCalls.tsx b/apps/web/src/components/common/agent-chat/AgentChatToolCalls.tsxindex 485fdcc0..288893fa 100644--- a/apps/web/src/components/common/agent-chat/AgentChatToolCalls.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatToolCalls.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { AiChatToolPart } from '@/lib/api';+import type { AiChatToolPart } from '@/lib/api/endpoints/agentChat';import AgentChatToolCall from './AgentChatToolCall';import AgentChatToolDisclosure from './AgentChatToolDisclosure';diff --git a/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx b/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsxindex 88a74594..6ce32818 100644--- a/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx+++ b/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx@@ -1,6 +1,6 @@import { Radio } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { cn } from '@/lib/utils';import { formatDurationShort } from '@/utils/dates';import { isRunnerOnline } from './runnerOnline';diff --git a/apps/web/src/components/common/agent-chat/useImportDraft.ts b/apps/web/src/components/common/agent-chat/useImportDraft.tsindex 50437c6d..b8255cf6 100644--- a/apps/web/src/components/common/agent-chat/useImportDraft.ts+++ b/apps/web/src/components/common/agent-chat/useImportDraft.ts@@ -7,7 +7,7 @@ import {getImport,type ImportConfirmResult,type IssueImport,-} from '@/lib/api';+} from '@/lib/api/endpoints/imports';// One import draft, read by the review card the agent's ```issue-import fence// renders. The card is drawn wherever the answer sits, so it re-reads the draftdiff --git a/apps/web/src/components/common/attachments/AttachmentViewer.tsx b/apps/web/src/components/common/attachments/AttachmentViewer.tsxindex 052c7246..6614cb47 100644--- a/apps/web/src/components/common/attachments/AttachmentViewer.tsx+++ b/apps/web/src/components/common/attachments/AttachmentViewer.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import { type Attachment } from '@/lib/api';+import type { Attachment } from '@/lib/api/endpoints/attachments';import { isImage } from '@/components/common/editor/attachmentEmbed';import Modal from '@/components/common/overlay/Modal';import { cn } from '@/lib/utils';diff --git a/apps/web/src/components/common/fields/AssigneeSelect.tsx b/apps/web/src/components/common/fields/AssigneeSelect.tsxindex f7de3a42..c60ff3aa 100644--- a/apps/web/src/components/common/fields/AssigneeSelect.tsx+++ b/apps/web/src/components/common/fields/AssigneeSelect.tsx@@ -1,5 +1,5 @@import { CircleDashed } from 'lucide-react';-import type { Assignee } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';import { useSession } from '@/lib/auth-client';import Avatar from '@/components/common/Avatar';import { Pill } from './Pill';diff --git a/apps/web/src/components/common/fields/InitiativeStatusSelect.tsx b/apps/web/src/components/common/fields/InitiativeStatusSelect.tsxindex 5d73df19..9b0bc9a3 100644--- a/apps/web/src/components/common/fields/InitiativeStatusSelect.tsx+++ b/apps/web/src/components/common/fields/InitiativeStatusSelect.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { Check } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InitiativeStatus } from '@/lib/api';+import type { InitiativeStatus } from '@/lib/api/endpoints/initiatives';import { Command, CommandGroup, CommandItem, CommandList } from '@/components/ui/command';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { colorDot } from '@/components/common/fields/colorDot';diff --git a/apps/web/src/components/common/fields/LabelPicker.tsx b/apps/web/src/components/common/fields/LabelPicker.tsxindex 90e1fdd5..997d39f8 100644--- a/apps/web/src/components/common/fields/LabelPicker.tsx+++ b/apps/web/src/components/common/fields/LabelPicker.tsx@@ -1,5 +1,5 @@import { useMemo, type ReactNode } from 'react';-import type { Label, LabelGroup } from '@/lib/api';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';import { groupLabels } from '@/utils/labels';import {DropdownMenu,diff --git a/apps/web/src/components/common/fields/LabelPickerItem.tsx b/apps/web/src/components/common/fields/LabelPickerItem.tsxindex 9c1231a6..cb756205 100644--- a/apps/web/src/components/common/fields/LabelPickerItem.tsx+++ b/apps/web/src/components/common/fields/LabelPickerItem.tsx@@ -1,4 +1,4 @@-import type { Label } from '@/lib/api';+import type { Label } from '@/lib/api/endpoints/labels';import { DropdownMenuCheckboxItem } from '@/components/ui/dropdown-menu';import { colorDot } from './colorDot';diff --git a/apps/web/src/components/common/fields/LabelPickerSection.tsx b/apps/web/src/components/common/fields/LabelPickerSection.tsxindex 1f782c85..8f8e9e77 100644--- a/apps/web/src/components/common/fields/LabelPickerSection.tsx+++ b/apps/web/src/components/common/fields/LabelPickerSection.tsx@@ -1,4 +1,4 @@-import type { Label, LabelGroup } from '@/lib/api';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';import {DropdownMenuSub,DropdownMenuSubContent,diff --git a/apps/web/src/components/common/fields/LabelsSelect.tsx b/apps/web/src/components/common/fields/LabelsSelect.tsxindex 6d34f234..191a2044 100644--- a/apps/web/src/components/common/fields/LabelsSelect.tsx+++ b/apps/web/src/components/common/fields/LabelsSelect.tsx@@ -1,5 +1,5 @@import { Tag } from 'lucide-react';-import type { Label, LabelGroup } from '@/lib/api';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';import { Pill } from './Pill';import ReadOnlyPill from './ReadOnlyPill';import LabelPicker from './LabelPicker';diff --git a/apps/web/src/components/common/fields/StatusSelect.tsx b/apps/web/src/components/common/fields/StatusSelect.tsxindex 882633db..02977ef8 100644--- a/apps/web/src/components/common/fields/StatusSelect.tsx+++ b/apps/web/src/components/common/fields/StatusSelect.tsx@@ -1,5 +1,5 @@import { CircleDashed } from 'lucide-react';-import type { Column } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';import { colorDot } from './colorDot';import { Pill } from './Pill';import PopoverPick from './PopoverPick';diff --git a/apps/web/src/components/common/fields/TypeSelect.tsx b/apps/web/src/components/common/fields/TypeSelect.tsxindex 42401798..e87b5296 100644--- a/apps/web/src/components/common/fields/TypeSelect.tsx+++ b/apps/web/src/components/common/fields/TypeSelect.tsx@@ -1,5 +1,5 @@import { CircleDashed } from 'lucide-react';-import type { IssueType } from '@/lib/api';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import { colorDot } from './colorDot';import { Pill } from './Pill';import PopoverPick from './PopoverPick';diff --git a/apps/web/src/components/common/hotkeys/HotkeysEditor.tsx b/apps/web/src/components/common/hotkeys/HotkeysEditor.tsxindex d2f48163..4ee92bc9 100644--- a/apps/web/src/components/common/hotkeys/HotkeysEditor.tsx+++ b/apps/web/src/components/common/hotkeys/HotkeysEditor.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { HotkeyOverrides } from '@/lib/api';+import type { HotkeyOverrides } from '@/lib/api/endpoints/settings';import {HOTKEYS,HOTKEY_GROUPS,diff --git a/apps/web/src/components/common/overlay/InitiativeDialog.tsx b/apps/web/src/components/common/overlay/InitiativeDialog.tsxindex f8b0879c..9d3128c5 100644--- a/apps/web/src/components/common/overlay/InitiativeDialog.tsx+++ b/apps/web/src/components/common/overlay/InitiativeDialog.tsx@@ -1,7 +1,7 @@import { useRef, useState } from 'react';import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';-import type { Initiative, InitiativeStatus } from '@/lib/api';+import type { Initiative, InitiativeStatus } from '@/lib/api/endpoints/initiatives';import { initiativePath } from '@/utils/paths';import { parseDate } from '@/utils/dates';import { useCreateInitiative, useUpdateInitiative } from '@/services/initiatives.service';diff --git a/apps/web/src/components/common/overlay/IssuePickerDialog.tsx b/apps/web/src/components/common/overlay/IssuePickerDialog.tsxindex d80cf032..0a11a560 100644--- a/apps/web/src/components/common/overlay/IssuePickerDialog.tsx+++ b/apps/web/src/components/common/overlay/IssuePickerDialog.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { Hash } from 'lucide-react';-import { type IssueSearchHit } from '@/lib/api';+import type { IssueSearchHit } from '@/lib/api/endpoints/issues';import { useDebouncedValue } from '@/hooks/useDebouncedValue';import { useIssueSearchQuery } from '@/services/issues.service';import {diff --git a/apps/web/src/components/common/page/MembersEmptyState.tsx b/apps/web/src/components/common/page/MembersEmptyState.tsxindex 876eb0e3..26c95623 100644--- a/apps/web/src/components/common/page/MembersEmptyState.tsx+++ b/apps/web/src/components/common/page/MembersEmptyState.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { MemberKind } from '@/lib/api';+import type { MemberKind } from '@/lib/api/endpoints/members';import { EmptyState } from '@/components/common/page/EmptyState';export default function MembersEmptyState({diff --git a/apps/web/src/components/common/permissions/AccessCard.tsx b/apps/web/src/components/common/permissions/AccessCard.tsxindex b0288fcb..a5befcfc 100644--- a/apps/web/src/components/common/permissions/AccessCard.tsx+++ b/apps/web/src/components/common/permissions/AccessCard.tsx@@ -2,7 +2,7 @@import type { ReactNode } from 'react';import { useTranslations } from 'next-intl';-import type { PermissionCatalog, Permissions } from '@/lib/api';+import type { PermissionCatalog, Permissions } from '@/lib/api/endpoints/roles';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import DisclosureCard from '@/components/common/DisclosureCard';import PermissionMatrix from './PermissionMatrix';diff --git a/apps/web/src/components/common/permissions/MemberAccessCard.tsx b/apps/web/src/components/common/permissions/MemberAccessCard.tsxindex 99cfdbeb..d50c69ca 100644--- a/apps/web/src/components/common/permissions/MemberAccessCard.tsx+++ b/apps/web/src/components/common/permissions/MemberAccessCard.tsx@@ -3,7 +3,7 @@import type { ReactNode } from 'react';import { Bot } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { PermissionCatalog, Permissions } from '@/lib/api';+import type { PermissionCatalog, Permissions } from '@/lib/api/endpoints/roles';import Avatar from '@/components/common/Avatar';import { Badge } from '@/components/ui/badge';import AccessCard from './AccessCard';diff --git a/apps/web/src/components/common/permissions/PermissionMatrix.tsx b/apps/web/src/components/common/permissions/PermissionMatrix.tsxindex 8942c282..de7e29d0 100644--- a/apps/web/src/components/common/permissions/PermissionMatrix.tsx+++ b/apps/web/src/components/common/permissions/PermissionMatrix.tsx@@ -2,7 +2,7 @@import { Fragment, useMemo } from 'react';import { Check, Minus } from 'lucide-react';-import type { PermissionCatalog, Permissions } from '@/lib/api';+import type { PermissionCatalog, Permissions } from '@/lib/api/endpoints/roles';import { useTranslations } from 'next-intl';import { catalogSupport, groupResources, orderActions } from '@/utils/permissions';import { usePermissionLabels } from '@/hooks/usePermissionLabels';diff --git a/apps/web/src/components/common/permissions/PermissionsPopover.tsx b/apps/web/src/components/common/permissions/PermissionsPopover.tsxindex fd7085f9..750ec996 100644--- a/apps/web/src/components/common/permissions/PermissionsPopover.tsx+++ b/apps/web/src/components/common/permissions/PermissionsPopover.tsx@@ -3,7 +3,7 @@import { Fragment } from 'react';import { Check, ListChecks } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { PermissionResource, Permissions } from '@/lib/api';+import type { PermissionResource, Permissions } from '@/lib/api/endpoints/roles';import { ACTION_ORDER, groupResources } from '@/utils/permissions';import { usePermissionLabels } from '@/hooks/usePermissionLabels';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/components/common/permissions/RequireFeature.tsx b/apps/web/src/components/common/permissions/RequireFeature.tsxindex b1fe3abc..ae319c97 100644--- a/apps/web/src/components/common/permissions/RequireFeature.tsx+++ b/apps/web/src/components/common/permissions/RequireFeature.tsx@@ -3,7 +3,7 @@import type { ReactNode } from 'react';import Link from 'next/link';import { useParams } from 'next/navigation';-import type { ProjectFeatures } from '@/lib/api';+import type { ProjectFeatures } from '@/lib/api/endpoints/settings';import { settingsPath } from '@/utils/paths';import { usePermissions } from '@/hooks/usePermissions';import { useProjectFeatures } from '@/hooks/useProjectFeatures';diff --git a/apps/web/src/components/common/permissions/RequirePermission.tsx b/apps/web/src/components/common/permissions/RequirePermission.tsxindex 4cb87864..8c2a7cf9 100644--- a/apps/web/src/components/common/permissions/RequirePermission.tsx+++ b/apps/web/src/components/common/permissions/RequirePermission.tsx@@ -3,7 +3,7 @@import type { ReactNode } from 'react';import { useTranslations } from 'next-intl';import { usePermissions } from '@/hooks/usePermissions';-import type { PermissionAction, PermissionResource } from '@/lib/api';+import type { PermissionAction, PermissionResource } from '@/lib/api/endpoints/roles';// Gates a whole page or section: renders children when the current user may perform// `action` on `resource`, otherwise a short access message. The API enforces thediff --git a/apps/web/src/components/layout/AppSidebar.tsx b/apps/web/src/components/layout/AppSidebar.tsxindex 8c22190c..c7707be7 100644--- a/apps/web/src/components/layout/AppSidebar.tsx+++ b/apps/web/src/components/layout/AppSidebar.tsx@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';import { usePathname } from 'next/navigation';import { Braces, Server, Shield } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Project } from '@/lib/api';+import type { Project } from '@/lib/api/endpoints/projects';import { useSession } from '@/lib/auth-client';import { apiDocsPath, godPath, mcpServerPath } from '@/utils/paths';import { GOD_SECTIONS } from '@/utils/godSections';diff --git a/apps/web/src/components/layout/CommandLayer.tsx b/apps/web/src/components/layout/CommandLayer.tsxindex 432d6d08..c80b3880 100644--- a/apps/web/src/components/layout/CommandLayer.tsx+++ b/apps/web/src/components/layout/CommandLayer.tsx@@ -1,4 +1,4 @@-import type { Project } from '@/lib/api';+import type { Project } from '@/lib/api/endpoints/projects';import type { WorkItemsView } from '@/utils/viewTypes';import type { CommandSection } from '@/utils/commands';import { useShell } from '@/context/shellContext';diff --git a/apps/web/src/components/layout/CommandPaletteIssues.tsx b/apps/web/src/components/layout/CommandPaletteIssues.tsxindex b0badfca..940820e1 100644--- a/apps/web/src/components/layout/CommandPaletteIssues.tsx+++ b/apps/web/src/components/layout/CommandPaletteIssues.tsx@@ -1,6 +1,6 @@import { Hash } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { IssueSearchHit } from '@/lib/api';+import type { IssueSearchHit } from '@/lib/api/endpoints/issues';import { ISSUE_PREFIX } from '@/utils/commandFilter';import { CommandGroup, CommandItem, CommandSeparator } from '@/components/ui/command';import ArchivedBadge from '@/components/common/ArchivedBadge';diff --git a/apps/web/src/components/layout/CopyProjectOptions.tsx b/apps/web/src/components/layout/CopyProjectOptions.tsxindex ebb70716..418be161 100644--- a/apps/web/src/components/layout/CopyProjectOptions.tsx+++ b/apps/web/src/components/layout/CopyProjectOptions.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import { type CopyProjectIncludeKey } from '@/lib/api';+import type { CopyProjectIncludeKey } from '@/lib/api/endpoints/teams';import { Checkbox } from '@/components/ui/checkbox';export type CopyInclude = Record<CopyProjectIncludeKey, boolean>;diff --git a/apps/web/src/components/layout/CustomFieldMenu.tsx b/apps/web/src/components/layout/CustomFieldMenu.tsxindex 76ceec31..f6a89406 100644--- a/apps/web/src/components/layout/CustomFieldMenu.tsx+++ b/apps/web/src/components/layout/CustomFieldMenu.tsx@@ -1,7 +1,8 @@import { useState } from 'react';import { ChevronDown, ChevronRight, MoreHorizontal } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { CustomField, IssueType } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import type { PropertyKey } from '@/utils/viewSettings';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import CustomFieldRow from '@/components/layout/CustomFieldRow';diff --git a/apps/web/src/components/layout/CustomFieldRow.tsx b/apps/web/src/components/layout/CustomFieldRow.tsxindex c8b02ed8..ec4779bc 100644--- a/apps/web/src/components/layout/CustomFieldRow.tsx+++ b/apps/web/src/components/layout/CustomFieldRow.tsx@@ -1,5 +1,5 @@import { Check } from 'lucide-react';-import type { CustomField } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';import { customFieldKey, type PropertyKey } from '@/utils/viewSettings';// One selectable custom field in the picker.diff --git a/apps/web/src/components/layout/DisplayCalendarRows.tsx b/apps/web/src/components/layout/DisplayCalendarRows.tsxindex 3b1d4249..a532c156 100644--- a/apps/web/src/components/layout/DisplayCalendarRows.tsx+++ b/apps/web/src/components/layout/DisplayCalendarRows.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { CustomField } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';import {customFieldKey,type BuiltinDateField,diff --git a/apps/web/src/components/layout/DisplayGroupingRows.tsx b/apps/web/src/components/layout/DisplayGroupingRows.tsxindex a67f780f..9d061b8a 100644--- a/apps/web/src/components/layout/DisplayGroupingRows.tsx+++ b/apps/web/src/components/layout/DisplayGroupingRows.tsx@@ -1,6 +1,6 @@import { ArrowDownNarrowWide, ArrowUpNarrowWide } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { CustomField } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';import { SORT_FIELDS, type SortField, type WorkItemsView } from '@/utils/viewTypes';import {customFieldKey,diff --git a/apps/web/src/components/layout/DisplayPopover.tsx b/apps/web/src/components/layout/DisplayPopover.tsxindex 19487ca1..2cac2eda 100644--- a/apps/web/src/components/layout/DisplayPopover.tsx+++ b/apps/web/src/components/layout/DisplayPopover.tsx@@ -1,7 +1,8 @@import { useState } from 'react';import { SlidersHorizontal } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { CustomField, IssueType } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import type { ViewSettings } from '@/utils/viewSettings';import type { WorkItemsView } from '@/utils/viewTypes';import { cn } from '@/lib/utils';diff --git a/apps/web/src/components/layout/DisplayPropertiesSection.tsx b/apps/web/src/components/layout/DisplayPropertiesSection.tsxindex fcc1496e..fd333229 100644--- a/apps/web/src/components/layout/DisplayPropertiesSection.tsx+++ b/apps/web/src/components/layout/DisplayPropertiesSection.tsx@@ -1,6 +1,7 @@import { useTranslations } from 'next-intl';import { byKey } from '@/utils/messageKey';-import type { CustomField, IssueType } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import {offeredDisplayProperties,type PropertyKey,diff --git a/apps/web/src/components/layout/DisplaySettingsBody.tsx b/apps/web/src/components/layout/DisplaySettingsBody.tsxindex 244525e1..1c3e394c 100644--- a/apps/web/src/components/layout/DisplaySettingsBody.tsx+++ b/apps/web/src/components/layout/DisplaySettingsBody.tsx@@ -1,4 +1,5 @@-import type { CustomField, IssueType } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import type { WorkItemsView } from '@/utils/viewTypes';import type { ViewSettings } from '@/utils/viewSettings';import DisplayCalendarRows from '@/components/layout/DisplayCalendarRows';diff --git a/apps/web/src/components/layout/FilterBar.tsx b/apps/web/src/components/layout/FilterBar.tsxindex 4bb00080..c5857458 100644--- a/apps/web/src/components/layout/FilterBar.tsx+++ b/apps/web/src/components/layout/FilterBar.tsx@@ -1,7 +1,8 @@import { useState } from 'react';import { Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectDetail, CustomField } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import type { FilterCondition, FilterSet } from '@/utils/filters';import type { FieldSpec } from '@/utils/filterFields';import { newCondition, useFilterFields } from '@/hooks/useFilterFields';diff --git a/apps/web/src/components/layout/FilterConditionPill.tsx b/apps/web/src/components/layout/FilterConditionPill.tsxindex 3cf0cb15..67e17642 100644--- a/apps/web/src/components/layout/FilterConditionPill.tsx+++ b/apps/web/src/components/layout/FilterConditionPill.tsx@@ -1,6 +1,6 @@import { X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import type { FilterCondition, FilterOperator, FilterValue } from '@/utils/filters';import { OPERATORS_BY_KIND, type FieldSpec } from '@/utils/filterFields';import { useFilterFields } from '@/hooks/useFilterFields';diff --git a/apps/web/src/components/layout/FilterValueEditor.tsx b/apps/web/src/components/layout/FilterValueEditor.tsxindex a45672f1..151d6cc3 100644--- a/apps/web/src/components/layout/FilterValueEditor.tsx+++ b/apps/web/src/components/layout/FilterValueEditor.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import type { FilterCondition, FilterValue } from '@/utils/filters';import type { FieldSpec } from '@/utils/filterFields';import { useFilterFields } from '@/hooks/useFilterFields';diff --git a/apps/web/src/components/layout/IssueBreadcrumb.tsx b/apps/web/src/components/layout/IssueBreadcrumb.tsxindex 03b5b918..dbc32556 100644--- a/apps/web/src/components/layout/IssueBreadcrumb.tsx+++ b/apps/web/src/components/layout/IssueBreadcrumb.tsx@@ -1,6 +1,6 @@import Link from 'next/link';import { ChevronRight } from 'lucide-react';-import type { IssueRef } from '@/lib/api';+import type { IssueRef } from '@/lib/api/endpoints/issues';import { issuePath, projectPath } from '@/utils/paths';// The header title on an issue page: project name › issue identifier, with thediff --git a/apps/web/src/components/layout/MobileViewSwitcher.tsx b/apps/web/src/components/layout/MobileViewSwitcher.tsxindex fbaff097..6d7b5c22 100644--- a/apps/web/src/components/layout/MobileViewSwitcher.tsx+++ b/apps/web/src/components/layout/MobileViewSwitcher.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { Check, ChevronDown, Layers, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { View } from '@/lib/api';+import type { View } from '@/lib/api/endpoints/views';import { cn } from '@/lib/utils';import { ViewIcon } from '@/utils/viewIcons';import {diff --git a/apps/web/src/components/layout/ProjectSwitcher.tsx b/apps/web/src/components/layout/ProjectSwitcher.tsxindex c215c9cb..a0b6619b 100644--- a/apps/web/src/components/layout/ProjectSwitcher.tsx+++ b/apps/web/src/components/layout/ProjectSwitcher.tsx@@ -2,7 +2,8 @@ import { useState } from 'react';import Link from 'next/link';import { useTranslations } from 'next-intl';import { ChevronsUpDown, UserPlus, Users } from 'lucide-react';-import type { Project, Team } from '@/lib/api';+import type { Team } from '@/lib/api/endpoints/teams';+import type { Project } from '@/lib/api/endpoints/projects';import { useTeamsQuery } from '@/services/teams.service';import { manageTeamsPath } from '@/utils/paths';import ItsAPlanMark from '@/components/brand/ItsAPlanMark';diff --git a/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsx b/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsxindex bcb545ed..05115968 100644--- a/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsx+++ b/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsx@@ -1,6 +1,6 @@import { Check, ChevronRight, SquareKanban, Users } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Project } from '@/lib/api';+import type { Project } from '@/lib/api/endpoints/projects';import { cn } from '@/lib/utils';import { Badge } from '@/components/ui/badge';import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';diff --git a/apps/web/src/components/layout/SavedViewTab.tsx b/apps/web/src/components/layout/SavedViewTab.tsxindex 130fe177..f91dcc1d 100644--- a/apps/web/src/components/layout/SavedViewTab.tsx+++ b/apps/web/src/components/layout/SavedViewTab.tsx@@ -4,7 +4,8 @@ import { useSortable } from '@dnd-kit/sortable';import { CSS } from '@dnd-kit/utilities';import { Globe, MoreHorizontal, Pencil, Star, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import { api, type View } from '@/lib/api';+import type { View } from '@/lib/api/endpoints/views';+import { enableViewShare, disableViewShare } from '@/lib/api/endpoints/share';import { qk } from '@/services/queryKeys';import { useSetViewFavorite } from '@/services/views.service';import { cn } from '@/lib/utils';@@ -46,12 +47,12 @@ export default function SavedViewTab({// and shareExtended (which the dialog reads) stay in sync. The same call creates// the link and flips how much a live one exposes.async function share(extended: boolean) {- const { token } = await api.enableViewShare(view.id, extended);+ const { token } = await enableViewShare(view.id, extended);await qc.invalidateQueries({ queryKey: qk.views(projectKey) });return token;}async function disableShare() {- await api.disableViewShare(view.id);+ await disableViewShare(view.id);await qc.invalidateQueries({ queryKey: qk.views(projectKey) });}// Reordering views is a views edit; disable dragging without it.diff --git a/apps/web/src/components/layout/Shell.tsx b/apps/web/src/components/layout/Shell.tsxindex 128a8376..46dfeb9f 100644--- a/apps/web/src/components/layout/Shell.tsx+++ b/apps/web/src/components/layout/Shell.tsx@@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation';import { useInitiativeOptionsQuery } from '@/services/initiatives.service';import { useIssueBySeqQuery } from '@/services/issues.service';import { useAccountPreferences } from '@/services/preferences.service';-import type { IssueOpenMode } from '@/lib/api';+import type { IssueOpenMode } from '@/lib/api/endpoints/userPreferences';import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts';import { useOverlays } from '@/hooks/useOverlays';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/components/layout/ShellHeaderTitle.tsx b/apps/web/src/components/layout/ShellHeaderTitle.tsxindex b02a03a4..7461073c 100644--- a/apps/web/src/components/layout/ShellHeaderTitle.tsx+++ b/apps/web/src/components/layout/ShellHeaderTitle.tsx@@ -1,6 +1,6 @@import { useTranslations } from 'next-intl';import { SETTINGS_SECTIONS } from '@/utils/settingsSections';-import type { IssueRef } from '@/lib/api';+import type { IssueRef } from '@/lib/api/endpoints/issues';import type { ShellRoute } from '@/hooks/useShellRoute';import { useSettingsSectionText } from '@/hooks/useSectionLabels';import CycleBreadcrumb from '@/components/layout/CycleBreadcrumb';diff --git a/apps/web/src/components/layout/ShellOverlays.tsx b/apps/web/src/components/layout/ShellOverlays.tsxindex 757300bf..a10c572b 100644--- a/apps/web/src/components/layout/ShellOverlays.tsx+++ b/apps/web/src/components/layout/ShellOverlays.tsx@@ -1,7 +1,7 @@'use client';import { useRouter } from 'next/navigation';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { issuePath, projectPath } from '@/utils/paths';import type { useOverlays } from '@/hooks/useOverlays';import NewProjectModal from '@/components/layout/NewProjectModal';diff --git a/apps/web/src/components/layout/TableProperties.tsx b/apps/web/src/components/layout/TableProperties.tsxindex 84129a4f..251ab01b 100644--- a/apps/web/src/components/layout/TableProperties.tsx+++ b/apps/web/src/components/layout/TableProperties.tsx@@ -3,7 +3,8 @@ import { closestCenter, DndContext, type DragEndEvent } from '@dnd-kit/core';import { arrayMove, rectSortingStrategy, SortableContext } from '@dnd-kit/sortable';import { useTranslations } from 'next-intl';import { byKey } from '@/utils/messageKey';-import type { CustomField, IssueType } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import { useStripSortSensors } from '@/lib/dnd';import {DISPLAY_PROPERTIES,diff --git a/apps/web/src/components/layout/ViewTabLabel.tsx b/apps/web/src/components/layout/ViewTabLabel.tsxindex 1f6b8fc7..9e633238 100644--- a/apps/web/src/components/layout/ViewTabLabel.tsx+++ b/apps/web/src/components/layout/ViewTabLabel.tsx@@ -1,5 +1,5 @@import { Star } from 'lucide-react';-import type { View } from '@/lib/api';+import type { View } from '@/lib/api/endpoints/views';import { ViewIcon } from '@/utils/viewIcons';// The saved-view label (icon + name), shown in the tab and in the drag overlay. Adiff --git a/apps/web/src/components/layout/ViewTabs.tsx b/apps/web/src/components/layout/ViewTabs.tsxindex 996678f5..b896a47e 100644--- a/apps/web/src/components/layout/ViewTabs.tsx+++ b/apps/web/src/components/layout/ViewTabs.tsx@@ -9,7 +9,7 @@ import {import { horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable';import { Filter, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { View } from '@/lib/api';+import type { View } from '@/lib/api/endpoints/views';import { useStripSortSensors } from '@/lib/dnd';import { usePermissions } from '@/hooks/usePermissions';import AllViewTab, { ALL_DROP_ID } from '@/components/layout/AllViewTab';diff --git a/apps/web/src/components/providers.tsx b/apps/web/src/components/providers.tsxindex c9976357..832826d2 100644--- a/apps/web/src/components/providers.tsx+++ b/apps/web/src/components/providers.tsx@@ -5,7 +5,7 @@ import { useRef, useState, type ReactNode } from 'react';import { useLocale, useTranslations } from 'next-intl';import { Direction } from 'radix-ui';import { toast } from 'sonner';-import { ApiError } from '@/lib/api';+import { ApiError } from '@/lib/api/core/client';import { localeDirection, type Locale } from '@/i18n/locales';import { HotkeysProvider } from '@/context/useHotkeys';import { SyncProvider } from '@/context/syncContext';diff --git a/apps/web/src/components/session-scope.tsx b/apps/web/src/components/session-scope.tsxindex efbc8256..3c2935bf 100644--- a/apps/web/src/components/session-scope.tsx+++ b/apps/web/src/components/session-scope.tsx@@ -3,7 +3,7 @@import { useEffect, useRef } from 'react';import { useQueryClient } from '@tanstack/react-query';import { useSession } from '@/lib/auth-client';-import { markSignedIn } from '@/lib/api';+import { markSignedIn } from '@/lib/api/core/client';// Everything cached in this tab belongs to one account. Signing in as somebody else// without a full page load (sign out and back in, a magic link opened in the samediff --git a/apps/web/src/context/shellContext.ts b/apps/web/src/context/shellContext.tsindex 30715271..e2ac0f13 100644--- a/apps/web/src/context/shellContext.ts+++ b/apps/web/src/context/shellContext.ts@@ -1,5 +1,8 @@import { createContext, useContext } from 'react';-import type { CustomField, IssueOpenMode, ProjectDetail, View } from '@/lib/api';+import type { IssueOpenMode } from '@/lib/api/endpoints/userPreferences';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { View } from '@/lib/api/endpoints/views';import type { NewIssueDefaults } from '@/utils/project';import type { useViewEditor } from '@/hooks/useViewEditor';diff --git a/apps/web/src/context/syncContext.tsx b/apps/web/src/context/syncContext.tsxindex f6160cca..945ade90 100644--- a/apps/web/src/context/syncContext.tsx+++ b/apps/web/src/context/syncContext.tsx@@ -10,7 +10,7 @@ import {type ReactNode,} from 'react';import { useQuery, useQueryClient, type QueryKey } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getRevs } from '@/lib/api/endpoints/sync';// One poll for the whole app. Every screen that wants to stay live registers the// scopes it depends on (see useLiveRefresh); this provider asks the API for their@@ -48,7 +48,7 @@ export function SyncProvider({ children }: { children: ReactNode }) {// The scope list is part of the key: a screen that mounts starts its own read// right away instead of waiting for the next tick.queryKey: ['sync', 'rev', scopes],- queryFn: () => api.getRevs(scopes),+ queryFn: () => getRevs(scopes),enabled: scopes.length > 0,refetchInterval: POLL_MS,// Never served as fresh, but kept for one interval: with gcTime 0 a remount indiff --git a/apps/web/src/features/account/AccountPreferencesPage.tsx b/apps/web/src/features/account/AccountPreferencesPage.tsxindex a224a0fb..ca53c295 100644--- a/apps/web/src/features/account/AccountPreferencesPage.tsx+++ b/apps/web/src/features/account/AccountPreferencesPage.tsx@@ -9,7 +9,7 @@ import type {IssueStatsView,StartPage,ThemePreference,-} from '@/lib/api';+} from '@/lib/api/endpoints/userPreferences';import { LOCALES, LOCALE_LABELS } from '@/i18n/locales';import {useAccountPreferencesQuery,diff --git a/apps/web/src/features/account/components/preferences/AccountHotkeys.tsx b/apps/web/src/features/account/components/preferences/AccountHotkeys.tsxindex 35009a83..81cfad55 100644--- a/apps/web/src/features/account/components/preferences/AccountHotkeys.tsx+++ b/apps/web/src/features/account/components/preferences/AccountHotkeys.tsx@@ -1,4 +1,4 @@-import type { HotkeyOverrides } from '@/lib/api';+import type { HotkeyOverrides } from '@/lib/api/endpoints/settings';import { applyOverrides, DEFAULT_COMBOS } from '@/utils/hotkeys';import { useHotkeySettingsQuery } from '@/services/hotkeys.service';import HotkeysEditor from '@/components/common/hotkeys/HotkeysEditor';diff --git a/apps/web/src/features/account/services/profile.service.ts b/apps/web/src/features/account/services/profile.service.tsindex 950b6860..1254e389 100644--- a/apps/web/src/features/account/services/profile.service.ts+++ b/apps/web/src/features/account/services/profile.service.ts@@ -1,4 +1,4 @@-import { API_URL, apiFailure } from '@/lib/api';+import { API_URL, apiFailure } from '@/lib/api/core/client';// Uploads an avatar image to the API (stored in MinIO). The API writes the new URL// to the user's image column itself and returns it, so the caller only has to readdiff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsxindex 429cc9a8..95add087 100644--- a/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsx+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsx@@ -2,7 +2,7 @@import { Bot, ChevronDown } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { DropdownMenu, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';import { InputGroupButton } from '@/components/ui/input-group';import { AiChatAgentMenu } from '../shared/AiChatAgentMenu';diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsxindex edcd688e..65dec830 100644--- a/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsx+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsx@@ -3,7 +3,7 @@import { useCallback } from 'react';import { MessageSquareOff } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { AgentContextSize } from '@/components/common/agent-chat/AgentContextSize';import { InputGroupButton } from '@/components/ui/input-group';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsxindex ede1a0fe..4e90bfca 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsx@@ -2,7 +2,7 @@import { Bot, Check } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import {DropdownMenuContent,DropdownMenuItem,diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsxindex a3f0d53f..c277beaa 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsx@@ -2,7 +2,7 @@import { useEffect, useRef, type ReactNode } from 'react';import { useQueryClient } from '@tanstack/react-query';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { useAgentChat } from '@/hooks/useAgentChat';import { useAgentThreadMessagesQuery } from '@/services/aiAgents.service';import { qk } from '@/services/queryKeys';diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatThreadItem.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatThreadItem.tsxindex 95688dc4..d91ce69d 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatThreadItem.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatThreadItem.tsx@@ -6,7 +6,7 @@ import { useTranslations } from 'next-intl';import { formatShortDate } from '@/utils/dates';import { cn } from '@/lib/utils';import { Button } from '@/components/ui/button';-import type { AiChatThread } from '@/lib/api';+import type { AiChatThread } from '@/lib/api/endpoints/agentChat';// One conversation in the chat history list. The controls sit next to the row rather// than inside it, so the row stays a single button. `query` is the search the list wasdiff --git a/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsxindex 558d0ad1..c85eb489 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsx@@ -12,7 +12,7 @@ import {import { useDebouncedValue } from '@/hooks/useDebouncedValue';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import { Input } from '@/components/ui/input';-import type { AiChatThread } from '@/lib/api';+import type { AiChatThread } from '@/lib/api/endpoints/agentChat';import { AiChatThreadItem } from './AiChatThreadItem';import { AiChatThreadItemSkeleton } from './AiChatThreadItemSkeleton';diff --git a/apps/web/src/features/ai-chat/hooks/useShownThread.ts b/apps/web/src/features/ai-chat/hooks/useShownThread.tsindex 6842a1ee..ed6d5190 100644--- a/apps/web/src/features/ai-chat/hooks/useShownThread.ts+++ b/apps/web/src/features/ai-chat/hooks/useShownThread.ts@@ -1,6 +1,6 @@'use client';-import type { AiChatThread } from '@/lib/api';+import type { AiChatThread } from '@/lib/api/endpoints/agentChat';import { useLoadedAgentThreads } from '@/services/aiAgents.service';// The saved thread the panel is showing, which is what carries the facts about thediff --git a/apps/web/src/features/ai-chat/utils/agentModelLabel.ts b/apps/web/src/features/ai-chat/utils/agentModelLabel.tsindex d1f86c18..43b80fae 100644--- a/apps/web/src/features/ai-chat/utils/agentModelLabel.ts+++ b/apps/web/src/features/ai-chat/utils/agentModelLabel.ts@@ -1,4 +1,4 @@-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';// The agent's model as shown in the chat UI: the model key plus its provider's// catalog label. `providerLabel` maps a provider key to that label.diff --git a/apps/web/src/features/api-docs/components/ScalarReference.tsx b/apps/web/src/features/api-docs/components/ScalarReference.tsxindex 29354c0e..5eac9db3 100644--- a/apps/web/src/features/api-docs/components/ScalarReference.tsx+++ b/apps/web/src/features/api-docs/components/ScalarReference.tsx@@ -3,7 +3,7 @@import { ApiReferenceReact } from '@scalar/api-reference-react';import '@scalar/api-reference-react/style.css';import './scalar-theme.css';-import { API_URL } from '@/lib/api';+import { API_URL } from '@/lib/api/core/client';// The API mounts /docs/json outside the session guard, so the browser fetches it// directly.diff --git a/apps/web/src/features/auth/components/login/AuthLoginForm.tsx b/apps/web/src/features/auth/components/login/AuthLoginForm.tsxindex fa9755e4..4055ab38 100644--- a/apps/web/src/features/auth/components/login/AuthLoginForm.tsx+++ b/apps/web/src/features/auth/components/login/AuthLoginForm.tsx@@ -58,7 +58,7 @@ export default function AuthLoginForm() {const passwordEnabled = authConfig?.emailPassword !== false;const params = useSearchParams();const justReset = params.get('reset') === '1';- // `apiFailure` in lib/api.ts sends the browser here with ?expired=1 after the API+ // `apiFailure` in lib/api/core/client.ts sends the browser here with ?expired=1 after the API// refused the session, so the screen can say why the user is back on it.const sessionExpired = params.get('expired') === '1';// A Google sign-in or a confirmation link that could not complete comes back herediff --git a/apps/web/src/features/cycles/components/CycleActions.tsx b/apps/web/src/features/cycles/components/CycleActions.tsxindex e857d77b..504b46a4 100644--- a/apps/web/src/features/cycles/components/CycleActions.tsx+++ b/apps/web/src/features/cycles/components/CycleActions.tsx@@ -11,7 +11,7 @@ import {Trash2,} from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { cyclesPath } from '@/utils/paths';import { usePermissions } from '@/hooks/usePermissions';import { unfinishedCount } from '@/utils/progress';diff --git a/apps/web/src/features/cycles/components/CycleForm.tsx b/apps/web/src/features/cycles/components/CycleForm.tsxindex 486a8447..8e03ca65 100644--- a/apps/web/src/features/cycles/components/CycleForm.tsx+++ b/apps/web/src/features/cycles/components/CycleForm.tsx@@ -3,7 +3,8 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { ApiError, type Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';+import { ApiError } from '@/lib/api/core/client';import { addDays, daysBetween, parseDate, toDateStr } from '@/utils/dates';import Modal from '@/components/common/overlay/Modal';import DatePill from '@/components/common/fields/DatePill';diff --git a/apps/web/src/features/cycles/components/CycleFormDialog.tsx b/apps/web/src/features/cycles/components/CycleFormDialog.tsxindex da491b4c..ffee09d3 100644--- a/apps/web/src/features/cycles/components/CycleFormDialog.tsx+++ b/apps/web/src/features/cycles/components/CycleFormDialog.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import Modal from '@/components/common/overlay/Modal';import { useCyclesQuery } from '@/services/cycles.service';import { cycleDefaults } from '../utils/cycleDefaults';diff --git a/apps/web/src/features/cycles/components/CycleRange.tsx b/apps/web/src/features/cycles/components/CycleRange.tsxindex c7981ad0..1841361c 100644--- a/apps/web/src/features/cycles/components/CycleRange.tsx+++ b/apps/web/src/features/cycles/components/CycleRange.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { formatShortDate } from '@/utils/dates';// The days a cycle ran. One that was finished before its planned end date ended ondiff --git a/apps/web/src/features/cycles/components/DeleteCycleDialog.tsx b/apps/web/src/features/cycles/components/DeleteCycleDialog.tsxindex 79ea872a..7c0823bb 100644--- a/apps/web/src/features/cycles/components/DeleteCycleDialog.tsx+++ b/apps/web/src/features/cycles/components/DeleteCycleDialog.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { useDeleteCycle } from '@/services/cycles.service';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';diff --git a/apps/web/src/features/cycles/components/FinishCycleDialog.tsx b/apps/web/src/features/cycles/components/FinishCycleDialog.tsxindex 11f5f837..c57a8366 100644--- a/apps/web/src/features/cycles/components/FinishCycleDialog.tsx+++ b/apps/web/src/features/cycles/components/FinishCycleDialog.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { formatShortDate } from '@/utils/dates';import { unfinishedCount } from '@/utils/progress';import { useFinishCycle } from '@/services/cycles.service';diff --git a/apps/web/src/features/cycles/components/StartNextCycleDialog.tsx b/apps/web/src/features/cycles/components/StartNextCycleDialog.tsxindex e9e7d978..30954df2 100644--- a/apps/web/src/features/cycles/components/StartNextCycleDialog.tsx+++ b/apps/web/src/features/cycles/components/StartNextCycleDialog.tsx@@ -1,6 +1,6 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { formatShortDate } from '@/utils/dates';import { unfinishedCount } from '@/utils/progress';import { useStartNextCycle } from '@/services/cycles.service';diff --git a/apps/web/src/features/cycles/components/TransferIssuesDialog.tsx b/apps/web/src/features/cycles/components/TransferIssuesDialog.tsxindex 6be7adc3..d64a3839 100644--- a/apps/web/src/features/cycles/components/TransferIssuesDialog.tsx+++ b/apps/web/src/features/cycles/components/TransferIssuesDialog.tsx@@ -3,7 +3,8 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { ApiError, type Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';+import { ApiError } from '@/lib/api/core/client';import { formatShortDate } from '@/utils/dates';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/cycles/components/detail/CycleHeader.tsx b/apps/web/src/features/cycles/components/detail/CycleHeader.tsxindex bdb66cef..cfa9c379 100644--- a/apps/web/src/features/cycles/components/detail/CycleHeader.tsx+++ b/apps/web/src/features/cycles/components/detail/CycleHeader.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { colorDot } from '@/components/common/fields/colorDot';import ProgressBar from '@/components/common/ProgressBar';diff --git a/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx b/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsxindex 14416236..37be479f 100644--- a/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx+++ b/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx@@ -1,7 +1,7 @@'use client';import { useMemo } from 'react';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { useShell } from '@/context/shellContext';import { applyFilters } from '@/utils/filters';import { defaultsFromFilters } from '@/utils/project';diff --git a/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx b/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsxindex 77bcfb56..20365b49 100644--- a/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx+++ b/apps/web/src/features/cycles/components/list/CycleInfoPopover.tsx@@ -3,7 +3,7 @@import Link from 'next/link';import { useTranslations } from 'next-intl';import { ArrowRight, Info } from 'lucide-react';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { cyclePath } from '@/utils/paths';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { colorDot } from '@/components/common/fields/colorDot';diff --git a/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx b/apps/web/src/features/cycles/components/list/CycleTableArchive.tsxindex 68c1aae9..d2612c51 100644--- a/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx+++ b/apps/web/src/features/cycles/components/list/CycleTableArchive.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import ShowMoreButton from '@/components/common/ShowMoreButton';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import type { CompletedCycles } from '../../hooks/useCompletedCycles';diff --git a/apps/web/src/features/cycles/components/list/CycleTableRow.tsx b/apps/web/src/features/cycles/components/list/CycleTableRow.tsxindex 4ba9bed1..30c279dd 100644--- a/apps/web/src/features/cycles/components/list/CycleTableRow.tsx+++ b/apps/web/src/features/cycles/components/list/CycleTableRow.tsx@@ -1,6 +1,6 @@import Link from 'next/link';import { useRouter } from 'next/navigation';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { cyclePath } from '@/utils/paths';import ProgressBar from '@/components/common/ProgressBar';import CycleActions from '../CycleActions';diff --git a/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsx b/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsxindex feb3ce7e..e409ac39 100644--- a/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsx+++ b/apps/web/src/features/cycles/components/list/CycleTimelineRow.tsx@@ -1,5 +1,5 @@import { CalendarRange, CircleDashed } from 'lucide-react';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { formatShortDate } from '@/utils/dates';import { progressPercent } from '@/utils/progress';diff --git a/apps/web/src/features/cycles/components/list/CyclesList.tsx b/apps/web/src/features/cycles/components/list/CyclesList.tsxindex 4795de8d..2c2bac68 100644--- a/apps/web/src/features/cycles/components/list/CyclesList.tsx+++ b/apps/web/src/features/cycles/components/list/CyclesList.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import type { CyclesView } from '@/utils/paths';import { Button } from '@/components/ui/button';import { EmptyState } from '@/components/common/page/EmptyState';diff --git a/apps/web/src/features/cycles/components/list/CyclesTable.tsx b/apps/web/src/features/cycles/components/list/CyclesTable.tsxindex f2c24b09..d2627224 100644--- a/apps/web/src/features/cycles/components/list/CyclesTable.tsx+++ b/apps/web/src/features/cycles/components/list/CyclesTable.tsx@@ -2,7 +2,7 @@import { Fragment, useState } from 'react';import { useTranslations } from 'next-intl';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { usePersistedSet } from '@/hooks/usePersistedSet';import { groupCycles } from '../../utils/cycleGroups';import type { CompletedCycles } from '../../hooks/useCompletedCycles';diff --git a/apps/web/src/features/cycles/components/list/CyclesTimeline.tsx b/apps/web/src/features/cycles/components/list/CyclesTimeline.tsxindex 514f5105..e620057e 100644--- a/apps/web/src/features/cycles/components/list/CyclesTimeline.tsx+++ b/apps/web/src/features/cycles/components/list/CyclesTimeline.tsx@@ -1,6 +1,6 @@import { useEffect, useRef } from 'react';import { useRouter } from 'next/navigation';-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { cyclePath } from '@/utils/paths';import { usePermissions } from '@/hooks/usePermissions';import { useElementWidth } from '@/hooks/useElementWidth';diff --git a/apps/web/src/features/cycles/hooks/useCompletedCycles.ts b/apps/web/src/features/cycles/hooks/useCompletedCycles.tsindex 2c095d98..6f541b29 100644--- a/apps/web/src/features/cycles/hooks/useCompletedCycles.ts+++ b/apps/web/src/features/cycles/hooks/useCompletedCycles.ts@@ -1,4 +1,4 @@-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { useCompletedCyclesQuery } from '@/services/cycles.service';// The archive as the table reads it: the pages loaded so far as one list, how manydiff --git a/apps/web/src/features/cycles/hooks/useCycleDrag.ts b/apps/web/src/features/cycles/hooks/useCycleDrag.tsindex 3b1bc18d..90efaf9d 100644--- a/apps/web/src/features/cycles/hooks/useCycleDrag.ts+++ b/apps/web/src/features/cycles/hooks/useCycleDrag.ts@@ -1,7 +1,8 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { ApiError, type Cycle, type CyclePatch } from '@/lib/api';+import type { Cycle, CyclePatch } from '@/lib/api/endpoints/cycles';+import { ApiError } from '@/lib/api/core/client';import { addDays, daysBetween, toDateStr } from '@/utils/dates';import { useUpdateCycle } from '@/services/cycles.service';import { cycleSpan, dateWindow, movableEnds } from '../utils/cycleDates';diff --git a/apps/web/src/features/cycles/utils/cycleDates.ts b/apps/web/src/features/cycles/utils/cycleDates.tsindex 6f914687..ecd520f5 100644--- a/apps/web/src/features/cycles/utils/cycleDates.ts+++ b/apps/web/src/features/cycles/utils/cycleDates.ts@@ -1,4 +1,4 @@-import type { Cycle, CycleStatus } from '@/lib/api';+import type { Cycle, CycleStatus } from '@/lib/api/endpoints/cycles';import { addDays, daysBetween, parseDate } from '@/utils/dates';export interface CycleSpan {diff --git a/apps/web/src/features/cycles/utils/cycleDefaults.ts b/apps/web/src/features/cycles/utils/cycleDefaults.tsindex a5a60282..437c6b2a 100644--- a/apps/web/src/features/cycles/utils/cycleDefaults.ts+++ b/apps/web/src/features/cycles/utils/cycleDefaults.ts@@ -1,4 +1,4 @@-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { addDays, daysBetween, toDateStr } from '@/utils/dates';import { occupiedUntil } from './cycleRanges';diff --git a/apps/web/src/features/cycles/utils/cycleGroups.ts b/apps/web/src/features/cycles/utils/cycleGroups.tsindex d268d776..3926b8f6 100644--- a/apps/web/src/features/cycles/utils/cycleGroups.ts+++ b/apps/web/src/features/cycles/utils/cycleGroups.ts@@ -1,4 +1,4 @@-import type { Cycle, CycleStatus } from '@/lib/api';+import type { Cycle, CycleStatus } from '@/lib/api/endpoints/cycles';import { CYCLE_STATUS_META, CYCLE_STATUS_ORDER } from '@/utils/cycleMeta';export interface CycleGroup {diff --git a/apps/web/src/features/cycles/utils/cycleRanges.ts b/apps/web/src/features/cycles/utils/cycleRanges.tsindex c8d6b4db..9fd5f6d1 100644--- a/apps/web/src/features/cycles/utils/cycleRanges.ts+++ b/apps/web/src/features/cycles/utils/cycleRanges.ts@@ -1,4 +1,4 @@-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { addDays, parseDate } from '@/utils/dates';// The date-picker limits that mirror the API's rule: cycles of one project may notdiff --git a/apps/web/src/features/cycles/utils/cycleTimeline.ts b/apps/web/src/features/cycles/utils/cycleTimeline.tsindex 7ef4ab69..9aa22db9 100644--- a/apps/web/src/features/cycles/utils/cycleTimeline.ts+++ b/apps/web/src/features/cycles/utils/cycleTimeline.ts@@ -1,4 +1,4 @@-import type { Cycle } from '@/lib/api';+import type { Cycle } from '@/lib/api/endpoints/cycles';import { buildDayTrack, type DayTrack } from '@/utils/timelineTrack';import { cycleSpan, type CycleSpan } from './cycleDates';import { groupCycles, type CycleGroup } from './cycleGroups';diff --git a/apps/web/src/features/dashboards/components/DashboardTab.tsx b/apps/web/src/features/dashboards/components/DashboardTab.tsxindex 2b3e25dd..d48629ac 100644--- a/apps/web/src/features/dashboards/components/DashboardTab.tsx+++ b/apps/web/src/features/dashboards/components/DashboardTab.tsx@@ -3,7 +3,7 @@ import { useSortable } from '@dnd-kit/sortable';import { CSS } from '@dnd-kit/utilities';import { LayoutDashboard, MoreHorizontal, Pencil, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Dashboard } from '@/lib/api';+import type { Dashboard } from '@/lib/api/endpoints/dashboards';import { cn } from '@/lib/utils';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';diff --git a/apps/web/src/features/dashboards/components/DashboardTabs.tsx b/apps/web/src/features/dashboards/components/DashboardTabs.tsxindex b98cec0b..e688dee4 100644--- a/apps/web/src/features/dashboards/components/DashboardTabs.tsx+++ b/apps/web/src/features/dashboards/components/DashboardTabs.tsx@@ -9,7 +9,7 @@ import {import { SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';import { LayoutDashboard, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Dashboard } from '@/lib/api';+import type { Dashboard } from '@/lib/api/endpoints/dashboards';import { useStripSortSensors } from '@/lib/dnd';import { usePermissions } from '@/hooks/usePermissions';import DashboardTab from './DashboardTab';diff --git a/apps/web/src/features/dashboards/components/WidgetBody.tsx b/apps/web/src/features/dashboards/components/WidgetBody.tsxindex 8ab00899..412bbc03 100644--- a/apps/web/src/features/dashboards/components/WidgetBody.tsx+++ b/apps/web/src/features/dashboards/components/WidgetBody.tsx@@ -1,4 +1,4 @@-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import type { WidgetInstance } from '@/utils/dashboardWidgets';import StatWidget from './widgets/StatWidget';import BreakdownWidget from './widgets/BreakdownWidget';diff --git a/apps/web/src/features/dashboards/components/WidgetGrid.tsx b/apps/web/src/features/dashboards/components/WidgetGrid.tsxindex c767cfba..0118a5b9 100644--- a/apps/web/src/features/dashboards/components/WidgetGrid.tsx+++ b/apps/web/src/features/dashboards/components/WidgetGrid.tsx@@ -2,7 +2,7 @@ import { useMemo } from 'react';import GridLayout, { useContainerWidth, verticalCompactor, type Layout } from 'react-grid-layout';import { Direction } from 'radix-ui';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { cn } from '@/lib/utils';import {COL_GAP,diff --git a/apps/web/src/features/dashboards/components/widgets/ActivityFeedWidget.tsx b/apps/web/src/features/dashboards/components/widgets/ActivityFeedWidget.tsxindex e463986c..223ae661 100644--- a/apps/web/src/features/dashboards/components/widgets/ActivityFeedWidget.tsx+++ b/apps/web/src/features/dashboards/components/widgets/ActivityFeedWidget.tsx@@ -2,7 +2,7 @@ import { useMemo } from 'react';import Link from 'next/link';import { useTranslations } from 'next-intl';import { formatDateTime } from '@/utils/dates';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { issuePath } from '@/utils/paths';import { EMPTY_FILTER_SET, applyFilters, isActiveFilterSet, type FilterSet } from '@/utils/filters';import type { WidgetConfig } from '@/utils/dashboardWidgets';diff --git a/apps/web/src/features/dashboards/components/widgets/AgentRunsWidget.tsx b/apps/web/src/features/dashboards/components/widgets/AgentRunsWidget.tsxindex f62d6486..34fff370 100644--- a/apps/web/src/features/dashboards/components/widgets/AgentRunsWidget.tsx+++ b/apps/web/src/features/dashboards/components/widgets/AgentRunsWidget.tsx@@ -2,7 +2,7 @@ import Link from 'next/link';import { useTranslations } from 'next-intl';import { formatDateTime } from '@/utils/dates';import { issuePath } from '@/utils/paths';-import type { AgentRunFeedItem } from '@/lib/api';+import type { AgentRunFeedItem } from '@/lib/api/endpoints/analytics';import type { WidgetConfig } from '@/utils/dashboardWidgets';import { Badge } from '@/components/ui/badge';import { Skeleton } from '@/components/ui/skeleton';diff --git a/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsx b/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsxindex aacbf5a3..54df6783 100644--- a/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsx+++ b/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsx@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';import { createPortal } from 'react-dom';import { useTranslations } from 'next-intl';import { cn } from '@/lib/utils';-import type { PulseUnit } from '@/lib/api';+import type { PulseUnit } from '@/lib/api/endpoints/analytics';import type { WidgetConfig } from '@/utils/dashboardWidgets';import { Skeleton } from '@/components/ui/skeleton';import { usePulseQuery } from '../../services/analytics.service';diff --git a/apps/web/src/features/dashboards/components/widgets/PulseWidgetSettings.tsx b/apps/web/src/features/dashboards/components/widgets/PulseWidgetSettings.tsxindex d951e67d..c2b11393 100644--- a/apps/web/src/features/dashboards/components/widgets/PulseWidgetSettings.tsx+++ b/apps/web/src/features/dashboards/components/widgets/PulseWidgetSettings.tsx@@ -1,6 +1,6 @@import { useTranslations } from 'next-intl';import { cn } from '@/lib/utils';-import type { PulseUnit } from '@/lib/api';+import type { PulseUnit } from '@/lib/api/endpoints/analytics';import type { WidgetConfig } from '@/utils/dashboardWidgets';const UNIT_OPTIONS: PulseUnit[] = ['hour', 'day', 'week'];diff --git a/apps/web/src/features/dashboards/hooks/useDashboardEditor.ts b/apps/web/src/features/dashboards/hooks/useDashboardEditor.tsindex 1f67a729..9811d5ef 100644--- a/apps/web/src/features/dashboards/hooks/useDashboardEditor.ts+++ b/apps/web/src/features/dashboards/hooks/useDashboardEditor.ts@@ -1,7 +1,7 @@import { useState } from 'react';import { arrayMove } from '@dnd-kit/sortable';import { useTranslations } from 'next-intl';-import type { Dashboard } from '@/lib/api';+import type { Dashboard } from '@/lib/api/endpoints/dashboards';import {createWidget,defaultDashboardLayout,diff --git a/apps/web/src/features/dashboards/services/analytics.service.ts b/apps/web/src/features/dashboards/services/analytics.service.tsindex 6f5d2f0f..220402d5 100644--- a/apps/web/src/features/dashboards/services/analytics.service.ts+++ b/apps/web/src/features/dashboards/services/analytics.service.ts@@ -4,28 +4,38 @@// dashboards feature reads these.import { useQuery } from '@tanstack/react-query';-import { api, type PulseUnit } from '@/lib/api';+import {+ type PulseUnit,+ getBreakdown,+ getPulse,+ getThroughput,+ getAgentRuns,+ getAgentRunStats,+ getWebhookStats,+ getAgentWorkload,+ listActivity,+} from '@/lib/api/endpoints/analytics';import type { BreakdownBy } from '@/utils/dashboardWidgets';import { qk } from '@/services/queryKeys';export function useBreakdownQuery(projectKey: string, by: BreakdownBy) {return useQuery({queryKey: qk.analytics(projectKey, 'breakdown', { by }),- queryFn: () => api.getBreakdown(projectKey, by),+ queryFn: () => getBreakdown(projectKey, by),});}export function usePulseQuery(projectKey: string, unit: PulseUnit, columns: number) {return useQuery({queryKey: qk.analytics(projectKey, 'pulse', { unit, columns }),- queryFn: () => api.getPulse(projectKey, unit, columns),+ queryFn: () => getPulse(projectKey, unit, columns),});}export function useThroughputQuery(projectKey: string, weeks: number) {return useQuery({queryKey: qk.analytics(projectKey, 'throughput', { weeks }),- queryFn: () => api.getThroughput(projectKey, weeks),+ queryFn: () => getThroughput(projectKey, weeks),});}@@ -35,28 +45,28 @@ export function useAgentRunsQuery() {return useQuery({queryKey: qk.analytics(projectKey, 'agent-runs', params),- queryFn: () => api.getAgentRuns(projectKey, params),+ queryFn: () => getAgentRuns(projectKey, params),});}export function useAgentRunStatsQuery(projectKey: string, days: number) {return useQuery({queryKey: qk.analytics(projectKey, 'agent-run-stats', { days }),- queryFn: () => api.getAgentRunStats(projectKey, days),+ queryFn: () => getAgentRunStats(projectKey, days),});}export function useWebhookStatsQuery(projectKey: string, days: number) {return useQuery({queryKey: qk.analytics(projectKey, 'webhook-stats', { days }),- queryFn: () => api.getWebhookStats(projectKey, days),+ queryFn: () => getWebhookStats(projectKey, days),});}export function useAgentWorkloadQuery(projectKey: string) {return useQuery({queryKey: qk.analytics(projectKey, 'agent-workload'),- queryFn: () => api.getAgentWorkload(projectKey),+ queryFn: () => getAgentWorkload(projectKey),});}@@ -66,6 +76,6 @@ export function useActivityFeedQuery() {return useQuery({queryKey: qk.analytics(projectKey, 'activity', params),- queryFn: () => api.listActivity(projectKey, params),+ queryFn: () => listActivity(projectKey, params),});}diff --git a/apps/web/src/features/documents/DocumentsPage.tsx b/apps/web/src/features/documents/DocumentsPage.tsxindex 824d557e..854f2c53 100644--- a/apps/web/src/features/documents/DocumentsPage.tsx+++ b/apps/web/src/features/documents/DocumentsPage.tsx@@ -9,7 +9,7 @@ import { revScope } from '@/utils/revScopes';import { qk } from '@/services/queryKeys';import { documentsPath, documentPath } from '@/utils/paths';import { Skeleton } from '@/components/ui/skeleton';-import { ApiError } from '@/lib/api';+import { ApiError } from '@/lib/api/core/client';import {useCreateDocument,useDeleteDocument,diff --git a/apps/web/src/features/documents/components/DocumentBreadcrumbs.tsx b/apps/web/src/features/documents/components/DocumentBreadcrumbs.tsxindex ac07b454..93317197 100644--- a/apps/web/src/features/documents/components/DocumentBreadcrumbs.tsx+++ b/apps/web/src/features/documents/components/DocumentBreadcrumbs.tsx@@ -1,7 +1,7 @@import { ChevronRight } from 'lucide-react';import Link from 'next/link';import { useTranslations } from 'next-intl';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { cn } from '@/lib/utils';import { documentPath, documentsPath } from '@/utils/paths';diff --git a/apps/web/src/features/documents/components/DocumentEditor.tsx b/apps/web/src/features/documents/components/DocumentEditor.tsxindex d362adae..6391b7d3 100644--- a/apps/web/src/features/documents/components/DocumentEditor.tsx+++ b/apps/web/src/features/documents/components/DocumentEditor.tsx@@ -2,7 +2,7 @@import { useEffect, useRef, useState } from 'react';import type { Editor } from '@tiptap/react';-import type { ProjectDocument, ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocument, ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { useRelativeTime } from '@/context/relativeTimeContext';import { useSession } from '@/lib/auth-client';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx b/apps/web/src/features/documents/components/DocumentEditorCanvas.tsxindex 2ca12dc1..4dfebcd3 100644--- a/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx+++ b/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx@@ -2,7 +2,7 @@import { useRef, type RefObject } from 'react';import type { Editor } from '@tiptap/react';-import type { ProjectDocument } from '@/lib/api';+import type { ProjectDocument } from '@/lib/api/endpoints/documents';import { cn } from '@/lib/utils';import { useTranslations } from 'next-intl';import DocumentMarkdownEditor, { insertDocumentImage } from './DocumentMarkdownEditor';diff --git a/apps/web/src/features/documents/components/DocumentEditorHeader.tsx b/apps/web/src/features/documents/components/DocumentEditorHeader.tsxindex 0844cce2..78130a8c 100644--- a/apps/web/src/features/documents/components/DocumentEditorHeader.tsx+++ b/apps/web/src/features/documents/components/DocumentEditorHeader.tsx@@ -1,6 +1,6 @@import { ArrowLeft, Check, CircleAlert, LoaderCircle, PanelRight, RefreshCw } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectDocument, ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocument, ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import { cn } from '@/lib/utils';import type { DocumentSaveState } from '../hooks/useDocumentDraft';diff --git a/apps/web/src/features/documents/components/DocumentEditorInspector.tsx b/apps/web/src/features/documents/components/DocumentEditorInspector.tsxindex 7846c6ac..53f60367 100644--- a/apps/web/src/features/documents/components/DocumentEditorInspector.tsx+++ b/apps/web/src/features/documents/components/DocumentEditorInspector.tsx@@ -1,7 +1,7 @@'use client';import type { Editor } from '@tiptap/react';-import type { ProjectDocument } from '@/lib/api';+import type { ProjectDocument } from '@/lib/api/endpoints/documents';import {Sheet,SheetContent,diff --git a/apps/web/src/features/documents/components/DocumentHistoryDialog.tsx b/apps/web/src/features/documents/components/DocumentHistoryDialog.tsxindex 52735604..a9a776b7 100644--- a/apps/web/src/features/documents/components/DocumentHistoryDialog.tsx+++ b/apps/web/src/features/documents/components/DocumentHistoryDialog.tsx@@ -3,7 +3,7 @@import { useEffect, useRef, useState } from 'react';import { useQuery } from '@tanstack/react-query';import { Check, History, Loader2, RefreshCw, RotateCcw } from 'lucide-react';-import { api, type ProjectDocument } from '@/lib/api';+import { type ProjectDocument, getDocumentRevision } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import {Dialog,@@ -59,7 +59,7 @@ export default function DocumentHistoryDialog({const canInteract = canInteractWithDocumentHistory(restoringRevisionId);const selectedRevision = useQuery({queryKey: ['documents', projectKey, 'document', documentId, 'revision', selectedRevisionId],- queryFn: () => api.getDocumentRevision(projectKey, documentId, selectedRevisionId!),+ queryFn: () => getDocumentRevision(projectKey, documentId, selectedRevisionId!),enabled: open && selectedRevisionId !== null,});diff --git a/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx b/apps/web/src/features/documents/components/DocumentOptionsMenu.tsxindex a547aea7..c6a199c1 100644--- a/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx+++ b/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx@@ -17,7 +17,7 @@ import {Trash2,} from 'lucide-react';import { toast } from 'sonner';-import type { ProjectDocument } from '@/lib/api';+import type { ProjectDocument } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/documents/components/DocumentPickerDialog.tsx b/apps/web/src/features/documents/components/DocumentPickerDialog.tsxindex bacb8b2b..8e3057c5 100644--- a/apps/web/src/features/documents/components/DocumentPickerDialog.tsx+++ b/apps/web/src/features/documents/components/DocumentPickerDialog.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { FileText, Lock } from 'lucide-react';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { useDebouncedValue } from '@/hooks/useDebouncedValue';import {CommandDialog,diff --git a/apps/web/src/features/documents/components/DocumentSidePanel.tsx b/apps/web/src/features/documents/components/DocumentSidePanel.tsxindex feabb8a7..a8dd6155 100644--- a/apps/web/src/features/documents/components/DocumentSidePanel.tsx+++ b/apps/web/src/features/documents/components/DocumentSidePanel.tsx@@ -18,7 +18,7 @@ import {X,} from 'lucide-react';import { toast } from 'sonner';-import type { ProjectDocument } from '@/lib/api';+import type { ProjectDocument } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import { Skeleton } from '@/components/ui/skeleton';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';diff --git a/apps/web/src/features/documents/components/DocumentTree.tsx b/apps/web/src/features/documents/components/DocumentTree.tsxindex fb663247..cf3b9c72 100644--- a/apps/web/src/features/documents/components/DocumentTree.tsx+++ b/apps/web/src/features/documents/components/DocumentTree.tsx@@ -17,7 +17,7 @@ import {} from '@dnd-kit/sortable';import { FilePlus2, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import { projectedDocumentMove } from '../utils/documentMove';import SortableDocumentRow from './SortableDocumentRow';diff --git a/apps/web/src/features/documents/components/DocumentsIndex.tsx b/apps/web/src/features/documents/components/DocumentsIndex.tsxindex 844b64eb..5321740f 100644--- a/apps/web/src/features/documents/components/DocumentsIndex.tsx+++ b/apps/web/src/features/documents/components/DocumentsIndex.tsx@@ -14,7 +14,7 @@ import {SlidersHorizontal,} from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/documents/components/SortableDocumentRow.tsx b/apps/web/src/features/documents/components/SortableDocumentRow.tsxindex af10ef8b..4d462b1a 100644--- a/apps/web/src/features/documents/components/SortableDocumentRow.tsx+++ b/apps/web/src/features/documents/components/SortableDocumentRow.tsx@@ -6,7 +6,7 @@ import { CSS } from '@dnd-kit/utilities';import { ChevronRight, FileText, GripVertical, LockKeyhole, Plus, Star } from 'lucide-react';import Link from 'next/link';import { useTranslations } from 'next-intl';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { Button } from '@/components/ui/button';import { cn } from '@/lib/utils';import { documentPath } from '@/utils/paths';diff --git a/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx b/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsxindex 9116a37c..c25e874d 100644--- a/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx+++ b/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx@@ -4,11 +4,10 @@ import { act } from 'react';import type { Root } from 'react-dom/client';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { JSDOM } from 'jsdom';-import type { ProjectDocument } from '@/lib/api';+import type { ProjectDocument } from '@/lib/api/endpoints/documents';type UseDocumentDraft = (typeof import('./useDocumentDraft'))['useDocumentDraft'];type DocumentDraftController = ReturnType<UseDocumentDraft>;-type Api = (typeof import('@/lib/api'))['api'];const replacedGlobals = ['window',@@ -22,11 +21,17 @@ let dom: JSDOM;let root: Root;let queryClient: QueryClient;let useDocumentDraft: UseDocumentDraft;-let api: Api;-let originalUpdateDocument: Api['updateDocument'];+let originalFetch: typeof fetch;let controller: DocumentDraftController | null;let originalGlobalDescriptors: Map<string, PropertyDescriptor | undefined>;+// Holds the save in flight until the test resolves it. The update is stubbed at+// fetch rather than at updateDocument: an ES module binding cannot be reassigned.+function stubSave(update: Promise<ProjectDocument>): void {+ globalThis.fetch = (() =>+ update.then((document) => new Response(JSON.stringify(document)))) as typeof fetch;+}+function projectDocument(version: number, content: string): ProjectDocument {return {id: 42,@@ -112,8 +117,7 @@ beforeEach(async () => {});({ useDocumentDraft } = await import('./useDocumentDraft'));- ({ api } = await import('@/lib/api'));- originalUpdateDocument = api.updateDocument;+ originalFetch = globalThis.fetch;queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });controller = null;@@ -124,7 +128,7 @@ beforeEach(async () => {});afterEach(() => {- api.updateDocument = originalUpdateDocument;+ globalThis.fetch = originalFetch;act(() => root.unmount());queryClient.clear();dom.window.close();@@ -177,7 +181,7 @@ describe('useDocumentDraft', () => {const update = new Promise<ProjectDocument>((resolve) => {resolveUpdate = resolve;});- api.updateDocument = () => update;+ stubSave(update);act(() => controller!.setContent('Snapshot A', { type: 'doc', content: [] }));let savePromise!: Promise<ProjectDocument | null>;@@ -222,7 +226,7 @@ describe('useDocumentDraft', () => {const update = new Promise<ProjectDocument>((resolve) => {resolveUpdate = resolve;});- api.updateDocument = () => update;+ stubSave(update);act(() => controller!.setContent('Saved by tab A', { type: 'doc', content: [] }));let savePromise!: Promise<ProjectDocument | null>;@@ -276,7 +280,7 @@ describe('useDocumentDraft', () => {const update = new Promise<ProjectDocument>((resolve) => {resolveUpdate = resolve;});- api.updateDocument = () => update;+ stubSave(update);act(() => tabA.setContent('Saved by tab A', { type: 'doc', content: [] }));let savePromise!: Promise<ProjectDocument | null>;diff --git a/apps/web/src/features/documents/hooks/useDocumentDraft.ts b/apps/web/src/features/documents/hooks/useDocumentDraft.tsindex e43af3cc..5c5969af 100644--- a/apps/web/src/features/documents/hooks/useDocumentDraft.ts+++ b/apps/web/src/features/documents/hooks/useDocumentDraft.ts@@ -1,6 +1,6 @@import { useCallback, useEffect, useRef, useState } from 'react';-import type { ProjectDocument } from '@/lib/api';-import { ApiError } from '@/lib/api';+import type { ProjectDocument } from '@/lib/api/endpoints/documents';+import { ApiError } from '@/lib/api/core/client';import { uuid } from '@/utils/uuid';import { useUpdateDocument } from '../services/documents.service';diff --git a/apps/web/src/features/documents/services/documents.service.ts b/apps/web/src/features/documents/services/documents.service.tsindex 5581e91f..4566aa73 100644--- a/apps/web/src/features/documents/services/documents.service.ts+++ b/apps/web/src/features/documents/services/documents.service.ts@@ -1,6 +1,5 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import {- api,type DocumentIssueLink,type DocumentAsset,type IssueDocumentLink,@@ -9,7 +8,30 @@ import {type ProjectDocumentPatch,type ProjectDocumentRevisionSummary,type ProjectDocumentSummary,-} from '@/lib/api';+ listDocuments,+ getDocument,+ listDocumentIssueLinks,+ listIssueDocumentLinks,+ linkDocumentIssue,+ unlinkDocumentIssue,+ listInitiativeDocumentLinks,+ linkDocumentInitiative,+ unlinkDocumentInitiative,+ createDocument,+ duplicateDocument,+ setDocumentAccess,+ setDocumentLocked,+ archiveDocument,+ restoreDocument,+ setDocumentFavorite,+ listDocumentRevisions,+ listDocumentAssets,+ uploadDocumentAsset,+ deleteDocumentAsset,+ restoreDocumentRevision,+ updateDocument,+ deleteDocument,+} from '@/lib/api/endpoints/documents';import { qk } from '@/services/queryKeys';import { applyOptimisticDocumentMove } from '../utils/documentMove';@@ -25,7 +47,7 @@ function invalidateLists(qc: ReturnType<typeof useQueryClient>, projectKey: striexport function useDocumentsQuery(projectKey: string | null, q = '', archived = false) {return useQuery({queryKey: qk.documents(projectKey ?? '', q, archived),- queryFn: () => api.listDocuments(projectKey!, q || undefined, archived),+ queryFn: () => listDocuments(projectKey!, q || undefined, archived),enabled: projectKey != null,});}@@ -33,7 +55,7 @@ export function useDocumentsQuery(projectKey: string | null, q = '', archived =export function useDocumentQuery(projectKey: string | null, documentId: number | null) {return useQuery({queryKey: qk.document(projectKey ?? '', documentId ?? 0),- queryFn: () => api.getDocument(projectKey!, documentId!),+ queryFn: () => getDocument(projectKey!, documentId!),enabled: projectKey != null && documentId != null,refetchOnMount: 'always',});@@ -46,7 +68,7 @@ export function useDocumentIssueLinksQuery() {return useQuery<DocumentIssueLink[]>({queryKey: qk.documentIssueLinks(projectKey ?? '', documentId ?? 0),- queryFn: () => api.listDocumentIssueLinks(projectKey!, documentId!),+ queryFn: () => listDocumentIssueLinks(projectKey!, documentId!),enabled: enabled && projectKey != null && documentId != null,});}@@ -58,7 +80,7 @@ export function useIssueDocumentLinksQuery() {return useQuery<IssueDocumentLink[]>({queryKey: qk.issueDocumentLinks(projectKey ?? '', issueId ?? 0),- queryFn: () => api.listIssueDocumentLinks(projectKey!, issueId!),+ queryFn: () => listIssueDocumentLinks(projectKey!, issueId!),enabled: enabled && projectKey != null && issueId != null,});}@@ -67,7 +89,7 @@ export function useLinkDocumentIssue(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, issueId }: { documentId: number; issueId: number }) =>- api.linkDocumentIssue(projectKey!, documentId, issueId),+ linkDocumentIssue(projectKey!, documentId, issueId),onSuccess: (_link, { documentId, issueId }) => {if (!projectKey) return;void qc.invalidateQueries({ queryKey: qk.documentIssueLinks(projectKey, documentId) });@@ -80,7 +102,7 @@ export function useUnlinkDocumentIssue(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, issueId }: { documentId: number; issueId: number }) =>- api.unlinkDocumentIssue(projectKey!, documentId, issueId),+ unlinkDocumentIssue(projectKey!, documentId, issueId),onSuccess: (_result, { documentId, issueId }) => {if (!projectKey) return;void qc.invalidateQueries({ queryKey: qk.documentIssueLinks(projectKey, documentId) });@@ -96,7 +118,7 @@ export function useInitiativeDocumentLinksQuery() {return useQuery<IssueDocumentLink[]>({queryKey: qk.initiativeDocumentLinks(projectKey ?? '', initiativeId ?? 0),- queryFn: () => api.listInitiativeDocumentLinks(projectKey!, initiativeId!),+ queryFn: () => listInitiativeDocumentLinks(projectKey!, initiativeId!),enabled: enabled && projectKey != null && initiativeId != null,});}@@ -105,7 +127,7 @@ export function useLinkDocumentInitiative(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, initiativeId }: { documentId: number; initiativeId: number }) =>- api.linkDocumentInitiative(projectKey!, documentId, initiativeId),+ linkDocumentInitiative(projectKey!, documentId, initiativeId),onSuccess: (_link, { initiativeId }) => {if (!projectKey) return;void qc.invalidateQueries({ queryKey: qk.initiativeDocumentLinks(projectKey, initiativeId) });@@ -117,7 +139,7 @@ export function useUnlinkDocumentInitiative(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, initiativeId }: { documentId: number; initiativeId: number }) =>- api.unlinkDocumentInitiative(projectKey!, documentId, initiativeId),+ unlinkDocumentInitiative(projectKey!, documentId, initiativeId),onSuccess: (_result, { initiativeId }) => {if (!projectKey) return;void qc.invalidateQueries({ queryKey: qk.initiativeDocumentLinks(projectKey, initiativeId) });@@ -128,7 +150,7 @@ export function useUnlinkDocumentInitiative(projectKey: string | null) {export function useCreateDocument(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewProjectDocumentInput) => api.createDocument(projectKey!, input),+ mutationFn: (input: NewProjectDocumentInput) => createDocument(projectKey!, input),onSuccess: (document) => {if (!projectKey) return;qc.setQueryData<ProjectDocument>(qk.document(projectKey, document.id), document);@@ -150,7 +172,7 @@ export function useDuplicateDocument(projectKey: string | null) {version: number;title: string;parentId: number | null;- }) => api.duplicateDocument(projectKey!, documentId, { version, title, parentId }),+ }) => duplicateDocument(projectKey!, documentId, { version, title, parentId }),onSuccess: (document) => {if (!projectKey) return;qc.setQueryData<ProjectDocument>(qk.document(projectKey, document.id), document);@@ -193,7 +215,7 @@ export function useSetDocumentAccess(projectKey: string | null) {documentId: number;version: number;isPrivate: boolean;- }) => api.setDocumentAccess(projectKey!, documentId, { version, isPrivate }),+ }) => setDocumentAccess(projectKey!, documentId, { version, isPrivate }),);}@@ -201,7 +223,7 @@ export function useSetDocumentLocked(projectKey: string | null) {return useDocumentMutation(projectKey,({ documentId, version, locked }: { documentId: number; version: number; locked: boolean }) =>- api.setDocumentLocked(projectKey!, documentId, version, locked),+ setDocumentLocked(projectKey!, documentId, version, locked),);}@@ -209,7 +231,7 @@ export function useArchiveDocument(projectKey: string | null) {return useDocumentMutation(projectKey,({ documentId, version }: { documentId: number; version: number }) =>- api.archiveDocument(projectKey!, documentId, version),+ archiveDocument(projectKey!, documentId, version),);}@@ -217,7 +239,7 @@ export function useRestoreDocument(projectKey: string | null) {return useDocumentMutation(projectKey,({ documentId, version }: { documentId: number; version: number }) =>- api.restoreDocument(projectKey!, documentId, version),+ restoreDocument(projectKey!, documentId, version),);}@@ -225,7 +247,7 @@ export function useSetDocumentFavorite(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, isFavorite }: { documentId: number; isFavorite: boolean }) =>- api.setDocumentFavorite(projectKey!, documentId, isFavorite),+ setDocumentFavorite(projectKey!, documentId, isFavorite),onMutate: async ({ documentId, isFavorite }) => {if (!projectKey) return;await qc.cancelQueries({ queryKey: qk.documentListsForProject(projectKey) });@@ -266,7 +288,7 @@ export function useDocumentRevisionsQuery() {return useQuery<ProjectDocumentRevisionSummary[]>({queryKey: qk.documentRevisions(projectKey ?? '', documentId ?? 0),- queryFn: () => api.listDocumentRevisions(projectKey!, documentId!),+ queryFn: () => listDocumentRevisions(projectKey!, documentId!),enabled: enabled && projectKey != null && documentId != null,});}@@ -274,7 +296,7 @@ export function useDocumentRevisionsQuery(export function useDocumentAssetsQuery(projectKey: string | null, documentId: number | null) {return useQuery<DocumentAsset[]>({queryKey: qk.documentAssets(projectKey ?? '', documentId ?? 0),- queryFn: () => api.listDocumentAssets(projectKey!, documentId!),+ queryFn: () => listDocumentAssets(projectKey!, documentId!),enabled: projectKey != null && documentId != null,});}@@ -282,7 +304,7 @@ export function useDocumentAssetsQuery(projectKey: string | null, documentId: nuexport function useUploadDocumentAsset(projectKey: string | null, documentId: number | null) {const qc = useQueryClient();return useMutation({- mutationFn: (file: File) => api.uploadDocumentAsset(projectKey!, documentId!, file),+ mutationFn: (file: File) => uploadDocumentAsset(projectKey!, documentId!, file),onSuccess: (asset) => {if (!projectKey || documentId === null) return;qc.setQueryData<DocumentAsset[]>(qk.documentAssets(projectKey, documentId), (previous) => [@@ -296,7 +318,7 @@ export function useUploadDocumentAsset(projectKey: string | null, documentId: nuexport function useDeleteDocumentAsset(projectKey: string | null, documentId: number | null) {const qc = useQueryClient();return useMutation({- mutationFn: (publicId: string) => api.deleteDocumentAsset(projectKey!, documentId!, publicId),+ mutationFn: (publicId: string) => deleteDocumentAsset(projectKey!, documentId!, publicId),onSuccess: (_result, publicId) => {if (!projectKey || documentId === null) return;qc.setQueryData<DocumentAsset[]>(qk.documentAssets(projectKey, documentId), (previous) =>@@ -317,7 +339,7 @@ export function useRestoreDocumentRevision(projectKey: string | null) {documentId: number;revisionId: number;version: number;- }) => api.restoreDocumentRevision(projectKey!, documentId, revisionId, version),+ }) => restoreDocumentRevision(projectKey!, documentId, revisionId, version),onSuccess: (document) => {if (!projectKey) return;cacheDocument(qc, projectKey, document);@@ -330,7 +352,7 @@ export function useUpdateDocument(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, patch }: { documentId: number; patch: ProjectDocumentPatch }) =>- api.updateDocument(projectKey!, documentId, patch),+ updateDocument(projectKey!, documentId, patch),onSuccess: (document) => {if (!projectKey) return;qc.setQueryData<ProjectDocument>(qk.document(projectKey, document.id), document);@@ -365,7 +387,7 @@ export function useMoveDocument(projectKey: string | null) {previousSiblingId: number | null;nextSiblingId: number | null;}) =>- api.updateDocument(projectKey!, documentId, {+ updateDocument(projectKey!, documentId, {version,parentId,position,@@ -405,7 +427,7 @@ export function useDeleteDocument(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ documentId, version }: { documentId: number; version: number }) =>- api.deleteDocument(projectKey!, documentId, version),+ deleteDocument(projectKey!, documentId, version),onSuccess: (_result, { documentId }) => {if (!projectKey) return;qc.removeQueries({ queryKey: qk.document(projectKey, documentId) });diff --git a/apps/web/src/features/documents/utils/documentList.test.ts b/apps/web/src/features/documents/utils/documentList.test.tsindex 14056bdd..38f8962f 100644--- a/apps/web/src/features/documents/utils/documentList.test.ts+++ b/apps/web/src/features/documents/utils/documentList.test.ts@@ -1,6 +1,6 @@import assert from 'node:assert/strict';import { describe, test } from 'node:test';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { documentBelongsToTab } from './documentList';const document = {diff --git a/apps/web/src/features/documents/utils/documentList.ts b/apps/web/src/features/documents/utils/documentList.tsindex f66f8ebc..91641c6e 100644--- a/apps/web/src/features/documents/utils/documentList.ts+++ b/apps/web/src/features/documents/utils/documentList.ts@@ -1,4 +1,4 @@-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';export const DOCUMENT_LIST_TABS = ['favorites', 'public', 'private', 'archived'] as const;diff --git a/apps/web/src/features/documents/utils/documentMove.test.ts b/apps/web/src/features/documents/utils/documentMove.test.tsindex 1c6ce0b2..e5d7a188 100644--- a/apps/web/src/features/documents/utils/documentMove.test.ts+++ b/apps/web/src/features/documents/utils/documentMove.test.ts@@ -1,6 +1,6 @@import assert from 'node:assert/strict';import { describe, it } from 'node:test';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { applyOptimisticDocumentMove, projectedDocumentMove } from './documentMove';const page = (id: number, parentId: number | null, position: number): ProjectDocumentSummary =>diff --git a/apps/web/src/features/documents/utils/documentMove.ts b/apps/web/src/features/documents/utils/documentMove.tsindex 80f81695..aa894184 100644--- a/apps/web/src/features/documents/utils/documentMove.ts+++ b/apps/web/src/features/documents/utils/documentMove.ts@@ -1,4 +1,4 @@-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';export interface OptimisticDocumentMove {documentId: number;diff --git a/apps/web/src/features/documents/utils/documentTree.test.ts b/apps/web/src/features/documents/utils/documentTree.test.tsindex 61d25bdf..fa5a52ea 100644--- a/apps/web/src/features/documents/utils/documentTree.test.ts+++ b/apps/web/src/features/documents/utils/documentTree.test.ts@@ -1,6 +1,6 @@import assert from 'node:assert/strict';import { describe, it } from 'node:test';-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';import { documentAncestors } from './documentTree';function document(id: number, parentId: number | null, title: string): ProjectDocumentSummary {diff --git a/apps/web/src/features/documents/utils/documentTree.ts b/apps/web/src/features/documents/utils/documentTree.tsindex 65022959..68889dd4 100644--- a/apps/web/src/features/documents/utils/documentTree.ts+++ b/apps/web/src/features/documents/utils/documentTree.ts@@ -1,4 +1,4 @@-import type { ProjectDocumentSummary } from '@/lib/api';+import type { ProjectDocumentSummary } from '@/lib/api/endpoints/documents';export function documentAncestors(document: ProjectDocumentSummary,diff --git a/apps/web/src/features/god/GodEmailPage.tsx b/apps/web/src/features/god/GodEmailPage.tsxindex b30c8bfd..e8477260 100644--- a/apps/web/src/features/god/GodEmailPage.tsx+++ b/apps/web/src/features/god/GodEmailPage.tsx@@ -2,7 +2,7 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { InstanceEmailSettings } from '@/lib/api';+import type { InstanceEmailSettings } from '@/lib/api/endpoints/god';import { Button } from '@/components/ui/button';import GodEmailSettings from './components/email/GodEmailSettings';import GodSectionPage from './components/GodSectionPage';diff --git a/apps/web/src/features/god/GodGeneralPage.tsx b/apps/web/src/features/god/GodGeneralPage.tsxindex cd465fa5..2af0699e 100644--- a/apps/web/src/features/god/GodGeneralPage.tsx+++ b/apps/web/src/features/god/GodGeneralPage.tsx@@ -12,7 +12,7 @@ import {useInstanceProjectDefaultsQuery,useUpdateInstanceProjectDefaults,} from './services/god.service';-import type { ProjectDefaults } from '@/lib/api';+import type { ProjectDefaults } from '@/lib/api/endpoints/projects';export default function GodGeneralPage() {const query = useInstanceProjectDefaultsQuery();diff --git a/apps/web/src/features/god/GodHotkeysPage.tsx b/apps/web/src/features/god/GodHotkeysPage.tsxindex 9dae4267..e9dcbe3c 100644--- a/apps/web/src/features/god/GodHotkeysPage.tsx+++ b/apps/web/src/features/god/GodHotkeysPage.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { HotkeyOverrides } from '@/lib/api';+import type { HotkeyOverrides } from '@/lib/api/endpoints/settings';import { DEFAULT_COMBOS } from '@/utils/hotkeys';import HotkeysEditor from '@/components/common/hotkeys/HotkeysEditor';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';diff --git a/apps/web/src/features/god/GodStoragePage.tsx b/apps/web/src/features/god/GodStoragePage.tsxindex 51bedc41..7433f17a 100644--- a/apps/web/src/features/god/GodStoragePage.tsx+++ b/apps/web/src/features/god/GodStoragePage.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { StorageSettings } from '@/lib/api';+import type { StorageSettings } from '@/lib/api/endpoints/settings';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsSection from '@/components/common/page/SettingsSection';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/god/GodTelegramPage.tsx b/apps/web/src/features/god/GodTelegramPage.tsxindex 60831a7d..09de59cd 100644--- a/apps/web/src/features/god/GodTelegramPage.tsx+++ b/apps/web/src/features/god/GodTelegramPage.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { InstanceTelegramSettings } from '@/lib/api';+import type { InstanceTelegramSettings } from '@/lib/api/endpoints/god';import SettingsCard from '@/components/common/page/SettingsCard';import EnabledSwitch from '@/components/common/inputs/EnabledSwitch';import SecretInput from '@/components/common/inputs/SecretInput';diff --git a/apps/web/src/features/god/GodUsersPage.tsx b/apps/web/src/features/god/GodUsersPage.tsxindex 3844a61b..31293a3a 100644--- a/apps/web/src/features/god/GodUsersPage.tsx+++ b/apps/web/src/features/god/GodUsersPage.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { InstanceUserKind } from '@/lib/api';+import type { InstanceUserKind } from '@/lib/api/endpoints/god';import { useDebouncedValue } from '@/hooks/useDebouncedValue';import { usePaging } from '@/hooks/usePaging';import ListPager from '@/components/common/ListPager';diff --git a/apps/web/src/features/god/components/auth-provider/GodAuthProviderForm.tsx b/apps/web/src/features/god/components/auth-provider/GodAuthProviderForm.tsxindex 2449e1d5..1e60f25c 100644--- a/apps/web/src/features/god/components/auth-provider/GodAuthProviderForm.tsx+++ b/apps/web/src/features/god/components/auth-provider/GodAuthProviderForm.tsx@@ -2,7 +2,7 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { InstanceGoogleSettings, InstanceOidcSettings } from '@/lib/api';+import type { InstanceGoogleSettings, InstanceOidcSettings } from '@/lib/api/endpoints/god';import { Button } from '@/components/ui/button';import GodSectionPage from '../GodSectionPage';import GodGoogleSettings from './GodGoogleSettings';diff --git a/apps/web/src/features/god/components/authentication/GodAuthenticationForm.tsx b/apps/web/src/features/god/components/authentication/GodAuthenticationForm.tsxindex 1fc5a20d..3fcf40b1 100644--- a/apps/web/src/features/god/components/authentication/GodAuthenticationForm.tsx+++ b/apps/web/src/features/god/components/authentication/GodAuthenticationForm.tsx@@ -2,7 +2,7 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { InstanceAuthSettings } from '@/lib/api';+import type { InstanceAuthSettings } from '@/lib/api/endpoints/god';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsSection from '@/components/common/page/SettingsSection';import SettingsRow from '@/components/common/page/SettingsRow';diff --git a/apps/web/src/features/god/components/authentication/RegistrationModePicker.tsx b/apps/web/src/features/god/components/authentication/RegistrationModePicker.tsxindex afdd852e..8e69f26d 100644--- a/apps/web/src/features/god/components/authentication/RegistrationModePicker.tsx+++ b/apps/web/src/features/god/components/authentication/RegistrationModePicker.tsx@@ -1,6 +1,6 @@import { Check } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { RegistrationMode } from '@/lib/api';+import type { RegistrationMode } from '@/lib/api/endpoints/god';import { cn } from '@/lib/utils';const MODES: RegistrationMode[] = ['open', 'invite', 'closed'];diff --git a/apps/web/src/features/god/components/email/GodEmailProviderSection.tsx b/apps/web/src/features/god/components/email/GodEmailProviderSection.tsxindex 6f3eb2ae..5acd481a 100644--- a/apps/web/src/features/god/components/email/GodEmailProviderSection.tsx+++ b/apps/web/src/features/god/components/email/GodEmailProviderSection.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { NotificationEncryption } from '@/lib/api';+import type { NotificationEncryption } from '@/lib/api/endpoints/notificationSettings';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import {diff --git a/apps/web/src/features/god/components/projects/GodProjectDetailPanel.tsx b/apps/web/src/features/god/components/projects/GodProjectDetailPanel.tsxindex 4898b690..d589fd2b 100644--- a/apps/web/src/features/god/components/projects/GodProjectDetailPanel.tsx+++ b/apps/web/src/features/god/components/projects/GodProjectDetailPanel.tsx@@ -2,7 +2,7 @@import { Users, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InstanceProjectDetail } from '@/lib/api';+import type { InstanceProjectDetail } from '@/lib/api/endpoints/god';import { formatDate, formatDateTime } from '@/utils/dates';import { useExitOnEscape } from '@/hooks/useExitOnEscape';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';diff --git a/apps/web/src/features/god/components/projects/GodProjectsTable.tsx b/apps/web/src/features/god/components/projects/GodProjectsTable.tsxindex 92c1161e..429f3a68 100644--- a/apps/web/src/features/god/components/projects/GodProjectsTable.tsx+++ b/apps/web/src/features/god/components/projects/GodProjectsTable.tsx@@ -2,7 +2,7 @@import { Pencil } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InstanceProject } from '@/lib/api';+import type { InstanceProject } from '@/lib/api/endpoints/god';import { formatShortDate } from '@/utils/dates';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/god/components/scim/GodScimGroupItem.tsx b/apps/web/src/features/god/components/scim/GodScimGroupItem.tsxindex 6b481e1f..59f18f8d 100644--- a/apps/web/src/features/god/components/scim/GodScimGroupItem.tsx+++ b/apps/web/src/features/god/components/scim/GodScimGroupItem.tsx@@ -2,7 +2,7 @@import { UsersRound } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InstanceScimGroup } from '@/lib/api';+import type { InstanceScimGroup } from '@/lib/api/endpoints/scim';import { Button } from '@/components/ui/button';import {Item,diff --git a/apps/web/src/features/god/components/scim/GodScimGroupList.tsx b/apps/web/src/features/god/components/scim/GodScimGroupList.tsxindex b40defd2..0430e6f5 100644--- a/apps/web/src/features/god/components/scim/GodScimGroupList.tsx+++ b/apps/web/src/features/god/components/scim/GodScimGroupList.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { InstanceScimGroup } from '@/lib/api';+import type { InstanceScimGroup } from '@/lib/api/endpoints/scim';import SettingsSection from '@/components/common/page/SettingsSection';import { ItemGroup } from '@/components/ui/item';import { Skeleton } from '@/components/ui/skeleton';diff --git a/apps/web/src/features/god/components/scim/GodScimGroupMappingDialog.tsx b/apps/web/src/features/god/components/scim/GodScimGroupMappingDialog.tsxindex 0c977a76..dc3bf427 100644--- a/apps/web/src/features/god/components/scim/GodScimGroupMappingDialog.tsx+++ b/apps/web/src/features/god/components/scim/GodScimGroupMappingDialog.tsx@@ -2,7 +2,7 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { InstanceScimGroup } from '@/lib/api';+import type { InstanceScimGroup } from '@/lib/api/endpoints/scim';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';import {diff --git a/apps/web/src/features/god/components/scim/GodScimMappingRow.tsx b/apps/web/src/features/god/components/scim/GodScimMappingRow.tsxindex bf57f4b0..5200570c 100644--- a/apps/web/src/features/god/components/scim/GodScimMappingRow.tsx+++ b/apps/web/src/features/god/components/scim/GodScimMappingRow.tsx@@ -2,7 +2,7 @@import { X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InstanceProjectOption } from '@/lib/api';+import type { InstanceProjectOption } from '@/lib/api/endpoints/god';import { Button } from '@/components/ui/button';import {Select,diff --git a/apps/web/src/features/god/components/scim/GodScimSettings.tsx b/apps/web/src/features/god/components/scim/GodScimSettings.tsxindex 8258c2c3..7a53e604 100644--- a/apps/web/src/features/god/components/scim/GodScimSettings.tsx+++ b/apps/web/src/features/god/components/scim/GodScimSettings.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { InstanceScimSettings } from '@/lib/api';+import type { InstanceScimSettings } from '@/lib/api/endpoints/scim';import SettingsSection from '@/components/common/page/SettingsSection';import SettingsCard from '@/components/common/page/SettingsCard';import CopyableValue from '@/components/common/page/CopyableValue';diff --git a/apps/web/src/features/god/components/users/GodUserProjectCard.tsx b/apps/web/src/features/god/components/users/GodUserProjectCard.tsxindex 6845086c..d091d0be 100644--- a/apps/web/src/features/god/components/users/GodUserProjectCard.tsx+++ b/apps/web/src/features/god/components/users/GodUserProjectCard.tsx@@ -1,7 +1,8 @@'use client';import { useTranslations } from 'next-intl';-import type { InstanceUserProject, PermissionCatalog } from '@/lib/api';+import type { PermissionCatalog } from '@/lib/api/endpoints/roles';+import type { InstanceUserProject } from '@/lib/api/endpoints/god';import { formatShortDate } from '@/utils/dates';import { Badge } from '@/components/ui/badge';import AccessCard from '@/components/common/permissions/AccessCard';diff --git a/apps/web/src/features/god/components/users/GodUsersTable.tsx b/apps/web/src/features/god/components/users/GodUsersTable.tsxindex 4f0434ae..8240ba22 100644--- a/apps/web/src/features/god/components/users/GodUsersTable.tsx+++ b/apps/web/src/features/god/components/users/GodUsersTable.tsx@@ -2,7 +2,7 @@import { Bot, Pencil, Shield } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InstanceUser } from '@/lib/api';+import type { InstanceUser } from '@/lib/api/endpoints/god';import { formatShortDate } from '@/utils/dates';import Avatar from '@/components/common/Avatar';import { Badge } from '@/components/ui/badge';diff --git a/apps/web/src/features/god/components/users/GodUsersToolbar.tsx b/apps/web/src/features/god/components/users/GodUsersToolbar.tsxindex faa31ede..27f18e7e 100644--- a/apps/web/src/features/god/components/users/GodUsersToolbar.tsx+++ b/apps/web/src/features/god/components/users/GodUsersToolbar.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { InstanceUserKind } from '@/lib/api';+import type { InstanceUserKind } from '@/lib/api/endpoints/god';import {Select,SelectContent,diff --git a/apps/web/src/features/god/hooks/useGodEmailForm.ts b/apps/web/src/features/god/hooks/useGodEmailForm.tsindex 994cdabc..a0635f9f 100644--- a/apps/web/src/features/god/hooks/useGodEmailForm.ts+++ b/apps/web/src/features/god/hooks/useGodEmailForm.ts@@ -1,11 +1,8 @@'use client';import { useState } from 'react';-import type {- NotificationEncryption,- InstanceEmailSettings,- InstanceEmailSettingsPatch,-} from '@/lib/api';+import type { InstanceEmailSettings, InstanceEmailSettingsPatch } from '@/lib/api/endpoints/god';+import type { NotificationEncryption } from '@/lib/api/endpoints/notificationSettings';import type { EmailProvider } from '@/components/common/inputs/ProviderToggle';import { toPositiveInt } from '@/lib/utils';import {diff --git a/apps/web/src/features/god/hooks/useGodGoogleForm.ts b/apps/web/src/features/god/hooks/useGodGoogleForm.tsindex b637fe8f..6f50f28d 100644--- a/apps/web/src/features/god/hooks/useGodGoogleForm.ts+++ b/apps/web/src/features/god/hooks/useGodGoogleForm.ts@@ -1,7 +1,7 @@'use client';import { useState } from 'react';-import type { InstanceGoogleSettings } from '@/lib/api';+import type { InstanceGoogleSettings } from '@/lib/api/endpoints/god';import { useUpdateInstanceGoogleSettings } from '../services/god.service';export interface GodGoogleForm {diff --git a/apps/web/src/features/god/hooks/useGodOidcForm.ts b/apps/web/src/features/god/hooks/useGodOidcForm.tsindex 2fe3e1df..b9daefbc 100644--- a/apps/web/src/features/god/hooks/useGodOidcForm.ts+++ b/apps/web/src/features/god/hooks/useGodOidcForm.ts@@ -1,7 +1,7 @@'use client';import { useState } from 'react';-import type { InstanceOidcSettings } from '@/lib/api';+import type { InstanceOidcSettings } from '@/lib/api/endpoints/god';import { useUpdateInstanceOidcSettings } from '../services/god.service';export interface GodOidcForm {diff --git a/apps/web/src/features/god/hooks/useGodPolicyForm.ts b/apps/web/src/features/god/hooks/useGodPolicyForm.tsindex 75921eb9..40447d96 100644--- a/apps/web/src/features/god/hooks/useGodPolicyForm.ts+++ b/apps/web/src/features/god/hooks/useGodPolicyForm.ts@@ -1,7 +1,7 @@'use client';import { useState } from 'react';-import type { InstanceAuthSettings, RegistrationMode } from '@/lib/api';+import type { InstanceAuthSettings, RegistrationMode } from '@/lib/api/endpoints/god';import { useUpdateInstanceAuthSettings } from '../services/god.service';export interface GodPolicyForm {diff --git a/apps/web/src/features/god/hooks/useGodScimMappingForm.ts b/apps/web/src/features/god/hooks/useGodScimMappingForm.tsindex 2d14311e..5aaf4a7c 100644--- a/apps/web/src/features/god/hooks/useGodScimMappingForm.ts+++ b/apps/web/src/features/god/hooks/useGodScimMappingForm.ts@@ -1,7 +1,7 @@'use client';import { useState } from 'react';-import type { InstanceScimGroup } from '@/lib/api';+import type { InstanceScimGroup } from '@/lib/api/endpoints/scim';import { useSetInstanceScimGroupMappings } from '../services/god.service';// One row of the form: a project the group grants membership in, and the role itdiff --git a/apps/web/src/features/god/services/god.service.ts b/apps/web/src/features/god/services/god.service.tsindex 94413509..3e909246 100644--- a/apps/web/src/features/god/services/god.service.ts+++ b/apps/web/src/features/god/services/god.service.ts@@ -1,18 +1,46 @@'use client';import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';+import type { StorageSettingsPatch } from '@/lib/api/endpoints/settings';+import type { ProjectDefaults } from '@/lib/api/endpoints/projects';+import type { PageParams } from '@/lib/api/core/paging';import {- api,type InstanceAuthSettingsPatch,type InstanceEmailSettingsPatch,type InstanceGoogleSettingsPatch,type InstanceOidcSettingsPatch,type InstanceTelegramSettingsPatch,type InstanceUserKind,- type PageParams,- type ProjectDefaults,- type StorageSettingsPatch,-} from '@/lib/api';+ getInstanceAuthSettings,+ updateInstanceAuthSettings,+ getInstanceEmailSettings,+ updateInstanceEmailSettings,+ testInstanceEmailSettings,+ getInstanceGoogleSettings,+ updateInstanceGoogleSettings,+ getInstanceOidcSettings,+ updateInstanceOidcSettings,+ getInstanceTelegramSettings,+ updateInstanceTelegramSettings,+ getInstanceProjectDefaults,+ updateInstanceProjectDefaults,+ getInstanceStorageSettings,+ updateInstanceStorageSettings,+ listInstanceUsers,+ getInstanceUser,+ deleteInstanceUser,+ listInstanceProjects,+ listInstanceProjectOptions,+ getInstanceProject,+ verifyInstanceUserEmail,+} from '@/lib/api/endpoints/god';+import {+ getInstanceScimSettings,+ updateInstanceScimSettings,+ createInstanceScimToken,+ listInstanceScimGroups,+ setInstanceScimGroupMappings,+} from '@/lib/api/endpoints/scim';import { qk } from '@/services/queryKeys';// Data hooks for god mode. Every write returns the new state, which replaces the@@ -29,14 +57,14 @@ function invalidateSignInMethods(qc: ReturnType<typeof useQueryClient>): void {export function useInstanceAuthSettingsQuery() {return useQuery({queryKey: qk.instanceAuthSettings,- queryFn: () => api.getInstanceAuthSettings(),+ queryFn: () => getInstanceAuthSettings(),});}export function useUpdateInstanceAuthSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: InstanceAuthSettingsPatch) => api.updateInstanceAuthSettings(patch),+ mutationFn: (patch: InstanceAuthSettingsPatch) => updateInstanceAuthSettings(patch),onSuccess: (data) => qc.setQueryData(qk.instanceAuthSettings, data),});}@@ -44,14 +72,14 @@ export function useUpdateInstanceAuthSettings() {export function useInstanceEmailSettingsQuery() {return useQuery({queryKey: qk.instanceEmailSettings,- queryFn: () => api.getInstanceEmailSettings(),+ queryFn: () => getInstanceEmailSettings(),});}export function useUpdateInstanceEmailSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: InstanceEmailSettingsPatch) => api.updateInstanceEmailSettings(patch),+ mutationFn: (patch: InstanceEmailSettingsPatch) => updateInstanceEmailSettings(patch),onSuccess: (data) => {qc.setQueryData(qk.instanceEmailSettings, data);// Turning a provider on unlocks the auth options that need outbound mail.@@ -62,21 +90,21 @@ export function useUpdateInstanceEmailSettings() {export function useTestInstanceEmailSettings() {return useMutation({- mutationFn: (patch: InstanceEmailSettingsPatch) => api.testInstanceEmailSettings(patch),+ mutationFn: (patch: InstanceEmailSettingsPatch) => testInstanceEmailSettings(patch),});}export function useInstanceGoogleSettingsQuery() {return useQuery({queryKey: qk.instanceGoogleSettings,- queryFn: () => api.getInstanceGoogleSettings(),+ queryFn: () => getInstanceGoogleSettings(),});}export function useUpdateInstanceGoogleSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: InstanceGoogleSettingsPatch) => api.updateInstanceGoogleSettings(patch),+ mutationFn: (patch: InstanceGoogleSettingsPatch) => updateInstanceGoogleSettings(patch),onSuccess: (data) => {qc.setQueryData(qk.instanceGoogleSettings, data);invalidateSignInMethods(qc);@@ -88,14 +116,14 @@ export function useUpdateInstanceGoogleSettings() {export function useInstanceOidcSettingsQuery() {return useQuery({queryKey: qk.instanceOidcSettings,- queryFn: () => api.getInstanceOidcSettings(),+ queryFn: () => getInstanceOidcSettings(),});}export function useUpdateInstanceOidcSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: InstanceOidcSettingsPatch) => api.updateInstanceOidcSettings(patch),+ mutationFn: (patch: InstanceOidcSettingsPatch) => updateInstanceOidcSettings(patch),onSuccess: (data) => {qc.setQueryData(qk.instanceOidcSettings, data);invalidateSignInMethods(qc);@@ -108,14 +136,14 @@ export function useUpdateInstanceOidcSettings() {export function useInstanceScimSettingsQuery() {return useQuery({queryKey: qk.instanceScimSettings,- queryFn: () => api.getInstanceScimSettings(),+ queryFn: () => getInstanceScimSettings(),});}export function useUpdateInstanceScimSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: { enabled: boolean }) => api.updateInstanceScimSettings(patch),+ mutationFn: (patch: { enabled: boolean }) => updateInstanceScimSettings(patch),onSuccess: (data) => qc.setQueryData(qk.instanceScimSettings, data),});}@@ -123,7 +151,7 @@ export function useUpdateInstanceScimSettings() {export function useCreateInstanceScimToken() {const qc = useQueryClient();return useMutation({- mutationFn: () => api.createInstanceScimToken(),+ mutationFn: () => createInstanceScimToken(),// The response is the token itself, not the settings, so the redacted view has// to be refetched for its new prefix.onSuccess: () => qc.invalidateQueries({ queryKey: qk.instanceScimSettings }),@@ -133,7 +161,7 @@ export function useCreateInstanceScimToken() {export function useInstanceScimGroupsQuery() {return useQuery({queryKey: qk.instanceScimGroups,- queryFn: () => api.listInstanceScimGroups(),+ queryFn: () => listInstanceScimGroups(),});}@@ -143,7 +171,7 @@ export function useSetInstanceScimGroupMappings() {mutationFn: (input: {groupId: string;mappings: { projectId: number; role: 'owner' | 'member'; roleId: number | null }[];- }) => api.setInstanceScimGroupMappings(input.groupId, input.mappings),+ }) => setInstanceScimGroupMappings(input.groupId, input.mappings),onSuccess: () => qc.invalidateQueries({ queryKey: qk.instanceScimGroups }),});}@@ -153,14 +181,14 @@ export function useSetInstanceScimGroupMappings() {export function useInstanceTelegramSettingsQuery() {return useQuery({queryKey: qk.instanceTelegramSettings,- queryFn: () => api.getInstanceTelegramSettings(),+ queryFn: () => getInstanceTelegramSettings(),});}export function useUpdateInstanceTelegramSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: InstanceTelegramSettingsPatch) => api.updateInstanceTelegramSettings(patch),+ mutationFn: (patch: InstanceTelegramSettingsPatch) => updateInstanceTelegramSettings(patch),onSuccess: (data) => qc.setQueryData(qk.instanceTelegramSettings, data),});}@@ -170,14 +198,14 @@ export function useUpdateInstanceTelegramSettings() {export function useInstanceProjectDefaultsQuery() {return useQuery({queryKey: qk.instanceProjectDefaults,- queryFn: () => api.getInstanceProjectDefaults(),+ queryFn: () => getInstanceProjectDefaults(),});}export function useUpdateInstanceProjectDefaults() {const qc = useQueryClient();return useMutation({- mutationFn: (body: ProjectDefaults) => api.updateInstanceProjectDefaults(body),+ mutationFn: (body: ProjectDefaults) => updateInstanceProjectDefaults(body),onSuccess: (data) => qc.setQueryData(qk.instanceProjectDefaults, data),});}@@ -187,14 +215,14 @@ export function useUpdateInstanceProjectDefaults() {export function useInstanceStorageSettingsQuery() {return useQuery({queryKey: qk.instanceStorageSettings,- queryFn: () => api.getInstanceStorageSettings(),+ queryFn: () => getInstanceStorageSettings(),});}export function useUpdateInstanceStorageSettings() {const qc = useQueryClient();return useMutation({- mutationFn: (patch: StorageSettingsPatch) => api.updateInstanceStorageSettings(patch),+ mutationFn: (patch: StorageSettingsPatch) => updateInstanceStorageSettings(patch),onSuccess: (data) => {qc.setQueryData(qk.instanceStorageSettings, data);// The upload UI reads the same limits through the open endpoint.@@ -214,7 +242,7 @@ export interface InstanceUserFilters extends PageParams {export function useInstanceUsersQuery(filters: InstanceUserFilters) {return useQuery({queryKey: qk.instanceUsers(filters),- queryFn: () => api.listInstanceUsers({ ...filters, search: filters.search || undefined }),+ queryFn: () => listInstanceUsers({ ...filters, search: filters.search || undefined }),placeholderData: keepPreviousData,});}@@ -224,7 +252,7 @@ export function useInstanceUsersQuery(filters: InstanceUserFilters) {export function useInstanceUserQuery(userId: string) {return useQuery({queryKey: qk.instanceUser(userId),- queryFn: () => api.getInstanceUser(userId),+ queryFn: () => getInstanceUser(userId),});}@@ -232,7 +260,7 @@ export function useDeleteInstanceUser() {const qc = useQueryClient();return useMutation({mutationFn: (input: { userId: string; withProjects: boolean }) =>- api.deleteInstanceUser(input.userId, input.withProjects),+ deleteInstanceUser(input.userId, input.withProjects),onSuccess: (_data, input) => {qc.removeQueries({ queryKey: qk.instanceUser(input.userId) });void qc.invalidateQueries({ queryKey: qk.anyInstanceUsers });@@ -252,7 +280,7 @@ export interface InstanceProjectFilters extends PageParams {export function useInstanceProjectsQuery(filters: InstanceProjectFilters) {return useQuery({queryKey: qk.instanceProjects(filters),- queryFn: () => api.listInstanceProjects({ ...filters, search: filters.search || undefined }),+ queryFn: () => listInstanceProjects({ ...filters, search: filters.search || undefined }),placeholderData: keepPreviousData,});}@@ -262,7 +290,7 @@ export function useInstanceProjectsQuery(filters: InstanceProjectFilters) {export function useInstanceProjectOptionsQuery() {return useQuery({queryKey: qk.instanceProjectOptions,- queryFn: () => api.listInstanceProjectOptions(),+ queryFn: () => listInstanceProjectOptions(),staleTime: Infinity,});}@@ -272,14 +300,14 @@ export function useInstanceProjectOptionsQuery() {export function useInstanceProjectQuery(projectId: number) {return useQuery({queryKey: qk.instanceProject(projectId),- queryFn: () => api.getInstanceProject(projectId),+ queryFn: () => getInstanceProject(projectId),});}export function useVerifyInstanceUserEmail() {const qc = useQueryClient();return useMutation({- mutationFn: (userId: string) => api.verifyInstanceUserEmail(userId),+ mutationFn: (userId: string) => verifyInstanceUserEmail(userId),onSuccess: (data) => {qc.setQueryData(qk.instanceUser(data.id), data);// The list carries emailVerified too, and its key holds the active filters.diff --git a/apps/web/src/features/inbox/components/InboxDetail.tsx b/apps/web/src/features/inbox/components/InboxDetail.tsxindex 53660500..b8e2a1f1 100644--- a/apps/web/src/features/inbox/components/InboxDetail.tsx+++ b/apps/web/src/features/inbox/components/InboxDetail.tsx@@ -2,7 +2,7 @@import { ChevronLeft } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { Button } from '@/components/ui/button';import IssueDetailContent from '@/features/issue/components/detail/IssueDetailContent';diff --git a/apps/web/src/features/inbox/components/InboxList.tsx b/apps/web/src/features/inbox/components/InboxList.tsxindex eb55002d..375a7113 100644--- a/apps/web/src/features/inbox/components/InboxList.tsx+++ b/apps/web/src/features/inbox/components/InboxList.tsx@@ -2,7 +2,7 @@import { useEffect, useRef } from 'react';import { useTranslations } from 'next-intl';-import { type Notification } from '@/lib/api';+import type { Notification } from '@/lib/api/endpoints/notifications';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import InboxListItem from './InboxListItem';diff --git a/apps/web/src/features/inbox/components/InboxListItem.tsx b/apps/web/src/features/inbox/components/InboxListItem.tsxindex 4b729a96..bbe2e6ef 100644--- a/apps/web/src/features/inbox/components/InboxListItem.tsx+++ b/apps/web/src/features/inbox/components/InboxListItem.tsx@@ -11,7 +11,7 @@ import {type LucideIcon,} from 'lucide-react';import { useTranslations } from 'next-intl';-import { type Notification, type NotificationType } from '@/lib/api';+import type { Notification, NotificationType } from '@/lib/api/endpoints/notifications';import { formatDurationShort } from '@/utils/dates';import { cn } from '@/lib/utils';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/inbox/components/InboxToolbar.tsx b/apps/web/src/features/inbox/components/InboxToolbar.tsxindex b61063ea..4e23031d 100644--- a/apps/web/src/features/inbox/components/InboxToolbar.tsx+++ b/apps/web/src/features/inbox/components/InboxToolbar.tsx@@ -2,7 +2,7 @@import { CheckCheck, ListFilter, MoreHorizontal, SlidersHorizontal, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type NotificationFilters, type NotificationType } from '@/lib/api';+import type { NotificationFilters, NotificationType } from '@/lib/api/endpoints/notifications';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/inbox/components/InboxView.tsx b/apps/web/src/features/inbox/components/InboxView.tsxindex 3d41b62e..1a80560d 100644--- a/apps/web/src/features/inbox/components/InboxView.tsx+++ b/apps/web/src/features/inbox/components/InboxView.tsx@@ -2,7 +2,8 @@import { useMemo, useState } from 'react';import { useTranslations } from 'next-intl';-import { type Notification, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Notification } from '@/lib/api/endpoints/notifications';import { cn } from '@/lib/utils';import { useLiveRefresh } from '@/hooks/useLiveRefresh';import { revScope } from '@/utils/revScopes';diff --git a/apps/web/src/features/inbox/hooks/useInboxFilters.ts b/apps/web/src/features/inbox/hooks/useInboxFilters.tsindex b6840078..7642e7df 100644--- a/apps/web/src/features/inbox/hooks/useInboxFilters.ts+++ b/apps/web/src/features/inbox/hooks/useInboxFilters.ts@@ -1,5 +1,5 @@import { useCallback, useState } from 'react';-import { type NotificationFilters } from '@/lib/api';+import type { NotificationFilters } from '@/lib/api/endpoints/notifications';// The inbox toolbar's type filter and display toggles, kept per project in// localStorage so reopening the inbox restores the last choices.diff --git a/apps/web/src/features/inbox/services/notifications.service.ts b/apps/web/src/features/inbox/services/notifications.service.tsindex f6d02287..6b59af3e 100644--- a/apps/web/src/features/inbox/services/notifications.service.ts+++ b/apps/web/src/features/inbox/services/notifications.service.ts@@ -1,10 +1,15 @@import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query';import {- api,type NotificationCursor,type NotificationFilters,type NotificationDeleteScope,-} from '@/lib/api';+ listNotifications,+ setNotificationRead,+ markAllNotificationsRead,+ snoozeNotification,+ deleteNotification,+ deleteNotifications,+} from '@/lib/api/endpoints/notifications';import { qk } from '@/services/queryKeys';// One project's inbox, keyset-paged and scoped by the active filters. The filters@@ -17,7 +22,7 @@ export function useNotificationsQuery(return useInfiniteQuery({queryKey: qk.notifications(projectKey, filters),queryFn: ({ pageParam }) =>- api.listNotifications(projectId, { cursor: pageParam, limit: 30, filters }),+ listNotifications(projectId, { cursor: pageParam, limit: 30, filters }),initialPageParam: null as NotificationCursor | null,getNextPageParam: (last) => last.nextCursor,});@@ -34,7 +39,7 @@ function useInvalidateInbox(projectKey: string) {export function useSetNotificationRead(projectKey: string) {const invalidate = useInvalidateInbox(projectKey);return useMutation({- mutationFn: ({ id, read }: { id: number; read: boolean }) => api.setNotificationRead(id, read),+ mutationFn: ({ id, read }: { id: number; read: boolean }) => setNotificationRead(id, read),onSuccess: invalidate,});}@@ -42,7 +47,7 @@ export function useSetNotificationRead(projectKey: string) {export function useMarkAllRead(projectKey: string, projectId: number) {const invalidate = useInvalidateInbox(projectKey);return useMutation({- mutationFn: () => api.markAllNotificationsRead(projectId),+ mutationFn: () => markAllNotificationsRead(projectId),onSuccess: invalidate,});}@@ -51,7 +56,7 @@ export function useSnoozeNotification(projectKey: string) {const invalidate = useInvalidateInbox(projectKey);return useMutation({mutationFn: ({ id, until }: { id: number; until: string | null }) =>- api.snoozeNotification(id, until),+ snoozeNotification(id, until),onSuccess: invalidate,});}@@ -59,7 +64,7 @@ export function useSnoozeNotification(projectKey: string) {export function useDeleteNotification(projectKey: string) {const invalidate = useInvalidateInbox(projectKey);return useMutation({- mutationFn: (id: number) => api.deleteNotification(id),+ mutationFn: (id: number) => deleteNotification(id),onSuccess: invalidate,});}@@ -67,7 +72,7 @@ export function useDeleteNotification(projectKey: string) {export function useDeleteNotifications(projectKey: string, projectId: number) {const invalidate = useInvalidateInbox(projectKey);return useMutation({- mutationFn: (scope: NotificationDeleteScope) => api.deleteNotifications(scope, projectId),+ mutationFn: (scope: NotificationDeleteScope) => deleteNotifications(scope, projectId),onSuccess: invalidate,});}diff --git a/apps/web/src/features/initiatives/InitiativesPage.tsx b/apps/web/src/features/initiatives/InitiativesPage.tsxindex 95ffab09..7f130202 100644--- a/apps/web/src/features/initiatives/InitiativesPage.tsx+++ b/apps/web/src/features/initiatives/InitiativesPage.tsx@@ -9,7 +9,7 @@ import { useTranslations } from 'next-intl';import { useShell } from '@/context/shellContext';import { usePermissions } from '@/hooks/usePermissions';import { useInitiativeCountsQuery, useInitiativesQuery } from '@/services/initiatives.service';-import { INITIATIVE_SORTS, type InitiativeSort } from '@/lib/api';+import { INITIATIVE_SORTS, type InitiativeSort } from '@/lib/api/endpoints/initiatives';import { useStripSortSensors } from '@/lib/dnd';import { initiativesTabPath, type InitiativesTab } from '@/utils/paths';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/initiatives/InitiativesRedirect.tsx b/apps/web/src/features/initiatives/InitiativesRedirect.tsxindex 6671ad5e..2a800603 100644--- a/apps/web/src/features/initiatives/InitiativesRedirect.tsx+++ b/apps/web/src/features/initiatives/InitiativesRedirect.tsx@@ -3,7 +3,7 @@import { useEffect } from 'react';import { useRouter } from 'next/navigation';import { useShell } from '@/context/shellContext';-import type { InitiativeCounts } from '@/lib/api';+import type { InitiativeCounts } from '@/lib/api/endpoints/initiatives';import { useInitiativeCountsQuery } from '@/services/initiatives.service';import { initiativesTabPath, type InitiativesTab } from '@/utils/paths';import { readInitiativeTabOrder } from './hooks/useInitiativeTabOrder';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeActions.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeActions.tsxindex d4fca63f..aad874fb 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeActions.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeActions.tsx@@ -4,7 +4,7 @@ import { useState } from 'react';import { useRouter } from 'next/navigation';import { MoreHorizontal, Pencil, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Initiative } from '@/lib/api';+import type { Initiative } from '@/lib/api/endpoints/initiatives';import { initiativesPath } from '@/utils/paths';import { usePermissions } from '@/hooks/usePermissions';import { useDeleteInitiative } from '@/services/initiatives.service';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeActiveWork.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeActiveWork.tsxindex f7fb4af1..25072473 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeActiveWork.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeActiveWork.tsx@@ -2,7 +2,7 @@import { useMemo } from 'react';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useShell } from '@/context/shellContext';import { StateIcon } from '@/features/issue/components/shared/IssueIcons';import Avatar from '@/components/common/Avatar';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeAttachments.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeAttachments.tsxindex 16ac143d..13bcbcdf 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeAttachments.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeAttachments.tsx@@ -3,7 +3,7 @@import { useRef, useState } from 'react';import { Download, Plus, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type Attachment } from '@/lib/api';+import type { Attachment } from '@/lib/api/endpoints/attachments';import { isImage, isVideo } from '@/components/common/editor/attachmentEmbed';import AttachmentThumb from '@/components/common/attachments/AttachmentThumb';import AttachmentViewer from '@/components/common/attachments/AttachmentViewer';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeFeedRow.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeFeedRow.tsxindex 51a5881f..dbc11c7c 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeFeedRow.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeFeedRow.tsx@@ -13,7 +13,7 @@ import {Tag,Flag,} from 'lucide-react';-import type { InitiativeFeedItem } from '@/lib/api';+import type { InitiativeFeedItem } from '@/lib/api/endpoints/initiatives';import { useRelativeTime } from '@/context/relativeTimeContext';import { formatDate } from '@/utils/dates';import { issuePath } from '@/utils/paths';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsxindex 69028cea..3fd05318 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx@@ -2,7 +2,8 @@import { Info } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Initiative, InitiativePatch, ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Initiative, InitiativePatch } from '@/lib/api/endpoints/initiatives';import { useUpdateInitiative } from '@/services/initiatives.service';import { parseDate } from '@/utils/dates';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeOverview.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeOverview.tsxindex 60a34539..9c3017c8 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeOverview.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeOverview.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { Initiative } from '@/lib/api';+import type { Initiative } from '@/lib/api/endpoints/initiatives';import MarkdownEditor from '@/components/common/editor/MarkdownEditor';import InitiativeAttachments from './InitiativeAttachments';import InitiativeDocuments from './InitiativeDocuments';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsxindex d413156e..f4f2a764 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsx@@ -1,7 +1,8 @@'use client';import { useTranslations } from 'next-intl';-import type { Initiative, ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Initiative } from '@/lib/api/endpoints/initiatives';import InitiativeActivityFeed from './InitiativeActivityFeed';import InitiativeActiveWork from './InitiativeActiveWork';import InitiativeStateBreakdown from './InitiativeStateBreakdown';diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeStateBreakdown.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeStateBreakdown.tsxindex 37f72e97..89389745 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeStateBreakdown.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeStateBreakdown.tsx@@ -2,7 +2,8 @@import { useMemo } from 'react';import { useTranslations } from 'next-intl';-import type { ProjectDetail, StateType } from '@/lib/api';+import type { StateType } from '@/lib/api/endpoints/columns';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';// The initiative's linked issues counted per state group. Complements the header// progress pill with the full distribution (backlog through canceled).diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeTimeline.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeTimeline.tsxindex 7223c1d2..30d2cbfa 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeTimeline.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeTimeline.tsx@@ -2,7 +2,7 @@import { parseISO, differenceInCalendarDays } from 'date-fns';import { useTranslations } from 'next-intl';-import type { Initiative } from '@/lib/api';+import type { Initiative } from '@/lib/api/endpoints/initiatives';import { formatDate } from '@/utils/dates';import HealthBadge from '../shared/HealthBadge';import HealthInfoPopover from '../shared/HealthInfoPopover';diff --git a/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx b/apps/web/src/features/initiatives/components/list/InitiativeRow.tsxindex 1799902a..ff02d1ac 100644--- a/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx+++ b/apps/web/src/features/initiatives/components/list/InitiativeRow.tsx@@ -2,7 +2,8 @@ import Link from 'next/link';import { useRouter } from 'next/navigation';import { Minus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Initiative, Assignee } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { Initiative } from '@/lib/api/endpoints/initiatives';import { initiativePath } from '@/utils/paths';import { formatShortDate } from '@/utils/dates';import { AssigneeAvatar } from '@/features/issue/components/shared/IssueBadges';diff --git a/apps/web/src/features/initiatives/components/list/InitiativesList.tsx b/apps/web/src/features/initiatives/components/list/InitiativesList.tsxindex 506242d6..22111e16 100644--- a/apps/web/src/features/initiatives/components/list/InitiativesList.tsx+++ b/apps/web/src/features/initiatives/components/list/InitiativesList.tsx@@ -1,6 +1,7 @@import { ChevronDown, ChevronUp, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Initiative, InitiativeSort, ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Initiative, InitiativeSort } from '@/lib/api/endpoints/initiatives';import type { InitiativesTab } from '@/utils/paths';import { Button } from '@/components/ui/button';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';diff --git a/apps/web/src/features/initiatives/components/shared/HealthBadge.tsx b/apps/web/src/features/initiatives/components/shared/HealthBadge.tsxindex 9bf584a5..fa40ae0b 100644--- a/apps/web/src/features/initiatives/components/shared/HealthBadge.tsx+++ b/apps/web/src/features/initiatives/components/shared/HealthBadge.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { InitiativeHealth } from '@/lib/api';+import type { InitiativeHealth } from '@/lib/api/endpoints/initiatives';import { healthColor } from '@/utils/initiativeMeta';// A small health signal: a colored dot plus its label. null renders a muteddiff --git a/apps/web/src/features/initiatives/components/shared/HealthInfoPopover.tsx b/apps/web/src/features/initiatives/components/shared/HealthInfoPopover.tsxindex f8b3a63c..0843450a 100644--- a/apps/web/src/features/initiatives/components/shared/HealthInfoPopover.tsx+++ b/apps/web/src/features/initiatives/components/shared/HealthInfoPopover.tsx@@ -1,7 +1,7 @@import { Fragment } from 'react';import { ChevronRight, HelpCircle } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InitiativeHealth } from '@/lib/api';+import type { InitiativeHealth } from '@/lib/api/endpoints/initiatives';import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { healthColor } from '@/utils/initiativeMeta';diff --git a/apps/web/src/features/initiatives/services/attachments.service.ts b/apps/web/src/features/initiatives/services/attachments.service.tsindex 86ad0935..254d5099 100644--- a/apps/web/src/features/initiatives/services/attachments.service.ts+++ b/apps/web/src/features/initiatives/services/attachments.service.ts@@ -2,21 +2,25 @@// the app uses.import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type Attachment } from '@/lib/api';+import {+ type Attachment,+ listInitiativeAttachments,+ uploadInitiativeAttachment,+ deleteInitiativeAttachment,+} from '@/lib/api/endpoints/attachments';import { qk } from '@/services/queryKeys';export function useInitiativeAttachmentsQuery(initiativeId: number) {return useQuery({queryKey: qk.initiativeAttachments(initiativeId),- queryFn: () => api.listInitiativeAttachments(initiativeId),+ queryFn: () => listInitiativeAttachments(initiativeId),});}export function useUploadInitiativeAttachment(initiativeId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (file: File): Promise<Attachment> =>- api.uploadInitiativeAttachment(initiativeId, file),+ mutationFn: (file: File): Promise<Attachment> => uploadInitiativeAttachment(initiativeId, file),onSuccess: () =>void qc.invalidateQueries({ queryKey: qk.initiativeAttachments(initiativeId) }),});@@ -25,7 +29,7 @@ export function useUploadInitiativeAttachment(initiativeId: number) {export function useDeleteInitiativeAttachment(initiativeId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (publicId: string) => api.deleteInitiativeAttachment(publicId),+ mutationFn: (publicId: string) => deleteInitiativeAttachment(publicId),// Deleting also strips the attachment's embeds from the description, so// refetch the initiative alongside the list.onSuccess: () => {diff --git a/apps/web/src/features/initiatives/utils/tabs.ts b/apps/web/src/features/initiatives/utils/tabs.tsindex c5fdf662..e05ff6b3 100644--- a/apps/web/src/features/initiatives/utils/tabs.ts+++ b/apps/web/src/features/initiatives/utils/tabs.ts@@ -1,4 +1,4 @@-import type { InitiativeCounts, InitiativeStatus } from '@/lib/api';+import type { InitiativeCounts, InitiativeStatus } from '@/lib/api/endpoints/initiatives';import type { InitiativesTab } from '@/utils/paths';// One tab per lifecycle status, except the terminal statuses share a "Completed"diff --git a/apps/web/src/features/invite/components/InviteActions.tsx b/apps/web/src/features/invite/components/InviteActions.tsxindex 189a6952..800037c6 100644--- a/apps/web/src/features/invite/components/InviteActions.tsx+++ b/apps/web/src/features/invite/components/InviteActions.tsx@@ -5,7 +5,8 @@ import Link from 'next/link';import { useRouter } from 'next/navigation';import { useQueryClient } from '@tanstack/react-query';import { useTranslations } from 'next-intl';-import { ApiError, api } from '@/lib/api';+import { acceptInvite, rejectInvite } from '@/lib/api/endpoints/invites';+import { ApiError } from '@/lib/api/core/client';import { projectPath } from '@/utils/paths';import { Button } from '@/components/ui/button';import { FieldError } from '@/components/ui/field';@@ -35,7 +36,7 @@ export default function InviteActions({setError(null);setBusy('accept');try {- const result = await api.acceptInvite(token);+ const result = await acceptInvite(token);router.push(result.projectKey ? projectPath(result.projectKey) : '/');router.refresh();} catch (err) {@@ -49,7 +50,7 @@ export default function InviteActions({setError(null);setBusy('reject');try {- await api.rejectInvite(token);+ await rejectInvite(token);await qc.invalidateQueries({ queryKey: ['invite', token] });} catch (err) {setError(err instanceof Error ? err.message : t('declineError'));diff --git a/apps/web/src/features/invite/components/InviteInfo.tsx b/apps/web/src/features/invite/components/InviteInfo.tsxindex 4e1eadb4..4fbb4f15 100644--- a/apps/web/src/features/invite/components/InviteInfo.tsx+++ b/apps/web/src/features/invite/components/InviteInfo.tsx@@ -1,7 +1,7 @@import type { ReactNode } from 'react';import { FolderKanban, Mail, Users } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type InviteView } from '@/lib/api';+import type { InviteView } from '@/lib/api/endpoints/invites';import { Badge } from '@/components/ui/badge';function InfoRow({diff --git a/apps/web/src/features/invite/components/InviteStep.tsx b/apps/web/src/features/invite/components/InviteStep.tsxindex 8a560185..c4672de1 100644--- a/apps/web/src/features/invite/components/InviteStep.tsx+++ b/apps/web/src/features/invite/components/InviteStep.tsx@@ -3,7 +3,7 @@import Link from 'next/link';import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';-import { type InviteView } from '@/lib/api';+import type { InviteView } from '@/lib/api/endpoints/invites';import { signOut, useSession } from '@/lib/auth-client';import { Button } from '@/components/ui/button';import InviteActions from './InviteActions';diff --git a/apps/web/src/features/invite/services/invite.service.ts b/apps/web/src/features/invite/services/invite.service.tsindex de2d4636..864c5b2b 100644--- a/apps/web/src/features/invite/services/invite.service.ts+++ b/apps/web/src/features/invite/services/invite.service.ts@@ -3,13 +3,13 @@// sign-in/sign-up is sent with the accept call that follows.import { useQuery } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getInvite, acceptInvite } from '@/lib/api/endpoints/invites';import { signIn, signUp } from '@/lib/auth-client';export function useInviteQuery(token: string) {return useQuery({queryKey: ['invite', token],- queryFn: () => api.getInvite(token),+ queryFn: () => getInvite(token),// A bad token is a 404, not a transient failure — do not retry.retry: false,});@@ -54,7 +54,7 @@ export async function registerAndAccept(input: {if (result.error) {throw new InviteAuthError(result.error.message ?? input.registerFailed, result.error.code);}- return api.acceptInvite(input.token);+ return acceptInvite(input.token);}// Sign in to an existing account. Does not accept: after the session updates thediff --git a/apps/web/src/features/issue/PublicIssuePage.tsx b/apps/web/src/features/issue/PublicIssuePage.tsxindex 3ca996ec..47226d12 100644--- a/apps/web/src/features/issue/PublicIssuePage.tsx+++ b/apps/web/src/features/issue/PublicIssuePage.tsx@@ -1,7 +1,7 @@'use client';import { useQuery } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getSharedIssue } from '@/lib/api/endpoints/share';import PublicShareFrame from '@/components/common/page/PublicShareFrame';import PublicShareHeader from '@/components/common/page/PublicShareHeader';import IssueDetailSkeleton from './components/detail/IssueDetailSkeleton';@@ -15,7 +15,7 @@ export default function PublicIssuePage({ token }: { token: string }) {const t = useTranslations('issue');const query = useQuery({queryKey: ['share', 'issue', token],- queryFn: () => api.getSharedIssue(token),+ queryFn: () => getSharedIssue(token),retry: false,});diff --git a/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsx b/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsxindex 684bd05e..f5e71163 100644--- a/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsx+++ b/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsx@@ -1,5 +1,6 @@import { useState } from 'react';-import { type Issue, type ProjectDetail, type SubtaskDisposition } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue, SubtaskDisposition } from '@/lib/api/endpoints/issues';import { dispositionReady, subtaskCount } from '@/utils/subtasks';import { useArchiveIssue } from '@/services/issues.service';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';diff --git a/apps/web/src/features/issue/components/actions/IssueActions.tsx b/apps/web/src/features/issue/components/actions/IssueActions.tsxindex 8105b0ac..9881e684 100644--- a/apps/web/src/features/issue/components/actions/IssueActions.tsx+++ b/apps/web/src/features/issue/components/actions/IssueActions.tsx@@ -1,5 +1,7 @@import { useState } from 'react';-import type { ActionDef, ProjectDetail, Issue, SubtaskDisposition } from '@/lib/api';+import type { ActionDef } from '@/lib/api/endpoints/actions';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue, SubtaskDisposition } from '@/lib/api/endpoints/issues';import { matchesFilterSet } from '@/utils/filters';import { describeEffect } from '@/utils/actions';import { useEffectText } from '@/hooks/useEffectText';diff --git a/apps/web/src/features/issue/components/actions/IssueActionsBar.tsx b/apps/web/src/features/issue/components/actions/IssueActionsBar.tsxindex b6f0ba4b..d4a589ab 100644--- a/apps/web/src/features/issue/components/actions/IssueActionsBar.tsx+++ b/apps/web/src/features/issue/components/actions/IssueActionsBar.tsx@@ -11,12 +11,10 @@ import {Share2,Trash2,} from 'lucide-react';-import {- api,- type ActionDef,- type ProjectDetail,- type IssueDetail as IssueDetailRow,-} from '@/lib/api';+import type { ActionDef } from '@/lib/api/endpoints/actions';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueDetail as IssueDetailRow } from '@/lib/api/endpoints/issues';+import { enableIssueShare, disableIssueShare } from '@/lib/api/endpoints/share';import { actionIcon } from '@/utils/actionIcons';import { useActionsQuery } from '@/services/actions.service';import { useRestoreIssue } from '@/services/issues.service';@@ -68,12 +66,12 @@ export default function IssueActionsBar({// shareExtended (which the dialog reads) stay in sync. The same call creates the// link and flips how much a live one exposes.async function share(extended: boolean) {- const { token } = await api.enableIssueShare(issue.id, extended);+ const { token } = await enableIssueShare(issue.id, extended);await qc.invalidateQueries({ queryKey: qk.issue(issue.id) });return token;}async function disableShare() {- await api.disableIssueShare(issue.id);+ await disableIssueShare(issue.id);await qc.invalidateQueries({ queryKey: qk.issue(issue.id) });}diff --git a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsxindex ff3e57e3..5d7a4d0f 100644--- a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx+++ b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx@@ -18,7 +18,9 @@ import {User,X,} from 'lucide-react';-import type { ActionDef, ProjectDetail, Issue, IssuePatch } from '@/lib/api';+import type { ActionDef } from '@/lib/api/endpoints/actions';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue, IssuePatch } from '@/lib/api/endpoints/issues';import { actionIcon } from '@/utils/actionIcons';import { useActionsQuery } from '@/services/actions.service';import { useRestoreIssue, useUpdateIssue } from '@/services/issues.service';diff --git a/apps/web/src/features/issue/components/actions/SubtaskDisposalChoice.tsx b/apps/web/src/features/issue/components/actions/SubtaskDisposalChoice.tsxindex f5512954..6480f2b8 100644--- a/apps/web/src/features/issue/components/actions/SubtaskDisposalChoice.tsx+++ b/apps/web/src/features/issue/components/actions/SubtaskDisposalChoice.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import { type SubtaskDisposition, type SubtaskMode } from '@/lib/api';+import type { SubtaskDisposition, SubtaskMode } from '@/lib/api/endpoints/issues';import { cn } from '@/lib/utils';import IssuePickerDialog from '@/components/common/overlay/IssuePickerDialog';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/issue/components/create/NewIssueBody.tsx b/apps/web/src/features/issue/components/create/NewIssueBody.tsxindex 47fa4313..135a2bb5 100644--- a/apps/web/src/features/issue/components/create/NewIssueBody.tsx+++ b/apps/web/src/features/issue/components/create/NewIssueBody.tsx@@ -1,5 +1,7 @@import { type Editor } from '@tiptap/react';-import { type Assignee, type CustomField, type IssueFieldValueInput } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { IssueFieldValueInput } from '@/lib/api/endpoints/issues';import { cn } from '@/lib/utils';import { type Embeddable } from '@/components/common/editor/attachmentEmbed';import { DESCRIPTION_SECTION, OTHER_SECTION, fieldSection } from '../../utils/bodySections';diff --git a/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx b/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsxindex 2999331e..26521c14 100644--- a/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx+++ b/apps/web/src/features/issue/components/create/NewIssueBodyFields.tsx@@ -1,4 +1,6 @@-import { type Assignee, type CustomField, type IssueFieldValueInput } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { IssueFieldValueInput } from '@/lib/api/endpoints/issues';import IssueCustomFieldPill from '../fields/IssueCustomFieldPill';// The body fields that are not markdown, gathered in the "Other" section: a pilldiff --git a/apps/web/src/features/issue/components/create/NewIssueModal.tsx b/apps/web/src/features/issue/components/create/NewIssueModal.tsxindex 45e802c9..f1dbea18 100644--- a/apps/web/src/features/issue/components/create/NewIssueModal.tsx+++ b/apps/web/src/features/issue/components/create/NewIssueModal.tsx@@ -1,13 +1,9 @@import { useEffect, useMemo, useRef, useState } from 'react';import { type Editor } from '@tiptap/react';import { MoreHorizontal } from 'lucide-react';-import {- type CycleRef,- type Issue,- type IssueFieldValueInput,- type IssueTemplate,- type ProjectDetail,-} from '@/lib/api';+import type { IssueTemplate } from '@/lib/api/endpoints/issueTemplates';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { CycleRef, Issue, IssueFieldValueInput } from '@/lib/api/endpoints/issues';import { type NewIssueDefaults } from '@/utils/project';import { parseDate } from '@/utils/dates';import { cn } from '@/lib/utils';diff --git a/apps/web/src/features/issue/components/create/NewIssueTemplatePill.tsx b/apps/web/src/features/issue/components/create/NewIssueTemplatePill.tsxindex 6b948006..25b1876c 100644--- a/apps/web/src/features/issue/components/create/NewIssueTemplatePill.tsx+++ b/apps/web/src/features/issue/components/create/NewIssueTemplatePill.tsx@@ -1,6 +1,6 @@import { useTranslations } from 'next-intl';import { FileText } from 'lucide-react';-import type { IssueTemplate } from '@/lib/api';+import type { IssueTemplate } from '@/lib/api/endpoints/issueTemplates';import { Pill } from '@/components/common/fields/Pill';import PopoverPick from '@/components/common/fields/PopoverPick';diff --git a/apps/web/src/features/issue/components/detail/ActivityItemList.tsx b/apps/web/src/features/issue/components/detail/ActivityItemList.tsxindex fdcf995a..2db6e7ca 100644--- a/apps/web/src/features/issue/components/detail/ActivityItemList.tsx+++ b/apps/web/src/features/issue/components/detail/ActivityItemList.tsx@@ -1,4 +1,4 @@-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import ActivityLine from './ActivityLine';import CommentThread from './CommentThread';import { type ComposerContext } from './CommentComposer';diff --git a/apps/web/src/features/issue/components/detail/ActivityLine.tsx b/apps/web/src/features/issue/components/detail/ActivityLine.tsxindex 59ff47b8..eebae561 100644--- a/apps/web/src/features/issue/components/detail/ActivityLine.tsx+++ b/apps/web/src/features/issue/components/detail/ActivityLine.tsx@@ -1,6 +1,6 @@import { useTranslations } from 'next-intl';import { CircleDot } from 'lucide-react';-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import { useRelativeTime } from '@/context/relativeTimeContext';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { ACTION_ICON } from '../../utils/activityIcons';diff --git a/apps/web/src/features/issue/components/detail/CommentComposer.tsx b/apps/web/src/features/issue/components/detail/CommentComposer.tsxindex afc62824..85e8c3ba 100644--- a/apps/web/src/features/issue/components/detail/CommentComposer.tsx+++ b/apps/web/src/features/issue/components/detail/CommentComposer.tsx@@ -1,6 +1,6 @@import { useEffect, useMemo, useRef, useState } from 'react';import { Bot, User } from 'lucide-react';-import { type Assignee } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';import Avatar from '@/components/common/Avatar';import { Button } from '@/components/ui/button';import { Textarea } from '@/components/ui/textarea';diff --git a/apps/web/src/features/issue/components/detail/CommentItem.tsx b/apps/web/src/features/issue/components/detail/CommentItem.tsxindex d7247be5..f51f2dd7 100644--- a/apps/web/src/features/issue/components/detail/CommentItem.tsx+++ b/apps/web/src/features/issue/components/detail/CommentItem.tsx@@ -1,5 +1,5 @@import { Reply } from 'lucide-react';-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import Avatar from '@/components/common/Avatar';import { Button } from '@/components/ui/button';import { useRelativeTime } from '@/context/relativeTimeContext';diff --git a/apps/web/src/features/issue/components/detail/CommentThread.tsx b/apps/web/src/features/issue/components/detail/CommentThread.tsxindex 54cec20d..27e2aa7f 100644--- a/apps/web/src/features/issue/components/detail/CommentThread.tsx+++ b/apps/web/src/features/issue/components/detail/CommentThread.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import { cn } from '@/lib/utils';import CommentItem from './CommentItem';import CommentComposer, { type ComposerContext } from './CommentComposer';diff --git a/apps/web/src/features/issue/components/detail/IssueActivityFeed.tsx b/apps/web/src/features/issue/components/detail/IssueActivityFeed.tsxindex c8e3a533..a68c4b7b 100644--- a/apps/web/src/features/issue/components/detail/IssueActivityFeed.tsx+++ b/apps/web/src/features/issue/components/detail/IssueActivityFeed.tsx@@ -1,5 +1,7 @@import { useState } from 'react';-import { type Assignee, type Column, type IssueActivityView } from '@/lib/api';+import type { IssueActivityView } from '@/lib/api/endpoints/userPreferences';+import type { Column } from '@/lib/api/endpoints/columns';+import type { Assignee } from '@/lib/api/endpoints/projects';import { useSession } from '@/lib/auth-client';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';import { useAccountPreferencesQuery } from '@/services/preferences.service';diff --git a/apps/web/src/features/issue/components/detail/IssueActivityGroup.tsx b/apps/web/src/features/issue/components/detail/IssueActivityGroup.tsxindex f0b8a514..3912d9e4 100644--- a/apps/web/src/features/issue/components/detail/IssueActivityGroup.tsx+++ b/apps/web/src/features/issue/components/detail/IssueActivityGroup.tsx@@ -1,4 +1,4 @@-import { type FeedGroup } from '@/lib/api';+import type { FeedGroup } from '@/lib/api/endpoints/activity';import { formatDateTime } from '@/utils/dates';import { durationLabel } from '../../utils/timeline';import ActivityItemList from './ActivityItemList';diff --git a/apps/web/src/features/issue/components/detail/IssueAttachmentCard.tsx b/apps/web/src/features/issue/components/detail/IssueAttachmentCard.tsxindex 732e499f..8d36972a 100644--- a/apps/web/src/features/issue/components/detail/IssueAttachmentCard.tsx+++ b/apps/web/src/features/issue/components/detail/IssueAttachmentCard.tsx@@ -1,6 +1,6 @@import { type DragEvent } from 'react';import { Download, PenLine, Plus, Trash2 } from 'lucide-react';-import { type Attachment } from '@/lib/api';+import type { Attachment } from '@/lib/api/endpoints/attachments';import { attachmentHtml, isImage, isVideo } from '@/components/common/editor/attachmentEmbed';import { formatSize } from '@/utils/fileSize';import AttachmentThumb from '@/components/common/attachments/AttachmentThumb';diff --git a/apps/web/src/features/issue/components/detail/IssueAttachmentsPanel.tsx b/apps/web/src/features/issue/components/detail/IssueAttachmentsPanel.tsxindex d6bd99a0..07ad549c 100644--- a/apps/web/src/features/issue/components/detail/IssueAttachmentsPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueAttachmentsPanel.tsx@@ -1,6 +1,6 @@import { useRef, useState } from 'react';import { Download, Plus } from 'lucide-react';-import { type Attachment } from '@/lib/api';+import type { Attachment } from '@/lib/api/endpoints/attachments';import { useFileDragZone } from '@/hooks/useFileDragZone';import { usePersistedOpen } from '../../hooks/usePersistedOpen';import {diff --git a/apps/web/src/features/issue/components/detail/IssueChecklistCard.tsx b/apps/web/src/features/issue/components/detail/IssueChecklistCard.tsxindex 1d1b7099..fd5c163b 100644--- a/apps/web/src/features/issue/components/detail/IssueChecklistCard.tsx+++ b/apps/web/src/features/issue/components/detail/IssueChecklistCard.tsx@@ -3,7 +3,7 @@ import { DndContext, closestCenter, type DragEndEvent } from '@dnd-kit/core';import { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';import { CSS } from '@dnd-kit/utilities';import { Plus } from 'lucide-react';-import { type Checklist } from '@/lib/api';+import type { Checklist } from '@/lib/api/endpoints/checklists';import { Button } from '@/components/ui/button';import { useDndSensors } from '@/lib/dnd';import { cn } from '@/lib/utils';diff --git a/apps/web/src/features/issue/components/detail/IssueChecklistHeader.tsx b/apps/web/src/features/issue/components/detail/IssueChecklistHeader.tsxindex fa7a98df..0532ab69 100644--- a/apps/web/src/features/issue/components/detail/IssueChecklistHeader.tsx+++ b/apps/web/src/features/issue/components/detail/IssueChecklistHeader.tsx@@ -1,6 +1,6 @@import { type useSortable } from '@dnd-kit/sortable';import { Trash2 } from 'lucide-react';-import { type Checklist } from '@/lib/api';+import type { Checklist } from '@/lib/api/endpoints/checklists';import { Button } from '@/components/ui/button';import { CHECKLIST_TITLE_MAX } from '../../utils/checklists';import IssueChecklistEditableText from './IssueChecklistEditableText';diff --git a/apps/web/src/features/issue/components/detail/IssueChecklistItemRow.tsx b/apps/web/src/features/issue/components/detail/IssueChecklistItemRow.tsxindex 46bdd5c3..85ea7287 100644--- a/apps/web/src/features/issue/components/detail/IssueChecklistItemRow.tsx+++ b/apps/web/src/features/issue/components/detail/IssueChecklistItemRow.tsx@@ -1,7 +1,7 @@import { useSortable } from '@dnd-kit/sortable';import { CSS } from '@dnd-kit/utilities';import { X } from 'lucide-react';-import { type ChecklistItem } from '@/lib/api';+import type { ChecklistItem } from '@/lib/api/endpoints/checklists';import { Button } from '@/components/ui/button';import { Checkbox } from '@/components/ui/checkbox';import { cn } from '@/lib/utils';diff --git a/apps/web/src/features/issue/components/detail/IssueChecklistsPanel.tsx b/apps/web/src/features/issue/components/detail/IssueChecklistsPanel.tsxindex 0ed0222b..d18b2e9b 100644--- a/apps/web/src/features/issue/components/detail/IssueChecklistsPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueChecklistsPanel.tsx@@ -2,7 +2,7 @@ import { useState } from 'react';import { DndContext, closestCenter, type DragEndEvent } from '@dnd-kit/core';import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';import { Plus } from 'lucide-react';-import { type IssueWithWatchers } from '@/lib/api';+import type { IssueWithWatchers } from '@/lib/api/endpoints/issues';import { usePermissions } from '@/hooks/usePermissions';import { Button } from '@/components/ui/button';import { useDndSensors } from '@/lib/dnd';diff --git a/apps/web/src/features/issue/components/detail/IssueDetail.tsx b/apps/web/src/features/issue/components/detail/IssueDetail.tsxindex ccb31db9..e0aa396e 100644--- a/apps/web/src/features/issue/components/detail/IssueDetail.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDetail.tsx@@ -1,6 +1,7 @@import { useRef, useState } from 'react';import { Maximize2, X } from 'lucide-react';-import { type ProjectDetail, type IssueDetail as IssueDetailRow } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueDetail as IssueDetailRow } from '@/lib/api/endpoints/issues';import IssueDetailContent from './IssueDetailContent';import IssueActionsBar from '../actions/IssueActionsBar';import { useExitOnEscape } from '@/hooks/useExitOnEscape';diff --git a/apps/web/src/features/issue/components/detail/IssueDetailContent.tsx b/apps/web/src/features/issue/components/detail/IssueDetailContent.tsxindex 3aa9df89..d183af2d 100644--- a/apps/web/src/features/issue/components/detail/IssueDetailContent.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDetailContent.tsx@@ -1,6 +1,7 @@import { type CSSProperties, useRef, useState } from 'react';import { Direction } from 'radix-ui';-import { type ProjectDetail, type IssueDetail as IssueDetailRow } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueDetail as IssueDetailRow } from '@/lib/api/endpoints/issues';import { usePermissions } from '@/hooks/usePermissions';import { usePersistedWidth } from '@/hooks/usePersistedWidth';import { useProjectFeatures } from '@/hooks/useProjectFeatures';diff --git a/apps/web/src/features/issue/components/detail/IssueDevelopmentChecks.tsx b/apps/web/src/features/issue/components/detail/IssueDevelopmentChecks.tsxindex e0d57a88..da373773 100644--- a/apps/web/src/features/issue/components/detail/IssueDevelopmentChecks.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDevelopmentChecks.tsx@@ -1,6 +1,6 @@import { ExternalLink } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type DevelopmentCheck } from '@/lib/api';+import type { DevelopmentCheck } from '@/lib/api/endpoints/git';import IssueDevelopmentCiBadge from './IssueDevelopmentCiBadge';export default function IssueDevelopmentChecks({ checks }: { checks: DevelopmentCheck[] }) {diff --git a/apps/web/src/features/issue/components/detail/IssueDevelopmentCiBadge.tsx b/apps/web/src/features/issue/components/detail/IssueDevelopmentCiBadge.tsxindex 85e98046..6ae2e61e 100644--- a/apps/web/src/features/issue/components/detail/IssueDevelopmentCiBadge.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDevelopmentCiBadge.tsx@@ -1,6 +1,6 @@import { CircleCheck, CircleDashed, CircleX, LoaderCircle } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type PipelineStatus } from '@/lib/api';+import type { PipelineStatus } from '@/lib/api/endpoints/git';import { Badge } from '@/components/ui/badge';import { issueDevelopmentBadgeClassName } from './issueDevelopmentBadgeStyles';diff --git a/apps/web/src/features/issue/components/detail/IssueDevelopmentLinkCard.tsx b/apps/web/src/features/issue/components/detail/IssueDevelopmentLinkCard.tsxindex 12beba54..78febaa5 100644--- a/apps/web/src/features/issue/components/detail/IssueDevelopmentLinkCard.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDevelopmentLinkCard.tsx@@ -1,6 +1,6 @@import { ExternalLink, GitBranch, GitPullRequest, Unlink } from 'lucide-react';import { useFormatter, useTranslations } from 'next-intl';-import { type DevelopmentLink } from '@/lib/api';+import type { DevelopmentLink } from '@/lib/api/endpoints/git';import IssueDevelopmentChecks from './IssueDevelopmentChecks';import IssueDevelopmentCiBadge from './IssueDevelopmentCiBadge';import IssueDevelopmentStateBadge from './IssueDevelopmentStateBadge';diff --git a/apps/web/src/features/issue/components/detail/IssueDevelopmentPanel.tsx b/apps/web/src/features/issue/components/detail/IssueDevelopmentPanel.tsxindex 0bf14c9b..4abdc236 100644--- a/apps/web/src/features/issue/components/detail/IssueDevelopmentPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDevelopmentPanel.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import { type DevelopmentLink } from '@/lib/api';+import type { DevelopmentLink } from '@/lib/api/endpoints/git';import { usePersistedOpen } from '../../hooks/usePersistedOpen';import IssueDevelopmentAddMenu from './IssueDevelopmentAddMenu';import IssueDevelopmentCreateDialog from './IssueDevelopmentCreateDialog';diff --git a/apps/web/src/features/issue/components/detail/IssueDevelopmentStateBadge.tsx b/apps/web/src/features/issue/components/detail/IssueDevelopmentStateBadge.tsxindex abf44824..b1e75e7d 100644--- a/apps/web/src/features/issue/components/detail/IssueDevelopmentStateBadge.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDevelopmentStateBadge.tsx@@ -7,7 +7,7 @@ import {GitPullRequestDraft,} from 'lucide-react';import { useTranslations } from 'next-intl';-import { type DevelopmentLink } from '@/lib/api';+import type { DevelopmentLink } from '@/lib/api/endpoints/git';import { Badge } from '@/components/ui/badge';import { issueDevelopmentBadgeClassName } from './issueDevelopmentBadgeStyles';diff --git a/apps/web/src/features/issue/components/detail/IssueFeedList.tsx b/apps/web/src/features/issue/components/detail/IssueFeedList.tsxindex 6d2fca3e..9d131e7e 100644--- a/apps/web/src/features/issue/components/detail/IssueFeedList.tsx+++ b/apps/web/src/features/issue/components/detail/IssueFeedList.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import { useFeedQuery } from '../../services/comments.service';import ShowMoreButton from '@/components/common/ShowMoreButton';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';diff --git a/apps/web/src/features/issue/components/detail/IssueGroupedFeed.tsx b/apps/web/src/features/issue/components/detail/IssueGroupedFeed.tsxindex 93659e0b..06e10e51 100644--- a/apps/web/src/features/issue/components/detail/IssueGroupedFeed.tsx+++ b/apps/web/src/features/issue/components/detail/IssueGroupedFeed.tsx@@ -1,5 +1,6 @@import { useTranslations } from 'next-intl';-import { type Column, type FeedGroup, type GroupedFeedPage } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';+import type { FeedGroup, GroupedFeedPage } from '@/lib/api/endpoints/activity';import ShowMoreButton from '@/components/common/ShowMoreButton';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import { useGroupedFeedQuery } from '../../services/comments.service';diff --git a/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsx b/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsxindex e906b63c..86935b22 100644--- a/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsx+++ b/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsx@@ -1,6 +1,7 @@import { useEffect, useState } from 'react';import { Hash } from 'lucide-react';-import { type IssueLinkInputKind, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueLinkInputKind } from '@/lib/api/endpoints/issues';import { useDebouncedValue } from '@/hooks/useDebouncedValue';import { useIssueSearchQuery } from '@/services/issues.service';import {diff --git a/apps/web/src/features/issue/components/detail/IssueLinksAddMenu.tsx b/apps/web/src/features/issue/components/detail/IssueLinksAddMenu.tsxindex 49ef4e14..249a4853 100644--- a/apps/web/src/features/issue/components/detail/IssueLinksAddMenu.tsx+++ b/apps/web/src/features/issue/components/detail/IssueLinksAddMenu.tsx@@ -1,5 +1,5 @@import { CirclePlus, Plus } from 'lucide-react';-import { type IssueLinkInputKind } from '@/lib/api';+import type { IssueLinkInputKind } from '@/lib/api/endpoints/issues';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx b/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsxindex 46ca905d..620d1412 100644--- a/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx@@ -1,5 +1,6 @@import { useState } from 'react';-import { type IssueLinkInputKind, type IssueRelations, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueLinkInputKind, IssueRelations } from '@/lib/api/endpoints/issues';import { usePermissions } from '@/hooks/usePermissions';import { LINK_RELATIONS, inverseRelation, linkRelation, storedKind } from '@/utils/issueLinks';import { useLinkRelationLabel } from '@/hooks/useLinkRelationLabel';diff --git a/apps/web/src/features/issue/components/detail/IssueProperties.tsx b/apps/web/src/features/issue/components/detail/IssueProperties.tsxindex 53e82987..68255b76 100644--- a/apps/web/src/features/issue/components/detail/IssueProperties.tsx+++ b/apps/web/src/features/issue/components/detail/IssueProperties.tsx@@ -1,13 +1,13 @@import { Fragment, type ReactNode } from 'react';import { RefreshCw, Target } from 'lucide-react';-import {- type CustomField,- type ProjectDetail,- type IssueDetail as IssueDetailRow,- type IssueFieldValueInput,- type IssuePatch,- type IssueWatcher,-} from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type {+ IssueDetail as IssueDetailRow,+ IssueFieldValueInput,+ IssuePatch,+ IssueWatcher,+} from '@/lib/api/endpoints/issues';import AssigneeSelect from '@/components/common/fields/AssigneeSelect';import DatePill from '@/components/common/fields/DatePill';import { Pill } from '@/components/common/fields/Pill';diff --git a/apps/web/src/features/issue/components/detail/IssueRefRow.tsx b/apps/web/src/features/issue/components/detail/IssueRefRow.tsxindex d6360154..56ea14cf 100644--- a/apps/web/src/features/issue/components/detail/IssueRefRow.tsx+++ b/apps/web/src/features/issue/components/detail/IssueRefRow.tsx@@ -1,6 +1,7 @@import Link from 'next/link';import { X } from 'lucide-react';-import { type IssueRef, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueRef } from '@/lib/api/endpoints/issues';import { issuePath } from '@/utils/paths';import { Button } from '@/components/ui/button';import ArchivedBadge from '@/components/common/ArchivedBadge';diff --git a/apps/web/src/features/issue/components/detail/IssueStatusTimeline.tsx b/apps/web/src/features/issue/components/detail/IssueStatusTimeline.tsxindex bc2dc73c..cc117b36 100644--- a/apps/web/src/features/issue/components/detail/IssueStatusTimeline.tsx+++ b/apps/web/src/features/issue/components/detail/IssueStatusTimeline.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import { type Column } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';import { Button } from '@/components/ui/button';import { useAccountPreferencesQuery } from '@/services/preferences.service';import { useTimelineQuery } from '../../services/comments.service';diff --git a/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx b/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsxindex 0ab63643..8e04c081 100644--- a/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx@@ -1,6 +1,7 @@import { useState } from 'react';import { Plus } from 'lucide-react';-import { type IssueRelations, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueRelations } from '@/lib/api/endpoints/issues';import { usePermissions } from '@/hooks/usePermissions';import { subtaskProgress } from '@/utils/subtasks';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/issue/components/detail/IssueWatchers.tsx b/apps/web/src/features/issue/components/detail/IssueWatchers.tsxindex 4424ec64..638165cd 100644--- a/apps/web/src/features/issue/components/detail/IssueWatchers.tsx+++ b/apps/web/src/features/issue/components/detail/IssueWatchers.tsx@@ -1,6 +1,7 @@import { Check, Eye, EyeOff, LoaderCircle, UserPlus } from 'lucide-react';import { useIsMutating } from '@tanstack/react-query';-import { type Assignee, type IssueWatcher } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { IssueWatcher } from '@/lib/api/endpoints/issues';import { useSession } from '@/lib/auth-client';import Avatar from '@/components/common/Avatar';import { Pill } from '@/components/common/fields/Pill';diff --git a/apps/web/src/features/issue/components/detail/IssueWorklogForm.tsx b/apps/web/src/features/issue/components/detail/IssueWorklogForm.tsxindex f76e9da3..40c1db7f 100644--- a/apps/web/src/features/issue/components/detail/IssueWorklogForm.tsx+++ b/apps/web/src/features/issue/components/detail/IssueWorklogForm.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { type WorklogInput } from '@/lib/api';+import type { WorklogInput } from '@/lib/api/endpoints/worklogs';import { toDateStr } from '@/utils/dates';import { parseMinutes, formatMinutes } from '@/utils/estimate';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsx b/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsxindex 44656ce2..d2691cf8 100644--- a/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsx@@ -3,7 +3,8 @@import { useState } from 'react';import { Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type IssueDetail, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssueDetail } from '@/lib/api/endpoints/issues';import { useSession } from '@/lib/auth-client';import { usePermissions } from '@/hooks/usePermissions';import { formatMinutes } from '@/utils/estimate';diff --git a/apps/web/src/features/issue/components/detail/IssueWorklogRow.tsx b/apps/web/src/features/issue/components/detail/IssueWorklogRow.tsxindex 2f9f45c2..fcb03bc2 100644--- a/apps/web/src/features/issue/components/detail/IssueWorklogRow.tsx+++ b/apps/web/src/features/issue/components/detail/IssueWorklogRow.tsx@@ -2,7 +2,7 @@import { Pencil, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type Worklog } from '@/lib/api';+import type { Worklog } from '@/lib/api/endpoints/worklogs';import { formatShortDate } from '@/utils/dates';import { formatMinutes } from '@/utils/estimate';import Avatar from '@/components/common/Avatar';diff --git a/apps/web/src/features/issue/components/detail/ReadOnlyActivityFeed.tsx b/apps/web/src/features/issue/components/detail/ReadOnlyActivityFeed.tsxindex 76e26b82..eb346593 100644--- a/apps/web/src/features/issue/components/detail/ReadOnlyActivityFeed.tsx+++ b/apps/web/src/features/issue/components/detail/ReadOnlyActivityFeed.tsx@@ -1,4 +1,4 @@-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import ActivityItemList from './ActivityItemList';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx b/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsxindex d42e6b4b..a804679e 100644--- a/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx+++ b/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx@@ -1,4 +1,4 @@-import { type SharedIssueBundle } from '@/lib/api';+import type { SharedIssueBundle } from '@/lib/api/endpoints/share';import { toPublicProjectDetail } from '@/utils/publicProject';import { usePersistedOpen, usePersistedOpenGroups } from '../../hooks/usePersistedOpen';import { fieldDefsForType } from '../../utils/fieldDefs';diff --git a/apps/web/src/features/issue/components/fields/CycleSelect.tsx b/apps/web/src/features/issue/components/fields/CycleSelect.tsxindex aeb4124e..d8b6fd48 100644--- a/apps/web/src/features/issue/components/fields/CycleSelect.tsx+++ b/apps/web/src/features/issue/components/fields/CycleSelect.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { Check, CircleDashed, RefreshCw } from 'lucide-react';-import type { CycleRef } from '@/lib/api';+import type { CycleRef } from '@/lib/api/endpoints/issues';import { useCycleOptionsQuery } from '@/services/cycles.service';import { colorDot } from '@/components/common/fields/colorDot';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';diff --git a/apps/web/src/features/issue/components/fields/DelegateSelect.tsx b/apps/web/src/features/issue/components/fields/DelegateSelect.tsxindex ae8d15b9..b216b7d9 100644--- a/apps/web/src/features/issue/components/fields/DelegateSelect.tsx+++ b/apps/web/src/features/issue/components/fields/DelegateSelect.tsx@@ -1,6 +1,6 @@import { CircleDashed } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Assignee } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';import Avatar from '@/components/common/Avatar';import { Pill } from '@/components/common/fields/Pill';import PopoverPick from '@/components/common/fields/PopoverPick';diff --git a/apps/web/src/features/issue/components/fields/IssueCustomFieldBody.tsx b/apps/web/src/features/issue/components/fields/IssueCustomFieldBody.tsxindex 28cd47fa..03b7f660 100644--- a/apps/web/src/features/issue/components/fields/IssueCustomFieldBody.tsx+++ b/apps/web/src/features/issue/components/fields/IssueCustomFieldBody.tsx@@ -1,9 +1,6 @@-import {- type Assignee,- type CustomField,- type IssueFieldValue,- type IssueFieldValueInput,-} from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { IssueFieldValue, IssueFieldValueInput } from '@/lib/api/endpoints/issues';import MarkdownEditor from '@/components/common/editor/MarkdownEditor';import { type Embeddable } from '@/components/common/editor/attachmentEmbed';import IssueCustomFieldControl from './IssueCustomFieldControl';diff --git a/apps/web/src/features/issue/components/fields/IssueCustomFieldControl.tsx b/apps/web/src/features/issue/components/fields/IssueCustomFieldControl.tsxindex f556c0ab..d20027dd 100644--- a/apps/web/src/features/issue/components/fields/IssueCustomFieldControl.tsx+++ b/apps/web/src/features/issue/components/fields/IssueCustomFieldControl.tsx@@ -1,9 +1,6 @@-import {- type Assignee,- type CustomField,- type IssueFieldValue,- type IssueFieldValueInput,-} from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { IssueFieldValue, IssueFieldValueInput } from '@/lib/api/endpoints/issues';import { formatDate, formatDateTimeRange } from '@/utils/dates';import { Button } from '@/components/ui/button';import { Checkbox } from '@/components/ui/checkbox';diff --git a/apps/web/src/features/issue/components/fields/IssueCustomFieldPill.tsx b/apps/web/src/features/issue/components/fields/IssueCustomFieldPill.tsxindex a8e6dcf7..f013ddee 100644--- a/apps/web/src/features/issue/components/fields/IssueCustomFieldPill.tsx+++ b/apps/web/src/features/issue/components/fields/IssueCustomFieldPill.tsx@@ -1,6 +1,8 @@import { useState } from 'react';import { Check } from 'lucide-react';-import { type Assignee, type CustomField, type IssueFieldValueInput } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { IssueFieldValueInput } from '@/lib/api/endpoints/issues';import { cn } from '@/lib/utils';import {Command,diff --git a/apps/web/src/features/issue/components/fields/MemberSelect.tsx b/apps/web/src/features/issue/components/fields/MemberSelect.tsxindex e1bd1272..389cfcb8 100644--- a/apps/web/src/features/issue/components/fields/MemberSelect.tsx+++ b/apps/web/src/features/issue/components/fields/MemberSelect.tsx@@ -1,6 +1,7 @@import { CircleDashed } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Assignee, MemberScope } from '@/lib/api';+import type { MemberScope } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';import Avatar from '@/components/common/Avatar';import { Pill } from '@/components/common/fields/Pill';import PopoverPick from '@/components/common/fields/PopoverPick';diff --git a/apps/web/src/features/issue/components/shared/IssueIcons.tsx b/apps/web/src/features/issue/components/shared/IssueIcons.tsxindex f1d7d975..c74a471d 100644--- a/apps/web/src/features/issue/components/shared/IssueIcons.tsx+++ b/apps/web/src/features/issue/components/shared/IssueIcons.tsx@@ -1,4 +1,4 @@-import type { StateType } from '@/lib/api';+import type { StateType } from '@/lib/api/endpoints/columns';// Linear-style status icon, colored by the column color. One glyph per state// type: backlog is a dashed ring, unstarted an empty ring, started a ring withdiff --git a/apps/web/src/features/issue/hooks/useActivityText.tsx b/apps/web/src/features/issue/hooks/useActivityText.tsxindex 105564a7..5e318470 100644--- a/apps/web/src/features/issue/hooks/useActivityText.tsx+++ b/apps/web/src/features/issue/hooks/useActivityText.tsx@@ -2,7 +2,7 @@import { type ReactNode } from 'react';import { useTranslations } from 'next-intl';-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import { formatDate } from '@/utils/dates';import { isLinkRelation } from '@/utils/issueLinks';import { byKey } from '@/utils/messageKey';diff --git a/apps/web/src/features/issue/hooks/useArchiveAction.tsx b/apps/web/src/features/issue/hooks/useArchiveAction.tsxindex 0c47796d..33931020 100644--- a/apps/web/src/features/issue/hooks/useArchiveAction.tsx+++ b/apps/web/src/features/issue/hooks/useArchiveAction.tsx@@ -1,7 +1,8 @@'use client';import { useState, type ReactNode } from 'react';-import { type Issue, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { subtaskCount } from '@/utils/subtasks';import { useArchiveIssue } from '@/services/issues.service';import ArchiveIssueDialog from '../components/actions/ArchiveIssueDialog';diff --git a/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx b/apps/web/src/features/issue/hooks/useCandidatePickItem.tsxindex 311602cb..00b5c5d7 100644--- a/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx+++ b/apps/web/src/features/issue/hooks/useCandidatePickItem.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { Assignee } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';import { useSession } from '@/lib/auth-client';import Avatar from '@/components/common/Avatar';import type { PickItem } from '@/components/common/fields/PopoverPick';diff --git a/apps/web/src/features/issue/hooks/useIssueCommands.tsx b/apps/web/src/features/issue/hooks/useIssueCommands.tsxindex 106bb184..b58f0f52 100644--- a/apps/web/src/features/issue/hooks/useIssueCommands.tsx+++ b/apps/web/src/features/issue/hooks/useIssueCommands.tsx@@ -15,7 +15,9 @@ import {User,X,} from 'lucide-react';-import type { ActionDef, IssuePatch, ProjectDetail } from '@/lib/api';+import type { ActionDef } from '@/lib/api/endpoints/actions';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { IssuePatch } from '@/lib/api/endpoints/issues';import { actionIcon } from '@/utils/actionIcons';import { toDateStr } from '@/utils/dates';import { useActionsQuery } from '@/services/actions.service';diff --git a/apps/web/src/features/issue/hooks/useIssueDetail.ts b/apps/web/src/features/issue/hooks/useIssueDetail.tsindex 072cac25..a908f099 100644--- a/apps/web/src/features/issue/hooks/useIssueDetail.ts+++ b/apps/web/src/features/issue/hooks/useIssueDetail.ts@@ -2,13 +2,13 @@ import { useEffect, useState } from 'react';import { type Editor } from '@tiptap/react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import {- type Attachment,- type ProjectDetail,- type IssueDetail as IssueDetailRow,- type IssueFieldValueInput,- type IssuePatch,-} from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Attachment } from '@/lib/api/endpoints/attachments';+import type {+ IssueDetail as IssueDetailRow,+ IssueFieldValueInput,+ IssuePatch,+} from '@/lib/api/endpoints/issues';import { useIssueQuery, useSetFieldValue, useUpdateIssue } from '@/services/issues.service';import { useLiveRefresh } from '@/hooks/useLiveRefresh';import { revScope } from '@/utils/revScopes';diff --git a/apps/web/src/features/issue/hooks/useLastComment.ts b/apps/web/src/features/issue/hooks/useLastComment.tsindex 1cc7bd24..6391d781 100644--- a/apps/web/src/features/issue/hooks/useLastComment.ts+++ b/apps/web/src/features/issue/hooks/useLastComment.ts@@ -1,4 +1,4 @@-import { type FeedItem } from '@/lib/api';+import type { FeedItem } from '@/lib/api/endpoints/activity';import { useFeedQuery, useGroupedFeedQuery } from '../services/comments.service';// The last comment written on the issue, read from whatever the activity section hasdiff --git a/apps/web/src/features/issue/services/attachments.service.ts b/apps/web/src/features/issue/services/attachments.service.tsindex 283a2dd7..ba72f573 100644--- a/apps/web/src/features/issue/services/attachments.service.ts+++ b/apps/web/src/features/issue/services/attachments.service.ts@@ -1,19 +1,24 @@-// Issue attachment reads and writes. The low-level fetch client (api.ts) is-// untouched; this module wraps it.+// Issue attachment reads and writes, wrapping lib/api/endpoints/attachments.import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type Attachment } from '@/lib/api';+import {+ type Attachment,+ listAttachments,+ uploadAttachment,+ replaceAttachment,+ deleteAttachment,+} from '@/lib/api/endpoints/attachments';import { qk } from '@/services/queryKeys';export function useAttachmentsQuery(id: number) {- return useQuery({ queryKey: qk.attachments(id), queryFn: () => api.listAttachments(id) });+ return useQuery({ queryKey: qk.attachments(id), queryFn: () => listAttachments(id) });}export function useUploadAttachment() {const qc = useQueryClient();return useMutation({mutationFn: ({ issueId, file }: { issueId: number; file: File }): Promise<Attachment> =>- api.uploadAttachment(issueId, file),+ uploadAttachment(issueId, file),onSuccess: (_data, { issueId }) =>void qc.invalidateQueries({ queryKey: qk.attachments(issueId) }),});@@ -23,7 +28,7 @@ export function useReplaceAttachment(issueId: number) {const qc = useQueryClient();return useMutation({mutationFn: ({ publicId, file }: { publicId: string; file: File }): Promise<Attachment> =>- api.replaceAttachment(publicId, file),+ replaceAttachment(publicId, file),onSuccess: () => void qc.invalidateQueries({ queryKey: qk.attachments(issueId) }),});}@@ -31,7 +36,7 @@ export function useReplaceAttachment(issueId: number) {export function useDeleteAttachment(issueId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (publicId: string) => api.deleteAttachment(publicId),+ mutationFn: (publicId: string) => deleteAttachment(publicId),// Deleting also strips the attachment's embeds from the description and// markdown field values, so refetch the issue alongside the panel list.onSuccess: () => {diff --git a/apps/web/src/features/issue/services/checklists.service.ts b/apps/web/src/features/issue/services/checklists.service.tsindex ef7918c7..33a61ea5 100644--- a/apps/web/src/features/issue/services/checklists.service.ts+++ b/apps/web/src/features/issue/services/checklists.service.ts@@ -4,7 +4,18 @@// on screen, and waiting for the round trip would make them feel broken.import { useMutation, useQueryClient } from '@tanstack/react-query';-import { api, type Checklist, type IssueWithWatchers } from '@/lib/api';+import {+ type Checklist,+ createChecklist,+ renameChecklist,+ deleteChecklist,+ createChecklistItem,+ deleteChecklistItem,+ updateChecklistItem,+ reorderChecklists,+ reorderChecklistItems,+} from '@/lib/api/endpoints/checklists';+import type { IssueWithWatchers } from '@/lib/api/endpoints/issues';import { qk } from '@/services/queryKeys';// Puts a list in the order given by ids. Ids that are not in the list are skipped,@@ -67,31 +78,31 @@ function useOptimisticChecklistMutation<TVars extends { issueId: number }>(export function useCreateChecklist() {return useChecklistMutation((vars: { issueId: number; title: string }) =>- api.createChecklist(vars.issueId, vars.title),+ createChecklist(vars.issueId, vars.title),);}export function useRenameChecklist() {return useChecklistMutation((vars: { issueId: number; checklistId: number; title: string }) =>- api.renameChecklist(vars.checklistId, vars.title),+ renameChecklist(vars.checklistId, vars.title),);}export function useDeleteChecklist() {return useChecklistMutation((vars: { issueId: number; checklistId: number }) =>- api.deleteChecklist(vars.checklistId),+ deleteChecklist(vars.checklistId),);}export function useCreateChecklistItem() {return useChecklistMutation((vars: { issueId: number; checklistId: number; content: string }) =>- api.createChecklistItem(vars.checklistId, vars.content),+ createChecklistItem(vars.checklistId, vars.content),);}export function useDeleteChecklistItem() {return useChecklistMutation((vars: { issueId: number; itemId: number }) =>- api.deleteChecklistItem(vars.itemId),+ deleteChecklistItem(vars.itemId),);}@@ -102,7 +113,7 @@ export function useUpdateChecklistItem() {checklistId: number;itemId: number;patch: { content?: string; done?: boolean };- }) => api.updateChecklistItem(vars.itemId, vars.patch),+ }) => updateChecklistItem(vars.itemId, vars.patch),(checklists, { checklistId, itemId, patch }) =>checklists.map((checklist) =>checklist.id === checklistId@@ -120,7 +131,7 @@ export function useUpdateChecklistItem() {export function useReorderChecklists() {return useOptimisticChecklistMutation((vars: { issueId: number; orderedIds: number[] }) =>- api.reorderChecklists(vars.issueId, vars.orderedIds),+ reorderChecklists(vars.issueId, vars.orderedIds),(checklists, { orderedIds }) => applyOrder(checklists, orderedIds),);}@@ -128,7 +139,7 @@ export function useReorderChecklists() {export function useReorderChecklistItems() {return useOptimisticChecklistMutation((vars: { issueId: number; checklistId: number; orderedIds: number[] }) =>- api.reorderChecklistItems(vars.checklistId, vars.orderedIds),+ reorderChecklistItems(vars.checklistId, vars.orderedIds),(checklists, { checklistId, orderedIds }) =>checklists.map((checklist) =>checklist.id === checklistIddiff --git a/apps/web/src/features/issue/services/comments.service.ts b/apps/web/src/features/issue/services/comments.service.tsindex d5a58dbd..98b02df6 100644--- a/apps/web/src/features/issue/services/comments.service.ts+++ b/apps/web/src/features/issue/services/comments.service.ts@@ -1,5 +1,5 @@-// Issue feed (comments + activity) reads and comment writes. The low-level fetch-// client (api.ts) is untouched; this module wraps it.+// Issue feed (comments + activity) reads and comment writes, wrapping+// lib/api/endpoints/activity.import {useInfiniteQuery,@@ -8,7 +8,14 @@ import {useQuery,useQueryClient,} from '@tanstack/react-query';-import { api, type FeedCursor } from '@/lib/api';+import {+ type FeedCursor,+ listFeed,+ listGroupedFeed,+ listTimeline,+ listTimelineItems,+ createComment,+} from '@/lib/api/endpoints/activity';import { qk } from '@/services/queryKeys';// The issue's timeline (comments + activity), paged newest first. Each page is@@ -16,7 +23,7 @@ import { qk } from '@/services/queryKeys';export function useFeedQuery(id: number, enabled = true) {return useInfiniteQuery({queryKey: qk.feed(id),- queryFn: ({ pageParam }) => api.listFeed(id, { cursor: pageParam, limit: 25 }),+ queryFn: ({ pageParam }) => listFeed(id, { cursor: pageParam, limit: 25 }),initialPageParam: null as FeedCursor | null,getNextPageParam: (last) => last.nextCursor,enabled,@@ -29,7 +36,7 @@ export function useFeedQuery(id: number, enabled = true) {export function useGroupedFeedQuery(id: number, enabled = true) {return useInfiniteQuery({queryKey: qk.groupedFeed(id),- queryFn: ({ pageParam }) => api.listGroupedFeed(id, { cursor: pageParam, limit: 25 }),+ queryFn: ({ pageParam }) => listGroupedFeed(id, { cursor: pageParam, limit: 25 }),initialPageParam: null as FeedCursor | null,getNextPageParam: (last) => last.nextCursor,enabled,@@ -39,7 +46,7 @@ export function useGroupedFeedQuery(id: number, enabled = true) {// The stretches the issue spent in one status, oldest first. Carries no entries,// so it stays small however long the issue's history is.export function useTimelineQuery(id: number) {- return useQuery({ queryKey: qk.timeline(id), queryFn: () => api.listTimeline(id) });+ return useQuery({ queryKey: qk.timeline(id), queryFn: () => listTimeline(id) });}// One time range of the issue's activity, as the timeline addresses its stretches.@@ -55,7 +62,7 @@ export function useTimelineItemsQuery(issueId: number, ranges: TimelineRange[])return useQueries({queries: ranges.map((range) => ({queryKey: qk.timelineItems(issueId, range.from, range.to),- queryFn: () => api.listTimelineItems(issueId, range.from, range.to),+ queryFn: () => listTimelineItems(issueId, range.from, range.to),})),combine: (results) => ({isPending: results.some((r) => r.isPending),@@ -74,7 +81,7 @@ export function useCreateComment() {}: {issueId: number;input: { body: string; replyToId?: number };- }) => api.createComment(issueId, input),+ }) => createComment(issueId, input),onSuccess: (_data, { issueId }) => void qc.invalidateQueries({ queryKey: qk.feed(issueId) }),});}diff --git a/apps/web/src/features/issue/services/links.service.ts b/apps/web/src/features/issue/services/links.service.tsindex f9383c55..c253453f 100644--- a/apps/web/src/features/issue/services/links.service.ts+++ b/apps/web/src/features/issue/services/links.service.ts@@ -2,7 +2,7 @@// so each mutation refreshes the issue detail and feed of both ends.import { useMutation, useQueryClient } from '@tanstack/react-query';-import { api, type IssueLinkInputKind } from '@/lib/api';+import { type IssueLinkInputKind, linkIssues, unlinkIssues } from '@/lib/api/endpoints/issues';import { qk } from '@/services/queryKeys';interface LinkVars {@@ -29,12 +29,12 @@ function useLinkMutation<TVars extends LinkVars>(run: (vars: TVars) => Promise<uexport function useLinkIssues() {return useLinkMutation((vars: LinkVars & { kind: IssueLinkInputKind }) =>- api.linkIssues(vars.issueId, vars.otherIssueId, vars.kind),+ linkIssues(vars.issueId, vars.otherIssueId, vars.kind),);}export function useUnlinkIssues() {return useLinkMutation((vars: LinkVars & { linkId: number }) =>- api.unlinkIssues(vars.issueId, vars.linkId),+ unlinkIssues(vars.issueId, vars.linkId),);}diff --git a/apps/web/src/features/issue/services/subtasks.service.ts b/apps/web/src/features/issue/services/subtasks.service.tsindex 65cbcfdf..ca3572b1 100644--- a/apps/web/src/features/issue/services/subtasks.service.ts+++ b/apps/web/src/features/issue/services/subtasks.service.ts@@ -3,7 +3,7 @@// parents it moved between, plus the board the subtask rows are read from.import { useMutation, useQueryClient } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { updateIssue } from '@/lib/api/endpoints/issues';import { qk } from '@/services/queryKeys';interface SetParentVars {@@ -17,7 +17,7 @@ interface SetParentVars {export function useSetIssueParent() {const qc = useQueryClient();return useMutation({- mutationFn: (vars: SetParentVars) => api.updateIssue(vars.issueId, { parentId: vars.parentId }),+ mutationFn: (vars: SetParentVars) => updateIssue(vars.issueId, { parentId: vars.parentId }),onSuccess: (_data, { projectKey, issueId, parentId, previousParentId }) => {for (const id of [issueId, parentId, previousParentId]) {if (id == null) continue;diff --git a/apps/web/src/features/issue/services/watchers.service.ts b/apps/web/src/features/issue/services/watchers.service.tsindex ccf9b8e9..f9c1029b 100644--- a/apps/web/src/features/issue/services/watchers.service.ts+++ b/apps/web/src/features/issue/services/watchers.service.ts@@ -3,7 +3,13 @@// refetched.import { useMutation, useQueryClient } from '@tanstack/react-query';-import { api, type IssueWithWatchers } from '@/lib/api';+import {+ type IssueWithWatchers,+ watchIssue,+ unwatchIssue,+ addIssueWatcher,+ removeIssueWatcher,+} from '@/lib/api/endpoints/issues';import { qk } from '@/services/queryKeys';export const watcherMutationKey = (issueId: number) => ['issue-watchers', issueId] as const;@@ -26,7 +32,7 @@ export function useSetIssueWatching(issueId: number) {return useMutation({mutationKey: watcherMutationKey(issueId),mutationFn: ({ watching }: { watching: boolean }) =>- watching ? api.watchIssue(issueId) : api.unwatchIssue(issueId),+ watching ? watchIssue(issueId) : unwatchIssue(issueId),scope: { id: `issue-watchers-${issueId}` },onSuccess: (watchers) => updateWatchers(qc, issueId, watchers),onSettled: () => void qc.invalidateQueries({ queryKey: qk.issue(issueId) }),@@ -38,7 +44,7 @@ export function useSetIssueWatcher(issueId: number) {return useMutation({mutationKey: watcherMutationKey(issueId),mutationFn: ({ userId, watching }: { userId: string; watching: boolean }) =>- watching ? api.addIssueWatcher(issueId, userId) : api.removeIssueWatcher(issueId, userId),+ watching ? addIssueWatcher(issueId, userId) : removeIssueWatcher(issueId, userId),scope: { id: `issue-watchers-${issueId}` },onSuccess: (watchers) => updateWatchers(qc, issueId, watchers),onSettled: () => void qc.invalidateQueries({ queryKey: qk.issue(issueId) }),diff --git a/apps/web/src/features/issue/services/worklogs.service.ts b/apps/web/src/features/issue/services/worklogs.service.tsindex 62163234..99c3b564 100644--- a/apps/web/src/features/issue/services/worklogs.service.ts+++ b/apps/web/src/features/issue/services/worklogs.service.ts@@ -3,11 +3,17 @@// three. The board carries the sum too, which is why the project's issues follow.import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type WorklogInput } from '@/lib/api';+import {+ type WorklogInput,+ listWorklogs,+ createWorklog,+ updateWorklog,+ deleteWorklog,+} from '@/lib/api/endpoints/worklogs';import { qk } from '@/services/queryKeys';export function useWorklogsQuery(issueId: number) {- return useQuery({ queryKey: qk.worklogs(issueId), queryFn: () => api.listWorklogs(issueId) });+ return useQuery({ queryKey: qk.worklogs(issueId), queryFn: () => listWorklogs(issueId) });}function useWorklogMutation<TVars extends { issueId: number; projectKey: string }>(@@ -27,7 +33,7 @@ function useWorklogMutation<TVars extends { issueId: number; projectKey: stringexport function useCreateWorklog() {return useWorklogMutation((vars: { issueId: number; projectKey: string; input: WorklogInput }) =>- api.createWorklog(vars.issueId, vars.input),+ createWorklog(vars.issueId, vars.input),);}@@ -38,12 +44,12 @@ export function useUpdateWorklog() {projectKey: string;worklogId: number;patch: Partial<WorklogInput>;- }) => api.updateWorklog(vars.worklogId, vars.patch),+ }) => updateWorklog(vars.worklogId, vars.patch),);}export function useDeleteWorklog() {return useWorklogMutation((vars: { issueId: number; projectKey: string; worklogId: number }) =>- api.deleteWorklog(vars.worklogId),+ deleteWorklog(vars.worklogId),);}diff --git a/apps/web/src/features/issue/utils/activityIcons.ts b/apps/web/src/features/issue/utils/activityIcons.tsindex feb797d0..a1b9f4c9 100644--- a/apps/web/src/features/issue/utils/activityIcons.ts+++ b/apps/web/src/features/issue/utils/activityIcons.ts@@ -20,7 +20,7 @@ import {UserRound,type LucideIcon,} from 'lucide-react';-import { type ActivityAction } from '@/lib/api';+import type { ActivityAction } from '@/lib/api/endpoints/activity';// The icon of each activity feed event. Its verb phrase is built by// useActivityText, which needs the reader's language.diff --git a/apps/web/src/features/issue/utils/delegates.ts b/apps/web/src/features/issue/utils/delegates.tsindex 3e6c8cfc..cc92b8c0 100644--- a/apps/web/src/features/issue/utils/delegates.ts+++ b/apps/web/src/features/issue/utils/delegates.ts@@ -1,4 +1,4 @@-import type { Assignee } from '@/lib/api';+import type { Assignee } from '@/lib/api/endpoints/projects';// An 'owner'-scoped agent only receives the runs of the member it belongs to, so// delegating it to anyone else queues work its runner never picks up.diff --git a/apps/web/src/features/issue/utils/fieldDefs.ts b/apps/web/src/features/issue/utils/fieldDefs.tsindex e8459084..4361865a 100644--- a/apps/web/src/features/issue/utils/fieldDefs.ts+++ b/apps/web/src/features/issue/utils/fieldDefs.ts@@ -1,4 +1,4 @@-import { type CustomField } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';// The project scaffold carries every field of the project; a detail surface takes// the project-wide ones plus the issue type's own.diff --git a/apps/web/src/features/issue/utils/fieldValues.ts b/apps/web/src/features/issue/utils/fieldValues.tsindex 5c701998..37185223 100644--- a/apps/web/src/features/issue/utils/fieldValues.ts+++ b/apps/web/src/features/issue/utils/fieldValues.ts@@ -1,4 +1,4 @@-import { type IssueFieldValueInput } from '@/lib/api';+import type { IssueFieldValueInput } from '@/lib/api/endpoints/issues';// Whether a field value carries anything: an empty string and an empty option// list read as untouched. The create modal skips such a value on save, and thediff --git a/apps/web/src/features/issue/utils/issuePrompt.ts b/apps/web/src/features/issue/utils/issuePrompt.tsindex 1c41d0b5..a4188dcf 100644--- a/apps/web/src/features/issue/utils/issuePrompt.ts+++ b/apps/web/src/features/issue/utils/issuePrompt.ts@@ -1,4 +1,5 @@-import type { Issue, ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { issuePath } from '@/utils/paths';// A git-branch-safe handle from the current user: the email local part (or name)diff --git a/apps/web/src/features/issue/utils/timeline.ts b/apps/web/src/features/issue/utils/timeline.tsindex 137812a5..77bb69db 100644--- a/apps/web/src/features/issue/utils/timeline.ts+++ b/apps/web/src/features/issue/utils/timeline.ts@@ -1,4 +1,5 @@-import { type Column, type StateType, type TimelineSegment } from '@/lib/api';+import type { Column, StateType } from '@/lib/api/endpoints/columns';+import type { TimelineSegment } from '@/lib/api/endpoints/activity';import { formatDuration, formatShortDate } from '@/utils/dates';// Turns the API's status segments into the geometry the timeline renders: one lanediff --git a/apps/web/src/features/mcp/components/McpAccessNotice.tsx b/apps/web/src/features/mcp/components/McpAccessNotice.tsxindex 735f6be5..872482a2 100644--- a/apps/web/src/features/mcp/components/McpAccessNotice.tsx+++ b/apps/web/src/features/mcp/components/McpAccessNotice.tsx@@ -3,7 +3,7 @@import type { ReactNode } from 'react';import Link from 'next/link';import { useTranslations } from 'next-intl';-import type { TeamRole } from '@/lib/api';+import type { TeamRole } from '@/lib/api/endpoints/teams';import { teamSectionPath } from '@/utils/paths';import { useTeamQuery } from '@/services/teams.service';import { Skeleton } from '@/components/ui/skeleton';diff --git a/apps/web/src/features/mcp/components/OAuthConsentPage.tsx b/apps/web/src/features/mcp/components/OAuthConsentPage.tsxindex 535e76d8..4cbfe916 100644--- a/apps/web/src/features/mcp/components/OAuthConsentPage.tsx+++ b/apps/web/src/features/mcp/components/OAuthConsentPage.tsx@@ -3,7 +3,7 @@import { useSearchParams } from 'next/navigation';import { useState } from 'react';import { useTranslations } from 'next-intl';-import { API_URL } from '@/lib/api';+import { API_URL } from '@/lib/api/core/client';type ConsentResponse = { redirectURI?: string; message?: string };diff --git a/apps/web/src/features/mcp/utils/clients.ts b/apps/web/src/features/mcp/utils/clients.tsindex f993d130..6349f853 100644--- a/apps/web/src/features/mcp/utils/clients.ts+++ b/apps/web/src/features/mcp/utils/clients.ts@@ -1,4 +1,4 @@-import { API_URL } from '@/lib/api';+import { API_URL } from '@/lib/api/core/client';// The MCP endpoint clients connect to; the transport is Streamable HTTP at /mcp.export const MCP_URL = `${API_URL}/mcp`;diff --git a/apps/web/src/features/members/components/invites/InviteRow.tsx b/apps/web/src/features/members/components/invites/InviteRow.tsxindex 863bcc93..541e3d49 100644--- a/apps/web/src/features/members/components/invites/InviteRow.tsx+++ b/apps/web/src/features/members/components/invites/InviteRow.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Check, Copy, Mail, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type InviteRow as Invite } from '@/lib/api';+import type { InviteRow as Invite } from '@/lib/api/endpoints/invites';import { inviteLink } from '@/utils/paths';import { formatShortDate } from '@/utils/dates';import { Badge } from '@/components/ui/badge';diff --git a/apps/web/src/features/members/components/invites/InvitesManager.tsx b/apps/web/src/features/members/components/invites/InvitesManager.tsxindex daa3b935..318f4205 100644--- a/apps/web/src/features/members/components/invites/InvitesManager.tsx+++ b/apps/web/src/features/members/components/invites/InvitesManager.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { type InviteRow as Invite } from '@/lib/api';+import type { InviteRow as Invite } from '@/lib/api/endpoints/invites';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import { ItemGroup } from '@/components/ui/item';import { useDeleteInvite, useInvitesQuery, useSendInviteEmail } from '@/services/members.service';diff --git a/apps/web/src/features/members/components/members/MemberAddDialog.tsx b/apps/web/src/features/members/components/members/MemberAddDialog.tsxindex 1ebc1105..36ffeea7 100644--- a/apps/web/src/features/members/components/members/MemberAddDialog.tsx+++ b/apps/web/src/features/members/components/members/MemberAddDialog.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Mail, Users } from 'lucide-react';import { useTranslations } from 'next-intl';-import { ApiError } from '@/lib/api';+import { ApiError } from '@/lib/api/core/client';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';import {diff --git a/apps/web/src/features/members/components/members/MemberDescription.tsx b/apps/web/src/features/members/components/members/MemberDescription.tsxindex 1ad3f55c..55944f84 100644--- a/apps/web/src/features/members/components/members/MemberDescription.tsx+++ b/apps/web/src/features/members/components/members/MemberDescription.tsx@@ -1,4 +1,4 @@-import type { MemberRow } from '@/lib/api';+import type { MemberRow } from '@/lib/api/endpoints/members';// A member's project description (what they do), shown under their name and indented// past the avatar so it lines up with the two lines beside it. Renders nothing whendiff --git a/apps/web/src/features/members/components/members/MemberDescriptionDialog.tsx b/apps/web/src/features/members/components/members/MemberDescriptionDialog.tsxindex a24b40d5..31c02211 100644--- a/apps/web/src/features/members/components/members/MemberDescriptionDialog.tsx+++ b/apps/web/src/features/members/components/members/MemberDescriptionDialog.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Pencil } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { MemberRow } from '@/lib/api';+import type { MemberRow } from '@/lib/api/endpoints/members';import Avatar from '@/components/common/Avatar';import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/members/components/members/MemberPicker.tsx b/apps/web/src/features/members/components/members/MemberPicker.tsxindex e5a0abf1..6830d028 100644--- a/apps/web/src/features/members/components/members/MemberPicker.tsx+++ b/apps/web/src/features/members/components/members/MemberPicker.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Check, ChevronDown, Mail } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { MemberCandidate } from '@/lib/api';+import type { MemberCandidate } from '@/lib/api/endpoints/members';import Avatar from '@/components/common/Avatar';import { Button } from '@/components/ui/button';import {diff --git a/apps/web/src/features/members/components/members/MemberRoleControl.tsx b/apps/web/src/features/members/components/members/MemberRoleControl.tsxindex e401ec4e..c3270c56 100644--- a/apps/web/src/features/members/components/members/MemberRoleControl.tsx+++ b/apps/web/src/features/members/components/members/MemberRoleControl.tsx@@ -1,7 +1,8 @@'use client';import { useTranslations } from 'next-intl';-import type { MemberRow, Role } from '@/lib/api';+import type { MemberRow } from '@/lib/api/endpoints/members';+import type { Role } from '@/lib/api/endpoints/roles';import { Badge } from '@/components/ui/badge';import {Select,diff --git a/apps/web/src/features/members/components/members/MemberRoleMenu.tsx b/apps/web/src/features/members/components/members/MemberRoleMenu.tsxindex ad33d8d6..9e890d35 100644--- a/apps/web/src/features/members/components/members/MemberRoleMenu.tsx+++ b/apps/web/src/features/members/components/members/MemberRoleMenu.tsx@@ -2,7 +2,8 @@import { Shield } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { MemberRow, Role } from '@/lib/api';+import type { MemberRow } from '@/lib/api/endpoints/members';+import type { Role } from '@/lib/api/endpoints/roles';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/members/components/members/MemberRow.tsx b/apps/web/src/features/members/components/members/MemberRow.tsxindex 9da5f57b..e2ba5018 100644--- a/apps/web/src/features/members/components/members/MemberRow.tsx+++ b/apps/web/src/features/members/components/members/MemberRow.tsx@@ -2,7 +2,8 @@import { LogOut, UserMinus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { MemberRow as Member, Role } from '@/lib/api';+import type { MemberRow as Member } from '@/lib/api/endpoints/members';+import type { Role } from '@/lib/api/endpoints/roles';import { formatDateTime } from '@/utils/dates';import Avatar from '@/components/common/Avatar';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/members/components/members/MembersList.tsx b/apps/web/src/features/members/components/members/MembersList.tsxindex 31cc24ee..dab4f6b1 100644--- a/apps/web/src/features/members/components/members/MembersList.tsx+++ b/apps/web/src/features/members/components/members/MembersList.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';-import type { MemberKind, MemberRow as Member } from '@/lib/api';+import type { MemberKind, MemberRow as Member } from '@/lib/api/endpoints/members';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import MembersEmptyState from '@/components/common/page/MembersEmptyState';diff --git a/apps/web/src/features/notes/NotesPage.tsx b/apps/web/src/features/notes/NotesPage.tsxindex 7c27627f..509509b8 100644--- a/apps/web/src/features/notes/NotesPage.tsx+++ b/apps/web/src/features/notes/NotesPage.tsx@@ -6,7 +6,7 @@ import { useTranslations } from 'next-intl';import { useQueryClient } from '@tanstack/react-query';import { ReactFlowProvider } from '@xyflow/react';import { useShell } from '@/context/shellContext';-import { ApiError } from '@/lib/api';+import { ApiError } from '@/lib/api/core/client';import { usePermissions } from '@/hooks/usePermissions';import { notePath, notesPath } from '@/utils/paths';import { qk } from '@/services/queryKeys';diff --git a/apps/web/src/features/notes/components/BoardSwitcher.tsx b/apps/web/src/features/notes/components/BoardSwitcher.tsxindex 9fe3990f..0a0f0e6b 100644--- a/apps/web/src/features/notes/components/BoardSwitcher.tsx+++ b/apps/web/src/features/notes/components/BoardSwitcher.tsx@@ -3,7 +3,7 @@import { useTranslations } from 'next-intl';import { useState } from 'react';import { Check, ChevronsUpDown, Layers, Loader2 } from 'lucide-react';-import type { NoteBoardSummary, NoteBoardVisibility } from '@/lib/api';+import type { NoteBoardSummary, NoteBoardVisibility } from '@/lib/api/endpoints/noteBoards';import { useDebouncedValue } from '@/hooks/useDebouncedValue';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import {diff --git a/apps/web/src/features/notes/components/NoteBoardAccessPicker.tsx b/apps/web/src/features/notes/components/NoteBoardAccessPicker.tsxindex 25f192f3..0f4d72d4 100644--- a/apps/web/src/features/notes/components/NoteBoardAccessPicker.tsx+++ b/apps/web/src/features/notes/components/NoteBoardAccessPicker.tsx@@ -2,7 +2,7 @@import { useTranslations } from 'next-intl';import { useState } from 'react';-import type { NoteBoardAccessCandidate, NoteBoardVisibility } from '@/lib/api';+import type { NoteBoardAccessCandidate, NoteBoardVisibility } from '@/lib/api/endpoints/noteBoards';import { useSession } from '@/lib/auth-client';import Avatar from '@/components/common/Avatar';import { Badge } from '@/components/ui/badge';diff --git a/apps/web/src/features/notes/components/NoteCanvas.tsx b/apps/web/src/features/notes/components/NoteCanvas.tsxindex 5b47ff0d..839e1523 100644--- a/apps/web/src/features/notes/components/NoteCanvas.tsx+++ b/apps/web/src/features/notes/components/NoteCanvas.tsx@@ -12,7 +12,7 @@ import {} from '@xyflow/react';import '@xyflow/react/dist/style.css';import { useTheme } from 'next-themes';-import type { NoteBoard } from '@/lib/api';+import type { NoteBoard } from '@/lib/api/endpoints/noteBoards';import { cn } from '@/lib/utils';import { useSetNoteBoardVisibility } from '../services/noteBoards.service';import StickerNode, { type StickerNodeType } from './StickerNode';diff --git a/apps/web/src/features/notes/components/NoteCanvasControls.tsx b/apps/web/src/features/notes/components/NoteCanvasControls.tsxindex dc27106a..ce116866 100644--- a/apps/web/src/features/notes/components/NoteCanvasControls.tsx+++ b/apps/web/src/features/notes/components/NoteCanvasControls.tsx@@ -2,7 +2,7 @@import { Maximize2, Minimize2, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { NoteBoardVisibility } from '@/lib/api';+import type { NoteBoardVisibility } from '@/lib/api/endpoints/noteBoards';import { Button } from '@/components/ui/button';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';import NoteBoardAccessList from './NoteBoardAccessList';diff --git a/apps/web/src/features/notes/components/NoteCanvasTitle.tsx b/apps/web/src/features/notes/components/NoteCanvasTitle.tsxindex 4e2241e8..2cce2a04 100644--- a/apps/web/src/features/notes/components/NoteCanvasTitle.tsx+++ b/apps/web/src/features/notes/components/NoteCanvasTitle.tsx@@ -2,7 +2,7 @@import { useTranslations } from 'next-intl';import { useEffect, useState } from 'react';-import type { NoteBoard } from '@/lib/api';+import type { NoteBoard } from '@/lib/api/endpoints/noteBoards';import { useShell } from '@/context/shellContext';import Avatar from '@/components/common/Avatar';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';diff --git a/apps/web/src/features/notes/components/StickerNode.tsx b/apps/web/src/features/notes/components/StickerNode.tsxindex a3aabec5..7a958b3d 100644--- a/apps/web/src/features/notes/components/StickerNode.tsx+++ b/apps/web/src/features/notes/components/StickerNode.tsx@@ -12,7 +12,7 @@ import {type Node,type NodeProps,} from '@xyflow/react';-import type { NoteSticker } from '@/lib/api';+import type { NoteSticker } from '@/lib/api/endpoints/noteBoards';import { useShell } from '@/context/shellContext';import { usePermissions } from '@/hooks/usePermissions';import { stickerColorValue } from '../utils/stickerColors';diff --git a/apps/web/src/features/notes/hooks/useNoteBoardAccess.ts b/apps/web/src/features/notes/hooks/useNoteBoardAccess.tsindex 3e27ce1a..87f9b76d 100644--- a/apps/web/src/features/notes/hooks/useNoteBoardAccess.ts+++ b/apps/web/src/features/notes/hooks/useNoteBoardAccess.ts@@ -1,4 +1,4 @@-import type { NoteBoard } from '@/lib/api';+import type { NoteBoard } from '@/lib/api/endpoints/noteBoards';import { useSession } from '@/lib/auth-client';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/notes/hooks/useNoteBoardMru.ts b/apps/web/src/features/notes/hooks/useNoteBoardMru.tsindex f13eea73..7d629a30 100644--- a/apps/web/src/features/notes/hooks/useNoteBoardMru.ts+++ b/apps/web/src/features/notes/hooks/useNoteBoardMru.ts@@ -1,5 +1,5 @@import { useCallback, useEffect, useState } from 'react';-import type { NoteBoardVisibility } from '@/lib/api';+import type { NoteBoardVisibility } from '@/lib/api/endpoints/noteBoards';// The recently-opened boards backing the tab strip. Kept per project in// localStorage (per browser, not synced): a lightweight most-recently-used list sodiff --git a/apps/web/src/features/notes/services/noteBoards.service.ts b/apps/web/src/features/notes/services/noteBoards.service.tsindex 7d37be9c..6b885e40 100644--- a/apps/web/src/features/notes/services/noteBoards.service.ts+++ b/apps/web/src/features/notes/services/noteBoards.service.ts@@ -1,11 +1,16 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import {- api,type NewNoteBoardInput,type NoteBoard,type NoteBoardVisibility,type NoteCanvas,-} from '@/lib/api';+ listNoteBoards,+ getNoteBoard,+ listNoteBoardAccessCandidates,+ createNoteBoard,+ updateNoteBoard,+ deleteNoteBoard,+} from '@/lib/api/endpoints/noteBoards';import { qk } from '@/services/queryKeys';// Invalidate every switcher/search list (but not open boards' canvases): renaming,@@ -22,7 +27,7 @@ function invalidateSearch(qc: ReturnType<typeof useQueryClient>, projectKey: strexport function useNoteBoardSearch(projectKey: string | null, q: string) {return useQuery({queryKey: qk.noteBoardsSearch(projectKey ?? '', q),- queryFn: () => api.listNoteBoards(projectKey!, { q: q || undefined }),+ queryFn: () => listNoteBoards(projectKey!, { q: q || undefined }),enabled: projectKey != null,});}@@ -32,7 +37,7 @@ export function useNoteBoardSearch(projectKey: string | null, q: string) {export function useNoteBoardQuery(projectKey: string | null, boardId: number | null) {return useQuery({queryKey: qk.noteBoard(projectKey ?? '', boardId ?? 0),- queryFn: () => api.getNoteBoard(projectKey!, boardId!),+ queryFn: () => getNoteBoard(projectKey!, boardId!),enabled: projectKey != null && boardId != null,refetchOnMount: 'always',});@@ -44,7 +49,7 @@ export function useNoteBoardQuery(projectKey: string | null, boardId: number | nexport function useNoteBoardAccessCandidates(projectKey: string | null) {return useQuery({queryKey: qk.noteBoardAccessCandidates(projectKey ?? ''),- queryFn: () => api.listNoteBoardAccessCandidates(projectKey!),+ queryFn: () => listNoteBoardAccessCandidates(projectKey!),enabled: projectKey != null,});}@@ -52,7 +57,7 @@ export function useNoteBoardAccessCandidates(projectKey: string | null) {export function useCreateNoteBoard(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewNoteBoardInput) => api.createNoteBoard(projectKey!, input),+ mutationFn: (input: NewNoteBoardInput) => createNoteBoard(projectKey!, input),onSuccess: () => {if (projectKey) invalidateSearch(qc, projectKey);},@@ -66,7 +71,7 @@ export function useRenameNoteBoard(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ boardId, name }: { boardId: number; name: string }) =>- api.updateNoteBoard(projectKey!, boardId, { name }),+ updateNoteBoard(projectKey!, boardId, { name }),onSuccess: (updated) => {if (!projectKey) return;qc.setQueryData<NoteBoard>(qk.noteBoard(projectKey, updated.id), updated);@@ -89,7 +94,7 @@ export function useSetNoteBoardVisibility(projectKey: string | null) {boardId: number;visibility: NoteBoardVisibility;memberIds?: string[];- }) => api.updateNoteBoard(projectKey!, boardId, { visibility, memberIds }),+ }) => updateNoteBoard(projectKey!, boardId, { visibility, memberIds }),onSuccess: (updated) => {if (!projectKey) return;qc.setQueryData<NoteBoard>(qk.noteBoard(projectKey, updated.id), updated);@@ -101,7 +106,7 @@ export function useSetNoteBoardVisibility(projectKey: string | null) {export function useDeleteNoteBoard(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (boardId: number) => api.deleteNoteBoard(projectKey!, boardId),+ mutationFn: (boardId: number) => deleteNoteBoard(projectKey!, boardId),onSuccess: (_res, boardId) => {if (!projectKey) return;qc.removeQueries({ queryKey: qk.noteBoard(projectKey, boardId) });@@ -117,7 +122,7 @@ export function useSaveNoteCanvas(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ boardId, canvas }: { boardId: number; canvas: NoteCanvas }) =>- api.updateNoteBoard(projectKey!, boardId, { canvas }),+ updateNoteBoard(projectKey!, boardId, { canvas }),onSuccess: (updated) => {if (!projectKey) return;qc.setQueryData<NoteBoard>(qk.noteBoard(projectKey, updated.id), updated);diff --git a/apps/web/src/features/notes/utils/noteCanvas.ts b/apps/web/src/features/notes/utils/noteCanvas.tsindex fdab67e5..55e91221 100644--- a/apps/web/src/features/notes/utils/noteCanvas.ts+++ b/apps/web/src/features/notes/utils/noteCanvas.ts@@ -1,5 +1,5 @@import type { Edge } from '@xyflow/react';-import type { NoteCanvas, NoteNode } from '@/lib/api';+import type { NoteCanvas, NoteNode } from '@/lib/api/endpoints/noteBoards';import { uuid } from '@/utils/uuid';import type { StickerNodeType } from '../components/StickerNode';import { DEFAULT_STICKER_COLOR } from './stickerColors';diff --git a/apps/web/src/features/notes/utils/stickerToIssue.ts b/apps/web/src/features/notes/utils/stickerToIssue.tsindex aab9d2ff..e4e7a8e8 100644--- a/apps/web/src/features/notes/utils/stickerToIssue.ts+++ b/apps/web/src/features/notes/utils/stickerToIssue.ts@@ -1,4 +1,4 @@-import type { NoteSticker } from '@/lib/api';+import type { NoteSticker } from '@/lib/api/endpoints/noteBoards';// Leading heading or bullet marker, stripped from a body line promoted to the// issue title.diff --git a/apps/web/src/features/notes/utils/visibility.ts b/apps/web/src/features/notes/utils/visibility.tsindex b99fcbc5..d1401d36 100644--- a/apps/web/src/features/notes/utils/visibility.ts+++ b/apps/web/src/features/notes/utils/visibility.ts@@ -1,5 +1,5 @@import { Globe, Lock, StickyNote, Users, type LucideIcon } from 'lucide-react';-import type { NoteBoardVisibility } from '@/lib/api';+import type { NoteBoardVisibility } from '@/lib/api/endpoints/noteBoards';// A new board is public or private; access is granted to picked members later,// on the board itself.diff --git a/apps/web/src/features/settings/NotificationPreferencesPage.tsx b/apps/web/src/features/settings/NotificationPreferencesPage.tsxindex 9ae2898e..3aa20078 100644--- a/apps/web/src/features/settings/NotificationPreferencesPage.tsx+++ b/apps/web/src/features/settings/NotificationPreferencesPage.tsx@@ -1,7 +1,7 @@'use client';import type { ReactNode } from 'react';-import type { NotificationPreferences as Prefs } from '@/lib/api';+import type { NotificationPreferences as Prefs } from '@/lib/api/endpoints/notificationPreferences';import { useShell } from '@/context/shellContext';import { Button } from '@/components/ui/button';import SectionPageView from '@/components/common/page/SectionPageView';diff --git a/apps/web/src/features/settings/SettingsConfigurationPage.tsx b/apps/web/src/features/settings/SettingsConfigurationPage.tsxindex 1c621ca7..2ebf61d4 100644--- a/apps/web/src/features/settings/SettingsConfigurationPage.tsx+++ b/apps/web/src/features/settings/SettingsConfigurationPage.tsx@@ -2,7 +2,7 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useShell } from '@/context/shellContext';import { settingsSection } from '@/utils/settingsSections';import { useSettingsSectionText } from '@/hooks/useSectionLabels';diff --git a/apps/web/src/features/settings/SettingsGeneralPage.tsx b/apps/web/src/features/settings/SettingsGeneralPage.tsxindex 9c3e61b8..6071f5b5 100644--- a/apps/web/src/features/settings/SettingsGeneralPage.tsx+++ b/apps/web/src/features/settings/SettingsGeneralPage.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useShell } from '@/context/shellContext';import { settingsSection } from '@/utils/settingsSections';import { useSettingsSectionText } from '@/hooks/useSectionLabels';diff --git a/apps/web/src/features/settings/components/actions/SettingsActionDialog.tsx b/apps/web/src/features/settings/components/actions/SettingsActionDialog.tsxindex 25ac2825..af1201d1 100644--- a/apps/web/src/features/settings/components/actions/SettingsActionDialog.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsActionDialog.tsx@@ -1,6 +1,8 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { ActionEffect, ProjectDetail, CustomField } from '@/lib/api';+import type { ActionEffect } from '@/lib/api/endpoints/actions';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { isActiveFilterSet, type FilterSet } from '@/utils/filters';import { isEmptyEffect } from '@/utils/actions';import Modal from '@/components/common/overlay/Modal';diff --git a/apps/web/src/features/settings/components/actions/SettingsActionRow.tsx b/apps/web/src/features/settings/components/actions/SettingsActionRow.tsxindex b9bdeaef..d03e43f3 100644--- a/apps/web/src/features/settings/components/actions/SettingsActionRow.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsActionRow.tsx@@ -1,6 +1,8 @@import { Copy, Pencil, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ActionDef, CustomField, ProjectDetail } from '@/lib/api';+import type { ActionDef } from '@/lib/api/endpoints/actions';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useFilterFields } from '@/hooks/useFilterFields';import { useEffectText } from '@/hooks/useEffectText';import { describeEffect } from '@/utils/actions';diff --git a/apps/web/src/features/settings/components/actions/SettingsActions.tsx b/apps/web/src/features/settings/components/actions/SettingsActions.tsxindex 4e29c62a..c1b63a93 100644--- a/apps/web/src/features/settings/components/actions/SettingsActions.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsActions.tsx@@ -1,6 +1,8 @@import { useEffect, useState } from 'react';import { useTranslations } from 'next-intl';-import type { ActionDef, ActionEffect, ProjectDetail, CustomField } from '@/lib/api';+import type { ActionDef, ActionEffect } from '@/lib/api/endpoints/actions';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import {useActionsQuery,useCreateAction,diff --git a/apps/web/src/features/settings/components/actions/SettingsActionsTable.tsx b/apps/web/src/features/settings/components/actions/SettingsActionsTable.tsxindex 7072fe74..92208e44 100644--- a/apps/web/src/features/settings/components/actions/SettingsActionsTable.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsActionsTable.tsx@@ -1,5 +1,7 @@import { useTranslations } from 'next-intl';-import type { ActionDef, CustomField, ProjectDetail } from '@/lib/api';+import type { ActionDef } from '@/lib/api/endpoints/actions';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';import { SettingsActionRow } from './SettingsActionRow';diff --git a/apps/web/src/features/settings/components/actions/SettingsEffectEditor.tsx b/apps/web/src/features/settings/components/actions/SettingsEffectEditor.tsxindex 44e9ad71..85c85054 100644--- a/apps/web/src/features/settings/components/actions/SettingsEffectEditor.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsEffectEditor.tsx@@ -1,7 +1,8 @@import { Fragment, useState } from 'react';import { Plus, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { ActionEffect, ProjectDetail } from '@/lib/api';+import type { ActionEffect } from '@/lib/api/endpoints/actions';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { EFFECT_FIELD_KEYS, effectFieldKeys, type EffectFieldKey } from '@/utils/actions';import { useEffectText } from '@/hooks/useEffectText';import AssigneeSelect from '@/components/common/fields/AssigneeSelect';diff --git a/apps/web/src/features/settings/components/crud/SettingsCreateAction.tsx b/apps/web/src/features/settings/components/crud/SettingsCreateAction.tsxindex a36cd2c6..4a145a22 100644--- a/apps/web/src/features/settings/components/crud/SettingsCreateAction.tsx+++ b/apps/web/src/features/settings/components/crud/SettingsCreateAction.tsx@@ -2,7 +2,7 @@import { useState, type ReactNode } from 'react';import { Plus } from 'lucide-react';-import type { PermissionResource } from '@/lib/api';+import type { PermissionResource } from '@/lib/api/endpoints/roles';import { Button } from '@/components/ui/button';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/settings/components/crud/SettingsHeaderAddButton.tsx b/apps/web/src/features/settings/components/crud/SettingsHeaderAddButton.tsxindex 9713c0bd..85d1dc28 100644--- a/apps/web/src/features/settings/components/crud/SettingsHeaderAddButton.tsx+++ b/apps/web/src/features/settings/components/crud/SettingsHeaderAddButton.tsx@@ -1,7 +1,7 @@'use client';import { Plus } from 'lucide-react';-import type { PermissionResource } from '@/lib/api';+import type { PermissionResource } from '@/lib/api/endpoints/roles';import { Button } from '@/components/ui/button';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/settings/components/crud/SettingsWipLimitField.tsx b/apps/web/src/features/settings/components/crud/SettingsWipLimitField.tsxindex a60d3eef..8040acaa 100644--- a/apps/web/src/features/settings/components/crud/SettingsWipLimitField.tsx+++ b/apps/web/src/features/settings/components/crud/SettingsWipLimitField.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';import { Gauge } from 'lucide-react';-import { type WipMode } from '@/lib/api';+import type { WipMode } from '@/lib/api/endpoints/columns';import { cn } from '@/lib/utils';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/settings/components/custom-fields/CustomFieldMeta.tsx b/apps/web/src/features/settings/components/custom-fields/CustomFieldMeta.tsxindex 2cf59e06..14c4ad68 100644--- a/apps/web/src/features/settings/components/custom-fields/CustomFieldMeta.tsx+++ b/apps/web/src/features/settings/components/custom-fields/CustomFieldMeta.tsx@@ -1,6 +1,6 @@import { ChevronRight } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { CustomField } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';import { FIELD_TYPE_ICONS, useFieldTypeLabel } from '../../utils/fieldTypes';// What a field is, at the end of its row: its type, then what that type lets the fielddiff --git a/apps/web/src/features/settings/components/custom-fields/CustomFieldsImportDialog.tsx b/apps/web/src/features/settings/components/custom-fields/CustomFieldsImportDialog.tsxindex 9cd28e74..1cd7f628 100644--- a/apps/web/src/features/settings/components/custom-fields/CustomFieldsImportDialog.tsx+++ b/apps/web/src/features/settings/components/custom-fields/CustomFieldsImportDialog.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { IssueType } from '@/lib/api';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import Modal from '@/components/common/overlay/Modal';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/custom-fields/CustomFieldsToolbar.tsx b/apps/web/src/features/settings/components/custom-fields/CustomFieldsToolbar.tsxindex 295ea6d9..2807f2ab 100644--- a/apps/web/src/features/settings/components/custom-fields/CustomFieldsToolbar.tsx+++ b/apps/web/src/features/settings/components/custom-fields/CustomFieldsToolbar.tsx@@ -4,7 +4,9 @@ import { useCallback, useEffect, useMemo, useState } from 'react';import { ClipboardPaste, Copy, MoreHorizontal } from 'lucide-react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { CustomField, IssueType, PermissionResource } from '@/lib/api';+import type { PermissionResource } from '@/lib/api/endpoints/roles';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/settings/components/custom-fields/SettingsCustomFieldDialog.tsx b/apps/web/src/features/settings/components/custom-fields/SettingsCustomFieldDialog.tsxindex 32d66216..b17a84cf 100644--- a/apps/web/src/features/settings/components/custom-fields/SettingsCustomFieldDialog.tsx+++ b/apps/web/src/features/settings/components/custom-fields/SettingsCustomFieldDialog.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { type CustomField, type CustomFieldType, type MemberScope } from '@/lib/api';+import type { CustomField, CustomFieldType, MemberScope } from '@/lib/api/endpoints/customFields';import { cn } from '@/lib/utils';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsx b/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsxindex f833a533..5ff91657 100644--- a/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsx+++ b/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsx@@ -1,7 +1,8 @@import { useState } from 'react';import { useTranslations } from 'next-intl';import { ChevronRight, Plus } from 'lucide-react';-import { type CustomField, type ProjectDetail } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { cn } from '@/lib/utils';import { Button } from '@/components/ui/button';import SettingsConfirmDeleteDialog from '../crud/SettingsConfirmDeleteDialog';diff --git a/apps/web/src/features/settings/components/general/SettingsFeatures.tsx b/apps/web/src/features/settings/components/general/SettingsFeatures.tsxindex a3d7df06..f71a8349 100644--- a/apps/web/src/features/settings/components/general/SettingsFeatures.tsx+++ b/apps/web/src/features/settings/components/general/SettingsFeatures.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { ProjectFeatures } from '@/lib/api';+import type { ProjectFeatures } from '@/lib/api/endpoints/settings';import { useFeatureLabel } from '@/hooks/useFeatureLabel';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsSection from '@/components/common/page/SettingsSection';diff --git a/apps/web/src/features/settings/components/git/GitAutomationsCard.tsx b/apps/web/src/features/settings/components/git/GitAutomationsCard.tsxindex 94524594..2dfd5203 100644--- a/apps/web/src/features/settings/components/git/GitAutomationsCard.tsx+++ b/apps/web/src/features/settings/components/git/GitAutomationsCard.tsx@@ -1,5 +1,6 @@import { useTranslations } from 'next-intl';-import type { Column, GitSettings } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';+import type { GitSettings } from '@/lib/api/endpoints/git';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsSection from '@/components/common/page/SettingsSection';import SettingsRow from '@/components/common/page/SettingsRow';diff --git a/apps/web/src/features/settings/components/git/GitColumnSelect.tsx b/apps/web/src/features/settings/components/git/GitColumnSelect.tsxindex a17b4284..8f73fd85 100644--- a/apps/web/src/features/settings/components/git/GitColumnSelect.tsx+++ b/apps/web/src/features/settings/components/git/GitColumnSelect.tsx@@ -1,6 +1,6 @@import { CircleDashed } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Column } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';import { colorDot } from '@/components/common/fields/colorDot';import { Pill } from '@/components/common/fields/Pill';import PopoverPick from '@/components/common/fields/PopoverPick';diff --git a/apps/web/src/features/settings/components/git/GitConnectionCard.tsx b/apps/web/src/features/settings/components/git/GitConnectionCard.tsxindex b39113a4..6179c159 100644--- a/apps/web/src/features/settings/components/git/GitConnectionCard.tsx+++ b/apps/web/src/features/settings/components/git/GitConnectionCard.tsx@@ -1,7 +1,8 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { API_URL, type GitSettings } from '@/lib/api';+import type { GitSettings } from '@/lib/api/endpoints/git';+import { API_URL } from '@/lib/api/core/client';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsSection from '@/components/common/page/SettingsSection';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/git/GitProviderConnectDialog.tsx b/apps/web/src/features/settings/components/git/GitProviderConnectDialog.tsxindex 5a8d60e6..d37c1201 100644--- a/apps/web/src/features/settings/components/git/GitProviderConnectDialog.tsx+++ b/apps/web/src/features/settings/components/git/GitProviderConnectDialog.tsx@@ -1,7 +1,7 @@import { useEffect, useState, type FormEvent } from 'react';import { useTranslations } from 'next-intl';import { toast } from 'sonner';-import type { GitConnectionProvider } from '@/lib/api';+import type { GitConnectionProvider } from '@/lib/api/endpoints/git';import { Button } from '@/components/ui/button';import {Dialog,diff --git a/apps/web/src/features/settings/components/git/GitProviderConnectionCard.tsx b/apps/web/src/features/settings/components/git/GitProviderConnectionCard.tsxindex 5a2e5bce..3b96273c 100644--- a/apps/web/src/features/settings/components/git/GitProviderConnectionCard.tsx+++ b/apps/web/src/features/settings/components/git/GitProviderConnectionCard.tsx@@ -2,7 +2,7 @@ import { useState } from 'react';import { ExternalLink, GitBranch, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';import { toast } from 'sonner';-import type { GitProviderConnection } from '@/lib/api';+import type { GitProviderConnection } from '@/lib/api/endpoints/git';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import SettingsCard from '@/components/common/page/SettingsCard';diff --git a/apps/web/src/features/settings/components/git/GitProviderConnections.tsx b/apps/web/src/features/settings/components/git/GitProviderConnections.tsxindex 34d0c22b..c456bc5b 100644--- a/apps/web/src/features/settings/components/git/GitProviderConnections.tsx+++ b/apps/web/src/features/settings/components/git/GitProviderConnections.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { GitBranch } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { GitConnectionProvider } from '@/lib/api';+import type { GitConnectionProvider } from '@/lib/api/endpoints/git';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import SettingsSection from '@/components/common/page/SettingsSection';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/git/GitRepositoryList.tsx b/apps/web/src/features/settings/components/git/GitRepositoryList.tsxindex 00e34555..e5493f3d 100644--- a/apps/web/src/features/settings/components/git/GitRepositoryList.tsx+++ b/apps/web/src/features/settings/components/git/GitRepositoryList.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { GitRepository } from '@/lib/api';+import type { GitRepository } from '@/lib/api/endpoints/git';import { useRelativeTime } from '@/context/relativeTimeContext';// Every repository that has delivered to this project, newest first. The listdiff --git a/apps/web/src/features/settings/components/git/GitRepositoryPickerDialog.tsx b/apps/web/src/features/settings/components/git/GitRepositoryPickerDialog.tsxindex c4564923..a883d13e 100644--- a/apps/web/src/features/settings/components/git/GitRepositoryPickerDialog.tsx+++ b/apps/web/src/features/settings/components/git/GitRepositoryPickerDialog.tsx@@ -1,7 +1,7 @@import { useEffect, useMemo, useState } from 'react';import { useTranslations } from 'next-intl';import { toast } from 'sonner';-import type { GitProviderConnection } from '@/lib/api';+import type { GitProviderConnection } from '@/lib/api/endpoints/git';import { useDebouncedValue } from '@/hooks/useDebouncedValue';import { Button } from '@/components/ui/button';import { Checkbox } from '@/components/ui/checkbox';diff --git a/apps/web/src/features/settings/components/git/SettingsGit.tsx b/apps/web/src/features/settings/components/git/SettingsGit.tsxindex b106899b..ffd945be 100644--- a/apps/web/src/features/settings/components/git/SettingsGit.tsx+++ b/apps/web/src/features/settings/components/git/SettingsGit.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsRow from '@/components/common/page/SettingsRow';diff --git a/apps/web/src/features/settings/components/git/providerConfig.ts b/apps/web/src/features/settings/components/git/providerConfig.tsindex 38a8ff4e..45a9e4de 100644--- a/apps/web/src/features/settings/components/git/providerConfig.ts+++ b/apps/web/src/features/settings/components/git/providerConfig.ts@@ -1,4 +1,4 @@-import type { GitConnectionProvider } from '@/lib/api';+import type { GitConnectionProvider } from '@/lib/api/endpoints/git';export const GIT_PROVIDER_CONFIG: Record<GitConnectionProvider,diff --git a/apps/web/src/features/settings/components/issue-templates/IssueTemplateProperties.tsx b/apps/web/src/features/settings/components/issue-templates/IssueTemplateProperties.tsxindex a27782cc..bb1a896a 100644--- a/apps/web/src/features/settings/components/issue-templates/IssueTemplateProperties.tsx+++ b/apps/web/src/features/settings/components/issue-templates/IssueTemplateProperties.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import AssigneeSelect from '@/components/common/fields/AssigneeSelect';import LabelsSelect from '@/components/common/fields/LabelsSelect';import PrioritySelect from '@/components/common/fields/PrioritySelect';diff --git a/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplateDialog.tsx b/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplateDialog.tsxindex 3ed3df8b..5c85b14a 100644--- a/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplateDialog.tsx+++ b/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplateDialog.tsx@@ -1,6 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { IssueTemplate, ProjectDetail } from '@/lib/api';+import type { IssueTemplate } from '@/lib/api/endpoints/issueTemplates';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsx b/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsxindex 007201b5..2f4a54ef 100644--- a/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsx+++ b/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsx@@ -1,6 +1,7 @@import { useEffect, useState } from 'react';import { useTranslations } from 'next-intl';-import type { IssueTemplate, ProjectDetail } from '@/lib/api';+import type { IssueTemplate } from '@/lib/api/endpoints/issueTemplates';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import SettingsConfirmDeleteDialog from '../crud/SettingsConfirmDeleteDialog';import { SettingsEmpty } from '../crud/SettingsEmpty';import { SettingsRow } from '../crud/SettingsRow';diff --git a/apps/web/src/features/settings/components/issue-types/IssueTypesToolbar.tsx b/apps/web/src/features/settings/components/issue-types/IssueTypesToolbar.tsxindex ec2cd6f7..3ef0dd36 100644--- a/apps/web/src/features/settings/components/issue-types/IssueTypesToolbar.tsx+++ b/apps/web/src/features/settings/components/issue-types/IssueTypesToolbar.tsx@@ -4,7 +4,8 @@ import { useCallback, useEffect, useState } from 'react';import { ClipboardPaste, Copy, MoreHorizontal } from 'lucide-react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { IssueType, PermissionResource } from '@/lib/api';+import type { PermissionResource } from '@/lib/api/endpoints/roles';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsx b/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsxindex 69c7bd18..8611fc6c 100644--- a/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsx+++ b/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsx@@ -1,7 +1,8 @@import { useEffect, useState } from 'react';import { Pencil, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type IssueType, type ProjectDetail } from '@/lib/api';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { DEFAULT_COLOR } from '@/utils/project';import { colorDot } from '@/components/common/fields/colorDot';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/labels/LabelsImportDialog.tsx b/apps/web/src/features/settings/components/labels/LabelsImportDialog.tsxindex 84be682a..b0c23022 100644--- a/apps/web/src/features/settings/components/labels/LabelsImportDialog.tsx+++ b/apps/web/src/features/settings/components/labels/LabelsImportDialog.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { LabelGroup } from '@/lib/api';+import type { LabelGroup } from '@/lib/api/endpoints/labels';import { colorDot } from '@/components/common/fields/colorDot';import Modal from '@/components/common/overlay/Modal';import { Badge } from '@/components/ui/badge';diff --git a/apps/web/src/features/settings/components/labels/LabelsToolbar.tsx b/apps/web/src/features/settings/components/labels/LabelsToolbar.tsxindex 2f7b5c7a..3ded6d8c 100644--- a/apps/web/src/features/settings/components/labels/LabelsToolbar.tsx+++ b/apps/web/src/features/settings/components/labels/LabelsToolbar.tsx@@ -4,7 +4,8 @@ import { useCallback, useEffect, useState } from 'react';import { ClipboardPaste, Copy, MoreHorizontal } from 'lucide-react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { Label, LabelGroup, PermissionResource } from '@/lib/api';+import type { PermissionResource } from '@/lib/api/endpoints/roles';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/settings/components/labels/SettingsDraggableLabelRow.tsx b/apps/web/src/features/settings/components/labels/SettingsDraggableLabelRow.tsxindex da0ec4f7..f892469d 100644--- a/apps/web/src/features/settings/components/labels/SettingsDraggableLabelRow.tsx+++ b/apps/web/src/features/settings/components/labels/SettingsDraggableLabelRow.tsx@@ -1,7 +1,7 @@import { useDraggable } from '@dnd-kit/core';import { GripVertical } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type Label as LabelRow } from '@/lib/api';+import type { Label as LabelRow } from '@/lib/api/endpoints/labels';import { colorDot } from '@/components/common/fields/colorDot';import { SettingsRow } from '../crud/SettingsRow';import { useSettingsCan } from '../../context/settingsPermission';diff --git a/apps/web/src/features/settings/components/labels/SettingsLabelDeleteDialogs.tsx b/apps/web/src/features/settings/components/labels/SettingsLabelDeleteDialogs.tsxindex 5a6fa91c..5559673a 100644--- a/apps/web/src/features/settings/components/labels/SettingsLabelDeleteDialogs.tsx+++ b/apps/web/src/features/settings/components/labels/SettingsLabelDeleteDialogs.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import { type Label as LabelRow, type LabelGroup } from '@/lib/api';+import type { Label as LabelRow, LabelGroup } from '@/lib/api/endpoints/labels';import SettingsConfirmDeleteDialog from '../crud/SettingsConfirmDeleteDialog';export function SettingsLabelDeleteDialog({diff --git a/apps/web/src/features/settings/components/labels/SettingsLabelGroupSection.tsx b/apps/web/src/features/settings/components/labels/SettingsLabelGroupSection.tsxindex f74d8eb8..8d4d3829 100644--- a/apps/web/src/features/settings/components/labels/SettingsLabelGroupSection.tsx+++ b/apps/web/src/features/settings/components/labels/SettingsLabelGroupSection.tsx@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';import { ChevronRight, Pencil, Plus, Trash2 } from 'lucide-react';import { useDroppable } from '@dnd-kit/core';import { useTranslations } from 'next-intl';-import { type LabelGroup } from '@/lib/api';+import type { LabelGroup } from '@/lib/api/endpoints/labels';import { cn } from '@/lib/utils';import { colorDot } from '@/components/common/fields/colorDot';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/labels/SettingsLabels.tsx b/apps/web/src/features/settings/components/labels/SettingsLabels.tsxindex 8fcf3847..7ac9a5fb 100644--- a/apps/web/src/features/settings/components/labels/SettingsLabels.tsx+++ b/apps/web/src/features/settings/components/labels/SettingsLabels.tsx@@ -1,7 +1,8 @@import { useState } from 'react';import { useTranslations } from 'next-intl';import { DndContext, DragOverlay, type DragEndEvent } from '@dnd-kit/core';-import { type Label as LabelRow, type LabelGroup, type ProjectDetail } from '@/lib/api';+import type { Label as LabelRow, LabelGroup } from '@/lib/api/endpoints/labels';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useDndSensors } from '@/lib/dnd';import { DEFAULT_COLOR } from '@/utils/project';import { colorDot } from '@/components/common/fields/colorDot';diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsxindex 0475dac3..9a69da23 100644--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx@@ -1,6 +1,7 @@import { useState } from 'react';import { Terminal } from 'lucide-react';-import type { AgentSchedule, AgentScheduleInput, AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';+import type { AgentSchedule, AgentScheduleInput } from '@/lib/api/endpoints/agentSchedules';import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsxindex 1b11ff99..79d79eec 100644--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleRow.tsx@@ -11,7 +11,7 @@ import {Trash2,Zap,} from 'lucide-react';-import type { AgentSchedule } from '@/lib/api';+import type { AgentSchedule } from '@/lib/api/endpoints/agentSchedules';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunRow.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunRow.tsxindex abc494f7..9bc21ba3 100644--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunRow.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunRow.tsx@@ -1,6 +1,6 @@import { useId, useState } from 'react';import { Ban, ChevronDown, ChevronRight } from 'lucide-react';-import type { AgentScheduleRun } from '@/lib/api';+import type { AgentScheduleRun } from '@/lib/api/endpoints/agentSchedules';import { formatDateTime } from '@/utils/dates';import { AgentContextSize } from '@/components/common/agent-chat/AgentContextSize';import { Badge } from '@/components/ui/badge';diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsxindex 0ccc48c6..cc0f2043 100644--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleRunsSheet.tsx@@ -1,4 +1,4 @@-import type { AgentSchedule } from '@/lib/api';+import type { AgentSchedule } from '@/lib/api/endpoints/agentSchedules';import {useAgentScheduleRuns,useCancelAgentScheduleRuns,diff --git a/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx b/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsxindex 56035f96..b14a7bca 100644--- a/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx@@ -1,6 +1,7 @@import { useEffect, useState } from 'react';import Link from 'next/link';-import type { AgentSchedule, AgentScheduleInput, ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { AgentSchedule, AgentScheduleInput } from '@/lib/api/endpoints/agentSchedules';import { aiAgentsPath } from '@/utils/paths';import { Button } from '@/components/ui/button';import { EmptyState } from '@/components/common/page/EmptyState';diff --git a/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx b/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsxindex 0dc8acea..785995a1 100644--- a/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsSchedulesTable.tsx@@ -1,4 +1,4 @@-import type { AgentSchedule } from '@/lib/api';+import type { AgentSchedule } from '@/lib/api/endpoints/agentSchedules';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';import { SettingsScheduleRow } from './SettingsScheduleRow';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsx b/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsxindex c7ee86a0..4897540d 100644--- a/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsx+++ b/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsx@@ -1,6 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { type ProjectDetail, type Column } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import { Checkbox } from '@/components/ui/checkbox';import { Label } from '@/components/ui/label';diff --git a/apps/web/src/features/settings/components/states/SettingsStateRow.tsx b/apps/web/src/features/settings/components/states/SettingsStateRow.tsxindex 100148d0..858b3eee 100644--- a/apps/web/src/features/settings/components/states/SettingsStateRow.tsx+++ b/apps/web/src/features/settings/components/states/SettingsStateRow.tsx@@ -2,7 +2,8 @@ import { useSortable } from '@dnd-kit/sortable';import { CSS } from '@dnd-kit/utilities';import { GripVertical, Pencil, Trash2, UserPlus } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type Assignee, type Column } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';+import type { Assignee } from '@/lib/api/endpoints/projects';import { cn } from '@/lib/utils';import Avatar from '@/components/common/Avatar';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/settings/components/states/SettingsStates.tsx b/apps/web/src/features/settings/components/states/SettingsStates.tsxindex 1f47dd4d..c7a95dbd 100644--- a/apps/web/src/features/settings/components/states/SettingsStates.tsx+++ b/apps/web/src/features/settings/components/states/SettingsStates.tsx@@ -3,7 +3,8 @@ import { closestCenter, DndContext, type DragEndEvent } from '@dnd-kit/core';import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';import { Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type Column, type ProjectDetail, type StateType, type WipMode } from '@/lib/api';+import type { Column, StateType, WipMode } from '@/lib/api/endpoints/columns';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useDndSensors } from '@/lib/dnd';import { STATE_TYPES } from '@/utils/fieldOptions';import { DEFAULT_COLOR } from '@/utils/project';diff --git a/apps/web/src/features/settings/components/states/StatesToolbar.tsx b/apps/web/src/features/settings/components/states/StatesToolbar.tsxindex b7aff7e5..215a67fa 100644--- a/apps/web/src/features/settings/components/states/StatesToolbar.tsx+++ b/apps/web/src/features/settings/components/states/StatesToolbar.tsx@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from 'react';import { ClipboardPaste, Copy, MoreHorizontal } from 'lucide-react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { Column } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';import { Button } from '@/components/ui/button';import {DropdownMenu,diff --git a/apps/web/src/features/settings/components/webhooks/SettingsWebhookDeliveriesSheet.tsx b/apps/web/src/features/settings/components/webhooks/SettingsWebhookDeliveriesSheet.tsxindex 5833fa0a..56eb7d3c 100644--- a/apps/web/src/features/settings/components/webhooks/SettingsWebhookDeliveriesSheet.tsx+++ b/apps/web/src/features/settings/components/webhooks/SettingsWebhookDeliveriesSheet.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';import { ChevronDown, ChevronRight } from 'lucide-react';-import type { Webhook, WebhookDelivery } from '@/lib/api';+import type { Webhook, WebhookDelivery } from '@/lib/api/endpoints/webhooks';import { formatDateTime } from '@/utils/dates';import { useWebhookDeliveries } from '@/services/webhooks.service';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';diff --git a/apps/web/src/features/settings/components/webhooks/SettingsWebhookDialog.tsx b/apps/web/src/features/settings/components/webhooks/SettingsWebhookDialog.tsxindex 88c86dd9..884a5efe 100644--- a/apps/web/src/features/settings/components/webhooks/SettingsWebhookDialog.tsx+++ b/apps/web/src/features/settings/components/webhooks/SettingsWebhookDialog.tsx@@ -1,6 +1,10 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { WEBHOOK_EVENT_TYPES, type Webhook, type WebhookEventType } from '@/lib/api';+import {+ WEBHOOK_EVENT_TYPES,+ type Webhook,+ type WebhookEventType,+} from '@/lib/api/endpoints/webhooks';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/settings/components/webhooks/SettingsWebhookRow.tsx b/apps/web/src/features/settings/components/webhooks/SettingsWebhookRow.tsxindex 55039177..84b44f1e 100644--- a/apps/web/src/features/settings/components/webhooks/SettingsWebhookRow.tsx+++ b/apps/web/src/features/settings/components/webhooks/SettingsWebhookRow.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';import { Check, Copy, Eye, EyeOff, History, MoreHorizontal, Pencil, Trash2 } from 'lucide-react';-import type { Webhook } from '@/lib/api';+import type { Webhook } from '@/lib/api/endpoints/webhooks';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import {diff --git a/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsx b/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsxindex 8505b316..cdeec71c 100644--- a/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsx+++ b/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsx@@ -1,6 +1,7 @@import { useEffect, useState } from 'react';import { useTranslations } from 'next-intl';-import type { ProjectDetail, Webhook } from '@/lib/api';+import type { Webhook } from '@/lib/api/endpoints/webhooks';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import {useWebhooksQuery,useCreateWebhook,diff --git a/apps/web/src/features/settings/components/webhooks/SettingsWebhooksTable.tsx b/apps/web/src/features/settings/components/webhooks/SettingsWebhooksTable.tsxindex 65aede0c..805ba581 100644--- a/apps/web/src/features/settings/components/webhooks/SettingsWebhooksTable.tsx+++ b/apps/web/src/features/settings/components/webhooks/SettingsWebhooksTable.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import type { Webhook } from '@/lib/api';+import type { Webhook } from '@/lib/api/endpoints/webhooks';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';import { SettingsWebhookRow } from './SettingsWebhookRow';diff --git a/apps/web/src/features/settings/context/settingsPermission.tsx b/apps/web/src/features/settings/context/settingsPermission.tsxindex 418425cb..5ed6c332 100644--- a/apps/web/src/features/settings/context/settingsPermission.tsx+++ b/apps/web/src/features/settings/context/settingsPermission.tsx@@ -2,7 +2,7 @@import { createContext, useContext, type ReactNode } from 'react';import { usePermissions } from '@/hooks/usePermissions';-import type { PermissionAction, PermissionResource } from '@/lib/api';+import type { PermissionAction, PermissionResource } from '@/lib/api/endpoints/roles';// The permission resource of the active settings section. Provided once per section// so the shared CRUD controls can gate their create/edit/delete buttons without everydiff --git a/apps/web/src/features/settings/hooks/useEstimatesForm.ts b/apps/web/src/features/settings/hooks/useEstimatesForm.tsindex 1a5f5c0f..e71f1c5b 100644--- a/apps/web/src/features/settings/hooks/useEstimatesForm.ts+++ b/apps/web/src/features/settings/hooks/useEstimatesForm.ts@@ -1,5 +1,5 @@import { useEffect, useState } from 'react';-import type { Project } from '@/lib/api';+import type { Project } from '@/lib/api/endpoints/projects';import { usePermissions } from '@/hooks/usePermissions';import { useUpdateEstimates } from '../services/settings.service';diff --git a/apps/web/src/features/settings/hooks/useFeatureToggles.ts b/apps/web/src/features/settings/hooks/useFeatureToggles.tsindex 42f519c7..f74526a3 100644--- a/apps/web/src/features/settings/hooks/useFeatureToggles.ts+++ b/apps/web/src/features/settings/hooks/useFeatureToggles.ts@@ -2,7 +2,8 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { ProjectDetail, ProjectFeatures } from '@/lib/api';+import type { ProjectFeatures } from '@/lib/api/endpoints/settings';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { projectFeatures } from '@/utils/projectFeatures';import { useFeatureLabel } from '@/hooks/useFeatureLabel';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/settings/hooks/useGeneralForm.ts b/apps/web/src/features/settings/hooks/useGeneralForm.tsindex d2ec6d70..408cfd6c 100644--- a/apps/web/src/features/settings/hooks/useGeneralForm.ts+++ b/apps/web/src/features/settings/hooks/useGeneralForm.ts@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useUpdateProject } from '@/services/projects.service';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/settings/hooks/useNotificationPreferencesForm.ts b/apps/web/src/features/settings/hooks/useNotificationPreferencesForm.tsindex 9b674c2e..4d11959a 100644--- a/apps/web/src/features/settings/hooks/useNotificationPreferencesForm.ts+++ b/apps/web/src/features/settings/hooks/useNotificationPreferencesForm.ts@@ -3,7 +3,8 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { NotificationEventToggles, NotificationPreferences } from '@/lib/api';+import type { NotificationPreferences } from '@/lib/api/endpoints/notificationPreferences';+import type { NotificationEventToggles } from '@/lib/api/endpoints/notificationSettings';import { useUpdateNotificationPreferences } from '../services/settings.service';import { eventsEqual } from '../utils/notificationEvents';diff --git a/apps/web/src/features/settings/services/settings.service.ts b/apps/web/src/features/settings/services/settings.service.tsindex 84193e4d..88a65911 100644--- a/apps/web/src/features/settings/services/settings.service.ts+++ b/apps/web/src/features/settings/services/settings.service.ts@@ -8,13 +8,58 @@import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import {- api,type AutoArchiveSettings,type EstimateSettings,- type NotificationPreferences,type ProjectFeatures,type SubtaskAutomationSettings,-} from '@/lib/api';+ getAutoArchive,+ updateAutoArchive,+ getSubtaskAutomation,+ updateSubtaskAutomation,+ updateEstimates,+ updateProjectSettings,+} from '@/lib/api/endpoints/settings';+import {+ createColumn,+ updateColumn,+ reorderColumns,+ deleteColumn,+} from '@/lib/api/endpoints/columns';+import {+ createCustomField,+ updateCustomField,+ deleteCustomField,+} from '@/lib/api/endpoints/customFields';+import {+ getGitSettings,+ updateGitSettings,+ regenerateGitSecret,+ listGitProviderConnections,+ connectGitProvider,+ disconnectGitProvider,+ listAvailableGitRepositories,+ connectGitRepositories,+ disconnectGitRepository,+} from '@/lib/api/endpoints/git';+import {+ createIssueTemplate,+ updateIssueTemplate,+ deleteIssueTemplate,+} from '@/lib/api/endpoints/issueTemplates';+import { createIssueType, updateIssueType, deleteIssueType } from '@/lib/api/endpoints/issueTypes';+import {+ createLabel,+ updateLabel,+ deleteLabel,+ createLabelGroup,+ updateLabelGroup,+ deleteLabelGroup,+} from '@/lib/api/endpoints/labels';+import {+ type NotificationPreferences,+ getNotificationPreferences,+ setNotificationPreferences,+} from '@/lib/api/endpoints/notificationPreferences';import { useInvalidateProject } from '@/services/projects.service';import { qk } from '@/services/queryKeys';@@ -29,85 +74,85 @@ function useProjectMutation<TArgs>(}export function useCreateColumn(projectKey: string) {- return useProjectMutation(projectKey, (input: Parameters<typeof api.createColumn>[1]) =>- api.createColumn(projectKey, input),+ return useProjectMutation(projectKey, (input: Parameters<typeof createColumn>[1]) =>+ createColumn(projectKey, input),);}export function useUpdateColumn(projectKey: string) {return useProjectMutation(projectKey,- ({ id, patch }: { id: number; patch: Parameters<typeof api.updateColumn>[2] }) =>- api.updateColumn(projectKey, id, patch),+ ({ id, patch }: { id: number; patch: Parameters<typeof updateColumn>[2] }) =>+ updateColumn(projectKey, id, patch),);}export function useReorderColumns(projectKey: string) {return useProjectMutation(projectKey, (orderedIds: number[]) =>- api.reorderColumns(projectKey, orderedIds),+ reorderColumns(projectKey, orderedIds),);}export function useDeleteColumn(projectKey: string) {return useProjectMutation(projectKey,- ({ id, body }: { id: number; body: Parameters<typeof api.deleteColumn>[2] }) =>- api.deleteColumn(projectKey, id, body),+ ({ id, body }: { id: number; body: Parameters<typeof deleteColumn>[2] }) =>+ deleteColumn(projectKey, id, body),);}export function useCreateIssueType(projectKey: string) {- return useProjectMutation(projectKey, (input: Parameters<typeof api.createIssueType>[1]) =>- api.createIssueType(projectKey, input),+ return useProjectMutation(projectKey, (input: Parameters<typeof createIssueType>[1]) =>+ createIssueType(projectKey, input),);}export function useUpdateIssueType(projectKey: string) {return useProjectMutation(projectKey,- ({ id, patch }: { id: number; patch: Parameters<typeof api.updateIssueType>[2] }) =>- api.updateIssueType(projectKey, id, patch),+ ({ id, patch }: { id: number; patch: Parameters<typeof updateIssueType>[2] }) =>+ updateIssueType(projectKey, id, patch),);}export function useDeleteIssueType(projectKey: string) {- return useProjectMutation(projectKey, (id: number) => api.deleteIssueType(projectKey, id));+ return useProjectMutation(projectKey, (id: number) => deleteIssueType(projectKey, id));}export function useCreateLabel(projectKey: string) {- return useProjectMutation(projectKey, (input: Parameters<typeof api.createLabel>[1]) =>- api.createLabel(projectKey, input),+ return useProjectMutation(projectKey, (input: Parameters<typeof createLabel>[1]) =>+ createLabel(projectKey, input),);}export function useUpdateLabel(projectKey: string) {return useProjectMutation(projectKey,- ({ id, patch }: { id: number; patch: Parameters<typeof api.updateLabel>[2] }) =>- api.updateLabel(projectKey, id, patch),+ ({ id, patch }: { id: number; patch: Parameters<typeof updateLabel>[2] }) =>+ updateLabel(projectKey, id, patch),);}export function useDeleteLabel(projectKey: string) {- return useProjectMutation(projectKey, (id: number) => api.deleteLabel(projectKey, id));+ return useProjectMutation(projectKey, (id: number) => deleteLabel(projectKey, id));}export function useCreateLabelGroup(projectKey: string) {- return useProjectMutation(projectKey, (input: Parameters<typeof api.createLabelGroup>[1]) =>- api.createLabelGroup(projectKey, input),+ return useProjectMutation(projectKey, (input: Parameters<typeof createLabelGroup>[1]) =>+ createLabelGroup(projectKey, input),);}export function useUpdateLabelGroup(projectKey: string) {return useProjectMutation(projectKey,- ({ id, patch }: { id: number; patch: Parameters<typeof api.updateLabelGroup>[2] }) =>- api.updateLabelGroup(projectKey, id, patch),+ ({ id, patch }: { id: number; patch: Parameters<typeof updateLabelGroup>[2] }) =>+ updateLabelGroup(projectKey, id, patch),);}export function useDeleteLabelGroup(projectKey: string) {- return useProjectMutation(projectKey, (id: number) => api.deleteLabelGroup(projectKey, id));+ return useProjectMutation(projectKey, (id: number) => deleteLabelGroup(projectKey, id));}// Configuration section: the project's auto-archive thresholds and subtask@@ -115,14 +160,14 @@ export function useDeleteLabelGroup(projectKey: string) {export function useAutoArchiveQuery(projectKey: string) {return useQuery({queryKey: qk.autoArchive(projectKey),- queryFn: () => api.getAutoArchive(projectKey),+ queryFn: () => getAutoArchive(projectKey),});}export function useUpdateAutoArchive(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: AutoArchiveSettings) => api.updateAutoArchive(projectKey, input),+ mutationFn: (input: AutoArchiveSettings) => updateAutoArchive(projectKey, input),onSuccess: (data) => qc.setQueryData(qk.autoArchive(projectKey), data),});}@@ -130,15 +175,14 @@ export function useUpdateAutoArchive(projectKey: string) {export function useSubtaskAutomationQuery(projectKey: string) {return useQuery({queryKey: qk.subtaskAutomation(projectKey),- queryFn: () => api.getSubtaskAutomation(projectKey),+ queryFn: () => getSubtaskAutomation(projectKey),});}export function useUpdateSubtaskAutomation(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: SubtaskAutomationSettings) =>- api.updateSubtaskAutomation(projectKey, input),+ mutationFn: (input: SubtaskAutomationSettings) => updateSubtaskAutomation(projectKey, input),onSuccess: (data) => qc.setQueryData(qk.subtaskAutomation(projectKey), data),});}@@ -147,7 +191,7 @@ export function useUpdateSubtaskAutomation(projectKey: string) {// detail the whole app reads them from rather than caching a payload of its own.export function useUpdateEstimates(projectKey: string) {return useProjectMutation(projectKey, (input: EstimateSettings) =>- api.updateEstimates(projectKey, input),+ updateEstimates(projectKey, input),);}@@ -155,15 +199,15 @@ export function useUpdateEstimates(projectKey: string) {export function useGitSettingsQuery(projectKey: string) {return useQuery({queryKey: qk.gitSettings(projectKey),- queryFn: () => api.getGitSettings(projectKey),+ queryFn: () => getGitSettings(projectKey),});}export function useUpdateGitSettings(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (patch: Parameters<typeof api.updateGitSettings>[1]) =>- api.updateGitSettings(projectKey, patch),+ mutationFn: (patch: Parameters<typeof updateGitSettings>[1]) =>+ updateGitSettings(projectKey, patch),onSuccess: (data) => qc.setQueryData(qk.gitSettings(projectKey), data),});}@@ -171,7 +215,7 @@ export function useUpdateGitSettings(projectKey: string) {export function useRegenerateGitSecret(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: () => api.regenerateGitSecret(projectKey),+ mutationFn: () => regenerateGitSecret(projectKey),onSuccess: (data) => qc.setQueryData(qk.gitSettings(projectKey), data),onSettled: () => qc.invalidateQueries({ queryKey: qk.gitConnections(projectKey) }),});@@ -180,15 +224,15 @@ export function useRegenerateGitSecret(projectKey: string) {export function useGitProviderConnectionsQuery(projectKey: string) {return useQuery({queryKey: qk.gitConnections(projectKey),- queryFn: () => api.listGitProviderConnections(projectKey),+ queryFn: () => listGitProviderConnections(projectKey),});}export function useConnectGitProvider(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: Parameters<typeof api.connectGitProvider>[1]) =>- api.connectGitProvider(projectKey, input),+ mutationFn: (input: Parameters<typeof connectGitProvider>[1]) =>+ connectGitProvider(projectKey, input),onSuccess: () => qc.invalidateQueries({ queryKey: qk.gitConnections(projectKey) }),});}@@ -196,7 +240,7 @@ export function useConnectGitProvider(projectKey: string) {export function useDisconnectGitProvider(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (connectionId: number) => api.disconnectGitProvider(projectKey, connectionId),+ mutationFn: (connectionId: number) => disconnectGitProvider(projectKey, connectionId),onSuccess: () => qc.invalidateQueries({ queryKey: qk.gitConnections(projectKey) }),});}@@ -210,7 +254,7 @@ export function useAvailableGitRepositoriesQuery(return useInfiniteQuery({queryKey: qk.gitAvailableRepositories(projectKey, connectionId, search),queryFn: ({ pageParam }) =>- api.listAvailableGitRepositories(projectKey, connectionId, { search, page: pageParam }),+ listAvailableGitRepositories(projectKey, connectionId, { search, page: pageParam }),initialPageParam: 1,getNextPageParam: (page) => page.nextPage ?? undefined,enabled,@@ -221,7 +265,7 @@ export function useConnectGitRepositories(projectKey: string, connectionId: numbconst qc = useQueryClient();return useMutation({mutationFn: (externalIds: string[]) =>- api.connectGitRepositories(projectKey, connectionId, externalIds),+ connectGitRepositories(projectKey, connectionId, externalIds),onSettled: () => qc.invalidateQueries({ queryKey: qk.gitConnections(projectKey) }),});}@@ -230,7 +274,7 @@ export function useDisconnectGitRepository(projectKey: string, connectionId: numconst qc = useQueryClient();return useMutation({mutationFn: (repositoryId: number) =>- api.disconnectGitRepository(projectKey, connectionId, repositoryId),+ disconnectGitRepository(projectKey, connectionId, repositoryId),onSuccess: () => qc.invalidateQueries({ queryKey: qk.gitConnections(projectKey) }),});}@@ -242,7 +286,7 @@ export function useUpdateProjectFeatures(projectKey: string) {const invalidate = useInvalidateProject(projectKey);return useMutation({mutationFn: (input: Partial<ProjectFeatures>) =>- api.updateProjectSettings(projectKey, { features: input }),+ updateProjectSettings(projectKey, { features: input }),onSuccess: () => invalidate(),});}@@ -252,15 +296,14 @@ export function useUpdateProjectFeatures(projectKey: string) {export function useNotificationPreferencesQuery(projectKey: string) {return useQuery({queryKey: qk.notificationPreferences(projectKey),- queryFn: () => api.getNotificationPreferences(projectKey),+ queryFn: () => getNotificationPreferences(projectKey),});}export function useUpdateNotificationPreferences(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NotificationPreferences) =>- api.setNotificationPreferences(projectKey, input),+ mutationFn: (input: NotificationPreferences) => setNotificationPreferences(projectKey, input),onSuccess: (data) => qc.setQueryData(qk.notificationPreferences(projectKey), data),});}@@ -268,39 +311,39 @@ export function useUpdateNotificationPreferences(projectKey: string) {// Custom fields. Writes go through the project-scoped endpoint; the shared// invalidation also refreshes the custom-field lists the reads depend on.export function useCreateCustomField(projectKey: string) {- return useProjectMutation(projectKey, (input: Parameters<typeof api.createCustomField>[1]) =>- api.createCustomField(projectKey, input),+ return useProjectMutation(projectKey, (input: Parameters<typeof createCustomField>[1]) =>+ createCustomField(projectKey, input),);}export function useUpdateCustomField(projectKey: string) {return useProjectMutation(projectKey,- ({ id, patch }: { id: number; patch: Parameters<typeof api.updateCustomField>[2] }) =>- api.updateCustomField(projectKey, id, patch),+ ({ id, patch }: { id: number; patch: Parameters<typeof updateCustomField>[2] }) =>+ updateCustomField(projectKey, id, patch),);}export function useDeleteCustomField(projectKey: string) {- return useProjectMutation(projectKey, (id: number) => api.deleteCustomField(projectKey, id));+ return useProjectMutation(projectKey, (id: number) => deleteCustomField(projectKey, id));}// Issue templates. The project detail carries the list, so the writes only have to// invalidate it.export function useCreateIssueTemplate(projectKey: string) {- return useProjectMutation(projectKey, (input: Parameters<typeof api.createIssueTemplate>[1]) =>- api.createIssueTemplate(projectKey, input),+ return useProjectMutation(projectKey, (input: Parameters<typeof createIssueTemplate>[1]) =>+ createIssueTemplate(projectKey, input),);}export function useUpdateIssueTemplate(projectKey: string) {return useProjectMutation(projectKey,- ({ id, patch }: { id: number; patch: Parameters<typeof api.updateIssueTemplate>[2] }) =>- api.updateIssueTemplate(projectKey, id, patch),+ ({ id, patch }: { id: number; patch: Parameters<typeof updateIssueTemplate>[2] }) =>+ updateIssueTemplate(projectKey, id, patch),);}export function useDeleteIssueTemplate(projectKey: string) {- return useProjectMutation(projectKey, (id: number) => api.deleteIssueTemplate(projectKey, id));+ return useProjectMutation(projectKey, (id: number) => deleteIssueTemplate(projectKey, id));}diff --git a/apps/web/src/features/settings/utils/customFieldsTransfer.ts b/apps/web/src/features/settings/utils/customFieldsTransfer.tsindex 81d7d161..99ddac9d 100644--- a/apps/web/src/features/settings/utils/customFieldsTransfer.ts+++ b/apps/web/src/features/settings/utils/customFieldsTransfer.ts@@ -5,7 +5,8 @@// project already defines), a missing one is created, and a referenced issue type that// does not exist yet is created first.-import type { CustomField, CustomFieldType, IssueType, MemberScope } from '@/lib/api';+import type { CustomField, CustomFieldType, MemberScope } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import { FIELD_TYPES, MEMBER_SCOPES } from './fieldTypes';const PAYLOAD_TYPE = 'plan.custom-fields';diff --git a/apps/web/src/features/settings/utils/fieldTypes.ts b/apps/web/src/features/settings/utils/fieldTypes.tsindex 8c0dfc29..71521e0f 100644--- a/apps/web/src/features/settings/utils/fieldTypes.ts+++ b/apps/web/src/features/settings/utils/fieldTypes.ts@@ -13,7 +13,7 @@ import {type LucideIcon,} from 'lucide-react';import { useTranslations } from 'next-intl';-import type { CustomFieldType, MemberScope } from '@/lib/api';+import type { CustomFieldType, MemberScope } from '@/lib/api/endpoints/customFields';// Every field type, in the order the picker shows them. Also the list a pasted// transfer payload is validated against.diff --git a/apps/web/src/features/settings/utils/issueTemplateForm.ts b/apps/web/src/features/settings/utils/issueTemplateForm.tsindex 1f4aa867..2dc48e17 100644--- a/apps/web/src/features/settings/utils/issueTemplateForm.ts+++ b/apps/web/src/features/settings/utils/issueTemplateForm.ts@@ -1,4 +1,4 @@-import type { IssueTemplate, NewIssueTemplateInput } from '@/lib/api';+import type { IssueTemplate, NewIssueTemplateInput } from '@/lib/api/endpoints/issueTemplates';// The template as the settings dialog edits it. `priority` is '' for none, the way// PrioritySelect carries it; the other properties are null when the templatediff --git a/apps/web/src/features/settings/utils/issueTypesTransfer.ts b/apps/web/src/features/settings/utils/issueTypesTransfer.tsindex aba5eb2c..aeb018d0 100644--- a/apps/web/src/features/settings/utils/issueTypesTransfer.ts+++ b/apps/web/src/features/settings/utils/issueTypesTransfer.ts@@ -2,7 +2,7 @@// projects. The clipboard payload is a small JSON envelope. Matching is by name;// a new type is created, a same-name type with a different color is recolored.-import type { IssueType } from '@/lib/api';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';import { DEFAULT_COLOR } from '@/utils/project';const PAYLOAD_TYPE = 'plan.issue-types';diff --git a/apps/web/src/features/settings/utils/labelsTransfer.ts b/apps/web/src/features/settings/utils/labelsTransfer.tsindex 9df25e2e..6fd5c33c 100644--- a/apps/web/src/features/settings/utils/labelsTransfer.ts+++ b/apps/web/src/features/settings/utils/labelsTransfer.ts@@ -3,7 +3,7 @@// and the labels, each label naming its group. Matching is by name; a new group/label// is created, and a same-name one with a different color is recolored.-import type { Label, LabelGroup } from '@/lib/api';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';import { DEFAULT_COLOR } from '@/utils/project';const PAYLOAD_TYPE = 'plan.labels';diff --git a/apps/web/src/features/settings/utils/notificationEvents.ts b/apps/web/src/features/settings/utils/notificationEvents.tsindex c92f2f96..1abf70bf 100644--- a/apps/web/src/features/settings/utils/notificationEvents.ts+++ b/apps/web/src/features/settings/utils/notificationEvents.ts@@ -1,4 +1,4 @@-import type { NotificationEventToggles } from '@/lib/api';+import type { NotificationEventToggles } from '@/lib/api/endpoints/notificationSettings';// The issue events a channel can send, matching the inbox notification types.// Shared by the email and telegram event sections; the label of an event is adiff --git a/apps/web/src/features/settings/utils/statesTransfer.ts b/apps/web/src/features/settings/utils/statesTransfer.tsindex 1d70723b..373e7148 100644--- a/apps/web/src/features/settings/utils/statesTransfer.ts+++ b/apps/web/src/features/settings/utils/statesTransfer.ts@@ -2,7 +2,7 @@// between projects. The clipboard payload is a small JSON envelope; parsing validates// it and drops states with an unknown state type.-import type { Column, StateType } from '@/lib/api';+import type { Column, StateType } from '@/lib/api/endpoints/columns';import { STATE_TYPES } from '@/utils/fieldOptions';import { DEFAULT_COLOR } from '@/utils/project';diff --git a/apps/web/src/features/teams/components/NewTeamModal.tsx b/apps/web/src/features/teams/components/NewTeamModal.tsxindex 90e1c019..5314d64b 100644--- a/apps/web/src/features/teams/components/NewTeamModal.tsx+++ b/apps/web/src/features/teams/components/NewTeamModal.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Users } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Team } from '@/lib/api';+import type { Team } from '@/lib/api/endpoints/teams';import { useCreateTeam } from '@/services/teams.service';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/teams/components/TeamSectionNav.tsx b/apps/web/src/features/teams/components/TeamSectionNav.tsxindex b409434e..f3c47f97 100644--- a/apps/web/src/features/teams/components/TeamSectionNav.tsx+++ b/apps/web/src/features/teams/components/TeamSectionNav.tsx@@ -17,7 +17,7 @@ import {type LucideIcon,} from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Team } from '@/lib/api';+import type { Team } from '@/lib/api/endpoints/teams';import { cn } from '@/lib/utils';import { teamSectionPath, type TeamSection } from '@/utils/paths';import { useTeamQuery } from '@/services/teams.service';diff --git a/apps/web/src/features/teams/components/TeamsRail.tsx b/apps/web/src/features/teams/components/TeamsRail.tsxindex dbd750d4..dcebaeb0 100644--- a/apps/web/src/features/teams/components/TeamsRail.tsx+++ b/apps/web/src/features/teams/components/TeamsRail.tsx@@ -3,7 +3,7 @@import Link from 'next/link';import { Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Team } from '@/lib/api';+import type { Team } from '@/lib/api/endpoints/teams';import { cn } from '@/lib/utils';import { teamPath } from '@/utils/paths';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';diff --git a/apps/web/src/features/teams/components/agent-skills/SkillCreateDialog.tsx b/apps/web/src/features/teams/components/agent-skills/SkillCreateDialog.tsxindex 4703e178..7bab7037 100644--- a/apps/web/src/features/teams/components/agent-skills/SkillCreateDialog.tsx+++ b/apps/web/src/features/teams/components/agent-skills/SkillCreateDialog.tsx@@ -1,6 +1,6 @@import { useMemo, useState } from 'react';import { Search, TriangleAlert, X } from 'lucide-react';-import type { GithubSkillCandidate, NewSkillInput } from '@/lib/api';+import type { GithubSkillCandidate, NewSkillInput } from '@/lib/api/endpoints/agentSkills';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/teams/components/agent-skills/SkillEditDialog.tsx b/apps/web/src/features/teams/components/agent-skills/SkillEditDialog.tsxindex 4bc7063c..e5c0d3dc 100644--- a/apps/web/src/features/teams/components/agent-skills/SkillEditDialog.tsx+++ b/apps/web/src/features/teams/components/agent-skills/SkillEditDialog.tsx@@ -1,7 +1,12 @@import { useState } from 'react';import { useQuery } from '@tanstack/react-query';import { X } from 'lucide-react';-import { api, type AgentSkill, type SkillPatch } from '@/lib/api';+import {+ type AgentSkill,+ type SkillPatch,+ getSkillMarkdown,+ getSkillReferenceContent,+} from '@/lib/api/endpoints/agentSkills';import { qk } from '@/services/queryKeys';import { cn } from '@/lib/utils';import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';@@ -63,8 +68,8 @@ export function SkillEditDialog({queryKey: [...qk.agentSkills(teamId), skillId, 'file', selected],queryFn: () =>selected === SKILL_MD- ? api.getSkillMarkdown(teamId, skillId).then((r) => r.markdown)- : api.getSkillReferenceContent(teamId, skillId, selected).then((r) => r.content),+ ? getSkillMarkdown(teamId, skillId).then((r) => r.markdown)+ : getSkillReferenceContent(teamId, skillId, selected).then((r) => r.content),});const draft = drafts[selected];diff --git a/apps/web/src/features/teams/components/agent-skills/SkillRow.tsx b/apps/web/src/features/teams/components/agent-skills/SkillRow.tsxindex 82bedbdf..f1930a0b 100644--- a/apps/web/src/features/teams/components/agent-skills/SkillRow.tsx+++ b/apps/web/src/features/teams/components/agent-skills/SkillRow.tsx@@ -1,5 +1,5 @@import { BookText, Pencil, Trash2 } from 'lucide-react';-import type { AgentSkill } from '@/lib/api';+import type { AgentSkill } from '@/lib/api/endpoints/agentSkills';import GithubIcon from '@/components/common/GithubIcon';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/teams/components/agent-skills/TeamAgentSkills.tsx b/apps/web/src/features/teams/components/agent-skills/TeamAgentSkills.tsxindex 2ca5c230..840c80c2 100644--- a/apps/web/src/features/teams/components/agent-skills/TeamAgentSkills.tsx+++ b/apps/web/src/features/teams/components/agent-skills/TeamAgentSkills.tsx@@ -1,6 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { AgentSkill, ResourcePermissions } from '@/lib/api';+import type { ResourcePermissions } from '@/lib/api/endpoints/roles';+import type { AgentSkill } from '@/lib/api/endpoints/agentSkills';import { useSkillsPageQuery, useDeleteSkill } from '@/services/agentSkills.service';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';import { EmptyState } from '@/components/common/page/EmptyState';diff --git a/apps/web/src/features/teams/components/agent-tools/TeamAgentTools.tsx b/apps/web/src/features/teams/components/agent-tools/TeamAgentTools.tsxindex 80f26d8a..8b8928b8 100644--- a/apps/web/src/features/teams/components/agent-tools/TeamAgentTools.tsx+++ b/apps/web/src/features/teams/components/agent-tools/TeamAgentTools.tsx@@ -1,6 +1,8 @@import { useMemo, useState } from 'react';import { useTranslations } from 'next-intl';-import type { ConfiguredTool, IntegrationMeta, ResourcePermissions } from '@/lib/api';+import type { ResourcePermissions } from '@/lib/api/endpoints/roles';+import type { ConfiguredTool } from '@/lib/api/endpoints/agentTools';+import type { IntegrationMeta } from '@/lib/api/endpoints/integrations';import {useConfiguredToolsPageQuery,useDeleteConfiguredTool,diff --git a/apps/web/src/features/teams/components/agent-tools/ToolConfigDialog.tsx b/apps/web/src/features/teams/components/agent-tools/ToolConfigDialog.tsxindex fce3b39d..4a58f4f6 100644--- a/apps/web/src/features/teams/components/agent-tools/ToolConfigDialog.tsx+++ b/apps/web/src/features/teams/components/agent-tools/ToolConfigDialog.tsx@@ -1,5 +1,5 @@import { useMemo, useState } from 'react';-import type { IntegrationMeta } from '@/lib/api';+import type { IntegrationMeta } from '@/lib/api/endpoints/integrations';import Modal from '@/components/common/overlay/Modal';import { ToolPicker } from './ToolPicker';import { ToolCredentialStep } from './ToolCredentialStep';diff --git a/apps/web/src/features/teams/components/agent-tools/ToolConfigRow.tsx b/apps/web/src/features/teams/components/agent-tools/ToolConfigRow.tsxindex 58dc03bc..630df44c 100644--- a/apps/web/src/features/teams/components/agent-tools/ToolConfigRow.tsx+++ b/apps/web/src/features/teams/components/agent-tools/ToolConfigRow.tsx@@ -1,5 +1,5 @@import { Trash2, Wrench } from 'lucide-react';-import type { ConfiguredTool } from '@/lib/api';+import type { ConfiguredTool } from '@/lib/api/endpoints/agentTools';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import { TableCell, TableRow } from '@/components/ui/table';diff --git a/apps/web/src/features/teams/components/agent-tools/ToolCredentialStep.tsx b/apps/web/src/features/teams/components/agent-tools/ToolCredentialStep.tsxindex 91c95c85..395a2a3e 100644--- a/apps/web/src/features/teams/components/agent-tools/ToolCredentialStep.tsx+++ b/apps/web/src/features/teams/components/agent-tools/ToolCredentialStep.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { ChevronLeft } from 'lucide-react';-import type { IntegrationOption } from '@/lib/api';+import type { IntegrationOption } from '@/lib/api/endpoints/integrations';import { Button } from '@/components/ui/button';import { Label } from '@/components/ui/label';import {diff --git a/apps/web/src/features/teams/components/ai-agents/AgentActionRow.tsx b/apps/web/src/features/teams/components/ai-agents/AgentActionRow.tsxindex 1eabe293..a3704730 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentActionRow.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentActionRow.tsx@@ -1,4 +1,4 @@-import type { AgentTool } from '@/lib/api';+import type { AgentTool } from '@/lib/api/endpoints/agents';import { Checkbox } from '@/components/ui/checkbox';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentActionsSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentActionsSection.tsxindex 32ac5e07..31fbb146 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentActionsSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentActionsSection.tsx@@ -2,7 +2,7 @@import { useMemo, useState } from 'react';import { ListChecks } from 'lucide-react';-import type { AgentTool } from '@/lib/api';+import type { AgentTool } from '@/lib/api/endpoints/agents';import { grantedToolCount, groupInOrder } from '../../utils/agentForm';import { AgentFormSection } from './AgentFormSection';import { AgentActionRow } from './AgentActionRow';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentCredentialField.tsx b/apps/web/src/features/teams/components/ai-agents/AgentCredentialField.tsxindex 2b21f4ed..f0d3d529 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentCredentialField.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentCredentialField.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { Check } from 'lucide-react';-import type { IntegrationOption } from '@/lib/api';+import type { IntegrationOption } from '@/lib/api/endpoints/integrations';import {Command,CommandEmpty,diff --git a/apps/web/src/features/teams/components/ai-agents/AgentMetaRow.tsx b/apps/web/src/features/teams/components/ai-agents/AgentMetaRow.tsxindex 36c4c650..f0c7834f 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentMetaRow.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentMetaRow.tsx@@ -1,5 +1,5 @@import { BookOpen, Sparkles, Wrench, Zap } from 'lucide-react';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { AgentMetaChip } from './AgentMetaChip';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentModelField.tsx b/apps/web/src/features/teams/components/ai-agents/AgentModelField.tsxindex c909bb27..3a1f82e3 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentModelField.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentModelField.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { Check } from 'lucide-react';-import type { ProviderModel } from '@/lib/api';+import type { ProviderModel } from '@/lib/api/endpoints/integrations';import {Command,CommandEmpty,diff --git a/apps/web/src/features/teams/components/ai-agents/AgentModelSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentModelSection.tsxindex 8647c272..ac3ca7ef 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentModelSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentModelSection.tsx@@ -1,7 +1,11 @@'use client';import { Cpu, KeyRound } from 'lucide-react';-import type { IntegrationMeta, IntegrationOption, ProviderModel } from '@/lib/api';+import type {+ IntegrationMeta,+ IntegrationOption,+ ProviderModel,+} from '@/lib/api/endpoints/integrations';import { manageTeamsPath } from '@/utils/paths';import type { AgentFormValue } from '../../utils/agentForm';import { integrationLabel } from '@/utils/integrationLabels';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentProjectsSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentProjectsSection.tsxindex d6663b13..f67aa2e3 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentProjectsSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentProjectsSection.tsx@@ -1,5 +1,5 @@import { FolderKanban } from 'lucide-react';-import type { TeamProjectOption } from '@/lib/api';+import type { TeamProjectOption } from '@/lib/api/endpoints/teams';import type { AgentFormValue } from '../../utils/agentForm';import { AgentCapabilityList } from './AgentCapabilityList';import { AgentEmptyNotice } from './AgentEmptyNotice';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentRunnerHelpSheet.tsx b/apps/web/src/features/teams/components/ai-agents/AgentRunnerHelpSheet.tsxindex 576a3a7a..6cbd4226 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentRunnerHelpSheet.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentRunnerHelpSheet.tsx@@ -1,6 +1,6 @@import { HelpCircle } from 'lucide-react';import { useTranslations } from 'next-intl';-import { API_URL } from '@/lib/api';+import { API_URL } from '@/lib/api/core/client';import { Button } from '@/components/ui/button';import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/components/ui/sheet';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsxindex db805efc..00d17175 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsx@@ -1,6 +1,6 @@import { Code2, Package, Terminal } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';import { AgentFormSection } from './AgentFormSection';import { AgentRunnerCodeBlock } from './AgentRunnerCodeBlock';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsx b/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsxindex 4c5b8ba5..1c5c0ccf 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsx@@ -1,6 +1,6 @@import { useEffect, useRef, useState } from 'react';import { Sparkles, Wrench } from 'lucide-react';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { teamSectionPath } from '@/utils/paths';import {useCreateAiAgent,diff --git a/apps/web/src/features/teams/components/ai-agents/AgentTokenSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentTokenSection.tsxindex ec865236..41a25191 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentTokenSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentTokenSection.tsx@@ -1,6 +1,6 @@import { useEffect, useRef, useState } from 'react';import { KeyRound, TriangleAlert, X } from 'lucide-react';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { useRegenerateAiAgentKey } from '@/services/aiAgents.service';import { Button } from '@/components/ui/button';import { useAgentCan, useAgentSection } from '../../context/agentSection';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentTriggers.tsx b/apps/web/src/features/teams/components/ai-agents/AgentTriggers.tsxindex 92dc0a42..66f0d113 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentTriggers.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentTriggers.tsx@@ -1,5 +1,5 @@import { AtSign, ListChecks, UserRoundCheck } from 'lucide-react';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';import { AgentTriggerChip, TRIGGER_CHIP } from './AgentTriggerChip';diff --git a/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsxindex d5f2b22e..3d76813f 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsx@@ -1,8 +1,9 @@import { Fragment } from 'react';import { Zap } from 'lucide-react';import { useQueries } from '@tanstack/react-query';-import type { CustomField, TeamProjectOption } from '@/lib/api';-import { api } from '@/lib/api';+import type { TeamProjectOption } from '@/lib/api/endpoints/teams';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import { getProject } from '@/lib/api/endpoints/projects';import { qk } from '@/services/queryKeys';import { Switch } from '@/components/ui/switch';import { isMemberField } from '@/utils/memberFields';@@ -41,7 +42,7 @@ export default function AgentTriggersSection({const scaffolds = useQueries({queries: attached.map((project) => ({queryKey: qk.project(project.key),- queryFn: () => api.getProject(project.key),+ queryFn: () => getProject(project.key),})),});const memberFields: ProjectField[] = scaffolds.flatMap((scaffold, index) =>diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsxindex c0c8bc80..6f2e5d7a 100644--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx@@ -1,13 +1,12 @@import { type ReactNode, useState } from 'react';import { SlidersHorizontal, Sparkles, Wrench } from 'lucide-react';+import type { TeamProjectOption } from '@/lib/api/endpoints/teams';+import type { AgentTool, AiAgent } from '@/lib/api/endpoints/agents';import type {- AgentTool,- AiAgent,IntegrationMeta,IntegrationOption,ProviderModel,- TeamProjectOption,-} from '@/lib/api';+} from '@/lib/api/endpoints/integrations';import { Input } from '@/components/ui/input';import { Checkbox } from '@/components/ui/checkbox';import { AGENT_KIND_ICON } from '../../utils/agentKindIcon';diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRow.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRow.tsxindex 8c4a3a9c..1f6ff135 100644--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRow.tsx+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRow.tsx@@ -1,5 +1,5 @@import { History, MessageSquare, MoreHorizontal, Pencil, Trash2 } from 'lucide-react';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRunsSheet.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRunsSheet.tsxindex aeae7a4d..07966ce8 100644--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRunsSheet.tsx+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentRunsSheet.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { ChevronDown, ChevronRight } from 'lucide-react';-import type { AgentRun, AiAgent } from '@/lib/api';+import type { AgentRun, AiAgent } from '@/lib/api/endpoints/agents';import { useRelativeTime } from '@/context/relativeTimeContext';import { formatDateTime } from '@/utils/dates';import { useAgentRuns } from '@/services/aiAgents.service';diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsxindex 97d65c3c..a1c921f1 100644--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsx+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Bot, MessageSquare, X } from 'lucide-react';import { AGENT_KIND_ICON } from '../../utils/agentKindIcon';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { useAiAgentsQuery } from '@/services/aiAgents.service';import {Sheet,diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgents.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgents.tsxindex 06e81263..5dcb9912 100644--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgents.tsx+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgents.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import type { AiAgent } from '@/lib/api';+import type { AiAgent } from '@/lib/api/endpoints/agents';import { useAiAgentsQuery, useDeleteAiAgent } from '@/services/aiAgents.service';import { useIntegrationCatalogQuery } from '@/services/integrations.service';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';diff --git a/apps/web/src/features/teams/components/info/TeamInfoSection.tsx b/apps/web/src/features/teams/components/info/TeamInfoSection.tsxindex 9cb99213..cb671309 100644--- a/apps/web/src/features/teams/components/info/TeamInfoSection.tsx+++ b/apps/web/src/features/teams/components/info/TeamInfoSection.tsx@@ -4,7 +4,7 @@ import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';import { TeamBillingSection } from '@/cloud';-import type { Team } from '@/lib/api';+import type { Team } from '@/lib/api/endpoints/teams';import { formatDate } from '@/utils/dates';import { useRenameTeam, useTeam } from '@/services/teams.service';import SectionPageView from '@/components/common/page/SectionPageView';diff --git a/apps/web/src/features/teams/components/info/TeamLeaveDialog.tsx b/apps/web/src/features/teams/components/info/TeamLeaveDialog.tsxindex d7838c01..5cfa531b 100644--- a/apps/web/src/features/teams/components/info/TeamLeaveDialog.tsx+++ b/apps/web/src/features/teams/components/info/TeamLeaveDialog.tsx@@ -2,7 +2,7 @@import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';-import type { Team } from '@/lib/api';+import type { Team } from '@/lib/api/endpoints/teams';import { manageTeamsPath } from '@/utils/paths';import { useLeaveTeam } from '@/services/teams.service';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';diff --git a/apps/web/src/features/teams/components/integrations/CredentialDialog.tsx b/apps/web/src/features/teams/components/integrations/CredentialDialog.tsxindex 8e482cb3..a8133905 100644--- a/apps/web/src/features/teams/components/integrations/CredentialDialog.tsx+++ b/apps/web/src/features/teams/components/integrations/CredentialDialog.tsx@@ -1,5 +1,5 @@import { useState } from 'react';-import type { IntegrationCredential, IntegrationMeta } from '@/lib/api';+import type { IntegrationCredential, IntegrationMeta } from '@/lib/api/endpoints/integrations';import Modal from '@/components/common/overlay/Modal';import { IntegrationPicker } from './IntegrationPicker';import { CredentialForm } from './CredentialForm';diff --git a/apps/web/src/features/teams/components/integrations/CredentialForm.tsx b/apps/web/src/features/teams/components/integrations/CredentialForm.tsxindex 25957c6e..d8df5e16 100644--- a/apps/web/src/features/teams/components/integrations/CredentialForm.tsx+++ b/apps/web/src/features/teams/components/integrations/CredentialForm.tsx@@ -1,6 +1,10 @@import { useState } from 'react';import { ChevronLeft } from 'lucide-react';-import type { ConfigField, IntegrationCredential, IntegrationMeta } from '@/lib/api';+import type {+ ConfigField,+ IntegrationCredential,+ IntegrationMeta,+} from '@/lib/api/endpoints/integrations';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';diff --git a/apps/web/src/features/teams/components/integrations/CredentialRow.tsx b/apps/web/src/features/teams/components/integrations/CredentialRow.tsxindex e22a74bb..4f924eea 100644--- a/apps/web/src/features/teams/components/integrations/CredentialRow.tsx+++ b/apps/web/src/features/teams/components/integrations/CredentialRow.tsx@@ -1,5 +1,5 @@import { KeyRound, Pencil, Trash2 } from 'lucide-react';-import type { IntegrationCredential } from '@/lib/api';+import type { IntegrationCredential } from '@/lib/api/endpoints/integrations';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import { TableCell, TableRow } from '@/components/ui/table';diff --git a/apps/web/src/features/teams/components/integrations/IntegrationPicker.tsx b/apps/web/src/features/teams/components/integrations/IntegrationPicker.tsxindex 034484eb..1b376e02 100644--- a/apps/web/src/features/teams/components/integrations/IntegrationPicker.tsx+++ b/apps/web/src/features/teams/components/integrations/IntegrationPicker.tsx@@ -1,6 +1,6 @@import { useMemo, useState } from 'react';import { Search } from 'lucide-react';-import type { IntegrationMeta } from '@/lib/api';+import type { IntegrationMeta } from '@/lib/api/endpoints/integrations';import { Input } from '@/components/ui/input';import { IntegrationIcon } from '@/components/common/IntegrationIcon';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/features/teams/components/integrations/TeamIntegrations.tsx b/apps/web/src/features/teams/components/integrations/TeamIntegrations.tsxindex ef9f71b3..6a4a65fe 100644--- a/apps/web/src/features/teams/components/integrations/TeamIntegrations.tsx+++ b/apps/web/src/features/teams/components/integrations/TeamIntegrations.tsx@@ -1,6 +1,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { IntegrationCredential, IntegrationMeta, ResourcePermissions } from '@/lib/api';+import type { ResourcePermissions } from '@/lib/api/endpoints/roles';+import type { IntegrationCredential, IntegrationMeta } from '@/lib/api/endpoints/integrations';import { useCredentialsPageQuery, useDeleteCredential } from '@/services/integrations.service';import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table';import { EmptyState } from '@/components/common/page/EmptyState';diff --git a/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx b/apps/web/src/features/teams/components/members/TeamInviteDialog.tsxindex 4593e809..72bc4bfc 100644--- a/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx+++ b/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx@@ -3,7 +3,9 @@import { useState, type FormEvent } from 'react';import { Mail, Users } from 'lucide-react';import { useTranslations } from 'next-intl';-import { ApiError, type InviteTeamRole, type TeamRole } from '@/lib/api';+import type { InviteTeamRole } from '@/lib/api/endpoints/invites';+import type { TeamRole } from '@/lib/api/endpoints/teams';+import { ApiError } from '@/lib/api/core/client';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/teams/components/members/TeamInviteRow.tsx b/apps/web/src/features/teams/components/members/TeamInviteRow.tsxindex 0a822379..14de80a6 100644--- a/apps/web/src/features/teams/components/members/TeamInviteRow.tsx+++ b/apps/web/src/features/teams/components/members/TeamInviteRow.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Check, Copy, Mail, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { InviteRow } from '@/lib/api';+import type { InviteRow } from '@/lib/api/endpoints/invites';import { inviteLink } from '@/utils/paths';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/teams/components/members/TeamMemberRoleControl.tsx b/apps/web/src/features/teams/components/members/TeamMemberRoleControl.tsxindex 82639377..056eeefe 100644--- a/apps/web/src/features/teams/components/members/TeamMemberRoleControl.tsx+++ b/apps/web/src/features/teams/components/members/TeamMemberRoleControl.tsx@@ -2,7 +2,7 @@import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { TeamMember, TeamRole } from '@/lib/api';+import type { TeamMember, TeamRole } from '@/lib/api/endpoints/teams';import { Badge } from '@/components/ui/badge';import {Select,diff --git a/apps/web/src/features/teams/components/members/TeamMemberRow.tsx b/apps/web/src/features/teams/components/members/TeamMemberRow.tsxindex 7a1085b6..bcee3f5e 100644--- a/apps/web/src/features/teams/components/members/TeamMemberRow.tsx+++ b/apps/web/src/features/teams/components/members/TeamMemberRow.tsx@@ -2,7 +2,7 @@import { X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { TeamMember } from '@/lib/api';+import type { TeamMember } from '@/lib/api/endpoints/teams';import { formatDate } from '@/utils/dates';import Avatar from '@/components/common/Avatar';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/teams/components/members/TeamMembersSection.tsx b/apps/web/src/features/teams/components/members/TeamMembersSection.tsxindex a54a6fa5..d293de4d 100644--- a/apps/web/src/features/teams/components/members/TeamMembersSection.tsx+++ b/apps/web/src/features/teams/components/members/TeamMembersSection.tsx@@ -4,7 +4,9 @@ import { useState } from 'react';import { Plus } from 'lucide-react';import { useTranslations } from 'next-intl';import { toast } from 'sonner';-import type { InviteRow, MemberKind, TeamMember } from '@/lib/api';+import type { InviteRow } from '@/lib/api/endpoints/invites';+import type { MemberKind } from '@/lib/api/endpoints/members';+import type { TeamMember } from '@/lib/api/endpoints/teams';import {useDeleteTeamInvite,useRemoveTeamMember,diff --git a/apps/web/src/features/teams/components/notifications/EmailSettings.tsx b/apps/web/src/features/teams/components/notifications/EmailSettings.tsxindex 7e82bc71..8a349a2a 100644--- a/apps/web/src/features/teams/components/notifications/EmailSettings.tsx+++ b/apps/web/src/features/teams/components/notifications/EmailSettings.tsx@@ -1,4 +1,4 @@-import type { NotificationEncryption } from '@/lib/api';+import type { NotificationEncryption } from '@/lib/api/endpoints/notificationSettings';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import {diff --git a/apps/web/src/features/teams/components/notifications/TeamNotificationProviders.tsx b/apps/web/src/features/teams/components/notifications/TeamNotificationProviders.tsxindex 2a9b0f34..136bba0c 100644--- a/apps/web/src/features/teams/components/notifications/TeamNotificationProviders.tsx+++ b/apps/web/src/features/teams/components/notifications/TeamNotificationProviders.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { NotificationSettings } from '@/lib/api';+import type { NotificationSettings } from '@/lib/api/endpoints/notificationSettings';import { Button } from '@/components/ui/button';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';import { useEmailForm } from '../../hooks/useEmailForm';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectActions.tsx b/apps/web/src/features/teams/components/projects/TeamProjectActions.tsxindex c6320664..74002a75 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectActions.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectActions.tsx@@ -4,7 +4,8 @@ import { useState } from 'react';import { useRouter } from 'next/navigation';import { Copy, LogOut, Pencil, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { MemberRole, TeamProject, TeamRole } from '@/lib/api';+import type { MemberRole } from '@/lib/api/endpoints/members';+import type { TeamProject, TeamRole } from '@/lib/api/endpoints/teams';import { useSession } from '@/lib/auth-client';import { projectPath } from '@/utils/paths';import RowAction from '@/components/common/RowAction';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsx b/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsxindex 6282780c..37c3ad12 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { TeamProject } from '@/lib/api';+import type { TeamProject } from '@/lib/api/endpoints/teams';import { useDeleteTeamProject } from '@/services/projects.service';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsx b/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsxindex cf3964de..1a469ff3 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Users } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { TeamProject } from '@/lib/api';+import type { TeamProject } from '@/lib/api/endpoints/teams';import { useUpdateTeamProject } from '@/services/projects.service';import { useTeam } from '@/services/teams.service';import Modal from '@/components/common/overlay/Modal';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsx b/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsxindex b6675780..ca4e3186 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { TeamProject } from '@/lib/api';+import type { TeamProject } from '@/lib/api/endpoints/teams';import { useLeaveProject } from '@/services/projects.service';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectMemberCard.tsx b/apps/web/src/features/teams/components/projects/TeamProjectMemberCard.tsxindex f176b236..525286b0 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectMemberCard.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectMemberCard.tsx@@ -3,7 +3,8 @@import { useState } from 'react';import { UserMinus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { PermissionCatalog, Role, TeamProjectMember } from '@/lib/api';+import type { PermissionCatalog, Role } from '@/lib/api/endpoints/roles';+import type { TeamProjectMember } from '@/lib/api/endpoints/teams';import { membershipPermissions } from '@/utils/permissions';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import RowAction from '@/components/common/RowAction';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectMembers.tsx b/apps/web/src/features/teams/components/projects/TeamProjectMembers.tsxindex 0b41cf4e..1757bc67 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectMembers.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectMembers.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { MemberKind } from '@/lib/api';+import type { MemberKind } from '@/lib/api/endpoints/members';import { useSearchTerm } from '@/hooks/useSearchTerm';import { useTeamProjectMembersQuery } from '@/services/teams.service';import { usePermissionCatalogQuery, useTeamRoleOptionsQuery } from '@/services/roles.service';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsx b/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsxindex 71ab1dd9..57791a03 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsx@@ -2,7 +2,7 @@import { X } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { TeamProject, TeamRole } from '@/lib/api';+import type { TeamProject, TeamRole } from '@/lib/api/endpoints/teams';import { formatDate, formatDateTime } from '@/utils/dates';import { useExitOnEscape } from '@/hooks/useExitOnEscape';import { useTeamProjectQuery } from '@/services/teams.service';diff --git a/apps/web/src/features/teams/components/projects/TeamProjectStats.tsx b/apps/web/src/features/teams/components/projects/TeamProjectStats.tsxindex 1278f639..db753bce 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectStats.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectStats.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { AnalyticsStats } from '@/lib/api';+import type { AnalyticsStats } from '@/lib/api/endpoints/analytics';// How the project's issues stand, in the order a team owner reads them: what is left// to do, what moves, and what needs attention.diff --git a/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsx b/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsxindex 966048f9..39f1160b 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsx@@ -3,7 +3,7 @@import Link from 'next/link';import { ArrowUpRight } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { TeamProject } from '@/lib/api';+import type { TeamProject } from '@/lib/api/endpoints/teams';import { formatDate } from '@/utils/dates';import { projectPath } from '@/utils/paths';import Avatar from '@/components/common/Avatar';diff --git a/apps/web/src/features/teams/components/roles/DeleteRoleDialog.tsx b/apps/web/src/features/teams/components/roles/DeleteRoleDialog.tsxindex 8ffef4de..e082cc79 100644--- a/apps/web/src/features/teams/components/roles/DeleteRoleDialog.tsx+++ b/apps/web/src/features/teams/components/roles/DeleteRoleDialog.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { Role } from '@/lib/api';+import type { Role } from '@/lib/api/endpoints/roles';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import {Select,diff --git a/apps/web/src/features/teams/components/roles/RoleEditorPanel.tsx b/apps/web/src/features/teams/components/roles/RoleEditorPanel.tsxindex ed639334..dc9a33d4 100644--- a/apps/web/src/features/teams/components/roles/RoleEditorPanel.tsx+++ b/apps/web/src/features/teams/components/roles/RoleEditorPanel.tsx@@ -9,7 +9,7 @@ import type {PermissionResource,Permissions,Role,-} from '@/lib/api';+} from '@/lib/api/endpoints/roles';import { useExitOnEscape } from '@/hooks/useExitOnEscape';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';diff --git a/apps/web/src/features/teams/components/roles/TeamRolesList.tsx b/apps/web/src/features/teams/components/roles/TeamRolesList.tsxindex 00598c64..da231e5c 100644--- a/apps/web/src/features/teams/components/roles/TeamRolesList.tsx+++ b/apps/web/src/features/teams/components/roles/TeamRolesList.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Pencil, Trash2 } from 'lucide-react';import { useTranslations } from 'next-intl';-import type { Role } from '@/lib/api';+import type { Role } from '@/lib/api/endpoints/roles';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';diff --git a/apps/web/src/features/teams/components/roles/TeamRolesSection.tsx b/apps/web/src/features/teams/components/roles/TeamRolesSection.tsxindex c40fc625..a2a6b29a 100644--- a/apps/web/src/features/teams/components/roles/TeamRolesSection.tsx+++ b/apps/web/src/features/teams/components/roles/TeamRolesSection.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import type { Role } from '@/lib/api';+import type { Role } from '@/lib/api/endpoints/roles';import {usePermissionCatalogQuery,useTeamRoleOptionsQuery,diff --git a/apps/web/src/features/teams/components/roles/TeamRolesToolbar.tsx b/apps/web/src/features/teams/components/roles/TeamRolesToolbar.tsxindex ddf39d4f..06e4effb 100644--- a/apps/web/src/features/teams/components/roles/TeamRolesToolbar.tsx+++ b/apps/web/src/features/teams/components/roles/TeamRolesToolbar.tsx@@ -6,7 +6,7 @@ import { toast } from 'sonner';import { useTranslations } from 'next-intl';import { Button } from '@/components/ui/button';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';-import type { PermissionCatalog, Role } from '@/lib/api';+import type { PermissionCatalog, Role } from '@/lib/api/endpoints/roles';import { useIsMac } from '@/context/useHotkeys';import RolesImportDialog from './RolesImportDialog';import { useClipboardHasRoles } from '../../hooks/useClipboardHasRoles';diff --git a/apps/web/src/features/teams/context/agentSection.tsx b/apps/web/src/features/teams/context/agentSection.tsxindex 170a23dc..7f8b46df 100644--- a/apps/web/src/features/teams/context/agentSection.tsx+++ b/apps/web/src/features/teams/context/agentSection.tsx@@ -1,7 +1,7 @@'use client';import { createContext, useContext, type ReactNode } from 'react';-import type { PermissionAction, Permissions } from '@/lib/api';+import type { PermissionAction, Permissions } from '@/lib/api/endpoints/roles';// The team whose agents the section edits, and what the caller may do with them.// Provided once by the section so the parts of the agent editor read both instead ofdiff --git a/apps/web/src/features/teams/hooks/useEmailForm.ts b/apps/web/src/features/teams/hooks/useEmailForm.tsindex b3ba0c9c..033345be 100644--- a/apps/web/src/features/teams/hooks/useEmailForm.ts+++ b/apps/web/src/features/teams/hooks/useEmailForm.ts@@ -3,7 +3,10 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { NotificationEncryption, NotificationSettings } from '@/lib/api';+import type {+ NotificationEncryption,+ NotificationSettings,+} from '@/lib/api/endpoints/notificationSettings';import { useUpdateNotificationSettings } from '@/services/teams.service';import type { EmailProvider } from '@/components/common/inputs/ProviderToggle';import { toPositiveInt } from '@/lib/utils';diff --git a/apps/web/src/features/teams/hooks/useTelegramForm.ts b/apps/web/src/features/teams/hooks/useTelegramForm.tsindex 88a4c5a3..8d8bf4dd 100644--- a/apps/web/src/features/teams/hooks/useTelegramForm.ts+++ b/apps/web/src/features/teams/hooks/useTelegramForm.ts@@ -3,7 +3,7 @@import { useState } from 'react';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import type { NotificationSettings } from '@/lib/api';+import type { NotificationSettings } from '@/lib/api/endpoints/notificationSettings';import { useUpdateNotificationSettings } from '@/services/teams.service';export interface TelegramForm {diff --git a/apps/web/src/features/teams/utils/agentForm.ts b/apps/web/src/features/teams/utils/agentForm.tsindex c661e562..2d2bd932 100644--- a/apps/web/src/features/teams/utils/agentForm.ts+++ b/apps/web/src/features/teams/utils/agentForm.ts@@ -1,4 +1,4 @@-import type { AgentTool, AiAgent, NewAiAgentInput, AiAgentPatch } from '@/lib/api';+import type { AgentTool, AiAgent, NewAiAgentInput, AiAgentPatch } from '@/lib/api/endpoints/agents';import { transliterate } from '@/utils/projectKey';// The editable shape of an agent form. temperature/maxSteps are kept as strings sodiff --git a/apps/web/src/features/teams/utils/rolesTransfer.ts b/apps/web/src/features/teams/utils/rolesTransfer.tsindex 9532a2c3..c04a94f0 100644--- a/apps/web/src/features/teams/utils/rolesTransfer.ts+++ b/apps/web/src/features/teams/utils/rolesTransfer.ts@@ -4,7 +4,7 @@// robust across catalog changes. The default role is never included — every team has// one of its own.-import type { PermissionCatalog, Permissions, Role } from '@/lib/api';+import type { PermissionCatalog, Permissions, Role } from '@/lib/api/endpoints/roles';import { matrixFromCatalog } from '@/utils/permissions';const PAYLOAD_TYPE = 'plan.roles';diff --git a/apps/web/src/features/whats-new/components/ReleaseHistory.tsx b/apps/web/src/features/whats-new/components/ReleaseHistory.tsxindex 7962c2c5..80b50295 100644--- a/apps/web/src/features/whats-new/components/ReleaseHistory.tsx+++ b/apps/web/src/features/whats-new/components/ReleaseHistory.tsx@@ -2,7 +2,7 @@import { useTranslations } from 'next-intl';import { ExternalLink, RefreshCw } from 'lucide-react';-import type { UpdateStatus } from '@/lib/api';+import type { UpdateStatus } from '@/lib/api/endpoints/updates';import TakeoverScreen from '@/components/common/page/TakeoverScreen';import { Button } from '@/components/ui/button';import { useCheckForUpdates } from '@/services/updates.service';diff --git a/apps/web/src/features/whats-new/components/ReleaseSections.tsx b/apps/web/src/features/whats-new/components/ReleaseSections.tsxindex 6a2a76b4..f7441aa3 100644--- a/apps/web/src/features/whats-new/components/ReleaseSections.tsx+++ b/apps/web/src/features/whats-new/components/ReleaseSections.tsx@@ -1,7 +1,7 @@'use client';import { useMemo } from 'react';-import type { Release } from '@/lib/api';+import type { Release } from '@/lib/api/endpoints/updates';import type { TakeoverSection } from '@/components/common/page/TakeoverScreen';import { renderMarkdown, sanitizeHtml } from '@/lib/markdown';import { isNewerVersion } from '@/utils/version';diff --git a/apps/web/src/features/whats-new/components/WhatsNewBackup.tsx b/apps/web/src/features/whats-new/components/WhatsNewBackup.tsxindex 38c9e537..0ed9b62d 100644--- a/apps/web/src/features/whats-new/components/WhatsNewBackup.tsx+++ b/apps/web/src/features/whats-new/components/WhatsNewBackup.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { BackupInfo } from '@/lib/api';+import type { BackupInfo } from '@/lib/api/endpoints/updates';import { formatDate } from '@/utils/dates';import CodeBlock from '@/components/common/CodeBlock';diff --git a/apps/web/src/features/whats-new/components/WhatsNewMigrationReport.tsx b/apps/web/src/features/whats-new/components/WhatsNewMigrationReport.tsxindex 8b594cdb..dd2e4fb2 100644--- a/apps/web/src/features/whats-new/components/WhatsNewMigrationReport.tsx+++ b/apps/web/src/features/whats-new/components/WhatsNewMigrationReport.tsx@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { TeamsMigrationReport } from '@/lib/api';+import type { TeamsMigrationReport } from '@/lib/api/endpoints/updates';import WhatsNewRenameGroup from './WhatsNewRenameGroup';// What the move to teams did to this instance's data: which projects landed in whichdiff --git a/apps/web/src/features/whats-new/components/WhatsNewOverlay.tsx b/apps/web/src/features/whats-new/components/WhatsNewOverlay.tsxindex 66eed320..169350ac 100644--- a/apps/web/src/features/whats-new/components/WhatsNewOverlay.tsx+++ b/apps/web/src/features/whats-new/components/WhatsNewOverlay.tsx@@ -2,7 +2,7 @@import { useTranslations } from 'next-intl';import { DatabaseBackup } from 'lucide-react';-import type { WhatsNew } from '@/lib/api';+import type { WhatsNew } from '@/lib/api/endpoints/updates';import TakeoverScreen, { type TakeoverSection } from '@/components/common/page/TakeoverScreen';import { releaseSections } from './ReleaseSections';import WhatsNewBackup from './WhatsNewBackup';diff --git a/apps/web/src/features/whats-new/services/whatsNew.service.ts b/apps/web/src/features/whats-new/services/whatsNew.service.tsindex e23c7247..4b00984b 100644--- a/apps/web/src/features/whats-new/services/whatsNew.service.ts+++ b/apps/web/src/features/whats-new/services/whatsNew.service.ts@@ -1,7 +1,7 @@'use client';import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getWhatsNew, markWhatsNewSeen } from '@/lib/api/endpoints/updates';import { useSession } from '@/lib/auth-client';import { qk } from '@/services/queryKeys';@@ -12,7 +12,7 @@ export function useWhatsNewQuery() {const { data: session } = useSession();return useQuery({queryKey: qk.whatsNew,- queryFn: () => api.getWhatsNew(),+ queryFn: () => getWhatsNew(),// The route needs a session; the login and invite screens have none.enabled: Boolean(session),staleTime: Infinity,@@ -22,7 +22,7 @@ export function useWhatsNewQuery() {export function useMarkWhatsNewSeen() {const qc = useQueryClient();return useMutation({- mutationFn: () => api.markWhatsNewSeen(),+ mutationFn: () => markWhatsNewSeen(),// The screen closes on click, so the write is not what the user waits for.onSuccess: () => qc.invalidateQueries({ queryKey: qk.whatsNew }),});diff --git a/apps/web/src/features/work-items/PublicBoardPage.tsx b/apps/web/src/features/work-items/PublicBoardPage.tsxindex 85e5445c..83b87162 100644--- a/apps/web/src/features/work-items/PublicBoardPage.tsx+++ b/apps/web/src/features/work-items/PublicBoardPage.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { useQuery } from '@tanstack/react-query';import { useTranslations } from 'next-intl';-import { api } from '@/lib/api';+import { getSharedView } from '@/lib/api/endpoints/share';import PublicShareFrame from '@/components/common/page/PublicShareFrame';import ListSkeleton from '@/components/common/skeleton/ListSkeleton';import ReadOnlyBoard from './components/public/ReadOnlyBoard';@@ -17,7 +17,7 @@ export default function PublicBoardPage({ token }: { token: string }) {const [openIssueId, setOpenIssueId] = useState<number | null>(null);const query = useQuery({queryKey: ['share', 'view', token],- queryFn: () => api.getSharedView(token),+ queryFn: () => getSharedView(token),retry: false,});diff --git a/apps/web/src/features/work-items/components/BoardLayout.tsx b/apps/web/src/features/work-items/components/BoardLayout.tsxindex 9a1efb30..8cc22fbc 100644--- a/apps/web/src/features/work-items/components/BoardLayout.tsx+++ b/apps/web/src/features/work-items/components/BoardLayout.tsx@@ -1,4 +1,4 @@-import type { BoardIssue } from '@/lib/api';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import type { WorkItemsViewProps } from '@/utils/project';import type { WorkItemsView } from '@/utils/viewTypes';import { withoutShownSubtasks } from '@/utils/subtasks';diff --git a/apps/web/src/features/work-items/components/calendar/CalendarDayCell.tsx b/apps/web/src/features/work-items/components/calendar/CalendarDayCell.tsxindex c49cd5c5..cf1888ff 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarDayCell.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarDayCell.tsx@@ -1,5 +1,6 @@import { useDroppable } from '@dnd-kit/core';-import { type ProjectDetail, type Issue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { cn } from '@/lib/utils';import { CalendarDayChip } from './CalendarDayChip';import { CalendarDayOverflow } from './CalendarDayOverflow';diff --git a/apps/web/src/features/work-items/components/calendar/CalendarDayChip.tsx b/apps/web/src/features/work-items/components/calendar/CalendarDayChip.tsxindex 68385dc3..acd6507c 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarDayChip.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarDayChip.tsx@@ -1,5 +1,6 @@import { useDraggable } from '@dnd-kit/core';-import { type ProjectDetail, type Issue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { useIsPhone } from '@/hooks/useIsPhone';import { usePermissions } from '@/hooks/usePermissions';import { cn } from '@/lib/utils';diff --git a/apps/web/src/features/work-items/components/calendar/CalendarDayOverflow.tsx b/apps/web/src/features/work-items/components/calendar/CalendarDayOverflow.tsxindex b2b096b7..30a6fd2e 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarDayOverflow.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarDayOverflow.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';diff --git a/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledCard.tsx b/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledCard.tsxindex 3e5b58e1..02fc76fa 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledCard.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledCard.tsx@@ -1,5 +1,6 @@import { useDraggable } from '@dnd-kit/core';-import { type ProjectDetail, type Issue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { useIsPhone } from '@/hooks/useIsPhone';import { usePermissions } from '@/hooks/usePermissions';import { cn } from '@/lib/utils';diff --git a/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledPanel.tsx b/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledPanel.tsxindex 02610f56..10b3c047 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledPanel.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarUnscheduledPanel.tsx@@ -1,6 +1,7 @@import { useDroppable } from '@dnd-kit/core';import { useTranslations } from 'next-intl';-import { type ProjectDetail, type Issue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { cn } from '@/lib/utils';import { isCustomFieldKey, type DateField } from '@/utils/viewSettings';import { CalendarUnscheduledCard } from './CalendarUnscheduledCard';diff --git a/apps/web/src/features/work-items/components/calendar/CalendarView.tsx b/apps/web/src/features/work-items/components/calendar/CalendarView.tsxindex a2d44052..8ee1bd91 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarView.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarView.tsx@@ -8,7 +8,7 @@ import {type DragStartEvent,} from '@dnd-kit/core';import { useTranslations } from 'next-intl';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';import { buildMaps, issueColor, type WorkItemsViewProps } from '@/utils/project';import { toDateStr } from '@/utils/dates';import { useDndSensors } from '@/lib/dnd';diff --git a/apps/web/src/features/work-items/components/kanban/BoardCard.tsx b/apps/web/src/features/work-items/components/kanban/BoardCard.tsxindex 3810e20d..73bcdc13 100644--- a/apps/web/src/features/work-items/components/kanban/BoardCard.tsx+++ b/apps/web/src/features/work-items/components/kanban/BoardCard.tsx@@ -1,7 +1,8 @@import { useRef } from 'react';import { useDndContext, useDraggable } from '@dnd-kit/core';import { DRAG_ACTIVATION_DISTANCE } from '@/lib/dnd';-import { type ProjectDetail, type BoardIssue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { useIsPhone } from '@/hooks/useIsPhone';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/work-items/components/kanban/BoardColumn.tsx b/apps/web/src/features/work-items/components/kanban/BoardColumn.tsxindex 86a3fbf2..04ab51a8 100644--- a/apps/web/src/features/work-items/components/kanban/BoardColumn.tsx+++ b/apps/web/src/features/work-items/components/kanban/BoardColumn.tsx@@ -3,7 +3,8 @@ import { useDroppable } from '@dnd-kit/core';import { useVirtualizer } from '@tanstack/react-virtual';import { ChevronsRightLeft, EyeOff, Pin, PinOff, Plus } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type ProjectDetail, type BoardIssue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import { type Maps, type IssueGroup } from '@/utils/project';import { cn } from '@/lib/utils';import type { PropertyKey } from '@/utils/viewSettings';diff --git a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsxindex 6cd9ee55..163ffb44 100644--- a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx+++ b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx@@ -3,7 +3,7 @@import { useState } from 'react';import { Archive, Bot, CircleDashed, RefreshCw, Tag, Target, Trash2, User, X } from 'lucide-react';import { useTranslations } from 'next-intl';-import { type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { usePermissions } from '@/hooks/usePermissions';import { usePriorityLabel } from '@/hooks/usePriorityLabel';import { useInitiativeOptionsQuery } from '@/services/initiatives.service';diff --git a/apps/web/src/features/work-items/components/kanban/BulkRemovalDialog.tsx b/apps/web/src/features/work-items/components/kanban/BulkRemovalDialog.tsxindex 2924ac8f..f0f20447 100644--- a/apps/web/src/features/work-items/components/kanban/BulkRemovalDialog.tsx+++ b/apps/web/src/features/work-items/components/kanban/BulkRemovalDialog.tsx@@ -2,7 +2,7 @@import { useState } from 'react';import { useTranslations } from 'next-intl';-import { type SubtaskDisposition } from '@/lib/api';+import type { SubtaskDisposition } from '@/lib/api/endpoints/issues';import { dispositionReady } from '@/utils/subtasks';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import SubtaskDisposalChoice from '@/features/issue/components/actions/SubtaskDisposalChoice';diff --git a/apps/web/src/features/work-items/components/kanban/CardOverlay.tsx b/apps/web/src/features/work-items/components/kanban/CardOverlay.tsxindex b8560d6b..8bfc42c9 100644--- a/apps/web/src/features/work-items/components/kanban/CardOverlay.tsx+++ b/apps/web/src/features/work-items/components/kanban/CardOverlay.tsx@@ -1,5 +1,5 @@import { DragOverlay } from '@dnd-kit/core';-import { type BoardIssue } from '@/lib/api';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import type { PropertyKey } from '@/utils/viewSettings';import { Badge } from '@/components/ui/badge';diff --git a/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx b/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsxindex 5461ee8f..e670a483 100644--- a/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx+++ b/apps/web/src/features/work-items/components/kanban/IssueCardBody.tsx@@ -8,7 +8,7 @@ import {Timer,} from 'lucide-react';import { useTranslations } from 'next-intl';-import { type BoardIssue } from '@/lib/api';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { cn } from '@/lib/utils';import { formatDurationShort, formatShortDate, isDueOverdue } from '@/utils/dates';diff --git a/apps/web/src/features/work-items/components/kanban/IssueCardLinks.tsx b/apps/web/src/features/work-items/components/kanban/IssueCardLinks.tsxindex 59c14d28..579efb7a 100644--- a/apps/web/src/features/work-items/components/kanban/IssueCardLinks.tsx+++ b/apps/web/src/features/work-items/components/kanban/IssueCardLinks.tsx@@ -1,4 +1,4 @@-import { type IssueLinkRef } from '@/lib/api';+import type { IssueLinkRef } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { cn } from '@/lib/utils';import { LINK_RELATION_ICONS } from '@/utils/issueLinks';diff --git a/apps/web/src/features/work-items/components/kanban/SwimlaneBoard.tsx b/apps/web/src/features/work-items/components/kanban/SwimlaneBoard.tsxindex 4a6ceb92..8d45ffad 100644--- a/apps/web/src/features/work-items/components/kanban/SwimlaneBoard.tsx+++ b/apps/web/src/features/work-items/components/kanban/SwimlaneBoard.tsx@@ -3,7 +3,7 @@ import { DndContext } from '@dnd-kit/core';import { toast } from 'sonner';import { useVirtualizer } from '@tanstack/react-virtual';import { ChevronDown, ChevronRight } from 'lucide-react';-import { type BoardIssue, type Issue } from '@/lib/api';+import type { BoardIssue, Issue } from '@/lib/api/endpoints/issues';import {buildGroups,buildMaps,diff --git a/apps/web/src/features/work-items/components/kanban/SwimlaneCell.tsx b/apps/web/src/features/work-items/components/kanban/SwimlaneCell.tsxindex 2b924607..92adb42a 100644--- a/apps/web/src/features/work-items/components/kanban/SwimlaneCell.tsx+++ b/apps/web/src/features/work-items/components/kanban/SwimlaneCell.tsx@@ -1,5 +1,6 @@import { useDroppable } from '@dnd-kit/core';-import { type ProjectDetail, type BoardIssue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { cn } from '@/lib/utils';import type { PropertyKey } from '@/utils/viewSettings';diff --git a/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx b/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsxindex 773dd25f..e6591daf 100644--- a/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx+++ b/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx@@ -2,7 +2,7 @@import { useQuery } from '@tanstack/react-query';import { useTranslations } from 'next-intl';-import { api } from '@/lib/api';+import { getSharedViewIssue } from '@/lib/api/endpoints/share';import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';import IssueDetailSkeleton from '@/features/issue/components/detail/IssueDetailSkeleton';import ReadOnlyIssueDetail from '@/features/issue/components/detail/ReadOnlyIssueDetail';@@ -31,7 +31,7 @@ export default function PublicIssueOverlay({const t = useTranslations('workItems.share');const query = useQuery({queryKey: ['share', 'view', token, 'issue', issueId],- queryFn: () => api.getSharedViewIssue(token, issueId as number),+ queryFn: () => getSharedViewIssue(token, issueId as number),enabled: issueId != null,retry: false,});diff --git a/apps/web/src/features/work-items/components/public/ReadOnlyBoard.tsx b/apps/web/src/features/work-items/components/public/ReadOnlyBoard.tsxindex 806ad15e..d4c5bf0b 100644--- a/apps/web/src/features/work-items/components/public/ReadOnlyBoard.tsx+++ b/apps/web/src/features/work-items/components/public/ReadOnlyBoard.tsx@@ -1,4 +1,4 @@-import { type SharedViewBundle } from '@/lib/api';+import type { SharedViewBundle } from '@/lib/api/endpoints/share';import { defaultViewSettings } from '@/utils/viewSettings';import { EMPTY_FILTER_SET } from '@/utils/filters';import { type WorkItemsViewProps } from '@/utils/project';diff --git a/apps/web/src/features/work-items/components/shared/IssueDragOverlay.tsx b/apps/web/src/features/work-items/components/shared/IssueDragOverlay.tsxindex 83bb3972..7221439e 100644--- a/apps/web/src/features/work-items/components/shared/IssueDragOverlay.tsx+++ b/apps/web/src/features/work-items/components/shared/IssueDragOverlay.tsx@@ -1,5 +1,5 @@import { DragOverlay } from '@dnd-kit/core';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';// The card that follows the pointer while a row is dragged, in the table and on// the timeline. The row itself stays in place, faded, so the drag reads asdiff --git a/apps/web/src/features/work-items/components/shared/IssueIdentifier.tsx b/apps/web/src/features/work-items/components/shared/IssueIdentifier.tsxindex 7b4e9243..f9bff632 100644--- a/apps/web/src/features/work-items/components/shared/IssueIdentifier.tsx+++ b/apps/web/src/features/work-items/components/shared/IssueIdentifier.tsx@@ -1,5 +1,5 @@import { ChevronRight } from 'lucide-react';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';import { cn } from '@/lib/utils';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';import { useParentIssue } from '../../context/useSubtasks';diff --git a/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx b/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsxindex feda3783..6981041a 100644--- a/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx+++ b/apps/web/src/features/work-items/components/table/TableBuiltinCell.tsx@@ -1,5 +1,5 @@import { CalendarClock } from 'lucide-react';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { formatDurationShort, formatShortDate, isDueOverdue } from '@/utils/dates';import { formatMinutes } from '@/utils/estimate';diff --git a/apps/web/src/features/work-items/components/table/TableCustomCell.tsx b/apps/web/src/features/work-items/components/table/TableCustomCell.tsxindex a4f5cba3..133ceb1a 100644--- a/apps/web/src/features/work-items/components/table/TableCustomCell.tsx+++ b/apps/web/src/features/work-items/components/table/TableCustomCell.tsx@@ -1,5 +1,6 @@import { Check, ExternalLink } from 'lucide-react';-import { type CustomField, type Issue } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Issue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { formatDateTimeRange, formatShortDate } from '@/utils/dates';import Avatar from '@/components/common/Avatar';diff --git a/apps/web/src/features/work-items/components/table/TableRow.tsx b/apps/web/src/features/work-items/components/table/TableRow.tsxindex 3c8c8e26..a7cb91f5 100644--- a/apps/web/src/features/work-items/components/table/TableRow.tsx+++ b/apps/web/src/features/work-items/components/table/TableRow.tsx@@ -1,6 +1,7 @@import { useCallback } from 'react';import { useDndContext, useDraggable, useDroppable } from '@dnd-kit/core';-import { type ProjectDetail, type BoardIssue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { useIsPhone } from '@/hooks/useIsPhone';import { usePermissions } from '@/hooks/usePermissions';diff --git a/apps/web/src/features/work-items/components/table/TableRowLinks.tsx b/apps/web/src/features/work-items/components/table/TableRowLinks.tsxindex 08097bd2..7e8e5493 100644--- a/apps/web/src/features/work-items/components/table/TableRowLinks.tsx+++ b/apps/web/src/features/work-items/components/table/TableRowLinks.tsx@@ -1,4 +1,4 @@-import { type IssueLinkRef } from '@/lib/api';+import type { IssueLinkRef } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { cn } from '@/lib/utils';import { useLinkRelationLabel } from '@/hooks/useLinkRelationLabel';diff --git a/apps/web/src/features/work-items/components/timeline/TimelineBar.tsx b/apps/web/src/features/work-items/components/timeline/TimelineBar.tsxindex e5f1de22..ef9cc68d 100644--- a/apps/web/src/features/work-items/components/timeline/TimelineBar.tsx+++ b/apps/web/src/features/work-items/components/timeline/TimelineBar.tsx@@ -1,5 +1,5 @@import { useTranslations } from 'next-intl';-import { type BoardIssue, type Issue } from '@/lib/api';+import type { BoardIssue, Issue } from '@/lib/api/endpoints/issues';import { isBlocked } from '@/utils/issueLinks';import { cn } from '@/lib/utils';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';diff --git a/apps/web/src/features/work-items/components/timeline/TimelineIssueRow.tsx b/apps/web/src/features/work-items/components/timeline/TimelineIssueRow.tsxindex 966afd7b..7d6cd2b0 100644--- a/apps/web/src/features/work-items/components/timeline/TimelineIssueRow.tsx+++ b/apps/web/src/features/work-items/components/timeline/TimelineIssueRow.tsx@@ -1,5 +1,6 @@import { useDraggable } from '@dnd-kit/core';-import { type BoardIssue, type ProjectDetail, type Issue } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue, Issue } from '@/lib/api/endpoints/issues';import { type Maps } from '@/utils/project';import { useIsPhone } from '@/hooks/useIsPhone';import { cn } from '@/lib/utils';diff --git a/apps/web/src/features/work-items/components/timeline/TimelineLinkRows.tsx b/apps/web/src/features/work-items/components/timeline/TimelineLinkRows.tsxindex 8b728499..7ba5387a 100644--- a/apps/web/src/features/work-items/components/timeline/TimelineLinkRows.tsx+++ b/apps/web/src/features/work-items/components/timeline/TimelineLinkRows.tsx@@ -1,4 +1,4 @@-import { type IssueLinkRef } from '@/lib/api';+import type { IssueLinkRef } from '@/lib/api/endpoints/issues';import { issueColor, type Maps } from '@/utils/project';import { cn } from '@/lib/utils';import { useLinkRelationLabel } from '@/hooks/useLinkRelationLabel';diff --git a/apps/web/src/features/work-items/context/useIssueLinks.tsx b/apps/web/src/features/work-items/context/useIssueLinks.tsxindex 1ee5a71e..49149b6b 100644--- a/apps/web/src/features/work-items/context/useIssueLinks.tsx+++ b/apps/web/src/features/work-items/context/useIssueLinks.tsx@@ -1,7 +1,7 @@'use client';import { createContext, useContext, useMemo, type ReactNode } from 'react';-import { type Issue, type IssueLinkInputKind, type IssueLinkRef } from '@/lib/api';+import type { Issue, IssueLinkInputKind, IssueLinkRef } from '@/lib/api/endpoints/issues';import { LINK_RELATIONS } from '@/utils/issueLinks';// One relation as a card or a table row shows it: how it reads from the issue itdiff --git a/apps/web/src/features/work-items/context/useSubtasks.tsx b/apps/web/src/features/work-items/context/useSubtasks.tsxindex 20bafcb7..4089e708 100644--- a/apps/web/src/features/work-items/context/useSubtasks.tsx+++ b/apps/web/src/features/work-items/context/useSubtasks.tsx@@ -1,7 +1,7 @@'use client';import { createContext, useContext, useMemo, type ReactNode } from 'react';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';// A subtask never shows as a card or a row of its own: it is rendered under its// parent, the way a relation is. The layouts read the project's issues before thediff --git a/apps/web/src/features/work-items/hooks/useApplyAssign.ts b/apps/web/src/features/work-items/hooks/useApplyAssign.tsindex 8690909e..e3791593 100644--- a/apps/web/src/features/work-items/hooks/useApplyAssign.ts+++ b/apps/web/src/features/work-items/hooks/useApplyAssign.ts@@ -1,4 +1,4 @@-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import type { GroupAssign } from '@/utils/project';import { memberFieldValue } from '@/utils/memberFields';import { useSetFieldValue, useUpdateIssue } from '@/services/issues.service';diff --git a/apps/web/src/features/work-items/hooks/useBoardDnd.ts b/apps/web/src/features/work-items/hooks/useBoardDnd.tsindex 9eca6a4d..d6b2a95b 100644--- a/apps/web/src/features/work-items/hooks/useBoardDnd.ts+++ b/apps/web/src/features/work-items/hooks/useBoardDnd.ts@@ -1,6 +1,6 @@import { useState } from 'react';import { type DragEndEvent, type DragStartEvent } from '@dnd-kit/core';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import { useDndSensors } from '@/lib/dnd';import { draggedIds, type BoardDropData } from '../utils/kanban';import { useApplyAssign } from './useApplyAssign';diff --git a/apps/web/src/features/work-items/hooks/useBulkActions.ts b/apps/web/src/features/work-items/hooks/useBulkActions.tsindex ba130a0f..17765273 100644--- a/apps/web/src/features/work-items/hooks/useBulkActions.ts+++ b/apps/web/src/features/work-items/hooks/useBulkActions.ts@@ -1,4 +1,5 @@-import { type BulkIssuePatch, type ProjectDetail, type SubtaskDisposition } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BulkIssuePatch, SubtaskDisposition } from '@/lib/api/endpoints/issues';import {useBulkAddLabels,useBulkArchiveIssues,diff --git a/apps/web/src/features/work-items/hooks/useIncomingCount.ts b/apps/web/src/features/work-items/hooks/useIncomingCount.tsindex c18465d9..a307eaab 100644--- a/apps/web/src/features/work-items/hooks/useIncomingCount.ts+++ b/apps/web/src/features/work-items/hooks/useIncomingCount.ts@@ -1,5 +1,5 @@import { useDndContext } from '@dnd-kit/core';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';import { type IssueGroup } from '@/utils/project';import { draggedIds } from '../utils/kanban';import { countEntering } from '../utils/wipLimit';diff --git a/apps/web/src/features/work-items/hooks/useIsOverContainer.ts b/apps/web/src/features/work-items/hooks/useIsOverContainer.tsindex 316416d5..dddf90ad 100644--- a/apps/web/src/features/work-items/hooks/useIsOverContainer.ts+++ b/apps/web/src/features/work-items/hooks/useIsOverContainer.ts@@ -1,5 +1,5 @@import { useDndContext } from '@dnd-kit/core';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';// Whether a drag is over a card container (a board column or a swimlane cell).// Collision detection prefers a card over its container, so the container's owndiff --git a/apps/web/src/features/work-items/hooks/useIssueReorder.ts b/apps/web/src/features/work-items/hooks/useIssueReorder.tsindex dd946fc9..58335443 100644--- a/apps/web/src/features/work-items/hooks/useIssueReorder.ts+++ b/apps/web/src/features/work-items/hooks/useIssueReorder.ts@@ -1,7 +1,8 @@import { useState } from 'react';import { type DragEndEvent, type DragStartEvent } from '@dnd-kit/core';import { toast } from 'sonner';-import { type Issue, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { positionsAt, type GroupAssign } from '@/utils/project';import { useDndSensors } from '@/lib/dnd';import type { Sort } from '@/utils/viewTypes';diff --git a/apps/web/src/features/work-items/hooks/useTimelineDrag.ts b/apps/web/src/features/work-items/hooks/useTimelineDrag.tsindex 2bd5a340..b724c98e 100644--- a/apps/web/src/features/work-items/hooks/useTimelineDrag.ts+++ b/apps/web/src/features/work-items/hooks/useTimelineDrag.ts@@ -1,5 +1,6 @@import { useState } from 'react';-import { type Issue, type IssuePatch, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue, IssuePatch } from '@/lib/api/endpoints/issues';import { addDays, toDateStr } from '@/utils/dates';import { useUpdateIssue } from '@/services/issues.service';import { effSpan } from '../utils/timeline';diff --git a/apps/web/src/features/work-items/utils/calendar.ts b/apps/web/src/features/work-items/utils/calendar.tsindex ec3a823a..b69b577d 100644--- a/apps/web/src/features/work-items/utils/calendar.ts+++ b/apps/web/src/features/work-items/utils/calendar.ts@@ -1,5 +1,6 @@import { addDays, startOfMonth, startOfWeek } from 'date-fns';-import { type CustomField, type Issue } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Issue } from '@/lib/api/endpoints/issues';import { issueDay } from '@/utils/calendarFields';import type { BuiltinDateField, ViewSettings } from '@/utils/viewSettings';diff --git a/apps/web/src/features/work-items/utils/kanban.ts b/apps/web/src/features/work-items/utils/kanban.tsindex 97f1dc8e..be308106 100644--- a/apps/web/src/features/work-items/utils/kanban.ts+++ b/apps/web/src/features/work-items/utils/kanban.ts@@ -1,5 +1,5 @@import { type Active } from '@dnd-kit/core';-import { type Issue } from '@/lib/api';+import type { Issue } from '@/lib/api/endpoints/issues';import { preferPrefix } from './dnd';// What a board drop target does with the dropped issues. A board drag carriesdiff --git a/apps/web/src/features/work-items/utils/table.ts b/apps/web/src/features/work-items/utils/table.tsindex bc980493..0245cab1 100644--- a/apps/web/src/features/work-items/utils/table.ts+++ b/apps/web/src/features/work-items/utils/table.ts@@ -1,4 +1,5 @@-import { type BoardIssue, type CustomField, type Issue } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { BoardIssue, Issue } from '@/lib/api/endpoints/issues';import {groupIssues,mergeAssign,diff --git a/apps/web/src/features/work-items/utils/timeline.ts b/apps/web/src/features/work-items/utils/timeline.tsindex b3eae6f0..89164c62 100644--- a/apps/web/src/features/work-items/utils/timeline.ts+++ b/apps/web/src/features/work-items/utils/timeline.ts@@ -1,5 +1,6 @@import { startOfDay } from 'date-fns';-import { type BoardIssue, type Issue, type ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue, Issue } from '@/lib/api/endpoints/issues';import { parseDate } from '@/utils/dates';import type { FilterSet } from '@/utils/filters';import { buildDayTrack, type DayTrack } from '@/utils/timelineTrack';diff --git a/apps/web/src/features/work-items/utils/wipLimit.ts b/apps/web/src/features/work-items/utils/wipLimit.tsindex 53252867..d3047cd3 100644--- a/apps/web/src/features/work-items/utils/wipLimit.ts+++ b/apps/web/src/features/work-items/utils/wipLimit.ts@@ -1,4 +1,4 @@-import { type Column, type WipMode } from '@/lib/api';+import type { Column, WipMode } from '@/lib/api/endpoints/columns';import { type IssueGroup } from '@/utils/project';// A column's work-in-progress limit as the board reads it.diff --git a/apps/web/src/hooks/useAgentChat.ts b/apps/web/src/hooks/useAgentChat.tsindex 1be6d585..fdd210b6 100644--- a/apps/web/src/hooks/useAgentChat.ts+++ b/apps/web/src/hooks/useAgentChat.ts@@ -1,8 +1,9 @@'use client';import { useCallback, useEffect, useRef, useState } from 'react';-import { ApiError, streamAiAgentChat, streamAiAgentRun } from '@/lib/api';-import type { AiChatMessage, AiChatPart, AiChatToolPart } from '@/lib/api';+import { streamAiAgentChat, streamAiAgentRun } from '@/lib/api/endpoints/agentChat';+import { ApiError } from '@/lib/api/core/client';+import type { AiChatMessage, AiChatPart, AiChatToolPart } from '@/lib/api/endpoints/agentChat';import { uuid } from '@/utils/uuid';import { useTranslations } from 'next-intl';diff --git a/apps/web/src/hooks/useAppCommands.tsx b/apps/web/src/hooks/useAppCommands.tsxindex a0962967..6506bbc3 100644--- a/apps/web/src/hooks/useAppCommands.tsx+++ b/apps/web/src/hooks/useAppCommands.tsx@@ -1,5 +1,5 @@import { LayoutGrid, ListChecks, MessagesSquare, Plus, SquarePlus, Target } from 'lucide-react';-import type { Project } from '@/lib/api';+import type { Project } from '@/lib/api/endpoints/projects';import { useTranslations } from 'next-intl';import { VIEWS, type WorkItemsView } from '@/utils/viewTypes';import { byKey } from '@/utils/messageKey';diff --git a/apps/web/src/hooks/useFeatureLabel.ts b/apps/web/src/hooks/useFeatureLabel.tsindex 9586cf21..4ac3767b 100644--- a/apps/web/src/hooks/useFeatureLabel.ts+++ b/apps/web/src/hooks/useFeatureLabel.ts@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { ProjectFeatures } from '@/lib/api';+import type { ProjectFeatures } from '@/lib/api/endpoints/settings';// What each optional section is called. Shared by the switches that turn a section// off, their confirmation, and the notice the section shows while it is off, so itdiff --git a/apps/web/src/hooks/useFilterFields.ts b/apps/web/src/hooks/useFilterFields.tsindex 51dd9e01..2040c476 100644--- a/apps/web/src/hooks/useFilterFields.ts+++ b/apps/web/src/hooks/useFilterFields.ts@@ -1,13 +1,10 @@'use client';import { useTranslations } from 'next-intl';-import type {- CustomField,- InitiativeOption,- InitiativeRef,- MemberScope,- ProjectDetail,-} from '@/lib/api';+import type { CustomField, MemberScope } from '@/lib/api/endpoints/customFields';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { InitiativeRef } from '@/lib/api/endpoints/issues';+import type { InitiativeOption } from '@/lib/api/endpoints/initiatives';import { useInitiativeOptionsQuery } from '@/services/initiatives.service';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { formatDate } from '@/utils/dates';diff --git a/apps/web/src/hooks/useInboxUnread.ts b/apps/web/src/hooks/useInboxUnread.tsindex a8a1e3d3..c74761c7 100644--- a/apps/web/src/hooks/useInboxUnread.ts+++ b/apps/web/src/hooks/useInboxUnread.ts@@ -1,5 +1,5 @@import { useQuery } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getUnreadCount } from '@/lib/api/endpoints/notifications';import { qk } from '@/services/queryKeys';import { revScope } from '@/utils/revScopes';import { useLiveRefresh } from './useLiveRefresh';@@ -15,7 +15,7 @@ export function useInboxUnread(projectKey: string | null, projectId: number | nu});return useQuery({queryKey: qk.notificationsUnread(projectKey ?? ''),- queryFn: () => api.getUnreadCount(projectId as number),+ queryFn: () => getUnreadCount(projectId as number),enabled: projectKey != null && projectId != null,select: (d) => d.unread,});diff --git a/apps/web/src/hooks/useLinkRelationLabel.ts b/apps/web/src/hooks/useLinkRelationLabel.tsindex 47038e29..d7e16bc0 100644--- a/apps/web/src/hooks/useLinkRelationLabel.ts+++ b/apps/web/src/hooks/useLinkRelationLabel.ts@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { IssueLinkInputKind } from '@/lib/api';+import type { IssueLinkInputKind } from '@/lib/api/endpoints/issues';// How one issue relates to another, named for the reader. Used wherever a// relation is listed: the issue detail panel, the board cards, the table and thediff --git a/apps/web/src/hooks/usePaging.ts b/apps/web/src/hooks/usePaging.tsindex 8adc184c..94e93e05 100644--- a/apps/web/src/hooks/usePaging.ts+++ b/apps/web/src/hooks/usePaging.ts@@ -1,7 +1,7 @@'use client';import { useCallback, useState } from 'react';-import type { PageParams } from '@/lib/api';+import type { PageParams } from '@/lib/api/core/paging';// What a paged list opens with, until the reader picks another size.export const DEFAULT_PAGE_SIZE = 10;diff --git a/apps/web/src/hooks/usePermissionLabels.ts b/apps/web/src/hooks/usePermissionLabels.tsindex c0bc21b8..cc834574 100644--- a/apps/web/src/hooks/usePermissionLabels.ts+++ b/apps/web/src/hooks/usePermissionLabels.ts@@ -1,7 +1,7 @@'use client';import { useTranslations } from 'next-intl';-import type { PermissionAction, PermissionResource } from '@/lib/api';+import type { PermissionAction, PermissionResource } from '@/lib/api/endpoints/roles';// The labels of the permission matrix: one resource, one action, one display group.// A key the messages do not carry (a resource added on the API) falls back to itsdiff --git a/apps/web/src/hooks/usePermissions.ts b/apps/web/src/hooks/usePermissions.tsindex d872792d..7ce133b1 100644--- a/apps/web/src/hooks/usePermissions.ts+++ b/apps/web/src/hooks/usePermissions.ts@@ -1,6 +1,7 @@import { useCallback, useContext } from 'react';import { ShellCtx } from '@/context/shellContext';-import type { PermissionAction, PermissionResource, ProjectDetail } from '@/lib/api';+import type { PermissionAction, PermissionResource } from '@/lib/api/endpoints/roles';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';// The current user's effective access in the active project, read from the payload// the Shell loads (project.viewer). Owners bypass the matrix (can everything); adiff --git a/apps/web/src/hooks/useProjectRouteSync.ts b/apps/web/src/hooks/useProjectRouteSync.tsindex c23f79cc..3e87552d 100644--- a/apps/web/src/hooks/useProjectRouteSync.ts+++ b/apps/web/src/hooks/useProjectRouteSync.ts@@ -1,6 +1,6 @@import { useEffect, useRef } from 'react';import { useRouter } from 'next/navigation';-import type { Project } from '@/lib/api';+import type { Project } from '@/lib/api/endpoints/projects';import { projectPath } from '@/utils/paths';import {useAccountPreferencesQuery,diff --git a/apps/web/src/hooks/useSettingsNavGroups.ts b/apps/web/src/hooks/useSettingsNavGroups.tsindex eda92213..c8fbbbd7 100644--- a/apps/web/src/hooks/useSettingsNavGroups.ts+++ b/apps/web/src/hooks/useSettingsNavGroups.ts@@ -10,7 +10,7 @@ import {} from '@/utils/settingsSections';import { usePermissions } from '@/hooks/usePermissions';import { useSettingsSectionText } from '@/hooks/useSectionLabels';-import type { ProjectDetail } from '@/lib/api';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';// The project settings sidebar (the "Project settings" mode) lists the// Configuration sections flat under group labels. This hook builds those groupsdiff --git a/apps/web/src/hooks/useShellProject.ts b/apps/web/src/hooks/useShellProject.tsindex 3bc701f6..51c3daf5 100644--- a/apps/web/src/hooks/useShellProject.ts+++ b/apps/web/src/hooks/useShellProject.ts@@ -7,7 +7,7 @@ import {} from '@/services/projects.service';import { useViewsQuery } from '@/services/views.service';import { useCycleOptionsQuery } from '@/services/cycles.service';-import { ApiError } from '@/lib/api';+import { ApiError } from '@/lib/api/core/client';import { applyFilters } from '@/utils/filters';import { withoutShownSubtasks } from '@/utils/subtasks';import { viewPath } from '@/utils/paths';diff --git a/apps/web/src/hooks/useViewEditor.ts b/apps/web/src/hooks/useViewEditor.tsindex 3b7c381a..220c25a9 100644--- a/apps/web/src/hooks/useViewEditor.ts+++ b/apps/web/src/hooks/useViewEditor.ts@@ -1,5 +1,5 @@import { useEffect, useMemo, useRef, useState } from 'react';-import type { View } from '@/lib/api';+import type { View } from '@/lib/api/endpoints/views';import type { WorkItemsView } from '@/utils/viewTypes';import {normalizeView,diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.tsdeleted file mode 100644index 8eec33ac..00000000--- a/apps/web/src/lib/api.ts+++ /dev/null@@ -1,4535 +0,0 @@-// Typed client for the planner API (apps/api/src/planner). Row shapes mirror the-// store DTOs. The API is a separate service; the browser reaches it at the API-// origin below. The planner routes require a better-auth session, so every-// request sends credentials (the session cookie).--import type { Locale } from '@/i18n/locales';-import type { FilterSet } from '@/utils/filters';-import type { SavedViewDisplay } from '@/utils/viewSettings';-import type { DashboardLayout, BreakdownBy } from '@/utils/dashboardWidgets';-import { runtimeEnv } from '@/utils/runtimeEnv';--// The API origin, read from the running server rather than from the build (see-// utils/runtimeEnv). A deployment without it ships a client that cannot reach the-// API. Fail at import instead of pointing at a wrong origin.-export const API_URL = runtimeEnv().apiUrl;-if (!API_URL) throw new Error('API_URL is not set on the web service');--// Points a relative media path (a stored avatar or attachment URL) at the web-// origin's media route (app/media), which streams it from the API. Leaves an-// absolute URL — an embed stored before this, or an external image — untouched.-export function mediaUrl(url: string): string {- return url.startsWith('http') ? url : `/media${url}`;-}--// An error carrying the HTTP status so callers can tell apart 401 (no session),-// 403 (no access to the project / not owner), 404 (not found) and 400 (a-// validation or business-rule failure). `message` is the API's `{ error }` text-// when present, so existing consumers that read `error.message` keep working.-// `code` names the failure where the API sends one, for a caller that has to-// branch on it rather than show the message.-export class ApiError extends Error {- constructor(- readonly status: number,- message: string,- readonly code?: string,- ) {- super(message);- this.name = 'ApiError';- }-}--// Set while the session is being dropped, by the sign-out below or by the app's own-// `signOut`. Concurrent requests that all fail with 401 then trigger a single-// sign-out and a single navigation, and a sign-out the person asked for does not-// end on the expired screen.-let signingOut = false;--// Called by `signOut` in @/lib/auth-client before it drops the session: the requests-// that fail right after are the expected fallout, not a session the API refused.-export function markSigningOut(): void {- signingOut = true;-}--// Called by SessionScope once a session appears without a page load, so a later 401-// is reacted to again. An accepted request does not prove one: /auth-config and the-// invite and share reads answer without a session.-export function markSignedIn(): void {- signingOut = false;-}--// A 401 means the session behind the cookie is gone. The proxy only checks that a-// session cookie exists, so a stale one keeps the app open on a page where every-// request fails. Sign out to drop the cookie, then leave for the expired screen-// whatever the sign-out answered — a cookie the server declines to clear must not-// hold the browser in the app.-// The request is written out rather than calling `signOut()` from @/lib/auth-client:-// that module reads API_URL from this one, so importing it back here would make a-// cycle that evaluates auth-client before API_URL is assigned.-function endSession(): void {- if (typeof window === 'undefined' || signingOut) return;- signingOut = true;- void fetch(`${API_URL}/api/auth/sign-out`, { method: 'POST', credentials: 'include' })- .catch(() => {})- .then(() => window.location.replace('/login?expired=1'));-}--// Turns a failed response into the error to throw, and catches an ended session on-// the way. Every request in this module reports its failure through here.-export async function apiFailure(res: Response): Promise<ApiError> {- const body = await res.json().catch(() => null);- if (res.status === 401) endSession();- return new ApiError(res.status, body?.error ?? `${res.status} ${res.statusText}`, body?.code);-}--async function request<T>(path: string, init?: RequestInit): Promise<T> {- const res = await fetch(`${API_URL}${path}`, {- ...init,- // Send the better-auth session cookie to the API (separate origin).- credentials: 'include',- // Never serve API reads from the HTTP cache — React Query owns caching, and a- // browser-cached GET can return stale data after a mutation refetch.- cache: 'no-store',- headers: {- 'Content-Type': 'application/json',- ...init?.headers,- },- });- if (!res.ok) throw await apiFailure(res);- if (res.status === 204) return undefined as T;- return res.json();-}--// Paging. A list route either pages or answers with the whole list, never both, so a-// paged read always names its window and a whole-list read is a call of its own-// (listSkillOptions, listConfiguredToolOptions, listNoteBoards, ...).-export interface PageParams {- page: number;- pageSize: number;-}--// One page of a list, with how many rows match in total.-export interface Page<T> {- items: T[];- total: number;- page: number;- pageSize: number;-}--// The next page of a list read as "show more": there is one while the pages loaded so-// far do not cover the total. What every useInfiniteQuery over a paged route passes as-// getNextPageParam.-export function nextPageParam<T>(last: Page<T>): number | undefined {- return last.page * last.pageSize < last.total ? last.page + 1 : undefined;-}--// The query string a paged read takes: the window, plus whatever filters the list-// narrows by. A filter left empty is left out.-function pageQuery(params: PageParams, filters: Record<string, string | undefined> = {}): string {- const qs = new URLSearchParams({- page: String(params.page),- pageSize: String(params.pageSize),- });- for (const [key, value] of Object.entries(filters)) {- if (value) qs.set(key, value);- }- return `?${qs}`;-}--// A team the caller belongs to. It owns projects and holds its own member list.-export interface Team {- id: number;- name: string;- // Whether the team is reachable over MCP at all, set in its MCP section. Off closes- // its own resources and every project it owns.- mcpEnabled: boolean;- // The caller's rank in the team. The API also answers an agent's own key, which reads- // 'agent' there; an agent never opens this app, so a person's rank is what arrives.- role: TeamRole;- // How the caller's own membership came about. A provisioned one is the identity- // provider's: the team cannot be left while it stands.- source: 'invite' | 'scim';- joinedAt: string;- projectCount: number;- memberCount: number;- // How many of those members are owners: the last one cannot leave.- ownerCount: number;- // The roles the team's projects assign from, the integration credentials they run- // on, the agents that work in them, and the skills and tools those agents use.- // Counted here so the page shows them beside the section without opening it.- roleCount: number;- integrationCount: number;- agentCount: number;- skillCount: number;- toolCount: number;- createdAt: string;-}--export type TeamRole = 'owner' | 'manager' | 'member';--// One member of a team: a person, or the bot user of one of its agents. An agent's-// standing in the team is 'agent' and says nothing about what it may do — that is the-// role each of its project memberships carries.-export interface TeamMember {- userId: string;- name: string;- email: string;- image: string | null;- role: TeamRole | 'agent';- // 'scim' when a provisioned group granted this membership. It ends at the identity- // provider, so the list does not remove it.- source: 'invite' | 'scim';- agentId: number | null;- username: string | null;- joinedAt: string;-}--// A project the team owns. `isMember` is the caller's own access to it: a team-// member sees every project of the team, but only opens the ones they belong to.-export interface TeamProject {- id: number;- key: string;- name: string;- description: string;- // Whether the team's MCP reach covers this project. Only counts while the team's- // own switch is on.- mcpEnabled: boolean;- memberCount: number;- owners: { userId: string; name: string; image: string | null }[];- isMember: boolean;- createdAt: string;-}--// What a team's project list asks for: the window, and a search over the key and the-// name. The search runs on the server, so the page and the total agree.-export interface TeamProjectListParams extends PageParams {- search?: string;-}--// A project as the pickers read it, plus the MCP reach the team's switches set.-export interface TeamProjectOption {- id: number;- key: string;- name: string;- mcpEnabled: boolean;-}--export interface TeamDetail extends Team {- // What the caller may do with the resources the team holds for all its projects.- // Owners and managers get the full matrix; a member gets the permissions of their- // project roles in the team, merged.- permissions: Permissions;- // The people who run the team, owners first.- leads: TeamLead[];-}--export interface TeamLead {- userId: string;- name: string;- email: string;- image: string | null;- role: 'owner' | 'manager';-}--// One project the team owns, as its row in the team panel opens it: how its issues-// stand, and where the reader stands in it. Its members are a page of their own.-export interface TeamProjectDetail {- lastActivityAt: string | null;- stats: AnalyticsStats;- // The reader's own membership in the project, null when they only run the team.- // A provisioned one ends at the identity provider, so it cannot be left here.- viewer: { role: MemberRole; source: 'invite' | 'scim'; permissions: Permissions } | null;-}--// One member of a project the team owns. The access their membership resolves to is-// the matrix of the role they hold, which the reader already has from the team's-// roles.-export interface TeamProjectMember {- userId: string;- name: string;- email: string;- // The handle they are mentioned by, @username. An agent's bot user carries the- // agent's handle.- username: string | null;- image: string | null;- isAgent: boolean;- role: MemberRole;- roleId: number | null;- roleName: string | null;- // What the member does in the project, and which path their membership came from —- // both needed by the panel, which edits the membership from there.- description: string;- source: 'invite' | 'scim';- timezone: string;- joinedAt: string;-}--export interface Project {- id: number;- teamId: number;- teamName: string;- key: string;- name: string;- description: string;- // Whether the team's MCP reach covers this project, and whether the team is- // reachable over MCP at all. Both are set in the team's MCP section; a tool call- // scoped to this project needs both.- mcpEnabled: boolean;- teamMcpEnabled: boolean;- // The optional sections, toggled by an owner in Settings -> General. Read through- // useProjectFeatures, which hides the navigation and the section itself.- initiativesEnabled: boolean;- dashboardsEnabled: boolean;- documentsEnabled: boolean;- notesEnabled: boolean;- cyclesEnabled: boolean;- subtasksEnabled: boolean;- checklistsEnabled: boolean;- issueStatsEnabled: boolean;- // The sections this project may use at all. One missing here is not available to- // the team: its flag above always reads false and the settings page does not offer- // it. Everything is available on a self-hosted instance.- availableFeatures: (keyof ProjectFeatures)[];- // Which estimate kinds the issues carry, set in Settings -> Configuration. Read- // through useProjectFeatures, which hides the estimate rows and their display- // properties while a kind is off.- pointsEstimateEnabled: boolean;- timeEstimateEnabled: boolean;- // Whether members log the time they spend on the issues, set in the same place.- // Independent of the time estimate.- timeLoggingEnabled: boolean;- createdAt: string;- // The caller's role in this project. Only present on the /projects list- // response; absent on the create/copy responses.- role?: MemberRole;-}--// Parts of a source project the copy can carry over, one key per project settings-// section. Passed to copyTeamProject as an include map; omitted keys are not-// copied. The API force-enables dependencies (a view needs its-// states/types/labels/fields).-export type CopyProjectIncludeKey =- | 'states'- | 'issueTypes'- | 'labels'- | 'customFields'- | 'views'- | 'dashboards'- | 'documents'- | 'actions'- | 'configuration'- | 'webhooks'- | 'agents'- | 'schedules';--export type StateType = 'backlog' | 'unstarted' | 'started' | 'completed' | 'canceled';--export interface Column {- id: number;- projectId: number;- name: string;- stateType: StateType;- color: string;- position: number;- // How many issues the column should hold, or null for no limit. wipMode decides- // whether passing it only warns on the board or is refused outright.- wipLimit: number | null;- wipMode: WipMode;- // The member every issue entering this column is assigned to, replacing whoever- // held it.- autoAssignUserId: string | null;-}--export type WipMode = 'soft' | 'hard';--export interface IssueType {- id: number;- projectId: number;- name: string;- icon: string;- color: string;- isDefault: boolean;- position: number;-}--export interface Label {- id: number;- projectId: number;- // The group this label belongs to, or null when ungrouped.- groupId: number | null;- name: string;- color: string;-}--// A container a label can belong to. Labels reference it by groupId.-export interface LabelGroup {- id: number;- projectId: number;- name: string;- color: string;-}--export interface Assignee {- userId: string;- name: string;- email: string;- // The handle they are mentioned by, @username. Null for a member who has none.- username: string | null;- image: string | null;- kind: 'member' | 'agent';- agentKind: 'external' | 'internal' | null;- // The user an 'owner'-scoped agent works for: delegating it to anyone else queues a- // run its runner never receives. Null for members and team-scoped agents.- restrictedToUserId: string | null;- // Whether this person may read issues and can therefore receive watcher- // notifications without leaking work-item content.- canReadWorkItems: boolean;-}--// One member custom field an agent reacts to, with the seconds its run waits.-export interface AgentFieldTrigger {- fieldId: number;- delaySec: number;-}--// The same trigger as a read of an agent returns it: the field's name comes along, so-// a screen can name it without loading the project the field belongs to.-export interface AgentFieldTriggerRead extends AgentFieldTrigger {- name: string;-}--// A project an agent works in, as its settings list them.-export interface AgentProject {- id: number;- key: string;- name: string;-}--// An AI agent of a team: a bot user plus its configuration. `kind` is-// 'external' (driven by an outside caller through the API) or 'internal' (run by-// the built-in runtime, so it carries provider/model/instructions/tools). Only an-// external agent has an API key: `apiKeyStart` is the non-secret prefix for display-// (null for internal), and the plaintext key is only returned once, on create and-// on regenerate.-export interface AiAgent {- id: number;- teamId: number;- // The projects of the team the agent works in. One key reaches every one of them.- projects: AgentProject[];- userId: string;- name: string;- username: string;- kind: 'external' | 'internal';- // The integration_credential (kind 'llm') the model runs on, or null.- modelCredentialId: number | null;- model: string | null;- instructions: string | null;- tools: string[];- temperature: number | null;- maxSteps: number | null;- memoryEnabled: boolean;- memoryLastMessages: number | null;- // Run triggers.- triggerOnMention: boolean;- triggerOnAssign: boolean;- // The member custom fields that start a run when the agent is set into one, each- // with the seconds its run waits before the agent may pick it up.- fieldTriggers: AgentFieldTriggerRead[];- // How long a delegation run waits before the agent may pick it up.- delegationDelaySec: number;- // The member who created the agent, and whose runs an 'owner'-scoped runner is- // limited to; 'team' scope serves any member's runs.- ownerUserId: string | null;- runnerScope: 'owner' | 'team';- // When the agent's runner last polled, or null while none ever has.- lastSeenAt: string | null;- createdAt: string;- apiKeyStart: string | null;- // The integration key of the model credential (the provider, e.g. "openai"), or- // null when no credential is set.- modelProvider: string | null;- // How many actions the agent can take (always-on read-only plus granted mutating),- // and how many skills and configured tools are enabled.- actionCount: number;- skillCount: number;- toolCount: number;-}--// A run waits as 'pending' until a worker or a runner takes it; 'canceled' is a-// pending run ended by hand.-export type AgentRunStatus = 'pending' | 'success' | 'failed' | 'canceled';--// One row of an agent's autonomous run history. Issue-triggered runs reference an-// issue; scheduled and manual runs do not.-export interface AgentRun {- id: number;- status: AgentRunStatus;- trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';- issueId: number | null;- issueIdentifier: string | null;- issueTitle: string | null;- prompt: string;- attempts: number;- lastError: string | null;- output: string | null;- // What the last model call of the run read and wrote: absent for a run that finished- // before this was recorded and for one whose agent reports no counts.- contextTokens?: number;- nextAttemptAt: string;- createdAt: string;-}--export interface AgentRunPage {- items: AgentRun[];- nextCursor: number | null;-}--export interface AgentSchedule {- id: number;- agentId: number;- agentName: string;- name: string;- prompt: string;- cron: string;- timezone: 'UTC';- status: 'active' | 'paused';- nextRunAt: string;- lastRunAt: string | null;- lastRunStatus: AgentRunStatus | null;- pendingRuns: number;- // False when the agent's runner is scoped to another member, who alone may run or- // stop it.- canTrigger: boolean;- createdAt: string;- updatedAt: string;-}--export interface AgentScheduleInput {- agentId: number;- name: string;- prompt: string;- cron: string;- status?: 'active' | 'paused';-}--export interface AgentScheduleRun {- id: number;- status: AgentRunStatus;- trigger: 'schedule' | 'manual';- prompt: string;- attempts: number;- lastError: string | null;- output: string | null;- // What the last model call of the run read and wrote: absent for a run that finished- // before this was recorded and for one whose agent reports no counts.- contextTokens?: number;- scheduledFor: string | null;- startedAt: string | null;- finishedAt: string | null;- createdAt: string;-}--// One work-item tool from the server-side catalog. `key` is stored on the agent-// (grantable actions only); label/description are for the picker. `always` marks the-// read-only tools that are always granted and shown non-editable. `permission` is the-// cell of the role matrix the action's route asserts; absent when the route asks only-// for project membership.-export interface AgentTool {- key: string;- group: 'issues' | 'initiatives' | 'cycles' | 'notes' | 'project';- label: string;- description: string;- always: boolean;- permission?: [PermissionResource, PermissionAction];-}--export interface NewAiAgentInput {- name: string;- username: string;- kind: 'external' | 'internal';- modelCredentialId?: number | null;- model?: string | null;- instructions?: string | null;- tools?: string[];- temperature?: number | null;- maxSteps?: number | null;- memoryEnabled?: boolean;- memoryLastMessages?: number | null;- triggerOnMention?: boolean;- triggerOnAssign?: boolean;- fieldTriggers?: AgentFieldTrigger[];- delegationDelaySec?: number;- projectIds?: number[];- runnerScope?: 'owner' | 'team';-}--export interface AiAgentPatch {- name?: string;- username?: string;- modelCredentialId?: number | null;- model?: string | null;- instructions?: string | null;- tools?: string[];- temperature?: number | null;- maxSteps?: number | null;- memoryEnabled?: boolean;- memoryLastMessages?: number | null;- triggerOnMention?: boolean;- triggerOnAssign?: boolean;- fieldTriggers?: AgentFieldTrigger[];- delegationDelaySec?: number;- projectIds?: number[];- runnerScope?: 'owner' | 'team';-}--// A field of an integration's credential form (from the catalog). `type` "secret"-// marks a value stored encrypted and shown masked.-export interface ConfigField {- key: string;- label: string;- type: 'string' | 'secret' | 'url' | 'number' | 'boolean';- required: boolean;- placeholder?: string;- help?: string;-}--// 'llm' is an AI provider (its models an agent runs on, no tools); 'tool' is a tool-// integration whose `tools` are configured on a credential.-export type IntegrationKind = 'llm' | 'tool';--// An integration the team can store a credential for (server-side catalog).-export interface IntegrationMeta {- key: string;- label: string;- kind: IntegrationKind;- credentialSchema: ConfigField[];- tools: { key: string; label: string; description: string; scopes?: string[] }[];-}--// A model an LLM provider offers, from the models.dev registry.-export interface ProviderModel {- id: string;- name: string;-}--// A stored integration credential. `redacted` mirrors the stored credential with-// secret fields masked; the real secrets are never returned.-export interface IntegrationCredential {- id: number;- teamId: number;- integrationKey: string;- label: string | null;- redacted: Record<string, unknown>;- createdAt: string;-}--// A connected integration as a picker option: what it is and what it is called,-// with none of the credential fields the admin list carries.-export interface IntegrationOption {- id: number;- integrationKey: string;- kind: IntegrationKind;- label: string | null;-}--export interface NewCredentialInput {- integrationKey: string;- label?: string | null;- credential: Record<string, unknown>;-}--export interface CredentialPatch {- label?: string | null;- // Only the fields being changed. Secret fields left out keep their stored value.- credential?: Record<string, unknown>;-}--// A reference file of a skill (metadata only).-export interface SkillRef {- path: string;- s3Key: string;- size: number;-}--// A skill in the team library: a SKILL.md plus optional reference files, given to-// the internal agents of the team's projects. Content lives in the object store;-// this is the metadata.-export interface AgentSkill {- id: number;- teamId: number;- name: string;- description: string;- source: 'upload' | 'inline' | 'github';- sourceUrl: string | null;- files: SkillRef[];- createdAt: string;-}--export interface NewSkillInput {- source: 'upload' | 'inline' | 'github';- name?: string | null;- description?: string | null;- markdown?: string;- sourceUrl?: string | null;-}--export interface SkillPatch {- name?: string;- description?: string;- markdown?: string;-}--// A skill found at a GitHub URL by the discover endpoint. `url` is a ready-to-import-// link for that single skill.-export interface GithubSkillCandidate {- name: string;- description: string;- subpath: string;- url: string;-}--// A configured tool: a catalog tool (toolKey) bound to an integration credential,-// enriched with the credential's integration and label for display. (Distinct from-// AgentTool, which is a built-in capability tool in the agent's Actions list.)-export interface ConfiguredTool {- id: number;- teamId: number;- toolKey: string;- credentialId: number;- integrationKey: string;- credentialLabel: string | null;- createdAt: string;-}--export interface NewConfiguredToolInput {- toolKey: string;- credentialId: number;-}--// One event of a streamed agent run (mirrors the API's AgentRunEvent). `text` is a-// chunk of the answer to append; `tool-start`/`tool-end` report a capability the-// agent is using, so the UI can show what it is doing; `done` ends the run with the-// conversation thread id; `error` reports a failure that happened mid-run.-export type AgentRunEvent =- | { type: 'text'; value: string }- | { type: 'tool-start'; toolCallId: string; toolName: string; args?: string }- // An external agent's runner sends a call's arguments after the call itself, in- // pieces; an internal agent has them all at its start.- | { type: 'tool-args'; toolCallId: string; delta: string }- | { type: 'tool-end'; toolCallId: string; result?: string }- | { type: 'done'; threadId: string | null }- | { type: 'error'; message: string };--// One of the caller's saved chat conversations with an agent. `title` is the first-// prompt (truncated); null when it was never set. `cliSessionId` is the coding agent-// session an external agent's runner keeps for the thread on its own machine — null-// before the runner has reported one, and always null for an internal agent.-// `contextTokens` is the size of the conversation's context after its last completed-// answer: absent while no answer has completed, null where the agent reports no counts-// that can be read as one.-// `favorite` is the star the caller put on the conversation. `snippet` and `match` come-// back from a search: the text around the hit, and where it was found.-export interface AiChatThread {- id: string;- title: string | null;- cliSessionId: string | null;- contextTokens?: number | null;- favorite: boolean;- snippet?: string;- match?: 'title' | 'user' | 'assistant';- createdAt: string;- updatedAt: string;-}--// One piece of a message, in the order the agent produced it: what it wrote, and the-// tools it called between one stretch of text and the next. A call carries what it was-// given and what it answered where the agent reported them.-export interface AiChatToolPart {- type: 'tool';- toolCallId: string;- toolName: string;- args?: string;- result?: string;-}--export type AiChatPart = { type: 'text'; text: string } | AiChatToolPart;--// One restored message of a chat thread's transcript. `stopped` marks an answer the-// member ended part-way: what the agent had written by then is all there is.-export interface AiChatMessage {- id: string;- role: 'user' | 'assistant';- parts: AiChatPart[];- createdAt: string;- stopped?: boolean;-}--export interface AiChatThreadPage {- items: AiChatThread[];- nextPage: number | null;-}--export interface AiChatMessagePage {- items: AiChatMessage[];- nextPage: number | null;-}--// Streams an internal agent's response over SSE, yielding each AgentRunEvent as it-// arrives. Sends the session cookie like every other call. Throws ApiError when the-// request itself fails before the stream starts (e.g. 403/404); a failure during-// the run arrives as an `error` event, not a throw.-//-// The run is bound to this connection, so aborting `signal` is the whole stop: the API-// drops the run with it.-export async function* streamAiAgentRun(- projectKey: string,- agentId: number,- input: { prompt: string; threadId?: string | null },- signal?: AbortSignal,-): AsyncGenerator<AgentRunEvent> {- const body = input.threadId- ? { prompt: input.prompt, threadId: input.threadId }- : { prompt: input.prompt };- const res = await fetch(`${API_URL}/projects/${projectKey}/ai-agents/${agentId}/run/stream`, {- method: 'POST',- credentials: 'include',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(body),- signal,- });- for await (const frame of readSseFrames(res)) {- yield JSON.parse(frame.data) as AgentRunEvent;- }-}--// The frames of one SSE connection: separated by a blank line, each carrying a single-// JSON-encoded event on its `data:` line and, on a resumable stream, the `id:` a-// reconnect resumes from. Throws ApiError when the request failed before the stream.-async function* readSseFrames(res: Response): AsyncGenerator<{ id: number | null; data: string }> {- if (!res.ok || !res.body) throw await apiFailure(res);- const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();- let buffer = '';- for (;;) {- const { done, value } = await reader.read();- if (done) return;- buffer += value;- let sep: number;- while ((sep = buffer.indexOf('\n\n')) !== -1) {- const lines = buffer.slice(0, sep).split('\n');- buffer = buffer.slice(sep + 2);- const dataLine = lines.find((l) => l.startsWith('data:'));- if (!dataLine) continue;- const idLine = lines.find((l) => l.startsWith('id:'));- yield {- id: idLine ? Number(idLine.slice(3).trim()) : null,- data: dataLine.slice(5).trim(),- };- }- }-}--// --- Chat attachments: a file dropped in an agent chat, for an agent to read or-// import issues from.--export interface ChatAttachment {- id: string;- filename: string;- contentType: string;- sizeBytes: number;- createdAt: string;- url: string;-}--// The upload route takes the bytes as base64 rather than multipart, so the chat-// composer and an MCP client call the same route.-export async function uploadChatAttachment(- projectKey: string,- file: File,-): Promise<ChatAttachment> {- const dataUrl = await new Promise<string>((resolve, reject) => {- const reader = new FileReader();- reader.onload = () => resolve(reader.result as string);- reader.onerror = () => reject(reader.error ?? new Error('Could not read the file'));- reader.readAsDataURL(file);- });- return request(`/projects/${projectKey}/chat-attachments`, {- method: 'POST',- body: JSON.stringify({- filename: file.name,- contentBase64: dataUrl.slice(dataUrl.indexOf(',') + 1),- contentType: file.type || undefined,- }),- });-}--// --- Issue imports: a chat attachment an agent mapped into issues, awaiting confirmation.--export interface IssueImport {- id: string;- filename: string;- contentType: string;- sizeBytes: number;- status: 'mapped' | 'confirmed' | 'canceled' | 'failed';- mapping: Record<string, string> | null;- errorText: string | null;- createdAt: string;- preview?: {- columns: { field: string; header: string }[];- rows: { cells: string[]; skip: string | null }[];- totalRows: number;- };-}--export interface ImportConfirmResult {- imported: { key: string; title: string }[];- skipped: { row: number; reason: string }[];-}--export async function getImport(importId: string): Promise<IssueImport> {- return request(`/imports/${importId}`);-}--export async function confirmImport(importId: string): Promise<ImportConfirmResult> {- return request(`/imports/${importId}/confirm`, { method: 'POST' });-}--export async function discardImport(importId: string): Promise<void> {- await request(`/imports/${importId}/cancel`, { method: 'POST' });-}--// What an external agent's runner reports while it answers, as AG-UI events-// (https://docs.ag-ui.com). Only the ones the chat renders are named; the rest of the-// protocol passes through and is ignored here.-interface AgUiEvent {- type: string;- delta?: string;- content?: string;- message?: string;- toolCallId?: string;- toolCallName?: string;-}--// How many times a dropped stream is picked up again. The answer keeps being produced-// on the operator's machine either way; this only decides how long the browser follows it.-const CHAT_STREAM_RETRIES = 3;--// Sends a message to an external agent and streams the answer its runner produces,-// yielding the same events as an internal agent's run so the chat consumes one shape.-// The answer starts only once a runner takes the message: until then the stream is open-// with nothing on it.-//-// Dropping the stream stops nothing here — the runner is on the operator's machine and-// only ever calls the API itself — so aborting `signal` also asks the API to cancel the-// answer, which is what the runner reads on its next report.-export async function* streamAiAgentChat(- projectKey: string,- agentId: number,- input: { prompt: string; threadId?: string | null },- signal?: AbortSignal,-): AsyncGenerator<AgentRunEvent> {- const body = input.threadId- ? { prompt: input.prompt, threadId: input.threadId }- : { prompt: input.prompt };- const sent = await request<{ threadId: string; messageId: number }>(- `/projects/${projectKey}/ai-agents/${agentId}/chat`,- { method: 'POST', body: JSON.stringify(body) },- );- const chat = `/projects/${projectKey}/ai-agents/${agentId}/chat/${sent.messageId}`;- const cancel = () => {- // A stop the API refused leaves the answer being produced. The stream this belongs- // to is already gone, so the console is the only place left to report it.- request(`${chat}/cancel`, { method: 'POST' }).catch((err) => {- console.error('Could not stop the answer', err);- });- };- if (signal?.aborted) cancel();- else signal?.addEventListener('abort', cancel, { once: true });- const base = `${API_URL}${chat}/stream`;- let after = 0;- // The answer always ends on a terminal event, so a stream that closed without one was- // cut: pick it up again from the last event already shown.- for (let attempt = 0; attempt <= CHAT_STREAM_RETRIES; attempt++) {- let ended = false;- try {- const res = await fetch(`${base}?after=${after}`, { credentials: 'include', signal });- for await (const frame of readSseFrames(res)) {- after = frame.id ?? after;- const event = JSON.parse(frame.data) as AgUiEvent;- if (event.type === 'RUN_FINISHED') {- ended = true;- break;- }- if (event.type === 'RUN_ERROR') {- ended = true;- yield { type: 'error', message: event.message ?? 'The agent stopped answering' };- break;- }- const mapped = toRunEvent(event);- if (mapped) yield mapped;- }- } catch (err) {- // A stop still has to name the thread: the reader binds it on `done`, and without- // that the next message would open a second conversation.- if (signal?.aborted) {- yield { type: 'done', threadId: sent.threadId };- throw err;- }- if (attempt === CHAT_STREAM_RETRIES) throw err;- }- if (ended) break;- }- yield { type: 'done', threadId: sent.threadId };-}--function toRunEvent(event: AgUiEvent): AgentRunEvent | null {- switch (event.type) {- case 'TEXT_MESSAGE_CONTENT':- return { type: 'text', value: event.delta ?? '' };- case 'TOOL_CALL_START':- return {- type: 'tool-start',- toolCallId: event.toolCallId ?? '',- toolName: event.toolCallName ?? '',- };- case 'TOOL_CALL_ARGS':- return { type: 'tool-args', toolCallId: event.toolCallId ?? '', delta: event.delta ?? '' };- // TOOL_CALL_END closes the call's arguments, which the runner reports in the same- // batch as the call itself. The tool is done when its result arrives.- case 'TOOL_CALL_RESULT':- return { type: 'tool-end', toolCallId: event.toolCallId ?? '', result: event.content };- default:- return null;- }-}--export type CustomFieldType =- | 'text'- | 'markdown'- | 'url'- | 'number'- | 'boolean'- | 'date'- | 'datetime'- | 'datetime_range'- | 'select'- | 'multi_select'- | 'member';--// Who a member field may hold: every candidate, the people only, or the agents only.-// Null for every other field type.-export type MemberScope = 'all' | 'humans' | 'agents';--export interface CustomFieldOption {- id: number;- value: string;- color: string;- position: number;-}--export interface CustomField {- id: number;- issueTypeId: number | null;- name: string;- fieldType: CustomFieldType;- memberScope: MemberScope | null;- // When true the field renders in the issue body (under the description);- // when false it renders as a Properties row.- showInBody: boolean;- position: number;- options: CustomFieldOption[];-}--// A preset a new issue can be created from: the title and description it starts-// with plus the properties applied on top of them. A property left null presets-// nothing — the create dialog keeps its own default for it.-export interface IssueTemplate {- id: number;- name: string;- description: string;- titleTemplate: string;- descriptionTemplate: string;- typeId: number | null;- columnId: number | null;- priority: string | null;- assigneeUserId: string | null;- labelIds: number[];-}--// One custom field value on a project issue: the scalar value (null for-// select/multi_select and unset fields), the end of a datetime_range, and the-// selected option ids. Only fields with a value set appear; unset fields are-// omitted (see listIssues).-export interface IssueFieldValueEntry {- fieldId: number;- value: string | number | boolean | null;- valueEnd: string | null;- optionIds: number[];-}--export interface Issue {- id: number;- projectId: number;- // Project-scoped sequence number (the "42" in "MKT-42"). Addresses the issue by- // its human number in URLs (/project/MKT/issue/42).- sequenceNumber: number;- identifier: string;- typeId: number | null;- // The initiative this issue is linked to, expanded to id + title for rendering,- // or null. Set through updateIssue by initiativeId.- initiative: InitiativeRef | null;- // The cycle this issue is planned into, expanded to id + name for rendering, or- // null. Set through updateIssue by cycleId.- cycle: CycleRef | null;- assigneeUserId: string | null;- delegateUserId: string | null;- columnId: number;- // The issue this one is a subtask of, or null when it stands on its own. The- // views render a subtask under its parent instead of on its own, so an issue- // with a parent never shows as a card or a row of its own.- parentId: number | null;- title: string;- description: string;- priority: string | null;- // Time is in minutes; the UI enters and shows it as hours and minutes.- estimatePoints: number | null;- estimateMinutes: number | null;- // The sum of the issue's logged time entries, 0 when nothing was logged. The- // entries themselves are read separately (listWorklogs).- loggedMinutes: number;- startDate: string | null;- dueDate: string | null;- position: number;- createdAt: string;- updatedAt: string;- // When the issue was archived (hidden from the board but kept), or null when it- // is active. Set by the archive action or the worker's auto-archive sweep.- archivedAt: string | null;- // When the issue entered its current column (or createdAt if it never moved).- // Drives the "time in current status" badge.- statusSince: string;- // Unguessable token for the public read-only share link, or null when not shared.- shareToken: string | null;- // Whether that link exposes the issue in full (assignees, labels, custom fields,- // activity) or only its title, description, state, type, priority, dates,- // subtasks and links.- shareExtended: boolean;- labelIds: number[];- fieldValues: IssueFieldValueEntry[];-}--// A light search result from GET /projects/:key/issues/search: enough to list and-// open a match, without the full issue's description or field values.-export interface IssueSearchHit {- id: number;- sequenceNumber: number;- identifier: string;- title: string;- columnId: number;- typeId: number | null;- initiativeId: number | null;- cycleId: number | null;- parentId: number | null;- assigneeUserId: string | null;- delegateUserId: string | null;- priority: string | null;- dueDate: string | null;- labelIds: number[];- archived: boolean;-}--// Per-project auto-archive thresholds: days an issue may sit inactive in a-// completed/canceled column before the worker archives it. null disables archiving-// for that state group. A new project starts at 28 completed / 7 canceled days.-export interface AutoArchiveSettings {- completedDays: number | null;- canceledDays: number | null;-}--// Which estimate kinds a project's issues carry and whether its members log the-// time they spend, all off by default. One turned off hides its UI and keeps what-// the issues already carry.-export interface EstimateSettings {- points: boolean;- time: boolean;- logging: boolean;-}--// Per-project subtask automations, both off by default. completeParent closes a-// parent once all its subtasks are closed; closeSubtasks closes the remaining-// subtasks of a closed parent. Only closing is synchronized — an issue moving-// between open states leaves the rest of the hierarchy alone.-export interface SubtaskAutomationSettings {- completeParent: boolean;- closeSubtasks: boolean;-}--// Per-project repository integration settings, shared by every provider.-// webhookId is the path segment of the payload URL registered on the repository;-// secret authenticates its deliveries and is null for members who may read but not-// edit integrations. onMergeColumnId is where an issue closed by a merged pull-// request moves (null = the first completed state); onOpenColumnId is where an-// issue moves when a linked pull request is opened (null = no action).-export interface GitSettings {- enabled: boolean;- webhookId: string;- secret: string | null;- onMergeColumnId: number | null;- onOpenColumnId: number | null;- linkbackComments: boolean;- repositories: GitRepository[];-}--// One repository that has delivered to the project, with the host it came from-// and when its last delivery arrived.-export interface GitRepository {- repo: string;- provider: string;- lastEventAt: string;-}--export type GitConnectionProvider = 'github' | 'gitlab' | 'gitea' | 'forgejo' | 'bitbucket';--export interface GitManagedRepository {- id: number;- externalId: string;- fullName: string;- webUrl: string;- status: 'connected' | 'error';- lastError: string | null;-}--export interface GitProviderConnection {- id: number;- provider: GitConnectionProvider;- baseUrl: string;- accountLogin: string;- repositories: GitManagedRepository[];- createdAt: string;- updatedAt: string;-}--export interface AvailableGitRepository {- externalId: string;- fullName: string;- webUrl: string;- private: boolean;- managedRepositoryId: number | null;-}--export interface AvailableGitRepositoryPage {- repositories: AvailableGitRepository[];- nextPage: number | null;-}--// Which optional sections a project shows. All on by default; turning one off-// hides its navigation entry and its section, keeping the rows behind it.-export interface ProjectFeatures {- initiatives: boolean;- cycles: boolean;- dashboards: boolean;- documents: boolean;- notes: boolean;- subtasks: boolean;- checklists: boolean;- issueStats: boolean;-}--// A project's settings: MCP reachability, which is read-only here, and the enabled-// sections.-export interface ProjectSettings {- mcpEnabled: boolean;- teamMcpEnabled: boolean;- features: ProjectFeatures;-}--// A team's MCP settings: the switch, and which of its projects the reach covers.-export interface TeamMcpSettings {- enabled: boolean;- projects: { projectId: number; enabled: boolean }[];-}--// Per-team notification provider credentials (owner-managed) plus a member's own-// delivery preferences for a project. The issue events match the inbox notification-// types.-export type NotificationEncryption = 'none' | 'ssl' | 'tls';--export interface NotificationEventToggles {- assigned: boolean;- mentioned: boolean;- commented: boolean;- state_changed: boolean;-}--// The provider credentials as read from the API: secrets are never returned, only a-// `hasX` flag telling whether a value is stored.-export interface NotificationSettings {- // Deliver email through the instance provider instead of the team's own. Its- // credentials belong to the instance, so the team only turns it on.- system: { enabled: boolean };- // Whether the instance provider exists and is shared with teams right now.- systemAvailable: boolean;- smtp: {- enabled: boolean;- host: string;- port: number | null;- encryption: NotificationEncryption;- username: string;- hasPassword: boolean;- timeout: number | null;- };- resend: { enabled: boolean; hasApiKey: boolean };- telegram: { enabled: boolean; hasBotToken: boolean };-}--// A partial write. Each section is optional so a provider card saves on its own.-// A secret field left out or empty keeps its stored value.-export interface NotificationSettingsPatch {- system?: { enabled: boolean };- smtp?: {- enabled: boolean;- host: string;- port: number | null;- encryption: NotificationEncryption;- username: string;- password?: string;- timeout: number | null;- };- resend?: { enabled: boolean; apiKey?: string };- telegram?: { enabled: boolean; botToken?: string };-}--// ── Storage limits ────────────────────────────────────────────────────────────--// The instance upload limits. Readable by any signed-in user, because the upload UI-// states them before a file is picked; only god mode can change them.-export interface ProjectDefaults {- mcpEnabled: boolean;-}--export interface StorageSettings {- maxAttachmentMb: number;- maxAvatarMb: number;- // Accepted attachment content types: a full type ('application/pdf') or a- // wildcard ('image/*'). Empty means any type is accepted.- attachmentMimeTypes: string[];- // Stored attachment bytes allowed per project, in MB. 0 means unlimited.- projectQuotaMb: number;-}--export type StorageSettingsPatch = Partial<StorageSettings>;--// One release. The ones above the running version come from the repository's feed-// and carry HTML notes; the ones up to it come from this build's changelog and-// carry markdown.-export interface Release {- tag: string;- version: string;- publishedAt: string;- url: string | null;- notes: string;- notesFormat: 'html' | 'markdown';-}--// How the running version compares to what is published. `latestVersion` and-// `checkedAt` are null until an upstream check has succeeded.-export interface UpdateStatus {- currentVersion: string;- latestVersion: string | null;- updateAvailable: boolean;- checkedAt: string | null;- releases: Release[];-}--// The screen shown once after an upgrade. `backup` and `migration` are filled for-// the instance owner and a team owner only — they name projects, roles and agents-// across the instance — and are null for everyone else.-export interface BackupInfo {- path: string;- sizeBytes: number;- createdAt: string;- expiresAt: string;- migrations: string[];-}--// What the move to teams did to this instance's data, as the migration recorded it.-export interface TeamsMigrationReport {- version: number;- teams: { name: string; projects: { key: string; name: string }[] }[];- // Keyed by what was renamed: roles, skills, agents, credentials.- renamed: Record<string, { from: string; to: string }[]>;- merged: { roles: number; agentTools: number };- movedInvites: number;- droppedNotificationSettings: string[];-}--export interface WhatsNew {- version: string;- pending: boolean;- // Every release this user has not seen yet, newest first.- releases: Release[];- backup: BackupInfo | null;- migration: TeamsMigrationReport | null;-}--// ── Instance administration (god mode) ────────────────────────────────────────--// Who may create an account on this instance.-export type RegistrationMode = 'open' | 'invite' | 'closed';--// The instance sign-in policy. hasEmailProvider tells whether outbound mail works;-// the options that depend on it cannot be turned on without one.-export interface InstanceAuthSettings {- registration: RegistrationMode;- requireEmailVerification: boolean;- magicLink: boolean;- emailPassword: boolean;- hasEmailProvider: boolean;- // Whether Google or the OIDC provider can run. Password sign-in may only be turned- // off while one of them can.- hasSsoProvider: boolean;-}--export interface InstanceAuthSettingsPatch {- registration?: RegistrationMode;- requireEmailVerification?: boolean;- magicLink?: boolean;- emailPassword?: boolean;-}--// The instance mail provider used for authentication email (password reset, address-// verification, magic links). Separate from a team's notification provider.-// Secrets are never returned, only a `hasX` flag.-export interface InstanceEmailSettings {- smtp: {- enabled: boolean;- host: string;- port: number | null;- encryption: NotificationEncryption;- username: string;- hasPassword: boolean;- timeout: number | null;- };- resend: { enabled: boolean; hasApiKey: boolean };- from: string;- // Whether projects may deliver their notifications through this provider.- allowProjects: boolean;-}--export interface InstanceEmailSettingsPatch {- smtp?: {- enabled: boolean;- host: string;- port: number | null;- encryption: NotificationEncryption;- username: string;- password?: string;- timeout: number | null;- };- resend?: { enabled: boolean; apiKey?: string };- from?: string;- allowProjects?: boolean;-}--export interface InstanceEmailTestResult {- recipient: string;-}--// The Google OAuth credentials used for social sign-in. The client secret is never-// returned, only a `hasClientSecret` flag. redirectUri is derived from the API origin-// and has to be registered in the Google Cloud console.-export interface InstanceGoogleSettings {- enabled: boolean;- clientId: string;- hasClientSecret: boolean;- redirectUri: string;-}--export interface InstanceGoogleSettingsPatch {- enabled?: boolean;- clientId?: string;- clientSecret?: string;-}--// The instance's generic OIDC/OAuth2 provider. The client secret is never returned,-// only a `hasClientSecret` flag. redirectUri is derived from the API origin and has-// to be registered with the identity provider.-export interface InstanceOidcSettings {- enabled: boolean;- label: string;- discoveryUrl: string;- clientId: string;- hasClientSecret: boolean;- scopes: string[];- pkce: boolean;- redirectUri: string;-}--export interface InstanceOidcSettingsPatch {- enabled?: boolean;- label?: string;- discoveryUrl?: string;- clientId?: string;- clientSecret?: string;- scopes?: string[];- pkce?: boolean;-}--// SCIM provisioning. The token is never returned, only its prefix; a new one is-// generated with createInstanceScimToken and shown once.-export interface InstanceScimSettings {- enabled: boolean;- hasToken: boolean;- tokenPrefix: string;- baseUrl: string;-}--// What a provisioned group grants: membership in a project, at a role. The group and-// its members come from the identity provider; the mappings are set here.-export interface InstanceScimGroupMapping {- projectId: number;- projectKey: string;- projectName: string;- role: 'owner' | 'member';- roleId: number | null;-}--export interface InstanceScimGroup {- id: string;- displayName: string;- externalId: string | null;- memberCount: number;- mappings: InstanceScimGroupMapping[];-}--// The instance Telegram bot: the one bot users link their accounts through, and the-// default sender for Telegram notifications. `botUsername` is resolved from Telegram-// when the token is saved.-export interface InstanceTelegramSettings {- enabled: boolean;- botUsername: string;- hasBotToken: boolean;-}-export interface InstanceTelegramSettingsPatch {- enabled?: boolean;- botToken?: string;-}--// One account in the instance user directory. `role` is the global better-auth role-// ("god" for the instance owner), which is unrelated to project membership.-export interface InstanceUser {- id: string;- name: string;- email: string;- image: string | null;- emailVerified: boolean;- role: string;- isAgent: boolean;- providers: string[];- projectCount: number;- lastSeenAt: string | null;- createdAt: string;-}--// A project the user can reach, with the permissions their membership resolves to-// (full for an owner, the assigned role's matrix for a member).-export interface InstanceUserProject {- projectId: number;- projectKey: string;- projectName: string;- role: MemberRole;- roleId: number | null;- roleName: string | null;- permissions: Permissions;- // How many owners the project has. 1 on a project this user owns means deleting- // the account would leave the project with nobody who can manage it.- ownerCount: number;- joinedAt: string;-}--export interface InstanceUserDetail extends InstanceUser {- projects: InstanceUserProject[];-}--// Which accounts the directory lists: real people, the bot users behind AI agents,-// or both.-export type InstanceUserKind = 'human' | 'agent' | 'all';--// One project in the instance project directory, with what it holds counted across-// its dependent tables. `lastActivityAt` is the most recent entry in its issue feed.-export interface InstanceProject {- id: number;- key: string;- name: string;- description: string;- mcpEnabled: boolean;- memberCount: number;- issueCount: number;- archivedIssueCount: number;- initiativeCount: number;- dashboardCount: number;- viewCount: number;- agentCount: number;- skillCount: number;- toolCount: number;- lastActivityAt: string | null;- createdAt: string;-}--// One member of a project, with the permissions their membership resolves to (full-// for an owner, the assigned role's matrix for a member).-export interface InstanceProjectMember {- userId: string;- name: string;- email: string;- username: string | null;- image: string | null;- isAgent: boolean;- role: MemberRole;- roleId: number | null;- roleName: string | null;- permissions: Permissions;- description: string;- timezone: string;- joinedAt: string;-}--export interface InstanceProjectDetail extends InstanceProject {- members: InstanceProjectMember[];- // The custom roles a member of this project can be put on, for the SCIM group- // mapping form.- roles: { id: number; name: string; isDefault: boolean }[];-}--// One instance project as a picker entry: what the SCIM mapping form needs to name it.-export interface InstanceProjectOption {- id: number;- key: string;- name: string;-}--// What the sign-in and sign-up screens read before there is a session. magicLink,-// requireEmailVerification and google are already resolved against their provider by-// the API, so a screen can trust them without checking the credentials itself.-export interface PublicAuthConfig {- registration: RegistrationMode;- magicLink: boolean;- requireEmailVerification: boolean;- emailEnabled: boolean;- // Whether the email/password form is offered at all. False only on an instance- // that has a working single sign-on provider.- emailPassword: boolean;- google: boolean;- oidc: boolean;- // The sign-in button text the operator gave their identity provider. Empty when- // OIDC is not offered, or when they left it blank.- oidcLabel: string;-}--// The session member's own notification preferences for a project: which issue-// events they want by email and/or Telegram. Email is sent to the member's account-// address, Telegram to the account they linked in their profile.-export interface NotificationPreferences {- emailEvents: NotificationEventToggles;- telegramEvents: NotificationEventToggles;-}--// The session user's Telegram link. `botUsername` is null when no instance bot is-// configured, which is when Telegram is not offered at all; `link` is null while the-// user has not connected an account.-export interface TelegramAccount {- botUsername: string | null;- link: { username: string | null; firstName: string | null; linkedAt: string } | null;-}--// The deep link that completes a Telegram connection, and when its code expires.-export interface TelegramLinkStart {- url: string;- expiresAt: string;-}--// The signed-in user's interface preferences, held per account so they apply on-// every device. timezone is an IANA zone name the app renders stored UTC timestamps-// in; issueOpenMode decides whether a clicked issue opens in the side panel or on-// its own page; startPage is the section the app root lands on; showChatByDefault-// keeps the floating AI chat button on screen from the start; lastProjectId is the-// project the app root reopens (null until the user has opened one).-export type ThemePreference = 'light' | 'dark' | 'system';-export type IssueOpenMode = 'panel' | 'page';-export type StartPage = 'inbox' | 'dashboard' | 'work-items' | 'initiatives';-export type IssueStatsView = 'compact' | 'timeline';-export type IssueActivityView = 'flat' | 'grouped';--export interface AccountPreferences {- timezone: string;- // The interface language. Mirrored into the NEXT_LOCALE cookie, which is what the- // server renders with; also the language of this user's emails and bot messages.- locale: Locale;- theme: ThemePreference;- issueOpenMode: IssueOpenMode;- startPage: StartPage;- showChatByDefault: boolean;- // How the status stats section of an issue starts out, and the shape its activity- // log starts in. Switching either on an issue is not saved — it lasts as long as- // that issue stays open.- issueStatsOpen: boolean;- issueStatsView: IssueStatsView;- issueActivityView: IssueActivityView;- // Whether the user is subscribed to the issues they create, are assigned, comment- // on or are mentioned in. Off means they only ever subscribe by hand.- autoWatch: boolean;- lastProjectId: number | null;- // The keyboard shortcuts this user rebound, as { commandId: combo }. Only the- // changed ones; the rest come from the instance settings, then the built-in- // bindings (see lib/hotkeys).- hotkeys: HotkeyOverrides;-}--// Rebound keyboard shortcuts: the combination each overridden command id takes. A-// command left out keeps the binding from the layer below.-export type HotkeyOverrides = Record<string, string>;--export type AccountPreferencesPatch = Partial<AccountPreferences>;--// A saved view (a tab above the work items view): a named filter set plus a display-// snapshot (layout + that layout's settings). The view itself is shared by the-// project; only `favorite` is per user. filters/display are stored as jsonb.-export interface View {- id: number;- projectId: number;- name: string;- icon: string | null;- filters: FilterSet;- display: SavedViewDisplay;- position: number;- // Unguessable token for the public read-only share link, or null when not shared.- shareToken: string | null;- // Whether the share link exposes the full issues (assignees, labels, custom- // fields, activity) or only their title, description, state, type, priority,- // dates, subtasks and links.- shareExtended: boolean;- // Whether the current user marked the view as a favorite: it pins the tab to the- // front and lists the view under Work items in the sidebar.- favorite: boolean;- createdAt: string;-}--export interface NewViewInput {- name: string;- icon?: string | null;- filters?: FilterSet;- display?: SavedViewDisplay;-}--export interface ViewPatch {- name?: string;- icon?: string | null;- filters?: FilterSet;- display?: SavedViewDisplay;-}--// A saved dashboard: the analytics counterpart of a View. `layout` is the ordered-// list of widgets (owned by the UI, stored verbatim server-side as jsonb).-export interface Dashboard {- id: number;- projectId: number;- name: string;- icon: string | null;- layout: DashboardLayout;- position: number;- createdAt: string;-}--export interface NewDashboardInput {- name: string;- icon?: string | null;- layout?: DashboardLayout;-}--export interface DashboardPatch {- name?: string;- icon?: string | null;- layout?: DashboardLayout;-}--// --- Note board DTOs ---------------------------------------------------------------// One sticky note on the canvas. body is markdown (may contain task-list items).-// color keys a background swatch defined by the UI. Declared as a type alias (not-// an interface) so it carries an implicit index signature and satisfies React-// Flow's Node data constraint (Record<string, unknown>).-export type NoteSticker = {- title: string;- body: string;- color: string;-};--// A React Flow node holding a sticker. Kept structurally compatible with React-// Flow's Node so the canvas can use it directly.-export interface NoteNode {- id: string;- type: 'sticker';- position: { x: number; y: number };- width?: number;- height?: number;- data: NoteSticker;-}--// A connection between two stickers (React Flow edge).-export interface NoteEdge {- id: string;- source: string;- target: string;-}--// The board canvas, stored verbatim as jsonb on the server.-export interface NoteCanvas {- nodes: NoteNode[];- edges: NoteEdge[];-}--// Who sees a board: every project member, its creator alone, or its creator plus-// the members granted access.-export type NoteBoardVisibility = 'public' | 'private' | 'restricted';--export interface NoteBoard {- id: number;- projectId: number;- // null for a public board; a user id for a private or restricted one.- ownerUserId: string | null;- // Only the creator can change who sees the board.- createdByUserId: string | null;- visibility: NoteBoardVisibility;- // The members granted access besides the creator (a restricted board).- memberIds: string[];- name: string;- canvas: NoteCanvas;- createdAt: string;- updatedAt: string;-}--// A board without its canvas or member list — what the switcher and MRU tabs list.-// The canvas is loaded one board at a time via getNoteBoard when the board is opened.-export type NoteBoardSummary = Omit<NoteBoard, 'canvas' | 'memberIds'>;--export interface NewNoteBoardInput {- name: string;- visibility?: Exclude<NoteBoardVisibility, 'restricted'>;- canvas?: NoteCanvas;-}--export interface NoteBoardPatch {- name?: string;- canvas?: NoteCanvas;- visibility?: NoteBoardVisibility;- // Replaces the granted members as a whole; only on a restricted board.- memberIds?: string[];-}--// Someone a restricted board can be shared with. `canAccess` false means their-// role cannot read notes at all, so the API rejects granting them access.-export interface NoteBoardAccessCandidate {- userId: string;- name: string;- image: string | null;- kind: 'member' | 'agent';- canAccess: boolean;-}--export interface NoteBoardListParams {- q?: string;- limit?: number;- offset?: number;-}--export interface ProjectDocumentSummary {- id: number;- projectId: number;- parentId: number | null;- title: string;- icon: string | null;- metadata: Record<string, unknown>;- fullWidth: boolean;- isPrivate: boolean;- isLocked: boolean;- isFavorite: boolean;- archivedAt: string | null;- position: number;- version: number;- ownerUserId: string | null;- createdByUserId: string | null;- updatedByUserId: string | null;- createdAt: string;- updatedAt: string;-}--export interface ProjectDocument extends ProjectDocumentSummary {- content: string;- contentJson: Record<string, unknown> | null;-}--export interface DocumentIssueLink {- issueId: number;- sequenceNumber: number;- identifier: string;- title: string;- archived: boolean;- createdAt: string;-}--export interface IssueDocumentLink {- documentId: number;- title: string;- icon: string | null;- isPrivate: boolean;- archived: boolean;- createdAt: string;-}--export interface NewProjectDocumentInput {- title?: string;- content?: string;- contentJson?: Record<string, unknown> | null;- icon?: string | null;- metadata?: Record<string, unknown>;- fullWidth?: boolean;- isPrivate?: boolean;- parentId?: number | null;-}--export interface ProjectDocumentPatch {- version: number;- title?: string;- content?: string;- contentJson?: Record<string, unknown> | null;- icon?: string | null;- metadata?: Record<string, unknown>;- fullWidth?: boolean;- parentId?: number | null;- position?: number;- previousSiblingId?: number | null;- nextSiblingId?: number | null;-}--export interface ProjectDocumentRevisionSummary {- id: number;- documentId: number;- version: number;- title: string;- createdByUserId: string | null;- createdAt: string;-}--export interface ProjectDocumentRevision extends ProjectDocumentRevisionSummary {- parentId: number | null;- content: string;- contentJson: Record<string, unknown> | null;- icon: string | null;- metadata: Record<string, unknown>;- fullWidth: boolean;- isPrivate: boolean;- isLocked: boolean;- archivedAt: string | null;- position: number;-}--export interface ProjectDocumentExport {- filename: string;- mimeType: 'text/markdown';- content: string;- version: number;- exportedAt: string;-}--export interface DocumentAsset {- id: string;- filename: string;- contentType: string;- sizeBytes: number;- uploadedByUserId: string | null;- createdAt: string;- url: string;-}--function withDocumentAssetUrl(asset: DocumentAsset): DocumentAsset {- const match = asset.url.match(- /^\/projects\/([^/]+)\/documents\/(\d+)\/assets\/([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})\/raw$/i,- );- if (!match) throw new Error('The document asset URL returned by the API is invalid');- const [, encodedProjectKey, documentId, publicId] = match;- return {- ...asset,- url: `/protected-media/projects/${encodeURIComponent(decodeURIComponent(encodedProjectKey))}/documents/${documentId}/assets/${publicId}/raw`,- };-}--async function sendDocumentAssetFile(- projectKey: string,- documentId: number,- file: File,-): Promise<DocumentAsset> {- const form = new FormData();- form.append('file', file);- const res = await fetch(`${API_URL}/projects/${projectKey}/documents/${documentId}/assets`, {- method: 'POST',- credentials: 'include',- body: form,- });- if (!res.ok) throw await apiFailure(res);- return withDocumentAssetUrl(await res.json());-}--// --- Analytics DTOs (project metrics behind the dashboard widgets) -----------------export interface AnalyticsStats {- open: number;- inProgress: number;- backlog: number;- overdue: number;- unassigned: number;- closedLast7d: number;-}--export interface BreakdownItem {- key: string;- label: string;- count: number;- color: string | null;-}--export type PulseUnit = 'hour' | 'day' | 'week';--// One heatmap cell from the server: a preformatted bucket label (for the hover-// tooltip) and its activity count. The series is ordered oldest to newest.-export interface PulseBucket {- label: string;- count: number;-}--export interface ThroughputWeek {- week: string;- created: number;- closed: number;-}--// One agent run in the project-wide feed (agent runs widget).-export interface AgentRunFeedItem {- id: number;- status: AgentRunStatus;- trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';- agentId: number;- agentName: string;- issueId: number | null;- issueSequence: number | null;- lastError: string | null;- createdAt: string;-}--// Agent run outcome counts over a window (agent health widget).-export interface AgentRunStats {- total: number;- success: number;- failed: number;- pending: number;-}--// Webhook delivery health over a window plus the subscription split (webhook health widget).-export interface WebhookStats {- total: number;- success: number;- failed: number;- pending: number;- activeWebhooks: number;- disabledWebhooks: number;-}--// One agent's workload row: delegated open issues and lifetime run outcomes.-export interface AgentWorkloadItem {- agentId: number;- agentName: string;- kind: string;- delegatedOpen: number;- runsTotal: number;- runsSuccess: number;- runsFailed: number;-}--export interface ActivityItem {- id: number;- issueId: number;- issueSequence: number;- issueTitle: string;- kind: 'comment' | 'activity';- actorUserId: string | null;- actorName: string | null;- body: string | null;- action: ActivityAction | null;- payload: ActivityPayload;- createdAt: string;-}--export interface ActivityPage {- items: ActivityItem[];- nextCursor: FeedCursor | null;-}--// A manual action: a saved macro on a project. `condition` is a FilterSet (empty-// = always available) that decides which issues the action shows on; `effect`-// is a partial issue patch over built-in fields applied in one update when the-// action runs. A present effect key sets that field (value may be null); an-// absent key leaves it unchanged.-export type ActionEffect = Pick<- IssuePatch,- 'columnId' | 'assigneeUserId' | 'priority' | 'typeId' | 'startDate' | 'dueDate' | 'labelIds'->;--export interface ActionDef {- id: number;- projectId: number;- name: string;- icon: string;- condition: FilterSet;- effect: ActionEffect;- position: number;- createdAt: string;-}--export interface NewActionInput {- name: string;- icon?: string;- condition?: FilterSet;- effect?: ActionEffect;-}--export interface ActionPatch {- name?: string;- icon?: string;- condition?: FilterSet;- effect?: ActionEffect;-}--// Outgoing webhook subscription (mirrors apps/api modules/webhooks/service.ts). The event-// types must stay in sync with WEBHOOK_EVENT_TYPES on the server.-export type WebhookEventType =- | 'issue.created'- | 'issue.updated'- | 'issue.deleted'- | 'issue.assigned'- | 'issue.state_changed'- | 'issue.label_changed'- | 'issue.link_changed'- | 'comment.created';--export const WEBHOOK_EVENT_TYPES: WebhookEventType[] = [- 'issue.created',- 'issue.updated',- 'issue.deleted',- 'issue.assigned',- 'issue.state_changed',- 'issue.label_changed',- 'issue.link_changed',- 'comment.created',-];--export interface Webhook {- id: number;- projectId: number;- url: string;- secret: string;- events: WebhookEventType[];- isActive: boolean;- createdAt: string;-}--export interface NewWebhookInput {- url: string;- events: WebhookEventType[];- isActive?: boolean;-}--export interface WebhookPatch {- url?: string;- events?: WebhookEventType[];- isActive?: boolean;-}--// A recorded delivery attempt for the history view. payload is the request body we-// sent; responseStatus/responseBody come from the last attempt; lastError is set-// on a failed or retrying delivery.-export interface WebhookDelivery {- id: number;- eventId: string;- eventType: WebhookEventType;- status: 'pending' | 'success' | 'failed';- attempts: number;- payload: unknown;- responseStatus: number | null;- responseBody: string | null;- lastError: string | null;- nextAttemptAt: string;- createdAt: string;-}--export interface WebhookDeliveryPage {- items: WebhookDelivery[];- nextCursor: number | null;-}--export interface Attachment {- id: string;- filename: string;- contentType: string;- sizeBytes: number;- createdAt: string;- // Absolute, no-auth URL — usable directly in <img>/<video> and in markdown.- url: string;-}--// `action` selects how the UI renders an activity row; the payload carries what-// changed (see ActivityPayload).-export type ActivityAction =- | 'created'- | 'title'- | 'description'- | 'status'- | 'assignee'- | 'delegate'- | 'priority'- | 'estimate'- | 'type'- | 'cycle'- | 'start_date'- | 'due_date'- | 'label_add'- | 'label_remove'- | 'link_add'- | 'link_remove'- | 'parent'- | 'subtask_add'- | 'subtask_remove'- | 'checklist_add'- | 'checklist_rename'- | 'checklist_remove'- | 'checklist_item_add'- | 'checklist_item_remove'- | 'worklog'- | 'field'- | 'archived'- | 'restored'- | 'git_pr'- // Entries recorded before the integration took other providers.- | 'github_pr'- | 'agent_started'- | 'agent_finished';--// One side of a change: the display-ready text snapshot (column/label/type/assignee-// name, raw priority, ISO date, or the new text of a long field) and the id of the-// row behind it when the side names one. A status side also carries the state type-// its column had at the time, a pull request its repository and number.-export interface ActivitySide {- value: string | null;- id?: number | string | null;- stateType?: string | null;- repo?: string;- number?: number;- // A 'worklog' side carries the day its time was spent on.- date?: string | null;-}--// What an activity row says changed. `subject` names the sub-item where the action-// alone is not enough (the custom field for 'field', the checklist of an item, the-// relation of a link); `from` and `to` are the two sides of the change. A side the-// action does not have is absent.-export interface ActivityPayload {- subject?: ActivitySide;- from?: ActivitySide;- to?: ActivitySide;-}--// One entry in an issue's timeline. kind selects which fields are set: a 'comment'-// carries body; an 'activity' carries action and payload.-// actorName is the author/actor snapshot (null when it was never set).-export interface FeedItem {- id: number;- issueId: number;- kind: 'comment' | 'activity';- // The comment this one replies to, null for a top-level entry.- replyToId: number | null;- actorUserId: string | null;- actorName: string | null;- body: string | null;- action: ActivityAction | null;- payload: ActivityPayload;- createdAt: string;-}--// Opaque keyset cursor returned by the feed endpoint; pass it back to load the-// next (older) page.-export interface FeedCursor {- ts: string;- id: number;-}--export interface FeedPage {- items: FeedItem[];- nextCursor: FeedCursor | null;-}--// One stretch of the grouped feed: the status the issue was in, and the entries of-// this page written while it was there. `to` is null for the stretch it is in now,-// and `repeat` marks a status the issue had already been in earlier.-export interface FeedGroup {- status: string | null;- from: string;- to: string | null;- durationMs: number;- repeat: boolean;- items: FeedItem[];-}--// A page of the feed split into stretches. Paged by the same cursor as FeedPage, so a-// stretch that spans a page boundary arrives in both, each time with that page's-// entries.-export interface GroupedFeedPage {- groups: FeedGroup[];- nextCursor: FeedCursor | null;-}--// The query string both feed reads take, empty for the first page.-function feedPageQuery(params: { cursor?: FeedCursor | null; limit?: number }): string {- const q = new URLSearchParams();- if (params.limit) q.set('limit', String(params.limit));- if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));- const qs = q.toString();- return qs ? `?${qs}` : '';-}--// One stretch the issue spent in a single column. `status` is the column under the-// name it carries now, falling back to the name it had at the time once it is-// deleted (null only when the stretch recorded none); `to` is null for the stretch-// the issue is in now. The entries written inside a stretch are a separate read-// (listTimelineItems), made when one is opened.-export interface TimelineSegment {- status: string | null;- from: string;- to: string | null;- durationMs: number;-}--export interface IssueFieldValue {- fieldId: number;- name: string;- fieldType: CustomFieldType;- value: string | number | boolean | null;- valueEnd: string | null;- optionIds: number[];-}--// A custom field value on the way in (setFieldValue). `value` carries the-// scalar types, `valueEnd` the end of a datetime_range, `optionIds` the-// select/multi_select ones; a field uses one or the other.-export interface IssueFieldValueInput {- value?: string | number | boolean | null;- valueEnd?: string | null;- optionIds?: number[];-}--// The caller's own role in a project (owner/member). Returned with the project;-// the resolved permission matrix is a sibling `permissions` field. See-// usePermissions.-export interface ProjectViewer {- role: MemberRole;- // The caller's standing in the team that owns the project, null when they are not- // a member of it. An owner or manager governs the project's settings alongside the- // project's own owner; 'agent' is a bot user reading its own board, which governs- // nothing.- teamRole: TeamRole | 'agent' | null;-}--// How an issue carries the initiative and the cycle it belongs to: the id plus-// what to render, and the initiative status the board orders its lanes by. The-// picker lists are InitiativeOption / CycleOption.-export interface InitiativeRef {- id: number;- title: string;- status: InitiativeStatus;-}--// One cycle an issue was in. The cycle history of an issue is a list of these,-// oldest first.-export interface IssueCycleEntry {- cycleId: number;- name: string;- startDate: string;- endDate: string;- status: CycleStatus;- enteredAt: string;- leftAt: string | null;-}--export interface CycleRef {- id: number;- name: string;- status: CycleStatus;-}--// The board scaffold, returned by getProject: everything the work-items UI needs-// except the issues themselves (those come from getBoardIssues).-export interface ProjectScaffold {- project: Project;- columns: Column[];- issueTypes: IssueType[];- labels: Label[];- labelGroups: LabelGroup[];- assignees: Assignee[];- // Every custom field of the project (all type scopes); consumers filter by- // issueTypeId locally.- customFields: CustomField[];- issueTemplates: IssueTemplate[];- viewer: ProjectViewer;- // The caller's resolved permission matrix (owners get every flag).- permissions: Permissions;-}--// An issue as a board carries it: with its relations to the project's other active-// issues. The board payload and the public share bundle have them; a write response-// returns a plain Issue.-export interface BoardIssue extends Issue {- links: IssueLinkRef[];- // How many subtasks the issue has, archived ones included. The board carries- // only active issues, so an archived subtask shows up nowhere else — and a- // delete or an archive still has to ask about it.- subtaskCount: number;-}--export interface BoardIssues {- issues: BoardIssue[];-}--// The scaffold composed with its issues and the project's unfinished cycles, as-// the Shell assembles it and passes it down. Downstream reads project.issues off-// this composite. `plannedCycles` is empty while the Cycles section is off and on a-// public share (whose bundle carries no cycle list).-export type ProjectDetail = ProjectScaffold & BoardIssues & { plannedCycles: CycleOption[] };--export interface IssueDetail extends Issue {- fields: IssueFieldValue[];-}--export type GitProvider = 'github' | 'gitlab' | 'gitea' | 'forgejo' | 'bitbucket';-export type PullRequestState = 'open' | 'merged' | 'closed';-export type PipelineStatus = 'pending' | 'running' | 'success' | 'failed' | 'canceled' | 'skipped';--export interface DevelopmentCheck {- id: number;- name: string;- status: PipelineStatus;- url: string | null;- updatedAt: string;-}--export interface DevelopmentLink {- id: number;- provider: GitProvider;- repository: string;- kind: 'pull_request' | 'branch';- number: number | null;- title: string;- url: string | null;- state: PullRequestState;- draft: boolean;- sourceBranch: string | null;- targetBranch: string;- headSha: string | null;- pipelineStatus: PipelineStatus | null;- pipelineUrl: string | null;- checkStatus: PipelineStatus | null;- checks: DevelopmentCheck[];- updatedAt: string;-}--export interface DevelopmentRepository {- id: number;- provider: 'github' | 'gitlab';- fullName: string;- webUrl: string;-}--export interface LinkablePullRequest {- number: number;- title: string;- url: string | null;- state: PullRequestState;- draft: boolean;- sourceBranch: string | null;- targetBranch: string;- headSha: string | null;- updatedAt: string;- linked: boolean;-}--export interface LinkablePullRequestPage {- pullRequests: LinkablePullRequest[];- nextPage: number | null;-}--export interface DevelopmentBranchPage {- branches: string[];- defaultBranch: string | null;- nextPage: number | null;-}--export interface CreateIssuePullRequestInput {- repositoryId: number;- sourceBranch: string;- targetBranch: string;- title: string;- description: string;- draft: boolean;-}--// A relation between two issues (mirrors apps/api modules/issues/links.ts). 'blocks' and-// 'duplicates' are directional and read differently on each end, which direction-// selects: 'outward' is the side that blocks/duplicates, 'inward' the side that is-// blocked/duplicated. On a symmetric 'relates' relation direction means nothing.-export type IssueLinkKind = 'blocks' | 'relates' | 'duplicates';-export type IssueLinkDirection = 'outward' | 'inward';--// What linkIssues accepts: the stored kinds plus the inverse reading of the two-// directional ones, so a relation can be stated from either end.-export type IssueLinkInputKind = IssueLinkKind | 'blocked_by' | 'duplicated_by';--export interface IssueLink {- id: number;- kind: IssueLinkKind;- direction: IssueLinkDirection;- // The issue on the other end of the relation.- issue: IssueRef;-}--// One of an issue's relations as the board payload carries it: how the relation-// reads from this issue, and the id of the issue on the other end. Both ends-// carry it, each with its own reading; the views name the other end by looking-// the id up among the board's issues, which is why a relation to an archived-// issue is not sent.-export interface IssueLinkRef {- id: number;- relation: IssueLinkInputKind;- issueId: number;-}--// A member following an issue: they receive every notification it produces.-export interface IssueWatcher {- userId: string;- name: string;- image: string | null;-}--// Another issue named with the state it is in: an issue's parent, one of its-// subtasks, or the other end of a relation.-export interface IssueRef {- id: number;- sequenceNumber: number;- identifier: string;- title: string;- columnId: number;- typeId: number | null;- archived: boolean;-}--// What a delete or an archive does with the issue's subtasks: they follow it-// (deleted with a delete, archived with an archive), they are detached into-// ordinary issues, or they move to another parent. Required whenever the issue-// being removed has subtasks.-export type SubtaskMode = 'cascade' | 'detach' | 'reassign';--export interface SubtaskDisposition {- subtasks: SubtaskMode;- newParentId?: number;-}--// One checkbox line of a checklist.-export interface ChecklistItem {- id: number;- content: string;- done: boolean;- position: number;-}--// A checklist on an issue: steps too small to be subtasks of their own. Both the-// checklists of an issue and the items of a checklist come back in display order.-export interface Checklist {- id: number;- title: string;- position: number;- items: ChecklistItem[];-}--// One entry of the time a member logged on an issue: how long they worked, the day-// the work happened on, an optional note, and the member it belongs to. The time an-// issue took is the sum of its entries (Issue.loggedMinutes).-export interface Worklog {- id: number;- issueId: number;- userId: string;- userName: string | null;- userImage: string | null;- minutes: number;- spentOn: string;- note: string | null;- createdAt: string;-}--// What a new entry carries. A change sends the same fields, any subset of them.-export interface WorklogInput {- minutes: number;- spentOn: string;- note?: string | null;-}--// The issue with its relations and its place in the subtask hierarchy. Shared-// pages carry this much; the detail routes add the watchers and the checklists,-// neither of which a public page exposes.-export interface IssueRelations extends IssueDetail {- links: IssueLink[];- parent: IssueRef | null;- subtasks: IssueRef[];-}--// The issue as the detail routes return it.-export interface IssueWithWatchers extends IssueRelations {- watchers: IssueWatcher[];- checklists: Checklist[];- development: DevelopmentLink[];-}--// Public read-only share bundles, returned by the /share/* routes with no session.-// The scaffold mirrors ProjectScaffold minus the caller's viewer/permissions and-// member emails and handles (a public page shows names and avatars only).-export type PublicScaffold = Omit<ProjectScaffold, 'viewer' | 'permissions' | 'assignees'> & {- assignees: Omit<Assignee, 'email' | 'username' | 'canReadWorkItems'>[];-};--export interface SharedIssueBundle {- project: PublicScaffold;- issue: IssueRelations;- feed: FeedItem[];-}--export interface SharedViewBundle {- project: PublicScaffold;- // The view's own filters stay on the server: it has already applied them to the- // issues below, and they can name assignees, labels and custom field values a- // link without `extended` withholds.- view: {- name: string;- icon: string | null;- display: SavedViewDisplay;- // Whether the link exposes the full issues or only their title, description,- // state, type, priority, dates, subtasks and links.- extended: boolean;- };- issues: BoardIssue[];-}--export interface NewIssueInput {- typeId?: number | null;- initiativeId?: number | null;- cycleId?: number | null;- assigneeUserId?: string | null;- delegateUserId?: string | null;- columnId: number;- parentId?: number | null;- title: string;- description?: string;- priority?: string | null;- estimatePoints?: number | null;- estimateMinutes?: number | null;- startDate?: string | null;- dueDate?: string | null;- labelIds?: number[];-}--// The fields a bulk update can set on many issues at once (the board-relevant-// subset of IssuePatch: no title/description/position).-export interface BulkIssuePatch {- columnId?: number;- typeId?: number | null;- initiativeId?: number | null;- cycleId?: number | null;- assigneeUserId?: string | null;- delegateUserId?: string | null;- priority?: string | null;- estimatePoints?: number | null;- estimateMinutes?: number | null;- startDate?: string | null;- dueDate?: string | null;-}--export interface IssuePatch {- columnId?: number;- position?: number;- typeId?: number | null;- parentId?: number | null;- initiativeId?: number | null;- cycleId?: number | null;- assigneeUserId?: string | null;- delegateUserId?: string | null;- title?: string;- description?: string;- priority?: string | null;- estimatePoints?: number | null;- estimateMinutes?: number | null;- startDate?: string | null;- dueDate?: string | null;- labelIds?: number[];-}--// --- Initiatives ------------------------------------------------------------------// A project-scoped grouping of issues. progress and health are derived server-side-// from the linked issues' states (health is null when there is nothing to judge).--export type InitiativeStatus = 'proposed' | 'planned' | 'active' | 'completed' | 'canceled';-export type InitiativeHealth = 'on_track' | 'at_risk' | 'off_track';--export interface InitiativeProgress {- completed: number;- canceled: number;- total: number;-}--export interface Initiative {- id: number;- projectId: number;- title: string;- description: string;- status: InitiativeStatus;- ownerUserId: string | null;- priority: string | null;- startDate: string | null;- targetDate: string | null;- position: number;- createdAt: string;- updatedAt: string;- labelIds: number[];- progress: InitiativeProgress;- health: InitiativeHealth | null;-}--// An initiative as a picker option, for linking an issue to one.-export interface InitiativeOption {- id: number;- title: string;- status: InitiativeStatus;-}--// A time-boxed period of work (a sprint). status follows from the dates against-// today, unless the cycle was finished ahead of them; progress follows from the-// linked issues' states.-export type CycleStatus = 'upcoming' | 'active' | 'completed';--// A cycle as a picker option, for planning an issue into one.-export interface CycleOption {- id: number;- name: string;- status: CycleStatus;-}--export interface CycleProgress {- completed: number;- canceled: number;- total: number;-}--export interface Cycle {- id: number;- projectId: number;- name: string;- // What the team commits to in this cycle (the sprint goal). Empty when unset.- goal: string;- startDate: string;- endDate: string;- // When the cycle was finished ahead of its planned end date, or null. endDate- // keeps the date it was planned to run until either way.- completedAt: string | null;- status: CycleStatus;- createdAt: string;- updatedAt: string;- progress: CycleProgress;-}--export interface NewCycleInput {- name: string;- goal?: string;- startDate: string;- endDate: string;-}--export interface CyclePatch {- name?: string;- goal?: string;- startDate?: string;- endDate?: string;-}--// Columns the initiative list can be sorted by, server-side. progress and health-// are derived and not sortable.-export const INITIATIVE_SORTS = ['title', 'priority', 'targetDate', 'owner'] as const;--export type InitiativeSort = (typeof INITIATIVE_SORTS)[number];--export interface InitiativeListParams extends PageParams {- statuses?: string[];- search?: string;- sort?: InitiativeSort;- dir?: 'asc' | 'desc';-}--// Per-status initiative counts for the list's status tabs.-export interface InitiativeCounts {- total: number;- proposed: number;- planned: number;- active: number;- completed: number;- canceled: number;-}--export interface NewInitiativeInput {- title: string;- description?: string;- status?: InitiativeStatus;- ownerUserId?: string | null;- priority?: string | null;- startDate?: string | null;- targetDate?: string | null;- labelIds?: number[];-}--export interface InitiativePatch {- title?: string;- description?: string;- status?: InitiativeStatus;- ownerUserId?: string | null;- priority?: string | null;- startDate?: string | null;- targetDate?: string | null;- labelIds?: number[];-}--// One entry in an initiative's feed: an event of the initiative itself (source-// 'initiative') or the activity of a linked issue (source 'issue', carrying the-// issue's id and identifier so the row can link to it).-export interface InitiativeFeedItem {- id: number;- source: 'initiative' | 'issue';- kind: 'comment' | 'activity';- actorUserId: string | null;- actorName: string | null;- body: string | null;- action: string | null;- payload: ActivityPayload;- createdAt: string;- issueId: number | null;- issueIdentifier: string | null;-}--export interface InitiativeFeedPage {- items: InitiativeFeedItem[];- nextCursor: FeedCursor | null;-}--// A field can be reshaped after it exists, and the values issues hold follow: a new-// fieldType clears them, a narrowed memberScope clears the ones it no longer allows,-// and an option missing from `options` is deleted along with the selections of it.-export interface CustomFieldPatch {- name?: string;- showInBody?: boolean;- fieldType?: CustomFieldType;- memberScope?: MemberScope;- // The full option list of a select field, in display order. An entry with an id- // renames that option; one without is new.- options?: { id?: number; value: string }[];-}--export interface NewCustomFieldInput {- issueTypeId?: number | null;- name: string;- fieldType: CustomFieldType;- memberScope?: MemberScope;- showInBody?: boolean;- options?: string[];-}--export interface NewIssueTemplateInput {- name: string;- description?: string;- titleTemplate?: string;- descriptionTemplate?: string;- typeId?: number | null;- columnId?: number | null;- priority?: string | null;- assigneeUserId?: string | null;- labelIds?: number[];-}--// A property left out keeps its value; `labelIds` replaces the whole label set.-export type IssueTemplatePatch = Partial<NewIssueTemplateInput>;--// The project permission matrix (mirrors apps/api shared/permissions.ts): each-// resource grants or denies 4 actions. A custom role carries one matrix.-export type PermissionAction = 'create' | 'edit' | 'read' | 'delete';--export type PermissionResource =- | 'work_items'- | 'initiatives'- | 'cycles'- | 'dashboards'- | 'documents'- | 'views'- | 'members_invite'- | 'members_manage'- | 'states'- | 'issue_types'- | 'labels'- | 'ai_agents'- | 'integrations'- | 'agent_skills'- | 'agent_tools'- | 'custom_fields'- | 'issue_templates'- | 'workflow_config'- | 'actions'- | 'webhooks'- | 'note_boards'- | 'danger_zone';--export type ResourcePermissions = Record<PermissionAction, boolean>;-export type Permissions = Record<PermissionResource, ResourcePermissions>;--// A project's custom role: a named permission matrix that can be assigned to a-// member. `isDefault` marks the fallback role new members get; it cannot be deleted.-export interface Role {- id: number;- name: string;- isDefault: boolean;- permissions: Permissions;- createdAt: string;-}--// What a role list asks for: the window, and a search over the name.-export interface RoleListParams extends PageParams {- search?: string;-}--// What a role is assigned to. Everything counted here is moved to another role-// before the role can be deleted.-export interface RoleUsage {- members: number;- agents: number;- invites: number;- // The provisioned group mappings that grant this role.- groups: number;-}--// The resources and actions the role editor renders. Fetched so the UI matches the-// API's matrix without hardcoding the list in two places. `actions` is the full-// column set; a resource lists the subset it supports, and a cell outside that-// subset is always denied.-export interface PermissionCatalogResource {- key: PermissionResource;- actions: PermissionAction[];-}--export interface PermissionCatalog {- resources: PermissionCatalogResource[];- actions: PermissionAction[];-}--// Project membership: a user's access to a project and their role in it. A member of-// the team that owns the project is added straight away; everyone else joins through-// an invite.-export type MemberRole = 'owner' | 'member';--export interface MemberRow {- userId: string;- name: string;- email: string;- // The sign-in name. null for an AI agent's bot user, which never gets one.- username: string | null;- image: string | null;- // The zone this member reads timestamps in, from their preferences.- timezone: string;- role: MemberRole;- // The assigned custom role. null when the member uses the project's default- // role; owners never use roles (both fields null).- roleId: number | null;- roleName: string | null;- // What this member does in the project, set by an owner. Empty string when unset.- description: string;- // True when this member is an AI agent's bot user. It joins and leaves with its AI- // Agent config, so this list does not revoke it; its role is set here like a- // person's.- isAgent: boolean;- // 'scim' when a provisioned group granted this membership. The sync rewrites such- // a row on every run, so the role and remove actions are refused for it.- source: 'invite' | 'scim';- createdAt: string;-}--// Which members a list asks for: everyone, the people, or the AI agents.-export type MemberKind = 'all' | 'human' | 'agent';--// How many members own the project is what a page window cannot answer, and the last-// owner's row is the one that may not be removed.-export type MemberPage = Page<MemberRow> & { ownerCount: number };--// The filters every member list takes, on top of the page window. The search runs on-// the server, so the page and the total agree.-export interface MemberListParams extends PageParams {- search?: string;- kind: MemberKind;-}--function memberListQuery(params: MemberListParams): string {- return pageQuery(params, { kind: params.kind, search: params.search });-}--// Someone who can be added to a project without an invite: a member of the team that-// owns it who is not in the project yet.-export interface MemberCandidate {- userId: string;- name: string;- email: string;- username: string | null;- image: string | null;- isAgent: boolean;-}--export type InviteStatus = 'pending' | 'accepted' | 'rejected';--// The rank an invite puts its invitee on in the team. Only a team owner sends one-// that grants 'owner' or 'manager'.-export type InviteTeamRole = 'owner' | 'manager' | 'member';--// An invite as shown to whoever manages a team's or a project's invites: carries the-// token so they can share the link, and who sent it.-export interface InviteRow {- id: number;- token: string;- email: string;- teamRole: InviteTeamRole;- // The project the invitee joins along with the team, or null for an invite into- // the team alone.- projectKey: string | null;- projectName: string | null;- // Their role in that project. null when the invite names no project.- role: MemberRole | null;- // The custom role the invitee joins the project on. null falls back to the team's- // default role; roleName resolves it for display. A project owner has both null.- roleId: number | null;- roleName: string | null;- status: InviteStatus;- createdAt: string;- respondedAt: string | null;- invitedByName: string | null;- invitedByEmail: string | null;-}--export interface InviteCreateResult extends InviteRow {- emailQueued: boolean;-}--export interface InviteEmailResult {- emailQueued: boolean;-}--// An invite as shown to the invitee opening the link: enough team and project-// context to decide, never the internal ids.-export interface InviteView {- token: string;- teamName: string;- projectKey: string | null;- projectName: string | null;- email: string;- teamRole: InviteTeamRole;- role: MemberRole | null;- roleId: number | null;- roleName: string | null;- status: InviteStatus;- createdAt: string;- // Whether the invited email already has an account, so the accept screen can- // open in sign-in mode instead of registration.- hasAccount: boolean;-}--// Where an invitee landed once the invite was accepted.-export interface AcceptedInvite {- teamName: string;- projectKey: string | null;- projectName: string | null;- role: MemberRole | null;-}--// The attachment DTO's url is relative to the API origin; point it at the web-// origin's media route so it works in <img>/<video> and markdown rendered there.-function withMediaUrl(a: Attachment): Attachment {- return { ...a, url: mediaUrl(a.url) };-}--// Multipart upload — cannot use request(), which forces a JSON Content-Type; the-// browser must set the multipart boundary itself, so no headers are set.-async function sendAttachmentFile(- path: string,- method: 'POST' | 'PUT',- file: File,-): Promise<Attachment> {- const form = new FormData();- form.append('file', file);- const res = await fetch(`${API_URL}${path}`, { method, credentials: 'include', body: form });- if (!res.ok) throw await apiFailure(res);- return withMediaUrl(await res.json());-}--// Inbox notifications. Each row is enriched with the issue and project it points at-// so the list renders without extra calls.-export type NotificationType = 'assigned' | 'mentioned' | 'commented' | 'state_changed';--export interface Notification {- id: number;- type: NotificationType;- actorUserId: string | null;- actorName: string | null;- readAt: string | null;- snoozedUntil: string | null;- createdAt: string;- issueId: number;- issueSeq: number;- issueTitle: string;- issueStateType: StateType;- projectId: number;- projectKey: string;- projectName: string;- // Only a 'state_changed' notification has them.- fromState: string | null;- toState: string | null;-}--export interface NotificationCursor {- ts: string;- id: number;-}--export interface NotificationPage {- items: Notification[];- nextCursor: NotificationCursor | null;-}--export interface NotificationFilters {- types?: NotificationType[];- from?: string;- includeRead?: boolean;- includeSnoozed?: boolean;-}--export type NotificationDeleteScope = 'all' | 'read' | 'read-completed';--// The subtask disposition as the delete route takes it: a query string, since a-// DELETE carries no body.-function subtaskQuery(disposition?: SubtaskDisposition): string {- if (!disposition) return '';- const qs = new URLSearchParams({ subtasks: disposition.subtasks });- if (disposition.newParentId != null) qs.set('newParentId', String(disposition.newParentId));- return `?${qs.toString()}`;-}--export const api = {- listTeams: () => request<Team[]>('/teams'),- getTeam: (teamId: number) => request<TeamDetail>(`/teams/${teamId}`),- // One page of the team's members. `search` matches the name, the address or the- // handle.- listTeamMembers: (teamId: number, params: MemberListParams) =>- request<Page<TeamMember>>(`/teams/${teamId}/members${memberListQuery(params)}`),- // One page of the projects the team owns. `search` matches the key or the name.- listTeamProjects: (teamId: number, params: TeamProjectListParams) =>- request<Page<TeamProject>>(- `/teams/${teamId}/projects${pageQuery(params, { search: params.search })}`,- ),- // Every project the reader has in the team, for the agent's project picker and the- // MCP switches.- listTeamProjectOptions: (teamId: number) =>- request<TeamProjectOption[]>(`/teams/${teamId}/projects/options`),- getTeamProject: (teamId: number, projectId: number) =>- request<TeamProjectDetail>(`/teams/${teamId}/projects/${projectId}`),- // One page of a project's members. `search` matches the name, the address or the- // handle.- listTeamProjectMembers: (teamId: number, projectId: number, params: MemberListParams) =>- request<Page<TeamProjectMember>>(- `/teams/${teamId}/projects/${projectId}/members${memberListQuery(params)}`,- ),- createTeam: (input: { name: string }) =>- request<Team>('/teams', { method: 'POST', body: JSON.stringify(input) }),- renameTeam: (teamId: number, input: { name: string }) =>- request<Team>(`/teams/${teamId}`, { method: 'PATCH', body: JSON.stringify(input) }),- leaveTeam: (teamId: number) => request<void>(`/teams/${teamId}/leave`, { method: 'POST' }),- setTeamMemberRole: (teamId: number, userId: string, role: TeamRole) =>- request<void>(`/teams/${teamId}/members/${userId}`, {- method: 'PATCH',- body: JSON.stringify({ role }),- }),- removeTeamMember: (teamId: number, userId: string) =>- request<void>(`/teams/${teamId}/members/${userId}`, { method: 'DELETE' }),- updateTeamMcp: (- teamId: number,- patch: { enabled?: boolean; projects?: { projectId: number; enabled: boolean }[] },- ) =>- request<TeamMcpSettings>(`/teams/${teamId}/mcp`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- // The projects a team owns: created, copied, and deleted by the team's own ranks- // (owner/manager create and copy, owner deletes) rather than by project membership.- createTeamProject: (- teamId: number,- input: { key: string; name: string; description?: string; preset?: string },- ) =>- request<Project>(`/teams/${teamId}/projects`, {- method: 'POST',- body: JSON.stringify(input),- }),- copyTeamProject: (- teamId: number,- projectId: number,- input: {- key: string;- name: string;- description?: string;- include?: Partial<Record<CopyProjectIncludeKey, boolean>>;- },- ) =>- request<Project>(`/teams/${teamId}/projects/${projectId}/copy`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateTeamProject: (- teamId: number,- projectId: number,- patch: { name?: string; description?: string },- ) =>- request<Project>(`/teams/${teamId}/projects/${projectId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteTeamProject: (teamId: number, projectId: number) =>- request<void>(`/teams/${teamId}/projects/${projectId}`, { method: 'DELETE' }),- listProjects: () => request<Project[]>('/projects'),- createProject: (input: { key: string; name: string; description?: string; preset?: string }) =>- request<Project>('/projects', { method: 'POST', body: JSON.stringify(input) }),- // Update a project's name/description. The key is immutable, so it is not sent.- updateProject: (projectKey: string, patch: { name?: string; description?: string }) =>- request<Project>(`/projects/${projectKey}`, { method: 'PATCH', body: JSON.stringify(patch) }),- // The board scaffold (no issues). The issues come from getBoardIssues.- getProject: (projectKey: string) => request<ProjectScaffold>(`/projects/${projectKey}`),- // The board's issues and their relations.- getBoardIssues: (projectKey: string) =>- request<BoardIssues>(`/projects/${projectKey}/issues/board`),- // The change markers of every scope the client is watching, in one request.- // Polled by the sync provider; see utils/revScopes.- getRevs: (scopes: string[]) =>- request<{ revs: Record<string, string> }>(`/sync/rev?scopes=${scopes.join(',')}`),-- createColumn: (- projectKey: string,- input: {- name: string;- stateType: StateType;- color?: string;- wipLimit?: number | null;- wipMode?: WipMode;- autoAssignUserId?: string | null;- },- ) =>- request<Column>(`/projects/${projectKey}/columns`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateColumn: (- projectKey: string,- columnId: number,- patch: {- name?: string;- stateType?: StateType;- color?: string;- // null clears the limit; absent leaves it as it is.- wipLimit?: number | null;- wipMode?: WipMode;- // null clears the automatic assignment; absent leaves it as it is.- autoAssignUserId?: string | null;- },- ) =>- request<Column>(`/projects/${projectKey}/columns/${columnId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- reorderColumns: (projectKey: string, orderedIds: number[]) =>- request<Column[]>(`/projects/${projectKey}/columns/reorder`, {- method: 'PUT',- body: JSON.stringify({ orderedIds }),- }),- deleteColumn: (- projectKey: string,- columnId: number,- body: { mode: 'move'; targetColumnId: number } | { mode: 'delete' },- ) =>- request<void>(`/projects/${projectKey}/columns/${columnId}`, {- method: 'DELETE',- body: JSON.stringify(body),- }),-- createIssueType: (- projectKey: string,- input: { name: string; icon?: string; color?: string; isDefault?: boolean },- ) =>- request<IssueType>(`/projects/${projectKey}/issue-types`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateIssueType: (- projectKey: string,- typeId: number,- patch: { name?: string; color?: string; isDefault?: boolean },- ) =>- request<IssueType>(`/projects/${projectKey}/issue-types/${typeId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteIssueType: (projectKey: string, typeId: number) =>- request<void>(`/projects/${projectKey}/issue-types/${typeId}`, { method: 'DELETE' }),-- createLabel: (- projectKey: string,- input: { name: string; color?: string; groupId?: number | null },- ) =>- request<Label>(`/projects/${projectKey}/labels`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateLabel: (- projectKey: string,- labelId: number,- patch: { name?: string; color?: string; groupId?: number | null },- ) =>- request<Label>(`/projects/${projectKey}/labels/${labelId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteLabel: (projectKey: string, labelId: number) =>- request<void>(`/projects/${projectKey}/labels/${labelId}`, { method: 'DELETE' }),-- createLabelGroup: (projectKey: string, input: { name: string; color?: string }) =>- request<LabelGroup>(`/projects/${projectKey}/label-groups`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateLabelGroup: (- projectKey: string,- groupId: number,- patch: { name?: string; color?: string },- ) =>- request<LabelGroup>(`/projects/${projectKey}/label-groups/${groupId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteLabelGroup: (projectKey: string, groupId: number) =>- request<void>(`/projects/${projectKey}/label-groups/${groupId}`, { method: 'DELETE' }),-- createCustomField: (projectKey: string, input: NewCustomFieldInput) =>- request<CustomField>(`/projects/${projectKey}/custom-fields`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateCustomField: (projectKey: string, fieldId: number, patch: CustomFieldPatch) =>- request<CustomField>(`/projects/${projectKey}/custom-fields/${fieldId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteCustomField: (projectKey: string, fieldId: number) =>- request<void>(`/projects/${projectKey}/custom-fields/${fieldId}`, { method: 'DELETE' }),-- createIssueTemplate: (projectKey: string, input: NewIssueTemplateInput) =>- request<IssueTemplate>(`/projects/${projectKey}/issue-templates`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateIssueTemplate: (projectKey: string, templateId: number, patch: IssueTemplatePatch) =>- request<IssueTemplate>(`/projects/${projectKey}/issue-templates/${templateId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteIssueTemplate: (projectKey: string, templateId: number) =>- request<void>(`/projects/${projectKey}/issue-templates/${templateId}`, { method: 'DELETE' }),-- createIssue: (projectKey: string, input: NewIssueInput) =>- request<Issue>(`/projects/${projectKey}/issues`, {- method: 'POST',- body: JSON.stringify(input),- }),- getIssue: (id: number) => request<IssueWithWatchers>(`/issues/${id}`),- listIssueCycles: (id: number) => request<IssueCycleEntry[]>(`/issues/${id}/cycles`),-- // Public read-only sharing. Enabling returns the link token and sets how much it- // exposes; calling it again on a shared entity keeps the link and only changes- // that. Disable revokes it. The getShared* reads need no session (public- // /share/* routes).- enableIssueShare: (id: number, extended: boolean) =>- request<{ token: string }>(`/issues/${id}/share`, {- method: 'POST',- body: JSON.stringify({ extended }),- }),- disableIssueShare: (id: number) => request<void>(`/issues/${id}/share`, { method: 'DELETE' }),- enableViewShare: (id: number, extended: boolean) =>- request<{ token: string }>(`/views/${id}/share`, {- method: 'POST',- body: JSON.stringify({ extended }),- }),- disableViewShare: (id: number) => request<void>(`/views/${id}/share`, { method: 'DELETE' }),- getSharedIssue: (token: string) => request<SharedIssueBundle>(`/share/issue/${token}`),- getSharedView: (token: string) => request<SharedViewBundle>(`/share/view/${token}`),- getSharedViewIssue: (token: string, issueId: number) =>- request<SharedIssueBundle>(`/share/view/${token}/issues/${issueId}`),- // Resolve an issue by its project-scoped number (the human "42" in the URL).- getIssueBySeq: (projectKey: string, seq: number) =>- request<IssueWithWatchers>(`/projects/${projectKey}/issues/${seq}`),- updateIssue: (id: number, patch: IssuePatch) =>- request<Issue>(`/issues/${id}`, { method: 'PATCH', body: JSON.stringify(patch) }),- removeIssueDevelopmentLink: (issueId: number, linkId: number) =>- request<void>(`/issues/${issueId}/development/${linkId}`, { method: 'DELETE' }),- listIssueDevelopmentRepositories: (issueId: number) =>- request<DevelopmentRepository[]>(`/issues/${issueId}/development/repositories`),- listLinkablePullRequests: (- issueId: number,- repositoryId: number,- input: { state: 'open' | 'all'; page: number },- ) =>- request<LinkablePullRequestPage>(- `/issues/${issueId}/development/repositories/${repositoryId}/pull-requests?${new URLSearchParams(- { state: input.state, page: String(input.page) },- )}`,- ),- listDevelopmentBranches: (issueId: number, repositoryId: number, page: number) =>- request<DevelopmentBranchPage>(- `/issues/${issueId}/development/repositories/${repositoryId}/branches?page=${page}`,- ),- linkIssueDevelopment: (issueId: number, input: { repositoryId: number; number: number }) =>- request<DevelopmentLink>(`/issues/${issueId}/development`, {- method: 'POST',- body: JSON.stringify(input),- }),- createIssuePullRequest: (issueId: number, input: CreateIssuePullRequestInput) =>- request<DevelopmentLink>(`/issues/${issueId}/development/pull-requests`, {- method: 'POST',- body: JSON.stringify(input),- }),- // An issue that has subtasks needs a disposition saying what happens to them;- // without one the server rejects the delete with a 409.- deleteIssue: (id: number, subtasks?: SubtaskDisposition) =>- request<void>(`/issues/${id}${subtaskQuery(subtasks)}`, { method: 'DELETE' }),- // Board multi-select: apply one change to many issues in a single request. The- // server filters the ids to the project and refetching happens once.- bulkUpdateIssues: (projectKey: string, ids: number[], patch: BulkIssuePatch) =>- request<{ updated: number }>(`/projects/${projectKey}/issues/bulk`, {- method: 'PATCH',- body: JSON.stringify({ ids, patch }),- }),- bulkAddLabels: (projectKey: string, ids: number[], add: number[]) =>- request<{ updated: number }>(`/projects/${projectKey}/issues/bulk/labels`, {- method: 'POST',- body: JSON.stringify({ ids, add }),- }),- bulkArchiveIssues: (projectKey: string, ids: number[], subtasks?: SubtaskDisposition) =>- request<{ archived: number }>(`/projects/${projectKey}/issues/bulk/archive`, {- method: 'POST',- body: JSON.stringify({ ids, ...subtasks }),- }),- bulkDeleteIssues: (projectKey: string, ids: number[], subtasks?: SubtaskDisposition) =>- request<{ deleted: number }>(`/projects/${projectKey}/issues/bulk/delete`, {- method: 'POST',- body: JSON.stringify({ ids, ...subtasks }),- }),- // Archive/restore: hide an issue from the board (kept, restorable) or bring it- // back. The board excludes archived issues; the archive settings section lists them.- archiveIssue: (id: number, subtasks?: SubtaskDisposition) =>- request<Issue>(`/issues/${id}/archive`, {- method: 'POST',- body: JSON.stringify(subtasks ?? {}),- }),- restoreIssue: (id: number) => request<Issue>(`/issues/${id}/restore`, { method: 'POST' }),- listArchivedIssues: (projectKey: string) =>- request<Issue[]>(`/projects/${projectKey}/issues/archived`),- // Server-side text search for the command palette. Always returns all matches,- // archived included (each hit carries an `archived` flag).- searchIssues: (projectKey: string, params: { q?: string; limit?: number }) => {- const qs = new URLSearchParams();- if (params.q) qs.set('q', params.q);- if (params.limit != null) qs.set('limit', String(params.limit));- return request<IssueSearchHit[]>(`/projects/${projectKey}/issues/search?${qs.toString()}`);- },- // Relations between issues. The relation reads from the issue in the path: it- // blocks / relates to / duplicates targetIssueId. Both ends show it.- linkIssues: (issueId: number, targetIssueId: number, kind: IssueLinkInputKind) =>- request<IssueLink>(`/issues/${issueId}/links`, {- method: 'POST',- body: JSON.stringify({ targetIssueId, kind }),- }),- unlinkIssues: (issueId: number, linkId: number) =>- request<void>(`/issues/${issueId}/links/${linkId}`, { method: 'DELETE' }),-- // Following an issue. The singular routes act on the signed-in user; the- // watcher routes let an editor curate other project members. Every route- // returns the resulting watcher list.- watchIssue: (issueId: number) =>- request<IssueWatcher[]>(`/issues/${issueId}/watch`, { method: 'POST' }),- unwatchIssue: (issueId: number) =>- request<IssueWatcher[]>(`/issues/${issueId}/watch`, { method: 'DELETE' }),- addIssueWatcher: (issueId: number, userId: string) =>- request<IssueWatcher[]>(`/issues/${issueId}/watchers/${userId}`, { method: 'PUT' }),- removeIssueWatcher: (issueId: number, userId: string) =>- request<IssueWatcher[]>(`/issues/${issueId}/watchers/${userId}`, { method: 'DELETE' }),-- setFieldValue: (issueId: number, fieldId: number, input: IssueFieldValueInput) =>- request<{ ok: boolean }>(`/issues/${issueId}/fields/${fieldId}`, {- method: 'PUT',- body: JSON.stringify(input),- }),-- // Checklists on an issue. The issue read already carries them, so there is no- // list call of their own — a write refreshes that read.- createChecklist: (issueId: number, title: string) =>- request<Checklist>(`/issues/${issueId}/checklists`, {- method: 'POST',- body: JSON.stringify({ title }),- }),- renameChecklist: (checklistId: number, title: string) =>- request<Checklist>(`/checklists/${checklistId}`, {- method: 'PATCH',- body: JSON.stringify({ title }),- }),- deleteChecklist: (checklistId: number) =>- request<void>(`/checklists/${checklistId}`, { method: 'DELETE' }),- reorderChecklists: (issueId: number, orderedIds: number[]) =>- request<Checklist[]>(`/issues/${issueId}/checklists/reorder`, {- method: 'PUT',- body: JSON.stringify({ orderedIds }),- }),-- createChecklistItem: (checklistId: number, content: string) =>- request<ChecklistItem>(`/checklists/${checklistId}/items`, {- method: 'POST',- body: JSON.stringify({ content }),- }),- updateChecklistItem: (itemId: number, patch: { content?: string; done?: boolean }) =>- request<ChecklistItem>(`/checklists/items/${itemId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteChecklistItem: (itemId: number) =>- request<void>(`/checklists/items/${itemId}`, { method: 'DELETE' }),- reorderChecklistItems: (checklistId: number, orderedIds: number[]) =>- request<ChecklistItem[]>(`/checklists/${checklistId}/items/reorder`, {- method: 'PUT',- body: JSON.stringify({ orderedIds }),- }),-- // The time logged on an issue. Unlike the checklists these are not part of the- // issue read — it carries their sum, and only the section listing them needs the- // entries.- listWorklogs: (issueId: number) => request<Worklog[]>(`/issues/${issueId}/worklogs`),- createWorklog: (issueId: number, input: WorklogInput) =>- request<Worklog>(`/issues/${issueId}/worklogs`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateWorklog: (worklogId: number, patch: Partial<WorklogInput>) =>- request<Worklog>(`/worklogs/${worklogId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteWorklog: (worklogId: number) =>- request<void>(`/worklogs/${worklogId}`, { method: 'DELETE' }),-- listAttachments: (issueId: number) =>- request<Attachment[]>(`/issues/${issueId}/attachments`).then((rows) => rows.map(withMediaUrl)),- uploadAttachment: (issueId: number, file: File) =>- sendAttachmentFile(`/issues/${issueId}/attachments`, 'POST', file),- // Keeps the attachment's id and URL, so an embed of it in a description shows- // the new file.- replaceAttachment: (publicId: string, file: File) =>- sendAttachmentFile(`/attachments/${publicId}`, 'PUT', file),- deleteAttachment: (publicId: string) =>- request<void>(`/attachments/${publicId}`, { method: 'DELETE' }),-- listInitiativeAttachments: (initiativeId: number) =>- request<Attachment[]>(`/initiatives/${initiativeId}/attachments`).then((rows) =>- rows.map(withMediaUrl),- ),- uploadInitiativeAttachment: (initiativeId: number, file: File) =>- sendAttachmentFile(`/initiatives/${initiativeId}/attachments`, 'POST', file),- deleteInitiativeAttachment: (publicId: string) =>- request<void>(`/initiative-attachments/${publicId}`, { method: 'DELETE' }),-- listFeed: (issueId: number, params: { cursor?: FeedCursor | null; limit?: number } = {}) =>- request<FeedPage>(`/issues/${issueId}/feed${feedPageQuery(params)}`),- // The same page, split into the stretches the issue spent in one status.- listGroupedFeed: (issueId: number, params: { cursor?: FeedCursor | null; limit?: number } = {}) =>- request<GroupedFeedPage>(`/issues/${issueId}/feed/grouped${feedPageQuery(params)}`),- listTimeline: (issueId: number) => request<TimelineSegment[]>(`/issues/${issueId}/timeline`),- // The entries of one stretch of the timeline: [from, to), open-ended without `to`.- listTimelineItems: (issueId: number, from: string, to: string | null) => {- const q = new URLSearchParams({ from });- if (to) q.set('to', to);- return request<FeedItem[]>(`/issues/${issueId}/timeline/items?${q.toString()}`);- },- createComment: (issueId: number, input: { body: string; replyToId?: number }) =>- request<FeedItem>(`/issues/${issueId}/comments`, {- method: 'POST',- body: JSON.stringify(input),- }),-- // Initiatives — collection ops take projectKey; ops on one initiative take its- // own id and hit /initiatives/:id (like issues).- listInitiatives: (projectKey: string, params: InitiativeListParams) =>- request<Page<Initiative>>(- `/projects/${projectKey}/initiatives${pageQuery(params, {- status: params.statuses?.join(','),- search: params.search,- sort: params.sort,- dir: params.dir,- })}`,- ),- listInitiativeOptions: (projectKey: string, params: { search?: string; include?: number }) => {- const q = new URLSearchParams();- if (params.search) q.set('search', params.search);- if (params.include) q.set('include', String(params.include));- const qs = q.toString();- return request<InitiativeOption[]>(- `/projects/${projectKey}/initiatives/options${qs ? `?${qs}` : ''}`,- );- },- initiativeCounts: (projectKey: string) =>- request<InitiativeCounts>(`/projects/${projectKey}/initiatives/counts`),- getInitiative: (id: number) => request<Initiative>(`/initiatives/${id}`),- createInitiative: (projectKey: string, input: NewInitiativeInput) =>- request<Initiative>(`/projects/${projectKey}/initiatives`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateInitiative: (id: number, patch: InitiativePatch) =>- request<Initiative>(`/initiatives/${id}`, { method: 'PATCH', body: JSON.stringify(patch) }),- deleteInitiative: (id: number) => request<void>(`/initiatives/${id}`, { method: 'DELETE' }),- listInitiativeFeed: (id: number, params: { cursor?: FeedCursor | null; limit?: number } = {}) => {- const q = new URLSearchParams();- if (params.limit) q.set('limit', String(params.limit));- if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));- const qs = q.toString();- return request<InitiativeFeedPage>(`/initiatives/${id}/feed${qs ? `?${qs}` : ''}`);- },-- // Cycles — same shape as initiatives: the list takes projectKey, ops on one cycle- // take its own id and hit /cycles/:id.- listCycles: (projectKey: string) => request<Cycle[]>(`/projects/${projectKey}/cycles`),- listPlannedCycles: (projectKey: string) =>- request<Cycle[]>(`/projects/${projectKey}/cycles?status=planned`),- listCycleOptions: (projectKey: string) =>- request<CycleOption[]>(`/projects/${projectKey}/cycles/options`),- listCompletedCycles: (projectKey: string, params: PageParams) =>- request<Page<Cycle>>(`/projects/${projectKey}/cycles/completed${pageQuery(params)}`),- getCycle: (id: number) => request<Cycle>(`/cycles/${id}`),- createCycle: (projectKey: string, input: NewCycleInput) =>- request<Cycle>(`/projects/${projectKey}/cycles`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateCycle: (id: number, patch: CyclePatch) =>- request<Cycle>(`/cycles/${id}`, { method: 'PATCH', body: JSON.stringify(patch) }),- deleteCycle: (id: number) => request<void>(`/cycles/${id}`, { method: 'DELETE' }),- transferCycleIssues: (id: number, targetCycleId: number | null) =>- request<{ moved: number }>(`/cycles/${id}/transfer`, {- method: 'POST',- body: JSON.stringify({ targetCycleId }),- }),- finishCycle: (id: number) => request<Cycle>(`/cycles/${id}/finish`, { method: 'POST' }),- startNextCycle: (id: number) =>- request<{ cycle: Cycle; moved: number }>(`/cycles/${id}/start-next`, { method: 'POST' }),-- listViews: (projectKey: string) => request<View[]>(`/projects/${projectKey}/views`),- createView: (projectKey: string, input: NewViewInput) =>- request<View>(`/projects/${projectKey}/views`, { method: 'POST', body: JSON.stringify(input) }),- updateView: (viewId: number, patch: ViewPatch) =>- request<View>(`/views/${viewId}`, { method: 'PATCH', body: JSON.stringify(patch) }),- deleteView: (viewId: number) => request<void>(`/views/${viewId}`, { method: 'DELETE' }),- setViewFavorite: (viewId: number, favorite: boolean) =>- request<void>(`/views/${viewId}/favorite`, { method: favorite ? 'PUT' : 'DELETE' }),- reorderViews: (projectKey: string, orderedIds: number[]) =>- request<View[]>(`/projects/${projectKey}/views/reorder`, {- method: 'PUT',- body: JSON.stringify({ orderedIds }),- }),-- // Dashboards — same CRUD shape as views: collection ops take projectKey, ops on- // a single dashboard take its own id and hit /dashboards/:id.- listDashboards: (projectKey: string) =>- request<Dashboard[]>(`/projects/${projectKey}/dashboards`),- createDashboard: (projectKey: string, input: NewDashboardInput) =>- request<Dashboard>(`/projects/${projectKey}/dashboards`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateDashboard: (dashboardId: number, patch: DashboardPatch) =>- request<Dashboard>(`/dashboards/${dashboardId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteDashboard: (dashboardId: number) =>- request<void>(`/dashboards/${dashboardId}`, { method: 'DELETE' }),- reorderDashboards: (projectKey: string, orderedIds: number[]) =>- request<Dashboard[]>(`/projects/${projectKey}/dashboards/reorder`, {- method: 'PUT',- body: JSON.stringify({ orderedIds }),- }),-- // Note boards — all ops are project-scoped (a board that is not public is- // filtered to who may see it server-side), so board ops take projectKey plus the- // board id. The list feeds the switcher, which shows every board, so it comes whole- // with `q` narrowing it; a single board carries its canvas.- listNoteBoards: (projectKey: string, params: { q?: string } = {}) =>- request<NoteBoardSummary[]>(- `/projects/${projectKey}/note-boards${params.q ? `?q=${encodeURIComponent(params.q)}` : ''}`,- ),- getNoteBoard: (projectKey: string, boardId: number) =>- request<NoteBoard>(`/projects/${projectKey}/note-boards/${boardId}`),- listNoteBoardAccessCandidates: (projectKey: string) =>- request<NoteBoardAccessCandidate[]>(`/projects/${projectKey}/note-boards/access-candidates`),- createNoteBoard: (projectKey: string, input: NewNoteBoardInput) =>- request<NoteBoard>(`/projects/${projectKey}/note-boards`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateNoteBoard: (projectKey: string, boardId: number, patch: NoteBoardPatch) =>- request<NoteBoard>(`/projects/${projectKey}/note-boards/${boardId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteNoteBoard: (projectKey: string, boardId: number) =>- request<void>(`/projects/${projectKey}/note-boards/${boardId}`, { method: 'DELETE' }),-- listDocuments: (projectKey: string, q?: string, archived = false) => {- const params = new URLSearchParams();- if (q) params.set('q', q);- if (archived) params.set('archived', 'true');- const suffix = params.size > 0 ? `?${params}` : '';- return request<ProjectDocumentSummary[]>(`/projects/${projectKey}/documents${suffix}`);- },- getDocument: (projectKey: string, documentId: number) =>- request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}`),- listDocumentIssueLinks: (projectKey: string, documentId: number) =>- request<DocumentIssueLink[]>(`/projects/${projectKey}/documents/${documentId}/issues`),- listIssueDocumentLinks: (projectKey: string, issueId: number) =>- request<IssueDocumentLink[]>(`/projects/${projectKey}/documents/for-issue/${issueId}`),- linkDocumentIssue: (projectKey: string, documentId: number, issueId: number) =>- request<DocumentIssueLink>(`/projects/${projectKey}/documents/${documentId}/issues`, {- method: 'POST',- body: JSON.stringify({ issueId }),- }),- unlinkDocumentIssue: (projectKey: string, documentId: number, issueId: number) =>- request<void>(`/projects/${projectKey}/documents/${documentId}/issues/${issueId}`, {- method: 'DELETE',- }),- listInitiativeDocumentLinks: (projectKey: string, initiativeId: number) =>- request<IssueDocumentLink[]>(- `/projects/${projectKey}/documents/for-initiative/${initiativeId}`,- ),- linkDocumentInitiative: (projectKey: string, documentId: number, initiativeId: number) =>- request<IssueDocumentLink>(`/projects/${projectKey}/documents/${documentId}/initiatives`, {- method: 'POST',- body: JSON.stringify({ initiativeId }),- }),- unlinkDocumentInitiative: (projectKey: string, documentId: number, initiativeId: number) =>- request<void>(`/projects/${projectKey}/documents/${documentId}/initiatives/${initiativeId}`, {- method: 'DELETE',- }),- createDocument: (projectKey: string, input: NewProjectDocumentInput) =>- request<ProjectDocument>(`/projects/${projectKey}/documents`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateDocument: (projectKey: string, documentId: number, patch: ProjectDocumentPatch) =>- request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteDocument: (projectKey: string, documentId: number, version: number) =>- request<void>(`/projects/${projectKey}/documents/${documentId}?version=${version}`, {- method: 'DELETE',- }),- setDocumentAccess: (- projectKey: string,- documentId: number,- input: { version: number; isPrivate: boolean },- ) =>- request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/access`, {- method: 'POST',- body: JSON.stringify(input),- }),- setDocumentLocked: (projectKey: string, documentId: number, version: number, locked: boolean) =>- request<ProjectDocument>(- `/projects/${projectKey}/documents/${documentId}/${locked ? 'lock' : 'unlock'}`,- { method: 'POST', body: JSON.stringify({ version }) },- ),- archiveDocument: (projectKey: string, documentId: number, version: number) =>- request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/archive`, {- method: 'POST',- body: JSON.stringify({ version }),- }),- restoreDocument: (projectKey: string, documentId: number, version: number) =>- request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/restore`, {- method: 'POST',- body: JSON.stringify({ version }),- }),- duplicateDocument: (- projectKey: string,- documentId: number,- input: { version: number; title?: string; parentId?: number | null },- ) =>- request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/duplicate`, {- method: 'POST',- body: JSON.stringify(input),- }),- setDocumentFavorite: (projectKey: string, documentId: number, isFavorite: boolean) =>- request<{ isFavorite: boolean }>(- `/projects/${projectKey}/documents/${documentId}/preferences`,- { method: 'PATCH', body: JSON.stringify({ isFavorite }) },- ),- listDocumentRevisions: (projectKey: string, documentId: number) =>- request<ProjectDocumentRevisionSummary[]>(- `/projects/${projectKey}/documents/${documentId}/revisions`,- ),- getDocumentRevision: (projectKey: string, documentId: number, revisionId: number) =>- request<ProjectDocumentRevision>(- `/projects/${projectKey}/documents/${documentId}/revisions/${revisionId}`,- ),- restoreDocumentRevision: (- projectKey: string,- documentId: number,- revisionId: number,- version: number,- ) =>- request<ProjectDocument>(- `/projects/${projectKey}/documents/${documentId}/revisions/${revisionId}/restore`,- { method: 'POST', body: JSON.stringify({ version }) },- ),- exportDocument: (projectKey: string, documentId: number) =>- request<ProjectDocumentExport>(`/projects/${projectKey}/documents/${documentId}/export`),- listDocumentAssets: (projectKey: string, documentId: number) =>- request<DocumentAsset[]>(`/projects/${projectKey}/documents/${documentId}/assets`).then(- (assets) => assets.map(withDocumentAssetUrl),- ),- uploadDocumentAsset: (projectKey: string, documentId: number, file: File) =>- sendDocumentAssetFile(projectKey, documentId, file),- deleteDocumentAsset: (projectKey: string, documentId: number, publicId: string) =>- request<void>(- `/projects/${projectKey}/documents/${documentId}/assets/${encodeURIComponent(publicId)}`,- { method: 'DELETE' },- ),-- // Analytics — read-only project metrics behind the dashboard widgets.- getStats: (projectKey: string) =>- request<AnalyticsStats>(`/projects/${projectKey}/analytics/stats`),- getBreakdown: (projectKey: string, by: BreakdownBy) =>- request<BreakdownItem[]>(`/projects/${projectKey}/analytics/breakdown?by=${by}`),- getPulse: (projectKey: string, unit: PulseUnit, columns: number) =>- request<PulseBucket[]>(- `/projects/${projectKey}/analytics/pulse?unit=${unit}&columns=${columns}`,- ),- getThroughput: (projectKey: string, weeks = 12) =>- request<ThroughputWeek[]>(`/projects/${projectKey}/analytics/throughput?weeks=${weeks}`),- listActivity: (- projectKey: string,- params: {- cursor?: FeedCursor | null;- limit?: number;- actorUserId?: string | null;- action?: string | null;- issueIds?: number[] | null;- } = {},- ) => {- const q = new URLSearchParams();- if (params.limit) q.set('limit', String(params.limit));- if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));- if (params.actorUserId != null) q.set('actorUserId', params.actorUserId);- if (params.action) q.set('action', params.action);- if (params.issueIds) q.set('issueIds', params.issueIds.join(','));- const qs = q.toString();- return request<ActivityPage>(`/projects/${projectKey}/analytics/activity${qs ? `?${qs}` : ''}`);- },- getAgentRuns: (projectKey: string, params: { status?: string | null; limit?: number } = {}) => {- const q = new URLSearchParams();- if (params.status) q.set('status', params.status);- if (params.limit) q.set('limit', String(params.limit));- const qs = q.toString();- return request<AgentRunFeedItem[]>(- `/projects/${projectKey}/analytics/agent-runs${qs ? `?${qs}` : ''}`,- );- },- getAgentRunStats: (projectKey: string, days = 30) =>- request<AgentRunStats>(`/projects/${projectKey}/analytics/agent-run-stats?days=${days}`),- getWebhookStats: (projectKey: string, days = 30) =>- request<WebhookStats>(`/projects/${projectKey}/analytics/webhook-stats?days=${days}`),- getAgentWorkload: (projectKey: string) =>- request<AgentWorkloadItem[]>(`/projects/${projectKey}/analytics/agent-workload`),-- // Members: list who is on a project, add someone from its team, and revoke access- // (an owner removes anyone; a member removes only themselves — leaving the- // project).- // One page of the project's members.- listMembers: (projectKey: string, params: MemberListParams) =>- request<MemberPage>(`/projects/${projectKey}/members${memberListQuery(params)}`),- listMemberCandidates: (projectKey: string) =>- request<MemberCandidate[]>(`/projects/${projectKey}/members/candidates`),- addMember: (- projectKey: string,- input: { userId: string; role: MemberRole; roleId?: number | null },- ) =>- request<void>(`/projects/${projectKey}/members`, {- method: 'POST',- body: JSON.stringify(input),- }),- removeMember: (projectKey: string, userId: string) =>- request<void>(`/projects/${projectKey}/members/${encodeURIComponent(userId)}`, {- method: 'DELETE',- }),- // Set a member's role (owner-only). role 'owner' promotes to owner; role- // 'member' assigns a custom role via roleId (null resets to the default role).- // The last owner cannot be demoted — the API rejects it.- setMemberRole: (- projectKey: string,- userId: string,- input: { role: MemberRole; roleId?: number | null },- ) =>- request<void>(`/projects/${projectKey}/members/${encodeURIComponent(userId)}`, {- method: 'PATCH',- body: JSON.stringify(input),- }),- // Set what a member does in the project (owner-only). Empty string clears it.- setMemberDescription: (projectKey: string, userId: string, description: string) =>- request<void>(`/projects/${projectKey}/members/${encodeURIComponent(userId)}/description`, {- method: 'PATCH',- body: JSON.stringify({ description }),- }),-- // AI agents: a team's bot users and their configuration. Pass projectId to list only- // the agents working in one project of the team. The plaintext key is returned only- // by create and regenerate-key, so those responses carry it alongside the agent; it- // is never part of a list/read.- listAiAgents: (teamId: number, projectId?: number) =>- request<AiAgent[]>(- `/teams/${teamId}/ai-agents${projectId != null ? `?projectId=${projectId}` : ''}`,- ),- listAgentTools: (teamId: number) => request<AgentTool[]>(`/teams/${teamId}/ai-agents/tools`),- createAiAgent: (teamId: number, input: NewAiAgentInput) =>- request<{ agent: AiAgent; apiKey: string | null }>(`/teams/${teamId}/ai-agents`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateAiAgent: (teamId: number, agentId: number, patch: AiAgentPatch) =>- request<AiAgent>(`/teams/${teamId}/ai-agents/${agentId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- regenerateAiAgentKey: (teamId: number, agentId: number) =>- request<{ apiKey: string }>(`/teams/${teamId}/ai-agents/${agentId}/regenerate-key`, {- method: 'POST',- }),- deleteAiAgent: (teamId: number, agentId: number) =>- request<void>(`/teams/${teamId}/ai-agents/${agentId}`, { method: 'DELETE' }),- listAgentRuns: (teamId: number, agentId: number, before?: number) =>- request<AgentRunPage>(- `/teams/${teamId}/ai-agents/${agentId}/runs?limit=25${before ? `&before=${before}` : ''}`,- ),- listAgentSchedules: (projectKey: string, params: PageParams) =>- request<Page<AgentSchedule>>(`/projects/${projectKey}/agent-schedules${pageQuery(params)}`),- createAgentSchedule: (projectKey: string, input: AgentScheduleInput) =>- request<AgentSchedule>(`/projects/${projectKey}/agent-schedules`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateAgentSchedule: (- projectKey: string,- scheduleId: number,- patch: Partial<AgentScheduleInput>,- ) =>- request<AgentSchedule>(`/projects/${projectKey}/agent-schedules/${scheduleId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteAgentSchedule: (projectKey: string, scheduleId: number) =>- request<void>(`/projects/${projectKey}/agent-schedules/${scheduleId}`, { method: 'DELETE' }),- runAgentSchedule: (projectKey: string, scheduleId: number) =>- request<{ runId: number }>(`/projects/${projectKey}/agent-schedules/${scheduleId}/run`, {- method: 'POST',- }),- listAgentScheduleRuns: (projectKey: string, scheduleId: number) =>- request<AgentScheduleRun[]>(`/projects/${projectKey}/agent-schedules/${scheduleId}/runs`),- // Ends the schedule's waiting runs — all of them, or the one given.- cancelAgentScheduleRuns: (projectKey: string, scheduleId: number, runId?: number) =>- request<{ canceled: number }>(- `/projects/${projectKey}/agent-schedules/${scheduleId}/runs${runId != null ? `/${runId}` : ''}/cancel`,- { method: 'POST' },- ),- // One page of the caller's own chat threads with an agent, newest first. `q` searches- // them by title and message text instead, over every page.- listAiAgentThreads: (projectKey: string, agentId: number, page: number, q = '') =>- request<AiChatThreadPage>(- `/projects/${projectKey}/ai-agents/${agentId}/threads?page=${page}` +- (q ? `&q=${encodeURIComponent(q)}` : ''),- ),- // The conversations the caller starred with an agent, newest first, in one go.- listAiAgentFavoriteThreads: (projectKey: string, agentId: number) =>- request<AiChatThreadPage>(- `/projects/${projectKey}/ai-agents/${agentId}/threads?favorites=true`,- ),- // Stars one of the caller's conversations, or takes the star off it.- setAiAgentThreadFavorite: (- projectKey: string,- agentId: number,- threadId: string,- favorite: boolean,- ) =>- request<void>(- `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}/favorite`,- { method: favorite ? 'PUT' : 'DELETE' },- ),- // The transcript of one chat thread, to restore the conversation.- getAiAgentThreadMessages: (projectKey: string, agentId: number, threadId: string, page: number) =>- request<AiChatMessagePage>(- `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}/messages?page=${page}`,- ),- // Renames one of the caller's chat threads.- renameAiAgentThread: (projectKey: string, agentId: number, threadId: string, title: string) =>- request<void>(- `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}`,- { method: 'PATCH', body: JSON.stringify({ title }) },- ),- deleteAiAgentThread: (projectKey: string, agentId: number, threadId: string) =>- request<void>(- `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}`,- { method: 'DELETE' },- ),-- // Integrations: the team's stored credentials for LLM providers and tool- // integrations, shared by every project it owns. The secret is write-only —- // responses carry only a redacted view.- listIntegrationCatalog: (teamId: number) =>- request<IntegrationMeta[]>(`/teams/${teamId}/integrations/catalog`),- listIntegrationModels: (teamId: number, provider: string) =>- request<ProviderModel[]>(- `/teams/${teamId}/integrations/models/${encodeURIComponent(provider)}`,- ),- listCredentials: (teamId: number, params: PageParams) =>- request<Page<IntegrationCredential>>(`/teams/${teamId}/integrations${pageQuery(params)}`),- listIntegrationOptions: (teamId: number, kind?: IntegrationKind) =>- request<IntegrationOption[]>(- `/teams/${teamId}/integrations/options${kind ? `?kind=${kind}` : ''}`,- ),- createCredential: (teamId: number, input: NewCredentialInput) =>- request<IntegrationCredential>(`/teams/${teamId}/integrations`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateCredential: (teamId: number, credentialId: number, patch: CredentialPatch) =>- request<IntegrationCredential>(`/teams/${teamId}/integrations/${credentialId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteCredential: (teamId: number, credentialId: number) =>- request<void>(`/teams/${teamId}/integrations/${credentialId}`, { method: 'DELETE' }),-- // Agent skills: the team skill library and the skills enabled on an agent.- listSkills: (teamId: number, params: PageParams) =>- request<Page<AgentSkill>>(`/teams/${teamId}/agent-skills${pageQuery(params)}`),- // The whole library, which the agent editor's skill picker needs entire.- listSkillOptions: (teamId: number) =>- request<AgentSkill[]>(`/teams/${teamId}/agent-skills/options`),- getSkill: (teamId: number, skillId: number) =>- request<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}`),- getSkillMarkdown: (teamId: number, skillId: number) =>- request<{ markdown: string }>(`/teams/${teamId}/agent-skills/${skillId}/markdown`),- getSkillReferenceContent: (teamId: number, skillId: number, path: string) =>- request<{ content: string }>(- `/teams/${teamId}/agent-skills/${skillId}/references/content?path=${encodeURIComponent(path)}`,- ),- createSkill: (teamId: number, input: NewSkillInput) =>- request<AgentSkill>(`/teams/${teamId}/agent-skills`, {- method: 'POST',- body: JSON.stringify(input),- }),- discoverGithubSkills: (teamId: number, url: string) =>- request<GithubSkillCandidate[]>(`/teams/${teamId}/agent-skills/github/discover`, {- method: 'POST',- body: JSON.stringify({ url }),- }),- updateSkill: (teamId: number, skillId: number, patch: SkillPatch) =>- request<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- deleteSkill: (teamId: number, skillId: number) =>- request<void>(`/teams/${teamId}/agent-skills/${skillId}`, { method: 'DELETE' }),- // Multipart upload for a skill reference — see sendAttachmentFile for why- // request() cannot be used.- addSkillReference: async (teamId: number, skillId: number, file: File): Promise<AgentSkill> => {- const form = new FormData();- form.append('file', file);- const res = await fetch(`${API_URL}/teams/${teamId}/agent-skills/${skillId}/references`, {- method: 'POST',- credentials: 'include',- body: form,- });- if (!res.ok) throw await apiFailure(res);- return res.json();- },- updateSkillReferenceContent: (teamId: number, skillId: number, path: string, content: string) =>- request<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}/references/content`, {- method: 'PATCH',- body: JSON.stringify({ path, content }),- }),- deleteSkillReference: (teamId: number, skillId: number, path: string) =>- request<AgentSkill>(- `/teams/${teamId}/agent-skills/${skillId}/references?path=${encodeURIComponent(path)}`,- { method: 'DELETE' },- ),- listAgentSkills: (teamId: number, agentId: number) =>- request<AgentSkill[]>(`/teams/${teamId}/ai-agents/${agentId}/skills`),- setAgentSkills: (teamId: number, agentId: number, skillIds: number[]) =>- request<AgentSkill[]>(`/teams/${teamId}/ai-agents/${agentId}/skills`, {- method: 'PUT',- body: JSON.stringify({ skillIds }),- }),-- // Configured tools: a team's tools bound to a credential, and the tools enabled on- // one agent. The tool catalog itself comes from the integrations catalog.- listConfiguredTools: (teamId: number, params: PageParams) =>- request<Page<ConfiguredTool>>(`/teams/${teamId}/agent-tools${pageQuery(params)}`),- // The whole list, which the agent editor's tool picker and the tool dialog need- // entire.- listConfiguredToolOptions: (teamId: number) =>- request<ConfiguredTool[]>(`/teams/${teamId}/agent-tools/options`),- createConfiguredTool: (teamId: number, input: NewConfiguredToolInput) =>- request<ConfiguredTool>(`/teams/${teamId}/agent-tools`, {- method: 'POST',- body: JSON.stringify(input),- }),- deleteConfiguredTool: (teamId: number, agentToolId: number) =>- request<void>(`/teams/${teamId}/agent-tools/${agentToolId}`, { method: 'DELETE' }),- listAgentToolLinks: (teamId: number, agentId: number) =>- request<ConfiguredTool[]>(`/teams/${teamId}/ai-agents/${agentId}/tool-configs`),- setAgentTools: (teamId: number, agentId: number, agentToolIds: number[]) =>- request<ConfiguredTool[]>(`/teams/${teamId}/ai-agents/${agentId}/tool-configs`, {- method: 'PUT',- body: JSON.stringify({ agentToolIds }),- }),-- // Roles: a team's roles and the permission catalog behind the role editor. Roles- // belong to the team, so one list serves every project it owns; an owner or a- // manager of the team writes them, and only its owner deletes one.- getPermissionCatalog: () => request<PermissionCatalog>('/permission-catalog'),- // One page of the team's roles. `search` matches the name.- listTeamRoles: (teamId: number, params: RoleListParams) =>- request<Page<Role>>(`/teams/${teamId}/roles${pageQuery(params, { search: params.search })}`),- // Every role of the team, with its matrix: what the role pickers assign from and- // what the clipboard export carries.- listTeamRoleOptions: (teamId: number) => request<Role[]>(`/teams/${teamId}/roles/options`),- createRole: (teamId: number, input: { name: string; permissions: Permissions }) =>- request<Role>(`/teams/${teamId}/roles`, { method: 'POST', body: JSON.stringify(input) }),- updateRole: (- teamId: number,- roleId: number,- patch: { name?: string; permissions?: Permissions },- ) =>- request<Role>(`/teams/${teamId}/roles/${roleId}`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- getRoleUsage: (teamId: number, roleId: number) =>- request<RoleUsage>(`/teams/${teamId}/roles/${roleId}/usage`),- deleteRole: (teamId: number, roleId: number, targetRoleId?: number) => {- const qs = targetRoleId === undefined ? '' : `?targetRoleId=${targetRoleId}`;- return request<void>(`/teams/${teamId}/roles/${roleId}${qs}`, { method: 'DELETE' });- },-- // Invites — the managing side: create, list, email, and revoke the invite links of- // a project or of a team. A project invite joins the team as well; a team invite- // names no project.- listInvites: (projectKey: string) => request<InviteRow[]>(`/projects/${projectKey}/invites`),- createInvite: (- projectKey: string,- input: { email: string; role: MemberRole; roleId?: number | null },- ) =>- request<InviteCreateResult>(`/projects/${projectKey}/invites`, {- method: 'POST',- body: JSON.stringify(input),- }),- sendInviteEmail: (projectKey: string, inviteId: number) =>- request<InviteEmailResult>(`/projects/${projectKey}/invites/${inviteId}/email`, {- method: 'POST',- }),- deleteInvite: (projectKey: string, inviteId: number) =>- request<void>(`/projects/${projectKey}/invites/${inviteId}`, { method: 'DELETE' }),- listTeamInvites: (teamId: number) => request<InviteRow[]>(`/teams/${teamId}/invites`),- createTeamInvite: (teamId: number, input: { email: string; role: InviteTeamRole }) =>- request<InviteRow>(`/teams/${teamId}/invites`, {- method: 'POST',- body: JSON.stringify(input),- }),- deleteTeamInvite: (teamId: number, inviteId: number) =>- request<void>(`/teams/${teamId}/invites/${inviteId}`, { method: 'DELETE' }),-- // Invites — invitee side: open a link by token, then accept or reject it. The- // session email must match the invite. Accept returns where to go next.- getInvite: (token: string) => request<InviteView>(`/invites/${encodeURIComponent(token)}`),- acceptInvite: (token: string) =>- request<AcceptedInvite>(`/invites/${encodeURIComponent(token)}/accept`, { method: 'POST' }),- rejectInvite: (token: string) =>- request<void>(`/invites/${encodeURIComponent(token)}/reject`, { method: 'POST' }),-- // The action list any project member may read; the permissioned list route is- // for API/MCP callers.- listQuickActions: (projectKey: string) =>- request<ActionDef[]>(`/projects/${projectKey}/actions/quick`),- createAction: (projectKey: string, input: NewActionInput) =>- request<ActionDef>(`/projects/${projectKey}/actions`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateAction: (actionId: number, patch: ActionPatch) =>- request<ActionDef>(`/actions/${actionId}`, { method: 'PATCH', body: JSON.stringify(patch) }),- deleteAction: (actionId: number) => request<void>(`/actions/${actionId}`, { method: 'DELETE' }),- reorderActions: (projectKey: string, orderedIds: number[]) =>- request<ActionDef[]>(`/projects/${projectKey}/actions/reorder`, {- method: 'PUT',- body: JSON.stringify({ orderedIds }),- }),-- listWebhooks: (projectKey: string) => request<Webhook[]>(`/projects/${projectKey}/webhooks`),- createWebhook: (projectKey: string, input: NewWebhookInput) =>- request<Webhook>(`/projects/${projectKey}/webhooks`, {- method: 'POST',- body: JSON.stringify(input),- }),- updateWebhook: (webhookId: number, patch: WebhookPatch) =>- request<Webhook>(`/webhooks/${webhookId}`, { method: 'PATCH', body: JSON.stringify(patch) }),- deleteWebhook: (webhookId: number) =>- request<void>(`/webhooks/${webhookId}`, { method: 'DELETE' }),- listWebhookDeliveries: (webhookId: number, before?: number) =>- request<WebhookDeliveryPage>(- `/webhooks/${webhookId}/deliveries?limit=25${before ? `&before=${before}` : ''}`,- ),-- // Project settings: MCP reachability and the enabled sections. Owner-only; the- // current state comes with the project payload (getProject), so there is no read- // here.- updateProjectSettings: (projectKey: string, patch: { features?: Partial<ProjectFeatures> }) =>- request<ProjectSettings>(`/projects/${projectKey}/settings`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),-- // The workflow configuration (workflow_config: read to view, edit to change):- // the auto-archive thresholds, the subtask automations, and the estimate kinds.- // The estimate kinds have no read of their own — they come with the project.- getAutoArchive: (projectKey: string) =>- request<AutoArchiveSettings>(`/projects/${projectKey}/settings/auto-archive`),- updateAutoArchive: (projectKey: string, input: AutoArchiveSettings) =>- request<AutoArchiveSettings>(`/projects/${projectKey}/settings/auto-archive`, {- method: 'PATCH',- body: JSON.stringify(input),- }),- getSubtaskAutomation: (projectKey: string) =>- request<SubtaskAutomationSettings>(`/projects/${projectKey}/settings/subtasks`),- updateSubtaskAutomation: (projectKey: string, input: SubtaskAutomationSettings) =>- request<SubtaskAutomationSettings>(`/projects/${projectKey}/settings/subtasks`, {- method: 'PATCH',- body: JSON.stringify(input),- }),-- updateEstimates: (projectKey: string, input: EstimateSettings) =>- request<EstimateSettings>(`/projects/${projectKey}/settings/estimates`, {- method: 'PATCH',- body: JSON.stringify(input),- }),-- // The repository integration (integrations: read to view, edit to change).- getGitSettings: (projectKey: string) =>- request<GitSettings>(`/projects/${projectKey}/settings/git`),- updateGitSettings: (- projectKey: string,- patch: {- enabled?: boolean;- onMergeColumnId?: number | null;- onOpenColumnId?: number | null;- linkbackComments?: boolean;- },- ) =>- request<GitSettings>(`/projects/${projectKey}/settings/git`, {- method: 'PATCH',- body: JSON.stringify(patch),- }),- regenerateGitSecret: (projectKey: string) =>- request<GitSettings>(`/projects/${projectKey}/settings/git/secret`, {- method: 'POST',- }),- listGitProviderConnections: (projectKey: string) =>- request<GitProviderConnection[]>(`/projects/${projectKey}/settings/git/connections`),- connectGitProvider: (- projectKey: string,- input: { provider: GitConnectionProvider; baseUrl?: string; token: string },- ) =>- request<GitProviderConnection>(`/projects/${projectKey}/settings/git/connections`, {- method: 'POST',- body: JSON.stringify(input),- }),- disconnectGitProvider: (projectKey: string, connectionId: number) =>- request<void>(`/projects/${projectKey}/settings/git/connections/${connectionId}`, {- method: 'DELETE',- }),- listAvailableGitRepositories: (- projectKey: string,- connectionId: number,- params: { page?: number; search?: string },- ) => {- const query = new URLSearchParams();- if (params.page) query.set('page', String(params.page));- if (params.search) query.set('search', params.search);- return request<AvailableGitRepositoryPage>(- `/projects/${projectKey}/settings/git/connections/${connectionId}/repositories?${query}`,- );- },- connectGitRepositories: (projectKey: string, connectionId: number, externalIds: string[]) =>- request<GitProviderConnection>(- `/projects/${projectKey}/settings/git/connections/${connectionId}/repositories`,- { method: 'POST', body: JSON.stringify({ externalIds }) },- ),- disconnectGitRepository: (projectKey: string, connectionId: number, repositoryId: number) =>- request<void>(- `/projects/${projectKey}/settings/git/connections/${connectionId}/repositories/${repositoryId}`,- { method: 'DELETE' },- ),-- // The team's notification provider credentials, shared by every project it owns- // (team owner only).- getNotificationSettings: (teamId: number) =>- request<NotificationSettings>(`/teams/${teamId}/notification-settings`),- setNotificationSettings: (teamId: number, input: NotificationSettingsPatch) =>- request<NotificationSettings>(`/teams/${teamId}/notification-settings`, {- method: 'PUT',- body: JSON.stringify(input),- }),-- // The session member's own notification preferences for a project (any member).- getNotificationPreferences: (projectKey: string) =>- request<NotificationPreferences>(`/projects/${projectKey}/notification-preferences`),- setNotificationPreferences: (projectKey: string, input: NotificationPreferences) =>- request<NotificationPreferences>(`/projects/${projectKey}/notification-preferences`, {- method: 'PUT',- body: JSON.stringify(input),- }),-- // The session user's own Telegram account link. Starting a link returns the bot- // deep link that completes it; the bot service writes the connection when the user- // opens it.- getTelegramAccount: () => request<TelegramAccount>('/telegram/account'),- startTelegramLink: () => request<TelegramLinkStart>('/telegram/account/link', { method: 'POST' }),- unlinkTelegramAccount: () => request<void>('/telegram/account', { method: 'DELETE' }),-- // The session user's own interface preferences, held per account. A read returns- // the defaults when nothing was saved; a write patches only the fields it carries.- getAccountPreferences: (locale: Locale) =>- request<AccountPreferences>('/account/preferences', {- headers: { 'Accept-Language': locale },- }),- updateAccountPreferences: (input: AccountPreferencesPatch, locale: Locale) =>- request<AccountPreferences>('/account/preferences', {- method: 'PATCH',- headers: { 'Accept-Language': locale },- body: JSON.stringify(input),- }),-- // Inbox notifications. The list is the session user's own; projectId scopes it to- // one project (the per-project inbox). cursor is the JSON-encoded keyset from the- // previous page.- listNotifications: (- projectId: number,- params: {- cursor?: NotificationCursor | null;- limit?: number;- filters?: NotificationFilters;- } = {},- ) => {- const q = new URLSearchParams();- q.set('projectId', String(projectId));- if (params.limit) q.set('limit', String(params.limit));- if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));- const f = params.filters ?? {};- if (f.types?.length) q.set('types', f.types.join(','));- if (f.from) q.set('from', f.from);- if (f.includeRead === false) q.set('includeRead', 'false');- if (f.includeSnoozed) q.set('includeSnoozed', 'true');- return request<NotificationPage>(`/notifications?${q.toString()}`);- },- // Unread count for the sidebar badge, refetched when the inbox scope moves.- getUnreadCount: (projectId: number) =>- request<{ unread: number }>(`/notifications/unread?projectId=${projectId}`),- setNotificationRead: (id: number, read: boolean) =>- request<void>(`/notifications/${id}/read`, { method: 'POST', body: JSON.stringify({ read }) }),- snoozeNotification: (id: number, until: string | null) =>- request<void>(`/notifications/${id}/snooze`, {- method: 'POST',- body: JSON.stringify({ until }),- }),- markAllNotificationsRead: (projectId: number) =>- request<{ count: number }>(`/notifications/read-all`, {- method: 'POST',- body: JSON.stringify({ projectId }),- }),- deleteNotification: (id: number) => request<void>(`/notifications/${id}`, { method: 'DELETE' }),- deleteNotifications: (scope: NotificationDeleteScope, projectId: number) =>- request<{ count: number }>(`/notifications?scope=${scope}&projectId=${projectId}`, {- method: 'DELETE',- }),-- // Instance administration (god mode). Every route below is owner-only; a plain- // user gets a 403, which is why the entries are hidden from the sidebar.- getInstanceAuthSettings: () => request<InstanceAuthSettings>('/god/auth-settings'),- updateInstanceAuthSettings: (patch: InstanceAuthSettingsPatch) =>- request<InstanceAuthSettings>('/god/auth-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),- getInstanceEmailSettings: () => request<InstanceEmailSettings>('/god/email-settings'),- updateInstanceEmailSettings: (patch: InstanceEmailSettingsPatch) =>- request<InstanceEmailSettings>('/god/email-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),- testInstanceEmailSettings: (patch: InstanceEmailSettingsPatch) =>- request<InstanceEmailTestResult>('/god/email-settings/test', {- method: 'POST',- body: JSON.stringify(patch),- }),- getInstanceTelegramSettings: () => request<InstanceTelegramSettings>('/god/telegram-settings'),- updateInstanceTelegramSettings: (patch: InstanceTelegramSettingsPatch) =>- request<InstanceTelegramSettings>('/god/telegram-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),-- // The upload limits. The read is open to any signed-in user (the upload UI shows- // the limit); the write is god mode.- getStorageSettings: () => request<StorageSettings>('/settings/storage'),-- // The instance keyboard shortcuts. The read is open to any signed-in user (every- // client applies them); the write is god mode.- getHotkeySettings: () => request<HotkeyOverrides>('/settings/hotkeys'),- getInstanceHotkeySettings: () => request<HotkeyOverrides>('/god/hotkey-settings'),- updateInstanceHotkeySettings: (combos: HotkeyOverrides) =>- request<HotkeyOverrides>('/god/hotkey-settings', {- method: 'PUT',- body: JSON.stringify(combos),- }),-- // The running version, shown in the sidebar to every signed-in user.- getAppVersion: () => request<{ version: string }>('/settings/version'),-- // The release this instance just upgraded to, and what the upgrade did to its- // data. Read once per session; closing the screen records the version.- getWhatsNew: () => request<WhatsNew>('/settings/whats-new'),- markWhatsNewSeen: () =>- request<{ version: string }>('/settings/whats-new/seen', { method: 'POST' }),-- // Whether a newer release exists, and the release notes behind it. God mode: the- // instance owner is the one who upgrades.- getUpdateStatus: () => request<UpdateStatus>('/god/updates'),- checkForUpdates: () => request<UpdateStatus>('/god/updates/check', { method: 'POST' }),-- getInstanceProjectDefaults: () => request<ProjectDefaults>('/god/project-defaults'),- updateInstanceProjectDefaults: (body: ProjectDefaults) =>- request<ProjectDefaults>('/god/project-defaults', {- method: 'PUT',- body: JSON.stringify(body),- }),-- getInstanceStorageSettings: () => request<StorageSettings>('/god/storage-settings'),- updateInstanceStorageSettings: (patch: StorageSettingsPatch) =>- request<StorageSettings>('/god/storage-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),-- getInstanceGoogleSettings: () => request<InstanceGoogleSettings>('/god/google-settings'),- updateInstanceGoogleSettings: (patch: InstanceGoogleSettingsPatch) =>- request<InstanceGoogleSettings>('/god/google-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),- getInstanceOidcSettings: () => request<InstanceOidcSettings>('/god/oidc-settings'),- updateInstanceOidcSettings: (patch: InstanceOidcSettingsPatch) =>- request<InstanceOidcSettings>('/god/oidc-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),-- getInstanceScimSettings: () => request<InstanceScimSettings>('/god/scim-settings'),- updateInstanceScimSettings: (patch: { enabled: boolean }) =>- request<InstanceScimSettings>('/god/scim-settings', {- method: 'PUT',- body: JSON.stringify(patch),- }),- // Returns the new token in the clear. It is shown once and cannot be read back.- createInstanceScimToken: () =>- request<{ token: string }>('/god/scim-settings/token', { method: 'POST' }),-- listInstanceScimGroups: () => request<InstanceScimGroup[]>('/god/scim-groups'),- setInstanceScimGroupMappings: (- groupId: string,- mappings: { projectId: number; role: 'owner' | 'member'; roleId: number | null }[],- ) =>- request<InstanceScimGroup>(`/god/scim-groups/${groupId}/mappings`, {- method: 'PUT',- body: JSON.stringify({ mappings }),- }),-- // The instance user directory: one page of accounts, and one account with the- // projects it can reach. Search, the kind filter and paging all run on the server.- listInstanceUsers: (params: PageParams & { search?: string; kind: InstanceUserKind }) =>- request<Page<InstanceUser>>(- `/god/users${pageQuery(params, { kind: params.kind, search: params.search })}`,- ),- getInstanceUser: (userId: string) => request<InstanceUserDetail>(`/god/users/${userId}`),- verifyInstanceUserEmail: (userId: string) =>- request<InstanceUserDetail>(`/god/users/${userId}/verify-email`, { method: 'POST' }),- // `withProjects` takes down the projects the user owns alone; without it the API- // refuses to delete an account that would leave a project ownerless.- deleteInstanceUser: (userId: string, withProjects: boolean) =>- request<void>(`/god/users/${userId}${withProjects ? '?withProjects=true' : ''}`, {- method: 'DELETE',- }),- // The instance project directory: one page of projects, and one project with its- // members. Search and paging run on the server.- listInstanceProjects: (params: PageParams & { search?: string }) =>- request<Page<InstanceProject>>(`/god/projects${pageQuery(params, { search: params.search })}`),- // Every project, for the SCIM mapping picker; the directory above is paged.- listInstanceProjectOptions: () => request<InstanceProjectOption[]>('/god/projects/options'),- getInstanceProject: (projectId: number) =>- request<InstanceProjectDetail>(`/god/projects/${projectId}`),- // The instance's own sign-in policy, readable without a session: the sign-up- // screen needs it before an account exists.- getAuthConfig: () => request<PublicAuthConfig>('/auth-config'),-};diff --git a/apps/web/src/lib/api/core/client.ts b/apps/web/src/lib/api/core/client.tsnew file mode 100644index 00000000..e2e0ca82--- /dev/null+++ b/apps/web/src/lib/api/core/client.ts@@ -0,0 +1,99 @@+// The transport every endpoint module goes through: the API origin, the request+// helper, and the failure path. The API is a separate service, so every request+// sends credentials (the better-auth session cookie).++import { runtimeEnv } from '@/utils/runtimeEnv';++// The API origin, read from the running server rather than from the build (see+// utils/runtimeEnv). A deployment without it ships a client that cannot reach the+// API. Fail at import instead of pointing at a wrong origin.+export const API_URL = runtimeEnv().apiUrl;+if (!API_URL) throw new Error('API_URL is not set on the web service');++// An error carrying the HTTP status so callers can tell apart 401 (no session),+// 403 (no access to the project / not owner), 404 (not found) and 400 (a+// validation or business-rule failure). `message` is the API's `{ error }` text+// when present, so existing consumers that read `error.message` keep working.+// `code` names the failure where the API sends one, for a caller that has to+// branch on it rather than show the message.+export class ApiError extends Error {+ constructor(+ readonly status: number,+ message: string,+ readonly code?: string,+ ) {+ super(message);+ this.name = 'ApiError';+ }+}++// Set while the session is being dropped, by the sign-out below or by the app's own+// `signOut`. Concurrent requests that all fail with 401 then trigger a single+// sign-out and a single navigation, and a sign-out the person asked for does not+// end on the expired screen. One flag for the whole app: it is read and written from+// this module only, so it must not be split across modules.+let signingOut = false;++// Called by `signOut` in @/lib/auth-client before it drops the session: the requests+// that fail right after are the expected fallout, not a session the API refused.+export function markSigningOut(): void {+ signingOut = true;+}++// Called by SessionScope once a session appears without a page load, so a later 401+// is reacted to again. An accepted request does not prove one: /auth-config and the+// invite and share reads answer without a session.+export function markSignedIn(): void {+ signingOut = false;+}++// A 401 means the session behind the cookie is gone. The proxy only checks that a+// session cookie exists, so a stale one keeps the app open on a page where every+// request fails. Sign out to drop the cookie, then leave for the expired screen+// whatever the sign-out answered — a cookie the server declines to clear must not+// hold the browser in the app.+// The request is written out rather than calling `signOut()` from @/lib/auth-client:+// that module reads API_URL from this one, so importing it back here would make a+// cycle that evaluates auth-client before API_URL is assigned.+function endSession(): void {+ if (typeof window === 'undefined' || signingOut) return;+ signingOut = true;+ void fetch(`${API_URL}/api/auth/sign-out`, { method: 'POST', credentials: 'include' })+ .catch(() => {})+ .then(() => window.location.replace('/login?expired=1'));+}++// Every request reports its failure through here, which is where an ended session is+// caught.+export async function apiFailure(res: Response): Promise<ApiError> {+ const body = await res.json().catch(() => null);+ if (res.status === 401) endSession();+ return new ApiError(res.status, body?.error ?? `${res.status} ${res.statusText}`, body?.code);+}++export async function request<T>(path: string, init?: RequestInit): Promise<T> {+ const res = await fetch(`${API_URL}${path}`, {+ ...init,+ credentials: 'include',+ // Never serve API reads from the HTTP cache — React Query owns caching, and a+ // browser-cached GET can return stale data after a mutation refetch.+ cache: 'no-store',+ headers: {+ 'Content-Type': 'application/json',+ ...init?.headers,+ },+ });+ if (!res.ok) throw await apiFailure(res);+ if (res.status === 204) return undefined as T;+ return res.json();+}++// Multipart upload. Cannot go through request(), which forces a JSON Content-Type:+// the browser must set the multipart boundary itself, so no headers are set here.+export async function uploadFile<T>(path: string, method: 'POST' | 'PUT', file: File): Promise<T> {+ const form = new FormData();+ form.append('file', file);+ const res = await fetch(`${API_URL}${path}`, { method, credentials: 'include', body: form });+ if (!res.ok) throw await apiFailure(res);+ return res.json();+}diff --git a/apps/web/src/lib/api/core/media.ts b/apps/web/src/lib/api/core/media.tsnew file mode 100644index 00000000..a2ee0f4a--- /dev/null+++ b/apps/web/src/lib/api/core/media.ts@@ -0,0 +1,6 @@+// Points a relative media path (a stored avatar or attachment URL) at the web+// origin's media route (app/media), which streams it from the API. Leaves an+// absolute URL — an embed stored before this, or an external image — untouched.+export function mediaUrl(url: string): string {+ return url.startsWith('http') ? url : `/media${url}`;+}diff --git a/apps/web/src/lib/api/core/paging.ts b/apps/web/src/lib/api/core/paging.tsnew file mode 100644index 00000000..26bbcf5f--- /dev/null+++ b/apps/web/src/lib/api/core/paging.ts@@ -0,0 +1,38 @@+// Paging. A list route either pages or answers with the whole list, never both, so a+// paged read always names its window and a whole-list read is a call of its own+// (listSkillOptions, listConfiguredToolOptions, listNoteBoards, ...).++export interface PageParams {+ page: number;+ pageSize: number;+}++export interface Page<T> {+ items: T[];+ total: number;+ page: number;+ pageSize: number;+}++// The next page of a list read as "show more": there is one while the pages loaded so+// far do not cover the total. What every useInfiniteQuery over a paged route passes as+// getNextPageParam.+export function nextPageParam<T>(last: Page<T>): number | undefined {+ return last.page * last.pageSize < last.total ? last.page + 1 : undefined;+}++// The query string a paged read takes: the window, plus whatever filters the list+// narrows by. A filter left empty is left out.+export function pageQuery(+ params: PageParams,+ filters: Record<string, string | undefined> = {},+): string {+ const qs = new URLSearchParams({+ page: String(params.page),+ pageSize: String(params.pageSize),+ });+ for (const [key, value] of Object.entries(filters)) {+ if (value) qs.set(key, value);+ }+ return `?${qs}`;+}diff --git a/apps/web/src/lib/api/endpoints/actions.ts b/apps/web/src/lib/api/endpoints/actions.tsnew file mode 100644index 00000000..fd1fd2e7--- /dev/null+++ b/apps/web/src/lib/api/endpoints/actions.ts@@ -0,0 +1,61 @@+import type { FilterSet } from '@/utils/filters';+import { request } from '@/lib/api/core/client';+import type { IssuePatch } from '@/lib/api/endpoints/issues';++// A manual action: a saved macro on a project. `condition` is a FilterSet (empty+// = always available) that decides which issues the action shows on; `effect`+// is a partial issue patch over built-in fields applied in one update when the+// action runs. A present effect key sets that field (value may be null); an+// absent key leaves it unchanged.+export type ActionEffect = Pick<+ IssuePatch,+ 'columnId' | 'assigneeUserId' | 'priority' | 'typeId' | 'startDate' | 'dueDate' | 'labelIds'+>;++export interface ActionDef {+ id: number;+ projectId: number;+ name: string;+ icon: string;+ condition: FilterSet;+ effect: ActionEffect;+ position: number;+ createdAt: string;+}++export interface NewActionInput {+ name: string;+ icon?: string;+ condition?: FilterSet;+ effect?: ActionEffect;+}++export interface ActionPatch {+ name?: string;+ icon?: string;+ condition?: FilterSet;+ effect?: ActionEffect;+}++// The action list any project member may read; the permissioned list route is+// for API/MCP callers.+export const listQuickActions = (projectKey: string) =>+ request<ActionDef[]>(`/projects/${projectKey}/actions/quick`);++export const createAction = (projectKey: string, input: NewActionInput) =>+ request<ActionDef>(`/projects/${projectKey}/actions`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateAction = (actionId: number, patch: ActionPatch) =>+ request<ActionDef>(`/actions/${actionId}`, { method: 'PATCH', body: JSON.stringify(patch) });++export const deleteAction = (actionId: number) =>+ request<void>(`/actions/${actionId}`, { method: 'DELETE' });++export const reorderActions = (projectKey: string, orderedIds: number[]) =>+ request<ActionDef[]>(`/projects/${projectKey}/actions/reorder`, {+ method: 'PUT',+ body: JSON.stringify({ orderedIds }),+ });diff --git a/apps/web/src/lib/api/endpoints/activity.ts b/apps/web/src/lib/api/endpoints/activity.tsnew file mode 100644index 00000000..423f1163--- /dev/null+++ b/apps/web/src/lib/api/endpoints/activity.ts@@ -0,0 +1,178 @@+import { request } from '@/lib/api/core/client';++// The query string both feed reads take, empty for the first page.+function feedPageQuery(params: { cursor?: FeedCursor | null; limit?: number }): string {+ const q = new URLSearchParams();+ if (params.limit) q.set('limit', String(params.limit));+ if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));+ const qs = q.toString();+ return qs ? `?${qs}` : '';+}++export interface ActivityItem {+ id: number;+ issueId: number;+ issueSequence: number;+ issueTitle: string;+ kind: 'comment' | 'activity';+ actorUserId: string | null;+ actorName: string | null;+ body: string | null;+ action: ActivityAction | null;+ payload: ActivityPayload;+ createdAt: string;+}++export interface ActivityPage {+ items: ActivityItem[];+ nextCursor: FeedCursor | null;+}++// `action` selects how the UI renders an activity row; the payload carries what+// changed (see ActivityPayload).+export type ActivityAction =+ | 'created'+ | 'title'+ | 'description'+ | 'status'+ | 'assignee'+ | 'delegate'+ | 'priority'+ | 'estimate'+ | 'type'+ | 'cycle'+ | 'start_date'+ | 'due_date'+ | 'label_add'+ | 'label_remove'+ | 'link_add'+ | 'link_remove'+ | 'parent'+ | 'subtask_add'+ | 'subtask_remove'+ | 'checklist_add'+ | 'checklist_rename'+ | 'checklist_remove'+ | 'checklist_item_add'+ | 'checklist_item_remove'+ | 'worklog'+ | 'field'+ | 'archived'+ | 'restored'+ | 'git_pr'+ // Entries recorded before the integration took other providers.+ | 'github_pr'+ | 'agent_started'+ | 'agent_finished';++// One side of a change: the display-ready text snapshot (column/label/type/assignee+// name, raw priority, ISO date, or the new text of a long field) and the id of the+// row behind it when the side names one. A status side also carries the state type+// its column had at the time, a pull request its repository and number.+export interface ActivitySide {+ value: string | null;+ id?: number | string | null;+ stateType?: string | null;+ repo?: string;+ number?: number;+ // A 'worklog' side carries the day its time was spent on.+ date?: string | null;+}++// What an activity row says changed. `subject` names the sub-item where the action+// alone is not enough (the custom field for 'field', the checklist of an item, the+// relation of a link); `from` and `to` are the two sides of the change. A side the+// action does not have is absent.+export interface ActivityPayload {+ subject?: ActivitySide;+ from?: ActivitySide;+ to?: ActivitySide;+}++// One entry in an issue's timeline. kind selects which fields are set: a 'comment'+// carries body; an 'activity' carries action and payload.+// actorName is the author/actor snapshot (null when it was never set).+export interface FeedItem {+ id: number;+ issueId: number;+ kind: 'comment' | 'activity';+ // The comment this one replies to, null for a top-level entry.+ replyToId: number | null;+ actorUserId: string | null;+ actorName: string | null;+ body: string | null;+ action: ActivityAction | null;+ payload: ActivityPayload;+ createdAt: string;+}++// Opaque keyset cursor returned by the feed endpoint; pass it back to load the+// next (older) page.+export interface FeedCursor {+ ts: string;+ id: number;+}++export interface FeedPage {+ items: FeedItem[];+ nextCursor: FeedCursor | null;+}++// One stretch of the grouped feed: the status the issue was in, and the entries of+// this page written while it was there. `to` is null for the stretch it is in now,+// and `repeat` marks a status the issue had already been in earlier.+export interface FeedGroup {+ status: string | null;+ from: string;+ to: string | null;+ durationMs: number;+ repeat: boolean;+ items: FeedItem[];+}++// A page of the feed split into stretches. Paged by the same cursor as FeedPage, so a+// stretch that spans a page boundary arrives in both, each time with that page's+// entries.+export interface GroupedFeedPage {+ groups: FeedGroup[];+ nextCursor: FeedCursor | null;+}++// One stretch the issue spent in a single column. `status` is the column under the+// name it carries now, falling back to the name it had at the time once it is+// deleted (null only when the stretch recorded none); `to` is null for the stretch+// the issue is in now. The entries written inside a stretch are a separate read+// (listTimelineItems), made when one is opened.+export interface TimelineSegment {+ status: string | null;+ from: string;+ to: string | null;+ durationMs: number;+}++export const listFeed = (+ issueId: number,+ params: { cursor?: FeedCursor | null; limit?: number } = {},+) => request<FeedPage>(`/issues/${issueId}/feed${feedPageQuery(params)}`);++// The same page, split into the stretches the issue spent in one status.+export const listGroupedFeed = (+ issueId: number,+ params: { cursor?: FeedCursor | null; limit?: number } = {},+) => request<GroupedFeedPage>(`/issues/${issueId}/feed/grouped${feedPageQuery(params)}`);++export const listTimeline = (issueId: number) =>+ request<TimelineSegment[]>(`/issues/${issueId}/timeline`);++// The entries of one stretch of the timeline: [from, to), open-ended without `to`.+export const listTimelineItems = (issueId: number, from: string, to: string | null) => {+ const q = new URLSearchParams({ from });+ if (to) q.set('to', to);+ return request<FeedItem[]>(`/issues/${issueId}/timeline/items?${q.toString()}`);+};++export const createComment = (issueId: number, input: { body: string; replyToId?: number }) =>+ request<FeedItem>(`/issues/${issueId}/comments`, {+ method: 'POST',+ body: JSON.stringify(input),+ });diff --git a/apps/web/src/lib/api/endpoints/agentChat.ts b/apps/web/src/lib/api/endpoints/agentChat.tsnew file mode 100644index 00000000..7a1fbc27--- /dev/null+++ b/apps/web/src/lib/api/endpoints/agentChat.ts@@ -0,0 +1,297 @@+import { API_URL, apiFailure, request } from '@/lib/api/core/client';+import type { AgentRunEvent } from '@/lib/api/endpoints/agents';++// The frames of one SSE connection: separated by a blank line, each carrying a single+// JSON-encoded event on its `data:` line and, on a resumable stream, the `id:` a+// reconnect resumes from. Throws ApiError when the request failed before the stream.+async function* readSseFrames(res: Response): AsyncGenerator<{ id: number | null; data: string }> {+ if (!res.ok || !res.body) throw await apiFailure(res);+ const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();+ let buffer = '';+ for (;;) {+ const { done, value } = await reader.read();+ if (done) return;+ buffer += value;+ let sep: number;+ while ((sep = buffer.indexOf('\n\n')) !== -1) {+ const lines = buffer.slice(0, sep).split('\n');+ buffer = buffer.slice(sep + 2);+ const dataLine = lines.find((l) => l.startsWith('data:'));+ if (!dataLine) continue;+ const idLine = lines.find((l) => l.startsWith('id:'));+ yield {+ id: idLine ? Number(idLine.slice(3).trim()) : null,+ data: dataLine.slice(5).trim(),+ };+ }+ }+}++// What an external agent's runner reports while it answers, as AG-UI events+// (https://docs.ag-ui.com). Only the ones the chat renders are named; the rest of the+// protocol passes through and is ignored here.+interface AgUiEvent {+ type: string;+ delta?: string;+ content?: string;+ message?: string;+ toolCallId?: string;+ toolCallName?: string;+}++// How many times a dropped stream is picked up again. The answer keeps being produced+// on the operator's machine either way; this only decides how long the browser follows it.+const CHAT_STREAM_RETRIES = 3;++function toRunEvent(event: AgUiEvent): AgentRunEvent | null {+ switch (event.type) {+ case 'TEXT_MESSAGE_CONTENT':+ return { type: 'text', value: event.delta ?? '' };+ case 'TOOL_CALL_START':+ return {+ type: 'tool-start',+ toolCallId: event.toolCallId ?? '',+ toolName: event.toolCallName ?? '',+ };+ case 'TOOL_CALL_ARGS':+ return { type: 'tool-args', toolCallId: event.toolCallId ?? '', delta: event.delta ?? '' };+ // TOOL_CALL_END closes the call's arguments, which the runner reports in the same+ // batch as the call itself. The tool is done when its result arrives.+ case 'TOOL_CALL_RESULT':+ return { type: 'tool-end', toolCallId: event.toolCallId ?? '', result: event.content };+ default:+ return null;+ }+}++// The run is bound to this connection, so aborting `signal` is the whole stop: the API+// drops the run with it.+// Streams an internal agent's response over SSE, yielding each AgentRunEvent as it+// arrives. Sends the session cookie like every other call. Throws ApiError when the+// request itself fails before the stream starts (e.g. 403/404); a failure during+// the run arrives as an `error` event, not a throw.+export async function* streamAiAgentRun(+ projectKey: string,+ agentId: number,+ input: { prompt: string; threadId?: string | null },+ signal?: AbortSignal,+): AsyncGenerator<AgentRunEvent> {+ const body = input.threadId+ ? { prompt: input.prompt, threadId: input.threadId }+ : { prompt: input.prompt };+ const res = await fetch(`${API_URL}/projects/${projectKey}/ai-agents/${agentId}/run/stream`, {+ method: 'POST',+ credentials: 'include',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(body),+ signal,+ });+ for await (const frame of readSseFrames(res)) {+ yield JSON.parse(frame.data) as AgentRunEvent;+ }+}++// Dropping the stream stops nothing here — the runner is on the operator's machine and+// only ever calls the API itself — so aborting `signal` also asks the API to cancel the+// answer, which is what the runner reads on its next report.+// Sends a message to an external agent and streams the answer its runner produces,+// yielding the same events as an internal agent's run so the chat consumes one shape.+// The answer starts only once a runner takes the message: until then the stream is open+// with nothing on it.+export async function* streamAiAgentChat(+ projectKey: string,+ agentId: number,+ input: { prompt: string; threadId?: string | null },+ signal?: AbortSignal,+): AsyncGenerator<AgentRunEvent> {+ const body = input.threadId+ ? { prompt: input.prompt, threadId: input.threadId }+ : { prompt: input.prompt };+ const sent = await request<{ threadId: string; messageId: number }>(+ `/projects/${projectKey}/ai-agents/${agentId}/chat`,+ { method: 'POST', body: JSON.stringify(body) },+ );+ const chat = `/projects/${projectKey}/ai-agents/${agentId}/chat/${sent.messageId}`;+ const cancel = () => {+ // A stop the API refused leaves the answer being produced. The stream this belongs+ // to is already gone, so the console is the only place left to report it.+ request(`${chat}/cancel`, { method: 'POST' }).catch((err) => {+ console.error('Could not stop the answer', err);+ });+ };+ if (signal?.aborted) cancel();+ else signal?.addEventListener('abort', cancel, { once: true });+ const base = `${API_URL}${chat}/stream`;+ let after = 0;+ // The answer always ends on a terminal event, so a stream that closed without one was+ // cut: pick it up again from the last event already shown.+ for (let attempt = 0; attempt <= CHAT_STREAM_RETRIES; attempt++) {+ let ended = false;+ try {+ const res = await fetch(`${base}?after=${after}`, { credentials: 'include', signal });+ for await (const frame of readSseFrames(res)) {+ after = frame.id ?? after;+ const event = JSON.parse(frame.data) as AgUiEvent;+ if (event.type === 'RUN_FINISHED') {+ ended = true;+ break;+ }+ if (event.type === 'RUN_ERROR') {+ ended = true;+ yield { type: 'error', message: event.message ?? 'The agent stopped answering' };+ break;+ }+ const mapped = toRunEvent(event);+ if (mapped) yield mapped;+ }+ } catch (err) {+ // A stop still has to name the thread: the reader binds it on `done`, and without+ // that the next message would open a second conversation.+ if (signal?.aborted) {+ yield { type: 'done', threadId: sent.threadId };+ throw err;+ }+ if (attempt === CHAT_STREAM_RETRIES) throw err;+ }+ if (ended) break;+ }+ yield { type: 'done', threadId: sent.threadId };+}++// The upload route takes the bytes as base64 rather than multipart, so the chat+// composer and an MCP client call the same route.+export async function uploadChatAttachment(+ projectKey: string,+ file: File,+): Promise<ChatAttachment> {+ const dataUrl = await new Promise<string>((resolve, reject) => {+ const reader = new FileReader();+ reader.onload = () => resolve(reader.result as string);+ reader.onerror = () => reject(reader.error ?? new Error('Could not read the file'));+ reader.readAsDataURL(file);+ });+ return request(`/projects/${projectKey}/chat-attachments`, {+ method: 'POST',+ body: JSON.stringify({+ filename: file.name,+ contentBase64: dataUrl.slice(dataUrl.indexOf(',') + 1),+ contentType: file.type || undefined,+ }),+ });+}++// One of the caller's saved chat conversations with an agent. `title` is the first+// prompt (truncated); null when it was never set. `cliSessionId` is the coding agent+// session an external agent's runner keeps for the thread on its own machine — null+// before the runner has reported one, and always null for an internal agent.+// `contextTokens` is the size of the conversation's context after its last completed+// answer: absent while no answer has completed, null where the agent reports no counts+// that can be read as one.+// `favorite` is the star the caller put on the conversation. `snippet` and `match` come+// back from a search: the text around the hit, and where it was found.+export interface AiChatThread {+ id: string;+ title: string | null;+ cliSessionId: string | null;+ contextTokens?: number | null;+ favorite: boolean;+ snippet?: string;+ match?: 'title' | 'user' | 'assistant';+ createdAt: string;+ updatedAt: string;+}++// One piece of a message, in the order the agent produced it: what it wrote, and the+// tools it called between one stretch of text and the next. A call carries what it was+// given and what it answered where the agent reported them.+export interface AiChatToolPart {+ type: 'tool';+ toolCallId: string;+ toolName: string;+ args?: string;+ result?: string;+}++export type AiChatPart = { type: 'text'; text: string } | AiChatToolPart;++// One restored message of a chat thread's transcript. `stopped` marks an answer the+// member ended part-way: what the agent had written by then is all there is.+export interface AiChatMessage {+ id: string;+ role: 'user' | 'assistant';+ parts: AiChatPart[];+ createdAt: string;+ stopped?: boolean;+}++export interface AiChatThreadPage {+ items: AiChatThread[];+ nextPage: number | null;+}++export interface AiChatMessagePage {+ items: AiChatMessage[];+ nextPage: number | null;+}++export interface ChatAttachment {+ id: string;+ filename: string;+ contentType: string;+ sizeBytes: number;+ createdAt: string;+ url: string;+}++// One page of the caller's own chat threads with an agent, newest first. `q` searches+// them by title and message text instead, over every page.+export const listAiAgentThreads = (projectKey: string, agentId: number, page: number, q = '') =>+ request<AiChatThreadPage>(+ `/projects/${projectKey}/ai-agents/${agentId}/threads?page=${page}` ++ (q ? `&q=${encodeURIComponent(q)}` : ''),+ );++// The conversations the caller starred with an agent, newest first, in one go.+export const listAiAgentFavoriteThreads = (projectKey: string, agentId: number) =>+ request<AiChatThreadPage>(`/projects/${projectKey}/ai-agents/${agentId}/threads?favorites=true`);++// Stars one of the caller's conversations, or takes the star off it.+export const setAiAgentThreadFavorite = (+ projectKey: string,+ agentId: number,+ threadId: string,+ favorite: boolean,+) =>+ request<void>(+ `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}/favorite`,+ { method: favorite ? 'PUT' : 'DELETE' },+ );++// The transcript of one chat thread, to restore the conversation.+export const getAiAgentThreadMessages = (+ projectKey: string,+ agentId: number,+ threadId: string,+ page: number,+) =>+ request<AiChatMessagePage>(+ `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}/messages?page=${page}`,+ );++// Renames one of the caller's chat threads.+export const renameAiAgentThread = (+ projectKey: string,+ agentId: number,+ threadId: string,+ title: string,+) =>+ request<void>(+ `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}`,+ { method: 'PATCH', body: JSON.stringify({ title }) },+ );++export const deleteAiAgentThread = (projectKey: string, agentId: number, threadId: string) =>+ request<void>(+ `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}`,+ { method: 'DELETE' },+ );diff --git a/apps/web/src/lib/api/endpoints/agentSchedules.ts b/apps/web/src/lib/api/endpoints/agentSchedules.tsnew file mode 100644index 00000000..8b31714b--- /dev/null+++ b/apps/web/src/lib/api/endpoints/agentSchedules.ts@@ -0,0 +1,85 @@+import { request } from '@/lib/api/core/client';+import type { AgentRunStatus } from '@/lib/api/endpoints/agents';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++export interface AgentSchedule {+ id: number;+ agentId: number;+ agentName: string;+ name: string;+ prompt: string;+ cron: string;+ timezone: 'UTC';+ status: 'active' | 'paused';+ nextRunAt: string;+ lastRunAt: string | null;+ lastRunStatus: AgentRunStatus | null;+ pendingRuns: number;+ // False when the agent's runner is scoped to another member, who alone may run or+ // stop it.+ canTrigger: boolean;+ createdAt: string;+ updatedAt: string;+}++export interface AgentScheduleInput {+ agentId: number;+ name: string;+ prompt: string;+ cron: string;+ status?: 'active' | 'paused';+}++export interface AgentScheduleRun {+ id: number;+ status: AgentRunStatus;+ trigger: 'schedule' | 'manual';+ prompt: string;+ attempts: number;+ lastError: string | null;+ output: string | null;+ // What the last model call of the run read and wrote: absent for a run that finished+ // before this was recorded and for one whose agent reports no counts.+ contextTokens?: number;+ scheduledFor: string | null;+ startedAt: string | null;+ finishedAt: string | null;+ createdAt: string;+}++export const listAgentSchedules = (projectKey: string, params: PageParams) =>+ request<Page<AgentSchedule>>(`/projects/${projectKey}/agent-schedules${pageQuery(params)}`);++export const createAgentSchedule = (projectKey: string, input: AgentScheduleInput) =>+ request<AgentSchedule>(`/projects/${projectKey}/agent-schedules`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateAgentSchedule = (+ projectKey: string,+ scheduleId: number,+ patch: Partial<AgentScheduleInput>,+) =>+ request<AgentSchedule>(`/projects/${projectKey}/agent-schedules/${scheduleId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteAgentSchedule = (projectKey: string, scheduleId: number) =>+ request<void>(`/projects/${projectKey}/agent-schedules/${scheduleId}`, { method: 'DELETE' });++export const runAgentSchedule = (projectKey: string, scheduleId: number) =>+ request<{ runId: number }>(`/projects/${projectKey}/agent-schedules/${scheduleId}/run`, {+ method: 'POST',+ });++export const listAgentScheduleRuns = (projectKey: string, scheduleId: number) =>+ request<AgentScheduleRun[]>(`/projects/${projectKey}/agent-schedules/${scheduleId}/runs`);++// Ends the schedule's waiting runs — all of them, or the one given.+export const cancelAgentScheduleRuns = (projectKey: string, scheduleId: number, runId?: number) =>+ request<{ canceled: number }>(+ `/projects/${projectKey}/agent-schedules/${scheduleId}/runs${runId != null ? `/${runId}` : ''}/cancel`,+ { method: 'POST' },+ );diff --git a/apps/web/src/lib/api/endpoints/agentSkills.ts b/apps/web/src/lib/api/endpoints/agentSkills.tsnew file mode 100644index 00000000..9a463a21--- /dev/null+++ b/apps/web/src/lib/api/endpoints/agentSkills.ts@@ -0,0 +1,115 @@+import { request, uploadFile } from '@/lib/api/core/client';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// A reference file of a skill (metadata only).+export interface SkillRef {+ path: string;+ s3Key: string;+ size: number;+}++// A skill in the team library: a SKILL.md plus optional reference files, given to+// the internal agents of the team's projects. Content lives in the object store;+// this is the metadata.+export interface AgentSkill {+ id: number;+ teamId: number;+ name: string;+ description: string;+ source: 'upload' | 'inline' | 'github';+ sourceUrl: string | null;+ files: SkillRef[];+ createdAt: string;+}++export interface NewSkillInput {+ source: 'upload' | 'inline' | 'github';+ name?: string | null;+ description?: string | null;+ markdown?: string;+ sourceUrl?: string | null;+}++export interface SkillPatch {+ name?: string;+ description?: string;+ markdown?: string;+}++// A skill found at a GitHub URL by the discover endpoint. `url` is a ready-to-import+// link for that single skill.+export interface GithubSkillCandidate {+ name: string;+ description: string;+ subpath: string;+ url: string;+}++// Agent skills: the team skill library and the skills enabled on an agent.+export const listSkills = (teamId: number, params: PageParams) =>+ request<Page<AgentSkill>>(`/teams/${teamId}/agent-skills${pageQuery(params)}`);++// The whole library, which the agent editor's skill picker needs entire.+export const listSkillOptions = (teamId: number) =>+ request<AgentSkill[]>(`/teams/${teamId}/agent-skills/options`);++export const getSkill = (teamId: number, skillId: number) =>+ request<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}`);++export const getSkillMarkdown = (teamId: number, skillId: number) =>+ request<{ markdown: string }>(`/teams/${teamId}/agent-skills/${skillId}/markdown`);++export const getSkillReferenceContent = (teamId: number, skillId: number, path: string) =>+ request<{ content: string }>(+ `/teams/${teamId}/agent-skills/${skillId}/references/content?path=${encodeURIComponent(path)}`,+ );++export const createSkill = (teamId: number, input: NewSkillInput) =>+ request<AgentSkill>(`/teams/${teamId}/agent-skills`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const discoverGithubSkills = (teamId: number, url: string) =>+ request<GithubSkillCandidate[]>(`/teams/${teamId}/agent-skills/github/discover`, {+ method: 'POST',+ body: JSON.stringify({ url }),+ });++export const updateSkill = (teamId: number, skillId: number, patch: SkillPatch) =>+ request<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteSkill = (teamId: number, skillId: number) =>+ request<void>(`/teams/${teamId}/agent-skills/${skillId}`, { method: 'DELETE' });++export const addSkillReference = (teamId: number, skillId: number, file: File) =>+ uploadFile<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}/references`, 'POST', file);++export const updateSkillReferenceContent = (+ teamId: number,+ skillId: number,+ path: string,+ content: string,+) =>+ request<AgentSkill>(`/teams/${teamId}/agent-skills/${skillId}/references/content`, {+ method: 'PATCH',+ body: JSON.stringify({ path, content }),+ });++export const deleteSkillReference = (teamId: number, skillId: number, path: string) =>+ request<AgentSkill>(+ `/teams/${teamId}/agent-skills/${skillId}/references?path=${encodeURIComponent(path)}`,+ { method: 'DELETE' },+ );++export const listAgentSkills = (teamId: number, agentId: number) =>+ request<AgentSkill[]>(`/teams/${teamId}/ai-agents/${agentId}/skills`);++export const setAgentSkills = (teamId: number, agentId: number, skillIds: number[]) =>+ request<AgentSkill[]>(`/teams/${teamId}/ai-agents/${agentId}/skills`, {+ method: 'PUT',+ body: JSON.stringify({ skillIds }),+ });diff --git a/apps/web/src/lib/api/endpoints/agentTools.ts b/apps/web/src/lib/api/endpoints/agentTools.tsnew file mode 100644index 00000000..fab4704a--- /dev/null+++ b/apps/web/src/lib/api/endpoints/agentTools.ts@@ -0,0 +1,48 @@+import { request } from '@/lib/api/core/client';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// A configured tool: a catalog tool (toolKey) bound to an integration credential,+// enriched with the credential's integration and label for display. (Distinct from+// AgentTool, which is a built-in capability tool in the agent's Actions list.)+export interface ConfiguredTool {+ id: number;+ teamId: number;+ toolKey: string;+ credentialId: number;+ integrationKey: string;+ credentialLabel: string | null;+ createdAt: string;+}++export interface NewConfiguredToolInput {+ toolKey: string;+ credentialId: number;+}++// Configured tools: a team's tools bound to a credential, and the tools enabled on+// one agent. The tool catalog itself comes from the integrations catalog.+export const listConfiguredTools = (teamId: number, params: PageParams) =>+ request<Page<ConfiguredTool>>(`/teams/${teamId}/agent-tools${pageQuery(params)}`);++// The whole list, which the agent editor's tool picker and the tool dialog need+// entire.+export const listConfiguredToolOptions = (teamId: number) =>+ request<ConfiguredTool[]>(`/teams/${teamId}/agent-tools/options`);++export const createConfiguredTool = (teamId: number, input: NewConfiguredToolInput) =>+ request<ConfiguredTool>(`/teams/${teamId}/agent-tools`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const deleteConfiguredTool = (teamId: number, agentToolId: number) =>+ request<void>(`/teams/${teamId}/agent-tools/${agentToolId}`, { method: 'DELETE' });++export const listAgentToolLinks = (teamId: number, agentId: number) =>+ request<ConfiguredTool[]>(`/teams/${teamId}/ai-agents/${agentId}/tool-configs`);++export const setAgentTools = (teamId: number, agentId: number, agentToolIds: number[]) =>+ request<ConfiguredTool[]>(`/teams/${teamId}/ai-agents/${agentId}/tool-configs`, {+ method: 'PUT',+ body: JSON.stringify({ agentToolIds }),+ });diff --git a/apps/web/src/lib/api/endpoints/agents.ts b/apps/web/src/lib/api/endpoints/agents.tsnew file mode 100644index 00000000..a6acf5ad--- /dev/null+++ b/apps/web/src/lib/api/endpoints/agents.ts@@ -0,0 +1,204 @@+import { request } from '@/lib/api/core/client';+import type { PermissionAction, PermissionResource } from '@/lib/api/endpoints/roles';++// One member custom field an agent reacts to, with the seconds its run waits.+export interface AgentFieldTrigger {+ fieldId: number;+ delaySec: number;+}++// The same trigger as a read of an agent returns it: the field's name comes along, so+// a screen can name it without loading the project the field belongs to.+export interface AgentFieldTriggerRead extends AgentFieldTrigger {+ name: string;+}++// A project an agent works in, as its settings list them.+export interface AgentProject {+ id: number;+ key: string;+ name: string;+}++// An AI agent of a team: a bot user plus its configuration. `kind` is+// 'external' (driven by an outside caller through the API) or 'internal' (run by+// the built-in runtime, so it carries provider/model/instructions/tools). Only an+// external agent has an API key: `apiKeyStart` is the non-secret prefix for display+// (null for internal), and the plaintext key is only returned once, on create and+// on regenerate.+export interface AiAgent {+ id: number;+ teamId: number;+ // The projects of the team the agent works in. One key reaches every one of them.+ projects: AgentProject[];+ userId: string;+ name: string;+ username: string;+ kind: 'external' | 'internal';+ // The integration_credential (kind 'llm') the model runs on, or null.+ modelCredentialId: number | null;+ model: string | null;+ instructions: string | null;+ tools: string[];+ temperature: number | null;+ maxSteps: number | null;+ memoryEnabled: boolean;+ memoryLastMessages: number | null;+ // Run triggers.+ triggerOnMention: boolean;+ triggerOnAssign: boolean;+ // The member custom fields that start a run when the agent is set into one, each+ // with the seconds its run waits before the agent may pick it up.+ fieldTriggers: AgentFieldTriggerRead[];+ // How long a delegation run waits before the agent may pick it up.+ delegationDelaySec: number;+ // The member who created the agent, and whose runs an 'owner'-scoped runner is+ // limited to; 'team' scope serves any member's runs.+ ownerUserId: string | null;+ runnerScope: 'owner' | 'team';+ // When the agent's runner last polled, or null while none ever has.+ lastSeenAt: string | null;+ createdAt: string;+ apiKeyStart: string | null;+ // The integration key of the model credential (the provider, e.g. "openai"), or+ // null when no credential is set.+ modelProvider: string | null;+ // How many actions the agent can take (always-on read-only plus granted mutating),+ // and how many skills and configured tools are enabled.+ actionCount: number;+ skillCount: number;+ toolCount: number;+}++// A run waits as 'pending' until a worker or a runner takes it; 'canceled' is a+// pending run ended by hand.+export type AgentRunStatus = 'pending' | 'success' | 'failed' | 'canceled';++// One row of an agent's autonomous run history. Issue-triggered runs reference an+// issue; scheduled and manual runs do not.+export interface AgentRun {+ id: number;+ status: AgentRunStatus;+ trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';+ issueId: number | null;+ issueIdentifier: string | null;+ issueTitle: string | null;+ prompt: string;+ attempts: number;+ lastError: string | null;+ output: string | null;+ // What the last model call of the run read and wrote: absent for a run that finished+ // before this was recorded and for one whose agent reports no counts.+ contextTokens?: number;+ nextAttemptAt: string;+ createdAt: string;+}++export interface AgentRunPage {+ items: AgentRun[];+ nextCursor: number | null;+}++// One work-item tool from the server-side catalog. `key` is stored on the agent+// (grantable actions only); label/description are for the picker. `always` marks the+// read-only tools that are always granted and shown non-editable. `permission` is the+// cell of the role matrix the action's route asserts; absent when the route asks only+// for project membership.+export interface AgentTool {+ key: string;+ group: 'issues' | 'initiatives' | 'cycles' | 'notes' | 'project';+ label: string;+ description: string;+ always: boolean;+ permission?: [PermissionResource, PermissionAction];+}++export interface NewAiAgentInput {+ name: string;+ username: string;+ kind: 'external' | 'internal';+ modelCredentialId?: number | null;+ model?: string | null;+ instructions?: string | null;+ tools?: string[];+ temperature?: number | null;+ maxSteps?: number | null;+ memoryEnabled?: boolean;+ memoryLastMessages?: number | null;+ triggerOnMention?: boolean;+ triggerOnAssign?: boolean;+ fieldTriggers?: AgentFieldTrigger[];+ delegationDelaySec?: number;+ projectIds?: number[];+ runnerScope?: 'owner' | 'team';+}++export interface AiAgentPatch {+ name?: string;+ username?: string;+ modelCredentialId?: number | null;+ model?: string | null;+ instructions?: string | null;+ tools?: string[];+ temperature?: number | null;+ maxSteps?: number | null;+ memoryEnabled?: boolean;+ memoryLastMessages?: number | null;+ triggerOnMention?: boolean;+ triggerOnAssign?: boolean;+ fieldTriggers?: AgentFieldTrigger[];+ delegationDelaySec?: number;+ projectIds?: number[];+ runnerScope?: 'owner' | 'team';+}++// One event of a streamed agent run (mirrors the API's AgentRunEvent). `text` is a+// chunk of the answer to append; `tool-start`/`tool-end` report a capability the+// agent is using, so the UI can show what it is doing; `done` ends the run with the+// conversation thread id; `error` reports a failure that happened mid-run.+export type AgentRunEvent =+ | { type: 'text'; value: string }+ | { type: 'tool-start'; toolCallId: string; toolName: string; args?: string }+ // An external agent's runner sends a call's arguments after the call itself, in+ // pieces; an internal agent has them all at its start.+ | { type: 'tool-args'; toolCallId: string; delta: string }+ | { type: 'tool-end'; toolCallId: string; result?: string }+ | { type: 'done'; threadId: string | null }+ | { type: 'error'; message: string };++// AI agents: a team's bot users and their configuration. Pass projectId to list only+// the agents working in one project of the team. The plaintext key is returned only+// by create and regenerate-key, so those responses carry it alongside the agent; it+// is never part of a list/read.+export const listAiAgents = (teamId: number, projectId?: number) =>+ request<AiAgent[]>(+ `/teams/${teamId}/ai-agents${projectId != null ? `?projectId=${projectId}` : ''}`,+ );++export const listAgentTools = (teamId: number) =>+ request<AgentTool[]>(`/teams/${teamId}/ai-agents/tools`);++export const createAiAgent = (teamId: number, input: NewAiAgentInput) =>+ request<{ agent: AiAgent; apiKey: string | null }>(`/teams/${teamId}/ai-agents`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateAiAgent = (teamId: number, agentId: number, patch: AiAgentPatch) =>+ request<AiAgent>(`/teams/${teamId}/ai-agents/${agentId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const regenerateAiAgentKey = (teamId: number, agentId: number) =>+ request<{ apiKey: string }>(`/teams/${teamId}/ai-agents/${agentId}/regenerate-key`, {+ method: 'POST',+ });++export const deleteAiAgent = (teamId: number, agentId: number) =>+ request<void>(`/teams/${teamId}/ai-agents/${agentId}`, { method: 'DELETE' });++export const listAgentRuns = (teamId: number, agentId: number, before?: number) =>+ request<AgentRunPage>(+ `/teams/${teamId}/ai-agents/${agentId}/runs?limit=25${before ? `&before=${before}` : ''}`,+ );diff --git a/apps/web/src/lib/api/endpoints/analytics.ts b/apps/web/src/lib/api/endpoints/analytics.tsnew file mode 100644index 00000000..27f0fb56--- /dev/null+++ b/apps/web/src/lib/api/endpoints/analytics.ts@@ -0,0 +1,129 @@+import type { BreakdownBy } from '@/utils/dashboardWidgets';+import type { AgentRunStatus } from '@/lib/api/endpoints/agents';+import { request } from '@/lib/api/core/client';+import type { ActivityPage, FeedCursor } from '@/lib/api/endpoints/activity';++export interface AnalyticsStats {+ open: number;+ inProgress: number;+ backlog: number;+ overdue: number;+ unassigned: number;+ closedLast7d: number;+}++export interface BreakdownItem {+ key: string;+ label: string;+ count: number;+ color: string | null;+}++export type PulseUnit = 'hour' | 'day' | 'week';++// One heatmap cell from the server: a preformatted bucket label (for the hover+// tooltip) and its activity count. The series is ordered oldest to newest.+export interface PulseBucket {+ label: string;+ count: number;+}++export interface ThroughputWeek {+ week: string;+ created: number;+ closed: number;+}++// One agent run in the project-wide feed (agent runs widget).+export interface AgentRunFeedItem {+ id: number;+ status: AgentRunStatus;+ trigger: 'mention' | 'delegation' | 'field' | 'schedule' | 'manual';+ agentId: number;+ agentName: string;+ issueId: number | null;+ issueSequence: number | null;+ lastError: string | null;+ createdAt: string;+}++// Agent run outcome counts over a window (agent health widget).+export interface AgentRunStats {+ total: number;+ success: number;+ failed: number;+ pending: number;+}++// Webhook delivery health over a window plus the subscription split (webhook health widget).+export interface WebhookStats {+ total: number;+ success: number;+ failed: number;+ pending: number;+ activeWebhooks: number;+ disabledWebhooks: number;+}++// One agent's workload row: delegated open issues and lifetime run outcomes.+export interface AgentWorkloadItem {+ agentId: number;+ agentName: string;+ kind: string;+ delegatedOpen: number;+ runsTotal: number;+ runsSuccess: number;+ runsFailed: number;+}++// Analytics — read-only project metrics behind the dashboard widgets.+export const getBreakdown = (projectKey: string, by: BreakdownBy) =>+ request<BreakdownItem[]>(`/projects/${projectKey}/analytics/breakdown?by=${by}`);++export const getPulse = (projectKey: string, unit: PulseUnit, columns: number) =>+ request<PulseBucket[]>(`/projects/${projectKey}/analytics/pulse?unit=${unit}&columns=${columns}`);++export const getThroughput = (projectKey: string, weeks = 12) =>+ request<ThroughputWeek[]>(`/projects/${projectKey}/analytics/throughput?weeks=${weeks}`);++export const listActivity = (+ projectKey: string,+ params: {+ cursor?: FeedCursor | null;+ limit?: number;+ actorUserId?: string | null;+ action?: string | null;+ issueIds?: number[] | null;+ } = {},+) => {+ const q = new URLSearchParams();+ if (params.limit) q.set('limit', String(params.limit));+ if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));+ if (params.actorUserId != null) q.set('actorUserId', params.actorUserId);+ if (params.action) q.set('action', params.action);+ if (params.issueIds) q.set('issueIds', params.issueIds.join(','));+ const qs = q.toString();+ return request<ActivityPage>(`/projects/${projectKey}/analytics/activity${qs ? `?${qs}` : ''}`);+};++export const getAgentRuns = (+ projectKey: string,+ params: { status?: string | null; limit?: number } = {},+) => {+ const q = new URLSearchParams();+ if (params.status) q.set('status', params.status);+ if (params.limit) q.set('limit', String(params.limit));+ const qs = q.toString();+ return request<AgentRunFeedItem[]>(+ `/projects/${projectKey}/analytics/agent-runs${qs ? `?${qs}` : ''}`,+ );+};++export const getAgentRunStats = (projectKey: string, days = 30) =>+ request<AgentRunStats>(`/projects/${projectKey}/analytics/agent-run-stats?days=${days}`);++export const getWebhookStats = (projectKey: string, days = 30) =>+ request<WebhookStats>(`/projects/${projectKey}/analytics/webhook-stats?days=${days}`);++export const getAgentWorkload = (projectKey: string) =>+ request<AgentWorkloadItem[]>(`/projects/${projectKey}/analytics/agent-workload`);diff --git a/apps/web/src/lib/api/endpoints/attachments.ts b/apps/web/src/lib/api/endpoints/attachments.tsnew file mode 100644index 00000000..da38cf38--- /dev/null+++ b/apps/web/src/lib/api/endpoints/attachments.ts@@ -0,0 +1,46 @@+import { request, uploadFile } from '@/lib/api/core/client';+import { mediaUrl } from '@/lib/api/core/media';++// The attachment DTO's url is relative to the API origin; point it at the web+// origin's media route so it works in <img>/<video> and markdown rendered there.+function withMediaUrl(a: Attachment): Attachment {+ return { ...a, url: mediaUrl(a.url) };+}++const sendAttachmentFile = (path: string, method: 'POST' | 'PUT', file: File) =>+ uploadFile<Attachment>(path, method, file).then(withMediaUrl);++export interface Attachment {+ id: string;+ filename: string;+ contentType: string;+ sizeBytes: number;+ createdAt: string;+ // Absolute, no-auth URL — usable directly in <img>/<video> and in markdown.+ url: string;+}++export const listAttachments = (issueId: number) =>+ request<Attachment[]>(`/issues/${issueId}/attachments`).then((rows) => rows.map(withMediaUrl));++export const uploadAttachment = (issueId: number, file: File) =>+ sendAttachmentFile(`/issues/${issueId}/attachments`, 'POST', file);++// Keeps the attachment's id and URL, so an embed of it in a description shows+// the new file.+export const replaceAttachment = (publicId: string, file: File) =>+ sendAttachmentFile(`/attachments/${publicId}`, 'PUT', file);++export const deleteAttachment = (publicId: string) =>+ request<void>(`/attachments/${publicId}`, { method: 'DELETE' });++export const listInitiativeAttachments = (initiativeId: number) =>+ request<Attachment[]>(`/initiatives/${initiativeId}/attachments`).then((rows) =>+ rows.map(withMediaUrl),+ );++export const uploadInitiativeAttachment = (initiativeId: number, file: File) =>+ sendAttachmentFile(`/initiatives/${initiativeId}/attachments`, 'POST', file);++export const deleteInitiativeAttachment = (publicId: string) =>+ request<void>(`/initiative-attachments/${publicId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/checklists.ts b/apps/web/src/lib/api/endpoints/checklists.tsnew file mode 100644index 00000000..ba1f2c3b--- /dev/null+++ b/apps/web/src/lib/api/endpoints/checklists.ts@@ -0,0 +1,62 @@+import { request } from '@/lib/api/core/client';++// One checkbox line of a checklist.+export interface ChecklistItem {+ id: number;+ content: string;+ done: boolean;+ position: number;+}++// A checklist on an issue: steps too small to be subtasks of their own. Both the+// checklists of an issue and the items of a checklist come back in display order.+export interface Checklist {+ id: number;+ title: string;+ position: number;+ items: ChecklistItem[];+}++// Checklists on an issue. The issue read already carries them, so there is no+// list call of their own — a write refreshes that read.+export const createChecklist = (issueId: number, title: string) =>+ request<Checklist>(`/issues/${issueId}/checklists`, {+ method: 'POST',+ body: JSON.stringify({ title }),+ });++export const renameChecklist = (checklistId: number, title: string) =>+ request<Checklist>(`/checklists/${checklistId}`, {+ method: 'PATCH',+ body: JSON.stringify({ title }),+ });++export const deleteChecklist = (checklistId: number) =>+ request<void>(`/checklists/${checklistId}`, { method: 'DELETE' });++export const reorderChecklists = (issueId: number, orderedIds: number[]) =>+ request<Checklist[]>(`/issues/${issueId}/checklists/reorder`, {+ method: 'PUT',+ body: JSON.stringify({ orderedIds }),+ });++export const createChecklistItem = (checklistId: number, content: string) =>+ request<ChecklistItem>(`/checklists/${checklistId}/items`, {+ method: 'POST',+ body: JSON.stringify({ content }),+ });++export const updateChecklistItem = (itemId: number, patch: { content?: string; done?: boolean }) =>+ request<ChecklistItem>(`/checklists/items/${itemId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteChecklistItem = (itemId: number) =>+ request<void>(`/checklists/items/${itemId}`, { method: 'DELETE' });++export const reorderChecklistItems = (checklistId: number, orderedIds: number[]) =>+ request<ChecklistItem[]>(`/checklists/${checklistId}/items/reorder`, {+ method: 'PUT',+ body: JSON.stringify({ orderedIds }),+ });diff --git a/apps/web/src/lib/api/endpoints/columns.ts b/apps/web/src/lib/api/endpoints/columns.tsnew file mode 100644index 00000000..aa9a64a4--- /dev/null+++ b/apps/web/src/lib/api/endpoints/columns.ts@@ -0,0 +1,72 @@+import { request } from '@/lib/api/core/client';++export type StateType = 'backlog' | 'unstarted' | 'started' | 'completed' | 'canceled';++export interface Column {+ id: number;+ projectId: number;+ name: string;+ stateType: StateType;+ color: string;+ position: number;+ // How many issues the column should hold, or null for no limit. wipMode decides+ // whether passing it only warns on the board or is refused outright.+ wipLimit: number | null;+ wipMode: WipMode;+ // The member every issue entering this column is assigned to, replacing whoever+ // held it.+ autoAssignUserId: string | null;+}++export type WipMode = 'soft' | 'hard';++export const createColumn = (+ projectKey: string,+ input: {+ name: string;+ stateType: StateType;+ color?: string;+ wipLimit?: number | null;+ wipMode?: WipMode;+ autoAssignUserId?: string | null;+ },+) =>+ request<Column>(`/projects/${projectKey}/columns`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateColumn = (+ projectKey: string,+ columnId: number,+ patch: {+ name?: string;+ stateType?: StateType;+ color?: string;+ // null clears the limit; absent leaves it as it is.+ wipLimit?: number | null;+ wipMode?: WipMode;+ // null clears the automatic assignment; absent leaves it as it is.+ autoAssignUserId?: string | null;+ },+) =>+ request<Column>(`/projects/${projectKey}/columns/${columnId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const reorderColumns = (projectKey: string, orderedIds: number[]) =>+ request<Column[]>(`/projects/${projectKey}/columns/reorder`, {+ method: 'PUT',+ body: JSON.stringify({ orderedIds }),+ });++export const deleteColumn = (+ projectKey: string,+ columnId: number,+ body: { mode: 'move'; targetColumnId: number } | { mode: 'delete' },+) =>+ request<void>(`/projects/${projectKey}/columns/${columnId}`, {+ method: 'DELETE',+ body: JSON.stringify(body),+ });diff --git a/apps/web/src/lib/api/endpoints/customFields.ts b/apps/web/src/lib/api/endpoints/customFields.tsnew file mode 100644index 00000000..b7fe048d--- /dev/null+++ b/apps/web/src/lib/api/endpoints/customFields.ts@@ -0,0 +1,75 @@+import { request } from '@/lib/api/core/client';++export type CustomFieldType =+ | 'text'+ | 'markdown'+ | 'url'+ | 'number'+ | 'boolean'+ | 'date'+ | 'datetime'+ | 'datetime_range'+ | 'select'+ | 'multi_select'+ | 'member';++// Who a member field may hold: every candidate, the people only, or the agents only.+// Null for every other field type.+export type MemberScope = 'all' | 'humans' | 'agents';++export interface CustomFieldOption {+ id: number;+ value: string;+ color: string;+ position: number;+}++export interface CustomField {+ id: number;+ issueTypeId: number | null;+ name: string;+ fieldType: CustomFieldType;+ memberScope: MemberScope | null;+ // When true the field renders in the issue body (under the description);+ // when false it renders as a Properties row.+ showInBody: boolean;+ position: number;+ options: CustomFieldOption[];+}++// A field can be reshaped after it exists, and the values issues hold follow: a new+// fieldType clears them, a narrowed memberScope clears the ones it no longer allows,+// and an option missing from `options` is deleted along with the selections of it.+export interface CustomFieldPatch {+ name?: string;+ showInBody?: boolean;+ fieldType?: CustomFieldType;+ memberScope?: MemberScope;+ // The full option list of a select field, in display order. An entry with an id+ // renames that option; one without is new.+ options?: { id?: number; value: string }[];+}++export interface NewCustomFieldInput {+ issueTypeId?: number | null;+ name: string;+ fieldType: CustomFieldType;+ memberScope?: MemberScope;+ showInBody?: boolean;+ options?: string[];+}++export const createCustomField = (projectKey: string, input: NewCustomFieldInput) =>+ request<CustomField>(`/projects/${projectKey}/custom-fields`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateCustomField = (projectKey: string, fieldId: number, patch: CustomFieldPatch) =>+ request<CustomField>(`/projects/${projectKey}/custom-fields/${fieldId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteCustomField = (projectKey: string, fieldId: number) =>+ request<void>(`/projects/${projectKey}/custom-fields/${fieldId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/cycles.ts b/apps/web/src/lib/api/endpoints/cycles.tsnew file mode 100644index 00000000..e1068e3c--- /dev/null+++ b/apps/web/src/lib/api/endpoints/cycles.ts@@ -0,0 +1,90 @@+import { request } from '@/lib/api/core/client';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// A time-boxed period of work (a sprint). status follows from the dates against+// today, unless the cycle was finished ahead of them; progress follows from the+// linked issues' states.+export type CycleStatus = 'upcoming' | 'active' | 'completed';++// A cycle as a picker option, for planning an issue into one.+export interface CycleOption {+ id: number;+ name: string;+ status: CycleStatus;+}++export interface CycleProgress {+ completed: number;+ canceled: number;+ total: number;+}++export interface Cycle {+ id: number;+ projectId: number;+ name: string;+ // What the team commits to in this cycle (the sprint goal). Empty when unset.+ goal: string;+ startDate: string;+ endDate: string;+ // When the cycle was finished ahead of its planned end date, or null. endDate+ // keeps the date it was planned to run until either way.+ completedAt: string | null;+ status: CycleStatus;+ createdAt: string;+ updatedAt: string;+ progress: CycleProgress;+}++export interface NewCycleInput {+ name: string;+ goal?: string;+ startDate: string;+ endDate: string;+}++export interface CyclePatch {+ name?: string;+ goal?: string;+ startDate?: string;+ endDate?: string;+}++// Cycles — same shape as initiatives: the list takes projectKey, ops on one cycle+// take its own id and hit /cycles/:id.+export const listCycles = (projectKey: string) =>+ request<Cycle[]>(`/projects/${projectKey}/cycles`);++export const listPlannedCycles = (projectKey: string) =>+ request<Cycle[]>(`/projects/${projectKey}/cycles?status=planned`);++export const listCycleOptions = (projectKey: string) =>+ request<CycleOption[]>(`/projects/${projectKey}/cycles/options`);++export const listCompletedCycles = (projectKey: string, params: PageParams) =>+ request<Page<Cycle>>(`/projects/${projectKey}/cycles/completed${pageQuery(params)}`);++export const getCycle = (id: number) => request<Cycle>(`/cycles/${id}`);++export const createCycle = (projectKey: string, input: NewCycleInput) =>+ request<Cycle>(`/projects/${projectKey}/cycles`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateCycle = (id: number, patch: CyclePatch) =>+ request<Cycle>(`/cycles/${id}`, { method: 'PATCH', body: JSON.stringify(patch) });++export const deleteCycle = (id: number) => request<void>(`/cycles/${id}`, { method: 'DELETE' });++export const transferCycleIssues = (id: number, targetCycleId: number | null) =>+ request<{ moved: number }>(`/cycles/${id}/transfer`, {+ method: 'POST',+ body: JSON.stringify({ targetCycleId }),+ });++export const finishCycle = (id: number) =>+ request<Cycle>(`/cycles/${id}/finish`, { method: 'POST' });++export const startNextCycle = (id: number) =>+ request<{ cycle: Cycle; moved: number }>(`/cycles/${id}/start-next`, { method: 'POST' });diff --git a/apps/web/src/lib/api/endpoints/dashboards.ts b/apps/web/src/lib/api/endpoints/dashboards.tsnew file mode 100644index 00000000..97d0fe38--- /dev/null+++ b/apps/web/src/lib/api/endpoints/dashboards.ts@@ -0,0 +1,52 @@+import type { DashboardLayout } from '@/utils/dashboardWidgets';+import { request } from '@/lib/api/core/client';++// A saved dashboard: the analytics counterpart of a View. `layout` is the ordered+// list of widgets (owned by the UI, stored verbatim server-side as jsonb).+export interface Dashboard {+ id: number;+ projectId: number;+ name: string;+ icon: string | null;+ layout: DashboardLayout;+ position: number;+ createdAt: string;+}++export interface NewDashboardInput {+ name: string;+ icon?: string | null;+ layout?: DashboardLayout;+}++export interface DashboardPatch {+ name?: string;+ icon?: string | null;+ layout?: DashboardLayout;+}++// Dashboards — same CRUD shape as views: collection ops take projectKey, ops on+// a single dashboard take its own id and hit /dashboards/:id.+export const listDashboards = (projectKey: string) =>+ request<Dashboard[]>(`/projects/${projectKey}/dashboards`);++export const createDashboard = (projectKey: string, input: NewDashboardInput) =>+ request<Dashboard>(`/projects/${projectKey}/dashboards`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateDashboard = (dashboardId: number, patch: DashboardPatch) =>+ request<Dashboard>(`/dashboards/${dashboardId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteDashboard = (dashboardId: number) =>+ request<void>(`/dashboards/${dashboardId}`, { method: 'DELETE' });++export const reorderDashboards = (projectKey: string, orderedIds: number[]) =>+ request<Dashboard[]>(`/projects/${projectKey}/dashboards/reorder`, {+ method: 'PUT',+ body: JSON.stringify({ orderedIds }),+ });diff --git a/apps/web/src/lib/api/endpoints/documents.ts b/apps/web/src/lib/api/endpoints/documents.tsnew file mode 100644index 00000000..6a10dcea--- /dev/null+++ b/apps/web/src/lib/api/endpoints/documents.ts@@ -0,0 +1,273 @@+import { request, uploadFile } from '@/lib/api/core/client';++function withDocumentAssetUrl(asset: DocumentAsset): DocumentAsset {+ const match = asset.url.match(+ /^\/projects\/([^/]+)\/documents\/(\d+)\/assets\/([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})\/raw$/i,+ );+ if (!match) throw new Error('The document asset URL returned by the API is invalid');+ const [, encodedProjectKey, documentId, publicId] = match;+ return {+ ...asset,+ url: `/protected-media/projects/${encodeURIComponent(decodeURIComponent(encodedProjectKey))}/documents/${documentId}/assets/${publicId}/raw`,+ };+}++export interface ProjectDocumentSummary {+ id: number;+ projectId: number;+ parentId: number | null;+ title: string;+ icon: string | null;+ metadata: Record<string, unknown>;+ fullWidth: boolean;+ isPrivate: boolean;+ isLocked: boolean;+ isFavorite: boolean;+ archivedAt: string | null;+ position: number;+ version: number;+ ownerUserId: string | null;+ createdByUserId: string | null;+ updatedByUserId: string | null;+ createdAt: string;+ updatedAt: string;+}++export interface ProjectDocument extends ProjectDocumentSummary {+ content: string;+ contentJson: Record<string, unknown> | null;+}++export interface DocumentIssueLink {+ issueId: number;+ sequenceNumber: number;+ identifier: string;+ title: string;+ archived: boolean;+ createdAt: string;+}++export interface IssueDocumentLink {+ documentId: number;+ title: string;+ icon: string | null;+ isPrivate: boolean;+ archived: boolean;+ createdAt: string;+}++export interface NewProjectDocumentInput {+ title?: string;+ content?: string;+ contentJson?: Record<string, unknown> | null;+ icon?: string | null;+ metadata?: Record<string, unknown>;+ fullWidth?: boolean;+ isPrivate?: boolean;+ parentId?: number | null;+}++export interface ProjectDocumentPatch {+ version: number;+ title?: string;+ content?: string;+ contentJson?: Record<string, unknown> | null;+ icon?: string | null;+ metadata?: Record<string, unknown>;+ fullWidth?: boolean;+ parentId?: number | null;+ position?: number;+ previousSiblingId?: number | null;+ nextSiblingId?: number | null;+}++export interface ProjectDocumentRevisionSummary {+ id: number;+ documentId: number;+ version: number;+ title: string;+ createdByUserId: string | null;+ createdAt: string;+}++export interface ProjectDocumentRevision extends ProjectDocumentRevisionSummary {+ parentId: number | null;+ content: string;+ contentJson: Record<string, unknown> | null;+ icon: string | null;+ metadata: Record<string, unknown>;+ fullWidth: boolean;+ isPrivate: boolean;+ isLocked: boolean;+ archivedAt: string | null;+ position: number;+}++export interface DocumentAsset {+ id: string;+ filename: string;+ contentType: string;+ sizeBytes: number;+ uploadedByUserId: string | null;+ createdAt: string;+ url: string;+}++export const listDocuments = (projectKey: string, q?: string, archived = false) => {+ const params = new URLSearchParams();+ if (q) params.set('q', q);+ if (archived) params.set('archived', 'true');+ const suffix = params.size > 0 ? `?${params}` : '';+ return request<ProjectDocumentSummary[]>(`/projects/${projectKey}/documents${suffix}`);+};++export const getDocument = (projectKey: string, documentId: number) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}`);++export const listDocumentIssueLinks = (projectKey: string, documentId: number) =>+ request<DocumentIssueLink[]>(`/projects/${projectKey}/documents/${documentId}/issues`);++export const listIssueDocumentLinks = (projectKey: string, issueId: number) =>+ request<IssueDocumentLink[]>(`/projects/${projectKey}/documents/for-issue/${issueId}`);++export const linkDocumentIssue = (projectKey: string, documentId: number, issueId: number) =>+ request<DocumentIssueLink>(`/projects/${projectKey}/documents/${documentId}/issues`, {+ method: 'POST',+ body: JSON.stringify({ issueId }),+ });++export const unlinkDocumentIssue = (projectKey: string, documentId: number, issueId: number) =>+ request<void>(`/projects/${projectKey}/documents/${documentId}/issues/${issueId}`, {+ method: 'DELETE',+ });++export const listInitiativeDocumentLinks = (projectKey: string, initiativeId: number) =>+ request<IssueDocumentLink[]>(`/projects/${projectKey}/documents/for-initiative/${initiativeId}`);++export const linkDocumentInitiative = (+ projectKey: string,+ documentId: number,+ initiativeId: number,+) =>+ request<IssueDocumentLink>(`/projects/${projectKey}/documents/${documentId}/initiatives`, {+ method: 'POST',+ body: JSON.stringify({ initiativeId }),+ });++export const unlinkDocumentInitiative = (+ projectKey: string,+ documentId: number,+ initiativeId: number,+) =>+ request<void>(`/projects/${projectKey}/documents/${documentId}/initiatives/${initiativeId}`, {+ method: 'DELETE',+ });++export const createDocument = (projectKey: string, input: NewProjectDocumentInput) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateDocument = (+ projectKey: string,+ documentId: number,+ patch: ProjectDocumentPatch,+) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteDocument = (projectKey: string, documentId: number, version: number) =>+ request<void>(`/projects/${projectKey}/documents/${documentId}?version=${version}`, {+ method: 'DELETE',+ });++export const setDocumentAccess = (+ projectKey: string,+ documentId: number,+ input: { version: number; isPrivate: boolean },+) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/access`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const setDocumentLocked = (+ projectKey: string,+ documentId: number,+ version: number,+ locked: boolean,+) =>+ request<ProjectDocument>(+ `/projects/${projectKey}/documents/${documentId}/${locked ? 'lock' : 'unlock'}`,+ { method: 'POST', body: JSON.stringify({ version }) },+ );++export const archiveDocument = (projectKey: string, documentId: number, version: number) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/archive`, {+ method: 'POST',+ body: JSON.stringify({ version }),+ });++export const restoreDocument = (projectKey: string, documentId: number, version: number) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/restore`, {+ method: 'POST',+ body: JSON.stringify({ version }),+ });++export const duplicateDocument = (+ projectKey: string,+ documentId: number,+ input: { version: number; title?: string; parentId?: number | null },+) =>+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/duplicate`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const setDocumentFavorite = (projectKey: string, documentId: number, isFavorite: boolean) =>+ request<{ isFavorite: boolean }>(`/projects/${projectKey}/documents/${documentId}/preferences`, {+ method: 'PATCH',+ body: JSON.stringify({ isFavorite }),+ });++export const listDocumentRevisions = (projectKey: string, documentId: number) =>+ request<ProjectDocumentRevisionSummary[]>(+ `/projects/${projectKey}/documents/${documentId}/revisions`,+ );++export const getDocumentRevision = (projectKey: string, documentId: number, revisionId: number) =>+ request<ProjectDocumentRevision>(+ `/projects/${projectKey}/documents/${documentId}/revisions/${revisionId}`,+ );++export const restoreDocumentRevision = (+ projectKey: string,+ documentId: number,+ revisionId: number,+ version: number,+) =>+ request<ProjectDocument>(+ `/projects/${projectKey}/documents/${documentId}/revisions/${revisionId}/restore`,+ { method: 'POST', body: JSON.stringify({ version }) },+ );++export const listDocumentAssets = (projectKey: string, documentId: number) =>+ request<DocumentAsset[]>(`/projects/${projectKey}/documents/${documentId}/assets`).then(+ (assets) => assets.map(withDocumentAssetUrl),+ );++export const uploadDocumentAsset = (projectKey: string, documentId: number, file: File) =>+ uploadFile<DocumentAsset>(+ `/projects/${projectKey}/documents/${documentId}/assets`,+ 'POST',+ file,+ ).then(withDocumentAssetUrl);++export const deleteDocumentAsset = (projectKey: string, documentId: number, publicId: string) =>+ request<void>(+ `/projects/${projectKey}/documents/${documentId}/assets/${encodeURIComponent(publicId)}`,+ { method: 'DELETE' },+ );diff --git a/apps/web/src/lib/api/endpoints/git.ts b/apps/web/src/lib/api/endpoints/git.tsnew file mode 100644index 00000000..8cd67ff4--- /dev/null+++ b/apps/web/src/lib/api/endpoints/git.ts@@ -0,0 +1,243 @@+import { request } from '@/lib/api/core/client';++// Per-project repository integration settings, shared by every provider.+// webhookId is the path segment of the payload URL registered on the repository;+// secret authenticates its deliveries and is null for members who may read but not+// edit integrations. onMergeColumnId is where an issue closed by a merged pull+// request moves (null = the first completed state); onOpenColumnId is where an+// issue moves when a linked pull request is opened (null = no action).+export interface GitSettings {+ enabled: boolean;+ webhookId: string;+ secret: string | null;+ onMergeColumnId: number | null;+ onOpenColumnId: number | null;+ linkbackComments: boolean;+ repositories: GitRepository[];+}++// One repository that has delivered to the project, with the host it came from+// and when its last delivery arrived.+export interface GitRepository {+ repo: string;+ provider: string;+ lastEventAt: string;+}++export type GitConnectionProvider = 'github' | 'gitlab' | 'gitea' | 'forgejo' | 'bitbucket';++export interface GitManagedRepository {+ id: number;+ externalId: string;+ fullName: string;+ webUrl: string;+ status: 'connected' | 'error';+ lastError: string | null;+}++export interface AvailableGitRepositoryPage {+ repositories: AvailableGitRepository[];+ nextPage: number | null;+}++export interface GitProviderConnection {+ id: number;+ provider: GitConnectionProvider;+ baseUrl: string;+ accountLogin: string;+ repositories: GitManagedRepository[];+ createdAt: string;+ updatedAt: string;+}++export interface AvailableGitRepository {+ externalId: string;+ fullName: string;+ webUrl: string;+ private: boolean;+ managedRepositoryId: number | null;+}++export type GitProvider = 'github' | 'gitlab' | 'gitea' | 'forgejo' | 'bitbucket';++export type PullRequestState = 'open' | 'merged' | 'closed';++export type PipelineStatus = 'pending' | 'running' | 'success' | 'failed' | 'canceled' | 'skipped';++export interface DevelopmentCheck {+ id: number;+ name: string;+ status: PipelineStatus;+ url: string | null;+ updatedAt: string;+}++export interface DevelopmentLink {+ id: number;+ provider: GitProvider;+ repository: string;+ kind: 'pull_request' | 'branch';+ number: number | null;+ title: string;+ url: string | null;+ state: PullRequestState;+ draft: boolean;+ sourceBranch: string | null;+ targetBranch: string;+ headSha: string | null;+ pipelineStatus: PipelineStatus | null;+ pipelineUrl: string | null;+ checkStatus: PipelineStatus | null;+ checks: DevelopmentCheck[];+ updatedAt: string;+}++export interface DevelopmentRepository {+ id: number;+ provider: 'github' | 'gitlab';+ fullName: string;+ webUrl: string;+}++export interface LinkablePullRequest {+ number: number;+ title: string;+ url: string | null;+ state: PullRequestState;+ draft: boolean;+ sourceBranch: string | null;+ targetBranch: string;+ headSha: string | null;+ updatedAt: string;+ linked: boolean;+}++export interface LinkablePullRequestPage {+ pullRequests: LinkablePullRequest[];+ nextPage: number | null;+}++export interface DevelopmentBranchPage {+ branches: string[];+ defaultBranch: string | null;+ nextPage: number | null;+}++export interface CreateIssuePullRequestInput {+ repositoryId: number;+ sourceBranch: string;+ targetBranch: string;+ title: string;+ description: string;+ draft: boolean;+}++// The repository integration (integrations: read to view, edit to change).+export const getGitSettings = (projectKey: string) =>+ request<GitSettings>(`/projects/${projectKey}/settings/git`);++export const updateGitSettings = (+ projectKey: string,+ patch: {+ enabled?: boolean;+ onMergeColumnId?: number | null;+ onOpenColumnId?: number | null;+ linkbackComments?: boolean;+ },+) =>+ request<GitSettings>(`/projects/${projectKey}/settings/git`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const regenerateGitSecret = (projectKey: string) =>+ request<GitSettings>(`/projects/${projectKey}/settings/git/secret`, {+ method: 'POST',+ });++export const listGitProviderConnections = (projectKey: string) =>+ request<GitProviderConnection[]>(`/projects/${projectKey}/settings/git/connections`);++export const connectGitProvider = (+ projectKey: string,+ input: { provider: GitConnectionProvider; baseUrl?: string; token: string },+) =>+ request<GitProviderConnection>(`/projects/${projectKey}/settings/git/connections`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const disconnectGitProvider = (projectKey: string, connectionId: number) =>+ request<void>(`/projects/${projectKey}/settings/git/connections/${connectionId}`, {+ method: 'DELETE',+ });++export const listAvailableGitRepositories = (+ projectKey: string,+ connectionId: number,+ params: { page?: number; search?: string },+) => {+ const query = new URLSearchParams();+ if (params.page) query.set('page', String(params.page));+ if (params.search) query.set('search', params.search);+ return request<AvailableGitRepositoryPage>(+ `/projects/${projectKey}/settings/git/connections/${connectionId}/repositories?${query}`,+ );+};++export const connectGitRepositories = (+ projectKey: string,+ connectionId: number,+ externalIds: string[],+) =>+ request<GitProviderConnection>(+ `/projects/${projectKey}/settings/git/connections/${connectionId}/repositories`,+ { method: 'POST', body: JSON.stringify({ externalIds }) },+ );++export const disconnectGitRepository = (+ projectKey: string,+ connectionId: number,+ repositoryId: number,+) =>+ request<void>(+ `/projects/${projectKey}/settings/git/connections/${connectionId}/repositories/${repositoryId}`,+ { method: 'DELETE' },+ );++export const listIssueDevelopmentRepositories = (issueId: number) =>+ request<DevelopmentRepository[]>(`/issues/${issueId}/development/repositories`);++export const listLinkablePullRequests = (+ issueId: number,+ repositoryId: number,+ input: { state: 'open' | 'all'; page: number },+) =>+ request<LinkablePullRequestPage>(+ `/issues/${issueId}/development/repositories/${repositoryId}/pull-requests?${new URLSearchParams(+ { state: input.state, page: String(input.page) },+ )}`,+ );++export const listDevelopmentBranches = (issueId: number, repositoryId: number, page: number) =>+ request<DevelopmentBranchPage>(+ `/issues/${issueId}/development/repositories/${repositoryId}/branches?page=${page}`,+ );++export const linkIssueDevelopment = (+ issueId: number,+ input: { repositoryId: number; number: number },+) =>+ request<DevelopmentLink>(`/issues/${issueId}/development`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const removeIssueDevelopmentLink = (issueId: number, linkId: number) =>+ request<void>(`/issues/${issueId}/development/${linkId}`, { method: 'DELETE' });++export const createIssuePullRequest = (issueId: number, input: CreateIssuePullRequestInput) =>+ request<DevelopmentLink>(`/issues/${issueId}/development/pull-requests`, {+ method: 'POST',+ body: JSON.stringify(input),+ });diff --git a/apps/web/src/lib/api/endpoints/god.ts b/apps/web/src/lib/api/endpoints/god.tsnew file mode 100644index 00000000..141d81f2--- /dev/null+++ b/apps/web/src/lib/api/endpoints/god.ts@@ -0,0 +1,327 @@+import { request } from '@/lib/api/core/client';+import type { MemberRole } from '@/lib/api/endpoints/members';+import type { NotificationEncryption } from '@/lib/api/endpoints/notificationSettings';+import type { Permissions } from '@/lib/api/endpoints/roles';+import type { ProjectDefaults } from '@/lib/api/endpoints/projects';+import type {+ HotkeyOverrides,+ StorageSettings,+ StorageSettingsPatch,+} from '@/lib/api/endpoints/settings';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// Who may create an account on this instance.+export type RegistrationMode = 'open' | 'invite' | 'closed';++// The instance sign-in policy. hasEmailProvider tells whether outbound mail works;+// the options that depend on it cannot be turned on without one.+export interface InstanceAuthSettings {+ registration: RegistrationMode;+ requireEmailVerification: boolean;+ magicLink: boolean;+ emailPassword: boolean;+ hasEmailProvider: boolean;+ // Whether Google or the OIDC provider can run. Password sign-in may only be turned+ // off while one of them can.+ hasSsoProvider: boolean;+}++export interface InstanceAuthSettingsPatch {+ registration?: RegistrationMode;+ requireEmailVerification?: boolean;+ magicLink?: boolean;+ emailPassword?: boolean;+}++// The instance mail provider used for authentication email (password reset, address+// verification, magic links). Separate from a team's notification provider.+// Secrets are never returned, only a `hasX` flag.+export interface InstanceEmailSettings {+ smtp: {+ enabled: boolean;+ host: string;+ port: number | null;+ encryption: NotificationEncryption;+ username: string;+ hasPassword: boolean;+ timeout: number | null;+ };+ resend: { enabled: boolean; hasApiKey: boolean };+ from: string;+ // Whether projects may deliver their notifications through this provider.+ allowProjects: boolean;+}++export interface InstanceEmailSettingsPatch {+ smtp?: {+ enabled: boolean;+ host: string;+ port: number | null;+ encryption: NotificationEncryption;+ username: string;+ password?: string;+ timeout: number | null;+ };+ resend?: { enabled: boolean; apiKey?: string };+ from?: string;+ allowProjects?: boolean;+}++export interface InstanceEmailTestResult {+ recipient: string;+}++// The Google OAuth credentials used for social sign-in. The client secret is never+// returned, only a `hasClientSecret` flag. redirectUri is derived from the API origin+// and has to be registered in the Google Cloud console.+export interface InstanceGoogleSettings {+ enabled: boolean;+ clientId: string;+ hasClientSecret: boolean;+ redirectUri: string;+}++export interface InstanceGoogleSettingsPatch {+ enabled?: boolean;+ clientId?: string;+ clientSecret?: string;+}++// The instance's generic OIDC/OAuth2 provider. The client secret is never returned,+// only a `hasClientSecret` flag. redirectUri is derived from the API origin and has+// to be registered with the identity provider.+export interface InstanceOidcSettings {+ enabled: boolean;+ label: string;+ discoveryUrl: string;+ clientId: string;+ hasClientSecret: boolean;+ scopes: string[];+ pkce: boolean;+ redirectUri: string;+}++export interface InstanceOidcSettingsPatch {+ enabled?: boolean;+ label?: string;+ discoveryUrl?: string;+ clientId?: string;+ clientSecret?: string;+ scopes?: string[];+ pkce?: boolean;+}++// The instance Telegram bot: the one bot users link their accounts through, and the+// default sender for Telegram notifications. `botUsername` is resolved from Telegram+// when the token is saved.+export interface InstanceTelegramSettings {+ enabled: boolean;+ botUsername: string;+ hasBotToken: boolean;+}++export interface InstanceTelegramSettingsPatch {+ enabled?: boolean;+ botToken?: string;+}++// One account in the instance user directory. `role` is the global better-auth role+// ("god" for the instance owner), which is unrelated to project membership.+export interface InstanceUser {+ id: string;+ name: string;+ email: string;+ image: string | null;+ emailVerified: boolean;+ role: string;+ isAgent: boolean;+ providers: string[];+ projectCount: number;+ lastSeenAt: string | null;+ createdAt: string;+}++// A project the user can reach, with the permissions their membership resolves to+// (full for an owner, the assigned role's matrix for a member).+export interface InstanceUserProject {+ projectId: number;+ projectKey: string;+ projectName: string;+ role: MemberRole;+ roleId: number | null;+ roleName: string | null;+ permissions: Permissions;+ // How many owners the project has. 1 on a project this user owns means deleting+ // the account would leave the project with nobody who can manage it.+ ownerCount: number;+ joinedAt: string;+}++export interface InstanceUserDetail extends InstanceUser {+ projects: InstanceUserProject[];+}++// Which accounts the directory lists: real people, the bot users behind AI agents,+// or both.+export type InstanceUserKind = 'human' | 'agent' | 'all';++// One project in the instance project directory, with what it holds counted across+// its dependent tables. `lastActivityAt` is the most recent entry in its issue feed.+export interface InstanceProject {+ id: number;+ key: string;+ name: string;+ description: string;+ mcpEnabled: boolean;+ memberCount: number;+ issueCount: number;+ archivedIssueCount: number;+ initiativeCount: number;+ dashboardCount: number;+ viewCount: number;+ agentCount: number;+ skillCount: number;+ toolCount: number;+ lastActivityAt: string | null;+ createdAt: string;+}++// One member of a project, with the permissions their membership resolves to (full+// for an owner, the assigned role's matrix for a member).+export interface InstanceProjectMember {+ userId: string;+ name: string;+ email: string;+ username: string | null;+ image: string | null;+ isAgent: boolean;+ role: MemberRole;+ roleId: number | null;+ roleName: string | null;+ permissions: Permissions;+ description: string;+ timezone: string;+ joinedAt: string;+}++export interface InstanceProjectDetail extends InstanceProject {+ members: InstanceProjectMember[];+ // The custom roles a member of this project can be put on, for the SCIM group+ // mapping form.+ roles: { id: number; name: string; isDefault: boolean }[];+}++// One instance project as a picker entry: what the SCIM mapping form needs to name it.+export interface InstanceProjectOption {+ id: number;+ key: string;+ name: string;+}++// Instance administration (god mode). Every route below is owner-only; a plain+// user gets a 403, which is why the entries are hidden from the sidebar.+export const getInstanceAuthSettings = () => request<InstanceAuthSettings>('/god/auth-settings');++export const updateInstanceAuthSettings = (patch: InstanceAuthSettingsPatch) =>+ request<InstanceAuthSettings>('/god/auth-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++export const getInstanceEmailSettings = () => request<InstanceEmailSettings>('/god/email-settings');++export const updateInstanceEmailSettings = (patch: InstanceEmailSettingsPatch) =>+ request<InstanceEmailSettings>('/god/email-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++export const testInstanceEmailSettings = (patch: InstanceEmailSettingsPatch) =>+ request<InstanceEmailTestResult>('/god/email-settings/test', {+ method: 'POST',+ body: JSON.stringify(patch),+ });++export const getInstanceTelegramSettings = () =>+ request<InstanceTelegramSettings>('/god/telegram-settings');++export const updateInstanceTelegramSettings = (patch: InstanceTelegramSettingsPatch) =>+ request<InstanceTelegramSettings>('/god/telegram-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++export const getInstanceHotkeySettings = () => request<HotkeyOverrides>('/god/hotkey-settings');++export const updateInstanceHotkeySettings = (combos: HotkeyOverrides) =>+ request<HotkeyOverrides>('/god/hotkey-settings', {+ method: 'PUT',+ body: JSON.stringify(combos),+ });++export const getInstanceProjectDefaults = () => request<ProjectDefaults>('/god/project-defaults');++export const updateInstanceProjectDefaults = (body: ProjectDefaults) =>+ request<ProjectDefaults>('/god/project-defaults', {+ method: 'PUT',+ body: JSON.stringify(body),+ });++export const getInstanceStorageSettings = () => request<StorageSettings>('/god/storage-settings');++export const updateInstanceStorageSettings = (patch: StorageSettingsPatch) =>+ request<StorageSettings>('/god/storage-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++export const getInstanceGoogleSettings = () =>+ request<InstanceGoogleSettings>('/god/google-settings');++export const updateInstanceGoogleSettings = (patch: InstanceGoogleSettingsPatch) =>+ request<InstanceGoogleSettings>('/god/google-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++export const getInstanceOidcSettings = () => request<InstanceOidcSettings>('/god/oidc-settings');++export const updateInstanceOidcSettings = (patch: InstanceOidcSettingsPatch) =>+ request<InstanceOidcSettings>('/god/oidc-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++// The instance user directory: one page of accounts, and one account with the+// projects it can reach. Search, the kind filter and paging all run on the server.+export const listInstanceUsers = (+ params: PageParams & { search?: string; kind: InstanceUserKind },+) =>+ request<Page<InstanceUser>>(+ `/god/users${pageQuery(params, { kind: params.kind, search: params.search })}`,+ );++export const getInstanceUser = (userId: string) =>+ request<InstanceUserDetail>(`/god/users/${userId}`);++export const verifyInstanceUserEmail = (userId: string) =>+ request<InstanceUserDetail>(`/god/users/${userId}/verify-email`, { method: 'POST' });++// `withProjects` takes down the projects the user owns alone; without it the API+// refuses to delete an account that would leave a project ownerless.+export const deleteInstanceUser = (userId: string, withProjects: boolean) =>+ request<void>(`/god/users/${userId}${withProjects ? '?withProjects=true' : ''}`, {+ method: 'DELETE',+ });++// The instance project directory: one page of projects, and one project with its+// members. Search and paging run on the server.+export const listInstanceProjects = (params: PageParams & { search?: string }) =>+ request<Page<InstanceProject>>(`/god/projects${pageQuery(params, { search: params.search })}`);++// Every project, for the SCIM mapping picker; the directory above is paged.+export const listInstanceProjectOptions = () =>+ request<InstanceProjectOption[]>('/god/projects/options');++export const getInstanceProject = (projectId: number) =>+ request<InstanceProjectDetail>(`/god/projects/${projectId}`);diff --git a/apps/web/src/lib/api/endpoints/imports.ts b/apps/web/src/lib/api/endpoints/imports.tsnew file mode 100644index 00000000..3098639c--- /dev/null+++ b/apps/web/src/lib/api/endpoints/imports.ts@@ -0,0 +1,36 @@+// Issue imports: a chat attachment an agent mapped into issues, awaiting confirmation.++import { request } from '@/lib/api/core/client';++export interface IssueImport {+ id: string;+ filename: string;+ contentType: string;+ sizeBytes: number;+ status: 'mapped' | 'confirmed' | 'canceled' | 'failed';+ mapping: Record<string, string> | null;+ errorText: string | null;+ createdAt: string;+ preview?: {+ columns: { field: string; header: string }[];+ rows: { cells: string[]; skip: string | null }[];+ totalRows: number;+ };+}++export interface ImportConfirmResult {+ imported: { key: string; title: string }[];+ skipped: { row: number; reason: string }[];+}++export async function getImport(importId: string): Promise<IssueImport> {+ return request(`/imports/${importId}`);+}++export async function confirmImport(importId: string): Promise<ImportConfirmResult> {+ return request(`/imports/${importId}/confirm`, { method: 'POST' });+}++export async function discardImport(importId: string): Promise<void> {+ await request(`/imports/${importId}/cancel`, { method: 'POST' });+}diff --git a/apps/web/src/lib/api/endpoints/initiatives.ts b/apps/web/src/lib/api/endpoints/initiatives.tsnew file mode 100644index 00000000..68eb2aca--- /dev/null+++ b/apps/web/src/lib/api/endpoints/initiatives.ts@@ -0,0 +1,158 @@+import { request } from '@/lib/api/core/client';+import type { ActivityPayload, FeedCursor } from '@/lib/api/endpoints/activity';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++export type InitiativeStatus = 'proposed' | 'planned' | 'active' | 'completed' | 'canceled';++export type InitiativeHealth = 'on_track' | 'at_risk' | 'off_track';++export interface InitiativeProgress {+ completed: number;+ canceled: number;+ total: number;+}++export interface Initiative {+ id: number;+ projectId: number;+ title: string;+ description: string;+ status: InitiativeStatus;+ ownerUserId: string | null;+ priority: string | null;+ startDate: string | null;+ targetDate: string | null;+ position: number;+ createdAt: string;+ updatedAt: string;+ labelIds: number[];+ progress: InitiativeProgress;+ health: InitiativeHealth | null;+}++// An initiative as a picker option, for linking an issue to one.+export interface InitiativeOption {+ id: number;+ title: string;+ status: InitiativeStatus;+}++// Columns the initiative list can be sorted by, server-side. progress and health+// are derived and not sortable.+export const INITIATIVE_SORTS = ['title', 'priority', 'targetDate', 'owner'] as const;++export type InitiativeSort = (typeof INITIATIVE_SORTS)[number];++export interface InitiativeListParams extends PageParams {+ statuses?: string[];+ search?: string;+ sort?: InitiativeSort;+ dir?: 'asc' | 'desc';+}++// Per-status initiative counts for the list's status tabs.+export interface InitiativeCounts {+ total: number;+ proposed: number;+ planned: number;+ active: number;+ completed: number;+ canceled: number;+}++export interface NewInitiativeInput {+ title: string;+ description?: string;+ status?: InitiativeStatus;+ ownerUserId?: string | null;+ priority?: string | null;+ startDate?: string | null;+ targetDate?: string | null;+ labelIds?: number[];+}++export interface InitiativePatch {+ title?: string;+ description?: string;+ status?: InitiativeStatus;+ ownerUserId?: string | null;+ priority?: string | null;+ startDate?: string | null;+ targetDate?: string | null;+ labelIds?: number[];+}++// One entry in an initiative's feed: an event of the initiative itself (source+// 'initiative') or the activity of a linked issue (source 'issue', carrying the+// issue's id and identifier so the row can link to it).+export interface InitiativeFeedItem {+ id: number;+ source: 'initiative' | 'issue';+ kind: 'comment' | 'activity';+ actorUserId: string | null;+ actorName: string | null;+ body: string | null;+ action: string | null;+ payload: ActivityPayload;+ createdAt: string;+ issueId: number | null;+ issueIdentifier: string | null;+}++export interface InitiativeFeedPage {+ items: InitiativeFeedItem[];+ nextCursor: FeedCursor | null;+}++// Initiatives — collection ops take projectKey; ops on one initiative take its+// own id and hit /initiatives/:id (like issues).+export const listInitiatives = (projectKey: string, params: InitiativeListParams) =>+ request<Page<Initiative>>(+ `/projects/${projectKey}/initiatives${pageQuery(params, {+ status: params.statuses?.join(','),+ search: params.search,+ sort: params.sort,+ dir: params.dir,+ })}`,+ );++export const listInitiativeOptions = (+ projectKey: string,+ params: { search?: string; include?: number },+) => {+ const q = new URLSearchParams();+ if (params.search) q.set('search', params.search);+ if (params.include) q.set('include', String(params.include));+ const qs = q.toString();+ return request<InitiativeOption[]>(+ `/projects/${projectKey}/initiatives/options${qs ? `?${qs}` : ''}`,+ );+};++export const initiativeCounts = (projectKey: string) =>+ request<InitiativeCounts>(`/projects/${projectKey}/initiatives/counts`);++export const getInitiative = (id: number) => request<Initiative>(`/initiatives/${id}`);++export const createInitiative = (projectKey: string, input: NewInitiativeInput) =>+ request<Initiative>(`/projects/${projectKey}/initiatives`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateInitiative = (id: number, patch: InitiativePatch) =>+ request<Initiative>(`/initiatives/${id}`, { method: 'PATCH', body: JSON.stringify(patch) });++export const deleteInitiative = (id: number) =>+ request<void>(`/initiatives/${id}`, { method: 'DELETE' });++export const listInitiativeFeed = (+ id: number,+ params: { cursor?: FeedCursor | null; limit?: number } = {},+) => {+ const q = new URLSearchParams();+ if (params.limit) q.set('limit', String(params.limit));+ if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));+ const qs = q.toString();+ return request<InitiativeFeedPage>(`/initiatives/${id}/feed${qs ? `?${qs}` : ''}`);+};diff --git a/apps/web/src/lib/api/endpoints/integrations.ts b/apps/web/src/lib/api/endpoints/integrations.tsnew file mode 100644index 00000000..214e6f65--- /dev/null+++ b/apps/web/src/lib/api/endpoints/integrations.ts@@ -0,0 +1,96 @@+import { request } from '@/lib/api/core/client';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// A field of an integration's credential form (from the catalog). `type` "secret"+// marks a value stored encrypted and shown masked.+export interface ConfigField {+ key: string;+ label: string;+ type: 'string' | 'secret' | 'url' | 'number' | 'boolean';+ required: boolean;+ placeholder?: string;+ help?: string;+}++// 'llm' is an AI provider (its models an agent runs on, no tools); 'tool' is a tool+// integration whose `tools` are configured on a credential.+export type IntegrationKind = 'llm' | 'tool';++// An integration the team can store a credential for (server-side catalog).+export interface IntegrationMeta {+ key: string;+ label: string;+ kind: IntegrationKind;+ credentialSchema: ConfigField[];+ tools: { key: string; label: string; description: string; scopes?: string[] }[];+}++// A model an LLM provider offers, from the models.dev registry.+export interface ProviderModel {+ id: string;+ name: string;+}++// A stored integration credential. `redacted` mirrors the stored credential with+// secret fields masked; the real secrets are never returned.+export interface IntegrationCredential {+ id: number;+ teamId: number;+ integrationKey: string;+ label: string | null;+ redacted: Record<string, unknown>;+ createdAt: string;+}++// A connected integration as a picker option: what it is and what it is called,+// with none of the credential fields the admin list carries.+export interface IntegrationOption {+ id: number;+ integrationKey: string;+ kind: IntegrationKind;+ label: string | null;+}++export interface NewCredentialInput {+ integrationKey: string;+ label?: string | null;+ credential: Record<string, unknown>;+}++export interface CredentialPatch {+ label?: string | null;+ // Only the fields being changed. Secret fields left out keep their stored value.+ credential?: Record<string, unknown>;+}++// Integrations: the team's stored credentials for LLM providers and tool+// integrations, shared by every project it owns. The secret is write-only —+// responses carry only a redacted view.+export const listIntegrationCatalog = (teamId: number) =>+ request<IntegrationMeta[]>(`/teams/${teamId}/integrations/catalog`);++export const listIntegrationModels = (teamId: number, provider: string) =>+ request<ProviderModel[]>(`/teams/${teamId}/integrations/models/${encodeURIComponent(provider)}`);++export const listCredentials = (teamId: number, params: PageParams) =>+ request<Page<IntegrationCredential>>(`/teams/${teamId}/integrations${pageQuery(params)}`);++export const listIntegrationOptions = (teamId: number, kind?: IntegrationKind) =>+ request<IntegrationOption[]>(+ `/teams/${teamId}/integrations/options${kind ? `?kind=${kind}` : ''}`,+ );++export const createCredential = (teamId: number, input: NewCredentialInput) =>+ request<IntegrationCredential>(`/teams/${teamId}/integrations`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateCredential = (teamId: number, credentialId: number, patch: CredentialPatch) =>+ request<IntegrationCredential>(`/teams/${teamId}/integrations/${credentialId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteCredential = (teamId: number, credentialId: number) =>+ request<void>(`/teams/${teamId}/integrations/${credentialId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/invites.ts b/apps/web/src/lib/api/endpoints/invites.tsnew file mode 100644index 00000000..fe8a83e7--- /dev/null+++ b/apps/web/src/lib/api/endpoints/invites.ts@@ -0,0 +1,112 @@+import { request } from '@/lib/api/core/client';+import type { MemberRole } from '@/lib/api/endpoints/members';++export type InviteStatus = 'pending' | 'accepted' | 'rejected';++// The rank an invite puts its invitee on in the team. Only a team owner sends one+// that grants 'owner' or 'manager'.+export type InviteTeamRole = 'owner' | 'manager' | 'member';++// An invite as shown to whoever manages a team's or a project's invites: carries the+// token so they can share the link, and who sent it.+export interface InviteRow {+ id: number;+ token: string;+ email: string;+ teamRole: InviteTeamRole;+ // The project the invitee joins along with the team, or null for an invite into+ // the team alone.+ projectKey: string | null;+ projectName: string | null;+ // Their role in that project. null when the invite names no project.+ role: MemberRole | null;+ // The custom role the invitee joins the project on. null falls back to the team's+ // default role; roleName resolves it for display. A project owner has both null.+ roleId: number | null;+ roleName: string | null;+ status: InviteStatus;+ createdAt: string;+ respondedAt: string | null;+ invitedByName: string | null;+ invitedByEmail: string | null;+}++export interface InviteCreateResult extends InviteRow {+ emailQueued: boolean;+}++export interface InviteEmailResult {+ emailQueued: boolean;+}++// An invite as shown to the invitee opening the link: enough team and project+// context to decide, never the internal ids.+export interface InviteView {+ token: string;+ teamName: string;+ projectKey: string | null;+ projectName: string | null;+ email: string;+ teamRole: InviteTeamRole;+ role: MemberRole | null;+ roleId: number | null;+ roleName: string | null;+ status: InviteStatus;+ createdAt: string;+ // Whether the invited email already has an account, so the accept screen can+ // open in sign-in mode instead of registration.+ hasAccount: boolean;+}++// Where an invitee landed once the invite was accepted.+export interface AcceptedInvite {+ teamName: string;+ projectKey: string | null;+ projectName: string | null;+ role: MemberRole | null;+}++// Invites — the managing side: create, list, email, and revoke the invite links of+// a project or of a team. A project invite joins the team as well; a team invite+// names no project.+export const listInvites = (projectKey: string) =>+ request<InviteRow[]>(`/projects/${projectKey}/invites`);++export const createInvite = (+ projectKey: string,+ input: { email: string; role: MemberRole; roleId?: number | null },+) =>+ request<InviteCreateResult>(`/projects/${projectKey}/invites`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const sendInviteEmail = (projectKey: string, inviteId: number) =>+ request<InviteEmailResult>(`/projects/${projectKey}/invites/${inviteId}/email`, {+ method: 'POST',+ });++export const deleteInvite = (projectKey: string, inviteId: number) =>+ request<void>(`/projects/${projectKey}/invites/${inviteId}`, { method: 'DELETE' });++export const listTeamInvites = (teamId: number) => request<InviteRow[]>(`/teams/${teamId}/invites`);++export const createTeamInvite = (teamId: number, input: { email: string; role: InviteTeamRole }) =>+ request<InviteRow>(`/teams/${teamId}/invites`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const deleteTeamInvite = (teamId: number, inviteId: number) =>+ request<void>(`/teams/${teamId}/invites/${inviteId}`, { method: 'DELETE' });++// Invites — invitee side: open a link by token, then accept or reject it. The+// session email must match the invite. Accept returns where to go next.+export const getInvite = (token: string) =>+ request<InviteView>(`/invites/${encodeURIComponent(token)}`);++export const acceptInvite = (token: string) =>+ request<AcceptedInvite>(`/invites/${encodeURIComponent(token)}/accept`, { method: 'POST' });++export const rejectInvite = (token: string) =>+ request<void>(`/invites/${encodeURIComponent(token)}/reject`, { method: 'POST' });diff --git a/apps/web/src/lib/api/endpoints/issueTemplates.ts b/apps/web/src/lib/api/endpoints/issueTemplates.tsnew file mode 100644index 00000000..3f1cea48--- /dev/null+++ b/apps/web/src/lib/api/endpoints/issueTemplates.ts@@ -0,0 +1,51 @@+import { request } from '@/lib/api/core/client';++// A preset a new issue can be created from: the title and description it starts+// with plus the properties applied on top of them. A property left null presets+// nothing — the create dialog keeps its own default for it.+export interface IssueTemplate {+ id: number;+ name: string;+ description: string;+ titleTemplate: string;+ descriptionTemplate: string;+ typeId: number | null;+ columnId: number | null;+ priority: string | null;+ assigneeUserId: string | null;+ labelIds: number[];+}++export interface NewIssueTemplateInput {+ name: string;+ description?: string;+ titleTemplate?: string;+ descriptionTemplate?: string;+ typeId?: number | null;+ columnId?: number | null;+ priority?: string | null;+ assigneeUserId?: string | null;+ labelIds?: number[];+}++// A property left out keeps its value; `labelIds` replaces the whole label set.+export type IssueTemplatePatch = Partial<NewIssueTemplateInput>;++export const createIssueTemplate = (projectKey: string, input: NewIssueTemplateInput) =>+ request<IssueTemplate>(`/projects/${projectKey}/issue-templates`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateIssueTemplate = (+ projectKey: string,+ templateId: number,+ patch: IssueTemplatePatch,+) =>+ request<IssueTemplate>(`/projects/${projectKey}/issue-templates/${templateId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteIssueTemplate = (projectKey: string, templateId: number) =>+ request<void>(`/projects/${projectKey}/issue-templates/${templateId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/issueTypes.ts b/apps/web/src/lib/api/endpoints/issueTypes.tsnew file mode 100644index 00000000..0e1d10ec--- /dev/null+++ b/apps/web/src/lib/api/endpoints/issueTypes.ts@@ -0,0 +1,33 @@+import { request } from '@/lib/api/core/client';++export interface IssueType {+ id: number;+ projectId: number;+ name: string;+ icon: string;+ color: string;+ isDefault: boolean;+ position: number;+}++export const createIssueType = (+ projectKey: string,+ input: { name: string; icon?: string; color?: string; isDefault?: boolean },+) =>+ request<IssueType>(`/projects/${projectKey}/issue-types`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateIssueType = (+ projectKey: string,+ typeId: number,+ patch: { name?: string; color?: string; isDefault?: boolean },+) =>+ request<IssueType>(`/projects/${projectKey}/issue-types/${typeId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteIssueType = (projectKey: string, typeId: number) =>+ request<void>(`/projects/${projectKey}/issue-types/${typeId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/issues.ts b/apps/web/src/lib/api/endpoints/issues.tsnew file mode 100644index 00000000..019e32ec--- /dev/null+++ b/apps/web/src/lib/api/endpoints/issues.ts@@ -0,0 +1,399 @@+import type { CycleStatus } from '@/lib/api/endpoints/cycles';+import type { InitiativeStatus } from '@/lib/api/endpoints/initiatives';+import { request } from '@/lib/api/core/client';+import type { Checklist } from '@/lib/api/endpoints/checklists';+import type { CustomFieldType } from '@/lib/api/endpoints/customFields';+import type { DevelopmentLink } from '@/lib/api/endpoints/git';++// The subtask disposition as the delete route takes it: a query string, since a+// DELETE carries no body.+function subtaskQuery(disposition?: SubtaskDisposition): string {+ if (!disposition) return '';+ const qs = new URLSearchParams({ subtasks: disposition.subtasks });+ if (disposition.newParentId != null) qs.set('newParentId', String(disposition.newParentId));+ return `?${qs.toString()}`;+}++// One custom field value on a project issue: the scalar value (null for+// select/multi_select and unset fields), the end of a datetime_range, and the+// selected option ids. Only fields with a value set appear; unset fields are+// omitted (see listIssues).+export interface IssueFieldValueEntry {+ fieldId: number;+ value: string | number | boolean | null;+ valueEnd: string | null;+ optionIds: number[];+}++export interface Issue {+ id: number;+ projectId: number;+ // Project-scoped sequence number (the "42" in "MKT-42"). Addresses the issue by+ // its human number in URLs (/project/MKT/issue/42).+ sequenceNumber: number;+ identifier: string;+ typeId: number | null;+ // The initiative this issue is linked to, expanded to id + title for rendering,+ // or null. Set through updateIssue by initiativeId.+ initiative: InitiativeRef | null;+ // The cycle this issue is planned into, expanded to id + name for rendering, or+ // null. Set through updateIssue by cycleId.+ cycle: CycleRef | null;+ assigneeUserId: string | null;+ delegateUserId: string | null;+ columnId: number;+ // The issue this one is a subtask of, or null when it stands on its own. The+ // views render a subtask under its parent instead of on its own, so an issue+ // with a parent never shows as a card or a row of its own.+ parentId: number | null;+ title: string;+ description: string;+ priority: string | null;+ // Time is in minutes; the UI enters and shows it as hours and minutes.+ estimatePoints: number | null;+ estimateMinutes: number | null;+ // The sum of the issue's logged time entries, 0 when nothing was logged. The+ // entries themselves are read separately (listWorklogs).+ loggedMinutes: number;+ startDate: string | null;+ dueDate: string | null;+ position: number;+ createdAt: string;+ updatedAt: string;+ // When the issue was archived (hidden from the board but kept), or null when it+ // is active. Set by the archive action or the worker's auto-archive sweep.+ archivedAt: string | null;+ // When the issue entered its current column (or createdAt if it never moved).+ // Drives the "time in current status" badge.+ statusSince: string;+ // Unguessable token for the public read-only share link, or null when not shared.+ shareToken: string | null;+ // Whether that link exposes the issue in full (assignees, labels, custom fields,+ // activity) or only its title, description, state, type, priority, dates,+ // subtasks and links.+ shareExtended: boolean;+ labelIds: number[];+ fieldValues: IssueFieldValueEntry[];+}++// A light search result from GET /projects/:key/issues/search: enough to list and+// open a match, without the full issue's description or field values.+export interface IssueSearchHit {+ id: number;+ sequenceNumber: number;+ identifier: string;+ title: string;+ columnId: number;+ typeId: number | null;+ initiativeId: number | null;+ cycleId: number | null;+ parentId: number | null;+ assigneeUserId: string | null;+ delegateUserId: string | null;+ priority: string | null;+ dueDate: string | null;+ labelIds: number[];+ archived: boolean;+}++export interface IssueFieldValue {+ fieldId: number;+ name: string;+ fieldType: CustomFieldType;+ value: string | number | boolean | null;+ valueEnd: string | null;+ optionIds: number[];+}++// A custom field value on the way in (setFieldValue). `value` carries the+// scalar types, `valueEnd` the end of a datetime_range, `optionIds` the+// select/multi_select ones; a field uses one or the other.+export interface IssueFieldValueInput {+ value?: string | number | boolean | null;+ valueEnd?: string | null;+ optionIds?: number[];+}++// How an issue carries the initiative and the cycle it belongs to: the id plus+// what to render, and the initiative status the board orders its lanes by. The+// picker lists are InitiativeOption / CycleOption.+export interface InitiativeRef {+ id: number;+ title: string;+ status: InitiativeStatus;+}++// One cycle an issue was in. The cycle history of an issue is a list of these,+// oldest first.+export interface IssueCycleEntry {+ cycleId: number;+ name: string;+ startDate: string;+ endDate: string;+ status: CycleStatus;+ enteredAt: string;+ leftAt: string | null;+}++export interface CycleRef {+ id: number;+ name: string;+ status: CycleStatus;+}++// An issue as a board carries it: with its relations to the project's other active+// issues. The board payload and the public share bundle have them; a write response+// returns a plain Issue.+export interface BoardIssue extends Issue {+ links: IssueLinkRef[];+ // How many subtasks the issue has, archived ones included. The board carries+ // only active issues, so an archived subtask shows up nowhere else — and a+ // delete or an archive still has to ask about it.+ subtaskCount: number;+}++export interface BoardIssues {+ issues: BoardIssue[];+}++export interface IssueDetail extends Issue {+ fields: IssueFieldValue[];+}++// A relation between two issues (mirrors apps/api modules/issues/links.ts). 'blocks' and+// 'duplicates' are directional and read differently on each end, which direction+// selects: 'outward' is the side that blocks/duplicates, 'inward' the side that is+// blocked/duplicated. On a symmetric 'relates' relation direction means nothing.+export type IssueLinkKind = 'blocks' | 'relates' | 'duplicates';++export type IssueLinkDirection = 'outward' | 'inward';++// What linkIssues accepts: the stored kinds plus the inverse reading of the two+// directional ones, so a relation can be stated from either end.+export type IssueLinkInputKind = IssueLinkKind | 'blocked_by' | 'duplicated_by';++export interface IssueLink {+ id: number;+ kind: IssueLinkKind;+ direction: IssueLinkDirection;+ // The issue on the other end of the relation.+ issue: IssueRef;+}++// One of an issue's relations as the board payload carries it: how the relation+// reads from this issue, and the id of the issue on the other end. Both ends+// carry it, each with its own reading; the views name the other end by looking+// the id up among the board's issues, which is why a relation to an archived+// issue is not sent.+export interface IssueLinkRef {+ id: number;+ relation: IssueLinkInputKind;+ issueId: number;+}++// A member following an issue: they receive every notification it produces.+export interface IssueWatcher {+ userId: string;+ name: string;+ image: string | null;+}++// Another issue named with the state it is in: an issue's parent, one of its+// subtasks, or the other end of a relation.+export interface IssueRef {+ id: number;+ sequenceNumber: number;+ identifier: string;+ title: string;+ columnId: number;+ typeId: number | null;+ archived: boolean;+}++// What a delete or an archive does with the issue's subtasks: they follow it+// (deleted with a delete, archived with an archive), they are detached into+// ordinary issues, or they move to another parent. Required whenever the issue+// being removed has subtasks.+export type SubtaskMode = 'cascade' | 'detach' | 'reassign';++export interface SubtaskDisposition {+ subtasks: SubtaskMode;+ newParentId?: number;+}++// The issue with its relations and its place in the subtask hierarchy. Shared+// pages carry this much; the detail routes add the watchers and the checklists,+// neither of which a public page exposes.+export interface IssueRelations extends IssueDetail {+ links: IssueLink[];+ parent: IssueRef | null;+ subtasks: IssueRef[];+}++// The issue as the detail routes return it.+export interface IssueWithWatchers extends IssueRelations {+ watchers: IssueWatcher[];+ checklists: Checklist[];+ development: DevelopmentLink[];+}++export interface NewIssueInput {+ typeId?: number | null;+ initiativeId?: number | null;+ cycleId?: number | null;+ assigneeUserId?: string | null;+ delegateUserId?: string | null;+ columnId: number;+ parentId?: number | null;+ title: string;+ description?: string;+ priority?: string | null;+ estimatePoints?: number | null;+ estimateMinutes?: number | null;+ startDate?: string | null;+ dueDate?: string | null;+ labelIds?: number[];+}++// The fields a bulk update can set on many issues at once (the board-relevant+// subset of IssuePatch: no title/description/position).+export interface BulkIssuePatch {+ columnId?: number;+ typeId?: number | null;+ initiativeId?: number | null;+ cycleId?: number | null;+ assigneeUserId?: string | null;+ delegateUserId?: string | null;+ priority?: string | null;+ estimatePoints?: number | null;+ estimateMinutes?: number | null;+ startDate?: string | null;+ dueDate?: string | null;+}++export interface IssuePatch {+ columnId?: number;+ position?: number;+ typeId?: number | null;+ parentId?: number | null;+ initiativeId?: number | null;+ cycleId?: number | null;+ assigneeUserId?: string | null;+ delegateUserId?: string | null;+ title?: string;+ description?: string;+ priority?: string | null;+ estimatePoints?: number | null;+ estimateMinutes?: number | null;+ startDate?: string | null;+ dueDate?: string | null;+ labelIds?: number[];+}++export const createIssue = (projectKey: string, input: NewIssueInput) =>+ request<Issue>(`/projects/${projectKey}/issues`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const getIssue = (id: number) => request<IssueWithWatchers>(`/issues/${id}`);++// Resolve an issue by its project-scoped number (the human "42" in the URL).+export const getIssueBySeq = (projectKey: string, seq: number) =>+ request<IssueWithWatchers>(`/projects/${projectKey}/issues/${seq}`);++export const listIssueCycles = (id: number) => request<IssueCycleEntry[]>(`/issues/${id}/cycles`);++export const updateIssue = (id: number, patch: IssuePatch) =>+ request<Issue>(`/issues/${id}`, { method: 'PATCH', body: JSON.stringify(patch) });++// An issue that has subtasks needs a disposition saying what happens to them;+// without one the server rejects the delete with a 409.+export const deleteIssue = (id: number, subtasks?: SubtaskDisposition) =>+ request<void>(`/issues/${id}${subtaskQuery(subtasks)}`, { method: 'DELETE' });++// Board multi-select: apply one change to many issues in a single request. The+// server filters the ids to the project and refetching happens once.+export const bulkUpdateIssues = (projectKey: string, ids: number[], patch: BulkIssuePatch) =>+ request<{ updated: number }>(`/projects/${projectKey}/issues/bulk`, {+ method: 'PATCH',+ body: JSON.stringify({ ids, patch }),+ });++export const bulkAddLabels = (projectKey: string, ids: number[], add: number[]) =>+ request<{ updated: number }>(`/projects/${projectKey}/issues/bulk/labels`, {+ method: 'POST',+ body: JSON.stringify({ ids, add }),+ });++export const bulkArchiveIssues = (+ projectKey: string,+ ids: number[],+ subtasks?: SubtaskDisposition,+) =>+ request<{ archived: number }>(`/projects/${projectKey}/issues/bulk/archive`, {+ method: 'POST',+ body: JSON.stringify({ ids, ...subtasks }),+ });++export const bulkDeleteIssues = (+ projectKey: string,+ ids: number[],+ subtasks?: SubtaskDisposition,+) =>+ request<{ deleted: number }>(`/projects/${projectKey}/issues/bulk/delete`, {+ method: 'POST',+ body: JSON.stringify({ ids, ...subtasks }),+ });++// Archive/restore: hide an issue from the board (kept, restorable) or bring it+// back. The board excludes archived issues; the archive settings section lists them.+export const archiveIssue = (id: number, subtasks?: SubtaskDisposition) =>+ request<Issue>(`/issues/${id}/archive`, {+ method: 'POST',+ body: JSON.stringify(subtasks ?? {}),+ });++export const restoreIssue = (id: number) =>+ request<Issue>(`/issues/${id}/restore`, { method: 'POST' });++// Server-side text search for the command palette. Always returns all matches,+// archived included (each hit carries an `archived` flag).+export const searchIssues = (projectKey: string, params: { q?: string; limit?: number }) => {+ const qs = new URLSearchParams();+ if (params.q) qs.set('q', params.q);+ if (params.limit != null) qs.set('limit', String(params.limit));+ return request<IssueSearchHit[]>(`/projects/${projectKey}/issues/search?${qs.toString()}`);+};++// Relations between issues. The relation reads from the issue in the path: it+// blocks / relates to / duplicates targetIssueId. Both ends show it.+export const linkIssues = (issueId: number, targetIssueId: number, kind: IssueLinkInputKind) =>+ request<IssueLink>(`/issues/${issueId}/links`, {+ method: 'POST',+ body: JSON.stringify({ targetIssueId, kind }),+ });++export const unlinkIssues = (issueId: number, linkId: number) =>+ request<void>(`/issues/${issueId}/links/${linkId}`, { method: 'DELETE' });++// Following an issue. The singular routes act on the signed-in user; the+// watcher routes let an editor curate other project members. Every route+// returns the resulting watcher list.+export const watchIssue = (issueId: number) =>+ request<IssueWatcher[]>(`/issues/${issueId}/watch`, { method: 'POST' });++export const unwatchIssue = (issueId: number) =>+ request<IssueWatcher[]>(`/issues/${issueId}/watch`, { method: 'DELETE' });++export const addIssueWatcher = (issueId: number, userId: string) =>+ request<IssueWatcher[]>(`/issues/${issueId}/watchers/${userId}`, { method: 'PUT' });++export const removeIssueWatcher = (issueId: number, userId: string) =>+ request<IssueWatcher[]>(`/issues/${issueId}/watchers/${userId}`, { method: 'DELETE' });++export const setFieldValue = (issueId: number, fieldId: number, input: IssueFieldValueInput) =>+ request<{ ok: boolean }>(`/issues/${issueId}/fields/${fieldId}`, {+ method: 'PUT',+ body: JSON.stringify(input),+ });diff --git a/apps/web/src/lib/api/endpoints/labels.ts b/apps/web/src/lib/api/endpoints/labels.tsnew file mode 100644index 00000000..bdf117f7--- /dev/null+++ b/apps/web/src/lib/api/endpoints/labels.ts@@ -0,0 +1,59 @@+import { request } from '@/lib/api/core/client';++export interface Label {+ id: number;+ projectId: number;+ // The group this label belongs to, or null when ungrouped.+ groupId: number | null;+ name: string;+ color: string;+}++// A container a label can belong to. Labels reference it by groupId.+export interface LabelGroup {+ id: number;+ projectId: number;+ name: string;+ color: string;+}++export const createLabel = (+ projectKey: string,+ input: { name: string; color?: string; groupId?: number | null },+) =>+ request<Label>(`/projects/${projectKey}/labels`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateLabel = (+ projectKey: string,+ labelId: number,+ patch: { name?: string; color?: string; groupId?: number | null },+) =>+ request<Label>(`/projects/${projectKey}/labels/${labelId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteLabel = (projectKey: string, labelId: number) =>+ request<void>(`/projects/${projectKey}/labels/${labelId}`, { method: 'DELETE' });++export const createLabelGroup = (projectKey: string, input: { name: string; color?: string }) =>+ request<LabelGroup>(`/projects/${projectKey}/label-groups`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateLabelGroup = (+ projectKey: string,+ groupId: number,+ patch: { name?: string; color?: string },+) =>+ request<LabelGroup>(`/projects/${projectKey}/label-groups/${groupId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteLabelGroup = (projectKey: string, groupId: number) =>+ request<void>(`/projects/${projectKey}/label-groups/${groupId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/members.ts b/apps/web/src/lib/api/endpoints/members.tsnew file mode 100644index 00000000..2997ac4e--- /dev/null+++ b/apps/web/src/lib/api/endpoints/members.ts@@ -0,0 +1,108 @@+import { request } from '@/lib/api/core/client';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// Project membership: a user's access to a project and their role in it. A member of+// the team that owns the project is added straight away; everyone else joins through+// an invite.+export type MemberRole = 'owner' | 'member';++export interface MemberRow {+ userId: string;+ name: string;+ email: string;+ // The sign-in name. null for an AI agent's bot user, which never gets one.+ username: string | null;+ image: string | null;+ // The zone this member reads timestamps in, from their preferences.+ timezone: string;+ role: MemberRole;+ // The assigned custom role. null when the member uses the project's default+ // role; owners never use roles (both fields null).+ roleId: number | null;+ roleName: string | null;+ // What this member does in the project, set by an owner. Empty string when unset.+ description: string;+ // True when this member is an AI agent's bot user. It joins and leaves with its AI+ // Agent config, so this list does not revoke it; its role is set here like a+ // person's.+ isAgent: boolean;+ // 'scim' when a provisioned group granted this membership. The sync rewrites such+ // a row on every run, so the role and remove actions are refused for it.+ source: 'invite' | 'scim';+ createdAt: string;+}++// Which members a list asks for: everyone, the people, or the AI agents.+export type MemberKind = 'all' | 'human' | 'agent';++// How many members own the project is what a page window cannot answer, and the last+// owner's row is the one that may not be removed.+export type MemberPage = Page<MemberRow> & { ownerCount: number };++// The filters every member list takes, on top of the page window. The search runs on+// the server, so the page and the total agree.+export interface MemberListParams extends PageParams {+ search?: string;+ kind: MemberKind;+}++// The query string a member list takes: the page window, the kind filter and the+// search. Shared with the team member lists.+export function memberListQuery(params: MemberListParams): string {+ return pageQuery(params, { kind: params.kind, search: params.search });+}++// Someone who can be added to a project without an invite: a member of the team that+// owns it who is not in the project yet.+export interface MemberCandidate {+ userId: string;+ name: string;+ email: string;+ username: string | null;+ image: string | null;+ isAgent: boolean;+}++// Members: list who is on a project, add someone from its team, and revoke access+// (an owner removes anyone; a member removes only themselves — leaving the+// project).+// One page of the project's members.+export const listMembers = (projectKey: string, params: MemberListParams) =>+ request<MemberPage>(`/projects/${projectKey}/members${memberListQuery(params)}`);++export const listMemberCandidates = (projectKey: string) =>+ request<MemberCandidate[]>(`/projects/${projectKey}/members/candidates`);++export const addMember = (+ projectKey: string,+ input: { userId: string; role: MemberRole; roleId?: number | null },+) =>+ request<void>(`/projects/${projectKey}/members`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const removeMember = (projectKey: string, userId: string) =>+ request<void>(`/projects/${projectKey}/members/${encodeURIComponent(userId)}`, {+ method: 'DELETE',+ });++// Set a member's role (owner-only). role 'owner' promotes to owner; role+// 'member' assigns a custom role via roleId (null resets to the default role).+// The last owner cannot be demoted — the API rejects it.+export const setMemberRole = (+ projectKey: string,+ userId: string,+ input: { role: MemberRole; roleId?: number | null },+) =>+ request<void>(`/projects/${projectKey}/members/${encodeURIComponent(userId)}`, {+ method: 'PATCH',+ body: JSON.stringify(input),+ });++// Set what a member does in the project (owner-only). Empty string clears it.+export const setMemberDescription = (projectKey: string, userId: string, description: string) =>+ request<void>(`/projects/${projectKey}/members/${encodeURIComponent(userId)}/description`, {+ method: 'PATCH',+ body: JSON.stringify({ description }),+ });diff --git a/apps/web/src/lib/api/endpoints/noteBoards.ts b/apps/web/src/lib/api/endpoints/noteBoards.tsnew file mode 100644index 00000000..c7e752a0--- /dev/null+++ b/apps/web/src/lib/api/endpoints/noteBoards.ts@@ -0,0 +1,119 @@+import { request } from '@/lib/api/core/client';++// One sticky note on the canvas. body is markdown (may contain task-list items).+// color keys a background swatch defined by the UI. Declared as a type alias (not+// an interface) so it carries an implicit index signature and satisfies React+// Flow's Node data constraint (Record<string, unknown>).+export type NoteSticker = {+ title: string;+ body: string;+ color: string;+};++// A React Flow node holding a sticker. Kept structurally compatible with React+// Flow's Node so the canvas can use it directly.+export interface NoteNode {+ id: string;+ type: 'sticker';+ position: { x: number; y: number };+ width?: number;+ height?: number;+ data: NoteSticker;+}++// A connection between two stickers (React Flow edge).+export interface NoteEdge {+ id: string;+ source: string;+ target: string;+}++// The board canvas, stored verbatim as jsonb on the server.+export interface NoteCanvas {+ nodes: NoteNode[];+ edges: NoteEdge[];+}++// Who sees a board: every project member, its creator alone, or its creator plus+// the members granted access.+export type NoteBoardVisibility = 'public' | 'private' | 'restricted';++export interface NoteBoard {+ id: number;+ projectId: number;+ // null for a public board; a user id for a private or restricted one.+ ownerUserId: string | null;+ // Only the creator can change who sees the board.+ createdByUserId: string | null;+ visibility: NoteBoardVisibility;+ // The members granted access besides the creator (a restricted board).+ memberIds: string[];+ name: string;+ canvas: NoteCanvas;+ createdAt: string;+ updatedAt: string;+}++// A board without its canvas or member list — what the switcher and MRU tabs list.+// The canvas is loaded one board at a time via getNoteBoard when the board is opened.+export type NoteBoardSummary = Omit<NoteBoard, 'canvas' | 'memberIds'>;++export interface NewNoteBoardInput {+ name: string;+ visibility?: Exclude<NoteBoardVisibility, 'restricted'>;+ canvas?: NoteCanvas;+}++export interface NoteBoardPatch {+ name?: string;+ canvas?: NoteCanvas;+ visibility?: NoteBoardVisibility;+ // Replaces the granted members as a whole; only on a restricted board.+ memberIds?: string[];+}++// Someone a restricted board can be shared with. `canAccess` false means their+// role cannot read notes at all, so the API rejects granting them access.+export interface NoteBoardAccessCandidate {+ userId: string;+ name: string;+ image: string | null;+ kind: 'member' | 'agent';+ canAccess: boolean;+}++export interface NoteBoardListParams {+ q?: string;+ limit?: number;+ offset?: number;+}++// Note boards — all ops are project-scoped (a board that is not public is+// filtered to who may see it server-side), so board ops take projectKey plus the+// board id. The list feeds the switcher, which shows every board, so it comes whole+// with `q` narrowing it; a single board carries its canvas.+export const listNoteBoards = (projectKey: string, params: { q?: string } = {}) =>+ request<NoteBoardSummary[]>(+ `/projects/${projectKey}/note-boards${params.q ? `?q=${encodeURIComponent(params.q)}` : ''}`,+ );++export const getNoteBoard = (projectKey: string, boardId: number) =>+ request<NoteBoard>(`/projects/${projectKey}/note-boards/${boardId}`);++export const listNoteBoardAccessCandidates = (projectKey: string) =>+ request<NoteBoardAccessCandidate[]>(`/projects/${projectKey}/note-boards/access-candidates`);++export const createNoteBoard = (projectKey: string, input: NewNoteBoardInput) =>+ request<NoteBoard>(`/projects/${projectKey}/note-boards`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateNoteBoard = (projectKey: string, boardId: number, patch: NoteBoardPatch) =>+ request<NoteBoard>(`/projects/${projectKey}/note-boards/${boardId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteNoteBoard = (projectKey: string, boardId: number) =>+ request<void>(`/projects/${projectKey}/note-boards/${boardId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/notificationPreferences.ts b/apps/web/src/lib/api/endpoints/notificationPreferences.tsnew file mode 100644index 00000000..39d04331--- /dev/null+++ b/apps/web/src/lib/api/endpoints/notificationPreferences.ts@@ -0,0 +1,20 @@+import { request } from '@/lib/api/core/client';+import type { NotificationEventToggles } from '@/lib/api/endpoints/notificationSettings';++// The session member's own notification preferences for a project: which issue+// events they want by email and/or Telegram. Email is sent to the member's account+// address, Telegram to the account they linked in their profile.+export interface NotificationPreferences {+ emailEvents: NotificationEventToggles;+ telegramEvents: NotificationEventToggles;+}++// The session member's own notification preferences for a project (any member).+export const getNotificationPreferences = (projectKey: string) =>+ request<NotificationPreferences>(`/projects/${projectKey}/notification-preferences`);++export const setNotificationPreferences = (projectKey: string, input: NotificationPreferences) =>+ request<NotificationPreferences>(`/projects/${projectKey}/notification-preferences`, {+ method: 'PUT',+ body: JSON.stringify(input),+ });diff --git a/apps/web/src/lib/api/endpoints/notificationSettings.ts b/apps/web/src/lib/api/endpoints/notificationSettings.tsnew file mode 100644index 00000000..e362ffaa--- /dev/null+++ b/apps/web/src/lib/api/endpoints/notificationSettings.ts@@ -0,0 +1,62 @@+import { request } from '@/lib/api/core/client';++// Per-team notification provider credentials (owner-managed) plus a member's own+// delivery preferences for a project. The issue events match the inbox notification+// types.+export type NotificationEncryption = 'none' | 'ssl' | 'tls';++export interface NotificationEventToggles {+ assigned: boolean;+ mentioned: boolean;+ commented: boolean;+ state_changed: boolean;+}++// The provider credentials as read from the API: secrets are never returned, only a+// `hasX` flag telling whether a value is stored.+export interface NotificationSettings {+ // Deliver email through the instance provider instead of the team's own. Its+ // credentials belong to the instance, so the team only turns it on.+ system: { enabled: boolean };+ // Whether the instance provider exists and is shared with teams right now.+ systemAvailable: boolean;+ smtp: {+ enabled: boolean;+ host: string;+ port: number | null;+ encryption: NotificationEncryption;+ username: string;+ hasPassword: boolean;+ timeout: number | null;+ };+ resend: { enabled: boolean; hasApiKey: boolean };+ telegram: { enabled: boolean; hasBotToken: boolean };+}++// A partial write. Each section is optional so a provider card saves on its own.+// A secret field left out or empty keeps its stored value.+export interface NotificationSettingsPatch {+ system?: { enabled: boolean };+ smtp?: {+ enabled: boolean;+ host: string;+ port: number | null;+ encryption: NotificationEncryption;+ username: string;+ password?: string;+ timeout: number | null;+ };+ resend?: { enabled: boolean; apiKey?: string };+ telegram?: { enabled: boolean; botToken?: string };+}++// The team's notification provider credentials, shared by every project it owns+// (team owner only).+export const getNotificationSettings = (teamId: number) =>+ request<NotificationSettings>(`/teams/${teamId}/notification-settings`);++export const setNotificationSettings = (teamId: number, input: NotificationSettingsPatch) =>+ request<NotificationSettings>(`/teams/${teamId}/notification-settings`, {+ method: 'PUT',+ body: JSON.stringify(input),+ });diff --git a/apps/web/src/lib/api/endpoints/notifications.ts b/apps/web/src/lib/api/endpoints/notifications.tsnew file mode 100644index 00000000..e73a679e--- /dev/null+++ b/apps/web/src/lib/api/endpoints/notifications.ts@@ -0,0 +1,95 @@+import { request } from '@/lib/api/core/client';+import type { StateType } from '@/lib/api/endpoints/columns';++// Inbox notifications. Each row is enriched with the issue and project it points at+// so the list renders without extra calls.+export type NotificationType = 'assigned' | 'mentioned' | 'commented' | 'state_changed';++export interface Notification {+ id: number;+ type: NotificationType;+ actorUserId: string | null;+ actorName: string | null;+ readAt: string | null;+ snoozedUntil: string | null;+ createdAt: string;+ issueId: number;+ issueSeq: number;+ issueTitle: string;+ issueStateType: StateType;+ projectId: number;+ projectKey: string;+ projectName: string;+ // Only a 'state_changed' notification has them.+ fromState: string | null;+ toState: string | null;+}++export interface NotificationCursor {+ ts: string;+ id: number;+}++export interface NotificationPage {+ items: Notification[];+ nextCursor: NotificationCursor | null;+}++export interface NotificationFilters {+ types?: NotificationType[];+ from?: string;+ includeRead?: boolean;+ includeSnoozed?: boolean;+}++export type NotificationDeleteScope = 'all' | 'read' | 'read-completed';++// Inbox notifications. The list is the session user's own; projectId scopes it to+// one project (the per-project inbox). cursor is the JSON-encoded keyset from the+// previous page.+export const listNotifications = (+ projectId: number,+ params: {+ cursor?: NotificationCursor | null;+ limit?: number;+ filters?: NotificationFilters;+ } = {},+) => {+ const q = new URLSearchParams();+ q.set('projectId', String(projectId));+ if (params.limit) q.set('limit', String(params.limit));+ if (params.cursor) q.set('cursor', JSON.stringify(params.cursor));+ const f = params.filters ?? {};+ if (f.types?.length) q.set('types', f.types.join(','));+ if (f.from) q.set('from', f.from);+ if (f.includeRead === false) q.set('includeRead', 'false');+ if (f.includeSnoozed) q.set('includeSnoozed', 'true');+ return request<NotificationPage>(`/notifications?${q.toString()}`);+};++// Unread count for the sidebar badge, refetched when the inbox scope moves.+export const getUnreadCount = (projectId: number) =>+ request<{ unread: number }>(`/notifications/unread?projectId=${projectId}`);++export const setNotificationRead = (id: number, read: boolean) =>+ request<void>(`/notifications/${id}/read`, { method: 'POST', body: JSON.stringify({ read }) });++export const snoozeNotification = (id: number, until: string | null) =>+ request<void>(`/notifications/${id}/snooze`, {+ method: 'POST',+ body: JSON.stringify({ until }),+ });++export const markAllNotificationsRead = (projectId: number) =>+ request<{ count: number }>(`/notifications/read-all`, {+ method: 'POST',+ body: JSON.stringify({ projectId }),+ });++export const deleteNotification = (id: number) =>+ request<void>(`/notifications/${id}`, { method: 'DELETE' });++export const deleteNotifications = (scope: NotificationDeleteScope, projectId: number) =>+ request<{ count: number }>(`/notifications?scope=${scope}&projectId=${projectId}`, {+ method: 'DELETE',+ });diff --git a/apps/web/src/lib/api/endpoints/projects.ts b/apps/web/src/lib/api/endpoints/projects.tsnew file mode 100644index 00000000..2c1df8a6--- /dev/null+++ b/apps/web/src/lib/api/endpoints/projects.ts@@ -0,0 +1,132 @@+import type { CycleOption } from '@/lib/api/endpoints/cycles';+import type { BoardIssues } from '@/lib/api/endpoints/issues';+import { request } from '@/lib/api/core/client';+import type { Column } from '@/lib/api/endpoints/columns';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueTemplate } from '@/lib/api/endpoints/issueTemplates';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';+import type { MemberRole } from '@/lib/api/endpoints/members';+import type { Permissions } from '@/lib/api/endpoints/roles';+import type { ProjectFeatures } from '@/lib/api/endpoints/settings';+import type { TeamRole } from '@/lib/api/endpoints/teams';++export interface Project {+ id: number;+ teamId: number;+ teamName: string;+ key: string;+ name: string;+ description: string;+ // Whether the team's MCP reach covers this project, and whether the team is+ // reachable over MCP at all. Both are set in the team's MCP section; a tool call+ // scoped to this project needs both.+ mcpEnabled: boolean;+ teamMcpEnabled: boolean;+ // The optional sections, toggled by an owner in Settings -> General. Read through+ // useProjectFeatures, which hides the navigation and the section itself.+ initiativesEnabled: boolean;+ dashboardsEnabled: boolean;+ documentsEnabled: boolean;+ notesEnabled: boolean;+ cyclesEnabled: boolean;+ subtasksEnabled: boolean;+ checklistsEnabled: boolean;+ issueStatsEnabled: boolean;+ // The sections this project may use at all. One missing here is not available to+ // the team: its flag above always reads false and the settings page does not offer+ // it. Everything is available on a self-hosted instance.+ availableFeatures: (keyof ProjectFeatures)[];+ // Which estimate kinds the issues carry, set in Settings -> Configuration. Read+ // through useProjectFeatures, which hides the estimate rows and their display+ // properties while a kind is off.+ pointsEstimateEnabled: boolean;+ timeEstimateEnabled: boolean;+ // Whether members log the time they spend on the issues, set in the same place.+ // Independent of the time estimate.+ timeLoggingEnabled: boolean;+ createdAt: string;+ // The caller's role in this project. Only present on the /projects list+ // response; absent on the create/copy responses.+ role?: MemberRole;+}++export interface Assignee {+ userId: string;+ name: string;+ email: string;+ // The handle they are mentioned by, @username. Null for a member who has none.+ username: string | null;+ image: string | null;+ kind: 'member' | 'agent';+ agentKind: 'external' | 'internal' | null;+ // The user an 'owner'-scoped agent works for: delegating it to anyone else queues a+ // run its runner never receives. Null for members and team-scoped agents.+ restrictedToUserId: string | null;+ // Whether this person may read issues and can therefore receive watcher+ // notifications without leaking work-item content.+ canReadWorkItems: boolean;+}++// The caller's own role in a project (owner/member). Returned with the project;+// the resolved permission matrix is a sibling `permissions` field. See+// usePermissions.+export interface ProjectViewer {+ role: MemberRole;+ // The caller's standing in the team that owns the project, null when they are not+ // a member of it. An owner or manager governs the project's settings alongside the+ // project's own owner; 'agent' is a bot user reading its own board, which governs+ // nothing.+ teamRole: TeamRole | 'agent' | null;+}++// The board scaffold, returned by getProject: everything the work-items UI needs+// except the issues themselves (those come from getBoardIssues).+export interface ProjectScaffold {+ project: Project;+ columns: Column[];+ issueTypes: IssueType[];+ labels: Label[];+ labelGroups: LabelGroup[];+ assignees: Assignee[];+ // Every custom field of the project (all type scopes); consumers filter by+ // issueTypeId locally.+ customFields: CustomField[];+ issueTemplates: IssueTemplate[];+ viewer: ProjectViewer;+ // The caller's resolved permission matrix (owners get every flag).+ permissions: Permissions;+}++// The scaffold composed with its issues and the project's unfinished cycles, as+// the Shell assembles it and passes it down. Downstream reads project.issues off+// this composite. `plannedCycles` is empty while the Cycles section is off and on a+// public share (whose bundle carries no cycle list).+export type ProjectDetail = ProjectScaffold & BoardIssues & { plannedCycles: CycleOption[] };++// The instance upload limits. Readable by any signed-in user, because the upload UI+// states them before a file is picked; only god mode can change them.+export interface ProjectDefaults {+ mcpEnabled: boolean;+}++export const listProjects = () => request<Project[]>('/projects');++export const createProject = (input: {+ key: string;+ name: string;+ description?: string;+ preset?: string;+}) => request<Project>('/projects', { method: 'POST', body: JSON.stringify(input) });++// Update a project's name/description. The key is immutable, so it is not sent.+export const updateProject = (projectKey: string, patch: { name?: string; description?: string }) =>+ request<Project>(`/projects/${projectKey}`, { method: 'PATCH', body: JSON.stringify(patch) });++// The board scaffold (no issues). The issues come from getBoardIssues.+export const getProject = (projectKey: string) =>+ request<ProjectScaffold>(`/projects/${projectKey}`);++// The board's issues and their relations.+export const getBoardIssues = (projectKey: string) =>+ request<BoardIssues>(`/projects/${projectKey}/issues/board`);diff --git a/apps/web/src/lib/api/endpoints/roles.ts b/apps/web/src/lib/api/endpoints/roles.tsnew file mode 100644index 00000000..e8ebbe20--- /dev/null+++ b/apps/web/src/lib/api/endpoints/roles.ts@@ -0,0 +1,108 @@+import { request } from '@/lib/api/core/client';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';++// The project permission matrix (mirrors apps/api shared/permissions.ts): each+// resource grants or denies 4 actions. A custom role carries one matrix.+export type PermissionAction = 'create' | 'edit' | 'read' | 'delete';++export type PermissionResource =+ | 'work_items'+ | 'initiatives'+ | 'cycles'+ | 'dashboards'+ | 'documents'+ | 'views'+ | 'members_invite'+ | 'members_manage'+ | 'states'+ | 'issue_types'+ | 'labels'+ | 'ai_agents'+ | 'integrations'+ | 'agent_skills'+ | 'agent_tools'+ | 'custom_fields'+ | 'issue_templates'+ | 'workflow_config'+ | 'actions'+ | 'webhooks'+ | 'note_boards'+ | 'danger_zone';++export type ResourcePermissions = Record<PermissionAction, boolean>;++export type Permissions = Record<PermissionResource, ResourcePermissions>;++// A project's custom role: a named permission matrix that can be assigned to a+// member. `isDefault` marks the fallback role new members get; it cannot be deleted.+export interface Role {+ id: number;+ name: string;+ isDefault: boolean;+ permissions: Permissions;+ createdAt: string;+}++// What a role list asks for: the window, and a search over the name.+export interface RoleListParams extends PageParams {+ search?: string;+}++// What a role is assigned to. Everything counted here is moved to another role+// before the role can be deleted.+export interface RoleUsage {+ members: number;+ agents: number;+ invites: number;+ // The provisioned group mappings that grant this role.+ groups: number;+}++// The resources and actions the role editor renders. Fetched so the UI matches the+// API's matrix without hardcoding the list in two places. `actions` is the full+// column set; a resource lists the subset it supports, and a cell outside that+// subset is always denied.+export interface PermissionCatalogResource {+ key: PermissionResource;+ actions: PermissionAction[];+}++export interface PermissionCatalog {+ resources: PermissionCatalogResource[];+ actions: PermissionAction[];+}++// Roles: a team's roles and the permission catalog behind the role editor. Roles+// belong to the team, so one list serves every project it owns; an owner or a+// manager of the team writes them, and only its owner deletes one.+export const getPermissionCatalog = () => request<PermissionCatalog>('/permission-catalog');++// One page of the team's roles. `search` matches the name.+export const listTeamRoles = (teamId: number, params: RoleListParams) =>+ request<Page<Role>>(`/teams/${teamId}/roles${pageQuery(params, { search: params.search })}`);++// Every role of the team, with its matrix: what the role pickers assign from and+// what the clipboard export carries.+export const listTeamRoleOptions = (teamId: number) =>+ request<Role[]>(`/teams/${teamId}/roles/options`);++export const createRole = (teamId: number, input: { name: string; permissions: Permissions }) =>+ request<Role>(`/teams/${teamId}/roles`, { method: 'POST', body: JSON.stringify(input) });++export const updateRole = (+ teamId: number,+ roleId: number,+ patch: { name?: string; permissions?: Permissions },+) =>+ request<Role>(`/teams/${teamId}/roles/${roleId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const getRoleUsage = (teamId: number, roleId: number) =>+ request<RoleUsage>(`/teams/${teamId}/roles/${roleId}/usage`);++export const deleteRole = (teamId: number, roleId: number, targetRoleId?: number) => {+ const qs = targetRoleId === undefined ? '' : `?targetRoleId=${targetRoleId}`;+ return request<void>(`/teams/${teamId}/roles/${roleId}${qs}`, { method: 'DELETE' });+};diff --git a/apps/web/src/lib/api/endpoints/scim.ts b/apps/web/src/lib/api/endpoints/scim.tsnew file mode 100644index 00000000..2aeefe9e--- /dev/null+++ b/apps/web/src/lib/api/endpoints/scim.ts@@ -0,0 +1,51 @@+import { request } from '@/lib/api/core/client';++// SCIM provisioning. The token is never returned, only its prefix; a new one is+// generated with createInstanceScimToken and shown once.+export interface InstanceScimSettings {+ enabled: boolean;+ hasToken: boolean;+ tokenPrefix: string;+ baseUrl: string;+}++// What a provisioned group grants: membership in a project, at a role. The group and+// its members come from the identity provider; the mappings are set here.+export interface InstanceScimGroupMapping {+ projectId: number;+ projectKey: string;+ projectName: string;+ role: 'owner' | 'member';+ roleId: number | null;+}++export interface InstanceScimGroup {+ id: string;+ displayName: string;+ externalId: string | null;+ memberCount: number;+ mappings: InstanceScimGroupMapping[];+}++export const getInstanceScimSettings = () => request<InstanceScimSettings>('/god/scim-settings');++export const updateInstanceScimSettings = (patch: { enabled: boolean }) =>+ request<InstanceScimSettings>('/god/scim-settings', {+ method: 'PUT',+ body: JSON.stringify(patch),+ });++// Returns the new token in the clear. It is shown once and cannot be read back.+export const createInstanceScimToken = () =>+ request<{ token: string }>('/god/scim-settings/token', { method: 'POST' });++export const listInstanceScimGroups = () => request<InstanceScimGroup[]>('/god/scim-groups');++export const setInstanceScimGroupMappings = (+ groupId: string,+ mappings: { projectId: number; role: 'owner' | 'member'; roleId: number | null }[],+) =>+ request<InstanceScimGroup>(`/god/scim-groups/${groupId}/mappings`, {+ method: 'PUT',+ body: JSON.stringify({ mappings }),+ });diff --git a/apps/web/src/lib/api/endpoints/settings.ts b/apps/web/src/lib/api/endpoints/settings.tsnew file mode 100644index 00000000..b42094a8--- /dev/null+++ b/apps/web/src/lib/api/endpoints/settings.ts@@ -0,0 +1,134 @@+import { request } from '@/lib/api/core/client';+import type { RegistrationMode } from '@/lib/api/endpoints/god';++// Per-project auto-archive thresholds: days an issue may sit inactive in a+// completed/canceled column before the worker archives it. null disables archiving+// for that state group. A new project starts at 28 completed / 7 canceled days.+export interface AutoArchiveSettings {+ completedDays: number | null;+ canceledDays: number | null;+}++// Which estimate kinds a project's issues carry and whether its members log the+// time they spend, all off by default. One turned off hides its UI and keeps what+// the issues already carry.+export interface EstimateSettings {+ points: boolean;+ time: boolean;+ logging: boolean;+}++// Per-project subtask automations, both off by default. completeParent closes a+// parent once all its subtasks are closed; closeSubtasks closes the remaining+// subtasks of a closed parent. Only closing is synchronized — an issue moving+// between open states leaves the rest of the hierarchy alone.+export interface SubtaskAutomationSettings {+ completeParent: boolean;+ closeSubtasks: boolean;+}++// Which optional sections a project shows. All on by default; turning one off+// hides its navigation entry and its section, keeping the rows behind it.+export interface ProjectFeatures {+ initiatives: boolean;+ cycles: boolean;+ dashboards: boolean;+ documents: boolean;+ notes: boolean;+ subtasks: boolean;+ checklists: boolean;+ issueStats: boolean;+}++// A project's settings: MCP reachability, which is read-only here, and the enabled+// sections.+export interface ProjectSettings {+ mcpEnabled: boolean;+ teamMcpEnabled: boolean;+ features: ProjectFeatures;+}++export interface StorageSettings {+ maxAttachmentMb: number;+ maxAvatarMb: number;+ // Accepted attachment content types: a full type ('application/pdf') or a+ // wildcard ('image/*'). Empty means any type is accepted.+ attachmentMimeTypes: string[];+ // Stored attachment bytes allowed per project, in MB. 0 means unlimited.+ projectQuotaMb: number;+}++export type StorageSettingsPatch = Partial<StorageSettings>;++// Rebound keyboard shortcuts: the combination each overridden command id takes. A+// command left out keeps the binding from the layer below.+export type HotkeyOverrides = Record<string, string>;++// What the sign-in and sign-up screens read before there is a session. magicLink,+// requireEmailVerification and google are already resolved against their provider by+// the API, so a screen can trust them without checking the credentials itself.+export interface PublicAuthConfig {+ registration: RegistrationMode;+ magicLink: boolean;+ requireEmailVerification: boolean;+ emailEnabled: boolean;+ // Whether the email/password form is offered at all. False only on an instance+ // that has a working single sign-on provider.+ emailPassword: boolean;+ google: boolean;+ oidc: boolean;+ // The sign-in button text the operator gave their identity provider. Empty when+ // OIDC is not offered, or when they left it blank.+ oidcLabel: string;+}++// Project settings: MCP reachability and the enabled sections. Owner-only; the+// current state comes with the project payload (getProject), so there is no read+// here.+export const updateProjectSettings = (+ projectKey: string,+ patch: { features?: Partial<ProjectFeatures> },+) =>+ request<ProjectSettings>(`/projects/${projectKey}/settings`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++// The workflow configuration (workflow_config: read to view, edit to change):+// the auto-archive thresholds, the subtask automations, and the estimate kinds.+// The estimate kinds have no read of their own — they come with the project.+export const getAutoArchive = (projectKey: string) =>+ request<AutoArchiveSettings>(`/projects/${projectKey}/settings/auto-archive`);++export const updateAutoArchive = (projectKey: string, input: AutoArchiveSettings) =>+ request<AutoArchiveSettings>(`/projects/${projectKey}/settings/auto-archive`, {+ method: 'PATCH',+ body: JSON.stringify(input),+ });++export const getSubtaskAutomation = (projectKey: string) =>+ request<SubtaskAutomationSettings>(`/projects/${projectKey}/settings/subtasks`);++export const updateSubtaskAutomation = (projectKey: string, input: SubtaskAutomationSettings) =>+ request<SubtaskAutomationSettings>(`/projects/${projectKey}/settings/subtasks`, {+ method: 'PATCH',+ body: JSON.stringify(input),+ });++export const updateEstimates = (projectKey: string, input: EstimateSettings) =>+ request<EstimateSettings>(`/projects/${projectKey}/settings/estimates`, {+ method: 'PATCH',+ body: JSON.stringify(input),+ });++// The upload limits. The read is open to any signed-in user (the upload UI shows+// the limit); the write is god mode.+export const getStorageSettings = () => request<StorageSettings>('/settings/storage');++// The instance keyboard shortcuts. The read is open to any signed-in user (every+// client applies them); the write is god mode.+export const getHotkeySettings = () => request<HotkeyOverrides>('/settings/hotkeys');++// The instance's own sign-in policy, readable without a session: the sign-up+// screen needs it before an account exists.+export const getAuthConfig = () => request<PublicAuthConfig>('/auth-config');diff --git a/apps/web/src/lib/api/endpoints/share.ts b/apps/web/src/lib/api/endpoints/share.tsnew file mode 100644index 00000000..f40f9550--- /dev/null+++ b/apps/web/src/lib/api/endpoints/share.ts@@ -0,0 +1,64 @@+import type { SavedViewDisplay } from '@/utils/viewSettings';+import { request } from '@/lib/api/core/client';+import type { FeedItem } from '@/lib/api/endpoints/activity';+import type { BoardIssue, IssueRelations } from '@/lib/api/endpoints/issues';+import type { Assignee, ProjectScaffold } from '@/lib/api/endpoints/projects';++// Public read-only share bundles, returned by the /share/* routes with no session.+// The scaffold mirrors ProjectScaffold minus the caller's viewer/permissions and+// member emails and handles (a public page shows names and avatars only).+export type PublicScaffold = Omit<ProjectScaffold, 'viewer' | 'permissions' | 'assignees'> & {+ assignees: Omit<Assignee, 'email' | 'username' | 'canReadWorkItems'>[];+};++export interface SharedIssueBundle {+ project: PublicScaffold;+ issue: IssueRelations;+ feed: FeedItem[];+}++export interface SharedViewBundle {+ project: PublicScaffold;+ // The view's own filters stay on the server: it has already applied them to the+ // issues below, and they can name assignees, labels and custom field values a+ // link without `extended` withholds.+ view: {+ name: string;+ icon: string | null;+ display: SavedViewDisplay;+ // Whether the link exposes the full issues or only their title, description,+ // state, type, priority, dates, subtasks and links.+ extended: boolean;+ };+ issues: BoardIssue[];+}++// Public read-only sharing. Enabling returns the link token and sets how much it+// exposes; calling it again on a shared entity keeps the link and only changes+// that. Disable revokes it. The getShared* reads need no session (public+// /share/* routes).+export const enableIssueShare = (id: number, extended: boolean) =>+ request<{ token: string }>(`/issues/${id}/share`, {+ method: 'POST',+ body: JSON.stringify({ extended }),+ });++export const disableIssueShare = (id: number) =>+ request<void>(`/issues/${id}/share`, { method: 'DELETE' });++export const enableViewShare = (id: number, extended: boolean) =>+ request<{ token: string }>(`/views/${id}/share`, {+ method: 'POST',+ body: JSON.stringify({ extended }),+ });++export const disableViewShare = (id: number) =>+ request<void>(`/views/${id}/share`, { method: 'DELETE' });++export const getSharedIssue = (token: string) =>+ request<SharedIssueBundle>(`/share/issue/${token}`);++export const getSharedView = (token: string) => request<SharedViewBundle>(`/share/view/${token}`);++export const getSharedViewIssue = (token: string, issueId: number) =>+ request<SharedIssueBundle>(`/share/view/${token}/issues/${issueId}`);diff --git a/apps/web/src/lib/api/endpoints/sync.ts b/apps/web/src/lib/api/endpoints/sync.tsnew file mode 100644index 00000000..152bcf88--- /dev/null+++ b/apps/web/src/lib/api/endpoints/sync.ts@@ -0,0 +1,6 @@+import { request } from '@/lib/api/core/client';++// The change markers of every scope the client is watching, in one request.+// Polled by the sync provider; see utils/revScopes.+export const getRevs = (scopes: string[]) =>+ request<{ revs: Record<string, string> }>(`/sync/rev?scopes=${scopes.join(',')}`);diff --git a/apps/web/src/lib/api/endpoints/teams.ts b/apps/web/src/lib/api/endpoints/teams.tsnew file mode 100644index 00000000..ac981397--- /dev/null+++ b/apps/web/src/lib/api/endpoints/teams.ts@@ -0,0 +1,262 @@+import type { AnalyticsStats } from '@/lib/api/endpoints/analytics';+import type { Project } from '@/lib/api/endpoints/projects';+import { request } from '@/lib/api/core/client';+import type { Permissions } from '@/lib/api/endpoints/roles';+import { pageQuery, type Page, type PageParams } from '@/lib/api/core/paging';+import {+ memberListQuery,+ type MemberListParams,+ type MemberRole,+} from '@/lib/api/endpoints/members';++// A team the caller belongs to. It owns projects and holds its own member list.+export interface Team {+ id: number;+ name: string;+ // Whether the team is reachable over MCP at all, set in its MCP section. Off closes+ // its own resources and every project it owns.+ mcpEnabled: boolean;+ // The caller's rank in the team. The API also answers an agent's own key, which reads+ // 'agent' there; an agent never opens this app, so a person's rank is what arrives.+ role: TeamRole;+ // How the caller's own membership came about. A provisioned one is the identity+ // provider's: the team cannot be left while it stands.+ source: 'invite' | 'scim';+ joinedAt: string;+ projectCount: number;+ memberCount: number;+ // How many of those members are owners: the last one cannot leave.+ ownerCount: number;+ // The roles the team's projects assign from, the integration credentials they run+ // on, the agents that work in them, and the skills and tools those agents use.+ // Counted here so the page shows them beside the section without opening it.+ roleCount: number;+ integrationCount: number;+ agentCount: number;+ skillCount: number;+ toolCount: number;+ createdAt: string;+}++export type TeamRole = 'owner' | 'manager' | 'member';++// One member of a team: a person, or the bot user of one of its agents. An agent's+// standing in the team is 'agent' and says nothing about what it may do — that is the+// role each of its project memberships carries.+export interface TeamMember {+ userId: string;+ name: string;+ email: string;+ image: string | null;+ role: TeamRole | 'agent';+ // 'scim' when a provisioned group granted this membership. It ends at the identity+ // provider, so the list does not remove it.+ source: 'invite' | 'scim';+ agentId: number | null;+ username: string | null;+ joinedAt: string;+}++// A project the team owns. `isMember` is the caller's own access to it: a team+// member sees every project of the team, but only opens the ones they belong to.+export interface TeamProject {+ id: number;+ key: string;+ name: string;+ description: string;+ // Whether the team's MCP reach covers this project. Only counts while the team's+ // own switch is on.+ mcpEnabled: boolean;+ memberCount: number;+ owners: { userId: string; name: string; image: string | null }[];+ isMember: boolean;+ createdAt: string;+}++// What a team's project list asks for: the window, and a search over the key and the+// name. The search runs on the server, so the page and the total agree.+export interface TeamProjectListParams extends PageParams {+ search?: string;+}++// A project as the pickers read it, plus the MCP reach the team's switches set.+export interface TeamProjectOption {+ id: number;+ key: string;+ name: string;+ mcpEnabled: boolean;+}++export interface TeamDetail extends Team {+ // What the caller may do with the resources the team holds for all its projects.+ // Owners and managers get the full matrix; a member gets the permissions of their+ // project roles in the team, merged.+ permissions: Permissions;+ // The people who run the team, owners first.+ leads: TeamLead[];+}++export interface TeamLead {+ userId: string;+ name: string;+ email: string;+ image: string | null;+ role: 'owner' | 'manager';+}++// One project the team owns, as its row in the team panel opens it: how its issues+// stand, and where the reader stands in it. Its members are a page of their own.+export interface TeamProjectDetail {+ lastActivityAt: string | null;+ stats: AnalyticsStats;+ // The reader's own membership in the project, null when they only run the team.+ // A provisioned one ends at the identity provider, so it cannot be left here.+ viewer: { role: MemberRole; source: 'invite' | 'scim'; permissions: Permissions } | null;+}++// One member of a project the team owns. The access their membership resolves to is+// the matrix of the role they hold, which the reader already has from the team's+// roles.+export interface TeamProjectMember {+ userId: string;+ name: string;+ email: string;+ // The handle they are mentioned by, @username. An agent's bot user carries the+ // agent's handle.+ username: string | null;+ image: string | null;+ isAgent: boolean;+ role: MemberRole;+ roleId: number | null;+ roleName: string | null;+ // What the member does in the project, and which path their membership came from —+ // both needed by the panel, which edits the membership from there.+ description: string;+ source: 'invite' | 'scim';+ timezone: string;+ joinedAt: string;+}++// A team's MCP settings: the switch, and which of its projects the reach covers.+export interface TeamMcpSettings {+ enabled: boolean;+ projects: { projectId: number; enabled: boolean }[];+}++// Parts of a source project the copy can carry over, one key per project settings+// section. Passed to copyTeamProject as an include map; omitted keys are not+// copied. The API force-enables dependencies (a view needs its+// states/types/labels/fields).+export type CopyProjectIncludeKey =+ | 'states'+ | 'issueTypes'+ | 'labels'+ | 'customFields'+ | 'views'+ | 'dashboards'+ | 'documents'+ | 'actions'+ | 'configuration'+ | 'webhooks'+ | 'agents'+ | 'schedules';++export const listTeams = () => request<Team[]>('/teams');++export const getTeam = (teamId: number) => request<TeamDetail>(`/teams/${teamId}`);++// One page of the team's members. `search` matches the name, the address or the+// handle.+export const listTeamMembers = (teamId: number, params: MemberListParams) =>+ request<Page<TeamMember>>(`/teams/${teamId}/members${memberListQuery(params)}`);++// One page of the projects the team owns. `search` matches the key or the name.+export const listTeamProjects = (teamId: number, params: TeamProjectListParams) =>+ request<Page<TeamProject>>(+ `/teams/${teamId}/projects${pageQuery(params, { search: params.search })}`,+ );++// Every project the reader has in the team, for the agent's project picker and the+// MCP switches.+export const listTeamProjectOptions = (teamId: number) =>+ request<TeamProjectOption[]>(`/teams/${teamId}/projects/options`);++export const getTeamProject = (teamId: number, projectId: number) =>+ request<TeamProjectDetail>(`/teams/${teamId}/projects/${projectId}`);++// One page of a project's members. `search` matches the name, the address or the+// handle.+export const listTeamProjectMembers = (+ teamId: number,+ projectId: number,+ params: MemberListParams,+) =>+ request<Page<TeamProjectMember>>(+ `/teams/${teamId}/projects/${projectId}/members${memberListQuery(params)}`,+ );++export const createTeam = (input: { name: string }) =>+ request<Team>('/teams', { method: 'POST', body: JSON.stringify(input) });++export const renameTeam = (teamId: number, input: { name: string }) =>+ request<Team>(`/teams/${teamId}`, { method: 'PATCH', body: JSON.stringify(input) });++export const leaveTeam = (teamId: number) =>+ request<void>(`/teams/${teamId}/leave`, { method: 'POST' });++export const setTeamMemberRole = (teamId: number, userId: string, role: TeamRole) =>+ request<void>(`/teams/${teamId}/members/${userId}`, {+ method: 'PATCH',+ body: JSON.stringify({ role }),+ });++export const removeTeamMember = (teamId: number, userId: string) =>+ request<void>(`/teams/${teamId}/members/${userId}`, { method: 'DELETE' });++export const updateTeamMcp = (+ teamId: number,+ patch: { enabled?: boolean; projects?: { projectId: number; enabled: boolean }[] },+) =>+ request<TeamMcpSettings>(`/teams/${teamId}/mcp`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++// The projects a team owns: created, copied, and deleted by the team's own ranks+// (owner/manager create and copy, owner deletes) rather than by project membership.+export const createTeamProject = (+ teamId: number,+ input: { key: string; name: string; description?: string; preset?: string },+) =>+ request<Project>(`/teams/${teamId}/projects`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const copyTeamProject = (+ teamId: number,+ projectId: number,+ input: {+ key: string;+ name: string;+ description?: string;+ include?: Partial<Record<CopyProjectIncludeKey, boolean>>;+ },+) =>+ request<Project>(`/teams/${teamId}/projects/${projectId}/copy`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateTeamProject = (+ teamId: number,+ projectId: number,+ patch: { name?: string; description?: string },+) =>+ request<Project>(`/teams/${teamId}/projects/${projectId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteTeamProject = (teamId: number, projectId: number) =>+ request<void>(`/teams/${teamId}/projects/${projectId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/telegram.ts b/apps/web/src/lib/api/endpoints/telegram.tsnew file mode 100644index 00000000..a1e9bd1f--- /dev/null+++ b/apps/web/src/lib/api/endpoints/telegram.ts@@ -0,0 +1,25 @@+import { request } from '@/lib/api/core/client';++// The session user's Telegram link. `botUsername` is null when no instance bot is+// configured, which is when Telegram is not offered at all; `link` is null while the+// user has not connected an account.+export interface TelegramAccount {+ botUsername: string | null;+ link: { username: string | null; firstName: string | null; linkedAt: string } | null;+}++// The deep link that completes a Telegram connection, and when its code expires.+export interface TelegramLinkStart {+ url: string;+ expiresAt: string;+}++// The session user's own Telegram account link. Starting a link returns the bot+// deep link that completes it; the bot service writes the connection when the user+// opens it.+export const getTelegramAccount = () => request<TelegramAccount>('/telegram/account');++export const startTelegramLink = () =>+ request<TelegramLinkStart>('/telegram/account/link', { method: 'POST' });++export const unlinkTelegramAccount = () => request<void>('/telegram/account', { method: 'DELETE' });diff --git a/apps/web/src/lib/api/endpoints/updates.ts b/apps/web/src/lib/api/endpoints/updates.tsnew file mode 100644index 00000000..709cf113--- /dev/null+++ b/apps/web/src/lib/api/endpoints/updates.ts@@ -0,0 +1,71 @@+import { request } from '@/lib/api/core/client';++// One release. The ones above the running version come from the repository's feed+// and carry HTML notes; the ones up to it come from this build's changelog and+// carry markdown.+export interface Release {+ tag: string;+ version: string;+ publishedAt: string;+ url: string | null;+ notes: string;+ notesFormat: 'html' | 'markdown';+}++// How the running version compares to what is published. `latestVersion` and+// `checkedAt` are null until an upstream check has succeeded.+export interface UpdateStatus {+ currentVersion: string;+ latestVersion: string | null;+ updateAvailable: boolean;+ checkedAt: string | null;+ releases: Release[];+}++// The screen shown once after an upgrade. `backup` and `migration` are filled for+// the instance owner and a team owner only — they name projects, roles and agents+// across the instance — and are null for everyone else.+export interface BackupInfo {+ path: string;+ sizeBytes: number;+ createdAt: string;+ expiresAt: string;+ migrations: string[];+}++// What the move to teams did to this instance's data, as the migration recorded it.+export interface TeamsMigrationReport {+ version: number;+ teams: { name: string; projects: { key: string; name: string }[] }[];+ // Keyed by what was renamed: roles, skills, agents, credentials.+ renamed: Record<string, { from: string; to: string }[]>;+ merged: { roles: number; agentTools: number };+ movedInvites: number;+ droppedNotificationSettings: string[];+}++export interface WhatsNew {+ version: string;+ pending: boolean;+ // Every release this user has not seen yet, newest first.+ releases: Release[];+ backup: BackupInfo | null;+ migration: TeamsMigrationReport | null;+}++// The running version, shown in the sidebar to every signed-in user.+export const getAppVersion = () => request<{ version: string }>('/settings/version');++// The release this instance just upgraded to, and what the upgrade did to its+// data. Read once per session; closing the screen records the version.+export const getWhatsNew = () => request<WhatsNew>('/settings/whats-new');++export const markWhatsNewSeen = () =>+ request<{ version: string }>('/settings/whats-new/seen', { method: 'POST' });++// Whether a newer release exists, and the release notes behind it. God mode: the+// instance owner is the one who upgrades.+export const getUpdateStatus = () => request<UpdateStatus>('/god/updates');++export const checkForUpdates = () =>+ request<UpdateStatus>('/god/updates/check', { method: 'POST' });diff --git a/apps/web/src/lib/api/endpoints/userPreferences.ts b/apps/web/src/lib/api/endpoints/userPreferences.tsnew file mode 100644index 00000000..fd7f9c71--- /dev/null+++ b/apps/web/src/lib/api/endpoints/userPreferences.ts@@ -0,0 +1,60 @@+import type { Locale } from '@/i18n/locales';+import { request } from '@/lib/api/core/client';+import type { HotkeyOverrides } from '@/lib/api/endpoints/settings';++// The signed-in user's interface preferences, held per account so they apply on+// every device. timezone is an IANA zone name the app renders stored UTC timestamps+// in; issueOpenMode decides whether a clicked issue opens in the side panel or on+// its own page; startPage is the section the app root lands on; showChatByDefault+// keeps the floating AI chat button on screen from the start; lastProjectId is the+// project the app root reopens (null until the user has opened one).+export type ThemePreference = 'light' | 'dark' | 'system';++export type IssueOpenMode = 'panel' | 'page';++export type StartPage = 'inbox' | 'dashboard' | 'work-items' | 'initiatives';++export type IssueStatsView = 'compact' | 'timeline';++export type IssueActivityView = 'flat' | 'grouped';++export interface AccountPreferences {+ timezone: string;+ // The interface language. Mirrored into the NEXT_LOCALE cookie, which is what the+ // server renders with; also the language of this user's emails and bot messages.+ locale: Locale;+ theme: ThemePreference;+ issueOpenMode: IssueOpenMode;+ startPage: StartPage;+ showChatByDefault: boolean;+ // How the status stats section of an issue starts out, and the shape its activity+ // log starts in. Switching either on an issue is not saved — it lasts as long as+ // that issue stays open.+ issueStatsOpen: boolean;+ issueStatsView: IssueStatsView;+ issueActivityView: IssueActivityView;+ // Whether the user is subscribed to the issues they create, are assigned, comment+ // on or are mentioned in. Off means they only ever subscribe by hand.+ autoWatch: boolean;+ lastProjectId: number | null;+ // The keyboard shortcuts this user rebound, as { commandId: combo }. Only the+ // changed ones; the rest come from the instance settings, then the built-in+ // bindings (see lib/hotkeys).+ hotkeys: HotkeyOverrides;+}++export type AccountPreferencesPatch = Partial<AccountPreferences>;++// The session user's own interface preferences, held per account. A read returns+// the defaults when nothing was saved; a write patches only the fields it carries.+export const getAccountPreferences = (locale: Locale) =>+ request<AccountPreferences>('/account/preferences', {+ headers: { 'Accept-Language': locale },+ });++export const updateAccountPreferences = (input: AccountPreferencesPatch, locale: Locale) =>+ request<AccountPreferences>('/account/preferences', {+ method: 'PATCH',+ headers: { 'Accept-Language': locale },+ body: JSON.stringify(input),+ });diff --git a/apps/web/src/lib/api/endpoints/views.ts b/apps/web/src/lib/api/endpoints/views.tsnew file mode 100644index 00000000..a352d5a2--- /dev/null+++ b/apps/web/src/lib/api/endpoints/views.ts@@ -0,0 +1,60 @@+import type { FilterSet } from '@/utils/filters';+import type { SavedViewDisplay } from '@/utils/viewSettings';+import { request } from '@/lib/api/core/client';++// A saved view (a tab above the work items view): a named filter set plus a display+// snapshot (layout + that layout's settings). The view itself is shared by the+// project; only `favorite` is per user. filters/display are stored as jsonb.+export interface View {+ id: number;+ projectId: number;+ name: string;+ icon: string | null;+ filters: FilterSet;+ display: SavedViewDisplay;+ position: number;+ // Unguessable token for the public read-only share link, or null when not shared.+ shareToken: string | null;+ // Whether the share link exposes the full issues (assignees, labels, custom+ // fields, activity) or only their title, description, state, type, priority,+ // dates, subtasks and links.+ shareExtended: boolean;+ // Whether the current user marked the view as a favorite: it pins the tab to the+ // front and lists the view under Work items in the sidebar.+ favorite: boolean;+ createdAt: string;+}++export interface NewViewInput {+ name: string;+ icon?: string | null;+ filters?: FilterSet;+ display?: SavedViewDisplay;+}++export interface ViewPatch {+ name?: string;+ icon?: string | null;+ filters?: FilterSet;+ display?: SavedViewDisplay;+}++export const listViews = (projectKey: string) => request<View[]>(`/projects/${projectKey}/views`);++export const createView = (projectKey: string, input: NewViewInput) =>+ request<View>(`/projects/${projectKey}/views`, { method: 'POST', body: JSON.stringify(input) });++export const updateView = (viewId: number, patch: ViewPatch) =>+ request<View>(`/views/${viewId}`, { method: 'PATCH', body: JSON.stringify(patch) });++export const deleteView = (viewId: number) =>+ request<void>(`/views/${viewId}`, { method: 'DELETE' });++export const setViewFavorite = (viewId: number, favorite: boolean) =>+ request<void>(`/views/${viewId}/favorite`, { method: favorite ? 'PUT' : 'DELETE' });++export const reorderViews = (projectKey: string, orderedIds: number[]) =>+ request<View[]>(`/projects/${projectKey}/views/reorder`, {+ method: 'PUT',+ body: JSON.stringify({ orderedIds }),+ });diff --git a/apps/web/src/lib/api/endpoints/webhooks.ts b/apps/web/src/lib/api/endpoints/webhooks.tsnew file mode 100644index 00000000..22f35575--- /dev/null+++ b/apps/web/src/lib/api/endpoints/webhooks.ts@@ -0,0 +1,88 @@+import { request } from '@/lib/api/core/client';++// Outgoing webhook subscription (mirrors apps/api modules/webhooks/service.ts). The event+// types must stay in sync with WEBHOOK_EVENT_TYPES on the server.+export type WebhookEventType =+ | 'issue.created'+ | 'issue.updated'+ | 'issue.deleted'+ | 'issue.assigned'+ | 'issue.state_changed'+ | 'issue.label_changed'+ | 'issue.link_changed'+ | 'comment.created';++export const WEBHOOK_EVENT_TYPES: WebhookEventType[] = [+ 'issue.created',+ 'issue.updated',+ 'issue.deleted',+ 'issue.assigned',+ 'issue.state_changed',+ 'issue.label_changed',+ 'issue.link_changed',+ 'comment.created',+];++export interface Webhook {+ id: number;+ projectId: number;+ url: string;+ secret: string;+ events: WebhookEventType[];+ isActive: boolean;+ createdAt: string;+}++export interface NewWebhookInput {+ url: string;+ events: WebhookEventType[];+ isActive?: boolean;+}++export interface WebhookPatch {+ url?: string;+ events?: WebhookEventType[];+ isActive?: boolean;+}++// A recorded delivery attempt for the history view. payload is the request body we+// sent; responseStatus/responseBody come from the last attempt; lastError is set+// on a failed or retrying delivery.+export interface WebhookDelivery {+ id: number;+ eventId: string;+ eventType: WebhookEventType;+ status: 'pending' | 'success' | 'failed';+ attempts: number;+ payload: unknown;+ responseStatus: number | null;+ responseBody: string | null;+ lastError: string | null;+ nextAttemptAt: string;+ createdAt: string;+}++export interface WebhookDeliveryPage {+ items: WebhookDelivery[];+ nextCursor: number | null;+}++export const listWebhooks = (projectKey: string) =>+ request<Webhook[]>(`/projects/${projectKey}/webhooks`);++export const createWebhook = (projectKey: string, input: NewWebhookInput) =>+ request<Webhook>(`/projects/${projectKey}/webhooks`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateWebhook = (webhookId: number, patch: WebhookPatch) =>+ request<Webhook>(`/webhooks/${webhookId}`, { method: 'PATCH', body: JSON.stringify(patch) });++export const deleteWebhook = (webhookId: number) =>+ request<void>(`/webhooks/${webhookId}`, { method: 'DELETE' });++export const listWebhookDeliveries = (webhookId: number, before?: number) =>+ request<WebhookDeliveryPage>(+ `/webhooks/${webhookId}/deliveries?limit=25${before ? `&before=${before}` : ''}`,+ );diff --git a/apps/web/src/lib/api/endpoints/worklogs.ts b/apps/web/src/lib/api/endpoints/worklogs.tsnew file mode 100644index 00000000..738ad980--- /dev/null+++ b/apps/web/src/lib/api/endpoints/worklogs.ts@@ -0,0 +1,43 @@+import { request } from '@/lib/api/core/client';++// One entry of the time a member logged on an issue: how long they worked, the day+// the work happened on, an optional note, and the member it belongs to. The time an+// issue took is the sum of its entries (Issue.loggedMinutes).+export interface Worklog {+ id: number;+ issueId: number;+ userId: string;+ userName: string | null;+ userImage: string | null;+ minutes: number;+ spentOn: string;+ note: string | null;+ createdAt: string;+}++// What a new entry carries. A change sends the same fields, any subset of them.+export interface WorklogInput {+ minutes: number;+ spentOn: string;+ note?: string | null;+}++// The time logged on an issue. Unlike the checklists these are not part of the+// issue read — it carries their sum, and only the section listing them needs the+// entries.+export const listWorklogs = (issueId: number) => request<Worklog[]>(`/issues/${issueId}/worklogs`);++export const createWorklog = (issueId: number, input: WorklogInput) =>+ request<Worklog>(`/issues/${issueId}/worklogs`, {+ method: 'POST',+ body: JSON.stringify(input),+ });++export const updateWorklog = (worklogId: number, patch: Partial<WorklogInput>) =>+ request<Worklog>(`/worklogs/${worklogId}`, {+ method: 'PATCH',+ body: JSON.stringify(patch),+ });++export const deleteWorklog = (worklogId: number) =>+ request<void>(`/worklogs/${worklogId}`, { method: 'DELETE' });diff --git a/apps/web/src/lib/auth-client.ts b/apps/web/src/lib/auth-client.tsindex fda122dc..5d92d229 100644--- a/apps/web/src/lib/auth-client.ts+++ b/apps/web/src/lib/auth-client.ts@@ -3,7 +3,7 @@ import { inferAdditionalFields } from 'better-auth/client/plugins';import { genericOAuthClient, magicLinkClient, usernameClient } from 'better-auth/client/plugins';import { passkeyClient } from '@better-auth/passkey/client';import { apiKeyClient } from '@better-auth/api-key/client';-import { API_URL, markSigningOut } from '@/lib/api';+import { API_URL, markSigningOut } from '@/lib/api/core/client';// The better-auth handler lives on the backend (Elysia), so baseURL is the API origin.// inferAdditionalFields declares the custom `role` column added in @repo/auth so thediff --git a/apps/web/src/lib/markdown.ts b/apps/web/src/lib/markdown.tsindex 50d2a14b..52b8e78f 100644--- a/apps/web/src/lib/markdown.ts+++ b/apps/web/src/lib/markdown.ts@@ -1,7 +1,7 @@import { marked } from 'marked';import DOMPurify from 'isomorphic-dompurify';import { parseChartSpec, type ChartSpec } from '@/utils/chartSpec';-import { mediaUrl } from '@/lib/api';+import { mediaUrl } from '@/lib/api/core/media';// Content whose links lead away from the current view (release notes, agent chat)// asks for newTabLinks, so following one does not replace what the reader was on.diff --git a/apps/web/src/proxy.ts b/apps/web/src/proxy.tsindex c1711287..42854f68 100644--- a/apps/web/src/proxy.ts+++ b/apps/web/src/proxy.ts@@ -33,7 +33,7 @@ function clearSession(request: NextRequest): NextResponse {// does the real validation on every request. It keeps unauthenticated users out of// the planner UI and bounces signed-in users away from the auth pages.// A cookie the API no longer accepts passes this check, so the client handles that-// case: `apiFailure` in `lib/api.ts` signs out on a 401 and lands on+// case: `apiFailure` in `lib/api/core/client.ts` signs out on a 401 and lands on// `/login?expired=1`, where the cookie is cleared for good.export function proxy(request: NextRequest) {const { pathname } = request.nextUrl;diff --git a/apps/web/src/services/actions.service.ts b/apps/web/src/services/actions.service.tsindex 6011e86b..0fba7334 100644--- a/apps/web/src/services/actions.service.ts+++ b/apps/web/src/services/actions.service.ts@@ -1,5 +1,12 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type ActionDef } from '@/lib/api';+import {+ type ActionDef,+ listQuickActions,+ createAction,+ updateAction,+ deleteAction,+ reorderActions,+} from '@/lib/api/endpoints/actions';import { EMPTY_FILTER_SET, type FilterSet } from '@/utils/filters';import { useOptimisticReorder } from '@/services/optimisticReorder';import { qk } from '@/services/queryKeys';@@ -21,7 +28,7 @@ export function normalizeAction(a: ActionDef): ActionDef {export function useActionsQuery(projectKey: string | null) {return useQuery({queryKey: qk.actions(projectKey ?? ''),- queryFn: () => api.listQuickActions(projectKey!),+ queryFn: () => listQuickActions(projectKey!),enabled: projectKey != null,select: (rows) => rows.map(normalizeAction),});@@ -30,8 +37,8 @@ export function useActionsQuery(projectKey: string | null) {export function useCreateAction(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ input }: { input: Parameters<typeof api.createAction>[1] }) =>- api.createAction(projectKey!, input),+ mutationFn: ({ input }: { input: Parameters<typeof createAction>[1] }) =>+ createAction(projectKey!, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.actions(projectKey) });},@@ -41,8 +48,8 @@ export function useCreateAction(projectKey: string | null) {export function useUpdateAction(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, input }: { id: number; input: Parameters<typeof api.updateAction>[1] }) =>- api.updateAction(id, input),+ mutationFn: ({ id, input }: { id: number; input: Parameters<typeof updateAction>[1] }) =>+ updateAction(id, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.actions(projectKey) });},@@ -52,7 +59,7 @@ export function useUpdateAction(projectKey: string | null) {export function useDeleteAction(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteAction(id),+ mutationFn: (id: number) => deleteAction(id),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.actions(projectKey) });},@@ -61,6 +68,6 @@ export function useDeleteAction(projectKey: string | null) {export function useReorderActions(projectKey: string | null) {return useOptimisticReorder<ActionDef>(projectKey ? qk.actions(projectKey) : null, (orderedIds) =>- api.reorderActions(projectKey!, orderedIds),+ reorderActions(projectKey!, orderedIds),);}diff --git a/apps/web/src/services/agentSchedules.service.ts b/apps/web/src/services/agentSchedules.service.tsindex f5076f3a..a8818f85 100644--- a/apps/web/src/services/agentSchedules.service.ts+++ b/apps/web/src/services/agentSchedules.service.ts@@ -1,5 +1,14 @@import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type PageParams } from '@/lib/api';+import {+ listAgentSchedules,+ listAgentScheduleRuns,+ createAgentSchedule,+ updateAgentSchedule,+ deleteAgentSchedule,+ cancelAgentScheduleRuns,+ runAgentSchedule,+} from '@/lib/api/endpoints/agentSchedules';+import type { PageParams } from '@/lib/api/core/paging';import { qk } from '@/services/queryKeys';// One page of the project's schedules. A page with a run still going is polled, so the@@ -7,7 +16,7 @@ import { qk } from '@/services/queryKeys';export function useAgentSchedules(projectKey: string, params: PageParams) {return useQuery({queryKey: qk.agentSchedulePage(projectKey, params),- queryFn: () => api.listAgentSchedules(projectKey, params),+ queryFn: () => listAgentSchedules(projectKey, params),placeholderData: keepPreviousData,refetchInterval: (query) =>query.state.data?.items.some((schedule) => schedule.lastRunStatus === 'pending')@@ -19,7 +28,7 @@ export function useAgentSchedules(projectKey: string, params: PageParams) {export function useAgentScheduleRuns(projectKey: string, scheduleId: number | null) {return useQuery({queryKey: qk.agentScheduleRuns(projectKey, scheduleId ?? 0),- queryFn: () => api.listAgentScheduleRuns(projectKey, scheduleId!),+ queryFn: () => listAgentScheduleRuns(projectKey, scheduleId!),enabled: scheduleId != null,refetchInterval: (query) =>query.state.data?.some((run) => run.status === 'pending') ? 2000 : false,@@ -29,8 +38,8 @@ export function useAgentScheduleRuns(projectKey: string, scheduleId: number | nuexport function useCreateAgentSchedule(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: Parameters<typeof api.createAgentSchedule>[1]) =>- api.createAgentSchedule(projectKey, input),+ mutationFn: (input: Parameters<typeof createAgentSchedule>[1]) =>+ createAgentSchedule(projectKey, input),onSuccess: () => qc.invalidateQueries({ queryKey: qk.agentSchedules(projectKey) }),});}@@ -38,13 +47,8 @@ export function useCreateAgentSchedule(projectKey: string) {export function useUpdateAgentSchedule(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: ({- id,- patch,- }: {- id: number;- patch: Parameters<typeof api.updateAgentSchedule>[2];- }) => api.updateAgentSchedule(projectKey, id, patch),+ mutationFn: ({ id, patch }: { id: number; patch: Parameters<typeof updateAgentSchedule>[2] }) =>+ updateAgentSchedule(projectKey, id, patch),onSuccess: () => qc.invalidateQueries({ queryKey: qk.agentSchedules(projectKey) }),});}@@ -52,7 +56,7 @@ export function useUpdateAgentSchedule(projectKey: string) {export function useDeleteAgentSchedule(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteAgentSchedule(projectKey, id),+ mutationFn: (id: number) => deleteAgentSchedule(projectKey, id),onSuccess: () => qc.invalidateQueries({ queryKey: qk.agentSchedules(projectKey) }),});}@@ -61,7 +65,7 @@ export function useCancelAgentScheduleRuns(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: ({ scheduleId, runId }: { scheduleId: number; runId?: number }) =>- api.cancelAgentScheduleRuns(projectKey, scheduleId, runId),+ cancelAgentScheduleRuns(projectKey, scheduleId, runId),onSuccess: (_data, { scheduleId }) => {void qc.invalidateQueries({ queryKey: qk.agentSchedules(projectKey) });void qc.invalidateQueries({ queryKey: qk.agentScheduleRuns(projectKey, scheduleId) });@@ -72,7 +76,7 @@ export function useCancelAgentScheduleRuns(projectKey: string) {export function useRunAgentSchedule(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.runAgentSchedule(projectKey, id),+ mutationFn: (id: number) => runAgentSchedule(projectKey, id),onSuccess: (_data, id) => {void qc.invalidateQueries({ queryKey: qk.agentSchedules(projectKey) });void qc.invalidateQueries({ queryKey: qk.agentScheduleRuns(projectKey, id) });diff --git a/apps/web/src/services/agentSkills.service.ts b/apps/web/src/services/agentSkills.service.tsindex d4bb08a8..58c323ca 100644--- a/apps/web/src/services/agentSkills.service.ts+++ b/apps/web/src/services/agentSkills.service.ts@@ -2,14 +2,30 @@// the team, so every hook here is keyed by it.import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type NewSkillInput, type PageParams, type SkillPatch } from '@/lib/api';+import {+ type NewSkillInput,+ type SkillPatch,+ listSkillOptions,+ getSkill,+ listSkills,+ createSkill,+ discoverGithubSkills,+ updateSkill,+ deleteSkill,+ addSkillReference,+ updateSkillReferenceContent,+ deleteSkillReference,+ listAgentSkills,+ setAgentSkills,+} from '@/lib/api/endpoints/agentSkills';+import type { PageParams } from '@/lib/api/core/paging';import { qk } from '@/services/queryKeys';// The whole library, which the agent editor's skill picker needs entire.export function useSkillOptionsQuery(teamId: number | null) {return useQuery({queryKey: qk.agentSkillOptions(teamId ?? 0),- queryFn: () => api.listSkillOptions(teamId!),+ queryFn: () => listSkillOptions(teamId!),enabled: teamId != null,});}@@ -19,7 +35,7 @@ export function useSkillOptionsQuery(teamId: number | null) {export function useSkillQuery(teamId: number, skillId: number) {return useQuery({queryKey: qk.agentSkill(teamId, skillId),- queryFn: () => api.getSkill(teamId, skillId),+ queryFn: () => getSkill(teamId, skillId),});}@@ -27,7 +43,7 @@ export function useSkillQuery(teamId: number, skillId: number) {export function useSkillsPageQuery(teamId: number | null, params: PageParams) {return useQuery({queryKey: qk.agentSkillPage(teamId ?? 0, params),- queryFn: () => api.listSkills(teamId!, params),+ queryFn: () => listSkills(teamId!, params),enabled: teamId != null,placeholderData: keepPreviousData,});@@ -36,7 +52,7 @@ export function useSkillsPageQuery(teamId: number | null, params: PageParams) {export function useCreateSkill(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewSkillInput) => api.createSkill(teamId, input),+ mutationFn: (input: NewSkillInput) => createSkill(teamId, input),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.agentSkills(teamId) });// The team list carries how many skills the team holds.@@ -49,7 +65,7 @@ export function useCreateSkill(teamId: number) {// no cache invalidation.export function useDiscoverGithubSkills(teamId: number) {return useMutation({- mutationFn: (url: string) => api.discoverGithubSkills(teamId, url),+ mutationFn: (url: string) => discoverGithubSkills(teamId, url),});}@@ -57,7 +73,7 @@ export function useUpdateSkill(teamId: number) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, patch }: { id: number; patch: SkillPatch }) =>- api.updateSkill(teamId, id, patch),+ updateSkill(teamId, id, patch),onSuccess: () => void qc.invalidateQueries({ queryKey: qk.agentSkills(teamId) }),});}@@ -65,7 +81,7 @@ export function useUpdateSkill(teamId: number) {export function useDeleteSkill(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteSkill(teamId, id),+ mutationFn: (id: number) => deleteSkill(teamId, id),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.agentSkills(teamId) });void qc.invalidateQueries({ queryKey: qk.teams });@@ -76,8 +92,7 @@ export function useDeleteSkill(teamId: number) {export function useAddSkillReference(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, file }: { id: number; file: File }) =>- api.addSkillReference(teamId, id, file),+ mutationFn: ({ id, file }: { id: number; file: File }) => addSkillReference(teamId, id, file),onSuccess: () => void qc.invalidateQueries({ queryKey: qk.agentSkills(teamId) }),});}@@ -86,7 +101,7 @@ export function useUpdateSkillReference(teamId: number) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, path, content }: { id: number; path: string; content: string }) =>- api.updateSkillReferenceContent(teamId, id, path, content),+ updateSkillReferenceContent(teamId, id, path, content),onSuccess: () => void qc.invalidateQueries({ queryKey: qk.agentSkills(teamId) }),});}@@ -95,7 +110,7 @@ export function useDeleteSkillReference(teamId: number) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, path }: { id: number; path: string }) =>- api.deleteSkillReference(teamId, id, path),+ deleteSkillReference(teamId, id, path),onSuccess: () => void qc.invalidateQueries({ queryKey: qk.agentSkills(teamId) }),});}@@ -104,7 +119,7 @@ export function useDeleteSkillReference(teamId: number) {export function useAgentSkillsQuery(teamId: number | null, agentId: number | null) {return useQuery({queryKey: qk.agentSkillLinks(teamId ?? 0, agentId ?? 0),- queryFn: () => api.listAgentSkills(teamId!, agentId!),+ queryFn: () => listAgentSkills(teamId!, agentId!),enabled: teamId != null && agentId != null,});}@@ -113,7 +128,7 @@ export function useSetAgentSkills(teamId: number | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ agentId, skillIds }: { agentId: number; skillIds: number[] }) =>- api.setAgentSkills(teamId!, agentId, skillIds),+ setAgentSkills(teamId!, agentId, skillIds),onSuccess: (_data, { agentId }) => {if (teamId != null)void qc.invalidateQueries({ queryKey: qk.agentSkillLinks(teamId, agentId) });diff --git a/apps/web/src/services/aiAgents.service.ts b/apps/web/src/services/aiAgents.service.tsindex f6d83495..c51bc406 100644--- a/apps/web/src/services/aiAgents.service.ts+++ b/apps/web/src/services/aiAgents.service.ts@@ -13,7 +13,25 @@ import {} from '@tanstack/react-query';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { api, type AiChatThread, type AiChatThreadPage } from '@/lib/api';+import {+ type AiChatThread,+ type AiChatThreadPage,+ listAiAgentThreads,+ listAiAgentFavoriteThreads,+ setAiAgentThreadFavorite,+ getAiAgentThreadMessages,+ renameAiAgentThread,+ deleteAiAgentThread,+} from '@/lib/api/endpoints/agentChat';+import {+ listAiAgents,+ listAgentRuns,+ listAgentTools,+ createAiAgent,+ updateAiAgent,+ regenerateAiAgentKey,+ deleteAiAgent,+} from '@/lib/api/endpoints/agents';import { qk } from '@/services/queryKeys';// Refetched on an interval because an external agent's runner presence comes from@@ -25,7 +43,7 @@ const RUNNER_PRESENCE_REFRESH_MS = 30_000;export function useAiAgentsQuery(teamId: number | null, projectId?: number) {return useQuery({queryKey: qk.aiAgents(teamId ?? 0, projectId),- queryFn: () => api.listAiAgents(teamId!, projectId),+ queryFn: () => listAiAgents(teamId!, projectId),enabled: teamId != null,refetchInterval: RUNNER_PRESENCE_REFRESH_MS,});@@ -36,7 +54,7 @@ export function useAiAgentsQuery(teamId: number | null, projectId?: number) {export function useAgentRuns(teamId: number | null, agentId: number | null) {return useInfiniteQuery({queryKey: qk.agentRuns(teamId ?? 0, agentId ?? 0),- queryFn: ({ pageParam }) => api.listAgentRuns(teamId!, agentId!, pageParam),+ queryFn: ({ pageParam }) => listAgentRuns(teamId!, agentId!, pageParam),initialPageParam: undefined as number | undefined,getNextPageParam: (last) => last.nextCursor ?? undefined,enabled: teamId != null && agentId != null,@@ -49,7 +67,7 @@ export function useAgentRuns(teamId: number | null, agentId: number | null) {export function useAgentThreadsQuery(projectKey: string | null, agentId: number | null, q = '') {return useInfiniteQuery({queryKey: qk.agentThreads(projectKey ?? '', agentId ?? 0, q),- queryFn: ({ pageParam }) => api.listAiAgentThreads(projectKey!, agentId!, pageParam, q),+ queryFn: ({ pageParam }) => listAiAgentThreads(projectKey!, agentId!, pageParam, q),initialPageParam: 0,getNextPageParam: (last) => last.nextPage ?? undefined,enabled: projectKey != null && agentId != null,@@ -61,7 +79,7 @@ export function useAgentThreadsQuery(projectKey: string | null, agentId: numberexport function useAgentFavoriteThreadsQuery(projectKey: string | null, agentId: number | null) {return useQuery({queryKey: qk.agentFavoriteThreads(projectKey ?? '', agentId ?? 0),- queryFn: () => api.listAiAgentFavoriteThreads(projectKey!, agentId!),+ queryFn: () => listAiAgentFavoriteThreads(projectKey!, agentId!),enabled: projectKey != null && agentId != null,});}@@ -74,7 +92,7 @@ export function useToggleAgentThreadFavorite(projectKey: string | null, agentId:const favorites = () => qk.agentFavoriteThreads(projectKey!, agentId!);return useMutation({mutationFn: ({ threadId, favorite }: { threadId: string; favorite: boolean }) =>- api.setAiAgentThreadFavorite(projectKey!, agentId!, threadId, favorite),+ setAiAgentThreadFavorite(projectKey!, agentId!, threadId, favorite),onMutate: async ({ threadId, favorite }) => {if (!projectKey || agentId == null) return;await Promise.all([@@ -152,7 +170,7 @@ export function useAgentThreadMessagesQuery(return useInfiniteQuery({queryKey: qk.agentThreadMessages(projectKey ?? '', agentId ?? 0, threadId ?? ''),queryFn: ({ pageParam }) =>- api.getAiAgentThreadMessages(projectKey!, agentId!, threadId!, pageParam),+ getAiAgentThreadMessages(projectKey!, agentId!, threadId!, pageParam),initialPageParam: 0,getNextPageParam: (last) => last.nextPage ?? undefined,enabled: projectKey != null && agentId != null && threadId != null,@@ -165,7 +183,7 @@ export function useRenameAgentThread(projectKey: string | null, agentId: numberconst qc = useQueryClient();return useMutation({mutationFn: ({ threadId, title }: { threadId: string; title: string }) =>- api.renameAiAgentThread(projectKey!, agentId!, threadId, title),+ renameAiAgentThread(projectKey!, agentId!, threadId, title),onSuccess: (_res, { threadId, title }) => {if (!projectKey || agentId == null) return;qc.setQueriesData<InfiniteData<AiChatThreadPage>>(@@ -191,7 +209,7 @@ export function useRenameAgentThread(projectKey: string | null, agentId: numberexport function useDeleteAgentThread(projectKey: string | null, agentId: number | null) {const qc = useQueryClient();return useMutation({- mutationFn: (threadId: string) => api.deleteAiAgentThread(projectKey!, agentId!, threadId),+ mutationFn: (threadId: string) => deleteAiAgentThread(projectKey!, agentId!, threadId),onSuccess: () => {if (projectKey && agentId != null) {void qc.invalidateQueries({ queryKey: qk.agentThreadLists(projectKey, agentId) });@@ -206,7 +224,7 @@ export function useDeleteAgentThread(projectKey: string | null, agentId: numberexport function useAgentToolsQuery(teamId: number | null) {return useQuery({queryKey: qk.agentTools(teamId ?? 0),- queryFn: () => api.listAgentTools(teamId!),+ queryFn: () => listAgentTools(teamId!),enabled: teamId != null,staleTime: Infinity,});@@ -226,8 +244,7 @@ export function useCreateAiAgent(teamId: number | null) {const t = useTranslations('teams.agents');const invalidate = useAgentInvalidator(teamId);return useMutation({- mutationFn: (input: Parameters<typeof api.createAiAgent>[1]) =>- api.createAiAgent(teamId!, input),+ mutationFn: (input: Parameters<typeof createAiAgent>[1]) => createAiAgent(teamId!, input),onSuccess: (res) => {toast.success(t('created', { username: res.agent.username }));invalidate();@@ -239,8 +256,8 @@ export function useUpdateAiAgent(teamId: number | null) {const t = useTranslations('teams.agents');const invalidate = useAgentInvalidator(teamId);return useMutation({- mutationFn: ({ id, patch }: { id: number; patch: Parameters<typeof api.updateAiAgent>[2] }) =>- api.updateAiAgent(teamId!, id, patch),+ mutationFn: ({ id, patch }: { id: number; patch: Parameters<typeof updateAiAgent>[2] }) =>+ updateAiAgent(teamId!, id, patch),onSuccess: (agent) => {toast.success(t('saved', { username: agent.username }));invalidate();@@ -251,7 +268,7 @@ export function useUpdateAiAgent(teamId: number | null) {export function useRegenerateAiAgentKey(teamId: number | null) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.regenerateAiAgentKey(teamId!, id),+ mutationFn: (id: number) => regenerateAiAgentKey(teamId!, id),onSuccess: () => {if (teamId != null) void qc.invalidateQueries({ queryKey: qk.teamAiAgents(teamId) });},@@ -261,7 +278,7 @@ export function useRegenerateAiAgentKey(teamId: number | null) {export function useDeleteAiAgent(teamId: number | null) {const invalidate = useAgentInvalidator(teamId);return useMutation({- mutationFn: (id: number) => api.deleteAiAgent(teamId!, id),+ mutationFn: (id: number) => deleteAiAgent(teamId!, id),onSuccess: invalidate,});}diff --git a/apps/web/src/services/authConfig.service.ts b/apps/web/src/services/authConfig.service.tsindex 1f643b48..dfe1c8eb 100644--- a/apps/web/src/services/authConfig.service.ts+++ b/apps/web/src/services/authConfig.service.ts@@ -1,7 +1,7 @@'use client';import { useQuery } from '@tanstack/react-query';-import { api, type PublicAuthConfig } from '@/lib/api';+import { type PublicAuthConfig, getAuthConfig } from '@/lib/api/endpoints/settings';import { qk } from '@/services/queryKeys';// The instance sign-in policy: whether registration is open, invite-only or closed,@@ -12,7 +12,7 @@ import { qk } from '@/services/queryKeys';export function useAuthConfigQuery() {return useQuery({queryKey: qk.authConfig,- queryFn: () => api.getAuthConfig(),+ queryFn: () => getAuthConfig(),// Set by an administrator and read on several screens, so keep it out of the// refetch path.staleTime: 5 * 60_000,diff --git a/apps/web/src/services/customTools.service.ts b/apps/web/src/services/customTools.service.tsindex 98440bd2..168d99aa 100644--- a/apps/web/src/services/customTools.service.ts+++ b/apps/web/src/services/customTools.service.ts@@ -3,7 +3,16 @@// lives in integrations.service.import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type NewConfiguredToolInput, type PageParams } from '@/lib/api';+import {+ type NewConfiguredToolInput,+ listConfiguredToolOptions,+ listConfiguredTools,+ createConfiguredTool,+ deleteConfiguredTool,+ listAgentToolLinks,+ setAgentTools,+} from '@/lib/api/endpoints/agentTools';+import type { PageParams } from '@/lib/api/core/paging';import { qk } from '@/services/queryKeys';// The whole list, which the agent editor's tool picker and the tool dialog need@@ -11,7 +20,7 @@ import { qk } from '@/services/queryKeys';export function useConfiguredToolOptionsQuery(teamId: number | null) {return useQuery({queryKey: qk.configuredToolOptions(teamId ?? 0),- queryFn: () => api.listConfiguredToolOptions(teamId!),+ queryFn: () => listConfiguredToolOptions(teamId!),enabled: teamId != null,});}@@ -20,7 +29,7 @@ export function useConfiguredToolOptionsQuery(teamId: number | null) {export function useConfiguredToolsPageQuery(teamId: number | null, params: PageParams) {return useQuery({queryKey: qk.configuredToolPage(teamId ?? 0, params),- queryFn: () => api.listConfiguredTools(teamId!, params),+ queryFn: () => listConfiguredTools(teamId!, params),enabled: teamId != null,placeholderData: keepPreviousData,});@@ -29,7 +38,7 @@ export function useConfiguredToolsPageQuery(teamId: number | null, params: PagePexport function useCreateConfiguredTool(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewConfiguredToolInput) => api.createConfiguredTool(teamId, input),+ mutationFn: (input: NewConfiguredToolInput) => createConfiguredTool(teamId, input),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.configuredTools(teamId) });// The team list carries how many tools the team holds.@@ -41,7 +50,7 @@ export function useCreateConfiguredTool(teamId: number) {export function useDeleteConfiguredTool(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteConfiguredTool(teamId, id),+ mutationFn: (id: number) => deleteConfiguredTool(teamId, id),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.configuredTools(teamId) });void qc.invalidateQueries({ queryKey: qk.teams });@@ -53,7 +62,7 @@ export function useDeleteConfiguredTool(teamId: number) {export function useAgentToolLinksQuery(teamId: number | null, agentId: number | null) {return useQuery({queryKey: qk.agentToolLinks(teamId ?? 0, agentId ?? 0),- queryFn: () => api.listAgentToolLinks(teamId!, agentId!),+ queryFn: () => listAgentToolLinks(teamId!, agentId!),enabled: teamId != null && agentId != null,});}@@ -62,7 +71,7 @@ export function useSetAgentTools(teamId: number | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ agentId, agentToolIds }: { agentId: number; agentToolIds: number[] }) =>- api.setAgentTools(teamId!, agentId, agentToolIds),+ setAgentTools(teamId!, agentId, agentToolIds),onSuccess: (_data, { agentId }) => {if (teamId != null)void qc.invalidateQueries({ queryKey: qk.agentToolLinks(teamId, agentId) });diff --git a/apps/web/src/services/cycles.service.ts b/apps/web/src/services/cycles.service.tsindex 2f704127..24693729 100644--- a/apps/web/src/services/cycles.service.ts+++ b/apps/web/src/services/cycles.service.ts@@ -1,5 +1,20 @@import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, nextPageParam, type CyclePatch, type NewCycleInput } from '@/lib/api';+import {+ type CyclePatch,+ type NewCycleInput,+ listCycles,+ listPlannedCycles,+ listCycleOptions,+ listCompletedCycles,+ getCycle,+ createCycle,+ updateCycle,+ deleteCycle,+ finishCycle,+ startNextCycle,+ transferCycleIssues,+} from '@/lib/api/endpoints/cycles';+import { nextPageParam } from '@/lib/api/core/paging';import { qk } from '@/services/queryKeys';// How many finished cycles the archive loads at a time.@@ -22,7 +37,7 @@ function invalidateCycleIssues(qc: ReturnType<typeof useQueryClient>, projectKeyexport function useCyclesQuery(projectKey: string | null) {return useQuery({queryKey: qk.cycles(projectKey ?? ''),- queryFn: () => api.listCycles(projectKey!),+ queryFn: () => listCycles(projectKey!),enabled: projectKey != null,});}@@ -34,7 +49,7 @@ export function useCyclesQuery(projectKey: string | null) {export function usePlannedCyclesQuery(projectKey: string | null) {return useQuery({queryKey: qk.plannedCycles(projectKey ?? ''),- queryFn: () => api.listPlannedCycles(projectKey!),+ queryFn: () => listPlannedCycles(projectKey!),enabled: projectKey != null,});}@@ -44,7 +59,7 @@ export function usePlannedCyclesQuery(projectKey: string | null) {export function useCycleOptionsQuery(projectKey: string | null) {return useQuery({queryKey: qk.cycleOptions(projectKey ?? ''),- queryFn: () => api.listCycleOptions(projectKey!),+ queryFn: () => listCycleOptions(projectKey!),enabled: projectKey != null,});}@@ -54,7 +69,7 @@ export function useCompletedCyclesQuery(projectKey: string | null) {return useInfiniteQuery({queryKey: qk.completedCycles(projectKey ?? ''),queryFn: ({ pageParam }) =>- api.listCompletedCycles(projectKey!, { page: pageParam, pageSize: COMPLETED_CYCLES_PAGE }),+ listCompletedCycles(projectKey!, { page: pageParam, pageSize: COMPLETED_CYCLES_PAGE }),initialPageParam: 1,getNextPageParam: nextPageParam,enabled: projectKey != null,@@ -64,7 +79,7 @@ export function useCompletedCyclesQuery(projectKey: string | null) {export function useCycleQuery(cycleId: number | null) {return useQuery({queryKey: qk.cycle(cycleId ?? -1),- queryFn: () => api.getCycle(cycleId!),+ queryFn: () => getCycle(cycleId!),enabled: cycleId != null,});}@@ -72,7 +87,7 @@ export function useCycleQuery(cycleId: number | null) {export function useCreateCycle(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewCycleInput) => api.createCycle(projectKey, input),+ mutationFn: (input: NewCycleInput) => createCycle(projectKey, input),onSuccess: () => invalidateCycles(qc, projectKey),});}@@ -80,7 +95,7 @@ export function useCreateCycle(projectKey: string) {export function useUpdateCycle(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, patch }: { id: number; patch: CyclePatch }) => api.updateCycle(id, patch),+ mutationFn: ({ id, patch }: { id: number; patch: CyclePatch }) => updateCycle(id, patch),onSuccess: () => invalidateCycles(qc, projectKey),});}@@ -88,7 +103,7 @@ export function useUpdateCycle(projectKey: string) {export function useDeleteCycle(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteCycle(id),+ mutationFn: (id: number) => deleteCycle(id),onSuccess: () => {invalidateCycles(qc, projectKey);invalidateCycleIssues(qc, projectKey);@@ -101,7 +116,7 @@ export function useDeleteCycle(projectKey: string) {export function useFinishCycle(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.finishCycle(id),+ mutationFn: (id: number) => finishCycle(id),onSuccess: () => invalidateCycles(qc, projectKey),});}@@ -109,7 +124,7 @@ export function useFinishCycle(projectKey: string) {export function useStartNextCycle(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.startNextCycle(id),+ mutationFn: (id: number) => startNextCycle(id),onSuccess: () => {invalidateCycles(qc, projectKey);invalidateCycleIssues(qc, projectKey);@@ -121,7 +136,7 @@ export function useTransferCycleIssues(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, targetCycleId }: { id: number; targetCycleId: number | null }) =>- api.transferCycleIssues(id, targetCycleId),+ transferCycleIssues(id, targetCycleId),onSuccess: () => {invalidateCycles(qc, projectKey);invalidateCycleIssues(qc, projectKey);diff --git a/apps/web/src/services/dashboards.service.ts b/apps/web/src/services/dashboards.service.tsindex e6f0b6eb..b15d4b86 100644--- a/apps/web/src/services/dashboards.service.ts+++ b/apps/web/src/services/dashboards.service.ts@@ -1,12 +1,19 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type Dashboard } from '@/lib/api';+import {+ type Dashboard,+ listDashboards,+ createDashboard,+ updateDashboard,+ deleteDashboard,+ reorderDashboards,+} from '@/lib/api/endpoints/dashboards';import { useOptimisticReorder } from '@/services/optimisticReorder';import { qk } from '@/services/queryKeys';export function useDashboardsQuery(projectKey: string | null) {return useQuery({queryKey: qk.dashboards(projectKey ?? ''),- queryFn: () => api.listDashboards(projectKey!),+ queryFn: () => listDashboards(projectKey!),enabled: projectKey != null,});}@@ -14,8 +21,8 @@ export function useDashboardsQuery(projectKey: string | null) {export function useCreateDashboard(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ input }: { input: Parameters<typeof api.createDashboard>[1] }) =>- api.createDashboard(projectKey!, input),+ mutationFn: ({ input }: { input: Parameters<typeof createDashboard>[1] }) =>+ createDashboard(projectKey!, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.dashboards(projectKey) });},@@ -25,8 +32,8 @@ export function useCreateDashboard(projectKey: string | null) {export function useUpdateDashboard(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, input }: { id: number; input: Parameters<typeof api.updateDashboard>[1] }) =>- api.updateDashboard(id, input),+ mutationFn: ({ id, input }: { id: number; input: Parameters<typeof updateDashboard>[1] }) =>+ updateDashboard(id, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.dashboards(projectKey) });},@@ -36,7 +43,7 @@ export function useUpdateDashboard(projectKey: string | null) {export function useDeleteDashboard(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteDashboard(id),+ mutationFn: (id: number) => deleteDashboard(id),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.dashboards(projectKey) });},@@ -46,6 +53,6 @@ export function useDeleteDashboard(projectKey: string | null) {export function useReorderDashboards(projectKey: string | null) {return useOptimisticReorder<Dashboard>(projectKey ? qk.dashboards(projectKey) : null,- (orderedIds) => api.reorderDashboards(projectKey!, orderedIds),+ (orderedIds) => reorderDashboards(projectKey!, orderedIds),);}diff --git a/apps/web/src/services/hotkeys.service.ts b/apps/web/src/services/hotkeys.service.tsindex 64f29a32..dcfb788d 100644--- a/apps/web/src/services/hotkeys.service.ts+++ b/apps/web/src/services/hotkeys.service.ts@@ -1,5 +1,6 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type HotkeyOverrides } from '@/lib/api';+import { type HotkeyOverrides, getHotkeySettings } from '@/lib/api/endpoints/settings';+import { getInstanceHotkeySettings, updateInstanceHotkeySettings } from '@/lib/api/endpoints/god';import { useSession } from '@/lib/auth-client';import { qk } from '@/services/queryKeys';@@ -10,7 +11,7 @@ export function useHotkeySettingsQuery() {const { data: session } = useSession();return useQuery({queryKey: qk.hotkeySettings,- queryFn: () => api.getHotkeySettings(),+ queryFn: () => getHotkeySettings(),// The route needs a session; the login and invite screens have none.enabled: Boolean(session),// Rarely change and are read on every screen, so keep them out of the refetch path.@@ -21,14 +22,14 @@ export function useHotkeySettingsQuery() {export function useInstanceHotkeySettingsQuery() {return useQuery({queryKey: qk.instanceHotkeySettings,- queryFn: () => api.getInstanceHotkeySettings(),+ queryFn: () => getInstanceHotkeySettings(),});}export function useUpdateInstanceHotkeySettings() {const qc = useQueryClient();return useMutation({- mutationFn: (combos: HotkeyOverrides) => api.updateInstanceHotkeySettings(combos),+ mutationFn: (combos: HotkeyOverrides) => updateInstanceHotkeySettings(combos),onSuccess: (data) => {qc.setQueryData(qk.instanceHotkeySettings, data);// Every client resolves its bindings from this map, including this one.diff --git a/apps/web/src/services/initiatives.service.ts b/apps/web/src/services/initiatives.service.tsindex 6974c822..f97e87e3 100644--- a/apps/web/src/services/initiatives.service.ts+++ b/apps/web/src/services/initiatives.service.ts@@ -5,13 +5,20 @@ import {useQuery,useQueryClient,} from '@tanstack/react-query';+import type { FeedCursor } from '@/lib/api/endpoints/activity';import {- api,- type FeedCursor,type InitiativeListParams,type InitiativePatch,type NewInitiativeInput,-} from '@/lib/api';+ listInitiatives,+ listInitiativeOptions,+ initiativeCounts,+ getInitiative,+ createInitiative,+ updateInitiative,+ deleteInitiative,+ listInitiativeFeed,+} from '@/lib/api/endpoints/initiatives';import { qk } from '@/services/queryKeys';// A page of the project's initiatives. params filter (status/search), sort and@@ -20,7 +27,7 @@ import { qk } from '@/services/queryKeys';export function useInitiativesQuery(projectKey: string | null, params: InitiativeListParams) {return useQuery({queryKey: qk.initiatives(projectKey ?? '', params),- queryFn: () => api.listInitiatives(projectKey!, params),+ queryFn: () => listInitiatives(projectKey!, params),enabled: projectKey != null,placeholderData: keepPreviousData,});@@ -35,7 +42,7 @@ export function useInitiativeOptionsQuery() {return useQuery({queryKey: qk.initiativeOptions(projectKey ?? '', params),- queryFn: () => api.listInitiativeOptions(projectKey!, params),+ queryFn: () => listInitiativeOptions(projectKey!, params),enabled: projectKey != null,placeholderData: keepPreviousData,});@@ -45,7 +52,7 @@ export function useInitiativeOptionsQuery(export function useInitiativeCountsQuery(projectKey: string | null) {return useQuery({queryKey: qk.initiativeCounts(projectKey ?? ''),- queryFn: () => api.initiativeCounts(projectKey!),+ queryFn: () => initiativeCounts(projectKey!),enabled: projectKey != null,});}@@ -53,7 +60,7 @@ export function useInitiativeCountsQuery(projectKey: string | null) {export function useInitiativeQuery(id: number | null) {return useQuery({queryKey: qk.initiative(id ?? 0),- queryFn: () => api.getInitiative(id!),+ queryFn: () => getInitiative(id!),enabled: id != null,});}@@ -61,7 +68,7 @@ export function useInitiativeQuery(id: number | null) {export function useCreateInitiative(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewInitiativeInput) => api.createInitiative(projectKey, input),+ mutationFn: (input: NewInitiativeInput) => createInitiative(projectKey, input),onSuccess: () => {qc.invalidateQueries({ queryKey: qk.initiativesForProject(projectKey) });qc.invalidateQueries({ queryKey: qk.initiativeCounts(projectKey) });@@ -74,7 +81,7 @@ export function useUpdateInitiative(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, patch }: { id: number; patch: InitiativePatch }) =>- api.updateInitiative(id, patch),+ updateInitiative(id, patch),onSuccess: (_data, { id }) => {qc.invalidateQueries({ queryKey: qk.initiativesForProject(projectKey) });qc.invalidateQueries({ queryKey: qk.initiativeCounts(projectKey) });@@ -88,7 +95,7 @@ export function useUpdateInitiative(projectKey: string) {export function useDeleteInitiative(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteInitiative(id),+ mutationFn: (id: number) => deleteInitiative(id),onSuccess: (_data, id) => {qc.invalidateQueries({ queryKey: qk.initiativesForProject(projectKey) });qc.invalidateQueries({ queryKey: qk.initiativeCounts(projectKey) });@@ -107,7 +114,7 @@ export function useDeleteInitiative(projectKey: string) {export function useInitiativeFeedQuery(id: number | null) {return useInfiniteQuery({queryKey: qk.initiativeFeed(id ?? 0),- queryFn: ({ pageParam }) => api.listInitiativeFeed(id!, { cursor: pageParam, limit: 25 }),+ queryFn: ({ pageParam }) => listInitiativeFeed(id!, { cursor: pageParam, limit: 25 }),initialPageParam: null as FeedCursor | null,getNextPageParam: (last) => last.nextCursor,enabled: id != null,diff --git a/apps/web/src/services/integrations.service.ts b/apps/web/src/services/integrations.service.tsindex 9495c38e..796779cc 100644--- a/apps/web/src/services/integrations.service.ts+++ b/apps/web/src/services/integrations.service.ts@@ -1,11 +1,17 @@import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import {- api,type CredentialPatch,type IntegrationKind,type NewCredentialInput,- type PageParams,-} from '@/lib/api';+ listCredentials,+ listIntegrationOptions,+ listIntegrationCatalog,+ listIntegrationModels,+ createCredential,+ updateCredential,+ deleteCredential,+} from '@/lib/api/endpoints/integrations';+import type { PageParams } from '@/lib/api/core/paging';import { qk } from '@/services/queryKeys';// One page of the team's stored credentials, secrets redacted. Backs the team's@@ -13,7 +19,7 @@ import { qk } from '@/services/queryKeys';export function useCredentialsPageQuery(teamId: number, params: PageParams) {return useQuery({queryKey: qk.teamCredentialPage(teamId, params),- queryFn: () => api.listCredentials(teamId, params),+ queryFn: () => listCredentials(teamId, params),placeholderData: keepPreviousData,});}@@ -23,7 +29,7 @@ export function useCredentialsPageQuery(teamId: number, params: PageParams) {export function useIntegrationOptionsQuery(teamId: number | null, kind?: IntegrationKind) {return useQuery({queryKey: qk.integrationOptions(teamId ?? 0, kind),- queryFn: () => api.listIntegrationOptions(teamId!, kind),+ queryFn: () => listIntegrationOptions(teamId!, kind),enabled: teamId != null,});}@@ -33,7 +39,7 @@ export function useIntegrationOptionsQuery(teamId: number | null, kind?: Integraexport function useIntegrationCatalogQuery(teamId: number | null) {return useQuery({queryKey: qk.integrationCatalog(teamId ?? 0),- queryFn: () => api.listIntegrationCatalog(teamId!),+ queryFn: () => listIntegrationCatalog(teamId!),enabled: teamId != null,staleTime: Infinity,});@@ -44,7 +50,7 @@ export function useIntegrationCatalogQuery(teamId: number | null) {export function useIntegrationModelsQuery(teamId: number | null, provider: string | null) {return useQuery({queryKey: qk.integrationModels(teamId ?? 0, provider ?? ''),- queryFn: () => api.listIntegrationModels(teamId!, provider!),+ queryFn: () => listIntegrationModels(teamId!, provider!),enabled: teamId != null && provider != null && provider.length > 0,staleTime: Infinity,});@@ -53,7 +59,7 @@ export function useIntegrationModelsQuery(teamId: number | null, provider: strinexport function useCreateCredential(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NewCredentialInput) => api.createCredential(teamId, input),+ mutationFn: (input: NewCredentialInput) => createCredential(teamId, input),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.integrations });// The team list carries how many credentials the team holds.@@ -66,7 +72,7 @@ export function useUpdateCredential(teamId: number) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, patch }: { id: number; patch: CredentialPatch }) =>- api.updateCredential(teamId, id, patch),+ updateCredential(teamId, id, patch),onSuccess: () => void qc.invalidateQueries({ queryKey: qk.integrations }),});}@@ -74,7 +80,7 @@ export function useUpdateCredential(teamId: number) {export function useDeleteCredential(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteCredential(teamId, id),+ mutationFn: (id: number) => deleteCredential(teamId, id),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.integrations });// The team list carries how many credentials the team holds.diff --git a/apps/web/src/services/issues.service.ts b/apps/web/src/services/issues.service.tsindex 579983fc..ba99eb64 100644--- a/apps/web/src/services/issues.service.ts+++ b/apps/web/src/services/issues.service.ts@@ -6,7 +6,14 @@ import {useQueryClient,} from '@tanstack/react-query';import {- api,+ removeIssueDevelopmentLink,+ listIssueDevelopmentRepositories,+ listLinkablePullRequests,+ listDevelopmentBranches,+ linkIssueDevelopment,+ createIssuePullRequest,+} from '@/lib/api/endpoints/git';+import {type BulkIssuePatch,type IssueFieldValueEntry,type IssueFieldValueInput,@@ -15,7 +22,21 @@ import {type BoardIssue,type BoardIssues,type SubtaskDisposition,-} from '@/lib/api';+ getIssue,+ listIssueCycles,+ getIssueBySeq,+ searchIssues,+ updateIssue,+ deleteIssue,+ archiveIssue,+ restoreIssue,+ setFieldValue,+ bulkUpdateIssues,+ bulkAddLabels,+ bulkArchiveIssues,+ bulkDeleteIssues,+ createIssue,+} from '@/lib/api/endpoints/issues';import { qk } from '@/services/queryKeys';// Deleting or archiving one issue. `subtasks` says what happens to the subtasks@@ -34,7 +55,7 @@ interface BulkRemoval {export function useIssueQuery(id: number | null) {return useQuery({queryKey: qk.issue(id ?? -1),- queryFn: () => api.getIssue(id!),+ queryFn: () => getIssue(id!),enabled: id != null,});}@@ -42,7 +63,7 @@ export function useIssueQuery(id: number | null) {export function useRemoveIssueDevelopmentLink(issueId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (linkId: number) => api.removeIssueDevelopmentLink(issueId, linkId),+ mutationFn: (linkId: number) => removeIssueDevelopmentLink(issueId, linkId),onSuccess: () => qc.invalidateQueries({ queryKey: qk.issue(issueId) }),});}@@ -50,7 +71,7 @@ export function useRemoveIssueDevelopmentLink(issueId: number) {export function useIssueDevelopmentRepositoriesQuery(issueId: number, enabled: boolean) {return useQuery({queryKey: qk.issueDevelopmentRepositories(issueId),- queryFn: () => api.listIssueDevelopmentRepositories(issueId),+ queryFn: () => listIssueDevelopmentRepositories(issueId),enabled,});}@@ -64,7 +85,7 @@ export function useLinkablePullRequestsQuery(return useInfiniteQuery({queryKey: qk.issueDevelopmentPullRequests(issueId, repositoryId ?? -1, state),queryFn: ({ pageParam }) =>- api.listLinkablePullRequests(issueId, repositoryId!, { state, page: pageParam }),+ listLinkablePullRequests(issueId, repositoryId!, { state, page: pageParam }),initialPageParam: 1,getNextPageParam: (page) => page.nextPage ?? undefined,enabled: enabled && repositoryId !== null,@@ -78,7 +99,7 @@ export function useDevelopmentBranchesQuery() {return useInfiniteQuery({queryKey: qk.issueDevelopmentBranches(issueId, repositoryId ?? -1),- queryFn: ({ pageParam }) => api.listDevelopmentBranches(issueId, repositoryId!, pageParam),+ queryFn: ({ pageParam }) => listDevelopmentBranches(issueId, repositoryId!, pageParam),initialPageParam: 1,getNextPageParam: (page) => page.nextPage ?? undefined,enabled: enabled && repositoryId !== null,@@ -89,7 +110,7 @@ export function useLinkIssueDevelopment(issueId: number) {const qc = useQueryClient();return useMutation({mutationFn: (input: { repositoryId: number; number: number }) =>- api.linkIssueDevelopment(issueId, input),+ linkIssueDevelopment(issueId, input),onSuccess: () => qc.invalidateQueries({ queryKey: qk.issue(issueId) }),});}@@ -97,8 +118,8 @@ export function useLinkIssueDevelopment(issueId: number) {export function useCreateIssuePullRequest(issueId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (input: Parameters<typeof api.createIssuePullRequest>[1]) =>- api.createIssuePullRequest(issueId, input),+ mutationFn: (input: Parameters<typeof createIssuePullRequest>[1]) =>+ createIssuePullRequest(issueId, input),onSuccess: () => qc.invalidateQueries({ queryKey: qk.issue(issueId) }),});}@@ -107,7 +128,7 @@ export function useCreateIssuePullRequest(issueId: number) {export function useIssueCyclesQuery(issueId: number) {return useQuery({queryKey: qk.issueCycles(issueId),- queryFn: () => api.listIssueCycles(issueId),+ queryFn: () => listIssueCycles(issueId),});}@@ -119,7 +140,7 @@ export function useIssueBySeqQuery(projectKey: string | null, seq: number | nullreturn useQuery({queryKey: qk.issueBySeq(projectKey ?? '', seq ?? -1),queryFn: async () => {- const issue = await api.getIssueBySeq(projectKey!, seq!);+ const issue = await getIssueBySeq(projectKey!, seq!);qc.setQueryData(qk.issue(issue.id), issue);return issue;},@@ -139,7 +160,7 @@ export function useIssueSearchQuery(const term = q.trim();return useQuery({queryKey: qk.issueSearch(projectKey ?? '', term),- queryFn: () => api.searchIssues(projectKey!, { q: term, limit: 50 }),+ queryFn: () => searchIssues(projectKey!, { q: term, limit: 50 }),enabled: opts.enabled && projectKey != null && term.length > 0,placeholderData: keepPreviousData,});@@ -152,7 +173,7 @@ export function useIssueSearchQuery(export function useUpdateIssue(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, patch }: { id: number; patch: IssuePatch }) => api.updateIssue(id, patch),+ mutationFn: ({ id, patch }: { id: number; patch: IssuePatch }) => updateIssue(id, patch),onMutate: async ({ id, patch }) => {if (!projectKey) return {};const key = qk.boardIssues(projectKey);@@ -195,7 +216,7 @@ function invalidateGroupings(qc: ReturnType<typeof useQueryClient>) {export function useDeleteIssue(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, subtasks }: IssueRemoval) => api.deleteIssue(id, subtasks),+ mutationFn: ({ id, subtasks }: IssueRemoval) => deleteIssue(id, subtasks),onSuccess: async (_data, { id }) => {if (projectKey) {// Cancel any project fetch already in flight before removing the issue@@ -223,7 +244,7 @@ export function useDeleteIssue(projectKey: string | null) {export function useArchiveIssue(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, subtasks }: IssueRemoval) => api.archiveIssue(id, subtasks),+ mutationFn: ({ id, subtasks }: IssueRemoval) => archiveIssue(id, subtasks),onSuccess: async (_data, { id }) => {if (projectKey) {await qc.cancelQueries({ queryKey: qk.boardIssues(projectKey) });@@ -245,7 +266,7 @@ export function useArchiveIssue(projectKey: string | null) {export function useRestoreIssue(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.restoreIssue(id),+ mutationFn: (id: number) => restoreIssue(id),onSuccess: (_data, id) => {if (projectKey) {void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });@@ -289,7 +310,7 @@ export function useSetFieldValue(projectKey: string | null) {issueId: number;fieldId: number;value: IssueFieldValueInput;- }) => api.setFieldValue(issueId, fieldId, value),+ }) => setFieldValue(issueId, fieldId, value),onMutate: async ({ issueId, fieldId, value }) => {if (!projectKey) return {};const key = qk.boardIssues(projectKey);@@ -328,7 +349,7 @@ export function useBulkUpdateIssues(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: ({ ids, patch }: { ids: number[]; patch: BulkIssuePatch }) =>- api.bulkUpdateIssues(projectKey, ids, patch),+ bulkUpdateIssues(projectKey, ids, patch),onMutate: async ({ ids, patch }) => {const key = qk.boardIssues(projectKey);await qc.cancelQueries({ queryKey: key });@@ -358,7 +379,7 @@ export function useBulkAddLabels(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: ({ ids, add }: { ids: number[]; add: number[] }) =>- api.bulkAddLabels(projectKey, ids, add),+ bulkAddLabels(projectKey, ids, add),onMutate: async ({ ids, add }) => {const key = qk.boardIssues(projectKey);await qc.cancelQueries({ queryKey: key });@@ -413,21 +434,19 @@ function useBulkRemoval(export function useBulkArchiveIssues(projectKey: string) {return useBulkRemoval(projectKey, (ids, subtasks) =>- api.bulkArchiveIssues(projectKey, ids, subtasks),+ bulkArchiveIssues(projectKey, ids, subtasks),);}export function useBulkDeleteIssues(projectKey: string) {- return useBulkRemoval(projectKey, (ids, subtasks) =>- api.bulkDeleteIssues(projectKey, ids, subtasks),- );+ return useBulkRemoval(projectKey, (ids, subtasks) => bulkDeleteIssues(projectKey, ids, subtasks));}export function useCreateIssue() {const qc = useQueryClient();return useMutation({mutationFn: ({ projectKey, input }: { projectKey: string; input: NewIssueInput }) =>- api.createIssue(projectKey, input),+ createIssue(projectKey, input),onSuccess: (_data, { projectKey }) => {void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });invalidateGroupings(qc);diff --git a/apps/web/src/services/members.service.ts b/apps/web/src/services/members.service.tsindex f4076ada..9ead2b95 100644--- a/apps/web/src/services/members.service.ts+++ b/apps/web/src/services/members.service.ts@@ -1,7 +1,22 @@import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { api, type MemberListParams, type MemberRole } from '@/lib/api';+import {+ listInvites,+ createInvite,+ sendInviteEmail,+ deleteInvite,+} from '@/lib/api/endpoints/invites';+import {+ type MemberListParams,+ type MemberRole,+ listMembers,+ listMemberCandidates,+ addMember,+ removeMember,+ setMemberRole,+ setMemberDescription,+} from '@/lib/api/endpoints/members';import { qk } from '@/services/queryKeys';// One page of the project's members. The window runs on the server, so the page@@ -10,7 +25,7 @@ import { qk } from '@/services/queryKeys';export function useMembersQuery(projectKey: string | null, params: MemberListParams) {return useQuery({queryKey: qk.memberPage(projectKey ?? '', params),- queryFn: () => api.listMembers(projectKey!, params),+ queryFn: () => listMembers(projectKey!, params),enabled: projectKey != null,placeholderData: keepPreviousData,});@@ -21,7 +36,7 @@ export function useMembersQuery(projectKey: string | null, params: MemberListParexport function useMemberCandidatesQuery(projectKey: string, enabled = true) {return useQuery({queryKey: qk.memberCandidates(projectKey),- queryFn: () => api.listMemberCandidates(projectKey),+ queryFn: () => listMemberCandidates(projectKey),enabled,});}@@ -33,7 +48,7 @@ export function useAddMember(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: (input: { userId: string; role: MemberRole; roleId?: number | null }) =>- api.addMember(projectKey, input),+ addMember(projectKey, input),onSuccess: () => {qc.invalidateQueries({ queryKey: qk.members(projectKey) });qc.invalidateQueries({ queryKey: qk.anyTeam });@@ -48,7 +63,7 @@ export function useAddMember(projectKey: string) {export function useRemoveMember(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (userId: string) => api.removeMember(projectKey, userId),+ mutationFn: (userId: string) => removeMember(projectKey, userId),onSuccess: () => {qc.invalidateQueries({ queryKey: qk.members(projectKey) });qc.invalidateQueries({ queryKey: qk.anyTeam });@@ -70,7 +85,7 @@ export function useSetMemberRole(projectKey: string) {userId: string;role: MemberRole;roleId?: number | null;- }) => api.setMemberRole(projectKey, userId, { role, roleId }),+ }) => setMemberRole(projectKey, userId, { role, roleId }),onSuccess: (_data, { role }) => {qc.invalidateQueries({ queryKey: qk.members(projectKey) });qc.invalidateQueries({ queryKey: qk.anyTeam });@@ -85,7 +100,7 @@ export function useSetMemberDescription(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: ({ userId, description }: { userId: string; description: string }) =>- api.setMemberDescription(projectKey, userId, description),+ setMemberDescription(projectKey, userId, description),onSuccess: () => {qc.invalidateQueries({ queryKey: qk.members(projectKey) });qc.invalidateQueries({ queryKey: qk.anyTeam });@@ -99,7 +114,7 @@ export function useSetMemberDescription(projectKey: string) {export function useInvitesQuery(projectKey: string | null, enabled = true) {return useQuery({queryKey: qk.invites(projectKey ?? ''),- queryFn: () => api.listInvites(projectKey!),+ queryFn: () => listInvites(projectKey!),enabled: projectKey != null && enabled,});}@@ -109,7 +124,7 @@ export function useCreateInvite(projectKey: string) {const qc = useQueryClient();return useMutation({mutationFn: (input: { email: string; role: MemberRole; roleId?: number | null }) =>- api.createInvite(projectKey, input),+ createInvite(projectKey, input),onSuccess: (result) => {qc.invalidateQueries({ queryKey: qk.invites(projectKey) });if (result.emailQueued) toast.success(t('emailQueued'));@@ -123,7 +138,7 @@ export function useCreateInvite(projectKey: string) {export function useSendInviteEmail(projectKey: string) {const t = useTranslations('members.invites');return useMutation({- mutationFn: (inviteId: number) => api.sendInviteEmail(projectKey, inviteId),+ mutationFn: (inviteId: number) => sendInviteEmail(projectKey, inviteId),onSuccess: (result) => {if (result.emailQueued) toast.success(t('emailQueued'));else toast.info(t('resendUnavailable'));@@ -134,7 +149,7 @@ export function useSendInviteEmail(projectKey: string) {export function useDeleteInvite(projectKey: string) {const qc = useQueryClient();return useMutation({- mutationFn: (inviteId: number) => api.deleteInvite(projectKey, inviteId),+ mutationFn: (inviteId: number) => deleteInvite(projectKey, inviteId),onSuccess: () => qc.invalidateQueries({ queryKey: qk.invites(projectKey) }),});}diff --git a/apps/web/src/services/preferences.service.ts b/apps/web/src/services/preferences.service.tsindex 0e68963d..877896ea 100644--- a/apps/web/src/services/preferences.service.ts+++ b/apps/web/src/services/preferences.service.ts@@ -1,7 +1,12 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import { useLocale } from 'next-intl';import type { Locale } from '@/i18n/locales';-import { api, type AccountPreferences, type AccountPreferencesPatch } from '@/lib/api';+import {+ type AccountPreferences,+ type AccountPreferencesPatch,+ getAccountPreferences,+ updateAccountPreferences,+} from '@/lib/api/endpoints/userPreferences';import { useSession } from '@/lib/auth-client';import { qk } from '@/services/queryKeys';@@ -30,7 +35,7 @@ export function useAccountPreferencesQuery() {const locale = useLocale() as Locale;return useQuery({queryKey: qk.accountPreferences,- queryFn: () => api.getAccountPreferences(locale),+ queryFn: () => getAccountPreferences(locale),// The route needs a session; the login and invite screens have none.enabled: Boolean(session),// Rarely change and are read on every screen, so keep them out of the refetch path.@@ -48,7 +53,7 @@ export function useUpdateAccountPreferences() {const qc = useQueryClient();const locale = useLocale() as Locale;return useMutation({- mutationFn: (input: AccountPreferencesPatch) => api.updateAccountPreferences(input, locale),+ mutationFn: (input: AccountPreferencesPatch) => updateAccountPreferences(input, locale),// Merge into the cache before the request completes: a second change made while// the first is still in flight is then built on the new value, not the stored// one, and the app (theme, timezone) reacts immediately.diff --git a/apps/web/src/services/projects.service.ts b/apps/web/src/services/projects.service.tsindex 259b695c..3bbee829 100644--- a/apps/web/src/services/projects.service.ts+++ b/apps/web/src/services/projects.service.ts@@ -1,9 +1,24 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type Project, type CopyProjectIncludeKey } from '@/lib/api';+import { removeMember } from '@/lib/api/endpoints/members';+import {+ type CopyProjectIncludeKey,+ createTeamProject,+ copyTeamProject,+ updateTeamProject,+ deleteTeamProject,+} from '@/lib/api/endpoints/teams';+import {+ type Project,+ listProjects,+ getProject,+ getBoardIssues,+ createProject,+ updateProject,+} from '@/lib/api/endpoints/projects';import { qk } from '@/services/queryKeys';export function useProjectsQuery() {- return useQuery({ queryKey: qk.projects, queryFn: () => api.listProjects() });+ return useQuery({ queryKey: qk.projects, queryFn: () => listProjects() });}// The board scaffold (columns, types, labels, custom fields, viewer). The issues@@ -11,7 +26,7 @@ export function useProjectsQuery() {export function useProjectQuery(projectKey: string | null) {return useQuery({queryKey: qk.project(projectKey ?? ''),- queryFn: () => api.getProject(projectKey!),+ queryFn: () => getProject(projectKey!),enabled: projectKey != null,});}@@ -20,7 +35,7 @@ export function useProjectQuery(projectKey: string | null) {export function useBoardIssuesQuery(projectKey: string | null) {return useQuery({queryKey: qk.boardIssues(projectKey ?? ''),- queryFn: () => api.getBoardIssues(projectKey!),+ queryFn: () => getBoardIssues(projectKey!),enabled: projectKey != null,});}@@ -65,10 +80,10 @@ export function useCreateProject() {preset?: string;};}) => {- if (teamId == null) return api.createProject(input);+ if (teamId == null) return createProject(input);return copyFromId == null- ? api.createTeamProject(teamId, input)- : api.copyTeamProject(teamId, copyFromId, input);+ ? createTeamProject(teamId, input)+ : copyTeamProject(teamId, copyFromId, input);},onSuccess: (project) => {// Add the new project to the cached list immediately so navigating to it@@ -92,7 +107,7 @@ export function useUpdateProject() {}: {projectKey: string;patch: { name?: string; description?: string };- }) => api.updateProject(projectKey, patch),+ }) => updateProject(projectKey, patch),onSuccess: (updated, { projectKey }) => {// Reflect the new name/description in the cached list immediately, then// refetch the list and the project detail (its header and switcher read@@ -124,7 +139,7 @@ export function useUpdateTeamProject() {projectId: number;projectKey: string;patch: { name?: string; description?: string };- }) => api.updateTeamProject(teamId, projectId, patch),+ }) => updateTeamProject(teamId, projectId, patch),onSuccess: (updated, { teamId, projectKey }) => {qc.setQueryData<Project[]>(qk.projects, (prev) =>prev?.map((p) =>@@ -157,7 +172,7 @@ export function useLeaveProject() {const qc = useQueryClient();return useMutation({mutationFn: ({ projectKey, userId }: { projectKey: string; userId: string }) =>- api.removeMember(projectKey, userId),+ removeMember(projectKey, userId),onSuccess: (_data, { projectKey }) => {forgetProject(qc, projectKey);// The team panel counts the members of each project it lists and names them.@@ -178,7 +193,7 @@ export function useDeleteTeamProject() {teamId: number;projectId: number;projectKey: string;- }) => api.deleteTeamProject(teamId, projectId),+ }) => deleteTeamProject(teamId, projectId),onSuccess: (_data, { teamId, projectKey }) => {forgetProject(qc, projectKey);void qc.invalidateQueries({ queryKey: qk.team(teamId) });diff --git a/apps/web/src/services/roles.service.ts b/apps/web/src/services/roles.service.tsindex 9691decf..ec58d351 100644--- a/apps/web/src/services/roles.service.ts+++ b/apps/web/src/services/roles.service.ts@@ -1,5 +1,15 @@import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type Permissions, type RoleListParams } from '@/lib/api';+import {+ type Permissions,+ type RoleListParams,+ getPermissionCatalog,+ listTeamRoles,+ listTeamRoleOptions,+ getRoleUsage,+ createRole,+ updateRole,+ deleteRole,+} from '@/lib/api/endpoints/roles';import { qk } from '@/services/queryKeys';// The resources and actions of the permission matrix. Static for the app's@@ -7,7 +17,7 @@ import { qk } from '@/services/queryKeys';export function usePermissionCatalogQuery() {return useQuery({queryKey: qk.permissionCatalog,- queryFn: () => api.getPermissionCatalog(),+ queryFn: () => getPermissionCatalog(),staleTime: Infinity,});}@@ -17,7 +27,7 @@ export function usePermissionCatalogQuery() {export function useTeamRolesQuery(teamId: number | null, params: RoleListParams) {return useQuery({queryKey: qk.teamRoles(teamId ?? 0, params),- queryFn: () => api.listTeamRoles(teamId!, params),+ queryFn: () => listTeamRoles(teamId!, params),enabled: teamId != null,placeholderData: keepPreviousData,});@@ -28,7 +38,7 @@ export function useTeamRolesQuery(teamId: number | null, params: RoleListParams)export function useTeamRoleOptionsQuery(teamId: number | null) {return useQuery({queryKey: qk.teamRoleOptions(teamId ?? 0),- queryFn: () => api.listTeamRoleOptions(teamId!),+ queryFn: () => listTeamRoleOptions(teamId!),enabled: teamId != null,});}@@ -38,7 +48,7 @@ export function useTeamRoleOptionsQuery(teamId: number | null) {export function useRoleUsageQuery(teamId: number, roleId: number) {return useQuery({queryKey: qk.roleUsage(teamId, roleId),- queryFn: () => api.getRoleUsage(teamId, roleId),+ queryFn: () => getRoleUsage(teamId, roleId),});}@@ -66,7 +76,7 @@ function useRoleMutation<TInput, TResult>(export function useCreateRole(teamId: number) {return useRoleMutation(teamId, (input: { name: string; permissions: Permissions }) =>- api.createRole(teamId, input),+ createRole(teamId, input),);}@@ -74,7 +84,7 @@ export function useUpdateRole(teamId: number) {return useRoleMutation(teamId,({ roleId, patch }: { roleId: number; patch: { name?: string; permissions?: Permissions } }) =>- api.updateRole(teamId, roleId, patch),+ updateRole(teamId, roleId, patch),);}@@ -84,6 +94,6 @@ export function useDeleteRole(teamId: number) {return useRoleMutation(teamId,({ roleId, targetRoleId }: { roleId: number; targetRoleId?: number }) =>- api.deleteRole(teamId, roleId, targetRoleId),+ deleteRole(teamId, roleId, targetRoleId),);}diff --git a/apps/web/src/services/storage.service.ts b/apps/web/src/services/storage.service.tsindex ce98e6a0..fbabc8eb 100644--- a/apps/web/src/services/storage.service.ts+++ b/apps/web/src/services/storage.service.ts@@ -1,7 +1,7 @@'use client';import { useQuery } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getStorageSettings } from '@/lib/api/endpoints/settings';import { qk } from '@/services/queryKeys';// The instance upload limits, read wherever a file can be picked (issue@@ -11,7 +11,7 @@ import { qk } from '@/services/queryKeys';export function useStorageSettingsQuery() {return useQuery({queryKey: qk.storageSettings,- queryFn: () => api.getStorageSettings(),+ queryFn: () => getStorageSettings(),staleTime: 5 * 60_000,});}diff --git a/apps/web/src/services/teams.service.ts b/apps/web/src/services/teams.service.tsindex 3f3a064e..4386027f 100644--- a/apps/web/src/services/teams.service.ts+++ b/apps/web/src/services/teams.service.ts@@ -6,21 +6,41 @@ import {useQueryClient,} from '@tanstack/react-query';import {- api,- nextPageParam,type InviteTeamRole,- type MemberKind,- type MemberListParams,- type NotificationSettingsPatch,+ listTeamInvites,+ createTeamInvite,+ deleteTeamInvite,+} from '@/lib/api/endpoints/invites';+import type { MemberKind, MemberListParams } from '@/lib/api/endpoints/members';+import {type TeamProjectListParams,type Team,type TeamRole,-} from '@/lib/api';+ listTeams,+ getTeam,+ listTeamMembers,+ listTeamProjects,+ listTeamProjectOptions,+ getTeamProject,+ listTeamProjectMembers,+ updateTeamMcp,+ createTeam,+ renameTeam,+ setTeamMemberRole,+ removeTeamMember,+ leaveTeam,+} from '@/lib/api/endpoints/teams';+import { nextPageParam } from '@/lib/api/core/paging';+import {+ type NotificationSettingsPatch,+ getNotificationSettings,+ setNotificationSettings,+} from '@/lib/api/endpoints/notificationSettings';import { DEFAULT_PAGE_SIZE } from '@/hooks/usePaging';import { qk } from '@/services/queryKeys';export function useTeamsQuery() {- return useQuery({ queryKey: qk.teams, queryFn: () => api.listTeams() });+ return useQuery({ queryKey: qk.teams, queryFn: () => listTeams() });}// The team a page is on, out of the list its rail already reads: its name, the@@ -33,7 +53,7 @@ export function useTeam(teamId: number): Team | null {// What the caller may do with the resources the team holds. Read on its own because// resolving it for a plain member costs a query per team, which the list avoids.export function useTeamQuery(teamId: number) {- return useQuery({ queryKey: qk.team(teamId), queryFn: () => api.getTeam(teamId) });+ return useQuery({ queryKey: qk.team(teamId), queryFn: () => getTeam(teamId) });}// One page of a team's members. The search and the window run on the server, so the@@ -42,7 +62,7 @@ export function useTeamQuery(teamId: number) {export function useTeamMembersQuery(teamId: number, params: MemberListParams) {return useQuery({queryKey: qk.teamMembers(teamId, params),- queryFn: () => api.listTeamMembers(teamId, params),+ queryFn: () => listTeamMembers(teamId, params),placeholderData: keepPreviousData,});}@@ -53,7 +73,7 @@ export function useTeamMembersQuery(teamId: number, params: MemberListParams) {export function useTeamProjectsQuery(teamId: number, params: TeamProjectListParams) {return useQuery({queryKey: qk.teamProjects(teamId, params),- queryFn: () => api.listTeamProjects(teamId, params),+ queryFn: () => listTeamProjects(teamId, params),placeholderData: keepPreviousData,});}@@ -63,7 +83,7 @@ export function useTeamProjectsQuery(teamId: number, params: TeamProjectListParaexport function useTeamProjectOptionsQuery(teamId: number) {return useQuery({queryKey: qk.teamProjectOptions(teamId),- queryFn: () => api.listTeamProjectOptions(teamId),+ queryFn: () => listTeamProjectOptions(teamId),});}@@ -72,7 +92,7 @@ export function useTeamProjectOptionsQuery(teamId: number) {export function useTeamProjectQuery(teamId: number, projectId: number) {return useQuery({queryKey: qk.teamProject(teamId, projectId),- queryFn: () => api.getTeamProject(teamId, projectId),+ queryFn: () => getTeamProject(teamId, projectId),});}@@ -88,7 +108,7 @@ export function useTeamProjectMembersQuery(return useInfiniteQuery({queryKey: qk.teamProjectMembers(teamId, projectId, { ...filters, pageSize }),queryFn: ({ pageParam }) =>- api.listTeamProjectMembers(teamId, projectId, { ...filters, page: pageParam, pageSize }),+ listTeamProjectMembers(teamId, projectId, { ...filters, page: pageParam, pageSize }),initialPageParam: 1,getNextPageParam: nextPageParam,});@@ -102,7 +122,7 @@ export function useUpdateTeamMcp(teamId: number) {mutationFn: (patch: {enabled?: boolean;projects?: { projectId: number; enabled: boolean }[];- }) => api.updateTeamMcp(teamId, patch),+ }) => updateTeamMcp(teamId, patch),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.teams });void qc.invalidateQueries({ queryKey: qk.anyTeamProjects(teamId) });@@ -117,7 +137,7 @@ export function useUpdateTeamMcp(teamId: number) {export function useCreateTeam() {const qc = useQueryClient();return useMutation({- mutationFn: (input: { name: string }) => api.createTeam(input),+ mutationFn: (input: { name: string }) => createTeam(input),onSuccess: (team) => {// Put the team in the cached list right away so the switcher shows it before// the refetch lands; it has no projects yet, so nothing else has to load.@@ -131,7 +151,7 @@ export function useRenameTeam() {const qc = useQueryClient();return useMutation({mutationFn: (input: { teamId: number; name: string }) =>- api.renameTeam(input.teamId, { name: input.name }),+ renameTeam(input.teamId, { name: input.name }),onSuccess: (team) => {void qc.invalidateQueries({ queryKey: qk.teams });void qc.invalidateQueries({ queryKey: qk.team(team.id) });@@ -148,7 +168,7 @@ export function useSetTeamMemberRole(teamId: number) {const qc = useQueryClient();return useMutation({mutationFn: (input: { userId: string; role: TeamRole }) =>- api.setTeamMemberRole(teamId, input.userId, input.role),+ setTeamMemberRole(teamId, input.userId, input.role),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.team(teamId) });void qc.invalidateQueries({ queryKey: qk.teams });@@ -163,7 +183,7 @@ export function useSetTeamMemberRole(teamId: number) {export function useRemoveTeamMember(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (userId: string) => api.removeTeamMember(teamId, userId),+ mutationFn: (userId: string) => removeTeamMember(teamId, userId),onSuccess: () => {void qc.invalidateQueries({ queryKey: qk.team(teamId) });void qc.invalidateQueries({ queryKey: qk.teams });@@ -177,7 +197,7 @@ export function useRemoveTeamMember(teamId: number) {export function useLeaveTeam() {const qc = useQueryClient();return useMutation({- mutationFn: (teamId: number) => api.leaveTeam(teamId),+ mutationFn: (teamId: number) => leaveTeam(teamId),onSuccess: (_result, teamId) => {qc.setQueryData<Team[]>(qk.teams, (prev) => prev?.filter((t) => t.id !== teamId));void qc.invalidateQueries({ queryKey: qk.teams });@@ -192,7 +212,7 @@ export function useLeaveTeam() {export function useTeamInvitesQuery(teamId: number, enabled = true) {return useQuery({queryKey: qk.teamInvites(teamId),- queryFn: () => api.listTeamInvites(teamId),+ queryFn: () => listTeamInvites(teamId),enabled,});}@@ -202,8 +222,7 @@ export function useTeamInvitesQuery(teamId: number, enabled = true) {export function useCreateTeamInvite(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (input: { email: string; role: InviteTeamRole }) =>- api.createTeamInvite(teamId, input),+ mutationFn: (input: { email: string; role: InviteTeamRole }) => createTeamInvite(teamId, input),onSuccess: () => qc.invalidateQueries({ queryKey: qk.teamInvites(teamId) }),meta: { suppressErrorToast: true },});@@ -212,7 +231,7 @@ export function useCreateTeamInvite(teamId: number) {export function useDeleteTeamInvite(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (inviteId: number) => api.deleteTeamInvite(teamId, inviteId),+ mutationFn: (inviteId: number) => deleteTeamInvite(teamId, inviteId),onSuccess: () => qc.invalidateQueries({ queryKey: qk.teamInvites(teamId) }),});}@@ -223,7 +242,7 @@ export function useDeleteTeamInvite(teamId: number) {export function useNotificationSettingsQuery(teamId: number | null) {return useQuery({queryKey: qk.notificationSettings(teamId ?? 0),- queryFn: () => api.getNotificationSettings(teamId!),+ queryFn: () => getNotificationSettings(teamId!),enabled: teamId != null,});}@@ -231,7 +250,7 @@ export function useNotificationSettingsQuery(teamId: number | null) {export function useUpdateNotificationSettings(teamId: number) {const qc = useQueryClient();return useMutation({- mutationFn: (input: NotificationSettingsPatch) => api.setNotificationSettings(teamId, input),+ mutationFn: (input: NotificationSettingsPatch) => setNotificationSettings(teamId, input),onSuccess: (data) => qc.setQueryData(qk.notificationSettings(teamId), data),});}diff --git a/apps/web/src/services/telegram.service.ts b/apps/web/src/services/telegram.service.tsindex 86edf51f..f2f30ef5 100644--- a/apps/web/src/services/telegram.service.ts+++ b/apps/web/src/services/telegram.service.ts@@ -2,7 +2,11 @@import { useTranslations } from 'next-intl';import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api } from '@/lib/api';+import {+ getTelegramAccount,+ startTelegramLink,+ unlinkTelegramAccount,+} from '@/lib/api/endpoints/telegram';import { qk } from '@/services/queryKeys';// The session user's Telegram account link. Shared rather than feature-local: the@@ -14,7 +18,7 @@ import { qk } from '@/services/queryKeys';export function useTelegramAccountQuery(pollMs?: number) {return useQuery({queryKey: qk.telegramAccount,- queryFn: () => api.getTelegramAccount(),+ queryFn: () => getTelegramAccount(),refetchInterval: pollMs ?? false,});}@@ -22,13 +26,13 @@ export function useTelegramAccountQuery(pollMs?: number) {// Starts a connection: the API mints a one-time code and returns the bot deep link// that completes it when opened.export function useStartTelegramLink() {- return useMutation({ mutationFn: () => api.startTelegramLink() });+ return useMutation({ mutationFn: () => startTelegramLink() });}export function useDisconnectTelegram() {const qc = useQueryClient();return useMutation({- mutationFn: () => api.unlinkTelegramAccount(),+ mutationFn: () => unlinkTelegramAccount(),onSuccess: () => qc.invalidateQueries({ queryKey: qk.telegramAccount }),});}diff --git a/apps/web/src/services/updates.service.ts b/apps/web/src/services/updates.service.tsindex 059151f4..4aae2df8 100644--- a/apps/web/src/services/updates.service.ts+++ b/apps/web/src/services/updates.service.ts@@ -1,7 +1,7 @@'use client';import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api } from '@/lib/api';+import { getAppVersion, getUpdateStatus, checkForUpdates } from '@/lib/api/endpoints/updates';import { useSession } from '@/lib/auth-client';import { qk } from '@/services/queryKeys';@@ -13,7 +13,7 @@ export function useAppVersionQuery() {const { data: session } = useSession();return useQuery({queryKey: qk.appVersion,- queryFn: () => api.getAppVersion(),+ queryFn: () => getAppVersion(),// The route needs a session; the login and invite screens have none.enabled: Boolean(session),// Fixed for the life of the process: it only changes when the instance restarts@@ -25,7 +25,7 @@ export function useAppVersionQuery() {export function useUpdateStatusQuery(enabled: boolean) {return useQuery({queryKey: qk.updateStatus,- queryFn: () => api.getUpdateStatus(),+ queryFn: () => getUpdateStatus(),enabled,// Every call reads the upstream feed, so this is the only thing keeping a// session from doing it on each navigation. "Check now" refetches regardless.@@ -36,7 +36,7 @@ export function useUpdateStatusQuery(enabled: boolean) {export function useCheckForUpdates() {const qc = useQueryClient();return useMutation({- mutationFn: () => api.checkForUpdates(),+ mutationFn: () => checkForUpdates(),onSuccess: (data) => qc.setQueryData(qk.updateStatus, data),});}diff --git a/apps/web/src/services/views.service.ts b/apps/web/src/services/views.service.tsindex 770cd0ad..0c6c1d6b 100644--- a/apps/web/src/services/views.service.ts+++ b/apps/web/src/services/views.service.ts@@ -1,5 +1,13 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api, type View } from '@/lib/api';+import {+ type View,+ listViews,+ createView,+ updateView,+ deleteView,+ setViewFavorite,+ reorderViews,+} from '@/lib/api/endpoints/views';import { EMPTY_FILTER_SET, type FilterSet } from '@/utils/filters';import { normalizeSavedDisplay } from '@/utils/viewSettings';import { useOptimisticReorder } from '@/services/optimisticReorder';@@ -20,7 +28,7 @@ export function normalizeView(v: View): View {export function useViewsQuery(projectKey: string | null) {return useQuery({queryKey: qk.views(projectKey ?? ''),- queryFn: () => api.listViews(projectKey!),+ queryFn: () => listViews(projectKey!),enabled: projectKey != null,// The caller's favorites are pinned to the front of the tab row; the rest keep// their stored order.@@ -32,8 +40,8 @@ export function useViewsQuery(projectKey: string | null) {export function useCreateView(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ input }: { input: Parameters<typeof api.createView>[1] }) =>- api.createView(projectKey!, input),+ mutationFn: ({ input }: { input: Parameters<typeof createView>[1] }) =>+ createView(projectKey!, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.views(projectKey) });},@@ -43,8 +51,8 @@ export function useCreateView(projectKey: string | null) {export function useUpdateView(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, input }: { id: number; input: Parameters<typeof api.updateView>[1] }) =>- api.updateView(id, input),+ mutationFn: ({ id, input }: { id: number; input: Parameters<typeof updateView>[1] }) =>+ updateView(id, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.views(projectKey) });},@@ -54,7 +62,7 @@ export function useUpdateView(projectKey: string | null) {export function useDeleteView(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteView(id),+ mutationFn: (id: number) => deleteView(id),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.views(projectKey) });},@@ -65,7 +73,7 @@ export function useSetViewFavorite(projectKey: string | null) {const qc = useQueryClient();return useMutation({mutationFn: ({ id, favorite }: { id: number; favorite: boolean }) =>- api.setViewFavorite(id, favorite),+ setViewFavorite(id, favorite),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.views(projectKey) });},@@ -74,6 +82,6 @@ export function useSetViewFavorite(projectKey: string | null) {export function useReorderViews(projectKey: string | null) {return useOptimisticReorder<View>(projectKey ? qk.views(projectKey) : null, (orderedIds) =>- api.reorderViews(projectKey!, orderedIds),+ reorderViews(projectKey!, orderedIds),);}diff --git a/apps/web/src/services/webhooks.service.ts b/apps/web/src/services/webhooks.service.tsindex 17fe036f..6cf1eadf 100644--- a/apps/web/src/services/webhooks.service.ts+++ b/apps/web/src/services/webhooks.service.ts@@ -1,11 +1,17 @@import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';-import { api } from '@/lib/api';+import {+ listWebhooks,+ listWebhookDeliveries,+ createWebhook,+ updateWebhook,+ deleteWebhook,+} from '@/lib/api/endpoints/webhooks';import { qk } from '@/services/queryKeys';export function useWebhooksQuery(projectKey: string | null) {return useQuery({queryKey: qk.webhooks(projectKey ?? ''),- queryFn: () => api.listWebhooks(projectKey!),+ queryFn: () => listWebhooks(projectKey!),enabled: projectKey != null,});}@@ -15,7 +21,7 @@ export function useWebhooksQuery(projectKey: string | null) {export function useWebhookDeliveries(webhookId: number | null) {return useInfiniteQuery({queryKey: qk.webhookDeliveries(webhookId ?? 0),- queryFn: ({ pageParam }) => api.listWebhookDeliveries(webhookId!, pageParam),+ queryFn: ({ pageParam }) => listWebhookDeliveries(webhookId!, pageParam),initialPageParam: undefined as number | undefined,getNextPageParam: (last) => last.nextCursor ?? undefined,enabled: webhookId != null,@@ -25,8 +31,8 @@ export function useWebhookDeliveries(webhookId: number | null) {export function useCreateWebhook(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ input }: { input: Parameters<typeof api.createWebhook>[1] }) =>- api.createWebhook(projectKey!, input),+ mutationFn: ({ input }: { input: Parameters<typeof createWebhook>[1] }) =>+ createWebhook(projectKey!, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.webhooks(projectKey) });},@@ -36,8 +42,8 @@ export function useCreateWebhook(projectKey: string | null) {export function useUpdateWebhook(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: ({ id, input }: { id: number; input: Parameters<typeof api.updateWebhook>[1] }) =>- api.updateWebhook(id, input),+ mutationFn: ({ id, input }: { id: number; input: Parameters<typeof updateWebhook>[1] }) =>+ updateWebhook(id, input),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.webhooks(projectKey) });},@@ -47,7 +53,7 @@ export function useUpdateWebhook(projectKey: string | null) {export function useDeleteWebhook(projectKey: string | null) {const qc = useQueryClient();return useMutation({- mutationFn: (id: number) => api.deleteWebhook(id),+ mutationFn: (id: number) => deleteWebhook(id),onSuccess: () => {if (projectKey) void qc.invalidateQueries({ queryKey: qk.webhooks(projectKey) });},diff --git a/apps/web/src/utils/actions.ts b/apps/web/src/utils/actions.tsindex f2f38f01..0fb3f5bf 100644--- a/apps/web/src/utils/actions.ts+++ b/apps/web/src/utils/actions.ts@@ -4,7 +4,8 @@// the field unchanged. Applying an effect is a single issue update with the// effect object as the patch (see api.updateIssue / useUpdateIssue).-import type { ActionEffect, ProjectDetail } from '@/lib/api';+import type { ActionEffect } from '@/lib/api/endpoints/actions';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';import type { EffectText } from '@/hooks/useEffectText';import { formatDate } from '@/utils/dates';diff --git a/apps/web/src/utils/calendarFields.ts b/apps/web/src/utils/calendarFields.tsindex b553dca7..85f508af 100644--- a/apps/web/src/utils/calendarFields.ts+++ b/apps/web/src/utils/calendarFields.ts@@ -1,4 +1,5 @@-import type { CustomField, Issue, IssueFieldValueInput } from '@/lib/api';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { Issue, IssueFieldValueInput } from '@/lib/api/endpoints/issues';import { dayKey, fromZonedParts, toZonedParts } from '@/utils/dates';import {customFieldId,diff --git a/apps/web/src/utils/cycleMeta.ts b/apps/web/src/utils/cycleMeta.tsindex 73e4cb63..30e85ddb 100644--- a/apps/web/src/utils/cycleMeta.ts+++ b/apps/web/src/utils/cycleMeta.ts@@ -1,4 +1,4 @@-import type { CycleStatus } from '@/lib/api';+import type { CycleStatus } from '@/lib/api/endpoints/cycles';// Display metadata for the cycle status, which the API derives from the dates.// Colors are raw hex so they can drive both a dot and a text color, like thediff --git a/apps/web/src/utils/dates.ts b/apps/web/src/utils/dates.tsindex c0421899..0bd9c2e2 100644--- a/apps/web/src/utils/dates.ts+++ b/apps/web/src/utils/dates.ts@@ -1,4 +1,4 @@-import type { StateType } from '@/lib/api';+import type { StateType } from '@/lib/api/endpoints/columns';import { DEFAULT_LOCALE } from '@/i18n/locales';// Date helpers shared by the project views. Kept separate from project grouping sodiff --git a/apps/web/src/utils/fieldOptions.ts b/apps/web/src/utils/fieldOptions.tsindex 9752ac49..d604a199 100644--- a/apps/web/src/utils/fieldOptions.ts+++ b/apps/web/src/utils/fieldOptions.ts@@ -3,7 +3,9 @@// keeping its own copy. Adding a priority/state is a single edit in this file// (plus its icon in the two icon renderers and its message).-import type { CycleStatus, InitiativeStatus, StateType } from '@/lib/api';+import type { StateType } from '@/lib/api/endpoints/columns';+import type { CycleStatus } from '@/lib/api/endpoints/cycles';+import type { InitiativeStatus } from '@/lib/api/endpoints/initiatives';export type Priority = 'urgent' | 'high' | 'medium' | 'low';diff --git a/apps/web/src/utils/filters.ts b/apps/web/src/utils/filters.tsindex b7d8c49d..3b114ac8 100644--- a/apps/web/src/utils/filters.ts+++ b/apps/web/src/utils/filters.ts@@ -3,7 +3,9 @@// set is applied to every layout (Project, Table, Timeline, Calendar) before the// issues are handed to the view. The server never inspects this shape.-import type { ProjectDetail, StateType, Issue } from '@/lib/api';+import type { StateType } from '@/lib/api/endpoints/columns';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { dayKey } from '@/utils/dates';// The built-in fields a condition can target. Custom fields are targeted withdiff --git a/apps/web/src/utils/initiativeMeta.ts b/apps/web/src/utils/initiativeMeta.tsindex f4a610d0..ed88d356 100644--- a/apps/web/src/utils/initiativeMeta.ts+++ b/apps/web/src/utils/initiativeMeta.ts@@ -1,4 +1,4 @@-import type { InitiativeStatus, InitiativeHealth } from '@/lib/api';+import type { InitiativeStatus, InitiativeHealth } from '@/lib/api/endpoints/initiatives';// Display metadata for the initiative status lifecycle and the derived health// signal. Colors are raw hex so they can drive both a dot and a text color. Thediff --git a/apps/web/src/utils/integrationLabels.ts b/apps/web/src/utils/integrationLabels.tsindex d7e2a038..8ede5444 100644--- a/apps/web/src/utils/integrationLabels.ts+++ b/apps/web/src/utils/integrationLabels.ts@@ -1,4 +1,4 @@-import type { IntegrationMeta } from '@/lib/api';+import type { IntegrationMeta } from '@/lib/api/endpoints/integrations';// The display name of an integration, falling back to its key when the catalog does// not know it (an integration the API dropped but a stored credential still names).diff --git a/apps/web/src/utils/issueLinks.ts b/apps/web/src/utils/issueLinks.tsindex b181b16b..ce810b0a 100644--- a/apps/web/src/utils/issueLinks.ts+++ b/apps/web/src/utils/issueLinks.ts@@ -1,5 +1,10 @@import { Ban, CircleSlash, Copy, Link2, type LucideIcon } from 'lucide-react';-import type { BoardIssue, IssueLink, IssueLinkInputKind, IssueLinkKind } from '@/lib/api';+import type {+ BoardIssue,+ IssueLink,+ IssueLinkInputKind,+ IssueLinkKind,+} from '@/lib/api/endpoints/issues';// A relation reads differently from each of its two ends, and both the panel and// the activity feed name it from the end being looked at. That reading is thediff --git a/apps/web/src/utils/labels.ts b/apps/web/src/utils/labels.tsindex 2f29138e..66b71358 100644--- a/apps/web/src/utils/labels.ts+++ b/apps/web/src/utils/labels.ts@@ -1,4 +1,4 @@-import type { Label, LabelGroup } from '@/lib/api';+import type { Label, LabelGroup } from '@/lib/api/endpoints/labels';// A group of labels for the pickers: either a real LabelGroup with its labels,// or the ungrouped bucket (group === null). Empty groups are omitted so a groupdiff --git a/apps/web/src/utils/memberFields.ts b/apps/web/src/utils/memberFields.tsindex a599aa6c..4fdf6018 100644--- a/apps/web/src/utils/memberFields.ts+++ b/apps/web/src/utils/memberFields.ts@@ -1,4 +1,6 @@-import type { Assignee, CustomField, Issue, MemberScope } from '@/lib/api';+import type { CustomField, MemberScope } from '@/lib/api/endpoints/customFields';+import type { Assignee } from '@/lib/api/endpoints/projects';+import type { Issue } from '@/lib/api/endpoints/issues';import { customFieldId, isCustomFieldKey, type GroupField } from '@/utils/viewSettings';// The custom fields that hold one person or agent. They are offered wherever thediff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.tsindex b687ab23..7006a3d2 100644--- a/apps/web/src/utils/paths.ts+++ b/apps/web/src/utils/paths.ts@@ -1,7 +1,7 @@// Path builders for the planner routes. The project, the open view and the open// settings section live in the URL, so these are the single source of truth —// see the app/project/[projectKey] route tree.-import type { StartPage } from '@/lib/api';+import type { StartPage } from '@/lib/api/endpoints/userPreferences';export const projectPath = (key: string) => `/project/${encodeURIComponent(key)}`;diff --git a/apps/web/src/utils/permissions.ts b/apps/web/src/utils/permissions.tsindex 680cdca6..a287b438 100644--- a/apps/web/src/utils/permissions.ts+++ b/apps/web/src/utils/permissions.ts@@ -3,7 +3,7 @@ import type {PermissionCatalog,PermissionResource,Permissions,-} from '@/lib/api';+} from '@/lib/api/endpoints/roles';// Column display order for the permission matrix. An action not listed (one added// on the API) sorts to the end, keeping its catalog order.diff --git a/apps/web/src/utils/project.ts b/apps/web/src/utils/project.tsindex 10b665e9..69adaf28 100644--- a/apps/web/src/utils/project.ts+++ b/apps/web/src/utils/project.ts@@ -2,21 +2,14 @@// Table, Timeline, Calendar) so they bucket and order issues the same way. Date// and avatar helpers live in lib/dates and lib/avatar.-import type {- Assignee,- ProjectDetail,- Column,- CustomField,- CycleOption,- InitiativeOption,- Label,- StateType,- InitiativeRef,- Issue,- IssuePatch,- IssueType,- NewIssueInput,-} from '@/lib/api';+import type { Column, StateType } from '@/lib/api/endpoints/columns';+import type { CustomField } from '@/lib/api/endpoints/customFields';+import type { IssueType } from '@/lib/api/endpoints/issueTypes';+import type { Label } from '@/lib/api/endpoints/labels';+import type { Assignee, ProjectDetail } from '@/lib/api/endpoints/projects';+import type { InitiativeRef, Issue, IssuePatch, NewIssueInput } from '@/lib/api/endpoints/issues';+import type { CycleOption } from '@/lib/api/endpoints/cycles';+import type { InitiativeOption } from '@/lib/api/endpoints/initiatives';import { CYCLE_STATUS_META } from '@/utils/cycleMeta';import { PRIORITY_ORDER, PRIORITY_RANK } from '@/utils/fieldOptions';import {diff --git a/apps/web/src/utils/projectFeatures.ts b/apps/web/src/utils/projectFeatures.tsindex b2fa7260..8f03e7e5 100644--- a/apps/web/src/utils/projectFeatures.ts+++ b/apps/web/src/utils/projectFeatures.ts@@ -1,4 +1,5 @@-import type { Project, ProjectFeatures } from '@/lib/api';+import type { ProjectFeatures } from '@/lib/api/endpoints/settings';+import type { Project } from '@/lib/api/endpoints/projects';// The optional sections plus the estimate kinds and time logging: everything the// rest of the app checks before showing a field. The sections are the Features page;diff --git a/apps/web/src/utils/publicProject.ts b/apps/web/src/utils/publicProject.tsindex d37e1ce5..4e4dff0d 100644--- a/apps/web/src/utils/publicProject.ts+++ b/apps/web/src/utils/publicProject.ts@@ -1,4 +1,7 @@-import type { BoardIssue, Permissions, ProjectDetail, PublicScaffold } from '@/lib/api';+import type { Permissions } from '@/lib/api/endpoints/roles';+import type { ProjectDetail } from '@/lib/api/endpoints/projects';+import type { BoardIssue } from '@/lib/api/endpoints/issues';+import type { PublicScaffold } from '@/lib/api/endpoints/share';// Assembles a ProjectDetail from a public share bundle so the read-only pages can// reuse the same components as the authenticated app (the board layouts, the issuediff --git a/apps/web/src/utils/settingsSections.ts b/apps/web/src/utils/settingsSections.tsindex 7e110400..26049484 100644--- a/apps/web/src/utils/settingsSections.ts+++ b/apps/web/src/utils/settingsSections.ts@@ -13,7 +13,7 @@ import {Webhook,Zap,} from 'lucide-react';-import type { PermissionResource } from '@/lib/api';+import type { PermissionResource } from '@/lib/api/endpoints/roles';// The sidebar group a section is listed under: the project-level general settings,// workflow configuration, automation/integrations, or the AI section. 'ai-team' anddiff --git a/apps/web/src/utils/subtasks.ts b/apps/web/src/utils/subtasks.tsindex b2b9d88d..9b9b75a9 100644--- a/apps/web/src/utils/subtasks.ts+++ b/apps/web/src/utils/subtasks.ts@@ -1,4 +1,5 @@-import type { BoardIssue, Column, SubtaskDisposition } from '@/lib/api';+import type { Column } from '@/lib/api/endpoints/columns';+import type { BoardIssue, SubtaskDisposition } from '@/lib/api/endpoints/issues';// A subtask choice the API can act on: 'reassign' also needs the issue to move to.// The delete and archive confirmations stay disabled until it is.diff --git a/apps/web/src/utils/uploadLimits.ts b/apps/web/src/utils/uploadLimits.tsindex ba7e57fb..97c219c7 100644--- a/apps/web/src/utils/uploadLimits.ts+++ b/apps/web/src/utils/uploadLimits.ts@@ -1,4 +1,4 @@-import type { StorageSettings } from '@/lib/api';+import type { StorageSettings } from '@/lib/api/endpoints/settings';// Client-side mirror of the api's upload checks (apps/api/src/attachments/routes.ts).// The api enforces the real limits; these helpers state them in the UI and reject an